a3js 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a3js.cjs.js +81 -81
- package/dist/a3js.cjs.js.map +1 -1
- package/dist/a3js.es.js +4619 -4402
- package/dist/a3js.es.js.map +1 -1
- package/package.json +1 -1
package/dist/a3js.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Rn=Object.create;var Mt=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var Ln=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var bn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of An(e))!Sn.call(n,r)&&r!==t&&Mt(n,r,{get:()=>e[r],enumerable:!(i=_n(e,r))||i.enumerable});return n};var On=(n,e,t)=>(t=n!=null?Rn(Ln(n)):{},bn(e||!n||!n.__esModule?Mt(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("three"),Yt=require("fflate");function xn(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const ge=xn(R);function Xt(n){return typeof n=="string"}function xt(n){return n.isMesh===!0}function In(n){return n.type==="RoundedBoxGeometry"}function Nn(n){return n.type==="BoxGeometry"}function kn(n){return n.type==="SphereGeometry"}function wn(n){return n.type==="IcosahedronGeometry"}function Cn(n){return n.type==="CylinderGeometry"}function Pn(n){return n.type==="CapsuleGeometry"}function Mn(n){return n.isBone===!0}function Dn(n){return n.isPerspectiveCamera===!0}class Fn{object;option;constructor(e,t){this.object=e,this.option=t}}let Ve;class tt{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!tt.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),tt.RAPIER=e,Ve=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOption(e)&&(t=e.timestep);const i=new Ve.World(e.gravity);return new Un(i,t)}isRapierWorldOption(e){return"timestep"in e}}class Un{world;timestep;constructor(e,t){this.world=e,this.timestep=t,this.world.integrationParameters.dt=this.timestep}add(e){Dt(e)&&e.addOneself(this)}remove(e){Dt(e)&&e.removeOneself(this)}update(e){const t=Math.ceil(e/this.timestep);for(let i=0;i<t;i++)this.world.step()}}class qt extends Fn{}function Dt(n){return"addOneself"in n&&"removeOneself"in n}class Bn extends qt{bodyDesc;body;colliderDescs=[];colliders=[];constructor(e,t){switch(super(e,t),t.rigidBody){case"dynamic":this.bodyDesc=Ve.RigidBodyDesc.dynamic();break;case"kinematic":this.bodyDesc=Ve.RigidBodyDesc.kinematicPositionBased();break;case"fixed":this.bodyDesc=Ve.RigidBodyDesc.fixed();break}this.bodyDesc.setTranslation(e.location.x,e.location.y,e.location.z),this.bodyDesc.setRotation({x:e.quat.x,y:e.quat.y,z:e.quat.z,w:e.quat.w});const i=[];this.object.object.traverse(a=>{if(xt(a)){const o=jn(a.geometry);if(o)this.colliderDescs.push(o.colliderDesc),o.colliderDesc.setRestitution(t.restitution).setFriction(t.friction),i.push(o.volume);else{let l,c;switch(t.meshCollider){case"tri_mesh":l=Gn(a),c=Ft(a.geometry);break;case"convex_hull":l=zn(a),c=Ft(a.geometry);break}l&&(this.colliderDescs.push(l),i.push(c))}}});let r=i.reduce((a,o)=>a+o,0);for(let a=0;a<this.colliderDescs.length;a++)this.colliderDescs[a].setRestitution(t.restitution),this.colliderDescs[a].setFriction(t.friction),this.colliderDescs[a].setMass(t.mass*(i[a]/r))}synchronize(e){if(this.body){const t=this.body.translation();e.location.set(t.x,t.y,t.z),e.object.position.set(t.x,t.y,t.z);const i=this.body.rotation();e.quat.set(i.x,i.y,i.z,i.w),e.object.quaternion.set(i.x,i.y,i.z,i.w)}}addOneself(e){this.body=e.world.createRigidBody(this.bodyDesc),this.colliderDescs.forEach(t=>{this.colliders.push(e.world.createCollider(t,this.body))})}removeOneself(e){this.body&&e.world.removeRigidBody(this.body),this.colliders.forEach(t=>{e.world.removeCollider(t,!1)})}setLocationNow(e){this.body&&this.body.setTranslation(e,!0)}setQuatNow(e){this.body&&this.body.setRotation(e,!0)}setScaleNow(e){}}function Gn(n){let e=null;if(xt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;let a=i.index?i.index.array:null;if(a)a instanceof Uint32Array||(a=new Uint32Array(a));else{const o=i.attributes.position.count;a=new Uint32Array(o);for(let l=0;l<o;l++)a[l]=l}r instanceof Float32Array&&(e=Ve.ColliderDesc.trimesh(r,a))}return e}function zn(n){let e=null;if(xt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;r instanceof Float32Array&&(e=Ve.ColliderDesc.convexHull(r))}return e}function Ft(n){const e=n.attributes.position;if(!e)throw new Error("position attribute not found");const t=n.index,i=e.array;let r=0;const a=new ge.Vector3,o=new ge.Vector3,l=new ge.Vector3;if(t){const c=t.array;for(let s=0;s<c.length;s+=3){const h=c[s]*3,f=c[s+1]*3,g=c[s+2]*3;a.set(i[h],i[h+1],i[h+2]),o.set(i[f],i[f+1],i[f+2]),l.set(i[g],i[g+1],i[g+2]),r+=a.dot(o.clone().cross(l))}}else for(let c=0;c<i.length;c+=9)a.set(i[c],i[c+1],i[c+2]),o.set(i[c+3],i[c+4],i[c+5]),l.set(i[c+6],i[c+7],i[c+8]),r+=a.dot(o.clone().cross(l));return Math.abs(r)/6}function jn(n){if(In(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,a=.1;return{colliderDesc:Ve.ColliderDesc.roundCuboid(t-a,i-a,r-a,a),volume:2*t*2*i*2*r}}else if(Nn(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Ve.ColliderDesc.cuboid(t,i,r),volume:2*t*2*i*2*r}}else if(kn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(wn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Cn(n)){const e=n.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.cylinder(i/2,t),volume:Math.PI*t*t*i}}else if(Pn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.capsule(i/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*i}}return null}const St=new tt;async function Vn(){await St.init()}class Qt{scene;objects;physicsWorld=null;physicsDt=1/60;constructor(){this.scene=new ge.Scene,this.objects=[],St.isInitialized&&(this.physicsWorld=St.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt}))}add(e){if(this.scene.add(e.object),this.objects.push(e),e.scene=this,e.controlMode==="physics")if(this.physicsWorld){if(!e.physics){const t=e.getPhysicsOption();e.initPhysics(t)}e.physics&&this.physicsWorld.add(e.physics)}else console.log("物理エンジンを初期化してない状態で、物理エンジンを必要とするObjectA3が追加されました。")}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,e.controlMode==="physics"&&this.physicsWorld&&e.physics&&this.physicsWorld.remove(e.physics)}update(e){this.physicsWorld&&this.physicsWorld.update(e);for(const t of this.objects)t.update(e)}}class ke{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,i,r){typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}clone(){return new ke(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t,this._w/=t):console.warn("Quat.normalize."),this}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}set(e,t,i,r){return typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}mul(e,t,i,r){const a=new ke(this),o=new ke;return typeof e=="number"?o.set(e,t,i,r):o.set(e),this._x=a.w*o.x+a.x*o.w+a.y*o.z-a.z*o.y,this._y=a.w*o.y-a.x*o.z+a.y*o.w+a.z*o.x,this._z=a.w*o.z+a.x*o.y-a.y*o.x+a.z*o.w,this._w=a.w*o.w-a.x*o.x-a.y*o.y-a.z*o.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w}slerp(e,t,i){if(i<0||i>1){console.warn("Quat.slerp(): t must be in [0,1]");return}const r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(r<.9995){const a=Math.acos(r),o=Math.sin((1-i)*a)/Math.sin(a),l=Math.sin(i*a)/Math.sin(a);this._x=o*e.x+l*t.x,this._y=o*e.y+l*t.y,this._z=o*e.z+l*t.z,this._w=o*e.w+l*t.w}else{this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w;const a=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);a<1e-4?(console.warn("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/a,this._y*=1/a,this._z*=1/a,this._w*=1/a)}}}function ft(n,e,t){t.normalize();const i=e.clone().sub(n).normalize(),r=new Se().cross(i,t).normalize(),a=new Se().cross(r,i),o=r.x,l=a.x,c=-i.x,s=r.y,h=a.y,f=-i.y,g=r.z,p=a.z,T=-i.z,m=o+h+T;if(m>0){const u=Math.sqrt(m+1)*2;return new ke((p-f)/u,(c-g)/u,(s-l)/u,.25*u)}else if(o>h&&o>T){const u=Math.sqrt(1+o-h-T)*2;return new ke(.25*u,(l+s)/u,(c+g)/u,(p-f)/u)}else if(h>T){const u=Math.sqrt(1+h-o-T)*2;return new ke((l+s)/u,.25*u,(f+p)/u,(c-g)/u)}else{const u=Math.sqrt(1+T-o-h)*2;return new ke((c+g)/u,(f+p)/u,.25*u,(s-l)/u)}}function Zt(n,e="XYZ"){const t=new ke(0,0,0,1);for(let i=0;i<3;i++)switch(e.charAt(i)){case"X":t.mul(new ke(Math.sin(n.x),0,0,Math.cos(n.x)));break;case"Y":t.mul(new ke(0,Math.sin(n.y),0,Math.cos(n.y)));break;case"Z":t.mul(new ke(0,0,Math.sin(n.z),Math.cos(n.z)));break}return t}class Se{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,i){typeof e=="number"?(this._x=e,this._y=t,this._z=i):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}clone(){return new Se(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t):console.warn("Vec3.normalize."),this}negate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}set(e,t,i){return typeof e=="number"?(this._x=e,this._y=t,this._z=i):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e,t,i){return typeof e=="number"?(this._x+=e,this._y+=t,this._z+=i):(this._x+=e.x,this._y+=e.y,this._z+=e.z),this}sub(e,t,i){return typeof e=="number"?(this._x-=e,this._y-=t,this._z-=i):(this._x-=e.x,this._y-=e.y,this._z-=e.z),this}scale(e){return this._x*=e,this._y*=e,this._z*=e,this}cross(e,t){return this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this}apply(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e);const o=new ke(this._x,this._y,this._z,0),l=new ke(a).conjugate();return a.mul(o).mul(l),this._x=a.x,this._y=a.y,this._z=a.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z}}class ze{static defaultRotationOrder="XYZ";static defaultUpVector=new Se(0,1,0);rotationOrder=null;upVector=null;_loc=new Se(0,0,0);_quat=new ke(0,0,0,1);_scale=new Se(1,1,1);object;controlMode="manual";scene=null;physics=null;balloon=null;interpolation=null;parent=null;children=[];constructor(e){this.object=this.initObject(e)}setControlMode(e){this.controlMode=e,e==="interpolated"&&!this.interpolation&&(this.interpolation=new Wn(this)),e==="physics"&&!this.physics&&this.initPhysics(this.getPhysicsOption())}update(e){switch(this.controlMode){case"manual":break;case"interpolated":this.interpolation&&this.interpolation.interpolate(this,e);break;case"physics":this.physics&&this.physics.synchronize(this);break;case"user":console.log('"user"モードを使う場合は自分でupdateメソッドをオーバーライドして実装して下さい。');break}this.children.forEach(t=>{t.update(e)})}getPhysicsOption(){return{rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5}}initPhysics(e){this.physics=new Bn(this,e),this.controlMode="physics"}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object.add(e.object)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=null,this.object.remove(e.object)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new Hn(e)}get location(){return this._loc}setLocation(e,t,i){const r=new Se;switch(typeof e=="number"?r.set(e,t,i):r.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setLocation(this,r);break;case"physics":break;default:this.location.set(r),this.object.position.set(r.x,r.y,r.z);break}}setLocationNow(e,t,i){const r=new Se;switch(typeof e=="number"?r.set(e,t,i):r.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setLocationNow(this,r);break;case"physics":this.physics&&this.physics.setLocationNow(r);break}this.location.set(r),this.object.position.set(r.x,r.y,r.z)}get quat(){return this._quat}setQuat(e,t,i,r){const a=new ke;switch(typeof e=="number"?a.set(e,t,i,r):a.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setQuat(this,a);break;case"physics":break;default:this.quat.set(a),this.object.quaternion.set(a.x,a.y,a.z,a.w);break}}setQuatNow(e,t,i,r){const a=new ke;switch(typeof e=="number"?a.set(e,t,i,r):a.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setQuatNow(this,a);break;case"physics":this.physics&&this.physics.setQuatNow(a);break}this.quat.set(a),this.object.quaternion.set(a.x,a.y,a.z,a.w)}get scale(){return this._scale}setScale(e,t,i){const r=new Se;switch(typeof e=="number"?r.set(e,t,i):r.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setScale(this,r);break;case"physics":break;default:this.scale.set(r),this.object.scale.set(r.x,r.y,r.z);break}}setScaleNow(e,t,i){const r=new Se;switch(typeof e=="number"?r.set(e,t,i):r.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setScaleNow(this,r);break;case"physics":this.physics&&this.physics.setScaleNow(r);break}this.scale.set(r),this.object.scale.set(r.x,r.y,r.z)}setRotation(e,t,i){const r=new Se;typeof e=="number"?r.set(e,t,i):r.set(e),r.scale(Math.PI/360);const a=this.rotationOrder?this.rotationOrder:ze.defaultRotationOrder,o=Zt(r,a);this.setQuat(o)}setRotationNow(e,t,i){const r=new Se;typeof e=="number"?r.set(e,t,i):r.set(e);const a=this.rotationOrder?this.rotationOrder:ze.defaultRotationOrder,o=new ke(0,0,0,1);for(let l=0;l<3;l++)switch(a.charAt(l)){case"X":o.mul(new ke(Math.sin(r.x),0,0,Math.cos(r.x)));break;case"Y":o.mul(new ke(0,Math.sin(r.y),0,Math.cos(r.y)));break;case"Z":o.mul(new ke(0,0,Math.sin(r.z),Math.cos(r.z)));break}this.setQuatNow(o)}lookAt(e,t,i){const r=new Se;typeof e=="number"?r.set(e,t,i):e instanceof ze?r.set(e.location):r.set(e);const a=this.upVector?this.upVector:ze.defaultUpVector,o=ft(this.location,r,a);this.setQuat(o)}lookAtNow(e,t,i){const r=new Se;typeof e=="number"?r.set(e,t,i):e instanceof ze?r.set(e.location):r.set(e);const a=this.upVector?this.upVector:ze.defaultUpVector,o=ft(this.location,r,a);this.setQuatNow(o)}getUnitVecX(){return new Se(1,0,0).apply(this.quat)}getUnitVecY(){return new Se(0,1,0).apply(this.quat)}getUnitVecZ(){return new Se(0,0,1).apply(this.quat)}contains(e){let t=!1;return this.object.traverse(i=>{i==e&&(t=!0)}),t}}class Hn{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class Wn{firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.firstLoc=new Se(e.location),this.firstRot=new ke(e.quat),this.firstScale=new Se(e.scale),this.nowLoc=new Se(e.location),this.nowRot=new ke(e.quat),this.nowScale=new Se(e.scale),this.lastLoc=new Se(e.location),this.lastRot=new ke(e.quat),this.lastScale=new Se(e.scale),this.nowTime=0,this.duration=1}setLocation(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastLoc.set(t),this.nowTime=0}setLocationNow(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastLoc.set(t),this.nowTime=1}setQuat(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastRot.set(t),this.nowTime=0}setQuatNow(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastRot.set(t),this.nowTime=1}setScale(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastScale.set(t),this.nowTime=0}setScaleNow(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.quat),this.firstScale.set(e.scale),this.lastScale.set(t),this.nowTime=1}smoothstep(e){return e*e*(3-2*e)}interpolate(e,t){this.nowTime+=t,this.nowTime>this.duration&&(this.nowTime=this.duration);const i=this.nowTime/this.duration,r=this.smoothstep(i);this.nowLoc.lerp(this.firstLoc,this.lastLoc,r),this.nowRot.slerp(this.firstRot,this.lastRot,r),this.nowScale.lerp(this.firstScale,this.lastScale,r),e.location.set(this.nowLoc),e.object.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),e.quat.set(this.nowRot),e.object.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),e.scale.set(this.nowScale),e.object.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class Jt extends ze{}class $t{view;constructor(e){this.view=e,e.setController(this)}update(e){}activate(){}deactivate(){}keyDown(e){}keyUp(e){}keyPress(e){}mouseDown(e){}mouseUp(e){}mouseMove(e){}mouseClick(e){}mouseEnter(e){}mouseLeave(e){}mouseWheel(e){}touchStart(e){}touchEnd(e){}touchMove(e){}touchCancel(e){}}class en extends $t{preMouse;leftClick=!1;target;cameraLoc=new Se(0,0,3);cameraQuat=new ke(0,0,0,1);constructor(e,t,i,r){super(e),this.preMouse={x:0,y:0},typeof t=="number"?this.target=new Se(t,i,r):this.target=new Se(t)}update(e){this.view.camera.setLocation(this.cameraLoc),this.view.camera.setQuat(this.cameraQuat)}mouseDown(e){e.button===0&&(this.leftClick=!0,this.preMouse.x=e.clientX,this.preMouse.y=e.clientY)}mouseMove(e){if(this.leftClick===!1)return;const t=.01,i=t*(e.clientX-this.preMouse.x),r=t*(e.clientY-this.preMouse.y),a=Math.sin(-i),o=Math.cos(-i),l=Math.sin(-r),c=Math.cos(-r),s=new Se(1,0,0).apply(this.cameraQuat),h=new Se(0,1,0).apply(this.cameraQuat),f=new ke(s.x*l,s.y*l,s.z*l,c),g=new ke(h.x*a,h.y*a,h.z*a,o),p=new Se(this.cameraLoc);p.sub(this.target),p.apply(f),p.apply(g),p.add(this.target),this.cameraLoc.set(p);const T=ft(this.cameraLoc,this.target,new Se(0,1,0));this.cameraQuat.set(T),this.preMouse.x=e.clientX,this.preMouse.y=e.clientY}mouseUp(e){e.button===0&&(this.leftClick=!1)}mouseWheel(e){const t=new Se(this.target).sub(this.cameraLoc);e.deltaY>0?t.scale(.05):e.deltaY<0&&t.scale(-.05),this.cameraLoc.add(t)}}function Kn(n){return 2*n}function Yn(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}async function tn(n){const t=await(await fetch(n)).arrayBuffer();return await new Promise((r,a)=>{Yt.unzip(new Uint8Array(t),(o,l)=>{o?a(o):r(l)})})}function It(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n[e])return Yt.strFromU8(n[e]);throw new Error(`readStringFromUnzipped(): no file at ${e}`)}function Xn(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n[e]){const t=Qn(e);return new Blob([new Uint8Array(n[e])],{type:t})}else throw new Error(`readBlobFromUnzipped(): no file at ${e}`)}const qn={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function Qn(n){for(const[e,t]of Object.entries(qn))if(t.test(n))return e;return"application/octet-stream"}function nn(n,e){if(!e)return n;const t={...n};for(const i in e)typeof n[i]=="object"&&typeof e[i]=="object"?t[i]=nn(n[i],e[i]):t[i]=e[i];return t}const Zn={type:"audio",autoplay:!1,loop:!1,volume:1,positional:{refDistance:1,maxDistance:1e3,rolloffFactor:1,directional:{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0}}};async function Jn(){try{$e.listener.context.state!=="running"&&await $e.listener.context.resume()}catch{console.warn("AudioContext resume failed. Did you call on user gesture?")}}class $e extends ze{static listener=new ge.AudioListener;static audioLoader=new ge.AudioLoader;ready;config;sound;constructor(e,t={}){super(),this.config=nn(Zn,t),this.ready=this.asyncInit(e)}initObject(){return new ge.Object3D}async asyncInit(e){if(this.config.type==="positional"){const t=new ge.PositionalAudio($e.listener);t.setRefDistance(this.config.positional.refDistance),t.setMaxDistance(this.config.positional.maxDistance),t.setRolloffFactor(this.config.positional.rolloffFactor);const i=this.config.positional.directional;t.setDirectionalCone(i.coneInnerAngle,i.coneOuterAngle,i.coneOuterGain),t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}else{const t=new ge.Audio($e.listener);t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}return this.object.add(this.sound),new Promise(t=>{$e.audioLoader.load(e,i=>{this.sound&&this.sound.setBuffer(i),t(this)})})}play(){this.sound?.play()}}class Nt{scene;camera;controller;constructor(e){this.scene=new Qt,this.camera=e,this.camera.setAudioListener($e.listener),this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3),this.controller=new en(this,0,0,0)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e),this.controller?.update(e),this.camera.update(e)}setController(e){this.controller?.deactivate(),this.controller=e,this.controller.activate()}worldToScreen(e){throw new Error("ViewBaseはworldToScreen()は実装していません")}}class at extends Jt{camera;headLight;constructor(e){super(),this.camera=e,this.headLight=new ge.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new ge.Object3D}setAudioListener(e){this.camera.add(e)}getHeadLight(){return this.headLight}setAspect(e){Dn(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}calcNDC(e){const t=new ge.Vector3(e.x,e.y,e.z);return t.project(this.camera),{x:t.x,y:t.y}}}class $n extends R.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new R.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const rt=new R.Vector3,Ut=new R.Matrix4,Bt=new R.Matrix4,Gt=new R.Vector3,zt=new R.Vector3;class rn{constructor(e={}){const t=this;let i,r,a,o;const l={objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(T,m){T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),m.parent===null&&m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),Ut.copy(m.matrixWorldInverse),Bt.multiplyMatrices(m.projectionMatrix,Ut),h(T,T,m),this.sortObjects&&p(T)},this.setSize=function(T,m){i=T,r=m,a=i/2,o=r/2,c.style.width=T+"px",c.style.height=m+"px"};function s(T){T.isCSS2DObject&&(T.element.style.display="none");for(let m=0,u=T.children.length;m<u;m++)s(T.children[m])}function h(T,m,u){if(T.visible===!1){s(T);return}if(T.isCSS2DObject){rt.setFromMatrixPosition(T.matrixWorld),rt.applyMatrix4(Bt);const d=rt.z>=-1&&rt.z<=1&&T.layers.test(u.layers)===!0,y=T.element;y.style.display=d===!0?"":"none",d===!0&&(T.onBeforeRender(t,m,u),y.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(rt.x*a+a)+"px,"+(-rt.y*o+o)+"px)",y.parentNode!==c&&c.appendChild(y),T.onAfterRender(t,m,u));const v={distanceToCameraSquared:f(u,T)};l.objects.set(T,v)}for(let d=0,y=T.children.length;d<y;d++)h(T.children[d],m,u)}function f(T,m){return Gt.setFromMatrixPosition(T.matrixWorld),zt.setFromMatrixPosition(m.matrixWorld),Gt.distanceToSquared(zt)}function g(T){const m=[];return T.traverseVisible(function(u){u.isCSS2DObject&&m.push(u)}),m}function p(T){const m=g(T).sort(function(d,y){if(d.renderOrder!==y.renderOrder)return y.renderOrder-d.renderOrder;const v=l.objects.get(d).distanceToCameraSquared,E=l.objects.get(y).distanceToCameraSquared;return v-E}),u=m.length;for(let d=0,y=m.length;d<y;d++)m[d].element.style.zIndex=u-d}}}class on extends HTMLElement{ro;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;_canvas;_css2DCanvas;constructor(e){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
1
|
+
"use strict";var xn=Object.create;var Bt=Object.defineProperty;var On=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var Nn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty;var kn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of In(e))!wn.call(n,r)&&r!==t&&Bt(n,r,{get:()=>e[r],enumerable:!(i=On(e,r))||i.enumerable});return n};var Cn=(n,e,t)=>(t=n!=null?xn(Nn(n)):{},kn(e||!n||!n.__esModule?Bt(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("three"),Jt=require("fflate");function Pn(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const de=Pn(R);function $t(n){return typeof n=="string"}function kt(n){return n.isMesh===!0}function Mn(n){return n.type==="RoundedBoxGeometry"}function Dn(n){return n.type==="BoxGeometry"}function Fn(n){return n.type==="SphereGeometry"}function Un(n){return n.type==="IcosahedronGeometry"}function Bn(n){return n.type==="CylinderGeometry"}function jn(n){return n.type==="CapsuleGeometry"}function Gn(n){return n.isBone===!0}function zn(n){return n.isPerspectiveCamera===!0}const en={rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};class Vn{object;option;constructor(e,t){this.object=e,this.option=t}}class ke{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,i,r){typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}clone(){return new ke(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t,this._w/=t):console.warn("Quat.normalize."),this}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}set(e,t,i,r){return typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}mul(e,t,i,r){const c=new ke(this),o=new ke;return typeof e=="number"?o.set(e,t,i,r):o.set(e),this._x=c.w*o.x+c.x*o.w+c.y*o.z-c.z*o.y,this._y=c.w*o.y-c.x*o.z+c.y*o.w+c.z*o.x,this._z=c.w*o.z+c.x*o.y-c.y*o.x+c.z*o.w,this._w=c.w*o.w-c.x*o.x-c.y*o.y-c.z*o.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w}slerp(e,t,i){if(i<0||i>1){console.warn("Quat.slerp(): t must be in [0,1]");return}const r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(r<.9995){const c=Math.acos(r),o=Math.sin((1-i)*c)/Math.sin(c),u=Math.sin(i*c)/Math.sin(c);this._x=o*e.x+u*t.x,this._y=o*e.y+u*t.y,this._z=o*e.z+u*t.z,this._w=o*e.w+u*t.w}else{this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w;const c=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);c<1e-4?(console.warn("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/c,this._y*=1/c,this._z*=1/c,this._w*=1/c)}}}function st(n,e,t){t.normalize();const i=e.clone().sub(n).normalize(),r=new _e().cross(i,t).normalize(),c=new _e().cross(r,i),o=r.x,u=c.x,a=-i.x,s=r.y,f=c.y,h=-i.y,T=r.z,p=c.z,g=-i.z,y=o+f+g;if(y>0){const l=Math.sqrt(y+1)*2;return new ke((p-h)/l,(a-T)/l,(s-u)/l,.25*l)}else if(o>f&&o>g){const l=Math.sqrt(1+o-f-g)*2;return new ke(.25*l,(u+s)/l,(a+T)/l,(p-h)/l)}else if(f>g){const l=Math.sqrt(1+f-o-g)*2;return new ke((u+s)/l,.25*l,(h+p)/l,(a-T)/l)}else{const l=Math.sqrt(1+g-o-f)*2;return new ke((a+T)/l,(h+p)/l,.25*l,(s-u)/l)}}function tn(n,e="XYZ"){const t=new ke(0,0,0,1);for(let i=0;i<3;i++)switch(e.charAt(i)){case"X":t.mul(new ke(Math.sin(n.x),0,0,Math.cos(n.x)));break;case"Y":t.mul(new ke(0,Math.sin(n.y),0,Math.cos(n.y)));break;case"Z":t.mul(new ke(0,0,Math.sin(n.z),Math.cos(n.z)));break}return t}class _e{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,i){typeof e=="number"?(this._x=e,this._y=t,this._z=i):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}clone(){return new _e(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t):console.warn("Vec3.normalize."),this}negate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}set(e,t,i){return typeof e=="number"?(this._x=e,this._y=t,this._z=i):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e,t,i){return typeof e=="number"?(this._x+=e,this._y+=t,this._z+=i):(this._x+=e.x,this._y+=e.y,this._z+=e.z),this}sub(e,t,i){return typeof e=="number"?(this._x-=e,this._y-=t,this._z-=i):(this._x-=e.x,this._y-=e.y,this._z-=e.z),this}scale(e){return this._x*=e,this._y*=e,this._z*=e,this}cross(e,t){return this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this}apply(e,t,i,r){const c=new ke;typeof e=="number"?c.set(e,t,i,r):c.set(e);const o=new ke(this._x,this._y,this._z,0),u=new ke(c).conjugate();return c.mul(o).mul(u),this._x=c.x,this._y=c.y,this._z=c.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z}}class lt{objectA3;object3D;interpolation;billboard;constructor(e){this.objectA3=e,this.object3D=e.object}setObject(e){this.objectA3=e,this.object3D=e.object}enableInterpolation(e){e&&!this.interpolation?this.interpolation=new Hn(this.object3D):!e&&this.interpolation&&(this.interpolation=void 0)}enableBillboard(e){e&&this.billboard?this.billboard.setTarget(e.object):e&&!this.billboard?this.billboard=new Wn(this.objectA3,e.object):this.billboard=void 0}update(e){this.interpolation&&this.interpolation.update(e),this.billboard&&this.billboard.update()}setLocation(e){this.interpolation?this.interpolation.setLocation(e):this.object3D.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setLocationNow(e){this.interpolation?this.interpolation.setLocationNow(e):this.object3D.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setQuat(e){this.billboard||(this.interpolation?this.interpolation.setQuat(e):this.object3D.quaternion.set(e.x,e.y,e.z,e.w))}setQuatNow(e){this.billboard||(this.interpolation?this.interpolation.setQuatNow(e):this.object3D.quaternion.set(e.x,e.y,e.z,e.w))}setScale(e){this.interpolation?this.interpolation.setScale(e):this.object3D.scale.set(e.x,e.y,e.z)}setScaleNow(e){this.interpolation?this.interpolation.setScaleNow(e):this.object3D.scale.set(e.x,e.y,e.z)}changeMotion(e){}setPause(e){}setTime(e){}addOnselfToPhysics(e){}removeOnselfFromPhysics(e){}}class Hn{obj;firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.obj=e,this.firstLoc=new _e(e.position),this.firstRot=new ke(e.quaternion),this.firstScale=new _e(e.scale),this.nowLoc=new _e(e.position),this.nowRot=new ke(e.quaternion),this.nowScale=new _e(e.scale),this.lastLoc=new _e(e.position),this.lastRot=new ke(e.quaternion),this.lastScale=new _e(e.scale),this.nowTime=0,this.duration=1}setLocation(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastLoc.set(e),this.nowTime=0}setLocationNow(e){this.setLocation(e),this.nowTime=1}setQuat(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastRot.set(e),this.nowTime=0}setQuatNow(e){this.setQuat(e),this.nowTime=1}setScale(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastScale.set(e),this.nowTime=0}setScaleNow(e){this.setScale(e),this.nowTime=1}smoothstep(e){return e*e*(3-2*e)}update(e){this.nowTime+=e,this.nowTime>this.duration&&(this.nowTime=this.duration);const t=this.nowTime/this.duration,i=this.smoothstep(t);this.nowLoc.lerp(this.firstLoc,this.lastLoc,i),this.nowRot.slerp(this.firstRot,this.lastRot,i),this.nowScale.lerp(this.firstScale,this.lastScale,i),this.obj.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),this.obj.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),this.obj.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class Wn{up;obj;target;tmpObjLoc=new _e;tmpTargetLoc=new _e;constructor(e,t){this.up=new _e,e.upVector?this.up.set(e.upVector):this.up.set(Be.defaultUpVector),this.obj=e.object,this.target=t}setTarget(e){this.target=e}update(){this.tmpObjLoc.set(this.obj.position),this.tmpTargetLoc.set(this.target.position);const e=st(this.tmpObjLoc,this.tmpTargetLoc,this.up);this.obj.quaternion.set(e.x,e.y,e.z,e.w)}}let Ve;class at{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!at.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),at.RAPIER=e,Ve=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOption(e)&&(t=e.timestep);const i=new Ve.World(e.gravity);return new xt(i,t)}isRapierWorldOption(e){return"timestep"in e}}class xt{world;timestep;collisionEventQueue;constructor(e,t){this.world=e,this.timestep=t,this.collisionEventQueue=new Ve.EventQueue(!0),this.world.integrationParameters.dt=this.timestep}add(e){jt(e)&&e.addOneself(this)}remove(e){jt(e)&&e.removeOneself(this)}update(e){const t=Math.ceil(e/this.timestep);for(let i=0;i<t;i++)this.world.step(this.collisionEventQueue)}getCollisions(){const e=[];return this.collisionEventQueue.drainCollisionEvents((t,i,r)=>{const c=Ot.collisionMap.get(t),o=Ot.collisionMap.get(i);c&&o&&e.push({objectA:c,partOfA:t,objectB:o,partOfB:i,started:r})}),e}}class Ot extends Vn{static collisionMap=new Map}function jt(n){return"addOneself"in n&&"removeOneself"in n}class Kn extends lt{bodyDesc;body;colliderDescs=[];colliders=[];constructor(e,t){super(e);const i={...en,...t};switch(i.rigidBody){case"dynamic":this.bodyDesc=Ve.RigidBodyDesc.dynamic();break;case"kinematic":this.bodyDesc=Ve.RigidBodyDesc.kinematicPositionBased();break;case"fixed":this.bodyDesc=Ve.RigidBodyDesc.fixed();break}this.bodyDesc.setTranslation(this.object3D.position.x,this.object3D.position.y,this.object3D.position.z),this.bodyDesc.setRotation({x:this.object3D.quaternion.x,y:this.object3D.quaternion.y,z:this.object3D.quaternion.z,w:this.object3D.quaternion.w});const r=[];this.object3D.traverse(o=>{if(kt(o)){const u=qn(o.geometry),a=i.membership<<16|i.filter;if(u)u.colliderDesc.setCollisionGroups(a),i.collisionDetection&&u.colliderDesc.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(u.colliderDesc),u.colliderDesc.setRestitution(i.restitution).setFriction(i.friction),r.push(u.volume);else{let s,f;switch(i.meshCollider){case"tri_mesh":s=Yn(o),f=Gt(o.geometry);break;case"convex_hull":s=Xn(o),f=Gt(o.geometry);break}s&&(s.setCollisionGroups(a),i.collisionDetection&&s.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(s),r.push(f))}}});let c=r.reduce((o,u)=>o+u,0);for(let o=0;o<this.colliderDescs.length;o++)this.colliderDescs[o].setRestitution(i.restitution),this.colliderDescs[o].setFriction(i.friction),this.colliderDescs[o].setMass(i.mass*(r[o]/c))}setObject(e){this.objectA3=e,this.object3D=e.object}update(e){if(this.body){const t=this.body.translation();this.object3D.position.set(t.x,t.y,t.z);const i=this.body.rotation();this.object3D.quaternion.set(i.x,i.y,i.z,i.w)}}enableInterpolation(e){}changeMotion(e){}setPause(e){}setTime(e){}setLocation(e){}setLocationNow(e){this.body&&this.body.setTranslation(e,!0)}setQuat(e){}setQuatNow(e){this.body&&this.body.setRotation(e,!0)}setScale(e){}setScaleNow(e){}addOnselfToPhysics(e){this.body=e.world.createRigidBody(this.bodyDesc),this.colliderDescs.forEach(t=>{const i=e.world.createCollider(t,this.body);this.colliders.push(i),Ot.collisionMap.set(i.handle,this.objectA3)})}removeOnselfFromPhysics(e){this.body&&e.world.removeRigidBody(this.body),this.colliders.forEach(t=>{e.world.removeCollider(t,!1)})}}function Yn(n){let e=null;if(kt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;let c=i.index?i.index.array:null;if(c)c instanceof Uint32Array||(c=new Uint32Array(c));else{const o=i.attributes.position.count;c=new Uint32Array(o);for(let u=0;u<o;u++)c[u]=u}r instanceof Float32Array&&(e=Ve.ColliderDesc.trimesh(r,c))}return e}function Xn(n){let e=null;if(kt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;r instanceof Float32Array&&(e=Ve.ColliderDesc.convexHull(r))}return e}function Gt(n){const e=n.attributes.position;if(!e)throw new Error("position attribute not found");const t=n.index,i=e.array;let r=0;const c=new de.Vector3,o=new de.Vector3,u=new de.Vector3;if(t){const a=t.array;for(let s=0;s<a.length;s+=3){const f=a[s]*3,h=a[s+1]*3,T=a[s+2]*3;c.set(i[f],i[f+1],i[f+2]),o.set(i[h],i[h+1],i[h+2]),u.set(i[T],i[T+1],i[T+2]),r+=c.dot(o.clone().cross(u))}}else for(let a=0;a<i.length;a+=9)c.set(i[a],i[a+1],i[a+2]),o.set(i[a+3],i[a+4],i[a+5]),u.set(i[a+6],i[a+7],i[a+8]),r+=c.dot(o.clone().cross(u));return Math.abs(r)/6}function qn(n){if(Mn(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,c=.1;return{colliderDesc:Ve.ColliderDesc.roundCuboid(t-c,i-c,r-c,c),volume:2*t*2*i*2*r}}else if(Dn(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Ve.ColliderDesc.cuboid(t,i,r),volume:2*t*2*i*2*r}}else if(Fn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Un(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Bn(n)){const e=n.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.cylinder(i/2,t),volume:Math.PI*t*t*i}}else if(jn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.capsule(i/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*i}}return null}const It=new at;async function Qn(){await It.init()}class nn{scene;objects;physicsWorld=null;physicsDt=1/60;collisionListener;constructor(){this.scene=new de.Scene,this.objects=[],It.isInitialized&&(this.physicsWorld=It.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt}))}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,this.physicsWorld instanceof xt&&e.motion.addOnselfToPhysics(this.physicsWorld)}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,this.physicsWorld instanceof xt&&e.motion.removeOnselfFromPhysics(this.physicsWorld)}setCollisionListener(e){this.collisionListener=e}update(e){if(this.physicsWorld){this.physicsWorld.update(e);const t=this.physicsWorld.getCollisions();t.forEach(i=>{i.objectA.handleCollision(i.objectB,i.started,i.partOfA,i.partOfB),i.objectB.handleCollision(i.objectA,i.started,i.partOfB,i.partOfA)}),this.collisionListener&&t.length>0&&this.collisionListener(t)}for(const t of this.objects)t.update(e)}}class Be{static defaultRotationOrder="XYZ";static defaultUpVector=new _e(0,1,0);rotationOrder=null;upVector=null;object;scene=null;balloon=null;motion;parent=null;children=[];clickListener;constructor(e){this.object=this.initObject(e),this.object.traverse(t=>{t.userData.a3js={objectA3:this}}),this.motion=this.initMotion()}initMotion(e){return new lt(this)}setMotion(e){e.setObject(this),this.motion=e}action(e){this.motion.changeMotion(e)}enableInterpolation(e){this.motion.enableInterpolation(e)}initDefaultPhysics(e){const t={...en,...e};this.motion=new Kn(this,t)}update(e){this.motion.update(e),this.children.forEach(t=>{t.update(e)})}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object.add(e.object)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=null,this.object.remove(e.object)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new Zn(e)}setClickListener(e){this.clickListener=e}handleCollision(e,t,i,r){}async clicked(){this.clickListener&&await this.clickListener(this)}get locX(){return this.object.position.x}get locY(){return this.object.position.y}get locZ(){return this.object.position.z}setLocation(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocation(r)}setLocationNow(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocationNow(r),this.object.position.set(r.x,r.y,r.z)}get quatX(){return this.object.quaternion.x}get quatY(){return this.object.quaternion.y}get quatZ(){return this.object.quaternion.z}get quatW(){return this.object.quaternion.w}setQuat(e,t,i,r){const c=new ke;typeof e=="number"?c.set(e,t,i,r):c.set(e),this.motion.setQuat(c)}setQuatNow(e,t,i,r){const c=new ke;typeof e=="number"?c.set(e,t,i,r):c.set(e),this.motion.setQuatNow(c)}get scaleX(){return this.object.scale.x}get scaleY(){return this.object.scale.y}get scaleZ(){return this.object.scale.z}setScale(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScale(r)}setScaleNow(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScaleNow(r)}setRotation(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e),r.scale(Math.PI/360);const c=this.rotationOrder?this.rotationOrder:Be.defaultRotationOrder,o=tn(r,c);this.setQuat(o)}setRotationNow(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):r.set(e);const c=this.rotationOrder?this.rotationOrder:Be.defaultRotationOrder,o=new ke(0,0,0,1);for(let u=0;u<3;u++)switch(c.charAt(u)){case"X":o.mul(new ke(Math.sin(r.x),0,0,Math.cos(r.x)));break;case"Y":o.mul(new ke(0,Math.sin(r.y),0,Math.cos(r.y)));break;case"Z":o.mul(new ke(0,0,Math.sin(r.z),Math.cos(r.z)));break}this.setQuatNow(o)}lookAt(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):e instanceof Be?r.set(e.locX,e.locY,e.locZ):r.set(e);const c=this.upVector?this.upVector:Be.defaultUpVector,o=st(new _e(this.object.position),r,c);this.setQuat(o)}lookAtNow(e,t,i){const r=new _e;typeof e=="number"?r.set(e,t,i):e instanceof Be?r.set(e.locX,e.locY,e.locZ):r.set(e);const c=this.upVector?this.upVector:Be.defaultUpVector,o=st(new _e(this.object.position),r,c);this.setQuatNow(o)}getUnitVecX(){return new _e(1,0,0).apply(this.object.quaternion)}getUnitVecY(){return new _e(0,1,0).apply(this.object.quaternion)}getUnitVecZ(){return new _e(0,0,1).apply(this.object.quaternion)}}class Zn{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class rn extends Be{controller;setController(e){this.controller=e}setLocation(e,t,i){typeof e=="number"?super.setLocation(e,t,i):super.setLocation(e),this.controller?.setCameraLocation(this.object.position)}}class on{view;constructor(e){this.view=e,e.setController(this)}update(e){}activate(){}deactivate(){}keyDown(e){}keyUp(e){}keyPress(e){}mouseDown(e){}mouseUp(e){}mouseMove(e){}mouseClick(e){}mouseEnter(e){}mouseLeave(e){}mouseWheel(e){}touchStart(e){}touchEnd(e){}touchMove(e){}touchCancel(e){}setCameraLocation(e){}setCameraLocationNow(e){}setCameraQuat(e){}setCameraQuatNow(e){}setCameraScale(e){}setCameraScaleNow(e){}}class sn extends on{preMouse;leftClick=!1;target;cameraLoc=new _e(0,0,3);cameraQuat=new ke(0,0,0,1);constructor(e,t,i,r){super(e),this.preMouse={x:0,y:0},typeof t=="number"?this.target=new _e(t,i,r):this.target=new _e(t)}update(e){this.view.camera.setLocation(this.cameraLoc),this.view.camera.setQuat(this.cameraQuat)}mouseDown(e){e.button===0&&(this.leftClick=!0,this.preMouse.x=e.clientX,this.preMouse.y=e.clientY)}mouseMove(e){if(this.leftClick===!1)return;const t=.01,i=t*(e.clientX-this.preMouse.x),r=t*(e.clientY-this.preMouse.y),c=Math.sin(-i),o=Math.cos(-i),u=Math.sin(-r),a=Math.cos(-r),s=new _e(1,0,0).apply(this.cameraQuat),f=new _e(0,1,0).apply(this.cameraQuat),h=new ke(s.x*u,s.y*u,s.z*u,a),T=new ke(f.x*c,f.y*c,f.z*c,o),p=new _e(this.cameraLoc);p.sub(this.target),p.apply(h),p.apply(T),p.add(this.target),this.cameraLoc.set(p);const g=st(this.cameraLoc,this.target,new _e(0,1,0));this.cameraQuat.set(g),this.preMouse.x=e.clientX,this.preMouse.y=e.clientY}mouseUp(e){e.button===0&&(this.leftClick=!1)}mouseWheel(e){const t=new _e(this.target).sub(this.cameraLoc);e.deltaY>0?t.scale(.05):e.deltaY<0&&t.scale(-.05),this.cameraLoc.add(t)}setCameraLocation(e){this.cameraLoc.set(e)}setCameraLocationNow(e){this.cameraLoc.set(e)}}function Jn(n){return 2*n}function $n(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}async function an(n){const t=await(await fetch(n)).arrayBuffer();return await new Promise((r,c)=>{Jt.unzip(new Uint8Array(t),(o,u)=>{o?c(o):r(u)})})}function Ct(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n[e])return Jt.strFromU8(n[e]);throw new Error(`readStringFromUnzipped(): no file at ${e}`)}function er(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n[e]){const t=nr(e);return new Blob([new Uint8Array(n[e])],{type:t})}else throw new Error(`readBlobFromUnzipped(): no file at ${e}`)}const tr={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function nr(n){for(const[e,t]of Object.entries(tr))if(t.test(n))return e;return"application/octet-stream"}function mt(n,e){if(!e)return n;const t={...n};for(const i in e)typeof n[i]=="object"&&typeof e[i]=="object"?t[i]=mt(n[i],e[i]):t[i]=e[i];return t}const rr={type:"audio",autoplay:!1,loop:!1,volume:1,positional:{refDistance:1,maxDistance:1e3,rolloffFactor:1,directional:{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0}}};async function ir(){try{$e.listener.context.state!=="running"&&await $e.listener.context.resume()}catch{console.warn("AudioContext resume failed. Did you call on user gesture?")}}class $e extends Be{static listener=new de.AudioListener;static audioLoader=new de.AudioLoader;ready;config;sound;constructor(e,t={}){super(),this.config=mt(rr,t),this.ready=this.asyncInit(e)}initObject(){return new de.Object3D}async asyncInit(e){if(this.config.type==="positional"){const t=new de.PositionalAudio($e.listener);t.setRefDistance(this.config.positional.refDistance),t.setMaxDistance(this.config.positional.maxDistance),t.setRolloffFactor(this.config.positional.rolloffFactor);const i=this.config.positional.directional;t.setDirectionalCone(i.coneInnerAngle,i.coneOuterAngle,i.coneOuterGain),t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}else{const t=new de.Audio($e.listener);t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}return this.object.add(this.sound),new Promise(t=>{$e.audioLoader.load(e,i=>{this.sound&&this.sound.setBuffer(i),t(this)})})}play(){this.sound?.play()}}class Pt{scene;camera;controller;constructor(e){this.scene=new nn,this.camera=e,this.camera.setAudioListener($e.listener),this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3),this.controller=new sn(this,0,0,0),this.camera.setController(this.controller)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e),this.controller?.update(e),this.camera.update(e)}setController(e){this.controller?.deactivate(),this.controller=e,this.controller.activate(),this.camera.setController(e)}worldToScreen(e){throw new Error("ViewBaseはworldToScreen()は実装していません")}screenToWorld(e,t,i){throw new Error("ViewBaseはscreenToWorld()は実装していません")}cameraToScreen(e){throw new Error("ViewBaseはcameraToScreen()は実装していません")}screenToCamera(e,t,i){throw new Error("ViewBaseはscreenToCamera()は実装していません")}}class ct extends rn{camera;headLight;constructor(e){super(),this.camera=e,this.headLight=new de.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new de.Object3D}setAudioListener(e){this.camera.add(e)}getHeadLight(){return this.headLight}setAspect(e){zn(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}calcNDC(e){const t=new de.Vector3(e.x,e.y,e.z);return t.project(this.camera),{x:t.x,y:t.y}}}class cn extends R.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new R.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const nt=new R.Vector3,zt=new R.Matrix4,Vt=new R.Matrix4,Ht=new R.Vector3,Wt=new R.Vector3;class ln{constructor(e={}){const t=this;let i,r,c,o;const u={objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(g,y){g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),y.parent===null&&y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),zt.copy(y.matrixWorldInverse),Vt.multiplyMatrices(y.projectionMatrix,zt),f(g,g,y),this.sortObjects&&p(g)},this.setSize=function(g,y){i=g,r=y,c=i/2,o=r/2,a.style.width=g+"px",a.style.height=y+"px"};function s(g){g.isCSS2DObject&&(g.element.style.display="none");for(let y=0,l=g.children.length;y<l;y++)s(g.children[y])}function f(g,y,l){if(g.visible===!1){s(g);return}if(g.isCSS2DObject){nt.setFromMatrixPosition(g.matrixWorld),nt.applyMatrix4(Vt);const d=nt.z>=-1&&nt.z<=1&&g.layers.test(l.layers)===!0,m=g.element;m.style.display=d===!0?"":"none",d===!0&&(g.onBeforeRender(t,y,l),m.style.transform="translate("+-100*g.center.x+"%,"+-100*g.center.y+"%)translate("+(nt.x*c+c)+"px,"+(-nt.y*o+o)+"px)",m.parentNode!==a&&a.appendChild(m),g.onAfterRender(t,y,l));const v={distanceToCameraSquared:h(l,g)};u.objects.set(g,v)}for(let d=0,m=g.children.length;d<m;d++)f(g.children[d],y,l)}function h(g,y){return Ht.setFromMatrixPosition(g.matrixWorld),Wt.setFromMatrixPosition(y.matrixWorld),Ht.distanceToSquared(Wt)}function T(g){const y=[];return g.traverseVisible(function(l){l.isCSS2DObject&&y.push(l)}),y}function p(g){const y=T(g).sort(function(d,m){if(d.renderOrder!==m.renderOrder)return m.renderOrder-d.renderOrder;const v=u.objects.get(d).distanceToCameraSquared,E=u.objects.get(m).distanceToCameraSquared;return v-E}),l=y.length;for(let d=0,m=y.length;d<m;d++)y[d].element.style.zIndex=l-d}}}class un extends HTMLElement{ro;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;_canvas;_css2DCanvas;constructor(e){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
width: 100%;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
</style>
|
|
23
23
|
<slot></slog>
|
|
24
|
-
`,e||(e={}),e.camera||(e.camera=new
|
|
24
|
+
`,e||(e={}),e.camera||(e.camera=new de.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new ct(e.camera);this.base=new Pt(t),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new de.Clock;const i={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new de.WebGLRenderer(i),this.renderer.setSize(600,300),"opaque"in e&&this.renderer.setClearAlpha(0),this._canvas=this.renderer.domElement,this._canvas.width=600,this._canvas.height=300,this.appendChild(this._canvas),this.css2DRenderer=new ln,this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="0px",this.appendChild(this._css2DCanvas),this.animationFrameId=requestAnimationFrame(this.renderingLoop),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)})}connectedCallback(){this.ro=new ResizeObserver(()=>{const e=window.devicePixelRatio||1,t=Math.floor(this.clientWidth*e),i=Math.floor(this.clientHeight*e);(this._canvas.width!==t||this._canvas.height!==i)&&(this._canvas.width=t,this._canvas.height=i,or(this.camera3js)&&(this.camera3js.aspect=t/i,this.camera3js.updateProjectionMatrix()),this.renderer.setSize(t,i),this.css2DRenderer.setSize(t,i))}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new de.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new de.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,c=(1-t.y)/2*i.y;return{x:r,y:c}}screenToWorld(e,t,i){const r=new de.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const c=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(c.multiplyScalar(i))}cameraToScreen(e){const i=new de.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new de.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=e=>{if(this.camera instanceof ct){const t=new de.Raycaster,i=new de.Vector2,r=e.target.getBoundingClientRect(),c=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(c/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),a=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;a.push({three:s.object,a3js:f})}),a.length>0&&a[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:a}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 0px; width: 100%; height: 100%; display: flex; flex-direction: column;";const c=document.createElement("p");c.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",c.textContent=e,r.appendChild(c);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("canvas-a3",un);function or(n){return n.isPerspectiveCamera===!0}class hn extends HTMLElement{_resizeObserver;_dragging=!1;_resizing=!1;_resizeDir="";_startMouseX=0;_startMouseY=0;_startLeft=0;_startTop=0;_startWidth=0;_startHeight=0;_borderSize=5;_canvas;_css2DCanvas;_titleEl=null;_titleBar=null;_closeBtn=null;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;constructor(e=600,t=300){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
25
25
|
<style>
|
|
26
26
|
:host {
|
|
27
27
|
position: absolute;
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<div class="content">
|
|
67
67
|
<slot></slot>
|
|
68
68
|
</div>
|
|
69
|
-
`,this.camera3js=new
|
|
69
|
+
`,this.camera3js=new de.PerspectiveCamera(75,e/t,.1,1e3),this.camera3js.aspect=e/t;const i=new ct(this.camera3js);this.base=new Pt(i),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new de.Clock,this.renderer=new de.WebGLRenderer,this.renderer.setSize(e,t),this._canvas=this.renderer.domElement,this._canvas.width=e,this._canvas.width=t,this.appendChild(this._canvas),this.css2DRenderer=new ln,this.css2DRenderer.setSize(e,t),this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="28px",this.appendChild(this._css2DCanvas),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)}),document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0}),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}_resizeCanvasToContent(){const e=this.shadowRoot.querySelector(".content");let t=e.clientWidth,i=e.clientHeight;const r=window.devicePixelRatio||1,c=Math.floor(t*r),o=Math.floor(i*r);(this._canvas.width!==c||this._canvas.height!==o)&&(this._canvas.width=c,this._canvas.height=o,this.camera3js.aspect=c/o,this.camera3js.updateProjectionMatrix(),this.renderer.setSize(c,o),this.css2DRenderer.setSize(c,o))}connectedCallback(){this._titleEl=this.shadowRoot.querySelector(".title"),this._titleEl.textContent=this.getAttribute("title")??"Window",this._titleBar=this.shadowRoot.querySelector(".titlebar"),this._closeBtn=this.shadowRoot.querySelector(".close"),this._titleBar.addEventListener("mousedown",this._onDragStart),this._closeBtn.addEventListener("click",()=>this.remove()),this.addEventListener("mousemove",this._onHover),this.addEventListener("mousedown",this._onResizeStart),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),this._resizeObserver=new ResizeObserver(()=>{this._canvas&&this._resizeCanvasToContent()});const e=this.shadowRoot.querySelector(".content");this._resizeObserver.observe(e),this._resizeCanvasToContent()}disconnectedCallback(){document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._resizeObserver?.disconnect()}_onDragStart=e=>{this._resizeDir||(this._dragging=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop)};_onHover=e=>{if(this._dragging||this._resizing)return;const t=this.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,c=this._borderSize;let o="";r<c?o+="n":r>t.height-c&&(o+="s"),i<c?o+="w":i>t.width-c&&(o+="e"),this._resizeDir=o,this.style.cursor=this._cursorFromDir(o)};_cursorFromDir(e){switch(e){case"n":return"ns-resize";case"s":return"ns-resize";case"e":return"ew-resize";case"w":return"ew-resize";case"ne":return"nesw-resize";case"sw":return"nesw-resize";case"nw":return"nwse-resize";case"se":return"nwse-resize";default:return"default"}}_onResizeStart=e=>{this._resizeDir&&(this._resizing=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop,this._startWidth=this.offsetWidth,this._startHeight=this.offsetHeight)};_onMouseMove=e=>{if(this._dragging&&(this.style.left=`${this._startLeft+(e.clientX-this._startMouseX)}px`,this.style.top=`${this._startTop+(e.clientY-this._startMouseY)}px`),this._resizing){const t=e.clientX-this._startMouseX,i=e.clientY-this._startMouseY;this._resizeDir.includes("e")&&(this.style.width=`${this._startWidth+t}px`),this._resizeDir.includes("s")&&(this.style.height=`${this._startHeight+i}px`),this._resizeDir.includes("w")&&(this.style.width=`${this._startWidth-t}px`,this.style.left=`${this._startLeft+t}px`),this._resizeDir.includes("n")&&(this.style.height=`${this._startHeight-i}px`,this.style.top=`${this._startTop+i}px`)}};_onMouseUp=()=>{this._dragging=!1,this._resizing=!1};replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new de.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new de.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,c=(1-t.y)/2*i.y;return{x:r,y:c}}screenToWorld(e,t,i){const r=new de.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const c=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(c.multiplyScalar(i))}cameraToScreen(e){const i=new de.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new de.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=e=>{if(this.camera instanceof ct){const t=new de.Raycaster,i=new de.Vector2,r=e.target.getBoundingClientRect(),c=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(c/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),a=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;a.push({three:s.object,a3js:f})}),a.length>0&&a[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:a}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 28px; width: 100%; height: 100%; display: flex; flex-direction: column;";const c=document.createElement("p");c.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",c.textContent=e,r.appendChild(c);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("window-a3",hn);const sr=`
|
|
70
70
|
color: white;
|
|
71
71
|
padding: 5px 10px;
|
|
72
72
|
background: rgba(0, 0, 0, 0.6);
|
|
@@ -75,117 +75,117 @@
|
|
|
75
75
|
font-family: sans-serif;
|
|
76
76
|
font-size: 14px;
|
|
77
77
|
pointer-events: none; /* マウスイベントを透過させて背後の操作を邪魔しない */
|
|
78
|
-
|
|
79
|
-
`)c=0,s-=o;else{const g=sr(f,a,c,s,t);i=="tb"?(c=0,s+=t.ascender*a):c+=g.offsetX,l.push(g.path)}}return l}function sr(n,e,t,i,r){const a=r.glyphs[n]||r.glyphs["?"];if(!a){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const o=new R.ShapePath;let l,c,s,h,f,g,p,T;if(a.o){const m=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let u=0,d=m.length;u<d;)switch(m[u++]){case"m":l=m[u++]*e+t,c=m[u++]*e+i,o.moveTo(l,c);break;case"l":l=m[u++]*e+t,c=m[u++]*e+i,o.lineTo(l,c);break;case"q":s=m[u++]*e+t,h=m[u++]*e+i,f=m[u++]*e+t,g=m[u++]*e+i,o.quadraticCurveTo(f,g,s,h);break;case"b":s=m[u++]*e+t,h=m[u++]*e+i,f=m[u++]*e+t,g=m[u++]*e+i,p=m[u++]*e+t,T=m[u++]*e+i,o.bezierCurveTo(f,g,p,T,s,h);break}}return{offsetX:a.ha*e,path:o}}class ar extends R.ExtrudeGeometry{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const r=i.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t)}this.type="TextGeometry"}}let dt=null;async function cr(n){if(n.match(/.zip$/i)){let e=n.substring(n.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await tn(n),i=It(t,e);dt=new an(JSON.parse(i))}else dt=await new ir().loadAsync(n)}class ur extends ze{initObject(e){let t;if(Xt(e)?t=e:t="ERROR",dt==null){const i=new ge.BoxGeometry,r=new ge.MeshStandardMaterial({color:16711680});return new ge.Mesh(i,r)}else{const i={font:dt,size:1,depth:.5,curveSegments:12},r=new ar(t,i);r.center();const a=new ge.MeshStandardMaterial({color:65280});return new ge.Mesh(r,a)}}}function jt(n,e){if(e===R.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===R.TriangleFanDrawMode||e===R.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],l=n.getAttribute("position");if(l!==void 0){for(let c=0;c<l.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===R.TriangleFanDrawMode)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=n.clone();return a.setIndex(r),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class lr extends R.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new mr(t)}),this.register(function(t){return new yr(t)}),this.register(function(t){return new Sr(t)}),this.register(function(t){return new br(t)}),this.register(function(t){return new Or(t)}),this.register(function(t){return new Tr(t)}),this.register(function(t){return new Er(t)}),this.register(function(t){return new vr(t)}),this.register(function(t){return new Rr(t)}),this.register(function(t){return new pr(t)}),this.register(function(t){return new _r(t)}),this.register(function(t){return new gr(t)}),this.register(function(t){return new Lr(t)}),this.register(function(t){return new Ar(t)}),this.register(function(t){return new fr(t)}),this.register(function(t){return new xr(t)}),this.register(function(t){return new Ir(t)})}load(e,t,i,r){const a=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const s=R.LoaderUtils.extractUrlBase(e);o=R.LoaderUtils.resolveURL(s,this.path)}else o=R.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const l=function(s){r?r(s):console.error(s),a.manager.itemError(e),a.manager.itemEnd(e)},c=new R.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(s){try{a.parse(s,o,function(h){t(h),a.manager.itemEnd(e)},l)}catch(h){l(h)}},i,l)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let a;const o={},l={},c=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===cn){try{o[_e.KHR_BINARY_GLTF]=new Nr(e)}catch(f){r&&r(f);return}a=JSON.parse(o[_e.KHR_BINARY_GLTF].content)}else a=JSON.parse(c.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const s=new Vr(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const f=this.pluginCallbacks[h](s);f.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[f.name]=f,o[f.name]=!0}if(a.extensionsUsed)for(let h=0;h<a.extensionsUsed.length;++h){const f=a.extensionsUsed[h],g=a.extensionsRequired||[];switch(f){case _e.KHR_MATERIALS_UNLIT:o[f]=new dr;break;case _e.KHR_DRACO_MESH_COMPRESSION:o[f]=new kr(a,this.dracoLoader);break;case _e.KHR_TEXTURE_TRANSFORM:o[f]=new wr;break;case _e.KHR_MESH_QUANTIZATION:o[f]=new Cr;break;default:g.indexOf(f)>=0&&l[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}s.setExtensions(o),s.setPlugins(l),s.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,a){i.parse(e,t,r,a)})}}function hr(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const _e={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 fr{constructor(e){this.parser=e,this.name=_e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,c=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let s;const h=new R.Color(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],R.LinearSRGBColorSpace);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":s=new R.DirectionalLight(h),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new R.PointLight(h),s.distance=f;break;case"spot":s=new R.SpotLight(h),s.distance=f,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,s.angle=c.spot.outerConeAngle,s.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return s.position.set(0,0,0),qe(s,c),c.intensity!==void 0&&(s.intensity=c.intensity),s.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(s),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,a=i.json.nodes[e],l=(a.extensions&&a.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(c){return i._getNodeRef(t.cache,l,c)})}}class dr{constructor(){this.name=_e.KHR_MATERIALS_UNLIT}getMaterialType(){return R.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new R.Color(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const o=a.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],R.LinearSRGBColorSpace),e.opacity=o[3]}a.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",a.baseColorTexture,R.SRGBColorSpace))}return Promise.all(r)}}class pr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name].emissiveStrength;return a!==void 0&&(t.emissiveIntensity=a),Promise.resolve()}}class mr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const l=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new R.Vector2(l,l)}return Promise.all(a)}}class yr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.dispersion=a.dispersion!==void 0?a.dispersion:0,Promise.resolve()}}class gr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(a)}}class Tr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[];t.sheenColor=new R.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){const l=o.sheenColorFactor;t.sheenColor.setRGB(l[0],l[1],l[2],R.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&a.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,R.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(a)}}class Er{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&a.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(a)}}class vr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&a.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const l=o.attenuationColor||[1,1,1];return t.attenuationColor=new R.Color().setRGB(l[0],l[1],l[2],R.LinearSRGBColorSpace),Promise.all(a)}}class Rr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.ior=a.ior!==void 0?a.ior:1.5,Promise.resolve()}}class _r{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&a.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const l=o.specularColorFactor||[1,1,1];return t.specularColor=new R.Color().setRGB(l[0],l[1],l[2],R.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&a.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,R.SRGBColorSpace)),Promise.all(a)}}class Ar{constructor(e){this.parser=e,this.name=_e.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&a.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(a)}}class Lr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&a.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(a)}}class Sr{constructor(e){this.parser=e,this.name=_e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,o)}}class br{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],l=r.images[o.source];let c=i.textureLoader;if(l.uri){const s=i.options.manager.getHandler(l.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class Or{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],l=r.images[o.source];let c=i.textureLoader;if(l.uri){const s=i.options.manager.getHandler(l.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class xr{constructor(e){this.name=_e.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],a=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then(function(l){const c=r.byteOffset||0,s=r.byteLength||0,h=r.count,f=r.byteStride,g=new Uint8Array(l,c,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,f,g,r.mode,r.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(h*f);return o.decodeGltfBuffer(new Uint8Array(p),h,f,g,r.mode,r.filter),p})})}else return null}}class Ir{constructor(e){this.name=_e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const s of r.primitives)if(s.mode!==Ke.TRIANGLES&&s.mode!==Ke.TRIANGLE_STRIP&&s.mode!==Ke.TRIANGLE_FAN&&s.mode!==void 0)return null;const o=i.extensions[this.name].attributes,l=[],c={};for(const s in o)l.push(this.parser.getDependency("accessor",o[s]).then(h=>(c[s]=h,c[s])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(s=>{const h=s.pop(),f=h.isGroup?h.children:[h],g=s[0].count,p=[];for(const T of f){const m=new R.Matrix4,u=new R.Vector3,d=new R.Quaternion,y=new R.Vector3(1,1,1),v=new R.InstancedMesh(T.geometry,T.material,g);for(let E=0;E<g;E++)c.TRANSLATION&&u.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&d.fromBufferAttribute(c.ROTATION,E),c.SCALE&&y.fromBufferAttribute(c.SCALE,E),v.setMatrixAt(E,m.compose(u,d,y));for(const E in c)if(E==="_COLOR_0"){const b=c[E];v.instanceColor=new R.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&T.geometry.setAttribute(E,c[E]);R.Object3D.prototype.copy.call(v,T),this.parser.assignFinalMaterial(v),p.push(v)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const cn="glTF",ot=12,Vt={JSON:1313821514,BIN:5130562};class Nr{constructor(e){this.name=_e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ot),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==cn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-ot,a=new DataView(e,ot);let o=0;for(;o<r;){const l=a.getUint32(o,!0);o+=4;const c=a.getUint32(o,!0);if(o+=4,c===Vt.JSON){const s=new Uint8Array(e,ot+o,l);this.content=i.decode(s)}else if(c===Vt.BIN){const s=ot+o;this.body=e.slice(s,s+l)}o+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kr{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,l={},c={},s={};for(const h in o){const f=bt[h]||h.toLowerCase();l[f]=o[h]}for(const h in e.attributes){const f=bt[h]||h.toLowerCase();if(o[h]!==void 0){const g=i.accessors[e.attributes[h]],p=it[g.componentType];s[f]=p.name,c[f]=g.normalized===!0}}return t.getDependency("bufferView",a).then(function(h){return new Promise(function(f,g){r.decodeDracoFile(h,function(p){for(const T in p.attributes){const m=p.attributes[T],u=c[T];u!==void 0&&(m.normalized=u)}f(p)},l,s,R.LinearSRGBColorSpace,g)})})}}class wr{constructor(){this.name=_e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Cr{constructor(){this.name=_e.KHR_MESH_QUANTIZATION}}class un extends R.Interpolant{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[a+o];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,o=this.sampleValues,l=this.valueSize,c=l*2,s=l*3,h=r-t,f=(i-t)/h,g=f*f,p=g*f,T=e*s,m=T-s,u=-2*p+3*g,d=p-g,y=1-u,v=d-g+f;for(let E=0;E!==l;E++){const b=o[m+E+l],P=o[m+E+c]*h,w=o[T+E+l],Y=o[T+E]*h;a[E]=y*b+v*P+u*w+d*Y}return a}}const Pr=new R.Quaternion;class Mr extends un{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return Pr.fromArray(a).normalize().toArray(a),a}}const Ke={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},it={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ht={9728:R.NearestFilter,9729:R.LinearFilter,9984:R.NearestMipmapNearestFilter,9985:R.LinearMipmapNearestFilter,9986:R.NearestMipmapLinearFilter,9987:R.LinearMipmapLinearFilter},Wt={33071:R.ClampToEdgeWrapping,33648:R.MirroredRepeatWrapping,10497:R.RepeatWrapping},vt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bt={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"},Je={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Dr={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete},Rt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Fr(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new R.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:R.FrontSide})),n.DefaultMaterial}function et(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function qe(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ur(n,e,t){let i=!1,r=!1,a=!1;for(let s=0,h=e.length;s<h;s++){const f=e[s];if(f.POSITION!==void 0&&(i=!0),f.NORMAL!==void 0&&(r=!0),f.COLOR_0!==void 0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(n);const o=[],l=[],c=[];for(let s=0,h=e.length;s<h;s++){const f=e[s];if(i){const g=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):n.attributes.position;o.push(g)}if(r){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):n.attributes.normal;l.push(g)}if(a){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):n.attributes.color;c.push(g)}}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(c)]).then(function(s){const h=s[0],f=s[1],g=s[2];return i&&(n.morphAttributes.position=h),r&&(n.morphAttributes.normal=f),a&&(n.morphAttributes.color=g),n.morphTargetsRelative=!0,n})}function Br(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Gr(n){let e;const t=n.extensions&&n.extensions[_e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+_t(t.attributes):e=n.indices+":"+_t(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+_t(n.targets[i]);return e}function _t(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function Ot(n){switch(n){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 zr(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const jr=new R.Matrix4;class Vr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hr,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 i=!1,r=-1,a=!1,o=-1;if(typeof navigator<"u"){const l=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(l)===!0;const c=l.match(/Version\/(\d+)/);r=i&&c?parseInt(c[1],10):-1,a=l.indexOf("Firefox")>-1,o=a?l.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||a&&o<98?this.textureLoader=new R.TextureLoader(this.options.manager):this.textureLoader=new R.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new R.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const l={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return et(a,l,r),qe(l,r),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(l)})).then(function(){for(const c of l.scenes)c.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const o=t[r].joints;for(let l=0,c=o.length;l<c;l++)e[o[l]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(o,l)=>{const c=this.associations.get(o);c!=null&&this.associations.set(l,c);for(const[s,h]of o.children.entries())a(h,l.children[s])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":r=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(a,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_e.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(a,o){i.load(R.LoaderUtils.resolveURL(t.uri,r.path),a,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const r=t.byteLength||0,a=t.byteOffset||0;return i.slice(a,a+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=vt[r.type],l=it[r.componentType],c=r.normalized===!0,s=new l(r.count*o);return Promise.resolve(new R.BufferAttribute(s,o,c))}const a=[];return r.bufferView!==void 0?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),r.sparse!==void 0&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then(function(o){const l=o[0],c=vt[r.type],s=it[r.componentType],h=s.BYTES_PER_ELEMENT,f=h*c,g=r.byteOffset||0,p=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,T=r.normalized===!0;let m,u;if(p&&p!==f){const d=Math.floor(g/p),y="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+d+":"+r.count;let v=t.cache.get(y);v||(m=new s(l,d*p,r.count*p/h),v=new R.InterleavedBuffer(m,p/h),t.cache.add(y,v)),u=new R.InterleavedBufferAttribute(v,c,g%p/h,T)}else l===null?m=new s(r.count*c):m=new s(l,g,r.count*c),u=new R.BufferAttribute(m,c,T);if(r.sparse!==void 0){const d=vt.SCALAR,y=it[r.sparse.indices.componentType],v=r.sparse.indices.byteOffset||0,E=r.sparse.values.byteOffset||0,b=new y(o[1],v,r.sparse.count*d),P=new s(o[2],E,r.sparse.count*c);l!==null&&(u=new R.BufferAttribute(u.array.slice(),u.itemSize,u.normalized)),u.normalized=!1;for(let w=0,Y=b.length;w<Y;w++){const x=b[w];if(u.setX(x,P[w*c]),c>=2&&u.setY(x,P[w*c+1]),c>=3&&u.setZ(x,P[w*c+2]),c>=4&&u.setW(x,P[w*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}u.normalized=T}return u})}loadTexture(e){const t=this.json,i=this.options,a=t.textures[e].source,o=t.images[a];let l=this.textureLoader;if(o.uri){const c=i.manager.getHandler(o.uri);c!==null&&(l=c)}return this.loadTextureImage(e,a,l)}loadTextureImage(e,t,i){const r=this,a=this.json,o=a.textures[e],l=a.images[t],c=(l.uri||l.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const s=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=o.name||l.name||"",h.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(h.name=l.uri);const g=(a.samplers||{})[o.sampler]||{};return h.magFilter=Ht[g.magFilter]||R.LinearFilter,h.minFilter=Ht[g.minFilter]||R.LinearMipmapLinearFilter,h.wrapS=Wt[g.wrapS]||R.RepeatWrapping,h.wrapT=Wt[g.wrapT]||R.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==R.NearestFilter&&h.minFilter!==R.LinearFilter,r.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=s,s}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=r.images[e],l=self.URL||self.webkitURL;let c=o.uri||"",s=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(f){s=!0;const g=new Blob([f],{type:o.mimeType});return c=l.createObjectURL(g),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(f){return new Promise(function(g,p){let T=g;t.isImageBitmapLoader===!0&&(T=function(m){const u=new R.Texture(m);u.needsUpdate=!0,g(u)}),t.load(R.LoaderUtils.resolveURL(f,a.path),T,void 0,p)})}).then(function(f){return s===!0&&l.revokeObjectURL(c),qe(f,o),f.userData.mimeType=o.mimeType||zr(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=h,h}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),a.extensions[_e.KHR_TEXTURE_TRANSFORM]){const l=i.extensions!==void 0?i.extensions[_e.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const c=a.associations.get(o);o=a.extensions[_e.KHR_TEXTURE_TRANSFORM].extendTexture(o,l),a.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+i.uuid;let c=this.cache.get(l);c||(c=new R.PointsMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(l,c)),i=c}else if(e.isLine){const l="LineBasicMaterial:"+i.uuid;let c=this.cache.get(l);c||(c=new R.LineBasicMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(l,c)),i=c}if(r||a||o){let l="ClonedMaterial:"+i.uuid+":";r&&(l+="derivative-tangents:"),a&&(l+="vertex-colors:"),o&&(l+="flat-shading:");let c=this.cache.get(l);c||(c=i.clone(),a&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(l,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return R.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let o;const l={},c=a.extensions||{},s=[];if(c[_e.KHR_MATERIALS_UNLIT]){const f=r[_e.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),s.push(f.extendParams(l,a,t))}else{const f=a.pbrMetallicRoughness||{};if(l.color=new R.Color(1,1,1),l.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;l.color.setRGB(g[0],g[1],g[2],R.LinearSRGBColorSpace),l.opacity=g[3]}f.baseColorTexture!==void 0&&s.push(t.assignTexture(l,"map",f.baseColorTexture,R.SRGBColorSpace)),l.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,l.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(s.push(t.assignTexture(l,"metalnessMap",f.metallicRoughnessTexture)),s.push(t.assignTexture(l,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),s.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,l)})))}a.doubleSided===!0&&(l.side=R.DoubleSide);const h=a.alphaMode||Rt.OPAQUE;if(h===Rt.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,h===Rt.MASK&&(l.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(l,"normalMap",a.normalTexture)),l.normalScale=new R.Vector2(1,1),a.normalTexture.scale!==void 0)){const f=a.normalTexture.scale;l.normalScale.set(f,f)}if(a.occlusionTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(l,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==R.MeshBasicMaterial){const f=a.emissiveFactor;l.emissive=new R.Color().setRGB(f[0],f[1],f[2],R.LinearSRGBColorSpace)}return a.emissiveTexture!==void 0&&o!==R.MeshBasicMaterial&&s.push(t.assignTexture(l,"emissiveMap",a.emissiveTexture,R.SRGBColorSpace)),Promise.all(s).then(function(){const f=new o(l);return a.name&&(f.name=a.name),qe(f,a),t.associations.set(f,{materials:e}),a.extensions&&et(r,f,a),f})}createUniqueName(e){const t=R.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(l){return i[_e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(c){return Kt(c,l,t)})}const o=[];for(let l=0,c=e.length;l<c;l++){const s=e[l],h=Gr(s),f=r[h];if(f)o.push(f.promise);else{let g;s.extensions&&s.extensions[_e.KHR_DRACO_MESH_COMPRESSION]?g=a(s):g=Kt(new R.BufferGeometry,s,t),r[h]={primitive:s,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],o=a.primitives,l=[];for(let c=0,s=o.length;c<s;c++){const h=o[c].material===void 0?Fr(this.cache):this.getDependency("material",o[c].material);l.push(h)}return l.push(t.loadGeometries(o)),Promise.all(l).then(function(c){const s=c.slice(0,c.length-1),h=c[c.length-1],f=[];for(let p=0,T=h.length;p<T;p++){const m=h[p],u=o[p];let d;const y=s[p];if(u.mode===Ke.TRIANGLES||u.mode===Ke.TRIANGLE_STRIP||u.mode===Ke.TRIANGLE_FAN||u.mode===void 0)d=a.isSkinnedMesh===!0?new R.SkinnedMesh(m,y):new R.Mesh(m,y),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===Ke.TRIANGLE_STRIP?d.geometry=jt(d.geometry,R.TriangleStripDrawMode):u.mode===Ke.TRIANGLE_FAN&&(d.geometry=jt(d.geometry,R.TriangleFanDrawMode));else if(u.mode===Ke.LINES)d=new R.LineSegments(m,y);else if(u.mode===Ke.LINE_STRIP)d=new R.Line(m,y);else if(u.mode===Ke.LINE_LOOP)d=new R.LineLoop(m,y);else if(u.mode===Ke.POINTS)d=new R.Points(m,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&Br(d,a),d.name=t.createUniqueName(a.name||"mesh_"+e),qe(d,a),u.extensions&&et(r,d,u),t.assignFinalMaterial(d),f.push(d)}for(let p=0,T=f.length;p<T;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return a.extensions&&et(r,f[0],a),f[0];const g=new R.Group;a.extensions&&et(r,g,a),t.associations.set(g,{meshes:e});for(let p=0,T=f.length;p<T;p++)g.add(f[p]);return g})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new R.PerspectiveCamera(R.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new R.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),qe(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const a=r.pop(),o=r,l=[],c=[];for(let s=0,h=o.length;s<h;s++){const f=o[s];if(f){l.push(f);const g=new R.Matrix4;a!==null&&g.fromArray(a.array,s*16),c.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new R.Skeleton(l,c)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,o=[],l=[],c=[],s=[],h=[];for(let f=0,g=r.channels.length;f<g;f++){const p=r.channels[f],T=r.samplers[p.sampler],m=p.target,u=m.node,d=r.parameters!==void 0?r.parameters[T.input]:T.input,y=r.parameters!==void 0?r.parameters[T.output]:T.output;m.node!==void 0&&(o.push(this.getDependency("node",u)),l.push(this.getDependency("accessor",d)),c.push(this.getDependency("accessor",y)),s.push(T),h.push(m))}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(s),Promise.all(h)]).then(function(f){const g=f[0],p=f[1],T=f[2],m=f[3],u=f[4],d=[];for(let v=0,E=g.length;v<E;v++){const b=g[v],P=p[v],w=T[v],Y=m[v],x=u[v];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const G=i._createAnimationTracks(b,P,w,Y,x);if(G)for(let M=0;M<G.length;M++)d.push(G[M])}const y=new R.AnimationClip(a,void 0,d);return qe(y,r),y})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(a){const o=i._getNodeRef(i.meshCache,r.mesh,a);return r.weights!==void 0&&o.traverse(function(l){if(l.isMesh)for(let c=0,s=r.weights.length;c<s;c++)l.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],a=i._loadNodeShallow(e),o=[],l=r.children||[];for(let s=0,h=l.length;s<h;s++)o.push(i.getDependency("node",l[s]));const c=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([a,Promise.all(o),c]).then(function(s){const h=s[0],f=s[1],g=s[2];g!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(g,jr)});for(let p=0,T=f.length;p<T;p++)h.add(f[p]);return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const a=t.nodes[e],o=a.name?r.createUniqueName(a.name):"",l=[],c=r._invokeOne(function(s){return s.createNodeMesh&&s.createNodeMesh(e)});return c&&l.push(c),a.camera!==void 0&&l.push(r.getDependency("camera",a.camera).then(function(s){return r._getNodeRef(r.cameraCache,a.camera,s)})),r._invokeAll(function(s){return s.createNodeAttachment&&s.createNodeAttachment(e)}).forEach(function(s){l.push(s)}),this.nodeCache[e]=Promise.all(l).then(function(s){let h;if(a.isBone===!0?h=new R.Bone:s.length>1?h=new R.Group:s.length===1?h=s[0]:h=new R.Object3D,h!==s[0])for(let f=0,g=s.length;f<g;f++)h.add(s[f]);if(a.name&&(h.userData.name=a.name,h.name=o),qe(h,a),a.extensions&&et(i,h,a),a.matrix!==void 0){const f=new R.Matrix4;f.fromArray(a.matrix),h.applyMatrix4(f)}else a.translation!==void 0&&h.position.fromArray(a.translation),a.rotation!==void 0&&h.quaternion.fromArray(a.rotation),a.scale!==void 0&&h.scale.fromArray(a.scale);if(!r.associations.has(h))r.associations.set(h,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){const f=r.associations.get(h);r.associations.set(h,{...f})}return r.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new R.Group;i.name&&(a.name=r.createUniqueName(i.name)),qe(a,i),i.extensions&&et(t,a,i);const o=i.nodes||[],l=[];for(let c=0,s=o.length;c<s;c++)l.push(r.getDependency("node",o[c]));return Promise.all(l).then(function(c){for(let h=0,f=c.length;h<f;h++)a.add(c[h]);const s=h=>{const f=new Map;for(const[g,p]of r.associations)(g instanceof R.Material||g instanceof R.Texture)&&f.set(g,p);return h.traverse(g=>{const p=r.associations.get(g);p!=null&&f.set(g,p)}),f};return r.associations=s(a),a})}_createAnimationTracks(e,t,i,r,a){const o=[],l=e.name?e.name:e.uuid,c=[];Je[a.path]===Je.weights?e.traverse(function(g){g.morphTargetInfluences&&c.push(g.name?g.name:g.uuid)}):c.push(l);let s;switch(Je[a.path]){case Je.weights:s=R.NumberKeyframeTrack;break;case Je.rotation:s=R.QuaternionKeyframeTrack;break;case Je.translation:case Je.scale:s=R.VectorKeyframeTrack;break;default:i.itemSize===1?s=R.NumberKeyframeTrack:s=R.VectorKeyframeTrack;break}const h=r.interpolation!==void 0?Dr[r.interpolation]:R.InterpolateLinear,f=this._getArrayFromAccessor(i);for(let g=0,p=c.length;g<p;g++){const T=new s(c[g]+"."+Je[a.path],t.array,f,h);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),o.push(T)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=Ot(t.constructor),r=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a++)r[a]=t[a]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const r=this instanceof R.QuaternionKeyframeTrack?Mr:un;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Hr(n,e,t){const i=e.attributes,r=new R.Box3;if(i.POSITION!==void 0){const l=t.json.accessors[i.POSITION],c=l.min,s=l.max;if(c!==void 0&&s!==void 0){if(r.set(new R.Vector3(c[0],c[1],c[2]),new R.Vector3(s[0],s[1],s[2])),l.normalized){const h=Ot(it[l.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=e.targets;if(a!==void 0){const l=new R.Vector3,c=new R.Vector3;for(let s=0,h=a.length;s<h;s++){const f=a[s];if(f.POSITION!==void 0){const g=t.json.accessors[f.POSITION],p=g.min,T=g.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),g.normalized){const m=Ot(it[g.componentType]);c.multiplyScalar(m)}l.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}n.boundingBox=r;const o=new R.Sphere;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function Kt(n,e,t){const i=e.attributes,r=[];function a(o,l){return t.getDependency("accessor",o).then(function(c){n.setAttribute(l,c)})}for(const o in i){const l=bt[o]||o.toLowerCase();l in n.attributes||r.push(a(i[o],l))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(l){n.setIndex(l)});r.push(o)}return R.ColorManagement.workingColorSpace!==R.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${R.ColorManagement.workingColorSpace}" not supported.`),qe(n,e),Hr(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Ur(n,e.targets,t):n})}const At=new WeakMap;class Wr extends R.Loader{constructor(e){super(e),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(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){const a=new R.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,o=>{this.parse(o,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,R.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,r,a=R.LinearSRGBColorSpace,o=()=>{}){const l={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,l).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(At.has(e)){const c=At.get(e);if(c.key===i)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,o=e.byteLength,l=this._getWorker(a,o).then(c=>(r=c,new Promise((s,h)=>{r._callbacks[a]={resolve:s,reject:h},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return l.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),At.set(e,{key:i,promise:l}),l}_createGeometry(e){const t=new R.BufferGeometry;e.index&&t.setIndex(new R.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:a,itemSize:o,stride:l,vertexColorSpace:c}=e.attributes[i];let s;if(o===l)s=new R.BufferAttribute(a,o);else{const h=new R.InterleavedBuffer(a,l);s=new R.InterleavedBufferAttribute(h,o,0)}r==="color"&&(this._assignVertexColorSpace(s,c),s.normalized=!(a instanceof Float32Array)),t.setAttribute(r,s)}return t}_assignVertexColorSpace(e,t){if(t!==R.SRGBColorSpace)return;const i=new R.Color;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r),R.ColorManagement.colorSpaceToWorking(i,R.SRGBColorSpace),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new R.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const a=Kr.toString(),o=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
|
|
80
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){const o=a.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Kr(){let n,e;onmessage=function(o){const l=o.data;switch(l.type){case"init":n=l.decoderConfig,e=new Promise(function(h){n.onModuleLoaded=function(f){h({draco:f})},DracoDecoderModule(n)});break;case"decode":const c=l.buffer,s=l.taskConfig;e.then(h=>{const f=h.draco,g=new f.Decoder;try{const p=t(f,g,new Int8Array(c),s),T=p.attributes.map(m=>m.array.buffer);p.index&&T.push(p.index.array.buffer),self.postMessage({type:"decode",id:l.id,geometry:p},T)}catch(p){console.error(p),self.postMessage({type:"error",id:l.id,error:p.message})}finally{f.destroy(g)}});break}};function t(o,l,c,s){const h=s.attributeIDs,f=s.attributeTypes;let g,p;const T=l.GetEncodedGeometryType(c);if(T===o.TRIANGULAR_MESH)g=new o.Mesh,p=l.DecodeArrayToMesh(c,c.byteLength,g);else if(T===o.POINT_CLOUD)g=new o.PointCloud,p=l.DecodeArrayToPointCloud(c,c.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const m={index:null,attributes:[]};for(const u in h){const d=self[f[u]];let y,v;if(s.useUniqueIDs)v=h[u],y=l.GetAttributeByUniqueId(g,v);else{if(v=l.GetAttributeId(g,o[h[u]]),v===-1)continue;y=l.GetAttribute(g,v)}const E=r(o,l,g,u,d,y);u==="color"&&(E.vertexColorSpace=s.vertexColorSpace),m.attributes.push(E)}return T===o.TRIANGULAR_MESH&&(m.index=i(o,l,g)),o.destroy(g),m}function i(o,l,c){const h=c.num_faces()*3,f=h*4,g=o._malloc(f);l.GetTrianglesUInt32Array(c,f,g);const p=new Uint32Array(o.HEAPF32.buffer,g,h).slice();return o._free(g),{array:p,itemSize:1}}function r(o,l,c,s,h,f){const g=c.num_points(),p=f.num_components(),T=a(o,h),m=p*h.BYTES_PER_ELEMENT,u=Math.ceil(m/4)*4,d=u/h.BYTES_PER_ELEMENT,y=g*m,v=g*u,E=o._malloc(y);l.GetAttributeDataArrayForAllPoints(c,f,T,y,E);const b=new h(o.HEAPF32.buffer,E,y/h.BYTES_PER_ELEMENT);let P;if(m===u)P=b.slice();else{P=new h(v/h.BYTES_PER_ELEMENT);let w=0;for(let Y=0,x=b.length;Y<x;Y++){for(let G=0;G<p;G++)P[w+G]=b[Y*p+G];w+=d}}return o._free(E),{name:s,count:g,itemSize:p,array:P,stride:d}}function a(o,l){switch(l){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function Yr(n){return"morphTargetDictionary"in n&&n.morphTargetDictionary!==void 0&&"morphTargetInfluences"in n&&Array.isArray(n.morphTargetInfluences)}const ln=new lr,hn=new Wr;hn.setDecoderPath("/examples/jsm/libs/draco/");ln.setDRACOLoader(hn);class Xr extends ze{ready;model=null;constructor(e){super(),this.ready=this.asyncInit(e),this.setControlMode("user")}initObject(){return new ge.Object3D}async asyncInit(e){if(Xt(e)){const t=await ln.loadAsync(e),i=new ge.AnimationMixer(t.scene),r={};console.log(`File: ${e}`),console.log(" actions:");for(let o=0;o<t.animations.length;o++){const l=t.animations[o],c=i.clipAction(l);r[l.name]=c,console.log(` ${l.name}`)}console.log(" morphs:");const a={};t.scene.traverse(o=>{if(Yr(o)){const{morphTargetDictionary:l,morphTargetInfluences:c}=o;Object.keys(l).forEach(s=>{const h=o.name+"."+s,f=l[s];a[h]={array:c,idx:f},console.log(` ${h}`)})}}),this.model={gltf:t,mixer:i,actions:r,morphs:a},this.object.add(this.model.gltf.scene)}else{const t=new ge.BoxGeometry,i=new ge.MeshStandardMaterial({color:16711680}),r=new ge.Mesh(t,i);this.object.add(r)}return this}action(e){if(this.model){this.model.mixer.stopAllAction();const t=this.model.actions[e];t&&t.play()}}morph(e,t){if(this.model&&e in this.model.morphs){const{array:i,idx:r}=this.model.morphs[e];i[r]=t}}update(e){this.model&&this.model.mixer.update(e)}}var ve=(n,e)=>()=>(e||(e={exports:{}},n(e.exports,e)),e.exports),fn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.VERSION=void 0,n.VERSION="9.0.1"}),xe=ve((n,e)=>{var t=n&&n.__spreadArray||function(F,K){for(var j=0,ee=K.length,fe=F.length;j<ee;j++,fe++)F[fe]=K[j];return F};Object.defineProperty(n,"__esModule",{value:!0}),n.toFastProperties=n.timer=n.peek=n.isES2015MapSupported=n.PRINT_WARNING=n.PRINT_ERROR=n.packArray=n.IDENTITY=n.NOOP=n.merge=n.groupBy=n.defaults=n.assignNoOverwrite=n.assign=n.zipObject=n.sortBy=n.indexOf=n.some=n.difference=n.every=n.isObject=n.isRegExp=n.isArray=n.partial=n.uniq=n.compact=n.reduce=n.findAll=n.find=n.cloneObj=n.cloneArr=n.contains=n.has=n.pick=n.reject=n.filter=n.dropRight=n.drop=n.isFunction=n.isUndefined=n.isString=n.forEach=n.last=n.first=n.flatten=n.map=n.mapValues=n.values=n.keys=n.isEmpty=void 0;function i(F){return F&&F.length===0}n.isEmpty=i;function r(F){return F==null?[]:Object.keys(F)}n.keys=r;function a(F){for(var K=[],j=Object.keys(F),ee=0;ee<j.length;ee++)K.push(F[j[ee]]);return K}n.values=a;function o(F,K){for(var j=[],ee=r(F),fe=0;fe<ee.length;fe++){var Ae=ee[fe];j.push(K.call(null,F[Ae],Ae))}return j}n.mapValues=o;function l(F,K){for(var j=[],ee=0;ee<F.length;ee++)j.push(K.call(null,F[ee],ee));return j}n.map=l;function c(F){for(var K=[],j=0;j<F.length;j++){var ee=F[j];Array.isArray(ee)?K=K.concat(c(ee)):K.push(ee)}return K}n.flatten=c;function s(F){return i(F)?void 0:F[0]}n.first=s;function h(F){var K=F&&F.length;return K?F[K-1]:void 0}n.last=h;function f(F,K){if(Array.isArray(F))for(var j=0;j<F.length;j++)K.call(null,F[j],j);else if(Q(F))for(var ee=r(F),j=0;j<ee.length;j++){var fe=ee[j],Ae=F[fe];K.call(null,Ae,fe)}else throw Error("non exhaustive match")}n.forEach=f;function g(F){return typeof F=="string"}n.isString=g;function p(F){return F===void 0}n.isUndefined=p;function T(F){return F instanceof Function}n.isFunction=T;function m(F,K){return K===void 0&&(K=1),F.slice(K,F.length)}n.drop=m;function u(F,K){return K===void 0&&(K=1),F.slice(0,F.length-K)}n.dropRight=u;function d(F,K){var j=[];if(Array.isArray(F))for(var ee=0;ee<F.length;ee++){var fe=F[ee];K.call(null,fe)&&j.push(fe)}return j}n.filter=d;function y(F,K){return d(F,function(j){return!K(j)})}n.reject=y;function v(F,K){for(var j=Object.keys(F),ee={},fe=0;fe<j.length;fe++){var Ae=j[fe],L=F[Ae];K(L)&&(ee[Ae]=L)}return ee}n.pick=v;function E(F,K){return Q(F)?F.hasOwnProperty(K):!1}n.has=E;function b(F,K){return Y(F,function(j){return j===K})!==void 0}n.contains=b;function P(F){for(var K=[],j=0;j<F.length;j++)K.push(F[j]);return K}n.cloneArr=P;function w(F){var K={};for(var j in F)Object.prototype.hasOwnProperty.call(F,j)&&(K[j]=F[j]);return K}n.cloneObj=w;function Y(F,K){for(var j=0;j<F.length;j++){var ee=F[j];if(K.call(null,ee))return ee}}n.find=Y;function x(F,K){for(var j=[],ee=0;ee<F.length;ee++){var fe=F[ee];K.call(null,fe)&&j.push(fe)}return j}n.findAll=x;function G(F,K,j){for(var ee=Array.isArray(F),fe=ee?F:a(F),Ae=ee?[]:r(F),L=j,_=0;_<fe.length;_++)L=K.call(null,L,fe[_],ee?_:Ae[_]);return L}n.reduce=G;function M(F){return y(F,function(K){return K==null})}n.compact=M;function O(F,K){K===void 0&&(K=function(ee){return ee});var j=[];return G(F,function(ee,fe){var Ae=K(fe);return b(j,Ae)?ee:(j.push(Ae),ee.concat(fe))},[])}n.uniq=O;function C(F){for(var K=[],j=1;j<arguments.length;j++)K[j-1]=arguments[j];var ee=[null],fe=ee.concat(K);return Function.bind.apply(F,fe)}n.partial=C;function k(F){return Array.isArray(F)}n.isArray=k;function X(F){return F instanceof RegExp}n.isRegExp=X;function Q(F){return F instanceof Object}n.isObject=Q;function H(F,K){for(var j=0;j<F.length;j++)if(!K(F[j],j))return!1;return!0}n.every=H;function $(F,K){return y(F,function(j){return b(K,j)})}n.difference=$;function te(F,K){for(var j=0;j<F.length;j++)if(K(F[j]))return!0;return!1}n.some=te;function ae(F,K){for(var j=0;j<F.length;j++)if(F[j]===K)return j;return-1}n.indexOf=ae;function se(F,K){var j=P(F);return j.sort(function(ee,fe){return K(ee)-K(fe)}),j}n.sortBy=se;function ce(F,K){if(F.length!==K.length)throw Error("can't zipObject with different number of keys and values!");for(var j={},ee=0;ee<F.length;ee++)j[F[ee]]=K[ee];return j}n.zipObject=ce;function ne(F){for(var K=[],j=1;j<arguments.length;j++)K[j-1]=arguments[j];for(var ee=0;ee<K.length;ee++)for(var fe=K[ee],Ae=r(fe),L=0;L<Ae.length;L++){var _=Ae[L];F[_]=fe[_]}return F}n.assign=ne;function de(F){for(var K=[],j=1;j<arguments.length;j++)K[j-1]=arguments[j];for(var ee=0;ee<K.length;ee++)for(var fe=K[ee],Ae=r(fe),L=0;L<Ae.length;L++){var _=Ae[L];E(F,_)||(F[_]=fe[_])}return F}n.assignNoOverwrite=de;function U(){for(var F=[],K=0;K<arguments.length;K++)F[K]=arguments[K];return de.apply(void 0,t([{}],F))}n.defaults=U;function z(F,K){var j={};return f(F,function(ee){var fe=K(ee),Ae=j[fe];Ae?Ae.push(ee):j[fe]=[ee]}),j}n.groupBy=z;function W(F,K){for(var j=w(F),ee=r(K),fe=0;fe<ee.length;fe++){var Ae=ee[fe],L=K[Ae];j[Ae]=L}return j}n.merge=W;function q(){}n.NOOP=q;function Z(F){return F}n.IDENTITY=Z;function ie(F){for(var K=[],j=0;j<F.length;j++){var ee=F[j];K.push(ee!==void 0?ee:void 0)}return K}n.packArray=ie;function Te(F){console&&console.error&&console.error("Error: "+F)}n.PRINT_ERROR=Te;function me(F){console&&console.warn&&console.warn("Warning: "+F)}n.PRINT_WARNING=me;function we(){return typeof Map=="function"}n.isES2015MapSupported=we;function Be(F){return F[F.length-1]}n.peek=Be;function We(F){var K=new Date().getTime(),j=F(),ee=new Date().getTime(),fe=ee-K;return{time:fe,value:j}}n.timer=We;function Ue(F){function K(){}K.prototype=F;var j=new K;function ee(){return typeof j.bar}return ee(),ee(),F}n.toFastProperties=Ue}),kt=ve((n,e)=>{(function(t,i){typeof define=="function"&&define.amd?define([],i):typeof e=="object"&&e.exports?e.exports=i():t.regexpToAst=i()})(typeof self<"u"?self:n,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(u){this.idx=u.idx,this.input=u.input,this.groupIdx=u.groupIdx},t.prototype.pattern=function(u){this.idx=0,this.input=u,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var y={type:"Flags",loc:{begin:this.idx,end:u.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(y,"global");break;case"i":c(y,"ignoreCase");break;case"m":c(y,"multiLine");break;case"u":c(y,"unicode");break;case"y":c(y,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:y,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var u=[],d=this.idx;for(u.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),u.push(this.alternative());return{type:"Disjunction",value:u,loc:this.loc(d)}},t.prototype.alternative=function(){for(var u=[],d=this.idx;this.isTerm();)u.push(this.term());return{type:"Alternative",value:u,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var u=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(u)};case"$":return{type:"EndAnchor",loc:this.loc(u)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(u)};case"B":return{type:"NonWordBoundary",loc:this.loc(u)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}s(d);var y=this.disjunction();return this.consumeChar(")"),{type:d,value:y,loc:this.loc(u)}}h()},t.prototype.quantifier=function(u){var d,y=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var v=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:v,atMost:v};break;case",":var E;this.isDigit()?(E=this.integerIncludingZero(),d={atLeast:v,atMost:E}):d={atLeast:v,atMost:1/0},this.consumeChar("}");break}if(u===!0&&d===void 0)return;s(d);break}if(!(u===!0&&d===void 0))return s(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(y),d},t.prototype.atom=function(){var u,d=this.idx;switch(this.peekChar()){case".":u=this.dotAll();break;case"\\":u=this.atomEscape();break;case"[":u=this.characterClass();break;case"(":u=this.group();break}return u===void 0&&this.isPatternCharacter()&&(u=this.patternCharacter()),s(u),u.loc=this.loc(d),this.isQuantifier()&&(u.quantifier=this.quantifier()),u},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
|
|
81
|
-
`),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var
|
|
82
|
-
`);break;case"r":
|
|
83
|
-
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var
|
|
84
|
-
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var
|
|
85
|
-
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(
|
|
86
|
-
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}},t.prototype.isQuantifier=function(){var
|
|
87
|
-
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(
|
|
88
|
-
`),o("\r"),o(" "),o("\v"),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o("\u2028"),o("\u2029"),o(" "),o(" "),o(" "),o("\uFEFF")];function
|
|
89
|
-
`;function
|
|
78
|
+
`,ar={testMode:!0};class cr extends Be{constructor(e){super(e)}initObject(){const e=new de.BoxGeometry,t=new de.MeshStandardMaterial({color:65280}),i=new de.Mesh(e,t),r=document.createElement("div");r.textContent="Hello Box!",r.style.cssText=sr;const c=new cn(r);return c.position.set(0,.8,0),i.add(c),i}initMotion(e){const t=mt(ar,e);return new lr(this,t)}}class lr extends lt{testMode=!0;constructor(e,t){super(e),this.testMode=t.testMode}update(e){this.testMode?(this.object3D.rotation.x+=e,this.object3D.rotation.y+=e,this.object3D.rotation.z+=e):super.update(e)}}class ur extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const c=this,o=new R.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(u){const a=c.parse(JSON.parse(u));t&&t(a)},i,r)}parse(e){return new fn(e)}}class fn{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,i="ltr"){const r=[],c=hr(e,t,this.data,i);for(let o=0,u=c.length;o<u;o++)r.push(...c[o].toShapes());return r}}function hr(n,e,t,i){const r=Array.from(n),c=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*c,u=[];let a=0,s=0;(i=="rtl"||i=="tb")&&r.reverse();for(let f=0;f<r.length;f++){const h=r[f];if(h===`
|
|
79
|
+
`)a=0,s-=o;else{const T=fr(h,c,a,s,t);i=="tb"?(a=0,s+=t.ascender*c):a+=T.offsetX,u.push(T.path)}}return u}function fr(n,e,t,i,r){const c=r.glyphs[n]||r.glyphs["?"];if(!c){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const o=new R.ShapePath;let u,a,s,f,h,T,p,g;if(c.o){const y=c._cachedOutline||(c._cachedOutline=c.o.split(" "));for(let l=0,d=y.length;l<d;)switch(y[l++]){case"m":u=y[l++]*e+t,a=y[l++]*e+i,o.moveTo(u,a);break;case"l":u=y[l++]*e+t,a=y[l++]*e+i,o.lineTo(u,a);break;case"q":s=y[l++]*e+t,f=y[l++]*e+i,h=y[l++]*e+t,T=y[l++]*e+i,o.quadraticCurveTo(h,T,s,f);break;case"b":s=y[l++]*e+t,f=y[l++]*e+i,h=y[l++]*e+t,T=y[l++]*e+i,p=y[l++]*e+t,g=y[l++]*e+i,o.bezierCurveTo(h,T,p,g,s,f);break}}return{offsetX:c.ha*e,path:o}}class dr extends R.ExtrudeGeometry{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const r=i.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t)}this.type="TextGeometry"}}let pt=null;async function pr(n){if(n.match(/.zip$/i)){let e=n.substring(n.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await an(n),i=Ct(t,e);pt=new fn(JSON.parse(i))}else pt=await new ur().loadAsync(n)}class mr extends Be{initObject(e){let t;if($t(e)?t=e:t="ERROR",pt==null){const i=new de.BoxGeometry,r=new de.MeshStandardMaterial({color:16711680});return new de.Mesh(i,r)}else{const i={font:pt,size:1,depth:.5,curveSegments:12},r=new dr(t,i);r.center();const c=new de.MeshStandardMaterial({color:65280});return new de.Mesh(r,c)}}}function Kt(n,e){if(e===R.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===R.TriangleFanDrawMode||e===R.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],u=n.getAttribute("position");if(u!==void 0){for(let a=0;a<u.count;a++)o.push(a);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===R.TriangleFanDrawMode)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const c=n.clone();return c.setIndex(r),c.clearGroups(),c}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class yr extends R.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Rr(t)}),this.register(function(t){return new _r(t)}),this.register(function(t){return new wr(t)}),this.register(function(t){return new kr(t)}),this.register(function(t){return new Cr(t)}),this.register(function(t){return new br(t)}),this.register(function(t){return new Lr(t)}),this.register(function(t){return new Sr(t)}),this.register(function(t){return new xr(t)}),this.register(function(t){return new vr(t)}),this.register(function(t){return new Or(t)}),this.register(function(t){return new Ar(t)}),this.register(function(t){return new Nr(t)}),this.register(function(t){return new Ir(t)}),this.register(function(t){return new Tr(t)}),this.register(function(t){return new Pr(t)}),this.register(function(t){return new Mr(t)})}load(e,t,i,r){const c=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const s=R.LoaderUtils.extractUrlBase(e);o=R.LoaderUtils.resolveURL(s,this.path)}else o=R.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const u=function(s){r?r(s):console.error(s),c.manager.itemError(e),c.manager.itemEnd(e)},a=new R.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(s){try{c.parse(s,o,function(f){t(f),c.manager.itemEnd(e)},u)}catch(f){u(f)}},i,u)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let c;const o={},u={},a=new TextDecoder;if(typeof e=="string")c=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===dn){try{o[Ae.KHR_BINARY_GLTF]=new Dr(e)}catch(h){r&&r(h);return}c=JSON.parse(o[Ae.KHR_BINARY_GLTF].content)}else c=JSON.parse(a.decode(e));else c=e;if(c.asset===void 0||c.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const s=new qr(c,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const h=this.pluginCallbacks[f](s);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[h.name]=h,o[h.name]=!0}if(c.extensionsUsed)for(let f=0;f<c.extensionsUsed.length;++f){const h=c.extensionsUsed[f],T=c.extensionsRequired||[];switch(h){case Ae.KHR_MATERIALS_UNLIT:o[h]=new Er;break;case Ae.KHR_DRACO_MESH_COMPRESSION:o[h]=new Fr(c,this.dracoLoader);break;case Ae.KHR_TEXTURE_TRANSFORM:o[h]=new Ur;break;case Ae.KHR_MESH_QUANTIZATION:o[h]=new Br;break;default:T.indexOf(h)>=0&&u[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}s.setExtensions(o),s.setPlugins(u),s.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,c){i.parse(e,t,r,c)})}}function gr(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Ae={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 Tr{constructor(e){this.parser=e,this.name=Ae.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const c=t[i];c.extensions&&c.extensions[this.name]&&c.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,c.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const c=t.json,a=((c.extensions&&c.extensions[this.name]||{}).lights||[])[e];let s;const f=new R.Color(16777215);a.color!==void 0&&f.setRGB(a.color[0],a.color[1],a.color[2],R.LinearSRGBColorSpace);const h=a.range!==void 0?a.range:0;switch(a.type){case"directional":s=new R.DirectionalLight(f),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new R.PointLight(f),s.distance=h;break;case"spot":s=new R.SpotLight(f),s.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,s.angle=a.spot.outerConeAngle,s.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return s.position.set(0,0,0),qe(s,a),a.intensity!==void 0&&(s.intensity=a.intensity),s.name=t.createUniqueName(a.name||"light_"+e),r=Promise.resolve(s),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,c=i.json.nodes[e],u=(c.extensions&&c.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(a){return i._getNodeRef(t.cache,u,a)})}}class Er{constructor(){this.name=Ae.KHR_MATERIALS_UNLIT}getMaterialType(){return R.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new R.Color(1,1,1),e.opacity=1;const c=t.pbrMetallicRoughness;if(c){if(Array.isArray(c.baseColorFactor)){const o=c.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],R.LinearSRGBColorSpace),e.opacity=o[3]}c.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",c.baseColorTexture,R.SRGBColorSpace))}return Promise.all(r)}}class vr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=r.extensions[this.name].emissiveStrength;return c!==void 0&&(t.emissiveIntensity=c),Promise.resolve()}}class Rr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&c.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&c.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(c.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const u=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new R.Vector2(u,u)}return Promise.all(c)}}class _r{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=r.extensions[this.name];return t.dispersion=c.dispersion!==void 0?c.dispersion:0,Promise.resolve()}}class Ar{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&c.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&c.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(c)}}class br{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[];t.sheenColor=new R.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){const u=o.sheenColorFactor;t.sheenColor.setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&c.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,R.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&c.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(c)}}class Lr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&c.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(c)}}class Sr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&c.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const u=o.attenuationColor||[1,1,1];return t.attenuationColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),Promise.all(c)}}class xr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=r.extensions[this.name];return t.ior=c.ior!==void 0?c.ior:1.5,Promise.resolve()}}class Or{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&c.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const u=o.specularColorFactor||[1,1,1];return t.specularColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&c.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,R.SRGBColorSpace)),Promise.all(c)}}class Ir{constructor(e){this.parser=e,this.name=Ae.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&c.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(c)}}class Nr{constructor(e){this.parser=e,this.name=Ae.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const c=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&c.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(c)}}class wr{constructor(e){this.parser=e,this.name=Ae.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const c=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,c.source,o)}}class kr{constructor(e){this.parser=e,this.name=Ae.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,c=r.textures[e];if(!c.extensions||!c.extensions[t])return null;const o=c.extensions[t],u=r.images[o.source];let a=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(a=s)}return i.loadTextureImage(e,o.source,a)}}class Cr{constructor(e){this.parser=e,this.name=Ae.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,c=r.textures[e];if(!c.extensions||!c.extensions[t])return null;const o=c.extensions[t],u=r.images[o.source];let a=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(a=s)}return i.loadTextureImage(e,o.source,a)}}class Pr{constructor(e){this.name=Ae.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],c=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return c.then(function(u){const a=r.byteOffset||0,s=r.byteLength||0,f=r.count,h=r.byteStride,T=new Uint8Array(u,a,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,h,T,r.mode,r.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(f*h);return o.decodeGltfBuffer(new Uint8Array(p),f,h,T,r.mode,r.filter),p})})}else return null}}class Mr{constructor(e){this.name=Ae.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const s of r.primitives)if(s.mode!==Ke.TRIANGLES&&s.mode!==Ke.TRIANGLE_STRIP&&s.mode!==Ke.TRIANGLE_FAN&&s.mode!==void 0)return null;const o=i.extensions[this.name].attributes,u=[],a={};for(const s in o)u.push(this.parser.getDependency("accessor",o[s]).then(f=>(a[s]=f,a[s])));return u.length<1?null:(u.push(this.parser.createNodeMesh(e)),Promise.all(u).then(s=>{const f=s.pop(),h=f.isGroup?f.children:[f],T=s[0].count,p=[];for(const g of h){const y=new R.Matrix4,l=new R.Vector3,d=new R.Quaternion,m=new R.Vector3(1,1,1),v=new R.InstancedMesh(g.geometry,g.material,T);for(let E=0;E<T;E++)a.TRANSLATION&&l.fromBufferAttribute(a.TRANSLATION,E),a.ROTATION&&d.fromBufferAttribute(a.ROTATION,E),a.SCALE&&m.fromBufferAttribute(a.SCALE,E),v.setMatrixAt(E,y.compose(l,d,m));for(const E in a)if(E==="_COLOR_0"){const S=a[E];v.instanceColor=new R.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&g.geometry.setAttribute(E,a[E]);R.Object3D.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),p.push(v)}return f.isGroup?(f.clear(),f.add(...p),f):p[0]}))}}const dn="glTF",it=12,Yt={JSON:1313821514,BIN:5130562};class Dr{constructor(e){this.name=Ae.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,it),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==dn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-it,c=new DataView(e,it);let o=0;for(;o<r;){const u=c.getUint32(o,!0);o+=4;const a=c.getUint32(o,!0);if(o+=4,a===Yt.JSON){const s=new Uint8Array(e,it+o,u);this.content=i.decode(s)}else if(a===Yt.BIN){const s=it+o;this.body=e.slice(s,s+u)}o+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Fr{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ae.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,c=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,u={},a={},s={};for(const f in o){const h=Nt[f]||f.toLowerCase();u[h]=o[f]}for(const f in e.attributes){const h=Nt[f]||f.toLowerCase();if(o[f]!==void 0){const T=i.accessors[e.attributes[f]],p=rt[T.componentType];s[h]=p.name,a[h]=T.normalized===!0}}return t.getDependency("bufferView",c).then(function(f){return new Promise(function(h,T){r.decodeDracoFile(f,function(p){for(const g in p.attributes){const y=p.attributes[g],l=a[g];l!==void 0&&(y.normalized=l)}h(p)},u,s,R.LinearSRGBColorSpace,T)})})}}class Ur{constructor(){this.name=Ae.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Br{constructor(){this.name=Ae.KHR_MESH_QUANTIZATION}}class pn extends R.Interpolant{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,c=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[c+o];return t}interpolate_(e,t,i,r){const c=this.resultBuffer,o=this.sampleValues,u=this.valueSize,a=u*2,s=u*3,f=r-t,h=(i-t)/f,T=h*h,p=T*h,g=e*s,y=g-s,l=-2*p+3*T,d=p-T,m=1-l,v=d-T+h;for(let E=0;E!==u;E++){const S=o[y+E+u],N=o[y+E+a]*f,C=o[g+E+u],Y=o[g+E]*f;c[E]=m*S+v*N+l*C+d*Y}return c}}const jr=new R.Quaternion;class Gr extends pn{interpolate_(e,t,i,r){const c=super.interpolate_(e,t,i,r);return jr.fromArray(c).normalize().toArray(c),c}}const Ke={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},rt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Xt={9728:R.NearestFilter,9729:R.LinearFilter,9984:R.NearestMipmapNearestFilter,9985:R.LinearMipmapNearestFilter,9986:R.NearestMipmapLinearFilter,9987:R.LinearMipmapLinearFilter},qt={33071:R.ClampToEdgeWrapping,33648:R.MirroredRepeatWrapping,10497:R.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Nt={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"},Je={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zr={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete},At={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Vr(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new R.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:R.FrontSide})),n.DefaultMaterial}function et(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function qe(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Hr(n,e,t){let i=!1,r=!1,c=!1;for(let s=0,f=e.length;s<f;s++){const h=e[s];if(h.POSITION!==void 0&&(i=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(c=!0),i&&r&&c)break}if(!i&&!r&&!c)return Promise.resolve(n);const o=[],u=[],a=[];for(let s=0,f=e.length;s<f;s++){const h=e[s];if(i){const T=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;o.push(T)}if(r){const T=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;u.push(T)}if(c){const T=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;a.push(T)}}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(a)]).then(function(s){const f=s[0],h=s[1],T=s[2];return i&&(n.morphAttributes.position=f),r&&(n.morphAttributes.normal=h),c&&(n.morphAttributes.color=T),n.morphTargetsRelative=!0,n})}function Wr(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Kr(n){let e;const t=n.extensions&&n.extensions[Ae.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+bt(t.attributes):e=n.indices+":"+bt(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+bt(n.targets[i]);return e}function bt(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function wt(n){switch(n){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 Yr(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Xr=new R.Matrix4;class qr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gr,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 i=!1,r=-1,c=!1,o=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const a=u.match(/Version\/(\d+)/);r=i&&a?parseInt(a[1],10):-1,c=u.indexOf("Firefox")>-1,o=c?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||c&&o<98?this.textureLoader=new R.TextureLoader(this.options.manager):this.textureLoader=new R.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new R.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,c=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const u={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return et(c,u,r),qe(u,r),Promise.all(i._invokeAll(function(a){return a.afterRoot&&a.afterRoot(u)})).then(function(){for(const a of u.scenes)a.updateMatrixWorld();e(u)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,c=t.length;r<c;r++){const o=t[r].joints;for(let u=0,a=o.length;u<a;u++)e[o[u]].isBone=!0}for(let r=0,c=e.length;r<c;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),c=(o,u)=>{const a=this.associations.get(o);a!=null&&this.associations.set(u,a);for(const[s,f]of o.children.entries())c(f,u.children[s])};return c(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const c=e(t[r]);c&&i.push(c)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(c){return c.loadNode&&c.loadNode(t)});break;case"mesh":r=this._invokeOne(function(c){return c.loadMesh&&c.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(c){return c.loadBufferView&&c.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(c){return c.loadMaterial&&c.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(c){return c.loadTexture&&c.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(c){return c.loadAnimation&&c.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(c){return c!=this&&c.getDependency&&c.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(c,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ae.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(c,o){i.load(R.LoaderUtils.resolveURL(t.uri,r.path),c,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const r=t.byteLength||0,c=t.byteOffset||0;return i.slice(c,c+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=_t[r.type],u=rt[r.componentType],a=r.normalized===!0,s=new u(r.count*o);return Promise.resolve(new R.BufferAttribute(s,o,a))}const c=[];return r.bufferView!==void 0?c.push(this.getDependency("bufferView",r.bufferView)):c.push(null),r.sparse!==void 0&&(c.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),c.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(c).then(function(o){const u=o[0],a=_t[r.type],s=rt[r.componentType],f=s.BYTES_PER_ELEMENT,h=f*a,T=r.byteOffset||0,p=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0;let y,l;if(p&&p!==h){const d=Math.floor(T/p),m="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+d+":"+r.count;let v=t.cache.get(m);v||(y=new s(u,d*p,r.count*p/f),v=new R.InterleavedBuffer(y,p/f),t.cache.add(m,v)),l=new R.InterleavedBufferAttribute(v,a,T%p/f,g)}else u===null?y=new s(r.count*a):y=new s(u,T,r.count*a),l=new R.BufferAttribute(y,a,g);if(r.sparse!==void 0){const d=_t.SCALAR,m=rt[r.sparse.indices.componentType],v=r.sparse.indices.byteOffset||0,E=r.sparse.values.byteOffset||0,S=new m(o[1],v,r.sparse.count*d),N=new s(o[2],E,r.sparse.count*a);u!==null&&(l=new R.BufferAttribute(l.array.slice(),l.itemSize,l.normalized)),l.normalized=!1;for(let C=0,Y=S.length;C<Y;C++){const O=S[C];if(l.setX(O,N[C*a]),a>=2&&l.setY(O,N[C*a+1]),a>=3&&l.setZ(O,N[C*a+2]),a>=4&&l.setW(O,N[C*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}l.normalized=g}return l})}loadTexture(e){const t=this.json,i=this.options,c=t.textures[e].source,o=t.images[c];let u=this.textureLoader;if(o.uri){const a=i.manager.getHandler(o.uri);a!==null&&(u=a)}return this.loadTextureImage(e,c,u)}loadTextureImage(e,t,i){const r=this,c=this.json,o=c.textures[e],u=c.images[t],a=(u.uri||u.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const s=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=o.name||u.name||"",f.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(f.name=u.uri);const T=(c.samplers||{})[o.sampler]||{};return f.magFilter=Xt[T.magFilter]||R.LinearFilter,f.minFilter=Xt[T.minFilter]||R.LinearMipmapLinearFilter,f.wrapS=qt[T.wrapS]||R.RepeatWrapping,f.wrapT=qt[T.wrapT]||R.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==R.NearestFilter&&f.minFilter!==R.LinearFilter,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[a]=s,s}loadImageSource(e,t){const i=this,r=this.json,c=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=r.images[e],u=self.URL||self.webkitURL;let a=o.uri||"",s=!1;if(o.bufferView!==void 0)a=i.getDependency("bufferView",o.bufferView).then(function(h){s=!0;const T=new Blob([h],{type:o.mimeType});return a=u.createObjectURL(T),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(a).then(function(h){return new Promise(function(T,p){let g=T;t.isImageBitmapLoader===!0&&(g=function(y){const l=new R.Texture(y);l.needsUpdate=!0,T(l)}),t.load(R.LoaderUtils.resolveURL(h,c.path),g,void 0,p)})}).then(function(h){return s===!0&&u.revokeObjectURL(a),qe(h,o),h.userData.mimeType=o.mimeType||Yr(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),h});return this.sourceCache[e]=f,f}assignTexture(e,t,i,r){const c=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),c.extensions[Ae.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[Ae.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const a=c.associations.get(o);o=c.extensions[Ae.KHR_TEXTURE_TRANSFORM].extendTexture(o,u),c.associations.set(o,a)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,c=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const u="PointsMaterial:"+i.uuid;let a=this.cache.get(u);a||(a=new R.PointsMaterial,R.Material.prototype.copy.call(a,i),a.color.copy(i.color),a.map=i.map,a.sizeAttenuation=!1,this.cache.add(u,a)),i=a}else if(e.isLine){const u="LineBasicMaterial:"+i.uuid;let a=this.cache.get(u);a||(a=new R.LineBasicMaterial,R.Material.prototype.copy.call(a,i),a.color.copy(i.color),a.map=i.map,this.cache.add(u,a)),i=a}if(r||c||o){let u="ClonedMaterial:"+i.uuid+":";r&&(u+="derivative-tangents:"),c&&(u+="vertex-colors:"),o&&(u+="flat-shading:");let a=this.cache.get(u);a||(a=i.clone(),c&&(a.vertexColors=!0),o&&(a.flatShading=!0),r&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(u,a),this.associations.set(a,this.associations.get(i))),i=a}e.material=i}getMaterialType(){return R.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,r=this.extensions,c=i.materials[e];let o;const u={},a=c.extensions||{},s=[];if(a[Ae.KHR_MATERIALS_UNLIT]){const h=r[Ae.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),s.push(h.extendParams(u,c,t))}else{const h=c.pbrMetallicRoughness||{};if(u.color=new R.Color(1,1,1),u.opacity=1,Array.isArray(h.baseColorFactor)){const T=h.baseColorFactor;u.color.setRGB(T[0],T[1],T[2],R.LinearSRGBColorSpace),u.opacity=T[3]}h.baseColorTexture!==void 0&&s.push(t.assignTexture(u,"map",h.baseColorTexture,R.SRGBColorSpace)),u.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,u.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(s.push(t.assignTexture(u,"metalnessMap",h.metallicRoughnessTexture)),s.push(t.assignTexture(u,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(T){return T.getMaterialType&&T.getMaterialType(e)}),s.push(Promise.all(this._invokeAll(function(T){return T.extendMaterialParams&&T.extendMaterialParams(e,u)})))}c.doubleSided===!0&&(u.side=R.DoubleSide);const f=c.alphaMode||At.OPAQUE;if(f===At.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,f===At.MASK&&(u.alphaTest=c.alphaCutoff!==void 0?c.alphaCutoff:.5)),c.normalTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"normalMap",c.normalTexture)),u.normalScale=new R.Vector2(1,1),c.normalTexture.scale!==void 0)){const h=c.normalTexture.scale;u.normalScale.set(h,h)}if(c.occlusionTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"aoMap",c.occlusionTexture)),c.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=c.occlusionTexture.strength)),c.emissiveFactor!==void 0&&o!==R.MeshBasicMaterial){const h=c.emissiveFactor;u.emissive=new R.Color().setRGB(h[0],h[1],h[2],R.LinearSRGBColorSpace)}return c.emissiveTexture!==void 0&&o!==R.MeshBasicMaterial&&s.push(t.assignTexture(u,"emissiveMap",c.emissiveTexture,R.SRGBColorSpace)),Promise.all(s).then(function(){const h=new o(u);return c.name&&(h.name=c.name),qe(h,c),t.associations.set(h,{materials:e}),c.extensions&&et(r,h,c),h})}createUniqueName(e){const t=R.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function c(u){return i[Ae.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,t).then(function(a){return Qt(a,u,t)})}const o=[];for(let u=0,a=e.length;u<a;u++){const s=e[u],f=Kr(s),h=r[f];if(h)o.push(h.promise);else{let T;s.extensions&&s.extensions[Ae.KHR_DRACO_MESH_COMPRESSION]?T=c(s):T=Qt(new R.BufferGeometry,s,t),r[f]={primitive:s,promise:T},o.push(T)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,r=this.extensions,c=i.meshes[e],o=c.primitives,u=[];for(let a=0,s=o.length;a<s;a++){const f=o[a].material===void 0?Vr(this.cache):this.getDependency("material",o[a].material);u.push(f)}return u.push(t.loadGeometries(o)),Promise.all(u).then(function(a){const s=a.slice(0,a.length-1),f=a[a.length-1],h=[];for(let p=0,g=f.length;p<g;p++){const y=f[p],l=o[p];let d;const m=s[p];if(l.mode===Ke.TRIANGLES||l.mode===Ke.TRIANGLE_STRIP||l.mode===Ke.TRIANGLE_FAN||l.mode===void 0)d=c.isSkinnedMesh===!0?new R.SkinnedMesh(y,m):new R.Mesh(y,m),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),l.mode===Ke.TRIANGLE_STRIP?d.geometry=Kt(d.geometry,R.TriangleStripDrawMode):l.mode===Ke.TRIANGLE_FAN&&(d.geometry=Kt(d.geometry,R.TriangleFanDrawMode));else if(l.mode===Ke.LINES)d=new R.LineSegments(y,m);else if(l.mode===Ke.LINE_STRIP)d=new R.Line(y,m);else if(l.mode===Ke.LINE_LOOP)d=new R.LineLoop(y,m);else if(l.mode===Ke.POINTS)d=new R.Points(y,m);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);Object.keys(d.geometry.morphAttributes).length>0&&Wr(d,c),d.name=t.createUniqueName(c.name||"mesh_"+e),qe(d,c),l.extensions&&et(r,d,l),t.assignFinalMaterial(d),h.push(d)}for(let p=0,g=h.length;p<g;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return c.extensions&&et(r,h[0],c),h[0];const T=new R.Group;c.extensions&&et(r,T,c),t.associations.set(T,{meshes:e});for(let p=0,g=h.length;p<g;p++)T.add(h[p]);return T})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new R.PerspectiveCamera(R.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new R.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),qe(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,c=t.joints.length;r<c;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const c=r.pop(),o=r,u=[],a=[];for(let s=0,f=o.length;s<f;s++){const h=o[s];if(h){u.push(h);const T=new R.Matrix4;c!==null&&T.fromArray(c.array,s*16),a.push(T)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new R.Skeleton(u,a)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],c=r.name?r.name:"animation_"+e,o=[],u=[],a=[],s=[],f=[];for(let h=0,T=r.channels.length;h<T;h++){const p=r.channels[h],g=r.samplers[p.sampler],y=p.target,l=y.node,d=r.parameters!==void 0?r.parameters[g.input]:g.input,m=r.parameters!==void 0?r.parameters[g.output]:g.output;y.node!==void 0&&(o.push(this.getDependency("node",l)),u.push(this.getDependency("accessor",d)),a.push(this.getDependency("accessor",m)),s.push(g),f.push(y))}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(a),Promise.all(s),Promise.all(f)]).then(function(h){const T=h[0],p=h[1],g=h[2],y=h[3],l=h[4],d=[];for(let v=0,E=T.length;v<E;v++){const S=T[v],N=p[v],C=g[v],Y=y[v],O=l[v];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const j=i._createAnimationTracks(S,N,C,Y,O);if(j)for(let M=0;M<j.length;M++)d.push(j[M])}const m=new R.AnimationClip(c,void 0,d);return qe(m,r),m})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(c){const o=i._getNodeRef(i.meshCache,r.mesh,c);return r.weights!==void 0&&o.traverse(function(u){if(u.isMesh)for(let a=0,s=r.weights.length;a<s;a++)u.morphTargetInfluences[a]=r.weights[a]}),o})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],c=i._loadNodeShallow(e),o=[],u=r.children||[];for(let s=0,f=u.length;s<f;s++)o.push(i.getDependency("node",u[s]));const a=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([c,Promise.all(o),a]).then(function(s){const f=s[0],h=s[1],T=s[2];T!==null&&f.traverse(function(p){p.isSkinnedMesh&&p.bind(T,Xr)});for(let p=0,g=h.length;p<g;p++)f.add(h[p]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const c=t.nodes[e],o=c.name?r.createUniqueName(c.name):"",u=[],a=r._invokeOne(function(s){return s.createNodeMesh&&s.createNodeMesh(e)});return a&&u.push(a),c.camera!==void 0&&u.push(r.getDependency("camera",c.camera).then(function(s){return r._getNodeRef(r.cameraCache,c.camera,s)})),r._invokeAll(function(s){return s.createNodeAttachment&&s.createNodeAttachment(e)}).forEach(function(s){u.push(s)}),this.nodeCache[e]=Promise.all(u).then(function(s){let f;if(c.isBone===!0?f=new R.Bone:s.length>1?f=new R.Group:s.length===1?f=s[0]:f=new R.Object3D,f!==s[0])for(let h=0,T=s.length;h<T;h++)f.add(s[h]);if(c.name&&(f.userData.name=c.name,f.name=o),qe(f,c),c.extensions&&et(i,f,c),c.matrix!==void 0){const h=new R.Matrix4;h.fromArray(c.matrix),f.applyMatrix4(h)}else c.translation!==void 0&&f.position.fromArray(c.translation),c.rotation!==void 0&&f.quaternion.fromArray(c.rotation),c.scale!==void 0&&f.scale.fromArray(c.scale);if(!r.associations.has(f))r.associations.set(f,{});else if(c.mesh!==void 0&&r.meshCache.refs[c.mesh]>1){const h=r.associations.get(f);r.associations.set(f,{...h})}return r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,c=new R.Group;i.name&&(c.name=r.createUniqueName(i.name)),qe(c,i),i.extensions&&et(t,c,i);const o=i.nodes||[],u=[];for(let a=0,s=o.length;a<s;a++)u.push(r.getDependency("node",o[a]));return Promise.all(u).then(function(a){for(let f=0,h=a.length;f<h;f++)c.add(a[f]);const s=f=>{const h=new Map;for(const[T,p]of r.associations)(T instanceof R.Material||T instanceof R.Texture)&&h.set(T,p);return f.traverse(T=>{const p=r.associations.get(T);p!=null&&h.set(T,p)}),h};return r.associations=s(c),c})}_createAnimationTracks(e,t,i,r,c){const o=[],u=e.name?e.name:e.uuid,a=[];Je[c.path]===Je.weights?e.traverse(function(T){T.morphTargetInfluences&&a.push(T.name?T.name:T.uuid)}):a.push(u);let s;switch(Je[c.path]){case Je.weights:s=R.NumberKeyframeTrack;break;case Je.rotation:s=R.QuaternionKeyframeTrack;break;case Je.translation:case Je.scale:s=R.VectorKeyframeTrack;break;default:i.itemSize===1?s=R.NumberKeyframeTrack:s=R.VectorKeyframeTrack;break}const f=r.interpolation!==void 0?zr[r.interpolation]:R.InterpolateLinear,h=this._getArrayFromAccessor(i);for(let T=0,p=a.length;T<p;T++){const g=new s(a[T]+"."+Je[c.path],t.array,h,f);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=wt(t.constructor),r=new Float32Array(t.length);for(let c=0,o=t.length;c<o;c++)r[c]=t[c]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const r=this instanceof R.QuaternionKeyframeTrack?Gr:pn;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Qr(n,e,t){const i=e.attributes,r=new R.Box3;if(i.POSITION!==void 0){const u=t.json.accessors[i.POSITION],a=u.min,s=u.max;if(a!==void 0&&s!==void 0){if(r.set(new R.Vector3(a[0],a[1],a[2]),new R.Vector3(s[0],s[1],s[2])),u.normalized){const f=wt(rt[u.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const c=e.targets;if(c!==void 0){const u=new R.Vector3,a=new R.Vector3;for(let s=0,f=c.length;s<f;s++){const h=c[s];if(h.POSITION!==void 0){const T=t.json.accessors[h.POSITION],p=T.min,g=T.max;if(p!==void 0&&g!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),T.normalized){const y=wt(rt[T.componentType]);a.multiplyScalar(y)}u.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(u)}n.boundingBox=r;const o=new R.Sphere;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function Qt(n,e,t){const i=e.attributes,r=[];function c(o,u){return t.getDependency("accessor",o).then(function(a){n.setAttribute(u,a)})}for(const o in i){const u=Nt[o]||o.toLowerCase();u in n.attributes||r.push(c(i[o],u))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(u){n.setIndex(u)});r.push(o)}return R.ColorManagement.workingColorSpace!==R.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${R.ColorManagement.workingColorSpace}" not supported.`),qe(n,e),Qr(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Hr(n,e.targets,t):n})}const Lt=new WeakMap;class Zr extends R.Loader{constructor(e){super(e),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(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){const c=new R.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,o=>{this.parse(o,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,R.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,r,c=R.LinearSRGBColorSpace,o=()=>{}){const u={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:c};return this.decodeGeometry(e,u).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(Lt.has(e)){const a=Lt.get(e);if(a.key===i)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const c=this.workerNextTaskID++,o=e.byteLength,u=this._getWorker(c,o).then(a=>(r=a,new Promise((s,f)=>{r._callbacks[c]={resolve:s,reject:f},r.postMessage({type:"decode",id:c,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return u.catch(()=>!0).then(()=>{r&&c&&this._releaseTask(r,c)}),Lt.set(e,{key:i,promise:u}),u}_createGeometry(e){const t=new R.BufferGeometry;e.index&&t.setIndex(new R.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:c,itemSize:o,stride:u,vertexColorSpace:a}=e.attributes[i];let s;if(o===u)s=new R.BufferAttribute(c,o);else{const f=new R.InterleavedBuffer(c,u);s=new R.InterleavedBufferAttribute(f,o,0)}r==="color"&&(this._assignVertexColorSpace(s,a),s.normalized=!(c instanceof Float32Array)),t.setAttribute(r,s)}return t}_assignVertexColorSpace(e,t){if(t!==R.SRGBColorSpace)return;const i=new R.Color;for(let r=0,c=e.count;r<c;r++)i.fromBufferAttribute(e,r),R.ColorManagement.colorSpaceToWorking(i,R.SRGBColorSpace),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new R.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,c)=>{i.load(e,r,void 0,c)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const c=Jr.toString(),o=["/* draco decoder */",r,"","/* worker */",c.substring(c.indexOf("{")+1,c.lastIndexOf("}"))].join(`
|
|
80
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(c){const o=c.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,c){return r._taskLoad>c._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Jr(){let n,e;onmessage=function(o){const u=o.data;switch(u.type){case"init":n=u.decoderConfig,e=new Promise(function(f){n.onModuleLoaded=function(h){f({draco:h})},DracoDecoderModule(n)});break;case"decode":const a=u.buffer,s=u.taskConfig;e.then(f=>{const h=f.draco,T=new h.Decoder;try{const p=t(h,T,new Int8Array(a),s),g=p.attributes.map(y=>y.array.buffer);p.index&&g.push(p.index.array.buffer),self.postMessage({type:"decode",id:u.id,geometry:p},g)}catch(p){console.error(p),self.postMessage({type:"error",id:u.id,error:p.message})}finally{h.destroy(T)}});break}};function t(o,u,a,s){const f=s.attributeIDs,h=s.attributeTypes;let T,p;const g=u.GetEncodedGeometryType(a);if(g===o.TRIANGULAR_MESH)T=new o.Mesh,p=u.DecodeArrayToMesh(a,a.byteLength,T);else if(g===o.POINT_CLOUD)T=new o.PointCloud,p=u.DecodeArrayToPointCloud(a,a.byteLength,T);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||T.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const l in f){const d=self[h[l]];let m,v;if(s.useUniqueIDs)v=f[l],m=u.GetAttributeByUniqueId(T,v);else{if(v=u.GetAttributeId(T,o[f[l]]),v===-1)continue;m=u.GetAttribute(T,v)}const E=r(o,u,T,l,d,m);l==="color"&&(E.vertexColorSpace=s.vertexColorSpace),y.attributes.push(E)}return g===o.TRIANGULAR_MESH&&(y.index=i(o,u,T)),o.destroy(T),y}function i(o,u,a){const f=a.num_faces()*3,h=f*4,T=o._malloc(h);u.GetTrianglesUInt32Array(a,h,T);const p=new Uint32Array(o.HEAPF32.buffer,T,f).slice();return o._free(T),{array:p,itemSize:1}}function r(o,u,a,s,f,h){const T=a.num_points(),p=h.num_components(),g=c(o,f),y=p*f.BYTES_PER_ELEMENT,l=Math.ceil(y/4)*4,d=l/f.BYTES_PER_ELEMENT,m=T*y,v=T*l,E=o._malloc(m);u.GetAttributeDataArrayForAllPoints(a,h,g,m,E);const S=new f(o.HEAPF32.buffer,E,m/f.BYTES_PER_ELEMENT);let N;if(y===l)N=S.slice();else{N=new f(v/f.BYTES_PER_ELEMENT);let C=0;for(let Y=0,O=S.length;Y<O;Y++){for(let j=0;j<p;j++)N[C+j]=S[Y*p+j];C+=d}}return o._free(E),{name:s,count:T,itemSize:p,array:N,stride:d}}function c(o,u){switch(u){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function $r(n){return"morphTargetDictionary"in n&&n.morphTargetDictionary!==void 0&&"morphTargetInfluences"in n&&Array.isArray(n.morphTargetInfluences)}const mn=new yr,yn=new Zr;yn.setDecoderPath("/examples/jsm/libs/draco/");mn.setDRACOLoader(yn);class gn extends Be{ready;model;constructor(e){super(),this.ready=this.asyncInit(e)}initObject(){return new de.Object3D}initMotion(){return new Zt(this)}async asyncInit(e){if($t(e)){const t=await mn.loadAsync(e),i=new de.AnimationMixer(t.scene),r={};console.log(`File: ${e}`),console.log(" actions:");for(let o=0;o<t.animations.length;o++){const u=t.animations[o],a=i.clipAction(u);r[u.name]=a,console.log(` ${u.name}`)}console.log(" morphs:");const c={};t.scene.traverse(o=>{if($r(o)){const{morphTargetDictionary:u,morphTargetInfluences:a}=o;Object.keys(u).forEach(s=>{const f=o.name+"."+s,h=u[s];c[f]={array:a,idx:h},console.log(` ${f}`)})}}),this.model={gltf:t,mixer:i,actions:r,morphs:c},this.model.gltf.scene.traverse(o=>{o.userData.a3js={objectA3:this}}),this.object.add(this.model.gltf.scene),this.motion instanceof Zt&&this.motion.setModel(this.model)}else{const t=new de.BoxGeometry,i=new de.MeshStandardMaterial({color:16711680}),r=new de.Mesh(t,i);this.object.add(r)}return this}morph(e,t){if(this.model&&e in this.model.morphs){const{array:i,idx:r}=this.model.morphs[e];i[r]=t}}}class Zt extends lt{model;isPaused;constructor(e){super(e),this.isPaused=!1}setModel(e){this.model=e}setObject(e){e instanceof gn?(super.setObject(e),this.model=e.model):console.warn("GLTFMotion can set only GLTFA3 object.")}update(e){super.update(e),!this.isPaused&&this.model&&this.model.mixer.update(e)}changeMotion(e){this.model?.mixer.stopAllAction();const t=this.model?.actions[e];t&&t.play()}setPause(e){this.isPaused=e}setTime(e){this.model?.mixer.setTime(e)}}var ve=(n,e)=>()=>(e||(e={exports:{}},n(e.exports,e)),e.exports),Tn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.VERSION=void 0,n.VERSION="9.0.1"}),Oe=ve((n,e)=>{var t=n&&n.__spreadArray||function(F,K){for(var z=0,ee=K.length,fe=F.length;z<ee;z++,fe++)F[fe]=K[z];return F};Object.defineProperty(n,"__esModule",{value:!0}),n.toFastProperties=n.timer=n.peek=n.isES2015MapSupported=n.PRINT_WARNING=n.PRINT_ERROR=n.packArray=n.IDENTITY=n.NOOP=n.merge=n.groupBy=n.defaults=n.assignNoOverwrite=n.assign=n.zipObject=n.sortBy=n.indexOf=n.some=n.difference=n.every=n.isObject=n.isRegExp=n.isArray=n.partial=n.uniq=n.compact=n.reduce=n.findAll=n.find=n.cloneObj=n.cloneArr=n.contains=n.has=n.pick=n.reject=n.filter=n.dropRight=n.drop=n.isFunction=n.isUndefined=n.isString=n.forEach=n.last=n.first=n.flatten=n.map=n.mapValues=n.values=n.keys=n.isEmpty=void 0;function i(F){return F&&F.length===0}n.isEmpty=i;function r(F){return F==null?[]:Object.keys(F)}n.keys=r;function c(F){for(var K=[],z=Object.keys(F),ee=0;ee<z.length;ee++)K.push(F[z[ee]]);return K}n.values=c;function o(F,K){for(var z=[],ee=r(F),fe=0;fe<ee.length;fe++){var be=ee[fe];z.push(K.call(null,F[be],be))}return z}n.mapValues=o;function u(F,K){for(var z=[],ee=0;ee<F.length;ee++)z.push(K.call(null,F[ee],ee));return z}n.map=u;function a(F){for(var K=[],z=0;z<F.length;z++){var ee=F[z];Array.isArray(ee)?K=K.concat(a(ee)):K.push(ee)}return K}n.flatten=a;function s(F){return i(F)?void 0:F[0]}n.first=s;function f(F){var K=F&&F.length;return K?F[K-1]:void 0}n.last=f;function h(F,K){if(Array.isArray(F))for(var z=0;z<F.length;z++)K.call(null,F[z],z);else if(Q(F))for(var ee=r(F),z=0;z<ee.length;z++){var fe=ee[z],be=F[fe];K.call(null,be,fe)}else throw Error("non exhaustive match")}n.forEach=h;function T(F){return typeof F=="string"}n.isString=T;function p(F){return F===void 0}n.isUndefined=p;function g(F){return F instanceof Function}n.isFunction=g;function y(F,K){return K===void 0&&(K=1),F.slice(K,F.length)}n.drop=y;function l(F,K){return K===void 0&&(K=1),F.slice(0,F.length-K)}n.dropRight=l;function d(F,K){var z=[];if(Array.isArray(F))for(var ee=0;ee<F.length;ee++){var fe=F[ee];K.call(null,fe)&&z.push(fe)}return z}n.filter=d;function m(F,K){return d(F,function(z){return!K(z)})}n.reject=m;function v(F,K){for(var z=Object.keys(F),ee={},fe=0;fe<z.length;fe++){var be=z[fe],b=F[be];K(b)&&(ee[be]=b)}return ee}n.pick=v;function E(F,K){return Q(F)?F.hasOwnProperty(K):!1}n.has=E;function S(F,K){return Y(F,function(z){return z===K})!==void 0}n.contains=S;function N(F){for(var K=[],z=0;z<F.length;z++)K.push(F[z]);return K}n.cloneArr=N;function C(F){var K={};for(var z in F)Object.prototype.hasOwnProperty.call(F,z)&&(K[z]=F[z]);return K}n.cloneObj=C;function Y(F,K){for(var z=0;z<F.length;z++){var ee=F[z];if(K.call(null,ee))return ee}}n.find=Y;function O(F,K){for(var z=[],ee=0;ee<F.length;ee++){var fe=F[ee];K.call(null,fe)&&z.push(fe)}return z}n.findAll=O;function j(F,K,z){for(var ee=Array.isArray(F),fe=ee?F:c(F),be=ee?[]:r(F),b=z,_=0;_<fe.length;_++)b=K.call(null,b,fe[_],ee?_:be[_]);return b}n.reduce=j;function M(F){return m(F,function(K){return K==null})}n.compact=M;function x(F,K){K===void 0&&(K=function(ee){return ee});var z=[];return j(F,function(ee,fe){var be=K(fe);return S(z,be)?ee:(z.push(be),ee.concat(fe))},[])}n.uniq=x;function P(F){for(var K=[],z=1;z<arguments.length;z++)K[z-1]=arguments[z];var ee=[null],fe=ee.concat(K);return Function.bind.apply(F,fe)}n.partial=P;function k(F){return Array.isArray(F)}n.isArray=k;function X(F){return F instanceof RegExp}n.isRegExp=X;function Q(F){return F instanceof Object}n.isObject=Q;function H(F,K){for(var z=0;z<F.length;z++)if(!K(F[z],z))return!1;return!0}n.every=H;function $(F,K){return m(F,function(z){return S(K,z)})}n.difference=$;function te(F,K){for(var z=0;z<F.length;z++)if(K(F[z]))return!0;return!1}n.some=te;function ae(F,K){for(var z=0;z<F.length;z++)if(F[z]===K)return z;return-1}n.indexOf=ae;function se(F,K){var z=N(F);return z.sort(function(ee,fe){return K(ee)-K(fe)}),z}n.sortBy=se;function ce(F,K){if(F.length!==K.length)throw Error("can't zipObject with different number of keys and values!");for(var z={},ee=0;ee<F.length;ee++)z[F[ee]]=K[ee];return z}n.zipObject=ce;function ne(F){for(var K=[],z=1;z<arguments.length;z++)K[z-1]=arguments[z];for(var ee=0;ee<K.length;ee++)for(var fe=K[ee],be=r(fe),b=0;b<be.length;b++){var _=be[b];F[_]=fe[_]}return F}n.assign=ne;function pe(F){for(var K=[],z=1;z<arguments.length;z++)K[z-1]=arguments[z];for(var ee=0;ee<K.length;ee++)for(var fe=K[ee],be=r(fe),b=0;b<be.length;b++){var _=be[b];E(F,_)||(F[_]=fe[_])}return F}n.assignNoOverwrite=pe;function U(){for(var F=[],K=0;K<arguments.length;K++)F[K]=arguments[K];return pe.apply(void 0,t([{}],F))}n.defaults=U;function G(F,K){var z={};return h(F,function(ee){var fe=K(ee),be=z[fe];be?be.push(ee):z[fe]=[ee]}),z}n.groupBy=G;function W(F,K){for(var z=C(F),ee=r(K),fe=0;fe<ee.length;fe++){var be=ee[fe],b=K[be];z[be]=b}return z}n.merge=W;function q(){}n.NOOP=q;function Z(F){return F}n.IDENTITY=Z;function ie(F){for(var K=[],z=0;z<F.length;z++){var ee=F[z];K.push(ee!==void 0?ee:void 0)}return K}n.packArray=ie;function Te(F){console&&console.error&&console.error("Error: "+F)}n.PRINT_ERROR=Te;function ye(F){console&&console.warn&&console.warn("Warning: "+F)}n.PRINT_WARNING=ye;function we(){return typeof Map=="function"}n.isES2015MapSupported=we;function je(F){return F[F.length-1]}n.peek=je;function We(F){var K=new Date().getTime(),z=F(),ee=new Date().getTime(),fe=ee-K;return{time:fe,value:z}}n.timer=We;function Ue(F){function K(){}K.prototype=F;var z=new K;function ee(){return typeof z.bar}return ee(),ee(),F}n.toFastProperties=Ue}),Mt=ve((n,e)=>{(function(t,i){typeof define=="function"&&define.amd?define([],i):typeof e=="object"&&e.exports?e.exports=i():t.regexpToAst=i()})(typeof self<"u"?self:n,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(l){this.idx=l.idx,this.input=l.input,this.groupIdx=l.groupIdx},t.prototype.pattern=function(l){this.idx=0,this.input=l,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var m={type:"Flags",loc:{begin:this.idx,end:l.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":a(m,"global");break;case"i":a(m,"ignoreCase");break;case"m":a(m,"multiLine");break;case"u":a(m,"unicode");break;case"y":a(m,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:m,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var l=[],d=this.idx;for(l.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),l.push(this.alternative());return{type:"Disjunction",value:l,loc:this.loc(d)}},t.prototype.alternative=function(){for(var l=[],d=this.idx;this.isTerm();)l.push(this.term());return{type:"Alternative",value:l,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var l=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(l)};case"$":return{type:"EndAnchor",loc:this.loc(l)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(l)};case"B":return{type:"NonWordBoundary",loc:this.loc(l)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}s(d);var m=this.disjunction();return this.consumeChar(")"),{type:d,value:m,loc:this.loc(l)}}f()},t.prototype.quantifier=function(l){var d,m=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var v=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:v,atMost:v};break;case",":var E;this.isDigit()?(E=this.integerIncludingZero(),d={atLeast:v,atMost:E}):d={atLeast:v,atMost:1/0},this.consumeChar("}");break}if(l===!0&&d===void 0)return;s(d);break}if(!(l===!0&&d===void 0))return s(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(m),d},t.prototype.atom=function(){var l,d=this.idx;switch(this.peekChar()){case".":l=this.dotAll();break;case"\\":l=this.atomEscape();break;case"[":l=this.characterClass();break;case"(":l=this.group();break}return l===void 0&&this.isPatternCharacter()&&(l=this.patternCharacter()),s(l),l.loc=this.loc(d),this.isQuantifier()&&(l.quantifier=this.quantifier()),l},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
|
|
81
|
+
`),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var l=this.positiveInteger();return{type:"GroupBackReference",value:l}},t.prototype.characterClassEscape=function(){var l,d=!1;switch(this.popChar()){case"d":l=T;break;case"D":l=T,d=!0;break;case"s":l=g;break;case"S":l=g,d=!0;break;case"w":l=p;break;case"W":l=p,d=!0;break}return s(l),{type:"Set",value:l,complement:d}},t.prototype.controlEscapeAtom=function(){var l;switch(this.popChar()){case"f":l=o("\f");break;case"n":l=o(`
|
|
82
|
+
`);break;case"r":l=o("\r");break;case"t":l=o(" ");break;case"v":l=o("\v");break}return s(l),{type:"Character",value:l}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var l=this.popChar();if(/[a-zA-Z]/.test(l)===!1)throw Error("Invalid ");var d=l.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:d}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var l=this.popChar();return{type:"Character",value:o(l)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
|
|
83
|
+
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var l=this.popChar();return{type:"Character",value:o(l)}}},t.prototype.characterClass=function(){var l=[],d=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),d=!0);this.isClassAtom();){var m=this.classAtom(),v=m.type==="Character";if(v&&this.isRangeDash()){this.consumeChar("-");var E=this.classAtom(),S=E.type==="Character";if(S){if(E.value<m.value)throw Error("Range out of order in character class");l.push({from:m.value,to:E.value})}else u(m.value,l),l.push(o("-")),u(E.value,l)}else u(m.value,l)}return this.consumeChar("]"),{type:"Set",complement:d,value:l}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
|
|
84
|
+
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var l=!0;(this.consumeChar("("),this.peekChar(0))==="?"?(this.consumeChar("?"),this.consumeChar(":"),l=!1):this.groupIdx++;var d=this.disjunction();this.consumeChar(")");var m={type:"Group",capturing:l,value:d};return l&&(m.idx=this.groupIdx),m},t.prototype.positiveInteger=function(){var l=this.popChar();if(c.test(l)===!1)throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)l+=this.popChar();return parseInt(l,10)},t.prototype.integerIncludingZero=function(){var l=this.popChar();if(r.test(l)===!1)throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)l+=this.popChar();return parseInt(l,10)},t.prototype.patternCharacter=function(){var l=this.popChar();switch(l){case`
|
|
85
|
+
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(l)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return this.peekChar()==="-"&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(l){switch(l===void 0&&(l=0),this.peekChar(l)){case"]":case`
|
|
86
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}},t.prototype.isQuantifier=function(){var l=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(l)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
87
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(l){for(var d="",m=0;m<l;m++){var v=this.popChar();if(i.test(v)===!1)throw Error("Expecting a HexDecimal digits");d+=v}var E=parseInt(d,16);return{type:"Character",value:E}},t.prototype.peekChar=function(l){return l===void 0&&(l=0),this.input[this.idx+l]},t.prototype.popChar=function(){var l=this.peekChar(0);return this.consumeChar(),l},t.prototype.consumeChar=function(l){if(l!==void 0&&this.input[this.idx]!==l)throw Error("Expected: '"+l+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(l){return{begin:l,end:this.idx}};var i=/[0-9a-fA-F]/,r=/[0-9]/,c=/[1-9]/;function o(l){return l.charCodeAt(0)}function u(l,d){l.length!==void 0?l.forEach(function(m){d.push(m)}):d.push(l)}function a(l,d){if(l[d]===!0)throw"duplicate flag "+d;l[d]=!0}function s(l){if(l===void 0)throw Error("Internal Error - Should never get here!")}function f(){throw Error("Internal Error - Should never get here!")}var h,T=[];for(h=o("0");h<=o("9");h++)T.push(h);var p=[o("_")].concat(T);for(h=o("a");h<=o("z");h++)p.push(h);for(h=o("A");h<=o("Z");h++)p.push(h);var g=[o(" "),o("\f"),o(`
|
|
88
|
+
`),o("\r"),o(" "),o("\v"),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o("\u2028"),o("\u2029"),o(" "),o(" "),o(" "),o("\uFEFF")];function y(){}return y.prototype.visitChildren=function(l){for(var d in l){var m=l[d];l.hasOwnProperty(d)&&(m.type!==void 0?this.visit(m):Array.isArray(m)&&m.forEach(function(v){this.visit(v)},this))}},y.prototype.visit=function(l){switch(l.type){case"Pattern":this.visitPattern(l);break;case"Flags":this.visitFlags(l);break;case"Disjunction":this.visitDisjunction(l);break;case"Alternative":this.visitAlternative(l);break;case"StartAnchor":this.visitStartAnchor(l);break;case"EndAnchor":this.visitEndAnchor(l);break;case"WordBoundary":this.visitWordBoundary(l);break;case"NonWordBoundary":this.visitNonWordBoundary(l);break;case"Lookahead":this.visitLookahead(l);break;case"NegativeLookahead":this.visitNegativeLookahead(l);break;case"Character":this.visitCharacter(l);break;case"Set":this.visitSet(l);break;case"Group":this.visitGroup(l);break;case"GroupBackReference":this.visitGroupBackReference(l);break;case"Quantifier":this.visitQuantifier(l);break}this.visitChildren(l)},y.prototype.visitPattern=function(l){},y.prototype.visitFlags=function(l){},y.prototype.visitDisjunction=function(l){},y.prototype.visitAlternative=function(l){},y.prototype.visitStartAnchor=function(l){},y.prototype.visitEndAnchor=function(l){},y.prototype.visitWordBoundary=function(l){},y.prototype.visitNonWordBoundary=function(l){},y.prototype.visitLookahead=function(l){},y.prototype.visitNegativeLookahead=function(l){},y.prototype.visitCharacter=function(l){},y.prototype.visitSet=function(l){},y.prototype.visitGroup=function(l){},y.prototype.visitGroupBackReference=function(l){},y.prototype.visitQuantifier=function(l){},{RegExpParser:t,BaseRegExpVisitor:y,VERSION:"0.5.0"}})}),Dt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clearRegExpParserCache=n.getRegExpAst=void 0;var e=Mt(),t={},i=new e.RegExpParser;function r(o){var u=o.toString();if(t.hasOwnProperty(u))return t[u];var a=i.pattern(u);return t[u]=a,a}n.getRegExpAst=r;function c(){t={}}n.clearRegExpParserCache=c}),ei=ve(n=>{var e=n&&n.__extends||(function(){var y=function(l,d){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,v){m.__proto__=v}||function(m,v){for(var E in v)Object.prototype.hasOwnProperty.call(v,E)&&(m[E]=v[E])},y(l,d)};return function(l,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");y(l,d);function m(){this.constructor=l}l.prototype=d===null?Object.create(d):(m.prototype=d.prototype,new m)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.canMatchCharCode=n.firstCharOptimizedIndices=n.getOptimizedStartCodesIndices=n.failedOptimizationPrefixMsg=void 0;var t=Mt(),i=Oe(),r=Dt(),c=En(),o="Complement Sets are not supported for first char optimization";n.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
|
|
89
|
+
`;function u(y,l){l===void 0&&(l=!1);try{var d=r.getRegExpAst(y),m=a(d.value,{},d.flags.ignoreCase);return m}catch(E){if(E.message===o)l&&i.PRINT_WARNING(""+n.failedOptimizationPrefixMsg+(" Unable to optimize: < "+y.toString()+` >
|
|
90
90
|
`)+` Complement Sets cannot be automatically optimized.
|
|
91
91
|
This will disable the lexer's first char optimizations.
|
|
92
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var v="";
|
|
92
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var v="";l&&(v=`
|
|
93
93
|
This will disable the lexer's first char optimizations.
|
|
94
94
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),i.PRINT_ERROR(n.failedOptimizationPrefixMsg+`
|
|
95
|
-
`+(" Failed parsing: < "+
|
|
95
|
+
`+(" Failed parsing: < "+y.toString()+` >
|
|
96
96
|
`)+(" Using the regexp-to-ast library version: "+t.VERSION+`
|
|
97
|
-
`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+v)}}return[]}n.getOptimizedStartCodesIndices=
|
|
98
|
-
`],tracer:function(
|
|
97
|
+
`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+v)}}return[]}n.getOptimizedStartCodesIndices=u;function a(y,l,d){switch(y.type){case"Disjunction":for(var m=0;m<y.value.length;m++)a(y.value[m],l,d);break;case"Alternative":for(var v=y.value,m=0;m<v.length;m++){var E=v[m];switch(E.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var S=E;switch(S.type){case"Character":s(S.value,l,d);break;case"Set":if(S.complement===!0)throw Error(o);i.forEach(S.value,function(Y){if(typeof Y=="number")s(Y,l,d);else{var O=Y;if(d===!0)for(var j=O.from;j<=O.to;j++)s(j,l,d);else{for(var j=O.from;j<=O.to&&j<c.minOptimizationVal;j++)s(j,l,d);if(O.to>=c.minOptimizationVal)for(var M=O.from>=c.minOptimizationVal?O.from:c.minOptimizationVal,x=O.to,P=c.charCodeToOptimizedIndex(M),k=c.charCodeToOptimizedIndex(x),X=P;X<=k;X++)l[X]=X}}});break;case"Group":a(S.value,l,d);break;default:throw Error("Non Exhaustive Match")}var N=S.quantifier!==void 0&&S.quantifier.atLeast===0;if(S.type==="Group"&&T(S)===!1||S.type!=="Group"&&N===!1)break}break;default:throw Error("non exhaustive match!")}return i.values(l)}n.firstCharOptimizedIndices=a;function s(y,l,d){var m=c.charCodeToOptimizedIndex(y);l[m]=m,d===!0&&f(y,l)}function f(y,l){var d=String.fromCharCode(y),m=d.toUpperCase();if(m!==d){var v=c.charCodeToOptimizedIndex(m.charCodeAt(0));l[v]=v}else{var E=d.toLowerCase();if(E!==d){var v=c.charCodeToOptimizedIndex(E.charCodeAt(0));l[v]=v}}}function h(y,l){return i.find(y.value,function(d){if(typeof d=="number")return i.contains(l,d);var m=d;return i.find(l,function(v){return m.from<=v&&v<=m.to})!==void 0})}function T(y){return y.quantifier&&y.quantifier.atLeast===0?!0:y.value?i.isArray(y.value)?i.every(y.value,T):T(y.value):!1}var p=(function(y){e(l,y);function l(d){var m=y.call(this)||this;return m.targetCharCodes=d,m.found=!1,m}return l.prototype.visitChildren=function(d){if(this.found!==!0){switch(d.type){case"Lookahead":this.visitLookahead(d);return;case"NegativeLookahead":this.visitNegativeLookahead(d);return}y.prototype.visitChildren.call(this,d)}},l.prototype.visitCharacter=function(d){i.contains(this.targetCharCodes,d.value)&&(this.found=!0)},l.prototype.visitSet=function(d){d.complement?h(d,this.targetCharCodes)===void 0&&(this.found=!0):h(d,this.targetCharCodes)!==void 0&&(this.found=!0)},l})(t.BaseRegExpVisitor);function g(y,l){if(l instanceof RegExp){var d=r.getRegExpAst(l),m=new p(y);return m.visit(d),m.found}else return i.find(l,function(v){return i.contains(y,v.charCodeAt(0))})!==void 0}n.canMatchCharCode=g}),En=ve(n=>{var e=n&&n.__extends||(function(){var U=function(G,W){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(q,Z){q.__proto__=Z}||function(q,Z){for(var ie in Z)Object.prototype.hasOwnProperty.call(Z,ie)&&(q[ie]=Z[ie])},U(G,W)};return function(G,W){if(typeof W!="function"&&W!==null)throw new TypeError("Class extends value "+String(W)+" is not a constructor or null");U(G,W);function q(){this.constructor=G}G.prototype=W===null?Object.create(W):(q.prototype=W.prototype,new q)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.charCodeToOptimizedIndex=n.minOptimizationVal=n.buildLineBreakIssueMessage=n.LineTerminatorOptimizedTester=n.isShortPattern=n.isCustomPattern=n.cloneEmptyGroups=n.performWarningRuntimeChecks=n.performRuntimeChecks=n.addStickyFlag=n.addStartOfInput=n.findUnreachablePatterns=n.findModesThatDoNotExist=n.findInvalidGroupType=n.findDuplicatePatterns=n.findUnsupportedFlags=n.findStartOfInputAnchor=n.findEmptyMatchRegExps=n.findEndOfInputAnchor=n.findInvalidPatterns=n.findMissingPatterns=n.validatePatterns=n.analyzeTokenTypes=n.enableSticky=n.disableSticky=n.SUPPORT_STICKY=n.MODES=n.DEFAULT_MODE=void 0;var t=Mt(),i=yt(),r=Oe(),c=ei(),o=Dt(),u="PATTERN";n.DEFAULT_MODE="defaultMode",n.MODES="modes",n.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function a(){n.SUPPORT_STICKY=!1}n.disableSticky=a;function s(){n.SUPPORT_STICKY=!0}n.enableSticky=s;function f(U,G){G=r.defaults(G,{useSticky:n.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
98
|
+
`],tracer:function(b,_){return _()}});var W=G.tracer;W("initCharCodeToOptimizedIndexMap",function(){pe()});var q;W("Reject Lexer.NA",function(){q=r.reject(U,function(b){return b[u]===i.Lexer.NA})});var Z=!1,ie;W("Transform Patterns",function(){Z=!1,ie=r.map(q,function(b){var _=b[u];if(r.isRegExp(_)){var A=_.source;return A.length===1&&A!=="^"&&A!=="$"&&A!=="."&&!_.ignoreCase?A:A.length===2&&A[0]==="\\"&&!r.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],A[1])?A[1]:G.useSticky?x(_):M(_)}else{if(r.isFunction(_))return Z=!0,{exec:_};if(r.has(_,"exec"))return Z=!0,_;if(typeof _=="string"){if(_.length===1)return _;var I=_.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(I);return G.useSticky?x(L):M(L)}else throw Error("non exhaustive match")}})});var Te,ye,we,je,We;W("misc mapping",function(){Te=r.map(q,function(b){return b.tokenTypeIdx}),ye=r.map(q,function(b){var _=b.GROUP;if(_!==i.Lexer.SKIPPED){if(r.isString(_))return _;if(r.isUndefined(_))return!1;throw Error("non exhaustive match")}}),we=r.map(q,function(b){var _=b.LONGER_ALT;if(_){var A=r.indexOf(q,_);return A}}),je=r.map(q,function(b){return b.PUSH_MODE}),We=r.map(q,function(b){return r.has(b,"POP_MODE")})});var Ue;W("Line Terminator Handling",function(){var b=ae(G.lineTerminatorCharacters);Ue=r.map(q,function(_){return!1}),G.positionTracking!=="onlyOffset"&&(Ue=r.map(q,function(_){if(r.has(_,"LINE_BREAKS"))return _.LINE_BREAKS;if($(_,b)===!1)return c.canMatchCharCode(b,_.PATTERN)}))});var F,K,z,ee;W("Misc Mapping #2",function(){F=r.map(q,Q),K=r.map(ie,H),z=r.reduce(q,function(b,_){var A=_.GROUP;return r.isString(A)&&A!==i.Lexer.SKIPPED&&(b[A]=[]),b},{}),ee=r.map(ie,function(b,_){return{pattern:ie[_],longerAlt:we[_],canLineTerminator:Ue[_],isCustom:F[_],short:K[_],group:ye[_],push:je[_],pop:We[_],tokenTypeIdx:Te[_],tokenType:q[_]}})});var fe=!0,be=[];return G.safeMode||W("First Char Optimization",function(){be=r.reduce(q,function(b,_,A){if(typeof _.PATTERN=="string"){var I=_.PATTERN.charCodeAt(0),L=ne(I);se(b,L,ee[A])}else if(r.isArray(_.START_CHARS_HINT)){var w;r.forEach(_.START_CHARS_HINT,function(B){var V=typeof B=="string"?B.charCodeAt(0):B,J=ne(V);w!==J&&(w=J,se(b,J,ee[A]))})}else if(r.isRegExp(_.PATTERN))if(_.PATTERN.unicode)fe=!1,G.ensureOptimizations&&r.PRINT_ERROR(""+c.failedOptimizationPrefixMsg+(" Unable to analyze < "+_.PATTERN.toString()+` > pattern.
|
|
99
99
|
`)+` The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
100
100
|
This will disable the lexer's first char optimizations.
|
|
101
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var D=
|
|
101
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var D=c.getOptimizedStartCodesIndices(_.PATTERN,G.ensureOptimizations);r.isEmpty(D)&&(fe=!1),r.forEach(D,function(B){se(b,B,ee[A])})}else G.ensureOptimizations&&r.PRINT_ERROR(""+c.failedOptimizationPrefixMsg+(" TokenType: <"+_.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
102
102
|
`)+` This will disable the lexer's first char optimizations.
|
|
103
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),fe=!1;return
|
|
103
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),fe=!1;return b},[])}),W("ArrayPacking",function(){be=r.packArray(be)}),{emptyGroups:z,patternIdxToConfig:ee,charCodeToPatternIdxToConfig:be,hasCustom:Z,canBeOptimized:fe}}n.analyzeTokenTypes=f;function h(U,G){var W=[],q=p(U);W=W.concat(q.errors);var Z=g(q.valid),ie=Z.valid;return W=W.concat(Z.errors),W=W.concat(T(ie)),W=W.concat(N(ie)),W=W.concat(C(ie,G)),W=W.concat(Y(ie)),W}n.validatePatterns=h;function T(U){var G=[],W=r.filter(U,function(q){return r.isRegExp(q[u])});return G=G.concat(l(W)),G=G.concat(v(W)),G=G.concat(E(W)),G=G.concat(S(W)),G=G.concat(d(W)),G}function p(U){var G=r.filter(U,function(Z){return!r.has(Z,u)}),W=r.map(G,function(Z){return{message:"Token Type: ->"+Z.name+"<- missing static 'PATTERN' property",type:i.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[Z]}}),q=r.difference(U,G);return{errors:W,valid:q}}n.findMissingPatterns=p;function g(U){var G=r.filter(U,function(Z){var ie=Z[u];return!r.isRegExp(ie)&&!r.isFunction(ie)&&!r.has(ie,"exec")&&!r.isString(ie)}),W=r.map(G,function(Z){return{message:"Token Type: ->"+Z.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:i.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[Z]}}),q=r.difference(U,G);return{errors:W,valid:q}}n.findInvalidPatterns=g;var y=/[^\\][\$]/;function l(U){var G=(function(Z){e(ie,Z);function ie(){var Te=Z!==null&&Z.apply(this,arguments)||this;return Te.found=!1,Te}return ie.prototype.visitEndAnchor=function(Te){this.found=!0},ie})(t.BaseRegExpVisitor),W=r.filter(U,function(Z){var ie=Z[u];try{var Te=o.getRegExpAst(ie),ye=new G;return ye.visit(Te),ye.found}catch{return y.test(ie.source)}}),q=r.map(W,function(Z){return{message:`Unexpected RegExp Anchor Error:
|
|
104
104
|
Token Type: ->`+Z.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
105
|
-
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:i.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[Z]}});return q}n.findEndOfInputAnchor=
|
|
105
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:i.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[Z]}});return q}n.findEndOfInputAnchor=l;function d(U){var G=r.filter(U,function(q){var Z=q[u];return Z.test("")}),W=r.map(G,function(q){return{message:"Token Type: ->"+q.name+"<- static 'PATTERN' must not match an empty string",type:i.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[q]}});return W}n.findEmptyMatchRegExps=d;var m=/[^\\[][\^]|^\^/;function v(U){var G=(function(Z){e(ie,Z);function ie(){var Te=Z!==null&&Z.apply(this,arguments)||this;return Te.found=!1,Te}return ie.prototype.visitStartAnchor=function(Te){this.found=!0},ie})(t.BaseRegExpVisitor),W=r.filter(U,function(Z){var ie=Z[u];try{var Te=o.getRegExpAst(ie),ye=new G;return ye.visit(Te),ye.found}catch{return m.test(ie.source)}}),q=r.map(W,function(Z){return{message:`Unexpected RegExp Anchor Error:
|
|
106
106
|
Token Type: ->`+Z.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
107
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:i.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[Z]}});return q}n.findStartOfInputAnchor=v;function E(U){var
|
|
107
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:i.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[Z]}});return q}n.findStartOfInputAnchor=v;function E(U){var G=r.filter(U,function(q){var Z=q[u];return Z instanceof RegExp&&(Z.multiline||Z.global)}),W=r.map(G,function(q){return{message:"Token Type: ->"+q.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:i.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[q]}});return W}n.findUnsupportedFlags=E;function S(U){var G=[],W=r.map(U,function(ie){return r.reduce(U,function(Te,ye){return ie.PATTERN.source===ye.PATTERN.source&&!r.contains(G,ye)&&ye.PATTERN!==i.Lexer.NA&&(G.push(ye),Te.push(ye)),Te},[])});W=r.compact(W);var q=r.filter(W,function(ie){return ie.length>1}),Z=r.map(q,function(ie){var Te=r.map(ie,function(we){return we.name}),ye=r.first(ie).PATTERN;return{message:"The same RegExp pattern ->"+ye+"<-"+("has been used in all of the following Token Types: "+Te.join(", ")+" <-"),type:i.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:ie}});return Z}n.findDuplicatePatterns=S;function N(U){var G=r.filter(U,function(q){if(!r.has(q,"GROUP"))return!1;var Z=q.GROUP;return Z!==i.Lexer.SKIPPED&&Z!==i.Lexer.NA&&!r.isString(Z)}),W=r.map(G,function(q){return{message:"Token Type: ->"+q.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:i.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[q]}});return W}n.findInvalidGroupType=N;function C(U,G){var W=r.filter(U,function(Z){return Z.PUSH_MODE!==void 0&&!r.contains(G,Z.PUSH_MODE)}),q=r.map(W,function(Z){var ie="Token Type: ->"+Z.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+Z.PUSH_MODE+"<-which does not exist";return{message:ie,type:i.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[Z]}});return q}n.findModesThatDoNotExist=C;function Y(U){var G=[],W=r.reduce(U,function(q,Z,ie){var Te=Z.PATTERN;return Te===i.Lexer.NA||(r.isString(Te)?q.push({str:Te,idx:ie,tokenType:Z}):r.isRegExp(Te)&&j(Te)&&q.push({str:Te.source,idx:ie,tokenType:Z})),q},[]);return r.forEach(U,function(q,Z){r.forEach(W,function(ie){var Te=ie.str,ye=ie.idx,we=ie.tokenType;if(Z<ye&&O(Te,q.PATTERN)){var je="Token: ->"+we.name+`<- can never be matched.
|
|
108
108
|
`+("Because it appears AFTER the Token Type ->"+q.name+"<-")+`in the lexer's definition.
|
|
109
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;
|
|
109
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;G.push({message:je,type:i.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[q,we]})}})}),G}n.findUnreachablePatterns=Y;function O(U,G){if(r.isRegExp(G)){var W=G.exec(U);return W!==null&&W.index===0}else{if(r.isFunction(G))return G(U,0,[],{});if(r.has(G,"exec"))return G.exec(U,0,[],{});if(typeof G=="string")return G===U;throw Error("non exhaustive match")}}function j(U){var G=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return r.find(G,function(W){return U.source.indexOf(W)!==-1})===void 0}function M(U){var G=U.ignoreCase?"i":"";return new RegExp("^(?:"+U.source+")",G)}n.addStartOfInput=M;function x(U){var G=U.ignoreCase?"iy":"y";return new RegExp(""+U.source,G)}n.addStickyFlag=x;function P(U,G,W){var q=[];return r.has(U,n.DEFAULT_MODE)||q.push({message:"A MultiMode Lexer cannot be initialized without a <"+n.DEFAULT_MODE+`> property in its definition
|
|
110
110
|
`,type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),r.has(U,n.MODES)||q.push({message:"A MultiMode Lexer cannot be initialized without a <"+n.MODES+`> property in its definition
|
|
111
111
|
`,type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),r.has(U,n.MODES)&&r.has(U,n.DEFAULT_MODE)&&!r.has(U.modes,U.defaultMode)&&q.push({message:"A MultiMode Lexer cannot be initialized with a "+n.DEFAULT_MODE+": <"+U.defaultMode+`>which does not exist
|
|
112
|
-
`,type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),r.has(U,n.MODES)&&r.forEach(U.modes,function(Z,ie){r.forEach(Z,function(Te,
|
|
113
|
-
`),type:i.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),q}n.performRuntimeChecks=
|
|
112
|
+
`,type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),r.has(U,n.MODES)&&r.forEach(U.modes,function(Z,ie){r.forEach(Z,function(Te,ye){r.isUndefined(Te)&&q.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+ie+"> at index: <"+ye+`>
|
|
113
|
+
`),type:i.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),q}n.performRuntimeChecks=P;function k(U,G,W){var q=[],Z=!1,ie=r.compact(r.flatten(r.mapValues(U.modes,function(we){return we}))),Te=r.reject(ie,function(we){return we[u]===i.Lexer.NA}),ye=ae(W);return G&&r.forEach(Te,function(we){var je=$(we,ye);if(je!==!1){var We=te(we,je),Ue={message:We,type:je.issue,tokenType:we};q.push(Ue)}else r.has(we,"LINE_BREAKS")?we.LINE_BREAKS===!0&&(Z=!0):c.canMatchCharCode(ye,we.PATTERN)&&(Z=!0)}),G&&!Z&&q.push({message:`Warning: No LINE_BREAKS Found.
|
|
114
114
|
This Lexer has been defined to track line and column information,
|
|
115
115
|
But none of the Token Types can be identified as matching a line terminator.
|
|
116
116
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
117
|
-
for details.`,type:i.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),q}n.performWarningRuntimeChecks=k;function X(U){var
|
|
117
|
+
for details.`,type:i.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),q}n.performWarningRuntimeChecks=k;function X(U){var G={},W=r.keys(U);return r.forEach(W,function(q){var Z=U[q];if(r.isArray(Z))G[q]=[];else throw Error("non exhaustive match")}),G}n.cloneEmptyGroups=X;function Q(U){var G=U.PATTERN;if(r.isRegExp(G))return!1;if(r.isFunction(G)||r.has(G,"exec"))return!0;if(r.isString(G))return!1;throw Error("non exhaustive match")}n.isCustomPattern=Q;function H(U){return r.isString(U)&&U.length===1?U.charCodeAt(0):!1}n.isShortPattern=H,n.LineTerminatorOptimizedTester={test:function(U){for(var G=U.length,W=this.lastIndex;W<G;W++){var q=U.charCodeAt(W);if(q===10)return this.lastIndex=W+1,!0;if(q===13)return U.charCodeAt(W+1)===10?this.lastIndex=W+2:this.lastIndex=W+1,!0}return!1},lastIndex:0};function $(U,G){if(r.has(U,"LINE_BREAKS"))return!1;if(r.isRegExp(U.PATTERN)){try{c.canMatchCharCode(G,U.PATTERN)}catch(W){return{issue:i.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:W.message}}return!1}else{if(r.isString(U.PATTERN))return!1;if(Q(U))return{issue:i.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function te(U,G){if(G.issue===i.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
118
118
|
`+(" The problem is in the <"+U.name+`> Token Type
|
|
119
|
-
`)+(" Root cause: "+
|
|
120
|
-
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(
|
|
119
|
+
`)+(" Root cause: "+G.errMsg+`.
|
|
120
|
+
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(G.issue===i.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
121
121
|
`+(" The problem is in the <"+U.name+`> Token Type
|
|
122
|
-
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}n.buildLineBreakIssueMessage=te;function ae(U){var
|
|
123
|
-
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:r.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(o);var
|
|
124
|
-
a boolean 2nd argument is no longer supported`);this.config=t.merge(o,
|
|
125
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(
|
|
122
|
+
`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}n.buildLineBreakIssueMessage=te;function ae(U){var G=r.map(U,function(W){return r.isString(W)&&W.length>0?W.charCodeAt(0):W});return G}function se(U,G,W){U[G]===void 0?U[G]=[W]:U[G].push(W)}n.minOptimizationVal=256;var ce=[];function ne(U){return U<n.minOptimizationVal?U:ce[U]}n.charCodeToOptimizedIndex=ne;function pe(){if(r.isEmpty(ce)){ce=new Array(65536);for(var U=0;U<65536;U++)ce[U]=U>255?255+~~(U/255):U}}}),ut=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isTokenType=n.hasExtendingTokensTypesMapProperty=n.hasExtendingTokensTypesProperty=n.hasCategoriesProperty=n.hasShortKeyProperty=n.singleAssignCategoriesToksMap=n.assignCategoriesMapProp=n.assignCategoriesTokensProp=n.assignTokenDefaultProps=n.expandCategories=n.augmentTokenTypes=n.tokenIdxToClass=n.tokenShortNameIdx=n.tokenStructuredMatcherNoCategories=n.tokenStructuredMatcher=void 0;var e=Oe();function t(y,l){var d=y.tokenTypeIdx;return d===l.tokenTypeIdx?!0:l.isParent===!0&&l.categoryMatchesMap[d]===!0}n.tokenStructuredMatcher=t;function i(y,l){return y.tokenTypeIdx===l.tokenTypeIdx}n.tokenStructuredMatcherNoCategories=i,n.tokenShortNameIdx=1,n.tokenIdxToClass={};function r(y){var l=c(y);o(l),a(l),u(l),e.forEach(l,function(d){d.isParent=d.categoryMatches.length>0})}n.augmentTokenTypes=r;function c(y){for(var l=e.cloneArr(y),d=y,m=!0;m;){d=e.compact(e.flatten(e.map(d,function(E){return E.CATEGORIES})));var v=e.difference(d,l);l=l.concat(v),e.isEmpty(v)?m=!1:d=v}return l}n.expandCategories=c;function o(y){e.forEach(y,function(l){f(l)||(n.tokenIdxToClass[n.tokenShortNameIdx]=l,l.tokenTypeIdx=n.tokenShortNameIdx++),h(l)&&!e.isArray(l.CATEGORIES)&&(l.CATEGORIES=[l.CATEGORIES]),h(l)||(l.CATEGORIES=[]),T(l)||(l.categoryMatches=[]),p(l)||(l.categoryMatchesMap={})})}n.assignTokenDefaultProps=o;function u(y){e.forEach(y,function(l){l.categoryMatches=[],e.forEach(l.categoryMatchesMap,function(d,m){l.categoryMatches.push(n.tokenIdxToClass[m].tokenTypeIdx)})})}n.assignCategoriesTokensProp=u;function a(y){e.forEach(y,function(l){s([],l)})}n.assignCategoriesMapProp=a;function s(y,l){e.forEach(y,function(d){l.categoryMatchesMap[d.tokenTypeIdx]=!0}),e.forEach(l.CATEGORIES,function(d){var m=y.concat(l);e.contains(m,d)||s(m,d)})}n.singleAssignCategoriesToksMap=s;function f(y){return e.has(y,"tokenTypeIdx")}n.hasShortKeyProperty=f;function h(y){return e.has(y,"CATEGORIES")}n.hasCategoriesProperty=h;function T(y){return e.has(y,"categoryMatches")}n.hasExtendingTokensTypesProperty=T;function p(y){return e.has(y,"categoryMatchesMap")}n.hasExtendingTokensTypesMapProperty=p;function g(y){return e.has(y,"tokenTypeIdx")}n.isTokenType=g}),vn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultLexerErrorProvider=void 0,n.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,i,r,c){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+i+" characters.")}}}),yt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Lexer=n.LexerDefinitionErrorType=void 0;var e=En(),t=Oe(),i=ut(),r=vn(),c=Dt();(function(a){a[a.MISSING_PATTERN=0]="MISSING_PATTERN",a[a.INVALID_PATTERN=1]="INVALID_PATTERN",a[a.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",a[a.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",a[a.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",a[a.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",a[a.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",a[a.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",a[a.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",a[a.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",a[a.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",a[a.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",a[a.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",a[a.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",a[a.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",a[a.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",a[a.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(n.LexerDefinitionErrorType||(n.LexerDefinitionErrorType={}));var o={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
123
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:r.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(o);var u=(function(){function a(s,f){var h=this;if(f===void 0&&(f=o),this.lexerDefinition=s,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},typeof f=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
124
|
+
a boolean 2nd argument is no longer supported`);this.config=t.merge(o,f);var T=this.config.traceInitPerf;T===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof T=="number"&&(this.traceInitMaxIdent=T,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var p,g=!0;h.TRACE_INIT("Lexer Config handling",function(){if(h.config.lineTerminatorsPattern===o.lineTerminatorsPattern)h.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(h.config.lineTerminatorCharacters===o.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
125
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(f.safeMode&&f.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');h.trackStartLines=/full|onlyStart/i.test(h.config.positionTracking),h.trackEndLines=/full/i.test(h.config.positionTracking),t.isArray(s)?(p={modes:{}},p.modes[e.DEFAULT_MODE]=t.cloneArr(s),p[e.DEFAULT_MODE]=e.DEFAULT_MODE):(g=!1,p=t.cloneObj(s))}),h.config.skipValidations===!1&&(h.TRACE_INIT("performRuntimeChecks",function(){h.lexerDefinitionErrors=h.lexerDefinitionErrors.concat(e.performRuntimeChecks(p,h.trackStartLines,h.config.lineTerminatorCharacters))}),h.TRACE_INIT("performWarningRuntimeChecks",function(){h.lexerDefinitionWarning=h.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(p,h.trackStartLines,h.config.lineTerminatorCharacters))})),p.modes=p.modes?p.modes:{},t.forEach(p.modes,function(m,v){p.modes[v]=t.reject(m,function(E){return t.isUndefined(E)})});var y=t.keys(p.modes);if(t.forEach(p.modes,function(m,v){h.TRACE_INIT("Mode: <"+v+"> processing",function(){if(h.modes.push(v),h.config.skipValidations===!1&&h.TRACE_INIT("validatePatterns",function(){h.lexerDefinitionErrors=h.lexerDefinitionErrors.concat(e.validatePatterns(m,y))}),t.isEmpty(h.lexerDefinitionErrors)){i.augmentTokenTypes(m);var E;h.TRACE_INIT("analyzeTokenTypes",function(){E=e.analyzeTokenTypes(m,{lineTerminatorCharacters:h.config.lineTerminatorCharacters,positionTracking:f.positionTracking,ensureOptimizations:f.ensureOptimizations,safeMode:f.safeMode,tracer:h.TRACE_INIT.bind(h)})}),h.patternIdxToConfig[v]=E.patternIdxToConfig,h.charCodeToPatternIdxToConfig[v]=E.charCodeToPatternIdxToConfig,h.emptyGroups=t.merge(h.emptyGroups,E.emptyGroups),h.hasCustom=E.hasCustom||h.hasCustom,h.canModeBeOptimized[v]=E.canBeOptimized}})}),h.defaultMode=p.defaultMode,!t.isEmpty(h.lexerDefinitionErrors)&&!h.config.deferDefinitionErrorsHandling){var l=t.map(h.lexerDefinitionErrors,function(m){return m.message}),d=l.join(`-----------------------
|
|
126
126
|
`);throw new Error(`Errors detected in definition of Lexer:
|
|
127
|
-
`+d)}t.forEach(
|
|
127
|
+
`+d)}t.forEach(h.lexerDefinitionWarning,function(m){t.PRINT_WARNING(m.message)}),h.TRACE_INIT("Choosing sub-methods implementations",function(){if(e.SUPPORT_STICKY?(h.chopInput=t.IDENTITY,h.match=h.matchWithTest):(h.updateLastIndex=t.NOOP,h.match=h.matchWithExec),g&&(h.handleModes=t.NOOP),h.trackStartLines===!1&&(h.computeNewColumn=t.IDENTITY),h.trackEndLines===!1&&(h.updateTokenEndLineColumnLocation=t.NOOP),/full/i.test(h.config.positionTracking))h.createTokenInstance=h.createFullToken;else if(/onlyStart/i.test(h.config.positionTracking))h.createTokenInstance=h.createStartOnlyToken;else if(/onlyOffset/i.test(h.config.positionTracking))h.createTokenInstance=h.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+h.config.positionTracking+'"');h.hasCustom?(h.addToken=h.addTokenUsingPush,h.handlePayload=h.handlePayloadWithCustom):(h.addToken=h.addTokenUsingMemberAccess,h.handlePayload=h.handlePayloadNoCustom)}),h.TRACE_INIT("Failed Optimization Warnings",function(){var m=t.reduce(h.canModeBeOptimized,function(v,E,S){return E===!1&&v.push(S),v},[]);if(f.ensureOptimizations&&!t.isEmpty(m))throw Error("Lexer Modes: < "+m.join(", ")+` > cannot be optimized.
|
|
128
128
|
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
129
|
-
Or inspect the console log for details on how to resolve these issues.`)}),
|
|
129
|
+
Or inspect the console log for details on how to resolve these issues.`)}),h.TRACE_INIT("clearRegExpParserCache",function(){c.clearRegExpParserCache()}),h.TRACE_INIT("toFastProperties",function(){t.toFastProperties(h)})})}return a.prototype.tokenize=function(s,f){if(f===void 0&&(f=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var h=t.map(this.lexerDefinitionErrors,function(g){return g.message}),T=h.join(`-----------------------
|
|
130
130
|
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
131
|
-
`+
|
|
132
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(E,c)&&(P.CATEGORIES=E[c]),i.augmentTokenTypes([P]),e.has(E,s)&&(P.LABEL=E[s]),e.has(E,h)&&(P.GROUP=E[h]),e.has(E,g)&&(P.POP_MODE=E[g]),e.has(E,f)&&(P.PUSH_MODE=E[f]),e.has(E,p)&&(P.LONGER_ALT=E[p]),e.has(E,T)&&(P.LINE_BREAKS=E[T]),e.has(E,m)&&(P.START_CHARS_HINT=E[m]),P}n.EOF=u({name:"EOF",pattern:t.Lexer.NA}),i.augmentTokenTypes([n.EOF]);function y(E,b,P,w,Y,x,G,M){return{image:b,startOffset:P,endOffset:w,startLine:Y,endLine:x,startColumn:G,endColumn:M,tokenTypeIdx:E.tokenTypeIdx,tokenType:E}}n.createTokenInstance=y;function v(E,b){return i.tokenStructuredMatcher(E,b)}n.tokenMatcher=v}),He=ve(n=>{var e=n&&n.__extends||(function(){var d=function(y,v){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,b){E.__proto__=b}||function(E,b){for(var P in b)Object.prototype.hasOwnProperty.call(b,P)&&(E[P]=b[P])},d(y,v)};return function(y,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");d(y,v);function E(){this.constructor=y}y.prototype=v===null?Object.create(v):(E.prototype=v.prototype,new E)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.serializeProduction=n.serializeGrammar=n.Terminal=n.Alternation=n.RepetitionWithSeparator=n.Repetition=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Option=n.Alternative=n.Rule=n.NonTerminal=n.AbstractProduction=void 0;var t=xe(),i=nt(),r=(function(){function d(y){this._definition=y}return Object.defineProperty(d.prototype,"definition",{get:function(){return this._definition},set:function(y){this._definition=y},enumerable:!1,configurable:!0}),d.prototype.accept=function(y){y.visit(this),t.forEach(this.definition,function(v){v.accept(y)})},d})();n.AbstractProduction=r;var a=(function(d){e(y,d);function y(v){var E=d.call(this,[])||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(v){},enumerable:!1,configurable:!0}),y.prototype.accept=function(v){v.visit(this)},y})(r);n.NonTerminal=a;var o=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.orgText="",t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.Rule=o;var l=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.ignoreAmbiguities=!1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.Alternative=l;var c=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.Option=c;var s=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.RepetitionMandatory=s;var h=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.RepetitionMandatoryWithSeparator=h;var f=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.Repetition=f;var g=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return y})(r);n.RepetitionWithSeparator=g;var p=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,E.ignoreAmbiguities=!1,E.hasPredicates=!1,t.assign(E,t.pick(v,function(b){return b!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),y})(r);n.Alternation=p;var T=(function(){function d(y){this.idx=1,t.assign(this,t.pick(y,function(v){return v!==void 0}))}return d.prototype.accept=function(y){y.visit(this)},d})();n.Terminal=T;function m(d){return t.map(d,u)}n.serializeGrammar=m;function u(d){function y(b){return t.map(b,u)}if(d instanceof a)return{type:"NonTerminal",name:d.nonTerminalName,idx:d.idx};if(d instanceof l)return{type:"Alternative",definition:y(d.definition)};if(d instanceof c)return{type:"Option",idx:d.idx,definition:y(d.definition)};if(d instanceof s)return{type:"RepetitionMandatory",idx:d.idx,definition:y(d.definition)};if(d instanceof h)return{type:"RepetitionMandatoryWithSeparator",idx:d.idx,separator:u(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof g)return{type:"RepetitionWithSeparator",idx:d.idx,separator:u(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof f)return{type:"Repetition",idx:d.idx,definition:y(d.definition)};if(d instanceof p)return{type:"Alternation",idx:d.idx,definition:y(d.definition)};if(d instanceof T){var v={type:"Terminal",name:d.terminalType.name,label:i.tokenLabel(d.terminalType),idx:d.idx},E=d.terminalType.PATTERN;return d.terminalType.PATTERN&&(v.pattern=t.isRegExp(E)?E.source:E),v}else{if(d instanceof o)return{type:"Rule",name:d.name,orgText:d.orgText,definition:y(d.definition)};throw Error("non exhaustive match")}}n.serializeProduction=u}),Ct=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RestWalker=void 0;var e=xe(),t=He(),i=(function(){function a(){}return a.prototype.walk=function(o,l){var c=this;l===void 0&&(l=[]),e.forEach(o.definition,function(s,h){var f=e.drop(o.definition,h+1);if(s instanceof t.NonTerminal)c.walkProdRef(s,f,l);else if(s instanceof t.Terminal)c.walkTerminal(s,f,l);else if(s instanceof t.Alternative)c.walkFlat(s,f,l);else if(s instanceof t.Option)c.walkOption(s,f,l);else if(s instanceof t.RepetitionMandatory)c.walkAtLeastOne(s,f,l);else if(s instanceof t.RepetitionMandatoryWithSeparator)c.walkAtLeastOneSep(s,f,l);else if(s instanceof t.RepetitionWithSeparator)c.walkManySep(s,f,l);else if(s instanceof t.Repetition)c.walkMany(s,f,l);else if(s instanceof t.Alternation)c.walkOr(s,f,l);else throw Error("non exhaustive match")})},a.prototype.walkTerminal=function(o,l,c){},a.prototype.walkProdRef=function(o,l,c){},a.prototype.walkFlat=function(o,l,c){var s=l.concat(c);this.walk(o,s)},a.prototype.walkOption=function(o,l,c){var s=l.concat(c);this.walk(o,s)},a.prototype.walkAtLeastOne=function(o,l,c){var s=[new t.Option({definition:o.definition})].concat(l,c);this.walk(o,s)},a.prototype.walkAtLeastOneSep=function(o,l,c){var s=r(o,l,c);this.walk(o,s)},a.prototype.walkMany=function(o,l,c){var s=[new t.Option({definition:o.definition})].concat(l,c);this.walk(o,s)},a.prototype.walkManySep=function(o,l,c){var s=r(o,l,c);this.walk(o,s)},a.prototype.walkOr=function(o,l,c){var s=this,h=l.concat(c);e.forEach(o.definition,function(f){var g=new t.Alternative({definition:[f]});s.walk(g,h)})},a})();n.RestWalker=i;function r(a,o,l){var c=[new t.Option({definition:[new t.Terminal({terminalType:a.separator})].concat(a.definition)})],s=c.concat(o,l);return s}}),ut=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GAstVisitor=void 0;var e=He(),t=(function(){function i(){}return i.prototype.visit=function(r){var a=r;switch(a.constructor){case e.NonTerminal:return this.visitNonTerminal(a);case e.Alternative:return this.visitAlternative(a);case e.Option:return this.visitOption(a);case e.RepetitionMandatory:return this.visitRepetitionMandatory(a);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(a);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(a);case e.Repetition:return this.visitRepetition(a);case e.Alternation:return this.visitAlternation(a);case e.Terminal:return this.visitTerminal(a);case e.Rule:return this.visitRule(a);default:throw Error("non exhaustive match")}},i.prototype.visitNonTerminal=function(r){},i.prototype.visitAlternative=function(r){},i.prototype.visitOption=function(r){},i.prototype.visitRepetition=function(r){},i.prototype.visitRepetitionMandatory=function(r){},i.prototype.visitRepetitionMandatoryWithSeparator=function(r){},i.prototype.visitRepetitionWithSeparator=function(r){},i.prototype.visitAlternation=function(r){},i.prototype.visitTerminal=function(r){},i.prototype.visitRule=function(r){},i})();n.GAstVisitor=t}),mt=ve(n=>{var e=n&&n.__extends||(function(){var g=function(p,T){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,u){m.__proto__=u}||function(m,u){for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(m[d]=u[d])},g(p,T)};return function(p,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");g(p,T);function m(){this.constructor=p}p.prototype=T===null?Object.create(T):(m.prototype=T.prototype,new m)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.collectMethods=n.DslMethodsCollectorVisitor=n.getProductionDslName=n.isBranchingProd=n.isOptionalProd=n.isSequenceProd=void 0;var t=xe(),i=He(),r=ut();function a(g){return g instanceof i.Alternative||g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionMandatory||g instanceof i.RepetitionMandatoryWithSeparator||g instanceof i.RepetitionWithSeparator||g instanceof i.Terminal||g instanceof i.Rule}n.isSequenceProd=a;function o(g,p){p===void 0&&(p=[]);var T=g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionWithSeparator;return T?!0:g instanceof i.Alternation?t.some(g.definition,function(m){return o(m,p)}):g instanceof i.NonTerminal&&t.contains(p,g)?!1:g instanceof i.AbstractProduction?(g instanceof i.NonTerminal&&p.push(g),t.every(g.definition,function(m){return o(m,p)})):!1}n.isOptionalProd=o;function l(g){return g instanceof i.Alternation}n.isBranchingProd=l;function c(g){if(g instanceof i.NonTerminal)return"SUBRULE";if(g instanceof i.Option)return"OPTION";if(g instanceof i.Alternation)return"OR";if(g instanceof i.RepetitionMandatory)return"AT_LEAST_ONE";if(g instanceof i.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(g instanceof i.RepetitionWithSeparator)return"MANY_SEP";if(g instanceof i.Repetition)return"MANY";if(g instanceof i.Terminal)return"CONSUME";throw Error("non exhaustive match")}n.getProductionDslName=c;var s=(function(g){e(p,g);function p(){var T=g!==null&&g.apply(this,arguments)||this;return T.separator="-",T.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},T}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(T){var m=T.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitNonTerminal=function(T){var m=T.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitOption=function(T){this.dslMethods.option.push(T)},p.prototype.visitRepetitionWithSeparator=function(T){this.dslMethods.repetitionWithSeparator.push(T)},p.prototype.visitRepetitionMandatory=function(T){this.dslMethods.repetitionMandatory.push(T)},p.prototype.visitRepetitionMandatoryWithSeparator=function(T){this.dslMethods.repetitionMandatoryWithSeparator.push(T)},p.prototype.visitRepetition=function(T){this.dslMethods.repetition.push(T)},p.prototype.visitAlternation=function(T){this.dslMethods.alternation.push(T)},p})(r.GAstVisitor);n.DslMethodsCollectorVisitor=s;var h=new s;function f(g){h.reset(),g.accept(h);var p=h.dslMethods;return h.reset(),p}n.collectMethods=f}),mn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.firstForTerminal=n.firstForBranching=n.firstForSequence=n.first=void 0;var e=xe(),t=He(),i=mt();function r(c){if(c instanceof t.NonTerminal)return r(c.referencedRule);if(c instanceof t.Terminal)return l(c);if(i.isSequenceProd(c))return a(c);if(i.isBranchingProd(c))return o(c);throw Error("non exhaustive match")}n.first=r;function a(c){for(var s=[],h=c.definition,f=0,g=h.length>f,p,T=!0;g&&T;)p=h[f],T=i.isOptionalProd(p),s=s.concat(r(p)),f=f+1,g=h.length>f;return e.uniq(s)}n.firstForSequence=a;function o(c){var s=e.map(c.definition,function(h){return r(h)});return e.uniq(e.flatten(s))}n.firstForBranching=o;function l(c){return[c.terminalType]}n.firstForTerminal=l}),yn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IN=void 0,n.IN="_~IN~_"}),Qr=ve(n=>{var e=n&&n.__extends||(function(){var f=function(g,p){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,m){T.__proto__=m}||function(T,m){for(var u in m)Object.prototype.hasOwnProperty.call(m,u)&&(T[u]=m[u])},f(g,p)};return function(g,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");f(g,p);function T(){this.constructor=g}g.prototype=p===null?Object.create(p):(T.prototype=p.prototype,new T)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.buildInProdFollowPrefix=n.buildBetweenProdsFollowPrefix=n.computeAllProdsFollows=n.ResyncFollowsWalker=void 0;var t=Ct(),i=mn(),r=xe(),a=yn(),o=He(),l=(function(f){e(g,f);function g(p){var T=f.call(this)||this;return T.topProd=p,T.follows={},T}return g.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},g.prototype.walkTerminal=function(p,T,m){},g.prototype.walkProdRef=function(p,T,m){var u=s(p.referencedRule,p.idx)+this.topProd.name,d=T.concat(m),y=new o.Alternative({definition:d}),v=i.first(y);this.follows[u]=v},g})(t.RestWalker);n.ResyncFollowsWalker=l;function c(f){var g={};return r.forEach(f,function(p){var T=new l(p).startWalking();r.assign(g,T)}),g}n.computeAllProdsFollows=c;function s(f,g){return f.name+g+a.IN}n.buildBetweenProdsFollowPrefix=s;function h(f){var g=f.terminalType.name;return g+f.idx+a.IN}n.buildInProdFollowPrefix=h}),yt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultGrammarValidatorErrorProvider=n.defaultGrammarResolverErrorProvider=n.defaultParserErrorProvider=void 0;var e=nt(),t=xe(),i=xe(),r=He(),a=mt();n.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var l=o.expected,c=o.actual;o.previous,o.ruleName;var s=e.hasTokenLabel(l),h=s?"--> "+e.tokenLabel(l)+" <--":"token of type --> "+l.name+" <--",f="Expecting "+h+" but found --> '"+c.image+"' <--";return f},buildNotAllInputParsedMessage:function(o){var l=o.firstRedundant;return o.ruleName,"Redundant input, expecting EOF but found: "+l.image},buildNoViableAltMessage:function(o){var l=o.expectedPathsPerAlt,c=o.actual;o.previous;var s=o.customUserDescription;o.ruleName;var h="Expecting: ",f=i.first(c).image,g=`
|
|
133
|
-
but found: '`+
|
|
134
|
-
`+
|
|
135
|
-
`);return
|
|
136
|
-
but found: '`+
|
|
137
|
-
`+("<"+p.join(" ,")+">");return
|
|
138
|
-
inside top level rule: ->`+o.name+"<-";return
|
|
139
|
-
appears more than once (`+
|
|
131
|
+
`+T)}var p=this.tokenizeInternal(s,f);return p},a.prototype.tokenizeInternal=function(s,f){var h=this,T,p,g,y,l,d,m,v,E,S,N,C,Y,O,j=s,M=j.length,x=0,P=0,k=this.hasCustom?0:Math.floor(s.length/10),X=new Array(k),Q=[],H=this.trackStartLines?1:void 0,$=this.trackStartLines?1:void 0,te=e.cloneEmptyGroups(this.emptyGroups),ae=this.trackStartLines,se=this.config.lineTerminatorsPattern,ce=0,ne=[],pe=[],U=[],G=[];Object.freeze(G);var W=void 0;function q(){return ne}function Z(w){var D=e.charCodeToOptimizedIndex(w),B=pe[D];return B===void 0?G:B}var ie=function(w){if(U.length===1&&w.tokenType.PUSH_MODE===void 0){var D=h.config.errorMessageProvider.buildUnableToPopLexerModeMessage(w);Q.push({offset:w.startOffset,line:w.startLine!==void 0?w.startLine:void 0,column:w.startColumn!==void 0?w.startColumn:void 0,length:w.image.length,message:D})}else{U.pop();var B=t.last(U);ne=h.patternIdxToConfig[B],pe=h.charCodeToPatternIdxToConfig[B],ce=ne.length;var V=h.canModeBeOptimized[B]&&h.config.safeMode===!1;pe&&V?W=Z:W=q}};function Te(w){U.push(w),pe=this.charCodeToPatternIdxToConfig[w],ne=this.patternIdxToConfig[w],ce=ne.length,ce=ne.length;var D=this.canModeBeOptimized[w]&&this.config.safeMode===!1;pe&&D?W=Z:W=q}Te.call(this,f);for(var ye;x<M;){l=null;var we=j.charCodeAt(x),je=W(we),We=je.length;for(T=0;T<We;T++){ye=je[T];var Ue=ye.pattern;d=null;var F=ye.short;if(F!==!1?we===F&&(l=Ue):ye.isCustom===!0?(O=Ue.exec(j,x,X,te),O!==null?(l=O[0],O.payload!==void 0&&(d=O.payload)):l=null):(this.updateLastIndex(Ue,x),l=this.match(Ue,s,x)),l!==null){if(y=ye.longerAlt,y!==void 0){var K=ne[y],z=K.pattern;m=null,K.isCustom===!0?(O=z.exec(j,x,X,te),O!==null?(g=O[0],O.payload!==void 0&&(m=O.payload)):g=null):(this.updateLastIndex(z,x),g=this.match(z,s,x)),g&&g.length>l.length&&(l=g,d=m,ye=K)}break}}if(l!==null){if(v=l.length,E=ye.group,E!==void 0&&(S=ye.tokenTypeIdx,N=this.createTokenInstance(l,x,S,ye.tokenType,H,$,v),this.handlePayload(N,d),E===!1?P=this.addToken(X,P,N):te[E].push(N)),s=this.chopInput(s,v),x=x+v,$=this.computeNewColumn($,v),ae===!0&&ye.canLineTerminator===!0){var ee=0,fe=void 0,be=void 0;se.lastIndex=0;do fe=se.test(l),fe===!0&&(be=se.lastIndex-1,ee++);while(fe===!0);ee!==0&&(H=H+ee,$=v-be,this.updateTokenEndLineColumnLocation(N,E,be,ee,H,$,v))}this.handleModes(ye,ie,Te,N)}else{for(var b=x,_=H,A=$,I=!1;!I&&x<M;)for(j.charCodeAt(x),s=this.chopInput(s,1),x++,p=0;p<ce;p++){var L=ne[p],Ue=L.pattern,F=L.short;if(F!==!1?j.charCodeAt(x)===F&&(I=!0):L.isCustom===!0?I=Ue.exec(j,x,X,te)!==null:(this.updateLastIndex(Ue,x),I=Ue.exec(s)!==null),I===!0)break}C=x-b,Y=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(j,b,C,_,A),Q.push({offset:b,line:_,column:A,length:C,message:Y})}}return this.hasCustom||(X.length=P),{tokens:X,groups:te,errors:Q}},a.prototype.handleModes=function(s,f,h,T){if(s.pop===!0){var p=s.push;f(T),p!==void 0&&h.call(this,p)}else s.push!==void 0&&h.call(this,s.push)},a.prototype.chopInput=function(s,f){return s.substring(f)},a.prototype.updateLastIndex=function(s,f){s.lastIndex=f},a.prototype.updateTokenEndLineColumnLocation=function(s,f,h,T,p,g,y){var l,d;f!==void 0&&(l=h===y-1,d=l?-1:0,T===1&&l===!0||(s.endLine=p+d,s.endColumn=g-1+-d))},a.prototype.computeNewColumn=function(s,f){return s+f},a.prototype.createTokenInstance=function(){for(var s=[],f=0;f<arguments.length;f++)s[f]=arguments[f];return null},a.prototype.createOffsetOnlyToken=function(s,f,h,T){return{image:s,startOffset:f,tokenTypeIdx:h,tokenType:T}},a.prototype.createStartOnlyToken=function(s,f,h,T,p,g){return{image:s,startOffset:f,startLine:p,startColumn:g,tokenTypeIdx:h,tokenType:T}},a.prototype.createFullToken=function(s,f,h,T,p,g,y){return{image:s,startOffset:f,endOffset:f+y-1,startLine:p,endLine:p,startColumn:g,endColumn:g+y-1,tokenTypeIdx:h,tokenType:T}},a.prototype.addToken=function(s,f,h){return 666},a.prototype.addTokenUsingPush=function(s,f,h){return s.push(h),f},a.prototype.addTokenUsingMemberAccess=function(s,f,h){return s[f]=h,f++,f},a.prototype.handlePayload=function(s,f){},a.prototype.handlePayloadNoCustom=function(s,f){},a.prototype.handlePayloadWithCustom=function(s,f){f!==null&&(s.payload=f)},a.prototype.match=function(s,f,h){return null},a.prototype.matchWithTest=function(s,f,h){var T=s.test(f);return T===!0?f.substring(h,s.lastIndex):null},a.prototype.matchWithExec=function(s,f){var h=s.exec(f);return h!==null?h[0]:h},a.prototype.TRACE_INIT=function(s,f){if(this.traceInitPerf===!0){this.traceInitIndent++;var h=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(h+"--> <"+s+">");var T=t.timer(f),p=T.time,g=T.value,y=p>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&y(h+"<-- <"+s+"> time: "+p+"ms"),this.traceInitIndent--,g}else return f()},a.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",a.NA=/NOT_APPLICABLE/,a})();n.Lexer=u}),tt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tokenMatcher=n.createTokenInstance=n.EOF=n.createToken=n.hasTokenLabel=n.tokenName=n.tokenLabel=void 0;var e=Oe(),t=yt(),i=ut();function r(E){return o(E)?E.LABEL:E.name}n.tokenLabel=r;function c(E){return E.name}n.tokenName=c;function o(E){return e.isString(E.LABEL)&&E.LABEL!==""}n.hasTokenLabel=o;var u="parent",a="categories",s="label",f="group",h="push_mode",T="pop_mode",p="longer_alt",g="line_breaks",y="start_chars_hint";function l(E){return d(E)}n.createToken=l;function d(E){var S=E.pattern,N={};if(N.name=E.name,e.isUndefined(S)||(N.PATTERN=S),e.has(E,u))throw`The parent property is no longer supported.
|
|
132
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(E,a)&&(N.CATEGORIES=E[a]),i.augmentTokenTypes([N]),e.has(E,s)&&(N.LABEL=E[s]),e.has(E,f)&&(N.GROUP=E[f]),e.has(E,T)&&(N.POP_MODE=E[T]),e.has(E,h)&&(N.PUSH_MODE=E[h]),e.has(E,p)&&(N.LONGER_ALT=E[p]),e.has(E,g)&&(N.LINE_BREAKS=E[g]),e.has(E,y)&&(N.START_CHARS_HINT=E[y]),N}n.EOF=l({name:"EOF",pattern:t.Lexer.NA}),i.augmentTokenTypes([n.EOF]);function m(E,S,N,C,Y,O,j,M){return{image:S,startOffset:N,endOffset:C,startLine:Y,endLine:O,startColumn:j,endColumn:M,tokenTypeIdx:E.tokenTypeIdx,tokenType:E}}n.createTokenInstance=m;function v(E,S){return i.tokenStructuredMatcher(E,S)}n.tokenMatcher=v}),He=ve(n=>{var e=n&&n.__extends||(function(){var d=function(m,v){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,S){E.__proto__=S}||function(E,S){for(var N in S)Object.prototype.hasOwnProperty.call(S,N)&&(E[N]=S[N])},d(m,v)};return function(m,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");d(m,v);function E(){this.constructor=m}m.prototype=v===null?Object.create(v):(E.prototype=v.prototype,new E)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.serializeProduction=n.serializeGrammar=n.Terminal=n.Alternation=n.RepetitionWithSeparator=n.Repetition=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Option=n.Alternative=n.Rule=n.NonTerminal=n.AbstractProduction=void 0;var t=Oe(),i=tt(),r=(function(){function d(m){this._definition=m}return Object.defineProperty(d.prototype,"definition",{get:function(){return this._definition},set:function(m){this._definition=m},enumerable:!1,configurable:!0}),d.prototype.accept=function(m){m.visit(this),t.forEach(this.definition,function(v){v.accept(m)})},d})();n.AbstractProduction=r;var c=(function(d){e(m,d);function m(v){var E=d.call(this,[])||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(m.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(v){},enumerable:!1,configurable:!0}),m.prototype.accept=function(v){v.visit(this)},m})(r);n.NonTerminal=c;var o=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.orgText="",t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.Rule=o;var u=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.ignoreAmbiguities=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.Alternative=u;var a=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.Option=a;var s=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.RepetitionMandatory=s;var f=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.RepetitionMandatoryWithSeparator=f;var h=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.Repetition=h;var T=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return m})(r);n.RepetitionWithSeparator=T;var p=(function(d){e(m,d);function m(v){var E=d.call(this,v.definition)||this;return E.idx=1,E.ignoreAmbiguities=!1,E.hasPredicates=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(m.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),m})(r);n.Alternation=p;var g=(function(){function d(m){this.idx=1,t.assign(this,t.pick(m,function(v){return v!==void 0}))}return d.prototype.accept=function(m){m.visit(this)},d})();n.Terminal=g;function y(d){return t.map(d,l)}n.serializeGrammar=y;function l(d){function m(S){return t.map(S,l)}if(d instanceof c)return{type:"NonTerminal",name:d.nonTerminalName,idx:d.idx};if(d instanceof u)return{type:"Alternative",definition:m(d.definition)};if(d instanceof a)return{type:"Option",idx:d.idx,definition:m(d.definition)};if(d instanceof s)return{type:"RepetitionMandatory",idx:d.idx,definition:m(d.definition)};if(d instanceof f)return{type:"RepetitionMandatoryWithSeparator",idx:d.idx,separator:l(new g({terminalType:d.separator})),definition:m(d.definition)};if(d instanceof T)return{type:"RepetitionWithSeparator",idx:d.idx,separator:l(new g({terminalType:d.separator})),definition:m(d.definition)};if(d instanceof h)return{type:"Repetition",idx:d.idx,definition:m(d.definition)};if(d instanceof p)return{type:"Alternation",idx:d.idx,definition:m(d.definition)};if(d instanceof g){var v={type:"Terminal",name:d.terminalType.name,label:i.tokenLabel(d.terminalType),idx:d.idx},E=d.terminalType.PATTERN;return d.terminalType.PATTERN&&(v.pattern=t.isRegExp(E)?E.source:E),v}else{if(d instanceof o)return{type:"Rule",name:d.name,orgText:d.orgText,definition:m(d.definition)};throw Error("non exhaustive match")}}n.serializeProduction=l}),Ft=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RestWalker=void 0;var e=Oe(),t=He(),i=(function(){function c(){}return c.prototype.walk=function(o,u){var a=this;u===void 0&&(u=[]),e.forEach(o.definition,function(s,f){var h=e.drop(o.definition,f+1);if(s instanceof t.NonTerminal)a.walkProdRef(s,h,u);else if(s instanceof t.Terminal)a.walkTerminal(s,h,u);else if(s instanceof t.Alternative)a.walkFlat(s,h,u);else if(s instanceof t.Option)a.walkOption(s,h,u);else if(s instanceof t.RepetitionMandatory)a.walkAtLeastOne(s,h,u);else if(s instanceof t.RepetitionMandatoryWithSeparator)a.walkAtLeastOneSep(s,h,u);else if(s instanceof t.RepetitionWithSeparator)a.walkManySep(s,h,u);else if(s instanceof t.Repetition)a.walkMany(s,h,u);else if(s instanceof t.Alternation)a.walkOr(s,h,u);else throw Error("non exhaustive match")})},c.prototype.walkTerminal=function(o,u,a){},c.prototype.walkProdRef=function(o,u,a){},c.prototype.walkFlat=function(o,u,a){var s=u.concat(a);this.walk(o,s)},c.prototype.walkOption=function(o,u,a){var s=u.concat(a);this.walk(o,s)},c.prototype.walkAtLeastOne=function(o,u,a){var s=[new t.Option({definition:o.definition})].concat(u,a);this.walk(o,s)},c.prototype.walkAtLeastOneSep=function(o,u,a){var s=r(o,u,a);this.walk(o,s)},c.prototype.walkMany=function(o,u,a){var s=[new t.Option({definition:o.definition})].concat(u,a);this.walk(o,s)},c.prototype.walkManySep=function(o,u,a){var s=r(o,u,a);this.walk(o,s)},c.prototype.walkOr=function(o,u,a){var s=this,f=u.concat(a);e.forEach(o.definition,function(h){var T=new t.Alternative({definition:[h]});s.walk(T,f)})},c})();n.RestWalker=i;function r(c,o,u){var a=[new t.Option({definition:[new t.Terminal({terminalType:c.separator})].concat(c.definition)})],s=a.concat(o,u);return s}}),ht=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GAstVisitor=void 0;var e=He(),t=(function(){function i(){}return i.prototype.visit=function(r){var c=r;switch(c.constructor){case e.NonTerminal:return this.visitNonTerminal(c);case e.Alternative:return this.visitAlternative(c);case e.Option:return this.visitOption(c);case e.RepetitionMandatory:return this.visitRepetitionMandatory(c);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(c);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(c);case e.Repetition:return this.visitRepetition(c);case e.Alternation:return this.visitAlternation(c);case e.Terminal:return this.visitTerminal(c);case e.Rule:return this.visitRule(c);default:throw Error("non exhaustive match")}},i.prototype.visitNonTerminal=function(r){},i.prototype.visitAlternative=function(r){},i.prototype.visitOption=function(r){},i.prototype.visitRepetition=function(r){},i.prototype.visitRepetitionMandatory=function(r){},i.prototype.visitRepetitionMandatoryWithSeparator=function(r){},i.prototype.visitRepetitionWithSeparator=function(r){},i.prototype.visitAlternation=function(r){},i.prototype.visitTerminal=function(r){},i.prototype.visitRule=function(r){},i})();n.GAstVisitor=t}),gt=ve(n=>{var e=n&&n.__extends||(function(){var T=function(p,g){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,l){y.__proto__=l}||function(y,l){for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(y[d]=l[d])},T(p,g)};return function(p,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");T(p,g);function y(){this.constructor=p}p.prototype=g===null?Object.create(g):(y.prototype=g.prototype,new y)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.collectMethods=n.DslMethodsCollectorVisitor=n.getProductionDslName=n.isBranchingProd=n.isOptionalProd=n.isSequenceProd=void 0;var t=Oe(),i=He(),r=ht();function c(T){return T instanceof i.Alternative||T instanceof i.Option||T instanceof i.Repetition||T instanceof i.RepetitionMandatory||T instanceof i.RepetitionMandatoryWithSeparator||T instanceof i.RepetitionWithSeparator||T instanceof i.Terminal||T instanceof i.Rule}n.isSequenceProd=c;function o(T,p){p===void 0&&(p=[]);var g=T instanceof i.Option||T instanceof i.Repetition||T instanceof i.RepetitionWithSeparator;return g?!0:T instanceof i.Alternation?t.some(T.definition,function(y){return o(y,p)}):T instanceof i.NonTerminal&&t.contains(p,T)?!1:T instanceof i.AbstractProduction?(T instanceof i.NonTerminal&&p.push(T),t.every(T.definition,function(y){return o(y,p)})):!1}n.isOptionalProd=o;function u(T){return T instanceof i.Alternation}n.isBranchingProd=u;function a(T){if(T instanceof i.NonTerminal)return"SUBRULE";if(T instanceof i.Option)return"OPTION";if(T instanceof i.Alternation)return"OR";if(T instanceof i.RepetitionMandatory)return"AT_LEAST_ONE";if(T instanceof i.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(T instanceof i.RepetitionWithSeparator)return"MANY_SEP";if(T instanceof i.Repetition)return"MANY";if(T instanceof i.Terminal)return"CONSUME";throw Error("non exhaustive match")}n.getProductionDslName=a;var s=(function(T){e(p,T);function p(){var g=T!==null&&T.apply(this,arguments)||this;return g.separator="-",g.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},g}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(g){var y=g.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},p.prototype.visitNonTerminal=function(g){var y=g.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},p.prototype.visitOption=function(g){this.dslMethods.option.push(g)},p.prototype.visitRepetitionWithSeparator=function(g){this.dslMethods.repetitionWithSeparator.push(g)},p.prototype.visitRepetitionMandatory=function(g){this.dslMethods.repetitionMandatory.push(g)},p.prototype.visitRepetitionMandatoryWithSeparator=function(g){this.dslMethods.repetitionMandatoryWithSeparator.push(g)},p.prototype.visitRepetition=function(g){this.dslMethods.repetition.push(g)},p.prototype.visitAlternation=function(g){this.dslMethods.alternation.push(g)},p})(r.GAstVisitor);n.DslMethodsCollectorVisitor=s;var f=new s;function h(T){f.reset(),T.accept(f);var p=f.dslMethods;return f.reset(),p}n.collectMethods=h}),Rn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.firstForTerminal=n.firstForBranching=n.firstForSequence=n.first=void 0;var e=Oe(),t=He(),i=gt();function r(a){if(a instanceof t.NonTerminal)return r(a.referencedRule);if(a instanceof t.Terminal)return u(a);if(i.isSequenceProd(a))return c(a);if(i.isBranchingProd(a))return o(a);throw Error("non exhaustive match")}n.first=r;function c(a){for(var s=[],f=a.definition,h=0,T=f.length>h,p,g=!0;T&&g;)p=f[h],g=i.isOptionalProd(p),s=s.concat(r(p)),h=h+1,T=f.length>h;return e.uniq(s)}n.firstForSequence=c;function o(a){var s=e.map(a.definition,function(f){return r(f)});return e.uniq(e.flatten(s))}n.firstForBranching=o;function u(a){return[a.terminalType]}n.firstForTerminal=u}),_n=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IN=void 0,n.IN="_~IN~_"}),ti=ve(n=>{var e=n&&n.__extends||(function(){var h=function(T,p){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,y){g.__proto__=y}||function(g,y){for(var l in y)Object.prototype.hasOwnProperty.call(y,l)&&(g[l]=y[l])},h(T,p)};return function(T,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");h(T,p);function g(){this.constructor=T}T.prototype=p===null?Object.create(p):(g.prototype=p.prototype,new g)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.buildInProdFollowPrefix=n.buildBetweenProdsFollowPrefix=n.computeAllProdsFollows=n.ResyncFollowsWalker=void 0;var t=Ft(),i=Rn(),r=Oe(),c=_n(),o=He(),u=(function(h){e(T,h);function T(p){var g=h.call(this)||this;return g.topProd=p,g.follows={},g}return T.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},T.prototype.walkTerminal=function(p,g,y){},T.prototype.walkProdRef=function(p,g,y){var l=s(p.referencedRule,p.idx)+this.topProd.name,d=g.concat(y),m=new o.Alternative({definition:d}),v=i.first(m);this.follows[l]=v},T})(t.RestWalker);n.ResyncFollowsWalker=u;function a(h){var T={};return r.forEach(h,function(p){var g=new u(p).startWalking();r.assign(T,g)}),T}n.computeAllProdsFollows=a;function s(h,T){return h.name+T+c.IN}n.buildBetweenProdsFollowPrefix=s;function f(h){var T=h.terminalType.name;return T+h.idx+c.IN}n.buildInProdFollowPrefix=f}),Tt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultGrammarValidatorErrorProvider=n.defaultGrammarResolverErrorProvider=n.defaultParserErrorProvider=void 0;var e=tt(),t=Oe(),i=Oe(),r=He(),c=gt();n.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var u=o.expected,a=o.actual;o.previous,o.ruleName;var s=e.hasTokenLabel(u),f=s?"--> "+e.tokenLabel(u)+" <--":"token of type --> "+u.name+" <--",h="Expecting "+f+" but found --> '"+a.image+"' <--";return h},buildNotAllInputParsedMessage:function(o){var u=o.firstRedundant;return o.ruleName,"Redundant input, expecting EOF but found: "+u.image},buildNoViableAltMessage:function(o){var u=o.expectedPathsPerAlt,a=o.actual;o.previous;var s=o.customUserDescription;o.ruleName;var f="Expecting: ",h=i.first(a).image,T=`
|
|
133
|
+
but found: '`+h+"'";if(s)return f+s+T;var p=i.reduce(u,function(d,m){return d.concat(m)},[]),g=i.map(p,function(d){return"["+i.map(d,function(m){return e.tokenLabel(m)}).join(", ")+"]"}),y=i.map(g,function(d,m){return" "+(m+1)+". "+d}),l=`one of these possible Token sequences:
|
|
134
|
+
`+y.join(`
|
|
135
|
+
`);return f+l+T},buildEarlyExitMessage:function(o){var u=o.expectedIterationPaths,a=o.actual,s=o.customUserDescription;o.ruleName;var f="Expecting: ",h=i.first(a).image,T=`
|
|
136
|
+
but found: '`+h+"'";if(s)return f+s+T;var p=i.map(u,function(y){return"["+i.map(y,function(l){return e.tokenLabel(l)}).join(",")+"]"}),g=`expecting at least one iteration which starts with one of these possible Token sequences::
|
|
137
|
+
`+("<"+p.join(" ,")+">");return f+g+T}},Object.freeze(n.defaultParserErrorProvider),n.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(o,u){var a="Invalid grammar, reference to a rule which is not defined: ->"+u.nonTerminalName+`<-
|
|
138
|
+
inside top level rule: ->`+o.name+"<-";return a}},n.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(o,u){function a(l){return l instanceof r.Terminal?l.terminalType.name:l instanceof r.NonTerminal?l.nonTerminalName:""}var s=o.name,f=i.first(u),h=f.idx,T=c.getProductionDslName(f),p=a(f),g=h>0,y="->"+T+(g?h:"")+"<- "+(p?"with argument: ->"+p+"<-":"")+`
|
|
139
|
+
appears more than once (`+u.length+" times) in the top level rule: ->"+s+`<-.
|
|
140
140
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
141
|
-
`;return
|
|
142
|
-
`),
|
|
141
|
+
`;return y=y.replace(/[ \t]+/g," "),y=y.replace(/\s\s+/g,`
|
|
142
|
+
`),y},buildNamespaceConflictError:function(o){var u=`Namespace conflict found in grammar.
|
|
143
143
|
`+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+o.name+`>.
|
|
144
144
|
`)+`To resolve this make sure each Terminal and Non-Terminal names are unique
|
|
145
145
|
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|
146
|
-
and Non-Terminal names start with a lower case letter.`;return
|
|
147
|
-
`+("in <OR"+
|
|
148
|
-
`)+("<"+
|
|
146
|
+
and Non-Terminal names start with a lower case letter.`;return u},buildAlternationPrefixAmbiguityError:function(o){var u=i.map(o.prefixPath,function(f){return e.tokenLabel(f)}).join(", "),a=o.alternation.idx===0?"":o.alternation.idx,s="Ambiguous alternatives: <"+o.ambiguityIndices.join(" ,")+`> due to common lookahead prefix
|
|
147
|
+
`+("in <OR"+a+"> inside <"+o.topLevelRule.name+`> Rule,
|
|
148
|
+
`)+("<"+u+`> may appears as a prefix path in all these alternatives.
|
|
149
149
|
`)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|
150
|
-
For Further details.`;return s},buildAlternationAmbiguityError:function(o){var
|
|
151
|
-
`)+("<"+
|
|
150
|
+
For Further details.`;return s},buildAlternationAmbiguityError:function(o){var u=i.map(o.prefixPath,function(f){return e.tokenLabel(f)}).join(", "),a=o.alternation.idx===0?"":o.alternation.idx,s="Ambiguous Alternatives Detected: <"+o.ambiguityIndices.join(" ,")+"> in <OR"+a+">"+(" inside <"+o.topLevelRule.name+`> Rule,
|
|
151
|
+
`)+("<"+u+`> may appears as a prefix path in all these alternatives.
|
|
152
152
|
`);return s=s+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
153
|
-
For Further details.`,s},buildEmptyRepetitionError:function(o){var
|
|
154
|
-
This could lead to an infinite loop.`;return
|
|
155
|
-
`)+"Only the last alternative may be an empty alternative.";return
|
|
153
|
+
For Further details.`,s},buildEmptyRepetitionError:function(o){var u=c.getProductionDslName(o.repetition);o.repetition.idx!==0&&(u+=o.repetition.idx);var a="The repetition <"+u+"> within Rule <"+o.topLevelRule.name+`> can never consume any tokens.
|
|
154
|
+
This could lead to an infinite loop.`;return a},buildTokenNameError:function(o){return"deprecated"},buildEmptyAlternationError:function(o){var u="Ambiguous empty alternative: <"+(o.emptyChoiceIdx+1)+">"+(" in <OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
|
|
155
|
+
`)+"Only the last alternative may be an empty alternative.";return u},buildTooManyAlternativesError:function(o){var u=`An Alternation cannot have more than 256 alternatives:
|
|
156
156
|
`+("<OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
|
|
157
|
-
has `+(o.alternation.definition.length+1)+" alternatives.");return
|
|
158
|
-
`+("rule: <"+
|
|
157
|
+
has `+(o.alternation.definition.length+1)+" alternatives.");return u},buildLeftRecursionError:function(o){var u=o.topLevelRule.name,a=t.map(o.leftRecursionPath,function(h){return h.name}),s=u+" --> "+a.concat([u]).join(" --> "),f=`Left Recursion found in grammar.
|
|
158
|
+
`+("rule: <"+u+`> can be invoked from itself (directly or indirectly)
|
|
159
159
|
`)+(`without consuming any Tokens. The grammar path that causes this is:
|
|
160
160
|
`+s+`
|
|
161
161
|
`)+` To fix this refactor your grammar to remove the left recursion.
|
|
162
|
-
see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return h},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var l;o.topLevelRule instanceof r.Rule?l=o.topLevelRule.name:l=o.topLevelRule;var c="Duplicate definition, rule: ->"+l+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return c}}}),Zr=ve(n=>{var e=n&&n.__extends||(function(){var l=function(c,s){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,f){h.__proto__=f}||function(h,f){for(var g in f)Object.prototype.hasOwnProperty.call(f,g)&&(h[g]=f[g])},l(c,s)};return function(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");l(c,s);function h(){this.constructor=c}c.prototype=s===null?Object.create(s):(h.prototype=s.prototype,new h)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.GastRefResolverVisitor=n.resolveGrammar=void 0;var t=Ye(),i=xe(),r=ut();function a(l,c){var s=new o(l,c);return s.resolveRefs(),s.errors}n.resolveGrammar=a;var o=(function(l){e(c,l);function c(s,h){var f=l.call(this)||this;return f.nameToTopRule=s,f.errMsgProvider=h,f.errors=[],f}return c.prototype.resolveRefs=function(){var s=this;i.forEach(i.values(this.nameToTopRule),function(h){s.currTopLevel=h,h.accept(s)})},c.prototype.visitNonTerminal=function(s){var h=this.nameToTopRule[s.nonTerminalName];if(h)s.referencedRule=h;else{var f=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,s);this.errors.push({message:f,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:s.nonTerminalName})}},c})(r.GAstVisitor);n.GastRefResolverVisitor=o}),gt=ve(n=>{var e=n&&n.__extends||(function(){var u=function(d,y){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,E){v.__proto__=E}||function(v,E){for(var b in E)Object.prototype.hasOwnProperty.call(E,b)&&(v[b]=E[b])},u(d,y)};return function(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");u(d,y);function v(){this.constructor=d}d.prototype=y===null?Object.create(y):(v.prototype=y.prototype,new v)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.nextPossibleTokensAfter=n.possiblePathsFrom=n.NextTerminalAfterAtLeastOneSepWalker=n.NextTerminalAfterAtLeastOneWalker=n.NextTerminalAfterManySepWalker=n.NextTerminalAfterManyWalker=n.AbstractNextTerminalAfterProductionWalker=n.NextAfterTokenWalker=n.AbstractNextPossibleTokensWalker=void 0;var t=Ct(),i=xe(),r=mn(),a=He(),o=(function(u){e(d,u);function d(y,v){var E=u.call(this)||this;return E.topProd=y,E.path=v,E.possibleTokTypes=[],E.nextProductionName="",E.nextProductionOccurrence=0,E.found=!1,E.isAtEndOfPath=!1,E}return d.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=i.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=i.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},d.prototype.walk=function(y,v){v===void 0&&(v=[]),this.found||u.prototype.walk.call(this,y,v)},d.prototype.walkProdRef=function(y,v,E){if(y.referencedRule.name===this.nextProductionName&&y.idx===this.nextProductionOccurrence){var b=v.concat(E);this.updateExpectedNext(),this.walk(y.referencedRule,b)}},d.prototype.updateExpectedNext=function(){i.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},d})(t.RestWalker);n.AbstractNextPossibleTokensWalker=o;var l=(function(u){e(d,u);function d(y,v){var E=u.call(this,y,v)||this;return E.path=v,E.nextTerminalName="",E.nextTerminalOccurrence=0,E.nextTerminalName=E.path.lastTok.name,E.nextTerminalOccurrence=E.path.lastTokOccurrence,E}return d.prototype.walkTerminal=function(y,v,E){if(this.isAtEndOfPath&&y.terminalType.name===this.nextTerminalName&&y.idx===this.nextTerminalOccurrence&&!this.found){var b=v.concat(E),P=new a.Alternative({definition:b});this.possibleTokTypes=r.first(P),this.found=!0}},d})(o);n.NextAfterTokenWalker=l;var c=(function(u){e(d,u);function d(y,v){var E=u.call(this)||this;return E.topRule=y,E.occurrence=v,E.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},E}return d.prototype.startWalking=function(){return this.walk(this.topRule),this.result},d})(t.RestWalker);n.AbstractNextTerminalAfterProductionWalker=c;var s=(function(u){e(d,u);function d(){return u!==null&&u.apply(this,arguments)||this}return d.prototype.walkMany=function(y,v,E){if(y.idx===this.occurrence){var b=i.first(v.concat(E));this.result.isEndOfRule=b===void 0,b instanceof a.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else u.prototype.walkMany.call(this,y,v,E)},d})(c);n.NextTerminalAfterManyWalker=s;var h=(function(u){e(d,u);function d(){return u!==null&&u.apply(this,arguments)||this}return d.prototype.walkManySep=function(y,v,E){if(y.idx===this.occurrence){var b=i.first(v.concat(E));this.result.isEndOfRule=b===void 0,b instanceof a.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else u.prototype.walkManySep.call(this,y,v,E)},d})(c);n.NextTerminalAfterManySepWalker=h;var f=(function(u){e(d,u);function d(){return u!==null&&u.apply(this,arguments)||this}return d.prototype.walkAtLeastOne=function(y,v,E){if(y.idx===this.occurrence){var b=i.first(v.concat(E));this.result.isEndOfRule=b===void 0,b instanceof a.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else u.prototype.walkAtLeastOne.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneWalker=f;var g=(function(u){e(d,u);function d(){return u!==null&&u.apply(this,arguments)||this}return d.prototype.walkAtLeastOneSep=function(y,v,E){if(y.idx===this.occurrence){var b=i.first(v.concat(E));this.result.isEndOfRule=b===void 0,b instanceof a.Terminal&&(this.result.token=b.terminalType,this.result.occurrence=b.idx)}else u.prototype.walkAtLeastOneSep.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneSepWalker=g;function p(u,d,y){y===void 0&&(y=[]),y=i.cloneArr(y);var v=[],E=0;function b(x){return x.concat(i.drop(u,E+1))}function P(x){var G=p(b(x),d,y);return v.concat(G)}for(;y.length<d&&E<u.length;){var w=u[E];if(w instanceof a.Alternative||w instanceof a.NonTerminal)return P(w.definition);if(w instanceof a.Option)v=P(w.definition);else if(w instanceof a.RepetitionMandatory){var Y=w.definition.concat([new a.Repetition({definition:w.definition})]);return P(Y)}else if(w instanceof a.RepetitionMandatoryWithSeparator){var Y=[new a.Alternative({definition:w.definition}),new a.Repetition({definition:[new a.Terminal({terminalType:w.separator})].concat(w.definition)})];return P(Y)}else if(w instanceof a.RepetitionWithSeparator){var Y=w.definition.concat([new a.Repetition({definition:[new a.Terminal({terminalType:w.separator})].concat(w.definition)})]);v=P(Y)}else if(w instanceof a.Repetition){var Y=w.definition.concat([new a.Repetition({definition:w.definition})]);v=P(Y)}else{if(w instanceof a.Alternation)return i.forEach(w.definition,function(x){i.isEmpty(x.definition)===!1&&(v=P(x.definition))}),v;if(w instanceof a.Terminal)y.push(w.terminalType);else throw Error("non exhaustive match")}E++}return v.push({partialPath:y,suffixDef:i.drop(u,E)}),v}n.possiblePathsFrom=p;function T(u,d,y,v){var E="EXIT_NONE_TERMINAL",b=[E],P="EXIT_ALTERNATIVE",w=!1,Y=d.length,x=Y-v-1,G=[],M=[];for(M.push({idx:-1,def:u,ruleStack:[],occurrenceStack:[]});!i.isEmpty(M);){var O=M.pop();if(O===P){w&&i.last(M).idx<=x&&M.pop();continue}var C=O.def,k=O.idx,X=O.ruleStack,Q=O.occurrenceStack;if(!i.isEmpty(C)){var H=C[0];if(H===E){var $={idx:k,def:i.drop(C),ruleStack:i.dropRight(X),occurrenceStack:i.dropRight(Q)};M.push($)}else if(H instanceof a.Terminal)if(k<Y-1){var te=k+1,ae=d[te];if(y(ae,H.terminalType)){var $={idx:te,def:i.drop(C),ruleStack:X,occurrenceStack:Q};M.push($)}}else if(k===Y-1)G.push({nextTokenType:H.terminalType,nextTokenOccurrence:H.idx,ruleStack:X,occurrenceStack:Q}),w=!0;else throw Error("non exhaustive match");else if(H instanceof a.NonTerminal){var se=i.cloneArr(X);se.push(H.nonTerminalName);var ce=i.cloneArr(Q);ce.push(H.idx);var $={idx:k,def:H.definition.concat(b,i.drop(C)),ruleStack:se,occurrenceStack:ce};M.push($)}else if(H instanceof a.Option){var ne={idx:k,def:i.drop(C),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(P);var de={idx:k,def:H.definition.concat(i.drop(C)),ruleStack:X,occurrenceStack:Q};M.push(de)}else if(H instanceof a.RepetitionMandatory){var U=new a.Repetition({definition:H.definition,idx:H.idx}),z=H.definition.concat([U],i.drop(C)),$={idx:k,def:z,ruleStack:X,occurrenceStack:Q};M.push($)}else if(H instanceof a.RepetitionMandatoryWithSeparator){var W=new a.Terminal({terminalType:H.separator}),U=new a.Repetition({definition:[W].concat(H.definition),idx:H.idx}),z=H.definition.concat([U],i.drop(C)),$={idx:k,def:z,ruleStack:X,occurrenceStack:Q};M.push($)}else if(H instanceof a.RepetitionWithSeparator){var ne={idx:k,def:i.drop(C),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(P);var W=new a.Terminal({terminalType:H.separator}),q=new a.Repetition({definition:[W].concat(H.definition),idx:H.idx}),z=H.definition.concat([q],i.drop(C)),de={idx:k,def:z,ruleStack:X,occurrenceStack:Q};M.push(de)}else if(H instanceof a.Repetition){var ne={idx:k,def:i.drop(C),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(P);var q=new a.Repetition({definition:H.definition,idx:H.idx}),z=H.definition.concat([q],i.drop(C)),de={idx:k,def:z,ruleStack:X,occurrenceStack:Q};M.push(de)}else if(H instanceof a.Alternation)for(var Z=H.definition.length-1;Z>=0;Z--){var ie=H.definition[Z],Te={idx:k,def:ie.definition.concat(i.drop(C)),ruleStack:X,occurrenceStack:Q};M.push(Te),M.push(P)}else if(H instanceof a.Alternative)M.push({idx:k,def:H.definition.concat(i.drop(C)),ruleStack:X,occurrenceStack:Q});else if(H instanceof a.Rule)M.push(m(H,k,X,Q));else throw Error("non exhaustive match")}}return G}n.nextPossibleTokensAfter=T;function m(u,d,y,v){var E=i.cloneArr(y);E.push(u.name);var b=i.cloneArr(v);return b.push(1),{idx:d,def:u.definition,ruleStack:E,occurrenceStack:b}}}),Tt=ve(n=>{var e=n&&n.__extends||(function(){var x=function(G,M){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,C){O.__proto__=C}||function(O,C){for(var k in C)Object.prototype.hasOwnProperty.call(C,k)&&(O[k]=C[k])},x(G,M)};return function(G,M){if(typeof M!="function"&&M!==null)throw new TypeError("Class extends value "+String(M)+" is not a constructor or null");x(G,M);function O(){this.constructor=G}G.prototype=M===null?Object.create(M):(O.prototype=M.prototype,new O)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.areTokenCategoriesNotUsed=n.isStrictPrefixOfPath=n.containsPath=n.getLookaheadPathsForOptionalProd=n.getLookaheadPathsForOr=n.lookAheadSequenceFromAlternatives=n.buildSingleAlternativeLookaheadFunction=n.buildAlternativesLookAheadFunc=n.buildLookaheadFuncForOptionalProd=n.buildLookaheadFuncForOr=n.getProdType=n.PROD_TYPE=void 0;var t=xe(),i=gt(),r=Ct(),a=ct(),o=He(),l=ut(),c;(function(x){x[x.OPTION=0]="OPTION",x[x.REPETITION=1]="REPETITION",x[x.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",x[x.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",x[x.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",x[x.ALTERNATION=5]="ALTERNATION"})(c=n.PROD_TYPE||(n.PROD_TYPE={}));function s(x){if(x instanceof o.Option)return c.OPTION;if(x instanceof o.Repetition)return c.REPETITION;if(x instanceof o.RepetitionMandatory)return c.REPETITION_MANDATORY;if(x instanceof o.RepetitionMandatoryWithSeparator)return c.REPETITION_MANDATORY_WITH_SEPARATOR;if(x instanceof o.RepetitionWithSeparator)return c.REPETITION_WITH_SEPARATOR;if(x instanceof o.Alternation)return c.ALTERNATION;throw Error("non exhaustive match")}n.getProdType=s;function h(x,G,M,O,C,k){var X=E(x,G,M),Q=Y(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return k(X,O,Q,C)}n.buildLookaheadFuncForOr=h;function f(x,G,M,O,C,k){var X=b(x,G,C,M),Q=Y(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return k(X[0],Q,O)}n.buildLookaheadFuncForOptionalProd=f;function g(x,G,M,O){var C=x.length,k=t.every(x,function(H){return t.every(H,function($){return $.length===1})});if(G)return function(H){for(var $=t.map(H,function(q){return q.GATE}),te=0;te<C;te++){var ae=x[te],se=ae.length,ce=$[te];if(!(ce!==void 0&&ce.call(this)===!1))e:for(var ne=0;ne<se;ne++){for(var de=ae[ne],U=de.length,z=0;z<U;z++){var W=this.LA(z+1);if(M(W,de[z])===!1)continue e}return te}}};if(k&&!O){var X=t.map(x,function(H){return t.flatten(H)}),Q=t.reduce(X,function(H,$,te){return t.forEach($,function(ae){t.has(H,ae.tokenTypeIdx)||(H[ae.tokenTypeIdx]=te),t.forEach(ae.categoryMatches,function(se){t.has(H,se)||(H[se]=te)})}),H},[]);return function(){var H=this.LA(1);return Q[H.tokenTypeIdx]}}else return function(){for(var H=0;H<C;H++){var $=x[H],te=$.length;e:for(var ae=0;ae<te;ae++){for(var se=$[ae],ce=se.length,ne=0;ne<ce;ne++){var de=this.LA(ne+1);if(M(de,se[ne])===!1)continue e}return H}}}}n.buildAlternativesLookAheadFunc=g;function p(x,G,M){var O=t.every(x,function($){return $.length===1}),C=x.length;if(O&&!M){var k=t.flatten(x);if(k.length===1&&t.isEmpty(k[0].categoryMatches)){var X=k[0],Q=X.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===Q}}else{var H=t.reduce(k,function($,te,ae){return $[te.tokenTypeIdx]=!0,t.forEach(te.categoryMatches,function(se){$[se]=!0}),$},[]);return function(){var $=this.LA(1);return H[$.tokenTypeIdx]===!0}}}else return function(){e:for(var $=0;$<C;$++){for(var te=x[$],ae=te.length,se=0;se<ae;se++){var ce=this.LA(se+1);if(G(ce,te[se])===!1)continue e}return!0}return!1}}n.buildSingleAlternativeLookaheadFunction=p;var T=(function(x){e(G,x);function G(M,O,C){var k=x.call(this)||this;return k.topProd=M,k.targetOccurrence=O,k.targetProdType=C,k}return G.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},G.prototype.checkIsTarget=function(M,O,C,k){return M.idx===this.targetOccurrence&&this.targetProdType===O?(this.restDef=C.concat(k),!0):!1},G.prototype.walkOption=function(M,O,C){this.checkIsTarget(M,c.OPTION,O,C)||x.prototype.walkOption.call(this,M,O,C)},G.prototype.walkAtLeastOne=function(M,O,C){this.checkIsTarget(M,c.REPETITION_MANDATORY,O,C)||x.prototype.walkOption.call(this,M,O,C)},G.prototype.walkAtLeastOneSep=function(M,O,C){this.checkIsTarget(M,c.REPETITION_MANDATORY_WITH_SEPARATOR,O,C)||x.prototype.walkOption.call(this,M,O,C)},G.prototype.walkMany=function(M,O,C){this.checkIsTarget(M,c.REPETITION,O,C)||x.prototype.walkOption.call(this,M,O,C)},G.prototype.walkManySep=function(M,O,C){this.checkIsTarget(M,c.REPETITION_WITH_SEPARATOR,O,C)||x.prototype.walkOption.call(this,M,O,C)},G})(r.RestWalker),m=(function(x){e(G,x);function G(M,O,C){var k=x.call(this)||this;return k.targetOccurrence=M,k.targetProdType=O,k.targetRef=C,k.result=[],k}return G.prototype.checkIsTarget=function(M,O){M.idx===this.targetOccurrence&&this.targetProdType===O&&(this.targetRef===void 0||M===this.targetRef)&&(this.result=M.definition)},G.prototype.visitOption=function(M){this.checkIsTarget(M,c.OPTION)},G.prototype.visitRepetition=function(M){this.checkIsTarget(M,c.REPETITION)},G.prototype.visitRepetitionMandatory=function(M){this.checkIsTarget(M,c.REPETITION_MANDATORY)},G.prototype.visitRepetitionMandatoryWithSeparator=function(M){this.checkIsTarget(M,c.REPETITION_MANDATORY_WITH_SEPARATOR)},G.prototype.visitRepetitionWithSeparator=function(M){this.checkIsTarget(M,c.REPETITION_WITH_SEPARATOR)},G.prototype.visitAlternation=function(M){this.checkIsTarget(M,c.ALTERNATION)},G})(l.GAstVisitor);function u(x){for(var G=new Array(x),M=0;M<x;M++)G[M]=[];return G}function d(x){for(var G=[""],M=0;M<x.length;M++){for(var O=x[M],C=[],k=0;k<G.length;k++){var X=G[k];C.push(X+"_"+O.tokenTypeIdx);for(var Q=0;Q<O.categoryMatches.length;Q++){var H="_"+O.categoryMatches[Q];C.push(X+H)}}G=C}return G}function y(x,G,M){for(var O=0;O<x.length;O++)if(O!==M)for(var C=x[O],k=0;k<G.length;k++){var X=G[k];if(C[X]===!0)return!1}return!0}function v(x,G){for(var M=t.map(x,function(te){return i.possiblePathsFrom([te],1)}),O=u(M.length),C=t.map(M,function(te){var ae={};return t.forEach(te,function(se){var ce=d(se.partialPath);t.forEach(ce,function(ne){ae[ne]=!0})}),ae}),k=M,X=1;X<=G;X++){var Q=k;k=u(Q.length);for(var H=function(te){for(var ae=Q[te],se=0;se<ae.length;se++){var ce=ae[se].partialPath,ne=ae[se].suffixDef,de=d(ce),U=y(C,de,te);if(U||t.isEmpty(ne)||ce.length===G){var z=O[te];if(P(z,ce)===!1){z.push(ce);for(var W=0;W<de.length;W++){var q=de[W];C[te][q]=!0}}}else{var Z=i.possiblePathsFrom(ne,X+1,ce);k[te]=k[te].concat(Z),t.forEach(Z,function(ie){var Te=d(ie.partialPath);t.forEach(Te,function(me){C[te][me]=!0})})}}},$=0;$<Q.length;$++)H($)}return O}n.lookAheadSequenceFromAlternatives=v;function E(x,G,M,O){var C=new m(x,c.ALTERNATION,O);return G.accept(C),v(C.result,M)}n.getLookaheadPathsForOr=E;function b(x,G,M,O){var C=new m(x,M);G.accept(C);var k=C.result,X=new T(G,x,M),Q=X.startWalking(),H=new o.Alternative({definition:k}),$=new o.Alternative({definition:Q});return v([H,$],O)}n.getLookaheadPathsForOptionalProd=b;function P(x,G){e:for(var M=0;M<x.length;M++){var O=x[M];if(O.length===G.length){for(var C=0;C<O.length;C++){var k=G[C],X=O[C],Q=k===X||X.categoryMatchesMap[k.tokenTypeIdx]!==void 0;if(Q===!1)continue e}return!0}}return!1}n.containsPath=P;function w(x,G){return x.length<G.length&&t.every(x,function(M,O){var C=G[O];return M===C||C.categoryMatchesMap[M.tokenTypeIdx]})}n.isStrictPrefixOfPath=w;function Y(x){return t.every(x,function(G){return t.every(G,function(M){return t.every(M,function(O){return t.isEmpty(O.categoryMatches)})})})}n.areTokenCategoriesNotUsed=Y}),gn=ve(n=>{var e=n&&n.__extends||(function(){var O=function(C,k){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(X,Q){X.__proto__=Q}||function(X,Q){for(var H in Q)Object.prototype.hasOwnProperty.call(Q,H)&&(X[H]=Q[H])},O(C,k)};return function(C,k){if(typeof k!="function"&&k!==null)throw new TypeError("Class extends value "+String(k)+" is not a constructor or null");O(C,k);function X(){this.constructor=C}C.prototype=k===null?Object.create(k):(X.prototype=k.prototype,new X)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.checkPrefixAlternativesAmbiguities=n.validateSomeNonEmptyLookaheadPath=n.validateTooManyAlts=n.RepetionCollector=n.validateAmbiguousAlternationAlternatives=n.validateEmptyOrAlternative=n.getFirstNoneTerminal=n.validateNoLeftRecursion=n.validateRuleIsOverridden=n.validateRuleDoesNotAlreadyExist=n.OccurrenceValidationCollector=n.identifyProductionForDuplicates=n.validateGrammar=void 0;var t=xe(),i=xe(),r=Ye(),a=mt(),o=Tt(),l=gt(),c=He(),s=ut();function h(O,C,k,X,Q){var H=t.map(O,function(U){return f(U,X)}),$=t.map(O,function(U){return d(U,U,X)}),te=[],ae=[],se=[];i.every($,i.isEmpty)&&(te=i.map(O,function(U){return E(U,X)}),ae=i.map(O,function(U){return b(U,C,X)}),se=Y(O,C,X));var ce=M(O,k,X),ne=i.map(O,function(U){return w(U,X)}),de=i.map(O,function(U){return m(U,O,Q,X)});return t.flatten(H.concat(se,$,te,ae,ce,ne,de))}n.validateGrammar=h;function f(O,C){var k=new T;O.accept(k);var X=k.allProductions,Q=t.groupBy(X,g),H=t.pick(Q,function(te){return te.length>1}),$=t.map(t.values(H),function(te){var ae=t.first(te),se=C.buildDuplicateFoundError(O,te),ce=a.getProductionDslName(ae),ne={message:se,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:O.name,dslName:ce,occurrence:ae.idx},de=p(ae);return de&&(ne.parameter=de),ne});return $}function g(O){return a.getProductionDslName(O)+"_#_"+O.idx+"_#_"+p(O)}n.identifyProductionForDuplicates=g;function p(O){return O instanceof c.Terminal?O.terminalType.name:O instanceof c.NonTerminal?O.nonTerminalName:""}var T=(function(O){e(C,O);function C(){var k=O!==null&&O.apply(this,arguments)||this;return k.allProductions=[],k}return C.prototype.visitNonTerminal=function(k){this.allProductions.push(k)},C.prototype.visitOption=function(k){this.allProductions.push(k)},C.prototype.visitRepetitionWithSeparator=function(k){this.allProductions.push(k)},C.prototype.visitRepetitionMandatory=function(k){this.allProductions.push(k)},C.prototype.visitRepetitionMandatoryWithSeparator=function(k){this.allProductions.push(k)},C.prototype.visitRepetition=function(k){this.allProductions.push(k)},C.prototype.visitAlternation=function(k){this.allProductions.push(k)},C.prototype.visitTerminal=function(k){this.allProductions.push(k)},C})(s.GAstVisitor);n.OccurrenceValidationCollector=T;function m(O,C,k,X){var Q=[],H=i.reduce(C,function(te,ae){return ae.name===O.name?te+1:te},0);if(H>1){var $=X.buildDuplicateRuleNameError({topLevelRule:O,grammarName:k});Q.push({message:$,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:O.name})}return Q}n.validateRuleDoesNotAlreadyExist=m;function u(O,C,k){var X=[],Q;return t.contains(C,O)||(Q="Invalid rule override, rule: ->"+O+"<- cannot be overridden in the grammar: ->"+k+"<-as it is not defined in any of the super grammars ",X.push({message:Q,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:O})),X}n.validateRuleIsOverridden=u;function d(O,C,k,X){X===void 0&&(X=[]);var Q=[],H=y(C.definition);if(t.isEmpty(H))return[];var $=O.name,te=t.contains(H,O);te&&Q.push({message:k.buildLeftRecursionError({topLevelRule:O,leftRecursionPath:X}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:$});var ae=t.difference(H,X.concat([O])),se=t.map(ae,function(ce){var ne=t.cloneArr(X);return ne.push(ce),d(O,ce,k,ne)});return Q.concat(t.flatten(se))}n.validateNoLeftRecursion=d;function y(O){var C=[];if(t.isEmpty(O))return C;var k=t.first(O);if(k instanceof c.NonTerminal)C.push(k.referencedRule);else if(k instanceof c.Alternative||k instanceof c.Option||k instanceof c.RepetitionMandatory||k instanceof c.RepetitionMandatoryWithSeparator||k instanceof c.RepetitionWithSeparator||k instanceof c.Repetition)C=C.concat(y(k.definition));else if(k instanceof c.Alternation)C=t.flatten(t.map(k.definition,function($){return y($.definition)}));else if(!(k instanceof c.Terminal))throw Error("non exhaustive match");var X=a.isOptionalProd(k),Q=O.length>1;if(X&&Q){var H=t.drop(O);return C.concat(y(H))}else return C}n.getFirstNoneTerminal=y;var v=(function(O){e(C,O);function C(){var k=O!==null&&O.apply(this,arguments)||this;return k.alternations=[],k}return C.prototype.visitAlternation=function(k){this.alternations.push(k)},C})(s.GAstVisitor);function E(O,C){var k=new v;O.accept(k);var X=k.alternations,Q=t.reduce(X,function(H,$){var te=t.dropRight($.definition),ae=t.map(te,function(se,ce){var ne=l.nextPossibleTokensAfter([se],[],null,1);return t.isEmpty(ne)?{message:C.buildEmptyAlternationError({topLevelRule:O,alternation:$,emptyChoiceIdx:ce}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:O.name,occurrence:$.idx,alternative:ce+1}:null});return H.concat(t.compact(ae))},[]);return Q}n.validateEmptyOrAlternative=E;function b(O,C,k){var X=new v;O.accept(X);var Q=X.alternations;Q=i.reject(Q,function($){return $.ignoreAmbiguities===!0});var H=t.reduce(Q,function($,te){var ae=te.idx,se=te.maxLookahead||C,ce=o.getLookaheadPathsForOr(ae,O,se,te),ne=x(ce,te,O,k),de=G(ce,te,O,k);return $.concat(ne,de)},[]);return H}n.validateAmbiguousAlternationAlternatives=b;var P=(function(O){e(C,O);function C(){var k=O!==null&&O.apply(this,arguments)||this;return k.allProductions=[],k}return C.prototype.visitRepetitionWithSeparator=function(k){this.allProductions.push(k)},C.prototype.visitRepetitionMandatory=function(k){this.allProductions.push(k)},C.prototype.visitRepetitionMandatoryWithSeparator=function(k){this.allProductions.push(k)},C.prototype.visitRepetition=function(k){this.allProductions.push(k)},C})(s.GAstVisitor);n.RepetionCollector=P;function w(O,C){var k=new v;O.accept(k);var X=k.alternations,Q=t.reduce(X,function(H,$){return $.definition.length>255&&H.push({message:C.buildTooManyAlternativesError({topLevelRule:O,alternation:$}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:O.name,occurrence:$.idx}),H},[]);return Q}n.validateTooManyAlts=w;function Y(O,C,k){var X=[];return i.forEach(O,function(Q){var H=new P;Q.accept(H);var $=H.allProductions;i.forEach($,function(te){var ae=o.getProdType(te),se=te.maxLookahead||C,ce=te.idx,ne=o.getLookaheadPathsForOptionalProd(ce,Q,ae,se),de=ne[0];if(i.isEmpty(i.flatten(de))){var U=k.buildEmptyRepetitionError({topLevelRule:Q,repetition:te});X.push({message:U,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:Q.name})}})}),X}n.validateSomeNonEmptyLookaheadPath=Y;function x(O,C,k,X){var Q=[],H=i.reduce(O,function(te,ae,se){return C.definition[se].ignoreAmbiguities===!0||i.forEach(ae,function(ce){var ne=[se];i.forEach(O,function(de,U){se!==U&&o.containsPath(de,ce)&&C.definition[U].ignoreAmbiguities!==!0&&ne.push(U)}),ne.length>1&&!o.containsPath(Q,ce)&&(Q.push(ce),te.push({alts:ne,path:ce}))}),te},[]),$=t.map(H,function(te){var ae=i.map(te.alts,function(ce){return ce+1}),se=X.buildAlternationAmbiguityError({topLevelRule:k,alternation:C,ambiguityIndices:ae,prefixPath:te.path});return{message:se,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:k.name,occurrence:C.idx,alternatives:[te.alts]}});return $}function G(O,C,k,X){var Q=[],H=i.reduce(O,function($,te,ae){var se=i.map(te,function(ce){return{idx:ae,path:ce}});return $.concat(se)},[]);return i.forEach(H,function($){var te=C.definition[$.idx];if(te.ignoreAmbiguities!==!0){var ae=$.idx,se=$.path,ce=i.findAll(H,function(de){return C.definition[de.idx].ignoreAmbiguities!==!0&&de.idx<ae&&o.isStrictPrefixOfPath(de.path,se)}),ne=i.map(ce,function(de){var U=[de.idx+1,ae+1],z=C.idx===0?"":C.idx,W=X.buildAlternationPrefixAmbiguityError({topLevelRule:k,alternation:C,ambiguityIndices:U,prefixPath:de.path});return{message:W,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:k.name,occurrence:z,alternatives:U}});Q=Q.concat(ne)}}),Q}n.checkPrefixAlternativesAmbiguities=G;function M(O,C,k){var X=[],Q=i.map(C,function(H){return H.name});return i.forEach(O,function(H){var $=H.name;if(i.contains(Q,$)){var te=k.buildNamespaceConflictError(H);X.push({message:te,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:$})}}),X}}),Jr=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateGrammar=n.resolveGrammar=void 0;var e=xe(),t=Zr(),i=gn(),r=yt();function a(l){l=e.defaults(l,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var c={};return e.forEach(l.rules,function(s){c[s.name]=s}),t.resolveGrammar(c,l.errMsgProvider)}n.resolveGrammar=a;function o(l){return l=e.defaults(l,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),i.validateGrammar(l.rules,l.maxLookahead,l.tokenTypes,l.errMsgProvider,l.grammarName)}n.validateGrammar=o}),lt=ve(n=>{var e=n&&n.__extends||(function(){var T=function(m,u){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,y){d.__proto__=y}||function(d,y){for(var v in y)Object.prototype.hasOwnProperty.call(y,v)&&(d[v]=y[v])},T(m,u)};return function(m,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");T(m,u);function d(){this.constructor=m}m.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.EarlyExitException=n.NotAllInputParsedException=n.NoViableAltException=n.MismatchedTokenException=n.isRecognitionException=void 0;var t=xe(),i="MismatchedTokenException",r="NoViableAltException",a="EarlyExitException",o="NotAllInputParsedException",l=[i,r,a,o];Object.freeze(l);function c(T){return t.contains(l,T.name)}n.isRecognitionException=c;var s=(function(T){e(m,T);function m(u,d){var y=this.constructor,v=T.call(this,u)||this;return v.token=d,v.resyncedTokens=[],Object.setPrototypeOf(v,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(v,v.constructor),v}return m})(Error),h=(function(T){e(m,T);function m(u,d,y){var v=T.call(this,u,d)||this;return v.previousToken=y,v.name=i,v}return m})(s);n.MismatchedTokenException=h;var f=(function(T){e(m,T);function m(u,d,y){var v=T.call(this,u,d)||this;return v.previousToken=y,v.name=r,v}return m})(s);n.NoViableAltException=f;var g=(function(T){e(m,T);function m(u,d){var y=T.call(this,u,d)||this;return y.name=o,y}return m})(s);n.NotAllInputParsedException=g;var p=(function(T){e(m,T);function m(u,d,y){var v=T.call(this,u,d)||this;return v.previousToken=y,v.name=a,v}return m})(s);n.EarlyExitException=p}),Tn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.attemptInRepetitionRecovery=n.Recoverable=n.InRuleRecoveryException=n.IN_RULE_RECOVERY_EXCEPTION=n.EOF_FOLLOW_KEY=void 0;var e=nt(),t=xe(),i=lt(),r=yn(),a=Ye();n.EOF_FOLLOW_KEY={},n.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(s){this.name=n.IN_RULE_RECOVERY_EXCEPTION,this.message=s}n.InRuleRecoveryException=o,o.prototype=Error.prototype;var l=(function(){function s(){}return s.prototype.initRecoverable=function(h){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(h,"recoveryEnabled")?h.recoveryEnabled:a.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},s.prototype.getTokenToInsert=function(h){var f=e.createTokenInstance(h,"",NaN,NaN,NaN,NaN,NaN,NaN);return f.isInsertedInRecovery=!0,f},s.prototype.canTokenTypeBeInsertedInRecovery=function(h){return!0},s.prototype.tryInRepetitionRecovery=function(h,f,g,p){for(var T=this,m=this.findReSyncTokenType(),u=this.exportLexerState(),d=[],y=!1,v=this.LA(1),E=this.LA(1),b=function(){var P=T.LA(0),w=T.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:v,previous:P,ruleName:T.getCurrRuleFullName()}),Y=new i.MismatchedTokenException(w,v,T.LA(0));Y.resyncedTokens=t.dropRight(d),T.SAVE_ERROR(Y)};!y;)if(this.tokenMatcher(E,p)){b();return}else if(g.call(this)){b(),h.apply(this,f);return}else this.tokenMatcher(E,m)?y=!0:(E=this.SKIP_TOKEN(),this.addToResyncTokens(E,d));this.importLexerState(u)},s.prototype.shouldInRepetitionRecoveryBeTried=function(h,f,g){return!(g===!1||h===void 0||f===void 0||this.tokenMatcher(this.LA(1),h)||this.isBackTracking()||this.canPerformInRuleRecovery(h,this.getFollowsForInRuleRecovery(h,f)))},s.prototype.getFollowsForInRuleRecovery=function(h,f){var g=this.getCurrentGrammarPath(h,f),p=this.getNextPossibleTokenTypes(g);return p},s.prototype.tryInRuleRecovery=function(h,f){if(this.canRecoverWithSingleTokenInsertion(h,f)){var g=this.getTokenToInsert(h);return g}if(this.canRecoverWithSingleTokenDeletion(h)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},s.prototype.canPerformInRuleRecovery=function(h,f){return this.canRecoverWithSingleTokenInsertion(h,f)||this.canRecoverWithSingleTokenDeletion(h)},s.prototype.canRecoverWithSingleTokenInsertion=function(h,f){var g=this;if(!this.canTokenTypeBeInsertedInRecovery(h)||t.isEmpty(f))return!1;var p=this.LA(1),T=t.find(f,function(m){return g.tokenMatcher(p,m)})!==void 0;return T},s.prototype.canRecoverWithSingleTokenDeletion=function(h){var f=this.tokenMatcher(this.LA(2),h);return f},s.prototype.isInCurrentRuleReSyncSet=function(h){var f=this.getCurrFollowKey(),g=this.getFollowSetFromFollowKey(f);return t.contains(g,h)},s.prototype.findReSyncTokenType=function(){for(var h=this.flattenFollowSet(),f=this.LA(1),g=2;;){var p=f.tokenType;if(t.contains(h,p))return p;f=this.LA(g),g++}},s.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return n.EOF_FOLLOW_KEY;var h=this.getLastExplicitRuleShortName(),f=this.getLastExplicitRuleOccurrenceIndex(),g=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(h),idxInCallingRule:f,inRule:this.shortRuleNameToFullName(g)}},s.prototype.buildFullFollowKeyStack=function(){var h=this,f=this.RULE_STACK,g=this.RULE_OCCURRENCE_STACK;return t.map(f,function(p,T){return T===0?n.EOF_FOLLOW_KEY:{ruleName:h.shortRuleNameToFullName(p),idxInCallingRule:g[T],inRule:h.shortRuleNameToFullName(f[T-1])}})},s.prototype.flattenFollowSet=function(){var h=this,f=t.map(this.buildFullFollowKeyStack(),function(g){return h.getFollowSetFromFollowKey(g)});return t.flatten(f)},s.prototype.getFollowSetFromFollowKey=function(h){if(h===n.EOF_FOLLOW_KEY)return[e.EOF];var f=h.ruleName+h.idxInCallingRule+r.IN+h.inRule;return this.resyncFollows[f]},s.prototype.addToResyncTokens=function(h,f){return this.tokenMatcher(h,e.EOF)||f.push(h),f},s.prototype.reSyncTo=function(h){for(var f=[],g=this.LA(1);this.tokenMatcher(g,h)===!1;)g=this.SKIP_TOKEN(),this.addToResyncTokens(g,f);return t.dropRight(f)},s.prototype.attemptInRepetitionRecovery=function(h,f,g,p,T,m,u){},s.prototype.getCurrentGrammarPath=function(h,f){var g=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),T={ruleStack:g,occurrenceStack:p,lastTok:h,lastTokOccurrence:f};return T},s.prototype.getHumanReadableRuleStack=function(){var h=this;return t.map(this.RULE_STACK,function(f){return h.shortRuleNameToFullName(f)})},s})();n.Recoverable=l;function c(s,h,f,g,p,T,m){var u=this.getKeyForAutomaticLookahead(g,p),d=this.firstAfterRepMap[u];if(d===void 0){var y=this.getCurrRuleFullName(),v=this.getGAstProductions()[y],E=new T(v,p);d=E.startWalking(),this.firstAfterRepMap[u]=d}var b=d.token,P=d.occurrence,w=d.isEndOfRule;this.RULE_STACK.length===1&&w&&b===void 0&&(b=e.EOF,P=1),this.shouldInRepetitionRecoveryBeTried(b,P,m)&&this.tryInRepetitionRecovery(s,h,f,b)}n.attemptInRepetitionRecovery=c}),Pt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getKeyForAutomaticLookahead=n.AT_LEAST_ONE_SEP_IDX=n.MANY_SEP_IDX=n.AT_LEAST_ONE_IDX=n.MANY_IDX=n.OPTION_IDX=n.OR_IDX=n.BITS_FOR_ALT_IDX=n.BITS_FOR_RULE_IDX=n.BITS_FOR_OCCURRENCE_IDX=n.BITS_FOR_METHOD_TYPE=void 0,n.BITS_FOR_METHOD_TYPE=4,n.BITS_FOR_OCCURRENCE_IDX=8,n.BITS_FOR_RULE_IDX=12,n.BITS_FOR_ALT_IDX=8,n.OR_IDX=1<<n.BITS_FOR_OCCURRENCE_IDX,n.OPTION_IDX=2<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_IDX=3<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_IDX=4<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_SEP_IDX=5<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_SEP_IDX=6<<n.BITS_FOR_OCCURRENCE_IDX;function e(t,i,r){return r|i|t}n.getKeyForAutomaticLookahead=e,32-n.BITS_FOR_ALT_IDX}),$r=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LooksAhead=void 0;var e=Tt(),t=xe(),i=Ye(),r=Pt(),a=mt(),o=(function(){function l(){}return l.prototype.initLooksAhead=function(c){this.dynamicTokensEnabled=t.has(c,"dynamicTokensEnabled")?c.dynamicTokensEnabled:i.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(c,"maxLookahead")?c.maxLookahead:i.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},l.prototype.preComputeLookaheadFunctions=function(c){var s=this;t.forEach(c,function(h){s.TRACE_INIT(h.name+" Rule Lookahead",function(){var f=a.collectMethods(h),g=f.alternation,p=f.repetition,T=f.option,m=f.repetitionMandatory,u=f.repetitionMandatoryWithSeparator,d=f.repetitionWithSeparator;t.forEach(g,function(y){var v=y.idx===0?"":y.idx;s.TRACE_INIT(""+a.getProductionDslName(y)+v,function(){var E=e.buildLookaheadFuncForOr(y.idx,h,y.maxLookahead||s.maxLookahead,y.hasPredicates,s.dynamicTokensEnabled,s.lookAheadBuilderForAlternatives),b=r.getKeyForAutomaticLookahead(s.fullRuleNameToShort[h.name],r.OR_IDX,y.idx);s.setLaFuncCache(b,E)})}),t.forEach(p,function(y){s.computeLookaheadFunc(h,y.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(T,function(y){s.computeLookaheadFunc(h,y.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(m,function(y){s.computeLookaheadFunc(h,y.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(u,function(y){s.computeLookaheadFunc(h,y.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(d,function(y){s.computeLookaheadFunc(h,y.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))})})})},l.prototype.computeLookaheadFunc=function(c,s,h,f,g,p){var T=this;this.TRACE_INIT(""+p+(s===0?"":s),function(){var m=e.buildLookaheadFuncForOptionalProd(s,c,g||T.maxLookahead,T.dynamicTokensEnabled,f,T.lookAheadBuilderForOptional),u=r.getKeyForAutomaticLookahead(T.fullRuleNameToShort[c.name],h,s);T.setLaFuncCache(u,m)})},l.prototype.lookAheadBuilderForOptional=function(c,s,h){return e.buildSingleAlternativeLookaheadFunction(c,s,h)},l.prototype.lookAheadBuilderForAlternatives=function(c,s,h,f){return e.buildAlternativesLookAheadFunc(c,s,h,f)},l.prototype.getKeyForAutomaticLookahead=function(c,s){var h=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(h,c,s)},l.prototype.getLaFuncFromCache=function(c){},l.prototype.getLaFuncFromMap=function(c){return this.lookAheadFuncsCache.get(c)},l.prototype.getLaFuncFromObj=function(c){return this.lookAheadFuncsCache[c]},l.prototype.setLaFuncCache=function(c,s){},l.prototype.setLaFuncCacheUsingMap=function(c,s){this.lookAheadFuncsCache.set(c,s)},l.prototype.setLaFuncUsingObj=function(c,s){this.lookAheadFuncsCache[c]=s},l})();n.LooksAhead=o}),ei=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addNoneTerminalToCst=n.addTerminalToCst=n.setNodeLocationFull=n.setNodeLocationOnlyOffset=void 0;function e(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.endOffset=o.endOffset):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset)}n.setNodeLocationOnlyOffset=e;function t(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.startColumn=o.startColumn,a.startLine=o.startLine,a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine)}n.setNodeLocationFull=t;function i(a,o,l){a.children[l]===void 0?a.children[l]=[o]:a.children[l].push(o)}n.addTerminalToCst=i;function r(a,o,l){a.children[o]===void 0?a.children[o]=[l]:a.children[o].push(l)}n.addNoneTerminalToCst=r}),En=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defineNameProp=n.functionName=n.classNameFromInstance=void 0;var e=xe();function t(o){return r(o.constructor)}n.classNameFromInstance=t;var i="name";function r(o){var l=o.name;return l||"anonymous"}n.functionName=r;function a(o,l){var c=Object.getOwnPropertyDescriptor(o,i);return e.isUndefined(c)||c.configurable?(Object.defineProperty(o,i,{enumerable:!1,configurable:!0,writable:!1,value:l}),!0):!1}n.defineNameProp=a}),ti=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateRedundantMethods=n.validateMissingCstMethods=n.validateVisitor=n.CstVisitorDefinitionError=n.createBaseVisitorConstructorWithDefaults=n.createBaseSemanticVisitorConstructor=n.defaultVisit=void 0;var e=xe(),t=En();function i(f,g){for(var p=e.keys(f),T=p.length,m=0;m<T;m++)for(var u=p[m],d=f[u],y=d.length,v=0;v<y;v++){var E=d[v];E.tokenTypeIdx===void 0&&this[E.name](E.children,g)}}n.defaultVisit=i;function r(f,g){var p=function(){};t.defineNameProp(p,f+"BaseSemantics");var T={visit:function(m,u){if(e.isArray(m)&&(m=m[0]),!e.isUndefined(m))return this[m.name](m.children,u)},validateVisitor:function(){var m=l(this,g);if(!e.isEmpty(m)){var u=e.map(m,function(d){return d.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
|
|
163
|
-
`+(""+
|
|
162
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return f},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var u;o.topLevelRule instanceof r.Rule?u=o.topLevelRule.name:u=o.topLevelRule;var a="Duplicate definition, rule: ->"+u+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return a}}}),ni=ve(n=>{var e=n&&n.__extends||(function(){var u=function(a,s){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,h){f.__proto__=h}||function(f,h){for(var T in h)Object.prototype.hasOwnProperty.call(h,T)&&(f[T]=h[T])},u(a,s)};return function(a,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");u(a,s);function f(){this.constructor=a}a.prototype=s===null?Object.create(s):(f.prototype=s.prototype,new f)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.GastRefResolverVisitor=n.resolveGrammar=void 0;var t=Ye(),i=Oe(),r=ht();function c(u,a){var s=new o(u,a);return s.resolveRefs(),s.errors}n.resolveGrammar=c;var o=(function(u){e(a,u);function a(s,f){var h=u.call(this)||this;return h.nameToTopRule=s,h.errMsgProvider=f,h.errors=[],h}return a.prototype.resolveRefs=function(){var s=this;i.forEach(i.values(this.nameToTopRule),function(f){s.currTopLevel=f,f.accept(s)})},a.prototype.visitNonTerminal=function(s){var f=this.nameToTopRule[s.nonTerminalName];if(f)s.referencedRule=f;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,s);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:s.nonTerminalName})}},a})(r.GAstVisitor);n.GastRefResolverVisitor=o}),Et=ve(n=>{var e=n&&n.__extends||(function(){var l=function(d,m){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,E){v.__proto__=E}||function(v,E){for(var S in E)Object.prototype.hasOwnProperty.call(E,S)&&(v[S]=E[S])},l(d,m)};return function(d,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");l(d,m);function v(){this.constructor=d}d.prototype=m===null?Object.create(m):(v.prototype=m.prototype,new v)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.nextPossibleTokensAfter=n.possiblePathsFrom=n.NextTerminalAfterAtLeastOneSepWalker=n.NextTerminalAfterAtLeastOneWalker=n.NextTerminalAfterManySepWalker=n.NextTerminalAfterManyWalker=n.AbstractNextTerminalAfterProductionWalker=n.NextAfterTokenWalker=n.AbstractNextPossibleTokensWalker=void 0;var t=Ft(),i=Oe(),r=Rn(),c=He(),o=(function(l){e(d,l);function d(m,v){var E=l.call(this)||this;return E.topProd=m,E.path=v,E.possibleTokTypes=[],E.nextProductionName="",E.nextProductionOccurrence=0,E.found=!1,E.isAtEndOfPath=!1,E}return d.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=i.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=i.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},d.prototype.walk=function(m,v){v===void 0&&(v=[]),this.found||l.prototype.walk.call(this,m,v)},d.prototype.walkProdRef=function(m,v,E){if(m.referencedRule.name===this.nextProductionName&&m.idx===this.nextProductionOccurrence){var S=v.concat(E);this.updateExpectedNext(),this.walk(m.referencedRule,S)}},d.prototype.updateExpectedNext=function(){i.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},d})(t.RestWalker);n.AbstractNextPossibleTokensWalker=o;var u=(function(l){e(d,l);function d(m,v){var E=l.call(this,m,v)||this;return E.path=v,E.nextTerminalName="",E.nextTerminalOccurrence=0,E.nextTerminalName=E.path.lastTok.name,E.nextTerminalOccurrence=E.path.lastTokOccurrence,E}return d.prototype.walkTerminal=function(m,v,E){if(this.isAtEndOfPath&&m.terminalType.name===this.nextTerminalName&&m.idx===this.nextTerminalOccurrence&&!this.found){var S=v.concat(E),N=new c.Alternative({definition:S});this.possibleTokTypes=r.first(N),this.found=!0}},d})(o);n.NextAfterTokenWalker=u;var a=(function(l){e(d,l);function d(m,v){var E=l.call(this)||this;return E.topRule=m,E.occurrence=v,E.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},E}return d.prototype.startWalking=function(){return this.walk(this.topRule),this.result},d})(t.RestWalker);n.AbstractNextTerminalAfterProductionWalker=a;var s=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkMany=function(m,v,E){if(m.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof c.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkMany.call(this,m,v,E)},d})(a);n.NextTerminalAfterManyWalker=s;var f=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkManySep=function(m,v,E){if(m.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof c.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkManySep.call(this,m,v,E)},d})(a);n.NextTerminalAfterManySepWalker=f;var h=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOne=function(m,v,E){if(m.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof c.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOne.call(this,m,v,E)},d})(a);n.NextTerminalAfterAtLeastOneWalker=h;var T=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOneSep=function(m,v,E){if(m.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof c.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOneSep.call(this,m,v,E)},d})(a);n.NextTerminalAfterAtLeastOneSepWalker=T;function p(l,d,m){m===void 0&&(m=[]),m=i.cloneArr(m);var v=[],E=0;function S(O){return O.concat(i.drop(l,E+1))}function N(O){var j=p(S(O),d,m);return v.concat(j)}for(;m.length<d&&E<l.length;){var C=l[E];if(C instanceof c.Alternative||C instanceof c.NonTerminal)return N(C.definition);if(C instanceof c.Option)v=N(C.definition);else if(C instanceof c.RepetitionMandatory){var Y=C.definition.concat([new c.Repetition({definition:C.definition})]);return N(Y)}else if(C instanceof c.RepetitionMandatoryWithSeparator){var Y=[new c.Alternative({definition:C.definition}),new c.Repetition({definition:[new c.Terminal({terminalType:C.separator})].concat(C.definition)})];return N(Y)}else if(C instanceof c.RepetitionWithSeparator){var Y=C.definition.concat([new c.Repetition({definition:[new c.Terminal({terminalType:C.separator})].concat(C.definition)})]);v=N(Y)}else if(C instanceof c.Repetition){var Y=C.definition.concat([new c.Repetition({definition:C.definition})]);v=N(Y)}else{if(C instanceof c.Alternation)return i.forEach(C.definition,function(O){i.isEmpty(O.definition)===!1&&(v=N(O.definition))}),v;if(C instanceof c.Terminal)m.push(C.terminalType);else throw Error("non exhaustive match")}E++}return v.push({partialPath:m,suffixDef:i.drop(l,E)}),v}n.possiblePathsFrom=p;function g(l,d,m,v){var E="EXIT_NONE_TERMINAL",S=[E],N="EXIT_ALTERNATIVE",C=!1,Y=d.length,O=Y-v-1,j=[],M=[];for(M.push({idx:-1,def:l,ruleStack:[],occurrenceStack:[]});!i.isEmpty(M);){var x=M.pop();if(x===N){C&&i.last(M).idx<=O&&M.pop();continue}var P=x.def,k=x.idx,X=x.ruleStack,Q=x.occurrenceStack;if(!i.isEmpty(P)){var H=P[0];if(H===E){var $={idx:k,def:i.drop(P),ruleStack:i.dropRight(X),occurrenceStack:i.dropRight(Q)};M.push($)}else if(H instanceof c.Terminal)if(k<Y-1){var te=k+1,ae=d[te];if(m(ae,H.terminalType)){var $={idx:te,def:i.drop(P),ruleStack:X,occurrenceStack:Q};M.push($)}}else if(k===Y-1)j.push({nextTokenType:H.terminalType,nextTokenOccurrence:H.idx,ruleStack:X,occurrenceStack:Q}),C=!0;else throw Error("non exhaustive match");else if(H instanceof c.NonTerminal){var se=i.cloneArr(X);se.push(H.nonTerminalName);var ce=i.cloneArr(Q);ce.push(H.idx);var $={idx:k,def:H.definition.concat(S,i.drop(P)),ruleStack:se,occurrenceStack:ce};M.push($)}else if(H instanceof c.Option){var ne={idx:k,def:i.drop(P),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(N);var pe={idx:k,def:H.definition.concat(i.drop(P)),ruleStack:X,occurrenceStack:Q};M.push(pe)}else if(H instanceof c.RepetitionMandatory){var U=new c.Repetition({definition:H.definition,idx:H.idx}),G=H.definition.concat([U],i.drop(P)),$={idx:k,def:G,ruleStack:X,occurrenceStack:Q};M.push($)}else if(H instanceof c.RepetitionMandatoryWithSeparator){var W=new c.Terminal({terminalType:H.separator}),U=new c.Repetition({definition:[W].concat(H.definition),idx:H.idx}),G=H.definition.concat([U],i.drop(P)),$={idx:k,def:G,ruleStack:X,occurrenceStack:Q};M.push($)}else if(H instanceof c.RepetitionWithSeparator){var ne={idx:k,def:i.drop(P),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(N);var W=new c.Terminal({terminalType:H.separator}),q=new c.Repetition({definition:[W].concat(H.definition),idx:H.idx}),G=H.definition.concat([q],i.drop(P)),pe={idx:k,def:G,ruleStack:X,occurrenceStack:Q};M.push(pe)}else if(H instanceof c.Repetition){var ne={idx:k,def:i.drop(P),ruleStack:X,occurrenceStack:Q};M.push(ne),M.push(N);var q=new c.Repetition({definition:H.definition,idx:H.idx}),G=H.definition.concat([q],i.drop(P)),pe={idx:k,def:G,ruleStack:X,occurrenceStack:Q};M.push(pe)}else if(H instanceof c.Alternation)for(var Z=H.definition.length-1;Z>=0;Z--){var ie=H.definition[Z],Te={idx:k,def:ie.definition.concat(i.drop(P)),ruleStack:X,occurrenceStack:Q};M.push(Te),M.push(N)}else if(H instanceof c.Alternative)M.push({idx:k,def:H.definition.concat(i.drop(P)),ruleStack:X,occurrenceStack:Q});else if(H instanceof c.Rule)M.push(y(H,k,X,Q));else throw Error("non exhaustive match")}}return j}n.nextPossibleTokensAfter=g;function y(l,d,m,v){var E=i.cloneArr(m);E.push(l.name);var S=i.cloneArr(v);return S.push(1),{idx:d,def:l.definition,ruleStack:E,occurrenceStack:S}}}),vt=ve(n=>{var e=n&&n.__extends||(function(){var O=function(j,M){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,P){x.__proto__=P}||function(x,P){for(var k in P)Object.prototype.hasOwnProperty.call(P,k)&&(x[k]=P[k])},O(j,M)};return function(j,M){if(typeof M!="function"&&M!==null)throw new TypeError("Class extends value "+String(M)+" is not a constructor or null");O(j,M);function x(){this.constructor=j}j.prototype=M===null?Object.create(M):(x.prototype=M.prototype,new x)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.areTokenCategoriesNotUsed=n.isStrictPrefixOfPath=n.containsPath=n.getLookaheadPathsForOptionalProd=n.getLookaheadPathsForOr=n.lookAheadSequenceFromAlternatives=n.buildSingleAlternativeLookaheadFunction=n.buildAlternativesLookAheadFunc=n.buildLookaheadFuncForOptionalProd=n.buildLookaheadFuncForOr=n.getProdType=n.PROD_TYPE=void 0;var t=Oe(),i=Et(),r=Ft(),c=ut(),o=He(),u=ht(),a;(function(O){O[O.OPTION=0]="OPTION",O[O.REPETITION=1]="REPETITION",O[O.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",O[O.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",O[O.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",O[O.ALTERNATION=5]="ALTERNATION"})(a=n.PROD_TYPE||(n.PROD_TYPE={}));function s(O){if(O instanceof o.Option)return a.OPTION;if(O instanceof o.Repetition)return a.REPETITION;if(O instanceof o.RepetitionMandatory)return a.REPETITION_MANDATORY;if(O instanceof o.RepetitionMandatoryWithSeparator)return a.REPETITION_MANDATORY_WITH_SEPARATOR;if(O instanceof o.RepetitionWithSeparator)return a.REPETITION_WITH_SEPARATOR;if(O instanceof o.Alternation)return a.ALTERNATION;throw Error("non exhaustive match")}n.getProdType=s;function f(O,j,M,x,P,k){var X=E(O,j,M),Q=Y(X)?c.tokenStructuredMatcherNoCategories:c.tokenStructuredMatcher;return k(X,x,Q,P)}n.buildLookaheadFuncForOr=f;function h(O,j,M,x,P,k){var X=S(O,j,P,M),Q=Y(X)?c.tokenStructuredMatcherNoCategories:c.tokenStructuredMatcher;return k(X[0],Q,x)}n.buildLookaheadFuncForOptionalProd=h;function T(O,j,M,x){var P=O.length,k=t.every(O,function(H){return t.every(H,function($){return $.length===1})});if(j)return function(H){for(var $=t.map(H,function(q){return q.GATE}),te=0;te<P;te++){var ae=O[te],se=ae.length,ce=$[te];if(!(ce!==void 0&&ce.call(this)===!1))e:for(var ne=0;ne<se;ne++){for(var pe=ae[ne],U=pe.length,G=0;G<U;G++){var W=this.LA(G+1);if(M(W,pe[G])===!1)continue e}return te}}};if(k&&!x){var X=t.map(O,function(H){return t.flatten(H)}),Q=t.reduce(X,function(H,$,te){return t.forEach($,function(ae){t.has(H,ae.tokenTypeIdx)||(H[ae.tokenTypeIdx]=te),t.forEach(ae.categoryMatches,function(se){t.has(H,se)||(H[se]=te)})}),H},[]);return function(){var H=this.LA(1);return Q[H.tokenTypeIdx]}}else return function(){for(var H=0;H<P;H++){var $=O[H],te=$.length;e:for(var ae=0;ae<te;ae++){for(var se=$[ae],ce=se.length,ne=0;ne<ce;ne++){var pe=this.LA(ne+1);if(M(pe,se[ne])===!1)continue e}return H}}}}n.buildAlternativesLookAheadFunc=T;function p(O,j,M){var x=t.every(O,function($){return $.length===1}),P=O.length;if(x&&!M){var k=t.flatten(O);if(k.length===1&&t.isEmpty(k[0].categoryMatches)){var X=k[0],Q=X.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===Q}}else{var H=t.reduce(k,function($,te,ae){return $[te.tokenTypeIdx]=!0,t.forEach(te.categoryMatches,function(se){$[se]=!0}),$},[]);return function(){var $=this.LA(1);return H[$.tokenTypeIdx]===!0}}}else return function(){e:for(var $=0;$<P;$++){for(var te=O[$],ae=te.length,se=0;se<ae;se++){var ce=this.LA(se+1);if(j(ce,te[se])===!1)continue e}return!0}return!1}}n.buildSingleAlternativeLookaheadFunction=p;var g=(function(O){e(j,O);function j(M,x,P){var k=O.call(this)||this;return k.topProd=M,k.targetOccurrence=x,k.targetProdType=P,k}return j.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},j.prototype.checkIsTarget=function(M,x,P,k){return M.idx===this.targetOccurrence&&this.targetProdType===x?(this.restDef=P.concat(k),!0):!1},j.prototype.walkOption=function(M,x,P){this.checkIsTarget(M,a.OPTION,x,P)||O.prototype.walkOption.call(this,M,x,P)},j.prototype.walkAtLeastOne=function(M,x,P){this.checkIsTarget(M,a.REPETITION_MANDATORY,x,P)||O.prototype.walkOption.call(this,M,x,P)},j.prototype.walkAtLeastOneSep=function(M,x,P){this.checkIsTarget(M,a.REPETITION_MANDATORY_WITH_SEPARATOR,x,P)||O.prototype.walkOption.call(this,M,x,P)},j.prototype.walkMany=function(M,x,P){this.checkIsTarget(M,a.REPETITION,x,P)||O.prototype.walkOption.call(this,M,x,P)},j.prototype.walkManySep=function(M,x,P){this.checkIsTarget(M,a.REPETITION_WITH_SEPARATOR,x,P)||O.prototype.walkOption.call(this,M,x,P)},j})(r.RestWalker),y=(function(O){e(j,O);function j(M,x,P){var k=O.call(this)||this;return k.targetOccurrence=M,k.targetProdType=x,k.targetRef=P,k.result=[],k}return j.prototype.checkIsTarget=function(M,x){M.idx===this.targetOccurrence&&this.targetProdType===x&&(this.targetRef===void 0||M===this.targetRef)&&(this.result=M.definition)},j.prototype.visitOption=function(M){this.checkIsTarget(M,a.OPTION)},j.prototype.visitRepetition=function(M){this.checkIsTarget(M,a.REPETITION)},j.prototype.visitRepetitionMandatory=function(M){this.checkIsTarget(M,a.REPETITION_MANDATORY)},j.prototype.visitRepetitionMandatoryWithSeparator=function(M){this.checkIsTarget(M,a.REPETITION_MANDATORY_WITH_SEPARATOR)},j.prototype.visitRepetitionWithSeparator=function(M){this.checkIsTarget(M,a.REPETITION_WITH_SEPARATOR)},j.prototype.visitAlternation=function(M){this.checkIsTarget(M,a.ALTERNATION)},j})(u.GAstVisitor);function l(O){for(var j=new Array(O),M=0;M<O;M++)j[M]=[];return j}function d(O){for(var j=[""],M=0;M<O.length;M++){for(var x=O[M],P=[],k=0;k<j.length;k++){var X=j[k];P.push(X+"_"+x.tokenTypeIdx);for(var Q=0;Q<x.categoryMatches.length;Q++){var H="_"+x.categoryMatches[Q];P.push(X+H)}}j=P}return j}function m(O,j,M){for(var x=0;x<O.length;x++)if(x!==M)for(var P=O[x],k=0;k<j.length;k++){var X=j[k];if(P[X]===!0)return!1}return!0}function v(O,j){for(var M=t.map(O,function(te){return i.possiblePathsFrom([te],1)}),x=l(M.length),P=t.map(M,function(te){var ae={};return t.forEach(te,function(se){var ce=d(se.partialPath);t.forEach(ce,function(ne){ae[ne]=!0})}),ae}),k=M,X=1;X<=j;X++){var Q=k;k=l(Q.length);for(var H=function(te){for(var ae=Q[te],se=0;se<ae.length;se++){var ce=ae[se].partialPath,ne=ae[se].suffixDef,pe=d(ce),U=m(P,pe,te);if(U||t.isEmpty(ne)||ce.length===j){var G=x[te];if(N(G,ce)===!1){G.push(ce);for(var W=0;W<pe.length;W++){var q=pe[W];P[te][q]=!0}}}else{var Z=i.possiblePathsFrom(ne,X+1,ce);k[te]=k[te].concat(Z),t.forEach(Z,function(ie){var Te=d(ie.partialPath);t.forEach(Te,function(ye){P[te][ye]=!0})})}}},$=0;$<Q.length;$++)H($)}return x}n.lookAheadSequenceFromAlternatives=v;function E(O,j,M,x){var P=new y(O,a.ALTERNATION,x);return j.accept(P),v(P.result,M)}n.getLookaheadPathsForOr=E;function S(O,j,M,x){var P=new y(O,M);j.accept(P);var k=P.result,X=new g(j,O,M),Q=X.startWalking(),H=new o.Alternative({definition:k}),$=new o.Alternative({definition:Q});return v([H,$],x)}n.getLookaheadPathsForOptionalProd=S;function N(O,j){e:for(var M=0;M<O.length;M++){var x=O[M];if(x.length===j.length){for(var P=0;P<x.length;P++){var k=j[P],X=x[P],Q=k===X||X.categoryMatchesMap[k.tokenTypeIdx]!==void 0;if(Q===!1)continue e}return!0}}return!1}n.containsPath=N;function C(O,j){return O.length<j.length&&t.every(O,function(M,x){var P=j[x];return M===P||P.categoryMatchesMap[M.tokenTypeIdx]})}n.isStrictPrefixOfPath=C;function Y(O){return t.every(O,function(j){return t.every(j,function(M){return t.every(M,function(x){return t.isEmpty(x.categoryMatches)})})})}n.areTokenCategoriesNotUsed=Y}),An=ve(n=>{var e=n&&n.__extends||(function(){var x=function(P,k){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(X,Q){X.__proto__=Q}||function(X,Q){for(var H in Q)Object.prototype.hasOwnProperty.call(Q,H)&&(X[H]=Q[H])},x(P,k)};return function(P,k){if(typeof k!="function"&&k!==null)throw new TypeError("Class extends value "+String(k)+" is not a constructor or null");x(P,k);function X(){this.constructor=P}P.prototype=k===null?Object.create(k):(X.prototype=k.prototype,new X)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.checkPrefixAlternativesAmbiguities=n.validateSomeNonEmptyLookaheadPath=n.validateTooManyAlts=n.RepetionCollector=n.validateAmbiguousAlternationAlternatives=n.validateEmptyOrAlternative=n.getFirstNoneTerminal=n.validateNoLeftRecursion=n.validateRuleIsOverridden=n.validateRuleDoesNotAlreadyExist=n.OccurrenceValidationCollector=n.identifyProductionForDuplicates=n.validateGrammar=void 0;var t=Oe(),i=Oe(),r=Ye(),c=gt(),o=vt(),u=Et(),a=He(),s=ht();function f(x,P,k,X,Q){var H=t.map(x,function(U){return h(U,X)}),$=t.map(x,function(U){return d(U,U,X)}),te=[],ae=[],se=[];i.every($,i.isEmpty)&&(te=i.map(x,function(U){return E(U,X)}),ae=i.map(x,function(U){return S(U,P,X)}),se=Y(x,P,X));var ce=M(x,k,X),ne=i.map(x,function(U){return C(U,X)}),pe=i.map(x,function(U){return y(U,x,Q,X)});return t.flatten(H.concat(se,$,te,ae,ce,ne,pe))}n.validateGrammar=f;function h(x,P){var k=new g;x.accept(k);var X=k.allProductions,Q=t.groupBy(X,T),H=t.pick(Q,function(te){return te.length>1}),$=t.map(t.values(H),function(te){var ae=t.first(te),se=P.buildDuplicateFoundError(x,te),ce=c.getProductionDslName(ae),ne={message:se,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:x.name,dslName:ce,occurrence:ae.idx},pe=p(ae);return pe&&(ne.parameter=pe),ne});return $}function T(x){return c.getProductionDslName(x)+"_#_"+x.idx+"_#_"+p(x)}n.identifyProductionForDuplicates=T;function p(x){return x instanceof a.Terminal?x.terminalType.name:x instanceof a.NonTerminal?x.nonTerminalName:""}var g=(function(x){e(P,x);function P(){var k=x!==null&&x.apply(this,arguments)||this;return k.allProductions=[],k}return P.prototype.visitNonTerminal=function(k){this.allProductions.push(k)},P.prototype.visitOption=function(k){this.allProductions.push(k)},P.prototype.visitRepetitionWithSeparator=function(k){this.allProductions.push(k)},P.prototype.visitRepetitionMandatory=function(k){this.allProductions.push(k)},P.prototype.visitRepetitionMandatoryWithSeparator=function(k){this.allProductions.push(k)},P.prototype.visitRepetition=function(k){this.allProductions.push(k)},P.prototype.visitAlternation=function(k){this.allProductions.push(k)},P.prototype.visitTerminal=function(k){this.allProductions.push(k)},P})(s.GAstVisitor);n.OccurrenceValidationCollector=g;function y(x,P,k,X){var Q=[],H=i.reduce(P,function(te,ae){return ae.name===x.name?te+1:te},0);if(H>1){var $=X.buildDuplicateRuleNameError({topLevelRule:x,grammarName:k});Q.push({message:$,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:x.name})}return Q}n.validateRuleDoesNotAlreadyExist=y;function l(x,P,k){var X=[],Q;return t.contains(P,x)||(Q="Invalid rule override, rule: ->"+x+"<- cannot be overridden in the grammar: ->"+k+"<-as it is not defined in any of the super grammars ",X.push({message:Q,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:x})),X}n.validateRuleIsOverridden=l;function d(x,P,k,X){X===void 0&&(X=[]);var Q=[],H=m(P.definition);if(t.isEmpty(H))return[];var $=x.name,te=t.contains(H,x);te&&Q.push({message:k.buildLeftRecursionError({topLevelRule:x,leftRecursionPath:X}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:$});var ae=t.difference(H,X.concat([x])),se=t.map(ae,function(ce){var ne=t.cloneArr(X);return ne.push(ce),d(x,ce,k,ne)});return Q.concat(t.flatten(se))}n.validateNoLeftRecursion=d;function m(x){var P=[];if(t.isEmpty(x))return P;var k=t.first(x);if(k instanceof a.NonTerminal)P.push(k.referencedRule);else if(k instanceof a.Alternative||k instanceof a.Option||k instanceof a.RepetitionMandatory||k instanceof a.RepetitionMandatoryWithSeparator||k instanceof a.RepetitionWithSeparator||k instanceof a.Repetition)P=P.concat(m(k.definition));else if(k instanceof a.Alternation)P=t.flatten(t.map(k.definition,function($){return m($.definition)}));else if(!(k instanceof a.Terminal))throw Error("non exhaustive match");var X=c.isOptionalProd(k),Q=x.length>1;if(X&&Q){var H=t.drop(x);return P.concat(m(H))}else return P}n.getFirstNoneTerminal=m;var v=(function(x){e(P,x);function P(){var k=x!==null&&x.apply(this,arguments)||this;return k.alternations=[],k}return P.prototype.visitAlternation=function(k){this.alternations.push(k)},P})(s.GAstVisitor);function E(x,P){var k=new v;x.accept(k);var X=k.alternations,Q=t.reduce(X,function(H,$){var te=t.dropRight($.definition),ae=t.map(te,function(se,ce){var ne=u.nextPossibleTokensAfter([se],[],null,1);return t.isEmpty(ne)?{message:P.buildEmptyAlternationError({topLevelRule:x,alternation:$,emptyChoiceIdx:ce}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:x.name,occurrence:$.idx,alternative:ce+1}:null});return H.concat(t.compact(ae))},[]);return Q}n.validateEmptyOrAlternative=E;function S(x,P,k){var X=new v;x.accept(X);var Q=X.alternations;Q=i.reject(Q,function($){return $.ignoreAmbiguities===!0});var H=t.reduce(Q,function($,te){var ae=te.idx,se=te.maxLookahead||P,ce=o.getLookaheadPathsForOr(ae,x,se,te),ne=O(ce,te,x,k),pe=j(ce,te,x,k);return $.concat(ne,pe)},[]);return H}n.validateAmbiguousAlternationAlternatives=S;var N=(function(x){e(P,x);function P(){var k=x!==null&&x.apply(this,arguments)||this;return k.allProductions=[],k}return P.prototype.visitRepetitionWithSeparator=function(k){this.allProductions.push(k)},P.prototype.visitRepetitionMandatory=function(k){this.allProductions.push(k)},P.prototype.visitRepetitionMandatoryWithSeparator=function(k){this.allProductions.push(k)},P.prototype.visitRepetition=function(k){this.allProductions.push(k)},P})(s.GAstVisitor);n.RepetionCollector=N;function C(x,P){var k=new v;x.accept(k);var X=k.alternations,Q=t.reduce(X,function(H,$){return $.definition.length>255&&H.push({message:P.buildTooManyAlternativesError({topLevelRule:x,alternation:$}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:x.name,occurrence:$.idx}),H},[]);return Q}n.validateTooManyAlts=C;function Y(x,P,k){var X=[];return i.forEach(x,function(Q){var H=new N;Q.accept(H);var $=H.allProductions;i.forEach($,function(te){var ae=o.getProdType(te),se=te.maxLookahead||P,ce=te.idx,ne=o.getLookaheadPathsForOptionalProd(ce,Q,ae,se),pe=ne[0];if(i.isEmpty(i.flatten(pe))){var U=k.buildEmptyRepetitionError({topLevelRule:Q,repetition:te});X.push({message:U,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:Q.name})}})}),X}n.validateSomeNonEmptyLookaheadPath=Y;function O(x,P,k,X){var Q=[],H=i.reduce(x,function(te,ae,se){return P.definition[se].ignoreAmbiguities===!0||i.forEach(ae,function(ce){var ne=[se];i.forEach(x,function(pe,U){se!==U&&o.containsPath(pe,ce)&&P.definition[U].ignoreAmbiguities!==!0&&ne.push(U)}),ne.length>1&&!o.containsPath(Q,ce)&&(Q.push(ce),te.push({alts:ne,path:ce}))}),te},[]),$=t.map(H,function(te){var ae=i.map(te.alts,function(ce){return ce+1}),se=X.buildAlternationAmbiguityError({topLevelRule:k,alternation:P,ambiguityIndices:ae,prefixPath:te.path});return{message:se,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:k.name,occurrence:P.idx,alternatives:[te.alts]}});return $}function j(x,P,k,X){var Q=[],H=i.reduce(x,function($,te,ae){var se=i.map(te,function(ce){return{idx:ae,path:ce}});return $.concat(se)},[]);return i.forEach(H,function($){var te=P.definition[$.idx];if(te.ignoreAmbiguities!==!0){var ae=$.idx,se=$.path,ce=i.findAll(H,function(pe){return P.definition[pe.idx].ignoreAmbiguities!==!0&&pe.idx<ae&&o.isStrictPrefixOfPath(pe.path,se)}),ne=i.map(ce,function(pe){var U=[pe.idx+1,ae+1],G=P.idx===0?"":P.idx,W=X.buildAlternationPrefixAmbiguityError({topLevelRule:k,alternation:P,ambiguityIndices:U,prefixPath:pe.path});return{message:W,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:k.name,occurrence:G,alternatives:U}});Q=Q.concat(ne)}}),Q}n.checkPrefixAlternativesAmbiguities=j;function M(x,P,k){var X=[],Q=i.map(P,function(H){return H.name});return i.forEach(x,function(H){var $=H.name;if(i.contains(Q,$)){var te=k.buildNamespaceConflictError(H);X.push({message:te,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:$})}}),X}}),ri=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateGrammar=n.resolveGrammar=void 0;var e=Oe(),t=ni(),i=An(),r=Tt();function c(u){u=e.defaults(u,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var a={};return e.forEach(u.rules,function(s){a[s.name]=s}),t.resolveGrammar(a,u.errMsgProvider)}n.resolveGrammar=c;function o(u){return u=e.defaults(u,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),i.validateGrammar(u.rules,u.maxLookahead,u.tokenTypes,u.errMsgProvider,u.grammarName)}n.validateGrammar=o}),ft=ve(n=>{var e=n&&n.__extends||(function(){var g=function(y,l){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,m){d.__proto__=m}||function(d,m){for(var v in m)Object.prototype.hasOwnProperty.call(m,v)&&(d[v]=m[v])},g(y,l)};return function(y,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");g(y,l);function d(){this.constructor=y}y.prototype=l===null?Object.create(l):(d.prototype=l.prototype,new d)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.EarlyExitException=n.NotAllInputParsedException=n.NoViableAltException=n.MismatchedTokenException=n.isRecognitionException=void 0;var t=Oe(),i="MismatchedTokenException",r="NoViableAltException",c="EarlyExitException",o="NotAllInputParsedException",u=[i,r,c,o];Object.freeze(u);function a(g){return t.contains(u,g.name)}n.isRecognitionException=a;var s=(function(g){e(y,g);function y(l,d){var m=this.constructor,v=g.call(this,l)||this;return v.token=d,v.resyncedTokens=[],Object.setPrototypeOf(v,m.prototype),Error.captureStackTrace&&Error.captureStackTrace(v,v.constructor),v}return y})(Error),f=(function(g){e(y,g);function y(l,d,m){var v=g.call(this,l,d)||this;return v.previousToken=m,v.name=i,v}return y})(s);n.MismatchedTokenException=f;var h=(function(g){e(y,g);function y(l,d,m){var v=g.call(this,l,d)||this;return v.previousToken=m,v.name=r,v}return y})(s);n.NoViableAltException=h;var T=(function(g){e(y,g);function y(l,d){var m=g.call(this,l,d)||this;return m.name=o,m}return y})(s);n.NotAllInputParsedException=T;var p=(function(g){e(y,g);function y(l,d,m){var v=g.call(this,l,d)||this;return v.previousToken=m,v.name=c,v}return y})(s);n.EarlyExitException=p}),bn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.attemptInRepetitionRecovery=n.Recoverable=n.InRuleRecoveryException=n.IN_RULE_RECOVERY_EXCEPTION=n.EOF_FOLLOW_KEY=void 0;var e=tt(),t=Oe(),i=ft(),r=_n(),c=Ye();n.EOF_FOLLOW_KEY={},n.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(s){this.name=n.IN_RULE_RECOVERY_EXCEPTION,this.message=s}n.InRuleRecoveryException=o,o.prototype=Error.prototype;var u=(function(){function s(){}return s.prototype.initRecoverable=function(f){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(f,"recoveryEnabled")?f.recoveryEnabled:c.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=a)},s.prototype.getTokenToInsert=function(f){var h=e.createTokenInstance(f,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},s.prototype.canTokenTypeBeInsertedInRecovery=function(f){return!0},s.prototype.tryInRepetitionRecovery=function(f,h,T,p){for(var g=this,y=this.findReSyncTokenType(),l=this.exportLexerState(),d=[],m=!1,v=this.LA(1),E=this.LA(1),S=function(){var N=g.LA(0),C=g.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:v,previous:N,ruleName:g.getCurrRuleFullName()}),Y=new i.MismatchedTokenException(C,v,g.LA(0));Y.resyncedTokens=t.dropRight(d),g.SAVE_ERROR(Y)};!m;)if(this.tokenMatcher(E,p)){S();return}else if(T.call(this)){S(),f.apply(this,h);return}else this.tokenMatcher(E,y)?m=!0:(E=this.SKIP_TOKEN(),this.addToResyncTokens(E,d));this.importLexerState(l)},s.prototype.shouldInRepetitionRecoveryBeTried=function(f,h,T){return!(T===!1||f===void 0||h===void 0||this.tokenMatcher(this.LA(1),f)||this.isBackTracking()||this.canPerformInRuleRecovery(f,this.getFollowsForInRuleRecovery(f,h)))},s.prototype.getFollowsForInRuleRecovery=function(f,h){var T=this.getCurrentGrammarPath(f,h),p=this.getNextPossibleTokenTypes(T);return p},s.prototype.tryInRuleRecovery=function(f,h){if(this.canRecoverWithSingleTokenInsertion(f,h)){var T=this.getTokenToInsert(f);return T}if(this.canRecoverWithSingleTokenDeletion(f)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},s.prototype.canPerformInRuleRecovery=function(f,h){return this.canRecoverWithSingleTokenInsertion(f,h)||this.canRecoverWithSingleTokenDeletion(f)},s.prototype.canRecoverWithSingleTokenInsertion=function(f,h){var T=this;if(!this.canTokenTypeBeInsertedInRecovery(f)||t.isEmpty(h))return!1;var p=this.LA(1),g=t.find(h,function(y){return T.tokenMatcher(p,y)})!==void 0;return g},s.prototype.canRecoverWithSingleTokenDeletion=function(f){var h=this.tokenMatcher(this.LA(2),f);return h},s.prototype.isInCurrentRuleReSyncSet=function(f){var h=this.getCurrFollowKey(),T=this.getFollowSetFromFollowKey(h);return t.contains(T,f)},s.prototype.findReSyncTokenType=function(){for(var f=this.flattenFollowSet(),h=this.LA(1),T=2;;){var p=h.tokenType;if(t.contains(f,p))return p;h=this.LA(T),T++}},s.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return n.EOF_FOLLOW_KEY;var f=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),T=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(f),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(T)}},s.prototype.buildFullFollowKeyStack=function(){var f=this,h=this.RULE_STACK,T=this.RULE_OCCURRENCE_STACK;return t.map(h,function(p,g){return g===0?n.EOF_FOLLOW_KEY:{ruleName:f.shortRuleNameToFullName(p),idxInCallingRule:T[g],inRule:f.shortRuleNameToFullName(h[g-1])}})},s.prototype.flattenFollowSet=function(){var f=this,h=t.map(this.buildFullFollowKeyStack(),function(T){return f.getFollowSetFromFollowKey(T)});return t.flatten(h)},s.prototype.getFollowSetFromFollowKey=function(f){if(f===n.EOF_FOLLOW_KEY)return[e.EOF];var h=f.ruleName+f.idxInCallingRule+r.IN+f.inRule;return this.resyncFollows[h]},s.prototype.addToResyncTokens=function(f,h){return this.tokenMatcher(f,e.EOF)||h.push(f),h},s.prototype.reSyncTo=function(f){for(var h=[],T=this.LA(1);this.tokenMatcher(T,f)===!1;)T=this.SKIP_TOKEN(),this.addToResyncTokens(T,h);return t.dropRight(h)},s.prototype.attemptInRepetitionRecovery=function(f,h,T,p,g,y,l){},s.prototype.getCurrentGrammarPath=function(f,h){var T=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),g={ruleStack:T,occurrenceStack:p,lastTok:f,lastTokOccurrence:h};return g},s.prototype.getHumanReadableRuleStack=function(){var f=this;return t.map(this.RULE_STACK,function(h){return f.shortRuleNameToFullName(h)})},s})();n.Recoverable=u;function a(s,f,h,T,p,g,y){var l=this.getKeyForAutomaticLookahead(T,p),d=this.firstAfterRepMap[l];if(d===void 0){var m=this.getCurrRuleFullName(),v=this.getGAstProductions()[m],E=new g(v,p);d=E.startWalking(),this.firstAfterRepMap[l]=d}var S=d.token,N=d.occurrence,C=d.isEndOfRule;this.RULE_STACK.length===1&&C&&S===void 0&&(S=e.EOF,N=1),this.shouldInRepetitionRecoveryBeTried(S,N,y)&&this.tryInRepetitionRecovery(s,f,h,S)}n.attemptInRepetitionRecovery=a}),Ut=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getKeyForAutomaticLookahead=n.AT_LEAST_ONE_SEP_IDX=n.MANY_SEP_IDX=n.AT_LEAST_ONE_IDX=n.MANY_IDX=n.OPTION_IDX=n.OR_IDX=n.BITS_FOR_ALT_IDX=n.BITS_FOR_RULE_IDX=n.BITS_FOR_OCCURRENCE_IDX=n.BITS_FOR_METHOD_TYPE=void 0,n.BITS_FOR_METHOD_TYPE=4,n.BITS_FOR_OCCURRENCE_IDX=8,n.BITS_FOR_RULE_IDX=12,n.BITS_FOR_ALT_IDX=8,n.OR_IDX=1<<n.BITS_FOR_OCCURRENCE_IDX,n.OPTION_IDX=2<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_IDX=3<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_IDX=4<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_SEP_IDX=5<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_SEP_IDX=6<<n.BITS_FOR_OCCURRENCE_IDX;function e(t,i,r){return r|i|t}n.getKeyForAutomaticLookahead=e,32-n.BITS_FOR_ALT_IDX}),ii=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LooksAhead=void 0;var e=vt(),t=Oe(),i=Ye(),r=Ut(),c=gt(),o=(function(){function u(){}return u.prototype.initLooksAhead=function(a){this.dynamicTokensEnabled=t.has(a,"dynamicTokensEnabled")?a.dynamicTokensEnabled:i.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(a,"maxLookahead")?a.maxLookahead:i.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},u.prototype.preComputeLookaheadFunctions=function(a){var s=this;t.forEach(a,function(f){s.TRACE_INIT(f.name+" Rule Lookahead",function(){var h=c.collectMethods(f),T=h.alternation,p=h.repetition,g=h.option,y=h.repetitionMandatory,l=h.repetitionMandatoryWithSeparator,d=h.repetitionWithSeparator;t.forEach(T,function(m){var v=m.idx===0?"":m.idx;s.TRACE_INIT(""+c.getProductionDslName(m)+v,function(){var E=e.buildLookaheadFuncForOr(m.idx,f,m.maxLookahead||s.maxLookahead,m.hasPredicates,s.dynamicTokensEnabled,s.lookAheadBuilderForAlternatives),S=r.getKeyForAutomaticLookahead(s.fullRuleNameToShort[f.name],r.OR_IDX,m.idx);s.setLaFuncCache(S,E)})}),t.forEach(p,function(m){s.computeLookaheadFunc(f,m.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,m.maxLookahead,c.getProductionDslName(m))}),t.forEach(g,function(m){s.computeLookaheadFunc(f,m.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,m.maxLookahead,c.getProductionDslName(m))}),t.forEach(y,function(m){s.computeLookaheadFunc(f,m.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,m.maxLookahead,c.getProductionDslName(m))}),t.forEach(l,function(m){s.computeLookaheadFunc(f,m.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,m.maxLookahead,c.getProductionDslName(m))}),t.forEach(d,function(m){s.computeLookaheadFunc(f,m.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,m.maxLookahead,c.getProductionDslName(m))})})})},u.prototype.computeLookaheadFunc=function(a,s,f,h,T,p){var g=this;this.TRACE_INIT(""+p+(s===0?"":s),function(){var y=e.buildLookaheadFuncForOptionalProd(s,a,T||g.maxLookahead,g.dynamicTokensEnabled,h,g.lookAheadBuilderForOptional),l=r.getKeyForAutomaticLookahead(g.fullRuleNameToShort[a.name],f,s);g.setLaFuncCache(l,y)})},u.prototype.lookAheadBuilderForOptional=function(a,s,f){return e.buildSingleAlternativeLookaheadFunction(a,s,f)},u.prototype.lookAheadBuilderForAlternatives=function(a,s,f,h){return e.buildAlternativesLookAheadFunc(a,s,f,h)},u.prototype.getKeyForAutomaticLookahead=function(a,s){var f=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(f,a,s)},u.prototype.getLaFuncFromCache=function(a){},u.prototype.getLaFuncFromMap=function(a){return this.lookAheadFuncsCache.get(a)},u.prototype.getLaFuncFromObj=function(a){return this.lookAheadFuncsCache[a]},u.prototype.setLaFuncCache=function(a,s){},u.prototype.setLaFuncCacheUsingMap=function(a,s){this.lookAheadFuncsCache.set(a,s)},u.prototype.setLaFuncUsingObj=function(a,s){this.lookAheadFuncsCache[a]=s},u})();n.LooksAhead=o}),oi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addNoneTerminalToCst=n.addTerminalToCst=n.setNodeLocationFull=n.setNodeLocationOnlyOffset=void 0;function e(c,o){isNaN(c.startOffset)===!0?(c.startOffset=o.startOffset,c.endOffset=o.endOffset):c.endOffset<o.endOffset&&(c.endOffset=o.endOffset)}n.setNodeLocationOnlyOffset=e;function t(c,o){isNaN(c.startOffset)===!0?(c.startOffset=o.startOffset,c.startColumn=o.startColumn,c.startLine=o.startLine,c.endOffset=o.endOffset,c.endColumn=o.endColumn,c.endLine=o.endLine):c.endOffset<o.endOffset&&(c.endOffset=o.endOffset,c.endColumn=o.endColumn,c.endLine=o.endLine)}n.setNodeLocationFull=t;function i(c,o,u){c.children[u]===void 0?c.children[u]=[o]:c.children[u].push(o)}n.addTerminalToCst=i;function r(c,o,u){c.children[o]===void 0?c.children[o]=[u]:c.children[o].push(u)}n.addNoneTerminalToCst=r}),Ln=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defineNameProp=n.functionName=n.classNameFromInstance=void 0;var e=Oe();function t(o){return r(o.constructor)}n.classNameFromInstance=t;var i="name";function r(o){var u=o.name;return u||"anonymous"}n.functionName=r;function c(o,u){var a=Object.getOwnPropertyDescriptor(o,i);return e.isUndefined(a)||a.configurable?(Object.defineProperty(o,i,{enumerable:!1,configurable:!0,writable:!1,value:u}),!0):!1}n.defineNameProp=c}),si=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateRedundantMethods=n.validateMissingCstMethods=n.validateVisitor=n.CstVisitorDefinitionError=n.createBaseVisitorConstructorWithDefaults=n.createBaseSemanticVisitorConstructor=n.defaultVisit=void 0;var e=Oe(),t=Ln();function i(h,T){for(var p=e.keys(h),g=p.length,y=0;y<g;y++)for(var l=p[y],d=h[l],m=d.length,v=0;v<m;v++){var E=d[v];E.tokenTypeIdx===void 0&&this[E.name](E.children,T)}}n.defaultVisit=i;function r(h,T){var p=function(){};t.defineNameProp(p,h+"BaseSemantics");var g={visit:function(y,l){if(e.isArray(y)&&(y=y[0]),!e.isUndefined(y))return this[y.name](y.children,l)},validateVisitor:function(){var y=u(this,T);if(!e.isEmpty(y)){var l=e.map(y,function(d){return d.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
|
|
163
|
+
`+(""+l.join(`
|
|
164
164
|
|
|
165
165
|
`).replace(/\n/g,`
|
|
166
|
-
`)))}}};return p.prototype=
|
|
166
|
+
`)))}}};return p.prototype=g,p.prototype.constructor=p,p._RULE_NAMES=T,p}n.createBaseSemanticVisitorConstructor=r;function c(h,T,p){var g=function(){};t.defineNameProp(g,h+"BaseSemanticsWithDefaults");var y=Object.create(p.prototype);return e.forEach(T,function(l){y[l]=i}),g.prototype=y,g.prototype.constructor=g,g}n.createBaseVisitorConstructorWithDefaults=c;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=n.CstVisitorDefinitionError||(n.CstVisitorDefinitionError={}));function u(h,T){var p=a(h,T),g=f(h,T);return p.concat(g)}n.validateVisitor=u;function a(h,T){var p=e.map(T,function(g){if(!e.isFunction(h[g]))return{msg:"Missing visitor method: <"+g+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:g}});return e.compact(p)}n.validateMissingCstMethods=a;var s=["constructor","visit","validateVisitor"];function f(h,T){var p=[];for(var g in h)e.isFunction(h[g])&&!e.contains(s,g)&&!e.contains(T,g)&&p.push({msg:"Redundant visitor method: <"+g+"> on "+t.functionName(h.constructor)+` CST Visitor
|
|
167
167
|
There is no Grammar Rule corresponding to this method's name.
|
|
168
|
-
`,type:o.REDUNDANT_METHOD,methodName:T});return p}n.validateRedundantMethods=h}),ni=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TreeBuilder=void 0;var e=ei(),t=xe(),i=ti(),r=Ye(),a=(function(){function o(){}return o.prototype.initTreeBuilder=function(l){if(this.CST_STACK=[],this.outputCst=l.outputCst,this.nodeLocationTracking=t.has(l,"nodeLocationTracking")?l.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+l.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(l){l.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(l){l.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(l){l.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(l){var c=this.LA(1);l.location={startOffset:c.startOffset,startLine:c.startLine,startColumn:c.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(l,c){var s={name:l,children:{}};this.setInitialNodeLocation(s),this.CST_STACK.push(s)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(l){var c=this.LA(0),s=l.location;s.startOffset<=c.startOffset?(s.endOffset=c.endOffset,s.endLine=c.endLine,s.endColumn=c.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(l){var c=this.LA(0),s=l.location;s.startOffset<=c.startOffset?s.endOffset=c.endOffset:s.startOffset=NaN},o.prototype.cstPostTerminal=function(l,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(s,c,l),this.setNodeLocationFromToken(s.location,c)},o.prototype.cstPostNonTerminal=function(l,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(s,c,l),this.setNodeLocationFromNode(s.location,l.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var l=i.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=l,l}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var l=i.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=l,l}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var l=this.RULE_STACK;return l[l.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var l=this.RULE_STACK;return l[l.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var l=this.RULE_OCCURRENCE_STACK;return l[l.length-1]},o})();n.TreeBuilder=a}),ri=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LexerAdapter=void 0;var e=Ye(),t=(function(){function i(){}return i.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(i.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),i.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},i.prototype.LA=function(r){var a=this.currIdx+r;return a<0||this.tokVectorLength<=a?e.END_OF_FILE:this.tokVector[a]},i.prototype.consumeToken=function(){this.currIdx++},i.prototype.exportLexerState=function(){return this.currIdx},i.prototype.importLexerState=function(r){this.currIdx=r},i.prototype.resetLexerState=function(){this.currIdx=-1},i.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},i.prototype.getLexerPosition=function(){return this.exportLexerState()},i})();n.LexerAdapter=t}),ii=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerApi=void 0;var e=xe(),t=lt(),i=Ye(),r=yt(),a=gn(),o=He(),l=(function(){function c(){}return c.prototype.ACTION=function(s){return s.call(this)},c.prototype.consume=function(s,h,f){return this.consumeInternal(h,s,f)},c.prototype.subrule=function(s,h,f){return this.subruleInternal(h,s,f)},c.prototype.option=function(s,h){return this.optionInternal(h,s)},c.prototype.or=function(s,h){return this.orInternal(h,s)},c.prototype.many=function(s,h){return this.manyInternal(s,h)},c.prototype.atLeastOne=function(s,h){return this.atLeastOneInternal(s,h)},c.prototype.CONSUME=function(s,h){return this.consumeInternal(s,0,h)},c.prototype.CONSUME1=function(s,h){return this.consumeInternal(s,1,h)},c.prototype.CONSUME2=function(s,h){return this.consumeInternal(s,2,h)},c.prototype.CONSUME3=function(s,h){return this.consumeInternal(s,3,h)},c.prototype.CONSUME4=function(s,h){return this.consumeInternal(s,4,h)},c.prototype.CONSUME5=function(s,h){return this.consumeInternal(s,5,h)},c.prototype.CONSUME6=function(s,h){return this.consumeInternal(s,6,h)},c.prototype.CONSUME7=function(s,h){return this.consumeInternal(s,7,h)},c.prototype.CONSUME8=function(s,h){return this.consumeInternal(s,8,h)},c.prototype.CONSUME9=function(s,h){return this.consumeInternal(s,9,h)},c.prototype.SUBRULE=function(s,h){return this.subruleInternal(s,0,h)},c.prototype.SUBRULE1=function(s,h){return this.subruleInternal(s,1,h)},c.prototype.SUBRULE2=function(s,h){return this.subruleInternal(s,2,h)},c.prototype.SUBRULE3=function(s,h){return this.subruleInternal(s,3,h)},c.prototype.SUBRULE4=function(s,h){return this.subruleInternal(s,4,h)},c.prototype.SUBRULE5=function(s,h){return this.subruleInternal(s,5,h)},c.prototype.SUBRULE6=function(s,h){return this.subruleInternal(s,6,h)},c.prototype.SUBRULE7=function(s,h){return this.subruleInternal(s,7,h)},c.prototype.SUBRULE8=function(s,h){return this.subruleInternal(s,8,h)},c.prototype.SUBRULE9=function(s,h){return this.subruleInternal(s,9,h)},c.prototype.OPTION=function(s){return this.optionInternal(s,0)},c.prototype.OPTION1=function(s){return this.optionInternal(s,1)},c.prototype.OPTION2=function(s){return this.optionInternal(s,2)},c.prototype.OPTION3=function(s){return this.optionInternal(s,3)},c.prototype.OPTION4=function(s){return this.optionInternal(s,4)},c.prototype.OPTION5=function(s){return this.optionInternal(s,5)},c.prototype.OPTION6=function(s){return this.optionInternal(s,6)},c.prototype.OPTION7=function(s){return this.optionInternal(s,7)},c.prototype.OPTION8=function(s){return this.optionInternal(s,8)},c.prototype.OPTION9=function(s){return this.optionInternal(s,9)},c.prototype.OR=function(s){return this.orInternal(s,0)},c.prototype.OR1=function(s){return this.orInternal(s,1)},c.prototype.OR2=function(s){return this.orInternal(s,2)},c.prototype.OR3=function(s){return this.orInternal(s,3)},c.prototype.OR4=function(s){return this.orInternal(s,4)},c.prototype.OR5=function(s){return this.orInternal(s,5)},c.prototype.OR6=function(s){return this.orInternal(s,6)},c.prototype.OR7=function(s){return this.orInternal(s,7)},c.prototype.OR8=function(s){return this.orInternal(s,8)},c.prototype.OR9=function(s){return this.orInternal(s,9)},c.prototype.MANY=function(s){this.manyInternal(0,s)},c.prototype.MANY1=function(s){this.manyInternal(1,s)},c.prototype.MANY2=function(s){this.manyInternal(2,s)},c.prototype.MANY3=function(s){this.manyInternal(3,s)},c.prototype.MANY4=function(s){this.manyInternal(4,s)},c.prototype.MANY5=function(s){this.manyInternal(5,s)},c.prototype.MANY6=function(s){this.manyInternal(6,s)},c.prototype.MANY7=function(s){this.manyInternal(7,s)},c.prototype.MANY8=function(s){this.manyInternal(8,s)},c.prototype.MANY9=function(s){this.manyInternal(9,s)},c.prototype.MANY_SEP=function(s){this.manySepFirstInternal(0,s)},c.prototype.MANY_SEP1=function(s){this.manySepFirstInternal(1,s)},c.prototype.MANY_SEP2=function(s){this.manySepFirstInternal(2,s)},c.prototype.MANY_SEP3=function(s){this.manySepFirstInternal(3,s)},c.prototype.MANY_SEP4=function(s){this.manySepFirstInternal(4,s)},c.prototype.MANY_SEP5=function(s){this.manySepFirstInternal(5,s)},c.prototype.MANY_SEP6=function(s){this.manySepFirstInternal(6,s)},c.prototype.MANY_SEP7=function(s){this.manySepFirstInternal(7,s)},c.prototype.MANY_SEP8=function(s){this.manySepFirstInternal(8,s)},c.prototype.MANY_SEP9=function(s){this.manySepFirstInternal(9,s)},c.prototype.AT_LEAST_ONE=function(s){this.atLeastOneInternal(0,s)},c.prototype.AT_LEAST_ONE1=function(s){return this.atLeastOneInternal(1,s)},c.prototype.AT_LEAST_ONE2=function(s){this.atLeastOneInternal(2,s)},c.prototype.AT_LEAST_ONE3=function(s){this.atLeastOneInternal(3,s)},c.prototype.AT_LEAST_ONE4=function(s){this.atLeastOneInternal(4,s)},c.prototype.AT_LEAST_ONE5=function(s){this.atLeastOneInternal(5,s)},c.prototype.AT_LEAST_ONE6=function(s){this.atLeastOneInternal(6,s)},c.prototype.AT_LEAST_ONE7=function(s){this.atLeastOneInternal(7,s)},c.prototype.AT_LEAST_ONE8=function(s){this.atLeastOneInternal(8,s)},c.prototype.AT_LEAST_ONE9=function(s){this.atLeastOneInternal(9,s)},c.prototype.AT_LEAST_ONE_SEP=function(s){this.atLeastOneSepFirstInternal(0,s)},c.prototype.AT_LEAST_ONE_SEP1=function(s){this.atLeastOneSepFirstInternal(1,s)},c.prototype.AT_LEAST_ONE_SEP2=function(s){this.atLeastOneSepFirstInternal(2,s)},c.prototype.AT_LEAST_ONE_SEP3=function(s){this.atLeastOneSepFirstInternal(3,s)},c.prototype.AT_LEAST_ONE_SEP4=function(s){this.atLeastOneSepFirstInternal(4,s)},c.prototype.AT_LEAST_ONE_SEP5=function(s){this.atLeastOneSepFirstInternal(5,s)},c.prototype.AT_LEAST_ONE_SEP6=function(s){this.atLeastOneSepFirstInternal(6,s)},c.prototype.AT_LEAST_ONE_SEP7=function(s){this.atLeastOneSepFirstInternal(7,s)},c.prototype.AT_LEAST_ONE_SEP8=function(s){this.atLeastOneSepFirstInternal(8,s)},c.prototype.AT_LEAST_ONE_SEP9=function(s){this.atLeastOneSepFirstInternal(9,s)},c.prototype.RULE=function(s,h,f){if(f===void 0&&(f=i.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,s)){var g=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:s,grammarName:this.className}),p={message:g,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:s};this.definitionErrors.push(p)}this.definedRulesNames.push(s);var T=this.defineRule(s,h,f);return this[s]=T,T},c.prototype.OVERRIDE_RULE=function(s,h,f){f===void 0&&(f=i.DEFAULT_RULE_CONFIG);var g=[];g=g.concat(a.validateRuleIsOverridden(s,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(g);var p=this.defineRule(s,h,f);return this[s]=p,p},c.prototype.BACKTRACK=function(s,h){return function(){this.isBackTrackingStack.push(1);var f=this.saveRecogState();try{return s.apply(this,h),!0}catch(g){if(t.isRecognitionException(g))return!1;throw g}finally{this.reloadRecogState(f),this.isBackTrackingStack.pop()}}},c.prototype.getGAstProductions=function(){return this.gastProductionsCache},c.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},c})();n.RecognizerApi=l}),oi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerEngine=void 0;var e=xe(),t=Pt(),i=lt(),r=Tt(),a=gt(),o=Ye(),l=Tn(),c=nt(),s=ct(),h=En(),f=(function(){function g(){}return g.prototype.initRecognizerEngine=function(p,T){if(this.className=h.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=s.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(T,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
168
|
+
`,type:o.REDUNDANT_METHOD,methodName:g});return p}n.validateRedundantMethods=f}),ai=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TreeBuilder=void 0;var e=oi(),t=Oe(),i=si(),r=Ye(),c=(function(){function o(){}return o.prototype.initTreeBuilder=function(u){if(this.CST_STACK=[],this.outputCst=u.outputCst,this.nodeLocationTracking=t.has(u,"nodeLocationTracking")?u.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+u.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(u){u.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(u){u.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(u){u.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(u){var a=this.LA(1);u.location={startOffset:a.startOffset,startLine:a.startLine,startColumn:a.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(u,a){var s={name:u,children:{}};this.setInitialNodeLocation(s),this.CST_STACK.push(s)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(u){var a=this.LA(0),s=u.location;s.startOffset<=a.startOffset?(s.endOffset=a.endOffset,s.endLine=a.endLine,s.endColumn=a.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(u){var a=this.LA(0),s=u.location;s.startOffset<=a.startOffset?s.endOffset=a.endOffset:s.startOffset=NaN},o.prototype.cstPostTerminal=function(u,a){var s=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(s,a,u),this.setNodeLocationFromToken(s.location,a)},o.prototype.cstPostNonTerminal=function(u,a){var s=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(s,a,u),this.setNodeLocationFromNode(s.location,u.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var u=i.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=u,u}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var u=i.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=u,u}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var u=this.RULE_OCCURRENCE_STACK;return u[u.length-1]},o})();n.TreeBuilder=c}),ci=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LexerAdapter=void 0;var e=Ye(),t=(function(){function i(){}return i.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(i.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),i.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},i.prototype.LA=function(r){var c=this.currIdx+r;return c<0||this.tokVectorLength<=c?e.END_OF_FILE:this.tokVector[c]},i.prototype.consumeToken=function(){this.currIdx++},i.prototype.exportLexerState=function(){return this.currIdx},i.prototype.importLexerState=function(r){this.currIdx=r},i.prototype.resetLexerState=function(){this.currIdx=-1},i.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},i.prototype.getLexerPosition=function(){return this.exportLexerState()},i})();n.LexerAdapter=t}),li=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerApi=void 0;var e=Oe(),t=ft(),i=Ye(),r=Tt(),c=An(),o=He(),u=(function(){function a(){}return a.prototype.ACTION=function(s){return s.call(this)},a.prototype.consume=function(s,f,h){return this.consumeInternal(f,s,h)},a.prototype.subrule=function(s,f,h){return this.subruleInternal(f,s,h)},a.prototype.option=function(s,f){return this.optionInternal(f,s)},a.prototype.or=function(s,f){return this.orInternal(f,s)},a.prototype.many=function(s,f){return this.manyInternal(s,f)},a.prototype.atLeastOne=function(s,f){return this.atLeastOneInternal(s,f)},a.prototype.CONSUME=function(s,f){return this.consumeInternal(s,0,f)},a.prototype.CONSUME1=function(s,f){return this.consumeInternal(s,1,f)},a.prototype.CONSUME2=function(s,f){return this.consumeInternal(s,2,f)},a.prototype.CONSUME3=function(s,f){return this.consumeInternal(s,3,f)},a.prototype.CONSUME4=function(s,f){return this.consumeInternal(s,4,f)},a.prototype.CONSUME5=function(s,f){return this.consumeInternal(s,5,f)},a.prototype.CONSUME6=function(s,f){return this.consumeInternal(s,6,f)},a.prototype.CONSUME7=function(s,f){return this.consumeInternal(s,7,f)},a.prototype.CONSUME8=function(s,f){return this.consumeInternal(s,8,f)},a.prototype.CONSUME9=function(s,f){return this.consumeInternal(s,9,f)},a.prototype.SUBRULE=function(s,f){return this.subruleInternal(s,0,f)},a.prototype.SUBRULE1=function(s,f){return this.subruleInternal(s,1,f)},a.prototype.SUBRULE2=function(s,f){return this.subruleInternal(s,2,f)},a.prototype.SUBRULE3=function(s,f){return this.subruleInternal(s,3,f)},a.prototype.SUBRULE4=function(s,f){return this.subruleInternal(s,4,f)},a.prototype.SUBRULE5=function(s,f){return this.subruleInternal(s,5,f)},a.prototype.SUBRULE6=function(s,f){return this.subruleInternal(s,6,f)},a.prototype.SUBRULE7=function(s,f){return this.subruleInternal(s,7,f)},a.prototype.SUBRULE8=function(s,f){return this.subruleInternal(s,8,f)},a.prototype.SUBRULE9=function(s,f){return this.subruleInternal(s,9,f)},a.prototype.OPTION=function(s){return this.optionInternal(s,0)},a.prototype.OPTION1=function(s){return this.optionInternal(s,1)},a.prototype.OPTION2=function(s){return this.optionInternal(s,2)},a.prototype.OPTION3=function(s){return this.optionInternal(s,3)},a.prototype.OPTION4=function(s){return this.optionInternal(s,4)},a.prototype.OPTION5=function(s){return this.optionInternal(s,5)},a.prototype.OPTION6=function(s){return this.optionInternal(s,6)},a.prototype.OPTION7=function(s){return this.optionInternal(s,7)},a.prototype.OPTION8=function(s){return this.optionInternal(s,8)},a.prototype.OPTION9=function(s){return this.optionInternal(s,9)},a.prototype.OR=function(s){return this.orInternal(s,0)},a.prototype.OR1=function(s){return this.orInternal(s,1)},a.prototype.OR2=function(s){return this.orInternal(s,2)},a.prototype.OR3=function(s){return this.orInternal(s,3)},a.prototype.OR4=function(s){return this.orInternal(s,4)},a.prototype.OR5=function(s){return this.orInternal(s,5)},a.prototype.OR6=function(s){return this.orInternal(s,6)},a.prototype.OR7=function(s){return this.orInternal(s,7)},a.prototype.OR8=function(s){return this.orInternal(s,8)},a.prototype.OR9=function(s){return this.orInternal(s,9)},a.prototype.MANY=function(s){this.manyInternal(0,s)},a.prototype.MANY1=function(s){this.manyInternal(1,s)},a.prototype.MANY2=function(s){this.manyInternal(2,s)},a.prototype.MANY3=function(s){this.manyInternal(3,s)},a.prototype.MANY4=function(s){this.manyInternal(4,s)},a.prototype.MANY5=function(s){this.manyInternal(5,s)},a.prototype.MANY6=function(s){this.manyInternal(6,s)},a.prototype.MANY7=function(s){this.manyInternal(7,s)},a.prototype.MANY8=function(s){this.manyInternal(8,s)},a.prototype.MANY9=function(s){this.manyInternal(9,s)},a.prototype.MANY_SEP=function(s){this.manySepFirstInternal(0,s)},a.prototype.MANY_SEP1=function(s){this.manySepFirstInternal(1,s)},a.prototype.MANY_SEP2=function(s){this.manySepFirstInternal(2,s)},a.prototype.MANY_SEP3=function(s){this.manySepFirstInternal(3,s)},a.prototype.MANY_SEP4=function(s){this.manySepFirstInternal(4,s)},a.prototype.MANY_SEP5=function(s){this.manySepFirstInternal(5,s)},a.prototype.MANY_SEP6=function(s){this.manySepFirstInternal(6,s)},a.prototype.MANY_SEP7=function(s){this.manySepFirstInternal(7,s)},a.prototype.MANY_SEP8=function(s){this.manySepFirstInternal(8,s)},a.prototype.MANY_SEP9=function(s){this.manySepFirstInternal(9,s)},a.prototype.AT_LEAST_ONE=function(s){this.atLeastOneInternal(0,s)},a.prototype.AT_LEAST_ONE1=function(s){return this.atLeastOneInternal(1,s)},a.prototype.AT_LEAST_ONE2=function(s){this.atLeastOneInternal(2,s)},a.prototype.AT_LEAST_ONE3=function(s){this.atLeastOneInternal(3,s)},a.prototype.AT_LEAST_ONE4=function(s){this.atLeastOneInternal(4,s)},a.prototype.AT_LEAST_ONE5=function(s){this.atLeastOneInternal(5,s)},a.prototype.AT_LEAST_ONE6=function(s){this.atLeastOneInternal(6,s)},a.prototype.AT_LEAST_ONE7=function(s){this.atLeastOneInternal(7,s)},a.prototype.AT_LEAST_ONE8=function(s){this.atLeastOneInternal(8,s)},a.prototype.AT_LEAST_ONE9=function(s){this.atLeastOneInternal(9,s)},a.prototype.AT_LEAST_ONE_SEP=function(s){this.atLeastOneSepFirstInternal(0,s)},a.prototype.AT_LEAST_ONE_SEP1=function(s){this.atLeastOneSepFirstInternal(1,s)},a.prototype.AT_LEAST_ONE_SEP2=function(s){this.atLeastOneSepFirstInternal(2,s)},a.prototype.AT_LEAST_ONE_SEP3=function(s){this.atLeastOneSepFirstInternal(3,s)},a.prototype.AT_LEAST_ONE_SEP4=function(s){this.atLeastOneSepFirstInternal(4,s)},a.prototype.AT_LEAST_ONE_SEP5=function(s){this.atLeastOneSepFirstInternal(5,s)},a.prototype.AT_LEAST_ONE_SEP6=function(s){this.atLeastOneSepFirstInternal(6,s)},a.prototype.AT_LEAST_ONE_SEP7=function(s){this.atLeastOneSepFirstInternal(7,s)},a.prototype.AT_LEAST_ONE_SEP8=function(s){this.atLeastOneSepFirstInternal(8,s)},a.prototype.AT_LEAST_ONE_SEP9=function(s){this.atLeastOneSepFirstInternal(9,s)},a.prototype.RULE=function(s,f,h){if(h===void 0&&(h=i.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,s)){var T=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:s,grammarName:this.className}),p={message:T,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:s};this.definitionErrors.push(p)}this.definedRulesNames.push(s);var g=this.defineRule(s,f,h);return this[s]=g,g},a.prototype.OVERRIDE_RULE=function(s,f,h){h===void 0&&(h=i.DEFAULT_RULE_CONFIG);var T=[];T=T.concat(c.validateRuleIsOverridden(s,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(T);var p=this.defineRule(s,f,h);return this[s]=p,p},a.prototype.BACKTRACK=function(s,f){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return s.apply(this,f),!0}catch(T){if(t.isRecognitionException(T))return!1;throw T}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},a.prototype.getGAstProductions=function(){return this.gastProductionsCache},a.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},a})();n.RecognizerApi=u}),ui=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerEngine=void 0;var e=Oe(),t=Ut(),i=ft(),r=vt(),c=Et(),o=Ye(),u=bn(),a=tt(),s=ut(),f=Ln(),h=(function(){function T(){}return T.prototype.initRecognizerEngine=function(p,g){if(this.className=f.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=s.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(g,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
169
169
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
170
170
|
For Further details.`);if(e.isArray(p)){if(e.isEmpty(p))throw Error(`A Token Vocabulary cannot be empty.
|
|
171
171
|
Note that the first argument for the parser constructor
|
|
172
172
|
is no longer a Token vector (since v4.0).`);if(typeof p[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
173
173
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
174
|
-
For Further details.`)}if(e.isArray(p))this.tokensMap=e.reduce(p,function(
|
|
175
|
-
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var u=e.has(m,"resyncEnabled")?m.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,d=e.has(m,"recoveryValueFunc")?m.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,y=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[y]=p,this.fullRuleNameToShort[p]=y;function v(P){try{if(this.outputCst===!0){T.apply(this,P);var w=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(w),w}else return T.apply(this,P)}catch(Y){return this.invokeRuleCatch(Y,u,d)}finally{this.ruleFinallyStateUpdate()}}var E=function(P,w){return P===void 0&&(P=0),this.ruleInvocationStateUpdate(y,p,P),v.call(this,w)},b="ruleName";return E[b]=p,E.originalGrammarAction=T,E},g.prototype.invokeRuleCatch=function(p,T,m){var u=this.RULE_STACK.length===1,d=T&&!this.isBackTracking()&&this.recoveryEnabled;if(i.isRecognitionException(p)){var y=p;if(d){var v=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(v))if(y.resyncedTokens=this.reSyncTo(v),this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];return E.recoveredNode=!0,E}else return m();else{if(this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];E.recoveredNode=!0,y.partialCstResult=E}throw y}}else{if(u)return this.moveToTerminatedState(),m();throw y}}else throw p},g.prototype.optionInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OPTION_IDX,T);return this.optionInternalLogic(p,T,m)},g.prototype.optionInternalLogic=function(p,T,m){var u=this,d=this.getLaFuncFromCache(m),y,v;if(p.DEF!==void 0){if(y=p.DEF,v=p.GATE,v!==void 0){var E=d;d=function(){return v.call(u)&&E.call(u)}}}else y=p;if(d.call(this)===!0)return y.call(this)},g.prototype.atLeastOneInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,T,m)},g.prototype.atLeastOneInternalLogic=function(p,T,m){var u=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(u)&&E.call(u)}}}else y=T;if(d.call(this)===!0)for(var b=this.doSingleRepetition(y);d.call(this)===!0&&b===!0;)b=this.doSingleRepetition(y);else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY,T.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,T],d,t.AT_LEAST_ONE_IDX,p,a.NextTerminalAfterAtLeastOneWalker)},g.prototype.atLeastOneSepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,T,m)},g.prototype.atLeastOneSepFirstInternalLogic=function(p,T,m){var u=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return u.tokenMatcher(u.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterAtLeastOneSepWalker],E,t.AT_LEAST_ONE_SEP_IDX,p,a.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,T.ERR_MSG)},g.prototype.manyInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,T,m)},g.prototype.manyInternalLogic=function(p,T,m){var u=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(u)&&E.call(u)}}}else y=T;for(var b=!0;d.call(this)===!0&&b===!0;)b=this.doSingleRepetition(y);this.attemptInRepetitionRecovery(this.manyInternal,[p,T],d,t.MANY_IDX,p,a.NextTerminalAfterManyWalker,b)},g.prototype.manySepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,T,m)},g.prototype.manySepFirstInternalLogic=function(p,T,m){var u=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return u.tokenMatcher(u.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterManySepWalker],E,t.MANY_SEP_IDX,p,a.NextTerminalAfterManySepWalker)}},g.prototype.repetitionSepSecondInternal=function(p,T,m,u,d){for(;m();)this.CONSUME(T),u.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,T,m,u,d],m,t.AT_LEAST_ONE_SEP_IDX,p,d)},g.prototype.doSingleRepetition=function(p){var T=this.getLexerPosition();p.call(this);var m=this.getLexerPosition();return m>T},g.prototype.orInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OR_IDX,T),u=e.isArray(p)?p:p.DEF,d=this.getLaFuncFromCache(m),y=d.call(this,u);if(y!==void 0){var v=u[y];return v.ALT.call(this)}this.raiseNoAltException(T,p.ERR_MSG)},g.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),T=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new i.NotAllInputParsedException(T,p))}},g.prototype.subruleInternal=function(p,T,m){var u;try{var d=m!==void 0?m.ARGS:void 0;return u=p.call(this,T,d),this.cstPostNonTerminal(u,m!==void 0&&m.LABEL!==void 0?m.LABEL:p.ruleName),u}catch(y){this.subruleInternalError(y,m,p.ruleName)}},g.prototype.subruleInternalError=function(p,T,m){throw i.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,T!==void 0&&T.LABEL!==void 0?T.LABEL:m),delete p.partialCstResult),p},g.prototype.consumeInternal=function(p,T,m){var u;try{var d=this.LA(1);this.tokenMatcher(d,p)===!0?(this.consumeToken(),u=d):this.consumeInternalError(p,d,m)}catch(y){u=this.consumeInternalRecovery(p,T,y)}return this.cstPostTerminal(m!==void 0&&m.LABEL!==void 0?m.LABEL:p.name,u),u},g.prototype.consumeInternalError=function(p,T,m){var u,d=this.LA(0);throw m!==void 0&&m.ERR_MSG?u=m.ERR_MSG:u=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:T,previous:d,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new i.MismatchedTokenException(u,T,d))},g.prototype.consumeInternalRecovery=function(p,T,m){if(this.recoveryEnabled&&m.name==="MismatchedTokenException"&&!this.isBackTracking()){var u=this.getFollowsForInRuleRecovery(p,T);try{return this.tryInRuleRecovery(p,u)}catch(d){throw d.name===l.IN_RULE_RECOVERY_EXCEPTION?m:d}}else throw m},g.prototype.saveRecogState=function(){var p=this.errors,T=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:T,CST_STACK:this.CST_STACK}},g.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},g.prototype.ruleInvocationStateUpdate=function(p,T,m){this.RULE_OCCURRENCE_STACK.push(m),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(T,p)},g.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},g.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},g.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},g.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},g.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},g})();n.RecognizerEngine=f}),si=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorHandler=void 0;var e=lt(),t=xe(),i=Tt(),r=Ye(),a=(function(){function o(){}return o.prototype.initErrorHandler=function(l){this._errors=[],this.errorMessageProvider=t.has(l,"errorMessageProvider")?l.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(l){if(e.isRecognitionException(l))return l.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(l),l;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(l){this._errors=l},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(l,c,s){for(var h=this.getCurrRuleFullName(),f=this.getGAstProductions()[h],g=i.getLookaheadPathsForOptionalProd(l,f,c,this.maxLookahead),p=g[0],T=[],m=1;m<=this.maxLookahead;m++)T.push(this.LA(m));var u=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:T,previous:this.LA(0),customUserDescription:s,ruleName:h});throw this.SAVE_ERROR(new e.EarlyExitException(u,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(l,c){for(var s=this.getCurrRuleFullName(),h=this.getGAstProductions()[s],f=i.getLookaheadPathsForOr(l,h,this.maxLookahead),g=[],p=1;p<=this.maxLookahead;p++)g.push(this.LA(p));var T=this.LA(0),m=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:f,actual:g,previous:T,customUserDescription:c,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(m,this.LA(1),T))},o})();n.ErrorHandler=a}),ai=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ContentAssist=void 0;var e=gt(),t=xe(),i=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(a,o){var l=this.gastProductionsCache[a];if(t.isUndefined(l))throw Error("Rule ->"+a+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([l],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(a){var o=t.first(a.ruleStack),l=this.getGAstProductions(),c=l[o],s=new e.NextAfterTokenWalker(c,a).startWalking();return s},r})();n.ContentAssist=i}),ci=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GastRecorder=void 0;var e=xe(),t=He(),i=pt(),r=ct(),a=nt(),o=Ye(),l=Pt(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var s=!0,h=Math.pow(2,l.BITS_FOR_OCCURRENCE_IDX)-1,f=a.createToken({name:"RECORDING_PHASE_TOKEN",pattern:i.Lexer.NA});r.augmentTokenTypes([f]);var g=a.createTokenInstance(f,`This IToken indicates the Parser is in Recording Phase
|
|
176
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(
|
|
177
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},
|
|
174
|
+
For Further details.`)}if(e.isArray(p))this.tokensMap=e.reduce(p,function(m,v){return m[v.name]=v,m},{});else if(e.has(p,"modes")&&e.every(e.flatten(e.values(p.modes)),s.isTokenType)){var y=e.flatten(e.values(p.modes)),l=e.uniq(y);this.tokensMap=e.reduce(l,function(m,v){return m[v.name]=v,m},{})}else if(e.isObject(p))this.tokensMap=e.cloneObj(p);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=a.EOF;var d=e.every(e.values(p),function(m){return e.isEmpty(m.categoryMatches)});this.tokenMatcher=d?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher,s.augmentTokenTypes(e.values(this.tokensMap))},T.prototype.defineRule=function(p,g,y){if(this.selfAnalysisDone)throw Error("Grammar rule <"+p+`> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
175
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var l=e.has(y,"resyncEnabled")?y.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,d=e.has(y,"recoveryValueFunc")?y.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,m=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[m]=p,this.fullRuleNameToShort[p]=m;function v(N){try{if(this.outputCst===!0){g.apply(this,N);var C=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(C),C}else return g.apply(this,N)}catch(Y){return this.invokeRuleCatch(Y,l,d)}finally{this.ruleFinallyStateUpdate()}}var E=function(N,C){return N===void 0&&(N=0),this.ruleInvocationStateUpdate(m,p,N),v.call(this,C)},S="ruleName";return E[S]=p,E.originalGrammarAction=g,E},T.prototype.invokeRuleCatch=function(p,g,y){var l=this.RULE_STACK.length===1,d=g&&!this.isBackTracking()&&this.recoveryEnabled;if(i.isRecognitionException(p)){var m=p;if(d){var v=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(v))if(m.resyncedTokens=this.reSyncTo(v),this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];return E.recoveredNode=!0,E}else return y();else{if(this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];E.recoveredNode=!0,m.partialCstResult=E}throw m}}else{if(l)return this.moveToTerminatedState(),y();throw m}}else throw p},T.prototype.optionInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.OPTION_IDX,g);return this.optionInternalLogic(p,g,y)},T.prototype.optionInternalLogic=function(p,g,y){var l=this,d=this.getLaFuncFromCache(y),m,v;if(p.DEF!==void 0){if(m=p.DEF,v=p.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else m=p;if(d.call(this)===!0)return m.call(this)},T.prototype.atLeastOneInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,g,y)},T.prototype.atLeastOneInternalLogic=function(p,g,y){var l=this,d=this.getLaFuncFromCache(y),m,v;if(g.DEF!==void 0){if(m=g.DEF,v=g.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else m=g;if(d.call(this)===!0)for(var S=this.doSingleRepetition(m);d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(m);else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY,g.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,g],d,t.AT_LEAST_ONE_IDX,p,c.NextTerminalAfterAtLeastOneWalker)},T.prototype.atLeastOneSepFirstInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,g,y)},T.prototype.atLeastOneSepFirstInternalLogic=function(p,g,y){var l=this,d=g.DEF,m=g.SEP,v=this.getLaFuncFromCache(y);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),m)};this.tokenMatcher(this.LA(1),m)===!0;)this.CONSUME(m),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,m,E,d,c.NextTerminalAfterAtLeastOneSepWalker],E,t.AT_LEAST_ONE_SEP_IDX,p,c.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.ERR_MSG)},T.prototype.manyInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,g,y)},T.prototype.manyInternalLogic=function(p,g,y){var l=this,d=this.getLaFuncFromCache(y),m,v;if(g.DEF!==void 0){if(m=g.DEF,v=g.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else m=g;for(var S=!0;d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(m);this.attemptInRepetitionRecovery(this.manyInternal,[p,g],d,t.MANY_IDX,p,c.NextTerminalAfterManyWalker,S)},T.prototype.manySepFirstInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,g,y)},T.prototype.manySepFirstInternalLogic=function(p,g,y){var l=this,d=g.DEF,m=g.SEP,v=this.getLaFuncFromCache(y);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),m)};this.tokenMatcher(this.LA(1),m)===!0;)this.CONSUME(m),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,m,E,d,c.NextTerminalAfterManySepWalker],E,t.MANY_SEP_IDX,p,c.NextTerminalAfterManySepWalker)}},T.prototype.repetitionSepSecondInternal=function(p,g,y,l,d){for(;y();)this.CONSUME(g),l.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,g,y,l,d],y,t.AT_LEAST_ONE_SEP_IDX,p,d)},T.prototype.doSingleRepetition=function(p){var g=this.getLexerPosition();p.call(this);var y=this.getLexerPosition();return y>g},T.prototype.orInternal=function(p,g){var y=this.getKeyForAutomaticLookahead(t.OR_IDX,g),l=e.isArray(p)?p:p.DEF,d=this.getLaFuncFromCache(y),m=d.call(this,l);if(m!==void 0){var v=l[m];return v.ALT.call(this)}this.raiseNoAltException(g,p.ERR_MSG)},T.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),g=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new i.NotAllInputParsedException(g,p))}},T.prototype.subruleInternal=function(p,g,y){var l;try{var d=y!==void 0?y.ARGS:void 0;return l=p.call(this,g,d),this.cstPostNonTerminal(l,y!==void 0&&y.LABEL!==void 0?y.LABEL:p.ruleName),l}catch(m){this.subruleInternalError(m,y,p.ruleName)}},T.prototype.subruleInternalError=function(p,g,y){throw i.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,g!==void 0&&g.LABEL!==void 0?g.LABEL:y),delete p.partialCstResult),p},T.prototype.consumeInternal=function(p,g,y){var l;try{var d=this.LA(1);this.tokenMatcher(d,p)===!0?(this.consumeToken(),l=d):this.consumeInternalError(p,d,y)}catch(m){l=this.consumeInternalRecovery(p,g,m)}return this.cstPostTerminal(y!==void 0&&y.LABEL!==void 0?y.LABEL:p.name,l),l},T.prototype.consumeInternalError=function(p,g,y){var l,d=this.LA(0);throw y!==void 0&&y.ERR_MSG?l=y.ERR_MSG:l=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:g,previous:d,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new i.MismatchedTokenException(l,g,d))},T.prototype.consumeInternalRecovery=function(p,g,y){if(this.recoveryEnabled&&y.name==="MismatchedTokenException"&&!this.isBackTracking()){var l=this.getFollowsForInRuleRecovery(p,g);try{return this.tryInRuleRecovery(p,l)}catch(d){throw d.name===u.IN_RULE_RECOVERY_EXCEPTION?y:d}}else throw y},T.prototype.saveRecogState=function(){var p=this.errors,g=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:g,CST_STACK:this.CST_STACK}},T.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},T.prototype.ruleInvocationStateUpdate=function(p,g,y){this.RULE_OCCURRENCE_STACK.push(y),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(g,p)},T.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},T.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},T.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},T.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),a.EOF)},T.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},T})();n.RecognizerEngine=h}),hi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorHandler=void 0;var e=ft(),t=Oe(),i=vt(),r=Ye(),c=(function(){function o(){}return o.prototype.initErrorHandler=function(u){this._errors=[],this.errorMessageProvider=t.has(u,"errorMessageProvider")?u.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(u){if(e.isRecognitionException(u))return u.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(u),u;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(u){this._errors=u},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(u,a,s){for(var f=this.getCurrRuleFullName(),h=this.getGAstProductions()[f],T=i.getLookaheadPathsForOptionalProd(u,h,a,this.maxLookahead),p=T[0],g=[],y=1;y<=this.maxLookahead;y++)g.push(this.LA(y));var l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:g,previous:this.LA(0),customUserDescription:s,ruleName:f});throw this.SAVE_ERROR(new e.EarlyExitException(l,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(u,a){for(var s=this.getCurrRuleFullName(),f=this.getGAstProductions()[s],h=i.getLookaheadPathsForOr(u,f,this.maxLookahead),T=[],p=1;p<=this.maxLookahead;p++)T.push(this.LA(p));var g=this.LA(0),y=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:T,previous:g,customUserDescription:a,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(y,this.LA(1),g))},o})();n.ErrorHandler=c}),fi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ContentAssist=void 0;var e=Et(),t=Oe(),i=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(c,o){var u=this.gastProductionsCache[c];if(t.isUndefined(u))throw Error("Rule ->"+c+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([u],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(c){var o=t.first(c.ruleStack),u=this.getGAstProductions(),a=u[o],s=new e.NextAfterTokenWalker(a,c).startWalking();return s},r})();n.ContentAssist=i}),di=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GastRecorder=void 0;var e=Oe(),t=He(),i=yt(),r=ut(),c=tt(),o=Ye(),u=Ut(),a={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(a);var s=!0,f=Math.pow(2,u.BITS_FOR_OCCURRENCE_IDX)-1,h=c.createToken({name:"RECORDING_PHASE_TOKEN",pattern:i.Lexer.NA});r.augmentTokenTypes([h]);var T=c.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
|
|
176
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(T);var p={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
177
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},g=(function(){function v(){}return v.prototype.initGastRecorder=function(E){this.recordingProdStack=[],this.RECORDING_PHASE=!1},v.prototype.enableRecording=function(){var E=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var S=function(C){var Y=C>0?C:"";E["CONSUME"+Y]=function(O,j){return this.consumeInternalRecord(O,C,j)},E["SUBRULE"+Y]=function(O,j){return this.subruleInternalRecord(O,C,j)},E["OPTION"+Y]=function(O){return this.optionInternalRecord(O,C)},E["OR"+Y]=function(O){return this.orInternalRecord(O,C)},E["MANY"+Y]=function(O){this.manyInternalRecord(C,O)},E["MANY_SEP"+Y]=function(O){this.manySepFirstInternalRecord(C,O)},E["AT_LEAST_ONE"+Y]=function(O){this.atLeastOneInternalRecord(C,O)},E["AT_LEAST_ONE_SEP"+Y]=function(O){this.atLeastOneSepFirstInternalRecord(C,O)}},N=0;N<10;N++)S(N);E.consume=function(C,Y,O){return this.consumeInternalRecord(Y,C,O)},E.subrule=function(C,Y,O){return this.subruleInternalRecord(Y,C,O)},E.option=function(C,Y){return this.optionInternalRecord(Y,C)},E.or=function(C,Y){return this.orInternalRecord(Y,C)},E.many=function(C,Y){this.manyInternalRecord(C,Y)},E.atLeastOne=function(C,Y){this.atLeastOneInternalRecord(C,Y)},E.ACTION=E.ACTION_RECORD,E.BACKTRACK=E.BACKTRACK_RECORD,E.LA=E.LA_RECORD})},v.prototype.disableRecording=function(){var E=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var S=0;S<10;S++){var N=S>0?S:"";delete E["CONSUME"+N],delete E["SUBRULE"+N],delete E["OPTION"+N],delete E["OR"+N],delete E["MANY"+N],delete E["MANY_SEP"+N],delete E["AT_LEAST_ONE"+N],delete E["AT_LEAST_ONE_SEP"+N]}delete E.consume,delete E.subrule,delete E.option,delete E.or,delete E.many,delete E.atLeastOne,delete E.ACTION,delete E.BACKTRACK,delete E.LA})},v.prototype.ACTION_RECORD=function(E){},v.prototype.BACKTRACK_RECORD=function(E,S){return function(){return!0}},v.prototype.LA_RECORD=function(E){return o.END_OF_FILE},v.prototype.topLevelRuleRecord=function(E,S){try{var N=new t.Rule({definition:[],name:E});return N.name=E,this.recordingProdStack.push(N),S.call(this),this.recordingProdStack.pop(),N}catch(C){if(C.KNOWN_RECORDER_ERROR!==!0)try{C.message=C.message+`
|
|
178
178
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
179
|
-
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw
|
|
180
|
-
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw
|
|
181
|
-
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw
|
|
182
|
-
`+("Idx value must be a none negative value smaller than "+(
|
|
179
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw C}throw C}},v.prototype.optionInternalRecord=function(E,S){return y.call(this,t.Option,E,S)},v.prototype.atLeastOneInternalRecord=function(E,S){y.call(this,t.RepetitionMandatory,S,E)},v.prototype.atLeastOneSepFirstInternalRecord=function(E,S){y.call(this,t.RepetitionMandatoryWithSeparator,S,E,s)},v.prototype.manyInternalRecord=function(E,S){y.call(this,t.Repetition,S,E)},v.prototype.manySepFirstInternalRecord=function(E,S){y.call(this,t.RepetitionWithSeparator,S,E,s)},v.prototype.orInternalRecord=function(E,S){return l.call(this,E,S)},v.prototype.subruleInternalRecord=function(E,S,N){if(m(S),!E||e.has(E,"ruleName")===!1){var C=new Error("<SUBRULE"+d(S)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(E)+">")+(`
|
|
180
|
+
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw C.KNOWN_RECORDER_ERROR=!0,C}var Y=e.peek(this.recordingProdStack),O=E.ruleName,j=new t.NonTerminal({idx:S,nonTerminalName:O,referencedRule:void 0});return Y.definition.push(j),this.outputCst?p:a},v.prototype.consumeInternalRecord=function(E,S,N){if(m(S),!r.hasShortKeyProperty(E)){var C=new Error("<CONSUME"+d(S)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(E)+">")+(`
|
|
181
|
+
inside top level rule: <`+this.recordingProdStack[0].name+">"));throw C.KNOWN_RECORDER_ERROR=!0,C}var Y=e.peek(this.recordingProdStack),O=new t.Terminal({idx:S,terminalType:E});return Y.definition.push(O),T},v})();n.GastRecorder=g;function y(v,E,S,N){N===void 0&&(N=!1),m(S);var C=e.peek(this.recordingProdStack),Y=e.isFunction(E)?E:E.DEF,O=new v({definition:[],idx:S});return N&&(O.separator=E.SEP),e.has(E,"MAX_LOOKAHEAD")&&(O.maxLookahead=E.MAX_LOOKAHEAD),this.recordingProdStack.push(O),Y.call(this),C.definition.push(O),this.recordingProdStack.pop(),a}function l(v,E){var S=this;m(E);var N=e.peek(this.recordingProdStack),C=e.isArray(v)===!1,Y=C===!1?v:v.DEF,O=new t.Alternation({definition:[],idx:E,ignoreAmbiguities:C&&v.IGNORE_AMBIGUITIES===!0});e.has(v,"MAX_LOOKAHEAD")&&(O.maxLookahead=v.MAX_LOOKAHEAD);var j=e.some(Y,function(M){return e.isFunction(M.GATE)});return O.hasPredicates=j,N.definition.push(O),e.forEach(Y,function(M){var x=new t.Alternative({definition:[]});O.definition.push(x),e.has(M,"IGNORE_AMBIGUITIES")?x.ignoreAmbiguities=M.IGNORE_AMBIGUITIES:e.has(M,"GATE")&&(x.ignoreAmbiguities=!0),S.recordingProdStack.push(x),M.ALT.call(S),S.recordingProdStack.pop()}),a}function d(v){return v===0?"":""+v}function m(v){if(v<0||v>f){var E=new Error("Invalid DSL Method idx value: <"+v+`>
|
|
182
|
+
`+("Idx value must be a none negative value smaller than "+(f+1)));throw E.KNOWN_RECORDER_ERROR=!0,E}}}),pi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PerformanceTracer=void 0;var e=Oe(),t=Ye(),i=(function(){function r(){}return r.prototype.initPerformanceTracer=function(c){if(e.has(c,"traceInitPerf")){var o=c.traceInitPerf,u=typeof o=="number";this.traceInitMaxIdent=u?o:1/0,this.traceInitPerf=u?o>0:o}else this.traceInitMaxIdent=0,this.traceInitPerf=t.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},r.prototype.TRACE_INIT=function(c,o){if(this.traceInitPerf===!0){this.traceInitIndent++;var u=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(u+"--> <"+c+">");var a=e.timer(o),s=a.time,f=a.value,h=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(u+"<-- <"+c+"> time: "+s+"ms"),this.traceInitIndent--,f}else return o()},r})();n.PerformanceTracer=i}),mi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.applyMixins=void 0;function e(t,i){i.forEach(function(r){var c=r.prototype;Object.getOwnPropertyNames(c).forEach(function(o){if(o!=="constructor"){var u=Object.getOwnPropertyDescriptor(c,o);u&&(u.get||u.set)?Object.defineProperty(t.prototype,o,u):t.prototype[o]=r.prototype[o]}})})}n.applyMixins=e}),Ye=ve(n=>{var e=n&&n.__extends||(function(){var N=function(C,Y){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,j){O.__proto__=j}||function(O,j){for(var M in j)Object.prototype.hasOwnProperty.call(j,M)&&(O[M]=j[M])},N(C,Y)};return function(C,Y){if(typeof Y!="function"&&Y!==null)throw new TypeError("Class extends value "+String(Y)+" is not a constructor or null");N(C,Y);function O(){this.constructor=C}C.prototype=Y===null?Object.create(Y):(O.prototype=Y.prototype,new O)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.EmbeddedActionsParser=n.CstParser=n.Parser=n.EMPTY_ALT=n.ParserDefinitionErrorType=n.DEFAULT_RULE_CONFIG=n.DEFAULT_PARSER_CONFIG=n.END_OF_FILE=void 0;var t=Oe(),i=ti(),r=tt(),c=Tt(),o=ri(),u=bn(),a=ii(),s=ai(),f=ci(),h=li(),T=ui(),p=hi(),g=fi(),y=di(),l=pi(),d=mi();n.END_OF_FILE=r.createTokenInstance(r.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(n.END_OF_FILE),n.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:c.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),n.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0}),(function(N){N[N.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",N[N.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",N[N.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",N[N.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",N[N.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",N[N.LEFT_RECURSION=5]="LEFT_RECURSION",N[N.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",N[N.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",N[N.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",N[N.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",N[N.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",N[N.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",N[N.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(n.ParserDefinitionErrorType||(n.ParserDefinitionErrorType={}));function m(N){return N===void 0&&(N=void 0),function(){return N}}n.EMPTY_ALT=m;var v=(function(){function N(C,Y){this.definitionErrors=[],this.selfAnalysisDone=!1;var O=this;if(O.initErrorHandler(Y),O.initLexerAdapter(),O.initLooksAhead(Y),O.initRecognizerEngine(C,Y),O.initRecoverable(Y),O.initTreeBuilder(Y),O.initContentAssist(),O.initGastRecorder(Y),O.initPerformanceTracer(Y),t.has(Y,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
183
183
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
184
184
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
185
|
-
For further details.`);this.skipValidations=t.has(Y,"skipValidations")?Y.skipValidations:n.DEFAULT_PARSER_CONFIG.skipValidations}return
|
|
185
|
+
For further details.`);this.skipValidations=t.has(Y,"skipValidations")?Y.skipValidations:n.DEFAULT_PARSER_CONFIG.skipValidations}return N.performSelfAnalysis=function(C){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},N.prototype.performSelfAnalysis=function(){var C=this;this.TRACE_INIT("performSelfAnalysis",function(){var Y;C.selfAnalysisDone=!0;var O=C.className;C.TRACE_INIT("toFastProps",function(){t.toFastProperties(C)}),C.TRACE_INIT("Grammar Recording",function(){try{C.enableRecording(),t.forEach(C.definedRulesNames,function(M){var x=C[M],P=x.originalGrammarAction,k=void 0;C.TRACE_INIT(M+" Rule",function(){k=C.topLevelRuleRecord(M,P)}),C.gastProductionsCache[M]=k})}finally{C.disableRecording()}});var j=[];if(C.TRACE_INIT("Grammar Resolving",function(){j=o.resolveGrammar({rules:t.values(C.gastProductionsCache)}),C.definitionErrors=C.definitionErrors.concat(j)}),C.TRACE_INIT("Grammar Validations",function(){if(t.isEmpty(j)&&C.skipValidations===!1){var M=o.validateGrammar({rules:t.values(C.gastProductionsCache),maxLookahead:C.maxLookahead,tokenTypes:t.values(C.tokensMap),errMsgProvider:c.defaultGrammarValidatorErrorProvider,grammarName:O});C.definitionErrors=C.definitionErrors.concat(M)}}),t.isEmpty(C.definitionErrors)&&(C.recoveryEnabled&&C.TRACE_INIT("computeAllProdsFollows",function(){var M=i.computeAllProdsFollows(t.values(C.gastProductionsCache));C.resyncFollows=M}),C.TRACE_INIT("ComputeLookaheadFunctions",function(){C.preComputeLookaheadFunctions(t.values(C.gastProductionsCache))})),!N.DEFER_DEFINITION_ERRORS_HANDLING&&!t.isEmpty(C.definitionErrors))throw Y=t.map(C.definitionErrors,function(M){return M.message}),new Error(`Parser Definition Errors detected:
|
|
186
186
|
`+Y.join(`
|
|
187
187
|
-------------------------------
|
|
188
|
-
`))})},
|
|
188
|
+
`))})},N.DEFER_DEFINITION_ERRORS_HANDLING=!1,N})();n.Parser=v,d.applyMixins(v,[u.Recoverable,a.LooksAhead,s.TreeBuilder,f.LexerAdapter,T.RecognizerEngine,h.RecognizerApi,p.ErrorHandler,g.ContentAssist,y.GastRecorder,l.PerformanceTracer]);var E=(function(N){e(C,N);function C(Y,O){O===void 0&&(O=n.DEFAULT_PARSER_CONFIG);var j=this,M=t.cloneObj(O);return M.outputCst=!0,j=N.call(this,Y,M)||this,j}return C})(v);n.CstParser=E;var S=(function(N){e(C,N);function C(Y,O){O===void 0&&(O=n.DEFAULT_PARSER_CONFIG);var j=this,M=t.cloneObj(O);return M.outputCst=!1,j=N.call(this,Y,M)||this,j}return C})(v);n.EmbeddedActionsParser=S}),yi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createSyntaxDiagramsCode=void 0;var e=Tn();function t(i,r){var c=r===void 0?{}:r,o=c.resourceBase,u=o===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/":o,a=c.css,s=a===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/diagrams.css":a,f=`
|
|
189
189
|
<!-- This is a generated file -->
|
|
190
190
|
<!DOCTYPE html>
|
|
191
191
|
<meta charset="utf-8">
|
|
@@ -195,26 +195,26 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
195
195
|
}
|
|
196
196
|
</style>
|
|
197
197
|
|
|
198
|
-
`,
|
|
198
|
+
`,h=`
|
|
199
199
|
<link rel='stylesheet' href='`+s+`'>
|
|
200
|
-
`,
|
|
201
|
-
<script src='`+
|
|
202
|
-
<script src='`+
|
|
203
|
-
<script src='`+
|
|
204
|
-
<script src='`+
|
|
200
|
+
`,T=`
|
|
201
|
+
<script src='`+u+`vendor/railroad-diagrams.js'><\/script>
|
|
202
|
+
<script src='`+u+`src/diagrams_builder.js'><\/script>
|
|
203
|
+
<script src='`+u+`src/diagrams_behavior.js'><\/script>
|
|
204
|
+
<script src='`+u+`src/main.js'><\/script>
|
|
205
205
|
`,p=`
|
|
206
206
|
<div id="diagrams" align="center"></div>
|
|
207
|
-
`,
|
|
207
|
+
`,g=`
|
|
208
208
|
<script>
|
|
209
209
|
window.serializedGrammar = `+JSON.stringify(i,null," ")+`;
|
|
210
210
|
<\/script>
|
|
211
|
-
`,
|
|
211
|
+
`,y=`
|
|
212
212
|
<script>
|
|
213
213
|
var diagramsDiv = document.getElementById("diagrams");
|
|
214
214
|
main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
|
|
215
215
|
<\/script>
|
|
216
|
-
`;return h+
|
|
216
|
+
`;return f+h+T+p+g+y}n.createSyntaxDiagramsCode=t}),gi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Parser=n.createSyntaxDiagramsCode=n.clearCache=n.GAstVisitor=n.serializeProduction=n.serializeGrammar=n.Terminal=n.Rule=n.RepetitionWithSeparator=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Repetition=n.Option=n.NonTerminal=n.Alternative=n.Alternation=n.defaultLexerErrorProvider=n.NoViableAltException=n.NotAllInputParsedException=n.MismatchedTokenException=n.isRecognitionException=n.EarlyExitException=n.defaultParserErrorProvider=n.tokenName=n.tokenMatcher=n.tokenLabel=n.EOF=n.createTokenInstance=n.createToken=n.LexerDefinitionErrorType=n.Lexer=n.EMPTY_ALT=n.ParserDefinitionErrorType=n.EmbeddedActionsParser=n.CstParser=n.VERSION=void 0;var e=Tn();Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=Ye();Object.defineProperty(n,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(n,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(n,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(n,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var i=yt();Object.defineProperty(n,"Lexer",{enumerable:!0,get:function(){return i.Lexer}}),Object.defineProperty(n,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return i.LexerDefinitionErrorType}});var r=tt();Object.defineProperty(n,"createToken",{enumerable:!0,get:function(){return r.createToken}}),Object.defineProperty(n,"createTokenInstance",{enumerable:!0,get:function(){return r.createTokenInstance}}),Object.defineProperty(n,"EOF",{enumerable:!0,get:function(){return r.EOF}}),Object.defineProperty(n,"tokenLabel",{enumerable:!0,get:function(){return r.tokenLabel}}),Object.defineProperty(n,"tokenMatcher",{enumerable:!0,get:function(){return r.tokenMatcher}}),Object.defineProperty(n,"tokenName",{enumerable:!0,get:function(){return r.tokenName}});var c=Tt();Object.defineProperty(n,"defaultParserErrorProvider",{enumerable:!0,get:function(){return c.defaultParserErrorProvider}});var o=ft();Object.defineProperty(n,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(n,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(n,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(n,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(n,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var u=vn();Object.defineProperty(n,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return u.defaultLexerErrorProvider}});var a=He();Object.defineProperty(n,"Alternation",{enumerable:!0,get:function(){return a.Alternation}}),Object.defineProperty(n,"Alternative",{enumerable:!0,get:function(){return a.Alternative}}),Object.defineProperty(n,"NonTerminal",{enumerable:!0,get:function(){return a.NonTerminal}}),Object.defineProperty(n,"Option",{enumerable:!0,get:function(){return a.Option}}),Object.defineProperty(n,"Repetition",{enumerable:!0,get:function(){return a.Repetition}}),Object.defineProperty(n,"RepetitionMandatory",{enumerable:!0,get:function(){return a.RepetitionMandatory}}),Object.defineProperty(n,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return a.RepetitionMandatoryWithSeparator}}),Object.defineProperty(n,"RepetitionWithSeparator",{enumerable:!0,get:function(){return a.RepetitionWithSeparator}}),Object.defineProperty(n,"Rule",{enumerable:!0,get:function(){return a.Rule}}),Object.defineProperty(n,"Terminal",{enumerable:!0,get:function(){return a.Terminal}});var s=He();Object.defineProperty(n,"serializeGrammar",{enumerable:!0,get:function(){return s.serializeGrammar}}),Object.defineProperty(n,"serializeProduction",{enumerable:!0,get:function(){return s.serializeProduction}});var f=ht();Object.defineProperty(n,"GAstVisitor",{enumerable:!0,get:function(){return f.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
|
|
217
217
|
It performs no action other than printing this message.
|
|
218
|
-
Please avoid using it as it will be completely removed in the future`)}n.clearCache=
|
|
219
|
-
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return T})();n.Parser=p});const st=fi();class di extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const a=this,o=a.path===""?R.LoaderUtils.extractUrlBase(e):a.path,l=new R.FileLoader(a.manager);l.setPath(a.path),l.setRequestHeader(a.requestHeader),l.setWithCredentials(a.withCredentials),l.load(e,function(c){try{t(a.parse(c,o))}catch(s){r?r(s):console.error(s),a.manager.itemError(e)}},i,r)}parse(e,t){const i={};function r(L){const _=a(),A=new pi(_.tokens),I=new yi(_.tokenVocabulary),S=o(I.getBaseCstVisitorConstructor()),N=A.lex(L);I.input=N.tokens;const D=I.vrml();if(I.errors.length>0)throw console.error(I.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return S.visit(D)}function a(){const L=st.createToken,_=L({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),A=L({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:_}),I=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],S=L({name:"Version",pattern:/#VRML.*/,longer_alt:A}),N=L({name:"NodeName",pattern:new RegExp(I.join("|")),longer_alt:A}),D=L({name:"DEF",pattern:/DEF/,longer_alt:A}),B=L({name:"USE",pattern:/USE/,longer_alt:A}),V=L({name:"ROUTE",pattern:/ROUTE/,longer_alt:A}),J=L({name:"TO",pattern:/TO/,longer_alt:A}),re=L({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),ye=L({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),Oe=L({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),Fe=L({name:"TrueLiteral",pattern:/TRUE/}),Ie=L({name:"FalseLiteral",pattern:/FALSE/}),Ee=L({name:"NullLiteral",pattern:/NULL/}),Re=L({name:"LSquare",pattern:/\[/}),Ne=L({name:"RSquare",pattern:/]/}),Pe=L({name:"LCurly",pattern:/{/}),be=L({name:"RCurly",pattern:/}/}),De=L({name:"Comment",pattern:/#.*/,group:st.Lexer.SKIPPED}),Ge=[L({name:"WhiteSpace",pattern:/[ ,\s]/,group:st.Lexer.SKIPPED}),N,D,B,V,J,Fe,Ie,Ee,S,A,_,re,ye,Oe,Re,Ne,Pe,be,De],je={};for(let Le=0,ue=Ge.length;Le<ue;Le++){const le=Ge[Le];je[le.name]=le}return{tokens:Ge,tokenVocabulary:je}}function o(L){class _ extends L{constructor(){super(),this.validateVisitor()}vrml(S){const N={version:this.visit(S.version),nodes:[],routes:[]};for(let D=0,B=S.node.length;D<B;D++){const V=S.node[D];N.nodes.push(this.visit(V))}if(S.route)for(let D=0,B=S.route.length;D<B;D++){const V=S.route[D];N.routes.push(this.visit(V))}return N}version(S){return S.Version[0].image}node(S){const N={name:S.NodeName[0].image,fields:[]};if(S.field)for(let D=0,B=S.field.length;D<B;D++){const V=S.field[D];N.fields.push(this.visit(V))}return S.def&&(N.DEF=this.visit(S.def[0])),N}field(S){const N={name:S.Identifier[0].image,type:null,values:null};let D;return S.singleFieldValue&&(D=this.visit(S.singleFieldValue[0])),S.multiFieldValue&&(D=this.visit(S.multiFieldValue[0])),N.type=D.type,N.values=D.values,N}def(S){return(S.Identifier||S.NodeName)[0].image}use(S){return{USE:(S.Identifier||S.NodeName)[0].image}}singleFieldValue(S){return A(this,S)}multiFieldValue(S){return A(this,S)}route(S){return{FROM:S.RouteIdentifier[0].image,TO:S.RouteIdentifier[1].image}}}function A(I,S){const N={type:null,values:[]};if(S.node){N.type="node";for(let D=0,B=S.node.length;D<B;D++){const V=S.node[D];N.values.push(I.visit(V))}}if(S.use){N.type="use";for(let D=0,B=S.use.length;D<B;D++){const V=S.use[D];N.values.push(I.visit(V))}}if(S.StringLiteral){N.type="string";for(let D=0,B=S.StringLiteral.length;D<B;D++){const V=S.StringLiteral[D];N.values.push(V.image.replace(/'|"/g,""))}}if(S.NumberLiteral){N.type="number";for(let D=0,B=S.NumberLiteral.length;D<B;D++){const V=S.NumberLiteral[D];N.values.push(parseFloat(V.image))}}if(S.HexLiteral){N.type="hex";for(let D=0,B=S.HexLiteral.length;D<B;D++){const V=S.HexLiteral[D];N.values.push(V.image)}}if(S.TrueLiteral){N.type="boolean";for(let D=0,B=S.TrueLiteral.length;D<B;D++)S.TrueLiteral[D].image==="TRUE"&&N.values.push(!0)}if(S.FalseLiteral){N.type="boolean";for(let D=0,B=S.FalseLiteral.length;D<B;D++)S.FalseLiteral[D].image==="FALSE"&&N.values.push(!1)}return S.NullLiteral&&(N.type="null",S.NullLiteral.forEach(function(){N.values.push(null)})),N}return new _}function l(L){const _=L.nodes,A=new R.Scene;for(let I=0,S=_.length;I<S;I++){const N=_[I];c(N)}for(let I=0,S=_.length;I<S;I++){const N=_[I],D=s(N);D instanceof R.Object3D&&A.add(D),N.name==="WorldInfo"&&(A.userData.worldInfo=D)}return A}function c(L){L.DEF&&(i[L.DEF]=L);const _=L.fields;for(let A=0,I=_.length;A<I;A++){const S=_[A];if(S.type==="node"){const N=S.values;for(let D=0,B=N.length;D<B;D++)c(N[D])}}}function s(L){return L.USE?Q(L.USE):(L.build!==void 0||(L.build=h(L)),L.build)}function h(L){const _=L.name;let A;switch(_){case"Anchor":case"Group":case"Transform":case"Collision":A=f(L);break;case"Background":A=g(L);break;case"Shape":A=p(L);break;case"Appearance":A=T(L);break;case"Material":A=m(L);break;case"ImageTexture":A=v(L);break;case"PixelTexture":A=y(L);break;case"TextureTransform":A=E(L);break;case"IndexedFaceSet":A=w(L);break;case"IndexedLineSet":A=Y(L);break;case"PointSet":A=x(L);break;case"Box":A=G(L);break;case"Cone":A=M(L);break;case"Cylinder":A=O(L);break;case"Sphere":A=C(L);break;case"ElevationGrid":A=k(L);break;case"Extrusion":A=X(L);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":A=b(L);break;case"WorldInfo":A=P(L);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",_);break}return A!==void 0&&L.DEF!==void 0&&A.hasOwnProperty("name")===!0&&(A.name=L.DEF),A}function f(L){const _=new R.Group,A=L.fields;for(let I=0,S=A.length;I<S;I++){const N=A[I],D=N.name,B=N.values;switch(D){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":H(B,_);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":const V=new R.Vector3(B[0],B[1],B[2]).normalize(),J=B[3];_.quaternion.setFromAxisAngle(V,J);break;case"scale":_.scale.set(B[0],B[1],B[2]);break;case"scaleOrientation":break;case"translation":_.position.set(B[0],B[1],B[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function g(L){const _=new R.Group;let A,I,S,N;const D=L.fields;for(let V=0,J=D.length;V<J;V++){const re=D[V],ye=re.name,Oe=re.values;switch(ye){case"groundAngle":A=Oe;break;case"groundColor":I=Oe;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":S=Oe;break;case"skyColor":N=Oe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",ye);break}}const B=1e4;if(N){const V=new R.SphereGeometry(B,32,16),J=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,depthWrite:!1,depthTest:!1});N.length>3?(j(V,B,S,F(N),!0),J.vertexColors=!0):J.color.setRGB(N[0],N[1],N[2],R.SRGBColorSpace);const re=new R.Mesh(V,J);_.add(re)}if(I&&I.length>0){const V=new R.SphereGeometry(B,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),J=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});j(V,B,A,F(I),!1);const re=new R.Mesh(V,J);_.add(re)}return _.renderOrder=-1/0,_}function p(L){const _=L.fields;let A=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0}),I;for(let N=0,D=_.length;N<D;N++){const B=_[N],V=B.name,J=B.values;switch(V){case"appearance":J[0]!==null&&(A=s(J[0]));break;case"geometry":J[0]!==null&&(I=s(J[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}let S;if(I&&I.attributes.position){const N=I._type;if(N==="points"){const D=new R.PointsMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:A.opacity,transparent:A.transparent});I.attributes.color!==void 0?D.vertexColors=!0:A.isMeshPhongMaterial&&D.color.copy(A.emissive),S=new R.Points(I,D)}else if(N==="line"){const D=new R.LineBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:A.opacity,transparent:A.transparent});I.attributes.color!==void 0?D.vertexColors=!0:A.isMeshPhongMaterial&&D.color.copy(A.emissive),S=new R.LineSegments(I,D)}else I._solid!==void 0&&(A.side=I._solid?R.FrontSide:R.DoubleSide),I.attributes.color!==void 0&&(A.vertexColors=!0),S=new R.Mesh(I,A)}else S=new R.Object3D,S.visible=!1;return S}function T(L){let _=new R.MeshPhongMaterial,A;const I=L.fields;for(let S=0,N=I.length;S<N;S++){const D=I[S],B=D.name,V=D.values;switch(B){case"material":if(V[0]!==null){const re=s(V[0]);re.diffuseColor&&_.color.copy(re.diffuseColor),re.emissiveColor&&_.emissive.copy(re.emissiveColor),re.shininess&&(_.shininess=re.shininess),re.specularColor&&_.specular.copy(re.specularColor),re.transparency&&(_.opacity=1-re.transparency),re.transparency>0&&(_.transparent=!0)}else _=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":const J=V[0];J!==null&&(J.name==="ImageTexture"||J.name==="PixelTexture")&&(_.map=s(J));break;case"textureTransform":V[0]!==null&&(A=s(V[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",B);break}}if(_.map){if(_.map.__type){switch(_.map.__type){case Xe.INTENSITY_ALPHA:_.opacity=1;break;case Xe.RGB:_.color.set(16777215);break;case Xe.RGBA:_.color.set(16777215),_.opacity=1;break}delete _.map.__type}A&&(_.map.center.copy(A.center),_.map.rotation=A.rotation,_.map.repeat.copy(A.scale),_.map.offset.copy(A.translation))}return _}function m(L){const _={},A=L.fields;for(let I=0,S=A.length;I<S;I++){const N=A[I],D=N.name,B=N.values;switch(D){case"ambientIntensity":break;case"diffuseColor":_.diffuseColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"emissiveColor":_.emissiveColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"shininess":_.shininess=B[0];break;case"specularColor":_.specularColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"transparency":_.transparency=B[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function u(L,_,A){let I;switch(_){case Xe.INTENSITY:I=parseInt(L),A.r=I,A.g=I,A.b=I,A.a=1;break;case Xe.INTENSITY_ALPHA:I=parseInt("0x"+L.substring(2,4)),A.r=I,A.g=I,A.b=I,A.a=parseInt("0x"+L.substring(4,6));break;case Xe.RGB:A.r=parseInt("0x"+L.substring(2,4)),A.g=parseInt("0x"+L.substring(4,6)),A.b=parseInt("0x"+L.substring(6,8)),A.a=1;break;case Xe.RGBA:A.r=parseInt("0x"+L.substring(2,4)),A.g=parseInt("0x"+L.substring(4,6)),A.b=parseInt("0x"+L.substring(6,8)),A.a=parseInt("0x"+L.substring(8,10));break}}function d(L){let _;switch(L){case 1:_=Xe.INTENSITY;break;case 2:_=Xe.INTENSITY_ALPHA;break;case 3:_=Xe.RGB;break;case 4:_=Xe.RGBA;break}return _}function y(L){let _,A=R.RepeatWrapping,I=R.RepeatWrapping;const S=L.fields;for(let N=0,D=S.length;N<D;N++){const B=S[N],V=B.name,J=B.values;switch(V){case"image":const re=J[0],ye=J[1],Oe=J[2],Fe=d(Oe),Ie=new Uint8Array(4*re*ye),Ee={r:0,g:0,b:0,a:0};for(let Re=3,Ne=0,Pe=J.length;Re<Pe;Re++,Ne++){u(J[Re],Fe,Ee);const be=Ne*4;Ie[be+0]=Ee.r,Ie[be+1]=Ee.g,Ie[be+2]=Ee.b,Ie[be+3]=Ee.a}_=new R.DataTexture(Ie,re,ye),_.colorSpace=R.SRGBColorSpace,_.needsUpdate=!0,_.__type=Fe;break;case"repeatS":J[0]===!1&&(A=R.ClampToEdgeWrapping);break;case"repeatT":J[0]===!1&&(I=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return _&&(_.wrapS=A,_.wrapT=I),_}function v(L){let _,A=R.RepeatWrapping,I=R.RepeatWrapping;const S=L.fields;for(let N=0,D=S.length;N<D;N++){const B=S[N],V=B.name,J=B.values;switch(V){case"url":const re=J[0];re&&(_=ee.load(re));break;case"repeatS":J[0]===!1&&(A=R.ClampToEdgeWrapping);break;case"repeatT":J[0]===!1&&(I=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return _&&(_.wrapS=A,_.wrapT=I,_.colorSpace=R.SRGBColorSpace),_}function E(L){const _={center:new R.Vector2,rotation:new R.Vector2,scale:new R.Vector2,translation:new R.Vector2},A=L.fields;for(let I=0,S=A.length;I<S;I++){const N=A[I],D=N.name,B=N.values;switch(D){case"center":_.center.set(B[0],B[1]);break;case"rotation":_.rotation=B[0];break;case"scale":_.scale.set(B[0],B[1]);break;case"translation":_.translation.set(B[0],B[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function b(L){return L.fields[0].values}function P(L){const _={},A=L.fields;for(let I=0,S=A.length;I<S;I++){const N=A[I],D=N.name,B=N.values;switch(D){case"title":_.title=B[0];break;case"info":_.info=B;break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function w(L){let _,A,I,S,N=!0,D=!0,B=0,V,J,re,ye,Oe=!0,Fe=!0;const Ie=L.fields;for(let Ce=0,Ge=Ie.length;Ce<Ge;Ce++){const je=Ie[Ce],Le=je.name,ue=je.values;switch(Le){case"color":const le=ue[0];le!==null&&(_=s(le));break;case"coord":const oe=ue[0];oe!==null&&(A=s(oe));break;case"normal":const he=ue[0];he!==null&&(I=s(he));break;case"texCoord":const pe=ue[0];pe!==null&&(S=s(pe));break;case"ccw":N=ue[0];break;case"colorIndex":V=ue;break;case"colorPerVertex":Oe=ue[0];break;case"convex":break;case"coordIndex":J=ue;break;case"creaseAngle":B=ue[0];break;case"normalIndex":re=ue;break;case"normalPerVertex":Fe=ue[0];break;case"solid":D=ue[0];break;case"texCoordIndex":ye=ue;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Le);break}}if(J===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new R.BufferGeometry;const Ee=$(J,N);let Re,Ne,Pe;if(_){if(Oe===!0)if(V&&V.length>0){const Ce=$(V,N);Re=Z(Ee,Ce,_,3)}else Re=me(Ee,new R.Float32BufferAttribute(_,3));else if(V&&V.length>0){const Ce=ae(_,V),Ge=te(Ce,J);Re=ie(Ee,Ge)}else{const Ce=te(_,J);Re=ie(Ee,Ce)}K(Re)}if(I)if(Fe===!0)if(re&&re.length>0){const Ce=$(re,N);Ne=Z(Ee,Ce,I,3)}else Ne=me(Ee,new R.Float32BufferAttribute(I,3));else if(re&&re.length>0){const Ce=ae(I,re),Ge=te(Ce,J);Ne=ie(Ee,Ge)}else{const Ce=te(I,J);Ne=ie(Ee,Ce)}else Ne=We(Ee,A,B);if(S)if(ye&&ye.length>0){const Ce=$(ye,N);Pe=Z(Ee,Ce,S,2)}else Pe=me(Ee,new R.Float32BufferAttribute(S,2));const be=new R.BufferGeometry,De=me(Ee,new R.Float32BufferAttribute(A,3));return be.setAttribute("position",De),be.setAttribute("normal",Ne),Re&&be.setAttribute("color",Re),Pe&&be.setAttribute("uv",Pe),be._solid=D,be._type="mesh",be}function Y(L){let _,A,I,S,N=!0;const D=L.fields;for(let ye=0,Oe=D.length;ye<Oe;ye++){const Fe=D[ye],Ie=Fe.name,Ee=Fe.values;switch(Ie){case"color":const Re=Ee[0];Re!==null&&(_=s(Re));break;case"coord":const Ne=Ee[0];Ne!==null&&(A=s(Ne));break;case"colorIndex":I=Ee;break;case"colorPerVertex":N=Ee[0];break;case"coordIndex":S=Ee;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ie);break}}let B;const V=se(S);if(_){if(N===!0)if(I.length>0){const ye=se(I);B=Z(V,ye,_,3)}else B=me(V,new R.Float32BufferAttribute(_,3));else if(I.length>0){const ye=ae(_,I),Oe=ce(ye,S);B=Te(V,Oe)}else{const ye=ce(_,S);B=Te(V,ye)}K(B)}const J=new R.BufferGeometry,re=me(V,new R.Float32BufferAttribute(A,3));return J.setAttribute("position",re),B&&J.setAttribute("color",B),J._type="line",J}function x(L){let _,A;const I=L.fields;for(let N=0,D=I.length;N<D;N++){const B=I[N],V=B.name,J=B.values;switch(V){case"color":const re=J[0];re!==null&&(_=s(re));break;case"coord":const ye=J[0];ye!==null&&(A=s(ye));break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}const S=new R.BufferGeometry;if(S.setAttribute("position",new R.Float32BufferAttribute(A,3)),_){const N=new R.Float32BufferAttribute(_,3);K(N),S.setAttribute("color",N)}return S._type="points",S}function G(L){const _=new R.Vector3(2,2,2),A=L.fields;for(let S=0,N=A.length;S<N;S++){const D=A[S],B=D.name,V=D.values;B==="size"?(_.x=V[0],_.y=V[1],_.z=V[2]):console.warn("THREE.VRMLLoader: Unknown field:",B)}return new R.BoxGeometry(_.x,_.y,_.z)}function M(L){let _=1,A=2,I=!1;const S=L.fields;for(let D=0,B=S.length;D<B;D++){const V=S[D],J=V.name,re=V.values;switch(J){case"bottom":I=!re[0];break;case"bottomRadius":_=re[0];break;case"height":A=re[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",J);break}}return new R.ConeGeometry(_,A,16,1,I)}function O(L){let _=1,A=2;const I=L.fields;for(let N=0,D=I.length;N<D;N++){const B=I[N],V=B.name,J=B.values;switch(V){case"bottom":break;case"radius":_=J[0];break;case"height":A=J[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return new R.CylinderGeometry(_,_,A,16,1)}function C(L){let _=1;const A=L.fields;for(let S=0,N=A.length;S<N;S++){const D=A[S],B=D.name,V=D.values;B==="radius"?_=V[0]:console.warn("THREE.VRMLLoader: Unknown field:",B)}return new R.SphereGeometry(_,16,16)}function k(L){let _,A,I,S,N=!0,D=!0,B=!0,V=!0,J=0,re=2,ye=2,Oe=1,Fe=1;const Ie=L.fields;for(let ue=0,le=Ie.length;ue<le;ue++){const oe=Ie[ue],he=oe.name,pe=oe.values;switch(he){case"color":const Me=pe[0];Me!==null&&(_=s(Me));break;case"normal":const Qe=pe[0];Qe!==null&&(A=s(Qe));break;case"texCoord":const Ze=pe[0];Ze!==null&&(I=s(Ze));break;case"height":S=pe;break;case"ccw":V=pe[0];break;case"colorPerVertex":N=pe[0];break;case"creaseAngle":J=pe[0];break;case"normalPerVertex":D=pe[0];break;case"solid":B=pe[0];break;case"xDimension":re=pe[0];break;case"xSpacing":Oe=pe[0];break;case"zDimension":ye=pe[0];break;case"zSpacing":Fe=pe[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}const Ee=[],Re=[],Ne=[],Pe=[];for(let ue=0;ue<ye;ue++)for(let le=0;le<re;le++){const oe=ue*re+le,he=Oe*ue,pe=S[oe],Me=Fe*le;if(Ee.push(he,pe,Me),_&&N===!0){const Qe=_[oe*3+0],Ze=_[oe*3+1],Et=_[oe*3+2];Ne.push(Qe,Ze,Et)}if(A&&D===!0){const Qe=A[oe*3+0],Ze=A[oe*3+1],Et=A[oe*3+2];Re.push(Qe,Ze,Et)}if(I){const Qe=I[oe*2+0],Ze=I[oe*2+1];Pe.push(Qe,Ze)}else Pe.push(ue/(re-1),le/(ye-1))}const be=[];for(let ue=0;ue<re-1;ue++)for(let le=0;le<ye-1;le++){const oe=ue+le*re,he=ue+(le+1)*re,pe=ue+1+(le+1)*re,Me=ue+1+le*re;V===!0?(be.push(oe,pe,he),be.push(pe,oe,Me)):(be.push(oe,he,pe),be.push(pe,Me,oe))}const De=me(be,new R.Float32BufferAttribute(Ee,3)),Ce=me(be,new R.Float32BufferAttribute(Pe,2));let Ge,je;if(_){if(N===!1){for(let ue=0;ue<re-1;ue++)for(let le=0;le<ye-1;le++){const oe=ue+le*(re-1),he=_[oe*3+0],pe=_[oe*3+1],Me=_[oe*3+2];Ne.push(he,pe,Me),Ne.push(he,pe,Me),Ne.push(he,pe,Me),Ne.push(he,pe,Me),Ne.push(he,pe,Me),Ne.push(he,pe,Me)}Ge=new R.Float32BufferAttribute(Ne,3)}else Ge=me(be,new R.Float32BufferAttribute(Ne,3));K(Ge)}if(A)if(D===!1){for(let ue=0;ue<re-1;ue++)for(let le=0;le<ye-1;le++){const oe=ue+le*(re-1),he=A[oe*3+0],pe=A[oe*3+1],Me=A[oe*3+2];Re.push(he,pe,Me),Re.push(he,pe,Me),Re.push(he,pe,Me),Re.push(he,pe,Me),Re.push(he,pe,Me),Re.push(he,pe,Me)}je=new R.Float32BufferAttribute(Re,3)}else je=me(be,new R.Float32BufferAttribute(Re,3));else je=We(be,Ee,J);const Le=new R.BufferGeometry;return Le.setAttribute("position",De),Le.setAttribute("normal",je),Le.setAttribute("uv",Ce),Ge&&Le.setAttribute("color",Ge),Le._solid=B,Le._type="mesh",Le}function X(L){let _=[1,1,1,-1,-1,-1,-1,1,1,1],A=[0,0,0,0,1,0],I,S,N=!0,D=!0,B=0,V=!0,J=!0;const re=L.fields;for(let Le=0,ue=re.length;Le<ue;Le++){const le=re[Le],oe=le.name,he=le.values;switch(oe){case"beginCap":N=he[0];break;case"ccw":D=he[0];break;case"convex":break;case"creaseAngle":B=he[0];break;case"crossSection":_=he;break;case"endCap":V=he[0];break;case"orientation":S=he;break;case"scale":I=he;break;case"solid":J=he[0];break;case"spine":A=he;break;default:console.warn("THREE.VRMLLoader: Unknown field:",oe);break}}const ye=_[0]===_[_.length-2]&&_[1]===_[_.length-1],Oe=[],Fe=new R.Vector3,Ie=new R.Vector3,Ee=new R.Vector3,Re=new R.Vector3,Ne=new R.Quaternion;for(let Le=0,ue=0,le=0,oe=A.length;Le<oe;Le+=3,ue+=2,le+=4){Fe.fromArray(A,Le),Ie.x=I?I[ue+0]:1,Ie.y=1,Ie.z=I?I[ue+1]:1,Ee.x=S?S[le+0]:0,Ee.y=S?S[le+1]:0,Ee.z=S?S[le+2]:1;const he=S?S[le+3]:0;for(let pe=0,Me=_.length;pe<Me;pe+=2)Re.x=_[pe+0],Re.y=0,Re.z=_[pe+1],Re.multiply(Ie),Ne.setFromAxisAngle(Ee,he),Re.applyQuaternion(Ne),Re.add(Fe),Oe.push(Re.x,Re.y,Re.z)}const Pe=[],be=A.length/3,De=_.length/2;for(let Le=0;Le<be-1;Le++)for(let ue=0;ue<De-1;ue++){const le=ue+Le*De;let oe=ue+1+Le*De;const he=ue+(Le+1)*De;let pe=ue+1+(Le+1)*De;ue===De-2&&ye===!0&&(oe=Le*De,pe=(Le+1)*De),D===!0?(Pe.push(le,oe,he),Pe.push(he,oe,pe)):(Pe.push(le,he,oe),Pe.push(he,pe,oe))}if(N===!0||V===!0){const Le=[];for(let oe=0,he=_.length;oe<he;oe+=2)Le.push(new R.Vector2(_[oe],_[oe+1]));const ue=R.ShapeUtils.triangulateShape(Le,[]),le=[];for(let oe=0,he=ue.length;oe<he;oe++){const pe=ue[oe];le.push(pe[0],pe[1],pe[2])}if(N===!0)for(let oe=0,he=le.length;oe<he;oe+=3)D===!0?Pe.push(le[oe+0],le[oe+1],le[oe+2]):Pe.push(le[oe+0],le[oe+2],le[oe+1]);if(V===!0){const oe=De*(be-1);for(let he=0,pe=le.length;he<pe;he+=3)D===!0?Pe.push(oe+le[he+0],oe+le[he+2],oe+le[he+1]):Pe.push(oe+le[he+0],oe+le[he+1],oe+le[he+2])}}const Ce=me(Pe,new R.Float32BufferAttribute(Oe,3)),Ge=We(Pe,Oe,B),je=new R.BufferGeometry;return je.setAttribute("position",Ce),je.setAttribute("normal",Ge),je._solid=J,je._type="mesh",je}function Q(L){const _=i[L],A=s(_);return A.isObject3D||A.isMaterial?A.clone():A}function H(L,_){for(let A=0,I=L.length;A<I;A++){const S=s(L[A]);S instanceof R.Object3D&&_.add(S)}}function $(L,_){const A=[];let I=0;for(let S=0,N=L.length;S<N;S++){const D=L[I],B=L[S+(_?1:2)],V=L[S+(_?2:1)];A.push(D,B,V),(L[S+3]===-1||S+3>=N)&&(S+=3,I=S+1)}return A}function te(L,_){const A=[];let I=0;for(let S=0,N=_.length;S<N;S++){const D=I*3,B=L[D],V=L[D+1],J=L[D+2];A.push(B,V,J),(_[S+3]===-1||S+3>=N)&&(S+=3,I++)}return A}function ae(L,_){const A=[];for(let I=0,S=_.length;I<S;I++){const D=_[I]*3,B=L[D],V=L[D+1],J=L[D+2];A.push(B,V,J)}return A}function se(L){const _=[];for(let A=0,I=L.length;A<I;A++){const S=L[A],N=L[A+1];_.push(S,N),(L[A+2]===-1||A+2>=I)&&(A+=2)}return _}function ce(L,_){const A=[];let I=0;for(let S=0,N=_.length;S<N;S++){const D=I*3,B=L[D],V=L[D+1],J=L[D+2];A.push(B,V,J),(_[S+2]===-1||S+2>=N)&&(S+=2,I++)}return A}const ne=new R.Vector3,de=new R.Vector3,U=new R.Vector3,z=new R.Vector2,W=new R.Vector2,q=new R.Vector2;function Z(L,_,A,I){const S=[];for(let N=0,D=L.length;N<D;N+=3){const B=_[N],V=_[N+1],J=_[N+2];I===2?(z.fromArray(A,B*I),W.fromArray(A,V*I),q.fromArray(A,J*I),S.push(z.x,z.y),S.push(W.x,W.y),S.push(q.x,q.y)):(ne.fromArray(A,B*I),de.fromArray(A,V*I),U.fromArray(A,J*I),S.push(ne.x,ne.y,ne.z),S.push(de.x,de.y,de.z),S.push(U.x,U.y,U.z))}return new R.Float32BufferAttribute(S,I)}function ie(L,_){const A=[];for(let I=0,S=0,N=L.length;I<N;I+=3,S++)ne.fromArray(_,S*3),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(A,3)}function Te(L,_){const A=[];for(let I=0,S=0,N=L.length;I<N;I+=2,S++)ne.fromArray(_,S*3),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(A,3)}function me(L,_){const A=_.array,I=_.itemSize,S=new A.constructor(L.length*I);let N=0,D=0;for(let B=0,V=L.length;B<V;B++){N=L[B]*I;for(let J=0;J<I;J++)S[D++]=A[N++]}return new R.Float32BufferAttribute(S,I)}const we=new R.Vector3,Be=new R.Vector3;function We(L,_,A){const I=[],S={};for(let D=0,B=L.length;D<B;D+=3){const V=L[D],J=L[D+1],re=L[D+2],ye=new gi(V,J,re);ne.fromArray(_,V*3),de.fromArray(_,J*3),U.fromArray(_,re*3),Be.subVectors(U,de),we.subVectors(ne,de),Be.cross(we),Be.normalize(),ye.normal.copy(Be),S[V]===void 0&&(S[V]=[]),S[J]===void 0&&(S[J]=[]),S[re]===void 0&&(S[re]=[]),S[V].push(ye.normal),S[J].push(ye.normal),S[re].push(ye.normal),I.push(ye)}const N=[];for(let D=0,B=I.length;D<B;D++){const V=I[D],J=Ue(S[V.a],V.normal,A),re=Ue(S[V.b],V.normal,A),ye=Ue(S[V.c],V.normal,A);ne.fromArray(_,V.a*3),de.fromArray(_,V.b*3),U.fromArray(_,V.c*3),N.push(J.x,J.y,J.z),N.push(re.x,re.y,re.z),N.push(ye.x,ye.y,ye.z)}return new R.Float32BufferAttribute(N,3)}function Ue(L,_,A){const I=new R.Vector3;if(A===0)I.copy(_);else for(let S=0,N=L.length;S<N;S++)L[S].angleTo(_)<A&&I.add(L[S]);return I.normalize()}function F(L){const _=[];for(let A=0,I=L.length;A<I;A+=3)_.push(new R.Color(L[A],L[A+1],L[A+2]));return _}function K(L){const _=new R.Color;for(let A=0;A<L.count;A++)_.fromBufferAttribute(L,A),R.ColorManagement.colorSpaceToWorking(_,R.SRGBColorSpace),L.setXYZ(A,_.r,_.g,_.b)}function j(L,_,A,I,S){const N=[],D=S===!0?0:Math.PI;for(let Oe=0,Fe=I.length;Oe<Fe;Oe++){let Ie=Oe===0?0:A[Oe-1];Ie=S===!0?Ie:D-Ie;const Ee=new R.Vector3;Ee.setFromSphericalCoords(_,Ie,0),N.push(Ee)}const B=L.index,V=L.attributes.position,J=new R.BufferAttribute(new Float32Array(L.attributes.position.count*3),3),re=new R.Vector3,ye=new R.Color;for(let Oe=0;Oe<B.count;Oe++){const Fe=B.getX(Oe);re.fromBufferAttribute(V,Fe);let Ie,Ee,Re=1;for(let be=1;be<N.length;be++){Ie=be-1,Ee=be;const De=N[Ie],Ce=N[Ee];if(S===!0){if(re.y<=De.y&&re.y>Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}else if(re.y>=De.y&&re.y<Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}const Ne=I[Ie],Pe=I[Ee];ye.copy(Ne).lerp(Pe,Re),R.ColorManagement.colorSpaceToWorking(ye,R.SRGBColorSpace),J.setXYZ(Fe,ye.r,ye.g,ye.b)}L.setAttribute("color",J)}const ee=new R.TextureLoader(this.manager);if(ee.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const fe=r(e);return l(fe)}}class pi{constructor(e){this.lexer=new st.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}const mi=st.CstParser;class yi extends mi{constructor(e){super(e);const t=this,i=e.Version,r=e.LCurly,a=e.RCurly,o=e.LSquare,l=e.RSquare,c=e.Identifier,s=e.RouteIdentifier,h=e.StringLiteral,f=e.HexLiteral,g=e.NumberLiteral,p=e.TrueLiteral,T=e.FalseLiteral,m=e.NullLiteral,u=e.DEF,d=e.USE,y=e.ROUTE,v=e.TO,E=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(i)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(E),t.CONSUME(r),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(a)}),t.RULE("field",function(){t.CONSUME(c),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(u),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("use",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(T)}},{ALT:function(){t.CONSUME(m)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(m)}}])}),t.CONSUME(l)}),t.RULE("route",function(){t.CONSUME(y),t.CONSUME(s),t.CONSUME(v),t.CONSUME2(s)}),this.performSelfAnalysis()}}class gi{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.normal=new R.Vector3}}const Xe={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};class Ti extends R.Loader{constructor(e){super(e),this.animateBonePositions=!0,this.animateBoneRotations=!0}load(e,t,i,r){const a=this,o=new R.FileLoader(a.manager);o.setPath(a.path),o.setRequestHeader(a.requestHeader),o.setWithCredentials(a.withCredentials),o.load(e,function(l){try{t(a.parse(l))}catch(c){r?r(c):console.error(c),a.manager.itemError(e)}},i,r)}parse(e){function t(p){l(p)!=="HIERARCHY"&&console.error("THREE.BVHLoader: HIERARCHY expected.");const T=[],m=r(p,l(p),T);l(p)!=="MOTION"&&console.error("THREE.BVHLoader: MOTION expected.");let u=l(p).split(/[\s]+/);const d=parseInt(u[1]);isNaN(d)&&console.error("THREE.BVHLoader: Failed to read number of frames."),u=l(p).split(/[\s]+/);const y=parseFloat(u[2]);isNaN(y)&&console.error("THREE.BVHLoader: Failed to read frame time.");for(let v=0;v<d;v++)u=l(p).split(/[\s]+/),i(u,v*y,m);return T}function i(p,T,m){if(m.type==="ENDSITE")return;const u={time:T,position:new R.Vector3,rotation:new R.Quaternion};m.frames.push(u);const d=new R.Quaternion,y=new R.Vector3(1,0,0),v=new R.Vector3(0,1,0),E=new R.Vector3(0,0,1);for(let b=0;b<m.channels.length;b++)switch(m.channels[b]){case"Xposition":u.position.x=parseFloat(p.shift().trim());break;case"Yposition":u.position.y=parseFloat(p.shift().trim());break;case"Zposition":u.position.z=parseFloat(p.shift().trim());break;case"Xrotation":d.setFromAxisAngle(y,parseFloat(p.shift().trim())*Math.PI/180),u.rotation.multiply(d);break;case"Yrotation":d.setFromAxisAngle(v,parseFloat(p.shift().trim())*Math.PI/180),u.rotation.multiply(d);break;case"Zrotation":d.setFromAxisAngle(E,parseFloat(p.shift().trim())*Math.PI/180),u.rotation.multiply(d);break;default:console.warn("THREE.BVHLoader: Invalid channel type.")}for(let b=0;b<m.children.length;b++)i(p,T,m.children[b])}function r(p,T,m){const u={name:"",type:"",frames:[]};m.push(u);let d=T.split(/[\s]+/);d[0].toUpperCase()==="END"&&d[1].toUpperCase()==="SITE"?(u.type="ENDSITE",u.name="ENDSITE"):(u.name=d[1],u.type=d[0].toUpperCase()),l(p)!=="{"&&console.error("THREE.BVHLoader: Expected opening { after type & name"),d=l(p).split(/[\s]+/),d[0]!=="OFFSET"&&console.error("THREE.BVHLoader: Expected OFFSET but got: "+d[0]),d.length!==4&&console.error("THREE.BVHLoader: Invalid number of values for OFFSET.");const y=new R.Vector3(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]));if((isNaN(y.x)||isNaN(y.y)||isNaN(y.z))&&console.error("THREE.BVHLoader: Invalid values of OFFSET."),u.offset=y,u.type!=="ENDSITE"){d=l(p).split(/[\s]+/),d[0]!=="CHANNELS"&&console.error("THREE.BVHLoader: Expected CHANNELS definition.");const v=parseInt(d[1]);u.channels=d.splice(2,v),u.children=[]}for(;;){const v=l(p);if(v==="}")return u;u.children.push(r(p,v,m))}}function a(p,T){const m=new R.Bone;if(T.push(m),m.position.add(p.offset),m.name=p.name,p.type!=="ENDSITE")for(let u=0;u<p.children.length;u++)m.add(a(p.children[u],T));return m}function o(p){const T=[];for(let m=0;m<p.length;m++){const u=p[m];if(u.type==="ENDSITE")continue;const d=[],y=[],v=[];for(let E=0;E<u.frames.length;E++){const b=u.frames[E];d.push(b.time),y.push(b.position.x+u.offset.x),y.push(b.position.y+u.offset.y),y.push(b.position.z+u.offset.z),v.push(b.rotation.x),v.push(b.rotation.y),v.push(b.rotation.z),v.push(b.rotation.w)}c.animateBonePositions&&T.push(new R.VectorKeyframeTrack(u.name+".position",d,y)),c.animateBoneRotations&&T.push(new R.QuaternionKeyframeTrack(u.name+".quaternion",d,v))}return new R.AnimationClip("animation",-1,T)}function l(p){let T;for(;(T=p.shift().trim()).length===0;);return T}const c=this,s=e.split(/[\r\n]+/g),h=t(s),f=[];a(h[0],f);const g=o(h);return{skeleton:new R.Skeleton(f),clip:g}}}let ht;async function Ei(n,e){return ht||(ht=new di),ht.manager.setURLModifier(i=>(i.startsWith("./")&&(i=i.substring(2)),URL.createObjectURL(Xn(n,i)))),await ht.loadAsync(e)}let Lt;async function vi(n,e){Lt||(Lt=new Ti);const t=It(n,e);return await Lt.parse(t)}class Ri extends ze{ready;actions;currentAction=null;comment=null;bvhs={};vrmls={};constructor(e){super(),this.ready=this.asyncInit(e),this.actions={}}initObject(){return new ge.Object3D}async asyncInit(e){const t=await tn(e),i=new DOMParser,r=It(t,"CATALOG.XML"),a=i.parseFromString(r,"application/xml");if(a.querySelector("parsererror"))return console.error("Acerola3D.asyncInit(): CATALOG.XML parse error."),this;const o="http://acerola3d.sourceforge.jp/a3/catalog",l=a.getElementsByTagNameNS(o,"c");l[0]&&(this.comment=l[0].textContent);const c=a.getElementsByTagNameNS(o,"a"),s=[];Array.from(c).forEach(h=>{const f=h.getAttribute("an"),g=h.getAttribute("bvh"),p=h.getAttribute("scale"),T=h.getAttribute("offset");if(f){const m={bvh:null,mixer:null,clipAction:null,parts:{},root:null,scale:1,offset:new Se};if(this.actions[f]=m,g)if(this.bvhs[g])m.bvh=this.bvhs[g];else{const d=vi(t,g);s.push(d),d.then(y=>{m.bvh=y})}if(m.scale=p?Number(p):1,T){const d=T.split(" ");m.offset.set(Number(d[0]),Number(d[1]),Number(d[2]))}const u=h.getElementsByTagNameNS(o,"p");Array.from(u).forEach(d=>{const y=d.getAttribute("name"),v=d.getAttribute("wrl");if(y&&v)if(this.vrmls[v])m.parts[y]={wrl:this.vrmls[v]};else{const E=Ei(t,v);s.push(E),E.then(b=>{m.parts[y]={wrl:b}})}})}}),await Promise.all(s);for(const h of Object.values(this.actions))h.bvh&&(h.root=h.bvh.skeleton.bones[0],h.root.scale.set(h.scale,h.scale,h.scale),h.root.position.set(h.offset.x,h.offset.y,h.offset.z),vn(h.root,h.parts),h.mixer=new ge.AnimationMixer(h.root),h.clipAction=h.mixer.clipAction(h.bvh.clip));for(const h of Object.values(this.actions))if(h.root){this.object.add(h.root),h.clipAction?.play(),this.currentAction=h;break}return this}action(e){const t=this.actions[e];t&&(this.currentAction?.clipAction?.stop(),this.currentAction?.root&&this.object.remove(this.currentAction?.root),this.currentAction=t,this.currentAction?.root&&this.object.add(this.currentAction.root),this.currentAction?.clipAction?.play())}update(e){super.update(e),this.currentAction?.mixer&&this.currentAction?.mixer.update(e)}}function vn(n,e){if(Mn(n)){const t=e[n.name];t&&n.add(t.wrl)}n.children&&n.children.forEach(t=>{vn(t,e)})}class _i extends ze{constructor(e){super(e)}initObject(e){return e}}class Ai extends ze{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new ge.BoxGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new ge.MeshStandardMaterial({color:a});return new ge.Mesh(r,o)}}class Li extends ze{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new ge.SphereGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new ge.MeshStandardMaterial({color:a});return new ge.Mesh(r,o)}}exports.Acerola3D=Ri;exports.Box=Ai;exports.Camera=Jt;exports.Canvas=on;exports.ControllerBase=$t;exports.GLTFA3=Xr;exports.GeneralCamera=at;exports.ObjectA3=ze;exports.OrbitController=en;exports.Quat=ke;exports.RapierPhysicsEngine=tt;exports.Scene=Qt;exports.Sound=$e;exports.Sphere=Li;exports.Test=nr;exports.Text3D=ur;exports.ThreeJS=_i;exports.Vec3=Se;exports.ViewBase=Nt;exports.Window=sn;exports.asyncSleep=Yn;exports.getQuatOfLookAt=ft;exports.initFont=cr;exports.initPhysics=Vn;exports.initSound=Jn;exports.times2=Kn;exports.vec3EulerToQuat=Zt;
|
|
218
|
+
Please avoid using it as it will be completely removed in the future`)}n.clearCache=h;var T=yi();Object.defineProperty(n,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return T.createSyntaxDiagramsCode}});var p=(function(){function g(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
|
|
219
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return g})();n.Parser=p});const ot=gi();class Ti extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const c=this,o=c.path===""?R.LoaderUtils.extractUrlBase(e):c.path,u=new R.FileLoader(c.manager);u.setPath(c.path),u.setRequestHeader(c.requestHeader),u.setWithCredentials(c.withCredentials),u.load(e,function(a){try{t(c.parse(a,o))}catch(s){r?r(s):console.error(s),c.manager.itemError(e)}},i,r)}parse(e,t){const i={};function r(b){const _=c(),A=new Ei(_.tokens),I=new Ri(_.tokenVocabulary),L=o(I.getBaseCstVisitorConstructor()),w=A.lex(b);I.input=w.tokens;const D=I.vrml();if(I.errors.length>0)throw console.error(I.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return L.visit(D)}function c(){const b=ot.createToken,_=b({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),A=b({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:_}),I=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],L=b({name:"Version",pattern:/#VRML.*/,longer_alt:A}),w=b({name:"NodeName",pattern:new RegExp(I.join("|")),longer_alt:A}),D=b({name:"DEF",pattern:/DEF/,longer_alt:A}),B=b({name:"USE",pattern:/USE/,longer_alt:A}),V=b({name:"ROUTE",pattern:/ROUTE/,longer_alt:A}),J=b({name:"TO",pattern:/TO/,longer_alt:A}),re=b({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),ge=b({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),xe=b({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),Fe=b({name:"TrueLiteral",pattern:/TRUE/}),Ie=b({name:"FalseLiteral",pattern:/FALSE/}),Ee=b({name:"NullLiteral",pattern:/NULL/}),Re=b({name:"LSquare",pattern:/\[/}),Ne=b({name:"RSquare",pattern:/]/}),Pe=b({name:"LCurly",pattern:/{/}),Se=b({name:"RCurly",pattern:/}/}),De=b({name:"Comment",pattern:/#.*/,group:ot.Lexer.SKIPPED}),Ge=[b({name:"WhiteSpace",pattern:/[ ,\s]/,group:ot.Lexer.SKIPPED}),w,D,B,V,J,Fe,Ie,Ee,L,A,_,re,ge,xe,Re,Ne,Pe,Se,De],ze={};for(let Le=0,le=Ge.length;Le<le;Le++){const ue=Ge[Le];ze[ue.name]=ue}return{tokens:Ge,tokenVocabulary:ze}}function o(b){class _ extends b{constructor(){super(),this.validateVisitor()}vrml(L){const w={version:this.visit(L.version),nodes:[],routes:[]};for(let D=0,B=L.node.length;D<B;D++){const V=L.node[D];w.nodes.push(this.visit(V))}if(L.route)for(let D=0,B=L.route.length;D<B;D++){const V=L.route[D];w.routes.push(this.visit(V))}return w}version(L){return L.Version[0].image}node(L){const w={name:L.NodeName[0].image,fields:[]};if(L.field)for(let D=0,B=L.field.length;D<B;D++){const V=L.field[D];w.fields.push(this.visit(V))}return L.def&&(w.DEF=this.visit(L.def[0])),w}field(L){const w={name:L.Identifier[0].image,type:null,values:null};let D;return L.singleFieldValue&&(D=this.visit(L.singleFieldValue[0])),L.multiFieldValue&&(D=this.visit(L.multiFieldValue[0])),w.type=D.type,w.values=D.values,w}def(L){return(L.Identifier||L.NodeName)[0].image}use(L){return{USE:(L.Identifier||L.NodeName)[0].image}}singleFieldValue(L){return A(this,L)}multiFieldValue(L){return A(this,L)}route(L){return{FROM:L.RouteIdentifier[0].image,TO:L.RouteIdentifier[1].image}}}function A(I,L){const w={type:null,values:[]};if(L.node){w.type="node";for(let D=0,B=L.node.length;D<B;D++){const V=L.node[D];w.values.push(I.visit(V))}}if(L.use){w.type="use";for(let D=0,B=L.use.length;D<B;D++){const V=L.use[D];w.values.push(I.visit(V))}}if(L.StringLiteral){w.type="string";for(let D=0,B=L.StringLiteral.length;D<B;D++){const V=L.StringLiteral[D];w.values.push(V.image.replace(/'|"/g,""))}}if(L.NumberLiteral){w.type="number";for(let D=0,B=L.NumberLiteral.length;D<B;D++){const V=L.NumberLiteral[D];w.values.push(parseFloat(V.image))}}if(L.HexLiteral){w.type="hex";for(let D=0,B=L.HexLiteral.length;D<B;D++){const V=L.HexLiteral[D];w.values.push(V.image)}}if(L.TrueLiteral){w.type="boolean";for(let D=0,B=L.TrueLiteral.length;D<B;D++)L.TrueLiteral[D].image==="TRUE"&&w.values.push(!0)}if(L.FalseLiteral){w.type="boolean";for(let D=0,B=L.FalseLiteral.length;D<B;D++)L.FalseLiteral[D].image==="FALSE"&&w.values.push(!1)}return L.NullLiteral&&(w.type="null",L.NullLiteral.forEach(function(){w.values.push(null)})),w}return new _}function u(b){const _=b.nodes,A=new R.Scene;for(let I=0,L=_.length;I<L;I++){const w=_[I];a(w)}for(let I=0,L=_.length;I<L;I++){const w=_[I],D=s(w);D instanceof R.Object3D&&A.add(D),w.name==="WorldInfo"&&(A.userData.worldInfo=D)}return A}function a(b){b.DEF&&(i[b.DEF]=b);const _=b.fields;for(let A=0,I=_.length;A<I;A++){const L=_[A];if(L.type==="node"){const w=L.values;for(let D=0,B=w.length;D<B;D++)a(w[D])}}}function s(b){return b.USE?Q(b.USE):(b.build!==void 0||(b.build=f(b)),b.build)}function f(b){const _=b.name;let A;switch(_){case"Anchor":case"Group":case"Transform":case"Collision":A=h(b);break;case"Background":A=T(b);break;case"Shape":A=p(b);break;case"Appearance":A=g(b);break;case"Material":A=y(b);break;case"ImageTexture":A=v(b);break;case"PixelTexture":A=m(b);break;case"TextureTransform":A=E(b);break;case"IndexedFaceSet":A=C(b);break;case"IndexedLineSet":A=Y(b);break;case"PointSet":A=O(b);break;case"Box":A=j(b);break;case"Cone":A=M(b);break;case"Cylinder":A=x(b);break;case"Sphere":A=P(b);break;case"ElevationGrid":A=k(b);break;case"Extrusion":A=X(b);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":A=S(b);break;case"WorldInfo":A=N(b);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",_);break}return A!==void 0&&b.DEF!==void 0&&A.hasOwnProperty("name")===!0&&(A.name=b.DEF),A}function h(b){const _=new R.Group,A=b.fields;for(let I=0,L=A.length;I<L;I++){const w=A[I],D=w.name,B=w.values;switch(D){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":H(B,_);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":const V=new R.Vector3(B[0],B[1],B[2]).normalize(),J=B[3];_.quaternion.setFromAxisAngle(V,J);break;case"scale":_.scale.set(B[0],B[1],B[2]);break;case"scaleOrientation":break;case"translation":_.position.set(B[0],B[1],B[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function T(b){const _=new R.Group;let A,I,L,w;const D=b.fields;for(let V=0,J=D.length;V<J;V++){const re=D[V],ge=re.name,xe=re.values;switch(ge){case"groundAngle":A=xe;break;case"groundColor":I=xe;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":L=xe;break;case"skyColor":w=xe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",ge);break}}const B=1e4;if(w){const V=new R.SphereGeometry(B,32,16),J=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,depthWrite:!1,depthTest:!1});w.length>3?(z(V,B,L,F(w),!0),J.vertexColors=!0):J.color.setRGB(w[0],w[1],w[2],R.SRGBColorSpace);const re=new R.Mesh(V,J);_.add(re)}if(I&&I.length>0){const V=new R.SphereGeometry(B,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),J=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});z(V,B,A,F(I),!1);const re=new R.Mesh(V,J);_.add(re)}return _.renderOrder=-1/0,_}function p(b){const _=b.fields;let A=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0}),I;for(let w=0,D=_.length;w<D;w++){const B=_[w],V=B.name,J=B.values;switch(V){case"appearance":J[0]!==null&&(A=s(J[0]));break;case"geometry":J[0]!==null&&(I=s(J[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}let L;if(I&&I.attributes.position){const w=I._type;if(w==="points"){const D=new R.PointsMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:A.opacity,transparent:A.transparent});I.attributes.color!==void 0?D.vertexColors=!0:A.isMeshPhongMaterial&&D.color.copy(A.emissive),L=new R.Points(I,D)}else if(w==="line"){const D=new R.LineBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:A.opacity,transparent:A.transparent});I.attributes.color!==void 0?D.vertexColors=!0:A.isMeshPhongMaterial&&D.color.copy(A.emissive),L=new R.LineSegments(I,D)}else I._solid!==void 0&&(A.side=I._solid?R.FrontSide:R.DoubleSide),I.attributes.color!==void 0&&(A.vertexColors=!0),L=new R.Mesh(I,A)}else L=new R.Object3D,L.visible=!1;return L}function g(b){let _=new R.MeshPhongMaterial,A;const I=b.fields;for(let L=0,w=I.length;L<w;L++){const D=I[L],B=D.name,V=D.values;switch(B){case"material":if(V[0]!==null){const re=s(V[0]);re.diffuseColor&&_.color.copy(re.diffuseColor),re.emissiveColor&&_.emissive.copy(re.emissiveColor),re.shininess&&(_.shininess=re.shininess),re.specularColor&&_.specular.copy(re.specularColor),re.transparency&&(_.opacity=1-re.transparency),re.transparency>0&&(_.transparent=!0)}else _=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":const J=V[0];J!==null&&(J.name==="ImageTexture"||J.name==="PixelTexture")&&(_.map=s(J));break;case"textureTransform":V[0]!==null&&(A=s(V[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",B);break}}if(_.map){if(_.map.__type){switch(_.map.__type){case Xe.INTENSITY_ALPHA:_.opacity=1;break;case Xe.RGB:_.color.set(16777215);break;case Xe.RGBA:_.color.set(16777215),_.opacity=1;break}delete _.map.__type}A&&(_.map.center.copy(A.center),_.map.rotation=A.rotation,_.map.repeat.copy(A.scale),_.map.offset.copy(A.translation))}return _}function y(b){const _={},A=b.fields;for(let I=0,L=A.length;I<L;I++){const w=A[I],D=w.name,B=w.values;switch(D){case"ambientIntensity":break;case"diffuseColor":_.diffuseColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"emissiveColor":_.emissiveColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"shininess":_.shininess=B[0];break;case"specularColor":_.specularColor=new R.Color().setRGB(B[0],B[1],B[2],R.SRGBColorSpace);break;case"transparency":_.transparency=B[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function l(b,_,A){let I;switch(_){case Xe.INTENSITY:I=parseInt(b),A.r=I,A.g=I,A.b=I,A.a=1;break;case Xe.INTENSITY_ALPHA:I=parseInt("0x"+b.substring(2,4)),A.r=I,A.g=I,A.b=I,A.a=parseInt("0x"+b.substring(4,6));break;case Xe.RGB:A.r=parseInt("0x"+b.substring(2,4)),A.g=parseInt("0x"+b.substring(4,6)),A.b=parseInt("0x"+b.substring(6,8)),A.a=1;break;case Xe.RGBA:A.r=parseInt("0x"+b.substring(2,4)),A.g=parseInt("0x"+b.substring(4,6)),A.b=parseInt("0x"+b.substring(6,8)),A.a=parseInt("0x"+b.substring(8,10));break}}function d(b){let _;switch(b){case 1:_=Xe.INTENSITY;break;case 2:_=Xe.INTENSITY_ALPHA;break;case 3:_=Xe.RGB;break;case 4:_=Xe.RGBA;break}return _}function m(b){let _,A=R.RepeatWrapping,I=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const B=L[w],V=B.name,J=B.values;switch(V){case"image":const re=J[0],ge=J[1],xe=J[2],Fe=d(xe),Ie=new Uint8Array(4*re*ge),Ee={r:0,g:0,b:0,a:0};for(let Re=3,Ne=0,Pe=J.length;Re<Pe;Re++,Ne++){l(J[Re],Fe,Ee);const Se=Ne*4;Ie[Se+0]=Ee.r,Ie[Se+1]=Ee.g,Ie[Se+2]=Ee.b,Ie[Se+3]=Ee.a}_=new R.DataTexture(Ie,re,ge),_.colorSpace=R.SRGBColorSpace,_.needsUpdate=!0,_.__type=Fe;break;case"repeatS":J[0]===!1&&(A=R.ClampToEdgeWrapping);break;case"repeatT":J[0]===!1&&(I=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return _&&(_.wrapS=A,_.wrapT=I),_}function v(b){let _,A=R.RepeatWrapping,I=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const B=L[w],V=B.name,J=B.values;switch(V){case"url":const re=J[0];re&&(_=ee.load(re));break;case"repeatS":J[0]===!1&&(A=R.ClampToEdgeWrapping);break;case"repeatT":J[0]===!1&&(I=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return _&&(_.wrapS=A,_.wrapT=I,_.colorSpace=R.SRGBColorSpace),_}function E(b){const _={center:new R.Vector2,rotation:new R.Vector2,scale:new R.Vector2,translation:new R.Vector2},A=b.fields;for(let I=0,L=A.length;I<L;I++){const w=A[I],D=w.name,B=w.values;switch(D){case"center":_.center.set(B[0],B[1]);break;case"rotation":_.rotation=B[0];break;case"scale":_.scale.set(B[0],B[1]);break;case"translation":_.translation.set(B[0],B[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function S(b){return b.fields[0].values}function N(b){const _={},A=b.fields;for(let I=0,L=A.length;I<L;I++){const w=A[I],D=w.name,B=w.values;switch(D){case"title":_.title=B[0];break;case"info":_.info=B;break;default:console.warn("THREE.VRMLLoader: Unknown field:",D);break}}return _}function C(b){let _,A,I,L,w=!0,D=!0,B=0,V,J,re,ge,xe=!0,Fe=!0;const Ie=b.fields;for(let Ce=0,Ge=Ie.length;Ce<Ge;Ce++){const ze=Ie[Ce],Le=ze.name,le=ze.values;switch(Le){case"color":const ue=le[0];ue!==null&&(_=s(ue));break;case"coord":const oe=le[0];oe!==null&&(A=s(oe));break;case"normal":const he=le[0];he!==null&&(I=s(he));break;case"texCoord":const me=le[0];me!==null&&(L=s(me));break;case"ccw":w=le[0];break;case"colorIndex":V=le;break;case"colorPerVertex":xe=le[0];break;case"convex":break;case"coordIndex":J=le;break;case"creaseAngle":B=le[0];break;case"normalIndex":re=le;break;case"normalPerVertex":Fe=le[0];break;case"solid":D=le[0];break;case"texCoordIndex":ge=le;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Le);break}}if(J===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new R.BufferGeometry;const Ee=$(J,w);let Re,Ne,Pe;if(_){if(xe===!0)if(V&&V.length>0){const Ce=$(V,w);Re=Z(Ee,Ce,_,3)}else Re=ye(Ee,new R.Float32BufferAttribute(_,3));else if(V&&V.length>0){const Ce=ae(_,V),Ge=te(Ce,J);Re=ie(Ee,Ge)}else{const Ce=te(_,J);Re=ie(Ee,Ce)}K(Re)}if(I)if(Fe===!0)if(re&&re.length>0){const Ce=$(re,w);Ne=Z(Ee,Ce,I,3)}else Ne=ye(Ee,new R.Float32BufferAttribute(I,3));else if(re&&re.length>0){const Ce=ae(I,re),Ge=te(Ce,J);Ne=ie(Ee,Ge)}else{const Ce=te(I,J);Ne=ie(Ee,Ce)}else Ne=We(Ee,A,B);if(L)if(ge&&ge.length>0){const Ce=$(ge,w);Pe=Z(Ee,Ce,L,2)}else Pe=ye(Ee,new R.Float32BufferAttribute(L,2));const Se=new R.BufferGeometry,De=ye(Ee,new R.Float32BufferAttribute(A,3));return Se.setAttribute("position",De),Se.setAttribute("normal",Ne),Re&&Se.setAttribute("color",Re),Pe&&Se.setAttribute("uv",Pe),Se._solid=D,Se._type="mesh",Se}function Y(b){let _,A,I,L,w=!0;const D=b.fields;for(let ge=0,xe=D.length;ge<xe;ge++){const Fe=D[ge],Ie=Fe.name,Ee=Fe.values;switch(Ie){case"color":const Re=Ee[0];Re!==null&&(_=s(Re));break;case"coord":const Ne=Ee[0];Ne!==null&&(A=s(Ne));break;case"colorIndex":I=Ee;break;case"colorPerVertex":w=Ee[0];break;case"coordIndex":L=Ee;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ie);break}}let B;const V=se(L);if(_){if(w===!0)if(I.length>0){const ge=se(I);B=Z(V,ge,_,3)}else B=ye(V,new R.Float32BufferAttribute(_,3));else if(I.length>0){const ge=ae(_,I),xe=ce(ge,L);B=Te(V,xe)}else{const ge=ce(_,L);B=Te(V,ge)}K(B)}const J=new R.BufferGeometry,re=ye(V,new R.Float32BufferAttribute(A,3));return J.setAttribute("position",re),B&&J.setAttribute("color",B),J._type="line",J}function O(b){let _,A;const I=b.fields;for(let w=0,D=I.length;w<D;w++){const B=I[w],V=B.name,J=B.values;switch(V){case"color":const re=J[0];re!==null&&(_=s(re));break;case"coord":const ge=J[0];ge!==null&&(A=s(ge));break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}const L=new R.BufferGeometry;if(L.setAttribute("position",new R.Float32BufferAttribute(A,3)),_){const w=new R.Float32BufferAttribute(_,3);K(w),L.setAttribute("color",w)}return L._type="points",L}function j(b){const _=new R.Vector3(2,2,2),A=b.fields;for(let L=0,w=A.length;L<w;L++){const D=A[L],B=D.name,V=D.values;B==="size"?(_.x=V[0],_.y=V[1],_.z=V[2]):console.warn("THREE.VRMLLoader: Unknown field:",B)}return new R.BoxGeometry(_.x,_.y,_.z)}function M(b){let _=1,A=2,I=!1;const L=b.fields;for(let D=0,B=L.length;D<B;D++){const V=L[D],J=V.name,re=V.values;switch(J){case"bottom":I=!re[0];break;case"bottomRadius":_=re[0];break;case"height":A=re[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",J);break}}return new R.ConeGeometry(_,A,16,1,I)}function x(b){let _=1,A=2;const I=b.fields;for(let w=0,D=I.length;w<D;w++){const B=I[w],V=B.name,J=B.values;switch(V){case"bottom":break;case"radius":_=J[0];break;case"height":A=J[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",V);break}}return new R.CylinderGeometry(_,_,A,16,1)}function P(b){let _=1;const A=b.fields;for(let L=0,w=A.length;L<w;L++){const D=A[L],B=D.name,V=D.values;B==="radius"?_=V[0]:console.warn("THREE.VRMLLoader: Unknown field:",B)}return new R.SphereGeometry(_,16,16)}function k(b){let _,A,I,L,w=!0,D=!0,B=!0,V=!0,J=0,re=2,ge=2,xe=1,Fe=1;const Ie=b.fields;for(let le=0,ue=Ie.length;le<ue;le++){const oe=Ie[le],he=oe.name,me=oe.values;switch(he){case"color":const Me=me[0];Me!==null&&(_=s(Me));break;case"normal":const Qe=me[0];Qe!==null&&(A=s(Qe));break;case"texCoord":const Ze=me[0];Ze!==null&&(I=s(Ze));break;case"height":L=me;break;case"ccw":V=me[0];break;case"colorPerVertex":w=me[0];break;case"creaseAngle":J=me[0];break;case"normalPerVertex":D=me[0];break;case"solid":B=me[0];break;case"xDimension":re=me[0];break;case"xSpacing":xe=me[0];break;case"zDimension":ge=me[0];break;case"zSpacing":Fe=me[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",he);break}}const Ee=[],Re=[],Ne=[],Pe=[];for(let le=0;le<ge;le++)for(let ue=0;ue<re;ue++){const oe=le*re+ue,he=xe*le,me=L[oe],Me=Fe*ue;if(Ee.push(he,me,Me),_&&w===!0){const Qe=_[oe*3+0],Ze=_[oe*3+1],Rt=_[oe*3+2];Ne.push(Qe,Ze,Rt)}if(A&&D===!0){const Qe=A[oe*3+0],Ze=A[oe*3+1],Rt=A[oe*3+2];Re.push(Qe,Ze,Rt)}if(I){const Qe=I[oe*2+0],Ze=I[oe*2+1];Pe.push(Qe,Ze)}else Pe.push(le/(re-1),ue/(ge-1))}const Se=[];for(let le=0;le<re-1;le++)for(let ue=0;ue<ge-1;ue++){const oe=le+ue*re,he=le+(ue+1)*re,me=le+1+(ue+1)*re,Me=le+1+ue*re;V===!0?(Se.push(oe,me,he),Se.push(me,oe,Me)):(Se.push(oe,he,me),Se.push(me,Me,oe))}const De=ye(Se,new R.Float32BufferAttribute(Ee,3)),Ce=ye(Se,new R.Float32BufferAttribute(Pe,2));let Ge,ze;if(_){if(w===!1){for(let le=0;le<re-1;le++)for(let ue=0;ue<ge-1;ue++){const oe=le+ue*(re-1),he=_[oe*3+0],me=_[oe*3+1],Me=_[oe*3+2];Ne.push(he,me,Me),Ne.push(he,me,Me),Ne.push(he,me,Me),Ne.push(he,me,Me),Ne.push(he,me,Me),Ne.push(he,me,Me)}Ge=new R.Float32BufferAttribute(Ne,3)}else Ge=ye(Se,new R.Float32BufferAttribute(Ne,3));K(Ge)}if(A)if(D===!1){for(let le=0;le<re-1;le++)for(let ue=0;ue<ge-1;ue++){const oe=le+ue*(re-1),he=A[oe*3+0],me=A[oe*3+1],Me=A[oe*3+2];Re.push(he,me,Me),Re.push(he,me,Me),Re.push(he,me,Me),Re.push(he,me,Me),Re.push(he,me,Me),Re.push(he,me,Me)}ze=new R.Float32BufferAttribute(Re,3)}else ze=ye(Se,new R.Float32BufferAttribute(Re,3));else ze=We(Se,Ee,J);const Le=new R.BufferGeometry;return Le.setAttribute("position",De),Le.setAttribute("normal",ze),Le.setAttribute("uv",Ce),Ge&&Le.setAttribute("color",Ge),Le._solid=B,Le._type="mesh",Le}function X(b){let _=[1,1,1,-1,-1,-1,-1,1,1,1],A=[0,0,0,0,1,0],I,L,w=!0,D=!0,B=0,V=!0,J=!0;const re=b.fields;for(let Le=0,le=re.length;Le<le;Le++){const ue=re[Le],oe=ue.name,he=ue.values;switch(oe){case"beginCap":w=he[0];break;case"ccw":D=he[0];break;case"convex":break;case"creaseAngle":B=he[0];break;case"crossSection":_=he;break;case"endCap":V=he[0];break;case"orientation":L=he;break;case"scale":I=he;break;case"solid":J=he[0];break;case"spine":A=he;break;default:console.warn("THREE.VRMLLoader: Unknown field:",oe);break}}const ge=_[0]===_[_.length-2]&&_[1]===_[_.length-1],xe=[],Fe=new R.Vector3,Ie=new R.Vector3,Ee=new R.Vector3,Re=new R.Vector3,Ne=new R.Quaternion;for(let Le=0,le=0,ue=0,oe=A.length;Le<oe;Le+=3,le+=2,ue+=4){Fe.fromArray(A,Le),Ie.x=I?I[le+0]:1,Ie.y=1,Ie.z=I?I[le+1]:1,Ee.x=L?L[ue+0]:0,Ee.y=L?L[ue+1]:0,Ee.z=L?L[ue+2]:1;const he=L?L[ue+3]:0;for(let me=0,Me=_.length;me<Me;me+=2)Re.x=_[me+0],Re.y=0,Re.z=_[me+1],Re.multiply(Ie),Ne.setFromAxisAngle(Ee,he),Re.applyQuaternion(Ne),Re.add(Fe),xe.push(Re.x,Re.y,Re.z)}const Pe=[],Se=A.length/3,De=_.length/2;for(let Le=0;Le<Se-1;Le++)for(let le=0;le<De-1;le++){const ue=le+Le*De;let oe=le+1+Le*De;const he=le+(Le+1)*De;let me=le+1+(Le+1)*De;le===De-2&&ge===!0&&(oe=Le*De,me=(Le+1)*De),D===!0?(Pe.push(ue,oe,he),Pe.push(he,oe,me)):(Pe.push(ue,he,oe),Pe.push(he,me,oe))}if(w===!0||V===!0){const Le=[];for(let oe=0,he=_.length;oe<he;oe+=2)Le.push(new R.Vector2(_[oe],_[oe+1]));const le=R.ShapeUtils.triangulateShape(Le,[]),ue=[];for(let oe=0,he=le.length;oe<he;oe++){const me=le[oe];ue.push(me[0],me[1],me[2])}if(w===!0)for(let oe=0,he=ue.length;oe<he;oe+=3)D===!0?Pe.push(ue[oe+0],ue[oe+1],ue[oe+2]):Pe.push(ue[oe+0],ue[oe+2],ue[oe+1]);if(V===!0){const oe=De*(Se-1);for(let he=0,me=ue.length;he<me;he+=3)D===!0?Pe.push(oe+ue[he+0],oe+ue[he+2],oe+ue[he+1]):Pe.push(oe+ue[he+0],oe+ue[he+1],oe+ue[he+2])}}const Ce=ye(Pe,new R.Float32BufferAttribute(xe,3)),Ge=We(Pe,xe,B),ze=new R.BufferGeometry;return ze.setAttribute("position",Ce),ze.setAttribute("normal",Ge),ze._solid=J,ze._type="mesh",ze}function Q(b){const _=i[b],A=s(_);return A.isObject3D||A.isMaterial?A.clone():A}function H(b,_){for(let A=0,I=b.length;A<I;A++){const L=s(b[A]);L instanceof R.Object3D&&_.add(L)}}function $(b,_){const A=[];let I=0;for(let L=0,w=b.length;L<w;L++){const D=b[I],B=b[L+(_?1:2)],V=b[L+(_?2:1)];A.push(D,B,V),(b[L+3]===-1||L+3>=w)&&(L+=3,I=L+1)}return A}function te(b,_){const A=[];let I=0;for(let L=0,w=_.length;L<w;L++){const D=I*3,B=b[D],V=b[D+1],J=b[D+2];A.push(B,V,J),(_[L+3]===-1||L+3>=w)&&(L+=3,I++)}return A}function ae(b,_){const A=[];for(let I=0,L=_.length;I<L;I++){const D=_[I]*3,B=b[D],V=b[D+1],J=b[D+2];A.push(B,V,J)}return A}function se(b){const _=[];for(let A=0,I=b.length;A<I;A++){const L=b[A],w=b[A+1];_.push(L,w),(b[A+2]===-1||A+2>=I)&&(A+=2)}return _}function ce(b,_){const A=[];let I=0;for(let L=0,w=_.length;L<w;L++){const D=I*3,B=b[D],V=b[D+1],J=b[D+2];A.push(B,V,J),(_[L+2]===-1||L+2>=w)&&(L+=2,I++)}return A}const ne=new R.Vector3,pe=new R.Vector3,U=new R.Vector3,G=new R.Vector2,W=new R.Vector2,q=new R.Vector2;function Z(b,_,A,I){const L=[];for(let w=0,D=b.length;w<D;w+=3){const B=_[w],V=_[w+1],J=_[w+2];I===2?(G.fromArray(A,B*I),W.fromArray(A,V*I),q.fromArray(A,J*I),L.push(G.x,G.y),L.push(W.x,W.y),L.push(q.x,q.y)):(ne.fromArray(A,B*I),pe.fromArray(A,V*I),U.fromArray(A,J*I),L.push(ne.x,ne.y,ne.z),L.push(pe.x,pe.y,pe.z),L.push(U.x,U.y,U.z))}return new R.Float32BufferAttribute(L,I)}function ie(b,_){const A=[];for(let I=0,L=0,w=b.length;I<w;I+=3,L++)ne.fromArray(_,L*3),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(A,3)}function Te(b,_){const A=[];for(let I=0,L=0,w=b.length;I<w;I+=2,L++)ne.fromArray(_,L*3),A.push(ne.x,ne.y,ne.z),A.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(A,3)}function ye(b,_){const A=_.array,I=_.itemSize,L=new A.constructor(b.length*I);let w=0,D=0;for(let B=0,V=b.length;B<V;B++){w=b[B]*I;for(let J=0;J<I;J++)L[D++]=A[w++]}return new R.Float32BufferAttribute(L,I)}const we=new R.Vector3,je=new R.Vector3;function We(b,_,A){const I=[],L={};for(let D=0,B=b.length;D<B;D+=3){const V=b[D],J=b[D+1],re=b[D+2],ge=new _i(V,J,re);ne.fromArray(_,V*3),pe.fromArray(_,J*3),U.fromArray(_,re*3),je.subVectors(U,pe),we.subVectors(ne,pe),je.cross(we),je.normalize(),ge.normal.copy(je),L[V]===void 0&&(L[V]=[]),L[J]===void 0&&(L[J]=[]),L[re]===void 0&&(L[re]=[]),L[V].push(ge.normal),L[J].push(ge.normal),L[re].push(ge.normal),I.push(ge)}const w=[];for(let D=0,B=I.length;D<B;D++){const V=I[D],J=Ue(L[V.a],V.normal,A),re=Ue(L[V.b],V.normal,A),ge=Ue(L[V.c],V.normal,A);ne.fromArray(_,V.a*3),pe.fromArray(_,V.b*3),U.fromArray(_,V.c*3),w.push(J.x,J.y,J.z),w.push(re.x,re.y,re.z),w.push(ge.x,ge.y,ge.z)}return new R.Float32BufferAttribute(w,3)}function Ue(b,_,A){const I=new R.Vector3;if(A===0)I.copy(_);else for(let L=0,w=b.length;L<w;L++)b[L].angleTo(_)<A&&I.add(b[L]);return I.normalize()}function F(b){const _=[];for(let A=0,I=b.length;A<I;A+=3)_.push(new R.Color(b[A],b[A+1],b[A+2]));return _}function K(b){const _=new R.Color;for(let A=0;A<b.count;A++)_.fromBufferAttribute(b,A),R.ColorManagement.colorSpaceToWorking(_,R.SRGBColorSpace),b.setXYZ(A,_.r,_.g,_.b)}function z(b,_,A,I,L){const w=[],D=L===!0?0:Math.PI;for(let xe=0,Fe=I.length;xe<Fe;xe++){let Ie=xe===0?0:A[xe-1];Ie=L===!0?Ie:D-Ie;const Ee=new R.Vector3;Ee.setFromSphericalCoords(_,Ie,0),w.push(Ee)}const B=b.index,V=b.attributes.position,J=new R.BufferAttribute(new Float32Array(b.attributes.position.count*3),3),re=new R.Vector3,ge=new R.Color;for(let xe=0;xe<B.count;xe++){const Fe=B.getX(xe);re.fromBufferAttribute(V,Fe);let Ie,Ee,Re=1;for(let Se=1;Se<w.length;Se++){Ie=Se-1,Ee=Se;const De=w[Ie],Ce=w[Ee];if(L===!0){if(re.y<=De.y&&re.y>Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}else if(re.y>=De.y&&re.y<Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}const Ne=I[Ie],Pe=I[Ee];ge.copy(Ne).lerp(Pe,Re),R.ColorManagement.colorSpaceToWorking(ge,R.SRGBColorSpace),J.setXYZ(Fe,ge.r,ge.g,ge.b)}b.setAttribute("color",J)}const ee=new R.TextureLoader(this.manager);if(ee.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const fe=r(e);return u(fe)}}class Ei{constructor(e){this.lexer=new ot.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}const vi=ot.CstParser;class Ri extends vi{constructor(e){super(e);const t=this,i=e.Version,r=e.LCurly,c=e.RCurly,o=e.LSquare,u=e.RSquare,a=e.Identifier,s=e.RouteIdentifier,f=e.StringLiteral,h=e.HexLiteral,T=e.NumberLiteral,p=e.TrueLiteral,g=e.FalseLiteral,y=e.NullLiteral,l=e.DEF,d=e.USE,m=e.ROUTE,v=e.TO,E=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(i)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(E),t.CONSUME(r),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(c)}),t.RULE("field",function(){t.CONSUME(a),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(l),t.OR([{ALT:function(){t.CONSUME(a)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("use",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(a)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(T)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(y)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(T)}},{ALT:function(){t.CONSUME(y)}}])}),t.CONSUME(u)}),t.RULE("route",function(){t.CONSUME(m),t.CONSUME(s),t.CONSUME(v),t.CONSUME2(s)}),this.performSelfAnalysis()}}class _i{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.normal=new R.Vector3}}const Xe={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};class Ai extends R.Loader{constructor(e){super(e),this.animateBonePositions=!0,this.animateBoneRotations=!0,this.animateBoneScales=!0}load(e,t,i,r){const c=this,o=new R.FileLoader(c.manager);o.setPath(c.path),o.setRequestHeader(c.requestHeader),o.setWithCredentials(c.withCredentials),o.load(e,function(u){try{t(c.parse(u))}catch(a){r?r(a):console.error(a),c.manager.itemError(e)}},i,r)}parse(e){function t(p){u(p)!=="HIERARCHY"&&console.error("THREE.BVHLoader2: HIERARCHY expected.");const g=[],y=r(p,u(p),g);u(p)!=="MOTION"&&console.error("THREE.BVHLoader2: MOTION expected.");let l=u(p).split(/[\s]+/);const d=parseInt(l[1]);isNaN(d)&&console.error("THREE.BVHLoader2: Failed to read number of frames."),l=u(p).split(/[\s]+/);const m=parseFloat(l[2]);isNaN(m)&&console.error("THREE.BVHLoader2: Failed to read frame time.");for(let v=0;v<d;v++)l=u(p).split(/[\s]+/),i(l,v*m,y);return g}function i(p,g,y){if(y.type==="ENDSITE")return;const l={time:g,position:new R.Vector3,rotation:new R.Quaternion,scale:new R.Vector3(1,1,1)};y.frames.push(l);const d=new R.Quaternion,m=new R.Vector3(1,0,0),v=new R.Vector3(0,1,0),E=new R.Vector3(0,0,1);for(let S=0;S<y.channels.length;S++)switch(y.channels[S]){case"Xposition":l.position.x=parseFloat(p.shift().trim());break;case"Yposition":l.position.y=parseFloat(p.shift().trim());break;case"Zposition":l.position.z=parseFloat(p.shift().trim());break;case"Xrotation":d.setFromAxisAngle(m,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Yrotation":d.setFromAxisAngle(v,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Zrotation":d.setFromAxisAngle(E,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Xscale":l.scale.x=parseFloat(p.shift().trim());break;case"Yscale":l.scale.y=parseFloat(p.shift().trim());break;case"Zscale":l.scale.z=parseFloat(p.shift().trim());break;default:console.warn("THREE.BVHLoader2: Invalid channel type.")}for(let S=0;S<y.children.length;S++)i(p,g,y.children[S])}function r(p,g,y){const l={name:"",type:"",frames:[]};y.push(l);let d=g.split(/[\s]+/);d[0].toUpperCase()==="END"&&d[1].toUpperCase()==="SITE"?(l.type="ENDSITE",l.name="ENDSITE"):(l.name=d[1],l.type=d[0].toUpperCase()),u(p)!=="{"&&console.error("THREE.BVHLoader2: Expected opening { after type & name"),d=u(p).split(/[\s]+/),d[0]!=="OFFSET"&&console.error("THREE.BVHLoader2: Expected OFFSET but got: "+d[0]),d.length!==4&&console.error("THREE.BVHLoader2: Invalid number of values for OFFSET.");const m=new R.Vector3(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]));if((isNaN(m.x)||isNaN(m.y)||isNaN(m.z))&&console.error("THREE.BVHLoader2: Invalid values of OFFSET."),l.offset=m,l.type!=="ENDSITE"){d=u(p).split(/[\s]+/),d[0]!=="CHANNELS"&&console.error("THREE.BVHLoader2: Expected CHANNELS definition.");const v=parseInt(d[1]);l.channels=d.splice(2,v),l.children=[]}for(;;){const v=u(p);if(v==="}")return l;l.children.push(r(p,v,y))}}function c(p,g){const y=new R.Bone;if(g.push(y),y.position.add(p.offset),y.name=p.name,p.type!=="ENDSITE")for(let l=0;l<p.children.length;l++)y.add(c(p.children[l],g));return y}function o(p){const g=[];for(let y=0;y<p.length;y++){const l=p[y];if(l.type==="ENDSITE")continue;const d=[],m=[],v=[],E=[];for(let S=0;S<l.frames.length;S++){const N=l.frames[S];d.push(N.time),m.push(N.position.x+l.offset.x),m.push(N.position.y+l.offset.y),m.push(N.position.z+l.offset.z),v.push(N.rotation.x),v.push(N.rotation.y),v.push(N.rotation.z),v.push(N.rotation.w),E.push(N.scale.x),E.push(N.scale.y),E.push(N.scale.z)}a.animateBonePositions&&g.push(new R.VectorKeyframeTrack(l.name+".position",d,m)),a.animateBoneRotations&&g.push(new R.QuaternionKeyframeTrack(l.name+".quaternion",d,v)),a.animateBoneScales&&g.push(new R.VectorKeyframeTrack(l.name+".scale",d,E))}return new R.AnimationClip("animation",-1,g)}function u(p){let g;for(;(g=p.shift().trim()).length===0;);return g}const a=this,s=e.split(/[\r\n]+/g),f=t(s),h=[];c(f[0],h);const T=o(f);return{skeleton:new R.Skeleton(h),clip:T}}}let dt;async function bi(n,e){return dt||(dt=new Ti),dt.manager.setURLModifier(i=>(i.startsWith("./")&&(i=i.substring(2)),URL.createObjectURL(er(n,i)))),await dt.loadAsync(e)}let St;async function Li(n,e){St||(St=new Ai);const t=Ct(n,e);return await St.parse(t)}class Si extends Be{ready;actions;currentAction=null;comment=null;vrmls={};constructor(e){super(),this.ready=this.asyncInit(e),this.actions={}}initObject(){return new de.Object3D}async asyncInit(e){const t=await an(e),i=new DOMParser,r=Ct(t,"CATALOG.XML"),c=i.parseFromString(r,"application/xml");if(c.querySelector("parsererror"))return console.error("Acerola3D.asyncInit(): CATALOG.XML parse error."),this;const o="http://acerola3d.sourceforge.jp/a3/catalog",u=c.getElementsByTagNameNS(o,"c");u[0]&&(this.comment=u[0].textContent);const a=c.getElementsByTagNameNS(o,"a");for(const s of Array.from(a)){const f=s.getAttribute("an"),h=s.getAttribute("bvh"),T=s.getAttribute("scale"),p=s.getAttribute("offset");if(f){const g={bvh:null,mixer:null,clipAction:null,parts:{},root:null,scale:1,offset:new _e};if(this.actions[f]=g,h){const l=await Li(t,h);g.bvh=l}if(g.scale=T?Number(T):1,p){const l=p.split(" ");g.offset.set(Number(l[0]),Number(l[1]),Number(l[2]))}const y=s.getElementsByTagNameNS(o,"p");for(const l of Array.from(y)){const d=l.getAttribute("name"),m=l.getAttribute("wrl");if(d&&m)if(this.vrmls[m]){const v=this.vrmls[m].clone();g.parts[d]={wrl:v}}else{const v=await bi(t,m);g.parts[d]={wrl:v},this.vrmls[m]=v}}}}for(const s of Object.values(this.actions))s.bvh&&(s.root=new de.Object3D,s.root.add(s.bvh.skeleton.bones[0]),s.root.scale.set(s.scale,s.scale,s.scale),s.root.position.set(s.offset.x,s.offset.y,s.offset.z),Sn(s.root,s.parts),s.mixer=new de.AnimationMixer(s.root),s.clipAction=s.mixer.clipAction(s.bvh.clip),s.root.traverse(f=>{f.userData.a3js={objectA3:this}}));for(const s of Object.values(this.actions))if(s.root){this.object.add(s.root),s.clipAction?.play(),this.currentAction=s;break}return this}action(e){const t=this.actions[e];t&&(this.currentAction?.clipAction?.stop(),this.currentAction?.root&&this.object.remove(this.currentAction?.root),this.currentAction=t,this.currentAction?.root&&this.object.add(this.currentAction.root),this.currentAction?.clipAction?.play())}update(e){super.update(e),this.currentAction?.mixer&&this.currentAction?.mixer.update(e)}}function Sn(n,e){if(Gn(n)){const t=e[n.name];t&&n.add(t.wrl)}n.children&&n.children.forEach(t=>{Sn(t,e)})}class xi extends Be{constructor(e){super(e)}initObject(e){return e}}class Oi extends Be{constructor(...e){super(e)}initObject(e){const t=e.filter(a=>typeof a=="number"),i=e.filter(a=>typeof a=="string"),r=new de.BoxGeometry(...t),c=i.length>0?i[0]:"rgb(128,128,128)",o=new de.MeshStandardMaterial({color:c});return new de.Mesh(r,o)}}class Ii extends Be{constructor(...e){super(e)}initObject(e){const t=e.filter(a=>typeof a=="number"),i=e.filter(a=>typeof a=="string"),r=new de.SphereGeometry(...t),c=i.length>0?i[0]:"rgb(128,128,128)",o=new de.MeshStandardMaterial({color:c});return new de.Mesh(r,o)}}class Ni extends Be{constructor(e){super(e)}initObject(e){return new cn(e)}}exports.Acerola3D=Si;exports.Box=Oi;exports.Camera=rn;exports.Canvas=un;exports.ControllerBase=on;exports.GLTFA3=gn;exports.GeneralCamera=ct;exports.HTML=Ni;exports.Motion=lt;exports.ObjectA3=Be;exports.OrbitController=sn;exports.Quat=ke;exports.RapierPhysicsEngine=at;exports.Scene=nn;exports.Sound=$e;exports.Sphere=Ii;exports.Test=cr;exports.Text3D=mr;exports.ThreeJS=xi;exports.Vec3=_e;exports.ViewBase=Pt;exports.Window=hn;exports.asyncSleep=$n;exports.deepMerge=mt;exports.getQuatOfLookAt=st;exports.initFont=pr;exports.initPhysics=Qn;exports.initSound=ir;exports.times2=Jn;exports.vec3EulerToQuat=tn;
|
|
220
220
|
//# sourceMappingURL=a3js.cjs.js.map
|