UNPKG

fumadocs-core

Version:

The React.js library for building a documentation website

2,749 lines • 52.3 kB
import { NextResponse } from "next/server";
// ../../node_modules/.pnpm/@formatjs+fast-memoize@3.1.7/node_modules/@formatjs/fast-memoize/index.js
function memoize(fn, options) {
	const cache = options && options.cache ? options.cache : cacheDefault;
	const serializer = options && options.serializer ? options.serializer : serializerDefault;
	return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
		cache,
		serializer
	});
}
function isPrimitive(value) {
	return value == null || typeof value === "number" || typeof value === "boolean";
}
function monadic(fn, cache, serializer, arg) {
	const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
	let computedValue = cache.get(cacheKey);
	if (typeof computedValue === "undefined") {
		computedValue = fn.call(this, arg);
		cache.set(cacheKey, computedValue);
	}
	return computedValue;
}
function variadic(fn, cache, serializer) {
	const args = Array.prototype.slice.call(arguments, 3);
	const cacheKey = serializer(args);
	let computedValue = cache.get(cacheKey);
	if (typeof computedValue === "undefined") {
		computedValue = fn.apply(this, args);
		cache.set(cacheKey, computedValue);
	}
	return computedValue;
}
function assemble(fn, context, strategy, cache, serialize) {
	return strategy.bind(context, fn, cache, serialize);
}
function strategyDefault(fn, options) {
	const strategy = fn.length === 1 ? monadic : variadic;
	return assemble(fn, this, strategy, options.cache.create(), options.serializer);
}
const serializerDefault = function() {
	return JSON.stringify(arguments);
};
var ObjectWithoutPrototypeCache = class {
	constructor() {
		this.cache = Object.create(null);
	}
	get(key) {
		return this.cache[key];
	}
	set(key, value) {
		this.cache[key] = value;
	}
};
const cacheDefault = { create: function create() {
	return new ObjectWithoutPrototypeCache();
} };
// ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.10.1/node_modules/@formatjs/intl-localematcher/index.js
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList(locales) {
	return Intl.getCanonicalLocales(locales);
}
const matchingData = {
	"language": {
		"nb|no": 1,
		"no|nb": 1,
		"hr|bs": 4,
		"bs|hr": 4,
		"sh|bs": 4,
		"bs|sh": 4,
		"sh|hr": 4,
		"hr|sh": 4,
		"sh|sr": 4,
		"sr|sh": 4,
		"ssy|aa": 4,
		"aa|ssy": 4,
		"gsw|de": 4,
		"lb|de": 4,
		"da|no": 8,
		"no|da": 8,
		"da|nb": 8,
		"nb|da": 8,
		"ab|ru": 30,
		"ach|en": 30,
		"af|en": 20,
		"ak|en": 30,
		"am|en": 30,
		"ay|es": 20,
		"az|ru": 30,
		"bal|ur": 20,
		"be|ru": 20,
		"bem|en": 30,
		"bh|hi": 30,
		"bn|en": 30,
		"bo|zh": 20,
		"br|fr": 20,
		"ca|es": 20,
		"ceb|fil": 30,
		"chr|en": 20,
		"ckb|ar": 30,
		"co|fr": 20,
		"crs|fr": 20,
		"cs|sk": 20,
		"sk|cs": 20,
		"cy|en": 20,
		"ee|en": 30,
		"eo|en": 30,
		"eu|es": 20,
		"fo|da": 20,
		"fy|nl": 20,
		"ga|en": 20,
		"gaa|en": 30,
		"gd|en": 20,
		"gl|es": 20,
		"gn|es": 20,
		"gu|hi": 30,
		"ha|en": 30,
		"haw|en": 20,
		"ht|fr": 20,
		"hy|ru": 30,
		"ia|en": 30,
		"ig|en": 30,
		"is|en": 20,
		"jv|id": 20,
		"ka|en": 30,
		"kg|fr": 30,
		"kk|ru": 30,
		"km|en": 30,
		"kn|en": 30,
		"kri|en": 30,
		"ku|tr": 30,
		"ky|ru": 30,
		"la|it": 20,
		"lg|en": 30,
		"ln|fr": 30,
		"lo|en": 30,
		"loz|en": 30,
		"lua|fr": 30,
		"mai|hi": 20,
		"mfe|en": 30,
		"mg|fr": 30,
		"mi|en": 20,
		"ml|en": 30,
		"mn|ru": 30,
		"mr|hi": 30,
		"ms|id": 30,
		"mt|en": 30,
		"my|en": 30,
		"ne|en": 30,
		"nn|nb": 20,
		"nb|nn": 20,
		"nn|no": 20,
		"no|nn": 20,
		"nso|en": 30,
		"ny|en": 30,
		"nyn|en": 30,
		"oc|fr": 20,
		"om|en": 30,
		"or|en": 30,
		"pa|en": 30,
		"pcm|en": 20,
		"ps|en": 30,
		"qu|es": 30,
		"rm|de": 20,
		"rn|rw": 10,
		"rw|rn": 10,
		"rn|fr": 30,
		"rn|en": 35,
		"rw|en": 30,
		"rw|fr": 35,
		"sa|hi": 30,
		"scn|it": 20,
		"sd|en": 30,
		"si|en": 30,
		"sn|en": 30,
		"so|en": 30,
		"sq|en": 30,
		"st|en": 30,
		"su|id": 20,
		"sw|en": 30,
		"ta|en": 30,
		"te|en": 30,
		"tg|ru": 30,
		"ti|en": 30,
		"tk|ru": 30,
		"tlh|en": 30,
		"tn|en": 30,
		"to|en": 30,
		"tt|ru": 30,
		"tum|en": 30,
		"ug|zh": 20,
		"ur|en": 30,
		"uz|ru": 30,
		"wo|fr": 30,
		"xh|en": 30,
		"yi|en": 30,
		"yo|en": 30,
		"za|zh": 20,
		"zu|en": 30,
		"aao|ar": 10,
		"abh|ar": 10,
		"abv|ar": 10,
		"acm|ar": 10,
		"acq|ar": 10,
		"acw|ar": 10,
		"acx|ar": 10,
		"acy|ar": 10,
		"adf|ar": 10,
		"aeb|ar": 10,
		"aec|ar": 10,
		"afb|ar": 10,
		"apc|ar": 10,
		"apd|ar": 10,
		"arq|ar": 10,
		"ars|ar": 10,
		"ary|ar": 10,
		"arz|ar": 10,
		"auz|ar": 10,
		"avl|ar": 10,
		"ayh|ar": 10,
		"ayl|ar": 10,
		"ayn|ar": 10,
		"ayp|ar": 10,
		"bbz|ar": 10,
		"pga|ar": 10,
		"shu|ar": 10,
		"ssh|ar": 10,
		"azb|az": 10,
		"vro|et": 10,
		"ffm|ff": 10,
		"fub|ff": 10,
		"fue|ff": 10,
		"fuf|ff": 10,
		"fuh|ff": 10,
		"fui|ff": 10,
		"fuq|ff": 10,
		"fuv|ff": 10,
		"gnw|gn": 10,
		"gui|gn": 10,
		"gun|gn": 10,
		"nhd|gn": 10,
		"ikt|iu": 10,
		"enb|kln": 10,
		"eyo|kln": 10,
		"niq|kln": 10,
		"oki|kln": 10,
		"pko|kln": 10,
		"sgc|kln": 10,
		"tec|kln": 10,
		"tuy|kln": 10,
		"knn|kok": 10,
		"gkp|kpe": 10,
		"ida|luy": 10,
		"lkb|luy": 10,
		"lko|luy": 10,
		"lks|luy": 10,
		"lri|luy": 10,
		"lrm|luy": 10,
		"lsm|luy": 10,
		"lto|luy": 10,
		"lts|luy": 10,
		"lwg|luy": 10,
		"nle|luy": 10,
		"nyd|luy": 10,
		"rag|luy": 10,
		"ltg|lv": 10,
		"bhr|mg": 10,
		"bjq|mg": 10,
		"bmm|mg": 10,
		"bzc|mg": 10,
		"msh|mg": 10,
		"skg|mg": 10,
		"tdx|mg": 10,
		"tkg|mg": 10,
		"txy|mg": 10,
		"xmv|mg": 10,
		"xmw|mg": 10,
		"mvf|mn": 10,
		"bjn|ms": 10,
		"btj|ms": 10,
		"bve|ms": 10,
		"bvu|ms": 10,
		"coa|ms": 10,
		"dup|ms": 10,
		"hji|ms": 10,
		"id|ms": 10,
		"jak|ms": 10,
		"jax|ms": 10,
		"kvb|ms": 10,
		"kvr|ms": 10,
		"kxd|ms": 10,
		"lce|ms": 10,
		"lcf|ms": 10,
		"liw|ms": 10,
		"max|ms": 10,
		"meo|ms": 10,
		"mfa|ms": 10,
		"mfb|ms": 10,
		"min|ms": 10,
		"mqg|ms": 10,
		"msi|ms": 10,
		"mui|ms": 10,
		"orn|ms": 10,
		"ors|ms": 10,
		"pel|ms": 10,
		"pse|ms": 10,
		"tmw|ms": 10,
		"urk|ms": 10,
		"vkk|ms": 10,
		"vkt|ms": 10,
		"xmm|ms": 10,
		"zlm|ms": 10,
		"zmi|ms": 10,
		"dty|ne": 10,
		"gax|om": 10,
		"hae|om": 10,
		"orc|om": 10,
		"spv|or": 10,
		"pbt|ps": 10,
		"pst|ps": 10,
		"qub|qu": 10,
		"qud|qu": 10,
		"quf|qu": 10,
		"qug|qu": 10,
		"quh|qu": 10,
		"quk|qu": 10,
		"qul|qu": 10,
		"qup|qu": 10,
		"qur|qu": 10,
		"qus|qu": 10,
		"quw|qu": 10,
		"qux|qu": 10,
		"quy|qu": 10,
		"qva|qu": 10,
		"qvc|qu": 10,
		"qve|qu": 10,
		"qvh|qu": 10,
		"qvi|qu": 10,
		"qvj|qu": 10,
		"qvl|qu": 10,
		"qvm|qu": 10,
		"qvn|qu": 10,
		"qvo|qu": 10,
		"qvp|qu": 10,
		"qvs|qu": 10,
		"qvw|qu": 10,
		"qvz|qu": 10,
		"qwa|qu": 10,
		"qwc|qu": 10,
		"qwh|qu": 10,
		"qws|qu": 10,
		"qxa|qu": 10,
		"qxc|qu": 10,
		"qxh|qu": 10,
		"qxl|qu": 10,
		"qxn|qu": 10,
		"qxo|qu": 10,
		"qxp|qu": 10,
		"qxr|qu": 10,
		"qxt|qu": 10,
		"qxu|qu": 10,
		"qxw|qu": 10,
		"sdc|sc": 10,
		"sdn|sc": 10,
		"sro|sc": 10,
		"aae|sq": 10,
		"aat|sq": 10,
		"aln|sq": 10,
		"aii|syr": 10,
		"uzs|uz": 10,
		"yih|yi": 10,
		"cdo|zh": 10,
		"cjy|zh": 10,
		"cnp|zh": 10,
		"cpx|zh": 10,
		"csp|zh": 10,
		"czh|zh": 10,
		"czo|zh": 10,
		"gan|zh": 10,
		"hak|zh": 10,
		"hnm|zh": 10,
		"hsn|zh": 10,
		"luh|zh": 10,
		"lzh|zh": 10,
		"mnp|zh": 10,
		"nan|zh": 10,
		"sjc|zh": 10,
		"wuu|zh": 10,
		"yue|zh": 10
	},
	"script": {
		"am|en|Ethi|Latn": 10,
		"az|ru|Latn|Cyrl": 10,
		"bn|en|Beng|Latn": 10,
		"bo|zh|Tibt|Hans": 10,
		"hy|ru|Armn|Cyrl": 10,
		"ka|en|Geor|Latn": 10,
		"km|en|Khmr|Latn": 10,
		"kn|en|Knda|Latn": 10,
		"lo|en|Laoo|Latn": 10,
		"ml|en|Mlym|Latn": 10,
		"my|en|Mymr|Latn": 10,
		"ne|en|Deva|Latn": 10,
		"or|en|Orya|Latn": 10,
		"pa|en|Guru|Latn": 10,
		"ps|en|Arab|Latn": 10,
		"sd|en|Arab|Latn": 10,
		"si|en|Sinh|Latn": 10,
		"ta|en|Taml|Latn": 10,
		"te|en|Telu|Latn": 10,
		"ti|en|Ethi|Latn": 10,
		"tk|ru|Latn|Cyrl": 10,
		"ur|en|Arab|Latn": 10,
		"uz|ru|Latn|Cyrl": 10,
		"yi|en|Hebr|Latn": 10,
		"sr|sr|Latn|Cyrl": 5,
		"sr|sr|Cyrl|Latn": 5,
		"za|zh|Latn|Hans": 10,
		"zh|zh|Hani|Hans": 20,
		"zh|zh|Hani|Hant": 20,
		"ar|ar|Latn|Arab": 20,
		"bn|bn|Latn|Beng": 20,
		"gu|gu|Latn|Gujr": 20,
		"hi|hi|Latn|Deva": 20,
		"kn|kn|Latn|Knda": 20,
		"ml|ml|Latn|Mlym": 20,
		"mr|mr|Latn|Deva": 20,
		"ta|ta|Latn|Taml": 20,
		"te|te|Latn|Telu": 20,
		"zh|zh|Latn|Hans": 20,
		"ja|ja|Latn|Jpan": 5,
		"ja|ja|Hani|Jpan": 5,
		"ja|ja|Hira|Jpan": 5,
		"ja|ja|Kana|Jpan": 5,
		"ja|ja|Hrkt|Jpan": 5,
		"ja|ja|Hira|Hrkt": 5,
		"ja|ja|Kana|Hrkt": 5,
		"ko|ko|Hani|Kore": 5,
		"ko|ko|Hang|Kore": 5,
		"ko|ko|Jamo|Kore": 5,
		"ko|ko|Jamo|Hang": 5
	},
	"region": {
		"ar|ar|*|*": [
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			5,
			5,
			5,
			5,
			4,
			5,
			5,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4
		],
		"en|en|*|*": [
			4,
			4,
			5,
			5,
			4,
			3,
			4,
			4,
			4,
			5,
			5,
			4,
			3,
			4,
			5,
			5,
			4,
			4,
			5,
			5,
			5,
			5,
			5,
			4,
			4,
			5,
			5,
			5,
			4,
			4,
			5,
			5,
			4,
			3,
			4,
			3,
			3,
			5,
			5,
			3,
			3,
			3,
			4,
			4,
			5,
			5,
			4,
			3,
			4
		],
		"es|es|*|*": [
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			5,
			5,
			5,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			5,
			5,
			5,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			4,
			4
		],
		"pt|pt|*|*": [
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			5,
			5,
			5,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			5,
			5,
			5,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			4,
			4,
			4,
			5,
			4,
			5,
			4,
			4,
			4
		],
		"zh|zh|Hant|Hant": [
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			5,
			5,
			5,
			5,
			5,
			5,
			5,
			4
		]
	},
	"regions": {
		"142": [
			0,
			2,
			6
		],
		"143": [0],
		"145": [0],
		"150": [0, 5],
		"151": [0],
		"154": [0, 5],
		"155": [0],
		"202": [0, 4],
		"419": [1, 3],
		"001": [
			0,
			1,
			2,
			3,
			4,
			5,
			6
		],
		"002": [0, 4],
		"003": [1, 3],
		"005": [1],
		"009": [0, 2],
		"011": [0, 4],
		"013": [1],
		"014": [0],
		"015": [0, 4],
		"017": [0],
		"018": [0],
		"019": [1, 3],
		"021": [1, 3],
		"029": [1, 3],
		"030": [0, 6],
		"034": [0],
		"035": [0, 2],
		"039": [0],
		"053": [0],
		"054": [0],
		"057": [0, 2],
		"061": [0, 2],
		"AC": [0],
		"AD": [0],
		"AE": [0],
		"AF": [0],
		"AG": [1],
		"AI": [1],
		"AL": [0],
		"AM": [0],
		"AO": [0],
		"AQ": [0],
		"AR": [1],
		"AS": [2],
		"AT": [0],
		"AU": [0],
		"AW": [1],
		"AX": [0],
		"AZ": [0],
		"BA": [0],
		"BB": [1],
		"BD": [0],
		"BE": [0],
		"BF": [0],
		"BG": [0],
		"BH": [0],
		"BI": [0],
		"BJ": [0],
		"BL": [1],
		"BM": [1],
		"BN": [0],
		"BO": [1],
		"BQ": [1],
		"BR": [1],
		"BS": [1],
		"BT": [0],
		"BV": [1],
		"BW": [0],
		"BY": [0],
		"BZ": [1],
		"CA": [3],
		"CC": [0],
		"CD": [0],
		"CF": [0],
		"CG": [0],
		"CH": [0],
		"CI": [0],
		"CK": [0],
		"CL": [1],
		"CM": [0],
		"CN": [0],
		"CO": [1],
		"CP": [0],
		"CQ": [0],
		"CR": [1],
		"CU": [1],
		"CV": [0],
		"CW": [1],
		"CX": [0],
		"CY": [0],
		"CZ": [0],
		"DE": [0],
		"DG": [0],
		"DJ": [0],
		"DK": [0],
		"DM": [1],
		"DO": [1],
		"DZ": [4],
		"EA": [0],
		"EC": [1],
		"EE": [0],
		"EG": [0],
		"EH": [4],
		"ER": [0],
		"ES": [0],
		"ET": [0],
		"EU": [0],
		"EZ": [0],
		"FI": [0],
		"FJ": [0],
		"FK": [1],
		"FM": [0],
		"FO": [0],
		"FR": [0],
		"GA": [0],
		"GB": [5],
		"GD": [1],
		"GE": [0],
		"GF": [1],
		"GG": [0],
		"GH": [0],
		"GI": [0],
		"GL": [1],
		"GM": [0],
		"GN": [0],
		"GP": [1],
		"GQ": [0],
		"GR": [0],
		"GS": [1],
		"GT": [1],
		"GU": [2],
		"GW": [0],
		"GY": [1],
		"HK": [6],
		"HM": [0],
		"HN": [1],
		"HR": [0],
		"HT": [1],
		"HU": [0],
		"IC": [0],
		"ID": [0],
		"IE": [0],
		"IL": [0],
		"IM": [0],
		"IN": [0],
		"IO": [0],
		"IQ": [0],
		"IR": [0],
		"IS": [0],
		"IT": [0],
		"JE": [0],
		"JM": [1],
		"JO": [0],
		"JP": [0],
		"KE": [0],
		"KG": [0],
		"KH": [0],
		"KI": [0],
		"KM": [0],
		"KN": [1],
		"KP": [0],
		"KR": [0],
		"KW": [0],
		"KY": [1],
		"KZ": [0],
		"LA": [0],
		"LB": [0],
		"LC": [1],
		"LI": [0],
		"LK": [0],
		"LR": [0],
		"LS": [0],
		"LT": [0],
		"LU": [0],
		"LV": [0],
		"LY": [4],
		"MA": [4],
		"MC": [0],
		"MD": [0],
		"ME": [0],
		"MF": [1],
		"MG": [0],
		"MH": [2],
		"MK": [0],
		"ML": [0],
		"MM": [0],
		"MN": [0],
		"MO": [6],
		"MP": [2],
		"MQ": [1],
		"MR": [4],
		"MS": [1],
		"MT": [0],
		"MU": [0],
		"MV": [0],
		"MW": [0],
		"MX": [1],
		"MY": [0],
		"MZ": [0],
		"NA": [0],
		"NC": [0],
		"NE": [0],
		"NF": [0],
		"NG": [0],
		"NI": [1],
		"NL": [0],
		"NO": [0],
		"NP": [0],
		"NR": [0],
		"NU": [0],
		"NZ": [0],
		"OM": [0],
		"PA": [1],
		"PE": [1],
		"PF": [0],
		"PG": [0],
		"PH": [2],
		"PK": [0],
		"PL": [0],
		"PM": [1],
		"PN": [0],
		"PR": [3],
		"PS": [0],
		"PT": [0],
		"PW": [0],
		"PY": [1],
		"QA": [0],
		"QO": [0],
		"RE": [0],
		"RO": [0],
		"RS": [0],
		"RU": [0],
		"RW": [0],
		"SA": [0],
		"SB": [0],
		"SC": [0],
		"SD": [0],
		"SE": [0],
		"SG": [0],
		"SH": [0],
		"SI": [0],
		"SJ": [0],
		"SK": [0],
		"SL": [0],
		"SM": [0],
		"SN": [0],
		"SO": [0],
		"SR": [1],
		"SS": [0],
		"ST": [0],
		"SV": [1],
		"SX": [1],
		"SY": [0],
		"SZ": [0],
		"TA": [0],
		"TC": [1],
		"TD": [0],
		"TF": [0],
		"TG": [0],
		"TH": [0],
		"TJ": [0],
		"TK": [0],
		"TL": [0],
		"TM": [0],
		"TN": [4],
		"TO": [0],
		"TR": [0],
		"TT": [1],
		"TV": [0],
		"TW": [0],
		"TZ": [0],
		"UA": [0],
		"UG": [0],
		"UM": [2],
		"UN": [
			0,
			1,
			2,
			3,
			4,
			5
		],
		"US": [3],
		"UY": [1],
		"UZ": [0],
		"VA": [0],
		"VC": [1],
		"VE": [1],
		"VG": [1],
		"VI": [3],
		"VN": [0],
		"VU": [0],
		"WF": [0],
		"WS": [0],
		"XK": [0],
		"YE": [0],
		"YT": [0],
		"ZA": [0],
		"ZM": [0],
		"ZW": [0]
	},
	"defaults": [
		80,
		50,
		4
	],
	"partitionCount": 7,
	"paradigms": [
		"en",
		"en-GB",
		"es",
		"es-419",
		"pt-BR",
		"pt-PT"
	],
	"cldrVersion": "49",
	"macroRegions": ["419"],
	"canonicalAliases": {
		"language": [
			"aam",
			"aar",
			"abk",
			"adp",
			"afr",
			"agp",
			"ais",
			"ajp",
			"ajt",
			"aju",
			"aka",
			"alb",
			"als",
			"amh",
			"ara",
			"arb",
			"arg",
			"arm",
			"asd",
			"asm",
			"aue",
			"ava",
			"ave",
			"aym",
			"ayr",
			"ayx",
			"aze",
			"azj",
			"bak",
			"bam",
			"baq",
			"baz",
			"bcc",
			"bcl",
			"bel",
			"ben",
			"bgm",
			"bh",
			"bhk",
			"bic",
			"bih",
			"bis",
			"bjd",
			"bjq",
			"bkb",
			"blg",
			"bod",
			"bos",
			"bre",
			"btb",
			"bul",
			"bur",
			"bxk",
			"bxr",
			"cat",
			"ccq",
			"ces",
			"cha",
			"che",
			"chi",
			"chu",
			"chv",
			"cjr",
			"cka",
			"cld",
			"cls",
			"cmk",
			"cmn",
			"cnr",
			"cor",
			"cos",
			"coy",
			"cqu",
			"cre",
			"cwd",
			"cym",
			"cze",
			"daf",
			"dan",
			"dap",
			"dek",
			"deu",
			"dgo",
			"dhd",
			"dik",
			"diq",
			"dit",
			"div",
			"djl",
			"dkl",
			"drh",
			"drr",
			"drw",
			"dud",
			"duj",
			"dut",
			"dwl",
			"dzo",
			"ekk",
			"ell",
			"elp",
			"emk",
			"eng",
			"epo",
			"esk",
			"est",
			"eus",
			"ewe",
			"fao",
			"fas",
			"fij",
			"fin",
			"fra",
			"fre",
			"fry",
			"fuc",
			"ful",
			"gav",
			"gaz",
			"gbc",
			"gbo",
			"geo",
			"ger",
			"gfx",
			"ggn",
			"ggo",
			"ggr",
			"gio",
			"gla",
			"gle",
			"glg",
			"gli",
			"glv",
			"gno",
			"gom",
			"gre",
			"grn",
			"gti",
			"gug",
			"guj",
			"guv",
			"gya",
			"hat",
			"hau",
			"hbs",
			"hdn",
			"hea",
			"heb",
			"her",
			"him",
			"hin",
			"hmo",
			"hrr",
			"hrv",
			"hun",
			"hye",
			"ibi",
			"ibo",
			"ice",
			"ido",
			"iii",
			"ike",
			"iku",
			"ile",
			"ill",
			"ilw",
			"in",
			"ina",
			"ind",
			"ipk",
			"isl",
			"ita",
			"iw",
			"izi",
			"jar",
			"jav",
			"jeg",
			"ji",
			"jpn",
			"jw",
			"kal",
			"kan",
			"kas",
			"kat",
			"kau",
			"kaz",
			"kdv",
			"kgc",
			"kgd",
			"kgh",
			"kgm",
			"khk",
			"khm",
			"kik",
			"kin",
			"kir",
			"kmr",
			"knc",
			"kng",
			"koj",
			"kom",
			"kon",
			"kor",
			"kpp",
			"kpv",
			"krm",
			"ktr",
			"kua",
			"kur",
			"kvs",
			"kwq",
			"kxe",
			"kxl",
			"kzh",
			"kzj",
			"kzt",
			"lak",
			"lao",
			"lat",
			"lav",
			"lbk",
			"leg",
			"lii",
			"lim",
			"lin",
			"lit",
			"llo",
			"lmm",
			"ltz",
			"lub",
			"lug",
			"lvs",
			"mac",
			"mah",
			"mal",
			"mao",
			"mar",
			"may",
			"meg",
			"mgx",
			"mhr",
			"mkd",
			"mlg",
			"mlt",
			"mnt",
			"mo",
			"mof",
			"mol",
			"mon",
			"mrd",
			"mri",
			"msa",
			"mst",
			"mup",
			"mwd",
			"mwj",
			"mya",
			"myd",
			"myt",
			"nad",
			"nau",
			"nav",
			"nbf",
			"nbl",
			"nbx",
			"ncp",
			"nde",
			"ndo",
			"nep",
			"nld",
			"nln",
			"nlr",
			"nno",
			"nns",
			"nnx",
			"nob",
			"nom",
			"noo",
			"nor",
			"npi",
			"nte",
			"nts",
			"nxu",
			"nya",
			"oci",
			"ojg",
			"oji",
			"ori",
			"orm",
			"ory",
			"oss",
			"oun",
			"pan",
			"pat",
			"pbu",
			"pcr",
			"per",
			"pes",
			"pli",
			"plt",
			"pmc",
			"pmk",
			"pmu",
			"pnb",
			"pol",
			"por",
			"ppa",
			"ppr",
			"prp",
			"prs",
			"pry",
			"pus",
			"puz",
			"que",
			"quz",
			"rmr",
			"rmy",
			"roh",
			"ron",
			"rum",
			"run",
			"rus",
			"sag",
			"san",
			"sap",
			"sca",
			"scc",
			"scr",
			"sgl",
			"sgn",
			"sh",
			"shl",
			"sin",
			"skk",
			"slk",
			"slo",
			"slv",
			"smd",
			"sme",
			"smo",
			"sna",
			"snb",
			"snd",
			"som",
			"sot",
			"spa",
			"spy",
			"sqi",
			"src",
			"srd",
			"srp",
			"ssw",
			"sul",
			"sum",
			"sun",
			"swa",
			"swc",
			"swe",
			"swh",
			"szd",
			"tah",
			"tam",
			"tat",
			"tdu",
			"tel",
			"tgg",
			"tgk",
			"tgl",
			"tha",
			"thc",
			"thw",
			"thx",
			"tib",
			"tid",
			"tie",
			"tir",
			"tkk",
			"tl",
			"tlw",
			"tmk",
			"tmp",
			"tne",
			"tnf",
			"ton",
			"tpw",
			"tsf",
			"tsn",
			"tso",
			"ttq",
			"tuk",
			"tur",
			"tw",
			"twi",
			"uig",
			"ukr",
			"umu",
			"unp",
			"uok",
			"urd",
			"uzb",
			"uzn",
			"ven",
			"vie",
			"vol",
			"wel",
			"wgw",
			"wit",
			"wiw",
			"wln",
			"wol",
			"xba",
			"xho",
			"xia",
			"xkh",
			"xpe",
			"xrq",
			"xsj",
			"xsl",
			"xss",
			"ybd",
			"ydd",
			"yen",
			"yid",
			"yiy",
			"yma",
			"ymt",
			"yol",
			"yor",
			"yos",
			"yuu",
			"zai",
			"zha",
			"zho",
			"zir",
			"zkb",
			"zsm",
			"zul",
			"zyb"
		],
		"script": ["Qaai"],
		"region": [
			"004",
			"008",
			"010",
			"012",
			"016",
			"020",
			"024",
			"028",
			"031",
			"032",
			"036",
			"040",
			"044",
			"048",
			"050",
			"051",
			"052",
			"056",
			"060",
			"062",
			"064",
			"068",
			"070",
			"072",
			"074",
			"076",
			"084",
			"086",
			"090",
			"092",
			"096",
			"100",
			"104",
			"108",
			"112",
			"116",
			"120",
			"124",
			"132",
			"136",
			"140",
			"144",
			"148",
			"152",
			"156",
			"158",
			"162",
			"166",
			"170",
			"172",
			"174",
			"175",
			"178",
			"180",
			"184",
			"188",
			"191",
			"192",
			"196",
			"200",
			"203",
			"204",
			"208",
			"212",
			"214",
			"218",
			"222",
			"226",
			"230",
			"231",
			"232",
			"233",
			"234",
			"238",
			"239",
			"242",
			"246",
			"248",
			"249",
			"250",
			"254",
			"258",
			"260",
			"262",
			"266",
			"268",
			"270",
			"275",
			"276",
			"278",
			"280",
			"288",
			"292",
			"296",
			"300",
			"304",
			"308",
			"312",
			"316",
			"320",
			"324",
			"328",
			"332",
			"334",
			"336",
			"340",
			"344",
			"348",
			"352",
			"356",
			"360",
			"364",
			"368",
			"372",
			"376",
			"380",
			"384",
			"388",
			"392",
			"398",
			"400",
			"404",
			"408",
			"410",
			"414",
			"417",
			"418",
			"422",
			"426",
			"428",
			"430",
			"434",
			"438",
			"440",
			"442",
			"446",
			"450",
			"454",
			"458",
			"462",
			"466",
			"470",
			"474",
			"478",
			"480",
			"484",
			"492",
			"496",
			"498",
			"499",
			"500",
			"504",
			"508",
			"512",
			"516",
			"520",
			"524",
			"528",
			"530",
			"531",
			"532",
			"533",
			"534",
			"535",
			"536",
			"540",
			"548",
			"554",
			"558",
			"562",
			"566",
			"570",
			"574",
			"578",
			"580",
			"581",
			"582",
			"583",
			"584",
			"585",
			"586",
			"591",
			"598",
			"600",
			"604",
			"608",
			"612",
			"616",
			"620",
			"624",
			"626",
			"630",
			"634",
			"638",
			"642",
			"643",
			"646",
			"652",
			"654",
			"659",
			"660",
			"662",
			"663",
			"666",
			"670",
			"674",
			"678",
			"682",
			"686",
			"688",
			"690",
			"694",
			"702",
			"703",
			"704",
			"705",
			"706",
			"710",
			"716",
			"720",
			"724",
			"728",
			"729",
			"732",
			"736",
			"740",
			"744",
			"748",
			"752",
			"756",
			"760",
			"762",
			"764",
			"768",
			"772",
			"776",
			"780",
			"784",
			"788",
			"792",
			"795",
			"796",
			"798",
			"800",
			"804",
			"807",
			"810",
			"818",
			"826",
			"830",
			"831",
			"832",
			"833",
			"834",
			"840",
			"850",
			"854",
			"858",
			"860",
			"862",
			"876",
			"882",
			"886",
			"887",
			"890",
			"891",
			"894",
			"958",
			"959",
			"960",
			"962",
			"963",
			"964",
			"965",
			"966",
			"967",
			"968",
			"969",
			"970",
			"971",
			"972",
			"973",
			"974",
			"975",
			"976",
			"977",
			"978",
			"979",
			"980",
			"981",
			"982",
			"983",
			"984",
			"985",
			"986",
			"987",
			"988",
			"989",
			"990",
			"991",
			"992",
			"993",
			"994",
			"995",
			"996",
			"997",
			"998",
			"999",
			"AN",
			"BU",
			"CS",
			"CT",
			"DD",
			"DY",
			"FQ",
			"FX",
			"HV",
			"JT",
			"MI",
			"NH",
			"NQ",
			"NT",
			"PC",
			"PU",
			"PZ",
			"QU",
			"RH",
			"SU",
			"TP",
			"UK",
			"VD",
			"WK",
			"YD",
			"YU",
			"ZR"
		]
	},
	"minLsrDistance": 1,
	"demotion": 5
};
function splitUnicodeExtension(locale) {
	const subtags = locale.split("-");
	for (let i = 1; i < subtags.length; i++) {
		if (subtags[i] === "x") break;
		if (subtags[i] !== "u") continue;
		let end = i + 1;
		while (end < subtags.length && subtags[end].length > 1) end++;
		return {
			locale: [...subtags.slice(0, i), ...subtags.slice(end)].join("-"),
			extension: "-" + subtags.slice(i, end).join("-")
		};
	}
	return { locale };
}
/**
* Asserts that a condition is true, throwing an error if it is not.
* Used for runtime validation and type narrowing.
*
* @param condition - The condition to check
* @param message - Error message if condition is false
* @param Err - Error constructor to use (defaults to Error)
* @throws {Error} When condition is false
*
* @example
* ```ts
* invariant(locale !== undefined, 'Locale must be defined')
* // locale is now narrowed to non-undefined type
* ```
*/
function invariant(condition, message, Err = Error) {
	if (!condition) throw new Err(message);
}
const DEFAULT_MATCHING_THRESHOLD = matchingData.defaults[1];
const DISTANCE_SCALE = 8;
const MIN_LSR_DISTANCE = matchingData.minLsrDistance;
const languageAliases = new Set(matchingData.canonicalAliases.language);
const scriptAliases = new Set(matchingData.canonicalAliases.script);
const regionAliases = new Set(matchingData.canonicalAliases.region);
function ascii(value, start, end, min, max) {
	for (let i = start; i < end; i++) {
		const code = value.charCodeAt(i);
		if (code < min || code > max) return false;
	}
	return true;
}
function languageSubtag(value) {
	return value.length >= 2 && value.length <= 8 && value.length !== 4 && ascii(value, 0, value.length, 97, 122);
}
function scriptSubtag(value) {
	return value.length === 4 && ascii(value, 0, 1, 65, 90) && ascii(value, 1, 4, 97, 122);
}
function regionSubtag(value) {
	return value.length === 2 && ascii(value, 0, 2, 65, 90) || value.length === 3 && ascii(value, 0, 3, 48, 57);
}
function pseudoRegion(value) {
	return value === "XA" || value === "XB" || value === "XC";
}
function prefix(tag) {
	let end = tag.indexOf("-");
	if (end < 0) end = tag.length;
	const language = tag.slice(0, end);
	let script = "";
	let region = "";
	if (end < tag.length) {
		let next = tag.indexOf("-", end + 1);
		if (next < 0) next = tag.length;
		let part = tag.slice(end + 1, next);
		if (scriptSubtag(part)) {
			script = part;
			end = next;
			next = tag.indexOf("-", end + 1);
			if (next < 0) next = tag.length;
			part = tag.slice(end + 1, next);
		}
		if (regionSubtag(part)) {
			region = part;
			end = next;
		}
	}
	return {
		language,
		script,
		region,
		end
	};
}
function fields(tag) {
	const parsed = prefix(tag);
	const language = parsed.language;
	let { script, region } = parsed;
	const parts = parsed.end < tag.length ? tag.slice(parsed.end + 1).split("-") : [];
	const extension = parts.findIndex((part) => part.length === 1);
	const pseudo = (extension < 0 ? parts : parts.slice(0, extension)).find((p) => p === "psaccent" || p === "psbidi" || p === "pscrack");
	if (!pseudo && !pseudoRegion(region)) {
		if (script === "Zzzz") script = "";
		if (region === "ZZ") region = "";
	}
	const flags = (language !== "und" ? 4 : 0) | (script && script !== "Zzzz" ? 2 : 0) | (region && region !== "ZZ" ? 1 : 0);
	return {
		language,
		script,
		region,
		flags,
		pseudo,
		key: tag === "und" || tag.startsWith("und-x-") ? tag : `${language}|${script}|${region}|${flags}|${pseudo || ""}`
	};
}
const stringKey = (value) => value;
const canonicalize = memoize((tag) => {
	const basic = prefix(tag);
	if (basic.end === tag.length && languageSubtag(basic.language) && !languageAliases.has(basic.language) && !scriptAliases.has(basic.script) && !regionAliases.has(basic.region)) return tag;
	return Intl.getCanonicalLocales(tag)[0];
}, { serializer: stringKey });
const maximal = memoize((tag) => {
	const input = fields(tag);
	if (tag === "und" || tag.startsWith("und-x-")) return {
		...input,
		language: tag,
		script: "",
		region: "",
		flags: 7,
		key: tag
	};
	const pseudo = pseudoRegion(input.region) ? input.region : input.pseudo === "psaccent" ? "XA" : input.pseudo === "psbidi" ? "XB" : input.pseudo === "pscrack" ? "XC" : void 0;
	if (pseudo) {
		const language = `${pseudo}:${input.language}`;
		const script = `${pseudo}:${input.script}`;
		const region = input.region || pseudo;
		const flags = input.region ? 7 : 6;
		return {
			...input,
			language,
			script,
			region,
			flags,
			key: `${language}|${script}|${region}|${flags}`
		};
	}
	const locale = new Intl.Locale(tag).maximize();
	let flags = input.flags;
	if (matchingData.macroRegions.includes(input.region)) {
		const regionLocale = new Intl.Locale(`und-${input.region}`).maximize();
		if (input.language === "und" && (!input.script || input.script === regionLocale.script) || !input.script && !new Intl.Locale(input.language).maximize().script) flags &= -2;
	}
	let language = locale.language;
	let script = locale.script || "";
	let region = locale.region || "";
	if (language === "und" || !script || !region) {
		const fallback = new Intl.Locale([
			"und",
			script,
			region
		].filter(Boolean).join("-")).maximize();
		if (language === "und") language = fallback.language === "und" ? "en" : fallback.language;
		script ||= fallback.script || "Latn";
		region ||= fallback.region || "US";
	}
	return {
		language,
		script,
		region,
		flags,
		key: `${language}|${script}|${region}|${flags}`
	};
}, { serializer: stringKey });
function rawKey(tag) {
	if (tag === "und") return "@und";
	if (tag.startsWith("und-x-")) return tag;
	const parsed = prefix(tag);
	const base = tag.slice(0, parsed.end);
	if (pseudoRegion(parsed.region)) return base;
	if (tag.includes("-ps")) {
		const input = fields(tag);
		if (input.pseudo) return input.key;
	}
	if (parsed.script !== "Zzzz" && parsed.region !== "ZZ") return base;
	return [
		parsed.language,
		parsed.script === "Zzzz" ? "" : parsed.script,
		parsed.region === "ZZ" ? "" : parsed.region
	].filter(Boolean).join("-");
}
function distance(desired, supported) {
	const languages = `${desired.language}|${supported.language}`;
	let result = desired.language === supported.language ? 0 : matchingData.language[languages] ?? matchingData.defaults[0];
	if (desired.script !== supported.script) result += matchingData.script[`${languages}|${desired.script}|${supported.script}`] ?? matchingData.defaults[1];
	if (desired.region !== supported.region) {
		const matrix = matchingData.region[`${languages}|${desired.script}|${supported.script}`] ?? matchingData.region[`${languages}|*|*`];
		const desiredPartitions = matchingData.regions[desired.region];
		const supportedPartitions = matchingData.regions[supported.region];
		let regionDistance = matchingData.defaults[2];
		if (matrix && desiredPartitions && supportedPartitions) {
			regionDistance = 0;
			for (const d of desiredPartitions) for (const s of supportedPartitions) regionDistance = Math.max(regionDistance, matrix[d * matchingData.partitionCount + s]);
		}
		result += regionDistance;
	}
	return result === 0 ? (desired.flags ^ supported.flags) / DISTANCE_SCALE : result;
}
/** ICU language/script/region distance, including fractional explicit-subtag ties. */
const findMatchingDistance = memoize((desired, supported) => distance(maximal(canonicalize(desired)), maximal(canonicalize(supported))), { serializer: (args) => `${args[0]}|${args[1]}` });
const supportedCache = /* @__PURE__ */ new WeakMap();
const immutableLocaleLists = /* @__PURE__ */ new WeakSet();
let paradigms;
function createLocaleListSnapshot(locales) {
	const snapshot = Object.freeze(Array.from(locales));
	immutableLocaleLists.add(snapshot);
	return snapshot;
}
function equivalentKey(lsr) {
	return `${lsr.language}|${lsr.script}|${lsr.region}`;
}
function prepare(locales) {
	const immutable = immutableLocaleLists.has(locales);
	let result = supportedCache.get(locales);
	if (result && !immutable && (result.original.length !== locales.length || result.original.some((tag, index) => tag !== locales[index]))) result = void 0;
	if (!result) {
		result = {
			original: immutable ? locales : Array.from(locales),
			tags: [],
			raw: /* @__PURE__ */ new Map(),
			orders: /* @__PURE__ */ new Map(),
			best: /* @__PURE__ */ new Map()
		};
		supportedCache.set(locales, result);
	}
	return result;
}
function rawMatch(data, key) {
	const cached = data.raw.get(key);
	if (cached !== void 0) return cached;
	for (let index = data.tags.length; index < data.original.length; index++) {
		const tag = canonicalize(data.original[index]);
		Object.defineProperty(data.tags, index, {
			value: tag,
			writable: true,
			enumerable: true,
			configurable: true
		});
		const candidate = rawKey(tag);
		if (!data.raw.has(candidate)) data.raw.set(candidate, index);
		if (candidate === key) return data.raw.get(candidate);
	}
}
function order(data, defaultLocale) {
	let result = data.orders.get(defaultLocale);
	if (!result) {
		if (!data.maximal) {
			data.maximal = data.tags.map(maximal);
			data.exact = /* @__PURE__ */ new Map();
			data.maximal.forEach((lsr, index) => {
				if (!data.exact.has(lsr.key)) data.exact.set(lsr.key, index);
			});
		}
		paradigms ??= new Set(matchingData.paradigms.map((tag) => equivalentKey(maximal(canonicalize(tag)))));
		const defaultKey = defaultLocale ? equivalentKey(maximal(canonicalize(defaultLocale))) : "";
		const rank = (index) => {
			const key = equivalentKey(data.maximal[index]);
			return key === defaultKey ? 0 : paradigms.has(key) ? 1 : 2;
		};
		result = data.tags.map((_, i) => i).sort((a, b) => rank(a) - rank(b));
		data.orders.set(defaultLocale, result);
	}
	return result;
}
function moreLikely(candidate, previous) {
	if (candidate.language !== previous.language) return false;
	if (!languageSubtag(candidate.language)) return false;
	const likely = maximal(candidate.language);
	return candidate.script !== previous.script ? candidate.script === likely.script : candidate.region !== previous.region && candidate.region === likely.region;
}
function equivalentMatch(desired, data) {
	let best;
	for (let flags = 0; flags < 8; flags++) {
		const key = [
			flags & 4 ? desired.language : "und",
			flags & 2 ? desired.script : "",
			flags & 1 ? desired.region : ""
		].filter(Boolean).join("-");
		const index = data.raw.get(key);
		if (index === void 0) continue;
		const supported = maximal(data.tags[index]);
		if (equivalentKey(desired) !== equivalentKey(supported)) continue;
		const d = distance(desired, supported);
		if (d < Math.min(1, MIN_LSR_DISTANCE) && (!best || d < best.distance || d === best.distance && index < best.index)) best = {
			index,
			distance: d
		};
	}
	return best;
}
/** Cached exact LSR lookup, then ICU distance matching. Threshold is exclusive. */
function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_MATCHING_THRESHOLD, defaultLocale = supportedLocales[0] || "", collectDistances = true) {
	const result = { distances: {} };
	if (!supportedLocales.length || !requestedLocales.length || threshold <= 0) return result;
	const data = prepare(supportedLocales);
	const demotion = matchingData.demotion;
	let bestDistance = threshold;
	for (let i = 0; i < requestedLocales.length && bestDistance > 0; i++) {
		const desiredTag = requestedLocales[i];
		const canonical = canonicalize(desiredTag);
		const exactRaw = rawMatch(data, rawKey(canonical));
		if (exactRaw !== void 0) {
			result.matchedDesiredLocale = desiredTag;
			result.matchedSupportedLocale = supportedLocales[exactRaw];
			if (collectDistances) result.distances[desiredTag] = { [supportedLocales[exactRaw]]: i * demotion };
			return result;
		}
		const desired = maximal(canonical);
		const cacheKey = `${canonical}|${defaultLocale}`;
		if (!collectDistances) {
			const equivalent = data.best.get(cacheKey) || equivalentMatch(desired, data);
			if (equivalent && equivalent.distance < Math.min(1, MIN_LSR_DISTANCE)) {
				data.best.set(cacheKey, equivalent);
				if (equivalent.distance < bestDistance) {
					bestDistance = equivalent.distance;
					result.matchedDesiredLocale = desiredTag;
					result.matchedSupportedLocale = supportedLocales[equivalent.index];
				}
				bestDistance -= demotion;
				continue;
			}
		}
		const indexes = order(data, defaultLocale);
		const exact = data.exact.get(desired.key);
		if (exact !== void 0) {
			result.matchedDesiredLocale = desiredTag;
			result.matchedSupportedLocale = supportedLocales[exact];
			if (collectDistances) result.distances[desiredTag] = { [supportedLocales[exact]]: i * demotion };
			return result;
		}
		let best = collectDistances ? void 0 : data.best.get(cacheKey);
		if (!best) {
			best = {
				index: -1,
				distance: Infinity
			};
			const distances = {};
			for (const index of indexes) {
				const d = collectDistances ? findMatchingDistance(desiredTag, supportedLocales[index]) : distance(desired, data.maximal[index]);
				if (collectDistances) distances[supportedLocales[index]] = d + i * demotion;
				if (d < best.distance || d === best.distance && d >= 1 && best.index >= 0 && moreLikely(data.maximal[index], data.maximal[best.index])) best = {
					index,
					distance: d
				};
			}
			if (collectDistances) result.distances[desiredTag] = distances;
			else {
				if (data.best.size >= 256) data.best.clear();
				data.best.set(cacheKey, best);
			}
		}
		if (best.distance < bestDistance) {
			bestDistance = best.distance;
			result.matchedDesiredLocale = desiredTag;
			result.matchedSupportedLocale = supportedLocales[best.index];
		}
		bestDistance -= demotion;
	}
	return result;
}
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
	let foundLocale;
	let extension;
	const noExtensionLocaleMap = Object.create(null);
	const noExtensionLocales = requestedLocales.map((l) => {
		const { locale: noExtensionLocale } = splitUnicodeExtension(l);
		noExtensionLocaleMap[noExtensionLocale] ??= l;
		return noExtensionLocale;
	});
	const defaultLocale = getDefaultLocale();
	const result = findBestMatch(noExtensionLocales, availableLocales, void 0, defaultLocale, false);
	if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
		foundLocale = result.matchedSupportedLocale;
		extension = splitUnicodeExtension(noExtensionLocaleMap[result.matchedDesiredLocale]).extension;
	}
	if (!foundLocale) return { locale: defaultLocale };
	return {
		locale: foundLocale,
		extension
	};
}
const subdivisionAlias = {
	"cn11": "cnbj",
	"cn12": "cntj",
	"cn13": "cnhe",
	"cn14": "cnsx",
	"cn15": "cnmn",
	"cn21": "cnln",
	"cn22": "cnjl",
	"cn23": "cnhl",
	"cn31": "cnsh",
	"cn32": "cnjs",
	"cn33": "cnzj",
	"cn34": "cnah",
	"cn35": "cnfj",
	"cn36": "cnjx",
	"cn37": "cnsd",
	"cn41": "cnha",
	"cn42": "cnhb",
	"cn43": "cnhn",
	"cn44": "cngd",
	"cn45": "cngx",
	"cn46": "cnhi",
	"cn50": "cncq",
	"cn51": "cnsc",
	"cn52": "cngz",
	"cn53": "cnyn",
	"cn54": "cnxz",
	"cn61": "cnsn",
	"cn62": "cngs",
	"cn63": "cnqh",
	"cn64": "cnnx",
	"cn65": "cnxj",
	"cn71": "twzzzz",
	"cn91": "hkzzzz",
	"cn92": "mozzzz",
	"cz10a": "cz110",
	"cz10b": "cz111",
	"cz10c": "cz112",
	"cz10d": "cz113",
	"cz10e": "cz114",
	"cz10f": "cz115",
	"cz611": "cz663",
	"cz612": "cz632",
	"cz613": "cz633",
	"cz614": "cz634",
	"cz615": "cz635",
	"cz621": "cz641",
	"cz622": "cz642",
	"cz623": "cz643",
	"cz624": "cz644",
	"cz626": "cz646",
	"cz627": "cz647",
	"czjc": "cz31",
	"czjm": "cz64",
	"czka": "cz41",
	"czkr": "cz52",
	"czli": "cz51",
	"czmo": "cz80",
	"czol": "cz71",
	"czpa": "cz53",
	"czpl": "cz32",
	"czpr": "cz10",
	"czst": "cz20",
	"czus": "cz42",
	"czvy": "cz63",
	"czzl": "cz72",
	"fi01": "axzzzz",
	"fra": "frges",
	"frb": "frnaq",
	"frbl": "blzzzz",
	"frc": "frara",
	"frcp": "cpzzzz",
	"frd": "frbfc",
	"fre": "frbre",
	"frf": "frcvl",
	"frg": "frges",
	"frgf": "gfzzzz",
	"frgp": "gpzzzz",
	"frgua": "gpzzzz",
	"frh": "frcor",
	"fri": "frbfc",
	"frj": "fridf",
	"frk": "frocc",
	"frl": "frnaq",
	"frlre": "rezzzz",
	"frm": "frges",
	"frmay": "ytzzzz",
	"frmf": "mfzzzz",
	"frmq": "mqzzzz",
	"frn": "frocc",
	"frnc": "nczzzz",
	"fro": "frhdf",
	"frp": "frnor",
	"frpf": "pfzzzz",
	"frpm": "pmzzzz",
	"frq": "frnor",
	"frr": "frpdl",
	"frre": "rezzzz",
	"frs": "frhdf",
	"frt": "frnaq",
	"frtf": "tfzzzz",
	"fru": "frpac",
	"frv": "frara",
	"frwf": "wfzzzz",
	"fryt": "ytzzzz",
	"laxn": "laxs",
	"lud": "lucl",
	"lug": "luec",
	"lul": "luca",
	"mrnkc": "mr13",
	"nlaw": "awzzzz",
	"nlcw": "cwzzzz",
	"nlsx": "sxzzzz",
	"no23": "no50",
	"nzn": "nzauk",
	"nzs": "nzcan",
	"omba": "ombj",
	"omsh": "omsj",
	"plds": "pl02",
	"plkp": "pl04",
	"pllb": "pl08",
	"plld": "pl10",
	"pllu": "pl06",
	"plma": "pl12",
	"plmz": "pl14",
	"plop": "pl16",
	"plpd": "pl20",
	"plpk": "pl18",
	"plpm": "pl22",
	"plsk": "pl26",
	"plsl": "pl24",
	"plwn": "pl28",
	"plwp": "pl30",
	"plzp": "pl32",
	"shta": "tazzzz",
	"tteto": "tttob",
	"ttrcm": "ttmrc",
	"ttwto": "tttob",
	"twkhq": "twkhh",
	"twtnq": "twtnn",
	"twtpq": "twnwt",
	"twtxq": "twtxg",
	"usas": "aszzzz",
	"usgu": "guzzzz",
	"usmp": "mpzzzz",
	"uspr": "przzzz",
	"usum": "umzzzz",
	"usvi": "vizzzz"
};
const extensionAlias = {
	"t": {
		"d0": { "name": "charname" },
		"m0": {
			"beta-metsehaf": "betamets",
			"ies-jes": "iesjes",
			"names": "prprname",
			"tekie-alibekit": "tekieali"
		}
	},
	"u": {
		"ca": {
			"ethiopic-amete-alem": "ethioaa",
			"islamicc": "islamic-civil"
		},
		"kb": { "yes": "true" },
		"kc": { "yes": "true" },
		"kh": { "yes": "true" },
		"kk": { "yes": "true" },
		"kn": { "yes": "true" },
		"ks": {
			"primary": "level1",
			"tertiary": "level3"
		},
		"ms": { "imperial": "uksystem" },
		"tz": {
			"aqams": "aqmcm",
			"aukns": "auhba",
			"caffs": "cawnp",
			"camtr": "cator",
			"canpg": "cator",
			"capnt": "caiql",
			"cathu": "cator",
			"cayzf": "caedm",
			"cet": "bebru",
			"cnckg": "cnsha",
			"cnhrb": "cnsha",
			"cnkhg": "cnurc",
			"cuba": "cuhav",
			"eet": "grath",
			"egypt": "egcai",
			"eire": "iedub",
			"est": "papty",
			"factory": "unk",
			"gaza": "gazastrp",
			"gmt0": "gmt",
			"hongkong": "hkhkg",
			"hst": "ushnl",
			"iceland": "isrey",
			"iran": "irthr",
			"israel": "jeruslm",
			"jamaica": "jmkin",
			"japan": "jptyo",
			"libya": "lytip",
			"met": "bebru",
			"mncoq": "mnuln",
			"mst": "usphx",
			"mxstis": "mxtij",
			"navajo": "usden",
			"poland": "plwaw",
			"portugal": "ptlis",
			"prc": "cnsha",
			"roc": "twtpe",
			"rok": "krsel",
			"turkey": "trist",
			"uaozh": "uaiev",
			"uauzh": "uaiev",
			"uct": "utc",
			"umjon": "ushnl",
			"usnavajo": "usden",
			"wet": "ptlis",
			"zulu": "utc"
		}
	}
};
function CanonicalizeUValue(ukey, uvalue) {
	invariant(ukey !== void 0, `ukey must be defined`);
	let canonicalized = "";
	for (let i = 0; i < uvalue.length; i++) {
		const code = uvalue.charCodeAt(i);
		canonicalized += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : uvalue[i];
	}
	const aliases = Object.prototype.hasOwnProperty.call(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
	if (aliases && Object.prototype.hasOwnProperty.call(aliases, canonicalized)) canonicalized = aliases[canonicalized];
	if ((ukey === "rg" || ukey === "sd") && Object.prototype.hasOwnProperty.call(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
	return canonicalized === "true" ? "" : canonicalized;
}
function CanonicalizeUnicodeLocaleId(locale) {
	return Intl.getCanonicalLocales(locale)[0];
}
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
	invariant(splitUnicodeExtension(locale).extension === void 0, "Expected locale to not have a Unicode locale extension");
	let extension = "-u";
	for (const attr of attributes) extension += `-${attr}`;
	for (const kw of keywords) {
		const { key, value } = kw;
		extension += `-${key}`;
		if (value !== "") extension += `-${value}`;
	}
	if (extension === "-u") return CanonicalizeUnicodeLocaleId(locale);
	let privateIndex = locale.indexOf("-x-");
	let newLocale;
	if (privateIndex === -1) newLocale = locale + extension;
	else {
		let preExtension = locale.slice(0, privateIndex);
		let postExtension = locale.slice(privateIndex);
		newLocale = preExtension + extension + postExtension;
	}
	return CanonicalizeUnicodeLocaleId(newLocale);
}
const availableLocalesSetCache = /* @__PURE__ */ new WeakMap();
/**
* https://tc39.es/ecma402/#sec-bestavailablelocale
* @param availableLocales
* @param locale
*/
function BestAvailableLocale(availableLocales, locale) {
	let availableSet = availableLocalesSetCache.get(availableLocales);
	if (!availableSet) {
		availableSet = new Set(availableLocales);
		availableLocalesSetCache.set(availableLocales, availableSet);
	}
	let candidate = locale;
	while (true) {
		if (availableSet.has(candidate)) return candidate;
		let pos = candidate.lastIndexOf("-");
		if (!~pos) return;
		if (pos >= 2 && candidate[pos - 2] === "-") pos -= 2;
		candidate = candidate.slice(0, pos);
	}
}
/**
* https://tc39.es/ecma402/#sec-lookupmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
	const result = { locale: "" };
	for (const locale of requestedLocales) {
		const { locale: noExtensionLocale, extension } = splitUnicodeExtension(locale);
		const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
		if (availableLocale) {
			result.locale = availableLocale;
			if (extension) result.extension = extension;
			return result;
		}
	}
	result.locale = getDefaultLocale();
	return result;
}
function UnicodeExtensionComponents(extension) {
	invariant(extension === extension.toLowerCase(), "Expected extension to be lowercase");
	invariant(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
	const attributes = [];
	const keywords = [];
	let keyword;
	let size = extension.length;
	let k = 3;
	while (k < size) {
		let e = extension.indexOf("-", k);
		let len;
		if (e === -1) len = size - k;
		else len = e - k;
		let subtag = extension.slice(k, k + len);
		invariant(len >= 2, "Expected a subtag to have at least 2 characters");
		if (keyword === void 0 && len != 2) {
			if (attributes.indexOf(subtag) === -1) attributes.push(subtag);
		} else if (len === 2) {
			keyword = {
				key: subtag,
				value: ""
			};
			if (keywords.find((k) => k.key === keyword?.key) === void 0) keywords.push(keyword);
		} else if (keyword?.value === "") keyword.value = subtag;
		else {
			invariant(keyword !== void 0, "Expected keyword to be defined");
			keyword.value += "-" + subtag;
		}
		k += len + 1;
	}
	return {
		attributes,
		keywords
	};
}
const availableLocaleArrays = /* @__PURE__ */ new WeakMap();
function localeArray(locales, bestFit) {
	if (Array.isArray(locales)) return locales;
	const available = locales;
	let cached = availableLocaleArrays.get(available);
	if (cached?.original.length !== available.size) cached = void 0;
	if (cached) {
		const original = cached.original;
		let index = 0;
		for (const locale of available) if (original[index++] !== locale) {
			cached = void 0;
			break;
		}
	}
	if (!cached) {
		cached = {
			original: Array.from(available),
			snapshot: void 0
		};
		availableLocaleArrays.set(available, cached);
	}
	if (!bestFit) return cached.original;
	return cached.snapshot ??= createLocaleListSnapshot(cached.original);
}
/**
* https://tc39.es/ecma402/#sec-resolvelocale
*/
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
	const matcher = options.localeMatcher;
	let r;
	if (matcher === "lookup") r = LookupMatcher(localeArray(availableLocales, false), requestedLocales, getDefaultLocale);
	else r = BestFitMatcher(localeArray(availableLocales, true), requestedLocales, getDefaultLocale);
	if (r == null) r = {
		locale: getDefaultLocale(),
		extension: ""
	};
	let foundLocale = r.locale;
	let foundLocaleData = localeData[foundLocale];
	const result = Object.create(null);
	result.locale = "en";
	result.dataLocale = foundLocale;
	let components;
	let keywords;
	if (r.extension) {
		components = UnicodeExtensionComponents(r.extension);
		keywords = components.keywords;
	} else keywords = [];
	let supportedKeywords = [];
	for (const key of relevantExtensionKeys) {
		let keyLocaleData = foundLocaleData?.[key] ?? [];
		invariant(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
		let value = keyLocaleData[0];
		invariant(value == null || typeof value === "string", `value must be a string, null, or undefined`);
		let supportedKeyword;
		let entry = keywords.find((k) => k.key === key);
		if (entry) {
			let requestedValue = entry.value;
			if (requestedValue !== "") {
				if (keyLocaleData.indexOf(requestedValue) > -1) {
					value = requestedValue;
					supportedKeyword = {
						key,
						value
					};
				}
			} else if (keyLocaleData.indexOf("true") > -1) {
				value = "true";
				supportedKeyword = {
					key,
					value
				};
			}
		}
		let optionsValue = options[key];
		invariant(optionsValue == null || typeof optionsValue === "string", `optionsValue must be a string or undefined`);
		if (typeof optionsValue === "string") {
			optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
			if (optionsValue === "") optionsValue = "true";
		}
		if (optionsValue !== void 0 && optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
			value = optionsValue;
			supportedKeyword = void 0;
		}
		if (supportedKeyword) supportedKeywords.push(supportedKeyword);
		result[key] = value;
	}
	let supportedAttributes = [];
	if (supportedKeywords.length > 0) {
		supportedAttributes = [];
		foundLocale = InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords);
	}
	result.locale = foundLocale;
	return result;
}
function match(requestedLocales, availableLocales, defaultLocale, opts) {
	return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
}
// src/utils/accept-language.ts
function parseAcceptLanguage(header) {
	const specs = [];
	for (const section of header.split(",")) {
		const [rawTag, ...params] = section.split(";");
		const full = rawTag.trim().toLowerCase();
		if (full.length === 0) continue;
		let quality = 1;
		for (const param of params) {
			const separator = param.indexOf("=");
			if (separator === -1 || param.slice(0, separator).trim().toLowerCase() !== "q") continue;
			const parsed = Number.parseFloat(param.slice(separator + 1));
			if (!Number.isNaN(parsed)) quality = parsed;
		}
		const dash = full.indexOf("-");
		specs.push({
			prefix: dash === -1 ? full : full.slice(0, dash),
			full,
			quality,
			order: specs.length
		});
	}
	return specs;
}
function matchLanguage(language, specs) {
	const full = language.trim().toLowerCase();
	const dash = full.indexOf("-");
	const prefix = dash === -1 ? full : full.slice(0, dash);
	const best = {
		language,
		quality: 0,
		specificity: 0,
		order: -1
	};
	for (const spec of specs) {
		let specificity;
		if (spec.full === full) specificity = 4;
		else if (spec.prefix === full) specificity = 2;
		else if (spec.full === prefix) specificity = 1;
		else if (spec.full === "*") specificity = 0;
		else continue;
		if ((specificity - best.specificity || spec.quality - best.quality || spec.order - best.order) > 0) {
			best.quality = spec.quality;
			best.specificity = specificity;
			best.order = spec.order;
		}
	}
	if (best.quality > 0) return best;
}
/**
* Filter `available` down to the languages the `Accept-Language` header accepts, ordered by
* client preference. A missing (`null`) header accepts everything.
*/
function negotiateLanguages(header, available) {
	const specs = parseAcceptLanguage(header ?? "*");
	const matches = [];
	for (const language of available) {
		const match = matchLanguage(language, specs);
		if (match) matches.push(match);
	}
	matches.sort((a, b) => b.quality - a.quality || b.specificity - a.specificity || a.order - b.order);
	return matches.map((match) => match.language);
}
// src/i18n/middleware.ts
const DefaultFormatter = {
	get(url) {
		const segs = url.pathname.split("/");
		if (segs.length > 1 && segs[1]) return segs[1];
	},
	add(url, locale) {
		const next = new URL(url);
		next.pathname = `${url.basePath}/${locale}/${url.pathname}`.replaceAll(/\/+/g, "/");
		return next;
	},
	remove(url) {
		const next = new URL(url);
		const pathname = url.pathname.split("/").slice(2).join("/");
		next.pathname = `${url.basePath}/${pathname}`.replaceAll(/\/+/g, "/");
		return next;
	}
};
function createI18nMiddleware({ languages, defaultLanguage, format = DefaultFormatter, cookieName = "FD_LOCALE", hideLocale = "never" }) {
	let formatter;
	if (typeof format === "function") formatter = {
		...DefaultFormatter,
		add(url, locale) {
			const next = new URL(url);
			next.pathname = format(locale, url.pathname);
			return next;
		}
	};
	else formatter = format;
	return (request) => {
		const url = request.nextUrl;
		let pathLocale = formatter.get(url);
		if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
		if (!pathLocale) {
			if (hideLocale === "default-locale") return NextResponse.rewrite(formatter.add(url, defaultLanguage));
			const preferred = match(negotiateLanguages(request.headers.get("accept-language"), languages), languages, defaultLanguage);
			if (hideLocale === "always") {
				let locale = request.cookies.get(cookieName)?.value;
				if (!locale || !languages.includes(locale)) locale = preferred;
				return NextResponse.rewrite(formatter.add(url, locale));
			}
			return NextResponse.redirect(formatter.add(url, preferred));
		}
		if (hideLocale === "always" || hideLocale === "default-locale" && pathLocale === defaultLanguage) {
			const res = NextResponse.redirect(formatter.remove(url));
			res.cookies.set(cookieName, pathLocale);
			return res;
		}
		return NextResponse.next();
	};
}
export { DefaultFormatter, createI18nMiddleware };