import { checkQuote } from "../util/check-quote.js";
image.peek = imagePeek;
function image(t, n, r, i) {
	let a = checkQuote(r), o = a === "\"" ? "Quote" : "Apostrophe", s = r.enter("image"), c = r.enter("label"), l = r.createTracker(i), u = l.move("![");
	return u += l.move(r.safe(t.alt, {
		before: u,
		after: "]",
		...l.current()
	})), u += l.move("]("), c(), !t.url && t.title || /[\0- \u007F]/.test(t.url) ? (c = r.enter("destinationLiteral"), u += l.move("<"), u += l.move(r.safe(t.url, {
		before: u,
		after: ">",
		...l.current()
	})), u += l.move(">")) : (c = r.enter("destinationRaw"), u += l.move(r.safe(t.url, {
		before: u,
		after: t.title ? " " : ")",
		...l.current()
	}))), c(), t.title && (c = r.enter(`title${o}`), u += l.move(" " + a), u += l.move(r.safe(t.title, {
		before: u,
		after: a,
		...l.current()
	})), u += l.move(a), c()), u += l.move(")"), s(), u;
}
function imagePeek() {
	return "!";
}
export { image };
