@onlyworlds/sdk 4.186.2 → 4.187.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -2
- package/README.md +19 -0
- package/SCHEMA.md +1 -1
- package/dist/{chunk-EFH2PAJN.js → chunk-5XUVYQ5Q.js} +2 -650
- package/dist/chunk-EU4B5WYE.js +662 -0
- package/dist/chunk-OCPNZOFN.js +938 -0
- package/dist/convert.d.ts +200 -0
- package/dist/convert.js +2395 -0
- package/dist/index.js +110 -978
- package/dist/waymark.js +4 -2
- package/package.json +12 -5
package/dist/convert.js
ADDED
|
@@ -0,0 +1,2395 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OwWorldFileError,
|
|
3
|
+
byCodePoint,
|
|
4
|
+
centralDirectory,
|
|
5
|
+
inflateEntry,
|
|
6
|
+
nfc,
|
|
7
|
+
uuid5
|
|
8
|
+
} from "./chunk-OCPNZOFN.js";
|
|
9
|
+
import {
|
|
10
|
+
ELEMENT_TYPES,
|
|
11
|
+
FIELD_SCHEMA,
|
|
12
|
+
refuseUnknownOptions
|
|
13
|
+
} from "./chunk-5XUVYQ5Q.js";
|
|
14
|
+
|
|
15
|
+
// src/convert/kanka.json
|
|
16
|
+
var kanka_default = {
|
|
17
|
+
about: "The Kanka import door's tables and wording, read by the Python package (onlyworlds.kanka) and the npm SDK (convertKanka), the same bytes in both. The rules are code in each; this file holds what they read: Kanka's folders to element types, its keys to fields, the fixed key lists, the names the door makes, and every line of its report. A template is Python format syntax: {name}, {name!r} for a quoted name, {n:g} for a number.",
|
|
18
|
+
version: 1,
|
|
19
|
+
producer_input: "kanka-export",
|
|
20
|
+
namespace_url: "https://onlyworlds.com/ns/kanka",
|
|
21
|
+
ext_prefix: "x_kanka_",
|
|
22
|
+
untyped_supertype: "Article",
|
|
23
|
+
untyped_type: "narrative",
|
|
24
|
+
module_types: {
|
|
25
|
+
characters: "character",
|
|
26
|
+
locations: "location",
|
|
27
|
+
organisations: "institution",
|
|
28
|
+
notes: "narrative",
|
|
29
|
+
families: "family",
|
|
30
|
+
races: "species",
|
|
31
|
+
items: "object",
|
|
32
|
+
creatures: "creature",
|
|
33
|
+
events: "event",
|
|
34
|
+
abilities: "ability",
|
|
35
|
+
quests: "narrative",
|
|
36
|
+
journals: "narrative",
|
|
37
|
+
maps: "map"
|
|
38
|
+
},
|
|
39
|
+
proven_modules: ["characters", "locations", "organisations", "notes"],
|
|
40
|
+
story_modules: ["notes", "quests", "journals"],
|
|
41
|
+
starter_window: 5,
|
|
42
|
+
proven_export_version: "3.15",
|
|
43
|
+
parent_fields: {
|
|
44
|
+
location: "parent_location",
|
|
45
|
+
institution: "parent_institution",
|
|
46
|
+
narrative: "parent_narrative",
|
|
47
|
+
object: "parent_object",
|
|
48
|
+
species: "parent_species",
|
|
49
|
+
map: "parent_map"
|
|
50
|
+
},
|
|
51
|
+
made_names: [
|
|
52
|
+
{ kind: "hidden-details", type: "narrative", pattern: "<entity>: hidden details", source: "ours", regex: ".+: hidden details" },
|
|
53
|
+
{ kind: "untitled-post", type: "narrative", pattern: "Post", source: "ours", regex: "Post" },
|
|
54
|
+
{ kind: "untitled-relationship", type: "relation", pattern: "Relationship", source: "ours", regex: "Relationship" },
|
|
55
|
+
{ kind: "untitled-entity", type: "*", pattern: "Untitled (<entity id>)", source: "ours", regex: "Untitled \\(.+\\)" }
|
|
56
|
+
],
|
|
57
|
+
campaign_file: "campaign.json",
|
|
58
|
+
info_file: "info.json",
|
|
59
|
+
root_files: ["info.json", "campaign.json"],
|
|
60
|
+
gallery: "gallery",
|
|
61
|
+
settings: "settings",
|
|
62
|
+
settings_files: ["settings/modules.json", "settings/custom-modules.json"],
|
|
63
|
+
custom_modules_file: "settings/custom-modules.json",
|
|
64
|
+
organisations: "organisations",
|
|
65
|
+
row_handled: [
|
|
66
|
+
"id",
|
|
67
|
+
"name",
|
|
68
|
+
"entry",
|
|
69
|
+
"type",
|
|
70
|
+
"is_private",
|
|
71
|
+
"entity",
|
|
72
|
+
"location_id",
|
|
73
|
+
"race_id",
|
|
74
|
+
"is_dead",
|
|
75
|
+
"character_traits",
|
|
76
|
+
"character_families",
|
|
77
|
+
"character_races",
|
|
78
|
+
"organisation_memberships",
|
|
79
|
+
"members",
|
|
80
|
+
"is_personality_visible",
|
|
81
|
+
"image_uuid"
|
|
82
|
+
],
|
|
83
|
+
entity_handled: [
|
|
84
|
+
"id",
|
|
85
|
+
"entity_id",
|
|
86
|
+
"parent_id",
|
|
87
|
+
"name",
|
|
88
|
+
"type",
|
|
89
|
+
"entry",
|
|
90
|
+
"is_private",
|
|
91
|
+
"is_attributes_private",
|
|
92
|
+
"posts",
|
|
93
|
+
"relationships",
|
|
94
|
+
"entityLocations",
|
|
95
|
+
"entityAttributes",
|
|
96
|
+
"image_uuid"
|
|
97
|
+
],
|
|
98
|
+
not_kept_keys: [
|
|
99
|
+
"campaign_id",
|
|
100
|
+
"type_id",
|
|
101
|
+
"created_at",
|
|
102
|
+
"updated_at",
|
|
103
|
+
"deleted_at",
|
|
104
|
+
"created_by",
|
|
105
|
+
"updated_by",
|
|
106
|
+
"deleted_by",
|
|
107
|
+
"focus_x",
|
|
108
|
+
"focus_y",
|
|
109
|
+
"header_uuid",
|
|
110
|
+
"marketplace_uuid",
|
|
111
|
+
"is_personality_pinned",
|
|
112
|
+
"is_appearance_pinned",
|
|
113
|
+
"is_pinned",
|
|
114
|
+
"mentions",
|
|
115
|
+
"characterTraits",
|
|
116
|
+
"characterFamilies",
|
|
117
|
+
"characterRaces",
|
|
118
|
+
"organisationMemberships"
|
|
119
|
+
],
|
|
120
|
+
kept_when_true: ["is_template"],
|
|
121
|
+
not_content: [
|
|
122
|
+
"id",
|
|
123
|
+
"mirror_id",
|
|
124
|
+
"position",
|
|
125
|
+
"default_order",
|
|
126
|
+
"created_at",
|
|
127
|
+
"updated_at",
|
|
128
|
+
"created_by",
|
|
129
|
+
"updated_by",
|
|
130
|
+
"deleted_at",
|
|
131
|
+
"deleted_by",
|
|
132
|
+
"marketplace_uuid",
|
|
133
|
+
"entity_id",
|
|
134
|
+
"character_id",
|
|
135
|
+
"words"
|
|
136
|
+
],
|
|
137
|
+
post_kept: ["location_id", "layout_id", "is_pinned", "is_template"],
|
|
138
|
+
post_display_settings: ["collapsed"],
|
|
139
|
+
trait_sections: {
|
|
140
|
+
"1": { field: "physicality", heading: "Appearance" },
|
|
141
|
+
"2": { field: "mentality", heading: "Personality" }
|
|
142
|
+
},
|
|
143
|
+
personality_section: 2,
|
|
144
|
+
deceased_field: "physicality",
|
|
145
|
+
character_lists: [
|
|
146
|
+
{ key: "character_races", id_key: "race_id", folder: "races", field: "species", row_key: "race_id" },
|
|
147
|
+
{ key: "character_families", id_key: "family_id", folder: "families", field: "family", row_key: null },
|
|
148
|
+
{ key: "organisation_memberships", id_key: "organisation_id", folder: "organisations", field: "institutions", row_key: null }
|
|
149
|
+
],
|
|
150
|
+
words: {
|
|
151
|
+
untitled: "Untitled ({entity_id})",
|
|
152
|
+
post: "Post",
|
|
153
|
+
relationship: "Relationship",
|
|
154
|
+
hidden_details: "{name}: hidden details",
|
|
155
|
+
campaign: "Kanka campaign {id}",
|
|
156
|
+
deceased: "[Deceased] ",
|
|
157
|
+
traits_heading: "Traits",
|
|
158
|
+
attributes_heading: "Attributes"
|
|
159
|
+
},
|
|
160
|
+
where: {
|
|
161
|
+
mention: "mention",
|
|
162
|
+
parent: "parent",
|
|
163
|
+
relationship: "relationship {text!r}"
|
|
164
|
+
},
|
|
165
|
+
why: {
|
|
166
|
+
no_entity: "no such entity in the export",
|
|
167
|
+
no_row: "no {folder} row with that id",
|
|
168
|
+
no_locations_row: "no locations row",
|
|
169
|
+
no_characters_row: "no characters row",
|
|
170
|
+
no_tags_row: "no tags row",
|
|
171
|
+
untyped_type: "a module with no OnlyWorlds type keeps its own type",
|
|
172
|
+
entry_differs: "the row's entry differs from the entity's (kept as written)",
|
|
173
|
+
members_elsewhere: "members on a module that is not organisations",
|
|
174
|
+
parent_not_id: "not an entity id",
|
|
175
|
+
parent_missing: "its parent is not in the folder",
|
|
176
|
+
posts_meta: "a post's layout, place, pins or visibility have no field",
|
|
177
|
+
traits_other: "a trait section other than appearance (1) and personality (2)",
|
|
178
|
+
list_more: "an item carries more than the id it links",
|
|
179
|
+
locations_one: "location links one; every place kept",
|
|
180
|
+
no_location_field: "{type} has no location field",
|
|
181
|
+
no_field: "{type} has no field {field!r}",
|
|
182
|
+
already_set: "{field} is already set",
|
|
183
|
+
not_integer: "the value is not a whole number ({field} is an integer)",
|
|
184
|
+
not_mentions: "{field} links a {target}; the value is not a list of mentions",
|
|
185
|
+
mention_not_found: "{field} links a {target}; a mention is not one in the folder",
|
|
186
|
+
links_one: "{field} links one; the value names {n}",
|
|
187
|
+
no_field_for_key: "no field for the {where}'s {key}",
|
|
188
|
+
member_role: "a member carries more than the character it links (a role)",
|
|
189
|
+
tag_hidden: "the element is hidden and the tag is not; the element keeps x_kanka_entity_tags",
|
|
190
|
+
tag_no_field: "Narrative has no field for a {type}; the element keeps x_kanka_entity_tags"
|
|
191
|
+
},
|
|
192
|
+
notes: {
|
|
193
|
+
not_json: "{rel}: not readable JSON ({error}); skipped",
|
|
194
|
+
version: "Kanka {kanka_version}, export version {version}",
|
|
195
|
+
version_unproven: " (this door was proven on {proven})",
|
|
196
|
+
root_file: "{rel}: a file at the export's root this door does not read",
|
|
197
|
+
not_entity_file: "{rel}: not an entity file (one JSON per entity in a module folder); skipped",
|
|
198
|
+
no_entity: "{rel}: no entity object with an id; skipped",
|
|
199
|
+
filename_id: "{rel}: the filename's number is not the entity's id {entity_id}",
|
|
200
|
+
second_file: "{rel}: a second file for entity {entity_id}; the first is kept",
|
|
201
|
+
custom_modules: "{rel}: custom modules are defined; their entities, if exported, are read by folder",
|
|
202
|
+
settings_file: "{rel}: a settings file this door does not read",
|
|
203
|
+
mentions_hidden: "{element!r}: visible text mentions the hidden {target!r} by name",
|
|
204
|
+
mirror_missing: "relationship {relation!r} on {element!r}: its mirror {mirror} is not in the export; kept one-way",
|
|
205
|
+
no_text: "a relationship from {owner!r} to {target!r} has no text; named {name!r}",
|
|
206
|
+
no_relation_field: "Relation {name!r} from {owner!r}: Relation has no field for a {type}; {end!r} is in x_kanka_source/target only",
|
|
207
|
+
not_kept: "not kept: timestamps and who made or changed a row (created_at, updated_at, created_by, updated_by), campaign_id and type_id, image focus points and the header image's upload uuid, marketplace ids, pin and display flags, the server's mentions index (the text holds the mentions), and the camelCase twins of a character's lists (characterTraits and the rest: the same rows without their ids)"
|
|
208
|
+
},
|
|
209
|
+
errors: {
|
|
210
|
+
no_campaign: "{source}: no campaign.json with an id (is it Kanka's JSON export?)"
|
|
211
|
+
},
|
|
212
|
+
report: {
|
|
213
|
+
head: "Kanka export {source} ({name!r}): {total} elements ({by_type}).",
|
|
214
|
+
head_none: "none",
|
|
215
|
+
modules: "What became what:",
|
|
216
|
+
module: " - {folder}/ ({entities}): {type}; {how}",
|
|
217
|
+
how: {
|
|
218
|
+
proven: "read on a real export",
|
|
219
|
+
believed: "believed, not yet seen in a real export",
|
|
220
|
+
untyped: "no OnlyWorlds type: Narratives, supertype {supertype}, subtype {folder!r}"
|
|
221
|
+
},
|
|
222
|
+
relations: "Relationships kept as Relation elements ({n}): {listed}.",
|
|
223
|
+
folded: "Exact duplicates folded into one ({n}):",
|
|
224
|
+
fold: " - {element!r}: {copies} identical {what}s {name!r}, kept once",
|
|
225
|
+
starter: "Possibly Kanka's starter content (made within {window:g} seconds of the campaign; nothing in the data marks it, so it is imported): {listed}.",
|
|
226
|
+
hidden: "Hidden as the source hides it (elements carrying hidden: true): {said}.",
|
|
227
|
+
hidden_elements: {
|
|
228
|
+
entities: ["private entity (is_private)", "private entities (is_private)"],
|
|
229
|
+
posts: ["post not visible to all, its own Narrative (visibility_id)", "posts not visible to all, each its own Narrative (visibility_id)"],
|
|
230
|
+
relationships: ["relationship hidden on a side or touching a hidden entity (visibility_id)", "relationships hidden on a side or touching a hidden entity (visibility_id)"]
|
|
231
|
+
},
|
|
232
|
+
hidden_held: {
|
|
233
|
+
traits: ["private trait (is_private)", "private traits (is_private)"],
|
|
234
|
+
personality: ["personality trait not visible to players (is_personality_visible)", "personality traits not visible to players (is_personality_visible)"],
|
|
235
|
+
attributes: ["private or hidden attribute (is_private, is_hidden, is_attributes_private)", "private or hidden attributes (is_private, is_hidden, is_attributes_private)"],
|
|
236
|
+
links: ["private link (is_private)", "private links (is_private)"]
|
|
237
|
+
},
|
|
238
|
+
hidden_details: ["{n} hidden-details Narrative holding {held}", "{n} hidden-details Narratives holding {held}"],
|
|
239
|
+
untagged: "Tags not linked to an element that carries them ({n}):",
|
|
240
|
+
untag: " - {tag!r} on {element!r}: {why}",
|
|
241
|
+
uploads: ["gallery/: {n} upload read as Kanka's image store; {named} named by an entity.", "gallery/: {n} uploads read as Kanka's image store; {named} named by an entity."],
|
|
242
|
+
pictures: "Pictures named but not imported ({n}): an OnlyWorlds image_url is a URL, and the folder format has no place for image files yet; each element keeps x_kanka_image:",
|
|
243
|
+
picture: " - {element!r}: {path}",
|
|
244
|
+
picture_original: " - {element!r}: {path} ({original})",
|
|
245
|
+
picture_private: " - {element!r}: upload {uuid} is not visible to all; its name and file stay out of this visible element, the uuid kept alone",
|
|
246
|
+
picture_missing: " - {element!r}: upload {uuid} is not in gallery/; the uuid kept alone",
|
|
247
|
+
unplaced: "Keys not placed on a field ({n}), kept as extensions:",
|
|
248
|
+
unplaced_item: " - {element!r} / {key!r}: {why}; kept as {kept_as}",
|
|
249
|
+
unresolved: "Links and mentions whose target is not in the folder ({n}):",
|
|
250
|
+
unresolved_item: " - {element!r}, {where}: {target}: {why}",
|
|
251
|
+
notes: "Notes ({n}):",
|
|
252
|
+
note: " - {note}",
|
|
253
|
+
wrote: "Wrote {out}.",
|
|
254
|
+
plan: "Plan only: nothing written."
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// src/convert/py.ts
|
|
259
|
+
var PyFloat = class {
|
|
260
|
+
constructor(value) {
|
|
261
|
+
this.value = value;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
var isDict = (v) => v instanceof Map;
|
|
265
|
+
var isList = (v) => Array.isArray(v);
|
|
266
|
+
var isInt = (v) => typeof v === "number";
|
|
267
|
+
var isStr = (v) => typeof v === "string";
|
|
268
|
+
function get(d, k) {
|
|
269
|
+
const v = d.get(k);
|
|
270
|
+
return v === void 0 ? null : v;
|
|
271
|
+
}
|
|
272
|
+
function numeric(v) {
|
|
273
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
274
|
+
if (typeof v === "number") return v;
|
|
275
|
+
if (v instanceof PyFloat) return v.value;
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
function truthy(v) {
|
|
279
|
+
if (v === null) return false;
|
|
280
|
+
if (typeof v === "boolean") return v;
|
|
281
|
+
if (typeof v === "number") return v !== 0;
|
|
282
|
+
if (v instanceof PyFloat) return v.value !== 0;
|
|
283
|
+
if (typeof v === "string") return v.length > 0;
|
|
284
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
285
|
+
return v.size > 0;
|
|
286
|
+
}
|
|
287
|
+
function eq(a, b) {
|
|
288
|
+
const x = numeric(a);
|
|
289
|
+
const y = numeric(b);
|
|
290
|
+
if (x !== null || y !== null) return x !== null && y !== null && x === y;
|
|
291
|
+
if (a === null || b === null) return a === b;
|
|
292
|
+
if (typeof a === "string" || typeof b === "string") return a === b;
|
|
293
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
294
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
295
|
+
return a.every((v, i) => eq(v, b[i]));
|
|
296
|
+
}
|
|
297
|
+
const da = a;
|
|
298
|
+
const db = b;
|
|
299
|
+
if (da.size !== db.size) return false;
|
|
300
|
+
for (const [k, v] of da) {
|
|
301
|
+
if (!db.has(k) || !eq(v, db.get(k))) return false;
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
var among = (v, options) => options.some((o) => eq(v, o));
|
|
306
|
+
var PY_SPACE = "\\t\\n\\x0b\\x0c\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
307
|
+
var LEAD = new RegExp(`^[${PY_SPACE}]+`);
|
|
308
|
+
var TRAIL = new RegExp(`[${PY_SPACE}]+$`);
|
|
309
|
+
var strip = (s) => s.replace(LEAD, "").replace(TRAIL, "");
|
|
310
|
+
var lstrip = (s) => s.replace(LEAD, "");
|
|
311
|
+
var rstrip = (s) => s.replace(TRAIL, "");
|
|
312
|
+
function stripChars(s, chars) {
|
|
313
|
+
let a = 0;
|
|
314
|
+
let b = s.length;
|
|
315
|
+
while (a < b && chars.includes(s[a])) a++;
|
|
316
|
+
while (b > a && chars.includes(s[b - 1])) b--;
|
|
317
|
+
return s.slice(a, b);
|
|
318
|
+
}
|
|
319
|
+
var ND = /^\p{Nd}$/u;
|
|
320
|
+
function digitsValue(digits) {
|
|
321
|
+
let n = 0;
|
|
322
|
+
for (const ch of digits) {
|
|
323
|
+
let cp = ch.codePointAt(0);
|
|
324
|
+
if (cp >= 48 && cp <= 57) {
|
|
325
|
+
n = n * 10 + (cp - 48);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
let start = cp;
|
|
329
|
+
while (ND.test(String.fromCodePoint(start - 1))) start--;
|
|
330
|
+
cp -= start;
|
|
331
|
+
n = n * 10 + cp % 10;
|
|
332
|
+
}
|
|
333
|
+
return n;
|
|
334
|
+
}
|
|
335
|
+
function intOfDigits(s) {
|
|
336
|
+
const t = strip(s);
|
|
337
|
+
return t && /^\p{Nd}+$/u.test(t) ? digitsValue(t) : null;
|
|
338
|
+
}
|
|
339
|
+
function floatRepr(x) {
|
|
340
|
+
if (Number.isNaN(x)) return "nan";
|
|
341
|
+
if (x === Infinity) return "inf";
|
|
342
|
+
if (x === -Infinity) return "-inf";
|
|
343
|
+
if (x === 0) return Object.is(x, -0) ? "-0.0" : "0.0";
|
|
344
|
+
const [mant, expPart] = Math.abs(x).toExponential().split("e");
|
|
345
|
+
const exp = Number(expPart);
|
|
346
|
+
const digits = mant.replace(".", "");
|
|
347
|
+
const sign = x < 0 ? "-" : "";
|
|
348
|
+
if (exp < -4 || exp >= 16) {
|
|
349
|
+
const m = digits.length > 1 ? `${digits[0]}.${digits.slice(1)}` : digits;
|
|
350
|
+
return `${sign}${m}e${exp < 0 ? "-" : "+"}${String(Math.abs(exp)).padStart(2, "0")}`;
|
|
351
|
+
}
|
|
352
|
+
if (exp < 0) return `${sign}0.${"0".repeat(-exp - 1)}${digits}`;
|
|
353
|
+
const whole = digits.slice(0, exp + 1).padEnd(exp + 1, "0");
|
|
354
|
+
const frac = digits.slice(exp + 1);
|
|
355
|
+
return `${sign}${whole}.${frac || "0"}`;
|
|
356
|
+
}
|
|
357
|
+
function intStr(n) {
|
|
358
|
+
return Number.isSafeInteger(n) ? String(n) : BigInt(n).toString();
|
|
359
|
+
}
|
|
360
|
+
var NOT_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
|
|
361
|
+
function strRepr(s) {
|
|
362
|
+
const quote = s.includes("'") && !s.includes('"') ? '"' : "'";
|
|
363
|
+
let out = quote;
|
|
364
|
+
for (const ch of s) {
|
|
365
|
+
const cp = ch.codePointAt(0);
|
|
366
|
+
if (ch === quote || ch === "\\") out += `\\${ch}`;
|
|
367
|
+
else if (ch === " ") out += "\\t";
|
|
368
|
+
else if (ch === "\n") out += "\\n";
|
|
369
|
+
else if (ch === "\r") out += "\\r";
|
|
370
|
+
else if (ch !== " " && NOT_PRINTABLE.test(ch)) {
|
|
371
|
+
if (cp < 256) out += `\\x${cp.toString(16).padStart(2, "0")}`;
|
|
372
|
+
else if (cp < 65536) out += `\\u${cp.toString(16).padStart(4, "0")}`;
|
|
373
|
+
else out += `\\U${cp.toString(16).padStart(8, "0")}`;
|
|
374
|
+
} else out += ch;
|
|
375
|
+
}
|
|
376
|
+
return out + quote;
|
|
377
|
+
}
|
|
378
|
+
function repr(v) {
|
|
379
|
+
if (typeof v === "string") return strRepr(v);
|
|
380
|
+
if (Array.isArray(v)) return `[${v.map(repr).join(", ")}]`;
|
|
381
|
+
if (v instanceof Map) return `{${[...v].map(([k, x]) => `${strRepr(k)}: ${repr(x)}`).join(", ")}}`;
|
|
382
|
+
return str(v);
|
|
383
|
+
}
|
|
384
|
+
function str(v) {
|
|
385
|
+
if (v === null) return "None";
|
|
386
|
+
if (v === true) return "True";
|
|
387
|
+
if (v === false) return "False";
|
|
388
|
+
if (typeof v === "number") return intStr(v);
|
|
389
|
+
if (v instanceof PyFloat) return floatRepr(v.value);
|
|
390
|
+
if (typeof v === "string") return v;
|
|
391
|
+
return repr(v);
|
|
392
|
+
}
|
|
393
|
+
function formatG(x) {
|
|
394
|
+
if (!Number.isFinite(x)) return Number.isNaN(x) ? "nan" : x > 0 ? "inf" : "-inf";
|
|
395
|
+
if (x === 0) return Object.is(x, -0) ? "-0" : "0";
|
|
396
|
+
const [mant, expPart] = x.toExponential(5).split("e");
|
|
397
|
+
const exp = Number(expPart);
|
|
398
|
+
const trim = (m) => m.includes(".") ? m.replace(/0+$/, "").replace(/\.$/, "") : m;
|
|
399
|
+
if (exp < -4 || exp >= 6) return `${trim(mant)}e${exp < 0 ? "-" : "+"}${String(Math.abs(exp)).padStart(2, "0")}`;
|
|
400
|
+
return trim(x.toFixed(Math.max(0, 5 - exp)));
|
|
401
|
+
}
|
|
402
|
+
function format(template, values) {
|
|
403
|
+
return template.replace(/\{\{|\}\}|\{([A-Za-z_][A-Za-z0-9_]*)(!r)?(?::(g))?\}|[{}]/g, (m, name2, r, g) => {
|
|
404
|
+
if (m === "{{") return "{";
|
|
405
|
+
if (m === "}}") return "}";
|
|
406
|
+
if (name2 === void 0) throw new Error(`a template holds a brace it cannot read: ${template}`);
|
|
407
|
+
if (!(name2 in values)) throw new Error(`a template names {${name2}}, which was not given: ${template}`);
|
|
408
|
+
const v = values[name2];
|
|
409
|
+
if (g) {
|
|
410
|
+
const x = numeric(v);
|
|
411
|
+
if (x === null) throw new Error(`{${name2}:g} is not a number`);
|
|
412
|
+
return formatG(x);
|
|
413
|
+
}
|
|
414
|
+
return r ? repr(v) : str(v);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
var PyJsonError = class extends Error {
|
|
418
|
+
constructor() {
|
|
419
|
+
super(...arguments);
|
|
420
|
+
this.pyName = "JSONDecodeError";
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
var NUMBER = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
|
|
424
|
+
var WS = /[ \t\n\r]*/y;
|
|
425
|
+
function loads(text) {
|
|
426
|
+
let i = 0;
|
|
427
|
+
const fail = (what) => {
|
|
428
|
+
throw new PyJsonError(`${what} at ${i}`);
|
|
429
|
+
};
|
|
430
|
+
const ws = () => {
|
|
431
|
+
WS.lastIndex = i;
|
|
432
|
+
WS.exec(text);
|
|
433
|
+
i = WS.lastIndex;
|
|
434
|
+
};
|
|
435
|
+
const string = () => {
|
|
436
|
+
i++;
|
|
437
|
+
let out = "";
|
|
438
|
+
for (; ; ) {
|
|
439
|
+
if (i >= text.length) fail("Unterminated string");
|
|
440
|
+
const c = text.charCodeAt(i);
|
|
441
|
+
if (c === 34) {
|
|
442
|
+
i++;
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
if (c < 32) fail("Invalid control character");
|
|
446
|
+
if (c !== 92) {
|
|
447
|
+
let j = i;
|
|
448
|
+
while (j < text.length) {
|
|
449
|
+
const d = text.charCodeAt(j);
|
|
450
|
+
if (d === 34 || d === 92 || d < 32) break;
|
|
451
|
+
j++;
|
|
452
|
+
}
|
|
453
|
+
out += text.slice(i, j);
|
|
454
|
+
i = j;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
const e = text[i + 1];
|
|
458
|
+
const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: " " };
|
|
459
|
+
if (e !== void 0 && e in simple) {
|
|
460
|
+
out += simple[e];
|
|
461
|
+
i += 2;
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
if (e !== "u") fail("Invalid \\escape");
|
|
465
|
+
const hex = text.slice(i + 2, i + 6);
|
|
466
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) fail("Invalid \\uXXXX escape");
|
|
467
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
468
|
+
i += 6;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
const value = () => {
|
|
472
|
+
ws();
|
|
473
|
+
const c = text[i];
|
|
474
|
+
if (c === '"') return string();
|
|
475
|
+
if (c === "{") {
|
|
476
|
+
i++;
|
|
477
|
+
const d = /* @__PURE__ */ new Map();
|
|
478
|
+
ws();
|
|
479
|
+
if (text[i] === "}") {
|
|
480
|
+
i++;
|
|
481
|
+
return d;
|
|
482
|
+
}
|
|
483
|
+
for (; ; ) {
|
|
484
|
+
ws();
|
|
485
|
+
if (text[i] !== '"') fail("Expecting property name enclosed in double quotes");
|
|
486
|
+
const k = string();
|
|
487
|
+
ws();
|
|
488
|
+
if (text[i] !== ":") fail("Expecting ':' delimiter");
|
|
489
|
+
i++;
|
|
490
|
+
d.set(k, value());
|
|
491
|
+
ws();
|
|
492
|
+
if (text[i] === ",") {
|
|
493
|
+
i++;
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
if (text[i] === "}") {
|
|
497
|
+
i++;
|
|
498
|
+
return d;
|
|
499
|
+
}
|
|
500
|
+
fail("Expecting ',' delimiter");
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (c === "[") {
|
|
504
|
+
i++;
|
|
505
|
+
const a = [];
|
|
506
|
+
ws();
|
|
507
|
+
if (text[i] === "]") {
|
|
508
|
+
i++;
|
|
509
|
+
return a;
|
|
510
|
+
}
|
|
511
|
+
for (; ; ) {
|
|
512
|
+
a.push(value());
|
|
513
|
+
ws();
|
|
514
|
+
if (text[i] === ",") {
|
|
515
|
+
i++;
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (text[i] === "]") {
|
|
519
|
+
i++;
|
|
520
|
+
return a;
|
|
521
|
+
}
|
|
522
|
+
fail("Expecting ',' delimiter");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
for (const [word, v2] of [
|
|
526
|
+
["null", null],
|
|
527
|
+
["true", true],
|
|
528
|
+
["false", false],
|
|
529
|
+
["NaN", new PyFloat(NaN)],
|
|
530
|
+
["Infinity", new PyFloat(Infinity)],
|
|
531
|
+
["-Infinity", new PyFloat(-Infinity)]
|
|
532
|
+
]) {
|
|
533
|
+
if (text.startsWith(word, i)) {
|
|
534
|
+
i += word.length;
|
|
535
|
+
return v2;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
NUMBER.lastIndex = i;
|
|
539
|
+
const m = NUMBER.exec(text);
|
|
540
|
+
if (!m) return fail("Expecting value");
|
|
541
|
+
i = NUMBER.lastIndex;
|
|
542
|
+
if (m[1] === void 0 && m[2] === void 0) {
|
|
543
|
+
const n = Number(m[0]);
|
|
544
|
+
return n === 0 ? 0 : n;
|
|
545
|
+
}
|
|
546
|
+
return new PyFloat(Number(m[0]));
|
|
547
|
+
};
|
|
548
|
+
const v = value();
|
|
549
|
+
ws();
|
|
550
|
+
if (i !== text.length) fail("Extra data");
|
|
551
|
+
return v;
|
|
552
|
+
}
|
|
553
|
+
function dumpsSorted(v) {
|
|
554
|
+
if (v === null) return "null";
|
|
555
|
+
if (v === true) return "true";
|
|
556
|
+
if (v === false) return "false";
|
|
557
|
+
if (typeof v === "number") return intStr(v);
|
|
558
|
+
if (v instanceof PyFloat) {
|
|
559
|
+
const x = v.value;
|
|
560
|
+
return Number.isNaN(x) ? "NaN" : x === Infinity ? "Infinity" : x === -Infinity ? "-Infinity" : floatRepr(x);
|
|
561
|
+
}
|
|
562
|
+
if (typeof v === "string") return dumpsString(v);
|
|
563
|
+
if (Array.isArray(v)) return `[${v.map(dumpsSorted).join(", ")}]`;
|
|
564
|
+
const keys = [...v.keys()].sort(byCodePoint);
|
|
565
|
+
return `{${keys.map((k) => `${dumpsString(k)}: ${dumpsSorted(v.get(k))}`).join(", ")}}`;
|
|
566
|
+
}
|
|
567
|
+
function dumpsString(s) {
|
|
568
|
+
const short = { '"': '\\"', "\\": "\\\\", "\n": "\\n", "\r": "\\r", " ": "\\t", "\b": "\\b", "\f": "\\f" };
|
|
569
|
+
return `"${s.replace(/["\\\x00-\x1f]/g, (c) => short[c] ?? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`)}"`;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/convert/folder.ts
|
|
573
|
+
var FOLDER_FORMAT_VERSION = "0.3.24";
|
|
574
|
+
var WRITE_ORDER = [
|
|
575
|
+
"ability",
|
|
576
|
+
"collective",
|
|
577
|
+
"character",
|
|
578
|
+
"construct",
|
|
579
|
+
"creature",
|
|
580
|
+
"event",
|
|
581
|
+
"family",
|
|
582
|
+
"institution",
|
|
583
|
+
"language",
|
|
584
|
+
"law",
|
|
585
|
+
"location",
|
|
586
|
+
"map",
|
|
587
|
+
"marker",
|
|
588
|
+
"narrative",
|
|
589
|
+
"object",
|
|
590
|
+
"phenomenon",
|
|
591
|
+
"pin",
|
|
592
|
+
"relation",
|
|
593
|
+
"species",
|
|
594
|
+
"title",
|
|
595
|
+
"trait",
|
|
596
|
+
"zone"
|
|
597
|
+
];
|
|
598
|
+
var SLUG_ID_SEP = "--";
|
|
599
|
+
var ID_TAIL_LEN = 8;
|
|
600
|
+
var SLUG_MAX_LEN = 40;
|
|
601
|
+
function slugify(name2) {
|
|
602
|
+
if (!name2) return "";
|
|
603
|
+
const ascii = name2.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
604
|
+
const trimmed = ascii.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
605
|
+
if (trimmed.length <= SLUG_MAX_LEN) return trimmed;
|
|
606
|
+
return trimmed.slice(0, SLUG_MAX_LEN).replace(/-+$/, "");
|
|
607
|
+
}
|
|
608
|
+
function idTail(id) {
|
|
609
|
+
if (id.length <= ID_TAIL_LEN) return id;
|
|
610
|
+
const raw = id.slice(-ID_TAIL_LEN);
|
|
611
|
+
if (raw.includes(SLUG_ID_SEP) || raw.startsWith("-")) {
|
|
612
|
+
const compact = id.split("-").join("");
|
|
613
|
+
return compact.length <= ID_TAIL_LEN ? compact : compact.slice(-ID_TAIL_LEN);
|
|
614
|
+
}
|
|
615
|
+
return raw;
|
|
616
|
+
}
|
|
617
|
+
function elementFilename(id, name2) {
|
|
618
|
+
const slug = slugify(name2);
|
|
619
|
+
return slug ? `${slug}${SLUG_ID_SEP}${idTail(id)}.json` : `${id}.json`;
|
|
620
|
+
}
|
|
621
|
+
function elementFilenameFullId(id, name2) {
|
|
622
|
+
const slug = slugify(name2);
|
|
623
|
+
return slug ? `${slug}${SLUG_ID_SEP}${id}.json` : `${id}.json`;
|
|
624
|
+
}
|
|
625
|
+
function resolveFilenames(elements) {
|
|
626
|
+
const names = /* @__PURE__ */ new Map();
|
|
627
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
628
|
+
for (const [id, name2] of elements) {
|
|
629
|
+
if (names.has(id)) throw new Error(`duplicate id '${id}' in one type directory`);
|
|
630
|
+
names.set(id, name2);
|
|
631
|
+
const key = elementFilename(id, name2).toLowerCase();
|
|
632
|
+
if (!buckets.has(key)) buckets.set(key, []);
|
|
633
|
+
buckets.get(key).push(id);
|
|
634
|
+
}
|
|
635
|
+
const out = /* @__PURE__ */ new Map();
|
|
636
|
+
for (const ids of buckets.values()) {
|
|
637
|
+
[...ids].sort(byCodePoint).forEach((id, i) => {
|
|
638
|
+
out.set(id, (i === 0 ? elementFilename : elementFilenameFullId)(id, names.get(id)));
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
return out;
|
|
642
|
+
}
|
|
643
|
+
function dump(v, indent2, out) {
|
|
644
|
+
if (v === null) out.push("null");
|
|
645
|
+
else if (v === true) out.push("true");
|
|
646
|
+
else if (v === false) out.push("false");
|
|
647
|
+
else if (typeof v === "number") out.push(intStr(v));
|
|
648
|
+
else if (v instanceof PyFloat) {
|
|
649
|
+
if (!Number.isFinite(v.value)) throw new Error(`non-finite number ${v.value} has no JSON form`);
|
|
650
|
+
out.push(JSON.stringify(v.value));
|
|
651
|
+
} else if (typeof v === "string") out.push(JSON.stringify(v));
|
|
652
|
+
else if (Array.isArray(v)) {
|
|
653
|
+
if (!v.length) {
|
|
654
|
+
out.push("[]");
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
const inner = `${indent2} `;
|
|
658
|
+
out.push("[");
|
|
659
|
+
v.forEach((item, i) => {
|
|
660
|
+
out.push(`${i === 0 ? "\n" : ",\n"}${inner}`);
|
|
661
|
+
dump(item, inner, out);
|
|
662
|
+
});
|
|
663
|
+
out.push(`
|
|
664
|
+
${indent2}]`);
|
|
665
|
+
} else {
|
|
666
|
+
if (!v.size) {
|
|
667
|
+
out.push("{}");
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const inner = `${indent2} `;
|
|
671
|
+
out.push("{");
|
|
672
|
+
let first = true;
|
|
673
|
+
for (const [k, item] of v) {
|
|
674
|
+
out.push(`${first ? "\n" : ",\n"}${inner}${JSON.stringify(k)}: `);
|
|
675
|
+
first = false;
|
|
676
|
+
dump(item, inner, out);
|
|
677
|
+
}
|
|
678
|
+
out.push(`
|
|
679
|
+
${indent2}}`);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function encode(v) {
|
|
683
|
+
const out = [];
|
|
684
|
+
dump(v, "", out);
|
|
685
|
+
out.push("\n");
|
|
686
|
+
return new TextEncoder().encode(out.join(""));
|
|
687
|
+
}
|
|
688
|
+
var WIRE_TO_DISK_WORLD_KEYS = { time_range_current: "time_current" };
|
|
689
|
+
function worldForDisk(world, counts) {
|
|
690
|
+
const id = world.get("id");
|
|
691
|
+
if (typeof id !== "string" || !id) throw new Error("world.json requires a non-empty string `id` (\xA74.1)");
|
|
692
|
+
if (typeof world.get("name") !== "string") throw new Error("world.json requires a string `name` (it MAY be empty) (\xA74.1)");
|
|
693
|
+
const out = /* @__PURE__ */ new Map();
|
|
694
|
+
for (const [key, value] of world) {
|
|
695
|
+
const disk = WIRE_TO_DISK_WORLD_KEYS[key] ?? key;
|
|
696
|
+
out.set(world.has(disk) ? key : disk, value);
|
|
697
|
+
}
|
|
698
|
+
if (out.has("snapshot_counts")) {
|
|
699
|
+
if (out.has("snapshot_of")) out.set("snapshot_counts", new Map([...counts].filter(([, n]) => n)));
|
|
700
|
+
else out.delete("snapshot_counts");
|
|
701
|
+
}
|
|
702
|
+
if (!out.has("format_version")) out.set("format_version", FOLDER_FORMAT_VERSION);
|
|
703
|
+
return out;
|
|
704
|
+
}
|
|
705
|
+
function folderFiles(world, elements) {
|
|
706
|
+
const byType = /* @__PURE__ */ new Map();
|
|
707
|
+
const owner = /* @__PURE__ */ new Map();
|
|
708
|
+
for (const [type, bodies] of elements) {
|
|
709
|
+
if (!ELEMENT_TYPES.includes(type)) throw new Error(`unknown element type '${type}'`);
|
|
710
|
+
if (!byType.has(type)) byType.set(type, /* @__PURE__ */ new Map());
|
|
711
|
+
const slot = byType.get(type);
|
|
712
|
+
for (const body of bodies) {
|
|
713
|
+
const id = body.get("id");
|
|
714
|
+
if (typeof id !== "string" || !id) throw new Error(`${type} element without a non-empty string id`);
|
|
715
|
+
if ((owner.get(id) ?? type) !== type) throw new Error(`id ${id} appears under both ${owner.get(id)} and ${type}`);
|
|
716
|
+
owner.set(id, type);
|
|
717
|
+
slot.delete(id);
|
|
718
|
+
slot.set(id, body);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const files = [];
|
|
722
|
+
const counts = /* @__PURE__ */ new Map();
|
|
723
|
+
const nameOf = (b) => {
|
|
724
|
+
const n = b.get("name");
|
|
725
|
+
return typeof n === "string" ? n : null;
|
|
726
|
+
};
|
|
727
|
+
for (const type of WRITE_ORDER) {
|
|
728
|
+
const bodies = byType.get(type);
|
|
729
|
+
if (!bodies || !bodies.size) continue;
|
|
730
|
+
const names = resolveFilenames([...bodies].map(([id, b]) => [id, nameOf(b)]));
|
|
731
|
+
for (const [id, body] of bodies) files.push({ path: `elements/${type}/${names.get(id)}`, data: encode(body) });
|
|
732
|
+
counts.set(type, bodies.size);
|
|
733
|
+
}
|
|
734
|
+
files.push({ path: "world.json", data: encode(worldForDisk(world, counts)) });
|
|
735
|
+
return files.sort((a, b) => byCodePoint(a.path, b.path));
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/convert/core.ts
|
|
739
|
+
var ANY_TYPE = "*";
|
|
740
|
+
var SCHEMA = FIELD_SCHEMA;
|
|
741
|
+
function fieldsOf(type) {
|
|
742
|
+
return Object.entries(SCHEMA[type]).map(([f, info]) => [f, info.type]);
|
|
743
|
+
}
|
|
744
|
+
function kindOf(type, field) {
|
|
745
|
+
return SCHEMA[type]?.[field]?.type;
|
|
746
|
+
}
|
|
747
|
+
function targetOf(type, field) {
|
|
748
|
+
return SCHEMA[type]?.[field]?.target;
|
|
749
|
+
}
|
|
750
|
+
var lowerCache = /* @__PURE__ */ new Map();
|
|
751
|
+
function fieldByLower(type, lower) {
|
|
752
|
+
let m = lowerCache.get(type);
|
|
753
|
+
if (!m) {
|
|
754
|
+
m = /* @__PURE__ */ new Map();
|
|
755
|
+
for (const [f] of fieldsOf(type)) m.set(f.toLowerCase(), f);
|
|
756
|
+
lowerCache.set(type, m);
|
|
757
|
+
}
|
|
758
|
+
return m.get(lower);
|
|
759
|
+
}
|
|
760
|
+
function multiLinkFor(on2) {
|
|
761
|
+
const out = /* @__PURE__ */ new Map();
|
|
762
|
+
for (const [f, kind] of fieldsOf(on2)) {
|
|
763
|
+
const target = targetOf(on2, f);
|
|
764
|
+
if (kind === "multi_link" && target && !out.has(target)) out.set(target, f);
|
|
765
|
+
}
|
|
766
|
+
return out;
|
|
767
|
+
}
|
|
768
|
+
var relationFields = null;
|
|
769
|
+
var narrativeFields = null;
|
|
770
|
+
function relationFieldFor(type) {
|
|
771
|
+
relationFields ?? (relationFields = multiLinkFor("relation"));
|
|
772
|
+
return relationFields.get(type);
|
|
773
|
+
}
|
|
774
|
+
function narrativeFieldFor(type) {
|
|
775
|
+
narrativeFields ?? (narrativeFields = multiLinkFor("narrative"));
|
|
776
|
+
return narrativeFields.get(type);
|
|
777
|
+
}
|
|
778
|
+
var CAMEL = /(?<=[a-z0-9])(?=[A-Z])/g;
|
|
779
|
+
var SEPARATORS = new RegExp(`[${PY_SPACE}-]+`, "g");
|
|
780
|
+
function normKey(name2) {
|
|
781
|
+
return strip(name2).replace(CAMEL, "_").toLowerCase().replace(SEPARATORS, "_");
|
|
782
|
+
}
|
|
783
|
+
function empty(v) {
|
|
784
|
+
return v === null || v === "" || Array.isArray(v) && !v.length || v instanceof Map && !v.size;
|
|
785
|
+
}
|
|
786
|
+
function contentKey(row, notContent) {
|
|
787
|
+
return dumpsSorted(new Map([...row].filter(([k]) => !notContent.has(k))));
|
|
788
|
+
}
|
|
789
|
+
var Draft = class {
|
|
790
|
+
constructor(type, id, name2) {
|
|
791
|
+
this.type = type;
|
|
792
|
+
this.id = id;
|
|
793
|
+
this.name = name2;
|
|
794
|
+
this.hidden = false;
|
|
795
|
+
this.fields = /* @__PURE__ */ new Map();
|
|
796
|
+
this.ext = /* @__PURE__ */ new Map();
|
|
797
|
+
this.taken = /* @__PURE__ */ new Set();
|
|
798
|
+
this.mentions = [];
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var DoorCore = class {
|
|
802
|
+
constructor(prefix, namespace2, notes) {
|
|
803
|
+
this.prefix = prefix;
|
|
804
|
+
this.namespace = namespace2;
|
|
805
|
+
/** Element id -> the made-name kind of the name it was given. */
|
|
806
|
+
this.named = /* @__PURE__ */ new Map();
|
|
807
|
+
this.seen = /* @__PURE__ */ new Set();
|
|
808
|
+
this.findings = { unplaced: [], unresolved: [], folded: [], notes };
|
|
809
|
+
}
|
|
810
|
+
/** The door's id for a key: UUIDv5 in its namespace. */
|
|
811
|
+
id(key) {
|
|
812
|
+
return uuid5(this.namespace, key);
|
|
813
|
+
}
|
|
814
|
+
note(text) {
|
|
815
|
+
this.findings.notes.push(text);
|
|
816
|
+
}
|
|
817
|
+
unresolved(element, where, target, why) {
|
|
818
|
+
this.findings.unresolved.push({ element, where, target, why });
|
|
819
|
+
}
|
|
820
|
+
/** A key not placed, reported once for each element, key, reason and extension. */
|
|
821
|
+
unplaced(element, key, why, keptAs) {
|
|
822
|
+
const k = JSON.stringify([element, key, why, keptAs]);
|
|
823
|
+
if (this.seen.has(k)) return;
|
|
824
|
+
this.seen.add(k);
|
|
825
|
+
this.findings.unplaced.push({ element, key, why, keptAs });
|
|
826
|
+
}
|
|
827
|
+
/** Keep a value as `<prefix><key>` (`_2` and on when taken) and report it. */
|
|
828
|
+
keep(d, key, value, why) {
|
|
829
|
+
const base = `${this.prefix}${normKey(key) || "value"}`;
|
|
830
|
+
let ext = base;
|
|
831
|
+
for (let n = 2; d.taken.has(ext); n++) ext = `${base}_${n}`;
|
|
832
|
+
d.taken.add(ext);
|
|
833
|
+
d.ext.set(ext, value);
|
|
834
|
+
this.unplaced(d.name, key, why, ext);
|
|
835
|
+
}
|
|
836
|
+
/** One of the door's own extension keys, not reported (the door's docs name them). */
|
|
837
|
+
own(d, key, value) {
|
|
838
|
+
const ext = `${this.prefix}${key}`;
|
|
839
|
+
d.taken.add(ext);
|
|
840
|
+
d.ext.set(ext, value);
|
|
841
|
+
}
|
|
842
|
+
/** Exact copies kept once, the first in order; each fold reported with the element it was on and the copy's name. */
|
|
843
|
+
fold(what, rows, keyOf, elementOf, nameOf) {
|
|
844
|
+
const at = /* @__PURE__ */ new Map();
|
|
845
|
+
const kept = [];
|
|
846
|
+
const copies = [];
|
|
847
|
+
for (const row of rows) {
|
|
848
|
+
const key = keyOf(row);
|
|
849
|
+
const i = at.get(key);
|
|
850
|
+
if (i !== void 0) {
|
|
851
|
+
copies[i]++;
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
at.set(key, kept.length);
|
|
855
|
+
kept.push(row);
|
|
856
|
+
copies.push(1);
|
|
857
|
+
}
|
|
858
|
+
kept.forEach((row, i) => {
|
|
859
|
+
if (copies[i] > 1) this.findings.folded.push({ element: elementOf(row), what, name: nameOf(row), copies: copies[i] });
|
|
860
|
+
});
|
|
861
|
+
return kept;
|
|
862
|
+
}
|
|
863
|
+
/** An element's body: type, id, name, the hidden mark, fields in the schema's order, extensions, mentions. */
|
|
864
|
+
body(d) {
|
|
865
|
+
const body = /* @__PURE__ */ new Map([["type", d.type], ["id", d.id], ["name", d.name]]);
|
|
866
|
+
if (d.hidden) body.set("hidden", true);
|
|
867
|
+
for (const [f] of fieldsOf(d.type)) {
|
|
868
|
+
if (f !== "name" && d.fields.has(f)) body.set(f, d.fields.get(f));
|
|
869
|
+
}
|
|
870
|
+
for (const [k, v] of d.ext) body.set(k, v);
|
|
871
|
+
if (d.mentions.length) body.set(`${this.prefix}mentions`, d.mentions);
|
|
872
|
+
return body;
|
|
873
|
+
}
|
|
874
|
+
/** A Narrative's link to the element it came from: `parent_narrative` for a Narrative, else Narrative's field for the type. */
|
|
875
|
+
linkBack(fields, d) {
|
|
876
|
+
if (d.type === "narrative") fields.set("parent_narrative", d.id);
|
|
877
|
+
else {
|
|
878
|
+
const f = narrativeFieldFor(d.type);
|
|
879
|
+
if (f) fields.set(f, [d.id]);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
/** The made names counted over the elements written, in the declared order, a kind with none left out. */
|
|
883
|
+
madeNames(made, ids) {
|
|
884
|
+
const declared = new Set(made.map((m) => m.kind));
|
|
885
|
+
const tally = /* @__PURE__ */ new Map();
|
|
886
|
+
for (const id of ids) {
|
|
887
|
+
const kind = this.named.get(id);
|
|
888
|
+
if (kind === void 0) continue;
|
|
889
|
+
if (!declared.has(kind)) throw new Error(`a made name of kind '${kind}', which the door does not declare`);
|
|
890
|
+
tally.set(kind, (tally.get(kind) ?? 0) + 1);
|
|
891
|
+
}
|
|
892
|
+
const out = {};
|
|
893
|
+
for (const m of made) if (tally.has(m.kind)) out[m.kind] = tally.get(m.kind);
|
|
894
|
+
return out;
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
var SAID = {
|
|
898
|
+
joined: "joined: the export's words, ours between them",
|
|
899
|
+
ours: "ours: the export gives it no name"
|
|
900
|
+
};
|
|
901
|
+
function madeNameLines(made, counts) {
|
|
902
|
+
const total = Object.values(counts).reduce((a, b) => a + b, 0);
|
|
903
|
+
if (!total) return [];
|
|
904
|
+
const byKind = new Map(made.map((m) => [m.kind, m]));
|
|
905
|
+
const lines = [format("Names made by the import, not taken whole from the export ({n}), one line a kind:", { n: total })];
|
|
906
|
+
for (const [kind, n] of Object.entries(counts)) {
|
|
907
|
+
const m = byKind.get(kind);
|
|
908
|
+
const what = m.type === ANY_TYPE ? "any type" : m.type;
|
|
909
|
+
lines.push(format(" - {kind}, {what} {pattern!r}: {n} ({said})", { kind: m.kind, what, pattern: m.pattern, n, said: SAID[m.source] }));
|
|
910
|
+
}
|
|
911
|
+
return lines;
|
|
912
|
+
}
|
|
913
|
+
function worldOf(id, name2, description, producer, input) {
|
|
914
|
+
const world = /* @__PURE__ */ new Map([["id", id], ["name", name2]]);
|
|
915
|
+
if (description !== null) world.set("description", description);
|
|
916
|
+
world.set("format_version", FOLDER_FORMAT_VERSION);
|
|
917
|
+
const line = /* @__PURE__ */ new Map([["tool", producer.tool]]);
|
|
918
|
+
if (producer.version !== void 0) line.set("version", producer.version);
|
|
919
|
+
line.set("input", input);
|
|
920
|
+
world.set("producer", line);
|
|
921
|
+
return world;
|
|
922
|
+
}
|
|
923
|
+
function grouped(bodies) {
|
|
924
|
+
const out = /* @__PURE__ */ new Map();
|
|
925
|
+
for (const b of bodies) {
|
|
926
|
+
const t = b.get("type");
|
|
927
|
+
if (!out.has(t)) out.set(t, []);
|
|
928
|
+
out.get(t).push(b);
|
|
929
|
+
}
|
|
930
|
+
return out;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/convert/html-entities.generated.ts
|
|
934
|
+
var HTML5_ENTITIES = { "AElig": "\xC6", "AElig;": "\xC6", "AMP": "&", "AMP;": "&", "Aacute": "\xC1", "Aacute;": "\xC1", "Abreve;": "\u0102", "Acirc": "\xC2", "Acirc;": "\xC2", "Acy;": "\u0410", "Afr;": "\u{1D504}", "Agrave": "\xC0", "Agrave;": "\xC0", "Alpha;": "\u0391", "Amacr;": "\u0100", "And;": "\u2A53", "Aogon;": "\u0104", "Aopf;": "\u{1D538}", "ApplyFunction;": "\u2061", "Aring": "\xC5", "Aring;": "\xC5", "Ascr;": "\u{1D49C}", "Assign;": "\u2254", "Atilde": "\xC3", "Atilde;": "\xC3", "Auml": "\xC4", "Auml;": "\xC4", "Backslash;": "\u2216", "Barv;": "\u2AE7", "Barwed;": "\u2306", "Bcy;": "\u0411", "Because;": "\u2235", "Bernoullis;": "\u212C", "Beta;": "\u0392", "Bfr;": "\u{1D505}", "Bopf;": "\u{1D539}", "Breve;": "\u02D8", "Bscr;": "\u212C", "Bumpeq;": "\u224E", "CHcy;": "\u0427", "COPY": "\xA9", "COPY;": "\xA9", "Cacute;": "\u0106", "Cap;": "\u22D2", "CapitalDifferentialD;": "\u2145", "Cayleys;": "\u212D", "Ccaron;": "\u010C", "Ccedil": "\xC7", "Ccedil;": "\xC7", "Ccirc;": "\u0108", "Cconint;": "\u2230", "Cdot;": "\u010A", "Cedilla;": "\xB8", "CenterDot;": "\xB7", "Cfr;": "\u212D", "Chi;": "\u03A7", "CircleDot;": "\u2299", "CircleMinus;": "\u2296", "CirclePlus;": "\u2295", "CircleTimes;": "\u2297", "ClockwiseContourIntegral;": "\u2232", "CloseCurlyDoubleQuote;": "\u201D", "CloseCurlyQuote;": "\u2019", "Colon;": "\u2237", "Colone;": "\u2A74", "Congruent;": "\u2261", "Conint;": "\u222F", "ContourIntegral;": "\u222E", "Copf;": "\u2102", "Coproduct;": "\u2210", "CounterClockwiseContourIntegral;": "\u2233", "Cross;": "\u2A2F", "Cscr;": "\u{1D49E}", "Cup;": "\u22D3", "CupCap;": "\u224D", "DD;": "\u2145", "DDotrahd;": "\u2911", "DJcy;": "\u0402", "DScy;": "\u0405", "DZcy;": "\u040F", "Dagger;": "\u2021", "Darr;": "\u21A1", "Dashv;": "\u2AE4", "Dcaron;": "\u010E", "Dcy;": "\u0414", "Del;": "\u2207", "Delta;": "\u0394", "Dfr;": "\u{1D507}", "DiacriticalAcute;": "\xB4", "DiacriticalDot;": "\u02D9", "DiacriticalDoubleAcute;": "\u02DD", "DiacriticalGrave;": "`", "DiacriticalTilde;": "\u02DC", "Diamond;": "\u22C4", "DifferentialD;": "\u2146", "Dopf;": "\u{1D53B}", "Dot;": "\xA8", "DotDot;": "\u20DC", "DotEqual;": "\u2250", "DoubleContourIntegral;": "\u222F", "DoubleDot;": "\xA8", "DoubleDownArrow;": "\u21D3", "DoubleLeftArrow;": "\u21D0", "DoubleLeftRightArrow;": "\u21D4", "DoubleLeftTee;": "\u2AE4", "DoubleLongLeftArrow;": "\u27F8", "DoubleLongLeftRightArrow;": "\u27FA", "DoubleLongRightArrow;": "\u27F9", "DoubleRightArrow;": "\u21D2", "DoubleRightTee;": "\u22A8", "DoubleUpArrow;": "\u21D1", "DoubleUpDownArrow;": "\u21D5", "DoubleVerticalBar;": "\u2225", "DownArrow;": "\u2193", "DownArrowBar;": "\u2913", "DownArrowUpArrow;": "\u21F5", "DownBreve;": "\u0311", "DownLeftRightVector;": "\u2950", "DownLeftTeeVector;": "\u295E", "DownLeftVector;": "\u21BD", "DownLeftVectorBar;": "\u2956", "DownRightTeeVector;": "\u295F", "DownRightVector;": "\u21C1", "DownRightVectorBar;": "\u2957", "DownTee;": "\u22A4", "DownTeeArrow;": "\u21A7", "Downarrow;": "\u21D3", "Dscr;": "\u{1D49F}", "Dstrok;": "\u0110", "ENG;": "\u014A", "ETH": "\xD0", "ETH;": "\xD0", "Eacute": "\xC9", "Eacute;": "\xC9", "Ecaron;": "\u011A", "Ecirc": "\xCA", "Ecirc;": "\xCA", "Ecy;": "\u042D", "Edot;": "\u0116", "Efr;": "\u{1D508}", "Egrave": "\xC8", "Egrave;": "\xC8", "Element;": "\u2208", "Emacr;": "\u0112", "EmptySmallSquare;": "\u25FB", "EmptyVerySmallSquare;": "\u25AB", "Eogon;": "\u0118", "Eopf;": "\u{1D53C}", "Epsilon;": "\u0395", "Equal;": "\u2A75", "EqualTilde;": "\u2242", "Equilibrium;": "\u21CC", "Escr;": "\u2130", "Esim;": "\u2A73", "Eta;": "\u0397", "Euml": "\xCB", "Euml;": "\xCB", "Exists;": "\u2203", "ExponentialE;": "\u2147", "Fcy;": "\u0424", "Ffr;": "\u{1D509}", "FilledSmallSquare;": "\u25FC", "FilledVerySmallSquare;": "\u25AA", "Fopf;": "\u{1D53D}", "ForAll;": "\u2200", "Fouriertrf;": "\u2131", "Fscr;": "\u2131", "GJcy;": "\u0403", "GT": ">", "GT;": ">", "Gamma;": "\u0393", "Gammad;": "\u03DC", "Gbreve;": "\u011E", "Gcedil;": "\u0122", "Gcirc;": "\u011C", "Gcy;": "\u0413", "Gdot;": "\u0120", "Gfr;": "\u{1D50A}", "Gg;": "\u22D9", "Gopf;": "\u{1D53E}", "GreaterEqual;": "\u2265", "GreaterEqualLess;": "\u22DB", "GreaterFullEqual;": "\u2267", "GreaterGreater;": "\u2AA2", "GreaterLess;": "\u2277", "GreaterSlantEqual;": "\u2A7E", "GreaterTilde;": "\u2273", "Gscr;": "\u{1D4A2}", "Gt;": "\u226B", "HARDcy;": "\u042A", "Hacek;": "\u02C7", "Hat;": "^", "Hcirc;": "\u0124", "Hfr;": "\u210C", "HilbertSpace;": "\u210B", "Hopf;": "\u210D", "HorizontalLine;": "\u2500", "Hscr;": "\u210B", "Hstrok;": "\u0126", "HumpDownHump;": "\u224E", "HumpEqual;": "\u224F", "IEcy;": "\u0415", "IJlig;": "\u0132", "IOcy;": "\u0401", "Iacute": "\xCD", "Iacute;": "\xCD", "Icirc": "\xCE", "Icirc;": "\xCE", "Icy;": "\u0418", "Idot;": "\u0130", "Ifr;": "\u2111", "Igrave": "\xCC", "Igrave;": "\xCC", "Im;": "\u2111", "Imacr;": "\u012A", "ImaginaryI;": "\u2148", "Implies;": "\u21D2", "Int;": "\u222C", "Integral;": "\u222B", "Intersection;": "\u22C2", "InvisibleComma;": "\u2063", "InvisibleTimes;": "\u2062", "Iogon;": "\u012E", "Iopf;": "\u{1D540}", "Iota;": "\u0399", "Iscr;": "\u2110", "Itilde;": "\u0128", "Iukcy;": "\u0406", "Iuml": "\xCF", "Iuml;": "\xCF", "Jcirc;": "\u0134", "Jcy;": "\u0419", "Jfr;": "\u{1D50D}", "Jopf;": "\u{1D541}", "Jscr;": "\u{1D4A5}", "Jsercy;": "\u0408", "Jukcy;": "\u0404", "KHcy;": "\u0425", "KJcy;": "\u040C", "Kappa;": "\u039A", "Kcedil;": "\u0136", "Kcy;": "\u041A", "Kfr;": "\u{1D50E}", "Kopf;": "\u{1D542}", "Kscr;": "\u{1D4A6}", "LJcy;": "\u0409", "LT": "<", "LT;": "<", "Lacute;": "\u0139", "Lambda;": "\u039B", "Lang;": "\u27EA", "Laplacetrf;": "\u2112", "Larr;": "\u219E", "Lcaron;": "\u013D", "Lcedil;": "\u013B", "Lcy;": "\u041B", "LeftAngleBracket;": "\u27E8", "LeftArrow;": "\u2190", "LeftArrowBar;": "\u21E4", "LeftArrowRightArrow;": "\u21C6", "LeftCeiling;": "\u2308", "LeftDoubleBracket;": "\u27E6", "LeftDownTeeVector;": "\u2961", "LeftDownVector;": "\u21C3", "LeftDownVectorBar;": "\u2959", "LeftFloor;": "\u230A", "LeftRightArrow;": "\u2194", "LeftRightVector;": "\u294E", "LeftTee;": "\u22A3", "LeftTeeArrow;": "\u21A4", "LeftTeeVector;": "\u295A", "LeftTriangle;": "\u22B2", "LeftTriangleBar;": "\u29CF", "LeftTriangleEqual;": "\u22B4", "LeftUpDownVector;": "\u2951", "LeftUpTeeVector;": "\u2960", "LeftUpVector;": "\u21BF", "LeftUpVectorBar;": "\u2958", "LeftVector;": "\u21BC", "LeftVectorBar;": "\u2952", "Leftarrow;": "\u21D0", "Leftrightarrow;": "\u21D4", "LessEqualGreater;": "\u22DA", "LessFullEqual;": "\u2266", "LessGreater;": "\u2276", "LessLess;": "\u2AA1", "LessSlantEqual;": "\u2A7D", "LessTilde;": "\u2272", "Lfr;": "\u{1D50F}", "Ll;": "\u22D8", "Lleftarrow;": "\u21DA", "Lmidot;": "\u013F", "LongLeftArrow;": "\u27F5", "LongLeftRightArrow;": "\u27F7", "LongRightArrow;": "\u27F6", "Longleftarrow;": "\u27F8", "Longleftrightarrow;": "\u27FA", "Longrightarrow;": "\u27F9", "Lopf;": "\u{1D543}", "LowerLeftArrow;": "\u2199", "LowerRightArrow;": "\u2198", "Lscr;": "\u2112", "Lsh;": "\u21B0", "Lstrok;": "\u0141", "Lt;": "\u226A", "Map;": "\u2905", "Mcy;": "\u041C", "MediumSpace;": "\u205F", "Mellintrf;": "\u2133", "Mfr;": "\u{1D510}", "MinusPlus;": "\u2213", "Mopf;": "\u{1D544}", "Mscr;": "\u2133", "Mu;": "\u039C", "NJcy;": "\u040A", "Nacute;": "\u0143", "Ncaron;": "\u0147", "Ncedil;": "\u0145", "Ncy;": "\u041D", "NegativeMediumSpace;": "\u200B", "NegativeThickSpace;": "\u200B", "NegativeThinSpace;": "\u200B", "NegativeVeryThinSpace;": "\u200B", "NestedGreaterGreater;": "\u226B", "NestedLessLess;": "\u226A", "NewLine;": "\n", "Nfr;": "\u{1D511}", "NoBreak;": "\u2060", "NonBreakingSpace;": "\xA0", "Nopf;": "\u2115", "Not;": "\u2AEC", "NotCongruent;": "\u2262", "NotCupCap;": "\u226D", "NotDoubleVerticalBar;": "\u2226", "NotElement;": "\u2209", "NotEqual;": "\u2260", "NotEqualTilde;": "\u2242\u0338", "NotExists;": "\u2204", "NotGreater;": "\u226F", "NotGreaterEqual;": "\u2271", "NotGreaterFullEqual;": "\u2267\u0338", "NotGreaterGreater;": "\u226B\u0338", "NotGreaterLess;": "\u2279", "NotGreaterSlantEqual;": "\u2A7E\u0338", "NotGreaterTilde;": "\u2275", "NotHumpDownHump;": "\u224E\u0338", "NotHumpEqual;": "\u224F\u0338", "NotLeftTriangle;": "\u22EA", "NotLeftTriangleBar;": "\u29CF\u0338", "NotLeftTriangleEqual;": "\u22EC", "NotLess;": "\u226E", "NotLessEqual;": "\u2270", "NotLessGreater;": "\u2278", "NotLessLess;": "\u226A\u0338", "NotLessSlantEqual;": "\u2A7D\u0338", "NotLessTilde;": "\u2274", "NotNestedGreaterGreater;": "\u2AA2\u0338", "NotNestedLessLess;": "\u2AA1\u0338", "NotPrecedes;": "\u2280", "NotPrecedesEqual;": "\u2AAF\u0338", "NotPrecedesSlantEqual;": "\u22E0", "NotReverseElement;": "\u220C", "NotRightTriangle;": "\u22EB", "NotRightTriangleBar;": "\u29D0\u0338", "NotRightTriangleEqual;": "\u22ED", "NotSquareSubset;": "\u228F\u0338", "NotSquareSubsetEqual;": "\u22E2", "NotSquareSuperset;": "\u2290\u0338", "NotSquareSupersetEqual;": "\u22E3", "NotSubset;": "\u2282\u20D2", "NotSubsetEqual;": "\u2288", "NotSucceeds;": "\u2281", "NotSucceedsEqual;": "\u2AB0\u0338", "NotSucceedsSlantEqual;": "\u22E1", "NotSucceedsTilde;": "\u227F\u0338", "NotSuperset;": "\u2283\u20D2", "NotSupersetEqual;": "\u2289", "NotTilde;": "\u2241", "NotTildeEqual;": "\u2244", "NotTildeFullEqual;": "\u2247", "NotTildeTilde;": "\u2249", "NotVerticalBar;": "\u2224", "Nscr;": "\u{1D4A9}", "Ntilde": "\xD1", "Ntilde;": "\xD1", "Nu;": "\u039D", "OElig;": "\u0152", "Oacute": "\xD3", "Oacute;": "\xD3", "Ocirc": "\xD4", "Ocirc;": "\xD4", "Ocy;": "\u041E", "Odblac;": "\u0150", "Ofr;": "\u{1D512}", "Ograve": "\xD2", "Ograve;": "\xD2", "Omacr;": "\u014C", "Omega;": "\u03A9", "Omicron;": "\u039F", "Oopf;": "\u{1D546}", "OpenCurlyDoubleQuote;": "\u201C", "OpenCurlyQuote;": "\u2018", "Or;": "\u2A54", "Oscr;": "\u{1D4AA}", "Oslash": "\xD8", "Oslash;": "\xD8", "Otilde": "\xD5", "Otilde;": "\xD5", "Otimes;": "\u2A37", "Ouml": "\xD6", "Ouml;": "\xD6", "OverBar;": "\u203E", "OverBrace;": "\u23DE", "OverBracket;": "\u23B4", "OverParenthesis;": "\u23DC", "PartialD;": "\u2202", "Pcy;": "\u041F", "Pfr;": "\u{1D513}", "Phi;": "\u03A6", "Pi;": "\u03A0", "PlusMinus;": "\xB1", "Poincareplane;": "\u210C", "Popf;": "\u2119", "Pr;": "\u2ABB", "Precedes;": "\u227A", "PrecedesEqual;": "\u2AAF", "PrecedesSlantEqual;": "\u227C", "PrecedesTilde;": "\u227E", "Prime;": "\u2033", "Product;": "\u220F", "Proportion;": "\u2237", "Proportional;": "\u221D", "Pscr;": "\u{1D4AB}", "Psi;": "\u03A8", "QUOT": '"', "QUOT;": '"', "Qfr;": "\u{1D514}", "Qopf;": "\u211A", "Qscr;": "\u{1D4AC}", "RBarr;": "\u2910", "REG": "\xAE", "REG;": "\xAE", "Racute;": "\u0154", "Rang;": "\u27EB", "Rarr;": "\u21A0", "Rarrtl;": "\u2916", "Rcaron;": "\u0158", "Rcedil;": "\u0156", "Rcy;": "\u0420", "Re;": "\u211C", "ReverseElement;": "\u220B", "ReverseEquilibrium;": "\u21CB", "ReverseUpEquilibrium;": "\u296F", "Rfr;": "\u211C", "Rho;": "\u03A1", "RightAngleBracket;": "\u27E9", "RightArrow;": "\u2192", "RightArrowBar;": "\u21E5", "RightArrowLeftArrow;": "\u21C4", "RightCeiling;": "\u2309", "RightDoubleBracket;": "\u27E7", "RightDownTeeVector;": "\u295D", "RightDownVector;": "\u21C2", "RightDownVectorBar;": "\u2955", "RightFloor;": "\u230B", "RightTee;": "\u22A2", "RightTeeArrow;": "\u21A6", "RightTeeVector;": "\u295B", "RightTriangle;": "\u22B3", "RightTriangleBar;": "\u29D0", "RightTriangleEqual;": "\u22B5", "RightUpDownVector;": "\u294F", "RightUpTeeVector;": "\u295C", "RightUpVector;": "\u21BE", "RightUpVectorBar;": "\u2954", "RightVector;": "\u21C0", "RightVectorBar;": "\u2953", "Rightarrow;": "\u21D2", "Ropf;": "\u211D", "RoundImplies;": "\u2970", "Rrightarrow;": "\u21DB", "Rscr;": "\u211B", "Rsh;": "\u21B1", "RuleDelayed;": "\u29F4", "SHCHcy;": "\u0429", "SHcy;": "\u0428", "SOFTcy;": "\u042C", "Sacute;": "\u015A", "Sc;": "\u2ABC", "Scaron;": "\u0160", "Scedil;": "\u015E", "Scirc;": "\u015C", "Scy;": "\u0421", "Sfr;": "\u{1D516}", "ShortDownArrow;": "\u2193", "ShortLeftArrow;": "\u2190", "ShortRightArrow;": "\u2192", "ShortUpArrow;": "\u2191", "Sigma;": "\u03A3", "SmallCircle;": "\u2218", "Sopf;": "\u{1D54A}", "Sqrt;": "\u221A", "Square;": "\u25A1", "SquareIntersection;": "\u2293", "SquareSubset;": "\u228F", "SquareSubsetEqual;": "\u2291", "SquareSuperset;": "\u2290", "SquareSupersetEqual;": "\u2292", "SquareUnion;": "\u2294", "Sscr;": "\u{1D4AE}", "Star;": "\u22C6", "Sub;": "\u22D0", "Subset;": "\u22D0", "SubsetEqual;": "\u2286", "Succeeds;": "\u227B", "SucceedsEqual;": "\u2AB0", "SucceedsSlantEqual;": "\u227D", "SucceedsTilde;": "\u227F", "SuchThat;": "\u220B", "Sum;": "\u2211", "Sup;": "\u22D1", "Superset;": "\u2283", "SupersetEqual;": "\u2287", "Supset;": "\u22D1", "THORN": "\xDE", "THORN;": "\xDE", "TRADE;": "\u2122", "TSHcy;": "\u040B", "TScy;": "\u0426", "Tab;": " ", "Tau;": "\u03A4", "Tcaron;": "\u0164", "Tcedil;": "\u0162", "Tcy;": "\u0422", "Tfr;": "\u{1D517}", "Therefore;": "\u2234", "Theta;": "\u0398", "ThickSpace;": "\u205F\u200A", "ThinSpace;": "\u2009", "Tilde;": "\u223C", "TildeEqual;": "\u2243", "TildeFullEqual;": "\u2245", "TildeTilde;": "\u2248", "Topf;": "\u{1D54B}", "TripleDot;": "\u20DB", "Tscr;": "\u{1D4AF}", "Tstrok;": "\u0166", "Uacute": "\xDA", "Uacute;": "\xDA", "Uarr;": "\u219F", "Uarrocir;": "\u2949", "Ubrcy;": "\u040E", "Ubreve;": "\u016C", "Ucirc": "\xDB", "Ucirc;": "\xDB", "Ucy;": "\u0423", "Udblac;": "\u0170", "Ufr;": "\u{1D518}", "Ugrave": "\xD9", "Ugrave;": "\xD9", "Umacr;": "\u016A", "UnderBar;": "_", "UnderBrace;": "\u23DF", "UnderBracket;": "\u23B5", "UnderParenthesis;": "\u23DD", "Union;": "\u22C3", "UnionPlus;": "\u228E", "Uogon;": "\u0172", "Uopf;": "\u{1D54C}", "UpArrow;": "\u2191", "UpArrowBar;": "\u2912", "UpArrowDownArrow;": "\u21C5", "UpDownArrow;": "\u2195", "UpEquilibrium;": "\u296E", "UpTee;": "\u22A5", "UpTeeArrow;": "\u21A5", "Uparrow;": "\u21D1", "Updownarrow;": "\u21D5", "UpperLeftArrow;": "\u2196", "UpperRightArrow;": "\u2197", "Upsi;": "\u03D2", "Upsilon;": "\u03A5", "Uring;": "\u016E", "Uscr;": "\u{1D4B0}", "Utilde;": "\u0168", "Uuml": "\xDC", "Uuml;": "\xDC", "VDash;": "\u22AB", "Vbar;": "\u2AEB", "Vcy;": "\u0412", "Vdash;": "\u22A9", "Vdashl;": "\u2AE6", "Vee;": "\u22C1", "Verbar;": "\u2016", "Vert;": "\u2016", "VerticalBar;": "\u2223", "VerticalLine;": "|", "VerticalSeparator;": "\u2758", "VerticalTilde;": "\u2240", "VeryThinSpace;": "\u200A", "Vfr;": "\u{1D519}", "Vopf;": "\u{1D54D}", "Vscr;": "\u{1D4B1}", "Vvdash;": "\u22AA", "Wcirc;": "\u0174", "Wedge;": "\u22C0", "Wfr;": "\u{1D51A}", "Wopf;": "\u{1D54E}", "Wscr;": "\u{1D4B2}", "Xfr;": "\u{1D51B}", "Xi;": "\u039E", "Xopf;": "\u{1D54F}", "Xscr;": "\u{1D4B3}", "YAcy;": "\u042F", "YIcy;": "\u0407", "YUcy;": "\u042E", "Yacute": "\xDD", "Yacute;": "\xDD", "Ycirc;": "\u0176", "Ycy;": "\u042B", "Yfr;": "\u{1D51C}", "Yopf;": "\u{1D550}", "Yscr;": "\u{1D4B4}", "Yuml;": "\u0178", "ZHcy;": "\u0416", "Zacute;": "\u0179", "Zcaron;": "\u017D", "Zcy;": "\u0417", "Zdot;": "\u017B", "ZeroWidthSpace;": "\u200B", "Zeta;": "\u0396", "Zfr;": "\u2128", "Zopf;": "\u2124", "Zscr;": "\u{1D4B5}", "aacute": "\xE1", "aacute;": "\xE1", "abreve;": "\u0103", "ac;": "\u223E", "acE;": "\u223E\u0333", "acd;": "\u223F", "acirc": "\xE2", "acirc;": "\xE2", "acute": "\xB4", "acute;": "\xB4", "acy;": "\u0430", "aelig": "\xE6", "aelig;": "\xE6", "af;": "\u2061", "afr;": "\u{1D51E}", "agrave": "\xE0", "agrave;": "\xE0", "alefsym;": "\u2135", "aleph;": "\u2135", "alpha;": "\u03B1", "amacr;": "\u0101", "amalg;": "\u2A3F", "amp": "&", "amp;": "&", "and;": "\u2227", "andand;": "\u2A55", "andd;": "\u2A5C", "andslope;": "\u2A58", "andv;": "\u2A5A", "ang;": "\u2220", "ange;": "\u29A4", "angle;": "\u2220", "angmsd;": "\u2221", "angmsdaa;": "\u29A8", "angmsdab;": "\u29A9", "angmsdac;": "\u29AA", "angmsdad;": "\u29AB", "angmsdae;": "\u29AC", "angmsdaf;": "\u29AD", "angmsdag;": "\u29AE", "angmsdah;": "\u29AF", "angrt;": "\u221F", "angrtvb;": "\u22BE", "angrtvbd;": "\u299D", "angsph;": "\u2222", "angst;": "\xC5", "angzarr;": "\u237C", "aogon;": "\u0105", "aopf;": "\u{1D552}", "ap;": "\u2248", "apE;": "\u2A70", "apacir;": "\u2A6F", "ape;": "\u224A", "apid;": "\u224B", "apos;": "'", "approx;": "\u2248", "approxeq;": "\u224A", "aring": "\xE5", "aring;": "\xE5", "ascr;": "\u{1D4B6}", "ast;": "*", "asymp;": "\u2248", "asympeq;": "\u224D", "atilde": "\xE3", "atilde;": "\xE3", "auml": "\xE4", "auml;": "\xE4", "awconint;": "\u2233", "awint;": "\u2A11", "bNot;": "\u2AED", "backcong;": "\u224C", "backepsilon;": "\u03F6", "backprime;": "\u2035", "backsim;": "\u223D", "backsimeq;": "\u22CD", "barvee;": "\u22BD", "barwed;": "\u2305", "barwedge;": "\u2305", "bbrk;": "\u23B5", "bbrktbrk;": "\u23B6", "bcong;": "\u224C", "bcy;": "\u0431", "bdquo;": "\u201E", "becaus;": "\u2235", "because;": "\u2235", "bemptyv;": "\u29B0", "bepsi;": "\u03F6", "bernou;": "\u212C", "beta;": "\u03B2", "beth;": "\u2136", "between;": "\u226C", "bfr;": "\u{1D51F}", "bigcap;": "\u22C2", "bigcirc;": "\u25EF", "bigcup;": "\u22C3", "bigodot;": "\u2A00", "bigoplus;": "\u2A01", "bigotimes;": "\u2A02", "bigsqcup;": "\u2A06", "bigstar;": "\u2605", "bigtriangledown;": "\u25BD", "bigtriangleup;": "\u25B3", "biguplus;": "\u2A04", "bigvee;": "\u22C1", "bigwedge;": "\u22C0", "bkarow;": "\u290D", "blacklozenge;": "\u29EB", "blacksquare;": "\u25AA", "blacktriangle;": "\u25B4", "blacktriangledown;": "\u25BE", "blacktriangleleft;": "\u25C2", "blacktriangleright;": "\u25B8", "blank;": "\u2423", "blk12;": "\u2592", "blk14;": "\u2591", "blk34;": "\u2593", "block;": "\u2588", "bne;": "=\u20E5", "bnequiv;": "\u2261\u20E5", "bnot;": "\u2310", "bopf;": "\u{1D553}", "bot;": "\u22A5", "bottom;": "\u22A5", "bowtie;": "\u22C8", "boxDL;": "\u2557", "boxDR;": "\u2554", "boxDl;": "\u2556", "boxDr;": "\u2553", "boxH;": "\u2550", "boxHD;": "\u2566", "boxHU;": "\u2569", "boxHd;": "\u2564", "boxHu;": "\u2567", "boxUL;": "\u255D", "boxUR;": "\u255A", "boxUl;": "\u255C", "boxUr;": "\u2559", "boxV;": "\u2551", "boxVH;": "\u256C", "boxVL;": "\u2563", "boxVR;": "\u2560", "boxVh;": "\u256B", "boxVl;": "\u2562", "boxVr;": "\u255F", "boxbox;": "\u29C9", "boxdL;": "\u2555", "boxdR;": "\u2552", "boxdl;": "\u2510", "boxdr;": "\u250C", "boxh;": "\u2500", "boxhD;": "\u2565", "boxhU;": "\u2568", "boxhd;": "\u252C", "boxhu;": "\u2534", "boxminus;": "\u229F", "boxplus;": "\u229E", "boxtimes;": "\u22A0", "boxuL;": "\u255B", "boxuR;": "\u2558", "boxul;": "\u2518", "boxur;": "\u2514", "boxv;": "\u2502", "boxvH;": "\u256A", "boxvL;": "\u2561", "boxvR;": "\u255E", "boxvh;": "\u253C", "boxvl;": "\u2524", "boxvr;": "\u251C", "bprime;": "\u2035", "breve;": "\u02D8", "brvbar": "\xA6", "brvbar;": "\xA6", "bscr;": "\u{1D4B7}", "bsemi;": "\u204F", "bsim;": "\u223D", "bsime;": "\u22CD", "bsol;": "\\", "bsolb;": "\u29C5", "bsolhsub;": "\u27C8", "bull;": "\u2022", "bullet;": "\u2022", "bump;": "\u224E", "bumpE;": "\u2AAE", "bumpe;": "\u224F", "bumpeq;": "\u224F", "cacute;": "\u0107", "cap;": "\u2229", "capand;": "\u2A44", "capbrcup;": "\u2A49", "capcap;": "\u2A4B", "capcup;": "\u2A47", "capdot;": "\u2A40", "caps;": "\u2229\uFE00", "caret;": "\u2041", "caron;": "\u02C7", "ccaps;": "\u2A4D", "ccaron;": "\u010D", "ccedil": "\xE7", "ccedil;": "\xE7", "ccirc;": "\u0109", "ccups;": "\u2A4C", "ccupssm;": "\u2A50", "cdot;": "\u010B", "cedil": "\xB8", "cedil;": "\xB8", "cemptyv;": "\u29B2", "cent": "\xA2", "cent;": "\xA2", "centerdot;": "\xB7", "cfr;": "\u{1D520}", "chcy;": "\u0447", "check;": "\u2713", "checkmark;": "\u2713", "chi;": "\u03C7", "cir;": "\u25CB", "cirE;": "\u29C3", "circ;": "\u02C6", "circeq;": "\u2257", "circlearrowleft;": "\u21BA", "circlearrowright;": "\u21BB", "circledR;": "\xAE", "circledS;": "\u24C8", "circledast;": "\u229B", "circledcirc;": "\u229A", "circleddash;": "\u229D", "cire;": "\u2257", "cirfnint;": "\u2A10", "cirmid;": "\u2AEF", "cirscir;": "\u29C2", "clubs;": "\u2663", "clubsuit;": "\u2663", "colon;": ":", "colone;": "\u2254", "coloneq;": "\u2254", "comma;": ",", "commat;": "@", "comp;": "\u2201", "compfn;": "\u2218", "complement;": "\u2201", "complexes;": "\u2102", "cong;": "\u2245", "congdot;": "\u2A6D", "conint;": "\u222E", "copf;": "\u{1D554}", "coprod;": "\u2210", "copy": "\xA9", "copy;": "\xA9", "copysr;": "\u2117", "crarr;": "\u21B5", "cross;": "\u2717", "cscr;": "\u{1D4B8}", "csub;": "\u2ACF", "csube;": "\u2AD1", "csup;": "\u2AD0", "csupe;": "\u2AD2", "ctdot;": "\u22EF", "cudarrl;": "\u2938", "cudarrr;": "\u2935", "cuepr;": "\u22DE", "cuesc;": "\u22DF", "cularr;": "\u21B6", "cularrp;": "\u293D", "cup;": "\u222A", "cupbrcap;": "\u2A48", "cupcap;": "\u2A46", "cupcup;": "\u2A4A", "cupdot;": "\u228D", "cupor;": "\u2A45", "cups;": "\u222A\uFE00", "curarr;": "\u21B7", "curarrm;": "\u293C", "curlyeqprec;": "\u22DE", "curlyeqsucc;": "\u22DF", "curlyvee;": "\u22CE", "curlywedge;": "\u22CF", "curren": "\xA4", "curren;": "\xA4", "curvearrowleft;": "\u21B6", "curvearrowright;": "\u21B7", "cuvee;": "\u22CE", "cuwed;": "\u22CF", "cwconint;": "\u2232", "cwint;": "\u2231", "cylcty;": "\u232D", "dArr;": "\u21D3", "dHar;": "\u2965", "dagger;": "\u2020", "daleth;": "\u2138", "darr;": "\u2193", "dash;": "\u2010", "dashv;": "\u22A3", "dbkarow;": "\u290F", "dblac;": "\u02DD", "dcaron;": "\u010F", "dcy;": "\u0434", "dd;": "\u2146", "ddagger;": "\u2021", "ddarr;": "\u21CA", "ddotseq;": "\u2A77", "deg": "\xB0", "deg;": "\xB0", "delta;": "\u03B4", "demptyv;": "\u29B1", "dfisht;": "\u297F", "dfr;": "\u{1D521}", "dharl;": "\u21C3", "dharr;": "\u21C2", "diam;": "\u22C4", "diamond;": "\u22C4", "diamondsuit;": "\u2666", "diams;": "\u2666", "die;": "\xA8", "digamma;": "\u03DD", "disin;": "\u22F2", "div;": "\xF7", "divide": "\xF7", "divide;": "\xF7", "divideontimes;": "\u22C7", "divonx;": "\u22C7", "djcy;": "\u0452", "dlcorn;": "\u231E", "dlcrop;": "\u230D", "dollar;": "$", "dopf;": "\u{1D555}", "dot;": "\u02D9", "doteq;": "\u2250", "doteqdot;": "\u2251", "dotminus;": "\u2238", "dotplus;": "\u2214", "dotsquare;": "\u22A1", "doublebarwedge;": "\u2306", "downarrow;": "\u2193", "downdownarrows;": "\u21CA", "downharpoonleft;": "\u21C3", "downharpoonright;": "\u21C2", "drbkarow;": "\u2910", "drcorn;": "\u231F", "drcrop;": "\u230C", "dscr;": "\u{1D4B9}", "dscy;": "\u0455", "dsol;": "\u29F6", "dstrok;": "\u0111", "dtdot;": "\u22F1", "dtri;": "\u25BF", "dtrif;": "\u25BE", "duarr;": "\u21F5", "duhar;": "\u296F", "dwangle;": "\u29A6", "dzcy;": "\u045F", "dzigrarr;": "\u27FF", "eDDot;": "\u2A77", "eDot;": "\u2251", "eacute": "\xE9", "eacute;": "\xE9", "easter;": "\u2A6E", "ecaron;": "\u011B", "ecir;": "\u2256", "ecirc": "\xEA", "ecirc;": "\xEA", "ecolon;": "\u2255", "ecy;": "\u044D", "edot;": "\u0117", "ee;": "\u2147", "efDot;": "\u2252", "efr;": "\u{1D522}", "eg;": "\u2A9A", "egrave": "\xE8", "egrave;": "\xE8", "egs;": "\u2A96", "egsdot;": "\u2A98", "el;": "\u2A99", "elinters;": "\u23E7", "ell;": "\u2113", "els;": "\u2A95", "elsdot;": "\u2A97", "emacr;": "\u0113", "empty;": "\u2205", "emptyset;": "\u2205", "emptyv;": "\u2205", "emsp13;": "\u2004", "emsp14;": "\u2005", "emsp;": "\u2003", "eng;": "\u014B", "ensp;": "\u2002", "eogon;": "\u0119", "eopf;": "\u{1D556}", "epar;": "\u22D5", "eparsl;": "\u29E3", "eplus;": "\u2A71", "epsi;": "\u03B5", "epsilon;": "\u03B5", "epsiv;": "\u03F5", "eqcirc;": "\u2256", "eqcolon;": "\u2255", "eqsim;": "\u2242", "eqslantgtr;": "\u2A96", "eqslantless;": "\u2A95", "equals;": "=", "equest;": "\u225F", "equiv;": "\u2261", "equivDD;": "\u2A78", "eqvparsl;": "\u29E5", "erDot;": "\u2253", "erarr;": "\u2971", "escr;": "\u212F", "esdot;": "\u2250", "esim;": "\u2242", "eta;": "\u03B7", "eth": "\xF0", "eth;": "\xF0", "euml": "\xEB", "euml;": "\xEB", "euro;": "\u20AC", "excl;": "!", "exist;": "\u2203", "expectation;": "\u2130", "exponentiale;": "\u2147", "fallingdotseq;": "\u2252", "fcy;": "\u0444", "female;": "\u2640", "ffilig;": "\uFB03", "fflig;": "\uFB00", "ffllig;": "\uFB04", "ffr;": "\u{1D523}", "filig;": "\uFB01", "fjlig;": "fj", "flat;": "\u266D", "fllig;": "\uFB02", "fltns;": "\u25B1", "fnof;": "\u0192", "fopf;": "\u{1D557}", "forall;": "\u2200", "fork;": "\u22D4", "forkv;": "\u2AD9", "fpartint;": "\u2A0D", "frac12": "\xBD", "frac12;": "\xBD", "frac13;": "\u2153", "frac14": "\xBC", "frac14;": "\xBC", "frac15;": "\u2155", "frac16;": "\u2159", "frac18;": "\u215B", "frac23;": "\u2154", "frac25;": "\u2156", "frac34": "\xBE", "frac34;": "\xBE", "frac35;": "\u2157", "frac38;": "\u215C", "frac45;": "\u2158", "frac56;": "\u215A", "frac58;": "\u215D", "frac78;": "\u215E", "frasl;": "\u2044", "frown;": "\u2322", "fscr;": "\u{1D4BB}", "gE;": "\u2267", "gEl;": "\u2A8C", "gacute;": "\u01F5", "gamma;": "\u03B3", "gammad;": "\u03DD", "gap;": "\u2A86", "gbreve;": "\u011F", "gcirc;": "\u011D", "gcy;": "\u0433", "gdot;": "\u0121", "ge;": "\u2265", "gel;": "\u22DB", "geq;": "\u2265", "geqq;": "\u2267", "geqslant;": "\u2A7E", "ges;": "\u2A7E", "gescc;": "\u2AA9", "gesdot;": "\u2A80", "gesdoto;": "\u2A82", "gesdotol;": "\u2A84", "gesl;": "\u22DB\uFE00", "gesles;": "\u2A94", "gfr;": "\u{1D524}", "gg;": "\u226B", "ggg;": "\u22D9", "gimel;": "\u2137", "gjcy;": "\u0453", "gl;": "\u2277", "glE;": "\u2A92", "gla;": "\u2AA5", "glj;": "\u2AA4", "gnE;": "\u2269", "gnap;": "\u2A8A", "gnapprox;": "\u2A8A", "gne;": "\u2A88", "gneq;": "\u2A88", "gneqq;": "\u2269", "gnsim;": "\u22E7", "gopf;": "\u{1D558}", "grave;": "`", "gscr;": "\u210A", "gsim;": "\u2273", "gsime;": "\u2A8E", "gsiml;": "\u2A90", "gt": ">", "gt;": ">", "gtcc;": "\u2AA7", "gtcir;": "\u2A7A", "gtdot;": "\u22D7", "gtlPar;": "\u2995", "gtquest;": "\u2A7C", "gtrapprox;": "\u2A86", "gtrarr;": "\u2978", "gtrdot;": "\u22D7", "gtreqless;": "\u22DB", "gtreqqless;": "\u2A8C", "gtrless;": "\u2277", "gtrsim;": "\u2273", "gvertneqq;": "\u2269\uFE00", "gvnE;": "\u2269\uFE00", "hArr;": "\u21D4", "hairsp;": "\u200A", "half;": "\xBD", "hamilt;": "\u210B", "hardcy;": "\u044A", "harr;": "\u2194", "harrcir;": "\u2948", "harrw;": "\u21AD", "hbar;": "\u210F", "hcirc;": "\u0125", "hearts;": "\u2665", "heartsuit;": "\u2665", "hellip;": "\u2026", "hercon;": "\u22B9", "hfr;": "\u{1D525}", "hksearow;": "\u2925", "hkswarow;": "\u2926", "hoarr;": "\u21FF", "homtht;": "\u223B", "hookleftarrow;": "\u21A9", "hookrightarrow;": "\u21AA", "hopf;": "\u{1D559}", "horbar;": "\u2015", "hscr;": "\u{1D4BD}", "hslash;": "\u210F", "hstrok;": "\u0127", "hybull;": "\u2043", "hyphen;": "\u2010", "iacute": "\xED", "iacute;": "\xED", "ic;": "\u2063", "icirc": "\xEE", "icirc;": "\xEE", "icy;": "\u0438", "iecy;": "\u0435", "iexcl": "\xA1", "iexcl;": "\xA1", "iff;": "\u21D4", "ifr;": "\u{1D526}", "igrave": "\xEC", "igrave;": "\xEC", "ii;": "\u2148", "iiiint;": "\u2A0C", "iiint;": "\u222D", "iinfin;": "\u29DC", "iiota;": "\u2129", "ijlig;": "\u0133", "imacr;": "\u012B", "image;": "\u2111", "imagline;": "\u2110", "imagpart;": "\u2111", "imath;": "\u0131", "imof;": "\u22B7", "imped;": "\u01B5", "in;": "\u2208", "incare;": "\u2105", "infin;": "\u221E", "infintie;": "\u29DD", "inodot;": "\u0131", "int;": "\u222B", "intcal;": "\u22BA", "integers;": "\u2124", "intercal;": "\u22BA", "intlarhk;": "\u2A17", "intprod;": "\u2A3C", "iocy;": "\u0451", "iogon;": "\u012F", "iopf;": "\u{1D55A}", "iota;": "\u03B9", "iprod;": "\u2A3C", "iquest": "\xBF", "iquest;": "\xBF", "iscr;": "\u{1D4BE}", "isin;": "\u2208", "isinE;": "\u22F9", "isindot;": "\u22F5", "isins;": "\u22F4", "isinsv;": "\u22F3", "isinv;": "\u2208", "it;": "\u2062", "itilde;": "\u0129", "iukcy;": "\u0456", "iuml": "\xEF", "iuml;": "\xEF", "jcirc;": "\u0135", "jcy;": "\u0439", "jfr;": "\u{1D527}", "jmath;": "\u0237", "jopf;": "\u{1D55B}", "jscr;": "\u{1D4BF}", "jsercy;": "\u0458", "jukcy;": "\u0454", "kappa;": "\u03BA", "kappav;": "\u03F0", "kcedil;": "\u0137", "kcy;": "\u043A", "kfr;": "\u{1D528}", "kgreen;": "\u0138", "khcy;": "\u0445", "kjcy;": "\u045C", "kopf;": "\u{1D55C}", "kscr;": "\u{1D4C0}", "lAarr;": "\u21DA", "lArr;": "\u21D0", "lAtail;": "\u291B", "lBarr;": "\u290E", "lE;": "\u2266", "lEg;": "\u2A8B", "lHar;": "\u2962", "lacute;": "\u013A", "laemptyv;": "\u29B4", "lagran;": "\u2112", "lambda;": "\u03BB", "lang;": "\u27E8", "langd;": "\u2991", "langle;": "\u27E8", "lap;": "\u2A85", "laquo": "\xAB", "laquo;": "\xAB", "larr;": "\u2190", "larrb;": "\u21E4", "larrbfs;": "\u291F", "larrfs;": "\u291D", "larrhk;": "\u21A9", "larrlp;": "\u21AB", "larrpl;": "\u2939", "larrsim;": "\u2973", "larrtl;": "\u21A2", "lat;": "\u2AAB", "latail;": "\u2919", "late;": "\u2AAD", "lates;": "\u2AAD\uFE00", "lbarr;": "\u290C", "lbbrk;": "\u2772", "lbrace;": "{", "lbrack;": "[", "lbrke;": "\u298B", "lbrksld;": "\u298F", "lbrkslu;": "\u298D", "lcaron;": "\u013E", "lcedil;": "\u013C", "lceil;": "\u2308", "lcub;": "{", "lcy;": "\u043B", "ldca;": "\u2936", "ldquo;": "\u201C", "ldquor;": "\u201E", "ldrdhar;": "\u2967", "ldrushar;": "\u294B", "ldsh;": "\u21B2", "le;": "\u2264", "leftarrow;": "\u2190", "leftarrowtail;": "\u21A2", "leftharpoondown;": "\u21BD", "leftharpoonup;": "\u21BC", "leftleftarrows;": "\u21C7", "leftrightarrow;": "\u2194", "leftrightarrows;": "\u21C6", "leftrightharpoons;": "\u21CB", "leftrightsquigarrow;": "\u21AD", "leftthreetimes;": "\u22CB", "leg;": "\u22DA", "leq;": "\u2264", "leqq;": "\u2266", "leqslant;": "\u2A7D", "les;": "\u2A7D", "lescc;": "\u2AA8", "lesdot;": "\u2A7F", "lesdoto;": "\u2A81", "lesdotor;": "\u2A83", "lesg;": "\u22DA\uFE00", "lesges;": "\u2A93", "lessapprox;": "\u2A85", "lessdot;": "\u22D6", "lesseqgtr;": "\u22DA", "lesseqqgtr;": "\u2A8B", "lessgtr;": "\u2276", "lesssim;": "\u2272", "lfisht;": "\u297C", "lfloor;": "\u230A", "lfr;": "\u{1D529}", "lg;": "\u2276", "lgE;": "\u2A91", "lhard;": "\u21BD", "lharu;": "\u21BC", "lharul;": "\u296A", "lhblk;": "\u2584", "ljcy;": "\u0459", "ll;": "\u226A", "llarr;": "\u21C7", "llcorner;": "\u231E", "llhard;": "\u296B", "lltri;": "\u25FA", "lmidot;": "\u0140", "lmoust;": "\u23B0", "lmoustache;": "\u23B0", "lnE;": "\u2268", "lnap;": "\u2A89", "lnapprox;": "\u2A89", "lne;": "\u2A87", "lneq;": "\u2A87", "lneqq;": "\u2268", "lnsim;": "\u22E6", "loang;": "\u27EC", "loarr;": "\u21FD", "lobrk;": "\u27E6", "longleftarrow;": "\u27F5", "longleftrightarrow;": "\u27F7", "longmapsto;": "\u27FC", "longrightarrow;": "\u27F6", "looparrowleft;": "\u21AB", "looparrowright;": "\u21AC", "lopar;": "\u2985", "lopf;": "\u{1D55D}", "loplus;": "\u2A2D", "lotimes;": "\u2A34", "lowast;": "\u2217", "lowbar;": "_", "loz;": "\u25CA", "lozenge;": "\u25CA", "lozf;": "\u29EB", "lpar;": "(", "lparlt;": "\u2993", "lrarr;": "\u21C6", "lrcorner;": "\u231F", "lrhar;": "\u21CB", "lrhard;": "\u296D", "lrm;": "\u200E", "lrtri;": "\u22BF", "lsaquo;": "\u2039", "lscr;": "\u{1D4C1}", "lsh;": "\u21B0", "lsim;": "\u2272", "lsime;": "\u2A8D", "lsimg;": "\u2A8F", "lsqb;": "[", "lsquo;": "\u2018", "lsquor;": "\u201A", "lstrok;": "\u0142", "lt": "<", "lt;": "<", "ltcc;": "\u2AA6", "ltcir;": "\u2A79", "ltdot;": "\u22D6", "lthree;": "\u22CB", "ltimes;": "\u22C9", "ltlarr;": "\u2976", "ltquest;": "\u2A7B", "ltrPar;": "\u2996", "ltri;": "\u25C3", "ltrie;": "\u22B4", "ltrif;": "\u25C2", "lurdshar;": "\u294A", "luruhar;": "\u2966", "lvertneqq;": "\u2268\uFE00", "lvnE;": "\u2268\uFE00", "mDDot;": "\u223A", "macr": "\xAF", "macr;": "\xAF", "male;": "\u2642", "malt;": "\u2720", "maltese;": "\u2720", "map;": "\u21A6", "mapsto;": "\u21A6", "mapstodown;": "\u21A7", "mapstoleft;": "\u21A4", "mapstoup;": "\u21A5", "marker;": "\u25AE", "mcomma;": "\u2A29", "mcy;": "\u043C", "mdash;": "\u2014", "measuredangle;": "\u2221", "mfr;": "\u{1D52A}", "mho;": "\u2127", "micro": "\xB5", "micro;": "\xB5", "mid;": "\u2223", "midast;": "*", "midcir;": "\u2AF0", "middot": "\xB7", "middot;": "\xB7", "minus;": "\u2212", "minusb;": "\u229F", "minusd;": "\u2238", "minusdu;": "\u2A2A", "mlcp;": "\u2ADB", "mldr;": "\u2026", "mnplus;": "\u2213", "models;": "\u22A7", "mopf;": "\u{1D55E}", "mp;": "\u2213", "mscr;": "\u{1D4C2}", "mstpos;": "\u223E", "mu;": "\u03BC", "multimap;": "\u22B8", "mumap;": "\u22B8", "nGg;": "\u22D9\u0338", "nGt;": "\u226B\u20D2", "nGtv;": "\u226B\u0338", "nLeftarrow;": "\u21CD", "nLeftrightarrow;": "\u21CE", "nLl;": "\u22D8\u0338", "nLt;": "\u226A\u20D2", "nLtv;": "\u226A\u0338", "nRightarrow;": "\u21CF", "nVDash;": "\u22AF", "nVdash;": "\u22AE", "nabla;": "\u2207", "nacute;": "\u0144", "nang;": "\u2220\u20D2", "nap;": "\u2249", "napE;": "\u2A70\u0338", "napid;": "\u224B\u0338", "napos;": "\u0149", "napprox;": "\u2249", "natur;": "\u266E", "natural;": "\u266E", "naturals;": "\u2115", "nbsp": "\xA0", "nbsp;": "\xA0", "nbump;": "\u224E\u0338", "nbumpe;": "\u224F\u0338", "ncap;": "\u2A43", "ncaron;": "\u0148", "ncedil;": "\u0146", "ncong;": "\u2247", "ncongdot;": "\u2A6D\u0338", "ncup;": "\u2A42", "ncy;": "\u043D", "ndash;": "\u2013", "ne;": "\u2260", "neArr;": "\u21D7", "nearhk;": "\u2924", "nearr;": "\u2197", "nearrow;": "\u2197", "nedot;": "\u2250\u0338", "nequiv;": "\u2262", "nesear;": "\u2928", "nesim;": "\u2242\u0338", "nexist;": "\u2204", "nexists;": "\u2204", "nfr;": "\u{1D52B}", "ngE;": "\u2267\u0338", "nge;": "\u2271", "ngeq;": "\u2271", "ngeqq;": "\u2267\u0338", "ngeqslant;": "\u2A7E\u0338", "nges;": "\u2A7E\u0338", "ngsim;": "\u2275", "ngt;": "\u226F", "ngtr;": "\u226F", "nhArr;": "\u21CE", "nharr;": "\u21AE", "nhpar;": "\u2AF2", "ni;": "\u220B", "nis;": "\u22FC", "nisd;": "\u22FA", "niv;": "\u220B", "njcy;": "\u045A", "nlArr;": "\u21CD", "nlE;": "\u2266\u0338", "nlarr;": "\u219A", "nldr;": "\u2025", "nle;": "\u2270", "nleftarrow;": "\u219A", "nleftrightarrow;": "\u21AE", "nleq;": "\u2270", "nleqq;": "\u2266\u0338", "nleqslant;": "\u2A7D\u0338", "nles;": "\u2A7D\u0338", "nless;": "\u226E", "nlsim;": "\u2274", "nlt;": "\u226E", "nltri;": "\u22EA", "nltrie;": "\u22EC", "nmid;": "\u2224", "nopf;": "\u{1D55F}", "not": "\xAC", "not;": "\xAC", "notin;": "\u2209", "notinE;": "\u22F9\u0338", "notindot;": "\u22F5\u0338", "notinva;": "\u2209", "notinvb;": "\u22F7", "notinvc;": "\u22F6", "notni;": "\u220C", "notniva;": "\u220C", "notnivb;": "\u22FE", "notnivc;": "\u22FD", "npar;": "\u2226", "nparallel;": "\u2226", "nparsl;": "\u2AFD\u20E5", "npart;": "\u2202\u0338", "npolint;": "\u2A14", "npr;": "\u2280", "nprcue;": "\u22E0", "npre;": "\u2AAF\u0338", "nprec;": "\u2280", "npreceq;": "\u2AAF\u0338", "nrArr;": "\u21CF", "nrarr;": "\u219B", "nrarrc;": "\u2933\u0338", "nrarrw;": "\u219D\u0338", "nrightarrow;": "\u219B", "nrtri;": "\u22EB", "nrtrie;": "\u22ED", "nsc;": "\u2281", "nsccue;": "\u22E1", "nsce;": "\u2AB0\u0338", "nscr;": "\u{1D4C3}", "nshortmid;": "\u2224", "nshortparallel;": "\u2226", "nsim;": "\u2241", "nsime;": "\u2244", "nsimeq;": "\u2244", "nsmid;": "\u2224", "nspar;": "\u2226", "nsqsube;": "\u22E2", "nsqsupe;": "\u22E3", "nsub;": "\u2284", "nsubE;": "\u2AC5\u0338", "nsube;": "\u2288", "nsubset;": "\u2282\u20D2", "nsubseteq;": "\u2288", "nsubseteqq;": "\u2AC5\u0338", "nsucc;": "\u2281", "nsucceq;": "\u2AB0\u0338", "nsup;": "\u2285", "nsupE;": "\u2AC6\u0338", "nsupe;": "\u2289", "nsupset;": "\u2283\u20D2", "nsupseteq;": "\u2289", "nsupseteqq;": "\u2AC6\u0338", "ntgl;": "\u2279", "ntilde": "\xF1", "ntilde;": "\xF1", "ntlg;": "\u2278", "ntriangleleft;": "\u22EA", "ntrianglelefteq;": "\u22EC", "ntriangleright;": "\u22EB", "ntrianglerighteq;": "\u22ED", "nu;": "\u03BD", "num;": "#", "numero;": "\u2116", "numsp;": "\u2007", "nvDash;": "\u22AD", "nvHarr;": "\u2904", "nvap;": "\u224D\u20D2", "nvdash;": "\u22AC", "nvge;": "\u2265\u20D2", "nvgt;": ">\u20D2", "nvinfin;": "\u29DE", "nvlArr;": "\u2902", "nvle;": "\u2264\u20D2", "nvlt;": "<\u20D2", "nvltrie;": "\u22B4\u20D2", "nvrArr;": "\u2903", "nvrtrie;": "\u22B5\u20D2", "nvsim;": "\u223C\u20D2", "nwArr;": "\u21D6", "nwarhk;": "\u2923", "nwarr;": "\u2196", "nwarrow;": "\u2196", "nwnear;": "\u2927", "oS;": "\u24C8", "oacute": "\xF3", "oacute;": "\xF3", "oast;": "\u229B", "ocir;": "\u229A", "ocirc": "\xF4", "ocirc;": "\xF4", "ocy;": "\u043E", "odash;": "\u229D", "odblac;": "\u0151", "odiv;": "\u2A38", "odot;": "\u2299", "odsold;": "\u29BC", "oelig;": "\u0153", "ofcir;": "\u29BF", "ofr;": "\u{1D52C}", "ogon;": "\u02DB", "ograve": "\xF2", "ograve;": "\xF2", "ogt;": "\u29C1", "ohbar;": "\u29B5", "ohm;": "\u03A9", "oint;": "\u222E", "olarr;": "\u21BA", "olcir;": "\u29BE", "olcross;": "\u29BB", "oline;": "\u203E", "olt;": "\u29C0", "omacr;": "\u014D", "omega;": "\u03C9", "omicron;": "\u03BF", "omid;": "\u29B6", "ominus;": "\u2296", "oopf;": "\u{1D560}", "opar;": "\u29B7", "operp;": "\u29B9", "oplus;": "\u2295", "or;": "\u2228", "orarr;": "\u21BB", "ord;": "\u2A5D", "order;": "\u2134", "orderof;": "\u2134", "ordf": "\xAA", "ordf;": "\xAA", "ordm": "\xBA", "ordm;": "\xBA", "origof;": "\u22B6", "oror;": "\u2A56", "orslope;": "\u2A57", "orv;": "\u2A5B", "oscr;": "\u2134", "oslash": "\xF8", "oslash;": "\xF8", "osol;": "\u2298", "otilde": "\xF5", "otilde;": "\xF5", "otimes;": "\u2297", "otimesas;": "\u2A36", "ouml": "\xF6", "ouml;": "\xF6", "ovbar;": "\u233D", "par;": "\u2225", "para": "\xB6", "para;": "\xB6", "parallel;": "\u2225", "parsim;": "\u2AF3", "parsl;": "\u2AFD", "part;": "\u2202", "pcy;": "\u043F", "percnt;": "%", "period;": ".", "permil;": "\u2030", "perp;": "\u22A5", "pertenk;": "\u2031", "pfr;": "\u{1D52D}", "phi;": "\u03C6", "phiv;": "\u03D5", "phmmat;": "\u2133", "phone;": "\u260E", "pi;": "\u03C0", "pitchfork;": "\u22D4", "piv;": "\u03D6", "planck;": "\u210F", "planckh;": "\u210E", "plankv;": "\u210F", "plus;": "+", "plusacir;": "\u2A23", "plusb;": "\u229E", "pluscir;": "\u2A22", "plusdo;": "\u2214", "plusdu;": "\u2A25", "pluse;": "\u2A72", "plusmn": "\xB1", "plusmn;": "\xB1", "plussim;": "\u2A26", "plustwo;": "\u2A27", "pm;": "\xB1", "pointint;": "\u2A15", "popf;": "\u{1D561}", "pound": "\xA3", "pound;": "\xA3", "pr;": "\u227A", "prE;": "\u2AB3", "prap;": "\u2AB7", "prcue;": "\u227C", "pre;": "\u2AAF", "prec;": "\u227A", "precapprox;": "\u2AB7", "preccurlyeq;": "\u227C", "preceq;": "\u2AAF", "precnapprox;": "\u2AB9", "precneqq;": "\u2AB5", "precnsim;": "\u22E8", "precsim;": "\u227E", "prime;": "\u2032", "primes;": "\u2119", "prnE;": "\u2AB5", "prnap;": "\u2AB9", "prnsim;": "\u22E8", "prod;": "\u220F", "profalar;": "\u232E", "profline;": "\u2312", "profsurf;": "\u2313", "prop;": "\u221D", "propto;": "\u221D", "prsim;": "\u227E", "prurel;": "\u22B0", "pscr;": "\u{1D4C5}", "psi;": "\u03C8", "puncsp;": "\u2008", "qfr;": "\u{1D52E}", "qint;": "\u2A0C", "qopf;": "\u{1D562}", "qprime;": "\u2057", "qscr;": "\u{1D4C6}", "quaternions;": "\u210D", "quatint;": "\u2A16", "quest;": "?", "questeq;": "\u225F", "quot": '"', "quot;": '"', "rAarr;": "\u21DB", "rArr;": "\u21D2", "rAtail;": "\u291C", "rBarr;": "\u290F", "rHar;": "\u2964", "race;": "\u223D\u0331", "racute;": "\u0155", "radic;": "\u221A", "raemptyv;": "\u29B3", "rang;": "\u27E9", "rangd;": "\u2992", "range;": "\u29A5", "rangle;": "\u27E9", "raquo": "\xBB", "raquo;": "\xBB", "rarr;": "\u2192", "rarrap;": "\u2975", "rarrb;": "\u21E5", "rarrbfs;": "\u2920", "rarrc;": "\u2933", "rarrfs;": "\u291E", "rarrhk;": "\u21AA", "rarrlp;": "\u21AC", "rarrpl;": "\u2945", "rarrsim;": "\u2974", "rarrtl;": "\u21A3", "rarrw;": "\u219D", "ratail;": "\u291A", "ratio;": "\u2236", "rationals;": "\u211A", "rbarr;": "\u290D", "rbbrk;": "\u2773", "rbrace;": "}", "rbrack;": "]", "rbrke;": "\u298C", "rbrksld;": "\u298E", "rbrkslu;": "\u2990", "rcaron;": "\u0159", "rcedil;": "\u0157", "rceil;": "\u2309", "rcub;": "}", "rcy;": "\u0440", "rdca;": "\u2937", "rdldhar;": "\u2969", "rdquo;": "\u201D", "rdquor;": "\u201D", "rdsh;": "\u21B3", "real;": "\u211C", "realine;": "\u211B", "realpart;": "\u211C", "reals;": "\u211D", "rect;": "\u25AD", "reg": "\xAE", "reg;": "\xAE", "rfisht;": "\u297D", "rfloor;": "\u230B", "rfr;": "\u{1D52F}", "rhard;": "\u21C1", "rharu;": "\u21C0", "rharul;": "\u296C", "rho;": "\u03C1", "rhov;": "\u03F1", "rightarrow;": "\u2192", "rightarrowtail;": "\u21A3", "rightharpoondown;": "\u21C1", "rightharpoonup;": "\u21C0", "rightleftarrows;": "\u21C4", "rightleftharpoons;": "\u21CC", "rightrightarrows;": "\u21C9", "rightsquigarrow;": "\u219D", "rightthreetimes;": "\u22CC", "ring;": "\u02DA", "risingdotseq;": "\u2253", "rlarr;": "\u21C4", "rlhar;": "\u21CC", "rlm;": "\u200F", "rmoust;": "\u23B1", "rmoustache;": "\u23B1", "rnmid;": "\u2AEE", "roang;": "\u27ED", "roarr;": "\u21FE", "robrk;": "\u27E7", "ropar;": "\u2986", "ropf;": "\u{1D563}", "roplus;": "\u2A2E", "rotimes;": "\u2A35", "rpar;": ")", "rpargt;": "\u2994", "rppolint;": "\u2A12", "rrarr;": "\u21C9", "rsaquo;": "\u203A", "rscr;": "\u{1D4C7}", "rsh;": "\u21B1", "rsqb;": "]", "rsquo;": "\u2019", "rsquor;": "\u2019", "rthree;": "\u22CC", "rtimes;": "\u22CA", "rtri;": "\u25B9", "rtrie;": "\u22B5", "rtrif;": "\u25B8", "rtriltri;": "\u29CE", "ruluhar;": "\u2968", "rx;": "\u211E", "sacute;": "\u015B", "sbquo;": "\u201A", "sc;": "\u227B", "scE;": "\u2AB4", "scap;": "\u2AB8", "scaron;": "\u0161", "sccue;": "\u227D", "sce;": "\u2AB0", "scedil;": "\u015F", "scirc;": "\u015D", "scnE;": "\u2AB6", "scnap;": "\u2ABA", "scnsim;": "\u22E9", "scpolint;": "\u2A13", "scsim;": "\u227F", "scy;": "\u0441", "sdot;": "\u22C5", "sdotb;": "\u22A1", "sdote;": "\u2A66", "seArr;": "\u21D8", "searhk;": "\u2925", "searr;": "\u2198", "searrow;": "\u2198", "sect": "\xA7", "sect;": "\xA7", "semi;": ";", "seswar;": "\u2929", "setminus;": "\u2216", "setmn;": "\u2216", "sext;": "\u2736", "sfr;": "\u{1D530}", "sfrown;": "\u2322", "sharp;": "\u266F", "shchcy;": "\u0449", "shcy;": "\u0448", "shortmid;": "\u2223", "shortparallel;": "\u2225", "shy": "\xAD", "shy;": "\xAD", "sigma;": "\u03C3", "sigmaf;": "\u03C2", "sigmav;": "\u03C2", "sim;": "\u223C", "simdot;": "\u2A6A", "sime;": "\u2243", "simeq;": "\u2243", "simg;": "\u2A9E", "simgE;": "\u2AA0", "siml;": "\u2A9D", "simlE;": "\u2A9F", "simne;": "\u2246", "simplus;": "\u2A24", "simrarr;": "\u2972", "slarr;": "\u2190", "smallsetminus;": "\u2216", "smashp;": "\u2A33", "smeparsl;": "\u29E4", "smid;": "\u2223", "smile;": "\u2323", "smt;": "\u2AAA", "smte;": "\u2AAC", "smtes;": "\u2AAC\uFE00", "softcy;": "\u044C", "sol;": "/", "solb;": "\u29C4", "solbar;": "\u233F", "sopf;": "\u{1D564}", "spades;": "\u2660", "spadesuit;": "\u2660", "spar;": "\u2225", "sqcap;": "\u2293", "sqcaps;": "\u2293\uFE00", "sqcup;": "\u2294", "sqcups;": "\u2294\uFE00", "sqsub;": "\u228F", "sqsube;": "\u2291", "sqsubset;": "\u228F", "sqsubseteq;": "\u2291", "sqsup;": "\u2290", "sqsupe;": "\u2292", "sqsupset;": "\u2290", "sqsupseteq;": "\u2292", "squ;": "\u25A1", "square;": "\u25A1", "squarf;": "\u25AA", "squf;": "\u25AA", "srarr;": "\u2192", "sscr;": "\u{1D4C8}", "ssetmn;": "\u2216", "ssmile;": "\u2323", "sstarf;": "\u22C6", "star;": "\u2606", "starf;": "\u2605", "straightepsilon;": "\u03F5", "straightphi;": "\u03D5", "strns;": "\xAF", "sub;": "\u2282", "subE;": "\u2AC5", "subdot;": "\u2ABD", "sube;": "\u2286", "subedot;": "\u2AC3", "submult;": "\u2AC1", "subnE;": "\u2ACB", "subne;": "\u228A", "subplus;": "\u2ABF", "subrarr;": "\u2979", "subset;": "\u2282", "subseteq;": "\u2286", "subseteqq;": "\u2AC5", "subsetneq;": "\u228A", "subsetneqq;": "\u2ACB", "subsim;": "\u2AC7", "subsub;": "\u2AD5", "subsup;": "\u2AD3", "succ;": "\u227B", "succapprox;": "\u2AB8", "succcurlyeq;": "\u227D", "succeq;": "\u2AB0", "succnapprox;": "\u2ABA", "succneqq;": "\u2AB6", "succnsim;": "\u22E9", "succsim;": "\u227F", "sum;": "\u2211", "sung;": "\u266A", "sup1": "\xB9", "sup1;": "\xB9", "sup2": "\xB2", "sup2;": "\xB2", "sup3": "\xB3", "sup3;": "\xB3", "sup;": "\u2283", "supE;": "\u2AC6", "supdot;": "\u2ABE", "supdsub;": "\u2AD8", "supe;": "\u2287", "supedot;": "\u2AC4", "suphsol;": "\u27C9", "suphsub;": "\u2AD7", "suplarr;": "\u297B", "supmult;": "\u2AC2", "supnE;": "\u2ACC", "supne;": "\u228B", "supplus;": "\u2AC0", "supset;": "\u2283", "supseteq;": "\u2287", "supseteqq;": "\u2AC6", "supsetneq;": "\u228B", "supsetneqq;": "\u2ACC", "supsim;": "\u2AC8", "supsub;": "\u2AD4", "supsup;": "\u2AD6", "swArr;": "\u21D9", "swarhk;": "\u2926", "swarr;": "\u2199", "swarrow;": "\u2199", "swnwar;": "\u292A", "szlig": "\xDF", "szlig;": "\xDF", "target;": "\u2316", "tau;": "\u03C4", "tbrk;": "\u23B4", "tcaron;": "\u0165", "tcedil;": "\u0163", "tcy;": "\u0442", "tdot;": "\u20DB", "telrec;": "\u2315", "tfr;": "\u{1D531}", "there4;": "\u2234", "therefore;": "\u2234", "theta;": "\u03B8", "thetasym;": "\u03D1", "thetav;": "\u03D1", "thickapprox;": "\u2248", "thicksim;": "\u223C", "thinsp;": "\u2009", "thkap;": "\u2248", "thksim;": "\u223C", "thorn": "\xFE", "thorn;": "\xFE", "tilde;": "\u02DC", "times": "\xD7", "times;": "\xD7", "timesb;": "\u22A0", "timesbar;": "\u2A31", "timesd;": "\u2A30", "tint;": "\u222D", "toea;": "\u2928", "top;": "\u22A4", "topbot;": "\u2336", "topcir;": "\u2AF1", "topf;": "\u{1D565}", "topfork;": "\u2ADA", "tosa;": "\u2929", "tprime;": "\u2034", "trade;": "\u2122", "triangle;": "\u25B5", "triangledown;": "\u25BF", "triangleleft;": "\u25C3", "trianglelefteq;": "\u22B4", "triangleq;": "\u225C", "triangleright;": "\u25B9", "trianglerighteq;": "\u22B5", "tridot;": "\u25EC", "trie;": "\u225C", "triminus;": "\u2A3A", "triplus;": "\u2A39", "trisb;": "\u29CD", "tritime;": "\u2A3B", "trpezium;": "\u23E2", "tscr;": "\u{1D4C9}", "tscy;": "\u0446", "tshcy;": "\u045B", "tstrok;": "\u0167", "twixt;": "\u226C", "twoheadleftarrow;": "\u219E", "twoheadrightarrow;": "\u21A0", "uArr;": "\u21D1", "uHar;": "\u2963", "uacute": "\xFA", "uacute;": "\xFA", "uarr;": "\u2191", "ubrcy;": "\u045E", "ubreve;": "\u016D", "ucirc": "\xFB", "ucirc;": "\xFB", "ucy;": "\u0443", "udarr;": "\u21C5", "udblac;": "\u0171", "udhar;": "\u296E", "ufisht;": "\u297E", "ufr;": "\u{1D532}", "ugrave": "\xF9", "ugrave;": "\xF9", "uharl;": "\u21BF", "uharr;": "\u21BE", "uhblk;": "\u2580", "ulcorn;": "\u231C", "ulcorner;": "\u231C", "ulcrop;": "\u230F", "ultri;": "\u25F8", "umacr;": "\u016B", "uml": "\xA8", "uml;": "\xA8", "uogon;": "\u0173", "uopf;": "\u{1D566}", "uparrow;": "\u2191", "updownarrow;": "\u2195", "upharpoonleft;": "\u21BF", "upharpoonright;": "\u21BE", "uplus;": "\u228E", "upsi;": "\u03C5", "upsih;": "\u03D2", "upsilon;": "\u03C5", "upuparrows;": "\u21C8", "urcorn;": "\u231D", "urcorner;": "\u231D", "urcrop;": "\u230E", "uring;": "\u016F", "urtri;": "\u25F9", "uscr;": "\u{1D4CA}", "utdot;": "\u22F0", "utilde;": "\u0169", "utri;": "\u25B5", "utrif;": "\u25B4", "uuarr;": "\u21C8", "uuml": "\xFC", "uuml;": "\xFC", "uwangle;": "\u29A7", "vArr;": "\u21D5", "vBar;": "\u2AE8", "vBarv;": "\u2AE9", "vDash;": "\u22A8", "vangrt;": "\u299C", "varepsilon;": "\u03F5", "varkappa;": "\u03F0", "varnothing;": "\u2205", "varphi;": "\u03D5", "varpi;": "\u03D6", "varpropto;": "\u221D", "varr;": "\u2195", "varrho;": "\u03F1", "varsigma;": "\u03C2", "varsubsetneq;": "\u228A\uFE00", "varsubsetneqq;": "\u2ACB\uFE00", "varsupsetneq;": "\u228B\uFE00", "varsupsetneqq;": "\u2ACC\uFE00", "vartheta;": "\u03D1", "vartriangleleft;": "\u22B2", "vartriangleright;": "\u22B3", "vcy;": "\u0432", "vdash;": "\u22A2", "vee;": "\u2228", "veebar;": "\u22BB", "veeeq;": "\u225A", "vellip;": "\u22EE", "verbar;": "|", "vert;": "|", "vfr;": "\u{1D533}", "vltri;": "\u22B2", "vnsub;": "\u2282\u20D2", "vnsup;": "\u2283\u20D2", "vopf;": "\u{1D567}", "vprop;": "\u221D", "vrtri;": "\u22B3", "vscr;": "\u{1D4CB}", "vsubnE;": "\u2ACB\uFE00", "vsubne;": "\u228A\uFE00", "vsupnE;": "\u2ACC\uFE00", "vsupne;": "\u228B\uFE00", "vzigzag;": "\u299A", "wcirc;": "\u0175", "wedbar;": "\u2A5F", "wedge;": "\u2227", "wedgeq;": "\u2259", "weierp;": "\u2118", "wfr;": "\u{1D534}", "wopf;": "\u{1D568}", "wp;": "\u2118", "wr;": "\u2240", "wreath;": "\u2240", "wscr;": "\u{1D4CC}", "xcap;": "\u22C2", "xcirc;": "\u25EF", "xcup;": "\u22C3", "xdtri;": "\u25BD", "xfr;": "\u{1D535}", "xhArr;": "\u27FA", "xharr;": "\u27F7", "xi;": "\u03BE", "xlArr;": "\u27F8", "xlarr;": "\u27F5", "xmap;": "\u27FC", "xnis;": "\u22FB", "xodot;": "\u2A00", "xopf;": "\u{1D569}", "xoplus;": "\u2A01", "xotime;": "\u2A02", "xrArr;": "\u27F9", "xrarr;": "\u27F6", "xscr;": "\u{1D4CD}", "xsqcup;": "\u2A06", "xuplus;": "\u2A04", "xutri;": "\u25B3", "xvee;": "\u22C1", "xwedge;": "\u22C0", "yacute": "\xFD", "yacute;": "\xFD", "yacy;": "\u044F", "ycirc;": "\u0177", "ycy;": "\u044B", "yen": "\xA5", "yen;": "\xA5", "yfr;": "\u{1D536}", "yicy;": "\u0457", "yopf;": "\u{1D56A}", "yscr;": "\u{1D4CE}", "yucy;": "\u044E", "yuml": "\xFF", "yuml;": "\xFF", "zacute;": "\u017A", "zcaron;": "\u017E", "zcy;": "\u0437", "zdot;": "\u017C", "zeetrf;": "\u2128", "zeta;": "\u03B6", "zfr;": "\u{1D537}", "zhcy;": "\u0436", "zigrarr;": "\u21DD", "zopf;": "\u{1D56B}", "zscr;": "\u{1D4CF}", "zwj;": "\u200D", "zwnj;": "\u200C" };
|
|
935
|
+
var INVALID_CHARREFS = { 0: "\uFFFD", 13: "\r", 128: "\u20AC", 129: "\x81", 130: "\u201A", 131: "\u0192", 132: "\u201E", 133: "\u2026", 134: "\u2020", 135: "\u2021", 136: "\u02C6", 137: "\u2030", 138: "\u0160", 139: "\u2039", 140: "\u0152", 141: "\x8D", 142: "\u017D", 143: "\x8F", 144: "\x90", 145: "\u2018", 146: "\u2019", 147: "\u201C", 148: "\u201D", 149: "\u2022", 150: "\u2013", 151: "\u2014", 152: "\u02DC", 153: "\u2122", 154: "\u0161", 155: "\u203A", 156: "\u0153", 157: "\x9D", 158: "\u017E", 159: "\u0178" };
|
|
936
|
+
var INVALID_CODEPOINTS = "1-8,b,e-1f,7f-9f,fdd0-fdef,fffe-ffff,1fffe-1ffff,2fffe-2ffff,3fffe-3ffff,4fffe-4ffff,5fffe-5ffff,6fffe-6ffff,7fffe-7ffff,8fffe-8ffff,9fffe-9ffff,afffe-affff,bfffe-bffff,cfffe-cffff,dfffe-dffff,efffe-effff,ffffe-fffff,10fffe-10ffff";
|
|
937
|
+
|
|
938
|
+
// src/convert/html.ts
|
|
939
|
+
var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
940
|
+
var dropped = null;
|
|
941
|
+
function droppedCodepoints() {
|
|
942
|
+
if (!dropped) {
|
|
943
|
+
dropped = /* @__PURE__ */ new Set();
|
|
944
|
+
for (const part of INVALID_CODEPOINTS.split(",")) {
|
|
945
|
+
const [a, b] = part.split("-").map((h) => parseInt(h, 16));
|
|
946
|
+
for (let c = a; c <= (b ?? a); c++) dropped.add(c);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return dropped;
|
|
950
|
+
}
|
|
951
|
+
function replaceCharref(s) {
|
|
952
|
+
if (s[0] === "#") {
|
|
953
|
+
const num = s[1] === "x" || s[1] === "X" ? parseInt(s.slice(2).replace(/;+$/, ""), 16) : Number(s.slice(1).replace(/;+$/, ""));
|
|
954
|
+
if (has(INVALID_CHARREFS, String(num))) return INVALID_CHARREFS[num];
|
|
955
|
+
if (num >= 55296 && num <= 57343 || num > 1114111) return "\uFFFD";
|
|
956
|
+
if (droppedCodepoints().has(num)) return "";
|
|
957
|
+
return String.fromCodePoint(num);
|
|
958
|
+
}
|
|
959
|
+
if (has(HTML5_ENTITIES, s)) return HTML5_ENTITIES[s];
|
|
960
|
+
for (let x = s.length - 1; x > 1; x--) {
|
|
961
|
+
if (has(HTML5_ENTITIES, s.slice(0, x))) return HTML5_ENTITIES[s.slice(0, x)] + s.slice(x);
|
|
962
|
+
}
|
|
963
|
+
return `&${s}`;
|
|
964
|
+
}
|
|
965
|
+
var CHARREF = /&(#[0-9]+;?|#[xX][0-9a-fA-F]+;?|[^\t\n\f <&#;]{1,32};?)/gu;
|
|
966
|
+
function unescape(s) {
|
|
967
|
+
if (!s.includes("&")) return s;
|
|
968
|
+
return s.replace(CHARREF, (_m, ref) => replaceCharref(ref));
|
|
969
|
+
}
|
|
970
|
+
var ATTR_CHARREF = /&(#[0-9]+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*)[;=]?/g;
|
|
971
|
+
function unescapeAttrValue(s) {
|
|
972
|
+
return s.replace(ATTR_CHARREF, (ref) => {
|
|
973
|
+
if (ref.startsWith("&#")) return unescape(ref);
|
|
974
|
+
if (!ref.endsWith("=") && has(HTML5_ENTITIES, ref.slice(1))) return unescape(ref);
|
|
975
|
+
return ref;
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
var STARTTAGOPEN = /<[a-zA-Z]/y;
|
|
979
|
+
var ENDTAGOPEN = /<\/[a-zA-Z]/y;
|
|
980
|
+
var COMMENTCLOSE = /--!?>/g;
|
|
981
|
+
var COMMENTABRUPTCLOSE = /-?>/y;
|
|
982
|
+
var TAGFIND = /([a-zA-Z][^\t\n\r\f />]*)(?:[\t\n\r\f ]|\/(?!>))*/y;
|
|
983
|
+
var ATTRFIND = /((?<=['"\t\n\r\f /])[^\t\n\r\f />][^\t\n\r\f /=>]*)([\t\n\r\f ]*=[\t\n\r\f ]*('[^']*'|"[^"]*"|(?!['"])[^>\t\n\r\f ]*))?(?:[\t\n\r\f ]|\/(?!>))*/y;
|
|
984
|
+
var LOCATETAGEND = /[a-zA-Z][^\t\n\r\f />]*[\t\n\r\f /]*(?:(?<=['"\t\n\r\f /])[^\t\n\r\f />][^\t\n\r\f /=>]*(?:[\t\n\r\f ]*=[\t\n\r\f ]*(?:'[^']*'|"[^"]*"|(?!['"])[^>\t\n\r\f ]*))?[\t\n\r\f /]*)*>?/y;
|
|
985
|
+
var CDATA_CONTENT = /* @__PURE__ */ new Set(["script", "style", "xmp", "iframe", "noembed", "noframes"]);
|
|
986
|
+
var RCDATA_CONTENT = /* @__PURE__ */ new Set(["textarea", "title"]);
|
|
987
|
+
var matchAt = (re, s, at) => {
|
|
988
|
+
re.lastIndex = at;
|
|
989
|
+
return re.exec(s);
|
|
990
|
+
};
|
|
991
|
+
var searchFrom = (re, s, at) => {
|
|
992
|
+
re.lastIndex = at;
|
|
993
|
+
return re.exec(s);
|
|
994
|
+
};
|
|
995
|
+
function endTagOf(elem) {
|
|
996
|
+
const name2 = [...elem].map((c) => /[a-z]/i.test(c) ? `[${c.toLowerCase()}${c.toUpperCase()}]` : c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
997
|
+
return new RegExp(`<\\/${name2}(?=[\\t\\n\\r\\f />])`, "g");
|
|
998
|
+
}
|
|
999
|
+
var Parser = class {
|
|
1000
|
+
constructor(h) {
|
|
1001
|
+
this.h = h;
|
|
1002
|
+
this.raw = "";
|
|
1003
|
+
this.cdataElem = null;
|
|
1004
|
+
this.interesting = null;
|
|
1005
|
+
this.escapable = true;
|
|
1006
|
+
}
|
|
1007
|
+
feed(data) {
|
|
1008
|
+
this.raw += data;
|
|
1009
|
+
this.goahead(false);
|
|
1010
|
+
}
|
|
1011
|
+
close() {
|
|
1012
|
+
this.goahead(true);
|
|
1013
|
+
}
|
|
1014
|
+
setCdataMode(elem, escapable) {
|
|
1015
|
+
this.cdataElem = elem.toLowerCase();
|
|
1016
|
+
this.escapable = escapable;
|
|
1017
|
+
this.interesting = this.cdataElem === "plaintext" ? null : endTagOf(this.cdataElem);
|
|
1018
|
+
}
|
|
1019
|
+
clearCdataMode() {
|
|
1020
|
+
this.interesting = null;
|
|
1021
|
+
this.cdataElem = null;
|
|
1022
|
+
this.escapable = true;
|
|
1023
|
+
}
|
|
1024
|
+
goahead(end) {
|
|
1025
|
+
const raw = this.raw;
|
|
1026
|
+
let i = 0;
|
|
1027
|
+
const n = raw.length;
|
|
1028
|
+
while (i < n) {
|
|
1029
|
+
let j;
|
|
1030
|
+
if (!this.cdataElem) {
|
|
1031
|
+
j = raw.indexOf("<", i);
|
|
1032
|
+
if (j < 0) {
|
|
1033
|
+
const amppos = raw.lastIndexOf("&");
|
|
1034
|
+
if (amppos >= Math.max(i, n - 34) && !/[\t\n\r\f ;]/.test(raw.slice(amppos))) break;
|
|
1035
|
+
j = n;
|
|
1036
|
+
}
|
|
1037
|
+
} else if (this.cdataElem === "plaintext") {
|
|
1038
|
+
j = n;
|
|
1039
|
+
} else {
|
|
1040
|
+
const m = searchFrom(this.interesting, raw, i);
|
|
1041
|
+
if (m) j = m.index;
|
|
1042
|
+
else break;
|
|
1043
|
+
}
|
|
1044
|
+
if (i < j) this.h.data(this.escapable ? unescape(raw.slice(i, j)) : raw.slice(i, j));
|
|
1045
|
+
i = j;
|
|
1046
|
+
if (i === n) break;
|
|
1047
|
+
let k;
|
|
1048
|
+
if (matchAt(STARTTAGOPEN, raw, i)) k = this.parseStarttag(i);
|
|
1049
|
+
else if (raw.startsWith("</", i)) k = this.parseEndtag(i);
|
|
1050
|
+
else if (raw.startsWith("<!--", i)) k = this.parseComment(i);
|
|
1051
|
+
else if (raw.startsWith("<?", i)) k = this.parsePi(i);
|
|
1052
|
+
else if (raw.startsWith("<!", i)) k = this.parseHtmlDeclaration(i);
|
|
1053
|
+
else if (i + 1 < n || end) {
|
|
1054
|
+
this.h.data("<");
|
|
1055
|
+
k = i + 1;
|
|
1056
|
+
} else break;
|
|
1057
|
+
if (k < 0) {
|
|
1058
|
+
if (!end) break;
|
|
1059
|
+
if (!matchAt(STARTTAGOPEN, raw, i) && raw.startsWith("</", i) && i + 2 === n) this.h.data("</");
|
|
1060
|
+
k = n;
|
|
1061
|
+
}
|
|
1062
|
+
i = k;
|
|
1063
|
+
}
|
|
1064
|
+
if (end && i < n) {
|
|
1065
|
+
this.h.data(this.escapable ? unescape(raw.slice(i, n)) : raw.slice(i, n));
|
|
1066
|
+
i = n;
|
|
1067
|
+
}
|
|
1068
|
+
this.raw = raw.slice(i);
|
|
1069
|
+
}
|
|
1070
|
+
parseHtmlDeclaration(i) {
|
|
1071
|
+
const raw = this.raw;
|
|
1072
|
+
if (raw.startsWith("<!--", i)) return this.parseComment(i);
|
|
1073
|
+
if (raw.startsWith("<![CDATA[", i)) {
|
|
1074
|
+
const j = raw.indexOf("]]>", i + 9);
|
|
1075
|
+
return j < 0 ? -1 : j + 3;
|
|
1076
|
+
}
|
|
1077
|
+
if (raw.slice(i, i + 9).toLowerCase() === "<!doctype") {
|
|
1078
|
+
const gt = raw.indexOf(">", i + 9);
|
|
1079
|
+
return gt === -1 ? -1 : gt + 1;
|
|
1080
|
+
}
|
|
1081
|
+
return this.parseBogusComment(i);
|
|
1082
|
+
}
|
|
1083
|
+
parseComment(i) {
|
|
1084
|
+
const raw = this.raw;
|
|
1085
|
+
let m = searchFrom(COMMENTCLOSE, raw, i + 4);
|
|
1086
|
+
if (!m) {
|
|
1087
|
+
m = matchAt(COMMENTABRUPTCLOSE, raw, i + 4);
|
|
1088
|
+
if (!m) return -1;
|
|
1089
|
+
}
|
|
1090
|
+
return m.index + m[0].length;
|
|
1091
|
+
}
|
|
1092
|
+
parseBogusComment(i) {
|
|
1093
|
+
const pos = this.raw.indexOf(">", i + 2);
|
|
1094
|
+
return pos === -1 ? -1 : pos + 1;
|
|
1095
|
+
}
|
|
1096
|
+
parsePi(i) {
|
|
1097
|
+
const j = this.raw.indexOf(">", i + 2);
|
|
1098
|
+
return j < 0 ? -1 : j + 1;
|
|
1099
|
+
}
|
|
1100
|
+
parseStarttag(i) {
|
|
1101
|
+
const raw = this.raw;
|
|
1102
|
+
const loc = matchAt(LOCATETAGEND, raw, i + 1);
|
|
1103
|
+
const endpos = i + 1 + loc[0].length;
|
|
1104
|
+
if (raw[endpos - 1] !== ">") return -1;
|
|
1105
|
+
const attrs = [];
|
|
1106
|
+
const tm = matchAt(TAGFIND, raw, i + 1);
|
|
1107
|
+
let k = i + 1 + tm[0].length;
|
|
1108
|
+
const tag = tm[1].toLowerCase();
|
|
1109
|
+
while (k < endpos) {
|
|
1110
|
+
const m = matchAt(ATTRFIND, raw, k);
|
|
1111
|
+
if (!m) break;
|
|
1112
|
+
const [, attrname, rest] = m;
|
|
1113
|
+
let value = m[3] ?? null;
|
|
1114
|
+
if (!rest) value = null;
|
|
1115
|
+
else if (value !== null && (value.slice(0, 1) === "'" && value.slice(-1) === "'" || value.slice(0, 1) === '"' && value.slice(-1) === '"')) {
|
|
1116
|
+
value = value.slice(1, -1);
|
|
1117
|
+
}
|
|
1118
|
+
if (value) value = unescapeAttrValue(value);
|
|
1119
|
+
attrs.push([attrname.toLowerCase(), value]);
|
|
1120
|
+
k += m[0].length;
|
|
1121
|
+
}
|
|
1122
|
+
const endText = strip(raw.slice(k, endpos));
|
|
1123
|
+
if (endText !== ">" && endText !== "/>") {
|
|
1124
|
+
this.h.data(raw.slice(i, endpos));
|
|
1125
|
+
return endpos;
|
|
1126
|
+
}
|
|
1127
|
+
if (endText.endsWith("/>")) {
|
|
1128
|
+
this.h.startendtag(tag, attrs);
|
|
1129
|
+
} else {
|
|
1130
|
+
this.h.starttag(tag, attrs);
|
|
1131
|
+
if (CDATA_CONTENT.has(tag) || tag === "plaintext") this.setCdataMode(tag, false);
|
|
1132
|
+
else if (RCDATA_CONTENT.has(tag)) this.setCdataMode(tag, true);
|
|
1133
|
+
}
|
|
1134
|
+
return endpos;
|
|
1135
|
+
}
|
|
1136
|
+
parseEndtag(i) {
|
|
1137
|
+
const raw = this.raw;
|
|
1138
|
+
if (raw.indexOf(">", i + 2) < 0) return -1;
|
|
1139
|
+
if (!matchAt(ENDTAGOPEN, raw, i)) {
|
|
1140
|
+
if (raw.slice(i + 2, i + 3) === ">") return i + 3;
|
|
1141
|
+
return this.parseBogusComment(i);
|
|
1142
|
+
}
|
|
1143
|
+
const loc = matchAt(LOCATETAGEND, raw, i + 2);
|
|
1144
|
+
const j = i + 2 + loc[0].length;
|
|
1145
|
+
if (raw[j - 1] !== ">") return -1;
|
|
1146
|
+
const tm = matchAt(TAGFIND, raw, i + 2);
|
|
1147
|
+
this.h.endtag(tm[1].toLowerCase());
|
|
1148
|
+
this.clearCdataMode();
|
|
1149
|
+
return j;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "meta", "link", "wbr", "col", "area", "source", "embed"]);
|
|
1153
|
+
var BLOCK = /* @__PURE__ */ new Set([
|
|
1154
|
+
"p",
|
|
1155
|
+
"div",
|
|
1156
|
+
"h1",
|
|
1157
|
+
"h2",
|
|
1158
|
+
"h3",
|
|
1159
|
+
"h4",
|
|
1160
|
+
"h5",
|
|
1161
|
+
"h6",
|
|
1162
|
+
"ul",
|
|
1163
|
+
"ol",
|
|
1164
|
+
"li",
|
|
1165
|
+
"blockquote",
|
|
1166
|
+
"pre",
|
|
1167
|
+
"hr",
|
|
1168
|
+
"table",
|
|
1169
|
+
"thead",
|
|
1170
|
+
"tbody",
|
|
1171
|
+
"tfoot",
|
|
1172
|
+
"tr",
|
|
1173
|
+
"td",
|
|
1174
|
+
"th",
|
|
1175
|
+
"figure",
|
|
1176
|
+
"figcaption",
|
|
1177
|
+
"section",
|
|
1178
|
+
"article",
|
|
1179
|
+
"header",
|
|
1180
|
+
"footer",
|
|
1181
|
+
"aside",
|
|
1182
|
+
"details",
|
|
1183
|
+
"summary",
|
|
1184
|
+
"dl",
|
|
1185
|
+
"dt",
|
|
1186
|
+
"dd"
|
|
1187
|
+
]);
|
|
1188
|
+
var attrMap = (attrs) => {
|
|
1189
|
+
const m = /* @__PURE__ */ new Map();
|
|
1190
|
+
for (const [k, v] of attrs) m.set(k, v || "");
|
|
1191
|
+
return m;
|
|
1192
|
+
};
|
|
1193
|
+
function parseHtml(html) {
|
|
1194
|
+
const root = { tag: "root", attrs: /* @__PURE__ */ new Map(), children: [] };
|
|
1195
|
+
const stack = [root];
|
|
1196
|
+
const parser = new Parser({
|
|
1197
|
+
starttag(tag, attrs) {
|
|
1198
|
+
const node = { tag, attrs: attrMap(attrs), children: [] };
|
|
1199
|
+
stack[stack.length - 1].children.push(node);
|
|
1200
|
+
if (!VOID.has(tag)) stack.push(node);
|
|
1201
|
+
},
|
|
1202
|
+
startendtag(tag, attrs) {
|
|
1203
|
+
stack[stack.length - 1].children.push({ tag, attrs: attrMap(attrs), children: [] });
|
|
1204
|
+
},
|
|
1205
|
+
endtag(tag) {
|
|
1206
|
+
for (let i = stack.length - 1; i > 0; i--) {
|
|
1207
|
+
if (stack[i].tag === tag) {
|
|
1208
|
+
stack.length = i;
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
},
|
|
1213
|
+
data(text) {
|
|
1214
|
+
stack[stack.length - 1].children.push(text);
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
parser.feed(html);
|
|
1218
|
+
parser.close();
|
|
1219
|
+
return root;
|
|
1220
|
+
}
|
|
1221
|
+
var RUN = new RegExp(`[${PY_SPACE}]+`, "g");
|
|
1222
|
+
var isBlock = (c) => typeof c !== "string" && BLOCK.has(c.tag);
|
|
1223
|
+
function wrap(text, mark) {
|
|
1224
|
+
const core = strip(text);
|
|
1225
|
+
if (!core) return text;
|
|
1226
|
+
const lead = text.slice(0, text.length - lstrip(text).length);
|
|
1227
|
+
const trail = text.slice(rstrip(text).length);
|
|
1228
|
+
return `${lead}${mark}${core}${mark}${trail}`;
|
|
1229
|
+
}
|
|
1230
|
+
function inline(children, pre = false) {
|
|
1231
|
+
const out = [];
|
|
1232
|
+
for (const c of children) {
|
|
1233
|
+
if (typeof c === "string") {
|
|
1234
|
+
out.push(pre ? c : c.replace(RUN, " "));
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
const tag = c.tag;
|
|
1238
|
+
if (tag === "br") out.push("\n");
|
|
1239
|
+
else if (tag === "strong" || tag === "b") out.push(wrap(inline(c.children, pre), "**"));
|
|
1240
|
+
else if (tag === "em" || tag === "i") out.push(wrap(inline(c.children, pre), "*"));
|
|
1241
|
+
else if (tag === "s" || tag === "strike" || tag === "del") out.push(wrap(inline(c.children, pre), "~~"));
|
|
1242
|
+
else if (tag === "code") out.push(wrap(inline(c.children, true), "`"));
|
|
1243
|
+
else if (tag === "a") {
|
|
1244
|
+
const text = inline(c.children, pre);
|
|
1245
|
+
const href = c.attrs.get("href") ?? "";
|
|
1246
|
+
out.push(href && strip(text) ? `[${strip(text)}](${href})` : text);
|
|
1247
|
+
} else if (tag === "img") {
|
|
1248
|
+
const src = c.attrs.get("src") ?? "";
|
|
1249
|
+
out.push(src ? `` : "");
|
|
1250
|
+
} else if (BLOCK.has(tag)) out.push(` ${blocks(c).join(" ")} `);
|
|
1251
|
+
else out.push(inline(c.children, pre));
|
|
1252
|
+
}
|
|
1253
|
+
return out.join("");
|
|
1254
|
+
}
|
|
1255
|
+
function clean(text) {
|
|
1256
|
+
return strip(text).split("\n").map(strip).join("\n");
|
|
1257
|
+
}
|
|
1258
|
+
function blocks(node) {
|
|
1259
|
+
const out = [];
|
|
1260
|
+
let run = [];
|
|
1261
|
+
const flush = () => {
|
|
1262
|
+
const text = clean(inline(run));
|
|
1263
|
+
if (text) out.push(text);
|
|
1264
|
+
run = [];
|
|
1265
|
+
};
|
|
1266
|
+
for (const c of node.children) {
|
|
1267
|
+
if (!isBlock(c)) {
|
|
1268
|
+
run.push(c);
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
flush();
|
|
1272
|
+
const b = block(c);
|
|
1273
|
+
if (b) out.push(b);
|
|
1274
|
+
}
|
|
1275
|
+
flush();
|
|
1276
|
+
return out;
|
|
1277
|
+
}
|
|
1278
|
+
function indent(body, marker) {
|
|
1279
|
+
const [first, ...rest] = body.split("\n");
|
|
1280
|
+
return [marker + first, ...rest.map((line) => line ? " ".repeat(marker.length) + line : "")].join("\n");
|
|
1281
|
+
}
|
|
1282
|
+
function block(node) {
|
|
1283
|
+
const tag = node.tag;
|
|
1284
|
+
if (/^h[1-6]$/.test(tag)) {
|
|
1285
|
+
const text = clean(inline(node.children)).split("\n").join(" ");
|
|
1286
|
+
return text ? `${"#".repeat(Number(tag[1]))} ${text}` : "";
|
|
1287
|
+
}
|
|
1288
|
+
if (tag === "hr") return "---";
|
|
1289
|
+
if (tag === "pre") return "```\n" + inline(node.children, true).replace(/^\n+|\n+$/g, "") + "\n```";
|
|
1290
|
+
if (tag === "blockquote") {
|
|
1291
|
+
const inner = blocks(node).join("\n\n");
|
|
1292
|
+
return inner ? inner.split("\n").map((line) => line ? `> ${line}` : ">").join("\n") : "";
|
|
1293
|
+
}
|
|
1294
|
+
if (tag === "ul" || tag === "ol") {
|
|
1295
|
+
const startAttr = node.attrs.get("start");
|
|
1296
|
+
const start = (startAttr === void 0 ? null : intOfDigits(startAttr)) || 1;
|
|
1297
|
+
const lines = [];
|
|
1298
|
+
let i = 0;
|
|
1299
|
+
for (const li of node.children) {
|
|
1300
|
+
if (typeof li === "string" || li.tag !== "li") continue;
|
|
1301
|
+
const marker = tag === "ol" ? `${start + i}. ` : "- ";
|
|
1302
|
+
lines.push(indent(blocks(li).join("\n"), marker));
|
|
1303
|
+
i++;
|
|
1304
|
+
}
|
|
1305
|
+
return lines.join("\n");
|
|
1306
|
+
}
|
|
1307
|
+
if (tag === "table") {
|
|
1308
|
+
let rows = [];
|
|
1309
|
+
const walk = (n) => {
|
|
1310
|
+
for (const c of n.children) {
|
|
1311
|
+
if (typeof c === "string") continue;
|
|
1312
|
+
if (c.tag === "tr") {
|
|
1313
|
+
const cells = c.children.filter((x) => typeof x !== "string" && (x.tag === "td" || x.tag === "th"));
|
|
1314
|
+
rows.push(cells.map((cell) => blocks(cell).join("<br>").split("|").join("\\|").split("\n").join("<br>")));
|
|
1315
|
+
} else walk(c);
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
walk(node);
|
|
1319
|
+
const width = rows.reduce((w, r) => Math.max(w, r.length), 0);
|
|
1320
|
+
if (!width) return "";
|
|
1321
|
+
rows = rows.map((r) => [...r, ...Array(width - r.length).fill("")]);
|
|
1322
|
+
const lines = [`| ${rows[0].join(" | ")} |`, `| ${Array(width).fill("---").join(" | ")} |`];
|
|
1323
|
+
return [...lines, ...rows.slice(1).map((r) => `| ${r.join(" | ")} |`)].join("\n");
|
|
1324
|
+
}
|
|
1325
|
+
return blocks(node).join("\n\n");
|
|
1326
|
+
}
|
|
1327
|
+
function htmlToMarkdown(html) {
|
|
1328
|
+
if (!html) return "";
|
|
1329
|
+
return strip(blocks(parseHtml(html)).join("\n\n"));
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// src/convert/tree.ts
|
|
1333
|
+
var NotAZip = class extends Error {
|
|
1334
|
+
};
|
|
1335
|
+
var CP437_HIGH = [
|
|
1336
|
+
199,
|
|
1337
|
+
252,
|
|
1338
|
+
233,
|
|
1339
|
+
226,
|
|
1340
|
+
228,
|
|
1341
|
+
224,
|
|
1342
|
+
229,
|
|
1343
|
+
231,
|
|
1344
|
+
234,
|
|
1345
|
+
235,
|
|
1346
|
+
232,
|
|
1347
|
+
239,
|
|
1348
|
+
238,
|
|
1349
|
+
236,
|
|
1350
|
+
196,
|
|
1351
|
+
197,
|
|
1352
|
+
201,
|
|
1353
|
+
230,
|
|
1354
|
+
198,
|
|
1355
|
+
244,
|
|
1356
|
+
246,
|
|
1357
|
+
242,
|
|
1358
|
+
251,
|
|
1359
|
+
249,
|
|
1360
|
+
255,
|
|
1361
|
+
214,
|
|
1362
|
+
220,
|
|
1363
|
+
162,
|
|
1364
|
+
163,
|
|
1365
|
+
165,
|
|
1366
|
+
8359,
|
|
1367
|
+
402,
|
|
1368
|
+
225,
|
|
1369
|
+
237,
|
|
1370
|
+
243,
|
|
1371
|
+
250,
|
|
1372
|
+
241,
|
|
1373
|
+
209,
|
|
1374
|
+
170,
|
|
1375
|
+
186,
|
|
1376
|
+
191,
|
|
1377
|
+
8976,
|
|
1378
|
+
172,
|
|
1379
|
+
189,
|
|
1380
|
+
188,
|
|
1381
|
+
161,
|
|
1382
|
+
171,
|
|
1383
|
+
187,
|
|
1384
|
+
9617,
|
|
1385
|
+
9618,
|
|
1386
|
+
9619,
|
|
1387
|
+
9474,
|
|
1388
|
+
9508,
|
|
1389
|
+
9569,
|
|
1390
|
+
9570,
|
|
1391
|
+
9558,
|
|
1392
|
+
9557,
|
|
1393
|
+
9571,
|
|
1394
|
+
9553,
|
|
1395
|
+
9559,
|
|
1396
|
+
9565,
|
|
1397
|
+
9564,
|
|
1398
|
+
9563,
|
|
1399
|
+
9488,
|
|
1400
|
+
9492,
|
|
1401
|
+
9524,
|
|
1402
|
+
9516,
|
|
1403
|
+
9500,
|
|
1404
|
+
9472,
|
|
1405
|
+
9532,
|
|
1406
|
+
9566,
|
|
1407
|
+
9567,
|
|
1408
|
+
9562,
|
|
1409
|
+
9556,
|
|
1410
|
+
9577,
|
|
1411
|
+
9574,
|
|
1412
|
+
9568,
|
|
1413
|
+
9552,
|
|
1414
|
+
9580,
|
|
1415
|
+
9575,
|
|
1416
|
+
9576,
|
|
1417
|
+
9572,
|
|
1418
|
+
9573,
|
|
1419
|
+
9561,
|
|
1420
|
+
9560,
|
|
1421
|
+
9554,
|
|
1422
|
+
9555,
|
|
1423
|
+
9579,
|
|
1424
|
+
9578,
|
|
1425
|
+
9496,
|
|
1426
|
+
9484,
|
|
1427
|
+
9608,
|
|
1428
|
+
9604,
|
|
1429
|
+
9612,
|
|
1430
|
+
9616,
|
|
1431
|
+
9600,
|
|
1432
|
+
945,
|
|
1433
|
+
223,
|
|
1434
|
+
915,
|
|
1435
|
+
960,
|
|
1436
|
+
931,
|
|
1437
|
+
963,
|
|
1438
|
+
181,
|
|
1439
|
+
964,
|
|
1440
|
+
934,
|
|
1441
|
+
920,
|
|
1442
|
+
937,
|
|
1443
|
+
948,
|
|
1444
|
+
8734,
|
|
1445
|
+
966,
|
|
1446
|
+
949,
|
|
1447
|
+
8745,
|
|
1448
|
+
8801,
|
|
1449
|
+
177,
|
|
1450
|
+
8805,
|
|
1451
|
+
8804,
|
|
1452
|
+
8992,
|
|
1453
|
+
8993,
|
|
1454
|
+
247,
|
|
1455
|
+
8776,
|
|
1456
|
+
176,
|
|
1457
|
+
8729,
|
|
1458
|
+
183,
|
|
1459
|
+
8730,
|
|
1460
|
+
8319,
|
|
1461
|
+
178,
|
|
1462
|
+
9632,
|
|
1463
|
+
160
|
|
1464
|
+
];
|
|
1465
|
+
function entryName(e) {
|
|
1466
|
+
let name2 = e.name;
|
|
1467
|
+
if (!(e.flags & 2048) && e.nonAscii) {
|
|
1468
|
+
name2 = Array.from(name2, (ch) => {
|
|
1469
|
+
const b = ch.charCodeAt(0);
|
|
1470
|
+
return b < 128 ? ch : String.fromCodePoint(CP437_HIGH[b - 128]);
|
|
1471
|
+
}).join("");
|
|
1472
|
+
}
|
|
1473
|
+
const nul = name2.indexOf("\0");
|
|
1474
|
+
if (nul >= 0) name2 = name2.slice(0, nul);
|
|
1475
|
+
return name2.split("\\").join("/");
|
|
1476
|
+
}
|
|
1477
|
+
function safeRel(name2) {
|
|
1478
|
+
const rel = nfc(name2.split("\\").join("/"));
|
|
1479
|
+
if (rel.startsWith("/") || /^[A-Za-z]:/.test(rel)) return null;
|
|
1480
|
+
const parts = rel.split("/").filter((p) => p !== "" && p !== ".");
|
|
1481
|
+
if (!parts.length || parts.includes("..")) return null;
|
|
1482
|
+
return parts.join("/");
|
|
1483
|
+
}
|
|
1484
|
+
var litter = (rel) => rel.split("/").some((p) => p.startsWith(".") || p === "__MACOSX");
|
|
1485
|
+
function entries(bytes) {
|
|
1486
|
+
try {
|
|
1487
|
+
return centralDirectory(bytes);
|
|
1488
|
+
} catch (err) {
|
|
1489
|
+
if (err instanceof OwWorldFileError) throw new NotAZip("File is not a zip file");
|
|
1490
|
+
throw err;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function addZip(bytes, files, notes, nested) {
|
|
1494
|
+
const named = entries(bytes).map((e) => ({ e, name: entryName(e) }));
|
|
1495
|
+
named.sort((a, b) => byCodePoint(a.name, b.name));
|
|
1496
|
+
for (const { e, name: name2 } of named) {
|
|
1497
|
+
if (name2.endsWith("/")) continue;
|
|
1498
|
+
const rel = safeRel(name2);
|
|
1499
|
+
if (rel === null) {
|
|
1500
|
+
notes.push(`skipped ${repr(name2)}: an unsafe path`);
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
if (litter(rel)) {
|
|
1504
|
+
notes.push(`skipped ${rel}: not part of the export (a dot-file or __MACOSX)`);
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
if (rel.toLowerCase().endsWith(".zip") && !nested) {
|
|
1508
|
+
addZip(inflateEntry(bytes, e), files, notes, true);
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
if (files.has(rel)) {
|
|
1512
|
+
notes.push(`skipped a second ${rel} (the first one read is kept)`);
|
|
1513
|
+
continue;
|
|
1514
|
+
}
|
|
1515
|
+
files.set(rel, () => inflateEntry(bytes, e));
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
function readExportZip(bytes) {
|
|
1519
|
+
const files = /* @__PURE__ */ new Map();
|
|
1520
|
+
const notes = [];
|
|
1521
|
+
addZip(bytes, files, notes, false);
|
|
1522
|
+
const tops = new Set([...files.keys()].map((rel) => rel.split("/", 1)[0]));
|
|
1523
|
+
if (tops.size === 1 && [...files.keys()].every((rel) => rel.includes("/"))) {
|
|
1524
|
+
const stripped = /* @__PURE__ */ new Map();
|
|
1525
|
+
for (const [rel, open] of files) stripped.set(rel.slice(rel.indexOf("/") + 1), open);
|
|
1526
|
+
return { files: stripped, notes };
|
|
1527
|
+
}
|
|
1528
|
+
return { files, notes };
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// package.json
|
|
1532
|
+
var name = "@onlyworlds/sdk";
|
|
1533
|
+
var version = "4.187.0";
|
|
1534
|
+
|
|
1535
|
+
// src/convert/kanka.ts
|
|
1536
|
+
var D = kanka_default;
|
|
1537
|
+
var W = D.words;
|
|
1538
|
+
var WHERE = D.where;
|
|
1539
|
+
var WHY = D.why;
|
|
1540
|
+
var NOTE = D.notes;
|
|
1541
|
+
var R = D.report;
|
|
1542
|
+
var PREFIX = D.ext_prefix;
|
|
1543
|
+
var MODULE_TYPES = new Map(Object.entries(D.module_types));
|
|
1544
|
+
var PROVEN = new Set(D.proven_modules);
|
|
1545
|
+
var STORY = new Set(D.story_modules);
|
|
1546
|
+
var PARENT_FIELD = new Map(Object.entries(D.parent_fields));
|
|
1547
|
+
var ROOT_FILES = new Set(D.root_files);
|
|
1548
|
+
var SETTINGS_FILES = new Set(D.settings_files);
|
|
1549
|
+
var ROW_HANDLED = new Set(D.row_handled);
|
|
1550
|
+
var ENTITY_HANDLED = new Set(D.entity_handled);
|
|
1551
|
+
var NOT_KEPT_KEYS = new Set(D.not_kept_keys);
|
|
1552
|
+
var KEPT_WHEN_TRUE = new Set(D.kept_when_true);
|
|
1553
|
+
var NOT_CONTENT = new Set(D.not_content);
|
|
1554
|
+
var POST_KEPT = D.post_kept;
|
|
1555
|
+
var POST_DISPLAY = new Set(D.post_display_settings);
|
|
1556
|
+
var TRAIT_SECTIONS = new Map(
|
|
1557
|
+
Object.entries(D.trait_sections).map(([k, v]) => [Number(k), v])
|
|
1558
|
+
);
|
|
1559
|
+
var CHARACTER_LISTS = D.character_lists;
|
|
1560
|
+
var KANKA_MADE_NAMES = D.made_names;
|
|
1561
|
+
var NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
1562
|
+
var on = (v) => !among(v, [null, false, 0, "", "0", "false"]);
|
|
1563
|
+
var isPublic = (v) => v === null || eq(v, 1) || v === "1";
|
|
1564
|
+
function intId(v) {
|
|
1565
|
+
if (typeof v === "boolean") return null;
|
|
1566
|
+
if (isInt(v)) return v;
|
|
1567
|
+
if (isStr(v)) return intOfDigits(v);
|
|
1568
|
+
return null;
|
|
1569
|
+
}
|
|
1570
|
+
function or(...vs) {
|
|
1571
|
+
for (const v of vs) if (truthy(v)) return v;
|
|
1572
|
+
return vs[vs.length - 1];
|
|
1573
|
+
}
|
|
1574
|
+
function each(v) {
|
|
1575
|
+
if (!truthy(v)) return [];
|
|
1576
|
+
if (isList(v)) return v;
|
|
1577
|
+
if (isDict(v)) return [...v.keys()];
|
|
1578
|
+
if (isStr(v)) return Array.from(v);
|
|
1579
|
+
throw new TypeError(`'${v instanceof PyFloat ? "float" : typeof v === "boolean" ? "bool" : "int"}' object is not iterable`);
|
|
1580
|
+
}
|
|
1581
|
+
var dicts = (v) => each(v).filter(isDict);
|
|
1582
|
+
var MENTION = /\[entity:(\p{Nd}+)(?:\|([^\]]*))?\]/gu;
|
|
1583
|
+
var FILE_ID = /_(\p{Nd}+)\.json$/u;
|
|
1584
|
+
var INT = new RegExp(`^[${PY_SPACE}]*(-?)(\\p{Nd}+)[${PY_SPACE}]*$`, "u");
|
|
1585
|
+
var ISO = /^(\d{4})-(\d{2})-(\d{2})(?:[^](\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d+))?)?)?(?:([+-])(\d{2})(?::?(\d{2})(?::?(\d{2})(?:[.,](\d{1,6}))?)?)?)?)?$/u;
|
|
1586
|
+
function daysFromCivil(y, m, d) {
|
|
1587
|
+
const yy = m <= 2 ? y - 1 : y;
|
|
1588
|
+
const era = Math.floor(yy / 400);
|
|
1589
|
+
const yoe = yy - era * 400;
|
|
1590
|
+
const doy = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5) + d - 1;
|
|
1591
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
1592
|
+
return era * 146097 + doe - 719468;
|
|
1593
|
+
}
|
|
1594
|
+
function when(v) {
|
|
1595
|
+
if (!isStr(v) || !v) return null;
|
|
1596
|
+
const m = ISO.exec(v.split("Z").join("+00:00"));
|
|
1597
|
+
if (!m) return null;
|
|
1598
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
1599
|
+
const [h, mi, s] = [Number(m[4] ?? 0), Number(m[5] ?? 0), Number(m[6] ?? 0)];
|
|
1600
|
+
const frac = Number((m[7] ?? "").slice(0, 6).padEnd(6, "0"));
|
|
1601
|
+
const dim = [31, y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1602
|
+
if (y < 1 || mo < 1 || mo > 12 || d < 1 || d > dim[mo - 1] || h > 23 || mi > 59 || s > 59) return null;
|
|
1603
|
+
let us = BigInt(daysFromCivil(y, mo, d)) * 86400000000n + BigInt((h * 60 + mi) * 60 + s) * 1000000n + BigInt(frac);
|
|
1604
|
+
if (m[8] !== void 0) {
|
|
1605
|
+
const [oh, om, os] = [Number(m[9]), Number(m[10] ?? 0), Number(m[11] ?? 0)];
|
|
1606
|
+
const ofrac = Number((m[12] ?? "").padEnd(6, "0"));
|
|
1607
|
+
if (oh > 23 || om > 59 || os > 59) return null;
|
|
1608
|
+
const off = BigInt((oh * 60 + om) * 60 + os) * 1000000n + BigInt(ofrac);
|
|
1609
|
+
us = m[8] === "-" ? us + off : us - off;
|
|
1610
|
+
}
|
|
1611
|
+
return us;
|
|
1612
|
+
}
|
|
1613
|
+
function secondsBetween(a, b) {
|
|
1614
|
+
return Number(b - a) / 1e6;
|
|
1615
|
+
}
|
|
1616
|
+
var OPTION_KEYS = ["source", "producer"];
|
|
1617
|
+
var PRODUCER_KEYS = ["tool", "version"];
|
|
1618
|
+
var OwConvertError = class extends Error {
|
|
1619
|
+
constructor(reason, message) {
|
|
1620
|
+
super(message);
|
|
1621
|
+
this.name = "OwConvertError";
|
|
1622
|
+
this.reason = reason;
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
function kankaReportText(report, out) {
|
|
1626
|
+
return [...report.lines, out !== null ? format(R.wrote, { out }) : R.plan].join("\n") + "\n";
|
|
1627
|
+
}
|
|
1628
|
+
var Item = class extends Draft {
|
|
1629
|
+
constructor(folder, row, ent, entityId, type, id, name2, typed) {
|
|
1630
|
+
super(type, id, name2);
|
|
1631
|
+
this.folder = folder;
|
|
1632
|
+
this.row = row;
|
|
1633
|
+
this.ent = ent;
|
|
1634
|
+
this.entityId = entityId;
|
|
1635
|
+
this.typed = typed;
|
|
1636
|
+
this.secret = /* @__PURE__ */ new Map();
|
|
1637
|
+
this.secretExt = /* @__PURE__ */ new Map();
|
|
1638
|
+
this.secretMentions = [];
|
|
1639
|
+
}
|
|
1640
|
+
};
|
|
1641
|
+
var NARRATIVE_FIELDS = fieldsOf("narrative").map(([f]) => f);
|
|
1642
|
+
var RELATION_FIELDS = fieldsOf("relation").map(([f]) => f);
|
|
1643
|
+
var Reader = class {
|
|
1644
|
+
constructor(files, source, notes) {
|
|
1645
|
+
this.files = files;
|
|
1646
|
+
this.source = source;
|
|
1647
|
+
this.campaign = /* @__PURE__ */ new Map();
|
|
1648
|
+
this.items = [];
|
|
1649
|
+
this.byEntity = /* @__PURE__ */ new Map();
|
|
1650
|
+
/** `folder:row id` -> item: what a row's foreign key names. */
|
|
1651
|
+
this.byRow = /* @__PURE__ */ new Map();
|
|
1652
|
+
this.relations = [];
|
|
1653
|
+
this.narratives = [];
|
|
1654
|
+
this.uploads = /* @__PURE__ */ new Map();
|
|
1655
|
+
this.namedUploads = /* @__PURE__ */ new Set();
|
|
1656
|
+
this.modules = [];
|
|
1657
|
+
this.relationCounts = /* @__PURE__ */ new Map();
|
|
1658
|
+
this.hidden = { entities: 0, posts: 0, relationships: 0, traits: 0, personality: 0, attributes: 0, links: 0, details: 0 };
|
|
1659
|
+
this.possiblyStarter = [];
|
|
1660
|
+
this.pictures = [];
|
|
1661
|
+
this.untagged = [];
|
|
1662
|
+
this.core = new DoorCore(PREFIX, uuid5Namespace(), [...notes]);
|
|
1663
|
+
}
|
|
1664
|
+
row(folder, rowId) {
|
|
1665
|
+
return this.byRow.get(`${folder}:${rowId}`);
|
|
1666
|
+
}
|
|
1667
|
+
/** A file's JSON (UTF-8, a byte order mark dropped); null, and a note naming Python's error, when it is not readable. */
|
|
1668
|
+
json(rel) {
|
|
1669
|
+
const bytes = this.files.get(rel)();
|
|
1670
|
+
let text;
|
|
1671
|
+
try {
|
|
1672
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
1673
|
+
} catch {
|
|
1674
|
+
this.core.note(format(NOTE.not_json, { rel, error: "UnicodeDecodeError" }));
|
|
1675
|
+
return null;
|
|
1676
|
+
}
|
|
1677
|
+
try {
|
|
1678
|
+
return loads(text);
|
|
1679
|
+
} catch (err) {
|
|
1680
|
+
if (!(err instanceof PyJsonError)) throw err;
|
|
1681
|
+
this.core.note(format(NOTE.not_json, { rel, error: err.pyName }));
|
|
1682
|
+
return null;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
id(...parts) {
|
|
1686
|
+
return this.core.id(["kanka", str(get(this.campaign, "id")), ...parts].join(":"));
|
|
1687
|
+
}
|
|
1688
|
+
// -- pass 1: every entity, with its type and id ------------------------------------------
|
|
1689
|
+
collect() {
|
|
1690
|
+
const campaign = this.files.has(D.campaign_file) ? this.json(D.campaign_file) : null;
|
|
1691
|
+
if (!isDict(campaign) || empty(get(campaign, "id"))) {
|
|
1692
|
+
throw new OwConvertError("not_an_export", format(D.errors.no_campaign, { source: this.source }));
|
|
1693
|
+
}
|
|
1694
|
+
this.campaign = campaign;
|
|
1695
|
+
const info = this.files.has(D.info_file) ? this.json(D.info_file) : null;
|
|
1696
|
+
if (isDict(info)) {
|
|
1697
|
+
const version2 = get(info, "export_version");
|
|
1698
|
+
this.core.note(format(NOTE.version, { kanka_version: get(info, "kanka_version"), version: version2 }) + (str(version2) === D.proven_export_version ? "" : format(NOTE.version_unproven, { proven: D.proven_export_version })));
|
|
1699
|
+
}
|
|
1700
|
+
const born = when(get(campaign, "created_at"));
|
|
1701
|
+
const plans = /* @__PURE__ */ new Map();
|
|
1702
|
+
for (const rel of [...this.files.keys()].sort(byCodePoint)) {
|
|
1703
|
+
const parts = rel.split("/");
|
|
1704
|
+
if (parts.length === 1) {
|
|
1705
|
+
if (!ROOT_FILES.has(rel)) this.core.note(format(NOTE.root_file, { rel }));
|
|
1706
|
+
continue;
|
|
1707
|
+
}
|
|
1708
|
+
const folder = parts[0];
|
|
1709
|
+
if (folder === D.settings) {
|
|
1710
|
+
this.setting(rel);
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
if (folder === D.gallery) {
|
|
1714
|
+
this.upload(rel, parts);
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
if (parts.length !== 2 || !rel.toLowerCase().endsWith(".json")) {
|
|
1718
|
+
this.core.note(format(NOTE.not_entity_file, { rel }));
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
const row = this.json(rel);
|
|
1722
|
+
if (row === null) continue;
|
|
1723
|
+
const ent = isDict(row) ? get(row, "entity") : null;
|
|
1724
|
+
const entityId = isDict(ent) ? intId(get(ent, "id")) : null;
|
|
1725
|
+
if (!isDict(row) || !isDict(ent) || entityId === null) {
|
|
1726
|
+
this.core.note(format(NOTE.no_entity, { rel }));
|
|
1727
|
+
continue;
|
|
1728
|
+
}
|
|
1729
|
+
const m = FILE_ID.exec(rel);
|
|
1730
|
+
if (m && digitsValue(m[1]) !== entityId) this.core.note(format(NOTE.filename_id, { rel, entity_id: entityId }));
|
|
1731
|
+
if (this.byEntity.has(entityId)) {
|
|
1732
|
+
this.core.note(format(NOTE.second_file, { rel, entity_id: entityId }));
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
const given = strip(str(or(get(ent, "name"), get(row, "name"), "")));
|
|
1736
|
+
const name2 = given || format(W.untitled, { entity_id: entityId });
|
|
1737
|
+
const type = MODULE_TYPES.get(folder) ?? D.untyped_type;
|
|
1738
|
+
const item = new Item(folder, row, ent, entityId, type, this.id(String(entityId)), name2, MODULE_TYPES.has(folder));
|
|
1739
|
+
if (!given) this.core.named.set(item.id, "untitled-entity");
|
|
1740
|
+
if (on(get(ent, "is_private")) || on(get(row, "is_private"))) {
|
|
1741
|
+
item.hidden = true;
|
|
1742
|
+
this.hidden.entities++;
|
|
1743
|
+
}
|
|
1744
|
+
this.items.push(item);
|
|
1745
|
+
this.byEntity.set(entityId, item);
|
|
1746
|
+
const rowId = intId(get(row, "id"));
|
|
1747
|
+
if (rowId !== null) this.byRow.set(`${folder}:${rowId}`, item);
|
|
1748
|
+
plans.set(folder, (plans.get(folder) ?? 0) + 1);
|
|
1749
|
+
const made = when(get(ent, "created_at"));
|
|
1750
|
+
if (born !== null && made !== null) {
|
|
1751
|
+
const s = secondsBetween(born, made);
|
|
1752
|
+
if (s >= 0 && s <= D.starter_window) this.possiblyStarter.push(name2);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
for (const folder of [...plans.keys()].sort(byCodePoint)) {
|
|
1756
|
+
const status = PROVEN.has(folder) ? "proven" : MODULE_TYPES.has(folder) ? "believed" : "untyped";
|
|
1757
|
+
this.modules.push({ folder, type: MODULE_TYPES.get(folder) ?? D.untyped_type, entities: plans.get(folder), status });
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
setting(rel) {
|
|
1761
|
+
const data = this.json(rel);
|
|
1762
|
+
if (rel === D.custom_modules_file && truthy(data)) this.core.note(format(NOTE.custom_modules, { rel }));
|
|
1763
|
+
else if (!SETTINGS_FILES.has(rel)) this.core.note(format(NOTE.settings_file, { rel }));
|
|
1764
|
+
}
|
|
1765
|
+
upload(rel, parts) {
|
|
1766
|
+
if (parts.length !== 2 || !rel.toLowerCase().endsWith(".json")) return;
|
|
1767
|
+
const data = this.json(rel);
|
|
1768
|
+
if (!isDict(data)) return;
|
|
1769
|
+
const stem = rel.slice(0, -".json".length);
|
|
1770
|
+
const key = strip(str(or(get(data, "id"), ""))) || parts[1].slice(0, -".json".length);
|
|
1771
|
+
if (!this.uploads.has(key)) this.uploads.set(key, [stem, data]);
|
|
1772
|
+
}
|
|
1773
|
+
// -- pass 2: fields, links, text ---------------------------------------------------------
|
|
1774
|
+
fill() {
|
|
1775
|
+
for (const item of this.items) this.fillItem(item);
|
|
1776
|
+
this.memberships();
|
|
1777
|
+
this.tags();
|
|
1778
|
+
for (const item of this.items) this.details(item);
|
|
1779
|
+
this.relationships();
|
|
1780
|
+
}
|
|
1781
|
+
fold(item, what, rows, nameKey = "name") {
|
|
1782
|
+
return this.core.fold(what, rows, (r) => contentKey(r, NOT_CONTENT), () => item.name, (r) => str(or(get(r, nameKey), "")));
|
|
1783
|
+
}
|
|
1784
|
+
/** Entry HTML as Markdown, mentions as names (collected into `into`), unresolved ones as written. `shown`: on a visible element. */
|
|
1785
|
+
text(item, html, into = item.mentions, shown = true) {
|
|
1786
|
+
const md = htmlToMarkdown(isStr(html) ? html : null);
|
|
1787
|
+
return md.replace(MENTION, (whole, digits, label) => {
|
|
1788
|
+
const target = this.byEntity.get(digitsValue(digits));
|
|
1789
|
+
if (target === void 0) {
|
|
1790
|
+
this.core.unresolved(item.name, WHERE.mention, digits, WHY.no_entity);
|
|
1791
|
+
return whole;
|
|
1792
|
+
}
|
|
1793
|
+
if (target !== item && !into.includes(target.id)) into.push(target.id);
|
|
1794
|
+
if (shown && !item.hidden && target.hidden) this.core.note(format(NOTE.mentions_hidden, { element: item.name, target: target.name }));
|
|
1795
|
+
return label ? label : target.name;
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
hide(item, heading, line) {
|
|
1799
|
+
if (!item.secret.has(heading)) item.secret.set(heading, []);
|
|
1800
|
+
item.secret.get(heading).push(line);
|
|
1801
|
+
}
|
|
1802
|
+
fillItem(item) {
|
|
1803
|
+
const { row, ent } = item;
|
|
1804
|
+
for (const k of ["id", "entity_id", "module", "parent", "mentions"]) item.taken.add(`${PREFIX}${k}`);
|
|
1805
|
+
this.core.own(item, "id", get(row, "id"));
|
|
1806
|
+
this.core.own(item, "entity_id", item.entityId);
|
|
1807
|
+
this.core.own(item, "module", item.folder);
|
|
1808
|
+
const kind = !empty(get(ent, "type")) ? get(ent, "type") : get(row, "type");
|
|
1809
|
+
if (item.typed) {
|
|
1810
|
+
if (!empty(kind)) item.fields.set("supertype", str(kind));
|
|
1811
|
+
} else {
|
|
1812
|
+
item.fields.set("supertype", D.untyped_supertype);
|
|
1813
|
+
item.fields.set("subtype", item.folder);
|
|
1814
|
+
if (!empty(kind)) this.core.keep(item, "type", kind, WHY.untyped_type);
|
|
1815
|
+
}
|
|
1816
|
+
this.parent(item);
|
|
1817
|
+
this.image(item);
|
|
1818
|
+
const parts = [];
|
|
1819
|
+
const entry = !empty(get(ent, "entry")) ? get(ent, "entry") : get(row, "entry");
|
|
1820
|
+
const text = this.text(item, entry);
|
|
1821
|
+
if (text) parts.push(text);
|
|
1822
|
+
if (!empty(get(row, "entry")) && !empty(get(ent, "entry")) && !eq(get(row, "entry"), get(ent, "entry"))) {
|
|
1823
|
+
this.core.keep(item, "entry", get(row, "entry"), WHY.entry_differs);
|
|
1824
|
+
}
|
|
1825
|
+
parts.push(...this.posts(item));
|
|
1826
|
+
const body = parts.join("\n\n");
|
|
1827
|
+
if (body) item.fields.set(item.type === "narrative" && STORY.has(item.folder) ? "story" : "description", body);
|
|
1828
|
+
if (item.type === "character") this.character(item);
|
|
1829
|
+
this.places(item);
|
|
1830
|
+
this.attributes(item);
|
|
1831
|
+
if (item.folder !== D.organisations && !empty(get(row, "members"))) {
|
|
1832
|
+
this.core.keep(item, "members", get(row, "members"), WHY.members_elsewhere);
|
|
1833
|
+
}
|
|
1834
|
+
this.generic(item);
|
|
1835
|
+
}
|
|
1836
|
+
parent(item) {
|
|
1837
|
+
const raw = get(item.ent, "parent_id");
|
|
1838
|
+
const pid = intId(raw);
|
|
1839
|
+
if (pid === null) {
|
|
1840
|
+
if (!empty(raw)) this.core.keep(item, "parent_id", raw, WHY.parent_not_id);
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
const parent = this.byEntity.get(pid);
|
|
1844
|
+
if (parent === void 0) {
|
|
1845
|
+
this.core.unresolved(item.name, WHERE.parent, String(pid), WHY.no_entity);
|
|
1846
|
+
this.core.keep(item, "parent_id", pid, WHY.parent_missing);
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
this.core.own(item, "parent", parent.id);
|
|
1850
|
+
const field = PARENT_FIELD.get(item.type);
|
|
1851
|
+
if (field && parent.type === item.type) item.fields.set(field, parent.id);
|
|
1852
|
+
}
|
|
1853
|
+
image(item) {
|
|
1854
|
+
const raw = !empty(get(item.ent, "image_uuid")) ? get(item.ent, "image_uuid") : get(item.row, "image_uuid");
|
|
1855
|
+
if (empty(raw)) return;
|
|
1856
|
+
const key = strip(str(raw));
|
|
1857
|
+
const found = this.uploads.get(key);
|
|
1858
|
+
if (found === void 0) {
|
|
1859
|
+
this.core.own(item, "image", /* @__PURE__ */ new Map([["uuid", key]]));
|
|
1860
|
+
this.pictures.push({ element: item.name, uuid: key, path: null, original: null, private: false });
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
const [stem, data] = found;
|
|
1864
|
+
this.namedUploads.add(key);
|
|
1865
|
+
if (!item.hidden && !isPublic(get(data, "visibility_id"))) {
|
|
1866
|
+
this.core.own(item, "image", /* @__PURE__ */ new Map([["uuid", key]]));
|
|
1867
|
+
this.pictures.push({ element: item.name, uuid: key, path: null, original: null, private: true });
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
const image = /* @__PURE__ */ new Map([["uuid", key]]);
|
|
1871
|
+
for (const k of ["name", "ext"]) if (!empty(get(data, k))) image.set(k, get(data, k));
|
|
1872
|
+
this.core.own(item, "image", image);
|
|
1873
|
+
const ext = get(data, "ext");
|
|
1874
|
+
const path = !empty(ext) ? `${stem}.${str(ext)}` : stem;
|
|
1875
|
+
const original = ["name", "ext"].filter((k) => !empty(get(data, k))).map((k) => str(get(data, k))).join(".") || null;
|
|
1876
|
+
this.pictures.push({ element: item.name, uuid: key, path, original, private: false });
|
|
1877
|
+
}
|
|
1878
|
+
posts(item) {
|
|
1879
|
+
let posts = dicts(get(item.ent, "posts"));
|
|
1880
|
+
const sortKey = (p) => [get(p, "position") === null ? 1 : 0, intId(get(p, "position")) || 0, intId(get(p, "id")) || 0];
|
|
1881
|
+
posts = posts.map((p, i) => ({ p, k: sortKey(p), i })).sort((a, b) => a.k[0] - b.k[0] || a.k[1] - b.k[1] || a.k[2] - b.k[2] || a.i - b.i).map((x) => x.p);
|
|
1882
|
+
posts = this.fold(item, "post", posts);
|
|
1883
|
+
const out = [];
|
|
1884
|
+
const meta = [];
|
|
1885
|
+
for (const p of posts) {
|
|
1886
|
+
const name2 = strip(str(or(get(p, "name"), ""))) || W.post;
|
|
1887
|
+
if (!item.hidden && !isPublic(get(p, "visibility_id"))) {
|
|
1888
|
+
this.postNarrative(item, p, name2);
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
const text = this.text(item, get(p, "entry"));
|
|
1892
|
+
out.push(text ? `## ${name2}
|
|
1893
|
+
|
|
1894
|
+
${text}` : `## ${name2}`);
|
|
1895
|
+
const extra = /* @__PURE__ */ new Map();
|
|
1896
|
+
for (const k of POST_KEPT) if (on(get(p, k))) extra.set(k, get(p, k));
|
|
1897
|
+
const settings = get(p, "settings");
|
|
1898
|
+
if (isDict(settings) && [...settings.keys()].some((k) => !POST_DISPLAY.has(k))) extra.set("settings", settings);
|
|
1899
|
+
if (!isPublic(get(p, "visibility_id"))) extra.set("visibility_id", get(p, "visibility_id"));
|
|
1900
|
+
if (extra.size) meta.push(new Map([["name", name2], ...extra]));
|
|
1901
|
+
}
|
|
1902
|
+
if (meta.length) this.core.keep(item, "posts_meta", meta, WHY.posts_meta);
|
|
1903
|
+
return out;
|
|
1904
|
+
}
|
|
1905
|
+
hiddenNarrative(key, name2, story, item, ext, mentions) {
|
|
1906
|
+
const fields = /* @__PURE__ */ new Map();
|
|
1907
|
+
if (story) fields.set("story", story);
|
|
1908
|
+
this.core.linkBack(fields, item);
|
|
1909
|
+
const body = /* @__PURE__ */ new Map([["type", "narrative"], ["id", this.id(key)], ["name", name2], ["hidden", true]]);
|
|
1910
|
+
for (const f of NARRATIVE_FIELDS) if (fields.has(f)) body.set(f, fields.get(f));
|
|
1911
|
+
body.set(`${PREFIX}parent`, item.id);
|
|
1912
|
+
for (const [k, v] of ext) body.set(k, v);
|
|
1913
|
+
if (mentions.length) body.set(`${PREFIX}mentions`, mentions);
|
|
1914
|
+
this.narratives.push(body);
|
|
1915
|
+
}
|
|
1916
|
+
postNarrative(item, p, name2) {
|
|
1917
|
+
const mentions = [];
|
|
1918
|
+
const text = this.text(item, get(p, "entry"), mentions, false);
|
|
1919
|
+
const ext = /* @__PURE__ */ new Map([[`${PREFIX}id`, get(p, "id")], [`${PREFIX}module`, "posts"]]);
|
|
1920
|
+
ext.set(`${PREFIX}visibility_id`, get(p, "visibility_id"));
|
|
1921
|
+
for (const k of POST_KEPT) if (on(get(p, k))) ext.set(`${PREFIX}${k}`, get(p, k));
|
|
1922
|
+
const key = `post:${str(get(p, "id"))}`;
|
|
1923
|
+
this.hiddenNarrative(key, name2, text, item, ext, mentions);
|
|
1924
|
+
if (!strip(str(or(get(p, "name"), "")))) this.core.named.set(this.id(key), "untitled-post");
|
|
1925
|
+
this.hidden.posts++;
|
|
1926
|
+
}
|
|
1927
|
+
details(item) {
|
|
1928
|
+
if (!item.secret.size && !item.secretExt.size) return;
|
|
1929
|
+
const story = [...item.secret].map(([h, lines]) => `## ${h}
|
|
1930
|
+
|
|
1931
|
+
${lines.join("\n")}`).join("\n\n");
|
|
1932
|
+
const ext = new Map([[`${PREFIX}entity_id`, item.entityId], ...item.secretExt]);
|
|
1933
|
+
const key = `hidden:${item.entityId}`;
|
|
1934
|
+
this.hiddenNarrative(key, format(W.hidden_details, { name: item.name }), story, item, ext, item.secretMentions);
|
|
1935
|
+
this.core.named.set(this.id(key), "hidden-details");
|
|
1936
|
+
this.hidden.details++;
|
|
1937
|
+
}
|
|
1938
|
+
character(item) {
|
|
1939
|
+
const row = item.row;
|
|
1940
|
+
const traits = this.fold(item, "trait", dicts(get(row, "character_traits")));
|
|
1941
|
+
const personalityHidden = get(row, "is_personality_visible") !== null && !on(get(row, "is_personality_visible"));
|
|
1942
|
+
const sections = /* @__PURE__ */ new Map();
|
|
1943
|
+
const other = [];
|
|
1944
|
+
for (const t of traits) {
|
|
1945
|
+
const section = intId(get(t, "section_id"));
|
|
1946
|
+
const priv = on(get(t, "is_private"));
|
|
1947
|
+
const tname = strip(str(or(get(t, "name"), "")));
|
|
1948
|
+
if (!item.hidden && (priv || section === D.personality_section && personalityHidden)) {
|
|
1949
|
+
const entry = this.text(item, get(t, "entry"), item.secretMentions, false);
|
|
1950
|
+
const heading = TRAIT_SECTIONS.get(section || 0)?.heading ?? W.traits_heading;
|
|
1951
|
+
this.hide(item, heading, strip(`${tname}: ${entry}`));
|
|
1952
|
+
if (priv) this.hidden.traits++;
|
|
1953
|
+
else this.hidden.personality++;
|
|
1954
|
+
continue;
|
|
1955
|
+
}
|
|
1956
|
+
const line = strip(`${tname}: ${this.text(item, get(t, "entry"))}`);
|
|
1957
|
+
if (section !== null && TRAIT_SECTIONS.has(section)) {
|
|
1958
|
+
if (!sections.has(section)) sections.set(section, []);
|
|
1959
|
+
sections.get(section).push(line);
|
|
1960
|
+
} else {
|
|
1961
|
+
other.push(/* @__PURE__ */ new Map([["name", get(t, "name")], ["entry", get(t, "entry")], ["section_id", get(t, "section_id")]]));
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
const dead = on(get(row, "is_dead"));
|
|
1965
|
+
for (const [section, to] of TRAIT_SECTIONS) {
|
|
1966
|
+
let text = (sections.get(section) ?? []).join("\n");
|
|
1967
|
+
if (dead && to.field === D.deceased_field) text = rstrip(`${W.deceased}${text}`);
|
|
1968
|
+
if (text) item.fields.set(to.field, text);
|
|
1969
|
+
}
|
|
1970
|
+
if (other.length) this.core.keep(item, "traits", other, WHY.traits_other);
|
|
1971
|
+
for (const lst of CHARACTER_LISTS) {
|
|
1972
|
+
const ids = this.list(item, lst.key, lst.id_key);
|
|
1973
|
+
if (lst.row_key !== null && intId(get(row, lst.row_key)) !== null) ids.push(get(row, lst.row_key));
|
|
1974
|
+
this.linkRows(item, lst.field, lst.folder, ids, lst.key);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
/** The ids a row's list names (`[{"race_id": 3}, ...]` or `[3, ...]`); the list kept when it says more. */
|
|
1978
|
+
list(item, key, idKey) {
|
|
1979
|
+
const ids = [];
|
|
1980
|
+
let more = false;
|
|
1981
|
+
const skip = /* @__PURE__ */ new Set([idKey, "id", "is_private", ...NOT_CONTENT]);
|
|
1982
|
+
for (const x of each(get(item.row, key))) {
|
|
1983
|
+
if (isDict(x)) {
|
|
1984
|
+
if (on(get(x, "is_private")) && !item.hidden) {
|
|
1985
|
+
const ext = `${PREFIX}${normKey(key)}`;
|
|
1986
|
+
if (!item.secretExt.has(ext)) item.secretExt.set(ext, []);
|
|
1987
|
+
item.secretExt.get(ext).push(x);
|
|
1988
|
+
this.hidden.links++;
|
|
1989
|
+
continue;
|
|
1990
|
+
}
|
|
1991
|
+
ids.push(get(x, idKey));
|
|
1992
|
+
if ([...x].some(([k, v]) => !empty(v) && !skip.has(k))) more = true;
|
|
1993
|
+
} else ids.push(x);
|
|
1994
|
+
}
|
|
1995
|
+
if (more) {
|
|
1996
|
+
const shown = each(get(item.row, key)).filter((x) => item.hidden || !(isDict(x) && on(get(x, "is_private"))));
|
|
1997
|
+
this.core.keep(item, key, shown, WHY.list_more);
|
|
1998
|
+
}
|
|
1999
|
+
return ids;
|
|
2000
|
+
}
|
|
2001
|
+
/** Module row ids of `folder` onto the multi-link `field`. */
|
|
2002
|
+
linkRows(item, field, folder, rawIds, where) {
|
|
2003
|
+
const ids = [];
|
|
2004
|
+
for (const raw of rawIds) {
|
|
2005
|
+
const rid = intId(raw);
|
|
2006
|
+
const target = rid !== null ? this.row(folder, rid) : void 0;
|
|
2007
|
+
if (target === void 0) this.core.unresolved(item.name, where, str(raw), format(WHY.no_row, { folder }));
|
|
2008
|
+
else if (!ids.includes(target.id)) ids.push(target.id);
|
|
2009
|
+
}
|
|
2010
|
+
if (ids.length) {
|
|
2011
|
+
if (!item.fields.has(field)) item.fields.set(field, []);
|
|
2012
|
+
const links = item.fields.get(field);
|
|
2013
|
+
links.push(...ids.filter((e) => !links.includes(e)));
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
places(item) {
|
|
2017
|
+
const raw = each(get(item.ent, "entityLocations")).map((x) => isDict(x) ? get(x, "location_id") : x);
|
|
2018
|
+
if (intId(get(item.row, "location_id")) !== null) raw.push(get(item.row, "location_id"));
|
|
2019
|
+
const ids = [];
|
|
2020
|
+
for (const r of raw) {
|
|
2021
|
+
const rid = intId(r);
|
|
2022
|
+
const target = rid !== null ? this.row("locations", rid) : void 0;
|
|
2023
|
+
if (target === void 0) this.core.unresolved(item.name, "entityLocations", str(r), WHY.no_locations_row);
|
|
2024
|
+
else if (!ids.includes(target.id)) ids.push(target.id);
|
|
2025
|
+
}
|
|
2026
|
+
if (!ids.length) return;
|
|
2027
|
+
const t = item.type;
|
|
2028
|
+
if (kindOf(t, "location") === "single_link" && targetOf(t, "location") === "location") {
|
|
2029
|
+
item.fields.set("location", ids[0]);
|
|
2030
|
+
if (ids.length > 1) this.core.keep(item, "locations", ids, WHY.locations_one);
|
|
2031
|
+
} else if (kindOf(t, "locations") === "multi_link" && targetOf(t, "locations") === "location") {
|
|
2032
|
+
item.fields.set("locations", ids);
|
|
2033
|
+
} else {
|
|
2034
|
+
this.core.keep(item, "locations", ids, format(WHY.no_location_field, { type: t }));
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
attributes(item) {
|
|
2038
|
+
const attrs = dicts(get(item.ent, "entityAttributes"));
|
|
2039
|
+
const allPrivate = on(get(item.ent, "is_attributes_private"));
|
|
2040
|
+
for (const a of this.fold(item, "attribute", attrs)) {
|
|
2041
|
+
if (!item.hidden && (allPrivate || on(get(a, "is_private")) || on(get(a, "is_hidden")))) {
|
|
2042
|
+
const raw = get(a, "value");
|
|
2043
|
+
if (empty(raw) || !strip(str(or(get(a, "name"), "")))) continue;
|
|
2044
|
+
const value = isStr(raw) ? this.text(item, raw, item.secretMentions, false) : raw;
|
|
2045
|
+
this.hide(item, W.attributes_heading, `${strip(str(get(a, "name")))}: ${str(value)}`);
|
|
2046
|
+
this.hidden.attributes++;
|
|
2047
|
+
continue;
|
|
2048
|
+
}
|
|
2049
|
+
this.attribute(item, a);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
attribute(item, a) {
|
|
2053
|
+
const key = strip(str(or(get(a, "name"), "")));
|
|
2054
|
+
const raw = get(a, "value");
|
|
2055
|
+
if (empty(raw) || !key) return;
|
|
2056
|
+
const before = [...item.mentions];
|
|
2057
|
+
const text = isStr(raw) ? this.text(item, raw) : raw;
|
|
2058
|
+
const field = fieldByLower(item.type, normKey(key));
|
|
2059
|
+
let why;
|
|
2060
|
+
if (field === void 0) why = format(WHY.no_field, { type: item.type, field: normKey(key) });
|
|
2061
|
+
else if (field === "name" || field === "supertype" || field === "subtype" || item.fields.has(field)) {
|
|
2062
|
+
why = format(WHY.already_set, { field });
|
|
2063
|
+
} else {
|
|
2064
|
+
const kind = kindOf(item.type, field);
|
|
2065
|
+
if (kind === "text") {
|
|
2066
|
+
item.fields.set(field, str(text));
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
if (kind === "integer") {
|
|
2070
|
+
if (typeof raw === "boolean") {
|
|
2071
|
+
item.fields.set(field, raw ? 1 : 0);
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
if (isInt(raw)) {
|
|
2075
|
+
item.fields.set(field, raw);
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2078
|
+
const m = isStr(raw) ? INT.exec(raw) : null;
|
|
2079
|
+
if (m) {
|
|
2080
|
+
const n = digitsValue(m[2]);
|
|
2081
|
+
item.fields.set(field, m[1] && n !== 0 ? -n : n);
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
why = format(WHY.not_integer, { field });
|
|
2085
|
+
} else {
|
|
2086
|
+
const target = targetOf(item.type, field) ?? "";
|
|
2087
|
+
const s = str(raw);
|
|
2088
|
+
const ids = [...s.matchAll(MENTION)].map((m) => digitsValue(m[1]));
|
|
2089
|
+
const rest = stripChars(s.replace(MENTION, ""), " ,;\n");
|
|
2090
|
+
const hits = ids.map((i) => this.byEntity.get(i));
|
|
2091
|
+
const distinct = new Set(ids).size;
|
|
2092
|
+
if (!ids.length || rest) why = format(WHY.not_mentions, { field, target });
|
|
2093
|
+
else if (hits.some((h) => h === void 0 || h.type !== target)) why = format(WHY.mention_not_found, { field, target });
|
|
2094
|
+
else if (kind === "single_link" && distinct > 1) why = format(WHY.links_one, { field, n: distinct });
|
|
2095
|
+
else {
|
|
2096
|
+
const linked = [...new Set(hits.map((h) => h.id))];
|
|
2097
|
+
item.fields.set(field, kind === "single_link" ? linked[0] : linked);
|
|
2098
|
+
item.mentions.length = 0;
|
|
2099
|
+
item.mentions.push(...before);
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
this.core.keep(item, key, text, why);
|
|
2105
|
+
}
|
|
2106
|
+
/** Every key of the row and the entity not read above, kept as `x_kanka_<key>`. */
|
|
2107
|
+
generic(item) {
|
|
2108
|
+
for (const [where, data, handled] of [["row", item.row, ROW_HANDLED], ["entity", item.ent, ENTITY_HANDLED]]) {
|
|
2109
|
+
for (const [key, value] of data) {
|
|
2110
|
+
if (handled.has(key) || NOT_KEPT_KEYS.has(key) || empty(value)) continue;
|
|
2111
|
+
if (KEPT_WHEN_TRUE.has(key) && !on(value)) continue;
|
|
2112
|
+
this.core.keep(item, key, value, format(WHY.no_field_for_key, { where, key }));
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
// -- links that need every element ---------------------------------------------------------
|
|
2117
|
+
memberships() {
|
|
2118
|
+
for (const org of this.items) {
|
|
2119
|
+
if (org.folder !== D.organisations) continue;
|
|
2120
|
+
for (const m of each(get(org.row, "members"))) {
|
|
2121
|
+
const cid = isDict(m) ? intId(get(m, "character_id")) : intId(m);
|
|
2122
|
+
if (isDict(m) && on(get(m, "is_private")) && !org.hidden) {
|
|
2123
|
+
const ext = `${PREFIX}members`;
|
|
2124
|
+
if (!org.secretExt.has(ext)) org.secretExt.set(ext, []);
|
|
2125
|
+
org.secretExt.get(ext).push(m);
|
|
2126
|
+
this.hidden.links++;
|
|
2127
|
+
continue;
|
|
2128
|
+
}
|
|
2129
|
+
const member = cid !== null ? this.row("characters", cid) : void 0;
|
|
2130
|
+
if (member === void 0) {
|
|
2131
|
+
this.core.unresolved(org.name, "members", cid === null ? "None" : String(cid), WHY.no_characters_row);
|
|
2132
|
+
continue;
|
|
2133
|
+
}
|
|
2134
|
+
if (!member.fields.has("institutions")) member.fields.set("institutions", []);
|
|
2135
|
+
const links = member.fields.get("institutions");
|
|
2136
|
+
if (!links.includes(org.id)) links.push(org.id);
|
|
2137
|
+
}
|
|
2138
|
+
const members = each(get(org.row, "members")).filter((m) => org.hidden || !(isDict(m) && on(get(m, "is_private"))));
|
|
2139
|
+
const skip = /* @__PURE__ */ new Set(["id", "character_id", "organisation_id", "is_private", ...NOT_CONTENT]);
|
|
2140
|
+
if (members.some((m) => isDict(m) && [...m].some(([k, v]) => !skip.has(k) && !empty(v)))) {
|
|
2141
|
+
this.core.keep(org, "members", members, WHY.member_role);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
/** A tag's Narrative links each element that carries it, tags and carriers in entity id order; a visible tag never links a hidden element. */
|
|
2146
|
+
tags() {
|
|
2147
|
+
const carried = /* @__PURE__ */ new Map();
|
|
2148
|
+
for (const item of this.items) {
|
|
2149
|
+
for (const t of each(get(item.ent, "entityTags"))) {
|
|
2150
|
+
const raw = isDict(t) ? get(t, "tag_id") : t;
|
|
2151
|
+
const rid = intId(raw);
|
|
2152
|
+
const tag = rid !== null ? this.row("tags", rid) : void 0;
|
|
2153
|
+
if (tag === void 0) {
|
|
2154
|
+
this.core.unresolved(item.name, "entityTags", str(raw), WHY.no_tags_row);
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
if (!carried.has(tag.entityId)) carried.set(tag.entityId, /* @__PURE__ */ new Map());
|
|
2158
|
+
carried.get(tag.entityId).set(item.entityId, item);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
for (const tagId of [...carried.keys()].sort((a, b) => a - b)) {
|
|
2162
|
+
const tag = this.byEntity.get(tagId);
|
|
2163
|
+
const carriers = carried.get(tagId);
|
|
2164
|
+
for (const entityId of [...carriers.keys()].sort((a, b) => a - b)) {
|
|
2165
|
+
const item = carriers.get(entityId);
|
|
2166
|
+
if (item.hidden && !tag.hidden) {
|
|
2167
|
+
this.untagged.push({ tag: tag.name, element: item.name, why: WHY.tag_hidden });
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
const field = narrativeFieldFor(item.type);
|
|
2171
|
+
if (field === void 0) {
|
|
2172
|
+
this.untagged.push({ tag: tag.name, element: item.name, why: format(WHY.tag_no_field, { type: item.type }) });
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
if (!tag.fields.has(field)) tag.fields.set(field, []);
|
|
2176
|
+
const links = tag.fields.get(field);
|
|
2177
|
+
if (!links.includes(item.id)) links.push(item.id);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
relationships() {
|
|
2182
|
+
const rows = /* @__PURE__ */ new Map();
|
|
2183
|
+
for (const item of this.items) {
|
|
2184
|
+
for (const rel of each(get(item.ent, "relationships"))) {
|
|
2185
|
+
const rid = isDict(rel) ? intId(get(rel, "id")) : null;
|
|
2186
|
+
if (rid === null || !isDict(rel)) continue;
|
|
2187
|
+
rows.set(rid, [item, rel]);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
const units = [];
|
|
2191
|
+
const used = /* @__PURE__ */ new Set();
|
|
2192
|
+
for (const rid of [...rows.keys()].sort((a, b) => a - b)) {
|
|
2193
|
+
if (used.has(rid)) continue;
|
|
2194
|
+
const [item, rel] = rows.get(rid);
|
|
2195
|
+
const mid = intId(get(rel, "mirror_id"));
|
|
2196
|
+
const pair = mid !== null ? rows.get(mid) : void 0;
|
|
2197
|
+
if (mid !== null && pair !== void 0 && intId(get(pair[1], "mirror_id")) === rid && !used.has(mid)) {
|
|
2198
|
+
used.add(rid);
|
|
2199
|
+
used.add(mid);
|
|
2200
|
+
units.push([rid, item, rel, pair[1]]);
|
|
2201
|
+
} else {
|
|
2202
|
+
used.add(rid);
|
|
2203
|
+
if (mid !== null && !rows.has(mid)) {
|
|
2204
|
+
this.core.note(format(NOTE.mirror_missing, { relation: get(rel, "relation"), element: item.name, mirror: mid }));
|
|
2205
|
+
}
|
|
2206
|
+
units.push([rid, item, rel, null]);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
const kept = this.core.fold(
|
|
2210
|
+
"relationship",
|
|
2211
|
+
units,
|
|
2212
|
+
([, , rel, mirror]) => `${contentKey(rel, NOT_CONTENT)}|${mirror !== null ? contentKey(mirror, NOT_CONTENT) : ""}`,
|
|
2213
|
+
([, owner]) => owner.name,
|
|
2214
|
+
([, , rel]) => str(or(get(rel, "relation"), ""))
|
|
2215
|
+
);
|
|
2216
|
+
for (const unit of kept) this.relation(...unit);
|
|
2217
|
+
}
|
|
2218
|
+
relation(rid, owner, rel, mirror) {
|
|
2219
|
+
const text = strip(str(or(get(rel, "relation"), "")));
|
|
2220
|
+
const tid = intId(get(rel, "target_id"));
|
|
2221
|
+
const target = tid !== null ? this.byEntity.get(tid) : void 0;
|
|
2222
|
+
if (target === void 0) {
|
|
2223
|
+
this.core.unresolved(owner.name, format(WHERE.relationship, { text }), str(get(rel, "target_id")), WHY.no_entity);
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
const name2 = text || W.relationship;
|
|
2227
|
+
if (!text) this.core.note(format(NOTE.no_text, { owner: owner.name, target: target.name, name: name2 }));
|
|
2228
|
+
const fields = /* @__PURE__ */ new Map();
|
|
2229
|
+
if (owner.type === "character") fields.set("actor", owner.id);
|
|
2230
|
+
for (const end of owner.type !== "character" ? [owner, target] : [target]) {
|
|
2231
|
+
const field = relationFieldFor(end.type);
|
|
2232
|
+
if (field === void 0) {
|
|
2233
|
+
this.core.note(format(NOTE.no_relation_field, { name: name2, owner: owner.name, type: end.type, end: end.name }));
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
if (!fields.has(field)) fields.set(field, []);
|
|
2237
|
+
const links = fields.get(field);
|
|
2238
|
+
if (!links.includes(end.id)) links.push(end.id);
|
|
2239
|
+
}
|
|
2240
|
+
const id = this.id("relation", String(rid));
|
|
2241
|
+
const body = /* @__PURE__ */ new Map([["type", "relation"], ["id", id], ["name", name2]]);
|
|
2242
|
+
if (!text) this.core.named.set(id, "untitled-relationship");
|
|
2243
|
+
const sides = mirror !== null ? [rel, mirror] : [rel];
|
|
2244
|
+
if (owner.hidden || target.hidden || sides.some((s) => !isPublic(get(s, "visibility_id")))) {
|
|
2245
|
+
body.set("hidden", true);
|
|
2246
|
+
this.hidden.relationships++;
|
|
2247
|
+
}
|
|
2248
|
+
for (const f of RELATION_FIELDS) if (fields.has(f)) body.set(f, fields.get(f));
|
|
2249
|
+
body.set(`${PREFIX}id`, rid);
|
|
2250
|
+
body.set(`${PREFIX}source`, owner.id);
|
|
2251
|
+
body.set(`${PREFIX}target`, target.id);
|
|
2252
|
+
if (mirror !== null) {
|
|
2253
|
+
body.set(`${PREFIX}two_way`, true);
|
|
2254
|
+
const content = (r) => new Map([...r].filter(([k]) => !NOT_CONTENT.has(k) && k !== "owner_id" && k !== "target_id"));
|
|
2255
|
+
const mine = content(rel);
|
|
2256
|
+
const theirs = content(mirror);
|
|
2257
|
+
const differs = /* @__PURE__ */ new Map();
|
|
2258
|
+
for (const k of [...theirs.keys()].sort(byCodePoint)) {
|
|
2259
|
+
if (!eq(get(mine, k), theirs.get(k))) differs.set(k, theirs.get(k));
|
|
2260
|
+
}
|
|
2261
|
+
if (differs.size) body.set(`${PREFIX}mirror`, differs);
|
|
2262
|
+
}
|
|
2263
|
+
if (get(rel, "attitude") !== null) body.set(`${PREFIX}attitude`, get(rel, "attitude"));
|
|
2264
|
+
if (!empty(get(rel, "colour"))) body.set(`${PREFIX}colour`, get(rel, "colour"));
|
|
2265
|
+
if (!isPublic(get(rel, "visibility_id"))) body.set(`${PREFIX}visibility_id`, get(rel, "visibility_id"));
|
|
2266
|
+
this.relations.push(body);
|
|
2267
|
+
this.relationCounts.set(name2, (this.relationCounts.get(name2) ?? 0) + 1);
|
|
2268
|
+
}
|
|
2269
|
+
// -- the bodies and the world -------------------------------------------------------------
|
|
2270
|
+
bodies() {
|
|
2271
|
+
const out = [...this.items.map((item) => this.core.body(item)), ...this.narratives, ...this.relations];
|
|
2272
|
+
if (this.items.length) this.core.note(NOTE.not_kept);
|
|
2273
|
+
return out;
|
|
2274
|
+
}
|
|
2275
|
+
world(producer) {
|
|
2276
|
+
const cid = get(this.campaign, "id");
|
|
2277
|
+
const name2 = strip(str(or(get(this.campaign, "name"), ""))) || format(W.campaign, { id: cid });
|
|
2278
|
+
const entry = get(this.campaign, "entry");
|
|
2279
|
+
return worldOf(this.core.id(`kanka:${str(cid)}`), name2, !empty(entry) ? htmlToMarkdown(str(entry)) : null, producer, D.producer_input);
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
var namespace = null;
|
|
2283
|
+
function uuid5Namespace() {
|
|
2284
|
+
namespace ?? (namespace = uuid5(NAMESPACE_URL, D.namespace_url));
|
|
2285
|
+
return namespace;
|
|
2286
|
+
}
|
|
2287
|
+
function counted(n, pair) {
|
|
2288
|
+
return `${n} ${n === 1 ? pair[0] : pair[1]}`;
|
|
2289
|
+
}
|
|
2290
|
+
function render(r) {
|
|
2291
|
+
const lines = [];
|
|
2292
|
+
const byType = Object.entries(r.counts).map(([t, n]) => `${t} ${n}`).join(", ");
|
|
2293
|
+
lines.push(format(R.head, { source: r.source, name: r.worldName, total: r.total, by_type: byType || R.head_none }));
|
|
2294
|
+
if (r.modules.length) {
|
|
2295
|
+
lines.push(R.modules);
|
|
2296
|
+
for (const m of r.modules) {
|
|
2297
|
+
const how = format(R.how[m.status], { supertype: D.untyped_supertype, folder: m.folder });
|
|
2298
|
+
lines.push(format(R.module, { folder: m.folder, entities: m.entities, type: m.type, how }));
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
if (r.relations.length) {
|
|
2302
|
+
const listed = r.relations.map((x) => `${repr(x.text)} ${x.count}`).join(", ");
|
|
2303
|
+
lines.push(format(R.relations, { n: r.relations.reduce((a, x) => a + x.count, 0), listed }));
|
|
2304
|
+
}
|
|
2305
|
+
if (r.folded.length) {
|
|
2306
|
+
lines.push(format(R.folded, { n: r.folded.length }));
|
|
2307
|
+
for (const f of r.folded) lines.push(format(R.fold, { element: f.element, copies: f.copies, what: f.what, name: f.name }));
|
|
2308
|
+
}
|
|
2309
|
+
if (r.possiblyStarter.length) {
|
|
2310
|
+
lines.push(format(R.starter, { window: D.starter_window, listed: r.possiblyStarter.map(repr).join(", ") }));
|
|
2311
|
+
}
|
|
2312
|
+
const h = r.hidden;
|
|
2313
|
+
const said = Object.entries(R.hidden_elements).filter(([k]) => h[k]).map(([k, pair]) => counted(h[k], pair));
|
|
2314
|
+
const inside = Object.entries(R.hidden_held).filter(([k]) => h[k]).map(([k, pair]) => counted(h[k], pair));
|
|
2315
|
+
if (inside.length) said.push(format(R.hidden_details[r.hidden.details === 1 ? 0 : 1], { n: r.hidden.details, held: inside.join(", ") }));
|
|
2316
|
+
if (said.length) lines.push(format(R.hidden, { said: said.join("; ") }));
|
|
2317
|
+
if (r.untagged.length) {
|
|
2318
|
+
lines.push(format(R.untagged, { n: r.untagged.length }));
|
|
2319
|
+
for (const u of r.untagged) lines.push(format(R.untag, { tag: u.tag, element: u.element, why: u.why }));
|
|
2320
|
+
}
|
|
2321
|
+
if (r.uploads) lines.push(format(R.uploads[r.uploads === 1 ? 0 : 1], { n: r.uploads, named: r.uploadsNamed }));
|
|
2322
|
+
if (r.pictures.length) {
|
|
2323
|
+
lines.push(format(R.pictures, { n: r.pictures.length }));
|
|
2324
|
+
for (const p of r.pictures) {
|
|
2325
|
+
if (p.private) lines.push(format(R.picture_private, { element: p.element, uuid: p.uuid }));
|
|
2326
|
+
else if (p.path === null) lines.push(format(R.picture_missing, { element: p.element, uuid: p.uuid }));
|
|
2327
|
+
else lines.push(format(p.original ? R.picture_original : R.picture, { element: p.element, path: p.path, original: p.original }));
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
if (r.unplaced.length) {
|
|
2331
|
+
lines.push(format(R.unplaced, { n: r.unplaced.length }));
|
|
2332
|
+
for (const u of r.unplaced) lines.push(format(R.unplaced_item, { element: u.element, key: u.key, why: u.why, kept_as: u.keptAs }));
|
|
2333
|
+
}
|
|
2334
|
+
if (r.unresolved.length) {
|
|
2335
|
+
lines.push(format(R.unresolved, { n: r.unresolved.length }));
|
|
2336
|
+
for (const u of r.unresolved) lines.push(format(R.unresolved_item, { element: u.element, where: u.where, target: u.target, why: u.why }));
|
|
2337
|
+
}
|
|
2338
|
+
lines.push(...madeNameLines(KANKA_MADE_NAMES, r.madeNames));
|
|
2339
|
+
if (r.notes.length) {
|
|
2340
|
+
lines.push(format(R.notes, { n: r.notes.length }));
|
|
2341
|
+
for (const n of r.notes) lines.push(format(R.note, { note: n }));
|
|
2342
|
+
}
|
|
2343
|
+
return lines;
|
|
2344
|
+
}
|
|
2345
|
+
function convertKanka(bytes, opts = {}) {
|
|
2346
|
+
refuseUnknownOptions("convertKanka", opts, OPTION_KEYS);
|
|
2347
|
+
if (opts.producer !== void 0) refuseUnknownOptions("convertKanka", opts.producer, PRODUCER_KEYS, "(in producer)");
|
|
2348
|
+
if (!(bytes instanceof Uint8Array)) throw new TypeError("convertKanka: the export is the zip's bytes, a Uint8Array.");
|
|
2349
|
+
const source = opts.source ?? "export.zip";
|
|
2350
|
+
const producer = opts.producer ?? { tool: name, version };
|
|
2351
|
+
let tree;
|
|
2352
|
+
try {
|
|
2353
|
+
tree = readExportZip(bytes);
|
|
2354
|
+
} catch (err) {
|
|
2355
|
+
if (err instanceof NotAZip) throw new OwConvertError("not_a_zip", `${source}: not a zip file (${err.message})`);
|
|
2356
|
+
throw err;
|
|
2357
|
+
}
|
|
2358
|
+
const reader = new Reader(tree.files, source, tree.notes);
|
|
2359
|
+
reader.collect();
|
|
2360
|
+
reader.fill();
|
|
2361
|
+
const bodies = reader.bodies();
|
|
2362
|
+
const elements = grouped(bodies);
|
|
2363
|
+
const counts = {};
|
|
2364
|
+
for (const t of [...elements.keys()].sort(byCodePoint)) counts[t] = elements.get(t).length;
|
|
2365
|
+
const madeNames = reader.core.madeNames(KANKA_MADE_NAMES, bodies.map((b) => b.get("id")));
|
|
2366
|
+
const world = reader.world(producer);
|
|
2367
|
+
const { unplaced, unresolved, folded, notes } = reader.core.findings;
|
|
2368
|
+
const base = {
|
|
2369
|
+
source,
|
|
2370
|
+
worldName: world.get("name"),
|
|
2371
|
+
counts,
|
|
2372
|
+
total: bodies.length,
|
|
2373
|
+
modules: reader.modules,
|
|
2374
|
+
relations: [...reader.relationCounts].sort((a, b) => byCodePoint(a[0], b[0])).map(([text, count]) => ({ text, count })),
|
|
2375
|
+
folded,
|
|
2376
|
+
unplaced,
|
|
2377
|
+
unresolved,
|
|
2378
|
+
hidden: reader.hidden,
|
|
2379
|
+
possiblyStarter: reader.possiblyStarter,
|
|
2380
|
+
uploads: reader.uploads.size,
|
|
2381
|
+
uploadsNamed: reader.namedUploads.size,
|
|
2382
|
+
pictures: reader.pictures,
|
|
2383
|
+
untagged: reader.untagged,
|
|
2384
|
+
madeNames,
|
|
2385
|
+
notes
|
|
2386
|
+
};
|
|
2387
|
+
return { files: folderFiles(world, elements), report: { ...base, lines: render(base) } };
|
|
2388
|
+
}
|
|
2389
|
+
export {
|
|
2390
|
+
ANY_TYPE,
|
|
2391
|
+
KANKA_MADE_NAMES,
|
|
2392
|
+
OwConvertError,
|
|
2393
|
+
convertKanka,
|
|
2394
|
+
kankaReportText
|
|
2395
|
+
};
|