@uptimizr/replay 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /* @uptimizr/replay standalone bundle (global) — Apache-2.0. Inject via a <script> tag into any page (e.g. playground.babylonjs.com); exposes window.UptimizrReplay. Bundles the Babylon Vector3 it constructs; the host page owns the scene (and its asset loader). */
2
- "use strict";var UptimizrReplay=(()=>{var _o=Object.defineProperty;var Jh=Object.getOwnPropertyDescriptor;var Kh=Object.getOwnPropertyNames;var qh=Object.prototype.hasOwnProperty;var Fe=(n,e)=>{for(var r in e)_o(n,r,{get:e[r],enumerable:!0})},Gh=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of Kh(e))!qh.call(n,t)&&t!==r&&_o(n,t,{get:()=>e[t],enumerable:!(i=Jh(e,t))||i.enumerable});return n};var Wh=n=>Gh(_o({},"__esModule",{value:!0}),n);var V$={};Fe(V$,{ReplayPlayer:()=>sr,createBabylonReplayDriver:()=>xo,fetchSessionEvents:()=>Rh,fetchSessionEventsStream:()=>ud,replayInScene:()=>F$});var J$=(1+Math.sqrt(5))/2,ce=.001;function Hh(n,e){let r=[];for(let i=0;i<n;++i)r.push(e());return r}function Ge(n,e){return Hh(n,e)}var ke=class n{static SetMatrixPrecision(e){if(n.MatrixTrackPrecisionChange=!1,e&&!n.MatrixUse64Bits&&n.MatrixTrackedMatrices)for(let r=0;r<n.MatrixTrackedMatrices.length;++r){let i=n.MatrixTrackedMatrices[r],t=i._m;i._m=new Array(16);for(let o=0;o<16;++o)i._m[o]=t[o]}n.MatrixUse64Bits=e,n.MatrixCurrentType=n.MatrixUse64Bits?Array:Float32Array,n.MatrixTrackedMatrices=null}};ke.MatrixUse64Bits=!1;ke.MatrixTrackPrecisionChange=!0;ke.MatrixCurrentType=Float32Array;ke.MatrixTrackedMatrices=[];var Xh=typeof WeakRef<"u",yo=class{constructor(e,r=!1,i,t){this.initialize(e,r,i,t)}initialize(e,r=!1,i,t){return this.mask=e,this.skipNextObservers=r,this.target=i,this.currentTarget=t,this}},$o=class{constructor(e,r,i=null){this.callback=e,this.mask=r,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}},cr=class n{static FromPromise(e,r){let i=new n;return e.then(t=>{i.notifyObservers(t)}).catch(t=>{if(r)r.notifyObservers(t);else throw t}),i}get observers(){return this._observers}constructor(e,r=!1){this.notifyIfTriggered=r,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new yo(0),e&&(this._onObserverAdded=e)}add(e,r=-1,i=!1,t=null,o=!1){if(!e)return null;let a=new $o(e,r,t);a.unregisterOnNextCall=o,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(a,this._lastNotifiedValue);let s=Xh?new WeakRef(this):{deref:()=>this};return a._remove=(c=!1)=>{let u=s.deref();u&&(c?u.remove(a):u._remove(a))},a}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}removeCallback(e,r){for(let i=0;i<this._observers.length;i++){let t=this._observers[i];if(!t._willBeUnregistered&&t.callback===e&&(!r||r===t.scope))return this._deferUnregister(t),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0))}_remove(e,r=!0){if(!e)return!1;let i=this._observers.indexOf(e);return i!==-1?(r&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,r=-1,i,t,o){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;let a=this._eventState;a.mask=r,a.target=i,a.currentTarget=t,a.skipNextObservers=!1,a.lastReturnValue=e,a.userInfo=o;for(let s of this._observers)if(!s._willBeUnregistered&&(s.mask&r&&(s.unregisterOnNextCall&&this._deferUnregister(s),s.scope?a.lastReturnValue=s.callback.apply(s.scope,[e,a]):a.lastReturnValue=s.callback(e,a)),a.skipNextObservers))return!1;return!0}notifyObserver(e,r,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=r),e._willBeUnregistered)return;let t=this._eventState;t.mask=i,t.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(r,t)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){let e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){let e=new n;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(let r of this._observers)if(r.mask&e||r.mask===e)return!0;return!1}};var Le=class{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}};Le.Instances=[];Le.OnEnginesDisposedObservable=new cr;Le._LastCreatedScene=null;Le.UseFallbackTexture=!0;Le.FallbackTexture="";function X(n,e,r=1401298e-51){return Math.abs(n-e)<=r}function G(n,e){return n===e?n:Math.random()*(e-n)+n}function fd(n,e,r){return n+(e-n)*r}function oe(n,e=0,r=1){return Math.min(r,Math.max(e,n))}function pd(n){return n-=Math.PI*2*Math.floor((n+Math.PI)/(Math.PI*2)),n}var gn=class{};gn._UpdateFlagSeed=0;function hd(n,e,r,i=0){let t=n.asArray(),o=e.asArray(),a=t[0],s=t[1],c=t[2],u=t[3],l=t[4],d=t[5],m=t[6],f=t[7],h=t[8],_=t[9],z=t[10],P=t[11],x=t[12],T=t[13],D=t[14],A=t[15],S=o[0],Z=o[1],K=o[2],ge=o[3],le=o[4],ve=o[5],re=o[6],te=o[7],H=o[8],Ce=o[9],Ue=o[10],Ye=o[11],De=o[12],Oe=o[13],Ne=o[14],qe=o[15];r[i]=a*S+s*le+c*H+u*De,r[i+1]=a*Z+s*ve+c*Ce+u*Oe,r[i+2]=a*K+s*re+c*Ue+u*Ne,r[i+3]=a*ge+s*te+c*Ye+u*qe,r[i+4]=l*S+d*le+m*H+f*De,r[i+5]=l*Z+d*ve+m*Ce+f*Oe,r[i+6]=l*K+d*re+m*Ue+f*Ne,r[i+7]=l*ge+d*te+m*Ye+f*qe,r[i+8]=h*S+_*le+z*H+P*De,r[i+9]=h*Z+_*ve+z*Ce+P*Oe,r[i+10]=h*K+_*re+z*Ue+P*Ne,r[i+11]=h*ge+_*te+z*Ye+P*qe,r[i+12]=x*S+T*le+D*H+A*De,r[i+13]=x*Z+T*ve+D*Ce+A*Oe,r[i+14]=x*K+T*re+D*Ue+A*Ne,r[i+15]=x*ge+T*te+D*Ye+A*qe}function gd(n,e,r=0){let i=n.asArray();e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15]}function vd(n,e){let r=n.asArray(),i=r[0],t=r[1],o=r[2],a=r[3],s=r[4],c=r[5],u=r[6],l=r[7],d=r[8],m=r[9],f=r[10],h=r[11],_=r[12],z=r[13],P=r[14],x=r[15],T=f*x-P*h,D=m*x-z*h,A=m*P-z*f,S=d*x-_*h,Z=d*P-f*_,K=d*z-_*m,ge=+(c*T-u*D+l*A),le=-(s*T-u*S+l*Z),ve=+(s*D-c*S+l*K),re=-(s*A-c*Z+u*K),te=i*ge+t*le+o*ve+a*re;if(te===0)return!1;let H=1/te,Ce=u*x-P*l,Ue=c*x-z*l,Ye=c*P-z*u,De=s*x-_*l,Oe=s*P-_*u,Ne=s*z-_*c,qe=u*h-f*l,Qe=c*h-m*l,Ot=c*f-m*u,ld=s*h-d*l,dd=s*f-d*u,md=s*m-d*c,jh=-(t*T-o*D+a*A),Uh=+(i*T-o*S+a*Z),Nh=-(i*D-t*S+a*K),Ah=+(i*A-t*Z+o*K),Eh=+(t*Ce-o*Ue+a*Ye),Zh=-(i*Ce-o*De+a*Oe),Ch=+(i*Ue-t*De+a*Ne),Fh=-(i*Ye-t*Oe+o*Ne),Lh=-(t*qe-o*Qe+a*Ot),Mh=+(i*qe-o*ld+a*dd),Vh=-(i*Qe-t*ld+a*md),Bh=+(i*Ot-t*dd+o*md);return e[0]=ge*H,e[1]=jh*H,e[2]=Eh*H,e[3]=Lh*H,e[4]=le*H,e[5]=Uh*H,e[6]=Zh*H,e[7]=Mh*H,e[8]=ve*H,e[9]=Nh*H,e[10]=Ch*H,e[11]=Vh*H,e[12]=re*H,e[13]=Ah*H,e[14]=Fh*H,e[15]=Bh*H,!0}var Yh={};function vn(n,e){Yh[n]=e}var de=n=>parseInt(n.toString().replace(/\W/g,"")),We=class n{constructor(e=0,r=0){this.x=e,this.y=r}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=de(this.x),r=de(this.y),i=e;return i=i*397^r,i}toArray(e,r=0){return e[r]=this.x,e[r+1]=this.y,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,r){return this.x=e,this.y=r,this}set(e,r){return this.copyFromFloats(e,r)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new n(this.x+e.x,this.y+e.y)}addToRef(e,r){return r.x=this.x+e.x,r.y=this.y+e.y,r}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,r){return this.x+=e,this.y+=r,this}addVector3(e){return new n(this.x+e.x,this.y+e.y)}subtract(e){return new n(this.x-e.x,this.y-e.y)}subtractToRef(e,r){return r.x=this.x-e.x,r.y=this.y-e.y,r}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new n(this.x*e.x,this.y*e.y)}multiplyToRef(e,r){return r.x=this.x*e.x,r.y=this.y*e.y,r}multiplyByFloats(e,r){return new n(this.x*e,this.y*r)}divide(e){return new n(this.x/e.x,this.y/e.y)}divideToRef(e,r){return r.x=this.x/e.x,r.y=this.y/e.y,r}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,r){return this.x=Math.min(e,this.x),this.y=Math.min(r,this.y),this}maximizeInPlaceFromFloats(e,r){return this.x=Math.max(e,this.x),this.y=Math.max(r,this.y),this}subtractFromFloats(e,r){return new n(this.x-e,this.y-r)}subtractFromFloatsToRef(e,r,i){return i.x=this.x-e,i.y=this.y-r,i}negate(){return new n(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new n(this.x*e,this.y*e)}scaleToRef(e,r){return r.x=this.x*e,r.y=this.y*e,r}scaleAndAddToRef(e,r){return r.x+=this.x*e,r.y+=this.y*e,r}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,r=ce){return e&&X(this.x,e.x,r)&&X(this.y,e.y,r)}equalsToFloats(e,r){return this.x===e&&this.y===r}floor(){return new n(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new n(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new n)}rotateToRef(e,r){let i=Math.cos(e),t=Math.sin(e);return r.x=i*this.x-t*this.y,r.y=t*this.x+i*this.y,r}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n;return this.normalizeToRef(e),e}normalizeToRef(e){let r=this.length();return r===0||r===1?(e.x=this.x,e.y=this.y,e):this.scaleToRef(1/r,e)}clone(){return new n(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new n(0,0)}static One(){return new n(1,1)}static Random(e=0,r=1){return new n(G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r))}static get ZeroReadOnly(){return n._ZeroReadOnly}static FromArray(e,r=0){return new n(e[r],e[r+1])}static FromArrayToRef(e,r,i){return i.x=e[r],i.y=e[r+1],i}static FromFloatsToRef(e,r,i){return i.copyFromFloats(e,r),i}static CatmullRom(e,r,i,t,o){let a=o*o,s=o*a,c=.5*(2*r.x+(-e.x+i.x)*o+(2*e.x-5*r.x+4*i.x-t.x)*a+(-e.x+3*r.x-3*i.x+t.x)*s),u=.5*(2*r.y+(-e.y+i.y)*o+(2*e.y-5*r.y+4*i.y-t.y)*a+(-e.y+3*r.y-3*i.y+t.y)*s);return new n(c,u)}static ClampToRef(e,r,i,t){return t.x=oe(e.x,r.x,i.x),t.y=oe(e.y,r.y,i.y),t}static Clamp(e,r,i){let t=oe(e.x,r.x,i.x),o=oe(e.y,r.y,i.y);return new n(t,o)}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e.x*c+i.x*u+r.x*l+t.x*d,f=e.y*c+i.y*u+r.y*l+t.y*d;return new n(m,f)}static Hermite1stDerivative(e,r,i,t,o){return this.Hermite1stDerivativeToRef(e,r,i,t,o,new n)}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a.x=(s-o)*6*e.x+(3*s-4*o+1)*r.x+(-s+o)*6*i.x+(3*s-2*o)*t.x,a.y=(s-o)*6*e.y+(3*s-4*o+1)*r.y+(-s+o)*6*i.y+(3*s-2*o)*t.y,a}static Lerp(e,r,i){return n.LerpToRef(e,r,i,new n)}static LerpToRef(e,r,i,t){return t.x=e.x+(r.x-e.x)*i,t.y=e.y+(r.y-e.y)*i,t}static Dot(e,r){return e.x*r.x+e.y*r.y}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Minimize(e,r){let i=e.x<r.x?e.x:r.x,t=e.y<r.y?e.y:r.y;return new n(i,t)}static Maximize(e,r){let i=e.x>r.x?e.x:r.x,t=e.y>r.y?e.y:r.y;return new n(i,t)}static Transform(e,r){return n.TransformToRef(e,r,new n)}static TransformToRef(e,r,i){let t=r.m,o=e.x*t[0]+e.y*t[4]+t[12],a=e.x*t[1]+e.y*t[5]+t[13];return i.x=o,i.y=a,i}static PointInTriangle(e,r,i,t){let o=.5*(-i.y*t.x+r.y*(-i.x+t.x)+r.x*(i.y-t.y)+i.x*t.y),a=o<0?-1:1,s=(r.y*t.x-r.x*t.y+(t.y-r.y)*e.x+(r.x-t.x)*e.y)*a,c=(r.x*i.y-r.y*i.x+(r.y-i.y)*e.x+(i.x-r.x)*e.y)*a;return s>0&&c>0&&s+c<2*o*a}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y;return i*i+t*t}static Center(e,r){return n.CenterToRef(e,r,new n)}static CenterToRef(e,r,i){return i.copyFromFloats((e.x+r.x)/2,(e.y+r.y)/2)}static DistanceOfPointFromSegment(e,r,i){let t=n.DistanceSquared(r,i);if(t===0)return n.Distance(e,r);let o=i.subtract(r),a=Math.max(0,Math.min(1,n.Dot(e.subtract(r),o)/t)),s=r.add(o.multiplyByFloats(a,a));return n.Distance(e,s)}};We._V8PerformanceHack=new We(.5,.5);We._ZeroReadOnly=We.Zero();var R=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,r=0,i=0){this._isDirty=!0,this._x=e,this._y=r,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=e;return t=t*397^r,t=t*397^i,t}asArray(){return[this._x,this._y,this._z]}toArray(e,r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}toQuaternion(){return ue.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,r,i){return this._x+=e,this._y+=r,this._z+=i,this._isDirty=!0,this}add(e){return new n(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,r){return r._x=this._x+e._x,r._y=this._y+e._y,r._z=this._z+e._z,r._isDirty=!0,r}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new n(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,r){return this.subtractFromFloatsToRef(e._x,e._y,e._z,r)}subtractFromFloats(e,r,i){return new n(this._x-e,this._y-r,this._z-i)}subtractFromFloatsToRef(e,r,i,t){return t._x=this._x-e,t._y=this._y-r,t._z=this._z-i,t._isDirty=!0,t}negate(){return new n(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=this._x*-1,e._y=this._y*-1,e._z=this._z*-1,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new n(this._x*e,this._y*e,this._z*e)}scaleToRef(e,r){return r._x=this._x*e,r._y=this._y*e,r._z=this._z*e,r._isDirty=!0,r}getNormalToRef(e){let r=this.length(),i=Math.acos(this._y/r),t=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;let o=r*Math.sin(i)*Math.cos(t),a=r*Math.cos(i),s=r*Math.sin(i)*Math.sin(t);return e.set(o,a,s),e}applyRotationQuaternionToRef(e,r){let i=this._x,t=this._y,o=this._z,a=e._x,s=e._y,c=e._z,u=e._w,l=2*(s*o-c*t),d=2*(c*i-a*o),m=2*(a*t-s*i);return r._x=i+u*l+s*m-c*d,r._y=t+u*d+c*l-a*m,r._z=o+u*m+a*d-s*l,r._isDirty=!0,r}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new n)}scaleAndAddToRef(e,r){return r._x+=this._x*e,r._y+=this._y*e,r._z+=this._z*e,r._isDirty=!0,r}projectOnPlane(e,r){return this.projectOnPlaneToRef(e,r,new n)}projectOnPlaneToRef(e,r,i){let t=e.normal,o=e.d,a=w.Vector3[0];this.subtractToRef(r,a),a.normalize();let s=n.Dot(a,t);if(Math.abs(s)<1e-10)i.setAll(1/0);else{let c=-(n.Dot(r,t)+o)/s,u=a.scaleInPlace(c);r.addToRef(u,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)}equalsToFloats(e,r,i){return this._x===e&&this._y===r&&this._z===i}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,r){return r._x=this._x*e._x,r._y=this._y*e._y,r._z=this._z*e._z,r._isDirty=!0,r}multiplyByFloats(e,r,i){return new n(this._x*e,this._y*r,this._z*i)}divide(e){return new n(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,r){return r._x=this._x/e._x,r._y=this._y/e._y,r._z=this._z/e._z,r._isDirty=!0,r}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,r,i){return e<this._x&&(this.x=e),r<this._y&&(this.y=r),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,r,i){return e>this._x&&(this.x=e),r>this._y&&(this.y=r),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){let r=Math.abs(this._x),i=Math.abs(this._y);if(!X(r,i,e))return!0;let t=Math.abs(this._z);return!X(r,t,e)||!X(i,t,e)}get isNonUniform(){let e=Math.abs(this._x),r=Math.abs(this._y);if(e!==r)return!0;let i=Math.abs(this._z);return e!==i}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new n(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fractToRef(e){return e._x=this._x-Math.floor(this._x),e._y=this._y-Math.floor(this._y),e._z=this._z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new n(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z===0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if(e=e.toLowerCase(),e==="xyz")return this;let r=w.Vector3[0].copyFrom(this);return this.x=r[e[0]],this.y=r[e[1]],this.z=r[e[2]],this}rotateByQuaternionToRef(e,r){return e.toRotationMatrix(w.Matrix[0]),n.TransformCoordinatesToRef(this,w.Matrix[0],r),r}rotateByQuaternionAroundPointToRef(e,r,i){return this.subtractToRef(r,w.Vector3[0]),w.Vector3[0].rotateByQuaternionToRef(e,w.Vector3[0]),r.addToRef(w.Vector3[0],i),i}cross(e){return n.CrossToRef(this,e,new n)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let r=this.length();return r===0||r===1?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/r,e)}clone(){return new n(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,r,i){return this._x=e,this._y=r,this._z=i,this._isDirty=!0,this}set(e,r,i){return this.copyFromFloats(e,r,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,r,i,t){let o=n.Dot(e,i),a=n.Dot(r,i);return(o-t)/(o-a)}static GetAngleBetweenVectors(e,r,i){let t=e.normalizeToRef(w.Vector3[1]),o=r.normalizeToRef(w.Vector3[2]),a=n.Dot(t,o);a=oe(a,-1,1);let s=Math.acos(a),c=w.Vector3[3];return n.CrossToRef(t,o,c),n.Dot(c,i)>0?isNaN(s)?0:s:isNaN(s)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,r,i){w.Vector3[0].copyFrom(e);let t=w.Vector3[0];w.Vector3[1].copyFrom(r);let o=w.Vector3[1];w.Vector3[2].copyFrom(i);let a=w.Vector3[2],s=w.Vector3[3],c=w.Vector3[4];t.normalize(),o.normalize(),a.normalize(),n.CrossToRef(a,t,s),n.CrossToRef(s,a,c);let u=Math.atan2(n.Dot(o,s),n.Dot(o,c));return pd(u)}static PitchYawRollToMoveBetweenPointsToRef(e,r,i){let t=Ie.Vector3[0];return r.subtractToRef(e,t),i._y=Math.atan2(t.x,t.z)||0,i._x=Math.atan2(Math.sqrt(t.x**2+t.z**2),t.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,r){let i=n.Zero();return n.PitchYawRollToMoveBetweenPointsToRef(e,r,i)}static SlerpToRef(e,r,i,t){i=oe(i,0,1);let o=w.Vector3[0],a=w.Vector3[1];o.copyFrom(e);let s=o.length();o.normalizeFromLength(s),a.copyFrom(r);let c=a.length();a.normalizeFromLength(c);let u=n.Dot(o,a),l,d;if(u<1-ce){let m=Math.acos(u),f=1/Math.sin(m);l=Math.sin((1-i)*m)*f,d=Math.sin(i*m)*f}else l=1-i,d=i;return o.scaleInPlace(l),a.scaleInPlace(d),t.copyFrom(o).addInPlace(a),t.scaleInPlace(fd(s,c,i)),t}static SmoothToRef(e,r,i,t,o){return n.SlerpToRef(e,r,t===0?1:i/t,o),o}static FromArray(e,r=0){return new n(e[r],e[r+1],e[r+2])}static FromFloatArray(e,r){return n.FromArray(e,r)}static FromArrayToRef(e,r,i){return i._x=e[r],i._y=e[r+1],i._z=e[r+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,r,i){return n.FromArrayToRef(e,r,i)}static FromFloatsToRef(e,r,i,t){return t.copyFromFloats(e,r,i),t}static Zero(){return new n(0,0,0)}static One(){return new n(1,1,1)}static Up(){return new n(0,1,0)}static get UpReadOnly(){return n._UpReadOnly}static get DownReadOnly(){return n._DownReadOnly}static get RightReadOnly(){return n._RightReadOnly}static get LeftReadOnly(){return n._LeftReadOnly}static get LeftHandedForwardReadOnly(){return n._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return n._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return n._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return n._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return n._ZeroReadOnly}static get OneReadOnly(){return n._OneReadOnly}static Down(){return new n(0,-1,0)}static Forward(e=!1){return new n(0,0,e?-1:1)}static Backward(e=!1){return new n(0,0,e?1:-1)}static Right(){return new n(1,0,0)}static Left(){return new n(-1,0,0)}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r),G(e,r))}static TransformCoordinates(e,r){let i=n.Zero();return n.TransformCoordinatesToRef(e,r,i),i}static TransformCoordinatesToRef(e,r,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformCoordinatesFromFloatsToRef(e,r,i,t,o){let a=t.m,s=e*a[0]+r*a[4]+i*a[8]+a[12],c=e*a[1]+r*a[5]+i*a[9]+a[13],u=e*a[2]+r*a[6]+i*a[10]+a[14],l=1/(e*a[3]+r*a[7]+i*a[11]+a[15]);return o._x=s*l,o._y=c*l,o._z=u*l,o._isDirty=!0,o}static TransformNormal(e,r){let i=n.Zero();return n.TransformNormalToRef(e,r,i),i}static TransformNormalToRef(e,r,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformNormalFromFloatsToRef(e,r,i,t,o){let a=t.m;return o._x=e*a[0]+r*a[4]+i*a[8],o._y=e*a[1]+r*a[5]+i*a[9],o._z=e*a[2]+r*a[6]+i*a[10],o._isDirty=!0,o}static CatmullRom(e,r,i,t,o){let a=o*o,s=o*a,c=.5*(2*r._x+(-e._x+i._x)*o+(2*e._x-5*r._x+4*i._x-t._x)*a+(-e._x+3*r._x-3*i._x+t._x)*s),u=.5*(2*r._y+(-e._y+i._y)*o+(2*e._y-5*r._y+4*i._y-t._y)*a+(-e._y+3*r._y-3*i._y+t._y)*s),l=.5*(2*r._z+(-e._z+i._z)*o+(2*e._z-5*r._z+4*i._z-t._z)*a+(-e._z+3*r._z-3*i._z+t._z)*s);return new n(c,u,l)}static Clamp(e,r,i){let t=new n;return n.ClampToRef(e,r,i,t),t}static ClampToRef(e,r,i,t){let o=e._x;o=o>i._x?i._x:o,o=o<r._x?r._x:o;let a=e._y;a=a>i._y?i._y:a,a=a<r._y?r._y:a;let s=e._z;return s=s>i._z?i._z:s,s=s<r._z?r._z:s,t.copyFromFloats(o,a,s),t}static CheckExtends(e,r,i){r.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e._x*c+i._x*u+r._x*l+t._x*d,f=e._y*c+i._y*u+r._y*l+t._y*d,h=e._z*c+i._z*u+r._z*l+t._z*d;return new n(m,f,h)}static Hermite1stDerivative(e,r,i,t,o){let a=new n;return this.Hermite1stDerivativeToRef(e,r,i,t,o,a),a}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a._x=(s-o)*6*e._x+(3*s-4*o+1)*r._x+(-s+o)*6*i._x+(3*s-2*o)*t._x,a._y=(s-o)*6*e._y+(3*s-4*o+1)*r._y+(-s+o)*6*i._y+(3*s-2*o)*t._y,a._z=(s-o)*6*e._z+(3*s-4*o+1)*r._z+(-s+o)*6*i._z+(3*s-2*o)*t._z,a._isDirty=!0,a}static Lerp(e,r,i){let t=new n(0,0,0);return n.LerpToRef(e,r,i,t),t}static LerpToRef(e,r,i,t){return t._x=e._x+(r._x-e._x)*i,t._y=e._y+(r._y-e._y)*i,t._z=e._z+(r._z-e._z)*i,t._isDirty=!0,t}static Dot(e,r){return e._x*r._x+e._y*r._y+e._z*r._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,r){let i=new n;return n.CrossToRef(e,r,i),i}static CrossToRef(e,r,i){let t=e._y*r._z-e._z*r._y,o=e._z*r._x-e._x*r._z,a=e._x*r._y-e._y*r._x;return i.copyFromFloats(t,o,a),i}static Normalize(e){let r=n.Zero();return n.NormalizeToRef(e,r),r}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Project(e,r,i,t){let o=new n;return n.ProjectToRef(e,r,i,t,o),o}static ProjectToRef(e,r,i,t,o){let a=t.width,s=t.height,c=t.x,u=t.y,l=w.Matrix[1],d=Le.LastCreatedEngine?.isNDCHalfZRange,m=d?1:.5,f=d?0:.5;me.FromValuesToRef(a/2,0,0,0,0,-s/2,0,0,0,0,m,0,c+a/2,s/2+u,f,1,l);let h=w.Matrix[0];return r.multiplyToRef(i,h),h.multiplyToRef(l,h),n.TransformCoordinatesToRef(e,h,o),o}static Reflect(e,r){return this.ReflectToRef(e,r,new n)}static ReflectToRef(e,r,i){let t=Ie.Vector3[0];return t.copyFrom(r).scaleInPlace(2*n.Dot(e,r)),i.copyFrom(e).subtractInPlace(t)}static UnprojectFromTransform(e,r,i,t,o){return this.Unproject(e,r,i,t,o,me.IdentityReadOnly)}static Unproject(e,r,i,t,o,a){let s=new n;return n.UnprojectToRef(e,r,i,t,o,a,s),s}static UnprojectToRef(e,r,i,t,o,a,s){return n.UnprojectFloatsToRef(e._x,e._y,e._z,r,i,t,o,a,s),s}static UnprojectFloatsToRef(e,r,i,t,o,a,s,c,u){let l=w.Matrix[0];a.multiplyToRef(s,l),l.multiplyToRef(c,l),l.invert();let d=w.Vector3[0];return d.x=e/t*2-1,d.y=-(r/o*2-1),Le.LastCreatedEngine?.isNDCHalfZRange?d.z=i:d.z=2*i-1,n.TransformCoordinatesToRef(d,l,u),u}static Minimize(e,r){let i=new n;return i.copyFrom(e),i.minimizeInPlace(r),i}static Maximize(e,r){let i=new n;return i.copyFrom(e),i.maximizeInPlace(r),i}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e._x-r._x,t=e._y-r._y,o=e._z-r._z;return i*i+t*t+o*o}static ProjectOnTriangleToRef(e,r,i,t,o){let a=w.Vector3[0],s=w.Vector3[1],c=w.Vector3[2],u=w.Vector3[3],l=w.Vector3[4];i.subtractToRef(r,a),t.subtractToRef(r,s),t.subtractToRef(i,c);let d=a.length(),m=s.length(),f=c.length();if(d<ce||m<ce||f<ce)return o.copyFrom(r),n.Distance(e,r);e.subtractToRef(r,l),n.CrossToRef(a,s,u);let h=u.length();if(h<ce)return o.copyFrom(r),n.Distance(e,r);u.normalizeFromLength(h);let _=l.length();if(_<ce)return o.copyFrom(r),0;l.normalizeFromLength(_);let z=n.Dot(u,l),P=w.Vector3[5],x=w.Vector3[6];P.copyFrom(u).scaleInPlace(-_*z),x.copyFrom(e).addInPlace(P);let T=w.Vector3[4],D=w.Vector3[5],A=w.Vector3[7],S=w.Vector3[8];T.copyFrom(a).scaleInPlace(1/d),S.copyFrom(s).scaleInPlace(1/m),T.addInPlace(S).scaleInPlace(-1),D.copyFrom(a).scaleInPlace(-1/d),S.copyFrom(c).scaleInPlace(1/f),D.addInPlace(S).scaleInPlace(-1),A.copyFrom(c).scaleInPlace(-1/f),S.copyFrom(s).scaleInPlace(-1/m),A.addInPlace(S).scaleInPlace(-1);let Z=w.Vector3[9],K;Z.copyFrom(x).subtractInPlace(r),n.CrossToRef(T,Z,S),K=n.Dot(S,u);let ge=K;Z.copyFrom(x).subtractInPlace(i),n.CrossToRef(D,Z,S),K=n.Dot(S,u);let le=K;Z.copyFrom(x).subtractInPlace(t),n.CrossToRef(A,Z,S),K=n.Dot(S,u);let ve=K,re=w.Vector3[10],te,H;ge>0&&le<0?(re.copyFrom(a),te=r,H=i):le>0&&ve<0?(re.copyFrom(c),te=i,H=t):(re.copyFrom(s).scaleInPlace(-1),te=t,H=r);let Ce=w.Vector3[9],Ue=w.Vector3[4];if(te.subtractToRef(x,S),H.subtractToRef(x,Ce),n.CrossToRef(S,Ce,Ue),!(n.Dot(Ue,u)<0))return o.copyFrom(x),Math.abs(_*z);let De=w.Vector3[5];n.CrossToRef(re,Ue,De),De.normalize();let Oe=w.Vector3[9];Oe.copyFrom(te).subtractInPlace(x);let Ne=Oe.length();if(Ne<ce)return o.copyFrom(te),n.Distance(e,te);Oe.normalizeFromLength(Ne);let qe=n.Dot(De,Oe),Qe=w.Vector3[7];Qe.copyFrom(x).addInPlace(De.scaleInPlace(Ne*qe)),S.copyFrom(Qe).subtractInPlace(te),_=re.length(),re.normalizeFromLength(_);let Ot=n.Dot(S,re)/Math.max(_,ce);return Ot=oe(Ot,0,1),Qe.copyFrom(te).addInPlace(re.scaleInPlace(Ot*_)),o.copyFrom(Qe),n.Distance(e,Qe)}static Center(e,r){return n.CenterToRef(e,r,n.Zero())}static CenterToRef(e,r,i){return i.copyFromFloats((e._x+r._x)/2,(e._y+r._y)/2,(e._z+r._z)/2)}static RotationFromAxis(e,r,i){let t=new n;return n.RotationFromAxisToRef(e,r,i,t),t}static RotationFromAxisToRef(e,r,i,t){let o=w.Quaternion[0];return ue.RotationQuaternionFromAxisToRef(e,r,i,o),o.toEulerAnglesToRef(t),t}};R._V8PerformanceHack=new R(.5,.5,.5);R._UpReadOnly=R.Up();R._DownReadOnly=R.Down();R._LeftHandedForwardReadOnly=R.Forward(!1);R._RightHandedForwardReadOnly=R.Forward(!0);R._LeftHandedBackwardReadOnly=R.Backward(!1);R._RightHandedBackwardReadOnly=R.Backward(!0);R._RightReadOnly=R.Right();R._LeftReadOnly=R.Left();R._ZeroReadOnly=R.Zero();R._OneReadOnly=R.One();var Me=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,r=0,i=0,t=0){this._isDirty=!0,this._x=e,this._y=r,this._z=i,this._w=t}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=de(this._w),o=e;return o=o*397^r,o=o*397^i,o=o*397^t,o}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,r){return r===void 0&&(r=0),e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}addInPlace(e){return this.x+=e._x,this.y+=e._y,this.z+=e._z,this.w+=e._w,this}addInPlaceFromFloats(e,r,i,t){return this.x+=e,this.y+=r,this.z+=i,this.w+=t,this}add(e){return new n(this._x+e.x,this._y+e.y,this._z+e.z,this._w+e.w)}addToRef(e,r){return r.x=this._x+e.x,r.y=this._y+e.y,r.z=this._z+e.z,r.w=this._w+e.w,r}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new n(this._x-e.x,this._y-e.y,this._z-e.z,this._w-e.w)}subtractToRef(e,r){return r.x=this._x-e.x,r.y=this._y-e.y,r.z=this._z-e.z,r.w=this._w-e.w,r}subtractFromFloats(e,r,i,t){return new n(this._x-e,this._y-r,this._z-i,this._w-t)}subtractFromFloatsToRef(e,r,i,t,o){return o.x=this._x-e,o.y=this._y-r,o.z=this._z-i,o.w=this._w-t,o}negate(){return new n(-this._x,-this._y,-this._z,-this._w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this._x,e.y=-this._y,e.z=-this._z,e.w=-this._w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new n(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,r){return r.x=this._x*e,r.y=this._y*e,r.z=this._z*e,r.w=this._w*e,r}scaleAndAddToRef(e,r){return r.x+=this._x*e,r.y+=this._y*e,r.z+=this._z*e,r.w+=this._w*e,r}equals(e){return e&&this._x===e.x&&this._y===e.y&&this._z===e.z&&this._w===e.w}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e.x,r)&&X(this._y,e.y,r)&&X(this._z,e.z,r)&&X(this._w,e.w,r)}equalsToFloats(e,r,i,t){return this._x===e&&this._y===r&&this._z===i&&this._w===t}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new n(this._x*e.x,this._y*e.y,this._z*e.z,this._w*e.w)}multiplyToRef(e,r){return r.x=this._x*e.x,r.y=this._y*e.y,r.z=this._z*e.z,r.w=this._w*e.w,r}multiplyByFloats(e,r,i,t){return new n(this._x*e,this._y*r,this._z*i,this._w*t)}divide(e){return new n(this._x/e.x,this._y/e.y,this._z/e.z,this._w/e.w)}divideToRef(e,r){return r.x=this._x/e.x,r.y=this._y/e.y,r.z=this._z/e.z,r.w=this._w/e.w,r}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this._x&&(this.x=e.x),e.y<this._y&&(this.y=e.y),e.z<this._z&&(this.z=e.z),e.w<this._w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this._x&&(this.x=e.x),e.y>this._y&&(this.y=e.y),e.z>this._z&&(this.z=e.z),e.w>this._w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,r,i,t){return this.x=Math.min(e,this._x),this.y=Math.min(r,this._y),this.z=Math.min(i,this._z),this.w=Math.min(t,this._w),this}maximizeInPlaceFromFloats(e,r,i,t){return this.x=Math.max(e,this._x),this.y=Math.max(r,this._y),this.z=Math.max(i,this._z),this.w=Math.max(t,this._w),this}floorToRef(e){return e.x=Math.floor(this._x),e.y=Math.floor(this._y),e.z=Math.floor(this._z),e.w=Math.floor(this._w),e}floor(){return new n(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),Math.floor(this._w))}fractToRef(e){return e.x=this._x-Math.floor(this._x),e.y=this._y-Math.floor(this._y),e.z=this._z-Math.floor(this._z),e.w=this._w-Math.floor(this._w),e}fract(){return new n(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z),this._w-Math.floor(this._w))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let r=this.length();return r===0||r===1?(e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e):this.scaleToRef(1/r,e)}toVector3(){return new R(this._x,this._y,this._z)}clone(){return new n(this._x,this._y,this._z,this._w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,r,i,t){return this.x=e,this.y=r,this.z=i,this.w=t,this}set(e,r,i,t){return this.copyFromFloats(e,r,i,t)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z+this._w*e.w}static FromArray(e,r){return r||(r=0),new n(e[r],e[r+1],e[r+2],e[r+3])}static FromArrayToRef(e,r,i){return i.x=e[r],i.y=e[r+1],i.z=e[r+2],i.w=e[r+3],i}static FromFloatArrayToRef(e,r,i){return n.FromArrayToRef(e,r,i),i}static FromFloatsToRef(e,r,i,t,o){return o.x=e,o.y=r,o.z=i,o.w=t,o}static Zero(){return new n(0,0,0,0)}static One(){return new n(1,1,1,1)}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.x=G(e,r),i.y=G(e,r),i.z=G(e,r),i.w=G(e,r),i}static Clamp(e,r,i){return n.ClampToRef(e,r,i,new n)}static ClampToRef(e,r,i,t){return t.x=oe(e.x,r.x,i.x),t.y=oe(e.y,r.y,i.y),t.z=oe(e.z,r.z,i.z),t.w=oe(e.w,r.w,i.w),t}static CheckExtends(e,r,i){r.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return n._ZeroReadOnly}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Minimize(e,r){let i=new n;return i.copyFrom(e),i.minimizeInPlace(r),i}static Maximize(e,r){let i=new n;return i.copyFrom(e),i.maximizeInPlace(r),i}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y,o=e.z-r.z,a=e.w-r.w;return i*i+t*t+o*o+a*a}static Center(e,r){return n.CenterToRef(e,r,new n)}static CenterToRef(e,r,i){return i.x=(e.x+r.x)/2,i.y=(e.y+r.y)/2,i.z=(e.z+r.z)/2,i.w=(e.w+r.w)/2,i}static TransformCoordinates(e,r){return n.TransformCoordinatesToRef(e,r,new n)}static TransformCoordinatesToRef(e,r,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformCoordinatesFromFloatsToRef(e,r,i,t,o){let a=t.m,s=e*a[0]+r*a[4]+i*a[8]+a[12],c=e*a[1]+r*a[5]+i*a[9]+a[13],u=e*a[2]+r*a[6]+i*a[10]+a[14],l=e*a[3]+r*a[7]+i*a[11]+a[15];return o.x=s,o.y=c,o.z=u,o.w=l,o}static TransformNormal(e,r){return n.TransformNormalToRef(e,r,new n)}static TransformNormalToRef(e,r,i){let t=r.m,o=e.x*t[0]+e.y*t[4]+e.z*t[8],a=e.x*t[1]+e.y*t[5]+e.z*t[9],s=e.x*t[2]+e.y*t[6]+e.z*t[10];return i.x=o,i.y=a,i.z=s,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,r,i,t,o,a){let s=o.m;return a.x=e*s[0]+r*s[4]+i*s[8],a.y=e*s[1]+r*s[5]+i*s[9],a.z=e*s[2]+r*s[6]+i*s[10],a.w=t,a}static FromVector3(e,r=0){return new n(e._x,e._y,e._z,r)}static Dot(e,r){return e.x*r.x+e.y*r.y+e.z*r.z+e.w*r.w}};Me._V8PerformanceHack=new Me(.5,.5,.5,.5);Me._ZeroReadOnly=Me.Zero();var ue=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,r=0,i=0,t=1){this._isDirty=!0,this._x=e,this._y=r,this._z=i,this._w=t}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=de(this._w),o=e;return o=o*397^r,o=o*397^i,o=o*397^t,o}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this)}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)&&X(this._w,e._w,r)}isApprox(e,r=ce){return e&&(X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)&&X(this._w,e._w,r)||X(this._x,-e._x,r)&&X(this._y,-e._y,r)&&X(this._z,-e._z,r)&&X(this._w,-e._w,r))}clone(){return new n(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,r,i,t){return this._x=e,this._y=r,this._z=i,this._w=t,this._isDirty=!0,this}set(e,r,i,t){return this.copyFromFloats(e,r,i,t)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new n(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}addToRef(e,r){return r._x=this._x+e._x,r._y=this._y+e._y,r._z=this._z+e._z,r._w=this._w+e._w,r._isDirty=!0,r}addInPlaceFromFloats(e,r,i,t){return this._x+=e,this._y+=r,this._z+=i,this._w+=t,this._isDirty=!0,this}subtractToRef(e,r){return r._x=this._x-e._x,r._y=this._y-e._y,r._z=this._z-e._z,r._w=this._w-e._w,r._isDirty=!0,r}subtractFromFloats(e,r,i,t){return this.subtractFromFloatsToRef(e,r,i,t,new n)}subtractFromFloatsToRef(e,r,i,t,o){return o._x=this._x-e,o._y=this._y-r,o._z=this._z-i,o._w=this._w-t,o._isDirty=!0,o}subtract(e){return new n(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new n(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,r){return r._x=this._x*e,r._y=this._y*e,r._z=this._z*e,r._w=this._w*e,r._isDirty=!0,r}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}scaleAndAddToRef(e,r){return r._x+=this._x*e,r._y+=this._y*e,r._z+=this._z*e,r._w+=this._w*e,r._isDirty=!0,r}multiply(e){let r=new n(0,0,0,1);return this.multiplyToRef(e,r),r}multiplyToRef(e,r){let i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,t=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,o=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,a=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return r.copyFromFloats(i,t,o,a),r}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,r,i,t){return this._x*=e,this._y*=r,this._z*=i,this._w*=t,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,r){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new n)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,r,i,t){return this._x===e&&this._y===r&&this._z===i&&this._w===t}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new n(-this._x,-this._y,-this._z,this._w)}invert(){let e=this.conjugate(),r=this.lengthSquared();return r==0||r==1||e.scaleInPlace(1/r),e}invertInPlace(){this.conjugateInPlace();let e=this.lengthSquared();return e==0||e==1?this:(this.scaleInPlace(1/e),this)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){let r=this.length();return r===0||r===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/r,e)}toEulerAngles(){let e=R.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){let r=this._z,i=this._x,t=this._y,o=this._w,a=t*r-i*o,s=.4999999;if(a<-s)e._y=2*Math.atan2(t,o),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>s)e._y=2*Math.atan2(t,o),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{let c=o*o,u=r*r,l=i*i,d=t*t;e._z=Math.atan2(2*(i*t+r*o),-u-l+d+c),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(r*i+t*o),u-l-d+c),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){let r=this._z,i=this._x,t=this._y,o=this._w,a=Math.sqrt(i*i+t*t),s=Math.sqrt(r*r+o*o),c=2*Math.atan2(a,s),u=2*Math.atan2(r,o),l=2*Math.atan2(t,i),d=(u+l)/2,m=(u-l)/2;return e.set(m,c,d),e}toRotationMatrix(e){return me.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return n.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){let e=R.Zero(),r=this.toAxisAngleToRef(e);return{axis:e,angle:r}}toAxisAngleToRef(e){let r,i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),t=this._w;return i>0?(r=2*Math.atan2(i,t),e.set(this._x/i,this._y/i,this._z/i)):(r=0,e.set(1,0,0)),r}static FromRotationMatrix(e){let r=new n;return n.FromRotationMatrixToRef(e,r),r}static FromRotationMatrixToRef(e,r){let i=e.m,t=i[0],o=i[4],a=i[8],s=i[1],c=i[5],u=i[9],l=i[2],d=i[6],m=i[10],f=t+c+m,h;return f>0?(h=.5/Math.sqrt(f+1),r._w=.25/h,r._x=(d-u)*h,r._y=(a-l)*h,r._z=(s-o)*h,r._isDirty=!0):t>c&&t>m?(h=2*Math.sqrt(1+t-c-m),r._w=(d-u)/h,r._x=.25*h,r._y=(o+s)/h,r._z=(a+l)/h,r._isDirty=!0):c>m?(h=2*Math.sqrt(1+c-t-m),r._w=(a-l)/h,r._x=(o+s)/h,r._y=.25*h,r._z=(u+d)/h,r._isDirty=!0):(h=2*Math.sqrt(1+m-t-c),r._w=(s-o)/h,r._x=(a+l)/h,r._y=(u+d)/h,r._z=.25*h,r._isDirty=!0),r}static Dot(e,r){return e._x*r._x+e._y*r._y+e._z*r._z+e._w*r._w}static AreClose(e,r,i=.1){let t=n.Dot(e,r);return 1-t*t<=i}static SmoothToRef(e,r,i,t,o){let a=t===0?1:i/t;return a=oe(a,0,1),n.SlerpToRef(e,r,a,o),o}static Zero(){return new n(0,0,0,0)}static Inverse(e){return new n(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,r){return r.set(-e._x,-e._y,-e._z,e._w),r}static Identity(){return new n(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,r){return n.RotationAxisToRef(e,r,new n)}static RotationAxisToRef(e,r,i){i._w=Math.cos(r/2);let t=Math.sin(r/2)/e.length();return i._x=e._x*t,i._y=e._y*t,i._z=e._z*t,i._isDirty=!0,i}static FromArray(e,r){return r||(r=0),new n(e[r],e[r+1],e[r+2],e[r+3])}static FromArrayToRef(e,r,i){return i._x=e[r],i._y=e[r+1],i._z=e[r+2],i._w=e[r+3],i._isDirty=!0,i}static FromFloatsToRef(e,r,i,t,o){return o.copyFromFloats(e,r,i,t),o}static FromEulerAngles(e,r,i){let t=new n;return n.RotationYawPitchRollToRef(r,e,i,t),t}static FromEulerAnglesToRef(e,r,i,t){return n.RotationYawPitchRollToRef(r,e,i,t),t}static FromEulerVector(e){let r=new n;return n.RotationYawPitchRollToRef(e._y,e._x,e._z,r),r}static FromEulerVectorToRef(e,r){return n.RotationYawPitchRollToRef(e._y,e._x,e._z,r),r}static FromUnitVectorsToRef(e,r,i,t=ce){let o=R.Dot(e,r)+1;return o<t?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(R.CrossToRef(e,r,Ie.Vector3[0]),i.set(Ie.Vector3[0].x,Ie.Vector3[0].y,Ie.Vector3[0].z,o)),i.normalize()}static RotationYawPitchRoll(e,r,i){let t=new n;return n.RotationYawPitchRollToRef(e,r,i,t),t}static RotationYawPitchRollToRef(e,r,i,t){let o=i*.5,a=r*.5,s=e*.5,c=Math.sin(o),u=Math.cos(o),l=Math.sin(a),d=Math.cos(a),m=Math.sin(s),f=Math.cos(s);return t._x=f*l*u+m*d*c,t._y=m*d*u-f*l*c,t._z=f*d*c-m*l*u,t._w=f*d*u+m*l*c,t._isDirty=!0,t}static RotationAlphaBetaGamma(e,r,i){let t=new n;return n.RotationAlphaBetaGammaToRef(e,r,i,t),t}static RotationAlphaBetaGammaToRef(e,r,i,t){let o=(i+e)*.5,a=(i-e)*.5,s=r*.5;return t._x=Math.cos(a)*Math.sin(s),t._y=Math.sin(a)*Math.sin(s),t._z=Math.sin(o)*Math.cos(s),t._w=Math.cos(o)*Math.cos(s),t._isDirty=!0,t}static RotationQuaternionFromAxis(e,r,i){let t=new n(0,0,0,0);return n.RotationQuaternionFromAxisToRef(e,r,i,t),t}static RotationQuaternionFromAxisToRef(e,r,i,t){let o=w.Matrix[0];return e=e.normalizeToRef(w.Vector3[0]),r=r.normalizeToRef(w.Vector3[1]),i=i.normalizeToRef(w.Vector3[2]),me.FromXYZAxesToRef(e,r,i,o),n.FromRotationMatrixToRef(o,t),t}static FromLookDirectionLH(e,r){let i=new n;return n.FromLookDirectionLHToRef(e,r,i),i}static FromLookDirectionLHToRef(e,r,i){let t=w.Matrix[0];return me.LookDirectionLHToRef(e,r,t),n.FromRotationMatrixToRef(t,i),i}static FromLookDirectionRH(e,r){let i=new n;return n.FromLookDirectionRHToRef(e,r,i),i}static FromLookDirectionRHToRef(e,r,i){let t=w.Matrix[0];return me.LookDirectionRHToRef(e,r,t),n.FromRotationMatrixToRef(t,i)}static Slerp(e,r,i){let t=n.Identity();return n.SlerpToRef(e,r,i,t),t}static SlerpToRef(e,r,i,t){let o,a,s=e._x*r._x+e._y*r._y+e._z*r._z+e._w*r._w,c=!1;if(s<0&&(c=!0,s=-s),s>.999999)a=1-i,o=c?-i:i;else{let u=Math.acos(s),l=1/Math.sin(u);a=Math.sin((1-i)*u)*l,o=c?-Math.sin(i*u)*l:Math.sin(i*u)*l}return t._x=a*e._x+o*r._x,t._y=a*e._y+o*r._y,t._z=a*e._z+o*r._z,t._w=a*e._w+o*r._w,t._isDirty=!0,t}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e._x*c+i._x*u+r._x*l+t._x*d,f=e._y*c+i._y*u+r._y*l+t._y*d,h=e._z*c+i._z*u+r._z*l+t._z*d,_=e._w*c+i._w*u+r._w*l+t._w*d;return new n(m,f,h,_)}static Hermite1stDerivative(e,r,i,t,o){let a=new n;return this.Hermite1stDerivativeToRef(e,r,i,t,o,a),a}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a._x=(s-o)*6*e._x+(3*s-4*o+1)*r._x+(-s+o)*6*i._x+(3*s-2*o)*t._x,a._y=(s-o)*6*e._y+(3*s-4*o+1)*r._y+(-s+o)*6*i._y+(3*s-2*o)*t._y,a._z=(s-o)*6*e._z+(3*s-4*o+1)*r._z+(-s+o)*6*i._z+(3*s-2*o)*t._z,a._w=(s-o)*6*e._w+(3*s-4*o+1)*r._w+(-s+o)*6*i._w+(3*s-2*o)*t._w,a._isDirty=!0,a}static Normalize(e){let r=n.Zero();return n.NormalizeToRef(e,r),r}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Clamp(e,r,i){let t=new n;return n.ClampToRef(e,r,i,t),t}static ClampToRef(e,r,i,t){return t.copyFromFloats(oe(e.x,r.x,i.x),oe(e.y,r.y,i.y),oe(e.z,r.z,i.z),oe(e.w,r.w,i.w))}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r),G(e,r),G(e,r))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y,o=e.z-r.z,a=e.w-r.w;return i*i+t*t+o*o+a*a}static Center(e,r){return n.CenterToRef(e,r,n.Zero())}static CenterToRef(e,r,i){return i.copyFromFloats((e.x+r.x)/2,(e.y+r.y)/2,(e.z+r.z)/2,(e.w+r.w)/2)}};ue._V8PerformanceHack=new ue(.5,.5,.5,.5);var me=class n{static get Use64Bits(){return ke.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=gn._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,r=!1,i=!1,t=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:r,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:t}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,ke.MatrixTrackPrecisionChange&&ke.MatrixTrackedMatrices.push(this),this._m=new ke.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;let e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1:this._m[1]!==0||this._m[2]!==0||this._m[3]!==0||this._m[4]!==0||this._m[6]!==0||this._m[7]!==0||this._m[8]!==0||this._m[9]!==0||this._m[10]!==0||this._m[11]!==0||this._m[12]!==0||this._m[13]!==0||this._m[14]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)return 1;let e=this._m,r=e[0],i=e[1],t=e[2],o=e[3],a=e[4],s=e[5],c=e[6],u=e[7],l=e[8],d=e[9],m=e[10],f=e[11],h=e[12],_=e[13],z=e[14],P=e[15],x=m*P-z*f,T=d*P-_*f,D=d*z-_*m,A=l*P-h*f,S=l*z-m*h,Z=l*_-h*d,K=+(s*x-c*T+u*D),ge=-(a*x-c*A+u*S),le=+(a*T-s*A+u*Z),ve=-(a*D-s*S+c*Z);return r*K+i*ge+t*le+o*ve}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}
2
+ "use strict";var UptimizrReplay=(()=>{var _o=Object.defineProperty;var Jh=Object.getOwnPropertyDescriptor;var Kh=Object.getOwnPropertyNames;var qh=Object.prototype.hasOwnProperty;var Fe=(n,e)=>{for(var r in e)_o(n,r,{get:e[r],enumerable:!0})},Gh=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of Kh(e))!qh.call(n,t)&&t!==r&&_o(n,t,{get:()=>e[t],enumerable:!(i=Jh(e,t))||i.enumerable});return n};var Wh=n=>Gh(_o({},"__esModule",{value:!0}),n);var V$={};Fe(V$,{ReplayPlayer:()=>sr,createBabylonReplayDriver:()=>xo,fetchSessionEvents:()=>Rh,fetchSessionEventsStream:()=>ud,replayInScene:()=>F$});var J$=(1+Math.sqrt(5))/2,ce=.001;function Hh(n,e){let r=[];for(let i=0;i<n;++i)r.push(e());return r}function Ge(n,e){return Hh(n,e)}var ke=class n{static SetMatrixPrecision(e){if(n.MatrixTrackPrecisionChange=!1,e&&!n.MatrixUse64Bits&&n.MatrixTrackedMatrices)for(let r=0;r<n.MatrixTrackedMatrices.length;++r){let i=n.MatrixTrackedMatrices[r],t=i._m;i._m=new Array(16);for(let o=0;o<16;++o)i._m[o]=t[o]}n.MatrixUse64Bits=e,n.MatrixCurrentType=n.MatrixUse64Bits?Array:Float32Array,n.MatrixTrackedMatrices=null}};ke.MatrixUse64Bits=!1;ke.MatrixTrackPrecisionChange=!0;ke.MatrixCurrentType=Float32Array;ke.MatrixTrackedMatrices=[];var Xh=typeof WeakRef<"u",yo=class{constructor(e,r=!1,i,t){this.initialize(e,r,i,t)}initialize(e,r=!1,i,t){return this.mask=e,this.skipNextObservers=r,this.target=i,this.currentTarget=t,this}},$o=class{constructor(e,r,i=null){this.callback=e,this.mask=r,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}},cr=class n{static FromPromise(e,r){let i=new n;return e.then(t=>{i.notifyObservers(t)}).catch(t=>{if(r)r.notifyObservers(t);else throw t}),i}get observers(){return this._observers}constructor(e,r=!1){this.notifyIfTriggered=r,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new yo(0),e&&(this._onObserverAdded=e)}add(e,r=-1,i=!1,t=null,o=!1){if(!e)return null;let a=new $o(e,r,t);a.unregisterOnNextCall=o,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&this.notifyObserver(a,this._lastNotifiedValue);let s=Xh?new WeakRef(this):{deref:()=>this};return a._remove=(c=!1)=>{let u=s.deref();u&&(c?u.remove(a):u._remove(a))},a}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}removeCallback(e,r){for(let i=0;i<this._observers.length;i++){let t=this._observers[i];if(!t._willBeUnregistered&&t.callback===e&&(!r||r===t.scope))return this._deferUnregister(t),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0))}_remove(e,r=!0){if(!e)return!1;let i=this._observers.indexOf(e);return i!==-1?(r&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,r=-1,i,t,o){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;let a=this._eventState;a.mask=r,a.target=i,a.currentTarget=t,a.skipNextObservers=!1,a.lastReturnValue=e,a.userInfo=o;for(let s of this._observers)if(!s._willBeUnregistered&&(s.mask&r&&(s.unregisterOnNextCall&&this._deferUnregister(s),s.scope?a.lastReturnValue=s.callback.apply(s.scope,[e,a]):a.lastReturnValue=s.callback(e,a)),a.skipNextObservers))return!1;return!0}notifyObserver(e,r,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=r),e._willBeUnregistered)return;let t=this._eventState;t.mask=i,t.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(r,t)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){let e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){let e=new n;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(let r of this._observers)if(r.mask&e||r.mask===e)return!0;return!1}};var Le=class{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}};Le.Instances=[];Le.OnEnginesDisposedObservable=new cr;Le._LastCreatedScene=null;Le.UseFallbackTexture=!0;Le.FallbackTexture="";function X(n,e,r=1401298e-51){return Math.abs(n-e)<=r}function G(n,e){return n===e?n:Math.random()*(e-n)+n}function fd(n,e,r){return n+(e-n)*r}function oe(n,e=0,r=1){return Math.min(r,Math.max(e,n))}function pd(n){return n-=Math.PI*2*Math.floor((n+Math.PI)/(Math.PI*2)),n}var gn=class{};gn._UpdateFlagSeed=0;function hd(n,e,r,i=0){let t=n.asArray(),o=e.asArray(),a=t[0],s=t[1],c=t[2],u=t[3],l=t[4],d=t[5],m=t[6],f=t[7],h=t[8],_=t[9],z=t[10],P=t[11],x=t[12],T=t[13],D=t[14],A=t[15],S=o[0],Z=o[1],K=o[2],ge=o[3],le=o[4],ve=o[5],re=o[6],te=o[7],H=o[8],Ce=o[9],Ue=o[10],Ye=o[11],De=o[12],Oe=o[13],Ne=o[14],qe=o[15];r[i]=a*S+s*le+c*H+u*De,r[i+1]=a*Z+s*ve+c*Ce+u*Oe,r[i+2]=a*K+s*re+c*Ue+u*Ne,r[i+3]=a*ge+s*te+c*Ye+u*qe,r[i+4]=l*S+d*le+m*H+f*De,r[i+5]=l*Z+d*ve+m*Ce+f*Oe,r[i+6]=l*K+d*re+m*Ue+f*Ne,r[i+7]=l*ge+d*te+m*Ye+f*qe,r[i+8]=h*S+_*le+z*H+P*De,r[i+9]=h*Z+_*ve+z*Ce+P*Oe,r[i+10]=h*K+_*re+z*Ue+P*Ne,r[i+11]=h*ge+_*te+z*Ye+P*qe,r[i+12]=x*S+T*le+D*H+A*De,r[i+13]=x*Z+T*ve+D*Ce+A*Oe,r[i+14]=x*K+T*re+D*Ue+A*Ne,r[i+15]=x*ge+T*te+D*Ye+A*qe}function gd(n,e,r=0){let i=n.asArray();e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15]}function vd(n,e){let r=n.asArray(),i=r[0],t=r[1],o=r[2],a=r[3],s=r[4],c=r[5],u=r[6],l=r[7],d=r[8],m=r[9],f=r[10],h=r[11],_=r[12],z=r[13],P=r[14],x=r[15],T=f*x-P*h,D=m*x-z*h,A=m*P-z*f,S=d*x-_*h,Z=d*P-f*_,K=d*z-_*m,ge=+(c*T-u*D+l*A),le=-(s*T-u*S+l*Z),ve=+(s*D-c*S+l*K),re=-(s*A-c*Z+u*K),te=i*ge+t*le+o*ve+a*re;if(te===0)return!1;let H=1/te,Ce=u*x-P*l,Ue=c*x-z*l,Ye=c*P-z*u,De=s*x-_*l,Oe=s*P-_*u,Ne=s*z-_*c,qe=u*h-f*l,Qe=c*h-m*l,Ot=c*f-m*u,ld=s*h-d*l,dd=s*f-d*u,md=s*m-d*c,jh=-(t*T-o*D+a*A),Uh=+(i*T-o*S+a*Z),Nh=-(i*D-t*S+a*K),Ah=+(i*A-t*Z+o*K),Eh=+(t*Ce-o*Ue+a*Ye),Zh=-(i*Ce-o*De+a*Oe),Ch=+(i*Ue-t*De+a*Ne),Fh=-(i*Ye-t*Oe+o*Ne),Lh=-(t*qe-o*Qe+a*Ot),Mh=+(i*qe-o*ld+a*dd),Vh=-(i*Qe-t*ld+a*md),Bh=+(i*Ot-t*dd+o*md);return e[0]=ge*H,e[1]=jh*H,e[2]=Eh*H,e[3]=Lh*H,e[4]=le*H,e[5]=Uh*H,e[6]=Zh*H,e[7]=Mh*H,e[8]=ve*H,e[9]=Nh*H,e[10]=Ch*H,e[11]=Vh*H,e[12]=re*H,e[13]=Ah*H,e[14]=Fh*H,e[15]=Bh*H,!0}var Yh={};function vn(n,e){Yh[n]=e}var de=n=>parseInt(n.toString().replace(/\W/g,"")),We=class n{constructor(e=0,r=0){this.x=e,this.y=r}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=de(this.x),r=de(this.y),i=e;return i=i*397^r,i}toArray(e,r=0){return e[r]=this.x,e[r+1]=this.y,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,r){return this.x=e,this.y=r,this}set(e,r){return this.copyFromFloats(e,r)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new n(this.x+e.x,this.y+e.y)}addToRef(e,r){return r.x=this.x+e.x,r.y=this.y+e.y,r}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,r){return this.x+=e,this.y+=r,this}addVector3(e){return new n(this.x+e.x,this.y+e.y)}subtract(e){return new n(this.x-e.x,this.y-e.y)}subtractToRef(e,r){return r.x=this.x-e.x,r.y=this.y-e.y,r}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new n(this.x*e.x,this.y*e.y)}multiplyToRef(e,r){return r.x=this.x*e.x,r.y=this.y*e.y,r}multiplyByFloats(e,r){return new n(this.x*e,this.y*r)}divide(e){return new n(this.x/e.x,this.y/e.y)}divideToRef(e,r){return r.x=this.x/e.x,r.y=this.y/e.y,r}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,r){return this.x=Math.min(e,this.x),this.y=Math.min(r,this.y),this}maximizeInPlaceFromFloats(e,r){return this.x=Math.max(e,this.x),this.y=Math.max(r,this.y),this}subtractFromFloats(e,r){return new n(this.x-e,this.y-r)}subtractFromFloatsToRef(e,r,i){return i.x=this.x-e,i.y=this.y-r,i}negate(){return new n(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new n(this.x*e,this.y*e)}scaleToRef(e,r){return r.x=this.x*e,r.y=this.y*e,r}scaleAndAddToRef(e,r){return r.x+=this.x*e,r.y+=this.y*e,r}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,r=ce){return e&&X(this.x,e.x,r)&&X(this.y,e.y,r)}equalsToFloats(e,r){return this.x===e&&this.y===r}floor(){return new n(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new n(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new n)}rotateToRef(e,r){let i=Math.cos(e),t=Math.sin(e);return r.x=i*this.x-t*this.y,r.y=t*this.x+i*this.y,r}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n;return this.normalizeToRef(e),e}normalizeToRef(e){let r=this.length();return r===0||r===1?(e.x=this.x,e.y=this.y,e):this.scaleToRef(1/r,e)}clone(){return new n(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new n(0,0)}static One(){return new n(1,1)}static Random(e=0,r=1){return new n(G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r))}static get ZeroReadOnly(){return n._ZeroReadOnly}static FromArray(e,r=0){return new n(e[r],e[r+1])}static FromArrayToRef(e,r,i){return i.x=e[r],i.y=e[r+1],i}static FromFloatsToRef(e,r,i){return i.copyFromFloats(e,r),i}static CatmullRom(e,r,i,t,o){let a=o*o,s=o*a,c=.5*(2*r.x+(-e.x+i.x)*o+(2*e.x-5*r.x+4*i.x-t.x)*a+(-e.x+3*r.x-3*i.x+t.x)*s),u=.5*(2*r.y+(-e.y+i.y)*o+(2*e.y-5*r.y+4*i.y-t.y)*a+(-e.y+3*r.y-3*i.y+t.y)*s);return new n(c,u)}static ClampToRef(e,r,i,t){return t.x=oe(e.x,r.x,i.x),t.y=oe(e.y,r.y,i.y),t}static Clamp(e,r,i){let t=oe(e.x,r.x,i.x),o=oe(e.y,r.y,i.y);return new n(t,o)}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e.x*c+i.x*u+r.x*l+t.x*d,f=e.y*c+i.y*u+r.y*l+t.y*d;return new n(m,f)}static Hermite1stDerivative(e,r,i,t,o){return this.Hermite1stDerivativeToRef(e,r,i,t,o,new n)}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a.x=(s-o)*6*e.x+(3*s-4*o+1)*r.x+(-s+o)*6*i.x+(3*s-2*o)*t.x,a.y=(s-o)*6*e.y+(3*s-4*o+1)*r.y+(-s+o)*6*i.y+(3*s-2*o)*t.y,a}static Lerp(e,r,i){return n.LerpToRef(e,r,i,new n)}static LerpToRef(e,r,i,t){return t.x=e.x+(r.x-e.x)*i,t.y=e.y+(r.y-e.y)*i,t}static Dot(e,r){return e.x*r.x+e.y*r.y}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Minimize(e,r){let i=e.x<r.x?e.x:r.x,t=e.y<r.y?e.y:r.y;return new n(i,t)}static Maximize(e,r){let i=e.x>r.x?e.x:r.x,t=e.y>r.y?e.y:r.y;return new n(i,t)}static Transform(e,r){return n.TransformToRef(e,r,new n)}static TransformToRef(e,r,i){let t=r.m,o=e.x*t[0]+e.y*t[4]+t[12],a=e.x*t[1]+e.y*t[5]+t[13];return i.x=o,i.y=a,i}static PointInTriangle(e,r,i,t){let o=.5*(-i.y*t.x+r.y*(-i.x+t.x)+r.x*(i.y-t.y)+i.x*t.y),a=o<0?-1:1,s=(r.y*t.x-r.x*t.y+(t.y-r.y)*e.x+(r.x-t.x)*e.y)*a,c=(r.x*i.y-r.y*i.x+(r.y-i.y)*e.x+(i.x-r.x)*e.y)*a;return s>0&&c>0&&s+c<2*o*a}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y;return i*i+t*t}static Center(e,r){return n.CenterToRef(e,r,new n)}static CenterToRef(e,r,i){return i.copyFromFloats((e.x+r.x)/2,(e.y+r.y)/2)}static DistanceOfPointFromSegment(e,r,i){let t=n.DistanceSquared(r,i);if(t===0)return n.Distance(e,r);let o=i.subtract(r),a=Math.max(0,Math.min(1,n.Dot(e.subtract(r),o)/t)),s=r.add(o.multiplyByFloats(a,a));return n.Distance(e,s)}};We._V8PerformanceHack=new We(.5,.5);We._ZeroReadOnly=We.Zero();var R=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,r=0,i=0){this._isDirty=!0,this._x=e,this._y=r,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=e;return t=t*397^r,t=t*397^i,t}asArray(){return[this._x,this._y,this._z]}toArray(e,r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}toQuaternion(){return ue.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,r,i){return this._x+=e,this._y+=r,this._z+=i,this._isDirty=!0,this}add(e){return new n(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,r){return r._x=this._x+e._x,r._y=this._y+e._y,r._z=this._z+e._z,r._isDirty=!0,r}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new n(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,r){return this.subtractFromFloatsToRef(e._x,e._y,e._z,r)}subtractFromFloats(e,r,i){return new n(this._x-e,this._y-r,this._z-i)}subtractFromFloatsToRef(e,r,i,t){return t._x=this._x-e,t._y=this._y-r,t._z=this._z-i,t._isDirty=!0,t}negate(){return new n(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=this._x*-1,e._y=this._y*-1,e._z=this._z*-1,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new n(this._x*e,this._y*e,this._z*e)}scaleToRef(e,r){return r._x=this._x*e,r._y=this._y*e,r._z=this._z*e,r._isDirty=!0,r}getNormalToRef(e){let r=this.length(),i=Math.acos(this._y/r),t=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;let o=r*Math.sin(i)*Math.cos(t),a=r*Math.cos(i),s=r*Math.sin(i)*Math.sin(t);return e.set(o,a,s),e}applyRotationQuaternionToRef(e,r){let i=this._x,t=this._y,o=this._z,a=e._x,s=e._y,c=e._z,u=e._w,l=2*(s*o-c*t),d=2*(c*i-a*o),m=2*(a*t-s*i);return r._x=i+u*l+s*m-c*d,r._y=t+u*d+c*l-a*m,r._z=o+u*m+a*d-s*l,r._isDirty=!0,r}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new n)}scaleAndAddToRef(e,r){return r._x+=this._x*e,r._y+=this._y*e,r._z+=this._z*e,r._isDirty=!0,r}projectOnPlane(e,r){return this.projectOnPlaneToRef(e,r,new n)}projectOnPlaneToRef(e,r,i){let t=e.normal,o=e.d,a=w.Vector3[0];this.subtractToRef(r,a),a.normalize();let s=n.Dot(a,t);if(Math.abs(s)<1e-10)i.setAll(1/0);else{let c=-(n.Dot(r,t)+o)/s,u=a.scaleInPlace(c);r.addToRef(u,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)}equalsToFloats(e,r,i){return this._x===e&&this._y===r&&this._z===i}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,r){return r._x=this._x*e._x,r._y=this._y*e._y,r._z=this._z*e._z,r._isDirty=!0,r}multiplyByFloats(e,r,i){return new n(this._x*e,this._y*r,this._z*i)}divide(e){return new n(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,r){return r._x=this._x/e._x,r._y=this._y/e._y,r._z=this._z/e._z,r._isDirty=!0,r}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,r,i){return e<this._x&&(this.x=e),r<this._y&&(this.y=r),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,r,i){return e>this._x&&(this.x=e),r>this._y&&(this.y=r),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){let r=Math.abs(this._x),i=Math.abs(this._y);if(!X(r,i,e))return!0;let t=Math.abs(this._z);return!X(r,t,e)||!X(i,t,e)}get isNonUniform(){let e=Math.abs(this._x),r=Math.abs(this._y);if(e!==r)return!0;let i=Math.abs(this._z);return e!==i}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new n(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fractToRef(e){return e._x=this._x-Math.floor(this._x),e._y=this._y-Math.floor(this._y),e._z=this._z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new n(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z===0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if(e=e.toLowerCase(),e==="xyz")return this;let r=w.Vector3[0].copyFrom(this);return this.x=r[e[0]],this.y=r[e[1]],this.z=r[e[2]],this}rotateByQuaternionToRef(e,r){return e.toRotationMatrix(w.Matrix[0]),n.TransformCoordinatesToRef(this,w.Matrix[0],r),r}rotateByQuaternionAroundPointToRef(e,r,i){return this.subtractToRef(r,w.Vector3[0]),w.Vector3[0].rotateByQuaternionToRef(e,w.Vector3[0]),r.addToRef(w.Vector3[0],i),i}cross(e){return n.CrossToRef(this,e,new n)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let r=this.length();return r===0||r===1?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/r,e)}clone(){return new n(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,r,i){return this._x=e,this._y=r,this._z=i,this._isDirty=!0,this}set(e,r,i){return this.copyFromFloats(e,r,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,r,i,t){let o=n.Dot(e,i),a=n.Dot(r,i);return(o-t)/(o-a)}static GetAngleBetweenVectors(e,r,i){let t=e.normalizeToRef(w.Vector3[1]),o=r.normalizeToRef(w.Vector3[2]),a=n.Dot(t,o);a=oe(a,-1,1);let s=Math.acos(a),c=w.Vector3[3];return n.CrossToRef(t,o,c),n.Dot(c,i)>0?isNaN(s)?0:s:isNaN(s)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,r,i){w.Vector3[0].copyFrom(e);let t=w.Vector3[0];w.Vector3[1].copyFrom(r);let o=w.Vector3[1];w.Vector3[2].copyFrom(i);let a=w.Vector3[2],s=w.Vector3[3],c=w.Vector3[4];t.normalize(),o.normalize(),a.normalize(),n.CrossToRef(a,t,s),n.CrossToRef(s,a,c);let u=Math.atan2(n.Dot(o,s),n.Dot(o,c));return pd(u)}static PitchYawRollToMoveBetweenPointsToRef(e,r,i){let t=Ie.Vector3[0];return r.subtractToRef(e,t),i._y=Math.atan2(t.x,t.z)||0,i._x=Math.atan2(Math.sqrt(t.x**2+t.z**2),t.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,r){let i=n.Zero();return n.PitchYawRollToMoveBetweenPointsToRef(e,r,i)}static SlerpToRef(e,r,i,t){i=oe(i,0,1);let o=w.Vector3[0],a=w.Vector3[1];o.copyFrom(e);let s=o.length();o.normalizeFromLength(s),a.copyFrom(r);let c=a.length();a.normalizeFromLength(c);let u=n.Dot(o,a),l,d;if(u<1-ce){let m=Math.acos(u),f=1/Math.sin(m);l=Math.sin((1-i)*m)*f,d=Math.sin(i*m)*f}else l=1-i,d=i;return o.scaleInPlace(l),a.scaleInPlace(d),t.copyFrom(o).addInPlace(a),t.scaleInPlace(fd(s,c,i)),t}static SmoothToRef(e,r,i,t,o){return n.SlerpToRef(e,r,t===0?1:i/t,o),o}static FromArray(e,r=0){return new n(e[r],e[r+1],e[r+2])}static FromFloatArray(e,r){return n.FromArray(e,r)}static FromArrayToRef(e,r,i){return i._x=e[r],i._y=e[r+1],i._z=e[r+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,r,i){return n.FromArrayToRef(e,r,i)}static FromFloatsToRef(e,r,i,t){return t.copyFromFloats(e,r,i),t}static Zero(){return new n(0,0,0)}static One(){return new n(1,1,1)}static Up(){return new n(0,1,0)}static get UpReadOnly(){return n._UpReadOnly}static get DownReadOnly(){return n._DownReadOnly}static get RightReadOnly(){return n._RightReadOnly}static get LeftReadOnly(){return n._LeftReadOnly}static get LeftHandedForwardReadOnly(){return n._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return n._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return n._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return n._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return n._ZeroReadOnly}static get OneReadOnly(){return n._OneReadOnly}static Down(){return new n(0,-1,0)}static Forward(e=!1){return new n(0,0,e?-1:1)}static Backward(e=!1){return new n(0,0,e?1:-1)}static Right(){return new n(1,0,0)}static Left(){return new n(-1,0,0)}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r),G(e,r))}static TransformCoordinates(e,r){let i=n.Zero();return n.TransformCoordinatesToRef(e,r,i),i}static TransformCoordinatesToRef(e,r,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformCoordinatesFromFloatsToRef(e,r,i,t,o){let a=t.m,s=e*a[0]+r*a[4]+i*a[8]+a[12],c=e*a[1]+r*a[5]+i*a[9]+a[13],u=e*a[2]+r*a[6]+i*a[10]+a[14],l=1/(e*a[3]+r*a[7]+i*a[11]+a[15]);return o._x=s*l,o._y=c*l,o._z=u*l,o._isDirty=!0,o}static TransformNormal(e,r){let i=n.Zero();return n.TransformNormalToRef(e,r,i),i}static TransformNormalToRef(e,r,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformNormalFromFloatsToRef(e,r,i,t,o){let a=t.m;return o._x=e*a[0]+r*a[4]+i*a[8],o._y=e*a[1]+r*a[5]+i*a[9],o._z=e*a[2]+r*a[6]+i*a[10],o._isDirty=!0,o}static CatmullRom(e,r,i,t,o){let a=o*o,s=o*a,c=.5*(2*r._x+(-e._x+i._x)*o+(2*e._x-5*r._x+4*i._x-t._x)*a+(-e._x+3*r._x-3*i._x+t._x)*s),u=.5*(2*r._y+(-e._y+i._y)*o+(2*e._y-5*r._y+4*i._y-t._y)*a+(-e._y+3*r._y-3*i._y+t._y)*s),l=.5*(2*r._z+(-e._z+i._z)*o+(2*e._z-5*r._z+4*i._z-t._z)*a+(-e._z+3*r._z-3*i._z+t._z)*s);return new n(c,u,l)}static Clamp(e,r,i){let t=new n;return n.ClampToRef(e,r,i,t),t}static ClampToRef(e,r,i,t){let o=e._x;o=o>i._x?i._x:o,o=o<r._x?r._x:o;let a=e._y;a=a>i._y?i._y:a,a=a<r._y?r._y:a;let s=e._z;return s=s>i._z?i._z:s,s=s<r._z?r._z:s,t.copyFromFloats(o,a,s),t}static CheckExtends(e,r,i){r.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e._x*c+i._x*u+r._x*l+t._x*d,f=e._y*c+i._y*u+r._y*l+t._y*d,h=e._z*c+i._z*u+r._z*l+t._z*d;return new n(m,f,h)}static Hermite1stDerivative(e,r,i,t,o){let a=new n;return this.Hermite1stDerivativeToRef(e,r,i,t,o,a),a}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a._x=(s-o)*6*e._x+(3*s-4*o+1)*r._x+(-s+o)*6*i._x+(3*s-2*o)*t._x,a._y=(s-o)*6*e._y+(3*s-4*o+1)*r._y+(-s+o)*6*i._y+(3*s-2*o)*t._y,a._z=(s-o)*6*e._z+(3*s-4*o+1)*r._z+(-s+o)*6*i._z+(3*s-2*o)*t._z,a._isDirty=!0,a}static Lerp(e,r,i){let t=new n(0,0,0);return n.LerpToRef(e,r,i,t),t}static LerpToRef(e,r,i,t){return t._x=e._x+(r._x-e._x)*i,t._y=e._y+(r._y-e._y)*i,t._z=e._z+(r._z-e._z)*i,t._isDirty=!0,t}static Dot(e,r){return e._x*r._x+e._y*r._y+e._z*r._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,r){let i=new n;return n.CrossToRef(e,r,i),i}static CrossToRef(e,r,i){let t=e._y*r._z-e._z*r._y,o=e._z*r._x-e._x*r._z,a=e._x*r._y-e._y*r._x;return i.copyFromFloats(t,o,a),i}static Normalize(e){let r=n.Zero();return n.NormalizeToRef(e,r),r}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Project(e,r,i,t){let o=new n;return n.ProjectToRef(e,r,i,t,o),o}static ProjectToRef(e,r,i,t,o){let a=t.width,s=t.height,c=t.x,u=t.y,l=w.Matrix[1],d=Le.LastCreatedEngine?.isNDCHalfZRange,m=d?1:.5,f=d?0:.5;me.FromValuesToRef(a/2,0,0,0,0,-s/2,0,0,0,0,m,0,c+a/2,s/2+u,f,1,l);let h=w.Matrix[0];return r.multiplyToRef(i,h),h.multiplyToRef(l,h),n.TransformCoordinatesToRef(e,h,o),o}static Reflect(e,r){return this.ReflectToRef(e,r,new n)}static ReflectToRef(e,r,i){let t=Ie.Vector3[0];return t.copyFrom(r).scaleInPlace(2*n.Dot(e,r)),i.copyFrom(e).subtractInPlace(t)}static UnprojectFromTransform(e,r,i,t,o){return this.Unproject(e,r,i,t,o,me.IdentityReadOnly)}static Unproject(e,r,i,t,o,a){let s=new n;return n.UnprojectToRef(e,r,i,t,o,a,s),s}static UnprojectToRef(e,r,i,t,o,a,s){return n.UnprojectFloatsToRef(e._x,e._y,e._z,r,i,t,o,a,s),s}static UnprojectFloatsToRef(e,r,i,t,o,a,s,c,u){let l=w.Matrix[0];a.multiplyToRef(s,l),l.multiplyToRef(c,l),l.invert();let d=w.Vector3[0];return d.x=e/t*2-1,d.y=-(r/o*2-1),Le.LastCreatedEngine?.isNDCHalfZRange?d.z=i:d.z=2*i-1,n.TransformCoordinatesToRef(d,l,u),u}static Minimize(e,r){let i=new n;return i.copyFrom(e),i.minimizeInPlace(r),i}static Maximize(e,r){let i=new n;return i.copyFrom(e),i.maximizeInPlace(r),i}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e._x-r._x,t=e._y-r._y,o=e._z-r._z;return i*i+t*t+o*o}static ProjectOnTriangleToRef(e,r,i,t,o){let a=w.Vector3[0],s=w.Vector3[1],c=w.Vector3[2],u=w.Vector3[3],l=w.Vector3[4];i.subtractToRef(r,a),t.subtractToRef(r,s),t.subtractToRef(i,c);let d=a.length(),m=s.length(),f=c.length();if(d<ce||m<ce||f<ce)return o.copyFrom(r),n.Distance(e,r);e.subtractToRef(r,l),n.CrossToRef(a,s,u);let h=u.length();if(h<ce)return o.copyFrom(r),n.Distance(e,r);u.normalizeFromLength(h);let _=l.length();if(_<ce)return o.copyFrom(r),0;l.normalizeFromLength(_);let z=n.Dot(u,l),P=w.Vector3[5],x=w.Vector3[6];P.copyFrom(u).scaleInPlace(-_*z),x.copyFrom(e).addInPlace(P);let T=w.Vector3[4],D=w.Vector3[5],A=w.Vector3[7],S=w.Vector3[8];T.copyFrom(a).scaleInPlace(1/d),S.copyFrom(s).scaleInPlace(1/m),T.addInPlace(S).scaleInPlace(-1),D.copyFrom(a).scaleInPlace(-1/d),S.copyFrom(c).scaleInPlace(1/f),D.addInPlace(S).scaleInPlace(-1),A.copyFrom(c).scaleInPlace(-1/f),S.copyFrom(s).scaleInPlace(-1/m),A.addInPlace(S).scaleInPlace(-1);let Z=w.Vector3[9],K;Z.copyFrom(x).subtractInPlace(r),n.CrossToRef(T,Z,S),K=n.Dot(S,u);let ge=K;Z.copyFrom(x).subtractInPlace(i),n.CrossToRef(D,Z,S),K=n.Dot(S,u);let le=K;Z.copyFrom(x).subtractInPlace(t),n.CrossToRef(A,Z,S),K=n.Dot(S,u);let ve=K,re=w.Vector3[10],te,H;ge>0&&le<0?(re.copyFrom(a),te=r,H=i):le>0&&ve<0?(re.copyFrom(c),te=i,H=t):(re.copyFrom(s).scaleInPlace(-1),te=t,H=r);let Ce=w.Vector3[9],Ue=w.Vector3[4];if(te.subtractToRef(x,S),H.subtractToRef(x,Ce),n.CrossToRef(S,Ce,Ue),!(n.Dot(Ue,u)<0))return o.copyFrom(x),Math.abs(_*z);let De=w.Vector3[5];n.CrossToRef(re,Ue,De),De.normalize();let Oe=w.Vector3[9];Oe.copyFrom(te).subtractInPlace(x);let Ne=Oe.length();if(Ne<ce)return o.copyFrom(te),n.Distance(e,te);Oe.normalizeFromLength(Ne);let qe=n.Dot(De,Oe),Qe=w.Vector3[7];Qe.copyFrom(x).addInPlace(De.scaleInPlace(Ne*qe)),S.copyFrom(Qe).subtractInPlace(te),_=re.length(),re.normalizeFromLength(_);let Ot=n.Dot(S,re)/Math.max(_,ce);return Ot=oe(Ot,0,1),Qe.copyFrom(te).addInPlace(re.scaleInPlace(Ot*_)),o.copyFrom(Qe),n.Distance(e,Qe)}static Center(e,r){return n.CenterToRef(e,r,n.Zero())}static CenterToRef(e,r,i){return i.copyFromFloats((e._x+r._x)/2,(e._y+r._y)/2,(e._z+r._z)/2)}static RotationFromAxis(e,r,i){let t=new n;return n.RotationFromAxisToRef(e,r,i,t),t}static RotationFromAxisToRef(e,r,i,t){let o=w.Quaternion[0];return ue.RotationQuaternionFromAxisToRef(e,r,i,o),o.toEulerAnglesToRef(t),t}};R._V8PerformanceHack=new R(.5,.5,.5);R._UpReadOnly=R.Up();R._DownReadOnly=R.Down();R._LeftHandedForwardReadOnly=R.Forward(!1);R._RightHandedForwardReadOnly=R.Forward(!0);R._LeftHandedBackwardReadOnly=R.Backward(!1);R._RightHandedBackwardReadOnly=R.Backward(!0);R._RightReadOnly=R.Right();R._LeftReadOnly=R.Left();R._ZeroReadOnly=R.Zero();R._OneReadOnly=R.One();var Me=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,r=0,i=0,t=0){this._isDirty=!0,this._x=e,this._y=r,this._z=i,this._w=t}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=de(this._w),o=e;return o=o*397^r,o=o*397^i,o=o*397^t,o}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,r){return r===void 0&&(r=0),e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this),this}addInPlace(e){return this.x+=e._x,this.y+=e._y,this.z+=e._z,this.w+=e._w,this}addInPlaceFromFloats(e,r,i,t){return this.x+=e,this.y+=r,this.z+=i,this.w+=t,this}add(e){return new n(this._x+e.x,this._y+e.y,this._z+e.z,this._w+e.w)}addToRef(e,r){return r.x=this._x+e.x,r.y=this._y+e.y,r.z=this._z+e.z,r.w=this._w+e.w,r}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new n(this._x-e.x,this._y-e.y,this._z-e.z,this._w-e.w)}subtractToRef(e,r){return r.x=this._x-e.x,r.y=this._y-e.y,r.z=this._z-e.z,r.w=this._w-e.w,r}subtractFromFloats(e,r,i,t){return new n(this._x-e,this._y-r,this._z-i,this._w-t)}subtractFromFloatsToRef(e,r,i,t,o){return o.x=this._x-e,o.y=this._y-r,o.z=this._z-i,o.w=this._w-t,o}negate(){return new n(-this._x,-this._y,-this._z,-this._w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this._x,e.y=-this._y,e.z=-this._z,e.w=-this._w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new n(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,r){return r.x=this._x*e,r.y=this._y*e,r.z=this._z*e,r.w=this._w*e,r}scaleAndAddToRef(e,r){return r.x+=this._x*e,r.y+=this._y*e,r.z+=this._z*e,r.w+=this._w*e,r}equals(e){return e&&this._x===e.x&&this._y===e.y&&this._z===e.z&&this._w===e.w}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e.x,r)&&X(this._y,e.y,r)&&X(this._z,e.z,r)&&X(this._w,e.w,r)}equalsToFloats(e,r,i,t){return this._x===e&&this._y===r&&this._z===i&&this._w===t}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new n(this._x*e.x,this._y*e.y,this._z*e.z,this._w*e.w)}multiplyToRef(e,r){return r.x=this._x*e.x,r.y=this._y*e.y,r.z=this._z*e.z,r.w=this._w*e.w,r}multiplyByFloats(e,r,i,t){return new n(this._x*e,this._y*r,this._z*i,this._w*t)}divide(e){return new n(this._x/e.x,this._y/e.y,this._z/e.z,this._w/e.w)}divideToRef(e,r){return r.x=this._x/e.x,r.y=this._y/e.y,r.z=this._z/e.z,r.w=this._w/e.w,r}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this._x&&(this.x=e.x),e.y<this._y&&(this.y=e.y),e.z<this._z&&(this.z=e.z),e.w<this._w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this._x&&(this.x=e.x),e.y>this._y&&(this.y=e.y),e.z>this._z&&(this.z=e.z),e.w>this._w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,r,i,t){return this.x=Math.min(e,this._x),this.y=Math.min(r,this._y),this.z=Math.min(i,this._z),this.w=Math.min(t,this._w),this}maximizeInPlaceFromFloats(e,r,i,t){return this.x=Math.max(e,this._x),this.y=Math.max(r,this._y),this.z=Math.max(i,this._z),this.w=Math.max(t,this._w),this}floorToRef(e){return e.x=Math.floor(this._x),e.y=Math.floor(this._y),e.z=Math.floor(this._z),e.w=Math.floor(this._w),e}floor(){return new n(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),Math.floor(this._w))}fractToRef(e){return e.x=this._x-Math.floor(this._x),e.y=this._y-Math.floor(this._y),e.z=this._z-Math.floor(this._z),e.w=this._w-Math.floor(this._w),e}fract(){return new n(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z),this._w-Math.floor(this._w))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let r=this.length();return r===0||r===1?(e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e):this.scaleToRef(1/r,e)}toVector3(){return new R(this._x,this._y,this._z)}clone(){return new n(this._x,this._y,this._z,this._w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,r,i,t){return this.x=e,this.y=r,this.z=i,this.w=t,this}set(e,r,i,t){return this.copyFromFloats(e,r,i,t)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z+this._w*e.w}static FromArray(e,r){return r||(r=0),new n(e[r],e[r+1],e[r+2],e[r+3])}static FromArrayToRef(e,r,i){return i.x=e[r],i.y=e[r+1],i.z=e[r+2],i.w=e[r+3],i}static FromFloatArrayToRef(e,r,i){return n.FromArrayToRef(e,r,i),i}static FromFloatsToRef(e,r,i,t,o){return o.x=e,o.y=r,o.z=i,o.w=t,o}static Zero(){return new n(0,0,0,0)}static One(){return new n(1,1,1,1)}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.x=G(e,r),i.y=G(e,r),i.z=G(e,r),i.w=G(e,r),i}static Clamp(e,r,i){return n.ClampToRef(e,r,i,new n)}static ClampToRef(e,r,i,t){return t.x=oe(e.x,r.x,i.x),t.y=oe(e.y,r.y,i.y),t.z=oe(e.z,r.z,i.z),t.w=oe(e.w,r.w,i.w),t}static CheckExtends(e,r,i){r.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return n._ZeroReadOnly}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Minimize(e,r){let i=new n;return i.copyFrom(e),i.minimizeInPlace(r),i}static Maximize(e,r){let i=new n;return i.copyFrom(e),i.maximizeInPlace(r),i}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y,o=e.z-r.z,a=e.w-r.w;return i*i+t*t+o*o+a*a}static Center(e,r){return n.CenterToRef(e,r,new n)}static CenterToRef(e,r,i){return i.x=(e.x+r.x)/2,i.y=(e.y+r.y)/2,i.z=(e.z+r.z)/2,i.w=(e.w+r.w)/2,i}static TransformCoordinates(e,r){return n.TransformCoordinatesToRef(e,r,new n)}static TransformCoordinatesToRef(e,r,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,r,i),i}static TransformCoordinatesFromFloatsToRef(e,r,i,t,o){let a=t.m,s=e*a[0]+r*a[4]+i*a[8]+a[12],c=e*a[1]+r*a[5]+i*a[9]+a[13],u=e*a[2]+r*a[6]+i*a[10]+a[14],l=e*a[3]+r*a[7]+i*a[11]+a[15];return o.x=s,o.y=c,o.z=u,o.w=l,o}static TransformNormal(e,r){return n.TransformNormalToRef(e,r,new n)}static TransformNormalToRef(e,r,i){let t=r.m,o=e.x*t[0]+e.y*t[4]+e.z*t[8],a=e.x*t[1]+e.y*t[5]+e.z*t[9],s=e.x*t[2]+e.y*t[6]+e.z*t[10];return i.x=o,i.y=a,i.z=s,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,r,i,t,o,a){let s=o.m;return a.x=e*s[0]+r*s[4]+i*s[8],a.y=e*s[1]+r*s[5]+i*s[9],a.z=e*s[2]+r*s[6]+i*s[10],a.w=t,a}static FromVector3(e,r=0){return new n(e._x,e._y,e._z,r)}static Dot(e,r){return e.x*r.x+e.y*r.y+e.z*r.z+e.w*r.w}};Me._V8PerformanceHack=new Me(.5,.5,.5,.5);Me._ZeroReadOnly=Me.Zero();var ue=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,r=0,i=0,t=1){this._isDirty=!0,this._x=e,this._y=r,this._z=i,this._w=t}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=de(this._x),r=de(this._y),i=de(this._z),t=de(this._w),o=e;return o=o*397^r,o=o*397^i,o=o*397^t,o}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,this}fromArray(e,r=0){return n.FromArrayToRef(e,r,this)}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,r=ce){return e&&X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)&&X(this._w,e._w,r)}isApprox(e,r=ce){return e&&(X(this._x,e._x,r)&&X(this._y,e._y,r)&&X(this._z,e._z,r)&&X(this._w,e._w,r)||X(this._x,-e._x,r)&&X(this._y,-e._y,r)&&X(this._z,-e._z,r)&&X(this._w,-e._w,r))}clone(){return new n(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,r,i,t){return this._x=e,this._y=r,this._z=i,this._w=t,this._isDirty=!0,this}set(e,r,i,t){return this.copyFromFloats(e,r,i,t)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new n(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}addToRef(e,r){return r._x=this._x+e._x,r._y=this._y+e._y,r._z=this._z+e._z,r._w=this._w+e._w,r._isDirty=!0,r}addInPlaceFromFloats(e,r,i,t){return this._x+=e,this._y+=r,this._z+=i,this._w+=t,this._isDirty=!0,this}subtractToRef(e,r){return r._x=this._x-e._x,r._y=this._y-e._y,r._z=this._z-e._z,r._w=this._w-e._w,r._isDirty=!0,r}subtractFromFloats(e,r,i,t){return this.subtractFromFloatsToRef(e,r,i,t,new n)}subtractFromFloatsToRef(e,r,i,t,o){return o._x=this._x-e,o._y=this._y-r,o._z=this._z-i,o._w=this._w-t,o._isDirty=!0,o}subtract(e){return new n(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new n(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,r){return r._x=this._x*e,r._y=this._y*e,r._z=this._z*e,r._w=this._w*e,r._isDirty=!0,r}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}scaleAndAddToRef(e,r){return r._x+=this._x*e,r._y+=this._y*e,r._z+=this._z*e,r._w+=this._w*e,r._isDirty=!0,r}multiply(e){let r=new n(0,0,0,1);return this.multiplyToRef(e,r),r}multiplyToRef(e,r){let i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,t=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,o=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,a=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return r.copyFromFloats(i,t,o,a),r}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,r,i,t){return this._x*=e,this._y*=r,this._z*=i,this._w*=t,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,r){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new n)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,r,i,t){return this._x===e&&this._y===r&&this._z===i&&this._w===t}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new n(-this._x,-this._y,-this._z,this._w)}invert(){let e=this.conjugate(),r=this.lengthSquared();return r==0||r==1||e.scaleInPlace(1/r),e}invertInPlace(){this.conjugateInPlace();let e=this.lengthSquared();return e==0||e==1?this:(this.scaleInPlace(1/e),this)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){let r=this.length();return r===0||r===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/r,e)}toEulerAngles(){let e=R.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){let r=this._z,i=this._x,t=this._y,o=this._w,a=t*r-i*o,s=.4999999;if(a<-s)e._y=2*Math.atan2(t,o),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>s)e._y=2*Math.atan2(t,o),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{let c=o*o,u=r*r,l=i*i,d=t*t;e._z=Math.atan2(2*(i*t+r*o),-u-l+d+c),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(r*i+t*o),u-l-d+c),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){let r=this._z,i=this._x,t=this._y,o=this._w,a=Math.sqrt(i*i+t*t),s=Math.sqrt(r*r+o*o),c=2*Math.atan2(a,s),u=2*Math.atan2(r,o),l=2*Math.atan2(t,i),d=(u+l)/2,m=(u-l)/2;return e.set(m,c,d),e}toRotationMatrix(e){return me.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return n.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){let e=R.Zero(),r=this.toAxisAngleToRef(e);return{axis:e,angle:r}}toAxisAngleToRef(e){let r,i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),t=this._w;return i>0?(r=2*Math.atan2(i,t),e.set(this._x/i,this._y/i,this._z/i)):(r=0,e.set(1,0,0)),r}static FromRotationMatrix(e){let r=new n;return n.FromRotationMatrixToRef(e,r),r}static FromRotationMatrixToRef(e,r){let i=e.m,t=i[0],o=i[4],a=i[8],s=i[1],c=i[5],u=i[9],l=i[2],d=i[6],m=i[10],f=t+c+m,h;return f>0?(h=.5/Math.sqrt(f+1),r._w=.25/h,r._x=(d-u)*h,r._y=(a-l)*h,r._z=(s-o)*h,r._isDirty=!0):t>c&&t>m?(h=2*Math.sqrt(1+t-c-m),r._w=(d-u)/h,r._x=.25*h,r._y=(o+s)/h,r._z=(a+l)/h,r._isDirty=!0):c>m?(h=2*Math.sqrt(1+c-t-m),r._w=(a-l)/h,r._x=(o+s)/h,r._y=.25*h,r._z=(u+d)/h,r._isDirty=!0):(h=2*Math.sqrt(1+m-t-c),r._w=(s-o)/h,r._x=(a+l)/h,r._y=(u+d)/h,r._z=.25*h,r._isDirty=!0),r}static Dot(e,r){return e._x*r._x+e._y*r._y+e._z*r._z+e._w*r._w}static AreClose(e,r,i=.1){let t=n.Dot(e,r);return 1-t*t<=i}static SmoothToRef(e,r,i,t,o){let a=t===0?1:i/t;return a=oe(a,0,1),n.SlerpToRef(e,r,a,o),o}static Zero(){return new n(0,0,0,0)}static Inverse(e){return new n(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,r){return r.set(-e._x,-e._y,-e._z,e._w),r}static Identity(){return new n(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,r){return n.RotationAxisToRef(e,r,new n)}static RotationAxisToRef(e,r,i){i._w=Math.cos(r/2);let t=Math.sin(r/2)/e.length();return i._x=e._x*t,i._y=e._y*t,i._z=e._z*t,i._isDirty=!0,i}static FromArray(e,r){return r||(r=0),new n(e[r],e[r+1],e[r+2],e[r+3])}static FromArrayToRef(e,r,i){return i._x=e[r],i._y=e[r+1],i._z=e[r+2],i._w=e[r+3],i._isDirty=!0,i}static FromFloatsToRef(e,r,i,t,o){return o.copyFromFloats(e,r,i,t),o}static FromEulerAngles(e,r,i){let t=new n;return n.RotationYawPitchRollToRef(r,e,i,t),t}static FromEulerAnglesToRef(e,r,i,t){return n.RotationYawPitchRollToRef(r,e,i,t),t}static FromEulerVector(e){let r=new n;return n.RotationYawPitchRollToRef(e._y,e._x,e._z,r),r}static FromEulerVectorToRef(e,r){return n.RotationYawPitchRollToRef(e._y,e._x,e._z,r),r}static FromUnitVectorsToRef(e,r,i,t=ce){let o=R.Dot(e,r)+1;return o<t?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(R.CrossToRef(e,r,Ie.Vector3[0]),i.set(Ie.Vector3[0].x,Ie.Vector3[0].y,Ie.Vector3[0].z,o)),i.normalize()}static RotationYawPitchRoll(e,r,i){let t=new n;return n.RotationYawPitchRollToRef(e,r,i,t),t}static RotationYawPitchRollToRef(e,r,i,t){let o=i*.5,a=r*.5,s=e*.5,c=Math.sin(o),u=Math.cos(o),l=Math.sin(a),d=Math.cos(a),m=Math.sin(s),f=Math.cos(s);return t._x=f*l*u+m*d*c,t._y=m*d*u-f*l*c,t._z=f*d*c-m*l*u,t._w=f*d*u+m*l*c,t._isDirty=!0,t}static RotationAlphaBetaGamma(e,r,i){let t=new n;return n.RotationAlphaBetaGammaToRef(e,r,i,t),t}static RotationAlphaBetaGammaToRef(e,r,i,t){let o=(i+e)*.5,a=(i-e)*.5,s=r*.5;return t._x=Math.cos(a)*Math.sin(s),t._y=Math.sin(a)*Math.sin(s),t._z=Math.sin(o)*Math.cos(s),t._w=Math.cos(o)*Math.cos(s),t._isDirty=!0,t}static RotationQuaternionFromAxis(e,r,i){let t=new n(0,0,0,0);return n.RotationQuaternionFromAxisToRef(e,r,i,t),t}static RotationQuaternionFromAxisToRef(e,r,i,t){let o=w.Matrix[0];return e=e.normalizeToRef(w.Vector3[0]),r=r.normalizeToRef(w.Vector3[1]),i=i.normalizeToRef(w.Vector3[2]),me.FromXYZAxesToRef(e,r,i,o),n.FromRotationMatrixToRef(o,t),t}static FromLookDirectionLH(e,r){let i=new n;return n.FromLookDirectionLHToRef(e,r,i),i}static FromLookDirectionLHToRef(e,r,i){let t=w.Matrix[0];return me.LookDirectionLHToRef(e,r,t),n.FromRotationMatrixToRef(t,i),i}static FromLookDirectionRH(e,r){let i=new n;return n.FromLookDirectionRHToRef(e,r,i),i}static FromLookDirectionRHToRef(e,r,i){let t=w.Matrix[0];return me.LookDirectionRHToRef(e,r,t),n.FromRotationMatrixToRef(t,i)}static Slerp(e,r,i){let t=n.Identity();return n.SlerpToRef(e,r,i,t),t}static SlerpToRef(e,r,i,t){let o,a,s=e._x*r._x+e._y*r._y+e._z*r._z+e._w*r._w,c=!1;if(s<0&&(c=!0,s=-s),s>.999999)a=1-i,o=c?-i:i;else{let u=Math.acos(s),l=1/Math.sin(u);a=Math.sin((1-i)*u)*l,o=c?-Math.sin(i*u)*l:Math.sin(i*u)*l}return t._x=a*e._x+o*r._x,t._y=a*e._y+o*r._y,t._z=a*e._z+o*r._z,t._w=a*e._w+o*r._w,t._isDirty=!0,t}static Hermite(e,r,i,t,o){let a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,d=s-a,m=e._x*c+i._x*u+r._x*l+t._x*d,f=e._y*c+i._y*u+r._y*l+t._y*d,h=e._z*c+i._z*u+r._z*l+t._z*d,_=e._w*c+i._w*u+r._w*l+t._w*d;return new n(m,f,h,_)}static Hermite1stDerivative(e,r,i,t,o){let a=new n;return this.Hermite1stDerivativeToRef(e,r,i,t,o,a),a}static Hermite1stDerivativeToRef(e,r,i,t,o,a){let s=o*o;return a._x=(s-o)*6*e._x+(3*s-4*o+1)*r._x+(-s+o)*6*i._x+(3*s-2*o)*t._x,a._y=(s-o)*6*e._y+(3*s-4*o+1)*r._y+(-s+o)*6*i._y+(3*s-2*o)*t._y,a._z=(s-o)*6*e._z+(3*s-4*o+1)*r._z+(-s+o)*6*i._z+(3*s-2*o)*t._z,a._w=(s-o)*6*e._w+(3*s-4*o+1)*r._w+(-s+o)*6*i._w+(3*s-2*o)*t._w,a._isDirty=!0,a}static Normalize(e){let r=n.Zero();return n.NormalizeToRef(e,r),r}static NormalizeToRef(e,r){return e.normalizeToRef(r),r}static Clamp(e,r,i){let t=new n;return n.ClampToRef(e,r,i,t),t}static ClampToRef(e,r,i,t){return t.copyFromFloats(oe(e.x,r.x,i.x),oe(e.y,r.y,i.y),oe(e.z,r.z,i.z),oe(e.w,r.w,i.w))}static Random(e=0,r=1){return new n(G(e,r),G(e,r),G(e,r),G(e,r))}static RandomToRef(e=0,r=1,i){return i.copyFromFloats(G(e,r),G(e,r),G(e,r),G(e,r))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,r){return Math.sqrt(n.DistanceSquared(e,r))}static DistanceSquared(e,r){let i=e.x-r.x,t=e.y-r.y,o=e.z-r.z,a=e.w-r.w;return i*i+t*t+o*o+a*a}static Center(e,r){return n.CenterToRef(e,r,n.Zero())}static CenterToRef(e,r,i){return i.copyFromFloats((e.x+r.x)/2,(e.y+r.y)/2,(e.z+r.z)/2,(e.w+r.w)/2)}};ue._V8PerformanceHack=new ue(.5,.5,.5,.5);var me=class n{static get Use64Bits(){return ke.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=gn._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,r=!1,i=!1,t=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:r,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:t}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,ke.MatrixTrackPrecisionChange&&ke.MatrixTrackedMatrices.push(this),this._m=new ke.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;let e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1:this._m[1]!==0||this._m[2]!==0||this._m[3]!==0||this._m[4]!==0||this._m[6]!==0||this._m[7]!==0||this._m[8]!==0||this._m[9]!==0||this._m[10]!==0||this._m[11]!==0||this._m[12]!==0||this._m[13]!==0||this._m[14]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)return 1;let e=this._m,r=e[0],i=e[1],t=e[2],o=e[3],a=e[4],s=e[5],c=e[6],u=e[7],l=e[8],d=e[9],m=e[10],f=e[11],h=e[12],_=e[13],z=e[14],P=e[15],x=m*P-z*f,T=d*P-_*f,D=d*z-_*m,A=l*P-h*f,S=l*z-m*h,Z=l*_-h*d,K=+(s*x-c*T+u*D),ge=-(a*x-c*A+u*S),le=+(a*T-s*A+u*Z),ve=-(a*D-s*S+c*Z);return r*K+i*ge+t*le+o*ve}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}
3
3
  ${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}
4
4
  ${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}
5
5
  ${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,r=0){if(!e)return this._m;let i=this._m;for(let t=0;t<16;t++)e[r+t]=i[t];return this}asArray(){return this._m}fromArray(e,r=0){return n.FromArrayToRef(e,r,this)}copyFromFloats(...e){return n.FromArrayToRef(e,0,this)}set(...e){let r=this._m;for(let i=0;i<16;i++)r[i]=e[i];return this.markAsUpdated(),this}setAll(e){let r=this._m;for(let i=0;i<16;i++)r[i]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return n.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){let r=new n;return this.addToRef(e,r),r}addToRef(e,r){let i=this._m,t=r._m,o=e.m;for(let a=0;a<16;a++)t[a]=i[a]+o[a];return r.markAsUpdated(),r}addToSelf(e){let r=this._m,i=e.m;return r[0]+=i[0],r[1]+=i[1],r[2]+=i[2],r[3]+=i[3],r[4]+=i[4],r[5]+=i[5],r[6]+=i[6],r[7]+=i[7],r[8]+=i[8],r[9]+=i[9],r[10]+=i[10],r[11]+=i[11],r[12]+=i[12],r[13]+=i[13],r[14]+=i[14],r[15]+=i[15],this.markAsUpdated(),this}addInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]+=i[t];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){let r=this._m;for(let i=0;i<16;i++)r[i]+=e[i];return this.markAsUpdated(),this}subtract(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]-=i[t];return this.markAsUpdated(),this}subtractToRef(e,r){let i=this._m,t=e.m,o=r._m;for(let a=0;a<16;a++)o[a]=i[a]-t[a];return r.markAsUpdated(),r}subtractInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]-=i[t];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new n)}subtractFromFloatsToRef(...e){let r=e.pop(),i=this._m,t=r._m,o=e;for(let a=0;a<16;a++)t[a]=i[a]-o[a];return r.markAsUpdated(),r}invertToRef(e){return this._isIdentity===!0?(n.IdentityToRef(e),e):(vd(this,e.asArray())?e.markAsUpdated():e.copyFrom(this),e)}addAtIndex(e,r){return this._m[e]+=r,this.markAsUpdated(),this}multiplyAtIndex(e,r){return this._m[e]*=r,this.markAsUpdated(),this}setTranslationFromFloats(e,r,i){return this._m[12]=e,this._m[13]=r,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,r,i){return this._m[12]+=e,this._m[13]+=r,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new R(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){let e=this.m;return n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),this}copyFrom(e){e.copyToArray(this._m);let r=e;return this.updateFlag=r.updateFlag,this._updateIdentityStatus(r._isIdentity,r._isIdentityDirty,r._isIdentity3x2,r._isIdentity3x2Dirty),this}copyToArray(e,r=0){return gd(this,e,r),this}multiply(e){let r=new n;return this.multiplyToRef(e,r),r}multiplyInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]*=i[t];return this.markAsUpdated(),this}multiplyByFloats(...e){let r=this._m;for(let i=0;i<16;i++)r[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){let r=e.pop(),i=this._m,t=r._m,o=e;for(let a=0;a<16;a++)t[a]=i[a]*o[a];return r.markAsUpdated(),r}multiplyToRef(e,r){return this._isIdentity?(r.copyFrom(e),r):e._isIdentity?(r.copyFrom(this),r):(this.multiplyToArray(e,r._m,0),r.markAsUpdated(),r)}multiplyToArray(e,r,i){return hd(this,e,r,i),this}divide(e){return this.divideToRef(e,new n)}divideToRef(e,r){let i=this._m,t=e.m,o=r._m;for(let a=0;a<16;a++)o[a]=i[a]/t[a];return r.markAsUpdated(),r}divideInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]/=i[t];return this.markAsUpdated(),this}minimizeInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]=Math.min(r[t],i[t]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){let r=this._m;for(let i=0;i<16;i++)r[i]=Math.min(r[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){let r=this._m,i=e.m;for(let t=0;t<16;t++)r[t]=Math.max(r[t],i[t]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){let r=this._m;for(let i=0;i<16;i++)r[i]=Math.max(r[i],e[i]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new n)}negateInPlace(){let e=this._m;for(let r=0;r<16;r++)e[r]=-e[r];return this.markAsUpdated(),this}negateToRef(e){let r=this._m,i=e._m;for(let t=0;t<16;t++)i[t]=-r[t];return e.markAsUpdated(),e}equals(e){let r=e;if(!r)return!1;if((this._isIdentity||r._isIdentity)&&!this._isIdentityDirty&&!r._isIdentityDirty)return this._isIdentity&&r._isIdentity;let i=this.m,t=r.m;return i[0]===t[0]&&i[1]===t[1]&&i[2]===t[2]&&i[3]===t[3]&&i[4]===t[4]&&i[5]===t[5]&&i[6]===t[6]&&i[7]===t[7]&&i[8]===t[8]&&i[9]===t[9]&&i[10]===t[10]&&i[11]===t[11]&&i[12]===t[12]&&i[13]===t[13]&&i[14]===t[14]&&i[15]===t[15]}equalsWithEpsilon(e,r=0){let i=this._m,t=e.m;for(let o=0;o<16;o++)if(!X(i[o],t[o],r))return!1;return!0}equalsToFloats(...e){let r=this._m;for(let i=0;i<16;i++)if(r[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new n)}floorToRef(e){let r=this._m,i=e._m;for(let t=0;t<16;t++)i[t]=Math.floor(r[t]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new n)}fractToRef(e){let r=this._m,i=e._m;for(let t=0;t<16;t++)i[t]=r[t]-Math.floor(r[t]);return e.markAsUpdated(),e}clone(){let e=new n;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=de(this._m[0]);for(let r=1;r<16;r++)e=e*397^de(this._m[r]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new ue,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,r,i,t,o=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),r&&r.copyFromFloats(0,0,0,1),!0;let a=this._m;if(i&&i.copyFromFloats(a[12],a[13],a[14]),e=e||w.Vector3[0],e.x=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),e.y=Math.sqrt(a[4]*a[4]+a[5]*a[5]+a[6]*a[6]),e.z=Math.sqrt(a[8]*a[8]+a[9]*a[9]+a[10]*a[10]),t){let s=(o?t.absoluteScaling.x:t.scaling.x)<0?-1:1,c=(o?t.absoluteScaling.y:t.scaling.y)<0?-1:1,u=(o?t.absoluteScaling.z:t.scaling.z)<0?-1:1;e.x*=s,e.y*=c,e.z*=u}else this.determinant()<=0&&(e.y*=-1);if(e._x===0||e._y===0||e._z===0)return r&&r.copyFromFloats(0,0,0,1),!1;if(r){let s=1/e._x,c=1/e._y,u=1/e._z;n.FromValuesToRef(a[0]*s,a[1]*s,a[2]*s,0,a[4]*c,a[5]*c,a[6]*c,0,a[8]*u,a[9]*u,a[10]*u,0,0,0,0,1,w.Matrix[0]),ue.FromRotationMatrixToRef(w.Matrix[0],r)}return!0}getRow(e){if(e<0||e>3)return null;let r=e*4;return new Me(this._m[r+0],this._m[r+1],this._m[r+2],this._m[r+3])}getRowToRef(e,r){if(e>=0&&e<=3){let i=e*4;r.x=this._m[i+0],r.y=this._m[i+1],r.z=this._m[i+2],r.w=this._m[i+3]}return r}setRow(e,r){return this.setRowFromFloats(e,r.x,r.y,r.z,r.w)}transpose(){let e=new n;return n.TransposeToRef(this,e),e}transposeToRef(e){return n.TransposeToRef(this,e),e}setRowFromFloats(e,r,i,t,o){if(e<0||e>3)return this;let a=e*4;return this._m[a+0]=r,this._m[a+1]=i,this._m[a+2]=t,this._m[a+3]=o,this.markAsUpdated(),this}scale(e){let r=new n;return this.scaleToRef(e,r),r}scaleToRef(e,r){for(let i=0;i<16;i++)r._m[i]=this._m[i]*e;return r.markAsUpdated(),r}scaleAndAddToRef(e,r){for(let i=0;i<16;i++)r._m[i]+=this._m[i]*e;return r.markAsUpdated(),r}scaleInPlace(e){let r=this._m;for(let i=0;i<16;i++)r[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){let r=w.Matrix[0];this.invertToRef(r),r.transposeToRef(e);let i=e._m;return n.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[10],0,0,0,0,1,e),e}getRotationMatrix(){let e=new n;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){let r=w.Vector3[0];if(!this.decompose(r))return n.IdentityToRef(e),e;let i=this._m,t=1/r._x,o=1/r._y,a=1/r._z;return n.FromValuesToRef(i[0]*t,i[1]*t,i[2]*t,0,i[4]*o,i[5]*o,i[6]*o,0,i[8]*a,i[9]*a,i[10]*a,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){let e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){let e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}_convertProjectionToHalfZRangeInPlace(){return this.multiplyToRef(et,this),this}static FromArray(e,r=0){let i=new n;return n.FromArrayToRef(e,r,i),i}static FromArrayToRef(e,r,i){for(let t=0;t<16;t++)i._m[t]=e[t+r];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,r,i,t){return t._m[0]=e[0+r]*i,t._m[1]=e[1+r]*i,t._m[2]=e[2+r]*i,t._m[3]=e[3+r]*i,t._m[4]=e[4+r]*i,t._m[5]=e[5+r]*i,t._m[6]=e[6+r]*i,t._m[7]=e[7+r]*i,t._m[8]=e[8+r]*i,t._m[9]=e[9+r]*i,t._m[10]=e[10+r]*i,t._m[11]=e[11+r]*i,t._m[12]=e[12+r]*i,t._m[13]=e[13+r]*i,t._m[14]=e[14+r]*i,t._m[15]=e[15+r]*i,t.markAsUpdated(),t}static get IdentityReadOnly(){return n._IdentityReadOnly}static FromValuesToRef(e,r,i,t,o,a,s,c,u,l,d,m,f,h,_,z,P){let x=P._m;x[0]=e,x[1]=r,x[2]=i,x[3]=t,x[4]=o,x[5]=a,x[6]=s,x[7]=c,x[8]=u,x[9]=l,x[10]=d,x[11]=m,x[12]=f,x[13]=h,x[14]=_,x[15]=z,P.markAsUpdated()}static FromValues(e,r,i,t,o,a,s,c,u,l,d,m,f,h,_,z){let P=new n,x=P._m;return x[0]=e,x[1]=r,x[2]=i,x[3]=t,x[4]=o,x[5]=a,x[6]=s,x[7]=c,x[8]=u,x[9]=l,x[10]=d,x[11]=m,x[12]=f,x[13]=h,x[14]=_,x[15]=z,P.markAsUpdated(),P}static Compose(e,r,i){let t=new n;return n.ComposeToRef(e,r,i,t),t}static ComposeToRef(e,r,i,t){let o=t._m,a=r._x,s=r._y,c=r._z,u=r._w,l=a+a,d=s+s,m=c+c,f=a*l,h=a*d,_=a*m,z=s*d,P=s*m,x=c*m,T=u*l,D=u*d,A=u*m,S=e._x,Z=e._y,K=e._z;return o[0]=(1-(z+x))*S,o[1]=(h+A)*S,o[2]=(_-D)*S,o[3]=0,o[4]=(h-A)*Z,o[5]=(1-(f+x))*Z,o[6]=(P+T)*Z,o[7]=0,o[8]=(_+D)*K,o[9]=(P-T)*K,o[10]=(1-(f+z))*K,o[11]=0,o[12]=i._x,o[13]=i._y,o[14]=i._z,o[15]=1,t.markAsUpdated(),t}static Identity(){let e=n.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){let e=n.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){let r=new n;return n.RotationXToRef(e,r),r}static Invert(e){let r=new n;return e.invertToRef(r),r}static RotationXToRef(e,r){let i=Math.sin(e),t=Math.cos(e);return n.FromValuesToRef(1,0,0,0,0,t,i,0,0,-i,t,0,0,0,0,1,r),r._updateIdentityStatus(t===1&&i===0),r}static RotationY(e){let r=new n;return n.RotationYToRef(e,r),r}static RotationYToRef(e,r){let i=Math.sin(e),t=Math.cos(e);return n.FromValuesToRef(t,0,-i,0,0,1,0,0,i,0,t,0,0,0,0,1,r),r._updateIdentityStatus(t===1&&i===0),r}static RotationZ(e){let r=new n;return n.RotationZToRef(e,r),r}static RotationZToRef(e,r){let i=Math.sin(e),t=Math.cos(e);return n.FromValuesToRef(t,i,0,0,-i,t,0,0,0,0,1,0,0,0,0,1,r),r._updateIdentityStatus(t===1&&i===0),r}static RotationAxis(e,r){let i=new n;return n.RotationAxisToRef(e,r,i),i}static RotationAxisToRef(e,r,i){let t=Math.sin(-r),o=Math.cos(-r),a=1-o;e=e.normalizeToRef(w.Vector3[0]);let s=i._m;return s[0]=e._x*e._x*a+o,s[1]=e._x*e._y*a-e._z*t,s[2]=e._x*e._z*a+e._y*t,s[3]=0,s[4]=e._y*e._x*a+e._z*t,s[5]=e._y*e._y*a+o,s[6]=e._y*e._z*a-e._x*t,s[7]=0,s[8]=e._z*e._x*a-e._y*t,s[9]=e._z*e._y*a+e._x*t,s[10]=e._z*e._z*a+o,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,r,i,t=!1){let o=R.Dot(r,e),a=i._m;if(o<-1+ce)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=t?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=t?-1:1,a[11]=0;else{let s=R.Cross(r,e),c=1/(1+o);a[0]=s._x*s._x*c+o,a[1]=s._y*s._x*c-s._z,a[2]=s._z*s._x*c+s._y,a[3]=0,a[4]=s._x*s._y*c+s._z,a[5]=s._y*s._y*c+o,a[6]=s._z*s._y*c-s._x,a[7]=0,a[8]=s._x*s._z*c-s._y,a[9]=s._y*s._z*c+s._x,a[10]=s._z*s._z*c+o,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,r,i){let t=new n;return n.RotationYawPitchRollToRef(e,r,i,t),t}static RotationYawPitchRollToRef(e,r,i,t){return ue.RotationYawPitchRollToRef(e,r,i,w.Quaternion[0]),w.Quaternion[0].toRotationMatrix(t),t}static Scaling(e,r,i){let t=new n;return n.ScalingToRef(e,r,i,t),t}static ScalingToRef(e,r,i,t){return n.FromValuesToRef(e,0,0,0,0,r,0,0,0,0,i,0,0,0,0,1,t),t._updateIdentityStatus(e===1&&r===1&&i===1),t}static Translation(e,r,i){let t=new n;return n.TranslationToRef(e,r,i,t),t}static TranslationToRef(e,r,i,t){return n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,r,i,1,t),t._updateIdentityStatus(e===0&&r===0&&i===0),t}static Lerp(e,r,i){let t=new n;return n.LerpToRef(e,r,i,t),t}static LerpToRef(e,r,i,t){let o=t._m,a=e.m,s=r.m;for(let c=0;c<16;c++)o[c]=a[c]*(1-i)+s[c]*i;return t.markAsUpdated(),t}static DecomposeLerp(e,r,i){let t=new n;return n.DecomposeLerpToRef(e,r,i,t),t}static DecomposeLerpToRef(e,r,i,t){let o=w.Vector3[0],a=w.Quaternion[0],s=w.Vector3[1];e.decompose(o,a,s);let c=w.Vector3[2],u=w.Quaternion[1],l=w.Vector3[3];r.decompose(c,u,l);let d=w.Vector3[4];R.LerpToRef(o,c,i,d);let m=w.Quaternion[2];ue.SlerpToRef(a,u,i,m);let f=w.Vector3[5];return R.LerpToRef(s,l,i,f),n.ComposeToRef(d,m,f,t),t}static LookAtLH(e,r,i){let t=new n;return n.LookAtLHToRef(e,r,i,t),t}static LookAtLHToRef(e,r,i,t){let o=w.Vector3[0],a=w.Vector3[1],s=w.Vector3[2];r.subtractToRef(e,s),s.normalize(),R.CrossToRef(i,s,o);let c=o.lengthSquared();c===0?o.x=1:o.normalizeFromLength(Math.sqrt(c)),R.CrossToRef(s,o,a),a.normalize();let u=-R.Dot(o,e),l=-R.Dot(a,e),d=-R.Dot(s,e);return n.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,l,d,1,t),t}static LookAtRH(e,r,i){let t=new n;return n.LookAtRHToRef(e,r,i,t),t}static LookAtRHToRef(e,r,i,t){let o=w.Vector3[0],a=w.Vector3[1],s=w.Vector3[2];e.subtractToRef(r,s),s.normalize(),R.CrossToRef(i,s,o);let c=o.lengthSquared();c===0?o.x=1:o.normalizeFromLength(Math.sqrt(c)),R.CrossToRef(s,o,a),a.normalize();let u=-R.Dot(o,e),l=-R.Dot(a,e),d=-R.Dot(s,e);return n.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,l,d,1,t),t}static LookDirectionLH(e,r){let i=new n;return n.LookDirectionLHToRef(e,r,i),i}static LookDirectionLHToRef(e,r,i){let t=w.Vector3[0];t.copyFrom(e),t.scaleInPlace(-1);let o=w.Vector3[1];return R.CrossToRef(r,t,o),n.FromValuesToRef(o._x,o._y,o._z,0,r._x,r._y,r._z,0,t._x,t._y,t._z,0,0,0,0,1,i),i}static LookDirectionRH(e,r){let i=new n;return n.LookDirectionRHToRef(e,r,i),i}static LookDirectionRHToRef(e,r,i){let t=w.Vector3[2];return R.CrossToRef(r,e,t),n.FromValuesToRef(t._x,t._y,t._z,0,r._x,r._y,r._z,0,e._x,e._y,e._z,0,0,0,0,1,i),i}static OrthoLH(e,r,i,t,o){let a=new n;return n.OrthoLHToRef(e,r,i,t,a,o),a}static OrthoLHToRef(e,r,i,t,o,a){let s=i,c=t,u=2/e,l=2/r,d=2/(c-s),m=-(c+s)/(c-s);return n.FromValuesToRef(u,0,0,0,0,l,0,0,0,0,d,0,0,0,m,1,o),a&&o.multiplyToRef(et,o),o._updateIdentityStatus(u===1&&l===1&&d===1&&m===0),o}static OrthoOffCenterLH(e,r,i,t,o,a,s){let c=new n;return n.OrthoOffCenterLHToRef(e,r,i,t,o,a,c,s),c}static OrthoOffCenterLHToRef(e,r,i,t,o,a,s,c){let u=o,l=a,d=2/(r-e),m=2/(t-i),f=2/(l-u),h=-(l+u)/(l-u),_=(e+r)/(e-r),z=(t+i)/(i-t);return n.FromValuesToRef(d,0,0,0,0,m,0,0,0,0,f,0,_,z,h,1,s),c&&s.multiplyToRef(et,s),s.markAsUpdated(),s}static ObliqueOffCenterLHToRef(e,r,i,t,o,a,s,c,u,l,d){let m=-s*Math.cos(c),f=-s*Math.sin(c);return n.TranslationToRef(0,0,-u,w.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,m,f,1,0,0,0,0,1,w.Matrix[0]),w.Matrix[1].multiplyToRef(w.Matrix[0],w.Matrix[0]),n.TranslationToRef(0,0,u,w.Matrix[1]),w.Matrix[0].multiplyToRef(w.Matrix[1],w.Matrix[0]),n.OrthoOffCenterLHToRef(e,r,i,t,o,a,l,d),w.Matrix[0].multiplyToRef(l,l),l}static OrthoOffCenterRH(e,r,i,t,o,a,s){let c=new n;return n.OrthoOffCenterRHToRef(e,r,i,t,o,a,c,s),c}static OrthoOffCenterRHToRef(e,r,i,t,o,a,s,c){return n.OrthoOffCenterLHToRef(e,r,i,t,o,a,s,c),s._m[10]*=-1,s}static ObliqueOffCenterRHToRef(e,r,i,t,o,a,s,c,u,l,d){let m=s*Math.cos(c),f=s*Math.sin(c);return n.TranslationToRef(0,0,u,w.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,m,f,1,0,0,0,0,1,w.Matrix[0]),w.Matrix[1].multiplyToRef(w.Matrix[0],w.Matrix[0]),n.TranslationToRef(0,0,-u,w.Matrix[1]),w.Matrix[0].multiplyToRef(w.Matrix[1],w.Matrix[0]),n.OrthoOffCenterRHToRef(e,r,i,t,o,a,l,d),w.Matrix[0].multiplyToRef(l,l),l}static PerspectiveLH(e,r,i,t,o,a=0){let s=new n,c=i,u=t,l=2*c/e,d=2*c/r,m=(u+c)/(u-c),f=-2*u*c/(u-c),h=Math.tan(a);return n.FromValuesToRef(l,0,0,0,0,d,0,h,0,0,m,1,0,0,f,0,s),o&&s.multiplyToRef(et,s),s._updateIdentityStatus(!1),s}static PerspectiveFovLH(e,r,i,t,o,a=0,s=!1){let c=new n;return n.PerspectiveFovLHToRef(e,r,i,t,c,!0,o,a,s),c}static PerspectiveFovLHToRef(e,r,i,t,o,a=!0,s,c=0,u=!1){let l=i,d=t,m=1/Math.tan(e*.5),f=a?m/r:m,h=a?m:m*r,_=u&&l===0?-1:d!==0?(d+l)/(d-l):1,z=u&&l===0?2*d:d!==0?-2*d*l/(d-l):-2*l,P=Math.tan(c);return n.FromValuesToRef(f,0,0,0,0,h,0,P,0,0,_,1,0,0,z,0,o),s&&o.multiplyToRef(et,o),o._updateIdentityStatus(!1),o}static PerspectiveFovReverseLHToRef(e,r,i,t,o,a=!0,s,c=0){let u=1/Math.tan(e*.5),l=a?u/r:u,d=a?u:u*r,m=Math.tan(c);return n.FromValuesToRef(l,0,0,0,0,d,0,m,0,0,-i,1,0,0,1,0,o),s&&o.multiplyToRef(et,o),o._updateIdentityStatus(!1),o}static PerspectiveFovRH(e,r,i,t,o,a=0,s=!1){let c=new n;return n.PerspectiveFovRHToRef(e,r,i,t,c,!0,o,a,s),c}static PerspectiveFovRHToRef(e,r,i,t,o,a=!0,s,c=0,u=!1){let l=i,d=t,m=1/Math.tan(e*.5),f=a?m/r:m,h=a?m:m*r,_=u&&l===0?1:d!==0?-(d+l)/(d-l):-1,z=u&&l===0?2*d:d!==0?-2*d*l/(d-l):-2*l,P=Math.tan(c);return n.FromValuesToRef(f,0,0,0,0,h,0,P,0,0,_,-1,0,0,z,0,o),s&&o.multiplyToRef(et,o),o._updateIdentityStatus(!1),o}static PerspectiveFovReverseRHToRef(e,r,i,t,o,a=!0,s,c=0){let u=1/Math.tan(e*.5),l=a?u/r:u,d=a?u:u*r,m=Math.tan(c);return n.FromValuesToRef(l,0,0,0,0,d,0,m,0,0,-i,-1,0,0,-1,0,o),s&&o.multiplyToRef(et,o),o._updateIdentityStatus(!1),o}static GetFinalMatrix(e,r,i,t,o,a){let s=e.width,c=e.height,u=e.x,l=e.y,d=n.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,u+s/2,c/2+l,o,1),m=new n;return r.multiplyToRef(i,m),m.multiplyToRef(t,m),m.multiplyToRef(d,m)}static GetAsMatrix2x2(e){let r=e.m,i=[r[0],r[1],r[4],r[5]];return ke.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){let r=e.m,i=[r[0],r[1],r[2],r[4],r[5],r[6],r[8],r[9],r[10]];return ke.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){let r=new n;return n.TransposeToRef(e,r),r}static TransposeToRef(e,r){let i=e.m,t=i[0],o=i[4],a=i[8],s=i[12],c=i[1],u=i[5],l=i[9],d=i[13],m=i[2],f=i[6],h=i[10],_=i[14],z=i[3],P=i[7],x=i[11],T=i[15],D=r._m;return D[0]=t,D[1]=o,D[2]=a,D[3]=s,D[4]=c,D[5]=u,D[6]=l,D[7]=d,D[8]=m,D[9]=f,D[10]=h,D[11]=_,D[12]=z,D[13]=P,D[14]=x,D[15]=T,r.markAsUpdated(),r._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),r}static Reflection(e){let r=new n;return n.ReflectionToRef(e,r),r}static ReflectionToRef(e,r){e.normalize();let i=e.normal.x,t=e.normal.y,o=e.normal.z,a=-2*i,s=-2*t,c=-2*o;return n.FromValuesToRef(a*i+1,s*i,c*i,0,a*t,s*t+1,c*t,0,a*o,s*o,c*o+1,0,a*e.d,s*e.d,c*e.d,1,r),r}static FromXYZAxesToRef(e,r,i,t){return n.FromValuesToRef(e._x,e._y,e._z,0,r._x,r._y,r._z,0,i._x,i._y,i._z,0,0,0,0,1,t),t}static FromQuaternionToRef(e,r){let i=e._x*e._x,t=e._y*e._y,o=e._z*e._z,a=e._x*e._y,s=e._z*e._w,c=e._z*e._x,u=e._y*e._w,l=e._y*e._z,d=e._x*e._w;return r._m[0]=1-2*(t+o),r._m[1]=2*(a+s),r._m[2]=2*(c-u),r._m[3]=0,r._m[4]=2*(a-s),r._m[5]=1-2*(o+i),r._m[6]=2*(l+d),r._m[7]=0,r._m[8]=2*(c+u),r._m[9]=2*(l-d),r._m[10]=1-2*(t+i),r._m[11]=0,r._m[12]=0,r._m[13]=0,r._m[14]=0,r._m[15]=1,r.markAsUpdated(),r}};me._IdentityReadOnly=me.Identity();var w=class{};w.Vector3=Ge(11,R.Zero);w.Matrix=Ge(2,me.Identity);w.Quaternion=Ge(3,ue.Zero);var Ie=class{};Ie.Vector2=Ge(3,We.Zero);Ie.Vector3=Ge(13,R.Zero);Ie.Vector4=Ge(3,Me.Zero);Ie.Quaternion=Ge(3,ue.Zero);Ie.Matrix=Ge(8,me.Identity);var et=me.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1),_d=!1;function yd(){_d||(_d=!0,Object.defineProperties(We.prototype,{dimension:{value:[2]},rank:{value:1}}),Object.defineProperties(R.prototype,{dimension:{value:[3]},rank:{value:1}}),Object.defineProperties(Me.prototype,{dimension:{value:[4]},rank:{value:1}}),Object.defineProperties(ue.prototype,{dimension:{value:[4]},rank:{value:1}}),Object.defineProperties(me.prototype,{dimension:{value:[4,4]},rank:{value:2}}),vn("BABYLON.Vector2",We),vn("BABYLON.Vector3",R),vn("BABYLON.Vector4",Me),vn("BABYLON.Matrix",me))}yd();async function $d(n,e){let r=await n(e?.pluginExtension);r.addAllToScene();let i=!1;return{rootNodes:r.rootNodes??[],meshes:r.meshes??[],container:r,dispose(){i||(i=!0,r.removeAllFromScene?.(),r.dispose?.())}}}function Qh(n){return n?typeof n=="function"?n()??null:n:null}function eg(n,e){let r=n;for(let i of e.split("/")){if(!i)continue;let t=r?.getChildren?.();if(!Array.isArray(t)||(r=t.find(o=>o.name===i)??null,!r))return null}return r}function xo(n){let e=new R,r=new R,i=new R;return{reset(){},apply(t){switch(t.type){case"camera_sample":{let o=n.camera??n.scene.activeCamera;if(!o)return;let[a,s,c]=t.position;if(t.target)e.set(t.target[0],t.target[1],t.target[2]);else{let[u,l,d]=t.direction;e.set(a+u,s+l,c+d)}o.setTarget?.(e),typeof o.setPosition=="function"?(r.set(a,s,c),o.setPosition(r)):o.position.set(a,s,c);break}case"pointer_move":case"pointer_click":case"pointer_down":case"pointer_up":n.onPointer?.(t.screen,t.hitPoint,t.hitMesh,t.type);break;case"mesh_interaction":n.onMeshInteraction?.(t.mesh,t.kind,t.point);break;case"custom":n.onCustom?.(t.name,t.props,t.ts);break;case"input_action":n.onInputAction?.({action:t.action,code:t.code,button:t.button,pressed:t.pressed,source:t.source},t.ts);break;case"viewport_resize":n.onLifecycle?.({type:"viewport_resize",width:t.width,height:t.height,dpr:t.dpr},t.ts);break;case"visibility_change":n.onLifecycle?.({type:"visibility_change",state:t.state},t.ts);break;case"focus_change":n.onLifecycle?.({type:"focus_change",focused:t.focused},t.ts);break;case"context_lost":n.onLifecycle?.({type:"context_lost"},t.ts);break;case"context_restored":n.onLifecycle?.({type:"context_restored"},t.ts);break;case"runtime_error":n.onError?.({kind:t.kind,message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,stack:t.stack},t.ts);break;case"camera_gesture":break;case"node_transform":{let o=Qh(n.nodes?.[t.nodeId]);if(o)if(t.boneId!==void 0){let a=o.skeleton?.bones?.find(s=>s.name===t.boneId);a&&(a.position?.set(t.position[0],t.position[1],t.position[2]),a.rotationQuaternion=new ue(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]),t.scale&&a.scaling?.set(t.scale[0],t.scale[1],t.scale[2]),a.markAsDirty?.())}else{let a=t.childPath===void 0?o:eg(o,t.childPath);a&&(typeof a.setAbsolutePosition=="function"?(i.set(t.position[0],t.position[1],t.position[2]),a.setAbsolutePosition(i)):a.position?.set(t.position[0],t.position[1],t.position[2]),a.rotationQuaternion=new ue(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]),t.scale&&a.scaling?.set(t.scale[0],t.scale[1],t.scale[2]))}n.onNodeTransform?.(t.nodeId,{boneId:t.boneId,childPath:t.childPath,position:t.position,rotation:t.rotation,scale:t.scale},t.ts);break}default:break}}}}var p={};Fe(p,{$brand:()=>Eo,$input:()=>ac,$output:()=>oc,NEVER:()=>Ao,TimePrecision:()=>gc,ZodAny:()=>nl,ZodArray:()=>al,ZodBase64:()=>eo,ZodBase64URL:()=>to,ZodBigInt:()=>dn,ZodBigIntFormat:()=>io,ZodBoolean:()=>ln,ZodCIDRv4:()=>Yi,ZodCIDRv6:()=>Qi,ZodCUID:()=>Ji,ZodCUID2:()=>Ki,ZodCatch:()=>Sl,ZodCodec:()=>rr,ZodCompileAsyncError:()=>Ee,ZodCompileUnsupportedError:()=>L,ZodCreditCard:()=>Wu,ZodCustom:()=>ir,ZodCustomStringFormat:()=>cn,ZodDate:()=>Xn,ZodDefault:()=>xl,ZodDiscriminatedUnion:()=>cl,ZodE164:()=>no,ZodEmail:()=>Li,ZodEmoji:()=>Vi,ZodEnum:()=>an,ZodError:()=>s$,ZodExactOptional:()=>co,ZodFile:()=>vl,ZodFirstPartyTypeKind:()=>Fl,ZodFunction:()=>El,ZodGUID:()=>Mi,ZodIPv4:()=>Hi,ZodIPv6:()=>Xi,ZodISODate:()=>dt,ZodISODateTime:()=>lt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,ZodIntersection:()=>ul,ZodIssueCode:()=>l$,ZodJWT:()=>ro,ZodKSUID:()=>Wi,ZodLazy:()=>Ul,ZodLiteral:()=>gl,ZodMAC:()=>Gu,ZodMap:()=>pl,ZodNaN:()=>Pl,ZodNanoID:()=>Bi,ZodNever:()=>il,ZodNonOptional:()=>uo,ZodNull:()=>el,ZodNullable:()=>$l,ZodNumber:()=>un,ZodNumberFormat:()=>Dt,ZodObject:()=>Qn,ZodOptional:()=>tr,ZodPipe:()=>nr,ZodPrefault:()=>zl,ZodPreprocess:()=>Dl,ZodPromise:()=>Al,ZodReadonly:()=>Ol,ZodRealError:()=>ze,ZodRecord:()=>on,ZodSet:()=>hl,ZodString:()=>sn,ZodStringFormat:()=>q,ZodSuccess:()=>Il,ZodSymbol:()=>Yu,ZodTemplateLiteral:()=>jl,ZodTransform:()=>_l,ZodTuple:()=>dl,ZodType:()=>E,ZodULID:()=>qi,ZodURL:()=>Hn,ZodUUID:()=>Ke,ZodUndefined:()=>Qu,ZodUnion:()=>er,ZodUnknown:()=>rl,ZodVoid:()=>ol,ZodXID:()=>Gi,ZodXor:()=>sl,_ZodString:()=>Fi,_default:()=>bl,_function:()=>Np,any:()=>mp,array:()=>Yn,base64:()=>Gf,base64url:()=>Wf,bigint:()=>sp,boolean:()=>Xu,catch:()=>Tl,check:()=>Ap,cidrv4:()=>Kf,cidrv6:()=>qf,clone:()=>V,codec:()=>Op,coerce:()=>Ll,compile:()=>lc,config:()=>ee,core:()=>Xe,creditCard:()=>Xf,cuid:()=>Zf,cuid2:()=>Cf,custom:()=>Ep,date:()=>pp,decode:()=>Lu,decodeAsync:()=>Vu,deepPartial:()=>Wp,describe:()=>Zp,discriminatedUnion:()=>$p,e164:()=>Hf,email:()=>Tf,emoji:()=>Af,encode:()=>Fu,encodeAsync:()=>Mu,endsWith:()=>Wt,enum:()=>ao,exactOptional:()=>yl,file:()=>Sp,flattenError:()=>Sn,float32:()=>rp,float64:()=>ip,formatError:()=>Tn,fromJSONSchema:()=>qp,function:()=>Np,getDiscriminatedOption:()=>Os,getErrorMap:()=>m$,globalRegistry:()=>ae,gt:()=>Be,gte:()=>Pe,guid:()=>Pf,hash:()=>np,hex:()=>tp,hostname:()=>ep,httpUrl:()=>Nf,includes:()=>qt,input:()=>Xp,instanceof:()=>Fp,int:()=>Zi,int32:()=>op,int64:()=>cp,intersection:()=>ll,invertCodec:()=>Rp,ipv4:()=>Vf,ipv6:()=>Jf,iso:()=>or,json:()=>Mp,jwt:()=>Yf,keyof:()=>hp,ksuid:()=>Mf,lazy:()=>Nl,length:()=>It,literal:()=>Ip,locales:()=>Fn,looseObject:()=>_p,looseRecord:()=>bp,lowercase:()=>Jt,lt:()=>Ve,lte:()=>Te,mac:()=>Bf,map:()=>zp,maxLength:()=>kt,maxSize:()=>at,memoizer:()=>Zn,meta:()=>Cp,mime:()=>Ht,minLength:()=>He,minSize:()=>Je,multipleOf:()=>ot,nan:()=>Dp,nanoid:()=>Ef,nativeEnum:()=>kp,negative:()=>Ii,never:()=>oo,nonnegative:()=>Ti,nonoptional:()=>kl,nonpositive:()=>Si,normalize:()=>Xt,null:()=>tl,nullable:()=>Wn,nullish:()=>Tp,number:()=>Hu,object:()=>gp,optional:()=>Tt,output:()=>Yp,overwrite:()=>Ze,parse:()=>Au,parseAsync:()=>Eu,partialRecord:()=>xp,pipe:()=>Ci,positive:()=>ki,prefault:()=>wl,preprocess:()=>Vp,prettifyError:()=>Mo,promise:()=>Up,properties:()=>Di,property:()=>Pi,readonly:()=>Rl,record:()=>fl,refine:()=>Zl,regex:()=>Bt,regexes:()=>fe,registry:()=>ni,safeDecode:()=>Ju,safeDecodeAsync:()=>qu,safeEncode:()=>Bu,safeEncodeAsync:()=>Ku,safeParse:()=>Zu,safeParseAsync:()=>Cu,set:()=>wp,setErrorMap:()=>d$,size:()=>wt,slugify:()=>tn,startsWith:()=>Gt,strictObject:()=>vp,string:()=>Gn,stringFormat:()=>Qf,stringbool:()=>Lp,success:()=>Pp,superRefine:()=>Cl,symbol:()=>lp,templateLiteral:()=>jp,toJSONSchema:()=>Ui,toLowerCase:()=>Qt,toUpperCase:()=>en,toZod:()=>_n,transform:()=>so,treeifyError:()=>Lo,trim:()=>Yt,tuple:()=>ml,uint32:()=>ap,uint64:()=>up,ulid:()=>Ff,undefined:()=>dp,union:()=>mn,unknown:()=>St,uppercase:()=>Kt,url:()=>Uf,util:()=>b,uuid:()=>Df,uuidv4:()=>Of,uuidv6:()=>Rf,uuidv7:()=>jf,validate:()=>Jo,validateAsync:()=>Ko,void:()=>fp,xid:()=>Lf,xor:()=>yp});var Xe={};Fe(Xe,{$ZodAny:()=>zs,$ZodArray:()=>Ts,$ZodAsyncError:()=>xe,$ZodBase64:()=>ms,$ZodBase64URL:()=>fs,$ZodBigInt:()=>Br,$ZodBigIntFormat:()=>ys,$ZodBoolean:()=>Un,$ZodCIDRv4:()=>ls,$ZodCIDRv6:()=>ds,$ZodCUID:()=>Ya,$ZodCUID2:()=>Qa,$ZodCatch:()=>qs,$ZodCheck:()=>W,$ZodCheckBigIntFormat:()=>Sa,$ZodCheckEndsWith:()=>Ca,$ZodCheckGreaterThan:()=>Tr,$ZodCheckIncludes:()=>Ea,$ZodCheckLengthEquals:()=>ja,$ZodCheckLessThan:()=>Sr,$ZodCheckLowerCase:()=>Na,$ZodCheckMaxLength:()=>Oa,$ZodCheckMaxSize:()=>Ta,$ZodCheckMimeType:()=>Fa,$ZodCheckMinLength:()=>Ra,$ZodCheckMinSize:()=>Pa,$ZodCheckMultipleOf:()=>ka,$ZodCheckNumberFormat:()=>Ia,$ZodCheckOverwrite:()=>La,$ZodCheckProperty:()=>Pr,$ZodCheckRegex:()=>Ua,$ZodCheckSizeEquals:()=>Da,$ZodCheckStartsWith:()=>Za,$ZodCheckStringFormat:()=>Lt,$ZodCheckUpperCase:()=>Aa,$ZodCodec:()=>An,$ZodCreditCard:()=>hs,$ZodCustom:()=>ec,$ZodCustomStringFormat:()=>vs,$ZodCyclicError:()=>Hr,$ZodDate:()=>Ss,$ZodDefault:()=>Vs,$ZodDiscriminatedUnion:()=>Rs,$ZodE164:()=>ps,$ZodEmail:()=>Ka,$ZodEmoji:()=>Ha,$ZodEncodeError:()=>rt,$ZodEnum:()=>Es,$ZodError:()=>In,$ZodExactOptional:()=>Ls,$ZodFile:()=>Cs,$ZodFunction:()=>Ys,$ZodGUID:()=>Ba,$ZodIPv4:()=>ss,$ZodIPv6:()=>cs,$ZodISODate:()=>is,$ZodISODateTime:()=>rs,$ZodISODuration:()=>as,$ZodISOTime:()=>os,$ZodIntersection:()=>js,$ZodJWT:()=>gs,$ZodKSUID:()=>ns,$ZodLazy:()=>En,$ZodLiteral:()=>Zs,$ZodMAC:()=>us,$ZodMap:()=>Ns,$ZodNaN:()=>Gs,$ZodNanoID:()=>Xa,$ZodNever:()=>ks,$ZodNonOptional:()=>Js,$ZodNull:()=>bs,$ZodNullable:()=>Ms,$ZodNumber:()=>Vr,$ZodNumberFormat:()=>_s,$ZodObject:()=>Xd,$ZodObjectJIT:()=>Ps,$ZodOptional:()=>Kr,$ZodPipe:()=>qr,$ZodPrefault:()=>Bs,$ZodPreprocess:()=>Ws,$ZodPromise:()=>Qs,$ZodReadonly:()=>Hs,$ZodRealError:()=>be,$ZodRecord:()=>Us,$ZodRegistry:()=>ti,$ZodSet:()=>As,$ZodString:()=>yt,$ZodStringFormat:()=>J,$ZodSuccess:()=>Ks,$ZodSymbol:()=>$s,$ZodTemplateLiteral:()=>Xs,$ZodTransform:()=>Fs,$ZodTuple:()=>Jr,$ZodType:()=>N,$ZodULID:()=>es,$ZodURL:()=>Wa,$ZodUUID:()=>Ja,$ZodUndefined:()=>xs,$ZodUnion:()=>Nn,$ZodUnknown:()=>ws,$ZodVoid:()=>Is,$ZodXID:()=>ts,$ZodXor:()=>Ds,$brand:()=>Eo,$constructor:()=>g,$input:()=>ac,$output:()=>oc,Doc:()=>_t,INVALID:()=>Se,JSONSchema:()=>kf,JSONSchemaGenerator:()=>Ni,NEVER:()=>Ao,TimePrecision:()=>gc,URL_BAD_FORMAT:()=>qa,URL_UNPARSEABLE:()=>Ga,ZodCompileAsyncError:()=>Ee,ZodCompileUnsupportedError:()=>L,_any:()=>jc,_array:()=>Fc,_base64:()=>xi,_base64url:()=>bi,_bigint:()=>Ic,_boolean:()=>wc,_catch:()=>Xy,_check:()=>_f,_cidrv4:()=>yi,_cidrv6:()=>$i,_coercedBigint:()=>Sc,_coercedBoolean:()=>kc,_coercedDate:()=>Zc,_coercedNumber:()=>_c,_coercedString:()=>fc,_creditCard:()=>hc,_cuid:()=>mi,_cuid2:()=>fi,_custom:()=>Mc,_date:()=>Ec,_decode:()=>vr,_decodeAsync:()=>yr,_default:()=>Gy,_discriminatedUnion:()=>Ay,_e164:()=>zi,_email:()=>ii,_emoji:()=>li,_encode:()=>gr,_encodeAsync:()=>_r,_endsWith:()=>Wt,_enum:()=>My,_file:()=>Lc,_float32:()=>$c,_float64:()=>xc,_gt:()=>Be,_gte:()=>Pe,_guid:()=>oi,_includes:()=>qt,_int:()=>yc,_int32:()=>bc,_int64:()=>Tc,_intersection:()=>Ey,_ipv4:()=>vi,_ipv6:()=>_i,_isoDate:()=>Vn,_isoDateTime:()=>Mn,_isoDuration:()=>Jn,_isoTime:()=>Bn,_jwt:()=>wi,_ksuid:()=>gi,_lazy:()=>t$,_length:()=>It,_literal:()=>By,_lowercase:()=>Jt,_lt:()=>Ve,_lte:()=>Te,_mac:()=>pc,_map:()=>Fy,_max:()=>Te,_maxLength:()=>kt,_maxSize:()=>at,_mime:()=>Ht,_min:()=>Pe,_minLength:()=>He,_minSize:()=>Je,_multipleOf:()=>ot,_nan:()=>Cc,_nanoid:()=>di,_nativeEnum:()=>Vy,_negative:()=>Ii,_never:()=>Nc,_nonnegative:()=>Ti,_nonoptional:()=>Wy,_nonpositive:()=>Si,_normalize:()=>Xt,_null:()=>Rc,_nullable:()=>qy,_number:()=>vc,_optional:()=>Ky,_overwrite:()=>Ze,_parse:()=>Et,_parseAsync:()=>Zt,_pipe:()=>Yy,_positive:()=>ki,_promise:()=>n$,_properties:()=>Di,_property:()=>Pi,_readonly:()=>Qy,_record:()=>Cy,_refine:()=>Vc,_regex:()=>Bt,_safeDecode:()=>xr,_safeDecodeAsync:()=>zr,_safeEncode:()=>$r,_safeEncodeAsync:()=>br,_safeParse:()=>Ct,_safeParseAsync:()=>Ft,_set:()=>Ly,_size:()=>wt,_slugify:()=>tn,_startsWith:()=>Gt,_string:()=>mc,_stringFormat:()=>nn,_stringbool:()=>qc,_success:()=>Hy,_superRefine:()=>Bc,_symbol:()=>Dc,_templateLiteral:()=>e$,_toLowerCase:()=>Qt,_toUpperCase:()=>en,_transform:()=>Jy,_trim:()=>Yt,_tuple:()=>Zy,_uint32:()=>zc,_uint64:()=>Pc,_ulid:()=>pi,_undefined:()=>Oc,_union:()=>Uy,_unknown:()=>Uc,_uppercase:()=>Kt,_url:()=>Ln,_uuid:()=>ai,_uuidv4:()=>si,_uuidv6:()=>ci,_uuidv7:()=>ui,_void:()=>Ac,_xid:()=>hi,_xor:()=>Ny,clone:()=>V,compile:()=>lc,compileFn:()=>ri,config:()=>ee,createStandardJSONSchemaMethod:()=>rn,createToJSONSchemaMethod:()=>Wc,decode:()=>Lg,decodeAsync:()=>Vg,describe:()=>Jc,encode:()=>Fg,encodeAsync:()=>Mg,extractDefs:()=>ct,finalize:()=>ut,flattenError:()=>Sn,formatError:()=>Tn,getDiscriminatedOption:()=>Os,globalConfig:()=>ie,globalRegistry:()=>ae,handleUnrepresentable:()=>ne,initializeContext:()=>st,isBackEdge:()=>Xr,isRecursiveSchema:()=>ic,isValidBase64:()=>jn,isValidBase64URL:()=>Fr,isValidCIDRv6:()=>Cr,isValidCreditCard:()=>Lr,isValidIPv6:()=>Rn,isValidJWT:()=>Mr,locales:()=>Fn,memoizer:()=>Zn,mergeValues:()=>Mt,meta:()=>Kc,parse:()=>pr,parseAsync:()=>hr,parseURLObject:()=>Nr,prettifyError:()=>Mo,process:()=>B,regexes:()=>fe,registry:()=>ni,safeDecode:()=>Jg,safeDecodeAsync:()=>qg,safeEncode:()=>Bg,safeEncodeAsync:()=>Kg,safeParse:()=>Vo,safeParseAsync:()=>Bo,standardProps:()=>Ur,stripTabAndNewline:()=>Ar,toDotPath:()=>Td,toJSONSchema:()=>Ui,toZod:()=>_n,treeifyError:()=>Lo,urlHostnameOk:()=>Er,urlProtocolOk:()=>Zr,util:()=>b,validate:()=>Jo,validateAsync:()=>Ko,version:()=>Ma});var b={};Fe(b,{BIGINT_FORMAT_RANGES:()=>Do,CONSTANT_CATCH:()=>mr,Class:()=>zo,NUMBER_FORMAT_RANGES:()=>Po,aborted:()=>nt,allowsEval:()=>Io,assert:()=>og,assertEqual:()=>tg,assertIs:()=>rg,assertNever:()=>ig,assertNotEqual:()=>ng,assignProp:()=>Q,attachSchema:()=>dr,base64ToUint8Array:()=>bd,base64urlToUint8Array:()=>zg,cached:()=>Nt,captureStackTrace:()=>lr,cleanEnum:()=>bg,cleanRegex:()=>$n,clone:()=>V,cloneDef:()=>sg,codePointLength:()=>gt,constantCatch:()=>Uo,createTransparentProxy:()=>fg,defineLazy:()=>wo,defineLazyInternal:()=>C,esc:()=>_e,escapeRegex:()=>je,explicitlyAborted:()=>Oo,extend:()=>gg,finalizeIssue:()=>$e,floatSafeRemainder:()=>xn,getElementAtPath:()=>cg,getEnumValues:()=>yn,getLengthableOrigin:()=>kn,getParsedType:()=>mg,getSizableOrigin:()=>wn,hexToUint8Array:()=>kg,hide:()=>jo,installLazyProp:()=>Dg,isObject:()=>ht,isPlainObject:()=>Re,issue:()=>At,joinValues:()=>v,jsonStringifyReplacer:()=>Ut,members:()=>Ro,merge:()=>_g,mergeDefs:()=>Ae,normalizeParams:()=>k,nullish:()=>ur,numKeys:()=>dg,objectClone:()=>ag,omit:()=>hg,optionalKeys:()=>To,own:()=>jt,parsedType:()=>$,partial:()=>yg,pick:()=>pg,prefixIssues:()=>ye,primitiveTypes:()=>So,promiseAllObject:()=>ug,propertyKeyTypes:()=>zn,randomString:()=>lg,required:()=>$g,safeExtend:()=>vg,shallowClone:()=>bn,slugify:()=>ko,stringifyPrimitive:()=>y,toZod:()=>_n,uint8ArrayToBase64:()=>zd,uint8ArrayToBase64url:()=>wg,uint8ArrayToHex:()=>Ig,unwrapMessage:()=>Rt});function tg(n){return n}function ng(n){return n}function _n(){return n=>n}function rg(n){}function ig(n){throw new Error("Unexpected value in exhaustive check")}function og(n){}function yn(n){let e=Object.values(n).filter(i=>typeof i=="number");return Object.entries(n).filter(([i,t])=>e.indexOf(+i)===-1).map(([i,t])=>t)}function v(n,e="|"){return n.map(r=>y(r)).join(e)}function Ut(n,e){return typeof e=="bigint"?e.toString():e}function Nt(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ur(n){return n==null}function $n(n){let e=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(e,r)}function xn(n,e){let r=n/e,i=Math.round(r),t=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<t?0:r-i}var xd=Symbol("evaluating");function wo(n,e,r){let i;Object.defineProperty(n,e,{get(){if(i!==xd)return i===void 0&&(i=xd,i=r()),i},set(t){Object.defineProperty(n,e,{value:t})},configurable:!0})}function ag(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function Q(n,e,r){Object.defineProperty(n,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ae(...n){let e={};for(let r of n){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function sg(n){return Ae(n._zod.def)}function cg(n,e){return e?e.reduce((r,i)=>r?.[i],n):n}function ug(n){let e=Object.keys(n),r=e.map(i=>n[i]);return Promise.all(r).then(i=>{let t={};for(let o=0;o<e.length;o++)t[e[o]]=i[o];return t})}function lg(n=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<n;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function _e(n){return JSON.stringify(n)}function ko(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var lr="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function ht(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var Io=Nt(()=>{if(ie.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function Re(n){if(ht(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(ht(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function bn(n){return Re(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}function dg(n){let e=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&e++;return e}var mg=n=>{let e=typeof n;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},zn=new Set(["string","number","symbol"]),So=new Set(["string","number","bigint","boolean","symbol","undefined"]);function je(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(n,e,r){let i=new n._zod.constr(e??n._zod.def);return(!e||r?.parent)&&(i._zod.parent=n),i}function k(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function fg(n){let e;return new Proxy({},{get(r,i,t){return e??(e=n()),Reflect.get(e,i,t)},set(r,i,t,o){return e??(e=n()),Reflect.set(e,i,t,o)},has(r,i){return e??(e=n()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=n()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=n()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=n()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,t){return e??(e=n()),Reflect.defineProperty(e,i,t)}})}function y(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function To(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var Po={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Do={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function pg(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Ae(n._zod.def,{get shape(){let a={};for(let s of Reflect.ownKeys(e)){if(!Object.prototype.hasOwnProperty.call(r.shape,s))throw new Error(`Unrecognized key: "${String(s)}"`);e[s]&&Q(a,s,r.shape[s])}return Q(this,"shape",a),a},checks:[]});return V(n,o)}function hg(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Ae(n._zod.def,{get shape(){let a={...n._zod.def.shape};for(let s of Reflect.ownKeys(e)){if(!Object.prototype.hasOwnProperty.call(r.shape,s))throw new Error(`Unrecognized key: "${String(s)}"`);e[s]&&delete a[s]}return Q(this,"shape",a),a},checks:[]});return V(n,o)}function gg(n,e){if(!Re(e))throw new Error("Invalid input to extend: expected a plain object");let r=n._zod.def.checks;if(r&&r.length>0){let o=n._zod.def.shape;for(let a of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let t=Ae(n._zod.def,{get shape(){let o={...n._zod.def.shape,...e};return Q(this,"shape",o),o}});return V(n,t)}function vg(n,e){if(!Re(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Ae(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e};return Q(this,"shape",i),i}});return V(n,r)}function _g(n,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(n._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Ae(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e._zod.def.shape};return Q(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return V(n,r)}function yg(n,e,r,i="partial"){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=Ae(e._zod.def,{get shape(){let c=e._zod.def.shape,u={...c};if(r)for(let l of Reflect.ownKeys(r)){if(!Object.prototype.hasOwnProperty.call(c,l))throw new Error(`Unrecognized key: "${String(l)}"`);r[l]&&(u[l]=n?new n({type:"optional",innerType:c[l]}):c[l])}else for(let l of Reflect.ownKeys(c))u[l]=n?new n({type:"optional",innerType:c[l]}):c[l];return Q(this,"shape",u),u},checks:[]});return V(e,s)}function $g(n,e,r){let i=Ae(e._zod.def,{get shape(){let t=e._zod.def.shape,o={...t};if(r)for(let a of Reflect.ownKeys(r)){if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Unrecognized key: "${String(a)}"`);r[a]&&(o[a]=new n({type:"nonoptional",innerType:t[a]}))}else for(let a of Reflect.ownKeys(t))o[a]=new n({type:"nonoptional",innerType:t[a]});return Q(this,"shape",o),o}});return V(e,i)}function nt(n,e=0){if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function Oo(n,e=0){if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(n.issues[r]?.continue===!1)return!0;return!1}function ye(n,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(n),r})}function Rt(n){return typeof n=="string"?n:n?.message}function dr(n,e,r){var i;for(let t=e;t<n.length;t++)(i=n[t]).schema??(i.schema=r)}function $e(n,e,r){var i;let t=n.inst?._zod?.traits;t?.has("$ZodType")&&(t.has("$ZodCheck")?(i=n).schema??(i.schema=n.inst):n.schema=n.inst);let o=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,a=n.message?n.message:Rt(n.inst?._zod.def?.error?.(n))??Rt(o?.(n))??Rt(e?.error?.(n))??Rt(r.customError?.(n))??Rt(r.localeError?.(n))??"Invalid input",{inst:s,schema:c,continue:u,input:l,...d}=n;return d.path??(d.path=[]),d.message=a,e?.reportInput&&(d.input=l),d}function wn(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}var xg=/[\uD800-\uDBFF]/;function gt(n){let e=n.length;if(!xg.test(n))return e;let r=e;for(let i=0;i<e-1;i++)(n.charCodeAt(i)&64512)===55296&&(n.charCodeAt(i+1)&64512)===56320&&(r--,i++);return r}function kn(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function $(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let r=n;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function At(...n){let[e,r,i]=n;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function bg(n){return Object.entries(n).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function bd(n){let e=atob(n),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function zd(n){let e="";for(let r=0;r<n.length;r++)e+=String.fromCharCode(n[r]);return btoa(e)}function zg(n){let e=n.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return bd(e+r)}function wg(n){return zd(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kg(n){let e=n.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function Ig(n){return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}var zo=class{constructor(...e){}};function Ro(n,e){for(let r in e){let i=Object.getOwnPropertyDescriptor(e,r);i.get?Object.defineProperty(n,r,{...i,enumerable:!1}):Sg(n,r,i.value)}}function jt(n,e,r,i=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function jo(n,e,r){return jt(n,e,r,!1)}function Sg(n,e,r){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?r:jt(this,e,r.bind(this))},set(i){jt(this,e,i)}})}function Tg(n,e){let r=Object.getPrototypeOf(n);return e in r?void 0:r}var bo,tt=!1,Pg={configurable:!0,get(){tt=!0}};function C(n,e,r){let i=Object.getPrototypeOf(n._zod);if(e in i&&bo!==n._zod){bo=void 0;return}bo=n._zod,Object.defineProperty(i,e,{configurable:!0,get(){Object.defineProperty(this,e,Pg);let t=tt;tt=!1;try{let o=r(this);return tt?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),tt=tt||t,o}catch(o){throw delete this[e],tt=tt||t,o}},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}function Dg(n,e,r,i){let t=Tg(n,e);t&&Object.defineProperty(t,e,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,e,o),o.value=r(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var mr="~constantCatch";function Uo(n){let e=()=>n;return e[mr]=!0,e}var wd,Ao=Object.freeze({status:"aborted"}),No={value:void 0,enumerable:!1},kd="captureStackTrace"in Error?Error:null;function Og(n){let e=kd;if(e){let r=e.stackTraceLimit;if(typeof r=="number"){try{e.stackTraceLimit=0}catch{return kd=null,new n}try{return new n}finally{e.stackTraceLimit=r}}}return new n}function g(n,e,r,i){let t={};function o(m){this.def=m,this.constr=d,this.traits=new Set}o.prototype=t;let a=r,s=a&&new WeakSet;function c(m,f){if(!m._zod){No.value=new o(f);try{Object.defineProperty(m,"_zod",No)}finally{No.value=void 0}}if(m._zod.traits.has(n))return;if(m._zod.traits.add(n),e(m,f),s){let _=Object.getPrototypeOf(m),z=m._zod.constr.prototype,P=_;for(;P&&P!==z;)P=Object.getPrototypeOf(P);let x=P??_;s.has(x)||(s.add(x),Ro(x,a))}let h=d.prototype;for(let _ in h)Object.prototype.hasOwnProperty.call(h,_)&&(_ in m||(m[_]=h[_].bind(m)))}let u=i?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:n});function d(m){let f=i?.Parent?Og(l):this;c(f,m);let h=f._zod.deferred;if(h){for(let z of h)z();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;return _&&_(f),f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:m=>i?.Parent&&m instanceof i.Parent?!0:m?._zod?.traits?.has(n)}),Object.defineProperty(d,"name",{value:n}),d}var Eo=Symbol("zod_brand"),xe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},rt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(wd=globalThis).__zod_globalConfig??(wd.__zod_globalConfig={});var ie=globalThis.__zod_globalConfig;function ee(n){return n&&Object.assign(ie,n),ie}function Rg(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,Ut,2)),n.message}function jg(n){this._zod.message=n}var Ug={get:Rg,set:jg,enumerable:!0,configurable:!0},Co={value:void 0,enumerable:!1},Fo={value:void 0,enumerable:!1},Id=new WeakSet([Object.prototype,Error.prototype]),Sd=(n,e)=>{n.name="$ZodError",Co.value=n._zod,Object.defineProperty(n,"_zod",Co),Fo.value=e,Object.defineProperty(n,"issues",Fo),Co.value=void 0,Fo.value=void 0,Object.defineProperty(n,"message",Ug);let r=Object.getPrototypeOf(n);Id.has(r)||(Id.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},In=g("$ZodError",Sd),be=g("$ZodError",Sd,void 0,{Parent:Error});function Ng(n,e,r){return Object.prototype.hasOwnProperty.call(n,e)||(e==="__proto__"?Object.defineProperty(n,e,{value:r(),writable:!0,enumerable:!0,configurable:!0}):n[e]=r()),n[e]}function Sn(n,e=r=>r.message){let r={},i=[];for(let t of n.issues)t.path.length>0?Ng(r,t.path[0],()=>[]).push(e(t)):i.push(e(t));return{formErrors:i,fieldErrors:r}}function Tn(n,e=r=>r.message){let r={_errors:[]},i=(t,o=[])=>{for(let a of t.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)r._errors.push(e(a));else{let c=r,u=0;for(;u<s.length;){let l=s[u],d=u===s.length-1;if(l==="_errors"){d&&c._errors.push(e(a)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];d&&m._errors.push(e(a)),c=m,u++}}}};return i(n),r}function Lo(n,e=r=>r.message){let r={errors:[]},i=(t,o=[])=>{var a;for(let s of t.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>i({issues:c},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let c=[...o,...s.path];if(c.length===0){r.errors.push(e(s));continue}let u=r,l=0;for(;l<c.length;){let d=c[l],m=l===c.length-1;typeof d=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,d)||Object.defineProperty(u.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[d]):(u.items??(u.items=[]),(a=u.items)[d]??(a[d]={errors:[]}),u=u.items[d]),m&&u.errors.push(e(s)),l++}}};return i(n),r}function Td(n){let e=[],r=n.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function Mo(n){let e=[],r=[...n.issues].sort((i,t)=>(i.path??[]).length-(t.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${Td(i.path)}`);return e.join(`
@@ -58,6 +58,6 @@ ${c}`:c:"",l=Function,d=`return (input) => {
58
58
  ${c}
59
59
  }`,m;try{m=new l(...a,d)(...s)}catch(f){throw new L(`this schema (generated code failed to evaluate: ${f.message})`)}return e?.debug&&(m.code=u),m}function j(n,e){for(let[i,t]of n.constants)if(t===e)return i;let r=`c${n.constantCounter++}`;return n.constants.set(r,e),r}function U(n){return`v${n.varCounter++}`}function Z_(n,e){let r=n._zod.run({value:e,issues:[]},{});if(r&&typeof r.then=="function")return Se;let i=r;return i.issues.length===0?i.value:Se}function pe(n,e,r,i,t=!0){let o=n.content.length,a=e.constants.size,s=e.constantCounter,c=e.varCounter;try{return Y(n,e,r,i,t)}catch(u){if(!(u instanceof L)||!u.islandable)throw u;if(n.content.length=o,e.constants.size>a){let l=Array.from(e.constants.keys()).slice(a);for(let d of l)e.constants.delete(d)}return e.constantCounter=s,e.varCounter=c,C_(n,e,r,i)}}function C_(n,e,r,i){let t=j(e,r),o=j(e,Z_),a=U(e);return n.write(`const ${a} = ${o}(${t}, ${i});`),n.write(`if (${a} === INVALID) return INVALID;`),a}var F_=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function L_(n,e,r,i){let t=r._zod.def.checks;if(!t||t.length===0)return i;let o=i;for(let a of t){let s=a._zod.def;if(s.when&&!F_.has(s.check))throw new L('check with a custom "when" condition');switch(s.check){case"greater_than":M_(n,e,s,o);break;case"less_than":V_(n,e,s,o);break;case"multiple_of":B_(n,e,s,o);break;case"number_format":gf(n,s,o);break;case"min_length":{let c=$t(s.minimum,"min_length"),u=sc(n,e,o,`${o}.length >= ${c} && ${o}.length < ${s.minimum*2}`);n.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{let c=$t(s.maximum,"max_length"),u=sc(n,e,o,`${o}.length > ${c}`);n.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{let c=$t(s.length,"length_equals"),u=sc(n,e,o,`${o}.length >= ${c} && ${o}.length <= ${s.length*2}`);n.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":n.write(`if (${o}.size < ${$t(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":n.write(`if (${o}.size > ${$t(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":n.write(`if (${o}.size !== ${$t(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=vf(n,e,s,o);break;case"custom":o=W_(n,e,a,o);break;case"bigint_format":J_(n,s,o);break;case"mime_type":K_(n,e,s,o);break;case"property":q_(n,e,s,o);break;case"overwrite":{let c=U(e);G_(n,e,a,o,c),o=c;break}default:throw new L(`check type ${s.check}`)}}return o}function sc(n,e,r,i){let t=j(e,gt),o=U(e);return n.write(`const ${o} = typeof ${r} === "string" && ${i} ? ${t}(${r}) : ${r}.length;`),o}function $t(n,e){if(typeof n!="number"||!Number.isFinite(n))throw new L(`${e} bound of type ${typeof n}`);return`${n}`}function hf(n,e){if(typeof e=="bigint")return`${e}n`;if(typeof e=="number"){if(Number.isNaN(e))throw new L("comparison check with NaN bound");return`${e}`}if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new L("comparison check with Invalid Date bound");return j(n,e)}throw new L(`comparison check bound of type ${typeof e}`)}function M_(n,e,r,i){let t=r.inclusive?"<":"<=";n.write(`if (${i} ${t} ${hf(e,r.value)}) return INVALID;`)}function V_(n,e,r,i){let t=r.inclusive?">":">=";n.write(`if (${i} ${t} ${hf(e,r.value)}) return INVALID;`)}function B_(n,e,r,i){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new L("multiple_of check with a zero divisor");n.write(`if (${i} % ${r.value}n !== 0n) return INVALID;`)}else{let t=j(e,xn);n.write(`if (${t}(${i}, ${$t(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function gf(n,e,r){let i=e.format;switch(i){case"safeint":n.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":n.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":n.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":n.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":n.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new L(`number format ${i}`)}}function J_(n,e,r){let i=e.format;if(i)switch(i){case"int64":n.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":n.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new L(`bigint format ${i}`)}}function K_(n,e,r,i){let t=r.mime;if(t&&t.length>0){let o=j(e,new Set(t));n.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function q_(n,e,r,i){let t=`${i}[${JSON.stringify(r.property)}]`;Y(n,e,r.schema,t)}function G_(n,e,r,i,t){let o=r._zod.def.tx;if(!o)throw new L("overwrite check without a transform function");if(zt(o))throw new Ee("z.compile: async overwrite transforms are not supported");let a=j(e,o);n.write(`const ${t} = ${a}(${i});`)}function cc(){throw new xe}function dc(n){this.issues.push(n)}function W_(n,e,r,i){let t=r._zod.def;if(t.fn){if(zt(t.fn))throw new Ee("z.compile: async .refine() predicates are not supported");let o=j(e,t.fn),a=j(e,cc),s=U(e);return n.write(`const ${s} = ${o}(${i});`),n.write(`if (${s} instanceof Promise) ${a}();`),n.write(`if (!${s}) return INVALID;`),i}if(r._zod.check){if(zt(r._zod.check))throw new Ee("z.compile: async .superRefine() / check functions are not supported");let o=r._zod.check,s=j(e,u=>{let l={value:u,issues:[],addIssue:dc};return o(l)instanceof Promise&&cc(),l.issues.length===0?l.value:Se}),c=U(e);return n.write(`const ${c} = ${s}(${i});`),n.write(`if (${c} === INVALID) return INVALID;`),c}throw new L("custom check without a predicate or check function")}var H_=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function vf(n,e,r,i){let t=r.format;if(t==="base64"){let c=j(e,jn);return n.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="base64url"){let c=j(e,Fr);return n.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="jwt"){let c=j(e,Mr),u=j(e,r.alg??null);return n.write(`if (!${c}(${i}, ${u})) return INVALID;`),i}if(t==="ipv6"){let c=j(e,Rn);return n.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="cidrv6"){let c=j(e,Cr);return n.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="credit_card"){let c=j(e,Lr);return n.write(`if (!${c}(${i})) return INVALID;`),i}let o=r;if(t==="url"||t==="httpurl"||o.normalize||o.hostname!==void 0||o.protocol!==void 0){let c=j(e,Nr),u=j(e,r),l=U(e),d=U(e);if(n.write(`const ${l} = ${i}.trim();`),n.write(`const ${d} = ${c}(${l}, ${u});`),n.write(`if (typeof ${d} === "number") return INVALID;`),o.hostname!==void 0){let h=j(e,Er);n.write(`if (!${h}(${d}, ${u}.hostname)) return INVALID;`)}if(o.protocol!==void 0){let h=j(e,Zr);n.write(`if (!${h}(${d}, ${u}.protocol)) return INVALID;`)}let m=U(e),f=o.normalize?`${d}.href`:`${j(e,Ar)}(${l})`;return n.write(`const ${m} = ${f};`),m}let a=r.fn;if(a){if(zt(a))throw new L(`async string format ${t}`);let c=j(e,a);return n.write(`if (!${c}(${i})) return INVALID;`),i}if(H_.has(t)&&r.pattern){let c=j(e,r.pattern);return n.write(`${c}.lastIndex = 0;`),n.write(`if (!${c}.test(${i})) return INVALID;`),i}let s=r.format;switch(s){case"regex":throw new L("regex format without a pattern");case"lowercase":n.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":n.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":n.write(`if (!${i}.includes(${_e(r.includes)})) return INVALID;`);break;case"starts_with":{let c=r.prefix;n.write(`if (${i}.slice(0, ${c.length}) !== ${_e(c)}) return INVALID;`);break}case"ends_with":{let c=r.suffix;n.write(`if (${i}.slice(-${c.length}) !== ${_e(c)}) return INVALID;`);break}default:throw new L(`string format ${s}`)}return i}function Y(n,e,r,i,t=!0){let o=r._zod.def,a=o.type;if(o.coerce)throw new L(`coercion (z.coerce.${a}())`);let s=t||!!o.checks?.length,c;switch(a){case"string":c=X_(n,e,r,i);break;case"number":c=Y_(n,r,i);break;case"boolean":c=Q_(n,i);break;case"bigint":c=ey(n,r,i);break;case"symbol":c=ty(n,i);break;case"undefined":c=ny(n,i);break;case"null":c=ry(n,i);break;case"any":case"unknown":c=i;break;case"never":n.write("return INVALID;"),c=i;break;case"void":c=iy(n,i);break;case"nan":c=oy(n,i);break;case"date":c=ay(n,i);break;case"object":c=sy(n,e,r,i,s);break;case"optional":c=cy(n,e,r,i,s);break;case"nullable":c=dy(n,e,r,i,s);break;case"array":c=my(n,e,r,i,s);break;case"literal":c=fy(n,e,r,i);break;case"enum":c=py(n,e,r,i);break;case"readonly":{let u=ff(n,e,r,i),l=U(e);n.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":ff(n,e,r,i),c="true";break;case"default":case"prefault":c=hy(n,e,r,i);break;case"nonoptional":c=gy(n,e,r,i);break;case"tuple":c=vy(n,e,r,i);break;case"union":c=_y(n,e,r,i);break;case"intersection":c=xy(n,e,r,i);break;case"record":c=by(n,e,r,i);break;case"map":c=wy(n,e,r,i);break;case"set":c=ky(n,e,r,i);break;case"file":c=Iy(n,i);break;case"template_literal":c=Sy(n,e,r,i);break;case"lazy":c=Ty(n,e,r,i);break;case"pipe":c=Py(n,e,r,i);break;case"custom":c=Dy(n,e,r,i);break;case"transform":c=jy(n,e,r,i);break;case"catch":c=Ry(n,e,r,i);break;default:throw new L(`schema type ${a}`)}return c===null?null:L_(n,e,r,c)}function X_(n,e,r,i){n.write(`if (typeof ${i} !== "string") return INVALID;`);let t=r._zod.def;return t.format===void 0?i:vf(n,e,t,i)}function Y_(n,e,r){n.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let i=e._zod.def;return i.check==="number_format"&&i.format&&gf(n,{format:i.format},r),r}function Q_(n,e){return n.write(`if (typeof ${e} !== "boolean") return INVALID;`),e}function ey(n,e,r){n.write(`if (typeof ${r} !== "bigint") return INVALID;`);let i=e._zod.def;if(i.format)switch(i.format){case"int64":n.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":n.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function ty(n,e){return n.write(`if (typeof ${e} !== "symbol") return INVALID;`),e}function ny(n,e){return n.write(`if (${e} !== undefined) return INVALID;`),e}function ry(n,e){return n.write(`if (${e} !== null) return INVALID;`),e}function iy(n,e){return n.write(`if (${e} !== undefined) return INVALID;`),e}function oy(n,e){return n.write(`if (typeof ${e} !== "number" || !Number.isNaN(${e})) return INVALID;`),e}function ay(n,e){return n.write(`if (!(${e} instanceof Date) || Number.isNaN(${e}.getTime())) return INVALID;`),e}function sy(n,e,r,i,t=!0){let o=r._zod.def;n.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),u=c.length?[...s,...c]:s,l=x=>typeof x=="symbol"?j(e,x):_e(x),d=x=>typeof x=="symbol"?`[${l(x)}]`:_e(x),m=a;if(s.includes("__proto__"))throw new L('object shape key "__proto__"');let f=new Map;for(let x of u){let T=m[x],D=l(x),A=U(e);if(n.write(`const ${A} = ${i}[${D}];`),T._zod.optin!==void 0){let S=U(e);n.write(`let ${S} = (() => {`),n.indented(Z=>{let K=pe(Z,e,T,A);Z.write(`return ${K};`)}),n.write("})();"),T._zod.optout==="optional"?(n.write(`if (${S} === INVALID) {`),n.indented(Z=>{Z.write(`if (${D} in ${i}) return INVALID;`),Z.write(`${S} = undefined;`)}),n.write("}")):n.write(`if (${S} === INVALID) return INVALID;`),f.set(x,S)}else{ly(T)&&n.write(`if (!(${D} in ${i})) return INVALID;`);let S=pe(n,e,T,A,t);S!==null&&f.set(x,S)}}let h=o.catchall,_="none";if(h){let x=h._zod.def.type;if(x==="never"){let T=s.map(D=>`k !== ${_e(D)}`).join(" && ")||"true";n.write(`for (const k in ${i}) {`),n.indented(D=>{D.write(`if (${T}) return INVALID;`)}),n.write("}")}else(x==="unknown"||x==="any")&&!h._zod.def.checks?.length?_="passthrough":_="schema"}let z=U(e),P=u.some(x=>bt(m[x])||uc(m[x]));if(!t){if(_==="schema"){let x=s.length>0?j(e,new Set(s)):null;n.write(`for (const k in ${i}) {`),n.indented(T=>{T.write('if (k === "__proto__") continue;'),x&&T.write(`if (${x}.has(k)) continue;`);let D=U(e);T.write(`const ${D} = ${i}[k];`),pe(T,e,h,D,!1)}),n.write("}")}return null}if(P){n.write(`const ${z} = {};`);for(let x of u){let T=l(x),D=f.get(x);uc(m[x])?n.write(`if (${T} in ${i}) ${z}[${T}] = ${D};`):bt(m[x])?n.write(`if (${D} !== undefined || ${T} in ${i}) ${z}[${T}] = ${D};`):n.write(`${z}[${T}] = ${D};`)}}else{let x=u.map(T=>`${d(T)}: ${f.get(T)}`).join(", ");n.write(`const ${z} = { ${x} };`)}if(_!=="none"){let x=s.length>0?j(e,new Set(s)):null;n.write(`for (const k in ${i}) {`),n.indented(T=>{if(T.write('if (k === "__proto__") continue;'),x&&T.write(`if (${x}.has(k)) continue;`),_==="passthrough")T.write(`${z}[k] = ${i}[k];`);else{let D=U(e);T.write(`const ${D} = ${i}[k];`);let A=pe(T,e,h,D);T.write(`${z}[k] = ${A};`)}}),n.write("}")}return z}function cy(n,e,r,i,t=!0){let o=r._zod.def;if(uy(r))return Y(n,e,o.innerType,i,t);if(o.innerType._zod.optin==="defaulted"){let s=U(e),c=U(e);return n.write(`let ${s};`),n.write(`if (${i} === undefined) {`),n.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{let d=Y(l,e,o.innerType,i);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${s} = ${c};`)}),n.write("} else {"),n.indented(u=>{let l=Y(u,e,o.innerType,i);u.write(`${s} = ${l};`)}),n.write("}"),s}let a=t?U(e):null;return a&&n.write(`let ${a};`),n.write(`if (${i} !== undefined) {`),n.indented(s=>{let c=Y(s,e,o.innerType,i,t);a&&c!==null&&s.write(`${a} = ${c};`)}),n.write("}"),a}function uy(n){return n._zod.traits?.has("$ZodExactOptional")===!0}function ly(n){return n._zod.optin===void 0&&xt(n)}function xt(n){if(n._zod.def.coerce)return!0;let e=n._zod.def;switch(e.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return e.innerType?xt(e.innerType):!1;case"literal":return!!e.values?.includes(void 0);case"enum":return!!n._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return e.innerType?xt(e.innerType):!0;case"catch":return!0;case"union":return e.options?e.options.some(xt):!0;case"intersection":return!e.left||!e.right?!0:xt(e.left)&&xt(e.right);case"pipe":return e.in?xt(e.in):!0;default:return!0}}function uc(n){return n._zod.optin==="optional"&&n._zod.optout==="optional"}function bt(n){let e=n._zod.def;switch(e.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!e.values?.includes(void 0);case"enum":return!!n._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return e.innerType?bt(e.innerType):!0;case"union":return e.options?e.options.some(bt):!0;case"intersection":return!e.left||!e.right||bt(e.left)||bt(e.right);case"pipe":return e.out?bt(e.out):!0;default:return!0}}function dy(n,e,r,i,t=!0){let o=r._zod.def,a=t?U(e):null;return a&&n.write(`let ${a} = null;`),n.write(`if (${i} !== null) {`),n.indented(s=>{let c=Y(s,e,o.innerType,i,t);a&&c!==null&&s.write(`${a} = ${c};`)}),n.write("}"),a}function my(n,e,r,i,t=!0){let o=r._zod.def;n.write(`if (!Array.isArray(${i})) return INVALID;`);let a=t?U(e):null,s=U(e),c=U(e);return a&&n.write(`const ${a} = new Array(${i}.length);`),n.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),n.indented(u=>{u.write(`const ${c} = ${i}[${s}];`);let l=pe(u,e,o.element,c,t);a&&l!==null&&u.write(`${a}[${s}] = ${l};`)}),n.write("}"),a}function fy(n,e,r,i){let o=r._zod.def.values;if(o.length!==1){let s=j(e,new Set(o));return n.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=j(e,new Set(o));return n.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")n.write(`if (${i} !== ${_e(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")n.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)n.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)n.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")n.write(`if (${i} !== ${a}n) return INVALID;`);else throw new L(`literal type ${typeof a}`);return i}function py(n,e,r,i){let t=r._zod.values;if(!t)throw new L("enum schema without enumerated values");let o=j(e,t);return n.write(`if (!${o}.has(${i})) return INVALID;`),i}function ff(n,e,r,i){let t=r._zod.def;return Y(n,e,t.innerType,i)}function hy(n,e,r,i){let t=r._zod.def,a=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!a)return Y(n,e,t.innerType,i);let c=j(e,a),u=U(e);return n.write(`let ${u} = ${i};`),n.write(`if (${i} === undefined) ${u} = ${c}();`),Y(n,e,t.innerType,u)}let s=U(e);if(a){let c=j(e,a),u=j(e,bn);n.write(`let ${s};`),n.write(`if (${i} === undefined) {`),n.indented(l=>{l.write(`${s} = ${u}(${c}());`)}),n.write("} else {"),n.indented(l=>{let d=Y(l,e,t.innerType,i);l.write(`${s} = ${d} === undefined ? ${u}(${c}()) : ${d};`)}),n.write("}")}else n.write(`let ${s};`),n.write(`if (${i} !== undefined) {`),n.indented(c=>{let u=Y(c,e,t.innerType,i);c.write(`${s} = ${u};`)}),n.write("}");return s}function gy(n,e,r,i){let t=r._zod.def,o=Y(n,e,t.innerType,i),a=U(e);return n.write(`const ${a} = ${o};`),n.write(`if (${a} === undefined) return INVALID;`),a}function vy(n,e,r,i){let t=r._zod.def,o=t.items,a=t.rest;n.write(`if (!Array.isArray(${i})) return INVALID;`);let s=pf(o,"optin"),c=pf(o,"optout");a?n.write(`if (${i}.length < ${s}) return INVALID;`):n.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let u=U(e);n.write(`const ${u} = [];`);for(let l=0;l<o.length;l++){let d=o[l];if(l>=c)n.write(`if (${u}.length === ${l}) {`),n.indented(m=>{m.write(`if (${l} < ${i}.length) {`),m.indented(f=>{let h=U(e);f.write(`const ${h} = ${i}[${l}];`);let _=pe(f,e,d,h);f.write(`${u}[${l}] = ${_};`)}),m.write("} else {"),m.indented(f=>{if(uc(d)){f.write(`${u}.length = ${l};`);return}let h=U(e),_=U(e);f.write(`const ${h} = undefined;`),f.write(`const ${_} = (() => {`),f.indented(z=>{let P=pe(z,e,d,h);z.write(`return ${P};`)}),f.write("})();"),f.write(`if (${_} === INVALID || ${_} === undefined) ${u}.length = ${l};`),f.write(`else ${u}[${l}] = ${_};`)}),m.write("}")}),n.write("}");else{let m=U(e);n.write(`const ${m} = ${i}[${l}];`);let f=pe(n,e,d,m);n.write(`${u}[${l}] = ${f};`)}}if(a){let l=U(e),d=U(e);n.write(`for (let ${l} = ${o.length}; ${l} < ${i}.length; ${l}++) {`),n.indented(m=>{m.write(`const ${d} = ${i}[${l}];`);let f=pe(m,e,a,d);m.write(`${u}[${l}] = ${f};`)}),n.write("}")}return u}function pf(n,e){for(let r=n.length-1;r>=0;r--)if(!(e==="optin"?n[r]._zod.optin!==void 0:n[r]._zod.optout==="optional"))return r+1;return 0}function _y(n,e,r,i){let t=r._zod.def,o=t.options;if(t.discriminator)return yy(n,e,t,i);if(t.inclusive===!1)throw new L("exclusive unions (z.xor)");if(o.length===0)return n.write("return INVALID;"),i;if(o.length===1)return Y(n,e,o[0],i);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(l=>l._zod.def.values)),u=j(e,c);return n.write(`if (!${u}.has(${i})) return INVALID;`),i}let s=U(e);n.write(`let ${s};`);for(let c=0;c<o.length;c++){let u=o[c];c===0?n.write(`${s} = (() => {`):n.write(`if (${s} === INVALID) ${s} = (() => {`),n.indented(l=>{let d=Y(l,e,u,i);l.write(`return ${d};`)}),n.write("})();")}return n.write(`if (${s} === INVALID) return INVALID;`),s}function yy(n,e,r,i){if(r.unionFallback)throw new L("discriminated union with unionFallback");if(r.options.length===0)return n.write("return INVALID;"),i;let t=U(e),o=U(e);n.write(`const ${t} = ${i}?.[${_e(r.discriminator)}];`),n.write(`let ${o};`);let a=!0,s=new Set;for(let c of r.options){let u=c._zod.propValues?.[r.discriminator];if(!u||u.size===0)throw new L("discriminated union option without static discriminator values");for(let m of u){if(s.has(m))throw new L(`duplicate discriminator value ${String(m)}`);s.add(m)}let l=Array.from(u,m=>$y(e,t,m)),d=a?"if":"else if";n.write(`${d} (${l.join(" || ")}) {`),n.indented(m=>{let f=Y(m,e,c,i);m.write(`${o} = ${f};`)}),n.write("}"),a=!1}return n.write("else { return INVALID; }"),o}function $y(n,e,r){if(typeof r=="string")return`${e} === ${_e(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${e})`:`${e} === ${r}`;if(typeof r=="boolean")return`${e} === ${r}`;if(r===null)return`${e} === null`;if(r===void 0)return`${e} === undefined`;if(typeof r=="bigint")return`${e} === ${r}n`;if(typeof r=="symbol"){let i=j(n,r);return`${e} === ${i}`}throw new L(`literal discriminator value ${String(r)}`)}function xy(n,e,r,i){let t=r._zod.def,o=pe(n,e,t.left,i),a=pe(n,e,t.right,i),s=j(e,Mt),c=U(e);return n.write(`const ${c} = ${s}(${o}, ${a});`),n.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function by(n,e,r,i){let t=r._zod.def,o=j(e,Re);n.write(`if (!${o}(${i})) return INVALID;`);let a=U(e),s=U(e),c=U(e);n.write(`const ${a} = {};`);let u=t,l=u.partial?void 0:t.keyType._zod.values;if(l){let h=[];for(let z of l){if(!(typeof z=="string"||typeof z=="number"||typeof z=="symbol"))throw new L(`record key value ${String(z)}`);let P=typeof z=="number"?z.toString():z;if(P==="__proto__")throw new L('record key "__proto__"');h.push(P);let x=j(e,z),T=Y(n,e,t.keyType,x),D=U(e);n.write(`const ${D} = ${i}[${zy(e,P)}];`);let A=pe(n,e,t.valueType,D);n.write(`${a}[${T}] = ${A};`)}let _=j(e,new Set(h));return n.write(`for (const ${s} in ${i}) {`),n.indented(z=>{z.write(`if (${_}.has(${s})) continue;`),u.mode==="loose"?z.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):z.write("return INVALID;")}),n.write("}"),a}let d=t.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let h=t.mode==="loose",_=j(e,ri(t.keyType)),z=j(e,it),P=j(e,Object.prototype.propertyIsEnumerable),x=U(e);return n.write(`for (const ${s} of Reflect.ownKeys(${i})) {`),n.indented(T=>{T.write(`if (${s} === "__proto__") continue;`),T.write(`if (!${P}.call(${i}, ${s})) continue;`),T.write(`let ${x} = ${_}(${s});`),T.write(`if (${x} === INVALID && typeof ${s} === "string" && ${z}.test(${s})) ${x} = ${_}(Number(${s}));`),h?T.write(`if (${x} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):T.write(`if (${x} === INVALID) return INVALID;`),T.write(`if (${x} === "__proto__") continue;`);let D=U(e);T.write(`const ${D} = ${i}[${s}];`);let A=pe(T,e,t.valueType,D);T.write(`${a}[${x}] = ${A};`)}),n.write("}"),a}let f=j(e,Object.prototype.propertyIsEnumerable);return n.write(`for (const ${s} of Reflect.ownKeys(${i})) {`),n.indented(h=>{h.write(`if (${s} === "__proto__") continue;`),h.write(`if (!${f}.call(${i}, ${s})) continue;`),h.write(`if (typeof ${s} !== "string") return INVALID;`),h.write(`const ${c} = ${i}[${s}];`);let _=pe(h,e,t.valueType,c);h.write(`${a}[${s}] = ${_};`)}),n.write("}"),a}function zy(n,e){return typeof e=="string"?_e(e):j(n,e)}function wy(n,e,r,i){let t=r._zod.def;n.write(`if (!(${i} instanceof Map)) return INVALID;`);let o=U(e),a=U(e),s=U(e);return n.write(`const ${o} = new Map();`),n.write(`for (const [${a}, ${s}] of ${i}) {`),n.indented(c=>{let u=Y(c,e,t.keyType,a),l=Y(c,e,t.valueType,s);c.write(`${o}.set(${u}, ${l});`)}),n.write("}"),o}function ky(n,e,r,i){let t=r._zod.def;n.write(`if (!(${i} instanceof Set)) return INVALID;`);let o=U(e),a=U(e);return n.write(`const ${o} = new Set();`),n.write(`for (const ${a} of ${i}) {`),n.indented(s=>{let c=Y(s,e,t.valueType,a);s.write(`${o}.add(${c});`)}),n.write("}"),o}function Iy(n,e){return n.write(`if (!(${e} instanceof File)) return INVALID;`),e}function Sy(n,e,r,i){n.write(`if (typeof ${i} !== "string") return INVALID;`);let t=r._zod.pattern;if(t){let o=j(e,t);n.write(`${o}.lastIndex = 0;`),n.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function Ty(n,e,r,i){let t=r._zod.def,o=j(e,t.getter),a=j(e,{parser:null});n.write(`if (!${a}.parser) {`),n.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${a}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),n.write("}");let s=U(e);return n.write(`const ${s} = ${a}.parser(${i});`),n.write(`if (${s} === INVALID) return INVALID;`),s}function Py(n,e,r,i){let t=r._zod.def,o=Y(n,e,t.in,i);if(t.transform){if(zt(t.transform))throw new Ee("z.compile: async transforms in pipes are not supported");let a=t.transform,c=j(e,l=>{let d={value:l,issues:[],addIssue:dc},m=a(l,d);return m instanceof Promise?Se:d.issues.length===0?m:Se}),u=U(e);return n.write(`const ${u} = ${c}(${o});`),n.write(`if (${u} === INVALID) return INVALID;`),Y(n,e,t.out,u)}else return Y(n,e,t.out,o)}function zt(n){return typeof n=="function"&&(n.constructor.name==="AsyncFunction"||n[Symbol.toStringTag]==="AsyncFunction")}function Dy(n,e,r,i){let t=r._zod.def;if(t.fn){if(zt(t.fn))throw new Ee("z.compile: async custom predicates are not supported");let o=j(e,t.fn),a=j(e,cc),s=U(e);n.write(`const ${s} = ${o}(${i});`),n.write(`if (${s} instanceof Promise) ${a}();`),n.write(`if (!${s}) return INVALID;`)}else throw new L("custom schema without a predicate function");return i}function Oy(n,e,r){let i=n._zod.run({value:r,issues:[]},{});if(i&&typeof i.then=="function")return Se;let t=i;return t.issues.length===0?t.value:e()}function Ry(n,e,r,i){let t=r._zod.def;if(!t.catchValue[mr])throw new L("catch with a callback (only a constant catch value compiles)",!1);let o=U(e);n.write(`let ${o} = (() => {`),n.indented(u=>{let l=pe(u,e,t.innerType,i);u.write(`return ${l};`)}),n.write("})();");let a=j(e,t.innerType),s=j(e,t.catchValue),c=j(e,Oy);return n.write(`if (${o} === INVALID) {`),n.indented(u=>{u.write(`${o} = ${c}(${a}, ${s}, ${i});`),u.write(`if (${o} === INVALID) return INVALID;`)}),n.write("}"),o}function jy(n,e,r,i){let t=r._zod.def;if(t.transform){if(zt(t.transform))throw new Ee("z.compile: async transforms are not supported");let o=t.transform,s=j(e,u=>{let l={value:u,issues:[],addIssue:dc},d=o(u,l);return d instanceof Promise?Se:l.issues.length===0?d:Se}),c=U(e);return n.write(`const ${c} = ${s}(${i});`),n.write(`if (${c} === INVALID) return INVALID;`),c}return i}function mc(n,e){return new n({type:"string",...k(e)})}function fc(n,e){return new n({type:"string",coerce:!0,...k(e)})}function ii(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...k(e)})}function oi(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...k(e)})}function ai(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...k(e)})}function si(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(e)})}function ci(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(e)})}function ui(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(e)})}function Ln(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...k(e)})}function li(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...k(e)})}function di(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(e)})}function mi(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...k(e)})}function fi(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(e)})}function pi(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...k(e)})}function hi(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...k(e)})}function gi(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(e)})}function vi(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(e)})}function _i(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(e)})}function pc(n,e){return new n({type:"string",format:"mac",check:"string_format",abort:!1,...k(e)})}function yi(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(e)})}function $i(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(e)})}function xi(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...k(e)})}function bi(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...k(e)})}function zi(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...k(e)})}function hc(n,e){return new n({type:"string",format:"credit_card",check:"string_format",abort:!1,...k(e)})}function wi(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...k(e)})}var gc={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Mn(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(e)})}function Vn(n,e){return new n({type:"string",format:"date",check:"string_format",...k(e)})}function Bn(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...k(e)})}function Jn(n,e){return new n({type:"string",format:"duration",check:"string_format",...k(e)})}function vc(n,e){return new n({type:"number",checks:[],...k(e)})}function _c(n,e){return new n({type:"number",coerce:!0,checks:[],...k(e)})}function yc(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...k(e)})}function $c(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float32",...k(e)})}function xc(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float64",...k(e)})}function bc(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"int32",...k(e)})}function zc(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"uint32",...k(e)})}function wc(n,e){return new n({type:"boolean",...k(e)})}function kc(n,e){return new n({type:"boolean",coerce:!0,...k(e)})}function Ic(n,e){return new n({type:"bigint",...k(e)})}function Sc(n,e){return new n({type:"bigint",coerce:!0,...k(e)})}function Tc(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...k(e)})}function Pc(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...k(e)})}function Dc(n,e){return new n({type:"symbol",...k(e)})}function Oc(n,e){return new n({type:"undefined",...k(e)})}function Rc(n,e){return new n({type:"null",...k(e)})}function jc(n){return new n({type:"any"})}function Uc(n){return new n({type:"unknown"})}function Nc(n,e){return new n({type:"never",...k(e)})}function Ac(n,e){return new n({type:"void",...k(e)})}function Ec(n,e){return new n({type:"date",...k(e)})}function Zc(n,e){return new n({type:"date",coerce:!0,...k(e)})}function Cc(n,e){return new n({type:"nan",...k(e)})}function Ve(n,e){return new Sr({check:"less_than",...k(e),value:n,inclusive:!1})}function Te(n,e){return new Sr({check:"less_than",...k(e),value:n,inclusive:!0})}function Be(n,e){return new Tr({check:"greater_than",...k(e),value:n,inclusive:!1})}function Pe(n,e){return new Tr({check:"greater_than",...k(e),value:n,inclusive:!0})}function ki(n){return Be(0,n)}function Ii(n){return Ve(0,n)}function Si(n){return Te(0,n)}function Ti(n){return Pe(0,n)}function ot(n,e){return new ka({check:"multiple_of",...k(e),value:n})}function at(n,e){return new Ta({check:"max_size",...k(e),maximum:n})}function Je(n,e){return new Pa({check:"min_size",...k(e),minimum:n})}function wt(n,e){return new Da({check:"size_equals",...k(e),size:n})}function kt(n,e){return new Oa({check:"max_length",...k(e),maximum:n})}function He(n,e){return new Ra({check:"min_length",...k(e),minimum:n})}function It(n,e){return new ja({check:"length_equals",...k(e),length:n})}function Bt(n,e){return new Ua({check:"string_format",format:"regex",...k(e),pattern:n})}function Jt(n){return new Na({check:"string_format",format:"lowercase",...k(n)})}function Kt(n){return new Aa({check:"string_format",format:"uppercase",...k(n)})}function qt(n,e){return new Ea({check:"string_format",format:"includes",...k(e),includes:n})}function Gt(n,e){return new Za({check:"string_format",format:"starts_with",...k(e),prefix:n})}function Wt(n,e){return new Ca({check:"string_format",format:"ends_with",...k(e),suffix:n})}function Pi(n,e,r){return new Pr({check:"property",property:n,schema:e,...k(r)})}function Di(n){return Object.entries(n).map(([e,r])=>new Pr({check:"property",property:e,schema:r}))}function Ht(n,e){return new Fa({check:"mime_type",mime:n,...k(e)})}function Ze(n){return new La({check:"overwrite",tx:n})}function Xt(n){return Ze(e=>e.normalize(n))}function Yt(){return Ze(n=>n.trim())}function Qt(){return Ze(n=>n.toLowerCase())}function en(){return Ze(n=>n.toUpperCase())}function tn(){return Ze(n=>ko(n))}function Fc(n,e,r){return new n({type:"array",element:e,...k(r)})}function Uy(n,e,r){return new n({type:"union",options:e,...k(r)})}function Ny(n,e,r){return new n({type:"union",options:e,inclusive:!1,...k(r)})}function Ay(n,e,r,i){return new n({type:"union",options:r,discriminator:e,...k(i)})}function Ey(n,e,r){return new n({type:"intersection",left:e,right:r})}function Zy(n,e,r,i){let t=r instanceof N,o=t?i:r,a=t?r:null;return new n({type:"tuple",items:e,rest:a,...k(o)})}function Cy(n,e,r,i){return new n({type:"record",keyType:e,valueType:r,...k(i)})}function Fy(n,e,r,i){return new n({type:"map",keyType:e,valueType:r,...k(i)})}function Ly(n,e,r){return new n({type:"set",valueType:e,...k(r)})}function My(n,e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(t=>[t,t])):e;return new n({type:"enum",entries:i,...k(r)})}function Vy(n,e,r){return new n({type:"enum",entries:e,...k(r)})}function By(n,e,r){return new n({type:"literal",values:Array.isArray(e)?e:[e],...k(r)})}function Lc(n,e){return new n({type:"file",...k(e)})}function Jy(n,e){return new n({type:"transform",transform:e})}function Ky(n,e){return new n({type:"optional",innerType:e})}function qy(n,e){return new n({type:"nullable",innerType:e})}function Gy(n,e,r){return new n({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():bn(r)}})}function Wy(n,e,r){return new n({type:"nonoptional",innerType:e,...k(r)})}function Hy(n,e){return new n({type:"success",innerType:e})}function Xy(n,e,r){return new n({type:"catch",innerType:e,catchValue:typeof r=="function"?r:Uo(r)})}function Yy(n,e,r){return new n({type:"pipe",in:e,out:r})}function Qy(n,e){return new n({type:"readonly",innerType:e})}function e$(n,e,r){return new n({type:"template_literal",parts:e,...k(r)})}function t$(n,e){return new n({type:"lazy",getter:e})}function n$(n,e){return new n({type:"promise",innerType:e})}function Mc(n,e,r){let i=k(r);return i.abort??(i.abort=!0),new n({type:"custom",check:"custom",fn:e,...i})}function Vc(n,e,r){return new n({type:"custom",check:"custom",fn:e,...k(r)})}function Bc(n,e){let r=_f(i=>(i.addIssue=t=>{if(typeof t=="string")i.issues.push(At(t,i.value,r._zod.def));else{let o=t;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),i.issues.push(At(o))}},n(i.value,i)),e);return r}function _f(n,e){let r=new W({check:"custom",...k(e)});return r._zod.check=n,r}function Jc(n){let e=new W({check:"describe"});return e._zod.onattach=[r=>{let i=ae.get(r)??{};ae.add(r,{...i,description:n})}],e._zod.check=()=>{},e}function Kc(n){let e=new W({check:"meta"});return e._zod.onattach=[r=>{let i=ae.get(r)??{};ae.add(r,{...i,...n})}],e._zod.check=()=>{},e}function qc(n,e){let r=k(e),i=r.truthy??["true","1","yes","on","y","enabled"],t=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(f=>typeof f=="string"?f.toLowerCase():f),t=t.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(i),a=new Set(t),s=n.Codec??An,c=n.Boolean??Un,u=n.String??yt,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),m=new s({type:"pipe",in:l,out:d,transform:((f,h)=>{let _=f;return r.case!=="sensitive"&&(_=_.toLowerCase()),o.has(_)?!0:a.has(_)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:h.value,inst:m,continue:!1}),{})}),reverseTransform:((f,h)=>f===!0?i[0]||"true":t[0]||"false"),error:r.error});return m._zod.bag.truthy=i,m._zod.bag.falsy=t,m._zod.bag.case=r.case??"insensitive",m}function nn(n,e,r,i={}){let t=k(i),o={check:"string_format",type:"string",format:e,fn:typeof r=="function"?r:s=>r.test(s),...t};return r instanceof RegExp&&(o.pattern=r),new n(o)}function Kn(n,...e){for(let r of e)for(let i of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,i)&&Q(n,i,r[i]);return n}function st(n){let e=n?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??ae,target:e,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:n?.cycles??"ref",reused:n?.reused??"inline",intersections:[],deferred:[],external:n?.external??void 0}}function ne(n,e,r,i,t){let o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:n,path:i.path,message:t}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(t);return Object.assign(r,o),!0}function B(n,e,r={path:[],schemaPath:[]}){var i;let t=n._zod.def,o=e.seen.get(n);if(o)return o.count++,r.schemaPath.includes(n)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(n,a),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;let s=n._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,n],path:r.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,a.schema,l);else{let m=a.schema,f=e.processors[t.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);f(n,e,m,l)}let d=n._zod.parent;d&&(a.ref||(a.ref=d),B(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(n);return c&&Kn(a.schema,c),e.io==="input"&&he(n)&&(delete a.schema.examples,delete a.schema.default),e.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,e.seen.get(n).schema}function yf(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function ct(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(n.external&&n.sharedDefsExtractedFor===n.external)return;let i=new Map;for(let a of n.seen.entries()){let s=n.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let t=a=>{let s=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let d=n.external.registry.get(a[0])?.id,m=n.external.uri??(h=>h);if(d)return{ref:m(d)};let f=a[1].defId??a[1].schema.id??`schema${n.counter++}`;return a[1].defId=f,{defId:f,ref:`${m("__shared")}#/${s}/${yf(f)}`}}let c="#",u=`${c}/${s}/`;if(a[1]===r&&!a[1].schema.id)return{ref:c};let l=a[1].schema.id??`__schema${n.counter++}`;return{defId:l,ref:u+yf(l)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=t(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(n.cycles==="throw")for(let a of n.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
60
60
 
61
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of n.seen.entries()){let s=a[1];if(e===a[0]){o(a);continue}if(n.external){let u=n.external.registry.get(a[0])?.id;if(e!==a[0]&&u){o(a);continue}}if(n.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&n.reused==="ref"){o(a);continue}}n.external&&(n.sharedDefsExtractedFor=n.external)}function bf(n){let e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;let r=[];for(let i of e){if(!i||typeof i!="object")return;bf(i);let t=Object.keys(i);if(t.length!==1||t[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete n.anyOf,n.type=r.length===1?r[0]:r}var zf=new Set(["type","properties","required","additionalProperties"]),$f=["oneOf","anyOf"];function xf(n){let e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Gc(n){let e=[];for(let o of n){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!zf.has(a))return null;e.push(o)}let r={},i=new Set;for(let o of e){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let u of e){let l=u.properties?.[a]??xf(u);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:Gc(s)??{allOf:s};Q(r,a,c)}for(let a of o.required??[])i.add(a)}let t={type:"object",properties:r};if(i.size&&(t.required=[...i]),e.every(o=>o.additionalProperties===!1))t.additionalProperties=!1;else{let o=[];for(let a of e){let s=xf(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?t.additionalProperties=o[0]:o.length>1&&(t.additionalProperties={allOf:o})}return t}function r$(n){let e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(let t of zf)if(t in n)return;let r=e.filter(t=>$f.some(o=>Array.isArray(t[o]))),i=null;if(!r.length)i=Gc(e);else{let t=r[0],o=$f.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=e.filter(c=>c!==t),s=t[o].map(c=>Gc([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete n.allOf,Kn(n,i))}function ut(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=n.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let f=n.seen.get(d),h=f.schema;if(h.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Kn(u,h),Kn(u,l),s._zod.parent===d)for(let z in u)z==="$ref"||z==="allOf"||z in l||delete u[z];if(h.$ref&&f.def)for(let z in u)z==="$ref"||z==="allOf"||z in f.def&&JSON.stringify(u[z])===JSON.stringify(f.def[z])&&delete u[z]}let m=s._zod.parent;if(m&&m!==d){i(m);let f=n.seen.get(m);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let h in u)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(u[h])===JSON.stringify(f.def[h])&&delete u[h]}n.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(let s of[...n.seen.entries()].reverse())i(s[0]);if(n.target!=="openapi-3.0")for(let s of n.seen.entries())bf(s[1].def??s[1].schema);for(let s of n.deferred)s();if(n.intersections.length){let s=new Map;for(let c of n.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(u):s.set(l,[u])}for(let c of n.intersections)for(let u of s.get(c)??[])r$(u)}}let t={};if(n.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){let s=n.external.registry.get(e)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=n.external.uri(s)}Kn(t,r.defId?r.schema:r.def??r.schema);let o=n.metadataRegistry.get(e)?.id;o!==void 0&&t.id===o&&delete t.id;let a=n.external?.defs??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(let s of n.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Q(a,c.defId,c.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(a).length>0&&(n.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...e["~standard"],jsonSchema:{input:rn(e,"input",n.processors),output:rn(e,"output",n.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function he(n,e){let r=e??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let i=n._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return he(i.element,r);if(i.type==="set")return he(i.valueType,r);if(i.type==="lazy")return he(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return he(i.innerType,r);if(i.type==="intersection")return he(i.left,r)||he(i.right,r);if(i.type==="record"||i.type==="map")return he(i.keyType,r)||he(i.valueType,r);if(i.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:he(i.in,r)||he(i.out,r);if(i.type==="object"){for(let t in i.shape)if(he(i.shape[t],r))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(he(t,r))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(he(t,r))return!0;return!!(i.rest&&he(i.rest,r))}return!1}var Wc=(n,e={})=>r=>{let i=st({...r,processors:e});return B(n,i),ct(i,n),ut(i,n)},rn=(n,e,r={})=>i=>{let{libraryOptions:t,target:o}=i??{},a=st({...t??{},target:o,io:e,processors:r});return B(n,a),ct(a,n),ut(a,n)};var i$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yc=(n,e,r,i)=>{let t=r;t.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=n._zod.bag;if(typeof o=="number"&&(t.minLength=o),typeof a=="number"&&(t.maxLength=a),s&&(t.format=i$[s]??s,t.format===""&&delete t.format,(s==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Qc=(n,e,r,i)=>{let t=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=n._zod.bag;typeof s=="string"&&s.includes("int")?t.type="integer":t.type="number";let d=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof o=="number"&&(t.minimum=o),m?f?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof c=="number"&&(Number.isFinite(c)&&c!==0?t.multipleOf=Math.abs(c):ne(n,e,t,i,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},eu=(n,e,r,i)=>{r.type="boolean"},tu=(n,e,r,i)=>{ne(n,e,r,i,"BigInt cannot be represented in JSON Schema")},nu=(n,e,r,i)=>{ne(n,e,r,i,"Symbols cannot be represented in JSON Schema")},ru=(n,e,r,i)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},iu=(n,e,r,i)=>{ne(n,e,r,i,"Undefined cannot be represented in JSON Schema")},ou=(n,e,r,i)=>{ne(n,e,r,i,"Void cannot be represented in JSON Schema")},au=(n,e,r,i)=>{r.not={}},su=(n,e,r,i)=>{},cu=(n,e,r,i)=>{},uu=(n,e,r,i)=>{ne(n,e,r,i,"Date cannot be represented in JSON Schema")},lu=(n,e,r,i)=>{let t=n._zod.def,o=yn(t.entries);if(o.length===0){r.not={};return}o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},du=(n,e,r,i)=>{let t=n._zod.def;if(t.values.length===0){r.not={};return}let o=[];for(let a of t.values)if(a===void 0){if(ne(n,e,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(ne(n,e,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},mu=(n,e,r,i)=>{ne(n,e,r,i,"NaN cannot be represented in JSON Schema")},fu=(n,e,r,i)=>{let t=r,o=n._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=o.source},pu=(n,e,r,i)=>{let t=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=n._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(t,o)):(Object.assign(t,o),t.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(t,o)},hu=(n,e,r,i)=>{r.type="boolean"},gu=(n,e,r,i)=>{ne(n,e,r,i,"Custom types cannot be represented in JSON Schema")},vu=(n,e,r,i)=>{ne(n,e,r,i,"Function types cannot be represented in JSON Schema")},_u=(n,e,r,i)=>{ne(n,e,r,i,"Transforms cannot be represented in JSON Schema")},yu=(n,e,r,i)=>{ne(n,e,r,i,"Map cannot be represented in JSON Schema")},$u=(n,e,r,i)=>{ne(n,e,r,i,"Set cannot be represented in JSON Schema")},xu=(n,e,r,i)=>{let t=r,o=n._zod.def,{minimum:a,maximum:s}=n._zod.bag;typeof a=="number"&&(t.minItems=a),typeof s=="number"&&(t.maxItems=s),t.type="array",t.items=B(o.element,e,{...i,path:[...i.path,"items"]})};function qn(n){let e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qn(e.out):e.type==="catch"?qn(e.innerType):n._zod.optin}var bu=(n,e,r,i)=>{let t=r,o=n._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&ne(n,e,t,i,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)Q(t.properties,l,B(a[l],e,{...i,path:[...i.path,"properties",l]}));let c=new Set(Object.keys(a)),u=new Set([...c].filter(l=>{let d=o.shape[l];return e.io==="input"?qn(d)===void 0:d._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),o.catchall?._zod.def.type==="never"?t.additionalProperties=!1:o.catchall?o.catchall&&(t.additionalProperties=B(o.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(t.additionalProperties=!1)},Ri=(n,e,r,i)=>{let t=n._zod.def,o=t.inclusive===!1,a=t.options.map((s,c)=>B(s,e,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},zu=(n,e,r,i)=>{let t=n._zod.def,o=B(t.left,e,{...i,path:[...i.path,"allOf",0]}),a=B(t.right,e,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c,e.intersections.push(c)},wu=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="array";let a=e.target==="draft-2020-12"?"prefixItems":"items",s=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((_,z)=>B(_,e,{...i,path:[...i.path,a,z]})),u=o.rest?B(o.rest,e,{...i,path:[...i.path,s,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let _=o.items[l-1];if(!(e.io==="input"?qn(_)!==void 0:_._zod.optout==="optional"))break;l--}let d=o.items.length,m=!o.rest;e.target==="draft-2020-12"?(t.prefixItems=c,m?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),m&&(t.maxItems=d)):e.target==="openapi-3.0"?(t.items={anyOf:c},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),m&&(t.maxItems=d)):(t.items=c,m?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),m&&(t.maxItems=d));let{minimum:f,maximum:h}=n._zod.bag;typeof f=="number"&&(t.minItems=f),typeof h=="number"&&(t.maxItems=h)};function Hc(n,e,r){if(e.$ref){if(r.has(e))return e;r.add(e);let h=n.get(e)?.def;if(!h)return e;let _=Hc(n,h,r);return _===h?e:_}for(let h of["anyOf","oneOf"]){let _=e[h];if(!Array.isArray(_))continue;let z=_.map(P=>Hc(n,P,r));z.some((P,x)=>P!==_[x])&&(e={...e,[h]:z})}let i=Array.isArray(e.type)?e.type:[e.type],t=!i.includes("string")&&i.some(h=>h==="number"||h==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!t&&!o?.some(h=>typeof h=="number"))return e;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:m,...f}=e;return f.enum?f.enum=f.enum.map(h=>typeof h=="number"?String(h):h):typeof f.const=="number"&&(f.const=String(f.const)),t&&(f.type="string",o||(f.pattern=(i.includes("number")?it:Pn).source)),f}var Xc=new WeakMap;function o$(n){let e=new Map;for(let i of n.seen.values())i.def&&!e.has(i.schema)&&e.set(i.schema,i);let r=new Map;for(let i of Xc.get(n)??[]){let t=n.seen.get(i),o=(t?.def??t?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let a=Hc(e,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let i of n.seen.values())for(let t of[i.schema,i.def]){let o=t&&r.get(t.propertyNames);o&&(t.propertyNames=o)}}var ku=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let d=B(o.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let m of c)Q(t.patternProperties,m.source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){t.propertyNames=B(o.keyType,e,{...i,path:[...i.path,"propertyNames"]});let d=Xc.get(e);d||(d=[],Xc.set(e,d),e.deferred.push(()=>o$(e))),d.push(n)}t.additionalProperties=B(o.valueType,e,{...i,path:[...i.path,"additionalProperties"]})}let u=a._zod.values,l=e.io==="input"&&qn(o.valueType)!==void 0;if(u&&!o.partial&&!l){let d=[...u].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(t.required=d.map(String))}},Iu=(n,e,r,i)=>{let t=n._zod.def,o=B(t.innerType,e,i),a=e.seen.get(n);e.target==="openapi-3.0"?(a.ref=t.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Su=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Tu=Symbol();function wf(n,e,r,i,t){let o=!1,a=JSON.stringify(n,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(ne(e,r,i,t,"BigInt defaults cannot be represented in JSON Schema"),Tu):JSON.parse(a)}var Pu=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let a=wf(t.defaultValue,n,e,r,i);a!==Tu&&(r.default=a)},Du=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);if(o.ref=t.innerType,e.io!=="input")return;let a=wf(t.defaultValue,n,e,r,i);a!==Tu&&(r._prefault=a)},Ou=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{ne(n,e,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},Ru=(n,e,r,i)=>{let t=n._zod.def,o=t.in._zod.traits.has("$ZodTransform"),a=e.io==="input"?o?t.out:t.in:t.out;B(a,e,i);let s=e.seen.get(n);s.ref=a},ju=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.readOnly=!0},Uu=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},ji=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Nu=(n,e,r,i)=>{let t=n._zod.innerType;B(t,e,i);let o=e.seen.get(n);o.ref=t},Oi={string:Yc,number:Qc,boolean:eu,bigint:tu,symbol:nu,null:ru,undefined:iu,void:ou,never:au,any:su,unknown:cu,date:uu,enum:lu,literal:du,nan:mu,template_literal:fu,file:pu,success:hu,custom:gu,function:vu,transform:_u,map:yu,set:$u,array:xu,object:bu,union:Ri,intersection:zu,tuple:wu,record:ku,nullable:Iu,nonoptional:Su,default:Pu,prefault:Du,catch:Ou,pipe:Ru,readonly:ju,promise:Uu,optional:ji,lazy:Nu};function Ui(n,e){if("_idmap"in n){let i=n,t=st({...e,processors:Oi}),o={};for(let c of i._idmap.entries()){let[u,l]=c;B(l,t)}let a={},s={registry:i,uri:e?.uri,defs:o};t.external=s;for(let c of i._idmap.entries()){let[u,l]=c;ct(t,l),Q(a,u,ut(t,l))}if(Object.keys(o).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=st({...e,processors:Oi});return B(n,r),ct(r,n),ut(r,n)}var Ni=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=st({processors:Oi,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return B(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ct(this.ctx,e);let i=ut(this.ctx,e),{"~standard":t,...o}=i;return o}};var kf={};var fn={};Fe(fn,{ZodAny:()=>nl,ZodArray:()=>al,ZodBase64:()=>eo,ZodBase64URL:()=>to,ZodBigInt:()=>dn,ZodBigIntFormat:()=>io,ZodBoolean:()=>ln,ZodCIDRv4:()=>Yi,ZodCIDRv6:()=>Qi,ZodCUID:()=>Ji,ZodCUID2:()=>Ki,ZodCatch:()=>Sl,ZodCodec:()=>rr,ZodCreditCard:()=>Wu,ZodCustom:()=>ir,ZodCustomStringFormat:()=>cn,ZodDate:()=>Xn,ZodDefault:()=>xl,ZodDiscriminatedUnion:()=>cl,ZodE164:()=>no,ZodEmail:()=>Li,ZodEmoji:()=>Vi,ZodEnum:()=>an,ZodExactOptional:()=>co,ZodFile:()=>vl,ZodFunction:()=>El,ZodGUID:()=>Mi,ZodIPv4:()=>Hi,ZodIPv6:()=>Xi,ZodISODate:()=>dt,ZodISODateTime:()=>lt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,ZodIntersection:()=>ul,ZodJWT:()=>ro,ZodKSUID:()=>Wi,ZodLazy:()=>Ul,ZodLiteral:()=>gl,ZodMAC:()=>Gu,ZodMap:()=>pl,ZodNaN:()=>Pl,ZodNanoID:()=>Bi,ZodNever:()=>il,ZodNonOptional:()=>uo,ZodNull:()=>el,ZodNullable:()=>$l,ZodNumber:()=>un,ZodNumberFormat:()=>Dt,ZodObject:()=>Qn,ZodOptional:()=>tr,ZodPipe:()=>nr,ZodPrefault:()=>zl,ZodPreprocess:()=>Dl,ZodPromise:()=>Al,ZodReadonly:()=>Ol,ZodRecord:()=>on,ZodSet:()=>hl,ZodString:()=>sn,ZodStringFormat:()=>q,ZodSuccess:()=>Il,ZodSymbol:()=>Yu,ZodTemplateLiteral:()=>jl,ZodTransform:()=>_l,ZodTuple:()=>dl,ZodType:()=>E,ZodULID:()=>qi,ZodURL:()=>Hn,ZodUUID:()=>Ke,ZodUndefined:()=>Qu,ZodUnion:()=>er,ZodUnknown:()=>rl,ZodVoid:()=>ol,ZodXID:()=>Gi,ZodXor:()=>sl,_ZodString:()=>Fi,_default:()=>bl,_function:()=>Np,any:()=>mp,array:()=>Yn,base64:()=>Gf,base64url:()=>Wf,bigint:()=>sp,boolean:()=>Xu,catch:()=>Tl,check:()=>Ap,cidrv4:()=>Kf,cidrv6:()=>qf,codec:()=>Op,creditCard:()=>Xf,cuid:()=>Zf,cuid2:()=>Cf,custom:()=>Ep,date:()=>pp,describe:()=>Zp,discriminatedUnion:()=>$p,e164:()=>Hf,email:()=>Tf,emoji:()=>Af,enum:()=>ao,exactOptional:()=>yl,file:()=>Sp,float32:()=>rp,float64:()=>ip,function:()=>Np,guid:()=>Pf,hash:()=>np,hex:()=>tp,hostname:()=>ep,httpUrl:()=>Nf,instanceof:()=>Fp,int:()=>Zi,int32:()=>op,int64:()=>cp,intersection:()=>ll,invertCodec:()=>Rp,ipv4:()=>Vf,ipv6:()=>Jf,json:()=>Mp,jwt:()=>Yf,keyof:()=>hp,ksuid:()=>Mf,lazy:()=>Nl,literal:()=>Ip,looseObject:()=>_p,looseRecord:()=>bp,mac:()=>Bf,map:()=>zp,meta:()=>Cp,nan:()=>Dp,nanoid:()=>Ef,nativeEnum:()=>kp,never:()=>oo,nonoptional:()=>kl,null:()=>tl,nullable:()=>Wn,nullish:()=>Tp,number:()=>Hu,object:()=>gp,optional:()=>Tt,partialRecord:()=>xp,pipe:()=>Ci,prefault:()=>wl,preprocess:()=>Vp,promise:()=>Up,readonly:()=>Rl,record:()=>fl,refine:()=>Zl,set:()=>wp,strictObject:()=>vp,string:()=>Gn,stringFormat:()=>Qf,stringbool:()=>Lp,success:()=>Pp,superRefine:()=>Cl,symbol:()=>lp,templateLiteral:()=>jp,transform:()=>so,tuple:()=>ml,uint32:()=>ap,uint64:()=>up,ulid:()=>Ff,undefined:()=>dp,union:()=>mn,unknown:()=>St,url:()=>Uf,uuid:()=>Df,uuidv4:()=>Of,uuidv6:()=>Rf,uuidv7:()=>jf,void:()=>fp,xid:()=>Lf,xor:()=>yp});var Ai={};Fe(Ai,{endsWith:()=>Wt,gt:()=>Be,gte:()=>Pe,includes:()=>qt,length:()=>It,lowercase:()=>Jt,lt:()=>Ve,lte:()=>Te,maxLength:()=>kt,maxSize:()=>at,mime:()=>Ht,minLength:()=>He,minSize:()=>Je,multipleOf:()=>ot,negative:()=>Ii,nonnegative:()=>Ti,nonpositive:()=>Si,normalize:()=>Xt,overwrite:()=>Ze,positive:()=>ki,properties:()=>Di,property:()=>Pi,regex:()=>Bt,size:()=>wt,slugify:()=>tn,startsWith:()=>Gt,toLowerCase:()=>Qt,toUpperCase:()=>en,trim:()=>Yt,uppercase:()=>Kt});var If=new WeakSet([Object.prototype,Error.prototype]);function Ei(n,e,r){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var Sf=(n,e)=>{In.init(n,e),n.name="ZodError";let r=Object.getPrototypeOf(n);If.has(r)||(If.add(r),Ei(r,"format",i=>t=>Tn(i,t)),Ei(r,"flatten",i=>t=>Sn(i,t)),Ei(r,"addIssue",i=>t=>{i.issues.push(t),i.message=JSON.stringify(i.issues,Ut,2)}),Ei(r,"addIssues",i=>t=>{i.issues.push(...t),i.message=JSON.stringify(i.issues,Ut,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},s$=g("ZodError",Sf),ze=g("ZodError",Sf,void 0,{Parent:Error});var Au=Et(ze),Eu=Zt(ze),Zu=Ct(ze),Cu=Ft(ze),Fu=gr(ze),Lu=vr(ze),Mu=_r(ze),Vu=yr(ze),Bu=$r(ze),Ju=xr(ze),Ku=br(ze),qu=zr(ze);function u$(){ie.localeError||ee(Yr())}function Pt(){ie.memoizer||ee({memoizer:Zn()})}var E=g("ZodType",(n,e)=>(u$(),N.init(n,e),n.def=e,n.type=e.type,n),{check(...n){let e=this.def;return this.clone(b.mergeDefs(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return V(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Zl(n,e))},superRefine(n,e){return this.check(Cl(n,e))},overwrite(n){return this.check(Ze(n))},optional(){return Tt(this)},exactOptional(){return yl(this)},nullable(){return Wn(this)},nullish(){return Tt(Wn(this))},nonoptional(n){return kl(this,n)},array(){return Yn(this)},or(n){return mn([this,n])},and(n){return ll(this,n)},transform(n){return Ci(this,so(n))},default(n){return bl(this,n)},prefault(n){return wl(this,n)},catch(n){return Tl(this,n)},pipe(n){return Ci(this,n)},readonly(){return Rl(this)},describe(n){let e=this.clone();return ae.add(e,{description:n}),e},meta(...n){if(n.length===0)return ae.get(this);let e=this.clone();return ae.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return b.hide(this,"~standard",{...Ur(this),jsonSchema:{input:rn(this,"input"),output:rn(this,"output")}})},set"~standard"(n){b.own(this,"~standard",n)},parse:function n(e,r){return Au(this,e,r,{callee:n})},parseAsync:async function n(e,r){return await Eu(this,e,r,{callee:n})},safeParse(n,e){return Zu(this,n,e)},async safeParseAsync(n,e){return Cu(this,n,e)},get spa(){return this?.safeParseAsync},set spa(n){b.own(this,"spa",n)},encode:function n(e,r){return Fu(this,e,r,{callee:n})},decode:function n(e,r){return Lu(this,e,r,{callee:n})},encodeAsync:async function n(e,r){return await Mu(this,e,r,{callee:n})},decodeAsync:async function n(e,r){return await Vu(this,e,r,{callee:n})},safeEncode(n,e){return Bu(this,n,e)},safeDecode(n,e){return Ju(this,n,e)},async safeEncodeAsync(n,e){return Ku(this,n,e)},async safeDecodeAsync(n,e){return qu(this,n,e)},toJSONSchema(n){return Wc(this,{})(n)},get description(){return ae.get(this)?.description},get _def(){return this._zod.def}}),Fi=g("_ZodString",(n,e)=>{yt.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Yc(n,i,t,o);let r=n._zod.bag;n.format=r.format??null,n.minLength=r.minimum??null,n.maxLength=r.maximum??null},{regex(...n){return this.check(Bt(...n))},includes(...n){return this.check(qt(...n))},startsWith(...n){return this.check(Gt(...n))},endsWith(...n){return this.check(Wt(...n))},min(...n){return this.check(He(...n))},max(...n){return this.check(kt(...n))},length(...n){return this.check(It(...n))},nonempty(...n){return this.check(He(1,...n))},lowercase(n){return this.check(Jt(n))},uppercase(n){return this.check(Kt(n))},trim(){return this.check(Yt())},normalize(...n){return this.check(Xt(...n))},toLowerCase(){return this.check(Qt())},toUpperCase(){return this.check(en())},slugify(){return this.check(tn())}}),sn=g("ZodString",(n,e)=>{yt.init(n,e),Fi.init(n,e)},{email(n){return this.check(ii(Li,n))},url(n){return this.check(Ln(Hn,n))},jwt(n){return this.check(wi(ro,n))},emoji(n){return this.check(li(Vi,n))},guid(n){return this.check(oi(Mi,n))},uuid(n){return this.check(ai(Ke,n))},uuidv4(n){return this.check(si(Ke,n))},uuidv6(n){return this.check(ci(Ke,n))},uuidv7(n){return this.check(ui(Ke,n))},nanoid(n){return this.check(di(Bi,n))},cuid(n){return this.check(mi(Ji,n))},cuid2(n){return this.check(fi(Ki,n))},ulid(n){return this.check(pi(qi,n))},base64(n){return this.check(xi(eo,n))},base64url(n){return this.check(bi(to,n))},xid(n){return this.check(hi(Gi,n))},ksuid(n){return this.check(gi(Wi,n))},ipv4(n){return this.check(vi(Hi,n))},ipv6(n){return this.check(_i(Xi,n))},cidrv4(n){return this.check(yi(Yi,n))},cidrv6(n){return this.check($i(Qi,n))},e164(n){return this.check(zi(no,n))},datetime(n){return this.check(Mn(lt,n))},date(n){return this.check(Vn(dt,n))},time(n){return this.check(Bn(mt,n))},duration(n){return this.check(Jn(ft,n))}});function Gn(n){return mc(sn,n)}var q=g("ZodStringFormat",(n,e)=>{J.init(n,e),Fi.init(n,e)}),lt=g("ZodISODateTime",(n,e)=>{rs.init(n,e),q.init(n,e)}),dt=g("ZodISODate",(n,e)=>{is.init(n,e),q.init(n,e)}),mt=g("ZodISOTime",(n,e)=>{os.init(n,e),q.init(n,e)}),ft=g("ZodISODuration",(n,e)=>{as.init(n,e),q.init(n,e)}),Li=g("ZodEmail",(n,e)=>{Ka.init(n,e),q.init(n,e)});function Tf(n){return ii(Li,n)}var Mi=g("ZodGUID",(n,e)=>{Ba.init(n,e),q.init(n,e)});function Pf(n){return oi(Mi,n)}var Ke=g("ZodUUID",(n,e)=>{Ja.init(n,e),q.init(n,e)});function Df(n){return ai(Ke,n)}function Of(n){return si(Ke,n)}function Rf(n){return ci(Ke,n)}function jf(n){return ui(Ke,n)}var Hn=g("ZodURL",(n,e)=>{Wa.init(n,e),q.init(n,e)});function Uf(n){return Ln(Hn,n)}function Nf(n){return Ln(Hn,{protocol:fe.httpProtocol,hostname:fe.domain,...b.normalizeParams(n)})}var Vi=g("ZodEmoji",(n,e)=>{Ha.init(n,e),q.init(n,e)});function Af(n){return li(Vi,n)}var Bi=g("ZodNanoID",(n,e)=>{Xa.init(n,e),q.init(n,e)});function Ef(n){return di(Bi,n)}var Ji=g("ZodCUID",(n,e)=>{Ya.init(n,e),q.init(n,e)});function Zf(n){return mi(Ji,n)}var Ki=g("ZodCUID2",(n,e)=>{Qa.init(n,e),q.init(n,e)});function Cf(n){return fi(Ki,n)}var qi=g("ZodULID",(n,e)=>{es.init(n,e),q.init(n,e)});function Ff(n){return pi(qi,n)}var Gi=g("ZodXID",(n,e)=>{ts.init(n,e),q.init(n,e)});function Lf(n){return hi(Gi,n)}var Wi=g("ZodKSUID",(n,e)=>{ns.init(n,e),q.init(n,e)});function Mf(n){return gi(Wi,n)}var Hi=g("ZodIPv4",(n,e)=>{ss.init(n,e),q.init(n,e)});function Vf(n){return vi(Hi,n)}var Gu=g("ZodMAC",(n,e)=>{us.init(n,e),q.init(n,e)});function Bf(n){return pc(Gu,n)}var Xi=g("ZodIPv6",(n,e)=>{cs.init(n,e),q.init(n,e)});function Jf(n){return _i(Xi,n)}var Yi=g("ZodCIDRv4",(n,e)=>{ls.init(n,e),q.init(n,e)});function Kf(n){return yi(Yi,n)}var Qi=g("ZodCIDRv6",(n,e)=>{ds.init(n,e),q.init(n,e)});function qf(n){return $i(Qi,n)}var eo=g("ZodBase64",(n,e)=>{ms.init(n,e),q.init(n,e)});function Gf(n){return xi(eo,n)}var to=g("ZodBase64URL",(n,e)=>{fs.init(n,e),q.init(n,e)});function Wf(n){return bi(to,n)}var no=g("ZodE164",(n,e)=>{ps.init(n,e),q.init(n,e)});function Hf(n){return zi(no,n)}var Wu=g("ZodCreditCard",(n,e)=>{hs.init(n,e),q.init(n,e)});function Xf(n){return hc(Wu,n)}var ro=g("ZodJWT",(n,e)=>{gs.init(n,e),q.init(n,e)});function Yf(n){return wi(ro,n)}var cn=g("ZodCustomStringFormat",(n,e)=>{vs.init(n,e),q.init(n,e)});function Qf(n,e,r={}){return nn(cn,n,e,r)}function ep(n){return nn(cn,"hostname",fe.hostname,n)}function tp(n){return nn(cn,"hex",fe.hex,n)}function np(n,e){let r=e?.enc??"hex",i=`${n}_${r}`,t=fe[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return nn(cn,i,t,e)}var un=g("ZodNumber",(n,e)=>{Vr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Qc(n,i,t,o);let r=n._zod.bag;n.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),n.isFinite=!0,n.format=r.format??null},{gt(n,e){return this.check(Be(n,e))},gte(n,e){return this.check(Pe(n,e))},min(n,e){return this.check(Pe(n,e))},lt(n,e){return this.check(Ve(n,e))},lte(n,e){return this.check(Te(n,e))},max(n,e){return this.check(Te(n,e))},int(n){return this.check(Zi(n))},safe(n){return this.check(Zi(n))},positive(n){return this.check(Be(0,n))},nonnegative(n){return this.check(Pe(0,n))},negative(n){return this.check(Ve(0,n))},nonpositive(n){return this.check(Te(0,n))},multipleOf(n,e){return this.check(ot(n,e))},step(n,e){return this.check(ot(n,e))},finite(){return this}});function Hu(n){return vc(un,n)}var Dt=g("ZodNumberFormat",(n,e)=>{_s.init(n,e),un.init(n,e)});function Zi(n){return yc(Dt,n)}function rp(n){return $c(Dt,n)}function ip(n){return xc(Dt,n)}function op(n){return bc(Dt,n)}function ap(n){return zc(Dt,n)}var ln=g("ZodBoolean",(n,e)=>{Un.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>eu(n,r,i,t)});function Xu(n){return wc(ln,n)}var dn=g("ZodBigInt",(n,e)=>{Br.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>tu(n,i,t,o);let r=n._zod.bag;n.minValue=r.minimum??null,n.maxValue=r.maximum??null,n.format=r.format??null},{gte(n,e){return this.check(Pe(n,e))},min(n,e){return this.check(Pe(n,e))},gt(n,e){return this.check(Be(n,e))},lt(n,e){return this.check(Ve(n,e))},lte(n,e){return this.check(Te(n,e))},max(n,e){return this.check(Te(n,e))},positive(n){return this.check(Be(BigInt(0),n))},negative(n){return this.check(Ve(BigInt(0),n))},nonpositive(n){return this.check(Te(BigInt(0),n))},nonnegative(n){return this.check(Pe(BigInt(0),n))},multipleOf(n,e){return this.check(ot(n,e))}});function sp(n){return Ic(dn,n)}var io=g("ZodBigIntFormat",(n,e)=>{ys.init(n,e),dn.init(n,e)});function cp(n){return Tc(io,n)}function up(n){return Pc(io,n)}var Yu=g("ZodSymbol",(n,e)=>{$s.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>nu(n,r,i,t)});function lp(n){return Dc(Yu,n)}var Qu=g("ZodUndefined",(n,e)=>{xs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>iu(n,r,i,t)});function dp(n){return Oc(Qu,n)}var el=g("ZodNull",(n,e)=>{bs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ru(n,r,i,t)});function tl(n){return Rc(el,n)}var nl=g("ZodAny",(n,e)=>{zs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>su(n,r,i,t)});function mp(){return jc(nl)}var rl=g("ZodUnknown",(n,e)=>{ws.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>cu(n,r,i,t)});function St(){return Uc(rl)}var il=g("ZodNever",(n,e)=>{ks.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>au(n,r,i,t)});function oo(n){return Nc(il,n)}var ol=g("ZodVoid",(n,e)=>{Is.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ou(n,r,i,t)});function fp(n){return Ac(ol,n)}var Xn=g("ZodDate",(n,e)=>{Ss.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>uu(n,i,t,o),n.min=(i,t)=>n.check(Pe(i,t)),n.max=(i,t)=>n.check(Te(i,t));let r=n._zod.bag;n.minDate=r.minimum?new Date(r.minimum):null,n.maxDate=r.maximum?new Date(r.maximum):null});function pp(n){return Ec(Xn,n)}var al=g("ZodArray",(n,e)=>{Pt(),Ts.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>xu(n,r,i,t),n.element=e.element},{min(n,e){return this.check(He(n,e))},nonempty(n){return this.check(He(1,n))},max(n,e){return this.check(kt(n,e))},length(n,e){return this.check(It(n,e))},unwrap(){return this.element}});function Yn(n,e){return Fc(al,n,e)}function hp(n){let e=n._zod.def.shape;return ao(Object.keys(e))}var Qn=g("ZodObject",(n,e)=>{Pt(),Ps.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>bu(n,r,i,t),b.installLazyProp(n,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ao(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:St()})},loose(){return this.clone({...this._zod.def,catchall:St()})},strict(){return this.clone({...this._zod.def,catchall:oo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return b.extend(this,n)},safeExtend(n){return b.safeExtend(this,n)},merge(n){return b.merge(this,n)},pick(n){return b.pick(this,n)},omit(n){return b.omit(this,n)},partial(...n){return b.partial(tr,this,n[0])},exactPartial(...n){return b.partial(co,this,n[0],"exactPartial")},required(...n){return b.required(uo,this,n[0])}});function gp(n,e){let r={type:"object",shape:n??{},...b.normalizeParams(e)};return new Qn(r)}function vp(n,e){return new Qn({type:"object",shape:n,catchall:oo(),...b.normalizeParams(e)})}function _p(n,e){return new Qn({type:"object",shape:n,catchall:St(),...b.normalizeParams(e)})}var er=g("ZodUnion",(n,e)=>{Nn.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ri(n,r,i,t),n.options=e.options});function mn(n,e){return new er({type:"union",options:n,...b.normalizeParams(e)})}var sl=g("ZodXor",(n,e)=>{er.init(n,e),Ds.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ri(n,r,i,t),n.options=e.options});function yp(n,e){return new sl({type:"union",options:n,inclusive:!1,...b.normalizeParams(e)})}var cl=g("ZodDiscriminatedUnion",(n,e)=>{er.init(n,e),Rs.init(n,e)});function $p(n,e,r){return new cl({type:"union",options:e,discriminator:n,...b.normalizeParams(r)})}var ul=g("ZodIntersection",(n,e)=>{js.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>zu(n,r,i,t)});function ll(n,e){return new ul({type:"intersection",left:n,right:e})}var dl=g("ZodTuple",(n,e)=>{Pt(),Jr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>wu(n,r,i,t)},{rest(n){return this.clone({...this._zod.def,rest:n})},partial(){let n=this._zod.def;if(n.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...n,items:n.items.map(e=>new tr({type:"optional",innerType:e}))})}});function ml(n,e,r){let i=e instanceof N,t=i?r:e,o=i?e:null;return new dl({type:"tuple",items:n,rest:o,...b.normalizeParams(t)})}var on=g("ZodRecord",(n,e)=>{Pt(),Us.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ku(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType});function fl(n,e,r){return!e||!e._zod?new on({type:"record",keyType:Gn(),valueType:n,...b.normalizeParams(e)}):new on({type:"record",keyType:n,valueType:e,...b.normalizeParams(r)})}function xp(n,e,r){return new on({type:"record",keyType:n,valueType:e,...b.normalizeParams(r),partial:!0})}function bp(n,e,r){return new on({type:"record",keyType:n,valueType:e,mode:"loose",...b.normalizeParams(r)})}var pl=g("ZodMap",(n,e)=>{Pt(),Ns.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>yu(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType,n.min=(...r)=>n.check(Je(...r)),n.nonempty=r=>n.check(Je(1,r)),n.max=(...r)=>n.check(at(...r)),n.size=(...r)=>n.check(wt(...r))});function zp(n,e,r){return new pl({type:"map",keyType:n,valueType:e,...b.normalizeParams(r)})}var hl=g("ZodSet",(n,e)=>{Pt(),As.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>$u(n,r,i,t),n.min=(...r)=>n.check(Je(...r)),n.nonempty=r=>n.check(Je(1,r)),n.max=(...r)=>n.check(at(...r)),n.size=(...r)=>n.check(wt(...r))});function wp(n,e){return new hl({type:"set",valueType:n,...b.normalizeParams(e)})}var an=g("ZodEnum",(n,e)=>{Es.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>lu(n,i,t,o),n.enum=e.entries,n.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));n.extract=(i,t)=>{let o={};for(let a of i)if(r.has(a))o[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new an({...e,checks:[],...b.normalizeParams(t),entries:o})},n.exclude=(i,t)=>{let o={...e.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new an({...e,checks:[],...b.normalizeParams(t),entries:o})}});function ao(n,e){let r=Array.isArray(n)?Object.fromEntries(n.map(i=>[i,i])):n;return new an({type:"enum",entries:r,...b.normalizeParams(e)})}function kp(n,e){return new an({type:"enum",entries:n,...b.normalizeParams(e)})}var gl=g("ZodLiteral",(n,e)=>{Zs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>du(n,r,i,t),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ip(n,e){return new gl({type:"literal",values:Array.isArray(n)?n:[n],...b.normalizeParams(e)})}var vl=g("ZodFile",(n,e)=>{Cs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>pu(n,r,i,t),n.min=(r,i)=>n.check(Je(r,i)),n.max=(r,i)=>n.check(at(r,i)),n.mime=(r,i)=>n.check(Ht(Array.isArray(r)?r:[r],i))});function Sp(n){return Lc(vl,n)}var _l=g("ZodTransform",(n,e)=>{Pt(),Fs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>_u(n,r,i,t),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new rt(n.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(b.issue(o,r.value,e));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=n),r.issues.push(b.issue(a))}};let t=e.transform(r.value,r);return t instanceof Promise?t.then(o=>(r.value=o,r)):(r.value=t,r)}});function so(n){return new _l({type:"transform",transform:n})}var tr=g("ZodOptional",(n,e)=>{Kr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ji(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Tt(n){return new tr({type:"optional",innerType:n})}var co=g("ZodExactOptional",(n,e)=>{Ls.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ji(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function yl(n){return new co({type:"optional",innerType:n})}var $l=g("ZodNullable",(n,e)=>{Ms.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Iu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Wn(n){return new $l({type:"nullable",innerType:n})}function Tp(n){return Tt(Wn(n))}var xl=g("ZodDefault",(n,e)=>{Vs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Pu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function bl(n,e){return new xl({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():b.shallowClone(e)}})}var zl=g("ZodPrefault",(n,e)=>{Bs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Du(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function wl(n,e){return new zl({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():b.shallowClone(e)}})}var uo=g("ZodNonOptional",(n,e)=>{Js.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Su(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function kl(n,e){return new uo({type:"nonoptional",innerType:n,...b.normalizeParams(e)})}var Il=g("ZodSuccess",(n,e)=>{Ks.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>hu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Pp(n){return new Il({type:"success",innerType:n})}var Sl=g("ZodCatch",(n,e)=>{qs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ou(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Tl(n,e){return new Sl({type:"catch",innerType:n,catchValue:typeof e=="function"?e:b.constantCatch(e)})}var Pl=g("ZodNaN",(n,e)=>{Gs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>mu(n,r,i,t)});function Dp(n){return Cc(Pl,n)}var nr=g("ZodPipe",(n,e)=>{qr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ru(n,r,i,t),n.in=e.in,n.out=e.out});function Ci(n,e){return new nr({type:"pipe",in:n,out:e})}var rr=g("ZodCodec",(n,e)=>{nr.init(n,e),An.init(n,e)});function Op(n,e,r){return new rr({type:"pipe",in:n,out:e,transform:r.decode,reverseTransform:r.encode})}function Rp(n){let e=n._zod.def;return new rr({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var Dl=g("ZodPreprocess",(n,e)=>{nr.init(n,e),Ws.init(n,e)}),Ol=g("ZodReadonly",(n,e)=>{Hs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ju(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Rl(n){return new Ol({type:"readonly",innerType:n})}var jl=g("ZodTemplateLiteral",(n,e)=>{Xs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>fu(n,r,i,t)});function jp(n,e){return new jl({type:"template_literal",parts:n,...b.normalizeParams(e)})}var Ul=g("ZodLazy",(n,e)=>{En.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Nu(n,r,i,t),n.unwrap=()=>n._zod.def.getter()});function Nl(n){return new Ul({type:"lazy",getter:n})}var Al=g("ZodPromise",(n,e)=>{Qs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Uu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Up(n){return new Al({type:"promise",innerType:n})}var El=g("ZodFunction",(n,e)=>{Ys.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>vu(n,r,i,t)});function Np(n){return new El({type:"function",input:Array.isArray(n?.input)?ml(n?.input):n?.input??Yn(St()),output:n?.output??St()})}var ir=g("ZodCustom",(n,e)=>{ec.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>gu(n,r,i,t)});function Ap(n){let e=new W({check:"custom"});return e._zod.check=n,e}function Ep(n,e){return Mc(ir,n??(()=>!0),e)}function Zl(n,e={}){return Vc(ir,n,e)}function Cl(n,e){return Bc(n,e)}var Zp=Jc,Cp=Kc;function Fp(n,e={}){let r=new ir({type:"custom",check:"custom",fn:i=>i instanceof n,abort:!0,...b.normalizeParams(e)});return r._zod.bag.Class=n,r._zod.check=i=>{i.value instanceof n||i.issues.push({code:"invalid_type",expected:n.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Lp=(...n)=>qc({Codec:rr,Boolean:ln,String:sn},...n);function Mp(n){let e=Nl(()=>mn([Gn(n),Hu(),Xu(),tl(),Yn(e),fl(Gn(),e)]));return e}function Vp(n,e){return new Dl({type:"pipe",in:so(n),out:e})}var l$={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function d$(n){ee({customError:n})}function m$(){return ee().customError}var Fl;Fl||(Fl={});var or={};Fe(or,{ZodISODate:()=>dt,ZodISODateTime:()=>lt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,date:()=>p$,datetime:()=>f$,duration:()=>g$,time:()=>h$});function f$(n){return Mn(lt,n)}function p$(n){return Vn(dt,n)}function h$(n){return Bn(mt,n)}function g$(n){return Jn(ft,n)}var I={...fn,...Ai,iso:or},v$=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function _$(n,e){let r=n.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function Bp(n,e){return n.map((r,i)=>i<e?r:r.optional())}function y$(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function $$(n,e){if(!n.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=n.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let t=r[1]===void 0?void 0:y$(r[1]);if(!t||!e.defs[t])throw new Error(`Reference not found: ${n}`);return e.defs[t]}throw new Error(`Reference not found: ${n}`)}function x$(n,e){return I.transform(i=>i).check(i=>{let t=i.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let o of Object.getOwnPropertyNames(t)){let a=e.safeParse(o);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:o,path:[o],continue:!0})}}).pipe(n)}function Jp(n,e){if(n!==!1)return n===void 0||n===!0?I.any():we(n,e)}var b$=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Kp(n,e){if(n.not!==void 0){if(typeof n.not=="object"&&Object.keys(n.not).length===0)return I.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(n.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(n.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(n.if!==void 0||n.then!==void 0||n.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(n.dependentSchemas!==void 0||n.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(n.$ref){let t=n.$ref;if(e.refs.has(t))return e.refs.get(t);if(e.processing.has(t))return I.lazy(()=>{if(!e.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return e.refs.get(t)});e.processing.add(t);let o=$$(t,e),a=we(o,e);return e.refs.set(t,a),e.processing.delete(t),a}if(n.enum!==void 0){let t=n.enum;if(e.version==="openapi-3.0"&&n.nullable===!0&&t.length===1&&t[0]===null)return I.null();if(t.length===0)return I.never();if(t.length===1)return I.literal(t[0]);if(t.every(a=>typeof a=="string"))return I.enum(t);let o=t.map(a=>I.literal(a));return o.length<2?o[0]:I.union([o[0],o[1],...o.slice(2)])}if(n.const!==void 0)return I.literal(n.const);let r=n.type;if(Array.isArray(r)){let t=r.map(o=>{let a={...n,type:o};return Kp(a,e)});return t.length===0?I.never():t.length===1?t[0]:I.union(t)}if(!r)return I.any();let i;switch(r){case"string":{let t=I.string();if(n.format){let o=n.format;o==="email"?t=t.check(I.email()):o==="uri"||o==="uri-reference"?t=t.check(I.url()):o==="uuid"||o==="guid"?t=t.check(I.uuid()):o==="date-time"?t=t.check(I.iso.datetime({offset:!0})):o==="date"?t=t.check(I.iso.date()):o==="time"?t=t.check(I.regex(b$)):o==="duration"?t=t.check(I.iso.duration()):o==="hostname"?t=t.check(I.hostname()):o==="ipv4"?t=t.check(I.ipv4()):o==="ipv6"?t=t.check(I.ipv6()):o==="mac"?t=t.check(I.mac()):o==="cidr"?t=t.check(I.cidrv4()):o==="cidr-v6"?t=t.check(I.cidrv6()):o==="base64"?t=t.check(I.base64()):o==="base64url"?t=t.check(I.base64url()):o==="e164"?t=t.check(I.e164()):o==="credit_card"?t=t.check(I.creditCard()):o==="jwt"?t=t.check(I.jwt()):o==="emoji"?t=t.check(I.emoji()):o==="nanoid"?t=t.check(I.nanoid()):o==="cuid"?t=t.check(I.cuid()):o==="cuid2"?t=t.check(I.cuid2()):o==="ulid"?t=t.check(I.ulid()):o==="xid"?t=t.check(I.xid()):o==="ksuid"&&(t=t.check(I.ksuid()))}typeof n.minLength=="number"&&(t=t.min(n.minLength)),typeof n.maxLength=="number"&&(t=t.max(n.maxLength)),n.pattern&&(t=t.regex(new RegExp(n.pattern))),i=t;break}case"number":case"integer":{let t=r==="integer"?I.number().int():I.number();typeof n.minimum=="number"&&n.exclusiveMinimum!==!0&&(t=t.min(n.minimum)),typeof n.maximum=="number"&&n.exclusiveMaximum!==!0&&(t=t.max(n.maximum)),typeof n.exclusiveMinimum=="number"?t=t.gt(n.exclusiveMinimum):n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t=t.gt(n.minimum)),typeof n.exclusiveMaximum=="number"?t=t.lt(n.exclusiveMaximum):n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t=t.lt(n.maximum)),typeof n.multipleOf=="number"&&(t=t.multipleOf(n.multipleOf)),i=t;break}case"boolean":{i=I.boolean();break}case"null":{i=I.null();break}case"object":{let t={},o=n.properties||{},a=new Set(n.required||[]),s=typeof n.additionalProperties=="object"?we(n.additionalProperties,e):void 0;for(let[c,u]of Object.entries(o)){let l=we(u,e);Q(t,c,a.has(c)?l:l.optional())}if(n.patternProperties){let c=n.patternProperties,u=Object.keys(c),l=[];for(let m of u){let f=we(c[m],e),h=I.string().regex(new RegExp(m));l.push(I.looseRecord(h,f))}let d=[];if(Object.keys(t).length>0&&d.push(I.object(t).passthrough()),d.push(...l),d.length===0)i=I.object({}).passthrough();else if(d.length===1)i=d[0];else{let m=I.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)m=I.intersection(m,d[f]);i=m}if(n.additionalProperties===!1){let m=Object.keys(t),f=u.map(_=>new RegExp(_)),h=i;i=i.check(_=>{if(!Re(_.value))return;let z=[];for(let P of Object.keys(_.value))m.includes(P)||f.some(x=>x.test(P))||z.push(P);z.length&&_.issues.push({code:"unrecognized_keys",keys:z,input:_.value,inst:h})})}}else{let c=I.object(t);n.additionalProperties===!1?i=c.strict():s?i=c.catchall(s):i=c.passthrough()}if(n.propertyNames!==void 0&&n.propertyNames!==!0){let c=typeof n.propertyNames=="object"&&n.propertyNames.type===void 0?{type:"string",...n.propertyNames}:n.propertyNames;i=x$(i,we(c,e))}break}case"array":{let t=n.prefixItems,o=n.items;if(t&&Array.isArray(t)){let a=typeof n.minItems=="number"?n.minItems:0,s=t.map(d=>we(d,e)),c=Bp(s,a),u=Array.isArray(o)?void 0:Jp(o,e),l=I.tuple(c);i=u?l.rest(u):l,typeof n.minItems=="number"&&(i=i.check(I.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(I.maxLength(n.maxItems)))}else if(Array.isArray(o)){let a=typeof n.minItems=="number"?n.minItems:0,s=o.map(d=>we(d,e)),c=Bp(s,a),u=Jp(n.additionalItems,e),l=I.tuple(c);i=u?l.rest(u):l,typeof n.minItems=="number"&&(i=i.check(I.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(I.maxLength(n.maxItems)))}else if(o!==void 0){let a=we(o,e),s=I.array(a);typeof n.minItems=="number"&&(s=s.min(n.minItems)),typeof n.maxItems=="number"&&(s=s.max(n.maxItems)),i=s}else i=I.array(I.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function we(n,e){if(typeof n=="boolean")return n?I.any():I.never();let r=Kp(n,e),i=n.type||n.enum!==void 0||n.const!==void 0;if(n.anyOf&&Array.isArray(n.anyOf)){let s=n.anyOf.map(u=>we(u,e)),c=I.union(s);r=i?I.intersection(r,c):c}if(n.oneOf&&Array.isArray(n.oneOf)){let s=n.oneOf.map(u=>we(u,e)),c=I.xor(s);r=i?I.intersection(r,c):c}if(n.allOf&&Array.isArray(n.allOf))if(n.allOf.length===0)r=i?r:I.any();else{let s=i?r:we(n.allOf[0],e),c=i?0:1;for(let u=c;u<n.allOf.length;u++)s=I.intersection(s,we(n.allOf[u],e));r=s}n.nullable===!0&&e.version==="openapi-3.0"&&(r=I.nullable(r)),n.readOnly===!0&&(r=I.readonly(r)),n.default!==void 0&&(r=r.default(n.default));let t={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in n&&(t[s]=n[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in n&&(t[s]=n[s]);n.propertyNames!==void 0&&n.type==="object"&&n.$ref===void 0&&(t.propertyNames=n.propertyNames);for(let s of Object.keys(n))v$.has(s)||Q(t,s,n[s]);return Object.keys(t).length>0&&e.registry.add(r,t),n.description&&(r=r.describe(n.description)),r}function qp(n,e){if(typeof n=="boolean")return n?I.any():I.never();let r;try{r=JSON.parse(JSON.stringify(n))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=_$(r,e?.defaultTarget),t=r.$defs||r.definitions||{},o={version:i,defs:t,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??ae};return we(r,o)}var Gp=Symbol("z.visit/resolving");function ar(n,e){let r=typeof e=="function"?e:(a,s)=>{let c=e[a._zod.def.type];return c?c(a,s):a},i=new Map;function t(a){let s=i.get(a);if(s===Gp)return new En({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,Gp);let c=o(a),u=r(c,c!==a);return i.set(a,u),u}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),d=!1,m={};for(let h of l){let _=t(u[h]);_!==u[h]&&(d=!0),m[h]=_}let f=s.catchall;return s.catchall&&(f=t(s.catchall),f!==s.catchall&&(d=!0)),d?V(a,{...s,shape:m,catchall:f}):a}case"array":{let u=t(s.element);return u===s.element?a:V(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,d=[];for(let f of u){let h=t(f);h!==f&&(l=!0),d.push(h)}let m=s.rest;return s.rest&&(m=t(s.rest),m!==s.rest&&(l=!0)),l?V(a,{...s,items:d,rest:m}):a}case"record":case"map":{let u=t(s.keyType),l=t(s.valueType);return u===s.keyType&&l===s.valueType?a:V(a,{...s,keyType:u,valueType:l})}case"set":{let u=t(s.valueType);return u===s.valueType?a:V(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,d=[];for(let m of u){let f=t(m);f!==m&&(l=!0),d.push(f)}return l?V(a,{...s,options:d}):a}case"intersection":{let u=t(s.left),l=t(s.right);return u===s.left&&l===s.right?a:V(a,{...s,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=t(s.innerType);return u===s.innerType?a:V(a,{...s,innerType:u})}case"pipe":{let u=t(s.in),l=t(s.out);return u===s.in&&l===s.out?a:V(a,{...s,in:u,out:l})}case"function":{let u=t(s.input),l=t(s.output);return u===s.input&&l===s.output?a:V(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...d}=s;return V(a,{...d,getter:()=>t(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return t(n)}function Wp(n){return ar(n,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:mn(r.options)}})}function z$(n,e){if(!e?.length)return n;let r=n._zod.def;return V(n,Ae(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function Hp(n){return z$(n.out,n.checks)}function w$(n){return n.in._zod.traits.has("$ZodTransform")?Hp(n):n.in}function Xp(n){return ar(n,{pipe:e=>w$(e._zod.def),default:(e,r)=>r?Tt(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function Yp(n){return ar(n,{pipe:e=>Hp(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var Ll={};Fe(Ll,{bigint:()=>T$,boolean:()=>S$,date:()=>P$,number:()=>I$,string:()=>k$});function k$(n){return fc(sn,n)}function I$(n){return _c(un,n)}function S$(n){return kc(ln,n)}function T$(n){return Sc(dn,n)}function P$(n){return Zc(Xn,n)}var F={maxBatchEvents:1e3,maxProjectIdLength:128,maxSessionIdLength:128,maxSdkVersionLength:64,maxUrlLength:2048,maxTitleLength:512,maxReferrerLength:2048,maxLanguageLength:35,maxMeshNameLength:256,maxAssetNameLength:1024,maxCustomNameLength:128,maxCustomPropValueLength:1024,maxCustomPropEntries:64,maxUserIdLength:128,maxUserTraitValueLength:1024,maxUserTraitEntries:64,maxSceneDescriptionLength:256,maxCameraNameLength:128,maxSceneProxyMeshNameLength:256,maxSceneProxyMeshPathLength:512,maxSceneProxyMeshes:1e4,maxNodeIdLength:128,maxBoneIdLength:128,maxChildPathLength:512,maxGraphicsDiagnosticMessageLength:1024,maxGraphicsDiagnosticCodeLength:64};function lo(n,e){return p.record(p.string(),n).refine(r=>Object.keys(r).length<=e,{message:`must have at most ${e} entries`})}var M=p.tuple([p.number(),p.number(),p.number()]),mo=p.tuple([p.number(),p.number(),p.number(),p.number()]),pn=p.tuple([p.number(),p.number()]),hn=p.tuple([p.number().min(0).max(1),p.number().min(0).max(1)]),fo=p.number().int().nonnegative(),po=p.string().regex(/^[A-Za-z0-9._:-]{1,64}$/,"sceneId must be 1-64 chars of [A-Za-z0-9._:-]");var D$=p.object({title:p.string().max(F.maxTitleLength).optional(),referrer:p.string().max(F.maxReferrerLength).optional(),viewport:p.tuple([p.number(),p.number()]).optional(),devicePixelRatio:p.number().positive().optional(),language:p.string().max(F.maxLanguageLength).optional()}).passthrough(),Ml={projectId:p.string().min(1).max(F.maxProjectIdLength),visitorId:p.string().optional(),sessionId:p.string().min(1).max(F.maxSessionIdLength),ts:fo,sdkVersion:p.string().min(1).max(F.maxSdkVersionLength),url:p.string().max(F.maxUrlLength).optional(),sceneId:po.optional(),pageMeta:D$.optional()},s0=p.object(Ml);function O(n,e){return p.object({type:p.literal(n),...Ml,...e})}var Vl=p.enum(["left","right"]),Bl=p.enum(["y","z"]),Qp=p.object({handedness:Vl,upAxis:Bl.default("y"),unitScale:p.number().positive().default(1)}).passthrough();var eh=p.object({engine:p.enum(["webgl2","webgpu","webgl","unknown"]).optional(),vendor:p.string().optional(),renderer:p.string().optional(),maxTextureSize:p.number().optional(),hardwareConcurrency:p.number().optional(),deviceMemoryGb:p.number().optional(),isMobile:p.boolean().optional(),browser:p.string().optional(),os:p.string().optional()}).passthrough(),th=p.enum(["arc-rotate","free","follow","static","other"]),nh=p.object({description:p.string().max(F.maxSceneDescriptionLength).optional(),cameraType:th.optional(),cameraName:p.string().max(F.maxCameraNameLength).optional(),meshCount:p.number().int().nonnegative().optional()}).passthrough(),rh=p.union([p.string().max(F.maxUserTraitValueLength),p.number(),p.boolean(),p.null()]),ih=p.object({id:p.string().max(F.maxUserIdLength).optional(),traits:lo(rh,F.maxUserTraitEntries).optional()}).passthrough(),oh=p.object({name:p.string(),version:p.string().optional(),coordinateSystem:Qp.optional()}).passthrough(),ho=p.enum(["webgl","webgl2","webgpu","opengl","opengles","d3d11","d3d12","vulkan","metal","unknown"]),ah=p.enum(["metal","d3d11","d3d12","vulkan","opengl","opengles","unknown"]),sh=p.enum(["glsl","glsl-es","wgsl","hlsl","msl","spirv","unknown"]),ch=p.object({api:ho.optional(),backend:ah.optional(),apiVersion:p.string().optional(),shadingLanguage:sh.optional()}).passthrough(),Jl=O("session_start",{device:eh.optional(),graphics:ch.optional(),scene:nh.optional(),user:ih.optional(),connector:oh.optional()});var Kl=O("session_end",{durationMs:p.number().nonnegative().optional(),reason:p.enum(["unload","hidden","manual","timeout"]).optional()});var ql=O("frame_perf",{fps:p.number().nonnegative(),frameTimeMs:p.number().nonnegative().optional(),frameTimeP95Ms:p.number().nonnegative().optional(),frameTimeP99Ms:p.number().nonnegative().optional(),longFrames:p.number().int().nonnegative().optional(),drawCalls:p.number().nonnegative().optional(),dpr:p.number().positive().optional(),renderScale:p.number().positive().optional(),position:M.optional()});var Gl=O("camera_sample",{position:M,direction:M,target:M.optional(),fov:p.number().optional(),aspect:p.number().positive().optional(),near:p.number().positive().optional(),hitPoint:M.optional(),hitMesh:p.string().optional()});var Wl=O("node_transform",{nodeId:p.string().min(1).max(F.maxNodeIdLength),boneId:p.string().min(1).max(F.maxBoneIdLength).optional(),childPath:p.string().min(1).max(F.maxChildPathLength).optional(),position:M,rotation:mo,scale:M.optional()});var uh=p.enum(["mouse","touch","stylus","pen","keyboard","gamepad","xr-controller","hand","gaze","transient","other"]),lh=p.enum(["left","right","none"]),dh=p.object({origin:M,direction:M}),se={source:uh.optional(),handedness:lh.optional(),sourceId:p.string().min(1).max(64).optional(),ray:dh.optional()};var O$={screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),...se},Hl=O("pointer_move",O$);var Xl=O("pointer_click",{screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),uv:pn.optional(),button:p.number().int().min(0).optional(),...se});var mh={screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),button:p.number().int().min(0).optional(),...se},Yl=O("pointer_down",mh),Ql=O("pointer_up",mh);var fh=p.enum(["orbit","pan","dolly","zoom","roll","fly","navigate"]),ed=O("camera_gesture",{kind:fh,durationMs:p.number().nonnegative(),orbitDeg:p.number().nonnegative().optional(),rollDeg:p.number().nonnegative().optional(),zoomRatio:p.number().positive().optional(),panDist:p.number().nonnegative().optional(),...se});var ph=p.enum(["hover","pick","click","drag","select","squeeze","grab","release","teleport"]),td=O("mesh_interaction",{mesh:p.string().min(1).max(F.maxMeshNameLength),kind:ph,point:M.optional(),uv:pn.optional(),...se});var go=p.tuple([p.number(),p.number(),p.number(),p.number(),p.number(),p.number()]),R$=p.literal("aabb"),j$=p.object({position:M,rotation:mo,scale:M}),U$=p.object({name:p.string().max(F.maxSceneProxyMeshNameLength),aabb:go,triangles:p.number().int().nonnegative().optional(),path:p.string().min(1).max(F.maxSceneProxyMeshPathLength).optional(),world:j$.optional()}),N$=1,fk=p.object({version:p.literal(N$),sceneId:po,kind:R$,bounds:go,upAxis:Bl,handedness:Vl.optional(),unitScale:p.number().positive(),meshes:p.array(U$).max(F.maxSceneProxyMeshes),meshCount:p.number().int().nonnegative(),contentHash:p.string().min(1),capturedAt:fo,sdkVersion:p.string().min(1)});var hh=O("mesh_visibility",{mesh:p.string().min(1).max(F.maxMeshNameLength),visibleMs:p.number().nonnegative(),centeredMs:p.number().nonnegative().optional(),maxScreenFraction:p.number().min(0).max(1).optional(),bounds:go.optional()});var gh=O("hover_dwell",{mesh:p.string().min(1),dwellMs:p.number().nonnegative(),uv:pn.optional(),...se});var A$=p.enum(["shader","pipeline","material","other"]),vh=O("compile_stall",{durationMs:p.number().nonnegative(),phase:A$.optional()});var _h=O("resource_sample",{textureBytes:p.number().nonnegative().optional(),geometryBytes:p.number().nonnegative().optional(),triangles:p.number().int().nonnegative().optional(),vertices:p.number().int().nonnegative().optional(),jsHeapBytes:p.number().nonnegative().optional()});var yh=p.enum(["graphics-backend","quality","device-recovery","tracking","feature","other"]),nd=O("capability_change",{kind:yh,from:p.string().max(64).optional(),to:p.string().max(64).optional(),reason:p.string().max(120).optional(),durationMs:p.number().nonnegative().optional(),...se});var rd=O("asset_load",{name:p.string().max(F.maxAssetNameLength),bytes:p.number().nonnegative().optional(),loadMs:p.number().nonnegative(),ttffMs:p.number().nonnegative().optional(),ttiMs:p.number().nonnegative().optional()});var id=O("scene_change",{});var $h=O("viewport_resize",{width:p.number().positive(),height:p.number().positive(),dpr:p.number().positive().optional()});var E$=p.enum(["visible","hidden"]),xh=O("visibility_change",{state:E$});var bh=O("focus_change",{focused:p.boolean()});var zh=O("context_lost",{reason:p.string().max(512).optional()}),wh=O("context_restored",{});var kh=p.enum(["info","warning","error","fatal"]),Ih=p.enum(["context-loss","validation","out-of-memory","shader-compile","device-lost","fallback"]),od=O("graphics_diagnostic",{severity:kh,category:Ih,backend:ho.optional(),message:p.string().max(F.maxGraphicsDiagnosticMessageLength).optional(),code:p.string().max(F.maxGraphicsDiagnosticCodeLength).optional(),count:p.number().int().positive().optional(),position:M.optional()});var Z$=p.enum(["error","unhandledrejection"]),Sh=O("runtime_error",{kind:Z$,message:p.string().max(1024),source:p.string().max(1024).optional(),lineno:p.number().int().nonnegative().optional(),colno:p.number().int().nonnegative().optional(),stack:p.string().max(4096).optional(),position:M.optional()});var ad=O("input_action",{action:p.string().min(1).max(64),code:p.string().min(1).max(64).optional(),button:p.number().int().nonnegative().optional(),pressed:p.boolean().optional(),...se});var Th=O("xr_boundary_proximity",{position:M,durationMs:p.number().nonnegative()});var Ph=p.enum(["floor","wall","table","ceiling","unknown"]),sd=O("ar_placement",{mesh:p.string().min(1).max(F.maxMeshNameLength),position:M,surface:Ph.optional(),attempts:p.number().int().positive(),timeToPlaceMs:p.number().nonnegative(),scale:p.number().positive(),final:p.boolean()});var Dh=p.union([p.string().max(F.maxCustomPropValueLength),p.number(),p.boolean(),p.null()]),cd=O("custom",{name:p.string().min(1).max(F.maxCustomNameLength),props:lo(Dh,F.maxCustomPropEntries).optional()});var vo=p.discriminatedUnion("type",[Jl,Kl,ql,Gl,Wl,Hl,Xl,Yl,Ql,ed,td,hh,gh,vh,_h,nd,rd,id,$h,xh,bh,zh,wh,od,Sh,ad,Th,sd,cd]);var Oh=p.array(vo);async function Rh(n){let e=n.fetchImpl??fetch,r=`${n.endpoint}/api/v1/sessions/${encodeURIComponent(n.sessionId)}/events`,i=await e(r,{headers:{"x-api-key":n.apiKey}});if(!i.ok)throw new Error(`replay fetch failed: ${i.status}`);let t=Oh.safeParse(await i.json());if(!t.success)throw new Error("replay fetch returned an invalid session payload");return t.data.sort((o,a)=>o.ts-a.ts)}async function*ud(n){let e=n.fetchImpl??fetch,r=`${n.endpoint}/api/v1/sessions/${encodeURIComponent(n.sessionId)}/events`,i=await e(`${r}?format=ndjson`,{headers:{"x-api-key":n.apiKey,accept:"application/x-ndjson"}});if(!i.ok)throw new Error(`replay fetch failed: ${i.status}`);if(!(i.headers.get("content-type")??"").includes("application/x-ndjson")){let d=Oh.safeParse(await i.json());if(!d.success)throw new Error("replay fetch returned an invalid session payload");for(let m of d.data.sort((f,h)=>f.ts-h.ts))yield m;return}if(!i.body)throw new Error("replay stream returned no body");let o=0,a=()=>n.onMalformedLine?.(++o),s=i.body.getReader(),c=new TextDecoder,u="",l=function*(d){let m=d.trim();if(m.length===0)return;let f;try{f=JSON.parse(m)}catch{a();return}let h=vo.safeParse(f);h.success?yield h.data:a()};for(;;){let{done:d,value:m}=await s.read();if(d)break;u+=c.decode(m,{stream:!0});let f=u.indexOf(`
61
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of n.seen.entries()){let s=a[1];if(e===a[0]){o(a);continue}if(n.external){let u=n.external.registry.get(a[0])?.id;if(e!==a[0]&&u){o(a);continue}}if(n.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&n.reused==="ref"){o(a);continue}}n.external&&(n.sharedDefsExtractedFor=n.external)}function bf(n){let e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;let r=[];for(let i of e){if(!i||typeof i!="object")return;bf(i);let t=Object.keys(i);if(t.length!==1||t[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete n.anyOf,n.type=r.length===1?r[0]:r}var zf=new Set(["type","properties","required","additionalProperties"]),$f=["oneOf","anyOf"];function xf(n){let e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Gc(n){let e=[];for(let o of n){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!zf.has(a))return null;e.push(o)}let r={},i=new Set;for(let o of e){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let u of e){let l=u.properties?.[a]??xf(u);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:Gc(s)??{allOf:s};Q(r,a,c)}for(let a of o.required??[])i.add(a)}let t={type:"object",properties:r};if(i.size&&(t.required=[...i]),e.every(o=>o.additionalProperties===!1))t.additionalProperties=!1;else{let o=[];for(let a of e){let s=xf(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?t.additionalProperties=o[0]:o.length>1&&(t.additionalProperties={allOf:o})}return t}function r$(n){let e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(let t of zf)if(t in n)return;let r=e.filter(t=>$f.some(o=>Array.isArray(t[o]))),i=null;if(!r.length)i=Gc(e);else{let t=r[0],o=$f.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=e.filter(c=>c!==t),s=t[o].map(c=>Gc([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete n.allOf,Kn(n,i))}function ut(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=n.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let f=n.seen.get(d),h=f.schema;if(h.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Kn(u,h),Kn(u,l),s._zod.parent===d)for(let z in u)z==="$ref"||z==="allOf"||z in l||delete u[z];if(h.$ref&&f.def)for(let z in u)z==="$ref"||z==="allOf"||z in f.def&&JSON.stringify(u[z])===JSON.stringify(f.def[z])&&delete u[z]}let m=s._zod.parent;if(m&&m!==d){i(m);let f=n.seen.get(m);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let h in u)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(u[h])===JSON.stringify(f.def[h])&&delete u[h]}n.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(let s of[...n.seen.entries()].reverse())i(s[0]);if(n.target!=="openapi-3.0")for(let s of n.seen.entries())bf(s[1].def??s[1].schema);for(let s of n.deferred)s();if(n.intersections.length){let s=new Map;for(let c of n.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(u):s.set(l,[u])}for(let c of n.intersections)for(let u of s.get(c)??[])r$(u)}}let t={};if(n.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){let s=n.external.registry.get(e)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=n.external.uri(s)}Kn(t,r.defId?r.schema:r.def??r.schema);let o=n.metadataRegistry.get(e)?.id;o!==void 0&&t.id===o&&delete t.id;let a=n.external?.defs??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(let s of n.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Q(a,c.defId,c.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(a).length>0&&(n.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...e["~standard"],jsonSchema:{input:rn(e,"input",n.processors),output:rn(e,"output",n.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function he(n,e){let r=e??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let i=n._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return he(i.element,r);if(i.type==="set")return he(i.valueType,r);if(i.type==="lazy")return he(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return he(i.innerType,r);if(i.type==="intersection")return he(i.left,r)||he(i.right,r);if(i.type==="record"||i.type==="map")return he(i.keyType,r)||he(i.valueType,r);if(i.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:he(i.in,r)||he(i.out,r);if(i.type==="object"){for(let t in i.shape)if(he(i.shape[t],r))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(he(t,r))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(he(t,r))return!0;return!!(i.rest&&he(i.rest,r))}return!1}var Wc=(n,e={})=>r=>{let i=st({...r,processors:e});return B(n,i),ct(i,n),ut(i,n)},rn=(n,e,r={})=>i=>{let{libraryOptions:t,target:o}=i??{},a=st({...t??{},target:o,io:e,processors:r});return B(n,a),ct(a,n),ut(a,n)};var i$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yc=(n,e,r,i)=>{let t=r;t.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=n._zod.bag;if(typeof o=="number"&&(t.minLength=o),typeof a=="number"&&(t.maxLength=a),s&&(t.format=i$[s]??s,t.format===""&&delete t.format,(s==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Qc=(n,e,r,i)=>{let t=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=n._zod.bag;typeof s=="string"&&s.includes("int")?t.type="integer":t.type="number";let d=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof o=="number"&&(t.minimum=o),m?f?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof c=="number"&&(Number.isFinite(c)&&c!==0?t.multipleOf=Math.abs(c):ne(n,e,t,i,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},eu=(n,e,r,i)=>{r.type="boolean"},tu=(n,e,r,i)=>{ne(n,e,r,i,"BigInt cannot be represented in JSON Schema")},nu=(n,e,r,i)=>{ne(n,e,r,i,"Symbols cannot be represented in JSON Schema")},ru=(n,e,r,i)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},iu=(n,e,r,i)=>{ne(n,e,r,i,"Undefined cannot be represented in JSON Schema")},ou=(n,e,r,i)=>{ne(n,e,r,i,"Void cannot be represented in JSON Schema")},au=(n,e,r,i)=>{r.not={}},su=(n,e,r,i)=>{},cu=(n,e,r,i)=>{},uu=(n,e,r,i)=>{ne(n,e,r,i,"Date cannot be represented in JSON Schema")},lu=(n,e,r,i)=>{let t=n._zod.def,o=yn(t.entries);if(o.length===0){r.not={};return}o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},du=(n,e,r,i)=>{let t=n._zod.def;if(t.values.length===0){r.not={};return}let o=[];for(let a of t.values)if(a===void 0){if(ne(n,e,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(ne(n,e,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},mu=(n,e,r,i)=>{ne(n,e,r,i,"NaN cannot be represented in JSON Schema")},fu=(n,e,r,i)=>{let t=r,o=n._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=o.source},pu=(n,e,r,i)=>{let t=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=n._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(t,o)):(Object.assign(t,o),t.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(t,o)},hu=(n,e,r,i)=>{r.type="boolean"},gu=(n,e,r,i)=>{ne(n,e,r,i,"Custom types cannot be represented in JSON Schema")},vu=(n,e,r,i)=>{ne(n,e,r,i,"Function types cannot be represented in JSON Schema")},_u=(n,e,r,i)=>{ne(n,e,r,i,"Transforms cannot be represented in JSON Schema")},yu=(n,e,r,i)=>{ne(n,e,r,i,"Map cannot be represented in JSON Schema")},$u=(n,e,r,i)=>{ne(n,e,r,i,"Set cannot be represented in JSON Schema")},xu=(n,e,r,i)=>{let t=r,o=n._zod.def,{minimum:a,maximum:s}=n._zod.bag;typeof a=="number"&&(t.minItems=a),typeof s=="number"&&(t.maxItems=s),t.type="array",t.items=B(o.element,e,{...i,path:[...i.path,"items"]})};function qn(n){let e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qn(e.out):e.type==="catch"?qn(e.innerType):n._zod.optin}var bu=(n,e,r,i)=>{let t=r,o=n._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&ne(n,e,t,i,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)Q(t.properties,l,B(a[l],e,{...i,path:[...i.path,"properties",l]}));let c=new Set(Object.keys(a)),u=new Set([...c].filter(l=>{let d=o.shape[l];return e.io==="input"?qn(d)===void 0:d._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),o.catchall?._zod.def.type==="never"?t.additionalProperties=!1:o.catchall?o.catchall&&(t.additionalProperties=B(o.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(t.additionalProperties=!1)},Ri=(n,e,r,i)=>{let t=n._zod.def,o=t.inclusive===!1,a=t.options.map((s,c)=>B(s,e,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},zu=(n,e,r,i)=>{let t=n._zod.def,o=B(t.left,e,{...i,path:[...i.path,"allOf",0]}),a=B(t.right,e,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c,e.intersections.push(c)},wu=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="array";let a=e.target==="draft-2020-12"?"prefixItems":"items",s=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((_,z)=>B(_,e,{...i,path:[...i.path,a,z]})),u=o.rest?B(o.rest,e,{...i,path:[...i.path,s,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let _=o.items[l-1];if(!(e.io==="input"?qn(_)!==void 0:_._zod.optout==="optional"))break;l--}let d=o.items.length,m=!o.rest;e.target==="draft-2020-12"?(t.prefixItems=c,m?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),m&&(t.maxItems=d)):e.target==="openapi-3.0"?(t.items={anyOf:c},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),m&&(t.maxItems=d)):(t.items=c,m?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),m&&(t.maxItems=d));let{minimum:f,maximum:h}=n._zod.bag;typeof f=="number"&&(t.minItems=f),typeof h=="number"&&(t.maxItems=h)};function Hc(n,e,r){if(e.$ref){if(r.has(e))return e;r.add(e);let h=n.get(e)?.def;if(!h)return e;let _=Hc(n,h,r);return _===h?e:_}for(let h of["anyOf","oneOf"]){let _=e[h];if(!Array.isArray(_))continue;let z=_.map(P=>Hc(n,P,r));z.some((P,x)=>P!==_[x])&&(e={...e,[h]:z})}let i=Array.isArray(e.type)?e.type:[e.type],t=!i.includes("string")&&i.some(h=>h==="number"||h==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!t&&!o?.some(h=>typeof h=="number"))return e;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:m,...f}=e;return f.enum?f.enum=f.enum.map(h=>typeof h=="number"?String(h):h):typeof f.const=="number"&&(f.const=String(f.const)),t&&(f.type="string",o||(f.pattern=(i.includes("number")?it:Pn).source)),f}var Xc=new WeakMap;function o$(n){let e=new Map;for(let i of n.seen.values())i.def&&!e.has(i.schema)&&e.set(i.schema,i);let r=new Map;for(let i of Xc.get(n)??[]){let t=n.seen.get(i),o=(t?.def??t?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let a=Hc(e,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let i of n.seen.values())for(let t of[i.schema,i.def]){let o=t&&r.get(t.propertyNames);o&&(t.propertyNames=o)}}var ku=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let d=B(o.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let m of c)Q(t.patternProperties,m.source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){t.propertyNames=B(o.keyType,e,{...i,path:[...i.path,"propertyNames"]});let d=Xc.get(e);d||(d=[],Xc.set(e,d),e.deferred.push(()=>o$(e))),d.push(n)}t.additionalProperties=B(o.valueType,e,{...i,path:[...i.path,"additionalProperties"]})}let u=a._zod.values,l=e.io==="input"&&qn(o.valueType)!==void 0;if(u&&!o.partial&&!l){let d=[...u].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(t.required=d.map(String))}},Iu=(n,e,r,i)=>{let t=n._zod.def,o=B(t.innerType,e,i),a=e.seen.get(n);e.target==="openapi-3.0"?(a.ref=t.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Su=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Tu=Symbol();function wf(n,e,r,i,t){let o=!1,a=JSON.stringify(n,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(ne(e,r,i,t,"BigInt defaults cannot be represented in JSON Schema"),Tu):JSON.parse(a)}var Pu=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let a=wf(t.defaultValue,n,e,r,i);a!==Tu&&(r.default=a)},Du=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);if(o.ref=t.innerType,e.io!=="input")return;let a=wf(t.defaultValue,n,e,r,i);a!==Tu&&(r._prefault=a)},Ou=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{ne(n,e,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},Ru=(n,e,r,i)=>{let t=n._zod.def,o=t.in._zod.traits.has("$ZodTransform"),a=e.io==="input"?o?t.out:t.in:t.out;B(a,e,i);let s=e.seen.get(n);s.ref=a},ju=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.readOnly=!0},Uu=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},ji=(n,e,r,i)=>{let t=n._zod.def;B(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Nu=(n,e,r,i)=>{let t=n._zod.innerType;B(t,e,i);let o=e.seen.get(n);o.ref=t},Oi={string:Yc,number:Qc,boolean:eu,bigint:tu,symbol:nu,null:ru,undefined:iu,void:ou,never:au,any:su,unknown:cu,date:uu,enum:lu,literal:du,nan:mu,template_literal:fu,file:pu,success:hu,custom:gu,function:vu,transform:_u,map:yu,set:$u,array:xu,object:bu,union:Ri,intersection:zu,tuple:wu,record:ku,nullable:Iu,nonoptional:Su,default:Pu,prefault:Du,catch:Ou,pipe:Ru,readonly:ju,promise:Uu,optional:ji,lazy:Nu};function Ui(n,e){if("_idmap"in n){let i=n,t=st({...e,processors:Oi}),o={};for(let c of i._idmap.entries()){let[u,l]=c;B(l,t)}let a={},s={registry:i,uri:e?.uri,defs:o};t.external=s;for(let c of i._idmap.entries()){let[u,l]=c;ct(t,l),Q(a,u,ut(t,l))}if(Object.keys(o).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=st({...e,processors:Oi});return B(n,r),ct(r,n),ut(r,n)}var Ni=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=st({processors:Oi,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return B(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ct(this.ctx,e);let i=ut(this.ctx,e),{"~standard":t,...o}=i;return o}};var kf={};var fn={};Fe(fn,{ZodAny:()=>nl,ZodArray:()=>al,ZodBase64:()=>eo,ZodBase64URL:()=>to,ZodBigInt:()=>dn,ZodBigIntFormat:()=>io,ZodBoolean:()=>ln,ZodCIDRv4:()=>Yi,ZodCIDRv6:()=>Qi,ZodCUID:()=>Ji,ZodCUID2:()=>Ki,ZodCatch:()=>Sl,ZodCodec:()=>rr,ZodCreditCard:()=>Wu,ZodCustom:()=>ir,ZodCustomStringFormat:()=>cn,ZodDate:()=>Xn,ZodDefault:()=>xl,ZodDiscriminatedUnion:()=>cl,ZodE164:()=>no,ZodEmail:()=>Li,ZodEmoji:()=>Vi,ZodEnum:()=>an,ZodExactOptional:()=>co,ZodFile:()=>vl,ZodFunction:()=>El,ZodGUID:()=>Mi,ZodIPv4:()=>Hi,ZodIPv6:()=>Xi,ZodISODate:()=>dt,ZodISODateTime:()=>lt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,ZodIntersection:()=>ul,ZodJWT:()=>ro,ZodKSUID:()=>Wi,ZodLazy:()=>Ul,ZodLiteral:()=>gl,ZodMAC:()=>Gu,ZodMap:()=>pl,ZodNaN:()=>Pl,ZodNanoID:()=>Bi,ZodNever:()=>il,ZodNonOptional:()=>uo,ZodNull:()=>el,ZodNullable:()=>$l,ZodNumber:()=>un,ZodNumberFormat:()=>Dt,ZodObject:()=>Qn,ZodOptional:()=>tr,ZodPipe:()=>nr,ZodPrefault:()=>zl,ZodPreprocess:()=>Dl,ZodPromise:()=>Al,ZodReadonly:()=>Ol,ZodRecord:()=>on,ZodSet:()=>hl,ZodString:()=>sn,ZodStringFormat:()=>q,ZodSuccess:()=>Il,ZodSymbol:()=>Yu,ZodTemplateLiteral:()=>jl,ZodTransform:()=>_l,ZodTuple:()=>dl,ZodType:()=>E,ZodULID:()=>qi,ZodURL:()=>Hn,ZodUUID:()=>Ke,ZodUndefined:()=>Qu,ZodUnion:()=>er,ZodUnknown:()=>rl,ZodVoid:()=>ol,ZodXID:()=>Gi,ZodXor:()=>sl,_ZodString:()=>Fi,_default:()=>bl,_function:()=>Np,any:()=>mp,array:()=>Yn,base64:()=>Gf,base64url:()=>Wf,bigint:()=>sp,boolean:()=>Xu,catch:()=>Tl,check:()=>Ap,cidrv4:()=>Kf,cidrv6:()=>qf,codec:()=>Op,creditCard:()=>Xf,cuid:()=>Zf,cuid2:()=>Cf,custom:()=>Ep,date:()=>pp,describe:()=>Zp,discriminatedUnion:()=>$p,e164:()=>Hf,email:()=>Tf,emoji:()=>Af,enum:()=>ao,exactOptional:()=>yl,file:()=>Sp,float32:()=>rp,float64:()=>ip,function:()=>Np,guid:()=>Pf,hash:()=>np,hex:()=>tp,hostname:()=>ep,httpUrl:()=>Nf,instanceof:()=>Fp,int:()=>Zi,int32:()=>op,int64:()=>cp,intersection:()=>ll,invertCodec:()=>Rp,ipv4:()=>Vf,ipv6:()=>Jf,json:()=>Mp,jwt:()=>Yf,keyof:()=>hp,ksuid:()=>Mf,lazy:()=>Nl,literal:()=>Ip,looseObject:()=>_p,looseRecord:()=>bp,mac:()=>Bf,map:()=>zp,meta:()=>Cp,nan:()=>Dp,nanoid:()=>Ef,nativeEnum:()=>kp,never:()=>oo,nonoptional:()=>kl,null:()=>tl,nullable:()=>Wn,nullish:()=>Tp,number:()=>Hu,object:()=>gp,optional:()=>Tt,partialRecord:()=>xp,pipe:()=>Ci,prefault:()=>wl,preprocess:()=>Vp,promise:()=>Up,readonly:()=>Rl,record:()=>fl,refine:()=>Zl,set:()=>wp,strictObject:()=>vp,string:()=>Gn,stringFormat:()=>Qf,stringbool:()=>Lp,success:()=>Pp,superRefine:()=>Cl,symbol:()=>lp,templateLiteral:()=>jp,transform:()=>so,tuple:()=>ml,uint32:()=>ap,uint64:()=>up,ulid:()=>Ff,undefined:()=>dp,union:()=>mn,unknown:()=>St,url:()=>Uf,uuid:()=>Df,uuidv4:()=>Of,uuidv6:()=>Rf,uuidv7:()=>jf,void:()=>fp,xid:()=>Lf,xor:()=>yp});var Ai={};Fe(Ai,{endsWith:()=>Wt,gt:()=>Be,gte:()=>Pe,includes:()=>qt,length:()=>It,lowercase:()=>Jt,lt:()=>Ve,lte:()=>Te,maxLength:()=>kt,maxSize:()=>at,mime:()=>Ht,minLength:()=>He,minSize:()=>Je,multipleOf:()=>ot,negative:()=>Ii,nonnegative:()=>Ti,nonpositive:()=>Si,normalize:()=>Xt,overwrite:()=>Ze,positive:()=>ki,properties:()=>Di,property:()=>Pi,regex:()=>Bt,size:()=>wt,slugify:()=>tn,startsWith:()=>Gt,toLowerCase:()=>Qt,toUpperCase:()=>en,trim:()=>Yt,uppercase:()=>Kt});var If=new WeakSet([Object.prototype,Error.prototype]);function Ei(n,e,r){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var Sf=(n,e)=>{In.init(n,e),n.name="ZodError";let r=Object.getPrototypeOf(n);If.has(r)||(If.add(r),Ei(r,"format",i=>t=>Tn(i,t)),Ei(r,"flatten",i=>t=>Sn(i,t)),Ei(r,"addIssue",i=>t=>{i.issues.push(t),i.message=JSON.stringify(i.issues,Ut,2)}),Ei(r,"addIssues",i=>t=>{i.issues.push(...t),i.message=JSON.stringify(i.issues,Ut,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},s$=g("ZodError",Sf),ze=g("ZodError",Sf,void 0,{Parent:Error});var Au=Et(ze),Eu=Zt(ze),Zu=Ct(ze),Cu=Ft(ze),Fu=gr(ze),Lu=vr(ze),Mu=_r(ze),Vu=yr(ze),Bu=$r(ze),Ju=xr(ze),Ku=br(ze),qu=zr(ze);function u$(){ie.localeError||ee(Yr())}function Pt(){ie.memoizer||ee({memoizer:Zn()})}var E=g("ZodType",(n,e)=>(u$(),N.init(n,e),n.def=e,n.type=e.type,n),{check(...n){let e=this.def;return this.clone(b.mergeDefs(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return V(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Zl(n,e))},superRefine(n,e){return this.check(Cl(n,e))},overwrite(n){return this.check(Ze(n))},optional(){return Tt(this)},exactOptional(){return yl(this)},nullable(){return Wn(this)},nullish(){return Tt(Wn(this))},nonoptional(n){return kl(this,n)},array(){return Yn(this)},or(n){return mn([this,n])},and(n){return ll(this,n)},transform(n){return Ci(this,so(n))},default(n){return bl(this,n)},prefault(n){return wl(this,n)},catch(n){return Tl(this,n)},pipe(n){return Ci(this,n)},readonly(){return Rl(this)},describe(n){let e=this.clone();return ae.add(e,{description:n}),e},meta(...n){if(n.length===0)return ae.get(this);let e=this.clone();return ae.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return b.hide(this,"~standard",{...Ur(this),jsonSchema:{input:rn(this,"input"),output:rn(this,"output")}})},set"~standard"(n){b.own(this,"~standard",n)},parse:function n(e,r){return Au(this,e,r,{callee:n})},parseAsync:async function n(e,r){return await Eu(this,e,r,{callee:n})},safeParse(n,e){return Zu(this,n,e)},async safeParseAsync(n,e){return Cu(this,n,e)},get spa(){return this?.safeParseAsync},set spa(n){b.own(this,"spa",n)},encode:function n(e,r){return Fu(this,e,r,{callee:n})},decode:function n(e,r){return Lu(this,e,r,{callee:n})},encodeAsync:async function n(e,r){return await Mu(this,e,r,{callee:n})},decodeAsync:async function n(e,r){return await Vu(this,e,r,{callee:n})},safeEncode(n,e){return Bu(this,n,e)},safeDecode(n,e){return Ju(this,n,e)},async safeEncodeAsync(n,e){return Ku(this,n,e)},async safeDecodeAsync(n,e){return qu(this,n,e)},toJSONSchema(n){return Wc(this,{})(n)},get description(){return ae.get(this)?.description},get _def(){return this._zod.def}}),Fi=g("_ZodString",(n,e)=>{yt.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Yc(n,i,t,o);let r=n._zod.bag;n.format=r.format??null,n.minLength=r.minimum??null,n.maxLength=r.maximum??null},{regex(...n){return this.check(Bt(...n))},includes(...n){return this.check(qt(...n))},startsWith(...n){return this.check(Gt(...n))},endsWith(...n){return this.check(Wt(...n))},min(...n){return this.check(He(...n))},max(...n){return this.check(kt(...n))},length(...n){return this.check(It(...n))},nonempty(...n){return this.check(He(1,...n))},lowercase(n){return this.check(Jt(n))},uppercase(n){return this.check(Kt(n))},trim(){return this.check(Yt())},normalize(...n){return this.check(Xt(...n))},toLowerCase(){return this.check(Qt())},toUpperCase(){return this.check(en())},slugify(){return this.check(tn())}}),sn=g("ZodString",(n,e)=>{yt.init(n,e),Fi.init(n,e)},{email(n){return this.check(ii(Li,n))},url(n){return this.check(Ln(Hn,n))},jwt(n){return this.check(wi(ro,n))},emoji(n){return this.check(li(Vi,n))},guid(n){return this.check(oi(Mi,n))},uuid(n){return this.check(ai(Ke,n))},uuidv4(n){return this.check(si(Ke,n))},uuidv6(n){return this.check(ci(Ke,n))},uuidv7(n){return this.check(ui(Ke,n))},nanoid(n){return this.check(di(Bi,n))},cuid(n){return this.check(mi(Ji,n))},cuid2(n){return this.check(fi(Ki,n))},ulid(n){return this.check(pi(qi,n))},base64(n){return this.check(xi(eo,n))},base64url(n){return this.check(bi(to,n))},xid(n){return this.check(hi(Gi,n))},ksuid(n){return this.check(gi(Wi,n))},ipv4(n){return this.check(vi(Hi,n))},ipv6(n){return this.check(_i(Xi,n))},cidrv4(n){return this.check(yi(Yi,n))},cidrv6(n){return this.check($i(Qi,n))},e164(n){return this.check(zi(no,n))},datetime(n){return this.check(Mn(lt,n))},date(n){return this.check(Vn(dt,n))},time(n){return this.check(Bn(mt,n))},duration(n){return this.check(Jn(ft,n))}});function Gn(n){return mc(sn,n)}var q=g("ZodStringFormat",(n,e)=>{J.init(n,e),Fi.init(n,e)}),lt=g("ZodISODateTime",(n,e)=>{rs.init(n,e),q.init(n,e)}),dt=g("ZodISODate",(n,e)=>{is.init(n,e),q.init(n,e)}),mt=g("ZodISOTime",(n,e)=>{os.init(n,e),q.init(n,e)}),ft=g("ZodISODuration",(n,e)=>{as.init(n,e),q.init(n,e)}),Li=g("ZodEmail",(n,e)=>{Ka.init(n,e),q.init(n,e)});function Tf(n){return ii(Li,n)}var Mi=g("ZodGUID",(n,e)=>{Ba.init(n,e),q.init(n,e)});function Pf(n){return oi(Mi,n)}var Ke=g("ZodUUID",(n,e)=>{Ja.init(n,e),q.init(n,e)});function Df(n){return ai(Ke,n)}function Of(n){return si(Ke,n)}function Rf(n){return ci(Ke,n)}function jf(n){return ui(Ke,n)}var Hn=g("ZodURL",(n,e)=>{Wa.init(n,e),q.init(n,e)});function Uf(n){return Ln(Hn,n)}function Nf(n){return Ln(Hn,{protocol:fe.httpProtocol,hostname:fe.domain,...b.normalizeParams(n)})}var Vi=g("ZodEmoji",(n,e)=>{Ha.init(n,e),q.init(n,e)});function Af(n){return li(Vi,n)}var Bi=g("ZodNanoID",(n,e)=>{Xa.init(n,e),q.init(n,e)});function Ef(n){return di(Bi,n)}var Ji=g("ZodCUID",(n,e)=>{Ya.init(n,e),q.init(n,e)});function Zf(n){return mi(Ji,n)}var Ki=g("ZodCUID2",(n,e)=>{Qa.init(n,e),q.init(n,e)});function Cf(n){return fi(Ki,n)}var qi=g("ZodULID",(n,e)=>{es.init(n,e),q.init(n,e)});function Ff(n){return pi(qi,n)}var Gi=g("ZodXID",(n,e)=>{ts.init(n,e),q.init(n,e)});function Lf(n){return hi(Gi,n)}var Wi=g("ZodKSUID",(n,e)=>{ns.init(n,e),q.init(n,e)});function Mf(n){return gi(Wi,n)}var Hi=g("ZodIPv4",(n,e)=>{ss.init(n,e),q.init(n,e)});function Vf(n){return vi(Hi,n)}var Gu=g("ZodMAC",(n,e)=>{us.init(n,e),q.init(n,e)});function Bf(n){return pc(Gu,n)}var Xi=g("ZodIPv6",(n,e)=>{cs.init(n,e),q.init(n,e)});function Jf(n){return _i(Xi,n)}var Yi=g("ZodCIDRv4",(n,e)=>{ls.init(n,e),q.init(n,e)});function Kf(n){return yi(Yi,n)}var Qi=g("ZodCIDRv6",(n,e)=>{ds.init(n,e),q.init(n,e)});function qf(n){return $i(Qi,n)}var eo=g("ZodBase64",(n,e)=>{ms.init(n,e),q.init(n,e)});function Gf(n){return xi(eo,n)}var to=g("ZodBase64URL",(n,e)=>{fs.init(n,e),q.init(n,e)});function Wf(n){return bi(to,n)}var no=g("ZodE164",(n,e)=>{ps.init(n,e),q.init(n,e)});function Hf(n){return zi(no,n)}var Wu=g("ZodCreditCard",(n,e)=>{hs.init(n,e),q.init(n,e)});function Xf(n){return hc(Wu,n)}var ro=g("ZodJWT",(n,e)=>{gs.init(n,e),q.init(n,e)});function Yf(n){return wi(ro,n)}var cn=g("ZodCustomStringFormat",(n,e)=>{vs.init(n,e),q.init(n,e)});function Qf(n,e,r={}){return nn(cn,n,e,r)}function ep(n){return nn(cn,"hostname",fe.hostname,n)}function tp(n){return nn(cn,"hex",fe.hex,n)}function np(n,e){let r=e?.enc??"hex",i=`${n}_${r}`,t=fe[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return nn(cn,i,t,e)}var un=g("ZodNumber",(n,e)=>{Vr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Qc(n,i,t,o);let r=n._zod.bag;n.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),n.isFinite=!0,n.format=r.format??null},{gt(n,e){return this.check(Be(n,e))},gte(n,e){return this.check(Pe(n,e))},min(n,e){return this.check(Pe(n,e))},lt(n,e){return this.check(Ve(n,e))},lte(n,e){return this.check(Te(n,e))},max(n,e){return this.check(Te(n,e))},int(n){return this.check(Zi(n))},safe(n){return this.check(Zi(n))},positive(n){return this.check(Be(0,n))},nonnegative(n){return this.check(Pe(0,n))},negative(n){return this.check(Ve(0,n))},nonpositive(n){return this.check(Te(0,n))},multipleOf(n,e){return this.check(ot(n,e))},step(n,e){return this.check(ot(n,e))},finite(){return this}});function Hu(n){return vc(un,n)}var Dt=g("ZodNumberFormat",(n,e)=>{_s.init(n,e),un.init(n,e)});function Zi(n){return yc(Dt,n)}function rp(n){return $c(Dt,n)}function ip(n){return xc(Dt,n)}function op(n){return bc(Dt,n)}function ap(n){return zc(Dt,n)}var ln=g("ZodBoolean",(n,e)=>{Un.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>eu(n,r,i,t)});function Xu(n){return wc(ln,n)}var dn=g("ZodBigInt",(n,e)=>{Br.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>tu(n,i,t,o);let r=n._zod.bag;n.minValue=r.minimum??null,n.maxValue=r.maximum??null,n.format=r.format??null},{gte(n,e){return this.check(Pe(n,e))},min(n,e){return this.check(Pe(n,e))},gt(n,e){return this.check(Be(n,e))},lt(n,e){return this.check(Ve(n,e))},lte(n,e){return this.check(Te(n,e))},max(n,e){return this.check(Te(n,e))},positive(n){return this.check(Be(BigInt(0),n))},negative(n){return this.check(Ve(BigInt(0),n))},nonpositive(n){return this.check(Te(BigInt(0),n))},nonnegative(n){return this.check(Pe(BigInt(0),n))},multipleOf(n,e){return this.check(ot(n,e))}});function sp(n){return Ic(dn,n)}var io=g("ZodBigIntFormat",(n,e)=>{ys.init(n,e),dn.init(n,e)});function cp(n){return Tc(io,n)}function up(n){return Pc(io,n)}var Yu=g("ZodSymbol",(n,e)=>{$s.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>nu(n,r,i,t)});function lp(n){return Dc(Yu,n)}var Qu=g("ZodUndefined",(n,e)=>{xs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>iu(n,r,i,t)});function dp(n){return Oc(Qu,n)}var el=g("ZodNull",(n,e)=>{bs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ru(n,r,i,t)});function tl(n){return Rc(el,n)}var nl=g("ZodAny",(n,e)=>{zs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>su(n,r,i,t)});function mp(){return jc(nl)}var rl=g("ZodUnknown",(n,e)=>{ws.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>cu(n,r,i,t)});function St(){return Uc(rl)}var il=g("ZodNever",(n,e)=>{ks.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>au(n,r,i,t)});function oo(n){return Nc(il,n)}var ol=g("ZodVoid",(n,e)=>{Is.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ou(n,r,i,t)});function fp(n){return Ac(ol,n)}var Xn=g("ZodDate",(n,e)=>{Ss.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>uu(n,i,t,o),n.min=(i,t)=>n.check(Pe(i,t)),n.max=(i,t)=>n.check(Te(i,t));let r=n._zod.bag;n.minDate=r.minimum?new Date(r.minimum):null,n.maxDate=r.maximum?new Date(r.maximum):null});function pp(n){return Ec(Xn,n)}var al=g("ZodArray",(n,e)=>{Pt(),Ts.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>xu(n,r,i,t),n.element=e.element},{min(n,e){return this.check(He(n,e))},nonempty(n){return this.check(He(1,n))},max(n,e){return this.check(kt(n,e))},length(n,e){return this.check(It(n,e))},unwrap(){return this.element}});function Yn(n,e){return Fc(al,n,e)}function hp(n){let e=n._zod.def.shape;return ao(Object.keys(e))}var Qn=g("ZodObject",(n,e)=>{Pt(),Ps.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>bu(n,r,i,t),b.installLazyProp(n,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ao(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:St()})},loose(){return this.clone({...this._zod.def,catchall:St()})},strict(){return this.clone({...this._zod.def,catchall:oo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return b.extend(this,n)},safeExtend(n){return b.safeExtend(this,n)},merge(n){return b.merge(this,n)},pick(n){return b.pick(this,n)},omit(n){return b.omit(this,n)},partial(...n){return b.partial(tr,this,n[0])},exactPartial(...n){return b.partial(co,this,n[0],"exactPartial")},required(...n){return b.required(uo,this,n[0])}});function gp(n,e){let r={type:"object",shape:n??{},...b.normalizeParams(e)};return new Qn(r)}function vp(n,e){return new Qn({type:"object",shape:n,catchall:oo(),...b.normalizeParams(e)})}function _p(n,e){return new Qn({type:"object",shape:n,catchall:St(),...b.normalizeParams(e)})}var er=g("ZodUnion",(n,e)=>{Nn.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ri(n,r,i,t),n.options=e.options});function mn(n,e){return new er({type:"union",options:n,...b.normalizeParams(e)})}var sl=g("ZodXor",(n,e)=>{er.init(n,e),Ds.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ri(n,r,i,t),n.options=e.options});function yp(n,e){return new sl({type:"union",options:n,inclusive:!1,...b.normalizeParams(e)})}var cl=g("ZodDiscriminatedUnion",(n,e)=>{er.init(n,e),Rs.init(n,e)});function $p(n,e,r){return new cl({type:"union",options:e,discriminator:n,...b.normalizeParams(r)})}var ul=g("ZodIntersection",(n,e)=>{js.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>zu(n,r,i,t)});function ll(n,e){return new ul({type:"intersection",left:n,right:e})}var dl=g("ZodTuple",(n,e)=>{Pt(),Jr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>wu(n,r,i,t)},{rest(n){return this.clone({...this._zod.def,rest:n})},partial(){let n=this._zod.def;if(n.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...n,items:n.items.map(e=>new tr({type:"optional",innerType:e}))})}});function ml(n,e,r){let i=e instanceof N,t=i?r:e,o=i?e:null;return new dl({type:"tuple",items:n,rest:o,...b.normalizeParams(t)})}var on=g("ZodRecord",(n,e)=>{Pt(),Us.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ku(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType});function fl(n,e,r){return!e||!e._zod?new on({type:"record",keyType:Gn(),valueType:n,...b.normalizeParams(e)}):new on({type:"record",keyType:n,valueType:e,...b.normalizeParams(r)})}function xp(n,e,r){return new on({type:"record",keyType:n,valueType:e,...b.normalizeParams(r),partial:!0})}function bp(n,e,r){return new on({type:"record",keyType:n,valueType:e,mode:"loose",...b.normalizeParams(r)})}var pl=g("ZodMap",(n,e)=>{Pt(),Ns.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>yu(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType,n.min=(...r)=>n.check(Je(...r)),n.nonempty=r=>n.check(Je(1,r)),n.max=(...r)=>n.check(at(...r)),n.size=(...r)=>n.check(wt(...r))});function zp(n,e,r){return new pl({type:"map",keyType:n,valueType:e,...b.normalizeParams(r)})}var hl=g("ZodSet",(n,e)=>{Pt(),As.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>$u(n,r,i,t),n.min=(...r)=>n.check(Je(...r)),n.nonempty=r=>n.check(Je(1,r)),n.max=(...r)=>n.check(at(...r)),n.size=(...r)=>n.check(wt(...r))});function wp(n,e){return new hl({type:"set",valueType:n,...b.normalizeParams(e)})}var an=g("ZodEnum",(n,e)=>{Es.init(n,e),E.init(n,e),n._zod.processJSONSchema=(i,t,o)=>lu(n,i,t,o),n.enum=e.entries,n.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));n.extract=(i,t)=>{let o={};for(let a of i)if(r.has(a))o[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new an({...e,checks:[],...b.normalizeParams(t),entries:o})},n.exclude=(i,t)=>{let o={...e.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new an({...e,checks:[],...b.normalizeParams(t),entries:o})}});function ao(n,e){let r=Array.isArray(n)?Object.fromEntries(n.map(i=>[i,i])):n;return new an({type:"enum",entries:r,...b.normalizeParams(e)})}function kp(n,e){return new an({type:"enum",entries:n,...b.normalizeParams(e)})}var gl=g("ZodLiteral",(n,e)=>{Zs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>du(n,r,i,t),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ip(n,e){return new gl({type:"literal",values:Array.isArray(n)?n:[n],...b.normalizeParams(e)})}var vl=g("ZodFile",(n,e)=>{Cs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>pu(n,r,i,t),n.min=(r,i)=>n.check(Je(r,i)),n.max=(r,i)=>n.check(at(r,i)),n.mime=(r,i)=>n.check(Ht(Array.isArray(r)?r:[r],i))});function Sp(n){return Lc(vl,n)}var _l=g("ZodTransform",(n,e)=>{Pt(),Fs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>_u(n,r,i,t),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new rt(n.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(b.issue(o,r.value,e));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=n),r.issues.push(b.issue(a))}};let t=e.transform(r.value,r);return t instanceof Promise?t.then(o=>(r.value=o,r)):(r.value=t,r)}});function so(n){return new _l({type:"transform",transform:n})}var tr=g("ZodOptional",(n,e)=>{Kr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ji(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Tt(n){return new tr({type:"optional",innerType:n})}var co=g("ZodExactOptional",(n,e)=>{Ls.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ji(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function yl(n){return new co({type:"optional",innerType:n})}var $l=g("ZodNullable",(n,e)=>{Ms.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Iu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Wn(n){return new $l({type:"nullable",innerType:n})}function Tp(n){return Tt(Wn(n))}var xl=g("ZodDefault",(n,e)=>{Vs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Pu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function bl(n,e){return new xl({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():b.shallowClone(e)}})}var zl=g("ZodPrefault",(n,e)=>{Bs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Du(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function wl(n,e){return new zl({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():b.shallowClone(e)}})}var uo=g("ZodNonOptional",(n,e)=>{Js.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Su(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function kl(n,e){return new uo({type:"nonoptional",innerType:n,...b.normalizeParams(e)})}var Il=g("ZodSuccess",(n,e)=>{Ks.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>hu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Pp(n){return new Il({type:"success",innerType:n})}var Sl=g("ZodCatch",(n,e)=>{qs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ou(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Tl(n,e){return new Sl({type:"catch",innerType:n,catchValue:typeof e=="function"?e:b.constantCatch(e)})}var Pl=g("ZodNaN",(n,e)=>{Gs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>mu(n,r,i,t)});function Dp(n){return Cc(Pl,n)}var nr=g("ZodPipe",(n,e)=>{qr.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ru(n,r,i,t),n.in=e.in,n.out=e.out});function Ci(n,e){return new nr({type:"pipe",in:n,out:e})}var rr=g("ZodCodec",(n,e)=>{nr.init(n,e),An.init(n,e)});function Op(n,e,r){return new rr({type:"pipe",in:n,out:e,transform:r.decode,reverseTransform:r.encode})}function Rp(n){let e=n._zod.def;return new rr({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var Dl=g("ZodPreprocess",(n,e)=>{nr.init(n,e),Ws.init(n,e)}),Ol=g("ZodReadonly",(n,e)=>{Hs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ju(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Rl(n){return new Ol({type:"readonly",innerType:n})}var jl=g("ZodTemplateLiteral",(n,e)=>{Xs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>fu(n,r,i,t)});function jp(n,e){return new jl({type:"template_literal",parts:n,...b.normalizeParams(e)})}var Ul=g("ZodLazy",(n,e)=>{En.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Nu(n,r,i,t),n.unwrap=()=>n._zod.def.getter()});function Nl(n){return new Ul({type:"lazy",getter:n})}var Al=g("ZodPromise",(n,e)=>{Qs.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Uu(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Up(n){return new Al({type:"promise",innerType:n})}var El=g("ZodFunction",(n,e)=>{Ys.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>vu(n,r,i,t)});function Np(n){return new El({type:"function",input:Array.isArray(n?.input)?ml(n?.input):n?.input??Yn(St()),output:n?.output??St()})}var ir=g("ZodCustom",(n,e)=>{ec.init(n,e),E.init(n,e),n._zod.processJSONSchema=(r,i,t)=>gu(n,r,i,t)});function Ap(n){let e=new W({check:"custom"});return e._zod.check=n,e}function Ep(n,e){return Mc(ir,n??(()=>!0),e)}function Zl(n,e={}){return Vc(ir,n,e)}function Cl(n,e){return Bc(n,e)}var Zp=Jc,Cp=Kc;function Fp(n,e={}){let r=new ir({type:"custom",check:"custom",fn:i=>i instanceof n,abort:!0,...b.normalizeParams(e)});return r._zod.bag.Class=n,r._zod.check=i=>{i.value instanceof n||i.issues.push({code:"invalid_type",expected:n.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Lp=(...n)=>qc({Codec:rr,Boolean:ln,String:sn},...n);function Mp(n){let e=Nl(()=>mn([Gn(n),Hu(),Xu(),tl(),Yn(e),fl(Gn(),e)]));return e}function Vp(n,e){return new Dl({type:"pipe",in:so(n),out:e})}var l$={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function d$(n){ee({customError:n})}function m$(){return ee().customError}var Fl;Fl||(Fl={});var or={};Fe(or,{ZodISODate:()=>dt,ZodISODateTime:()=>lt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,date:()=>p$,datetime:()=>f$,duration:()=>g$,time:()=>h$});function f$(n){return Mn(lt,n)}function p$(n){return Vn(dt,n)}function h$(n){return Bn(mt,n)}function g$(n){return Jn(ft,n)}var I={...fn,...Ai,iso:or},v$=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function _$(n,e){let r=n.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function Bp(n,e){return n.map((r,i)=>i<e?r:r.optional())}function y$(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function $$(n,e){if(!n.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=n.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let t=r[1]===void 0?void 0:y$(r[1]);if(!t||!e.defs[t])throw new Error(`Reference not found: ${n}`);return e.defs[t]}throw new Error(`Reference not found: ${n}`)}function x$(n,e){return I.transform(i=>i).check(i=>{let t=i.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let o of Object.getOwnPropertyNames(t)){let a=e.safeParse(o);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:o,path:[o],continue:!0})}}).pipe(n)}function Jp(n,e){if(n!==!1)return n===void 0||n===!0?I.any():we(n,e)}var b$=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Kp(n,e){if(n.not!==void 0){if(typeof n.not=="object"&&Object.keys(n.not).length===0)return I.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(n.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(n.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(n.if!==void 0||n.then!==void 0||n.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(n.dependentSchemas!==void 0||n.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(n.$ref){let t=n.$ref;if(e.refs.has(t))return e.refs.get(t);if(e.processing.has(t))return I.lazy(()=>{if(!e.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return e.refs.get(t)});e.processing.add(t);let o=$$(t,e),a=we(o,e);return e.refs.set(t,a),e.processing.delete(t),a}if(n.enum!==void 0){let t=n.enum;if(e.version==="openapi-3.0"&&n.nullable===!0&&t.length===1&&t[0]===null)return I.null();if(t.length===0)return I.never();if(t.length===1)return I.literal(t[0]);if(t.every(a=>typeof a=="string"))return I.enum(t);let o=t.map(a=>I.literal(a));return o.length<2?o[0]:I.union([o[0],o[1],...o.slice(2)])}if(n.const!==void 0)return I.literal(n.const);let r=n.type;if(Array.isArray(r)){let t=r.map(o=>{let a={...n,type:o};return Kp(a,e)});return t.length===0?I.never():t.length===1?t[0]:I.union(t)}if(!r)return I.any();let i;switch(r){case"string":{let t=I.string();if(n.format){let o=n.format;o==="email"?t=t.check(I.email()):o==="uri"||o==="uri-reference"?t=t.check(I.url()):o==="uuid"||o==="guid"?t=t.check(I.uuid()):o==="date-time"?t=t.check(I.iso.datetime({offset:!0})):o==="date"?t=t.check(I.iso.date()):o==="time"?t=t.check(I.regex(b$)):o==="duration"?t=t.check(I.iso.duration()):o==="hostname"?t=t.check(I.hostname()):o==="ipv4"?t=t.check(I.ipv4()):o==="ipv6"?t=t.check(I.ipv6()):o==="mac"?t=t.check(I.mac()):o==="cidr"?t=t.check(I.cidrv4()):o==="cidr-v6"?t=t.check(I.cidrv6()):o==="base64"?t=t.check(I.base64()):o==="base64url"?t=t.check(I.base64url()):o==="e164"?t=t.check(I.e164()):o==="credit_card"?t=t.check(I.creditCard()):o==="jwt"?t=t.check(I.jwt()):o==="emoji"?t=t.check(I.emoji()):o==="nanoid"?t=t.check(I.nanoid()):o==="cuid"?t=t.check(I.cuid()):o==="cuid2"?t=t.check(I.cuid2()):o==="ulid"?t=t.check(I.ulid()):o==="xid"?t=t.check(I.xid()):o==="ksuid"&&(t=t.check(I.ksuid()))}typeof n.minLength=="number"&&(t=t.min(n.minLength)),typeof n.maxLength=="number"&&(t=t.max(n.maxLength)),n.pattern&&(t=t.regex(new RegExp(n.pattern))),i=t;break}case"number":case"integer":{let t=r==="integer"?I.number().int():I.number();typeof n.minimum=="number"&&n.exclusiveMinimum!==!0&&(t=t.min(n.minimum)),typeof n.maximum=="number"&&n.exclusiveMaximum!==!0&&(t=t.max(n.maximum)),typeof n.exclusiveMinimum=="number"?t=t.gt(n.exclusiveMinimum):n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t=t.gt(n.minimum)),typeof n.exclusiveMaximum=="number"?t=t.lt(n.exclusiveMaximum):n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t=t.lt(n.maximum)),typeof n.multipleOf=="number"&&(t=t.multipleOf(n.multipleOf)),i=t;break}case"boolean":{i=I.boolean();break}case"null":{i=I.null();break}case"object":{let t={},o=n.properties||{},a=new Set(n.required||[]),s=typeof n.additionalProperties=="object"?we(n.additionalProperties,e):void 0;for(let[c,u]of Object.entries(o)){let l=we(u,e);Q(t,c,a.has(c)?l:l.optional())}if(n.patternProperties){let c=n.patternProperties,u=Object.keys(c),l=[];for(let m of u){let f=we(c[m],e),h=I.string().regex(new RegExp(m));l.push(I.looseRecord(h,f))}let d=[];if(Object.keys(t).length>0&&d.push(I.object(t).passthrough()),d.push(...l),d.length===0)i=I.object({}).passthrough();else if(d.length===1)i=d[0];else{let m=I.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)m=I.intersection(m,d[f]);i=m}if(n.additionalProperties===!1){let m=Object.keys(t),f=u.map(_=>new RegExp(_)),h=i;i=i.check(_=>{if(!Re(_.value))return;let z=[];for(let P of Object.keys(_.value))m.includes(P)||f.some(x=>x.test(P))||z.push(P);z.length&&_.issues.push({code:"unrecognized_keys",keys:z,input:_.value,inst:h})})}}else{let c=I.object(t);n.additionalProperties===!1?i=c.strict():s?i=c.catchall(s):i=c.passthrough()}if(n.propertyNames!==void 0&&n.propertyNames!==!0){let c=typeof n.propertyNames=="object"&&n.propertyNames.type===void 0?{type:"string",...n.propertyNames}:n.propertyNames;i=x$(i,we(c,e))}break}case"array":{let t=n.prefixItems,o=n.items;if(t&&Array.isArray(t)){let a=typeof n.minItems=="number"?n.minItems:0,s=t.map(d=>we(d,e)),c=Bp(s,a),u=Array.isArray(o)?void 0:Jp(o,e),l=I.tuple(c);i=u?l.rest(u):l,typeof n.minItems=="number"&&(i=i.check(I.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(I.maxLength(n.maxItems)))}else if(Array.isArray(o)){let a=typeof n.minItems=="number"?n.minItems:0,s=o.map(d=>we(d,e)),c=Bp(s,a),u=Jp(n.additionalItems,e),l=I.tuple(c);i=u?l.rest(u):l,typeof n.minItems=="number"&&(i=i.check(I.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(I.maxLength(n.maxItems)))}else if(o!==void 0){let a=we(o,e),s=I.array(a);typeof n.minItems=="number"&&(s=s.min(n.minItems)),typeof n.maxItems=="number"&&(s=s.max(n.maxItems)),i=s}else i=I.array(I.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function we(n,e){if(typeof n=="boolean")return n?I.any():I.never();let r=Kp(n,e),i=n.type||n.enum!==void 0||n.const!==void 0;if(n.anyOf&&Array.isArray(n.anyOf)){let s=n.anyOf.map(u=>we(u,e)),c=I.union(s);r=i?I.intersection(r,c):c}if(n.oneOf&&Array.isArray(n.oneOf)){let s=n.oneOf.map(u=>we(u,e)),c=I.xor(s);r=i?I.intersection(r,c):c}if(n.allOf&&Array.isArray(n.allOf))if(n.allOf.length===0)r=i?r:I.any();else{let s=i?r:we(n.allOf[0],e),c=i?0:1;for(let u=c;u<n.allOf.length;u++)s=I.intersection(s,we(n.allOf[u],e));r=s}n.nullable===!0&&e.version==="openapi-3.0"&&(r=I.nullable(r)),n.readOnly===!0&&(r=I.readonly(r)),n.default!==void 0&&(r=r.default(n.default));let t={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in n&&(t[s]=n[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in n&&(t[s]=n[s]);n.propertyNames!==void 0&&n.type==="object"&&n.$ref===void 0&&(t.propertyNames=n.propertyNames);for(let s of Object.keys(n))v$.has(s)||Q(t,s,n[s]);return Object.keys(t).length>0&&e.registry.add(r,t),n.description&&(r=r.describe(n.description)),r}function qp(n,e){if(typeof n=="boolean")return n?I.any():I.never();let r;try{r=JSON.parse(JSON.stringify(n))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=_$(r,e?.defaultTarget),t=r.$defs||r.definitions||{},o={version:i,defs:t,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??ae};return we(r,o)}var Gp=Symbol("z.visit/resolving");function ar(n,e){let r=typeof e=="function"?e:(a,s)=>{let c=e[a._zod.def.type];return c?c(a,s):a},i=new Map;function t(a){let s=i.get(a);if(s===Gp)return new En({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,Gp);let c=o(a),u=r(c,c!==a);return i.set(a,u),u}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),d=!1,m={};for(let h of l){let _=t(u[h]);_!==u[h]&&(d=!0),m[h]=_}let f=s.catchall;return s.catchall&&(f=t(s.catchall),f!==s.catchall&&(d=!0)),d?V(a,{...s,shape:m,catchall:f}):a}case"array":{let u=t(s.element);return u===s.element?a:V(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,d=[];for(let f of u){let h=t(f);h!==f&&(l=!0),d.push(h)}let m=s.rest;return s.rest&&(m=t(s.rest),m!==s.rest&&(l=!0)),l?V(a,{...s,items:d,rest:m}):a}case"record":case"map":{let u=t(s.keyType),l=t(s.valueType);return u===s.keyType&&l===s.valueType?a:V(a,{...s,keyType:u,valueType:l})}case"set":{let u=t(s.valueType);return u===s.valueType?a:V(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,d=[];for(let m of u){let f=t(m);f!==m&&(l=!0),d.push(f)}return l?V(a,{...s,options:d}):a}case"intersection":{let u=t(s.left),l=t(s.right);return u===s.left&&l===s.right?a:V(a,{...s,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=t(s.innerType);return u===s.innerType?a:V(a,{...s,innerType:u})}case"pipe":{let u=t(s.in),l=t(s.out);return u===s.in&&l===s.out?a:V(a,{...s,in:u,out:l})}case"function":{let u=t(s.input),l=t(s.output);return u===s.input&&l===s.output?a:V(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...d}=s;return V(a,{...d,getter:()=>t(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return t(n)}function Wp(n){return ar(n,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:mn(r.options)}})}function z$(n,e){if(!e?.length)return n;let r=n._zod.def;return V(n,Ae(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function Hp(n){return z$(n.out,n.checks)}function w$(n){return n.in._zod.traits.has("$ZodTransform")?Hp(n):n.in}function Xp(n){return ar(n,{pipe:e=>w$(e._zod.def),default:(e,r)=>r?Tt(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function Yp(n){return ar(n,{pipe:e=>Hp(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var Ll={};Fe(Ll,{bigint:()=>T$,boolean:()=>S$,date:()=>P$,number:()=>I$,string:()=>k$});function k$(n){return fc(sn,n)}function I$(n){return _c(un,n)}function S$(n){return kc(ln,n)}function T$(n){return Sc(dn,n)}function P$(n){return Zc(Xn,n)}var F={maxBatchEvents:1e3,maxProjectIdLength:128,maxSessionIdLength:128,maxSdkVersionLength:64,maxUrlLength:2048,maxTitleLength:512,maxReferrerLength:2048,maxLanguageLength:35,maxMeshNameLength:256,maxAssetNameLength:1024,maxCustomNameLength:128,maxCustomPropValueLength:1024,maxCustomPropEntries:64,maxUserIdLength:128,maxUserTraitValueLength:1024,maxUserTraitEntries:64,maxSceneDescriptionLength:256,maxCameraNameLength:128,maxSceneProxyMeshNameLength:256,maxSceneProxyMeshPathLength:512,maxSceneProxyMeshes:1e4,maxSceneRegionLabelLength:120,maxSceneRegionDescriptionLength:500,maxSceneRegions:200,maxNodeIdLength:128,maxBoneIdLength:128,maxChildPathLength:512,maxGraphicsDiagnosticMessageLength:1024,maxGraphicsDiagnosticCodeLength:64};function lo(n,e){return p.record(p.string(),n).refine(r=>Object.keys(r).length<=e,{message:`must have at most ${e} entries`})}var M=p.tuple([p.number(),p.number(),p.number()]),mo=p.tuple([p.number(),p.number(),p.number(),p.number()]),pn=p.tuple([p.number(),p.number()]),hn=p.tuple([p.number().min(0).max(1),p.number().min(0).max(1)]),fo=p.number().int().nonnegative(),po=p.string().regex(/^[A-Za-z0-9._:-]{1,64}$/,"sceneId must be 1-64 chars of [A-Za-z0-9._:-]");var D$=p.object({title:p.string().max(F.maxTitleLength).optional(),referrer:p.string().max(F.maxReferrerLength).optional(),viewport:p.tuple([p.number(),p.number()]).optional(),devicePixelRatio:p.number().positive().optional(),language:p.string().max(F.maxLanguageLength).optional()}).passthrough(),Ml={projectId:p.string().min(1).max(F.maxProjectIdLength),visitorId:p.string().optional(),sessionId:p.string().min(1).max(F.maxSessionIdLength),ts:fo,sdkVersion:p.string().min(1).max(F.maxSdkVersionLength),url:p.string().max(F.maxUrlLength).optional(),sceneId:po.optional(),pageMeta:D$.optional()},s0=p.object(Ml);function O(n,e){return p.object({type:p.literal(n),...Ml,...e})}var Vl=p.enum(["left","right"]),Bl=p.enum(["y","z"]),Qp=p.object({handedness:Vl,upAxis:Bl.default("y"),unitScale:p.number().positive().default(1)}).passthrough();var eh=p.object({engine:p.enum(["webgl2","webgpu","webgl","unknown"]).optional(),vendor:p.string().optional(),renderer:p.string().optional(),maxTextureSize:p.number().optional(),hardwareConcurrency:p.number().optional(),deviceMemoryGb:p.number().optional(),isMobile:p.boolean().optional(),browser:p.string().optional(),os:p.string().optional()}).passthrough(),th=p.enum(["arc-rotate","free","follow","static","other"]),nh=p.object({description:p.string().max(F.maxSceneDescriptionLength).optional(),cameraType:th.optional(),cameraName:p.string().max(F.maxCameraNameLength).optional(),meshCount:p.number().int().nonnegative().optional()}).passthrough(),rh=p.union([p.string().max(F.maxUserTraitValueLength),p.number(),p.boolean(),p.null()]),ih=p.object({id:p.string().max(F.maxUserIdLength).optional(),traits:lo(rh,F.maxUserTraitEntries).optional()}).passthrough(),oh=p.object({name:p.string(),version:p.string().optional(),coordinateSystem:Qp.optional()}).passthrough(),ho=p.enum(["webgl","webgl2","webgpu","opengl","opengles","d3d11","d3d12","vulkan","metal","unknown"]),ah=p.enum(["metal","d3d11","d3d12","vulkan","opengl","opengles","unknown"]),sh=p.enum(["glsl","glsl-es","wgsl","hlsl","msl","spirv","unknown"]),ch=p.object({api:ho.optional(),backend:ah.optional(),apiVersion:p.string().optional(),shadingLanguage:sh.optional()}).passthrough(),Jl=O("session_start",{device:eh.optional(),graphics:ch.optional(),scene:nh.optional(),user:ih.optional(),connector:oh.optional()});var Kl=O("session_end",{durationMs:p.number().nonnegative().optional(),reason:p.enum(["unload","hidden","manual","timeout"]).optional()});var ql=O("frame_perf",{fps:p.number().nonnegative(),frameTimeMs:p.number().nonnegative().optional(),frameTimeP95Ms:p.number().nonnegative().optional(),frameTimeP99Ms:p.number().nonnegative().optional(),longFrames:p.number().int().nonnegative().optional(),drawCalls:p.number().nonnegative().optional(),dpr:p.number().positive().optional(),renderScale:p.number().positive().optional(),position:M.optional()});var Gl=O("camera_sample",{position:M,direction:M,target:M.optional(),fov:p.number().optional(),aspect:p.number().positive().optional(),near:p.number().positive().optional(),hitPoint:M.optional(),hitMesh:p.string().optional()});var Wl=O("node_transform",{nodeId:p.string().min(1).max(F.maxNodeIdLength),boneId:p.string().min(1).max(F.maxBoneIdLength).optional(),childPath:p.string().min(1).max(F.maxChildPathLength).optional(),position:M,rotation:mo,scale:M.optional()});var uh=p.enum(["mouse","touch","stylus","pen","keyboard","gamepad","xr-controller","hand","gaze","transient","other"]),lh=p.enum(["left","right","none"]),dh=p.object({origin:M,direction:M}),se={source:uh.optional(),handedness:lh.optional(),sourceId:p.string().min(1).max(64).optional(),ray:dh.optional()};var O$={screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),...se},Hl=O("pointer_move",O$);var Xl=O("pointer_click",{screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),uv:pn.optional(),button:p.number().int().min(0).optional(),...se});var mh={screen:hn.optional(),hitPoint:M.optional(),hitMesh:p.string().optional(),button:p.number().int().min(0).optional(),...se},Yl=O("pointer_down",mh),Ql=O("pointer_up",mh);var fh=p.enum(["orbit","pan","dolly","zoom","roll","fly","navigate"]),ed=O("camera_gesture",{kind:fh,durationMs:p.number().nonnegative(),orbitDeg:p.number().nonnegative().optional(),rollDeg:p.number().nonnegative().optional(),zoomRatio:p.number().positive().optional(),panDist:p.number().nonnegative().optional(),...se});var ph=p.enum(["hover","pick","click","drag","select","squeeze","grab","release","teleport"]),td=O("mesh_interaction",{mesh:p.string().min(1).max(F.maxMeshNameLength),kind:ph,point:M.optional(),uv:pn.optional(),...se});var go=p.tuple([p.number(),p.number(),p.number(),p.number(),p.number(),p.number()]),R$=p.literal("aabb"),j$=p.object({position:M,rotation:mo,scale:M}),U$=p.object({name:p.string().max(F.maxSceneProxyMeshNameLength),aabb:go,triangles:p.number().int().nonnegative().optional(),path:p.string().min(1).max(F.maxSceneProxyMeshPathLength).optional(),world:j$.optional()}),N$=1,fk=p.object({version:p.literal(N$),sceneId:po,kind:R$,bounds:go,upAxis:Bl,handedness:Vl.optional(),unitScale:p.number().positive(),meshes:p.array(U$).max(F.maxSceneProxyMeshes),meshCount:p.number().int().nonnegative(),contentHash:p.string().min(1),capturedAt:fo,sdkVersion:p.string().min(1)});var hh=O("mesh_visibility",{mesh:p.string().min(1).max(F.maxMeshNameLength),visibleMs:p.number().nonnegative(),centeredMs:p.number().nonnegative().optional(),maxScreenFraction:p.number().min(0).max(1).optional(),bounds:go.optional()});var gh=O("hover_dwell",{mesh:p.string().min(1),dwellMs:p.number().nonnegative(),uv:pn.optional(),...se});var A$=p.enum(["shader","pipeline","material","other"]),vh=O("compile_stall",{durationMs:p.number().nonnegative(),phase:A$.optional()});var _h=O("resource_sample",{textureBytes:p.number().nonnegative().optional(),geometryBytes:p.number().nonnegative().optional(),triangles:p.number().int().nonnegative().optional(),vertices:p.number().int().nonnegative().optional(),jsHeapBytes:p.number().nonnegative().optional()});var yh=p.enum(["graphics-backend","quality","device-recovery","tracking","feature","other"]),nd=O("capability_change",{kind:yh,from:p.string().max(64).optional(),to:p.string().max(64).optional(),reason:p.string().max(120).optional(),durationMs:p.number().nonnegative().optional(),...se});var rd=O("asset_load",{name:p.string().max(F.maxAssetNameLength),bytes:p.number().nonnegative().optional(),loadMs:p.number().nonnegative(),ttffMs:p.number().nonnegative().optional(),ttiMs:p.number().nonnegative().optional()});var id=O("scene_change",{});var $h=O("viewport_resize",{width:p.number().positive(),height:p.number().positive(),dpr:p.number().positive().optional()});var E$=p.enum(["visible","hidden"]),xh=O("visibility_change",{state:E$});var bh=O("focus_change",{focused:p.boolean()});var zh=O("context_lost",{reason:p.string().max(512).optional()}),wh=O("context_restored",{});var kh=p.enum(["info","warning","error","fatal"]),Ih=p.enum(["context-loss","validation","out-of-memory","shader-compile","device-lost","fallback"]),od=O("graphics_diagnostic",{severity:kh,category:Ih,backend:ho.optional(),message:p.string().max(F.maxGraphicsDiagnosticMessageLength).optional(),code:p.string().max(F.maxGraphicsDiagnosticCodeLength).optional(),count:p.number().int().positive().optional(),position:M.optional()});var Z$=p.enum(["error","unhandledrejection"]),Sh=O("runtime_error",{kind:Z$,message:p.string().max(1024),source:p.string().max(1024).optional(),lineno:p.number().int().nonnegative().optional(),colno:p.number().int().nonnegative().optional(),stack:p.string().max(4096).optional(),position:M.optional()});var ad=O("input_action",{action:p.string().min(1).max(64),code:p.string().min(1).max(64).optional(),button:p.number().int().nonnegative().optional(),pressed:p.boolean().optional(),...se});var Th=O("xr_boundary_proximity",{position:M,durationMs:p.number().nonnegative()});var Ph=p.enum(["floor","wall","table","ceiling","unknown"]),sd=O("ar_placement",{mesh:p.string().min(1).max(F.maxMeshNameLength),position:M,surface:Ph.optional(),attempts:p.number().int().positive(),timeToPlaceMs:p.number().nonnegative(),scale:p.number().positive(),final:p.boolean()});var Dh=p.union([p.string().max(F.maxCustomPropValueLength),p.number(),p.boolean(),p.null()]),cd=O("custom",{name:p.string().min(1).max(F.maxCustomNameLength),props:lo(Dh,F.maxCustomPropEntries).optional()});var vo=p.discriminatedUnion("type",[Jl,Kl,ql,Gl,Wl,Hl,Xl,Yl,Ql,ed,td,hh,gh,vh,_h,nd,rd,id,$h,xh,bh,zh,wh,od,Sh,ad,Th,sd,cd]);var Oh=p.array(vo);async function Rh(n){let e=n.fetchImpl??fetch,r=`${n.endpoint}/api/v1/sessions/${encodeURIComponent(n.sessionId)}/events`,i=await e(r,{headers:{"x-api-key":n.apiKey}});if(!i.ok)throw new Error(`replay fetch failed: ${i.status}`);let t=Oh.safeParse(await i.json());if(!t.success)throw new Error("replay fetch returned an invalid session payload");return t.data.sort((o,a)=>o.ts-a.ts)}async function*ud(n){let e=n.fetchImpl??fetch,r=`${n.endpoint}/api/v1/sessions/${encodeURIComponent(n.sessionId)}/events`,i=await e(`${r}?format=ndjson`,{headers:{"x-api-key":n.apiKey,accept:"application/x-ndjson"}});if(!i.ok)throw new Error(`replay fetch failed: ${i.status}`);if(!(i.headers.get("content-type")??"").includes("application/x-ndjson")){let d=Oh.safeParse(await i.json());if(!d.success)throw new Error("replay fetch returned an invalid session payload");for(let m of d.data.sort((f,h)=>f.ts-h.ts))yield m;return}if(!i.body)throw new Error("replay stream returned no body");let o=0,a=()=>n.onMalformedLine?.(++o),s=i.body.getReader(),c=new TextDecoder,u="",l=function*(d){let m=d.trim();if(m.length===0)return;let f;try{f=JSON.parse(m)}catch{a();return}let h=vo.safeParse(f);h.success?yield h.data:a()};for(;;){let{done:d,value:m}=await s.read();if(d)break;u+=c.decode(m,{stream:!0});let f=u.indexOf(`
62
62
  `);for(;f>=0;){let h=u.slice(0,f);u=u.slice(f+1),yield*l(h),f=u.indexOf(`
63
63
  `)}}yield*l(u)}function C$(){let n=typeof requestAnimationFrame=="function";return{now:()=>typeof performance<"u"?performance.now():Date.now(),requestFrame:e=>n?requestAnimationFrame(e):setTimeout(e,16),cancelFrame:e=>n?cancelAnimationFrame(e):clearTimeout(e)}}var sr=class{constructor(e,r,i={},t=C$()){this.driver=r;this.options=i;this.env=t;this.events=[...e].sort((o,a)=>o.ts-a.ts),this.baseTs=this.events.length>0?this.events[0].ts:0,this.durationMs=this.events.length>0?this.events[this.events.length-1].ts-this.baseTs:0}driver;options;env;events;baseTs;durationMs;cursor=0;elapsed=0;playing=!1;completed=!1;rafId=null;startWall=0;startElapsed=0;get isPlaying(){return this.playing}rel(e){return e.ts-this.baseTs}update(e){let r=Math.max(0,e);for(r<this.elapsed&&(this.driver.reset(),this.cursor=0,this.completed=!1);this.cursor<this.events.length&&this.rel(this.events[this.cursor])<=r;)this.driver.apply(this.events[this.cursor]),this.cursor++;this.elapsed=r,this.options.onProgress?.(Math.min(r,this.durationMs),this.durationMs),!this.completed&&this.cursor>=this.events.length&&r>=this.durationMs&&(this.completed=!0,this.pause(),this.options.onComplete?.())}seek(e){this.update(e)}play(){if(this.playing||this.events.length===0)return;this.completed&&this.update(0),this.playing=!0,this.startWall=this.env.now(),this.startElapsed=this.elapsed;let e=this.options.speed??1,r=()=>{if(!this.playing)return;let i=this.env.now();this.update(this.startElapsed+(i-this.startWall)*e),this.playing&&(this.rafId=this.env.requestFrame(r))};this.rafId=this.env.requestFrame(r)}pause(){this.playing=!1,this.rafId!==null&&(this.env.cancelFrame(this.rafId),this.rafId=null)}stop(){this.pause(),this.driver.reset(),this.cursor=0,this.elapsed=0,this.completed=!1}};var pt="[UptimizrReplay]";async function F$(n){let e=n.debug??!1,r=(...c)=>{e&&console.info(pt,...c)};r(`fetching session "${n.sessionId}" from ${n.endpoint}`);let i;try{i=[];let c=0;for await(let u of ud({endpoint:n.endpoint,apiKey:n.apiKey,sessionId:n.sessionId,onMalformedLine:l=>{c=l}}))i.push(u);c>0&&console.warn(`${pt} skipped ${c} malformed event line(s) while streaming the session.`)}catch(c){throw console.error(`${pt} failed to fetch session events:`,c),c}let t=i.filter(c=>c.type==="camera_sample").length;i.length===0?console.error(`${pt} session "${n.sessionId}" returned 0 events \u2014 nothing to replay. Most likely the API key belongs to a different project than this session: copy the session id and the API key from the SAME dashboard project. Other causes: a mistyped session id, or the collector not having ENABLE_RAW_SESSION_RETENTION=true.`):t===0&&console.warn(`${pt} session has ${i.length} events but no camera_sample events, so the camera won't move. Pointer/mesh/custom callbacks will still fire.`),(n.camera??n.scene.activeCamera)||console.warn(`${pt} scene has no active camera and none was provided \u2014 camera pose won't be applied. Pass a \`camera\`, or set \`scene.activeCamera\` before replaying.`),n.backdropUrl!==void 0&&await L$(n,r);let a=xo({scene:n.scene,camera:n.camera,onPointer:n.onPointer,onMeshInteraction:n.onMeshInteraction,onCustom:n.onCustom,onLifecycle:n.onLifecycle,onError:n.onError}),s=new sr(i,a,{speed:n.speed??1,onProgress:n.onProgress,onComplete:()=>{r("playback complete"),n.onComplete?.()}});return r(`loaded ${i.length} events (${t} camera_sample), duration ${Math.round(s.durationMs)}ms \u2014 playing at ${n.speed??1}x`),s.play(),s}async function L$(n,e){let r=n.backdropUrl;if(r===void 0)return;let i=M$(n);if(!i){console.warn(`${pt} a backdrop was requested but no Babylon loader was found. Pass \`loadBackdrop\`, or expose Babylon as \`window.BABYLON\` with \`LoadAssetContainerAsync\` (and a glTF loader registered). Replaying without a backdrop.`);return}let t=typeof r=="string"?r:r.name??"dropped file";e(`loading backdrop "${t}"`);try{let o=await $d(a=>i(r,n.scene,a),{pluginExtension:n.backdropPluginExtension});return e(`backdrop loaded (${o.meshes.length} meshes)`),o}catch(o){console.warn(`${pt} failed to load backdrop "${t}":`,o);return}}function M$(n){if(n.loadBackdrop)return n.loadBackdrop;let e=globalThis.BABYLON;if(e?.LoadAssetContainerAsync){let i=e.LoadAssetContainerAsync.bind(e);return(t,o,a)=>i(t,o,a?{pluginExtension:a}:void 0)}let r=e?.SceneLoader?.LoadAssetContainerAsync;if(r){let i=r.bind(e.SceneLoader);return(t,o,a)=>i(t,"",o,null,a)}return null}return Wh(V$);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uptimizr/replay",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Framework-agnostic session-replay core + Babylon driver. Re-drives a captured session in the user's own scene.",
5
5
  "keywords": [
6
6
  "uptimizr",
@@ -78,12 +78,12 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "zod": "^4.5.4",
81
- "@uptimizr/schema": "1.0.0",
82
- "@uptimizr/sdk-core": "1.0.0"
81
+ "@uptimizr/schema": "1.1.0",
82
+ "@uptimizr/sdk-core": "1.1.0"
83
83
  },
84
84
  "devDependencies": {
85
- "@babylonjs/core": "^9.23.0",
86
- "@babylonjs/lite": "^1.25.0",
85
+ "@babylonjs/core": "^9.25.0",
86
+ "@babylonjs/lite": "^1.27.0",
87
87
  "esbuild": "^0.28.2",
88
88
  "playcanvas": "2.21.4",
89
89
  "three": "^0.185.1",
@@ -91,11 +91,11 @@
91
91
  },
92
92
  "scripts": {
93
93
  "build": "tsc -p tsconfig.json && pnpm run bundle:global",
94
- "bundle:global": "esbuild src/global.ts --bundle --format=iife --global-name=UptimizrReplay --platform=browser --target=es2022 --minify --legal-comments=none --external:@babylonjs/core/Loading/sceneLoader.js --banner:js=\"/* @uptimizr/replay standalone bundle (global) — Apache-2.0. Inject via a <script> tag into any page (e.g. playground.babylonjs.com); exposes window.UptimizrReplay. Bundles the Babylon Vector3 it constructs; the host page owns the scene (and its asset loader). */\" --outfile=dist/uptimizr-replay.global.js",
94
+ "bundle:global": "esbuild src/global.ts --bundle --format=iife --log-override:empty-import-meta=silent --global-name=UptimizrReplay --platform=browser --target=es2022 --minify --legal-comments=none --external:@babylonjs/core/Loading/sceneLoader.js --banner:js=\"/* @uptimizr/replay standalone bundle (global) — Apache-2.0. Inject via a <script> tag into any page (e.g. playground.babylonjs.com); exposes window.UptimizrReplay. Bundles the Babylon Vector3 it constructs; the host page owns the scene (and its asset loader). */\" --outfile=dist/uptimizr-replay.global.js",
95
95
  "dev": "tsc -p tsconfig.json --watch",
96
96
  "typecheck": "tsc -p tsconfig.json --noEmit",
97
97
  "test": "vitest run",
98
98
  "lint": "eslint .",
99
- "clean": "rm -rf dist"
99
+ "clean": "rimraf dist"
100
100
  }
101
101
  }