vite-plugin-sitemap 0.1.1

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/dist/index.mjs ADDED
@@ -0,0 +1,3872 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
25
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
26
+ }) : x)(function(x) {
27
+ if (typeof require !== "undefined")
28
+ return require.apply(this, arguments);
29
+ throw new Error('Dynamic require of "' + x + '" is not supported');
30
+ });
31
+ var __esm = (fn, res) => function __init() {
32
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
33
+ };
34
+ var __commonJS = (cb, mod) => function __require2() {
35
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
36
+ };
37
+ var __copyProps = (to, from, except, desc) => {
38
+ if (from && typeof from === "object" || typeof from === "function") {
39
+ for (let key of __getOwnPropNames(from))
40
+ if (!__hasOwnProp.call(to, key) && key !== except)
41
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
+ }
43
+ return to;
44
+ };
45
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
46
+ var __accessCheck = (obj, member, msg) => {
47
+ if (!member.has(obj))
48
+ throw TypeError("Cannot " + msg);
49
+ };
50
+ var __privateGet = (obj, member, getter) => {
51
+ __accessCheck(obj, member, "read from private field");
52
+ return getter ? getter.call(obj) : member.get(obj);
53
+ };
54
+ var __privateAdd = (obj, member, value) => {
55
+ if (member.has(obj))
56
+ throw TypeError("Cannot add the same private member more than once");
57
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
58
+ };
59
+ var __privateSet = (obj, member, value, setter) => {
60
+ __accessCheck(obj, member, "write to private field");
61
+ setter ? setter.call(obj, value) : member.set(obj, value);
62
+ return value;
63
+ };
64
+ var __privateWrapper = (obj, member, setter, getter) => {
65
+ return {
66
+ set _(value) {
67
+ __privateSet(obj, member, value, setter);
68
+ },
69
+ get _() {
70
+ return __privateGet(obj, member, getter);
71
+ }
72
+ };
73
+ };
74
+
75
+ // node_modules/.pnpm/tsup@5.12.6_typescript@4.6.3/node_modules/tsup/assets/esm_shims.js
76
+ import { fileURLToPath } from "url";
77
+ import path from "path";
78
+ var getFilename, getDirname, __dirname;
79
+ var init_esm_shims = __esm({
80
+ "node_modules/.pnpm/tsup@5.12.6_typescript@4.6.3/node_modules/tsup/assets/esm_shims.js"() {
81
+ getFilename = () => fileURLToPath(import.meta.url);
82
+ getDirname = () => path.dirname(getFilename());
83
+ __dirname = /* @__PURE__ */ getDirname();
84
+ }
85
+ });
86
+
87
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/errors.js
88
+ var require_errors = __commonJS({
89
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/errors.js"(exports) {
90
+ "use strict";
91
+ init_esm_shims();
92
+ Object.defineProperty(exports, "__esModule", { value: true });
93
+ exports.EmptySitemap = exports.EmptyStream = exports.InvalidVideoPriceCurrency = exports.InvalidVideoResolution = exports.InvalidVideoPriceType = exports.InvalidVideoRestrictionRelationship = exports.InvalidVideoRestriction = exports.InvalidVideoFamilyFriendly = exports.InvalidVideoCategory = exports.InvalidVideoTagCount = exports.InvalidVideoViewCount = exports.InvalidVideoTitle = exports.XMLLintUnavailable = exports.InvalidNewsAccessValue = exports.InvalidNewsFormat = exports.InvalidAttr = exports.InvalidAttrValue = exports.InvalidVideoRating = exports.InvalidVideoDescription = exports.InvalidVideoDuration = exports.InvalidVideoFormat = exports.UndefinedTargetFolder = exports.PriorityInvalidError = exports.ChangeFreqInvalidError = exports.NoConfigError = exports.NoURLError = void 0;
94
+ var NoURLError = class extends Error {
95
+ constructor(message) {
96
+ super(message || "URL is required");
97
+ this.name = "NoURLError";
98
+ Error.captureStackTrace(this, NoURLError);
99
+ }
100
+ };
101
+ exports.NoURLError = NoURLError;
102
+ var NoConfigError = class extends Error {
103
+ constructor(message) {
104
+ super(message || "SitemapItem requires a configuration");
105
+ this.name = "NoConfigError";
106
+ Error.captureStackTrace(this, NoConfigError);
107
+ }
108
+ };
109
+ exports.NoConfigError = NoConfigError;
110
+ var ChangeFreqInvalidError = class extends Error {
111
+ constructor(url, changefreq) {
112
+ super(`${url}: changefreq "${changefreq}" is invalid`);
113
+ this.name = "ChangeFreqInvalidError";
114
+ Error.captureStackTrace(this, ChangeFreqInvalidError);
115
+ }
116
+ };
117
+ exports.ChangeFreqInvalidError = ChangeFreqInvalidError;
118
+ var PriorityInvalidError = class extends Error {
119
+ constructor(url, priority) {
120
+ super(`${url}: priority "${priority}" must be a number between 0 and 1 inclusive`);
121
+ this.name = "PriorityInvalidError";
122
+ Error.captureStackTrace(this, PriorityInvalidError);
123
+ }
124
+ };
125
+ exports.PriorityInvalidError = PriorityInvalidError;
126
+ var UndefinedTargetFolder = class extends Error {
127
+ constructor(message) {
128
+ super(message || "Target folder must exist");
129
+ this.name = "UndefinedTargetFolder";
130
+ Error.captureStackTrace(this, UndefinedTargetFolder);
131
+ }
132
+ };
133
+ exports.UndefinedTargetFolder = UndefinedTargetFolder;
134
+ var InvalidVideoFormat = class extends Error {
135
+ constructor(url) {
136
+ super(`${url} video must include thumbnail_loc, title and description fields for videos`);
137
+ this.name = "InvalidVideoFormat";
138
+ Error.captureStackTrace(this, InvalidVideoFormat);
139
+ }
140
+ };
141
+ exports.InvalidVideoFormat = InvalidVideoFormat;
142
+ var InvalidVideoDuration = class extends Error {
143
+ constructor(url, duration) {
144
+ super(`${url} duration "${duration}" must be an integer of seconds between 0 and 28800`);
145
+ this.name = "InvalidVideoDuration";
146
+ Error.captureStackTrace(this, InvalidVideoDuration);
147
+ }
148
+ };
149
+ exports.InvalidVideoDuration = InvalidVideoDuration;
150
+ var InvalidVideoDescription = class extends Error {
151
+ constructor(url, length) {
152
+ const message = `${url}: video description is too long ${length} vs limit of 2048 characters.`;
153
+ super(message);
154
+ this.name = "InvalidVideoDescription";
155
+ Error.captureStackTrace(this, InvalidVideoDescription);
156
+ }
157
+ };
158
+ exports.InvalidVideoDescription = InvalidVideoDescription;
159
+ var InvalidVideoRating = class extends Error {
160
+ constructor(url, title, rating) {
161
+ super(`${url}: video "${title}" rating "${rating}" must be between 0 and 5 inclusive`);
162
+ this.name = "InvalidVideoRating";
163
+ Error.captureStackTrace(this, InvalidVideoRating);
164
+ }
165
+ };
166
+ exports.InvalidVideoRating = InvalidVideoRating;
167
+ var InvalidAttrValue = class extends Error {
168
+ constructor(key, val, validator) {
169
+ super('"' + val + '" tested against: ' + validator + ' is not a valid value for attr: "' + key + '"');
170
+ this.name = "InvalidAttrValue";
171
+ Error.captureStackTrace(this, InvalidAttrValue);
172
+ }
173
+ };
174
+ exports.InvalidAttrValue = InvalidAttrValue;
175
+ var InvalidAttr = class extends Error {
176
+ constructor(key) {
177
+ super('"' + key + '" is malformed');
178
+ this.name = "InvalidAttr";
179
+ Error.captureStackTrace(this, InvalidAttr);
180
+ }
181
+ };
182
+ exports.InvalidAttr = InvalidAttr;
183
+ var InvalidNewsFormat = class extends Error {
184
+ constructor(url) {
185
+ super(`${url} News must include publication, publication name, publication language, title, and publication_date for news`);
186
+ this.name = "InvalidNewsFormat";
187
+ Error.captureStackTrace(this, InvalidNewsFormat);
188
+ }
189
+ };
190
+ exports.InvalidNewsFormat = InvalidNewsFormat;
191
+ var InvalidNewsAccessValue = class extends Error {
192
+ constructor(url, access) {
193
+ super(`${url} News access "${access}" must be either Registration, Subscription or not be present`);
194
+ this.name = "InvalidNewsAccessValue";
195
+ Error.captureStackTrace(this, InvalidNewsAccessValue);
196
+ }
197
+ };
198
+ exports.InvalidNewsAccessValue = InvalidNewsAccessValue;
199
+ var XMLLintUnavailable = class extends Error {
200
+ constructor(message) {
201
+ super(message || "xmlLint is not installed. XMLLint is required to validate");
202
+ this.name = "XMLLintUnavailable";
203
+ Error.captureStackTrace(this, XMLLintUnavailable);
204
+ }
205
+ };
206
+ exports.XMLLintUnavailable = XMLLintUnavailable;
207
+ var InvalidVideoTitle = class extends Error {
208
+ constructor(url, length) {
209
+ super(`${url}: video title is too long ${length} vs 100 character limit`);
210
+ this.name = "InvalidVideoTitle";
211
+ Error.captureStackTrace(this, InvalidVideoTitle);
212
+ }
213
+ };
214
+ exports.InvalidVideoTitle = InvalidVideoTitle;
215
+ var InvalidVideoViewCount = class extends Error {
216
+ constructor(url, count) {
217
+ super(`${url}: video view count must be positive, view count was ${count}`);
218
+ this.name = "InvalidVideoViewCount";
219
+ Error.captureStackTrace(this, InvalidVideoViewCount);
220
+ }
221
+ };
222
+ exports.InvalidVideoViewCount = InvalidVideoViewCount;
223
+ var InvalidVideoTagCount = class extends Error {
224
+ constructor(url, count) {
225
+ super(`${url}: video can have no more than 32 tags, this has ${count}`);
226
+ this.name = "InvalidVideoTagCount";
227
+ Error.captureStackTrace(this, InvalidVideoTagCount);
228
+ }
229
+ };
230
+ exports.InvalidVideoTagCount = InvalidVideoTagCount;
231
+ var InvalidVideoCategory = class extends Error {
232
+ constructor(url, count) {
233
+ super(`${url}: video category can only be 256 characters but was passed ${count}`);
234
+ this.name = "InvalidVideoCategory";
235
+ Error.captureStackTrace(this, InvalidVideoCategory);
236
+ }
237
+ };
238
+ exports.InvalidVideoCategory = InvalidVideoCategory;
239
+ var InvalidVideoFamilyFriendly = class extends Error {
240
+ constructor(url, fam) {
241
+ super(`${url}: video family friendly must be yes or no, was passed "${fam}"`);
242
+ this.name = "InvalidVideoFamilyFriendly";
243
+ Error.captureStackTrace(this, InvalidVideoFamilyFriendly);
244
+ }
245
+ };
246
+ exports.InvalidVideoFamilyFriendly = InvalidVideoFamilyFriendly;
247
+ var InvalidVideoRestriction = class extends Error {
248
+ constructor(url, code) {
249
+ super(`${url}: video restriction must be one or more two letter country codes. Was passed "${code}"`);
250
+ this.name = "InvalidVideoRestriction";
251
+ Error.captureStackTrace(this, InvalidVideoRestriction);
252
+ }
253
+ };
254
+ exports.InvalidVideoRestriction = InvalidVideoRestriction;
255
+ var InvalidVideoRestrictionRelationship = class extends Error {
256
+ constructor(url, val) {
257
+ super(`${url}: video restriction relationship must be either allow or deny. Was passed "${val}"`);
258
+ this.name = "InvalidVideoRestrictionRelationship";
259
+ Error.captureStackTrace(this, InvalidVideoRestrictionRelationship);
260
+ }
261
+ };
262
+ exports.InvalidVideoRestrictionRelationship = InvalidVideoRestrictionRelationship;
263
+ var InvalidVideoPriceType = class extends Error {
264
+ constructor(url, priceType, price) {
265
+ super(priceType === void 0 && price === "" ? `${url}: video priceType is required when price is not provided` : `${url}: video price type "${priceType}" is not "rent" or "purchase"`);
266
+ this.name = "InvalidVideoPriceType";
267
+ Error.captureStackTrace(this, InvalidVideoPriceType);
268
+ }
269
+ };
270
+ exports.InvalidVideoPriceType = InvalidVideoPriceType;
271
+ var InvalidVideoResolution = class extends Error {
272
+ constructor(url, resolution) {
273
+ super(`${url}: video price resolution "${resolution}" is not hd or sd`);
274
+ this.name = "InvalidVideoResolution";
275
+ Error.captureStackTrace(this, InvalidVideoResolution);
276
+ }
277
+ };
278
+ exports.InvalidVideoResolution = InvalidVideoResolution;
279
+ var InvalidVideoPriceCurrency = class extends Error {
280
+ constructor(url, currency) {
281
+ super(`${url}: video price currency "${currency}" must be a three capital letter abbrieviation for the country currency`);
282
+ this.name = "InvalidVideoPriceCurrency";
283
+ Error.captureStackTrace(this, InvalidVideoPriceCurrency);
284
+ }
285
+ };
286
+ exports.InvalidVideoPriceCurrency = InvalidVideoPriceCurrency;
287
+ var EmptyStream = class extends Error {
288
+ constructor() {
289
+ super("You have ended the stream before anything was written. streamToPromise MUST be called before ending the stream.");
290
+ this.name = "EmptyStream";
291
+ Error.captureStackTrace(this, EmptyStream);
292
+ }
293
+ };
294
+ exports.EmptyStream = EmptyStream;
295
+ var EmptySitemap = class extends Error {
296
+ constructor() {
297
+ super("You ended the stream without writing anything.");
298
+ this.name = "EmptySitemap";
299
+ Error.captureStackTrace(this, EmptyStream);
300
+ }
301
+ };
302
+ exports.EmptySitemap = EmptySitemap;
303
+ }
304
+ });
305
+
306
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/types.js
307
+ var require_types = __commonJS({
308
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/types.js"(exports) {
309
+ "use strict";
310
+ init_esm_shims();
311
+ Object.defineProperty(exports, "__esModule", { value: true });
312
+ exports.IndexTagNames = exports.TagNames = exports.ErrorLevel = exports.isAllowDeny = exports.EnumAllowDeny = exports.isValidYesNo = exports.EnumYesNo = exports.isValidChangeFreq = exports.CHANGEFREQ = exports.isResolution = exports.isPriceType = exports.validators = exports.EnumChangefreq = void 0;
313
+ var EnumChangefreq;
314
+ (function(EnumChangefreq2) {
315
+ EnumChangefreq2["DAILY"] = "daily";
316
+ EnumChangefreq2["MONTHLY"] = "monthly";
317
+ EnumChangefreq2["ALWAYS"] = "always";
318
+ EnumChangefreq2["HOURLY"] = "hourly";
319
+ EnumChangefreq2["WEEKLY"] = "weekly";
320
+ EnumChangefreq2["YEARLY"] = "yearly";
321
+ EnumChangefreq2["NEVER"] = "never";
322
+ })(EnumChangefreq = exports.EnumChangefreq || (exports.EnumChangefreq = {}));
323
+ var allowDeny = /^(?:allow|deny)$/;
324
+ exports.validators = {
325
+ "price:currency": /^[A-Z]{3}$/,
326
+ "price:type": /^(?:rent|purchase|RENT|PURCHASE)$/,
327
+ "price:resolution": /^(?:HD|hd|sd|SD)$/,
328
+ "platform:relationship": allowDeny,
329
+ "restriction:relationship": allowDeny,
330
+ restriction: /^([A-Z]{2}( +[A-Z]{2})*)?$/,
331
+ platform: /^((web|mobile|tv)( (web|mobile|tv))*)?$/,
332
+ language: /^zh-cn|zh-tw|([a-z]{2,3})$/,
333
+ genres: /^(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated)(, *(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated))*$/,
334
+ stock_tickers: /^(\w+:\w+(, *\w+:\w+){0,4})?$/
335
+ };
336
+ function isPriceType(pt) {
337
+ return exports.validators["price:type"].test(pt);
338
+ }
339
+ exports.isPriceType = isPriceType;
340
+ function isResolution(res) {
341
+ return exports.validators["price:resolution"].test(res);
342
+ }
343
+ exports.isResolution = isResolution;
344
+ exports.CHANGEFREQ = Object.values(EnumChangefreq);
345
+ function isValidChangeFreq(freq) {
346
+ return exports.CHANGEFREQ.includes(freq);
347
+ }
348
+ exports.isValidChangeFreq = isValidChangeFreq;
349
+ var EnumYesNo;
350
+ (function(EnumYesNo2) {
351
+ EnumYesNo2["YES"] = "YES";
352
+ EnumYesNo2["NO"] = "NO";
353
+ EnumYesNo2["Yes"] = "Yes";
354
+ EnumYesNo2["No"] = "No";
355
+ EnumYesNo2["yes"] = "yes";
356
+ EnumYesNo2["no"] = "no";
357
+ })(EnumYesNo = exports.EnumYesNo || (exports.EnumYesNo = {}));
358
+ function isValidYesNo(yn) {
359
+ return /^YES|NO|[Yy]es|[Nn]o$/.test(yn);
360
+ }
361
+ exports.isValidYesNo = isValidYesNo;
362
+ var EnumAllowDeny;
363
+ (function(EnumAllowDeny2) {
364
+ EnumAllowDeny2["ALLOW"] = "allow";
365
+ EnumAllowDeny2["DENY"] = "deny";
366
+ })(EnumAllowDeny = exports.EnumAllowDeny || (exports.EnumAllowDeny = {}));
367
+ function isAllowDeny(ad) {
368
+ return allowDeny.test(ad);
369
+ }
370
+ exports.isAllowDeny = isAllowDeny;
371
+ var ErrorLevel;
372
+ (function(ErrorLevel2) {
373
+ ErrorLevel2["SILENT"] = "silent";
374
+ ErrorLevel2["WARN"] = "warn";
375
+ ErrorLevel2["THROW"] = "throw";
376
+ })(ErrorLevel = exports.ErrorLevel || (exports.ErrorLevel = {}));
377
+ var TagNames;
378
+ (function(TagNames2) {
379
+ TagNames2["url"] = "url";
380
+ TagNames2["loc"] = "loc";
381
+ TagNames2["urlset"] = "urlset";
382
+ TagNames2["lastmod"] = "lastmod";
383
+ TagNames2["changefreq"] = "changefreq";
384
+ TagNames2["priority"] = "priority";
385
+ TagNames2["video:thumbnail_loc"] = "video:thumbnail_loc";
386
+ TagNames2["video:video"] = "video:video";
387
+ TagNames2["video:title"] = "video:title";
388
+ TagNames2["video:description"] = "video:description";
389
+ TagNames2["video:tag"] = "video:tag";
390
+ TagNames2["video:duration"] = "video:duration";
391
+ TagNames2["video:player_loc"] = "video:player_loc";
392
+ TagNames2["video:content_loc"] = "video:content_loc";
393
+ TagNames2["image:image"] = "image:image";
394
+ TagNames2["image:loc"] = "image:loc";
395
+ TagNames2["image:geo_location"] = "image:geo_location";
396
+ TagNames2["image:license"] = "image:license";
397
+ TagNames2["image:title"] = "image:title";
398
+ TagNames2["image:caption"] = "image:caption";
399
+ TagNames2["video:requires_subscription"] = "video:requires_subscription";
400
+ TagNames2["video:publication_date"] = "video:publication_date";
401
+ TagNames2["video:id"] = "video:id";
402
+ TagNames2["video:restriction"] = "video:restriction";
403
+ TagNames2["video:family_friendly"] = "video:family_friendly";
404
+ TagNames2["video:view_count"] = "video:view_count";
405
+ TagNames2["video:uploader"] = "video:uploader";
406
+ TagNames2["video:expiration_date"] = "video:expiration_date";
407
+ TagNames2["video:platform"] = "video:platform";
408
+ TagNames2["video:price"] = "video:price";
409
+ TagNames2["video:rating"] = "video:rating";
410
+ TagNames2["video:category"] = "video:category";
411
+ TagNames2["video:live"] = "video:live";
412
+ TagNames2["video:gallery_loc"] = "video:gallery_loc";
413
+ TagNames2["news:news"] = "news:news";
414
+ TagNames2["news:publication"] = "news:publication";
415
+ TagNames2["news:name"] = "news:name";
416
+ TagNames2["news:access"] = "news:access";
417
+ TagNames2["news:genres"] = "news:genres";
418
+ TagNames2["news:publication_date"] = "news:publication_date";
419
+ TagNames2["news:title"] = "news:title";
420
+ TagNames2["news:keywords"] = "news:keywords";
421
+ TagNames2["news:stock_tickers"] = "news:stock_tickers";
422
+ TagNames2["news:language"] = "news:language";
423
+ TagNames2["mobile:mobile"] = "mobile:mobile";
424
+ TagNames2["xhtml:link"] = "xhtml:link";
425
+ TagNames2["expires"] = "expires";
426
+ })(TagNames = exports.TagNames || (exports.TagNames = {}));
427
+ var IndexTagNames;
428
+ (function(IndexTagNames2) {
429
+ IndexTagNames2["sitemap"] = "sitemap";
430
+ IndexTagNames2["sitemapindex"] = "sitemapindex";
431
+ IndexTagNames2["loc"] = "loc";
432
+ IndexTagNames2["lastmod"] = "lastmod";
433
+ })(IndexTagNames = exports.IndexTagNames || (exports.IndexTagNames = {}));
434
+ }
435
+ });
436
+
437
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-xml.js
438
+ var require_sitemap_xml = __commonJS({
439
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-xml.js"(exports) {
440
+ "use strict";
441
+ init_esm_shims();
442
+ Object.defineProperty(exports, "__esModule", { value: true });
443
+ exports.element = exports.ctag = exports.otag = exports.text = void 0;
444
+ var invalidXMLUnicodeRegex = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\uFDD0-\uFDDF\u{1FFFE}-\u{1FFFF}\u{2FFFE}-\u{2FFFF}\u{3FFFE}-\u{3FFFF}\u{4FFFE}-\u{4FFFF}\u{5FFFE}-\u{5FFFF}\u{6FFFE}-\u{6FFFF}\u{7FFFE}-\u{7FFFF}\u{8FFFE}-\u{8FFFF}\u{9FFFE}-\u{9FFFF}\u{AFFFE}-\u{AFFFF}\u{BFFFE}-\u{BFFFF}\u{CFFFE}-\u{CFFFF}\u{DFFFE}-\u{DFFFF}\u{EFFFE}-\u{EFFFF}\u{FFFFE}-\u{FFFFF}\u{10FFFE}-\u{10FFFF}]/gu;
445
+ var amp = /&/g;
446
+ var lt = /</g;
447
+ var apos = /'/g;
448
+ var quot = /"/g;
449
+ function text(txt) {
450
+ return txt.replace(amp, "&amp;").replace(lt, "&lt;").replace(invalidXMLUnicodeRegex, "");
451
+ }
452
+ exports.text = text;
453
+ function otag(nodeName, attrs, selfClose = false) {
454
+ let attrstr = "";
455
+ for (const k in attrs) {
456
+ const val = attrs[k].replace(amp, "&amp;").replace(lt, "&lt;").replace(apos, "&apos;").replace(quot, "&quot;").replace(invalidXMLUnicodeRegex, "");
457
+ attrstr += ` ${k}="${val}"`;
458
+ }
459
+ return `<${nodeName}${attrstr}${selfClose ? "/" : ""}>`;
460
+ }
461
+ exports.otag = otag;
462
+ function ctag(nodeName) {
463
+ return `</${nodeName}>`;
464
+ }
465
+ exports.ctag = ctag;
466
+ function element(nodeName, attrs, innerText) {
467
+ if (typeof attrs === "string") {
468
+ return otag(nodeName) + text(attrs) + ctag(nodeName);
469
+ } else if (innerText) {
470
+ return otag(nodeName, attrs) + text(innerText) + ctag(nodeName);
471
+ } else {
472
+ return otag(nodeName, attrs, true);
473
+ }
474
+ }
475
+ exports.element = element;
476
+ }
477
+ });
478
+
479
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-item-stream.js
480
+ var require_sitemap_item_stream = __commonJS({
481
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-item-stream.js"(exports) {
482
+ "use strict";
483
+ init_esm_shims();
484
+ Object.defineProperty(exports, "__esModule", { value: true });
485
+ exports.SitemapItemStream = void 0;
486
+ var stream_1 = __require("stream");
487
+ var errors_1 = require_errors();
488
+ var types_1 = require_types();
489
+ var sitemap_xml_1 = require_sitemap_xml();
490
+ function attrBuilder(conf, keys) {
491
+ if (typeof keys === "string") {
492
+ keys = [keys];
493
+ }
494
+ const iv = {};
495
+ return keys.reduce((attrs, key) => {
496
+ if (conf[key] !== void 0) {
497
+ const keyAr = key.split(":");
498
+ if (keyAr.length !== 2) {
499
+ throw new errors_1.InvalidAttr(key);
500
+ }
501
+ attrs[keyAr[1]] = conf[key];
502
+ }
503
+ return attrs;
504
+ }, iv);
505
+ }
506
+ var SitemapItemStream = class extends stream_1.Transform {
507
+ constructor(opts = { level: types_1.ErrorLevel.WARN }) {
508
+ opts.objectMode = true;
509
+ super(opts);
510
+ this.level = opts.level || types_1.ErrorLevel.WARN;
511
+ }
512
+ _transform(item, encoding, callback) {
513
+ this.push((0, sitemap_xml_1.otag)(types_1.TagNames.url));
514
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.loc, item.url));
515
+ if (item.lastmod) {
516
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.lastmod, item.lastmod));
517
+ }
518
+ if (item.changefreq) {
519
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.changefreq, item.changefreq));
520
+ }
521
+ if (item.priority !== void 0 && item.priority !== null) {
522
+ if (item.fullPrecisionPriority) {
523
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.priority, item.priority.toString()));
524
+ } else {
525
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.priority, item.priority.toFixed(1)));
526
+ }
527
+ }
528
+ item.video.forEach((video) => {
529
+ this.push((0, sitemap_xml_1.otag)(types_1.TagNames["video:video"]));
530
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:thumbnail_loc"], video.thumbnail_loc));
531
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:title"], video.title));
532
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:description"], video.description));
533
+ if (video.content_loc) {
534
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:content_loc"], video.content_loc));
535
+ }
536
+ if (video.player_loc) {
537
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:player_loc"], attrBuilder(video, [
538
+ "player_loc:autoplay",
539
+ "player_loc:allow_embed"
540
+ ]), video.player_loc));
541
+ }
542
+ if (video.duration) {
543
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:duration"], video.duration.toString()));
544
+ }
545
+ if (video.expiration_date) {
546
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:expiration_date"], video.expiration_date));
547
+ }
548
+ if (video.rating !== void 0) {
549
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:rating"], video.rating.toString()));
550
+ }
551
+ if (video.view_count !== void 0) {
552
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:view_count"], video.view_count.toString()));
553
+ }
554
+ if (video.publication_date) {
555
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:publication_date"], video.publication_date));
556
+ }
557
+ for (const tag of video.tag) {
558
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:tag"], tag));
559
+ }
560
+ if (video.category) {
561
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:category"], video.category));
562
+ }
563
+ if (video.family_friendly) {
564
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:family_friendly"], video.family_friendly));
565
+ }
566
+ if (video.restriction) {
567
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:restriction"], attrBuilder(video, "restriction:relationship"), video.restriction));
568
+ }
569
+ if (video.gallery_loc) {
570
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:gallery_loc"], { title: video["gallery_loc:title"] }, video.gallery_loc));
571
+ }
572
+ if (video.price) {
573
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:price"], attrBuilder(video, [
574
+ "price:resolution",
575
+ "price:currency",
576
+ "price:type"
577
+ ]), video.price));
578
+ }
579
+ if (video.requires_subscription) {
580
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:requires_subscription"], video.requires_subscription));
581
+ }
582
+ if (video.uploader) {
583
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:uploader"], attrBuilder(video, "uploader:info"), video.uploader));
584
+ }
585
+ if (video.platform) {
586
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:platform"], attrBuilder(video, "platform:relationship"), video.platform));
587
+ }
588
+ if (video.live) {
589
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:live"], video.live));
590
+ }
591
+ if (video.id) {
592
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:id"], { type: "url" }, video.id));
593
+ }
594
+ this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["video:video"]));
595
+ });
596
+ item.links.forEach((link) => {
597
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
598
+ rel: "alternate",
599
+ hreflang: link.lang || link.hreflang,
600
+ href: link.url
601
+ }));
602
+ });
603
+ if (item.expires) {
604
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames.expires, new Date(item.expires).toISOString()));
605
+ }
606
+ if (item.androidLink) {
607
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
608
+ rel: "alternate",
609
+ href: item.androidLink
610
+ }));
611
+ }
612
+ if (item.ampLink) {
613
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
614
+ rel: "amphtml",
615
+ href: item.ampLink
616
+ }));
617
+ }
618
+ if (item.news) {
619
+ this.push((0, sitemap_xml_1.otag)(types_1.TagNames["news:news"]));
620
+ this.push((0, sitemap_xml_1.otag)(types_1.TagNames["news:publication"]));
621
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:name"], item.news.publication.name));
622
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:language"], item.news.publication.language));
623
+ this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["news:publication"]));
624
+ if (item.news.access) {
625
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:access"], item.news.access));
626
+ }
627
+ if (item.news.genres) {
628
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:genres"], item.news.genres));
629
+ }
630
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:publication_date"], item.news.publication_date));
631
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:title"], item.news.title));
632
+ if (item.news.keywords) {
633
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:keywords"], item.news.keywords));
634
+ }
635
+ if (item.news.stock_tickers) {
636
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:stock_tickers"], item.news.stock_tickers));
637
+ }
638
+ this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["news:news"]));
639
+ }
640
+ item.img.forEach((image) => {
641
+ this.push((0, sitemap_xml_1.otag)(types_1.TagNames["image:image"]));
642
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:loc"], image.url));
643
+ if (image.caption) {
644
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:caption"], image.caption));
645
+ }
646
+ if (image.geoLocation) {
647
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:geo_location"], image.geoLocation));
648
+ }
649
+ if (image.title) {
650
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:title"], image.title));
651
+ }
652
+ if (image.license) {
653
+ this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:license"], image.license));
654
+ }
655
+ this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["image:image"]));
656
+ });
657
+ this.push((0, sitemap_xml_1.ctag)(types_1.TagNames.url));
658
+ callback();
659
+ }
660
+ };
661
+ exports.SitemapItemStream = SitemapItemStream;
662
+ }
663
+ });
664
+
665
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/utils.js
666
+ var require_utils = __commonJS({
667
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/utils.js"(exports) {
668
+ "use strict";
669
+ init_esm_shims();
670
+ Object.defineProperty(exports, "__esModule", { value: true });
671
+ exports.normalizeURL = exports.chunk = exports.lineSeparatedURLsToSitemapOptions = exports.ReadlineStream = exports.mergeStreams = exports.validateSMIOptions = void 0;
672
+ var fs_1 = __require("fs");
673
+ var stream_1 = __require("stream");
674
+ var readline_1 = __require("readline");
675
+ var url_1 = __require("url");
676
+ var types_1 = require_types();
677
+ var errors_1 = require_errors();
678
+ var types_2 = require_types();
679
+ function validate(subject, name, url, level) {
680
+ Object.keys(subject).forEach((key) => {
681
+ const val = subject[key];
682
+ if (types_2.validators[key] && !types_2.validators[key].test(val)) {
683
+ if (level === types_1.ErrorLevel.THROW) {
684
+ throw new errors_1.InvalidAttrValue(key, val, types_2.validators[key]);
685
+ } else {
686
+ console.warn(`${url}: ${name} key ${key} has invalid value: ${val}`);
687
+ }
688
+ }
689
+ });
690
+ }
691
+ function handleError(error, level) {
692
+ if (level === types_1.ErrorLevel.THROW) {
693
+ throw error;
694
+ } else if (level === types_1.ErrorLevel.WARN) {
695
+ console.warn(error.name, error.message);
696
+ }
697
+ }
698
+ function validateSMIOptions(conf, level = types_1.ErrorLevel.WARN, errorHandler = handleError) {
699
+ if (!conf) {
700
+ throw new errors_1.NoConfigError();
701
+ }
702
+ if (level === types_1.ErrorLevel.SILENT) {
703
+ return conf;
704
+ }
705
+ const { url, changefreq, priority, news, video } = conf;
706
+ if (!url) {
707
+ errorHandler(new errors_1.NoURLError(), level);
708
+ }
709
+ if (changefreq) {
710
+ if (!(0, types_1.isValidChangeFreq)(changefreq)) {
711
+ errorHandler(new errors_1.ChangeFreqInvalidError(url, changefreq), level);
712
+ }
713
+ }
714
+ if (priority) {
715
+ if (!(priority >= 0 && priority <= 1)) {
716
+ errorHandler(new errors_1.PriorityInvalidError(url, priority), level);
717
+ }
718
+ }
719
+ if (news) {
720
+ if (news.access && news.access !== "Registration" && news.access !== "Subscription") {
721
+ errorHandler(new errors_1.InvalidNewsAccessValue(url, news.access), level);
722
+ }
723
+ if (!news.publication || !news.publication.name || !news.publication.language || !news.publication_date || !news.title) {
724
+ errorHandler(new errors_1.InvalidNewsFormat(url), level);
725
+ }
726
+ validate(news, "news", url, level);
727
+ validate(news.publication, "publication", url, level);
728
+ }
729
+ if (video) {
730
+ video.forEach((vid) => {
731
+ var _a;
732
+ if (vid.duration !== void 0) {
733
+ if (vid.duration < 0 || vid.duration > 28800) {
734
+ errorHandler(new errors_1.InvalidVideoDuration(url, vid.duration), level);
735
+ }
736
+ }
737
+ if (vid.rating !== void 0 && (vid.rating < 0 || vid.rating > 5)) {
738
+ errorHandler(new errors_1.InvalidVideoRating(url, vid.title, vid.rating), level);
739
+ }
740
+ if (typeof vid !== "object" || !vid.thumbnail_loc || !vid.title || !vid.description) {
741
+ errorHandler(new errors_1.InvalidVideoFormat(url), level);
742
+ }
743
+ if (vid.title.length > 100) {
744
+ errorHandler(new errors_1.InvalidVideoTitle(url, vid.title.length), level);
745
+ }
746
+ if (vid.description.length > 2048) {
747
+ errorHandler(new errors_1.InvalidVideoDescription(url, vid.description.length), level);
748
+ }
749
+ if (vid.view_count !== void 0 && vid.view_count < 0) {
750
+ errorHandler(new errors_1.InvalidVideoViewCount(url, vid.view_count), level);
751
+ }
752
+ if (vid.tag.length > 32) {
753
+ errorHandler(new errors_1.InvalidVideoTagCount(url, vid.tag.length), level);
754
+ }
755
+ if (vid.category !== void 0 && ((_a = vid.category) === null || _a === void 0 ? void 0 : _a.length) > 256) {
756
+ errorHandler(new errors_1.InvalidVideoCategory(url, vid.category.length), level);
757
+ }
758
+ if (vid.family_friendly !== void 0 && !(0, types_1.isValidYesNo)(vid.family_friendly)) {
759
+ errorHandler(new errors_1.InvalidVideoFamilyFriendly(url, vid.family_friendly), level);
760
+ }
761
+ if (vid.restriction) {
762
+ if (!types_2.validators.restriction.test(vid.restriction)) {
763
+ errorHandler(new errors_1.InvalidVideoRestriction(url, vid.restriction), level);
764
+ }
765
+ if (!vid["restriction:relationship"] || !(0, types_1.isAllowDeny)(vid["restriction:relationship"])) {
766
+ errorHandler(new errors_1.InvalidVideoRestrictionRelationship(url, vid["restriction:relationship"]), level);
767
+ }
768
+ }
769
+ if (vid.price === "" && vid["price:type"] === void 0 || vid["price:type"] !== void 0 && !(0, types_1.isPriceType)(vid["price:type"])) {
770
+ errorHandler(new errors_1.InvalidVideoPriceType(url, vid["price:type"], vid.price), level);
771
+ }
772
+ if (vid["price:resolution"] !== void 0 && !(0, types_1.isResolution)(vid["price:resolution"])) {
773
+ errorHandler(new errors_1.InvalidVideoResolution(url, vid["price:resolution"]), level);
774
+ }
775
+ if (vid["price:currency"] !== void 0 && !types_2.validators["price:currency"].test(vid["price:currency"])) {
776
+ errorHandler(new errors_1.InvalidVideoPriceCurrency(url, vid["price:currency"]), level);
777
+ }
778
+ validate(vid, "video", url, level);
779
+ });
780
+ }
781
+ return conf;
782
+ }
783
+ exports.validateSMIOptions = validateSMIOptions;
784
+ function mergeStreams(streams, options) {
785
+ let pass = new stream_1.PassThrough(options);
786
+ let waiting = streams.length;
787
+ for (const stream of streams) {
788
+ pass = stream.pipe(pass, { end: false });
789
+ stream.once("end", () => --waiting === 0 && pass.emit("end"));
790
+ }
791
+ return pass;
792
+ }
793
+ exports.mergeStreams = mergeStreams;
794
+ var ReadlineStream = class extends stream_1.Readable {
795
+ constructor(options) {
796
+ if (options.autoDestroy === void 0) {
797
+ options.autoDestroy = true;
798
+ }
799
+ options.objectMode = true;
800
+ super(options);
801
+ this._source = (0, readline_1.createInterface)({
802
+ input: options.input,
803
+ terminal: false,
804
+ crlfDelay: Infinity
805
+ });
806
+ this._source.on("line", (chunk2) => {
807
+ if (!this.push(chunk2))
808
+ this._source.pause();
809
+ });
810
+ this._source.on("close", () => {
811
+ this.push(null);
812
+ });
813
+ }
814
+ _read(size) {
815
+ this._source.resume();
816
+ }
817
+ };
818
+ exports.ReadlineStream = ReadlineStream;
819
+ function lineSeparatedURLsToSitemapOptions(stream, { isJSON } = {}) {
820
+ return new ReadlineStream({ input: stream }).pipe(new stream_1.Transform({
821
+ objectMode: true,
822
+ transform: (line, encoding, cb) => {
823
+ if (isJSON || isJSON === void 0 && line[0] === "{") {
824
+ cb(null, JSON.parse(line));
825
+ } else {
826
+ cb(null, line);
827
+ }
828
+ }
829
+ }));
830
+ }
831
+ exports.lineSeparatedURLsToSitemapOptions = lineSeparatedURLsToSitemapOptions;
832
+ function chunk(array, size = 1) {
833
+ size = Math.max(Math.trunc(size), 0);
834
+ const length = array ? array.length : 0;
835
+ if (!length || size < 1) {
836
+ return [];
837
+ }
838
+ const result = Array(Math.ceil(length / size));
839
+ let index = 0, resIndex = 0;
840
+ while (index < length) {
841
+ result[resIndex++] = array.slice(index, index += size);
842
+ }
843
+ return result;
844
+ }
845
+ exports.chunk = chunk;
846
+ function boolToYESNO(bool) {
847
+ if (bool === void 0) {
848
+ return bool;
849
+ }
850
+ if (typeof bool === "boolean") {
851
+ return bool ? types_1.EnumYesNo.yes : types_1.EnumYesNo.no;
852
+ }
853
+ return bool;
854
+ }
855
+ function normalizeURL(elem, hostname, lastmodDateOnly = false) {
856
+ let smi = {
857
+ img: [],
858
+ video: [],
859
+ links: [],
860
+ url: ""
861
+ };
862
+ let smiLoose;
863
+ if (typeof elem === "string") {
864
+ smi.url = elem;
865
+ smiLoose = { url: elem };
866
+ } else {
867
+ smiLoose = elem;
868
+ }
869
+ smi.url = new url_1.URL(smiLoose.url, hostname).toString();
870
+ let img = [];
871
+ if (smiLoose.img) {
872
+ if (typeof smiLoose.img === "string") {
873
+ smiLoose.img = [{ url: smiLoose.img }];
874
+ } else if (!Array.isArray(smiLoose.img)) {
875
+ smiLoose.img = [smiLoose.img];
876
+ }
877
+ img = smiLoose.img.map((el) => typeof el === "string" ? { url: el } : el);
878
+ }
879
+ smi.img = img.map((el) => __spreadProps(__spreadValues({}, el), {
880
+ url: new url_1.URL(el.url, hostname).toString()
881
+ }));
882
+ let links = [];
883
+ if (smiLoose.links) {
884
+ links = smiLoose.links;
885
+ }
886
+ smi.links = links.map((link) => {
887
+ return __spreadProps(__spreadValues({}, link), { url: new url_1.URL(link.url, hostname).toString() });
888
+ });
889
+ if (smiLoose.video) {
890
+ if (!Array.isArray(smiLoose.video)) {
891
+ smiLoose.video = [smiLoose.video];
892
+ }
893
+ smi.video = smiLoose.video.map((video) => {
894
+ const nv = __spreadProps(__spreadValues({}, video), {
895
+ family_friendly: boolToYESNO(video.family_friendly),
896
+ live: boolToYESNO(video.live),
897
+ requires_subscription: boolToYESNO(video.requires_subscription),
898
+ tag: [],
899
+ rating: void 0
900
+ });
901
+ if (video.tag !== void 0) {
902
+ nv.tag = !Array.isArray(video.tag) ? [video.tag] : video.tag;
903
+ }
904
+ if (video.rating !== void 0) {
905
+ if (typeof video.rating === "string") {
906
+ nv.rating = parseFloat(video.rating);
907
+ } else {
908
+ nv.rating = video.rating;
909
+ }
910
+ }
911
+ if (typeof video.view_count === "string") {
912
+ nv.view_count = parseInt(video.view_count, 10);
913
+ } else if (typeof video.view_count === "number") {
914
+ nv.view_count = video.view_count;
915
+ }
916
+ return nv;
917
+ });
918
+ }
919
+ if (smiLoose.lastmodfile) {
920
+ const { mtime } = (0, fs_1.statSync)(smiLoose.lastmodfile);
921
+ smi.lastmod = new Date(mtime).toISOString();
922
+ } else if (smiLoose.lastmodISO) {
923
+ smi.lastmod = new Date(smiLoose.lastmodISO).toISOString();
924
+ } else if (smiLoose.lastmod) {
925
+ smi.lastmod = new Date(smiLoose.lastmod).toISOString();
926
+ }
927
+ if (lastmodDateOnly && smi.lastmod) {
928
+ smi.lastmod = smi.lastmod.slice(0, 10);
929
+ }
930
+ delete smiLoose.lastmodfile;
931
+ delete smiLoose.lastmodISO;
932
+ smi = __spreadValues(__spreadValues({}, smiLoose), smi);
933
+ return smi;
934
+ }
935
+ exports.normalizeURL = normalizeURL;
936
+ }
937
+ });
938
+
939
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-stream.js
940
+ var require_sitemap_stream = __commonJS({
941
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-stream.js"(exports) {
942
+ "use strict";
943
+ init_esm_shims();
944
+ Object.defineProperty(exports, "__esModule", { value: true });
945
+ exports.streamToPromise = exports.SitemapStream = exports.closetag = exports.stylesheetInclude = void 0;
946
+ var stream_1 = __require("stream");
947
+ var types_1 = require_types();
948
+ var utils_1 = require_utils();
949
+ var sitemap_item_stream_1 = require_sitemap_item_stream();
950
+ var errors_1 = require_errors();
951
+ var xmlDec = '<?xml version="1.0" encoding="UTF-8"?>';
952
+ var stylesheetInclude = (url) => {
953
+ return `<?xml-stylesheet type="text/xsl" href="${url}"?>`;
954
+ };
955
+ exports.stylesheetInclude = stylesheetInclude;
956
+ var urlsetTagStart = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
957
+ var getURLSetNs = ({ news, video, image, xhtml, custom }, xslURL) => {
958
+ let ns = xmlDec;
959
+ if (xslURL) {
960
+ ns += (0, exports.stylesheetInclude)(xslURL);
961
+ }
962
+ ns += urlsetTagStart;
963
+ if (news) {
964
+ ns += ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"';
965
+ }
966
+ if (xhtml) {
967
+ ns += ' xmlns:xhtml="http://www.w3.org/1999/xhtml"';
968
+ }
969
+ if (image) {
970
+ ns += ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"';
971
+ }
972
+ if (video) {
973
+ ns += ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
974
+ }
975
+ if (custom) {
976
+ ns += " " + custom.join(" ");
977
+ }
978
+ return ns + ">";
979
+ };
980
+ exports.closetag = "</urlset>";
981
+ var defaultXMLNS = {
982
+ news: true,
983
+ xhtml: true,
984
+ image: true,
985
+ video: true
986
+ };
987
+ var defaultStreamOpts = {
988
+ xmlns: defaultXMLNS
989
+ };
990
+ var SitemapStream2 = class extends stream_1.Transform {
991
+ constructor(opts = defaultStreamOpts) {
992
+ opts.objectMode = true;
993
+ super(opts);
994
+ this.hasHeadOutput = false;
995
+ this.hostname = opts.hostname;
996
+ this.level = opts.level || types_1.ErrorLevel.WARN;
997
+ this.errorHandler = opts.errorHandler;
998
+ this.smiStream = new sitemap_item_stream_1.SitemapItemStream({ level: opts.level });
999
+ this.smiStream.on("data", (data) => this.push(data));
1000
+ this.lastmodDateOnly = opts.lastmodDateOnly || false;
1001
+ this.xmlNS = opts.xmlns || defaultXMLNS;
1002
+ this.xslUrl = opts.xslUrl;
1003
+ }
1004
+ _transform(item, encoding, callback) {
1005
+ if (!this.hasHeadOutput) {
1006
+ this.hasHeadOutput = true;
1007
+ this.push(getURLSetNs(this.xmlNS, this.xslUrl));
1008
+ }
1009
+ this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler));
1010
+ callback();
1011
+ }
1012
+ _flush(cb) {
1013
+ if (!this.hasHeadOutput) {
1014
+ cb(new errors_1.EmptySitemap());
1015
+ } else {
1016
+ this.push(exports.closetag);
1017
+ cb();
1018
+ }
1019
+ }
1020
+ };
1021
+ exports.SitemapStream = SitemapStream2;
1022
+ function streamToPromise2(stream) {
1023
+ return new Promise((resolve2, reject) => {
1024
+ const drain = [];
1025
+ stream.pipe(new stream_1.Writable({
1026
+ write(chunk, enc, next) {
1027
+ drain.push(chunk);
1028
+ next();
1029
+ }
1030
+ })).on("error", reject).on("finish", () => {
1031
+ if (!drain.length) {
1032
+ reject(new errors_1.EmptyStream());
1033
+ } else {
1034
+ resolve2(Buffer.concat(drain));
1035
+ }
1036
+ });
1037
+ });
1038
+ }
1039
+ exports.streamToPromise = streamToPromise2;
1040
+ }
1041
+ });
1042
+
1043
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-stream.js
1044
+ var require_sitemap_index_stream = __commonJS({
1045
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-stream.js"(exports) {
1046
+ "use strict";
1047
+ init_esm_shims();
1048
+ Object.defineProperty(exports, "__esModule", { value: true });
1049
+ exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = void 0;
1050
+ var stream_1 = __require("stream");
1051
+ var types_1 = require_types();
1052
+ var sitemap_stream_1 = require_sitemap_stream();
1053
+ var sitemap_xml_1 = require_sitemap_xml();
1054
+ var IndexTagNames;
1055
+ (function(IndexTagNames2) {
1056
+ IndexTagNames2["sitemap"] = "sitemap";
1057
+ IndexTagNames2["loc"] = "loc";
1058
+ IndexTagNames2["lastmod"] = "lastmod";
1059
+ })(IndexTagNames = exports.IndexTagNames || (exports.IndexTagNames = {}));
1060
+ var xmlDec = '<?xml version="1.0" encoding="UTF-8"?>';
1061
+ var sitemapIndexTagStart = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
1062
+ var closetag = "</sitemapindex>";
1063
+ var defaultStreamOpts = {};
1064
+ var SitemapIndexStream = class extends stream_1.Transform {
1065
+ constructor(opts = defaultStreamOpts) {
1066
+ var _a;
1067
+ opts.objectMode = true;
1068
+ super(opts);
1069
+ this.hasHeadOutput = false;
1070
+ this.lastmodDateOnly = opts.lastmodDateOnly || false;
1071
+ this.level = (_a = opts.level) !== null && _a !== void 0 ? _a : types_1.ErrorLevel.WARN;
1072
+ this.xslUrl = opts.xslUrl;
1073
+ }
1074
+ _transform(item, encoding, callback) {
1075
+ if (!this.hasHeadOutput) {
1076
+ this.hasHeadOutput = true;
1077
+ let stylesheet = "";
1078
+ if (this.xslUrl) {
1079
+ stylesheet = (0, sitemap_stream_1.stylesheetInclude)(this.xslUrl);
1080
+ }
1081
+ this.push(xmlDec + stylesheet + sitemapIndexTagStart);
1082
+ }
1083
+ this.push((0, sitemap_xml_1.otag)(IndexTagNames.sitemap));
1084
+ if (typeof item === "string") {
1085
+ this.push((0, sitemap_xml_1.element)(IndexTagNames.loc, item));
1086
+ } else {
1087
+ this.push((0, sitemap_xml_1.element)(IndexTagNames.loc, item.url));
1088
+ if (item.lastmod) {
1089
+ const lastmod = new Date(item.lastmod).toISOString();
1090
+ this.push((0, sitemap_xml_1.element)(IndexTagNames.lastmod, this.lastmodDateOnly ? lastmod.slice(0, 10) : lastmod));
1091
+ }
1092
+ }
1093
+ this.push((0, sitemap_xml_1.ctag)(IndexTagNames.sitemap));
1094
+ callback();
1095
+ }
1096
+ _flush(cb) {
1097
+ this.push(closetag);
1098
+ cb();
1099
+ }
1100
+ };
1101
+ exports.SitemapIndexStream = SitemapIndexStream;
1102
+ var SitemapAndIndexStream = class extends SitemapIndexStream {
1103
+ constructor(opts) {
1104
+ var _a;
1105
+ opts.objectMode = true;
1106
+ super(opts);
1107
+ this.i = 0;
1108
+ this.getSitemapStream = opts.getSitemapStream;
1109
+ [this.idxItem, this.currentSitemap, this.currentSitemapPipeline] = this.getSitemapStream(0);
1110
+ this.limit = (_a = opts.limit) !== null && _a !== void 0 ? _a : 45e3;
1111
+ }
1112
+ _writeSMI(item) {
1113
+ this.currentSitemap.write(item);
1114
+ this.i++;
1115
+ }
1116
+ _transform(item, encoding, callback) {
1117
+ var _a;
1118
+ if (this.i === 0) {
1119
+ this._writeSMI(item);
1120
+ super._transform(this.idxItem, encoding, callback);
1121
+ } else if (this.i % this.limit === 0) {
1122
+ const onFinish = () => {
1123
+ const [idxItem, currentSitemap, currentSitemapPipeline] = this.getSitemapStream(this.i / this.limit);
1124
+ this.currentSitemap = currentSitemap;
1125
+ this.currentSitemapPipeline = currentSitemapPipeline;
1126
+ this._writeSMI(item);
1127
+ super._transform(idxItem, encoding, callback);
1128
+ };
1129
+ (_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on("finish", onFinish);
1130
+ this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : void 0);
1131
+ } else {
1132
+ this._writeSMI(item);
1133
+ callback();
1134
+ }
1135
+ }
1136
+ _flush(cb) {
1137
+ var _a;
1138
+ const onFinish = () => super._flush(cb);
1139
+ (_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on("finish", onFinish);
1140
+ this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : void 0);
1141
+ }
1142
+ };
1143
+ exports.SitemapAndIndexStream = SitemapAndIndexStream;
1144
+ }
1145
+ });
1146
+
1147
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/xmllint.js
1148
+ var require_xmllint = __commonJS({
1149
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/xmllint.js"(exports) {
1150
+ "use strict";
1151
+ init_esm_shims();
1152
+ Object.defineProperty(exports, "__esModule", { value: true });
1153
+ exports.xmlLint = void 0;
1154
+ var path_1 = __require("path");
1155
+ var child_process_1 = __require("child_process");
1156
+ var errors_1 = require_errors();
1157
+ function xmlLint(xml) {
1158
+ const args = [
1159
+ "--schema",
1160
+ (0, path_1.resolve)(__dirname, "..", "..", "schema", "all.xsd"),
1161
+ "--noout",
1162
+ "-"
1163
+ ];
1164
+ if (typeof xml === "string") {
1165
+ args[args.length - 1] = xml;
1166
+ }
1167
+ return new Promise((resolve2, reject) => {
1168
+ (0, child_process_1.execFile)("which", ["xmllint"], (error, stdout, stderr) => {
1169
+ if (error) {
1170
+ reject([new errors_1.XMLLintUnavailable()]);
1171
+ return;
1172
+ }
1173
+ const xmllint = (0, child_process_1.execFile)("xmllint", args, (error2, stdout2, stderr2) => {
1174
+ if (error2) {
1175
+ reject([error2, stderr2]);
1176
+ }
1177
+ resolve2();
1178
+ });
1179
+ if (xmllint.stdout) {
1180
+ xmllint.stdout.unpipe();
1181
+ if (typeof xml !== "string" && xml && xmllint.stdin) {
1182
+ xml.pipe(xmllint.stdin);
1183
+ }
1184
+ }
1185
+ });
1186
+ });
1187
+ }
1188
+ exports.xmlLint = xmlLint;
1189
+ }
1190
+ });
1191
+
1192
+ // node_modules/.pnpm/sax@1.2.4/node_modules/sax/lib/sax.js
1193
+ var require_sax = __commonJS({
1194
+ "node_modules/.pnpm/sax@1.2.4/node_modules/sax/lib/sax.js"(exports) {
1195
+ init_esm_shims();
1196
+ (function(sax) {
1197
+ sax.parser = function(strict, opt) {
1198
+ return new SAXParser(strict, opt);
1199
+ };
1200
+ sax.SAXParser = SAXParser;
1201
+ sax.SAXStream = SAXStream;
1202
+ sax.createStream = createStream;
1203
+ sax.MAX_BUFFER_LENGTH = 64 * 1024;
1204
+ var buffers = [
1205
+ "comment",
1206
+ "sgmlDecl",
1207
+ "textNode",
1208
+ "tagName",
1209
+ "doctype",
1210
+ "procInstName",
1211
+ "procInstBody",
1212
+ "entity",
1213
+ "attribName",
1214
+ "attribValue",
1215
+ "cdata",
1216
+ "script"
1217
+ ];
1218
+ sax.EVENTS = [
1219
+ "text",
1220
+ "processinginstruction",
1221
+ "sgmldeclaration",
1222
+ "doctype",
1223
+ "comment",
1224
+ "opentagstart",
1225
+ "attribute",
1226
+ "opentag",
1227
+ "closetag",
1228
+ "opencdata",
1229
+ "cdata",
1230
+ "closecdata",
1231
+ "error",
1232
+ "end",
1233
+ "ready",
1234
+ "script",
1235
+ "opennamespace",
1236
+ "closenamespace"
1237
+ ];
1238
+ function SAXParser(strict, opt) {
1239
+ if (!(this instanceof SAXParser)) {
1240
+ return new SAXParser(strict, opt);
1241
+ }
1242
+ var parser = this;
1243
+ clearBuffers(parser);
1244
+ parser.q = parser.c = "";
1245
+ parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
1246
+ parser.opt = opt || {};
1247
+ parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
1248
+ parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase";
1249
+ parser.tags = [];
1250
+ parser.closed = parser.closedRoot = parser.sawRoot = false;
1251
+ parser.tag = parser.error = null;
1252
+ parser.strict = !!strict;
1253
+ parser.noscript = !!(strict || parser.opt.noscript);
1254
+ parser.state = S.BEGIN;
1255
+ parser.strictEntities = parser.opt.strictEntities;
1256
+ parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES);
1257
+ parser.attribList = [];
1258
+ if (parser.opt.xmlns) {
1259
+ parser.ns = Object.create(rootNS);
1260
+ }
1261
+ parser.trackPosition = parser.opt.position !== false;
1262
+ if (parser.trackPosition) {
1263
+ parser.position = parser.line = parser.column = 0;
1264
+ }
1265
+ emit(parser, "onready");
1266
+ }
1267
+ if (!Object.create) {
1268
+ Object.create = function(o) {
1269
+ function F() {
1270
+ }
1271
+ F.prototype = o;
1272
+ var newf = new F();
1273
+ return newf;
1274
+ };
1275
+ }
1276
+ if (!Object.keys) {
1277
+ Object.keys = function(o) {
1278
+ var a = [];
1279
+ for (var i in o)
1280
+ if (o.hasOwnProperty(i))
1281
+ a.push(i);
1282
+ return a;
1283
+ };
1284
+ }
1285
+ function checkBufferLength(parser) {
1286
+ var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
1287
+ var maxActual = 0;
1288
+ for (var i = 0, l = buffers.length; i < l; i++) {
1289
+ var len = parser[buffers[i]].length;
1290
+ if (len > maxAllowed) {
1291
+ switch (buffers[i]) {
1292
+ case "textNode":
1293
+ closeText(parser);
1294
+ break;
1295
+ case "cdata":
1296
+ emitNode(parser, "oncdata", parser.cdata);
1297
+ parser.cdata = "";
1298
+ break;
1299
+ case "script":
1300
+ emitNode(parser, "onscript", parser.script);
1301
+ parser.script = "";
1302
+ break;
1303
+ default:
1304
+ error(parser, "Max buffer length exceeded: " + buffers[i]);
1305
+ }
1306
+ }
1307
+ maxActual = Math.max(maxActual, len);
1308
+ }
1309
+ var m = sax.MAX_BUFFER_LENGTH - maxActual;
1310
+ parser.bufferCheckPosition = m + parser.position;
1311
+ }
1312
+ function clearBuffers(parser) {
1313
+ for (var i = 0, l = buffers.length; i < l; i++) {
1314
+ parser[buffers[i]] = "";
1315
+ }
1316
+ }
1317
+ function flushBuffers(parser) {
1318
+ closeText(parser);
1319
+ if (parser.cdata !== "") {
1320
+ emitNode(parser, "oncdata", parser.cdata);
1321
+ parser.cdata = "";
1322
+ }
1323
+ if (parser.script !== "") {
1324
+ emitNode(parser, "onscript", parser.script);
1325
+ parser.script = "";
1326
+ }
1327
+ }
1328
+ SAXParser.prototype = {
1329
+ end: function() {
1330
+ end(this);
1331
+ },
1332
+ write,
1333
+ resume: function() {
1334
+ this.error = null;
1335
+ return this;
1336
+ },
1337
+ close: function() {
1338
+ return this.write(null);
1339
+ },
1340
+ flush: function() {
1341
+ flushBuffers(this);
1342
+ }
1343
+ };
1344
+ var Stream;
1345
+ try {
1346
+ Stream = __require("stream").Stream;
1347
+ } catch (ex) {
1348
+ Stream = function() {
1349
+ };
1350
+ }
1351
+ var streamWraps = sax.EVENTS.filter(function(ev) {
1352
+ return ev !== "error" && ev !== "end";
1353
+ });
1354
+ function createStream(strict, opt) {
1355
+ return new SAXStream(strict, opt);
1356
+ }
1357
+ function SAXStream(strict, opt) {
1358
+ if (!(this instanceof SAXStream)) {
1359
+ return new SAXStream(strict, opt);
1360
+ }
1361
+ Stream.apply(this);
1362
+ this._parser = new SAXParser(strict, opt);
1363
+ this.writable = true;
1364
+ this.readable = true;
1365
+ var me = this;
1366
+ this._parser.onend = function() {
1367
+ me.emit("end");
1368
+ };
1369
+ this._parser.onerror = function(er) {
1370
+ me.emit("error", er);
1371
+ me._parser.error = null;
1372
+ };
1373
+ this._decoder = null;
1374
+ streamWraps.forEach(function(ev) {
1375
+ Object.defineProperty(me, "on" + ev, {
1376
+ get: function() {
1377
+ return me._parser["on" + ev];
1378
+ },
1379
+ set: function(h) {
1380
+ if (!h) {
1381
+ me.removeAllListeners(ev);
1382
+ me._parser["on" + ev] = h;
1383
+ return h;
1384
+ }
1385
+ me.on(ev, h);
1386
+ },
1387
+ enumerable: true,
1388
+ configurable: false
1389
+ });
1390
+ });
1391
+ }
1392
+ SAXStream.prototype = Object.create(Stream.prototype, {
1393
+ constructor: {
1394
+ value: SAXStream
1395
+ }
1396
+ });
1397
+ SAXStream.prototype.write = function(data) {
1398
+ if (typeof Buffer === "function" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(data)) {
1399
+ if (!this._decoder) {
1400
+ var SD = __require("string_decoder").StringDecoder;
1401
+ this._decoder = new SD("utf8");
1402
+ }
1403
+ data = this._decoder.write(data);
1404
+ }
1405
+ this._parser.write(data.toString());
1406
+ this.emit("data", data);
1407
+ return true;
1408
+ };
1409
+ SAXStream.prototype.end = function(chunk) {
1410
+ if (chunk && chunk.length) {
1411
+ this.write(chunk);
1412
+ }
1413
+ this._parser.end();
1414
+ return true;
1415
+ };
1416
+ SAXStream.prototype.on = function(ev, handler) {
1417
+ var me = this;
1418
+ if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) {
1419
+ me._parser["on" + ev] = function() {
1420
+ var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
1421
+ args.splice(0, 0, ev);
1422
+ me.emit.apply(me, args);
1423
+ };
1424
+ }
1425
+ return Stream.prototype.on.call(me, ev, handler);
1426
+ };
1427
+ var CDATA = "[CDATA[";
1428
+ var DOCTYPE = "DOCTYPE";
1429
+ var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
1430
+ var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
1431
+ var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE };
1432
+ var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1433
+ var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
1434
+ var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1435
+ var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
1436
+ function isWhitespace(c) {
1437
+ return c === " " || c === "\n" || c === "\r" || c === " ";
1438
+ }
1439
+ function isQuote(c) {
1440
+ return c === '"' || c === "'";
1441
+ }
1442
+ function isAttribEnd(c) {
1443
+ return c === ">" || isWhitespace(c);
1444
+ }
1445
+ function isMatch(regex, c) {
1446
+ return regex.test(c);
1447
+ }
1448
+ function notMatch(regex, c) {
1449
+ return !isMatch(regex, c);
1450
+ }
1451
+ var S = 0;
1452
+ sax.STATE = {
1453
+ BEGIN: S++,
1454
+ BEGIN_WHITESPACE: S++,
1455
+ TEXT: S++,
1456
+ TEXT_ENTITY: S++,
1457
+ OPEN_WAKA: S++,
1458
+ SGML_DECL: S++,
1459
+ SGML_DECL_QUOTED: S++,
1460
+ DOCTYPE: S++,
1461
+ DOCTYPE_QUOTED: S++,
1462
+ DOCTYPE_DTD: S++,
1463
+ DOCTYPE_DTD_QUOTED: S++,
1464
+ COMMENT_STARTING: S++,
1465
+ COMMENT: S++,
1466
+ COMMENT_ENDING: S++,
1467
+ COMMENT_ENDED: S++,
1468
+ CDATA: S++,
1469
+ CDATA_ENDING: S++,
1470
+ CDATA_ENDING_2: S++,
1471
+ PROC_INST: S++,
1472
+ PROC_INST_BODY: S++,
1473
+ PROC_INST_ENDING: S++,
1474
+ OPEN_TAG: S++,
1475
+ OPEN_TAG_SLASH: S++,
1476
+ ATTRIB: S++,
1477
+ ATTRIB_NAME: S++,
1478
+ ATTRIB_NAME_SAW_WHITE: S++,
1479
+ ATTRIB_VALUE: S++,
1480
+ ATTRIB_VALUE_QUOTED: S++,
1481
+ ATTRIB_VALUE_CLOSED: S++,
1482
+ ATTRIB_VALUE_UNQUOTED: S++,
1483
+ ATTRIB_VALUE_ENTITY_Q: S++,
1484
+ ATTRIB_VALUE_ENTITY_U: S++,
1485
+ CLOSE_TAG: S++,
1486
+ CLOSE_TAG_SAW_WHITE: S++,
1487
+ SCRIPT: S++,
1488
+ SCRIPT_ENDING: S++
1489
+ };
1490
+ sax.XML_ENTITIES = {
1491
+ "amp": "&",
1492
+ "gt": ">",
1493
+ "lt": "<",
1494
+ "quot": '"',
1495
+ "apos": "'"
1496
+ };
1497
+ sax.ENTITIES = {
1498
+ "amp": "&",
1499
+ "gt": ">",
1500
+ "lt": "<",
1501
+ "quot": '"',
1502
+ "apos": "'",
1503
+ "AElig": 198,
1504
+ "Aacute": 193,
1505
+ "Acirc": 194,
1506
+ "Agrave": 192,
1507
+ "Aring": 197,
1508
+ "Atilde": 195,
1509
+ "Auml": 196,
1510
+ "Ccedil": 199,
1511
+ "ETH": 208,
1512
+ "Eacute": 201,
1513
+ "Ecirc": 202,
1514
+ "Egrave": 200,
1515
+ "Euml": 203,
1516
+ "Iacute": 205,
1517
+ "Icirc": 206,
1518
+ "Igrave": 204,
1519
+ "Iuml": 207,
1520
+ "Ntilde": 209,
1521
+ "Oacute": 211,
1522
+ "Ocirc": 212,
1523
+ "Ograve": 210,
1524
+ "Oslash": 216,
1525
+ "Otilde": 213,
1526
+ "Ouml": 214,
1527
+ "THORN": 222,
1528
+ "Uacute": 218,
1529
+ "Ucirc": 219,
1530
+ "Ugrave": 217,
1531
+ "Uuml": 220,
1532
+ "Yacute": 221,
1533
+ "aacute": 225,
1534
+ "acirc": 226,
1535
+ "aelig": 230,
1536
+ "agrave": 224,
1537
+ "aring": 229,
1538
+ "atilde": 227,
1539
+ "auml": 228,
1540
+ "ccedil": 231,
1541
+ "eacute": 233,
1542
+ "ecirc": 234,
1543
+ "egrave": 232,
1544
+ "eth": 240,
1545
+ "euml": 235,
1546
+ "iacute": 237,
1547
+ "icirc": 238,
1548
+ "igrave": 236,
1549
+ "iuml": 239,
1550
+ "ntilde": 241,
1551
+ "oacute": 243,
1552
+ "ocirc": 244,
1553
+ "ograve": 242,
1554
+ "oslash": 248,
1555
+ "otilde": 245,
1556
+ "ouml": 246,
1557
+ "szlig": 223,
1558
+ "thorn": 254,
1559
+ "uacute": 250,
1560
+ "ucirc": 251,
1561
+ "ugrave": 249,
1562
+ "uuml": 252,
1563
+ "yacute": 253,
1564
+ "yuml": 255,
1565
+ "copy": 169,
1566
+ "reg": 174,
1567
+ "nbsp": 160,
1568
+ "iexcl": 161,
1569
+ "cent": 162,
1570
+ "pound": 163,
1571
+ "curren": 164,
1572
+ "yen": 165,
1573
+ "brvbar": 166,
1574
+ "sect": 167,
1575
+ "uml": 168,
1576
+ "ordf": 170,
1577
+ "laquo": 171,
1578
+ "not": 172,
1579
+ "shy": 173,
1580
+ "macr": 175,
1581
+ "deg": 176,
1582
+ "plusmn": 177,
1583
+ "sup1": 185,
1584
+ "sup2": 178,
1585
+ "sup3": 179,
1586
+ "acute": 180,
1587
+ "micro": 181,
1588
+ "para": 182,
1589
+ "middot": 183,
1590
+ "cedil": 184,
1591
+ "ordm": 186,
1592
+ "raquo": 187,
1593
+ "frac14": 188,
1594
+ "frac12": 189,
1595
+ "frac34": 190,
1596
+ "iquest": 191,
1597
+ "times": 215,
1598
+ "divide": 247,
1599
+ "OElig": 338,
1600
+ "oelig": 339,
1601
+ "Scaron": 352,
1602
+ "scaron": 353,
1603
+ "Yuml": 376,
1604
+ "fnof": 402,
1605
+ "circ": 710,
1606
+ "tilde": 732,
1607
+ "Alpha": 913,
1608
+ "Beta": 914,
1609
+ "Gamma": 915,
1610
+ "Delta": 916,
1611
+ "Epsilon": 917,
1612
+ "Zeta": 918,
1613
+ "Eta": 919,
1614
+ "Theta": 920,
1615
+ "Iota": 921,
1616
+ "Kappa": 922,
1617
+ "Lambda": 923,
1618
+ "Mu": 924,
1619
+ "Nu": 925,
1620
+ "Xi": 926,
1621
+ "Omicron": 927,
1622
+ "Pi": 928,
1623
+ "Rho": 929,
1624
+ "Sigma": 931,
1625
+ "Tau": 932,
1626
+ "Upsilon": 933,
1627
+ "Phi": 934,
1628
+ "Chi": 935,
1629
+ "Psi": 936,
1630
+ "Omega": 937,
1631
+ "alpha": 945,
1632
+ "beta": 946,
1633
+ "gamma": 947,
1634
+ "delta": 948,
1635
+ "epsilon": 949,
1636
+ "zeta": 950,
1637
+ "eta": 951,
1638
+ "theta": 952,
1639
+ "iota": 953,
1640
+ "kappa": 954,
1641
+ "lambda": 955,
1642
+ "mu": 956,
1643
+ "nu": 957,
1644
+ "xi": 958,
1645
+ "omicron": 959,
1646
+ "pi": 960,
1647
+ "rho": 961,
1648
+ "sigmaf": 962,
1649
+ "sigma": 963,
1650
+ "tau": 964,
1651
+ "upsilon": 965,
1652
+ "phi": 966,
1653
+ "chi": 967,
1654
+ "psi": 968,
1655
+ "omega": 969,
1656
+ "thetasym": 977,
1657
+ "upsih": 978,
1658
+ "piv": 982,
1659
+ "ensp": 8194,
1660
+ "emsp": 8195,
1661
+ "thinsp": 8201,
1662
+ "zwnj": 8204,
1663
+ "zwj": 8205,
1664
+ "lrm": 8206,
1665
+ "rlm": 8207,
1666
+ "ndash": 8211,
1667
+ "mdash": 8212,
1668
+ "lsquo": 8216,
1669
+ "rsquo": 8217,
1670
+ "sbquo": 8218,
1671
+ "ldquo": 8220,
1672
+ "rdquo": 8221,
1673
+ "bdquo": 8222,
1674
+ "dagger": 8224,
1675
+ "Dagger": 8225,
1676
+ "bull": 8226,
1677
+ "hellip": 8230,
1678
+ "permil": 8240,
1679
+ "prime": 8242,
1680
+ "Prime": 8243,
1681
+ "lsaquo": 8249,
1682
+ "rsaquo": 8250,
1683
+ "oline": 8254,
1684
+ "frasl": 8260,
1685
+ "euro": 8364,
1686
+ "image": 8465,
1687
+ "weierp": 8472,
1688
+ "real": 8476,
1689
+ "trade": 8482,
1690
+ "alefsym": 8501,
1691
+ "larr": 8592,
1692
+ "uarr": 8593,
1693
+ "rarr": 8594,
1694
+ "darr": 8595,
1695
+ "harr": 8596,
1696
+ "crarr": 8629,
1697
+ "lArr": 8656,
1698
+ "uArr": 8657,
1699
+ "rArr": 8658,
1700
+ "dArr": 8659,
1701
+ "hArr": 8660,
1702
+ "forall": 8704,
1703
+ "part": 8706,
1704
+ "exist": 8707,
1705
+ "empty": 8709,
1706
+ "nabla": 8711,
1707
+ "isin": 8712,
1708
+ "notin": 8713,
1709
+ "ni": 8715,
1710
+ "prod": 8719,
1711
+ "sum": 8721,
1712
+ "minus": 8722,
1713
+ "lowast": 8727,
1714
+ "radic": 8730,
1715
+ "prop": 8733,
1716
+ "infin": 8734,
1717
+ "ang": 8736,
1718
+ "and": 8743,
1719
+ "or": 8744,
1720
+ "cap": 8745,
1721
+ "cup": 8746,
1722
+ "int": 8747,
1723
+ "there4": 8756,
1724
+ "sim": 8764,
1725
+ "cong": 8773,
1726
+ "asymp": 8776,
1727
+ "ne": 8800,
1728
+ "equiv": 8801,
1729
+ "le": 8804,
1730
+ "ge": 8805,
1731
+ "sub": 8834,
1732
+ "sup": 8835,
1733
+ "nsub": 8836,
1734
+ "sube": 8838,
1735
+ "supe": 8839,
1736
+ "oplus": 8853,
1737
+ "otimes": 8855,
1738
+ "perp": 8869,
1739
+ "sdot": 8901,
1740
+ "lceil": 8968,
1741
+ "rceil": 8969,
1742
+ "lfloor": 8970,
1743
+ "rfloor": 8971,
1744
+ "lang": 9001,
1745
+ "rang": 9002,
1746
+ "loz": 9674,
1747
+ "spades": 9824,
1748
+ "clubs": 9827,
1749
+ "hearts": 9829,
1750
+ "diams": 9830
1751
+ };
1752
+ Object.keys(sax.ENTITIES).forEach(function(key) {
1753
+ var e = sax.ENTITIES[key];
1754
+ var s2 = typeof e === "number" ? String.fromCharCode(e) : e;
1755
+ sax.ENTITIES[key] = s2;
1756
+ });
1757
+ for (var s in sax.STATE) {
1758
+ sax.STATE[sax.STATE[s]] = s;
1759
+ }
1760
+ S = sax.STATE;
1761
+ function emit(parser, event, data) {
1762
+ parser[event] && parser[event](data);
1763
+ }
1764
+ function emitNode(parser, nodeType, data) {
1765
+ if (parser.textNode)
1766
+ closeText(parser);
1767
+ emit(parser, nodeType, data);
1768
+ }
1769
+ function closeText(parser) {
1770
+ parser.textNode = textopts(parser.opt, parser.textNode);
1771
+ if (parser.textNode)
1772
+ emit(parser, "ontext", parser.textNode);
1773
+ parser.textNode = "";
1774
+ }
1775
+ function textopts(opt, text) {
1776
+ if (opt.trim)
1777
+ text = text.trim();
1778
+ if (opt.normalize)
1779
+ text = text.replace(/\s+/g, " ");
1780
+ return text;
1781
+ }
1782
+ function error(parser, er) {
1783
+ closeText(parser);
1784
+ if (parser.trackPosition) {
1785
+ er += "\nLine: " + parser.line + "\nColumn: " + parser.column + "\nChar: " + parser.c;
1786
+ }
1787
+ er = new Error(er);
1788
+ parser.error = er;
1789
+ emit(parser, "onerror", er);
1790
+ return parser;
1791
+ }
1792
+ function end(parser) {
1793
+ if (parser.sawRoot && !parser.closedRoot)
1794
+ strictFail(parser, "Unclosed root tag");
1795
+ if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
1796
+ error(parser, "Unexpected end");
1797
+ }
1798
+ closeText(parser);
1799
+ parser.c = "";
1800
+ parser.closed = true;
1801
+ emit(parser, "onend");
1802
+ SAXParser.call(parser, parser.strict, parser.opt);
1803
+ return parser;
1804
+ }
1805
+ function strictFail(parser, message) {
1806
+ if (typeof parser !== "object" || !(parser instanceof SAXParser)) {
1807
+ throw new Error("bad call to strictFail");
1808
+ }
1809
+ if (parser.strict) {
1810
+ error(parser, message);
1811
+ }
1812
+ }
1813
+ function newTag(parser) {
1814
+ if (!parser.strict)
1815
+ parser.tagName = parser.tagName[parser.looseCase]();
1816
+ var parent = parser.tags[parser.tags.length - 1] || parser;
1817
+ var tag = parser.tag = { name: parser.tagName, attributes: {} };
1818
+ if (parser.opt.xmlns) {
1819
+ tag.ns = parent.ns;
1820
+ }
1821
+ parser.attribList.length = 0;
1822
+ emitNode(parser, "onopentagstart", tag);
1823
+ }
1824
+ function qname(name, attribute) {
1825
+ var i = name.indexOf(":");
1826
+ var qualName = i < 0 ? ["", name] : name.split(":");
1827
+ var prefix = qualName[0];
1828
+ var local = qualName[1];
1829
+ if (attribute && name === "xmlns") {
1830
+ prefix = "xmlns";
1831
+ local = "";
1832
+ }
1833
+ return { prefix, local };
1834
+ }
1835
+ function attrib(parser) {
1836
+ if (!parser.strict) {
1837
+ parser.attribName = parser.attribName[parser.looseCase]();
1838
+ }
1839
+ if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
1840
+ parser.attribName = parser.attribValue = "";
1841
+ return;
1842
+ }
1843
+ if (parser.opt.xmlns) {
1844
+ var qn = qname(parser.attribName, true);
1845
+ var prefix = qn.prefix;
1846
+ var local = qn.local;
1847
+ if (prefix === "xmlns") {
1848
+ if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
1849
+ strictFail(parser, "xml: prefix must be bound to " + XML_NAMESPACE + "\nActual: " + parser.attribValue);
1850
+ } else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
1851
+ strictFail(parser, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\nActual: " + parser.attribValue);
1852
+ } else {
1853
+ var tag = parser.tag;
1854
+ var parent = parser.tags[parser.tags.length - 1] || parser;
1855
+ if (tag.ns === parent.ns) {
1856
+ tag.ns = Object.create(parent.ns);
1857
+ }
1858
+ tag.ns[local] = parser.attribValue;
1859
+ }
1860
+ }
1861
+ parser.attribList.push([parser.attribName, parser.attribValue]);
1862
+ } else {
1863
+ parser.tag.attributes[parser.attribName] = parser.attribValue;
1864
+ emitNode(parser, "onattribute", {
1865
+ name: parser.attribName,
1866
+ value: parser.attribValue
1867
+ });
1868
+ }
1869
+ parser.attribName = parser.attribValue = "";
1870
+ }
1871
+ function openTag(parser, selfClosing) {
1872
+ if (parser.opt.xmlns) {
1873
+ var tag = parser.tag;
1874
+ var qn = qname(parser.tagName);
1875
+ tag.prefix = qn.prefix;
1876
+ tag.local = qn.local;
1877
+ tag.uri = tag.ns[qn.prefix] || "";
1878
+ if (tag.prefix && !tag.uri) {
1879
+ strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(parser.tagName));
1880
+ tag.uri = qn.prefix;
1881
+ }
1882
+ var parent = parser.tags[parser.tags.length - 1] || parser;
1883
+ if (tag.ns && parent.ns !== tag.ns) {
1884
+ Object.keys(tag.ns).forEach(function(p) {
1885
+ emitNode(parser, "onopennamespace", {
1886
+ prefix: p,
1887
+ uri: tag.ns[p]
1888
+ });
1889
+ });
1890
+ }
1891
+ for (var i = 0, l = parser.attribList.length; i < l; i++) {
1892
+ var nv = parser.attribList[i];
1893
+ var name = nv[0];
1894
+ var value = nv[1];
1895
+ var qualName = qname(name, true);
1896
+ var prefix = qualName.prefix;
1897
+ var local = qualName.local;
1898
+ var uri = prefix === "" ? "" : tag.ns[prefix] || "";
1899
+ var a = {
1900
+ name,
1901
+ value,
1902
+ prefix,
1903
+ local,
1904
+ uri
1905
+ };
1906
+ if (prefix && prefix !== "xmlns" && !uri) {
1907
+ strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(prefix));
1908
+ a.uri = prefix;
1909
+ }
1910
+ parser.tag.attributes[name] = a;
1911
+ emitNode(parser, "onattribute", a);
1912
+ }
1913
+ parser.attribList.length = 0;
1914
+ }
1915
+ parser.tag.isSelfClosing = !!selfClosing;
1916
+ parser.sawRoot = true;
1917
+ parser.tags.push(parser.tag);
1918
+ emitNode(parser, "onopentag", parser.tag);
1919
+ if (!selfClosing) {
1920
+ if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
1921
+ parser.state = S.SCRIPT;
1922
+ } else {
1923
+ parser.state = S.TEXT;
1924
+ }
1925
+ parser.tag = null;
1926
+ parser.tagName = "";
1927
+ }
1928
+ parser.attribName = parser.attribValue = "";
1929
+ parser.attribList.length = 0;
1930
+ }
1931
+ function closeTag(parser) {
1932
+ if (!parser.tagName) {
1933
+ strictFail(parser, "Weird empty close tag.");
1934
+ parser.textNode += "</>";
1935
+ parser.state = S.TEXT;
1936
+ return;
1937
+ }
1938
+ if (parser.script) {
1939
+ if (parser.tagName !== "script") {
1940
+ parser.script += "</" + parser.tagName + ">";
1941
+ parser.tagName = "";
1942
+ parser.state = S.SCRIPT;
1943
+ return;
1944
+ }
1945
+ emitNode(parser, "onscript", parser.script);
1946
+ parser.script = "";
1947
+ }
1948
+ var t = parser.tags.length;
1949
+ var tagName = parser.tagName;
1950
+ if (!parser.strict) {
1951
+ tagName = tagName[parser.looseCase]();
1952
+ }
1953
+ var closeTo = tagName;
1954
+ while (t--) {
1955
+ var close = parser.tags[t];
1956
+ if (close.name !== closeTo) {
1957
+ strictFail(parser, "Unexpected close tag");
1958
+ } else {
1959
+ break;
1960
+ }
1961
+ }
1962
+ if (t < 0) {
1963
+ strictFail(parser, "Unmatched closing tag: " + parser.tagName);
1964
+ parser.textNode += "</" + parser.tagName + ">";
1965
+ parser.state = S.TEXT;
1966
+ return;
1967
+ }
1968
+ parser.tagName = tagName;
1969
+ var s2 = parser.tags.length;
1970
+ while (s2-- > t) {
1971
+ var tag = parser.tag = parser.tags.pop();
1972
+ parser.tagName = parser.tag.name;
1973
+ emitNode(parser, "onclosetag", parser.tagName);
1974
+ var x = {};
1975
+ for (var i in tag.ns) {
1976
+ x[i] = tag.ns[i];
1977
+ }
1978
+ var parent = parser.tags[parser.tags.length - 1] || parser;
1979
+ if (parser.opt.xmlns && tag.ns !== parent.ns) {
1980
+ Object.keys(tag.ns).forEach(function(p) {
1981
+ var n = tag.ns[p];
1982
+ emitNode(parser, "onclosenamespace", { prefix: p, uri: n });
1983
+ });
1984
+ }
1985
+ }
1986
+ if (t === 0)
1987
+ parser.closedRoot = true;
1988
+ parser.tagName = parser.attribValue = parser.attribName = "";
1989
+ parser.attribList.length = 0;
1990
+ parser.state = S.TEXT;
1991
+ }
1992
+ function parseEntity(parser) {
1993
+ var entity = parser.entity;
1994
+ var entityLC = entity.toLowerCase();
1995
+ var num;
1996
+ var numStr = "";
1997
+ if (parser.ENTITIES[entity]) {
1998
+ return parser.ENTITIES[entity];
1999
+ }
2000
+ if (parser.ENTITIES[entityLC]) {
2001
+ return parser.ENTITIES[entityLC];
2002
+ }
2003
+ entity = entityLC;
2004
+ if (entity.charAt(0) === "#") {
2005
+ if (entity.charAt(1) === "x") {
2006
+ entity = entity.slice(2);
2007
+ num = parseInt(entity, 16);
2008
+ numStr = num.toString(16);
2009
+ } else {
2010
+ entity = entity.slice(1);
2011
+ num = parseInt(entity, 10);
2012
+ numStr = num.toString(10);
2013
+ }
2014
+ }
2015
+ entity = entity.replace(/^0+/, "");
2016
+ if (isNaN(num) || numStr.toLowerCase() !== entity) {
2017
+ strictFail(parser, "Invalid character entity");
2018
+ return "&" + parser.entity + ";";
2019
+ }
2020
+ return String.fromCodePoint(num);
2021
+ }
2022
+ function beginWhiteSpace(parser, c) {
2023
+ if (c === "<") {
2024
+ parser.state = S.OPEN_WAKA;
2025
+ parser.startTagPosition = parser.position;
2026
+ } else if (!isWhitespace(c)) {
2027
+ strictFail(parser, "Non-whitespace before first tag.");
2028
+ parser.textNode = c;
2029
+ parser.state = S.TEXT;
2030
+ }
2031
+ }
2032
+ function charAt(chunk, i) {
2033
+ var result = "";
2034
+ if (i < chunk.length) {
2035
+ result = chunk.charAt(i);
2036
+ }
2037
+ return result;
2038
+ }
2039
+ function write(chunk) {
2040
+ var parser = this;
2041
+ if (this.error) {
2042
+ throw this.error;
2043
+ }
2044
+ if (parser.closed) {
2045
+ return error(parser, "Cannot write after close. Assign an onready handler.");
2046
+ }
2047
+ if (chunk === null) {
2048
+ return end(parser);
2049
+ }
2050
+ if (typeof chunk === "object") {
2051
+ chunk = chunk.toString();
2052
+ }
2053
+ var i = 0;
2054
+ var c = "";
2055
+ while (true) {
2056
+ c = charAt(chunk, i++);
2057
+ parser.c = c;
2058
+ if (!c) {
2059
+ break;
2060
+ }
2061
+ if (parser.trackPosition) {
2062
+ parser.position++;
2063
+ if (c === "\n") {
2064
+ parser.line++;
2065
+ parser.column = 0;
2066
+ } else {
2067
+ parser.column++;
2068
+ }
2069
+ }
2070
+ switch (parser.state) {
2071
+ case S.BEGIN:
2072
+ parser.state = S.BEGIN_WHITESPACE;
2073
+ if (c === "\uFEFF") {
2074
+ continue;
2075
+ }
2076
+ beginWhiteSpace(parser, c);
2077
+ continue;
2078
+ case S.BEGIN_WHITESPACE:
2079
+ beginWhiteSpace(parser, c);
2080
+ continue;
2081
+ case S.TEXT:
2082
+ if (parser.sawRoot && !parser.closedRoot) {
2083
+ var starti = i - 1;
2084
+ while (c && c !== "<" && c !== "&") {
2085
+ c = charAt(chunk, i++);
2086
+ if (c && parser.trackPosition) {
2087
+ parser.position++;
2088
+ if (c === "\n") {
2089
+ parser.line++;
2090
+ parser.column = 0;
2091
+ } else {
2092
+ parser.column++;
2093
+ }
2094
+ }
2095
+ }
2096
+ parser.textNode += chunk.substring(starti, i - 1);
2097
+ }
2098
+ if (c === "<" && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
2099
+ parser.state = S.OPEN_WAKA;
2100
+ parser.startTagPosition = parser.position;
2101
+ } else {
2102
+ if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
2103
+ strictFail(parser, "Text data outside of root node.");
2104
+ }
2105
+ if (c === "&") {
2106
+ parser.state = S.TEXT_ENTITY;
2107
+ } else {
2108
+ parser.textNode += c;
2109
+ }
2110
+ }
2111
+ continue;
2112
+ case S.SCRIPT:
2113
+ if (c === "<") {
2114
+ parser.state = S.SCRIPT_ENDING;
2115
+ } else {
2116
+ parser.script += c;
2117
+ }
2118
+ continue;
2119
+ case S.SCRIPT_ENDING:
2120
+ if (c === "/") {
2121
+ parser.state = S.CLOSE_TAG;
2122
+ } else {
2123
+ parser.script += "<" + c;
2124
+ parser.state = S.SCRIPT;
2125
+ }
2126
+ continue;
2127
+ case S.OPEN_WAKA:
2128
+ if (c === "!") {
2129
+ parser.state = S.SGML_DECL;
2130
+ parser.sgmlDecl = "";
2131
+ } else if (isWhitespace(c)) {
2132
+ } else if (isMatch(nameStart, c)) {
2133
+ parser.state = S.OPEN_TAG;
2134
+ parser.tagName = c;
2135
+ } else if (c === "/") {
2136
+ parser.state = S.CLOSE_TAG;
2137
+ parser.tagName = "";
2138
+ } else if (c === "?") {
2139
+ parser.state = S.PROC_INST;
2140
+ parser.procInstName = parser.procInstBody = "";
2141
+ } else {
2142
+ strictFail(parser, "Unencoded <");
2143
+ if (parser.startTagPosition + 1 < parser.position) {
2144
+ var pad = parser.position - parser.startTagPosition;
2145
+ c = new Array(pad).join(" ") + c;
2146
+ }
2147
+ parser.textNode += "<" + c;
2148
+ parser.state = S.TEXT;
2149
+ }
2150
+ continue;
2151
+ case S.SGML_DECL:
2152
+ if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
2153
+ emitNode(parser, "onopencdata");
2154
+ parser.state = S.CDATA;
2155
+ parser.sgmlDecl = "";
2156
+ parser.cdata = "";
2157
+ } else if (parser.sgmlDecl + c === "--") {
2158
+ parser.state = S.COMMENT;
2159
+ parser.comment = "";
2160
+ parser.sgmlDecl = "";
2161
+ } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
2162
+ parser.state = S.DOCTYPE;
2163
+ if (parser.doctype || parser.sawRoot) {
2164
+ strictFail(parser, "Inappropriately located doctype declaration");
2165
+ }
2166
+ parser.doctype = "";
2167
+ parser.sgmlDecl = "";
2168
+ } else if (c === ">") {
2169
+ emitNode(parser, "onsgmldeclaration", parser.sgmlDecl);
2170
+ parser.sgmlDecl = "";
2171
+ parser.state = S.TEXT;
2172
+ } else if (isQuote(c)) {
2173
+ parser.state = S.SGML_DECL_QUOTED;
2174
+ parser.sgmlDecl += c;
2175
+ } else {
2176
+ parser.sgmlDecl += c;
2177
+ }
2178
+ continue;
2179
+ case S.SGML_DECL_QUOTED:
2180
+ if (c === parser.q) {
2181
+ parser.state = S.SGML_DECL;
2182
+ parser.q = "";
2183
+ }
2184
+ parser.sgmlDecl += c;
2185
+ continue;
2186
+ case S.DOCTYPE:
2187
+ if (c === ">") {
2188
+ parser.state = S.TEXT;
2189
+ emitNode(parser, "ondoctype", parser.doctype);
2190
+ parser.doctype = true;
2191
+ } else {
2192
+ parser.doctype += c;
2193
+ if (c === "[") {
2194
+ parser.state = S.DOCTYPE_DTD;
2195
+ } else if (isQuote(c)) {
2196
+ parser.state = S.DOCTYPE_QUOTED;
2197
+ parser.q = c;
2198
+ }
2199
+ }
2200
+ continue;
2201
+ case S.DOCTYPE_QUOTED:
2202
+ parser.doctype += c;
2203
+ if (c === parser.q) {
2204
+ parser.q = "";
2205
+ parser.state = S.DOCTYPE;
2206
+ }
2207
+ continue;
2208
+ case S.DOCTYPE_DTD:
2209
+ parser.doctype += c;
2210
+ if (c === "]") {
2211
+ parser.state = S.DOCTYPE;
2212
+ } else if (isQuote(c)) {
2213
+ parser.state = S.DOCTYPE_DTD_QUOTED;
2214
+ parser.q = c;
2215
+ }
2216
+ continue;
2217
+ case S.DOCTYPE_DTD_QUOTED:
2218
+ parser.doctype += c;
2219
+ if (c === parser.q) {
2220
+ parser.state = S.DOCTYPE_DTD;
2221
+ parser.q = "";
2222
+ }
2223
+ continue;
2224
+ case S.COMMENT:
2225
+ if (c === "-") {
2226
+ parser.state = S.COMMENT_ENDING;
2227
+ } else {
2228
+ parser.comment += c;
2229
+ }
2230
+ continue;
2231
+ case S.COMMENT_ENDING:
2232
+ if (c === "-") {
2233
+ parser.state = S.COMMENT_ENDED;
2234
+ parser.comment = textopts(parser.opt, parser.comment);
2235
+ if (parser.comment) {
2236
+ emitNode(parser, "oncomment", parser.comment);
2237
+ }
2238
+ parser.comment = "";
2239
+ } else {
2240
+ parser.comment += "-" + c;
2241
+ parser.state = S.COMMENT;
2242
+ }
2243
+ continue;
2244
+ case S.COMMENT_ENDED:
2245
+ if (c !== ">") {
2246
+ strictFail(parser, "Malformed comment");
2247
+ parser.comment += "--" + c;
2248
+ parser.state = S.COMMENT;
2249
+ } else {
2250
+ parser.state = S.TEXT;
2251
+ }
2252
+ continue;
2253
+ case S.CDATA:
2254
+ if (c === "]") {
2255
+ parser.state = S.CDATA_ENDING;
2256
+ } else {
2257
+ parser.cdata += c;
2258
+ }
2259
+ continue;
2260
+ case S.CDATA_ENDING:
2261
+ if (c === "]") {
2262
+ parser.state = S.CDATA_ENDING_2;
2263
+ } else {
2264
+ parser.cdata += "]" + c;
2265
+ parser.state = S.CDATA;
2266
+ }
2267
+ continue;
2268
+ case S.CDATA_ENDING_2:
2269
+ if (c === ">") {
2270
+ if (parser.cdata) {
2271
+ emitNode(parser, "oncdata", parser.cdata);
2272
+ }
2273
+ emitNode(parser, "onclosecdata");
2274
+ parser.cdata = "";
2275
+ parser.state = S.TEXT;
2276
+ } else if (c === "]") {
2277
+ parser.cdata += "]";
2278
+ } else {
2279
+ parser.cdata += "]]" + c;
2280
+ parser.state = S.CDATA;
2281
+ }
2282
+ continue;
2283
+ case S.PROC_INST:
2284
+ if (c === "?") {
2285
+ parser.state = S.PROC_INST_ENDING;
2286
+ } else if (isWhitespace(c)) {
2287
+ parser.state = S.PROC_INST_BODY;
2288
+ } else {
2289
+ parser.procInstName += c;
2290
+ }
2291
+ continue;
2292
+ case S.PROC_INST_BODY:
2293
+ if (!parser.procInstBody && isWhitespace(c)) {
2294
+ continue;
2295
+ } else if (c === "?") {
2296
+ parser.state = S.PROC_INST_ENDING;
2297
+ } else {
2298
+ parser.procInstBody += c;
2299
+ }
2300
+ continue;
2301
+ case S.PROC_INST_ENDING:
2302
+ if (c === ">") {
2303
+ emitNode(parser, "onprocessinginstruction", {
2304
+ name: parser.procInstName,
2305
+ body: parser.procInstBody
2306
+ });
2307
+ parser.procInstName = parser.procInstBody = "";
2308
+ parser.state = S.TEXT;
2309
+ } else {
2310
+ parser.procInstBody += "?" + c;
2311
+ parser.state = S.PROC_INST_BODY;
2312
+ }
2313
+ continue;
2314
+ case S.OPEN_TAG:
2315
+ if (isMatch(nameBody, c)) {
2316
+ parser.tagName += c;
2317
+ } else {
2318
+ newTag(parser);
2319
+ if (c === ">") {
2320
+ openTag(parser);
2321
+ } else if (c === "/") {
2322
+ parser.state = S.OPEN_TAG_SLASH;
2323
+ } else {
2324
+ if (!isWhitespace(c)) {
2325
+ strictFail(parser, "Invalid character in tag name");
2326
+ }
2327
+ parser.state = S.ATTRIB;
2328
+ }
2329
+ }
2330
+ continue;
2331
+ case S.OPEN_TAG_SLASH:
2332
+ if (c === ">") {
2333
+ openTag(parser, true);
2334
+ closeTag(parser);
2335
+ } else {
2336
+ strictFail(parser, "Forward-slash in opening tag not followed by >");
2337
+ parser.state = S.ATTRIB;
2338
+ }
2339
+ continue;
2340
+ case S.ATTRIB:
2341
+ if (isWhitespace(c)) {
2342
+ continue;
2343
+ } else if (c === ">") {
2344
+ openTag(parser);
2345
+ } else if (c === "/") {
2346
+ parser.state = S.OPEN_TAG_SLASH;
2347
+ } else if (isMatch(nameStart, c)) {
2348
+ parser.attribName = c;
2349
+ parser.attribValue = "";
2350
+ parser.state = S.ATTRIB_NAME;
2351
+ } else {
2352
+ strictFail(parser, "Invalid attribute name");
2353
+ }
2354
+ continue;
2355
+ case S.ATTRIB_NAME:
2356
+ if (c === "=") {
2357
+ parser.state = S.ATTRIB_VALUE;
2358
+ } else if (c === ">") {
2359
+ strictFail(parser, "Attribute without value");
2360
+ parser.attribValue = parser.attribName;
2361
+ attrib(parser);
2362
+ openTag(parser);
2363
+ } else if (isWhitespace(c)) {
2364
+ parser.state = S.ATTRIB_NAME_SAW_WHITE;
2365
+ } else if (isMatch(nameBody, c)) {
2366
+ parser.attribName += c;
2367
+ } else {
2368
+ strictFail(parser, "Invalid attribute name");
2369
+ }
2370
+ continue;
2371
+ case S.ATTRIB_NAME_SAW_WHITE:
2372
+ if (c === "=") {
2373
+ parser.state = S.ATTRIB_VALUE;
2374
+ } else if (isWhitespace(c)) {
2375
+ continue;
2376
+ } else {
2377
+ strictFail(parser, "Attribute without value");
2378
+ parser.tag.attributes[parser.attribName] = "";
2379
+ parser.attribValue = "";
2380
+ emitNode(parser, "onattribute", {
2381
+ name: parser.attribName,
2382
+ value: ""
2383
+ });
2384
+ parser.attribName = "";
2385
+ if (c === ">") {
2386
+ openTag(parser);
2387
+ } else if (isMatch(nameStart, c)) {
2388
+ parser.attribName = c;
2389
+ parser.state = S.ATTRIB_NAME;
2390
+ } else {
2391
+ strictFail(parser, "Invalid attribute name");
2392
+ parser.state = S.ATTRIB;
2393
+ }
2394
+ }
2395
+ continue;
2396
+ case S.ATTRIB_VALUE:
2397
+ if (isWhitespace(c)) {
2398
+ continue;
2399
+ } else if (isQuote(c)) {
2400
+ parser.q = c;
2401
+ parser.state = S.ATTRIB_VALUE_QUOTED;
2402
+ } else {
2403
+ strictFail(parser, "Unquoted attribute value");
2404
+ parser.state = S.ATTRIB_VALUE_UNQUOTED;
2405
+ parser.attribValue = c;
2406
+ }
2407
+ continue;
2408
+ case S.ATTRIB_VALUE_QUOTED:
2409
+ if (c !== parser.q) {
2410
+ if (c === "&") {
2411
+ parser.state = S.ATTRIB_VALUE_ENTITY_Q;
2412
+ } else {
2413
+ parser.attribValue += c;
2414
+ }
2415
+ continue;
2416
+ }
2417
+ attrib(parser);
2418
+ parser.q = "";
2419
+ parser.state = S.ATTRIB_VALUE_CLOSED;
2420
+ continue;
2421
+ case S.ATTRIB_VALUE_CLOSED:
2422
+ if (isWhitespace(c)) {
2423
+ parser.state = S.ATTRIB;
2424
+ } else if (c === ">") {
2425
+ openTag(parser);
2426
+ } else if (c === "/") {
2427
+ parser.state = S.OPEN_TAG_SLASH;
2428
+ } else if (isMatch(nameStart, c)) {
2429
+ strictFail(parser, "No whitespace between attributes");
2430
+ parser.attribName = c;
2431
+ parser.attribValue = "";
2432
+ parser.state = S.ATTRIB_NAME;
2433
+ } else {
2434
+ strictFail(parser, "Invalid attribute name");
2435
+ }
2436
+ continue;
2437
+ case S.ATTRIB_VALUE_UNQUOTED:
2438
+ if (!isAttribEnd(c)) {
2439
+ if (c === "&") {
2440
+ parser.state = S.ATTRIB_VALUE_ENTITY_U;
2441
+ } else {
2442
+ parser.attribValue += c;
2443
+ }
2444
+ continue;
2445
+ }
2446
+ attrib(parser);
2447
+ if (c === ">") {
2448
+ openTag(parser);
2449
+ } else {
2450
+ parser.state = S.ATTRIB;
2451
+ }
2452
+ continue;
2453
+ case S.CLOSE_TAG:
2454
+ if (!parser.tagName) {
2455
+ if (isWhitespace(c)) {
2456
+ continue;
2457
+ } else if (notMatch(nameStart, c)) {
2458
+ if (parser.script) {
2459
+ parser.script += "</" + c;
2460
+ parser.state = S.SCRIPT;
2461
+ } else {
2462
+ strictFail(parser, "Invalid tagname in closing tag.");
2463
+ }
2464
+ } else {
2465
+ parser.tagName = c;
2466
+ }
2467
+ } else if (c === ">") {
2468
+ closeTag(parser);
2469
+ } else if (isMatch(nameBody, c)) {
2470
+ parser.tagName += c;
2471
+ } else if (parser.script) {
2472
+ parser.script += "</" + parser.tagName;
2473
+ parser.tagName = "";
2474
+ parser.state = S.SCRIPT;
2475
+ } else {
2476
+ if (!isWhitespace(c)) {
2477
+ strictFail(parser, "Invalid tagname in closing tag");
2478
+ }
2479
+ parser.state = S.CLOSE_TAG_SAW_WHITE;
2480
+ }
2481
+ continue;
2482
+ case S.CLOSE_TAG_SAW_WHITE:
2483
+ if (isWhitespace(c)) {
2484
+ continue;
2485
+ }
2486
+ if (c === ">") {
2487
+ closeTag(parser);
2488
+ } else {
2489
+ strictFail(parser, "Invalid characters in closing tag");
2490
+ }
2491
+ continue;
2492
+ case S.TEXT_ENTITY:
2493
+ case S.ATTRIB_VALUE_ENTITY_Q:
2494
+ case S.ATTRIB_VALUE_ENTITY_U:
2495
+ var returnState;
2496
+ var buffer;
2497
+ switch (parser.state) {
2498
+ case S.TEXT_ENTITY:
2499
+ returnState = S.TEXT;
2500
+ buffer = "textNode";
2501
+ break;
2502
+ case S.ATTRIB_VALUE_ENTITY_Q:
2503
+ returnState = S.ATTRIB_VALUE_QUOTED;
2504
+ buffer = "attribValue";
2505
+ break;
2506
+ case S.ATTRIB_VALUE_ENTITY_U:
2507
+ returnState = S.ATTRIB_VALUE_UNQUOTED;
2508
+ buffer = "attribValue";
2509
+ break;
2510
+ }
2511
+ if (c === ";") {
2512
+ parser[buffer] += parseEntity(parser);
2513
+ parser.entity = "";
2514
+ parser.state = returnState;
2515
+ } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
2516
+ parser.entity += c;
2517
+ } else {
2518
+ strictFail(parser, "Invalid character in entity name");
2519
+ parser[buffer] += "&" + parser.entity + c;
2520
+ parser.entity = "";
2521
+ parser.state = returnState;
2522
+ }
2523
+ continue;
2524
+ default:
2525
+ throw new Error(parser, "Unknown state: " + parser.state);
2526
+ }
2527
+ }
2528
+ if (parser.position >= parser.bufferCheckPosition) {
2529
+ checkBufferLength(parser);
2530
+ }
2531
+ return parser;
2532
+ }
2533
+ if (!String.fromCodePoint) {
2534
+ (function() {
2535
+ var stringFromCharCode = String.fromCharCode;
2536
+ var floor = Math.floor;
2537
+ var fromCodePoint = function() {
2538
+ var MAX_SIZE = 16384;
2539
+ var codeUnits = [];
2540
+ var highSurrogate;
2541
+ var lowSurrogate;
2542
+ var index = -1;
2543
+ var length = arguments.length;
2544
+ if (!length) {
2545
+ return "";
2546
+ }
2547
+ var result = "";
2548
+ while (++index < length) {
2549
+ var codePoint = Number(arguments[index]);
2550
+ if (!isFinite(codePoint) || codePoint < 0 || codePoint > 1114111 || floor(codePoint) !== codePoint) {
2551
+ throw RangeError("Invalid code point: " + codePoint);
2552
+ }
2553
+ if (codePoint <= 65535) {
2554
+ codeUnits.push(codePoint);
2555
+ } else {
2556
+ codePoint -= 65536;
2557
+ highSurrogate = (codePoint >> 10) + 55296;
2558
+ lowSurrogate = codePoint % 1024 + 56320;
2559
+ codeUnits.push(highSurrogate, lowSurrogate);
2560
+ }
2561
+ if (index + 1 === length || codeUnits.length > MAX_SIZE) {
2562
+ result += stringFromCharCode.apply(null, codeUnits);
2563
+ codeUnits.length = 0;
2564
+ }
2565
+ }
2566
+ return result;
2567
+ };
2568
+ if (Object.defineProperty) {
2569
+ Object.defineProperty(String, "fromCodePoint", {
2570
+ value: fromCodePoint,
2571
+ configurable: true,
2572
+ writable: true
2573
+ });
2574
+ } else {
2575
+ String.fromCodePoint = fromCodePoint;
2576
+ }
2577
+ })();
2578
+ }
2579
+ })(typeof exports === "undefined" ? exports.sax = {} : exports);
2580
+ }
2581
+ });
2582
+
2583
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-parser.js
2584
+ var require_sitemap_parser = __commonJS({
2585
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-parser.js"(exports) {
2586
+ "use strict";
2587
+ init_esm_shims();
2588
+ var __importDefault = exports && exports.__importDefault || function(mod) {
2589
+ return mod && mod.__esModule ? mod : { "default": mod };
2590
+ };
2591
+ Object.defineProperty(exports, "__esModule", { value: true });
2592
+ exports.ObjectStreamToJSON = exports.parseSitemap = exports.XMLToSitemapItemStream = void 0;
2593
+ var sax_1 = __importDefault(require_sax());
2594
+ var stream_1 = __require("stream");
2595
+ var types_1 = require_types();
2596
+ function isValidTagName(tagName) {
2597
+ return tagName in types_1.TagNames;
2598
+ }
2599
+ function tagTemplate() {
2600
+ return {
2601
+ img: [],
2602
+ video: [],
2603
+ links: [],
2604
+ url: ""
2605
+ };
2606
+ }
2607
+ function videoTemplate() {
2608
+ return {
2609
+ tag: [],
2610
+ thumbnail_loc: "",
2611
+ title: "",
2612
+ description: ""
2613
+ };
2614
+ }
2615
+ var imageTemplate = {
2616
+ url: ""
2617
+ };
2618
+ var linkTemplate = {
2619
+ lang: "",
2620
+ url: ""
2621
+ };
2622
+ function newsTemplate() {
2623
+ return {
2624
+ publication: { name: "", language: "" },
2625
+ publication_date: "",
2626
+ title: ""
2627
+ };
2628
+ }
2629
+ var defaultLogger = (level, ...message) => console[level](...message);
2630
+ var defaultStreamOpts = {
2631
+ logger: defaultLogger
2632
+ };
2633
+ var XMLToSitemapItemStream = class extends stream_1.Transform {
2634
+ constructor(opts = defaultStreamOpts) {
2635
+ var _a;
2636
+ opts.objectMode = true;
2637
+ super(opts);
2638
+ this.error = null;
2639
+ this.saxStream = sax_1.default.createStream(true, {
2640
+ xmlns: true,
2641
+ strictEntities: true,
2642
+ trim: true
2643
+ });
2644
+ this.level = opts.level || types_1.ErrorLevel.WARN;
2645
+ if (this.level !== types_1.ErrorLevel.SILENT && opts.logger !== false) {
2646
+ this.logger = (_a = opts.logger) !== null && _a !== void 0 ? _a : defaultLogger;
2647
+ } else {
2648
+ this.logger = () => void 0;
2649
+ }
2650
+ let currentItem = tagTemplate();
2651
+ let currentTag;
2652
+ let currentVideo = videoTemplate();
2653
+ let currentImage = __spreadValues({}, imageTemplate);
2654
+ let currentLink = __spreadValues({}, linkTemplate);
2655
+ let dontpushCurrentLink = false;
2656
+ this.saxStream.on("opentagstart", (tag) => {
2657
+ currentTag = tag.name;
2658
+ if (currentTag.startsWith("news:") && !currentItem.news) {
2659
+ currentItem.news = newsTemplate();
2660
+ }
2661
+ });
2662
+ this.saxStream.on("opentag", (tag) => {
2663
+ if (isValidTagName(tag.name)) {
2664
+ if (tag.name === "xhtml:link") {
2665
+ if (typeof tag.attributes.rel === "string" || typeof tag.attributes.href === "string") {
2666
+ return;
2667
+ }
2668
+ if (tag.attributes.rel.value === "alternate" && tag.attributes.hreflang) {
2669
+ currentLink.url = tag.attributes.href.value;
2670
+ if (typeof tag.attributes.hreflang === "string")
2671
+ return;
2672
+ currentLink.lang = tag.attributes.hreflang.value;
2673
+ } else if (tag.attributes.rel.value === "alternate") {
2674
+ dontpushCurrentLink = true;
2675
+ currentItem.androidLink = tag.attributes.href.value;
2676
+ } else if (tag.attributes.rel.value === "amphtml") {
2677
+ dontpushCurrentLink = true;
2678
+ currentItem.ampLink = tag.attributes.href.value;
2679
+ } else {
2680
+ this.logger("log", "unhandled attr for xhtml:link", tag.attributes);
2681
+ this.err(`unhandled attr for xhtml:link ${tag.attributes}`);
2682
+ }
2683
+ }
2684
+ } else {
2685
+ this.logger("warn", "unhandled tag", tag.name);
2686
+ this.err(`unhandled tag: ${tag.name}`);
2687
+ }
2688
+ });
2689
+ this.saxStream.on("text", (text) => {
2690
+ switch (currentTag) {
2691
+ case "mobile:mobile":
2692
+ break;
2693
+ case types_1.TagNames.loc:
2694
+ currentItem.url = text;
2695
+ break;
2696
+ case types_1.TagNames.changefreq:
2697
+ if ((0, types_1.isValidChangeFreq)(text)) {
2698
+ currentItem.changefreq = text;
2699
+ }
2700
+ break;
2701
+ case types_1.TagNames.priority:
2702
+ currentItem.priority = parseFloat(text);
2703
+ break;
2704
+ case types_1.TagNames.lastmod:
2705
+ currentItem.lastmod = text;
2706
+ break;
2707
+ case types_1.TagNames["video:thumbnail_loc"]:
2708
+ currentVideo.thumbnail_loc = text;
2709
+ break;
2710
+ case types_1.TagNames["video:tag"]:
2711
+ currentVideo.tag.push(text);
2712
+ break;
2713
+ case types_1.TagNames["video:duration"]:
2714
+ currentVideo.duration = parseInt(text, 10);
2715
+ break;
2716
+ case types_1.TagNames["video:player_loc"]:
2717
+ currentVideo.player_loc = text;
2718
+ break;
2719
+ case types_1.TagNames["video:content_loc"]:
2720
+ currentVideo.content_loc = text;
2721
+ break;
2722
+ case types_1.TagNames["video:requires_subscription"]:
2723
+ if ((0, types_1.isValidYesNo)(text)) {
2724
+ currentVideo.requires_subscription = text;
2725
+ }
2726
+ break;
2727
+ case types_1.TagNames["video:publication_date"]:
2728
+ currentVideo.publication_date = text;
2729
+ break;
2730
+ case types_1.TagNames["video:id"]:
2731
+ currentVideo.id = text;
2732
+ break;
2733
+ case types_1.TagNames["video:restriction"]:
2734
+ currentVideo.restriction = text;
2735
+ break;
2736
+ case types_1.TagNames["video:view_count"]:
2737
+ currentVideo.view_count = parseInt(text, 10);
2738
+ break;
2739
+ case types_1.TagNames["video:uploader"]:
2740
+ currentVideo.uploader = text;
2741
+ break;
2742
+ case types_1.TagNames["video:family_friendly"]:
2743
+ if ((0, types_1.isValidYesNo)(text)) {
2744
+ currentVideo.family_friendly = text;
2745
+ }
2746
+ break;
2747
+ case types_1.TagNames["video:expiration_date"]:
2748
+ currentVideo.expiration_date = text;
2749
+ break;
2750
+ case types_1.TagNames["video:platform"]:
2751
+ currentVideo.platform = text;
2752
+ break;
2753
+ case types_1.TagNames["video:price"]:
2754
+ currentVideo.price = text;
2755
+ break;
2756
+ case types_1.TagNames["video:rating"]:
2757
+ currentVideo.rating = parseFloat(text);
2758
+ break;
2759
+ case types_1.TagNames["video:category"]:
2760
+ currentVideo.category = text;
2761
+ break;
2762
+ case types_1.TagNames["video:live"]:
2763
+ if ((0, types_1.isValidYesNo)(text)) {
2764
+ currentVideo.live = text;
2765
+ }
2766
+ break;
2767
+ case types_1.TagNames["video:gallery_loc"]:
2768
+ currentVideo.gallery_loc = text;
2769
+ break;
2770
+ case types_1.TagNames["image:loc"]:
2771
+ currentImage.url = text;
2772
+ break;
2773
+ case types_1.TagNames["image:geo_location"]:
2774
+ currentImage.geoLocation = text;
2775
+ break;
2776
+ case types_1.TagNames["image:license"]:
2777
+ currentImage.license = text;
2778
+ break;
2779
+ case types_1.TagNames["news:access"]:
2780
+ if (!currentItem.news) {
2781
+ currentItem.news = newsTemplate();
2782
+ }
2783
+ currentItem.news.access = text;
2784
+ break;
2785
+ case types_1.TagNames["news:genres"]:
2786
+ if (!currentItem.news) {
2787
+ currentItem.news = newsTemplate();
2788
+ }
2789
+ currentItem.news.genres = text;
2790
+ break;
2791
+ case types_1.TagNames["news:publication_date"]:
2792
+ if (!currentItem.news) {
2793
+ currentItem.news = newsTemplate();
2794
+ }
2795
+ currentItem.news.publication_date = text;
2796
+ break;
2797
+ case types_1.TagNames["news:keywords"]:
2798
+ if (!currentItem.news) {
2799
+ currentItem.news = newsTemplate();
2800
+ }
2801
+ currentItem.news.keywords = text;
2802
+ break;
2803
+ case types_1.TagNames["news:stock_tickers"]:
2804
+ if (!currentItem.news) {
2805
+ currentItem.news = newsTemplate();
2806
+ }
2807
+ currentItem.news.stock_tickers = text;
2808
+ break;
2809
+ case types_1.TagNames["news:language"]:
2810
+ if (!currentItem.news) {
2811
+ currentItem.news = newsTemplate();
2812
+ }
2813
+ currentItem.news.publication.language = text;
2814
+ break;
2815
+ case types_1.TagNames["video:title"]:
2816
+ currentVideo.title += text;
2817
+ break;
2818
+ case types_1.TagNames["video:description"]:
2819
+ currentVideo.description += text;
2820
+ break;
2821
+ case types_1.TagNames["news:name"]:
2822
+ if (!currentItem.news) {
2823
+ currentItem.news = newsTemplate();
2824
+ }
2825
+ currentItem.news.publication.name += text;
2826
+ break;
2827
+ case types_1.TagNames["news:title"]:
2828
+ if (!currentItem.news) {
2829
+ currentItem.news = newsTemplate();
2830
+ }
2831
+ currentItem.news.title += text;
2832
+ break;
2833
+ case types_1.TagNames["image:caption"]:
2834
+ if (!currentImage.caption) {
2835
+ currentImage.caption = text;
2836
+ } else {
2837
+ currentImage.caption += text;
2838
+ }
2839
+ break;
2840
+ case types_1.TagNames["image:title"]:
2841
+ if (!currentImage.title) {
2842
+ currentImage.title = text;
2843
+ } else {
2844
+ currentImage.title += text;
2845
+ }
2846
+ break;
2847
+ default:
2848
+ this.logger("log", "unhandled text for tag:", currentTag, `'${text}'`);
2849
+ this.err(`unhandled text for tag: ${currentTag} '${text}'`);
2850
+ break;
2851
+ }
2852
+ });
2853
+ this.saxStream.on("cdata", (text) => {
2854
+ switch (currentTag) {
2855
+ case types_1.TagNames["video:title"]:
2856
+ currentVideo.title += text;
2857
+ break;
2858
+ case types_1.TagNames["video:description"]:
2859
+ currentVideo.description += text;
2860
+ break;
2861
+ case types_1.TagNames["news:name"]:
2862
+ if (!currentItem.news) {
2863
+ currentItem.news = newsTemplate();
2864
+ }
2865
+ currentItem.news.publication.name += text;
2866
+ break;
2867
+ case types_1.TagNames["news:title"]:
2868
+ if (!currentItem.news) {
2869
+ currentItem.news = newsTemplate();
2870
+ }
2871
+ currentItem.news.title += text;
2872
+ break;
2873
+ case types_1.TagNames["image:caption"]:
2874
+ if (!currentImage.caption) {
2875
+ currentImage.caption = text;
2876
+ } else {
2877
+ currentImage.caption += text;
2878
+ }
2879
+ break;
2880
+ case types_1.TagNames["image:title"]:
2881
+ if (!currentImage.title) {
2882
+ currentImage.title = text;
2883
+ } else {
2884
+ currentImage.title += text;
2885
+ }
2886
+ break;
2887
+ default:
2888
+ this.logger("log", "unhandled cdata for tag:", currentTag);
2889
+ this.err(`unhandled cdata for tag: ${currentTag}`);
2890
+ break;
2891
+ }
2892
+ });
2893
+ this.saxStream.on("attribute", (attr) => {
2894
+ switch (currentTag) {
2895
+ case types_1.TagNames["urlset"]:
2896
+ case types_1.TagNames["xhtml:link"]:
2897
+ case types_1.TagNames["video:id"]:
2898
+ break;
2899
+ case types_1.TagNames["video:restriction"]:
2900
+ if (attr.name === "relationship" && (0, types_1.isAllowDeny)(attr.value)) {
2901
+ currentVideo["restriction:relationship"] = attr.value;
2902
+ } else {
2903
+ this.logger("log", "unhandled attr", currentTag, attr.name);
2904
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2905
+ }
2906
+ break;
2907
+ case types_1.TagNames["video:price"]:
2908
+ if (attr.name === "type" && (0, types_1.isPriceType)(attr.value)) {
2909
+ currentVideo["price:type"] = attr.value;
2910
+ } else if (attr.name === "currency") {
2911
+ currentVideo["price:currency"] = attr.value;
2912
+ } else if (attr.name === "resolution" && (0, types_1.isResolution)(attr.value)) {
2913
+ currentVideo["price:resolution"] = attr.value;
2914
+ } else {
2915
+ this.logger("log", "unhandled attr for video:price", attr.name);
2916
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2917
+ }
2918
+ break;
2919
+ case types_1.TagNames["video:player_loc"]:
2920
+ if (attr.name === "autoplay") {
2921
+ currentVideo["player_loc:autoplay"] = attr.value;
2922
+ } else if (attr.name === "allow_embed" && (0, types_1.isValidYesNo)(attr.value)) {
2923
+ currentVideo["player_loc:allow_embed"] = attr.value;
2924
+ } else {
2925
+ this.logger("log", "unhandled attr for video:player_loc", attr.name);
2926
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2927
+ }
2928
+ break;
2929
+ case types_1.TagNames["video:platform"]:
2930
+ if (attr.name === "relationship" && (0, types_1.isAllowDeny)(attr.value)) {
2931
+ currentVideo["platform:relationship"] = attr.value;
2932
+ } else {
2933
+ this.logger("log", "unhandled attr for video:platform", attr.name, attr.value);
2934
+ this.err(`unhandled attr: ${currentTag} ${attr.name} ${attr.value}`);
2935
+ }
2936
+ break;
2937
+ case types_1.TagNames["video:gallery_loc"]:
2938
+ if (attr.name === "title") {
2939
+ currentVideo["gallery_loc:title"] = attr.value;
2940
+ } else {
2941
+ this.logger("log", "unhandled attr for video:galler_loc", attr.name);
2942
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2943
+ }
2944
+ break;
2945
+ case types_1.TagNames["video:uploader"]:
2946
+ if (attr.name === "info") {
2947
+ currentVideo["uploader:info"] = attr.value;
2948
+ } else {
2949
+ this.logger("log", "unhandled attr for video:uploader", attr.name);
2950
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2951
+ }
2952
+ break;
2953
+ default:
2954
+ this.logger("log", "unhandled attr", currentTag, attr.name);
2955
+ this.err(`unhandled attr: ${currentTag} ${attr.name}`);
2956
+ }
2957
+ });
2958
+ this.saxStream.on("closetag", (tag) => {
2959
+ switch (tag) {
2960
+ case types_1.TagNames.url:
2961
+ this.push(currentItem);
2962
+ currentItem = tagTemplate();
2963
+ break;
2964
+ case types_1.TagNames["video:video"]:
2965
+ currentItem.video.push(currentVideo);
2966
+ currentVideo = videoTemplate();
2967
+ break;
2968
+ case types_1.TagNames["image:image"]:
2969
+ currentItem.img.push(currentImage);
2970
+ currentImage = __spreadValues({}, imageTemplate);
2971
+ break;
2972
+ case types_1.TagNames["xhtml:link"]:
2973
+ if (!dontpushCurrentLink) {
2974
+ currentItem.links.push(currentLink);
2975
+ }
2976
+ currentLink = __spreadValues({}, linkTemplate);
2977
+ break;
2978
+ default:
2979
+ break;
2980
+ }
2981
+ });
2982
+ }
2983
+ _transform(data, encoding, callback) {
2984
+ try {
2985
+ this.saxStream.write(data, encoding);
2986
+ callback(this.level === types_1.ErrorLevel.THROW ? this.error : null);
2987
+ } catch (error) {
2988
+ callback(error);
2989
+ }
2990
+ }
2991
+ err(msg) {
2992
+ if (!this.error)
2993
+ this.error = new Error(msg);
2994
+ }
2995
+ };
2996
+ exports.XMLToSitemapItemStream = XMLToSitemapItemStream;
2997
+ async function parseSitemap(xml) {
2998
+ const urls = [];
2999
+ return new Promise((resolve2, reject) => {
3000
+ xml.pipe(new XMLToSitemapItemStream()).on("data", (smi) => urls.push(smi)).on("end", () => {
3001
+ resolve2(urls);
3002
+ }).on("error", (error) => {
3003
+ reject(error);
3004
+ });
3005
+ });
3006
+ }
3007
+ exports.parseSitemap = parseSitemap;
3008
+ var defaultObjectStreamOpts = {
3009
+ lineSeparated: false
3010
+ };
3011
+ var ObjectStreamToJSON = class extends stream_1.Transform {
3012
+ constructor(opts = defaultObjectStreamOpts) {
3013
+ opts.writableObjectMode = true;
3014
+ super(opts);
3015
+ this.lineSeparated = opts.lineSeparated;
3016
+ this.firstWritten = false;
3017
+ }
3018
+ _transform(chunk, encoding, cb) {
3019
+ if (!this.firstWritten) {
3020
+ this.firstWritten = true;
3021
+ if (!this.lineSeparated) {
3022
+ this.push("[");
3023
+ }
3024
+ } else if (this.lineSeparated) {
3025
+ this.push("\n");
3026
+ } else {
3027
+ this.push(",");
3028
+ }
3029
+ if (chunk) {
3030
+ this.push(JSON.stringify(chunk));
3031
+ }
3032
+ cb();
3033
+ }
3034
+ _flush(cb) {
3035
+ if (!this.lineSeparated) {
3036
+ this.push("]");
3037
+ }
3038
+ cb();
3039
+ }
3040
+ };
3041
+ exports.ObjectStreamToJSON = ObjectStreamToJSON;
3042
+ }
3043
+ });
3044
+
3045
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-parser.js
3046
+ var require_sitemap_index_parser = __commonJS({
3047
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-parser.js"(exports) {
3048
+ "use strict";
3049
+ init_esm_shims();
3050
+ var __importDefault = exports && exports.__importDefault || function(mod) {
3051
+ return mod && mod.__esModule ? mod : { "default": mod };
3052
+ };
3053
+ Object.defineProperty(exports, "__esModule", { value: true });
3054
+ exports.IndexObjectStreamToJSON = exports.parseSitemapIndex = exports.XMLToSitemapIndexStream = void 0;
3055
+ var sax_1 = __importDefault(require_sax());
3056
+ var stream_1 = __require("stream");
3057
+ var types_1 = require_types();
3058
+ function isValidTagName(tagName) {
3059
+ return tagName in types_1.IndexTagNames;
3060
+ }
3061
+ function tagTemplate() {
3062
+ return {
3063
+ url: ""
3064
+ };
3065
+ }
3066
+ var defaultLogger = (level, ...message) => console[level](...message);
3067
+ var defaultStreamOpts = {
3068
+ logger: defaultLogger
3069
+ };
3070
+ var XMLToSitemapIndexStream = class extends stream_1.Transform {
3071
+ constructor(opts = defaultStreamOpts) {
3072
+ var _a;
3073
+ opts.objectMode = true;
3074
+ super(opts);
3075
+ this.saxStream = sax_1.default.createStream(true, {
3076
+ xmlns: true,
3077
+ strictEntities: true,
3078
+ trim: true
3079
+ });
3080
+ this.level = opts.level || types_1.ErrorLevel.WARN;
3081
+ if (this.level !== types_1.ErrorLevel.SILENT && opts.logger !== false) {
3082
+ this.logger = (_a = opts.logger) !== null && _a !== void 0 ? _a : defaultLogger;
3083
+ } else {
3084
+ this.logger = () => void 0;
3085
+ }
3086
+ let currentItem = tagTemplate();
3087
+ let currentTag;
3088
+ this.saxStream.on("opentagstart", (tag) => {
3089
+ currentTag = tag.name;
3090
+ });
3091
+ this.saxStream.on("opentag", (tag) => {
3092
+ if (!isValidTagName(tag.name)) {
3093
+ this.logger("warn", "unhandled tag", tag.name);
3094
+ }
3095
+ });
3096
+ this.saxStream.on("text", (text) => {
3097
+ switch (currentTag) {
3098
+ case types_1.IndexTagNames.loc:
3099
+ currentItem.url = text;
3100
+ break;
3101
+ case types_1.IndexTagNames.lastmod:
3102
+ currentItem.lastmod = text;
3103
+ break;
3104
+ default:
3105
+ this.logger("log", "unhandled text for tag:", currentTag, `'${text}'`);
3106
+ break;
3107
+ }
3108
+ });
3109
+ this.saxStream.on("cdata", (_text) => {
3110
+ switch (currentTag) {
3111
+ default:
3112
+ this.logger("log", "unhandled cdata for tag:", currentTag);
3113
+ break;
3114
+ }
3115
+ });
3116
+ this.saxStream.on("attribute", (attr) => {
3117
+ switch (currentTag) {
3118
+ case types_1.IndexTagNames.sitemapindex:
3119
+ break;
3120
+ default:
3121
+ this.logger("log", "unhandled attr", currentTag, attr.name);
3122
+ }
3123
+ });
3124
+ this.saxStream.on("closetag", (tag) => {
3125
+ switch (tag) {
3126
+ case types_1.IndexTagNames.sitemap:
3127
+ this.push(currentItem);
3128
+ currentItem = tagTemplate();
3129
+ break;
3130
+ default:
3131
+ break;
3132
+ }
3133
+ });
3134
+ }
3135
+ _transform(data, encoding, callback) {
3136
+ try {
3137
+ this.saxStream.write(data, encoding);
3138
+ callback();
3139
+ } catch (error) {
3140
+ callback(error);
3141
+ }
3142
+ }
3143
+ };
3144
+ exports.XMLToSitemapIndexStream = XMLToSitemapIndexStream;
3145
+ async function parseSitemapIndex(xml) {
3146
+ const urls = [];
3147
+ return new Promise((resolve2, reject) => {
3148
+ xml.pipe(new XMLToSitemapIndexStream()).on("data", (smi) => urls.push(smi)).on("end", () => {
3149
+ resolve2(urls);
3150
+ }).on("error", (error) => {
3151
+ reject(error);
3152
+ });
3153
+ });
3154
+ }
3155
+ exports.parseSitemapIndex = parseSitemapIndex;
3156
+ var defaultObjectStreamOpts = {
3157
+ lineSeparated: false
3158
+ };
3159
+ var IndexObjectStreamToJSON = class extends stream_1.Transform {
3160
+ constructor(opts = defaultObjectStreamOpts) {
3161
+ opts.writableObjectMode = true;
3162
+ super(opts);
3163
+ this.lineSeparated = opts.lineSeparated;
3164
+ this.firstWritten = false;
3165
+ }
3166
+ _transform(chunk, encoding, cb) {
3167
+ if (!this.firstWritten) {
3168
+ this.firstWritten = true;
3169
+ if (!this.lineSeparated) {
3170
+ this.push("[");
3171
+ }
3172
+ } else if (this.lineSeparated) {
3173
+ this.push("\n");
3174
+ } else {
3175
+ this.push(",");
3176
+ }
3177
+ if (chunk) {
3178
+ this.push(JSON.stringify(chunk));
3179
+ }
3180
+ cb();
3181
+ }
3182
+ _flush(cb) {
3183
+ if (!this.lineSeparated) {
3184
+ this.push("]");
3185
+ }
3186
+ cb();
3187
+ }
3188
+ };
3189
+ exports.IndexObjectStreamToJSON = IndexObjectStreamToJSON;
3190
+ }
3191
+ });
3192
+
3193
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-simple.js
3194
+ var require_sitemap_simple = __commonJS({
3195
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-simple.js"(exports) {
3196
+ "use strict";
3197
+ init_esm_shims();
3198
+ Object.defineProperty(exports, "__esModule", { value: true });
3199
+ exports.simpleSitemapAndIndex = void 0;
3200
+ var index_1 = require_dist();
3201
+ var zlib_1 = __require("zlib");
3202
+ var fs_1 = __require("fs");
3203
+ var path_1 = __require("path");
3204
+ var stream_1 = __require("stream");
3205
+ var util_1 = __require("util");
3206
+ var url_1 = __require("url");
3207
+ var pipeline = (0, util_1.promisify)(stream_1.pipeline);
3208
+ var simpleSitemapAndIndex = async ({
3209
+ hostname,
3210
+ sitemapHostname = hostname,
3211
+ sourceData,
3212
+ destinationDir,
3213
+ limit = 5e4,
3214
+ gzip = true,
3215
+ publicBasePath = "./"
3216
+ }) => {
3217
+ await fs_1.promises.mkdir(destinationDir, { recursive: true });
3218
+ const sitemapAndIndexStream = new index_1.SitemapAndIndexStream({
3219
+ limit,
3220
+ getSitemapStream: (i) => {
3221
+ const sitemapStream = new index_1.SitemapStream({
3222
+ hostname
3223
+ });
3224
+ const path2 = `./sitemap-${i}.xml`;
3225
+ const writePath2 = (0, path_1.resolve)(destinationDir, path2 + (gzip ? ".gz" : ""));
3226
+ if (!publicBasePath.endsWith("/")) {
3227
+ publicBasePath += "/";
3228
+ }
3229
+ const publicPath = (0, path_1.normalize)(publicBasePath + path2);
3230
+ let pipeline2;
3231
+ if (gzip) {
3232
+ pipeline2 = sitemapStream.pipe((0, zlib_1.createGzip)()).pipe((0, fs_1.createWriteStream)(writePath2));
3233
+ } else {
3234
+ pipeline2 = sitemapStream.pipe((0, fs_1.createWriteStream)(writePath2));
3235
+ }
3236
+ return [
3237
+ new url_1.URL(`${publicPath}${gzip ? ".gz" : ""}`, sitemapHostname).toString(),
3238
+ sitemapStream,
3239
+ pipeline2
3240
+ ];
3241
+ }
3242
+ });
3243
+ let src;
3244
+ if (typeof sourceData === "string") {
3245
+ src = (0, index_1.lineSeparatedURLsToSitemapOptions)((0, fs_1.createReadStream)(sourceData));
3246
+ } else if (sourceData instanceof stream_1.Readable) {
3247
+ src = sourceData;
3248
+ } else if (Array.isArray(sourceData)) {
3249
+ src = stream_1.Readable.from(sourceData);
3250
+ } else {
3251
+ throw new Error("unhandled source type. You've passed in data that is not supported");
3252
+ }
3253
+ const writePath = (0, path_1.resolve)(destinationDir, `./sitemap-index.xml${gzip ? ".gz" : ""}`);
3254
+ if (gzip) {
3255
+ return pipeline(src, sitemapAndIndexStream, (0, zlib_1.createGzip)(), (0, fs_1.createWriteStream)(writePath));
3256
+ } else {
3257
+ return pipeline(src, sitemapAndIndexStream, (0, fs_1.createWriteStream)(writePath));
3258
+ }
3259
+ };
3260
+ exports.simpleSitemapAndIndex = simpleSitemapAndIndex;
3261
+ exports.default = exports.simpleSitemapAndIndex;
3262
+ }
3263
+ });
3264
+
3265
+ // node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/index.js
3266
+ var require_dist = __commonJS({
3267
+ "node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/index.js"(exports) {
3268
+ "use strict";
3269
+ init_esm_shims();
3270
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
3271
+ if (k2 === void 0)
3272
+ k2 = k;
3273
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
3274
+ return m[k];
3275
+ } });
3276
+ } : function(o, m, k, k2) {
3277
+ if (k2 === void 0)
3278
+ k2 = k;
3279
+ o[k2] = m[k];
3280
+ });
3281
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
3282
+ for (var p in m)
3283
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
3284
+ __createBinding(exports2, m, p);
3285
+ };
3286
+ Object.defineProperty(exports, "__esModule", { value: true });
3287
+ exports.simpleSitemapAndIndex = exports.IndexObjectStreamToJSON = exports.XMLToSitemapIndexStream = exports.parseSitemapIndex = exports.ObjectStreamToJSON = exports.XMLToSitemapItemStream = exports.parseSitemap = exports.xmlLint = exports.ReadlineStream = exports.normalizeURL = exports.validateSMIOptions = exports.mergeStreams = exports.lineSeparatedURLsToSitemapOptions = exports.SitemapStream = exports.streamToPromise = exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = exports.SitemapItemStream = void 0;
3288
+ var sitemap_item_stream_1 = require_sitemap_item_stream();
3289
+ Object.defineProperty(exports, "SitemapItemStream", { enumerable: true, get: function() {
3290
+ return sitemap_item_stream_1.SitemapItemStream;
3291
+ } });
3292
+ var sitemap_index_stream_1 = require_sitemap_index_stream();
3293
+ Object.defineProperty(exports, "IndexTagNames", { enumerable: true, get: function() {
3294
+ return sitemap_index_stream_1.IndexTagNames;
3295
+ } });
3296
+ Object.defineProperty(exports, "SitemapIndexStream", { enumerable: true, get: function() {
3297
+ return sitemap_index_stream_1.SitemapIndexStream;
3298
+ } });
3299
+ Object.defineProperty(exports, "SitemapAndIndexStream", { enumerable: true, get: function() {
3300
+ return sitemap_index_stream_1.SitemapAndIndexStream;
3301
+ } });
3302
+ var sitemap_stream_1 = require_sitemap_stream();
3303
+ Object.defineProperty(exports, "streamToPromise", { enumerable: true, get: function() {
3304
+ return sitemap_stream_1.streamToPromise;
3305
+ } });
3306
+ Object.defineProperty(exports, "SitemapStream", { enumerable: true, get: function() {
3307
+ return sitemap_stream_1.SitemapStream;
3308
+ } });
3309
+ __exportStar(require_errors(), exports);
3310
+ __exportStar(require_types(), exports);
3311
+ var utils_1 = require_utils();
3312
+ Object.defineProperty(exports, "lineSeparatedURLsToSitemapOptions", { enumerable: true, get: function() {
3313
+ return utils_1.lineSeparatedURLsToSitemapOptions;
3314
+ } });
3315
+ Object.defineProperty(exports, "mergeStreams", { enumerable: true, get: function() {
3316
+ return utils_1.mergeStreams;
3317
+ } });
3318
+ Object.defineProperty(exports, "validateSMIOptions", { enumerable: true, get: function() {
3319
+ return utils_1.validateSMIOptions;
3320
+ } });
3321
+ Object.defineProperty(exports, "normalizeURL", { enumerable: true, get: function() {
3322
+ return utils_1.normalizeURL;
3323
+ } });
3324
+ Object.defineProperty(exports, "ReadlineStream", { enumerable: true, get: function() {
3325
+ return utils_1.ReadlineStream;
3326
+ } });
3327
+ var xmllint_1 = require_xmllint();
3328
+ Object.defineProperty(exports, "xmlLint", { enumerable: true, get: function() {
3329
+ return xmllint_1.xmlLint;
3330
+ } });
3331
+ var sitemap_parser_1 = require_sitemap_parser();
3332
+ Object.defineProperty(exports, "parseSitemap", { enumerable: true, get: function() {
3333
+ return sitemap_parser_1.parseSitemap;
3334
+ } });
3335
+ Object.defineProperty(exports, "XMLToSitemapItemStream", { enumerable: true, get: function() {
3336
+ return sitemap_parser_1.XMLToSitemapItemStream;
3337
+ } });
3338
+ Object.defineProperty(exports, "ObjectStreamToJSON", { enumerable: true, get: function() {
3339
+ return sitemap_parser_1.ObjectStreamToJSON;
3340
+ } });
3341
+ var sitemap_index_parser_1 = require_sitemap_index_parser();
3342
+ Object.defineProperty(exports, "parseSitemapIndex", { enumerable: true, get: function() {
3343
+ return sitemap_index_parser_1.parseSitemapIndex;
3344
+ } });
3345
+ Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function() {
3346
+ return sitemap_index_parser_1.XMLToSitemapIndexStream;
3347
+ } });
3348
+ Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function() {
3349
+ return sitemap_index_parser_1.IndexObjectStreamToJSON;
3350
+ } });
3351
+ var sitemap_simple_1 = require_sitemap_simple();
3352
+ Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function() {
3353
+ return sitemap_simple_1.simpleSitemapAndIndex;
3354
+ } });
3355
+ }
3356
+ });
3357
+
3358
+ // node_modules/.pnpm/xml-parser-xo@3.2.0/node_modules/xml-parser-xo/index.js
3359
+ var require_xml_parser_xo = __commonJS({
3360
+ "node_modules/.pnpm/xml-parser-xo@3.2.0/node_modules/xml-parser-xo/index.js"(exports, module) {
3361
+ init_esm_shims();
3362
+ function parse2(xml, options = {}) {
3363
+ options.filter = options.filter || (() => true);
3364
+ function nextChild() {
3365
+ return tag() || content() || comment() || cdata();
3366
+ }
3367
+ function nextRootChild() {
3368
+ match(/\s*/);
3369
+ return tag(true) || comment() || doctype() || processingInstruction(false);
3370
+ }
3371
+ function document() {
3372
+ const decl = declaration();
3373
+ const children = [];
3374
+ let documentRootNode;
3375
+ let child = nextRootChild();
3376
+ while (child) {
3377
+ if (child.node.type === "Element") {
3378
+ if (documentRootNode) {
3379
+ throw new Error("Found multiple root nodes");
3380
+ }
3381
+ documentRootNode = child.node;
3382
+ }
3383
+ if (!child.excluded) {
3384
+ children.push(child.node);
3385
+ }
3386
+ child = nextRootChild();
3387
+ }
3388
+ if (!documentRootNode) {
3389
+ throw new Error("Failed to parse XML");
3390
+ }
3391
+ return {
3392
+ declaration: decl ? decl.node : null,
3393
+ root: documentRootNode,
3394
+ children
3395
+ };
3396
+ }
3397
+ function declaration() {
3398
+ return processingInstruction(true);
3399
+ }
3400
+ function processingInstruction(matchDeclaration) {
3401
+ const m = matchDeclaration ? match(/^<\?(xml)\s*/) : match(/^<\?([\w-:.]+)\s*/);
3402
+ if (!m)
3403
+ return;
3404
+ const node = {
3405
+ name: m[1],
3406
+ type: "ProcessingInstruction",
3407
+ attributes: {}
3408
+ };
3409
+ while (!(eos() || is("?>"))) {
3410
+ const attr = attribute();
3411
+ if (!attr)
3412
+ return node;
3413
+ node.attributes[attr.name] = attr.value;
3414
+ }
3415
+ match(/\?>/);
3416
+ return {
3417
+ excluded: matchDeclaration ? false : options.filter(node) === false,
3418
+ node
3419
+ };
3420
+ }
3421
+ function tag(matchRoot) {
3422
+ const m = match(/^<([\w-:.]+)\s*/);
3423
+ if (!m)
3424
+ return;
3425
+ const node = {
3426
+ type: "Element",
3427
+ name: m[1],
3428
+ attributes: {},
3429
+ children: []
3430
+ };
3431
+ while (!(eos() || is(">") || is("?>") || is("/>"))) {
3432
+ const attr = attribute();
3433
+ if (!attr)
3434
+ return node;
3435
+ node.attributes[attr.name] = attr.value;
3436
+ }
3437
+ const excluded = matchRoot ? false : options.filter(node) === false;
3438
+ if (match(/^\s*\/>/)) {
3439
+ node.children = null;
3440
+ return {
3441
+ excluded,
3442
+ node
3443
+ };
3444
+ }
3445
+ match(/\??>/);
3446
+ if (!excluded) {
3447
+ let child = nextChild();
3448
+ while (child) {
3449
+ if (!child.excluded) {
3450
+ node.children.push(child.node);
3451
+ }
3452
+ child = nextChild();
3453
+ }
3454
+ }
3455
+ match(/^<\/[\w-:.]+>/);
3456
+ return {
3457
+ excluded,
3458
+ node
3459
+ };
3460
+ }
3461
+ function doctype() {
3462
+ const m = match(/^<!DOCTYPE\s+[^>]*>/);
3463
+ if (m) {
3464
+ const node = {
3465
+ type: "DocumentType",
3466
+ content: m[0]
3467
+ };
3468
+ return {
3469
+ excluded: options.filter(node) === false,
3470
+ node
3471
+ };
3472
+ }
3473
+ }
3474
+ function cdata() {
3475
+ if (xml.startsWith("<![CDATA[")) {
3476
+ const endPositionStart = xml.indexOf("]]>");
3477
+ if (endPositionStart > -1) {
3478
+ const endPositionFinish = endPositionStart + 3;
3479
+ const node = {
3480
+ type: "CDATA",
3481
+ content: xml.substring(0, endPositionFinish)
3482
+ };
3483
+ xml = xml.slice(endPositionFinish);
3484
+ return {
3485
+ excluded: options.filter(node) === false,
3486
+ node
3487
+ };
3488
+ }
3489
+ }
3490
+ }
3491
+ function comment() {
3492
+ const m = match(/^<!--[\s\S]*?-->/);
3493
+ if (m) {
3494
+ const node = {
3495
+ type: "Comment",
3496
+ content: m[0]
3497
+ };
3498
+ return {
3499
+ excluded: options.filter(node) === false,
3500
+ node
3501
+ };
3502
+ }
3503
+ }
3504
+ function content() {
3505
+ const m = match(/^([^<]+)/);
3506
+ if (m) {
3507
+ const node = {
3508
+ type: "Text",
3509
+ content: m[1]
3510
+ };
3511
+ return {
3512
+ excluded: options.filter(node) === false,
3513
+ node
3514
+ };
3515
+ }
3516
+ }
3517
+ function attribute() {
3518
+ const m = match(/([\w-:.]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
3519
+ if (!m)
3520
+ return;
3521
+ return { name: m[1], value: strip(m[2]) };
3522
+ }
3523
+ function strip(val) {
3524
+ return val.replace(/^['"]|['"]$/g, "");
3525
+ }
3526
+ function match(re) {
3527
+ const m = xml.match(re);
3528
+ if (!m)
3529
+ return;
3530
+ xml = xml.slice(m[0].length);
3531
+ return m;
3532
+ }
3533
+ function eos() {
3534
+ return xml.length === 0;
3535
+ }
3536
+ function is(prefix) {
3537
+ return xml.indexOf(prefix) === 0;
3538
+ }
3539
+ xml = xml.trim();
3540
+ return document();
3541
+ }
3542
+ module.exports = parse2;
3543
+ }
3544
+ });
3545
+
3546
+ // node_modules/.pnpm/xml-formatter@2.6.1/node_modules/xml-formatter/index.js
3547
+ var require_xml_formatter = __commonJS({
3548
+ "node_modules/.pnpm/xml-formatter@2.6.1/node_modules/xml-formatter/index.js"(exports, module) {
3549
+ init_esm_shims();
3550
+ function newLine(state) {
3551
+ if (!state.options.indentation && !state.options.lineSeparator)
3552
+ return;
3553
+ state.content += state.options.lineSeparator;
3554
+ let i;
3555
+ for (i = 0; i < state.level; i++) {
3556
+ state.content += state.options.indentation;
3557
+ }
3558
+ }
3559
+ function appendContent(state, content) {
3560
+ state.content += content;
3561
+ }
3562
+ function processNode(node, state, preserveSpace) {
3563
+ if (typeof node.content === "string") {
3564
+ processContentNode(node, state, preserveSpace);
3565
+ } else if (node.type === "Element") {
3566
+ processElementNode(node, state, preserveSpace);
3567
+ } else if (node.type === "ProcessingInstruction") {
3568
+ processProcessingIntruction(node, state, preserveSpace);
3569
+ } else {
3570
+ throw new Error("Unknown node type: " + node.type);
3571
+ }
3572
+ }
3573
+ function processContentNode(node, state, preserveSpace) {
3574
+ if (!preserveSpace) {
3575
+ node.content = node.content.trim();
3576
+ }
3577
+ if (node.content.length > 0) {
3578
+ if (!preserveSpace && state.content.length > 0) {
3579
+ newLine(state);
3580
+ }
3581
+ appendContent(state, node.content);
3582
+ }
3583
+ }
3584
+ function processElementNode(node, state, preserveSpace) {
3585
+ if (!preserveSpace && state.content.length > 0) {
3586
+ newLine(state);
3587
+ }
3588
+ appendContent(state, "<" + node.name);
3589
+ processAttributes(state, node.attributes);
3590
+ if (node.children === null) {
3591
+ const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? " />" : "/>";
3592
+ appendContent(state, selfClosingNodeClosingTag);
3593
+ } else if (node.children.length === 0) {
3594
+ appendContent(state, "></" + node.name + ">");
3595
+ } else {
3596
+ appendContent(state, ">");
3597
+ state.level++;
3598
+ let nodePreserveSpace = node.attributes["xml:space"] === "preserve";
3599
+ if (!nodePreserveSpace && state.options.collapseContent) {
3600
+ let containsTextNodes = false;
3601
+ let containsTextNodesWithLineBreaks = false;
3602
+ let containsNonTextNodes = false;
3603
+ node.children.forEach(function(child, index) {
3604
+ if (child.type === "Text") {
3605
+ if (child.content.includes("\n")) {
3606
+ containsTextNodesWithLineBreaks = true;
3607
+ child.content = child.content.trim();
3608
+ } else if (index === 0 || index === node.children.length - 1) {
3609
+ if (child.content.trim().length === 0) {
3610
+ child.content = "";
3611
+ }
3612
+ }
3613
+ if (child.content.length > 0) {
3614
+ containsTextNodes = true;
3615
+ }
3616
+ } else if (child.type === "CDATA") {
3617
+ containsTextNodes = true;
3618
+ } else {
3619
+ containsNonTextNodes = true;
3620
+ }
3621
+ });
3622
+ if (containsTextNodes && (!containsNonTextNodes || !containsTextNodesWithLineBreaks)) {
3623
+ nodePreserveSpace = true;
3624
+ }
3625
+ }
3626
+ node.children.forEach(function(child) {
3627
+ processNode(child, state, preserveSpace || nodePreserveSpace, state.options);
3628
+ });
3629
+ state.level--;
3630
+ if (!preserveSpace && !nodePreserveSpace) {
3631
+ newLine(state);
3632
+ }
3633
+ appendContent(state, "</" + node.name + ">");
3634
+ }
3635
+ }
3636
+ function processAttributes(state, attributes) {
3637
+ Object.keys(attributes).forEach(function(attr) {
3638
+ const escaped = attributes[attr].replace(/"/g, "&quot;");
3639
+ appendContent(state, " " + attr + '="' + escaped + '"');
3640
+ });
3641
+ }
3642
+ function processProcessingIntruction(node, state) {
3643
+ if (state.content.length > 0) {
3644
+ newLine(state);
3645
+ }
3646
+ appendContent(state, "<?" + node.name);
3647
+ processAttributes(state, node.attributes);
3648
+ appendContent(state, "?>");
3649
+ }
3650
+ function format2(xml, options = {}) {
3651
+ options.indentation = "indentation" in options ? options.indentation : " ";
3652
+ options.collapseContent = options.collapseContent === true;
3653
+ options.lineSeparator = "lineSeparator" in options ? options.lineSeparator : "\r\n";
3654
+ options.whiteSpaceAtEndOfSelfclosingTag = !!options.whiteSpaceAtEndOfSelfclosingTag;
3655
+ const parser = require_xml_parser_xo();
3656
+ const parsedXml = parser(xml, { filter: options.filter });
3657
+ const state = { content: "", level: 0, options };
3658
+ if (parsedXml.declaration) {
3659
+ processProcessingIntruction(parsedXml.declaration, state);
3660
+ }
3661
+ parsedXml.children.forEach(function(child) {
3662
+ processNode(child, state, false);
3663
+ });
3664
+ return state.content.replace(/\r\n/g, "\n").replace(/\n/g, options.lineSeparator);
3665
+ }
3666
+ module.exports = format2;
3667
+ }
3668
+ });
3669
+
3670
+ // src/index.ts
3671
+ init_esm_shims();
3672
+ var import_sitemap = __toESM(require_dist());
3673
+ var import_xml_formatter = __toESM(require_xml_formatter());
3674
+ import { writeFileSync } from "fs";
3675
+
3676
+ // src/options.ts
3677
+ init_esm_shims();
3678
+ function resolveOptions(userOptions) {
3679
+ return Object.assign({
3680
+ hostname: "http://localhost/",
3681
+ dynamicRoutes: [],
3682
+ outDir: "dist",
3683
+ changefreq: "daily",
3684
+ priority: 1,
3685
+ lastmod: new Date(),
3686
+ readable: false,
3687
+ robots: [{
3688
+ userAgent: "*",
3689
+ allow: "/"
3690
+ }]
3691
+ }, userOptions);
3692
+ }
3693
+
3694
+ // src/robots.ts
3695
+ init_esm_shims();
3696
+
3697
+ // node_modules/.pnpm/@antfu+utils@0.5.1/node_modules/@antfu/utils/dist/index.mjs
3698
+ init_esm_shims();
3699
+ function slash(str) {
3700
+ return str.replace(/\\/g, "/");
3701
+ }
3702
+ function ensurePrefix(prefix, str) {
3703
+ if (!str.startsWith(prefix))
3704
+ return prefix + str;
3705
+ return str;
3706
+ }
3707
+ function ensureSuffix(suffix, str) {
3708
+ if (!str.endsWith(suffix))
3709
+ return str + suffix;
3710
+ return str;
3711
+ }
3712
+ var Node = class {
3713
+ value;
3714
+ next;
3715
+ constructor(value) {
3716
+ this.value = value;
3717
+ }
3718
+ };
3719
+ var _head, _tail, _size;
3720
+ var Queue = class {
3721
+ constructor() {
3722
+ __privateAdd(this, _head, void 0);
3723
+ __privateAdd(this, _tail, void 0);
3724
+ __privateAdd(this, _size, void 0);
3725
+ this.clear();
3726
+ }
3727
+ enqueue(value) {
3728
+ const node = new Node(value);
3729
+ if (__privateGet(this, _head)) {
3730
+ __privateGet(this, _tail).next = node;
3731
+ __privateSet(this, _tail, node);
3732
+ } else {
3733
+ __privateSet(this, _head, node);
3734
+ __privateSet(this, _tail, node);
3735
+ }
3736
+ __privateWrapper(this, _size)._++;
3737
+ }
3738
+ dequeue() {
3739
+ const current = __privateGet(this, _head);
3740
+ if (!current) {
3741
+ return;
3742
+ }
3743
+ __privateSet(this, _head, __privateGet(this, _head).next);
3744
+ __privateWrapper(this, _size)._--;
3745
+ return current.value;
3746
+ }
3747
+ clear() {
3748
+ __privateSet(this, _head, void 0);
3749
+ __privateSet(this, _tail, void 0);
3750
+ __privateSet(this, _size, 0);
3751
+ }
3752
+ get size() {
3753
+ return __privateGet(this, _size);
3754
+ }
3755
+ *[Symbol.iterator]() {
3756
+ let current = __privateGet(this, _head);
3757
+ while (current) {
3758
+ yield current.value;
3759
+ current = current.next;
3760
+ }
3761
+ }
3762
+ };
3763
+ _head = new WeakMap();
3764
+ _tail = new WeakMap();
3765
+ _size = new WeakMap();
3766
+ var VOID = Symbol("p-void");
3767
+
3768
+ // src/robots.ts
3769
+ var RobotCorrespondences = /* @__PURE__ */ ((RobotCorrespondences2) => {
3770
+ RobotCorrespondences2["userAgent"] = "User-agent";
3771
+ RobotCorrespondences2["allow"] = "Allow";
3772
+ RobotCorrespondences2["disallow"] = "Disallow";
3773
+ RobotCorrespondences2["crawlDelay"] = "Crawl-delay";
3774
+ RobotCorrespondences2["cleanParam"] = "Clean-param";
3775
+ return RobotCorrespondences2;
3776
+ })(RobotCorrespondences || {});
3777
+ function getRules(options) {
3778
+ const rules = [];
3779
+ options.forEach((rule) => {
3780
+ const keys = Object.keys(RobotCorrespondences).filter((key) => typeof rule[key] !== "undefined");
3781
+ keys.forEach((key) => {
3782
+ const values = Array.isArray(rule[key]) ? rule[key] : [rule[key]];
3783
+ values.forEach((value) => {
3784
+ rules.push({
3785
+ key: RobotCorrespondences[key],
3786
+ value
3787
+ });
3788
+ });
3789
+ });
3790
+ });
3791
+ return rules;
3792
+ }
3793
+ function getContent(rules, hostname) {
3794
+ return rules.map((rule) => `${rule.key}: ${String(rule.value).trim()}`).join("\n").concat(`
3795
+
3796
+ Sitemap: ${getFinalSitemapPath(hostname)}`);
3797
+ }
3798
+ function getFinalSitemapPath(hostname) {
3799
+ return `${ensureSuffix("/", hostname)}sitemap.xml`;
3800
+ }
3801
+
3802
+ // src/sitemap.ts
3803
+ init_esm_shims();
3804
+ import { join, parse } from "path";
3805
+ import glob from "fast-glob";
3806
+ function getRoutes(options) {
3807
+ return [
3808
+ ...glob.sync("**/*.html", { cwd: options.outDir }).map((route) => {
3809
+ const parsedRoute = parse(route.replace(/index\.html/g, ""));
3810
+ return slash(join("/", parsedRoute.dir, parsedRoute.name));
3811
+ }),
3812
+ ...options.dynamicRoutes.map((route) => slash(join("/", join(parse(route).dir, parse(route).name))))
3813
+ ];
3814
+ }
3815
+ function getFormattedSitemap(options, routes) {
3816
+ return routes.map((route) => ({
3817
+ url: new URL(route, options.hostname).href,
3818
+ changefreq: options.changefreq,
3819
+ priority: options.priority,
3820
+ lastmod: options.lastmod
3821
+ }));
3822
+ }
3823
+
3824
+ // src/utils.ts
3825
+ init_esm_shims();
3826
+ import { resolve } from "path";
3827
+ function getResolvedPath(file, resolvedOptions) {
3828
+ return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
3829
+ }
3830
+
3831
+ // src/types.ts
3832
+ init_esm_shims();
3833
+
3834
+ // src/index.ts
3835
+ function generateSitemap(options = {}) {
3836
+ const resolvedOptions = resolveOptions(options);
3837
+ const robotRules = getRules(resolvedOptions.robots);
3838
+ const robotContent = getContent(robotRules, resolvedOptions.hostname);
3839
+ writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
3840
+ const routes = getRoutes(resolvedOptions);
3841
+ if (!routes.length)
3842
+ return;
3843
+ const formattedSitemap = getFormattedSitemap(resolvedOptions, routes);
3844
+ const stream = new import_sitemap.SitemapStream();
3845
+ formattedSitemap.forEach((item) => stream.write(item));
3846
+ (0, import_sitemap.streamToPromise)(stream).then((sitemap) => {
3847
+ const utfSitemap = sitemap.toString("utf-8");
3848
+ const formattedSitemap2 = resolvedOptions.readable ? (0, import_xml_formatter.default)(utfSitemap) : utfSitemap;
3849
+ writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
3850
+ });
3851
+ stream.end();
3852
+ }
3853
+ function sitemapPlugin(options = {}) {
3854
+ return {
3855
+ name: "vite-plugin-sitemap",
3856
+ closeBundle() {
3857
+ generateSitemap(options);
3858
+ }
3859
+ };
3860
+ }
3861
+ var src_default = sitemapPlugin;
3862
+ export {
3863
+ src_default as default,
3864
+ generateSitemap
3865
+ };
3866
+ /*!
3867
+ * Sitemap
3868
+ * Copyright(c) 2011 Eugene Kalinin
3869
+ * MIT Licensed
3870
+ */
3871
+ /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
3872
+ //# sourceMappingURL=index.mjs.map