canada-api 4.0.5 → 5.0.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/README.md +45 -28
- package/dist/ca.js +1 -1
- package/package.json +36 -31
- package/src/children.mjs +32 -11
- package/src/config.mjs +5 -0
- package/src/content.mjs +8 -3
- package/src/index.mjs +10 -0
- package/src/meta.mjs +54 -24
- package/src/normalize.mjs +15 -11
- package/src/request.mjs +7 -2
- package/CONTRIBUTING.md +0 -19
- package/webpack.config.js +0 -18
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
Cross platform API for fetching public data from [canada.ca](https://www.canada.ca).
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
## Browser
|
|
8
|
+
|
|
9
9
|
```html
|
|
10
|
-
<script src="https://cdn.jsdelivr.net/npm/canada-api@
|
|
10
|
+
<script src="https://cdn.jsdelivr.net/npm/canada-api@5.0.1"></script>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Node
|
|
13
|
+
## Node 18+
|
|
14
14
|
|
|
15
15
|
### Install
|
|
16
16
|
|
|
@@ -21,17 +21,35 @@ npm install canada-api
|
|
|
21
21
|
### Usage
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
|
|
24
|
+
import ca from 'canada-api'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Testing
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
npm test
|
|
25
31
|
```
|
|
26
32
|
|
|
33
|
+
Tests use the built-in Node.js test runner (`node:test`) and require Node 18 or later.
|
|
34
|
+
|
|
27
35
|
## Core API
|
|
28
36
|
|
|
37
|
+
### `ca.normalize(url)`
|
|
38
|
+
|
|
39
|
+
- `url` {string|URL} - Full URL or relative path (e.g. `'/en/page'` or `'https://www.canada.ca/en/page'`)
|
|
40
|
+
- Returns: {URL} Normalized URL object with cleaned pathname
|
|
41
|
+
|
|
42
|
+
Validates and normalizes a canada.ca URL. Strips the `/content/canadasite` prefix, file extensions, and trailing slashes.
|
|
43
|
+
|
|
44
|
+
Throws {TypeError} if `url` is not a string or URL object.
|
|
45
|
+
Throws {Error} if the URL is not on canada.ca or the path does not start with `/en/` or `/fr/`.
|
|
46
|
+
|
|
29
47
|
### `ca.request(url)`
|
|
30
48
|
|
|
31
|
-
- `url` {string|URL}
|
|
32
|
-
- Returns: {Promise} Fulfills with axios response
|
|
49
|
+
- `url` {string|URL} - Relative or absolute URL on [canada.ca](https://www.canada.ca)
|
|
50
|
+
- Returns: {Promise} Fulfills with an axios response object
|
|
33
51
|
|
|
34
|
-
|
|
52
|
+
Raw HTTP client for canada.ca. No URL transformation is applied.
|
|
35
53
|
|
|
36
54
|
```json
|
|
37
55
|
{
|
|
@@ -44,40 +62,32 @@ Throws {Error} if the request does not complete successfully or if the destinati
|
|
|
44
62
|
}
|
|
45
63
|
```
|
|
46
64
|
|
|
47
|
-
### `ca.normalize(url)`
|
|
48
|
-
|
|
49
|
-
- `url` {string|URL} node URL
|
|
50
|
-
|
|
51
|
-
Validates and formats [canada.ca](https://www.canada.ca). Throws an {Error} if the URL is invalid, or the type requested is not possible.
|
|
52
|
-
|
|
53
65
|
## Basic API
|
|
54
66
|
|
|
55
67
|
### `ca.children(url)`
|
|
56
68
|
|
|
57
|
-
- `url` {string|URL}
|
|
58
|
-
- Returns: {Promise} Fulfills with
|
|
69
|
+
- `url` {string|URL} - Absolute or relative URL
|
|
70
|
+
- Returns: {Promise} Fulfills with an axios response whose `data` is an array of sitemap entries
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
Fetches and parses the sitemap for the given page, returning its child pages. Entries without a `<loc>` element are skipped.
|
|
61
73
|
|
|
62
74
|
```json
|
|
63
75
|
{
|
|
64
76
|
"data": [
|
|
65
77
|
{
|
|
66
|
-
"path": "
|
|
67
|
-
"lastmod": "2022-09-
|
|
68
|
-
}
|
|
78
|
+
"path": "/en/department-national-defence/maple-leaf",
|
|
79
|
+
"lastmod": "2022-09-20T00:00:00.000Z"
|
|
80
|
+
}
|
|
69
81
|
]
|
|
70
82
|
}
|
|
71
83
|
```
|
|
72
84
|
|
|
73
|
-
Getting children of DAM folders/assets is not available.
|
|
74
|
-
|
|
75
85
|
### `ca.content(url)`
|
|
76
86
|
|
|
77
|
-
- `url` {string|URL}
|
|
78
|
-
- Returns: {Promise} Fulfills with
|
|
87
|
+
- `url` {string|URL} - Absolute or relative URL
|
|
88
|
+
- Returns: {Promise} Fulfills with an axios response whose `data` is the raw HTML string
|
|
79
89
|
|
|
80
|
-
Retrieves the
|
|
90
|
+
Retrieves the HTML content of the page.
|
|
81
91
|
|
|
82
92
|
```json
|
|
83
93
|
{
|
|
@@ -87,17 +97,24 @@ Retrieves the document contents.
|
|
|
87
97
|
|
|
88
98
|
### `ca.meta(url)`
|
|
89
99
|
|
|
90
|
-
- `url` {string|URL}
|
|
91
|
-
- Returns: {Promise} Fulfills with
|
|
100
|
+
- `url` {string|URL} - Absolute or relative URL
|
|
101
|
+
- Returns: {Promise} Fulfills with an axios response whose `data` is a formatted metadata object
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+
Fetches JCR metadata for the given page. The following transformations are applied:
|
|
104
|
+
|
|
105
|
+
- String `"true"` / `"false"` values are converted to booleans
|
|
106
|
+
- `@TypeHint` properties are removed
|
|
107
|
+
- Empty arrays are removed
|
|
108
|
+
- Date strings are converted to ISO 8601
|
|
109
|
+
- Keys are sorted alphabetically
|
|
110
|
+
- A normalized `peer` field is added when `gcAltLanguagePeer` is present
|
|
94
111
|
|
|
95
112
|
```json
|
|
96
113
|
{
|
|
97
114
|
"data": {
|
|
98
115
|
"cq:lastModified": "2022-10-25T19:16:28.000Z",
|
|
99
116
|
"fluidWidth": false,
|
|
117
|
+
"peer": "/fr/ministere-defense-nationale/feuille-erable"
|
|
100
118
|
}
|
|
101
119
|
}
|
|
102
120
|
```
|
|
103
|
-
|
package/dist/ca.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ca",[],t):"object"==typeof exports?exports.ca=t():e.ca=t()}(Object("undefined"!=typeof self?self:this),()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{default:()=>jt});var n={};e.r(n),e.d(n,{hasBrowserEnv:()=>fe,hasStandardBrowserEnv:()=>pe,hasStandardBrowserWebWorkerEnv:()=>he,navigator:()=>de,origin:()=>me});const r=e=>{if("string"==typeof e)e=new URL(e,"https://www.canada.ca/");else if(!(e instanceof URL))throw new TypeError("string or URL object expected");if("https://www.canada.ca"!==e.origin)throw new Error("URL must start with "+baseURL);if(e.pathname=e.pathname.replace(/^\/content\/canadasite/,""),!e.pathname.startsWith("/en/")&&!e.pathname.startsWith("/fr/"))throw new Error("Invalid path");return e.pathname=e.pathname.replace(/(\.[^/]+|\/+)$/,""),e};function o(e,t){return function(){return e.apply(t,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:i}=Object,{iterator:a,toStringTag:c}=Symbol,l=(u=Object.create(null),e=>{const t=s.call(e);return u[t]||(u[t]=t.slice(8,-1).toLowerCase())});var u;const f=e=>(e=e.toLowerCase(),t=>l(t)===e),d=e=>t=>typeof t===e,{isArray:p}=Array,h=d("undefined");function m(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&g(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const b=f("ArrayBuffer"),y=d("string"),g=d("function"),w=d("number"),R=e=>null!==e&&"object"==typeof e,E=e=>{if("object"!==l(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||c in e||a in e)},O=f("Date"),S=f("File"),T=f("Blob"),A=f("FileList"),v=f("URLSearchParams"),[j,_,x,P]=["ReadableStream","Request","Response","Headers"].map(f);function N(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),p(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(m(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function U(e,t){if(m(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e.g,L=e=>!h(e)&&e!==C,D=(F="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>F&&e instanceof F);var F;const B=f("HTMLFormElement"),k=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),q=f("RegExp"),I=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};N(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)},M=f("AsyncFunction"),z=(H="function"==typeof setImmediate,J=g(C.postMessage),H?setImmediate:J?(W=`axios@${Math.random()}`,$=[],C.addEventListener("message",({source:e,data:t})=>{e===C&&t===W&&$.length&&$.shift()()},!1),e=>{$.push(e),C.postMessage(W,"*")}):e=>setTimeout(e));var H,J,W,$;const K="undefined"!=typeof queueMicrotask?queueMicrotask.bind(C):"undefined"!=typeof process&&process.nextTick||z,V={isArray:p,isArrayBuffer:b,isBuffer:m,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||g(e.append)&&("formdata"===(t=l(e))||"object"===t&&g(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&b(e.buffer),t},isString:y,isNumber:w,isBoolean:e=>!0===e||!1===e,isObject:R,isPlainObject:E,isEmptyObject:e=>{if(!R(e)||m(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:j,isRequest:_,isResponse:x,isHeaders:P,isUndefined:h,isDate:O,isFile:S,isBlob:T,isRegExp:q,isFunction:g,isStream:e=>R(e)&&g(e.pipe),isURLSearchParams:v,isTypedArray:D,isFileList:A,forEach:N,merge:function e(){const{caseless:t,skipUndefined:n}=L(this)&&this||{},r={},o=(o,s)=>{if("__proto__"===s||"constructor"===s||"prototype"===s)return;const i=t&&U(r,s)||s;E(r[i])&&E(o)?r[i]=e(r[i],o):E(o)?r[i]=e({},o):p(o)?r[i]=o.slice():n&&h(o)||(r[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&N(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(N(t,(t,r)=>{n&&g(t)?Object.defineProperty(e,r,{value:o(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&i(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:l,kindOfTest:f,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(p(e))return e;let t=e.length;if(!w(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[a]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:B,hasOwnProperty:k,hasOwnProp:k,reduceDescriptors:I,freezeMethods:e=>{I(e,(t,n)=>{if(g(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];g(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return p(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:U,global:C,isContextDefined:L,isSpecCompliantForm:function(e){return!!(e&&g(e.append)&&"FormData"===e[c]&&e[a])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(R(e)){if(t.indexOf(e)>=0)return;if(m(e))return e;if(!("toJSON"in e)){t[r]=e;const o=p(e)?[]:{};return N(e,(e,t)=>{const s=n(e,r+1);!h(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:M,isThenable:e=>e&&(R(e)||g(e))&&g(e.then)&&g(e.catch),setImmediate:z,asap:K,isIterable:e=>null!=e&&g(e[a])};class X extends Error{static from(e,t,n,r,o,s){const i=new X(e.message,t||e.code,n,r,o);return i.cause=e,i.name=e.name,s&&Object.assign(i,s),i}constructor(e,t,n,r,o){super(e),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}}X.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",X.ERR_BAD_OPTION="ERR_BAD_OPTION",X.ECONNABORTED="ECONNABORTED",X.ETIMEDOUT="ETIMEDOUT",X.ERR_NETWORK="ERR_NETWORK",X.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",X.ERR_DEPRECATED="ERR_DEPRECATED",X.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",X.ERR_BAD_REQUEST="ERR_BAD_REQUEST",X.ERR_CANCELED="ERR_CANCELED",X.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",X.ERR_INVALID_URL="ERR_INVALID_URL";const G=X;function Q(e){return V.isPlainObject(e)||V.isArray(e)}function Y(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map(function(e,t){return e=Y(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const ee=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)}),te=function(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!V.isUndefined(t[e])})).metaTokens,o=n.visitor||l,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(V.isDate(e))return e.toISOString();if(V.isBoolean(e))return e.toString();if(!a&&V.isBlob(e))throw new G("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(e)||V.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(V.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(V.isArray(e)&&function(e){return V.isArray(e)&&!e.some(Q)}(e)||(V.isFileList(e)||V.endsWith(n,"[]"))&&(a=V.toArray(e)))return n=Y(n),a.forEach(function(e,r){!V.isUndefined(e)&&null!==e&&t.append(!0===i?Z([n],r,s):null===i?n:n+"[]",c(e))}),!1;return!!Q(e)||(t.append(Z(o,n,s),c(e)),!1)}const u=[],f=Object.assign(ee,{defaultVisitor:l,convertValue:c,isVisitable:Q});if(!V.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!V.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),V.forEach(n,function(n,s){!0===(!(V.isUndefined(n)||null===n)&&o.call(t,n,V.isString(s)?s.trim():s,r,f))&&e(n,r?r.concat(s):[s])}),u.pop()}}(e),t};function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function re(e,t){this._pairs=[],e&&te(e,this,t)}const oe=re.prototype;oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};const se=re;function ie(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ae(e,t,n){if(!t)return e;const r=n&&n.encode||ie,o=V.isFunction(n)?{serialize:n}:n,s=o&&o.serialize;let i;if(i=s?s(t,o):V.isURLSearchParams(t)?t.toString():new se(t,o).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}const ce=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(t){null!==t&&e(t)})}},le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},ue={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:se,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},fe="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,pe=fe&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,me=fe&&window.location.href||"http://localhost",be={...n,...ue},ye=function(e){function t(e,n,r,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;return s=!s&&V.isArray(r)?r.length:s,a?(V.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i):(r[s]&&V.isObject(r[s])||(r[s]=[]),t(e,n,r[s],o)&&V.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(e,r)=>{t(function(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null},ge={transitional:le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=V.isObject(e);if(o&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return r?JSON.stringify(ye(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new be.classes.URLSearchParams,{visitor:function(e,t,n,r){return be.isNode&&V.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=V.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e){if(V.isString(e))try{return(0,JSON.parse)(e),V.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ge.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw G.from(e,G.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:be.classes.FormData,Blob:be.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{ge.headers[e]={}});const we=ge,Re=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ee=Symbol("internals");function Oe(e){return e&&String(e).trim().toLowerCase()}function Se(e){return!1===e||null==e?e:V.isArray(e)?e.map(Se):String(e)}function Te(e,t,n,r,o){return V.isFunction(r)?r.call(this,t,n):(o&&(t=n),V.isString(t)?V.isString(r)?-1!==t.indexOf(r):V.isRegExp(r)?r.test(t):void 0:void 0)}class Ae{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Oe(t);if(!o)throw new Error("header name must be a non-empty string");const s=V.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Se(e))}const s=(e,t)=>V.forEach(e,(e,n)=>o(e,n,t));if(V.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(V.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Re[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(V.isObject(e)&&V.isIterable(e)){let n,r,o={};for(const t of e){if(!V.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?V.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Oe(e)){const n=V.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(V.isFunction(t))return t.call(this,e,n);if(V.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Oe(e)){const n=V.findKey(this,e);return!(!n||void 0===this[n]||t&&!Te(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Oe(e)){const o=V.findKey(n,e);!o||t&&!Te(0,n[o],o,t)||(delete n[o],r=!0)}}return V.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Te(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return V.forEach(this,(r,o)=>{const s=V.findKey(n,o);if(s)return t[s]=Se(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Se(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&V.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Ee]=this[Ee]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Oe(e);t[r]||(function(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return V.isArray(e)?e.forEach(r):r(e),this}}Ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Ae.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),V.freezeMethods(Ae);const ve=Ae;function je(e,t){const n=this||we,r=t||n,o=ve.from(r.headers);let s=r.data;return V.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _e(e){return!(!e||!e.__CANCEL__)}const xe=class extends G{constructor(e,t,n){super(null==e?"canceled":e,G.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function Pe(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new G("Request failed with status code "+n.status,[G.ERR_BAD_REQUEST,G.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const Ne=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=r[i];o||(o=c),n[s]=a,r[s]=c;let u=i,f=0;for(;u!==s;)f+=n[u++],u%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const d=l&&c-l;return d?Math.round(1e3*f/d):void 0}}(50,250);return function(e,t){let n,r,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(n=e,r||(r=setTimeout(()=>{r=null,i(n)},s-a)))},()=>n&&i(n)]}(n=>{const s=n.loaded,i=n.lengthComputable?n.total:void 0,a=s-r,c=o(a);r=s,e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},Ue=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ce=e=>(...t)=>V.asap(()=>e(...t)),Le=be.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,be.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(be.origin),be.navigator&&/(msie|trident)/i.test(be.navigator.userAgent)):()=>!0,De=be.hasStandardBrowserEnv?{write(e,t,n,r,o,s,i){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];V.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),V.isString(r)&&a.push(`path=${r}`),V.isString(o)&&a.push(`domain=${o}`),!0===s&&a.push("secure"),V.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Fe(e,t,n){let r=!("string"==typeof(o=t)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o));var o;return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Be=e=>e instanceof ve?{...e}:e;function ke(e,t){t=t||{};const n={};function r(e,t,n,r){return V.isPlainObject(e)&&V.isPlainObject(t)?V.merge.call({caseless:r},e,t):V.isPlainObject(t)?V.merge({},t):V.isArray(t)?t.slice():t}function o(e,t,n,o){return V.isUndefined(t)?V.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!V.isUndefined(t))return r(void 0,t)}function i(e,t){return V.isUndefined(t)?V.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(Be(e),Be(t),0,!0)};return V.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const s=V.hasOwnProp(c,r)?c[r]:o,i=s(e[r],t[r],r);V.isUndefined(i)&&s!==a||(n[r]=i)}),n}const qe=e=>{const t=ke({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=ve.from(i),t.url=ae(Fe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n))if(be.hasStandardBrowserEnv||be.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&i.set(e,n)})}if(be.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||!1!==r&&Le(t.url))){const e=o&&s&&De.read(s);e&&i.set(o,e)}return t},Ie="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=qe(e);let o=r.data;const s=ve.from(r.headers).normalize();let i,a,c,l,u,{responseType:f,onUploadProgress:d,onDownloadProgress:p}=r;function h(){l&&l(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function b(){if(!m)return;const r=ve.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Pe(function(e){t(e),h()},function(e){n(e),h()},{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=b:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(b)},m.onabort=function(){m&&(n(new G("Request aborted",G.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=t&&t.message?t.message:"Network Error",o=new G(r,G.ERR_NETWORK,e,m);o.event=t||null,n(o),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||le;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new G(t,o.clarifyTimeoutError?G.ETIMEDOUT:G.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&V.forEach(s.toJSON(),function(e,t){m.setRequestHeader(t,e)}),V.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),f&&"json"!==f&&(m.responseType=r.responseType),p&&([c,u]=Ne(p,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,l]=Ne(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(i=t=>{m&&(n(!t||t.type?new xe(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===be.protocols.indexOf(y)?n(new G("Unsupported protocol "+y+":",G.ERR_BAD_REQUEST,e)):m.send(o||null)})},Me=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof G?t:new xe(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new G(`timeout of ${t}ms exceeded`,G.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>V.asap(i),a}},ze=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},He=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*ze(n,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=i+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:Je}=V,We=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:$e,TextEncoder:Ke}=V.global,Ve=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Xe=e=>{e=V.merge.call({skipUndefined:!0},We,e);const{fetch:t,Request:n,Response:r}=e,o=t?Je(t):"function"==typeof fetch,s=Je(n),i=Je(r);if(!o)return!1;const a=o&&Je($e),c=o&&("function"==typeof Ke?(l=new Ke,e=>l.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var l;const u=s&&a&&Ve(()=>{let e=!1;const t=new n(be.origin,{body:new $e,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),f=i&&a&&Ve(()=>V.isReadableStream(new r("").body)),d={stream:f&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new G(`Response type '${e}' is not supported`,G.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:o,method:i,data:a,signal:l,cancelToken:p,timeout:h,onDownloadProgress:m,onUploadProgress:b,responseType:y,headers:g,withCredentials:w="same-origin",fetchOptions:R}=qe(e),E=t||fetch;y=y?(y+"").toLowerCase():"text";let O=Me([l,p&&p.toAbortSignal()],h),S=null;const T=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let A;try{if(b&&u&&"get"!==i&&"head"!==i&&0!==(A=await(async(e,t)=>{const r=V.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(V.isBlob(e))return e.size;if(V.isSpecCompliantForm(e)){const t=new n(be.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return V.isArrayBufferView(e)||V.isArrayBuffer(e)?e.byteLength:(V.isURLSearchParams(e)&&(e+=""),V.isString(e)?(await c(e)).byteLength:void 0)})(t):r})(g,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(V.isFormData(a)&&(e=t.headers.get("content-type"))&&g.setContentType(e),t.body){const[e,n]=Ue(A,Ne(Ce(b)));a=He(t.body,65536,e,n)}}V.isString(w)||(w=w?"include":"omit");const t=s&&"credentials"in n.prototype,l={...R,signal:O,method:i.toUpperCase(),headers:g.normalize().toJSON(),body:a,duplex:"half",credentials:t?w:void 0};S=s&&new n(o,l);let p=await(s?E(S,R):E(o,l));const h=f&&("stream"===y||"response"===y);if(f&&(m||h&&T)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=V.toFiniteNumber(p.headers.get("content-length")),[n,o]=m&&Ue(t,Ne(Ce(m),!0))||[];p=new r(He(p.body,65536,n,()=>{o&&o(),T&&T()}),e)}y=y||"text";let v=await d[V.findKey(d,y)||"text"](p,e);return!h&&T&&T(),await new Promise((t,n)=>{Pe(t,n,{data:v,headers:ve.from(p.headers),status:p.status,statusText:p.statusText,config:e,request:S})})}catch(t){if(T&&T(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new G("Network Error",G.ERR_NETWORK,e,S,t&&t.response),{cause:t.cause||t});throw G.from(t,t&&t.code,e,S,t&&t.response)}}},Ge=new Map,Qe=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i,a,c=s.length,l=Ge;for(;c--;)i=s[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:Xe(t)),l=a;return a},Ye=(Qe(),{http:null,xhr:Ie,fetch:{get:Qe}});V.forEach(Ye,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Ze=e=>`- ${e}`,et=e=>V.isFunction(e)||null===e||!1===e,tt=function(e,t){e=V.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){let n;if(r=e[i],o=r,!et(r)&&(o=Ye[(n=String(r)).toLowerCase()],void 0===o))throw new G(`Unknown adapter '${n}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[n||"#"+i]=o}if(!o){const e=Object.entries(s).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(Ze).join("\n"):" "+Ze(e[0]):"as no adapter specified";throw new G("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return o};function nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xe(null,e)}function rt(e){return nt(e),e.headers=ve.from(e.headers),e.data=je.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tt(e.adapter||we.adapter,e)(e).then(function(t){return nt(e),t.data=je.call(e,e.transformResponse,t),t.headers=ve.from(t.headers),t},function(t){return _e(t)||(nt(e),t&&t.response&&(t.response.data=je.call(e,e.transformResponse,t.response),t.response.headers=ve.from(t.response.headers))),Promise.reject(t)})}const ot="1.13.5",st={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{st[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const it={};st.transitional=function(e,t,n){function r(e,t){return"[Axios v"+ot+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new G(r(o," has been removed"+(t?" in "+t:"")),G.ERR_DEPRECATED);return t&&!it[o]&&(it[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}},st.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};const at={assertOptions:function(e,t,n){if("object"!=typeof e)throw new G("options must be an object",G.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new G("option "+s+" must be "+n,G.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new G("Unknown option "+s,G.ERR_BAD_OPTION)}},validators:st},ct=at.validators;class lt{constructor(e){this.defaults=e||{},this.interceptors={request:new ce,response:new ce}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ke(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&at.assertOptions(n,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean),legacyInterceptorReqResOrdering:ct.transitional(ct.boolean)},!1),null!=r&&(V.isFunction(r)?t.paramsSerializer={serialize:r}:at.assertOptions(r,{encode:ct.function,serialize:ct.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),at.assertOptions(t,{baseUrl:ct.spelling("baseURL"),withXsrfToken:ct.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&V.merge(o.common,o[t.method]);o&&V.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=ve.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;a=a&&e.synchronous;const n=t.transitional||le;n&&n.legacyInterceptorReqResOrdering?i.unshift(e.fulfilled,e.rejected):i.push(e.fulfilled,e.rejected)});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,f=0;if(!a){const e=[rt.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,l=Promise.resolve(t);f<u;)l=l.then(e[f++],e[f++]);return l}u=i.length;let d=t;for(;f<u;){const e=i[f++],t=i[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{l=rt.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,u=c.length;f<u;)l=l.then(c[f++],c[f++]);return l}getUri(e){return ae(Fe((e=ke(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}V.forEach(["delete","get","head","options"],function(e){lt.prototype[e]=function(t,n){return this.request(ke(n||{},{method:e,url:t,data:(n||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(ke(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}lt.prototype[e]=t(),lt.prototype[e+"Form"]=t(!0)});const ut=lt;class ft{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new xe(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ft(function(t){e=t}),cancel:e}}}const dt=ft,pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(pt).forEach(([e,t])=>{pt[t]=e});const ht=pt,mt=function e(t){const n=new ut(t),r=o(ut.prototype.request,n);return V.extend(r,ut.prototype,n,{allOwnKeys:!0}),V.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(ke(t,n))},r}(we);mt.Axios=ut,mt.CanceledError=xe,mt.CancelToken=dt,mt.isCancel=_e,mt.VERSION=ot,mt.toFormData=te,mt.AxiosError=G,mt.Cancel=mt.CanceledError,mt.all=function(e){return Promise.all(e)},mt.spread=function(e){return function(t){return e.apply(null,t)}},mt.isAxiosError=function(e){return V.isObject(e)&&!0===e.isAxiosError},mt.mergeConfig=ke,mt.AxiosHeaders=ve,mt.formToJSON=e=>ye(V.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=tt,mt.HttpStatusCode=ht,mt.default=mt;const bt=mt,yt=bt.create({baseURL:"https://www.canada.ca",timeout:3e4}),gt=bt.create({baseURL:"https://www.canada.ca",timeout:3e4,maxRedirects:0});gt.interceptors.request.use(e=>{const t=r(e.url);return t.pathname=t.pathname+".sitemap.xml",t.searchParams.set("_",Date.now()),e.url=t.toString(),e},e=>Promise.reject(e)),gt.interceptors.response.use(e=>(e.data=wt(e.data),e),e=>Promise.reject(e));const wt=e=>[...e.matchAll(/<url>.*?<loc>([^<]+)<\/loc>.*?(?:<lastmod>([^<]+)<\/lastmod>)?.*?<\/url>/g)].map(e=>({loc:r(e[1]).pathname,lastmod:e[2]?new Date(e[2]).toISOString():null})),Rt=gt,Et=bt.create({baseURL:"https://www.canada.ca",timeout:5e3,maxRedirects:0});Et.interceptors.request.use(e=>{const t=r(e.url);return t.pathname=t.pathname+".html",t.searchParams.set("_",Date.now()),e.url=t.toString(),e},e=>Promise.reject(e));const Ot=Et,St=bt.create({baseURL:"https://www.canada.ca",timeout:5e3,maxRedirects:0});St.interceptors.request.use(e=>{const t=r(e.url);return t.pathname=t.pathname+"/_jcr_content.json",t.searchParams.set("_",Date.now()),e.url=t.toString(),e},e=>Promise.reject(e)),St.interceptors.response.use(e=>(e.data=vt(e.data),e),e=>Promise.reject(e));const Tt={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"};function At(e){if(/^\d{4}-\d{2}-\d{2}$/.test(e))return new Date(e).toISOString();let t=/^\w{3} (\w{3}) (\d{2}) (\d{4}) ([\d:]{8}) GMT([\-+]\d{4})$/.exec(e);return t?new Date(t[3]+"-"+Tt[t[1]]+"-"+t[2]+"T"+t[4]+t[5]).toISOString():e}const vt=e=>{for(const[t,n]of Object.entries(e))"true"===n?e[t]=!0:"false"===n?e[t]=!1:t.endsWith("@TypeHint")?delete e[t]:"string"==typeof n?e[t]=At(e[t].trim()):Array.isArray(n)&&0===n.length&&delete e[t];return Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})},jt={normalize:r,request:yt,children:Rt,content:Ot,meta:St};return t})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("ca",[],e):"object"==typeof exports?exports.ca=e():t.ca=e()}(Object("undefined"!=typeof self?self:this),()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{default:()=>or});var n={};t.r(n),t.d(n,{hasBrowserEnv:()=>ft,hasStandardBrowserEnv:()=>mt,hasStandardBrowserWebWorkerEnv:()=>bt,navigator:()=>gt,origin:()=>yt});const r="https://www.canada.ca",s=t=>{if("string"==typeof t)t=new URL(t,r);else if(!(t instanceof URL))throw new TypeError("string or URL object expected");if(t.origin!==r)throw new Error("URL must start with "+r);if(t.pathname=t.pathname.replace(/^\/content\/canadasite/,""),t.pathname=t.pathname.replace(/\.[^/]*$/,"").replace(/\/+$/,""),!t.pathname.startsWith("/en/")&&!t.pathname.startsWith("/fr/"))throw new Error(`Invalid path: "${t.pathname}" must start with /en/ or /fr/`);return t};function i(t,e){return function(){return t.apply(e,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:a}=Object,{iterator:l,toStringTag:c}=Symbol,u=(h=Object.create(null),t=>{const e=o.call(t);return h[e]||(h[e]=e.slice(8,-1).toLowerCase())});var h;const d=t=>(t=t.toLowerCase(),e=>u(e)===t),p=t=>e=>typeof e===t,{isArray:f}=Array,g=p("undefined");function m(t){return null!==t&&!g(t)&&null!==t.constructor&&!g(t.constructor)&&x(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const b=d("ArrayBuffer"),y=p("string"),x=p("function"),E=p("number"),w=t=>null!==t&&"object"==typeof t,v=t=>{if("object"!==u(t))return!1;const e=a(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||c in t||l in t)},S=d("Date"),_=d("File"),N=d("Blob"),T=d("FileList"),O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t.g?t.g:{},A=void 0!==O.FormData?O.FormData:void 0,R=d("URLSearchParams"),[C,P,D,j]=["ReadableStream","Request","Response","Headers"].map(d);function I(t,e,{allOwnKeys:n=!1}={}){if(null==t)return;let r,s;if("object"!=typeof t&&(t=[t]),f(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(m(t))return;const s=n?Object.getOwnPropertyNames(t):Object.keys(t),i=s.length;let o;for(r=0;r<i;r++)o=s[r],e.call(null,t[o],o,t)}}function L(t,e){if(m(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r,s=n.length;for(;s-- >0;)if(r=n[s],e===r.toLowerCase())return r;return null}const U="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:t.g,k=t=>!g(t)&&t!==U,F=(B="undefined"!=typeof Uint8Array&&a(Uint8Array),t=>B&&t instanceof B);var B;const M=d("HTMLFormElement"),$=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),q=d("RegExp"),V=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};I(n,(n,s)=>{let i;!1!==(i=e(n,s,t))&&(r[s]=i||n)}),Object.defineProperties(t,r)},W=d("AsyncFunction"),z=(J="function"==typeof setImmediate,H=x(U.postMessage),J?setImmediate:H?(K=`axios@${Math.random()}`,X=[],U.addEventListener("message",({source:t,data:e})=>{t===U&&e===K&&X.length&&X.shift()()},!1),t=>{X.push(t),U.postMessage(K,"*")}):t=>setTimeout(t));var J,H,K,X;const Y="undefined"!=typeof queueMicrotask?queueMicrotask.bind(U):"undefined"!=typeof process&&process.nextTick||z,G={isArray:f,isArrayBuffer:b,isBuffer:m,isFormData:t=>{let e;return t&&(A&&t instanceof A||x(t.append)&&("formdata"===(e=u(t))||"object"===e&&x(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&b(t.buffer),e},isString:y,isNumber:E,isBoolean:t=>!0===t||!1===t,isObject:w,isPlainObject:v,isEmptyObject:t=>{if(!w(t)||m(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:C,isRequest:P,isResponse:D,isHeaders:j,isUndefined:g,isDate:S,isFile:_,isReactNativeBlob:t=>!(!t||void 0===t.uri),isReactNative:t=>t&&void 0!==t.getParts,isBlob:N,isRegExp:q,isFunction:x,isStream:t=>w(t)&&x(t.pipe),isURLSearchParams:R,isTypedArray:F,isFileList:T,forEach:I,merge:function t(){const{caseless:e,skipUndefined:n}=k(this)&&this||{},r={},s=(s,i)=>{if("__proto__"===i||"constructor"===i||"prototype"===i)return;const o=e&&L(r,i)||i;v(r[o])&&v(s)?r[o]=t(r[o],s):v(s)?r[o]=t({},s):f(s)?r[o]=s.slice():n&&g(s)||(r[o]=s)};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&I(arguments[t],s);return r},extend:(t,e,n,{allOwnKeys:r}={})=>(I(e,(e,r)=>{n&&x(e)?Object.defineProperty(t,r,{value:i(e,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,r,{value:e,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject:(t,e,n,r)=>{let s,i,o;const l={};if(e=e||{},null==t)return e;do{for(s=Object.getOwnPropertyNames(t),i=s.length;i-- >0;)o=s[i],r&&!r(o,t,e)||l[o]||(e[o]=t[o],l[o]=!0);t=!1!==n&&a(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kindOf:u,kindOfTest:d,endsWith:(t,e,n)=>{t=String(t),(void 0===n||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return-1!==r&&r===n},toArray:t=>{if(!t)return null;if(f(t))return t;let e=t.length;if(!E(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},forEachEntry:(t,e)=>{const n=(t&&t[l]).call(t);let r;for(;(r=n.next())&&!r.done;){const n=r.value;e.call(t,n[0],n[1])}},matchAll:(t,e)=>{let n;const r=[];for(;null!==(n=t.exec(e));)r.push(n);return r},isHTMLForm:M,hasOwnProperty:$,hasOwnProp:$,reduceDescriptors:V,freezeMethods:t=>{V(t,(e,n)=>{if(x(t)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=t[n];x(r)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(t,e)=>{const n={},r=t=>{t.forEach(t=>{n[t]=!0})};return f(t)?r(t):r(String(t).split(e)),n},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,n){return e.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:L,global:U,isContextDefined:k,isSpecCompliantForm:function(t){return!!(t&&x(t.append)&&"FormData"===t[c]&&t[l])},toJSONObject:t=>{const e=new Array(10),n=(t,r)=>{if(w(t)){if(e.indexOf(t)>=0)return;if(m(t))return t;if(!("toJSON"in t)){e[r]=t;const s=f(t)?[]:{};return I(t,(t,e)=>{const i=n(t,r+1);!g(i)&&(s[e]=i)}),e[r]=void 0,s}}return t};return n(t,0)},isAsyncFn:W,isThenable:t=>t&&(w(t)||x(t))&&x(t.then)&&x(t.catch),setImmediate:z,asap:Y,isIterable:t=>null!=t&&x(t[l])};class Z extends Error{static from(t,e,n,r,s,i){const o=new Z(t.message,e||t.code,n,r,s);return o.cause=t,o.name=t.name,null!=t.status&&null==o.status&&(o.status=t.status),i&&Object.assign(o,i),o}constructor(t,e,n,r,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:G.toJSONObject(this.config),code:this.code,status:this.status}}}Z.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Z.ERR_BAD_OPTION="ERR_BAD_OPTION",Z.ECONNABORTED="ECONNABORTED",Z.ETIMEDOUT="ETIMEDOUT",Z.ERR_NETWORK="ERR_NETWORK",Z.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Z.ERR_DEPRECATED="ERR_DEPRECATED",Z.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Z.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Z.ERR_CANCELED="ERR_CANCELED",Z.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Z.ERR_INVALID_URL="ERR_INVALID_URL";const Q=Z;function tt(t){return G.isPlainObject(t)||G.isArray(t)}function et(t){return G.endsWith(t,"[]")?t.slice(0,-2):t}function nt(t,e,n){return t?t.concat(e).map(function(t,e){return t=et(t),!n&&e?"["+t+"]":t}).join(n?".":""):e}const rt=G.toFlatObject(G,{},null,function(t){return/^is[A-Z]/.test(t)}),st=function(t,e,n){if(!G.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const r=(n=G.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!G.isUndefined(e[t])})).metaTokens,s=n.visitor||c,i=n.dots,o=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&G.isSpecCompliantForm(e);if(!G.isFunction(s))throw new TypeError("visitor must be a function");function l(t){if(null===t)return"";if(G.isDate(t))return t.toISOString();if(G.isBoolean(t))return t.toString();if(!a&&G.isBlob(t))throw new Q("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(t)||G.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function c(t,n,s){let a=t;if(G.isReactNative(e)&&G.isReactNativeBlob(t))return e.append(nt(s,n,i),l(t)),!1;if(t&&!s&&"object"==typeof t)if(G.endsWith(n,"{}"))n=r?n:n.slice(0,-2),t=JSON.stringify(t);else if(G.isArray(t)&&function(t){return G.isArray(t)&&!t.some(tt)}(t)||(G.isFileList(t)||G.endsWith(n,"[]"))&&(a=G.toArray(t)))return n=et(n),a.forEach(function(t,r){!G.isUndefined(t)&&null!==t&&e.append(!0===o?nt([n],r,i):null===o?n:n+"[]",l(t))}),!1;return!!tt(t)||(e.append(nt(s,n,i),l(t)),!1)}const u=[],h=Object.assign(rt,{defaultVisitor:c,convertValue:l,isVisitable:tt});if(!G.isObject(t))throw new TypeError("data must be an object");return function t(n,r){if(!G.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),G.forEach(n,function(n,i){!0===(!(G.isUndefined(n)||null===n)&&s.call(e,n,G.isString(i)?i.trim():i,r,h))&&t(n,r?r.concat(i):[i])}),u.pop()}}(t),e};function it(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function ot(t,e){this._pairs=[],t&&st(t,this,e)}const at=ot.prototype;at.append=function(t,e){this._pairs.push([t,e])},at.toString=function(t){const e=t?function(e){return t.call(this,e,it)}:it;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};const lt=ot;function ct(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ut(t,e,n){if(!e)return t;const r=n&&n.encode||ct,s=G.isFunction(n)?{serialize:n}:n,i=s&&s.serialize;let o;if(o=i?i(e,s):G.isURLSearchParams(e)?e.toString():new lt(e,s).toString(r),o){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}const ht=class{constructor(){this.handlers=[]}use(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){G.forEach(this.handlers,function(e){null!==e&&t(e)})}},dt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},pt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:lt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ft="undefined"!=typeof window&&"undefined"!=typeof document,gt="object"==typeof navigator&&navigator||void 0,mt=ft&&(!gt||["ReactNative","NativeScript","NS"].indexOf(gt.product)<0),bt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,yt=ft&&window.location.href||"http://localhost",xt={...n,...pt},Et=function(t){function e(t,n,r,s){let i=t[s++];if("__proto__"===i)return!0;const o=Number.isFinite(+i),a=s>=t.length;return i=!i&&G.isArray(r)?r.length:i,a?(G.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!o):(r[i]&&G.isObject(r[i])||(r[i]=[]),e(t,n,r[i],s)&&G.isArray(r[i])&&(r[i]=function(t){const e={},n=Object.keys(t);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],e[i]=t[i];return e}(r[i])),!o)}if(G.isFormData(t)&&G.isFunction(t.entries)){const n={};return G.forEachEntry(t,(t,r)=>{e(function(t){return G.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),r,n,0)}),n}return null},wt={transitional:dt,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const n=e.getContentType()||"",r=n.indexOf("application/json")>-1,s=G.isObject(t);if(s&&G.isHTMLForm(t)&&(t=new FormData(t)),G.isFormData(t))return r?JSON.stringify(Et(t)):t;if(G.isArrayBuffer(t)||G.isBuffer(t)||G.isStream(t)||G.isFile(t)||G.isBlob(t)||G.isReadableStream(t))return t;if(G.isArrayBufferView(t))return t.buffer;if(G.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let i;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return st(t,new xt.classes.URLSearchParams,{visitor:function(t,e,n,r){return xt.isNode&&G.isBuffer(t)?(this.append(e,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((i=G.isFileList(t))||n.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return st(i?{"files[]":t}:t,e&&new e,this.formSerializer)}}return s||r?(e.setContentType("application/json",!1),function(t){if(G.isString(t))try{return(0,JSON.parse)(t),G.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||wt.transitional,n=e&&e.forcedJSONParsing,r="json"===this.responseType;if(G.isResponse(t)||G.isReadableStream(t))return t;if(t&&G.isString(t)&&(n&&!this.responseType||r)){const n=!(e&&e.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(t){if(n){if("SyntaxError"===t.name)throw Q.from(t,Q.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],t=>{wt.headers[t]={}});const vt=wt,St=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_t=t=>{const e={};let n,r,s;return t&&t.split("\n").forEach(function(t){s=t.indexOf(":"),n=t.substring(0,s).trim().toLowerCase(),r=t.substring(s+1).trim(),!n||e[n]&&St[n]||("set-cookie"===n?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e};(Object.getOwnPropertyDescriptor(_t,"name")||{}).writable||Object.defineProperty(_t,"name",{value:"default",configurable:!0});const Nt=Symbol("internals");function Tt(t,e){if(!1!==t&&null!=t)if(G.isArray(t))t.forEach(t=>Tt(t,e));else if(!(t=>!/[\r\n]/.test(t))(String(t)))throw new Error(`Invalid character in header content ["${e}"]`)}function Ot(t){return t&&String(t).trim().toLowerCase()}function At(t){return!1===t||null==t?t:G.isArray(t)?t.map(At):function(t){let e=t.length;for(;e>0;){const n=t.charCodeAt(e-1);if(10!==n&&13!==n)break;e-=1}return e===t.length?t:t.slice(0,e)}(String(t))}function Rt(t,e,n,r,s){return G.isFunction(r)?r.call(this,e,n):(s&&(e=n),G.isString(e)?G.isString(r)?-1!==e.indexOf(r):G.isRegExp(r)?r.test(e):void 0:void 0)}class Ct{constructor(t){t&&this.set(t)}set(t,e,n){const r=this;function s(t,e,n){const s=Ot(e);if(!s)throw new Error("header name must be a non-empty string");const i=G.findKey(r,s);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(Tt(t,e),r[i||e]=At(t))}const i=(t,e)=>G.forEach(t,(t,n)=>s(t,n,e));if(G.isPlainObject(t)||t instanceof this.constructor)i(t,e);else if(G.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))i(_t(t),e);else if(G.isObject(t)&&G.isIterable(t)){let n,r,s={};for(const e of t){if(!G.isArray(e))throw TypeError("Object iterator must return a key-value pair");s[r=e[0]]=(n=s[r])?G.isArray(n)?[...n,e[1]]:[n,e[1]]:e[1]}i(s,e)}else null!=t&&s(e,t,n);return this}get(t,e){if(t=Ot(t)){const n=G.findKey(this,t);if(n){const t=this[n];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}(t);if(G.isFunction(e))return e.call(this,t,n);if(G.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Ot(t)){const n=G.findKey(this,t);return!(!n||void 0===this[n]||e&&!Rt(0,this[n],n,e))}return!1}delete(t,e){const n=this;let r=!1;function s(t){if(t=Ot(t)){const s=G.findKey(n,t);!s||e&&!Rt(0,n[s],s,e)||(delete n[s],r=!0)}}return G.isArray(t)?t.forEach(s):s(t),r}clear(t){const e=Object.keys(this);let n=e.length,r=!1;for(;n--;){const s=e[n];t&&!Rt(0,this[s],s,t,!0)||(delete this[s],r=!0)}return r}normalize(t){const e=this,n={};return G.forEach(this,(r,s)=>{const i=G.findKey(n,s);if(i)return e[i]=At(r),void delete e[s];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,n)=>e.toUpperCase()+n)}(s):String(s).trim();o!==s&&delete e[s],e[o]=At(r),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return G.forEach(this,(n,r)=>{null!=n&&!1!==n&&(e[r]=t&&G.isArray(n)?n.join(", "):n)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const n=new this(t);return e.forEach(t=>n.set(t)),n}static accessor(t){const e=(this[Nt]=this[Nt]={accessors:{}}).accessors,n=this.prototype;function r(t){const r=Ot(t);e[r]||(function(t,e){const n=G.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(t,n,s){return this[r].call(this,e,t,n,s)},configurable:!0})})}(n,t),e[r]=!0)}return G.isArray(t)?t.forEach(r):r(t),this}}Ct.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),G.reduceDescriptors(Ct.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[n]=t}}}),G.freezeMethods(Ct);const Pt=Ct;function Dt(t,e){const n=this||vt,r=e||n,s=Pt.from(r.headers);let i=r.data;return G.forEach(t,function(t){i=t.call(n,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function jt(t){return!(!t||!t.__CANCEL__)}const It=class extends Q{constructor(t,e,n){super(null==t?"canceled":t,Q.ERR_CANCELED,e,n),this.name="CanceledError",this.__CANCEL__=!0}};function Lt(t,e,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?e(new Q("Request failed with status code "+n.status,[Q.ERR_BAD_REQUEST,Q.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}const Ut=(t,e,n=3)=>{let r=0;const s=function(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s,i=0,o=0;return e=void 0!==e?e:1e3,function(a){const l=Date.now(),c=r[o];s||(s=l),n[i]=a,r[i]=l;let u=o,h=0;for(;u!==i;)h+=n[u++],u%=t;if(i=(i+1)%t,i===o&&(o=(o+1)%t),l-s<e)return;const d=c&&l-c;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(t,e){let n,r,s=0,i=1e3/e;const o=(e,i=Date.now())=>{s=i,n=null,r&&(clearTimeout(r),r=null),t(...e)};return[(...t)=>{const e=Date.now(),a=e-s;a>=i?o(t,e):(n=t,r||(r=setTimeout(()=>{r=null,o(n)},i-a)))},()=>n&&o(n)]}(n=>{const i=n.loaded,o=n.lengthComputable?n.total:void 0,a=i-r,l=s(a);r=i,t({loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:l||void 0,estimated:l&&o&&i<=o?(o-i)/l:void 0,event:n,lengthComputable:null!=o,[e?"download":"upload"]:!0})},n)},kt=(t,e)=>{const n=null!=t;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Ft=t=>(...e)=>G.asap(()=>t(...e)),Bt=xt.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,xt.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,Mt=xt.hasStandardBrowserEnv?{write(t,e,n,r,s,i,o){if("undefined"==typeof document)return;const a=[`${t}=${encodeURIComponent(e)}`];G.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),G.isString(r)&&a.push(`path=${r}`),G.isString(s)&&a.push(`domain=${s}`),!0===i&&a.push("secure"),G.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(t){if("undefined"==typeof document)return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function $t(t,e,n){let r=!("string"==typeof(s=e)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s));var s;return t&&(r||0==n)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const qt=t=>t instanceof Pt?{...t}:t;function Vt(t,e){e=e||{};const n={};function r(t,e,n,r){return G.isPlainObject(t)&&G.isPlainObject(e)?G.merge.call({caseless:r},t,e):G.isPlainObject(e)?G.merge({},e):G.isArray(e)?e.slice():e}function s(t,e,n,s){return G.isUndefined(e)?G.isUndefined(t)?void 0:r(void 0,t,0,s):r(t,e,0,s)}function i(t,e){if(!G.isUndefined(e))return r(void 0,e)}function o(t,e){return G.isUndefined(e)?G.isUndefined(t)?void 0:r(void 0,t):r(void 0,e)}function a(n,s,i){return i in e?r(n,s):i in t?r(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(t,e,n)=>s(qt(t),qt(e),0,!0)};return G.forEach(Object.keys({...t,...e}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const i=G.hasOwnProp(l,r)?l[r]:s,o=i(t[r],e[r],r);G.isUndefined(o)&&i!==a||(n[r]=o)}),n}const Wt=t=>{const e=Vt({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:a}=e;if(e.headers=o=Pt.from(o),e.url=ut($t(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),G.isFormData(n))if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(G.isFunction(n.getHeaders)){const t=n.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,n])=>{e.includes(t.toLowerCase())&&o.set(t,n)})}if(xt.hasStandardBrowserEnv&&(r&&G.isFunction(r)&&(r=r(e)),r||!1!==r&&Bt(e.url))){const t=s&&i&&Mt.read(i);t&&o.set(s,t)}return e};(Object.getOwnPropertyDescriptor(Wt,"name")||{}).writable||Object.defineProperty(Wt,"name",{value:"default",configurable:!0});const zt="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,n){const r=Wt(t);let s=r.data;const i=Pt.from(r.headers).normalize();let o,a,l,c,u,{responseType:h,onUploadProgress:d,onDownloadProgress:p}=r;function f(){c&&c(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(o),r.signal&&r.signal.removeEventListener("abort",o)}let g=new XMLHttpRequest;function m(){if(!g)return;const r=Pt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Lt(function(t){e(t),f()},function(t){n(t),f()},{data:h&&"text"!==h&&"json"!==h?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:t,request:g}),g=null}g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(n(new Q("Request aborted",Q.ECONNABORTED,t,g)),g=null)},g.onerror=function(e){const r=e&&e.message?e.message:"Network Error",s=new Q(r,Q.ERR_NETWORK,t,g);s.event=e||null,n(s),g=null},g.ontimeout=function(){let e=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const s=r.transitional||dt;r.timeoutErrorMessage&&(e=r.timeoutErrorMessage),n(new Q(e,s.clarifyTimeoutError?Q.ETIMEDOUT:Q.ECONNABORTED,t,g)),g=null},void 0===s&&i.setContentType(null),"setRequestHeader"in g&&G.forEach(i.toJSON(),function(t,e){g.setRequestHeader(e,t)}),G.isUndefined(r.withCredentials)||(g.withCredentials=!!r.withCredentials),h&&"json"!==h&&(g.responseType=r.responseType),p&&([l,u]=Ut(p,!0),g.addEventListener("progress",l)),d&&g.upload&&([a,c]=Ut(d),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(o=e=>{g&&(n(!e||e.type?new It(null,t,g):e),g.abort(),g=null)},r.cancelToken&&r.cancelToken.subscribe(o),r.signal&&(r.signal.aborted?o():r.signal.addEventListener("abort",o)));const b=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(r.url);b&&-1===xt.protocols.indexOf(b)?n(new Q("Unsupported protocol "+b+":",Q.ERR_BAD_REQUEST,t)):g.send(s||null)})},Jt=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let n,r=new AbortController;const s=function(t){if(!n){n=!0,o();const e=t instanceof Error?t:this.reason;r.abort(e instanceof Q?e:new It(e instanceof Error?e.message:e))}};let i=e&&setTimeout(()=>{i=null,s(new Q(`timeout of ${e}ms exceeded`,Q.ETIMEDOUT))},e);const o=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(s):t.removeEventListener("abort",s)}),t=null)};t.forEach(t=>t.addEventListener("abort",s));const{signal:a}=r;return a.unsubscribe=()=>G.asap(o),a}},Ht=function*(t,e){let n=t.byteLength;if(!e||n<e)return void(yield t);let r,s=0;for(;s<n;)r=s+e,yield t.slice(s,r),s=r},Kt=(t,e,n,r)=>{const s=async function*(t,e){for await(const n of async function*(t){if(t[Symbol.asyncIterator])return void(yield*t);const e=t.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}}(t))yield*Ht(n,e)}(t,e);let i,o=0,a=t=>{i||(i=!0,r&&r(t))};return new ReadableStream({async pull(t){try{const{done:e,value:r}=await s.next();if(e)return a(),void t.close();let i=r.byteLength;if(n){let t=o+=i;n(t)}t.enqueue(new Uint8Array(r))}catch(t){throw a(t),t}},cancel:t=>(a(t),s.return())},{highWaterMark:2})},{isFunction:Xt}=G,Yt=(({Request:t,Response:e})=>({Request:t,Response:e}))(G.global),{ReadableStream:Gt,TextEncoder:Zt}=G.global,Qt=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},te=t=>{t=G.merge.call({skipUndefined:!0},Yt,t);const{fetch:e,Request:n,Response:r}=t,s=e?Xt(e):"function"==typeof fetch,i=Xt(n),o=Xt(r);if(!s)return!1;const a=s&&Xt(Gt),l=s&&("function"==typeof Zt?(c=new Zt,t=>c.encode(t)):async t=>new Uint8Array(await new n(t).arrayBuffer()));var c;const u=i&&a&&Qt(()=>{let t=!1;const e=new Gt,r=new n(xt.origin,{body:e,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return e.cancel(),t&&!r}),h=o&&a&&Qt(()=>G.isReadableStream(new r("").body)),d={stream:h&&(t=>t.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!d[t]&&(d[t]=(e,n)=>{let r=e&&e[t];if(r)return r.call(e);throw new Q(`Response type '${t}' is not supported`,Q.ERR_NOT_SUPPORT,n)})});return async t=>{let{url:s,method:o,data:a,signal:c,cancelToken:p,timeout:f,onDownloadProgress:g,onUploadProgress:m,responseType:b,headers:y,withCredentials:x="same-origin",fetchOptions:E}=Wt(t),w=e||fetch;b=b?(b+"").toLowerCase():"text";let v=Jt([c,p&&p.toAbortSignal()],f),S=null;const _=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let N;try{if(m&&u&&"get"!==o&&"head"!==o&&0!==(N=await(async(t,e)=>{const r=G.toFiniteNumber(t.getContentLength());return null==r?(async t=>{if(null==t)return 0;if(G.isBlob(t))return t.size;if(G.isSpecCompliantForm(t)){const e=new n(xt.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return G.isArrayBufferView(t)||G.isArrayBuffer(t)?t.byteLength:(G.isURLSearchParams(t)&&(t+=""),G.isString(t)?(await l(t)).byteLength:void 0)})(e):r})(y,a))){let t,e=new n(s,{method:"POST",body:a,duplex:"half"});if(G.isFormData(a)&&(t=e.headers.get("content-type"))&&y.setContentType(t),e.body){const[t,n]=kt(N,Ut(Ft(m)));a=Kt(e.body,65536,t,n)}}G.isString(x)||(x=x?"include":"omit");const e=i&&"credentials"in n.prototype,c={...E,signal:v,method:o.toUpperCase(),headers:y.normalize().toJSON(),body:a,duplex:"half",credentials:e?x:void 0};S=i&&new n(s,c);let p=await(i?w(S,E):w(s,c));const f=h&&("stream"===b||"response"===b);if(h&&(g||f&&_)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=p[e]});const e=G.toFiniteNumber(p.headers.get("content-length")),[n,s]=g&&kt(e,Ut(Ft(g),!0))||[];p=new r(Kt(p.body,65536,n,()=>{s&&s(),_&&_()}),t)}b=b||"text";let T=await d[G.findKey(d,b)||"text"](p,t);return!f&&_&&_(),await new Promise((e,n)=>{Lt(e,n,{data:T,headers:Pt.from(p.headers),status:p.status,statusText:p.statusText,config:t,request:S})})}catch(e){if(_&&_(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new Q("Network Error",Q.ERR_NETWORK,t,S,e&&e.response),{cause:e.cause||e});throw Q.from(e,e&&e.code,t,S,e&&e.response)}}},ee=new Map,ne=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:s}=e,i=[r,s,n];let o,a,l=i.length,c=ee;for(;l--;)o=i[l],a=c.get(o),void 0===a&&c.set(o,a=l?new Map:te(e)),c=a;return a},re=(ne(),{http:null,xhr:zt,fetch:{get:ne}});G.forEach(re,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const se=t=>`- ${t}`,ie=t=>G.isFunction(t)||null===t||!1===t,oe=function(t,e){t=G.isArray(t)?t:[t];const{length:n}=t;let r,s;const i={};for(let o=0;o<n;o++){let n;if(r=t[o],s=r,!ie(r)&&(s=re[(n=String(r)).toLowerCase()],void 0===s))throw new Q(`Unknown adapter '${n}'`);if(s&&(G.isFunction(s)||(s=s.get(e))))break;i[n||"#"+o]=s}if(!s){const t=Object.entries(i).map(([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));let e=n?t.length>1?"since :\n"+t.map(se).join("\n"):" "+se(t[0]):"as no adapter specified";throw new Q("There is no suitable adapter to dispatch the request "+e,"ERR_NOT_SUPPORT")}return s};function ae(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new It(null,t)}function le(t){return ae(t),t.headers=Pt.from(t.headers),t.data=Dt.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),oe(t.adapter||vt.adapter,t)(t).then(function(e){return ae(t),e.data=Dt.call(t,t.transformResponse,e),e.headers=Pt.from(e.headers),e},function(e){return jt(e)||(ae(t),e&&e.response&&(e.response.data=Dt.call(t,t.transformResponse,e.response),e.response.headers=Pt.from(e.response.headers))),Promise.reject(e)})}const ce="1.15.0",ue={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{ue[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const he={};ue.transitional=function(t,e,n){function r(t,e){return"[Axios v"+ce+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return(n,s,i)=>{if(!1===t)throw new Q(r(s," has been removed"+(e?" in "+e:"")),Q.ERR_DEPRECATED);return e&&!he[s]&&(he[s]=!0,console.warn(r(s," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,s,i)}},ue.spelling=function(t){return(e,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};const de={assertOptions:function(t,e,n){if("object"!=typeof t)throw new Q("options must be an object",Q.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const e=t[i],n=void 0===e||o(e,i,t);if(!0!==n)throw new Q("option "+i+" must be "+n,Q.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Q("Unknown option "+i,Q.ERR_BAD_OPTION)}},validators:ue},pe=de.validators;class fe{constructor(t){this.defaults=t||{},this.interceptors={request:new ht,response:new ht}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const n=(()=>{if(!e.stack)return"";const t=e.stack.indexOf("\n");return-1===t?"":e.stack.slice(t+1)})();try{if(t.stack){if(n){const e=n.indexOf("\n"),r=-1===e?-1:n.indexOf("\n",e+1),s=-1===r?"":n.slice(r+1);String(t.stack).endsWith(s)||(t.stack+="\n"+n)}}else t.stack=n}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Vt(this.defaults,e);const{transitional:n,paramsSerializer:r,headers:s}=e;void 0!==n&&de.assertOptions(n,{silentJSONParsing:pe.transitional(pe.boolean),forcedJSONParsing:pe.transitional(pe.boolean),clarifyTimeoutError:pe.transitional(pe.boolean),legacyInterceptorReqResOrdering:pe.transitional(pe.boolean)},!1),null!=r&&(G.isFunction(r)?e.paramsSerializer={serialize:r}:de.assertOptions(r,{encode:pe.function,serialize:pe.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),de.assertOptions(e,{baseUrl:pe.spelling("baseURL"),withXsrfToken:pe.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let i=s&&G.merge(s.common,s[e.method]);s&&G.forEach(["delete","get","head","post","put","patch","common"],t=>{delete s[t]}),e.headers=Pt.concat(i,s);const o=[];let a=!0;this.interceptors.request.forEach(function(t){if("function"==typeof t.runWhen&&!1===t.runWhen(e))return;a=a&&t.synchronous;const n=e.transitional||dt;n&&n.legacyInterceptorReqResOrdering?o.unshift(t.fulfilled,t.rejected):o.push(t.fulfilled,t.rejected)});const l=[];let c;this.interceptors.response.forEach(function(t){l.push(t.fulfilled,t.rejected)});let u,h=0;if(!a){const t=[le.bind(this),void 0];for(t.unshift(...o),t.push(...l),u=t.length,c=Promise.resolve(e);h<u;)c=c.then(t[h++],t[h++]);return c}u=o.length;let d=e;for(;h<u;){const t=o[h++],e=o[h++];try{d=t(d)}catch(t){e.call(this,t);break}}try{c=le.call(this,d)}catch(t){return Promise.reject(t)}for(h=0,u=l.length;h<u;)c=c.then(l[h++],l[h++]);return c}getUri(t){return ut($t((t=Vt(this.defaults,t)).baseURL,t.url,t.allowAbsoluteUrls),t.params,t.paramsSerializer)}}G.forEach(["delete","get","head","options"],function(t){fe.prototype[t]=function(e,n){return this.request(Vt(n||{},{method:t,url:e,data:(n||{}).data}))}}),G.forEach(["post","put","patch"],function(t){function e(e){return function(n,r,s){return this.request(Vt(s||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}fe.prototype[t]=e(),fe.prototype[t+"Form"]=e(!0)});const ge=fe;class me{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const n=this;this.promise.then(t=>{if(!n._listeners)return;let e=n._listeners.length;for(;e-- >0;)n._listeners[e](t);n._listeners=null}),this.promise.then=t=>{let e;const r=new Promise(t=>{n.subscribe(t),e=t}).then(t);return r.cancel=function(){n.unsubscribe(e)},r},t(function(t,r,s){n.reason||(n.reason=new It(t,r,s),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new me(function(e){t=e}),cancel:t}}}const be=me,ye={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ye).forEach(([t,e])=>{ye[e]=t});const xe=ye,Ee=function t(e){const n=new ge(e),r=i(ge.prototype.request,n);return G.extend(r,ge.prototype,n,{allOwnKeys:!0}),G.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return t(Vt(e,n))},r}(vt);Ee.Axios=ge,Ee.CanceledError=It,Ee.CancelToken=be,Ee.isCancel=jt,Ee.VERSION=ce,Ee.toFormData=st,Ee.AxiosError=Q,Ee.Cancel=Ee.CanceledError,Ee.all=function(t){return Promise.all(t)},Ee.spread=function(t){return function(e){return t.apply(null,e)}},Ee.isAxiosError=function(t){return G.isObject(t)&&!0===t.isAxiosError},Ee.mergeConfig=Vt,Ee.AxiosHeaders=Pt,Ee.formToJSON=t=>Et(G.isHTMLForm(t)?new FormData(t):t),Ee.getAdapter=oe,Ee.HttpStatusCode=xe,Ee.default=Ee;const we=Ee,ve=we.create({baseURL:r,timeout:3e4}),Se=":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",_e=new RegExp("^["+Se+"]["+Se+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Ne(t,e){const n=[];let r=e.exec(t);for(;r;){const s=[];s.startIndex=e.lastIndex-r[0].length;const i=r.length;for(let t=0;t<i;t++)s.push(r[t]);n.push(s),r=e.exec(t)}return n}const Te=function(t){return!(null==_e.exec(t))},Oe=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Ae=["__proto__","constructor","prototype"],Re={allowBooleanAttributes:!1,unpairedTags:[]};function Ce(t,e){e=Object.assign({},Re,e);const n=[];let r=!1,s=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let i=0;i<t.length;i++)if("<"===t[i]&&"?"===t[i+1]){if(i+=2,i=De(t,i),i.err)return i}else{if("<"!==t[i]){if(Pe(t[i]))continue;return Me("InvalidChar","char '"+t[i]+"' is not expected.",Ve(t,i))}{let o=i;if(i++,"!"===t[i]){i=je(t,i);continue}{let a=!1;"/"===t[i]&&(a=!0,i++);let l="";for(;i<t.length&&">"!==t[i]&&" "!==t[i]&&"\t"!==t[i]&&"\n"!==t[i]&&"\r"!==t[i];i++)l+=t[i];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),i--),!qe(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Me("InvalidTag",e,Ve(t,i))}const c=Ue(t,i);if(!1===c)return Me("InvalidAttr","Attributes for '"+l+"' have open quote.",Ve(t,i));let u=c.value;if(i=c.index,"/"===u[u.length-1]){const n=i-u.length;u=u.substring(0,u.length-1);const s=Fe(u,e);if(!0!==s)return Me(s.err.code,s.err.msg,Ve(t,n+s.err.line));r=!0}else if(a){if(!c.tagClosed)return Me("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Ve(t,i));if(u.trim().length>0)return Me("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Ve(t,o));if(0===n.length)return Me("InvalidTag","Closing tag '"+l+"' has not been opened.",Ve(t,o));{const e=n.pop();if(l!==e.tagName){let n=Ve(t,e.tagStartPos);return Me("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+l+"'.",Ve(t,o))}0==n.length&&(s=!0)}}else{const a=Fe(u,e);if(!0!==a)return Me(a.err.code,a.err.msg,Ve(t,i-u.length+a.err.line));if(!0===s)return Me("InvalidXml","Multiple possible root nodes found.",Ve(t,i));-1!==e.unpairedTags.indexOf(l)||n.push({tagName:l,tagStartPos:o}),r=!0}for(i++;i<t.length;i++)if("<"===t[i]){if("!"===t[i+1]){i++,i=je(t,i);continue}if("?"!==t[i+1])break;if(i=De(t,++i),i.err)return i}else if("&"===t[i]){const e=Be(t,i);if(-1==e)return Me("InvalidChar","char '&' is not expected.",Ve(t,i));i=e}else if(!0===s&&!Pe(t[i]))return Me("InvalidXml","Extra text at the end",Ve(t,i));"<"===t[i]&&i--}}}return r?1==n.length?Me("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Ve(t,n[0].tagStartPos)):!(n.length>0)||Me("InvalidXml","Invalid '"+JSON.stringify(n.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Me("InvalidXml","Start tag expected.",1)}function Pe(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function De(t,e){const n=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const r=t.substr(n,e-n);if(e>5&&"xml"===r)return Me("InvalidXml","XML declaration allowed only at the start of the document.",Ve(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function je(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let n=1;for(e+=8;e<t.length;e++)if("<"===t[e])n++;else if(">"===t[e]&&(n--,0===n))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const Ie='"',Le="'";function Ue(t,e){let n="",r="",s=!1;for(;e<t.length;e++){if(t[e]===Ie||t[e]===Le)""===r?r=t[e]:r!==t[e]||(r="");else if(">"===t[e]&&""===r){s=!0;break}n+=t[e]}return""===r&&{value:n,index:e,tagClosed:s}}const ke=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Fe(t,e){const n=Ne(t,ke),r={};for(let t=0;t<n.length;t++){if(0===n[t][1].length)return Me("InvalidAttr","Attribute '"+n[t][2]+"' has no space in starting.",We(n[t]));if(void 0!==n[t][3]&&void 0===n[t][4])return Me("InvalidAttr","Attribute '"+n[t][2]+"' is without value.",We(n[t]));if(void 0===n[t][3]&&!e.allowBooleanAttributes)return Me("InvalidAttr","boolean attribute '"+n[t][2]+"' is not allowed.",We(n[t]));const s=n[t][2];if(!$e(s))return Me("InvalidAttr","Attribute '"+s+"' is an invalid name.",We(n[t]));if(Object.prototype.hasOwnProperty.call(r,s))return Me("InvalidAttr","Attribute '"+s+"' is repeated.",We(n[t]));r[s]=1}return!0}function Be(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let n=/\d/;for("x"===t[e]&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(n))break}return-1}(t,++e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(";"===t[e])break;return-1}return e}function Me(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function $e(t){return Te(t)}function qe(t){return Te(t)}function Ve(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function We(t){return t.startIndex+t[1].length}const ze={validate:Ce},Je=t=>Oe.includes(t)?"__"+t:t,He={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Je};function Ke(t,e){if("string"!=typeof t)return;const n=t.toLowerCase();if(Oe.some(t=>n===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Ae.some(t=>n===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Xe(t){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:Xe(!0)}const Ye=function(t){const e=Object.assign({},He,t),n=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:t,name:e}of n)t&&Ke(t,e);return null===e.onDangerousProperty&&(e.onDangerousProperty=Je),e.processEntities=Xe(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),e};let Ge;Ge="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Ze{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][Ge]={startIndex:e})}static getMetaDataSymbol(){return Ge}}class Qe{constructor(t){this.suppressValidationErr=!t,this.options=t}readDocType(t,e){const n=Object.create(null);let r=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let s=1,i=!1,o=!1,a="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,s--):s--,0===s)break}else"["===t[e]?i=!0:a+=t[e];else{if(i&&en(t,"!ENTITY",e)){let s,i;if(e+=7,[s,i,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===i.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&r>=this.options.maxEntityCount)throw new Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const t=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n[s]={regx:RegExp(`&${t};`,"g"),val:i},r++}}else if(i&&en(t,"!ELEMENT",e)){e+=8;const{index:n}=this.readElementExp(t,e+1);e=n}else if(i&&en(t,"!ATTLIST",e))e+=8;else if(i&&en(t,"!NOTATION",e)){e+=9;const{index:n}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=n}else{if(!en(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}s++,a=""}if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:e}}readEntityExp(t,e){const n=e=tn(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let r=t.substring(n,e);if(nn(r),e=tn(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}let s="";if([e,s]=this.readIdentifierVal(t,e,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${r}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[r,s,--e]}readNotationExp(t,e){const n=e=tn(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let r=t.substring(n,e);!this.suppressValidationErr&&nn(r),e=tn(t,e);const s=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==s&&"PUBLIC"!==s)throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);e+=s.length,e=tn(t,e);let i=null,o=null;if("PUBLIC"===s)[e,i]=this.readIdentifierVal(t,e,"publicIdentifier"),'"'!==t[e=tn(t,e)]&&"'"!==t[e]||([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"));else if("SYSTEM"===s&&([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:r,publicIdentifier:i,systemIdentifier:o,index:--e}}readIdentifierVal(t,e,n){let r="";const s=t[e];if('"'!==s&&"'"!==s)throw new Error(`Expected quoted string, found "${s}"`);const i=++e;for(;e<t.length&&t[e]!==s;)e++;if(r=t.substring(i,e),t[e]!==s)throw new Error(`Unterminated ${n} value`);return[++e,r]}readElementExp(t,e){const n=e=tn(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let r=t.substring(n,e);if(!this.suppressValidationErr&&!Te(r))throw new Error(`Invalid element name: "${r}"`);let s="";if("E"===t[e=tn(t,e)]&&en(t,"MPTY",e))e+=4;else if("A"===t[e]&&en(t,"NY",e))e+=2;else if("("===t[e]){const n=++e;for(;e<t.length&&")"!==t[e];)e++;if(s=t.substring(n,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[e]}"`);return{elementName:r,contentModel:s.trim(),index:e}}readAttlistExp(t,e){let n=e=tn(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let r=t.substring(n,e);for(nn(r),n=e=tn(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(n,e);if(!nn(s))throw new Error(`Invalid attribute name: "${s}"`);e=tn(t,e);let i="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(i="NOTATION","("!==t[e=tn(t,e+=8)])throw new Error(`Expected '(', found "${t[e]}"`);e++;let n=[];for(;e<t.length&&")"!==t[e];){const r=e;for(;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;let s=t.substring(r,e);if(s=s.trim(),!nn(s))throw new Error(`Invalid notation name: "${s}"`);n.push(s),"|"===t[e]&&(e++,e=tn(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,i+=" ("+n.join("|")+")"}else{const n=e;for(;e<t.length&&!/\s/.test(t[e]);)e++;i+=t.substring(n,e);const r=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!r.includes(i.toUpperCase()))throw new Error(`Invalid attribute type: "${i}"`)}e=tn(t,e);let o="";return"#REQUIRED"===t.substring(e,e+8).toUpperCase()?(o="#REQUIRED",e+=8):"#IMPLIED"===t.substring(e,e+7).toUpperCase()?(o="#IMPLIED",e+=7):[e,o]=this.readIdentifierVal(t,e,"ATTLIST"),{elementName:r,attributeName:s,attributeType:i,defaultValue:o,index:e}}}const tn=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function en(t,e,n){for(let r=0;r<e.length;r++)if(e[r]!==t[n+r+1])return!1;return!0}function nn(t){if(Te(t))return t;throw new Error(`Invalid entity name ${t}`)}const rn=/^[-+]?0x[a-fA-F0-9]+$/,sn=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,on={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const an=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class ln{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const n=e[e.length-1];return void 0!==n.values&&t in n.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class cn{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new ln(this)}push(t,e=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const r=this.path.length;this.siblingStacks[r]||(this.siblingStacks[r]=new Map);const s=this.siblingStacks[r],i=n?`${n}:${t}`:t,o=s.get(i)||0;let a=0;for(const t of s.values())a+=t;s.set(i,o+1);const l={tag:t,position:a,counter:o};null!=n&&(l.namespace=n),null!=e&&(l.values=e),this.path.push(l)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const n=t||this.separator;if(n===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(n);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(n)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,n=t.length-1;for(;n>=0&&e>=0;){const r=t[n];if("deep-wildcard"===r.type){if(n--,n<0)return!0;const r=t[n];let s=!1;for(let t=e;t>=0;t--)if(this._matchSegment(r,this.path[t],t===this.path.length-1)){e=t-1,n--,s=!0;break}if(!s)return!1}else{if(!this._matchSegment(r,this.path[e],e===this.path.length-1))return!1;e--,n--}}return n<0}_matchSegment(t,e,n){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!n)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!n)return!1;const r=e.counter??0;if("first"===t.position&&0!==r)return!1;if("odd"===t.position&&r%2!=1)return!1;if("even"===t.position&&r%2!=0)return!1;if("nth"===t.position&&r!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class un{constructor(t,e={},n){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=n,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let n=0,r="";for(;n<t.length;)t[n]===this.separator?n+1<t.length&&t[n+1]===this.separator?(r.trim()&&(e.push(this._parseSegment(r.trim())),r=""),e.push({type:"deep-wildcard"}),n+=2):(r.trim()&&e.push(this._parseSegment(r.trim())),r="",n++):(r+=t[n],n++);return r.trim()&&e.push(this._parseSegment(r.trim())),e}_parseSegment(t){const e={type:"tag"};let n=null,r=t;const s=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(r=s[1]+s[3],s[2])){const t=s[2].slice(1,-1);t&&(n=t)}let i,o,a=r;if(r.includes("::")){const e=r.indexOf("::");if(i=r.substring(0,e).trim(),a=r.substring(e+2).trim(),!i)throw new Error(`Invalid namespace in pattern: ${t}`)}let l=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),n=a.substring(t+1).trim();["first","last","odd","even"].includes(n)||/^nth\(\d+\)$/.test(n)?(o=e,l=n):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,i&&(e.namespace=i),n)if(n.includes("=")){const t=n.indexOf("=");e.attrName=n.substring(0,t).trim(),e.attrValue=n.substring(t+1).trim()}else e.attrName=n.trim();if(l){const t=l.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=l}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class hn{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,n=t.segments[t.segments.length-1],r=n?.tag;if(r&&"*"!==r){const n=`${e}:${r}`;this._byDepthAndTag.has(n)||this._byDepthAndTag.set(n,[]),this._byDepthAndTag.get(n).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),n=`${e}:${t.getCurrentTag()}`,r=this._byDepthAndTag.get(n);if(r)for(let e=0;e<r.length;e++)if(t.matches(r[e]))return r[e];const s=this._wildcardByDepth.get(e);if(s)for(let e=0;e<s.length;e++)if(t.matches(s[e]))return s[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const dn={apos:{regex:/&(apos|#0*39|#x0*27);/g,val:"'"},gt:{regex:/&(gt|#0*62|#x0*3[Ee]);/g,val:">"},lt:{regex:/&(lt|#0*60|#x0*3[Cc]);/g,val:"<"},quot:{regex:/&(quot|#0*34|#x0*22);/g,val:'"'}},pn=/&(amp|#0*38|#x0*26);/g,fn=new Set("!?\\\\/[]$%{}^&*()<>|+");function gn(t){for(const e of t)if(fn.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${t}"`);return t}function mn(t){return t.replace(/[.\-+*:]/g,"\\$&")}function bn(t,e,n=!1){return!1===t||null===t?null:!0===t?e:void 0===t?n?e:null:"object"==typeof t?t:null}function yn(t){const e=[];for(const n of Object.keys(t)){const r=t[n];if("object"==typeof r&&null!==r&&void 0!==r.val)e.push([n,{regex:r.regex??r.regx,val:r.val}]);else if("string"==typeof r){if(-1!==r.indexOf("&"))continue;gn(n),e.push([n,{regex:new RegExp("&"+mn(n)+";","g"),val:r}])}}return e}class xn{constructor(t={}){var e;this._defaultTable=bn(t.default,dn,!0),this._systemTable=bn(t.system,null,!1),this._ampEnabled=!1!==t.amp&&null!==t.amp,this._maxTotalExpansions=t.maxTotalExpansions||0,this._maxExpandedLength=t.maxExpandedLength||0,this._applyLimitsTo="all"===(e=t.applyLimitsTo??"external")?"all":"string"==typeof e?new Set([e]):Array.isArray(e)?new Set(e):new Set(["external"]),this._postCheck="function"==typeof t.postCheck?t.postCheck:t=>t,this._limitExternal="all"===this._applyLimitsTo||this._applyLimitsTo instanceof Set&&this._applyLimitsTo.has("external"),this._limitSystem="all"===this._applyLimitsTo||this._applyLimitsTo instanceof Set&&this._applyLimitsTo.has("system"),this._limitDefault="all"===this._applyLimitsTo||this._applyLimitsTo instanceof Set&&this._applyLimitsTo.has("default"),this._defaultEntries=this._defaultTable?Object.entries(this._defaultTable):[],this._systemEntries=this._systemTable?Object.entries(this._systemTable):[],this._persistentEntries=[],this._inputEntries=[],this._totalExpansions=0,this._expandedLength=0}setExternalEntities(t){this._persistentEntries=yn(t)}addExternalEntity(t,e){gn(t),"string"==typeof e&&-1===e.indexOf("&")&&this._persistentEntries.push([t,{regex:new RegExp("&"+mn(t)+";","g"),val:e}])}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputEntries=yn(t)}reset(){this._inputEntries=[],this._totalExpansions=0,this._expandedLength=0}replace(t){if("string"!=typeof t||0===t.length)return t;if(-1===t.indexOf("&"))return t;const e=t;return this._persistentEntries.length>0&&(t=this._applyEntries(t,this._persistentEntries,this._limitExternal)),this._inputEntries.length>0&&-1!==t.indexOf("&")&&(t=this._applyEntries(t,this._inputEntries,this._limitExternal)),this._defaultEntries.length>0&&-1!==t.indexOf("&")&&(t=this._applyEntries(t,this._defaultEntries,this._limitDefault)),this._systemEntries.length>0&&-1!==t.indexOf("&")&&(t=this._applyEntries(t,this._systemEntries,this._limitSystem)),this._ampEnabled&&-1!==t.indexOf("&")&&(t=t.replace(pn,"&")),this._postCheck(t,e)}parse(t){return this.replace(t)}_applyEntries(t,e,n){const r=n&&this._maxTotalExpansions>0,s=n&&this._maxExpandedLength>0,i=r||s;for(let n=0;n<e.length&&-1!==t.indexOf("&");n++){const o=e[n][1];if(i)if(r&&!s){let e=0;if(t=t.replace(o.regex,(...t)=>(e++,"function"==typeof o.val?o.val(...t):o.val)),e>0&&(this._totalExpansions+=e,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`)}else if(s&&!r){const e=t.length,n=(t=t.replace(o.regex,o.val)).length-e;if(n>0&&(this._expandedLength+=n,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}else{const e=t.length;let n=0;if(t=t.replace(o.regex,(...t)=>(n++,"function"==typeof o.val?o.val(...t):o.val)),n>0&&(this._totalExpansions+=n,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);const r=t.length-e;if(r>0&&(this._expandedLength+=r,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}else t=t.replace(o.regex,o.val)}return t}}const En={nbsp:{regex:/&(nbsp|#0*160|#x0*[Aa]0);/g,val:" "},copy:{regex:/&(copy|#0*169|#x0*[Aa]9);/g,val:"©"},reg:{regex:/&(reg|#0*174|#x0*[Aa][Ee]);/g,val:"®"},trade:{regex:/&(trade|#0*8482|#x0*2122);/g,val:"™"},mdash:{regex:/&(mdash|#0*8212|#x0*2014);/g,val:"—"},ndash:{regex:/&(ndash|#0*8211|#x0*2013);/g,val:"–"},hellip:{regex:/&(hellip|#0*8230|#x0*2026);/g,val:"…"},laquo:{regex:/&(laquo|#0*171|#x0*[Aa][Bb]);/g,val:"«"},raquo:{regex:/&(raquo|#0*187|#x0*[Bb][Bb]);/g,val:"»"},lsquo:{regex:/&(lsquo|#0*8216|#x0*2018);/g,val:"‘"},rsquo:{regex:/&(rsquo|#0*8217|#x0*2019);/g,val:"’"},ldquo:{regex:/&(ldquo|#0*8220|#x0*201[Cc]);/g,val:"“"},rdquo:{regex:/&(rdquo|#0*8221|#x0*201[Dd]);/g,val:"”"},bull:{regex:/&(bull|#0*8226|#x0*2022);/g,val:"•"},para:{regex:/&(para|#0*182|#x0*[Bb]6);/g,val:"¶"},sect:{regex:/&(sect|#0*167|#x0*[Aa]7);/g,val:"§"},deg:{regex:/&(deg|#0*176|#x0*[Bb]0);/g,val:"°"},frac12:{regex:/&(frac12|#0*189|#x0*[Bb][Dd]);/g,val:"½"},frac14:{regex:/&(frac14|#0*188|#x0*[Bb][Cc]);/g,val:"¼"},frac34:{regex:/&(frac34|#0*190|#x0*[Bb][Ee]);/g,val:"¾"},inr:{regex:/&(inr|#0*8377);/g,val:"₹"}},wn={cent:{regex:/&(cent|#0*162|#x0*[Aa]2);/g,val:"¢"},pound:{regex:/&(pound|#0*163|#x0*[Aa]3);/g,val:"£"},yen:{regex:/&(yen|#0*165|#x0*[Aa]5);/g,val:"¥"},euro:{regex:/&(euro|#0*8364|#x0*20[Aa][Cc]);/g,val:"€"},inr:{regex:/&(inr|#0*8377|#x0*20[Bb]9);/g,val:"₹"},curren:{regex:/&(curren|#0*164|#x0*[Aa]4);/g,val:"¤"},fnof:{regex:/&(fnof|#0*402|#x0*192);/g,val:"ƒ"}},vn={num_dec:{regex:/�*([0-9]{1,7});/g,val:(t,e)=>Sn(e,10,"&#")},num_hex:{regex:/�*([0-9a-fA-F]{1,6});/g,val:(t,e)=>Sn(e,16,"&#x")}};function Sn(t,e,n){const r=Number.parseInt(t,e);return r>=0&&r<=1114111?String.fromCodePoint(r):n+t+";"}function _n(t,e){if(!t)return{};const n=e.attributesGroupName?t[e.attributesGroupName]:t;if(!n)return{};const r={};for(const t in n)t.startsWith(e.attributeNamePrefix)?r[t.substring(e.attributeNamePrefix.length)]=n[t]:r[t]=n[t];return r}function Nn(t){if(!t||"string"!=typeof t)return;const e=t.indexOf(":");if(-1!==e&&e>0){const n=t.substring(0,e);if("xmlns"!==n)return n}}class Tn{constructor(t){var e;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Pn,this.parseTextData=On,this.resolveNameSpace=An,this.buildAttributesMap=Cn,this.isItStopNode=Ln,this.replaceEntitiesValue=jn,this.readStopNodeData=Bn,this.saveTextToParentTag=In,this.addChild=Dn,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const n of e){if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:()=>!1,this.entityExpansionCount=0,this.currentExpandedLength=0,this.entityReplacer=new xn({default:!0,system:this.options.htmlEntities?{...En,...vn,...wn}:{},maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:"all"}),this.matcher=new cn,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new hn;const n=this.options.stopNodes;if(n&&n.length>0){for(let t=0;t<n.length;t++){const e=n[t];"string"==typeof e?this.stopNodeExpressionsSet.add(new un(e)):e instanceof un&&this.stopNodeExpressionsSet.add(e)}this.stopNodeExpressionsSet.seal()}}}function On(t,e,n,r,s,i,o){const a=this.options;if(void 0!==t&&(a.trimValues&&!r&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t,e,n));const r=a.jPath?n.toString():n,l=a.tagValueProcessor(e,t,r,s,i);return null==l?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?Mn(t,a.parseTagValue,a.numberParseOptions):t}}function An(t){if(this.options.removeNSPrefix){const e=t.split(":"),n="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=n+e[1])}return t}const Rn=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Cn(t,e,n){const r=this.options;if(!0!==r.ignoreAttributes&&"string"==typeof t){const s=Ne(t,Rn),i=s.length,o={},a=new Array(i);let l=!1;const c={};for(let t=0;t<i;t++){const e=this.resolveNameSpace(s[t][1]),i=s[t][4];if(e.length&&void 0!==i){let s=i;r.trimValues&&(s=s.trim()),s=this.replaceEntitiesValue(s,n,this.readonlyMatcher),a[t]=s,c[e]=s,l=!0}}l&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(c);const u=r.jPath?e.toString():this.readonlyMatcher;let h=!1;for(let t=0;t<i;t++){const e=this.resolveNameSpace(s[t][1]);if(this.ignoreAttributesFn(e,u))continue;let n=r.attributeNamePrefix+e;if(e.length)if(r.transformAttributeName&&(n=r.transformAttributeName(n)),n=qn(n,r),void 0!==s[t][4]){const s=a[t],i=r.attributeValueProcessor(e,s,u);o[n]=null==i?s:typeof i!=typeof s||i!==s?i:Mn(s,r.parseAttributeValue,r.numberParseOptions),h=!0}else r.allowBooleanAttributes&&(o[n]=!0,h=!0)}if(!h)return;if(r.attributesGroupName){const t={};return t[r.attributesGroupName]=o,t}return o}}const Pn=function(t){t=t.replace(/\r\n?/g,"\n");const e=new Ze("!xml");let n=e,r="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const s=this.options,i=new Qe(s.processEntities),o=t.length;for(let a=0;a<o;a++)if("<"===t[a]){const l=t.charCodeAt(a+1);if(47===l){const e=Un(t,">",a,"Closing Tag is not closed.");let i=t.substring(a+2,e).trim();if(s.removeNSPrefix){const t=i.indexOf(":");-1!==t&&(i=i.substr(t+1))}i=$n(s.transformTagName,i,"",s).tagName,n&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher));const o=this.matcher.getCurrentTag();if(i&&s.unpairedTagsSet.has(i))throw new Error(`Unpaired tag can not be used as closing tag: </${i}>`);o&&s.unpairedTagsSet.has(o)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop(),r="",a=e}else if(63===l){let e=Fn(t,a,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,this.readonlyMatcher),s.ignoreDeclaration&&"?xml"===e.tagName||s.ignorePiTags);else{const t=new Ze(e.tagName);t.add(s.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[":@"]=this.buildAttributesMap(e.tagExp,this.matcher,e.tagName)),this.addChild(n,t,this.readonlyMatcher,a)}a=e.closeIndex+1}else if(33===l&&45===t.charCodeAt(a+2)&&45===t.charCodeAt(a+3)){const e=Un(t,"--\x3e",a+4,"Comment is not closed.");if(s.commentPropName){const i=t.substring(a+4,e-2);r=this.saveTextToParentTag(r,n,this.readonlyMatcher),n.add(s.commentPropName,[{[s.textNodeName]:i}])}a=e}else if(33===l&&68===t.charCodeAt(a+2)){const e=i.readDocType(t,a);this.entityReplacer.addInputEntities(e.entities),a=e.i}else if(33===l&&91===t.charCodeAt(a+2)){const e=Un(t,"]]>",a,"CDATA is not closed.")-2,i=t.substring(a+9,e);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.parseTextData(i,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==o&&(o=""),s.cdataPropName?n.add(s.cdataPropName,[{[s.textNodeName]:i}]):n.add(s.textNodeName,o),a=e+2}else{let i=Fn(t,a,s.removeNSPrefix);if(!i){const e=t.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${e}"`)}let l=i.tagName;const c=i.rawTagName;let u=i.tagExp,h=i.attrExpPresent,d=i.closeIndex;if(({tagName:l,tagExp:u}=$n(s.transformTagName,l,u,s)),s.strictReservedNames&&(l===s.commentPropName||l===s.cdataPropName||l===s.textNodeName||l===s.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher,!1));const p=n;p&&s.unpairedTagsSet.has(p.tagname)&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let f=!1;u.length>0&&u.lastIndexOf("/")===u.length-1&&(f=!0,"/"===l[l.length-1]?(l=l.substr(0,l.length-1),u=l):u=u.substr(0,u.length-1),h=l!==u);let g,m=null,b={};g=Nn(c),l!==e.tagname&&this.matcher.push(l,{},g),l!==u&&h&&(m=this.buildAttributesMap(u,this.matcher,l),m&&(b=_n(m,s))),l!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const y=a;if(this.isCurrentNodeStopNode){let e="";if(f)a=i.closeIndex;else if(s.unpairedTagsSet.has(l))a=i.closeIndex;else{const n=this.readStopNodeData(t,c,d+1);if(!n)throw new Error(`Unexpected end of ${c}`);a=n.i,e=n.tagContent}const r=new Ze(l);m&&(r[":@"]=m),r.add(s.textNodeName,e),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,r,this.readonlyMatcher,y)}else{if(f){({tagName:l,tagExp:u}=$n(s.transformTagName,l,u,s));const t=new Ze(l);m&&(t[":@"]=m),this.addChild(n,t,this.readonlyMatcher,y),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(s.unpairedTagsSet.has(l)){const t=new Ze(l);m&&(t[":@"]=m),this.addChild(n,t,this.readonlyMatcher,y),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=i.closeIndex;continue}{const t=new Ze(l);if(this.tagsNodeStack.length>s.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),m&&(t[":@"]=m),this.addChild(n,t,this.readonlyMatcher,y),n=t}}r="",a=d}}}else r+=t[a];return e.child};function Dn(t,e,n,r){this.options.captureMetaData||(r=void 0);const s=this.options.jPath?n.toString():n,i=this.options.updateTag(e.tagname,s,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e,r)):t.addChild(e,r))}function jn(t,e,n){const r=this.options.processEntities;if(!r||!r.enabled)return t;if(r.allowedTags){const s=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(e):r.allowedTags(e,s)))return t}if(r.tagFilter){const s=this.options.jPath?n.toString():n;if(!r.tagFilter(e,s))return t}return this.entityReplacer.replace(t)}function In(t,e,n,r){return t&&(void 0===r&&(r=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,n,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,r))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function Ln(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Un(t,e,n,r){const s=t.indexOf(e,n);if(-1===s)throw new Error(r);return s+e.length-1}function kn(t,e,n,r){const s=t.indexOf(e,n);if(-1===s)throw new Error(r);return s}function Fn(t,e,n,r=">"){const s=function(t,e,n=">"){let r=0;const s=[],i=t.length,o=n.charCodeAt(0),a=n.length>1?n.charCodeAt(1):-1;for(let n=e;n<i;n++){const e=t.charCodeAt(n);if(r)e===r&&(r=0);else if(34===e||39===e)r=e;else if(e===o){if(-1===a)return{data:String.fromCharCode(...s),index:n};if(t.charCodeAt(n+1)===a)return{data:String.fromCharCode(...s),index:n}}else if(9===e){s.push(32);continue}s.push(e)}}(t,e+1,r);if(!s)return;let i=s.data;const o=s.index,a=i.search(/\s/);let l=i,c=!0;-1!==a&&(l=i.substring(0,a),i=i.substring(a+1).trimStart());const u=l;if(n){const t=l.indexOf(":");-1!==t&&(l=l.substr(t+1),c=l!==s.data.substr(t+1))}return{tagName:l,tagExp:i,closeIndex:o,attrExpPresent:c,rawTagName:u}}function Bn(t,e,n){const r=n;let s=1;const i=t.length;for(;n<i;n++)if("<"===t[n]){const i=t.charCodeAt(n+1);if(47===i){const i=kn(t,">",n,`${e} is not closed`);if(t.substring(n+2,i).trim()===e&&(s--,0===s))return{tagContent:t.substring(r,n),i};n=i}else if(63===i)n=Un(t,"?>",n+1,"StopNode is not closed.");else if(33===i&&45===t.charCodeAt(n+2)&&45===t.charCodeAt(n+3))n=Un(t,"--\x3e",n+3,"StopNode is not closed.");else if(33===i&&91===t.charCodeAt(n+2))n=Un(t,"]]>",n,"StopNode is not closed.")-2;else{const r=Fn(t,n,">");r&&((r&&r.tagName)===e&&"/"!==r.tagExp[r.tagExp.length-1]&&s++,n=r.closeIndex)}}}function Mn(t,e,n){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&function(t,e={}){if(e=Object.assign({},on,e),!t||"string"!=typeof t)return t;let n=t.trim();if(0===n.length)return t;if(void 0!==e.skipLike&&e.skipLike.test(n))return t;if("0"===n)return 0;if(e.hex&&rn.test(n))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(n);if(isFinite(n)){if(n.includes("e")||n.includes("E"))return function(t,e,n){if(!n.eNotation)return t;const r=e.match(an);if(r){let s=r[1]||"";const i=-1===r[3].indexOf("e")?"E":"e",o=r[2],a=s?t[o.length+1]===i:t[o.length]===i;return o.length>1&&a?t:(1!==o.length||!r[3].startsWith(`.${i}`)&&r[3][0]!==i)&&o.length>0?n.leadingZeros&&!a?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,n,e);{const s=sn.exec(n);if(s){const i=s[1]||"",o=s[2];let a=(r=s[3])&&-1!==r.indexOf(".")?("."===(r=r.replace(/0+$/,""))?r="0":"."===r[0]?r="0"+r:"."===r[r.length-1]&&(r=r.substring(0,r.length-1)),r):r;const l=i?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!l))return t;{const r=Number(n),s=String(r);if(0===r)return r;if(-1!==s.search(/[eE]/))return e.eNotation?r:t;if(-1!==n.indexOf("."))return"0"===s||s===a||s===`${i}${a}`?r:t;let l=o?a:n;return o?l===s||i+l===s?r:t:l===s||l===i+s?r:t}}return t}}var r;return function(t,e,n){const r=e===1/0;switch(n.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return r?"Infinity":"-Infinity";default:return t}}(t,Number(n),e)}(t,n)}return void 0!==t?t:""}function $n(t,e,n,r){if(t){const r=t(e);n===e&&(n=r),e=r}return{tagName:e=qn(e,r),tagExp:n}}function qn(t,e){if(Ae.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Oe.includes(t)?e.onDangerousProperty(t):t}const Vn=Ze.getMetaDataSymbol();function Wn(t,e){if(!t||"object"!=typeof t)return{};if(!e)return t;const n={};for(const r in t)r.startsWith(e)?n[r.substring(e.length)]=t[r]:n[r]=t[r];return n}function zn(t,e,n,r){return Jn(t,e,n,r)}function Jn(t,e,n,r){let s;const i={};for(let o=0;o<t.length;o++){const a=t[o],l=Hn(a);if(void 0!==l&&l!==e.textNodeName){const t=Wn(a[":@"]||{},e.attributeNamePrefix);n.push(l,t)}if(l===e.textNodeName)void 0===s?s=a[l]:s+=""+a[l];else{if(void 0===l)continue;if(a[l]){let t=Jn(a[l],e,n,r);const s=Xn(t,e);if(a[":@"]?Kn(t,a[":@"],r,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==a[Vn]&&"object"==typeof t&&null!==t&&(t[Vn]=a[Vn]),void 0!==i[l]&&Object.prototype.hasOwnProperty.call(i,l))Array.isArray(i[l])||(i[l]=[i[l]]),i[l].push(t);else{const n=e.jPath?r.toString():r;e.isArray(l,n,s)?i[l]=[t]:i[l]=t}void 0!==l&&l!==e.textNodeName&&n.pop()}}}return"string"==typeof s?s.length>0&&(i[e.textNodeName]=s):void 0!==s&&(i[e.textNodeName]=s),i}function Hn(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const n=e[t];if(":@"!==n)return n}}function Kn(t,e,n,r){if(e){const s=Object.keys(e),i=s.length;for(let o=0;o<i;o++){const i=s[o],a=i.startsWith(r.attributeNamePrefix)?i.substring(r.attributeNamePrefix.length):i,l=r.jPath?n.toString()+"."+a:n;r.isArray(i,l,!0,!0)?t[i]=[e[i]]:t[i]=e[i]}}}function Xn(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return 0===r||!(1!==r||!t[n]&&"boolean"!=typeof t[n]&&0!==t[n])}class Yn{constructor(t){this.externalEntities={},this.options=Ye(t)}parse(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});const n=Ce(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new Tn(this.options);n.entityReplacer.setExternalEntities(this.externalEntities);const r=n.parseXml(t);return this.options.preserveOrder||void 0===r?r:zn(r,this.options,n.matcher,n.readonlyMatcher)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return Ze.getMetaDataSymbol()}}const Gn=we.create({baseURL:r,timeout:3e4,maxRedirects:0});Gn.interceptors.request.use(t=>{const e=s(t.url);return e.pathname=e.pathname+".sitemap.xml",e.searchParams.set("_",Date.now()),t.url=e.toString(),t},t=>Promise.reject(t)),Gn.interceptors.response.use(t=>(t.data=Zn(t.data),t),t=>Promise.reject(t));const Zn=t=>{const e=ze.validate(t);if(!0!==e)throw new Error(e.err.msg);const n=(new Yn).parse(t),r=n.urlset?.url||[];return(Array.isArray(r)?r:[r]).filter(t=>t.loc).map(t=>({path:s(t.loc).pathname,lastmod:t.lastmod?new Date(t.lastmod).toISOString():null}))},Qn=Gn,tr=we.create({baseURL:r,timeout:5e3,maxRedirects:0});tr.interceptors.request.use(t=>{const e=s(t.url);return e.pathname=e.pathname+".html",e.searchParams.set("_",Date.now()),t.url=e.toString(),t},t=>Promise.reject(t));const er=tr,nr=we.create({baseURL:r,timeout:5e3,maxRedirects:0});nr.interceptors.request.use(t=>{const e=s(t.url);return e.pathname=e.pathname+"/_jcr_content.json",e.searchParams.set("_",Date.now()),t.url=e.toString(),t},t=>Promise.reject(t)),nr.interceptors.response.use(t=>(t.data=ir(t.data),t),t=>Promise.reject(t));const rr={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"};function sr(t){if(/^\d{4}-\d{2}-\d{2}$/.test(t))return new Date(t).toISOString();let e=/^\w{3} (\w{3}) (\d{2}) (\d{4}) ([\d:]{8}) GMT([\-+]\d{4})$/.exec(t);return e?new Date(`${e[3]}-${rr[e[1]]}-${e[2]}T${e[4]}${e[5]}`).toISOString():t}const ir=t=>{const e={};for(const[n,r]of Object.entries(t))n.endsWith("@TypeHint")||Array.isArray(r)&&0===r.length||("true"===r?e[n]=!0:"false"===r?e[n]=!1:"gcAltLanguagePeer"===n?(e[n]=r,e.peer=s(r).pathname):e[n]="string"==typeof r?sr(r.trim()):r);return Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})},or={normalize:s,request:ve,children:Qn,content:er,meta:nr};return e})());
|
package/package.json
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
2
|
+
"name": "canada-api",
|
|
3
|
+
"version": "5.0.1",
|
|
4
|
+
"description": "Cross platform API to fetch data from canada.ca",
|
|
5
|
+
"browser": "dist/ca.js",
|
|
6
|
+
"main": "src/index.mjs",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "node --test tests/**/*.test.mjs",
|
|
9
|
+
"build": "webpack",
|
|
10
|
+
"dev": "webpack --mode development"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/dnd-mdn/canada-api.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"canada",
|
|
18
|
+
"api",
|
|
19
|
+
"fetch"
|
|
20
|
+
],
|
|
21
|
+
"author": "National Defence",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"homepage": "https://github.com/dnd-mdn/canada-api#readme",
|
|
24
|
+
"bugs": "https://github.com/dnd-mdn/canada-api/issues",
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"webpack": "^5.105.4",
|
|
31
|
+
"webpack-cli": "^7.0.2"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"axios": "^1.15.0",
|
|
35
|
+
"fast-xml-parser": "^5.6.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/children.mjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
|
2
3
|
import normalize from "./normalize.mjs";
|
|
4
|
+
import { BASE_URL } from "./config.mjs";
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Axios instance configured for fetching sitemap URLs
|
|
8
|
+
* @type {import('axios').AxiosInstance}
|
|
9
|
+
* @description Returns normalized node list of sitemap children
|
|
10
|
+
*/
|
|
5
11
|
const children = axios.create({
|
|
6
|
-
baseURL:
|
|
12
|
+
baseURL: BASE_URL,
|
|
7
13
|
timeout: 30000,
|
|
8
14
|
maxRedirects: 0
|
|
9
15
|
});
|
|
@@ -14,7 +20,7 @@ children.interceptors.request.use(config => {
|
|
|
14
20
|
|
|
15
21
|
url.pathname = url.pathname + '.sitemap.xml';
|
|
16
22
|
url.searchParams.set('_', Date.now());
|
|
17
|
-
|
|
23
|
+
|
|
18
24
|
config.url = url.toString();
|
|
19
25
|
return config;
|
|
20
26
|
}, error => {
|
|
@@ -31,16 +37,31 @@ children.interceptors.response.use(response => {
|
|
|
31
37
|
});
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
40
|
+
* Represents a single URL entry from a sitemap
|
|
41
|
+
* @typedef {object} SitemapEntry
|
|
42
|
+
* @property {string} path - The normalized URL path (e.g., '/en/page')
|
|
43
|
+
* @property {string|null} lastmod - ISO 8601 timestamp or null if not present
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Parse XML sitemap data into structured URL entries
|
|
48
|
+
* @param {string} data - Raw XML sitemap content
|
|
49
|
+
* @returns {SitemapEntry[]} Array of sitemap entries with path and lastmod
|
|
50
|
+
* @throws {Error} If the XML is malformed or invalid
|
|
51
|
+
* @description Parses XML sitemap format and returns normalized entries with ISO timestamps.
|
|
52
|
+
* Entries missing a `<loc>` element are silently skipped.
|
|
37
53
|
*/
|
|
38
54
|
export const parseSitemap = (data) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
const validation = XMLValidator.validate(data);
|
|
56
|
+
if (validation !== true) throw new Error(validation.err.msg);
|
|
57
|
+
|
|
58
|
+
const parser = new XMLParser();
|
|
59
|
+
const result = parser.parse(data);
|
|
60
|
+
|
|
61
|
+
const urls = result.urlset?.url || [];
|
|
62
|
+
return (Array.isArray(urls) ? urls : [urls]).filter(item => item.loc).map(item => ({
|
|
63
|
+
path: normalize(item.loc).pathname,
|
|
64
|
+
lastmod: item.lastmod ? new Date(item.lastmod).toISOString() : null
|
|
44
65
|
}));
|
|
45
66
|
};
|
|
46
67
|
|
package/src/config.mjs
ADDED
package/src/content.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import normalize from "./normalize.mjs";
|
|
3
|
+
import { BASE_URL } from "./config.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Axios instance configured for fetching HTML content
|
|
7
|
+
* @type {import('axios').AxiosInstance}
|
|
8
|
+
* @description Returns raw HTML content
|
|
9
|
+
*/
|
|
5
10
|
const content = axios.create({
|
|
6
|
-
baseURL:
|
|
11
|
+
baseURL: BASE_URL,
|
|
7
12
|
timeout: 5000,
|
|
8
13
|
maxRedirects: 0
|
|
9
14
|
});
|
|
@@ -14,7 +19,7 @@ content.interceptors.request.use(config => {
|
|
|
14
19
|
|
|
15
20
|
url.pathname = url.pathname + '.html';
|
|
16
21
|
url.searchParams.set('_', Date.now());
|
|
17
|
-
|
|
22
|
+
|
|
18
23
|
config.url = url.toString();
|
|
19
24
|
return config;
|
|
20
25
|
}, error => {
|
package/src/index.mjs
CHANGED
|
@@ -4,6 +4,16 @@ import children from "./children.mjs";
|
|
|
4
4
|
import content from "./content.mjs";
|
|
5
5
|
import meta from "./meta.mjs";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Canada API - Cross-platform client for fetching and parsing canada.ca data
|
|
9
|
+
*
|
|
10
|
+
* @typedef {object} CanadaAPI
|
|
11
|
+
* @property {function} normalize - Normalize and validate canada.ca URLs
|
|
12
|
+
* @property {import('axios').AxiosInstance} request - Raw HTTP client for canada.ca requests
|
|
13
|
+
* @property {import('axios').AxiosInstance} children - Fetch and parse sitemap hierarchies
|
|
14
|
+
* @property {import('axios').AxiosInstance} content - Fetch HTML content pages
|
|
15
|
+
* @property {import('axios').AxiosInstance} meta - Fetch and format JCR metadata
|
|
16
|
+
*/
|
|
7
17
|
const ca = {
|
|
8
18
|
normalize,
|
|
9
19
|
request,
|
package/src/meta.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import normalize from "./normalize.mjs";
|
|
3
|
+
import { BASE_URL } from "./config.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Axios instance configured for fetching JCR metadata
|
|
7
|
+
* @type {import('axios').AxiosInstance}
|
|
8
|
+
* @description Returns formatted metadata
|
|
9
|
+
*/
|
|
5
10
|
const meta = axios.create({
|
|
6
|
-
baseURL:
|
|
11
|
+
baseURL: BASE_URL,
|
|
7
12
|
timeout: 5000,
|
|
8
13
|
maxRedirects: 0
|
|
9
14
|
});
|
|
@@ -14,7 +19,7 @@ meta.interceptors.request.use(config => {
|
|
|
14
19
|
|
|
15
20
|
url.pathname = url.pathname + '/_jcr_content.json';
|
|
16
21
|
url.searchParams.set('_', Date.now());
|
|
17
|
-
|
|
22
|
+
|
|
18
23
|
config.url = url.toString();
|
|
19
24
|
return config;
|
|
20
25
|
}, error => {
|
|
@@ -31,55 +36,80 @@ meta.interceptors.response.use(response => {
|
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @const {
|
|
39
|
+
* Month name to number mapping
|
|
40
|
+
* @const {Record<string, string>}
|
|
36
41
|
* @private
|
|
37
42
|
*/
|
|
38
43
|
const months = {
|
|
39
|
-
'Jan': '01',
|
|
40
|
-
'
|
|
44
|
+
'Jan': '01',
|
|
45
|
+
'Feb': '02',
|
|
46
|
+
'Mar': '03',
|
|
47
|
+
'Apr': '04',
|
|
48
|
+
'May': '05',
|
|
49
|
+
'Jun': '06',
|
|
50
|
+
'Jul': '07',
|
|
51
|
+
'Aug': '08',
|
|
52
|
+
'Sep': '09',
|
|
53
|
+
'Oct': '10',
|
|
54
|
+
'Nov': '11',
|
|
55
|
+
'Dec': '12'
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
/**
|
|
44
|
-
* Try to format
|
|
45
|
-
* @param {string} text
|
|
46
|
-
* @returns {string}
|
|
59
|
+
* Try to parse and format date strings from JCR into ISO 8601
|
|
60
|
+
* @param {string} text - Potential date string to format
|
|
61
|
+
* @returns {string} ISO 8601 timestamp or original text if not a recognized date
|
|
62
|
+
* @description Supports YYYY-MM-DD and JCR date format (e.g. "Wed Nov 20 2019 13:17:13 GMT-0500").
|
|
63
|
+
* Uses explicit parsing to ensure consistent output across Node.js and browsers.
|
|
47
64
|
* @private
|
|
48
65
|
*/
|
|
49
66
|
function formatDate(text) {
|
|
50
|
-
// Simple
|
|
67
|
+
// Simple YYYY-MM-DD format
|
|
51
68
|
if (/^\d{4}-\d{2}-\d{2}$/.test(text)) {
|
|
52
69
|
return new Date(text).toISOString()
|
|
53
70
|
}
|
|
54
71
|
|
|
55
|
-
// RFC1123
|
|
72
|
+
// RFC1123 format
|
|
56
73
|
let m = /^\w{3} (\w{3}) (\d{2}) (\d{4}) ([\d:]{8}) GMT([\-+]\d{4})$/.exec(text)
|
|
57
74
|
if (m) {
|
|
58
|
-
return new Date(m[3]
|
|
75
|
+
return new Date(`${m[3]}-${months[m[1]]}-${m[2]}T${m[4]}${m[5]}`).toISOString()
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
return text
|
|
62
79
|
}
|
|
63
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Format and normalize metadata object
|
|
83
|
+
* @param {Record<string, any>} data - Raw metadata object from JCR
|
|
84
|
+
* @returns {Record<string, any>} Formatted metadata with normalized types and sorted keys
|
|
85
|
+
* @description Converts string booleans to native booleans, formats dates to ISO 8601,
|
|
86
|
+
* removes @TypeHint properties and empty arrays, sorts keys alphabetically, and adds a
|
|
87
|
+
* normalized `peer` field when `gcAltLanguagePeer` is present.
|
|
88
|
+
*/
|
|
64
89
|
export const formatMeta = (data) => {
|
|
65
|
-
|
|
90
|
+
const result = {}
|
|
91
|
+
|
|
66
92
|
for (const [key, value] of Object.entries(data)) {
|
|
93
|
+
if (key.endsWith('@TypeHint')) continue
|
|
94
|
+
if (Array.isArray(value) && value.length === 0) continue
|
|
95
|
+
|
|
67
96
|
if (value === 'true') {
|
|
68
|
-
|
|
97
|
+
result[key] = true
|
|
69
98
|
} else if (value === 'false') {
|
|
70
|
-
|
|
71
|
-
} else if (key
|
|
72
|
-
|
|
99
|
+
result[key] = false
|
|
100
|
+
} else if (key === 'gcAltLanguagePeer') {
|
|
101
|
+
result[key] = value
|
|
102
|
+
result['peer'] = normalize(value).pathname
|
|
73
103
|
} else if (typeof value === 'string') {
|
|
74
|
-
|
|
75
|
-
} else
|
|
76
|
-
|
|
104
|
+
result[key] = formatDate(value.trim())
|
|
105
|
+
} else {
|
|
106
|
+
result[key] = value
|
|
77
107
|
}
|
|
78
108
|
}
|
|
79
|
-
|
|
109
|
+
|
|
80
110
|
// Sort object keys alphabetically for readability
|
|
81
|
-
return Object.keys(
|
|
82
|
-
obj[key] =
|
|
111
|
+
return Object.keys(result).sort().reduce((obj, key) => {
|
|
112
|
+
obj[key] = result[key]
|
|
83
113
|
return obj
|
|
84
114
|
}, {})
|
|
85
115
|
}
|
package/src/normalize.mjs
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
|
|
2
|
+
import { BASE_URL } from './config.mjs';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
|
-
* Normalize
|
|
4
|
-
* @param {string|URL} url
|
|
5
|
-
* @returns {URL}
|
|
5
|
+
* Normalize a canada.ca URL to a clean pathname
|
|
6
|
+
* @param {string|URL} url - A full URL or relative path (e.g., 'https://www.canada.ca/en/page' or '/en/page')
|
|
7
|
+
* @returns {URL} Normalized URL object with cleaned pathname
|
|
8
|
+
* @throws {TypeError} If url is not a string or URL object
|
|
9
|
+
* @throws {Error} If URL is not from canada.ca or path doesn't start with /en/ or /fr/
|
|
6
10
|
*/
|
|
7
11
|
const normalize = (url) => {
|
|
8
12
|
|
|
9
13
|
if (typeof url === 'string') {
|
|
10
|
-
url = new URL(url,
|
|
14
|
+
url = new URL(url, BASE_URL)
|
|
11
15
|
} else if (!(url instanceof URL)) {
|
|
12
16
|
throw new TypeError('string or URL object expected')
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
// Verify domain
|
|
16
|
-
if (url.origin !==
|
|
17
|
-
throw new Error('URL must start with ' +
|
|
20
|
+
if (url.origin !== BASE_URL) {
|
|
21
|
+
throw new Error('URL must start with ' + BASE_URL)
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
url.pathname = url.pathname.replace(/^\/content\/canadasite/, '');
|
|
21
25
|
|
|
22
|
-
//
|
|
26
|
+
// Remove file extensions (like .html, .xml) and trailing slashes
|
|
27
|
+
url.pathname = url.pathname.replace(/\.[^/]*$/, '').replace(/\/+$/, '');
|
|
28
|
+
|
|
29
|
+
// Verify root language
|
|
23
30
|
if (!url.pathname.startsWith('/en/') && !url.pathname.startsWith('/fr/')) {
|
|
24
|
-
throw new Error(
|
|
31
|
+
throw new Error(`Invalid path: "${url.pathname}" must start with /en/ or /fr/`)
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
// Strip extension and trailing slashes
|
|
28
|
-
url.pathname = url.pathname.replace(/(\.[^/]+|\/+)$/, '')
|
|
29
|
-
|
|
30
34
|
return url
|
|
31
35
|
}
|
|
32
36
|
|
package/src/request.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { BASE_URL } from "./config.mjs";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Axios instance configured for raw requests to canada.ca
|
|
6
|
+
* @type {import('axios').AxiosInstance}
|
|
7
|
+
* @description Base HTTP client for making raw requests.
|
|
8
|
+
*/
|
|
4
9
|
const request = axios.create({
|
|
5
|
-
baseURL:
|
|
10
|
+
baseURL: BASE_URL,
|
|
6
11
|
timeout: 30000
|
|
7
12
|
});
|
|
8
13
|
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
([Français](#comment-contribuer))
|
|
2
|
-
|
|
3
|
-
# How to Contribute
|
|
4
|
-
|
|
5
|
-
When contributing, post comments and discuss changes you wish to make via Issues.
|
|
6
|
-
|
|
7
|
-
Feel free to propose changes by creating Pull Requests. If you don't have write access, editing a file will create a Fork of this project for you to save your proposed changes to. Submitting a change to a file will write it to a new Branch in your Fork, so you can send a Pull Request.
|
|
8
|
-
|
|
9
|
-
If this is your first time contributing on GitHub, don't worry! Let us know if you have any questions.
|
|
10
|
-
|
|
11
|
-
______________________
|
|
12
|
-
|
|
13
|
-
## Comment contribuer
|
|
14
|
-
|
|
15
|
-
Lorsque vous contribuez, veuillez également publier des commentaires et discuter des modifications que vous souhaitez apporter par l'entremise des enjeux (Issues).
|
|
16
|
-
|
|
17
|
-
N'hésitez pas à proposer des modifications en créant des demandes de tirage (Pull Requests). Si vous n'avez pas accès au mode de rédaction, la modification d'un fichier créera une copie (Fork) de ce projet afin que vous puissiez enregistrer les modifications que vous proposez. Le fait de proposer une modification à un fichier l'écrira dans une nouvelle branche dans votre copie (Fork), de sorte que vous puissiez envoyer une demande de tirage (Pull Request).
|
|
18
|
-
|
|
19
|
-
Si c'est la première fois que vous contribuez à GitHub, ne vous en faites pas! Faites-nous part de vos questions.
|
package/webpack.config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
mode: 'production',
|
|
5
|
-
entry: './src/index.mjs',
|
|
6
|
-
output: {
|
|
7
|
-
path: path.resolve(__dirname, './dist/'),
|
|
8
|
-
filename: 'ca.js',
|
|
9
|
-
library: {
|
|
10
|
-
name: 'ca',
|
|
11
|
-
type: 'umd',
|
|
12
|
-
umdNamedDefine: true
|
|
13
|
-
},
|
|
14
|
-
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
|
15
|
-
clean: true
|
|
16
|
-
},
|
|
17
|
-
devtool: false
|
|
18
|
-
}
|