/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{m as t}from"./p-Tvs4yxd5.js";class s{constructor(s){this.stream=s;this.isTransforming=false;this.currentDelta=t.makeIdentity()}async dispose(){if(this.isTransforming){this.endTransform()}}async beginTransform(s=t.makeIdentity()){this.clearEndInteractionTimeout();if(!this.isTransforming){this.currentDelta=s;this.isTransforming=true;console.debug("Beginning transform interaction");await this.stream.beginInteraction({transform:{delta:this.toDeltaTransform(s)}})}}async updateTransform(t){this.currentDelta=t;await this.stream.updateInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta,true)}})}async updateTranslation(s){this.currentDelta=t.makeTranslation(s);await this.stream.updateInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta)}})}getCurrentDelta(){return this.currentDelta}async endTransform(){if(this.isTransforming){await this.endInteraction()}}async endTransformDebounced(t,s){if(this.isTransforming){this.restartEndInteractionTimeout(t,s)}}clearTransform(){this.currentDelta=t.makeIdentity();this.previousDelta=undefined;this.endTransform()}async EXPERIMENTAL_undoTransform(){if(this.previousDelta!=null){const s=t.invert(this.previousDelta);console.debug(`Undo of previous transform [delta-applied=${s}]`);await this.beginTransform();await this.updateTransform(t.invert(this.previousDelta));await this.endTransform();this.previousDelta=undefined;return s}else{console.debug("No previous transform to undo.")}}async endInteraction(){console.debug(`Ending transform interaction [delta=${this.currentDelta}]`);this.clearEndInteractionTimeout();this.previousDelta=this.currentDelta;await this.stream.endInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta)}});this.isTransforming=false;this.currentDelta=t.makeIdentity()}restartEndInteractionTimeout(t,s){this.clearEndInteractionTimeout();this.endDebounceTimeout=setTimeout((async()=>{t===null||t===void 0?void 0:t();await this.endInteraction();s===null||s===void 0?void 0:s()}),500)}clearEndInteractionTimeout(){if(this.endDebounceTimeout!=null){clearTimeout(this.endDebounceTimeout);this.endDebounceTimeout=undefined}}toDeltaTransform(s,i=false){const a=t.toObject(s);const n=i?{x:a.m11,y:a.m21,z:a.m31}:{x:a.m11,y:a.m12,z:a.m13};const e=i?{x:a.m12,y:a.m22,z:a.m32}:{x:a.m21,y:a.m22,z:a.m23};const o=i?{x:a.m13,y:a.m23,z:a.m33}:{x:a.m31,y:a.m32,z:a.m33};return{basisX:n,basisY:e,basisZ:o,xlate:{x:a.m14,y:a.m24,z:a.m34},scale:a.m44}}}export{s as T};
//# sourceMappingURL=p-B6pxBmYG.js.map