import { NEXT, PREV, VALUE } from "../shared/symbols.js";
import { $String } from "../shared/utils.js";
import { characterDataAsJSON } from "../shared/jsdon.js";
import { moCallback } from "./mutation-observer.js";
import { Node } from "./node.js";
import { isConnected, nextSibling, parentElement, previousSibling } from "../shared/node.js";
import { nextElementSibling, previousElementSibling } from "../mixin/non-document-type-child-node.js";
import { after, before, remove, replaceWith } from "../mixin/child-node.js";
//#region node_modules/linkedom/esm/interface/character-data.js
/**
* @implements globalThis.CharacterData
*/
var CharacterData = class extends Node {
	constructor(ownerDocument, localName, nodeType, data) {
		super(ownerDocument, localName, nodeType);
		this[VALUE] = $String(data);
	}
	get isConnected() {
		return isConnected(this);
	}
	get parentElement() {
		return parentElement(this);
	}
	get previousSibling() {
		return previousSibling(this);
	}
	get nextSibling() {
		return nextSibling(this);
	}
	get previousElementSibling() {
		return previousElementSibling(this);
	}
	get nextElementSibling() {
		return nextElementSibling(this);
	}
	before(...nodes) {
		before(this, nodes);
	}
	after(...nodes) {
		after(this, nodes);
	}
	replaceWith(...nodes) {
		replaceWith(this, nodes);
	}
	remove() {
		remove(this[PREV], this, this[NEXT]);
	}
	/* c8 ignore start */
	get data() {
		return this[VALUE];
	}
	set data(value) {
		this[VALUE] = $String(value);
		moCallback(this, this.parentNode);
	}
	get nodeValue() {
		return this.data;
	}
	set nodeValue(value) {
		this.data = value;
	}
	get textContent() {
		return this.data;
	}
	set textContent(value) {
		this.data = value;
	}
	get length() {
		return this.data.length;
	}
	substringData(offset, count) {
		return this.data.substr(offset, count);
	}
	appendData(data) {
		this.data += data;
	}
	insertData(offset, data) {
		const { data: t } = this;
		this.data = t.slice(0, offset) + data + t.slice(offset);
	}
	deleteData(offset, count) {
		const { data: t } = this;
		this.data = t.slice(0, offset) + t.slice(offset + count);
	}
	replaceData(offset, count, data) {
		const { data: t } = this;
		this.data = t.slice(0, offset) + data + t.slice(offset + count);
	}
	/* c8 ignore stop */
	toJSON() {
		const json = [];
		characterDataAsJSON(this, json);
		return json;
	}
};
//#endregion
export { CharacterData };
