export function parseDn(seq: string): Map<string, string> {let quoted = falselet key: string | null = nulllet token = ""let nextNonSpace = 0seq = seq.trim()const result = new Map<string, string>()for (let i = 0; i <= seq.length; i++) {if (i === seq.length) {if (key !== null) {result.set(key, token)}break}const ch = seq[i]if (quoted) {if (ch === '"') {quoted = falsecontinue}} else {if (ch === '"') {quoted = truecontinue}if (ch === "\\") {i++const ord = parseInt(seq.slice(i, i + 2), 16)if (Number.isNaN(ord)) {token += seq[i]} else {i++token += String.fromCharCode(ord)}continue}if (key === null && ch === "=") {key = tokentoken = ""continue}if (ch === "," || ch === ";" || ch === "+") {if (key !== null) {result.set(key, token)}key = nulltoken = ""continue}}if (ch === " " && !quoted) {if (token.length === 0) {continue}if (i > nextNonSpace) {let j = iwhile (seq[j] === " ") {j++}nextNonSpace = j}if (nextNonSpace >= seq.length ||seq[nextNonSpace] === "," ||seq[nextNonSpace] === ";" ||(key === null && seq[nextNonSpace] === "=") ||(key !== null && seq[nextNonSpace] === "+")) {i = nextNonSpace - 1continue}}token += ch}return result}