import{i as t,G as s,s as i}from"./p-96dc1249.js";import{i as h}from"./p-6e70d3cc.js";class e{constructor(t,s,i=0,h=0,e,n,r){this._startOffset=0,this._endOffset=0,this._startContainer=t,this._endContainer=s,this._startOffset=i,this._endOffset=h,this._startNode=e,this._endNode=n,r&&(this._oldNativeRange=r)}get startContainer(){return this._startContainer}get endContainer(){return this._endContainer}get startNode(){return this._startNode}get endNode(){return this._endNode}get startOffset(){return this._startOffset}get endOffset(){return this._endOffset}updateRTERange(s,i){const{startOffset:h,endOffset:n}=s;this._startOffset=h,this._endOffset=n;const r=s.startNode,o=s.endNode;if(r instanceof t){this._startNode=r,this._endNode=o;const t=this._startNode.getRangeContainer(),s=this._startNode===this._endNode?t:this._endNode.getRangeContainer();t&&(this._startContainer=t,this._endContainer=s)}else this._startContainer=r,this._endContainer=o,this._startNode=this.getRTENodeByElement(this._startContainer),this._endNode=this._startContainer===this._endContainer?this._startNode:this.getRTENodeByElement(this._endContainer),i&&(this._oldNativeRange=i);return new e(this._startContainer,this._endContainer,this._startOffset,this._endOffset,this._startNode,this._endNode,this._oldNativeRange)}clone(){return new e(this._startContainer,this._endContainer,this._startOffset,this._endOffset,this._startNode,this._endNode,this._oldNativeRange)}toNativeRange(){let t=null;if(this._startNode){const s=this._startNode.getRangeContainer(),i=this._startNode===this._endNode?s:this._endNode.getRangeContainer();if(s&&i)return t=new Range,t.setStart(s,this._startOffset),t.setEnd(i,this._endOffset),this._startContainer=s,this._endContainer=i,this._oldNativeRange=t,t}if(!t&&this._oldNativeRange)return this._oldNativeRange}getRTENodeByElement(t){if(t){const e=t.nodeType===Node.TEXT_NODE?t.parentElement:h(t)&&s.isDecoratorNodeContainerElement(t)?s.getDecoratorNodeElement(t):t;return i.getEntityByDOM(e)}}}export{e as R}