ofsc-utility-browser 1.0.21 → 1.0.23

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.
@@ -0,0 +1,156 @@
1
+ import { fetchWithRetry } from "../utilities";
2
+ export * from "./activityType";
3
+ export * from "./activityTypeGroup";
4
+ export * from "./resourceTypes";
5
+ /**
6
+ * Fetches all proeprties from the OFSC instance.
7
+ *
8
+ * @param {string} clientId - The OFSC client ID.
9
+ * @param {string} clientSecret - The OFSC client secret.
10
+ * @param {string} instanceUrl - The OFSC instance URL.
11
+ * @param {string} [initialToken] - The OAuth token to use. If not provided, a new token will be fetched.
12
+ *
13
+ * @returns {Promise<any[]>} A promise which resolves to an array of resource objects.
14
+ */
15
+ export async function AllProperties(clientId, clientSecret, instanceUrl, initialToken = "") {
16
+ /**
17
+ * The number of API calls made so far.
18
+ * Used to determine if we should wait 10 seconds to avoid server rate limits.
19
+ */
20
+ let apiCallCount = 0;
21
+ /**
22
+ * The number of API calls after which we should wait 10 seconds.
23
+ */
24
+ const WAIT_AFTER_CALLS = 20;
25
+ /**
26
+ * The delay in milliseconds to wait after reaching the API call limit.
27
+ */
28
+ const DELAY_MS = 10000; // 10 seconds
29
+ /**
30
+ * Sleeps for the given amount of milliseconds.
31
+ *
32
+ * @param {number} ms - The amount of milliseconds to sleep.
33
+ * @returns {Promise<void>} A promise which resolves when the sleep is over.
34
+ */
35
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
36
+ /**
37
+ * Fetches resources from the OFSC instance.
38
+ *
39
+ * @param {number} offset - The offset from which to fetch resources.
40
+ * @param {string} token - The OAuth token to use.
41
+ * @returns {Promise<Response[]>} A promise which resolves to an array of resource responses.
42
+ */
43
+ const AllProperties = async (offset, token) => {
44
+ apiCallCount++;
45
+ // Wait 10 seconds after 20 API calls to avoid server rate limits.
46
+ if (apiCallCount % WAIT_AFTER_CALLS === 0) {
47
+ console.warn(` Waiting 10 seconds after ${apiCallCount} API calls to avoid server rate limits.`);
48
+ await sleep(DELAY_MS);
49
+ }
50
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/properties/?offset=${offset}&limit=100`;
51
+ const res = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
52
+ const { items, totalResults } = res.data;
53
+ const totalFetched = items.length;
54
+ console.log(`Received ${totalFetched} items (Total: ${offset + totalFetched})`);
55
+ if (offset + totalFetched >= totalResults) {
56
+ return items;
57
+ }
58
+ const nextItems = await AllProperties(offset + totalFetched, res.token);
59
+ return [...items, ...nextItems];
60
+ };
61
+ return AllProperties(0, initialToken);
62
+ }
63
+ export async function compareProperties(propEnv1, propEnv2, e1Instance, e2Instance) {
64
+ const errors = [];
65
+ const env2Map = new Map(propEnv2.map(p => [p.label, p]));
66
+ for (const prop1 of propEnv1) {
67
+ const prop2 = env2Map.get(prop1.label);
68
+ if (!prop2) {
69
+ errors.push({
70
+ label: prop1.label,
71
+ message: `Missing in ${e2Instance}`,
72
+ env1Value: prop1.label, // prop1
73
+ });
74
+ continue;
75
+ }
76
+ // Primitive fields comparison
77
+ const fields = ["name", "type", "entity", "gui"];
78
+ for (const field of fields) {
79
+ if (prop1[field] !== prop2[field]) {
80
+ errors.push({
81
+ label: prop1.label,
82
+ field,
83
+ message: `${field} mismatch`,
84
+ env1Value: prop1[field],
85
+ env2Value: prop2[field],
86
+ env1Instance: e1Instance,
87
+ env2Instance: e2Instance
88
+ });
89
+ }
90
+ }
91
+ // Translations comparison
92
+ const tMap = new Map(prop2.translations.map(t => [t.languageISO, t]));
93
+ for (const t1 of prop1.translations) {
94
+ const t2 = tMap.get(t1.languageISO);
95
+ if (!t2) {
96
+ errors.push({
97
+ label: prop1.label,
98
+ field: "translations",
99
+ message: `Translation missing in ${e2Instance} - (${t1.languageISO})`,
100
+ env1Value: t1
101
+ });
102
+ continue;
103
+ }
104
+ if (t1.name !== t2.name) {
105
+ errors.push({
106
+ label: prop1.label,
107
+ field: `translations.name[${t1.languageISO}]`,
108
+ message: `Translation name mismatch`,
109
+ env1Value: t1.name,
110
+ env2Value: t2.name,
111
+ env1Instance: e1Instance,
112
+ env2Instance: e2Instance
113
+ });
114
+ }
115
+ if (t1.language !== t2.language) {
116
+ errors.push({
117
+ label: prop1.label,
118
+ field: `translations.language[${t1.languageISO}]`,
119
+ message: `Translation language mismatch`,
120
+ env1Value: t1.language,
121
+ env2Value: t2.language,
122
+ env1Instance: e1Instance,
123
+ env2Instance: e2Instance
124
+ });
125
+ }
126
+ }
127
+ // Missing translations in env1
128
+ const env1LangSet = new Set(prop1.translations.map(t => t.languageISO));
129
+ for (const t2 of prop2.translations) {
130
+ if (!env1LangSet.has(t2.languageISO)) {
131
+ errors.push({
132
+ label: prop1.label,
133
+ field: "translations",
134
+ message: `Translation missing in ${e1Instance} - (${t2.languageISO})`,
135
+ env2Value: t2,
136
+ env1Instance: e1Instance,
137
+ env2Instance: e2Instance
138
+ });
139
+ }
140
+ }
141
+ }
142
+ // Missing properties in env1
143
+ const env1Labels = new Set(propEnv1.map(p => p.label));
144
+ for (const prop2 of propEnv2) {
145
+ if (!env1Labels.has(prop2.label)) {
146
+ errors.push({
147
+ label: prop2.label,
148
+ message: `Missing in ${e1Instance}`,
149
+ env2Value: prop2.label,
150
+ env1Instance: e1Instance,
151
+ env2Instance: e2Instance
152
+ });
153
+ }
154
+ }
155
+ return errors;
156
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Fetches all proeprties from the OFSC instance.
3
+ *
4
+ * @param {string} clientId - The OFSC client ID.
5
+ * @param {string} clientSecret - The OFSC client secret.
6
+ * @param {string} instanceUrl - The OFSC instance URL.
7
+ * @param {string} [initialToken] - The OAuth token to use. If not provided, a new token will be fetched.
8
+ *
9
+ * @returns {Promise<any[]>} A promise which resolves to an array of resource objects.
10
+ */
11
+ export declare function AllResourceType(clientId: string, clientSecret: string, instanceUrl: string, initialToken?: string): Promise<any[]>;
12
+ type Translation = {
13
+ language: string;
14
+ name: string;
15
+ languageISO: string;
16
+ };
17
+ type ResourceType = {
18
+ label: string;
19
+ name: string;
20
+ active: boolean;
21
+ role: string;
22
+ translations?: Translation[];
23
+ };
24
+ type CompareError = {
25
+ label: string;
26
+ field?: string;
27
+ message: string;
28
+ env1Value?: any;
29
+ env2Value?: any;
30
+ env1Instance?: string;
31
+ env2Instance?: string;
32
+ };
33
+ export declare function deepCompareResourceTypes(env1: ResourceType[], env2: ResourceType[], e1Instance: string, e2Instance: string): CompareError[];
34
+ export {};
@@ -0,0 +1,161 @@
1
+ import { fetchWithRetry } from "../utilities";
2
+ /**
3
+ * Fetches all proeprties from the OFSC instance.
4
+ *
5
+ * @param {string} clientId - The OFSC client ID.
6
+ * @param {string} clientSecret - The OFSC client secret.
7
+ * @param {string} instanceUrl - The OFSC instance URL.
8
+ * @param {string} [initialToken] - The OAuth token to use. If not provided, a new token will be fetched.
9
+ *
10
+ * @returns {Promise<any[]>} A promise which resolves to an array of resource objects.
11
+ */
12
+ export async function AllResourceType(clientId, clientSecret, instanceUrl, initialToken = "") {
13
+ /**
14
+ * The number of API calls made so far.
15
+ * Used to determine if we should wait 10 seconds to avoid server rate limits.
16
+ */
17
+ let apiCallCount = 0;
18
+ /**
19
+ * The number of API calls after which we should wait 10 seconds.
20
+ */
21
+ const WAIT_AFTER_CALLS = 20;
22
+ /**
23
+ * The delay in milliseconds to wait after reaching the API call limit.
24
+ */
25
+ const DELAY_MS = 10000; // 10 seconds
26
+ /**
27
+ * Sleeps for the given amount of milliseconds.
28
+ *
29
+ * @param {number} ms - The amount of milliseconds to sleep.
30
+ * @returns {Promise<void>} A promise which resolves when the sleep is over.
31
+ */
32
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
33
+ /**
34
+ * Fetches resources from the OFSC instance.
35
+ *
36
+ * @param {number} offset - The offset from which to fetch resources.
37
+ * @param {string} token - The OAuth token to use.
38
+ * @returns {Promise<Response[]>} A promise which resolves to an array of resource responses.
39
+ */
40
+ const AllResourceType = async (offset, token) => {
41
+ apiCallCount++;
42
+ // Wait 10 seconds after 20 API calls to avoid server rate limits.
43
+ if (apiCallCount % WAIT_AFTER_CALLS === 0) {
44
+ console.warn(` Waiting 10 seconds after ${apiCallCount} API calls to avoid server rate limits.`);
45
+ await sleep(DELAY_MS);
46
+ }
47
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/resourceTypes?offset=${offset}&limit=100`;
48
+ const res = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
49
+ const { items, totalResults } = res.data;
50
+ const totalFetched = items.length;
51
+ console.log(`Received ${totalFetched} items (Total: ${offset + totalFetched})`);
52
+ if (offset + totalFetched >= totalResults) {
53
+ return items;
54
+ }
55
+ const nextItems = await AllResourceType(offset + totalFetched, res.token);
56
+ return [...items, ...nextItems];
57
+ };
58
+ return AllResourceType(0, initialToken);
59
+ }
60
+ export function deepCompareResourceTypes(env1, env2, e1Instance, e2Instance) {
61
+ var _a, _b;
62
+ const errors = [];
63
+ const env2Map = new Map(env2.map(e => [e.label, e]));
64
+ const env1Map = new Map(env1.map(e => [e.label, e]));
65
+ // ---- compare env1 → env2 ----
66
+ for (const r1 of env1) {
67
+ const r2 = env2Map.get(r1.label);
68
+ if (!r2) {
69
+ errors.push({
70
+ label: r1.label,
71
+ message: "Missing in env2",
72
+ env1Value: r1,
73
+ env1Instance: e1Instance,
74
+ env2Instance: e2Instance
75
+ });
76
+ continue;
77
+ }
78
+ // ---- primitive fields ----
79
+ const fields = ["name", "active", "role"];
80
+ for (const field of fields) {
81
+ if (r1[field] !== r2[field]) {
82
+ errors.push({
83
+ label: r1.label,
84
+ field: String(field),
85
+ message: `${field} mismatch`,
86
+ env1Value: r1[field],
87
+ env2Value: r2[field],
88
+ env1Instance: e1Instance,
89
+ env2Instance: e2Instance
90
+ });
91
+ }
92
+ }
93
+ // ---- translations ----
94
+ const t1 = (_a = r1.translations) !== null && _a !== void 0 ? _a : [];
95
+ const t2 = (_b = r2.translations) !== null && _b !== void 0 ? _b : [];
96
+ const t2Map = new Map(t2.map(t => [t.languageISO, t]));
97
+ const t1Set = new Set(t1.map(t => t.languageISO));
98
+ for (const tr1 of t1) {
99
+ const tr2 = t2Map.get(tr1.languageISO);
100
+ if (!tr2) {
101
+ errors.push({
102
+ label: r1.label,
103
+ field: "translations",
104
+ message: `Missing translation in env2 (${tr1.languageISO})`,
105
+ env1Value: tr1,
106
+ env1Instance: e1Instance,
107
+ env2Instance: e2Instance
108
+ });
109
+ continue;
110
+ }
111
+ if (tr1.name !== tr2.name) {
112
+ errors.push({
113
+ label: r1.label,
114
+ field: `translations.name[${tr1.languageISO}]`,
115
+ message: "Translation name mismatch",
116
+ env1Value: tr1.name,
117
+ env2Value: tr2.name,
118
+ env1Instance: e1Instance,
119
+ env2Instance: e2Instance
120
+ });
121
+ }
122
+ if (tr1.language !== tr2.language) {
123
+ errors.push({
124
+ label: r1.label,
125
+ field: `translations.language[${tr1.languageISO}]`,
126
+ message: "Translation language mismatch",
127
+ env1Value: tr1.language,
128
+ env2Value: tr2.language,
129
+ env1Instance: e1Instance,
130
+ env2Instance: e2Instance
131
+ });
132
+ }
133
+ }
134
+ // ---- missing translations in env1 ----
135
+ for (const tr2 of t2) {
136
+ if (!t1Set.has(tr2.languageISO)) {
137
+ errors.push({
138
+ label: r1.label,
139
+ field: "translations",
140
+ message: `Missing translation in env1 (${tr2.languageISO})`,
141
+ env2Value: tr2,
142
+ env1Instance: e1Instance,
143
+ env2Instance: e2Instance
144
+ });
145
+ }
146
+ }
147
+ }
148
+ // ---- missing in env1 ----
149
+ for (const r2 of env2) {
150
+ if (!env1Map.has(r2.label)) {
151
+ errors.push({
152
+ label: r2.label,
153
+ message: "Missing in env1",
154
+ env2Value: r2,
155
+ env1Instance: e1Instance,
156
+ env2Instance: e2Instance
157
+ });
158
+ }
159
+ }
160
+ return errors;
161
+ }
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,o={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},a=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(r,{method:"POST",headers:o,body:a});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return(await e.json()).access_token}catch(e){throw console.error("Error fetching OAuth token:",e),e}}var n,r=Object.freeze({__proto__:null,getOAuthToken:t}),o={},a={};var i,s={};function c(){if(i)return s;i=1;var e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),n=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$");function r(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,r)}function o(){}function a(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function c(e,t,n,r,o,a){function i(e,t,r){e in n.attributeNames&&a.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,c=++t,u=0;;){var l=e.charAt(c);switch(l){case"=":if(1===u)s=e.slice(t,c),u=3;else{if(2!==u)throw new Error("attribute equal must after attrName");u=3}break;case"'":case'"':if(3===u||1===u){if(1===u&&(a.warning('attribute value must after "="'),s=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");i(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t-1),u=5}else{if(4!=u)throw new Error('attribute value must after "="');i(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t),a.warning('attribute "'+s+'" missed start quot('+l+")!!"),t=c+1,u=5}break;case"/":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:u=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return a.error("unexpected end of input"),0==u&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,c)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===u&&(d=s),4==u?(a.warning('attribute "'+d+'" missed quot(")!'),i(s,d.replace(/&#?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||a.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),i(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return c;case"€":l=" ";default:if(l<=" ")switch(u){case 0:n.setTagName(e.slice(t,c)),u=6;break;case 1:s=e.slice(t,c),u=2;break;case 4:var d=e.slice(t,c).replace(/&#?\w+;/g,o);a.warning('attribute "'+d+'" missed quot(")!!'),i(s,d,t);case 5:u=6}else switch(u){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||a.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),i(s,s,t),t=c,u=1;break;case 5:a.warning('attribute space is required"'+s+'"!!');case 6:u=1,t=c;break;case 3:u=4,t=c;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function u(e,t,n){for(var r=e.tagName,o=null,a=e.length;a--;){var i=e[a],s=i.qName,c=i.value;if((m=s.indexOf(":"))>0)var u=i.prefix=s.slice(0,m),l=s.slice(m+1),d="xmlns"===u&&l;else l=s,u=null,d="xmlns"===s&&"";i.localName=l,!1!==d&&(null==o&&(o={},f(n,n={})),n[d]=o[d]=c,i.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(a=e.length;a--;){(u=(i=e[a]).prefix)&&("xml"===u&&(i.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(i.uri=n[u||""]))}var m;(m=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,m),l=e.localName=r.slice(m+1)):(u=null,l=e.localName=r);var h=e.uri=n[u||""];if(t.startElement(h,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(h,l,r),o)for(u in o)t.endPrefixMapping(u)}function l(e,t,n,r,o){if(/^(?:script|textarea)$/i.test(n)){var a=e.indexOf("</"+n+">",t),i=e.substring(t+1,a);if(/[&<]/.test(i))return/^script$/i.test(n)?(o.characters(i,0,i.length),a):(i=i.replace(/&#?\w+;/g,r),o.characters(i,0,i.length),a)}return t+1}function d(e,t,n,r){var o=r[n];return null==o&&((o=e.lastIndexOf("</"+n+">"))<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function f(e,t){for(var n in e)t[n]=e[n]}function m(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(o=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,o-t-4),o+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var o=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var a=function(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;o.lastIndex=t,o.exec(e);for(;n=o.exec(e);)if(r.push(n),n[1])return r}(e,t),i=a.length;if(i>1&&/!doctype/i.test(a[0][0])){var s=a[1][0],c=!1,u=!1;i>3&&(/^public$/i.test(a[2][0])?(c=a[3][0],u=i>4&&a[4][0]):/^system$/i.test(a[2][0])&&(u=a[3][0]));var l=a[i-1];return n.startDTD(s,c,u),n.endDTD(),l.index+l[0].length}return-1}function h(e,t,n){var r=e.indexOf("?>",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return o?(o[0].length,n.processingInstruction(o[1],o[2]),r+2):-1}return-1}function p(){this.attributeNames={}}return r.prototype=new Error,r.prototype.name=r.name,o.prototype={parse:function(e,t,n){var o=this.domBuilder;o.startDocument(),f(t,t={}),function(e,t,n,o,i){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function f(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(i.error("entity not found:"+e),e)}function g(t){if(t>D){var n=e.substring(D,t).replace(/&#?\w+;/g,f);y&&w(D),o.characters(n,0,t-D),D=t}}function w(t,n){for(;t>=N&&(n=b.exec(e));)v=n.index,N=v+n[0].length,y.lineNumber++;y.columnNumber=t-v+1}var v=0,N=0,b=/.*(?:\r\n?|\n)|.*$/g,y=o.locator,E=[{currentNSMap:t}],T={},D=0;for(;;){try{var S=e.indexOf("<",D);if(S<0){if(!e.substr(D).match(/^\s*$/)){var x=o.doc,A=x.createTextNode(e.substr(D));x.appendChild(A),o.currentElement=A}return}switch(S>D&&g(S),e.charAt(S+1)){case"/":var _=e.indexOf(">",S+3),C=e.substring(S+2,_),I=E.pop();_<0?(C=e.substring(S+2).replace(/[\s<].*/,""),i.error("end tag name: "+C+" is not complete:"+I.tagName),_=S+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),i.error("end tag name: "+C+" maybe not complete"),_=S+1+C.length);var R=I.localNSMap,$=I.tagName==C;if($||I.tagName&&I.tagName.toLowerCase()==C.toLowerCase()){if(o.endElement(I.uri,I.localName,C),R)for(var O in R)o.endPrefixMapping(O);$||i.fatalError("end tag name: "+C+" is not match the current start tagName:"+I.tagName)}else E.push(I);_++;break;case"?":y&&w(S),_=h(e,S,o);break;case"!":y&&w(S),_=m(e,S,o,i);break;default:y&&w(S);var k=new p,P=E[E.length-1].currentNSMap,M=(_=c(e,S,k,P,f,i),k.length);if(!k.closed&&d(e,_,k.tagName,T)&&(k.closed=!0,n.nbsp||i.warning("unclosed xml attribute")),y&&M){for(var U=a(y,{}),F=0;F<M;F++){var j=k[F];w(j.offset),j.locator=a(y,{})}o.locator=U,u(k,o,P)&&E.push(k),o.locator=y}else u(k,o,P)&&E.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?_++:_=l(e,_,k.tagName,f,o)}}catch(e){if(e instanceof r)throw e;i.error("element parse error: "+e),_=-1}_>D?D=_:g(Math.max(S,D)+1)}}(e,t,n,o,this.errorHandler),o.endDocument()}},p.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},s.XMLReader=o,s.ParseError=r,s}var u,l,d={};function f(){if(u)return d;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var r=t.prototype;if(!(r instanceof n)){function o(){}o.prototype=n.prototype,e(r,o=new o),t.prototype=r=o}r.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),r.constructor=t)}u=1;var n={},r=n.ELEMENT_NODE=1,o=n.ATTRIBUTE_NODE=2,a=n.TEXT_NODE=3,i=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,c=n.ENTITY_NODE=6,l=n.PROCESSING_INSTRUCTION_NODE=7,f=n.COMMENT_NODE=8,m=n.DOCUMENT_NODE=9,h=n.DOCUMENT_TYPE_NODE=10,p=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,w={},v={};w.INDEX_SIZE_ERR=(v[1]="Index size error",1),w.DOMSTRING_SIZE_ERR=(v[2]="DOMString size error",2);var N=w.HIERARCHY_REQUEST_ERR=(v[3]="Hierarchy request error",3);w.WRONG_DOCUMENT_ERR=(v[4]="Wrong document",4),w.INVALID_CHARACTER_ERR=(v[5]="Invalid character",5),w.NO_DATA_ALLOWED_ERR=(v[6]="No data allowed",6),w.NO_MODIFICATION_ALLOWED_ERR=(v[7]="No modification allowed",7);var b=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var y=w.INUSE_ATTRIBUTE_ERR=(v[10]="Attribute in use",10);function E(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,v[e]),this.message=v[e],Error.captureStackTrace&&Error.captureStackTrace(this,E);return n.code=e,t&&(this.message=this.message+": "+t),n}function T(){}function D(e,t){this._node=e,this._refresh=t,S(this)}function S(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var r=t._refresh(t._node);re(t,"length",r.length),e(r,t),t._inc=n}}function x(){}function A(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function _(e,t,n,r){if(r?t[A(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var o=e.ownerDocument;o&&(r&&P(o,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(o,e,n))}}function C(e,t,n){var r=A(t,n);if(!(r>=0))throw E(b,new Error(e.tagName+"@"+n));for(var o=t.length-1;r<o;)t[r]=t[++r];if(t.length=o,e){var a=e.ownerDocument;a&&(P(a,e,n),n.ownerElement=null)}}function I(e){if(this._features={},e)for(var t in e)this._features=e[t]}function R(){}function $(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function O(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(O(e,t))return!0}while(e=e.nextSibling)}function k(){}function P(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function M(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var o=t.firstChild,a=0;o;)r[a++]=o,o=o.nextSibling;r.length=a}}}function U(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,M(e.ownerDocument,e),t}function F(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===p){var o=t.firstChild;if(null==o)return t;var a=t.lastChild}else o=a=t;var i=n?n.previousSibling:e.lastChild;o.previousSibling=i,a.nextSibling=n,i?i.nextSibling=o:e.firstChild=o,null==n?e.lastChild=a:n.previousSibling=a;do{o.parentNode=e}while(o!==a&&(o=o.nextSibling));return M(e.ownerDocument||e,e),t.nodeType==p&&(t.firstChild=t.lastChild=null),t}function j(){this._nsMap={}}function L(){}function B(){}function q(){}function z(){}function V(){}function H(){}function W(){}function Y(){}function X(){}function G(){}function Z(){}function J(){}function Q(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,o=r.prefix,a=r.namespaceURI;if(a&&null==o&&null==(o=r.lookupPrefix(a)))var i=[{namespace:a,prefix:null}];return ee(this,n,e,t,i),n.join("")}function K(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!r&&!o)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===o||"http://www.w3.org/2000/xmlns/"==o)return!1;for(var a=n.length;a--;){var i=n[a];if(i.prefix==r)return i.namespace!=o}return!0}function ee(e,t,n,c,u){if(c){if(!(e=c(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case r:u||(u=[]),u.length;var d=e.attributes,g=d.length,w=e.firstChild,v=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",v);for(var N=0;N<g;N++){"xmlns"==(b=d.item(N)).prefix?u.push({prefix:b.localName,namespace:b.value}):"xmlns"==b.nodeName&&u.push({prefix:"",namespace:b.value})}for(N=0;N<g;N++){var b;if(K(b=d.item(N),0,u)){var y=b.prefix||"",E=b.namespaceURI,T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}ee(b,t,n,c,u)}if(K(e,0,u)){y=e.prefix||"";if(E=e.namespaceURI){T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}}if(w||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(v)){if(t.push(">"),n&&/^script$/i.test(v))for(;w;)w.data?t.push(w.data):ee(w,t,n,c,u),w=w.nextSibling;else for(;w;)ee(w,t,n,c,u),w=w.nextSibling;t.push("</",v,">")}else t.push("/>");return;case m:case p:for(w=e.firstChild;w;)ee(w,t,n,c,u),w=w.nextSibling;return;case o:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,$),'"');case a:return t.push(e.data.replace(/[<&]/g,$).replace(/]]>/g,"]]&gt;"));case i:return t.push("<![CDATA[",e.data,"]]>");case f:return t.push("\x3c!--",e.data,"--\x3e");case h:var D=e.publicId,S=e.systemId;if(t.push("<!DOCTYPE ",e.name),D)t.push(" PUBLIC ",D),S&&"."!=S&&t.push(" ",S),t.push(">");else if(S&&"."!=S)t.push(" SYSTEM ",S,">");else{var x=e.internalSubset;x&&t.push(" [",x,"]"),t.push(">")}return;case l:return t.push("<?",e.target," ",e.data,"?>");case s:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,n){var a;switch(t.nodeType){case r:(a=t.cloneNode(!1)).ownerDocument=e;case p:break;case o:n=!0}if(a||(a=t.cloneNode(!1)),a.ownerDocument=e,a.parentNode=null,n)for(var i=t.firstChild;i;)a.appendChild(te(e,i,n)),i=i.nextSibling;return a}function ne(e,t,n){var a=new t.constructor;for(var i in t){var s=t[i];"object"!=typeof s&&s!=a[i]&&(a[i]=s)}switch(t.childNodes&&(a.childNodes=new T),a.ownerDocument=e,a.nodeType){case r:var c=t.attributes,u=a.attributes=new x,l=c.length;u._ownerElement=a;for(var d=0;d<l;d++)a.setAttributeNode(ne(e,c.item(d),!0));break;case o:n=!0}if(n)for(var f=t.firstChild;f;)a.appendChild(ne(e,f,n)),f=f.nextSibling;return a}function re(e,t,n){e[t]=n}w.INVALID_STATE_ERR=(v[11]="Invalid state",11),w.SYNTAX_ERR=(v[12]="Syntax error",12),w.INVALID_MODIFICATION_ERR=(v[13]="Invalid modification",13),w.NAMESPACE_ERR=(v[14]="Invalid namespace",14),w.INVALID_ACCESS_ERR=(v[15]="Invalid access",15),E.prototype=Error.prototype,e(w,E),T.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ee(this[r],n,e,t);return n.join("")}},D.prototype.item=function(e){return S(this),this[e]},t(D,T),x.prototype={length:0,item:T.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new E(y);var n=this.getNamedItem(e.nodeName);return _(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new E(y);return t=this.getNamedItemNS(e.namespaceURI,e.localName),_(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return C(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return C(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},I.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new k;if(r.implementation=this,r.childNodes=new T,r.doctype=n,n&&r.appendChild(n),t){var o=r.createElementNS(e,t);r.appendChild(o)}return r},createDocumentType:function(e,t,n){var r=new H;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},R.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return F(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return U(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ne(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==a&&e.nodeType==a?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,R),e(n,R.prototype),k.prototype={nodeName:"#document",nodeType:m,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==p){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&e.nodeType==r&&(this.documentElement=e),F(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),U(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return O(this.documentElement,function(n){if(n.nodeType==r&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new D(this,function(e){var n=[];return O(e.documentElement,function(o){o!==e&&o.nodeType==r&&t.test(o.getAttribute("class"))&&n.push(o)}),n})},createElement:function(e){var t=new j;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new T,(t.attributes=new x)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new T,e},createTextNode:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Z;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new L;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new X;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new j,r=t.split(":"),o=n.attributes=new x;return n.childNodes=new T,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,o._ownerElement=n,n},createAttributeNS:function(e,t){var n=new L,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},t(k,R),j.prototype={nodeType:r,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===p?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,M(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new D(this,function(t){var n=[];return O(t,function(o){o===t||o.nodeType!=r||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new D(this,function(n){var o=[];return O(n,function(a){a===n||a.nodeType!==r||"*"!==e&&a.namespaceURI!==e||"*"!==t&&a.localName!=t||o.push(a)}),o})}},k.prototype.getElementsByTagName=j.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=j.prototype.getElementsByTagNameNS,t(j,R),L.prototype.nodeType=o,t(L,R),B.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(v[N])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},t(B,R),q.prototype={nodeName:"#text",nodeType:a,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},t(q,B),z.prototype={nodeName:"#comment",nodeType:f},t(z,B),V.prototype={nodeName:"#cdata-section",nodeType:i},t(V,B),H.prototype.nodeType=h,t(H,R),W.prototype.nodeType=g,t(W,R),Y.prototype.nodeType=c,t(Y,R),X.prototype.nodeType=s,t(X,R),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=p,t(G,R),Z.prototype.nodeType=l,t(Z,R),J.prototype.serializeToString=function(e,t,n){return Q.call(e,t,n)},R.prototype.toString=Q;try{if(Object.defineProperty){function oe(e){switch(e.nodeType){case r:case p:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(oe(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(D.prototype,"length",{get:function(){return S(this),this.$$length}}),Object.defineProperty(R.prototype,"textContent",{get:function(){return oe(this)},set:function(e){switch(this.nodeType){case r:case p:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),re=function(e,t,n){e["$$"+t]=n}}}catch(ae){}return d.Node=R,d.DOMException=E,d.DOMImplementation=I,d.XMLSerializer=J,d}var m=function(){if(l)return o;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function r(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function i(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}l=1,e.prototype.parseFromString=function(e,n){var r=this.options,o=new h,a=r.domBuilder||new t,s=r.errorHandler,c=r.locator,u=r.xmlns||{},l=/\/x?html?$/.test(n),f=l?d.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&a.setDocumentLocator(c),o.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var o={},a=e instanceof Function;function s(t){var n=e[t];!n&&a&&(n=2==e.length?function(n){e(t,n)}:e),o[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+i(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),o}(s,a,c),o.domBuilder=r.domBuilder||a,l&&(u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?o.parse(e,u,f):o.errorHandler.error("invalid doc source"),a.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,o){var a=this.doc,i=a.createElementNS(e,n||t),s=o.length;u(this,i),this.currentElement=i,this.locator&&r(this.locator,i);for(var c=0;c<s;c++){e=o.getURI(c);var l=o.getValue(c),d=(n=o.getQName(c),a.createAttributeNS(e,n));this.locator&&r(o.getLocator(c),d),d.value=d.nodeValue=l,i.setAttributeNode(d)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&r(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.apply(this,arguments)){if(this.cdata)var o=this.doc.createCDATASection(e);else o=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(o):/^\s*$/.test(e)&&this.doc.appendChild(o),this.locator&&r(this.locator,o)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var o=this.doc.createComment(e);this.locator&&r(this.locator,o),u(this,o)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var o=this.doc.implementation;if(o&&o.createDocumentType){var a=o.createDocumentType(e,t,n);this.locator&&r(this.locator,a),u(this,a)}},warning:function(e){console.warn("[xmldom warning]\t"+e,i(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,i(this.locator))},fatalError:function(e){throw new p(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){t.prototype[e]=function(){return null}});var d=(n||(n=1,a.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),a),m=c(),h=m.XMLReader,p=m.ParseError,g=o.DOMImplementation=f().DOMImplementation;return o.XMLSerializer=f().XMLSerializer,o.DOMParser=e,o.__DOMHandler=t,o}();const h="plugin-items";function p(){return new Promise((e,t)=>{const n=indexedDB.open("OFSC_Plugin_npm_browser",1);n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(h)||e.createObjectStore(h,{keyPath:"id"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var g=Object.freeze({__proto__:null,add:async function(e){const t=(await p()).transaction(h,"readwrite");return t.objectStore(h).add(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},clear:async function(){const e=(await p()).transaction(h,"readwrite");return e.objectStore(h).clear(),new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error)})},get:async function(e){const t=(await p()).transaction(h,"readonly").objectStore(h).get(e);return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})},getAll:async function(){const e=(await p()).transaction(h,"readonly").objectStore(h).getAll();return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})},remove:async function(e){const t=(await p()).transaction(h,"readwrite");return t.objectStore(h).delete(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},update:async function(e){const t=(await p()).transaction(h,"readwrite");return t.objectStore(h).put(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})}});const w=async(e,n,r,o,a,i)=>{const s=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(i)});let c=await s(a);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),a=await t(n,r,o),c=await s(a)),!c.ok)throw new Error(`HTTP ${c.status}: ${await c.text()}`);return{data:await c.json(),token:a}},v=async(e,n,r,o,a,i=5,s=500)=>{const c=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let u=await c(a);if(401===u.status&&(console.warn("⚠️ Token expired — renewing token…"),a=await t(n,r,o),u=await c(a)),404===u.status)return console.log(JSON.stringify(await u.text())),{data:[],token:a};if(429===u.status&&i>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 received. Retrying in ${c}ms... (${i} left)`),await new Promise(e=>setTimeout(e,c)),v(e,n,r,o,a,i-1,2*s)}if(!u.ok){const e=await u.text();throw new Error(`❌ Request failed: ${u.status} ${u.statusText}\n${e}`)}return{data:await u.json(),token:a}};function N(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const b=(e,t="data")=>{if(!e.length)return n="No data to download",r="error",void console.log(`[${r.toUpperCase()}] ${n}`);var n,r;const o=N(e),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a");i.href=URL.createObjectURL(a),i.download=`${t}_${Date.now()}.csv`,i.click(),setTimeout(()=>URL.revokeObjectURL(i.href),100)};var y=Object.freeze({__proto__:null,downloadCSV:b,fetchWithRetry:v,localStorage:g,patchWithRetry:w,stringCsv:N,xmlNodeToObjects:function(e,t){const n=(new m.DOMParser).parseFromString(e,"application/xml"),r=Array.from(n.getElementsByTagName(t));if(0===r.length)throw new Error(`No <${t}> nodes found`);return r.map(e=>{var t,n;const r={},o=Array.from(e.getElementsByTagName("Field"));for(const e of o){const o=e.getAttribute("name");o&&(r[o]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return r})}});const E=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);var T=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,r,o=""){const a=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(r)}/`;return console.log(`➡️ Fetching activity by ID: ${a}`),await v(a,e,t,n,o)},getAllActivities:async function(e,n,r,o,a,i,s,c,u=!1){if(!E(a)||!E(i))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let l=1e3,d=0;const f=[],m=await t(e,n,r);for(;;){const t=new URLSearchParams({offset:d.toString(),limit:l.toString()});s&&t.append("q",s),o&&t.append("resources",o),c&&t.append("fields",c),a&&t.append("dateFrom",a),i&&t.append("dateTo",i),u&&t.append("includeNonScheduled","true");const h=`https://${r}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(h),console.log(`➡️ Fetching offset=${d}, limit=${l}`);const p=(await v(h,e,n,r,m)).data;if(!p.items||0===p.items.length){console.log("✔ No more items found. Stopping pagination.");break}f.push(...p.items),console.log(` ✔ Received ${p.items.length} items (Total: ${f.length})`),l=p.limit,d+=l}return f}});var D=Object.freeze({__proto__:null,AllFiles:async function(e,t,n,r=""){let o=0;return(async()=>{var a,i,s;o++,o%20==0&&(console.warn(`Waiting 10 seconds after ${o} API calls to avoid rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/folders/dailyExtract/folders/${r}/files`;return null===(i=null===(a=(await v(c,e,t,n,"")).data)||void 0===a?void 0:a.files)||void 0===i?void 0:i.items})()}});var S=Object.freeze({__proto__:null,resourcePositionHistoryRange:async function(e,t,n,r,o,a,i=""){let s=0;const c=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,u=async(o,a,i)=>{var c;s++,s%20==0&&(console.warn(`Waiting 10 seconds after ${s} API calls...`),await(c=1e4,new Promise(e=>setTimeout(e,c)))),console.log(`Calling API for date=${o}, offset=${a}`);const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}/positionHistory/?date=${o}&offset=${a}&limit=100`,d=await v(l,e,t,n,i);i=d.token;const{items:f=[],totalResults:m=0}=d.data||{},h=(null==f?void 0:f.length)||0;if(console.log(`[${o}] Received ${h} items (Total: ${a+h}/${m})`),a+h>=m)return{items:f,token:d.token};const p=await u(o,a+h,d.token);return{items:[...f,...p],token:d.token}},l=((e,t)=>{const n=[];let r=new Date(e);const o=new Date(t);if(r>o)throw new Error("fromDate cannot be greater than toDate");for(;r<=o;)n.push(c(r)),r.setDate(r.getDate()+1);return n})(o,a);console.log(`Total dates to process: ${l.length}`);let d=[],f=i;for(let e=0;e<l.length;e++){const t=l[e];console.log(`\nProcessing ${e+1}/${l.length}: ${t}`);const n=await u(t,0,f);d=[...d,...n.items.map(e=>{const{acc:t,alt:n,dir:o,i:a,s:i,spd:s,...c}=e;return{ResourceId:r,"Accuracy of the position in meters":t,Altitude:n,"direction (in degrees) in which the vehicle is headed":o,"Duration of the position":a,Status:i,Speed:s,...c}})],f=n.token}return console.log(`\n✅ Completed. Total records fetched: ${d.length}`),d}});async function x(e,t,n,r="",o=""){let a=0;const i=async(o,s)=>{var c;a++,a%20==0&&(console.warn(` Waiting 10 seconds after ${a} API calls to avoid server rate limits.`),await(c=1e4,new Promise(e=>setTimeout(e,c))));const u=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${o}&limit=100`,l=await v(u,e,t,n,s),{items:d,totalResults:f}=l.data,m=d.length;if(console.log(`Resources: Received ${m} items (Total: ${o+m})`),o+m>=f)return d;const h=await i(o+m,l.token);return""!==r?[...d,...h].filter(e=>e.resourceType===r&&"active"===e.status):[...d,...h]};return i(0,o)}async function A(e,t,n,r,o,a=""){return w(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}`,e,t,n,a,o)}async function _(e,t,n,r,o=""){const a=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${encodeURIComponent(r)}/workSkills`;console.log(`➡️ Fetching workSkills by resourceID: ${r}`);const i=await v(a,e,t,n,o);return{token:i.token,data:i.data.items}}var C=Object.freeze({__proto__:null,AllDescendantsOfResource:async function(e,t,n,r,o=""){let a=0;if(!r)throw new Error("Resource ID is required");const i=async(o,s)=>{var c;a++,a%20==0&&(console.warn(` Waiting 10 seconds after ${a} API calls to avoid server rate limits.`),await(c=1e4,new Promise(e=>setTimeout(e,c))));const u=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}/descendants?offset=${o}&limit=100`,l=await v(u,e,t,n,s),{items:d,totalResults:f}=l.data,m=d.length;if(console.log(`Resources: Received ${m} items (Total: ${o+m})`),o+m>=f)return d;const h=await i(o+m,l.token);return[...d,...h]};return i(0,o)},AllResources:x,getAllResourcesWorkSkills:async function(e,t,n,r="",o=""){const a=[];let i=0;const s=e=>new Promise(t=>setTimeout(t,e)),c=await x(e,t,n,r),u=new Set(c.filter(e=>null!==e.parentResourceId).map(e=>e.parentResourceId));let l=c.filter(e=>!u.has(e.resourceId)).filter(e=>"active"===e.status).filter(e=>"Bucket"!==e.resourceType);""!=o&&(l=l.filter(e=>e.resourceType===o)),console.log(`➡️ Number of resourceID: ${l.length}`);const d=l.length;for(const o of l){if("active"!==o.status)continue;i++,i%50==0&&(console.warn(`⏳ ${i} API calls reached(Total: ${d}). Waiting 5s...`),await s(5e3));const c=await _(e,t,n,o.resourceId,r);for(const e of c.data)a.push({resourceId:o.resourceId,name:o.name,parentResourceId:o.parentResourceId,resourceStatus:o.status,resourceType:o.resourceType,...e});r=c.token}return a},getworkSkillsOfResource:_,resetResourcesEmail:async function(e,t,n,r="noreply.com",o=""){const a=(await x(e,t,n,o)).filter(e=>e.email),i=[];for(let s=0;s<a.length;s+=200){const c=a.slice(s,s+200);for(const s of c){if(console.log(`Total : ${a.length}`,`Total updated: ${i.length}`),!s.email)continue;if(!s.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(s)}`);continue}let c=s.email;if(c.includes("@")||(c=c.replace(r,`@${r}`)),c.includes(r)){i.push({id:s.resourceId,email:s.email,newEmail:"",comment:"Email already updated"});continue}c=s.email.replace(/@.*/,`@${r}`),console.log(`Updating email for ${s.resourceId} (${s.email} -> ${c}) on ${n}`);const u={email:c},l=await A(e,t,n,s.resourceId,u,o);o=l.token,i.push({id:l.data.resourceId,email:s.email,newEmail:l.data.email})}s+200<a.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return i},updateResource:A});var I=Object.freeze({__proto__:null,AllUsers:async function(e,t,n,r=""){let o=0;const a=async(r,i)=>{var s;o++,o%20==0&&(console.warn(` Waiting 10 seconds after ${o} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${r}&limit=100`,u=await v(c,e,t,n,i),{items:l,totalResults:d}=u.data,f=l.length;if(console.log(`Received ${f} items (Total: ${r+f})`),r+f>=d)return l;const m=await a(r+f,u.token);return[...l,...m]};return a(0,r)}}),R={Activity:T,OauthTokenService:r,Utilities:y,Resources:C,downloadCSV:b,Users:I,DailyExtract:D,GPS:S};e.Activity=T,e.DailyExtract=D,e.GPS=S,e.OauthTokenService=r,e.Resources=C,e.Users=I,e.Utilities=y,e.default=R,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const a=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,r={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},o=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(a,{method:"POST",headers:r,body:o});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return(await e.json()).access_token}catch(e){throw console.error("Error fetching OAuth token:",e),e}}var n,a=Object.freeze({__proto__:null,getOAuthToken:t}),r={},o={};var s,i={};function l(){if(s)return i;s=1;var e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),n=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$");function a(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,a)}function r(){}function o(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function l(e,t,n,a,r,o){function s(e,t,a){e in n.attributeNames&&o.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,a)}for(var i,l=++t,c=0;;){var u=e.charAt(l);switch(u){case"=":if(1===c)i=e.slice(t,l),c=3;else{if(2!==c)throw new Error("attribute equal must after attrName");c=3}break;case"'":case'"':if(3===c||1===c){if(1===c&&(o.warning('attribute value must after "="'),i=e.slice(t,l)),t=l+1,!((l=e.indexOf(u,t))>0))throw new Error("attribute value no end '"+u+"' match");s(i,m=e.slice(t,l).replace(/&#?\w+;/g,r),t-1),c=5}else{if(4!=c)throw new Error('attribute value must after "="');s(i,m=e.slice(t,l).replace(/&#?\w+;/g,r),t),o.warning('attribute "'+i+'" missed start quot('+u+")!!"),t=l+1,c=5}break;case"/":switch(c){case 0:n.setTagName(e.slice(t,l));case 5:case 6:case 7:c=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),0==c&&n.setTagName(e.slice(t,l)),l;case">":switch(c){case 0:n.setTagName(e.slice(t,l));case 5:case 6:case 7:break;case 4:case 1:"/"===(m=e.slice(t,l)).slice(-1)&&(n.closed=!0,m=m.slice(0,-1));case 2:2===c&&(m=i),4==c?(o.warning('attribute "'+m+'" missed quot(")!'),s(i,m.replace(/&#?\w+;/g,r),t)):("http://www.w3.org/1999/xhtml"===a[""]&&m.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+m+'" missed value!! "'+m+'" instead!!'),s(m,m,t));break;case 3:throw new Error("attribute value missed!!")}return l;case"€":u=" ";default:if(u<=" ")switch(c){case 0:n.setTagName(e.slice(t,l)),c=6;break;case 1:i=e.slice(t,l),c=2;break;case 4:var m=e.slice(t,l).replace(/&#?\w+;/g,r);o.warning('attribute "'+m+'" missed quot(")!!'),s(i,m,t);case 5:c=6}else switch(c){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===a[""]&&i.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+i+'" missed value!! "'+i+'" instead2!!'),s(i,i,t),t=l,c=1;break;case 5:o.warning('attribute space is required"'+i+'"!!');case 6:c=1,t=l;break;case 3:c=4,t=l;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function c(e,t,n){for(var a=e.tagName,r=null,o=e.length;o--;){var s=e[o],i=s.qName,l=s.value;if((f=i.indexOf(":"))>0)var c=s.prefix=i.slice(0,f),u=i.slice(f+1),m="xmlns"===c&&u;else u=i,c=null,m="xmlns"===i&&"";s.localName=u,!1!==m&&(null==r&&(r={},d(n,n={})),n[m]=r[m]=l,s.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(m,l))}for(o=e.length;o--;){(c=(s=e[o]).prefix)&&("xml"===c&&(s.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==c&&(s.uri=n[c||""]))}var f;(f=a.indexOf(":"))>0?(c=e.prefix=a.slice(0,f),u=e.localName=a.slice(f+1)):(c=null,u=e.localName=a);var p=e.uri=n[c||""];if(t.startElement(p,u,a,e),!e.closed)return e.currentNSMap=n,e.localNSMap=r,!0;if(t.endElement(p,u,a),r)for(c in r)t.endPrefixMapping(c)}function u(e,t,n,a,r){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),s=e.substring(t+1,o);if(/[&<]/.test(s))return/^script$/i.test(n)?(r.characters(s,0,s.length),o):(s=s.replace(/&#?\w+;/g,a),r.characters(s,0,s.length),o)}return t+1}function m(e,t,n,a){var r=a[n];return null==r&&((r=e.lastIndexOf("</"+n+">"))<t&&(r=e.lastIndexOf("</"+n)),a[n]=r),r<t}function d(e,t){for(var n in e)t[n]=e[n]}function f(e,t,n,a){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(r=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,r-t-4),r+3):(a.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var r=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,r-t-9),n.endCDATA(),r+3}var o=function(e,t){var n,a=[],r=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;r.lastIndex=t,r.exec(e);for(;n=r.exec(e);)if(a.push(n),n[1])return a}(e,t),s=o.length;if(s>1&&/!doctype/i.test(o[0][0])){var i=o[1][0],l=!1,c=!1;s>3&&(/^public$/i.test(o[2][0])?(l=o[3][0],c=s>4&&o[4][0]):/^system$/i.test(o[2][0])&&(c=o[3][0]));var u=o[s-1];return n.startDTD(i,l,c),n.endDTD(),u.index+u[0].length}return-1}function p(e,t,n){var a=e.indexOf("?>",t);if(a){var r=e.substring(t,a).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return r?(r[0].length,n.processingInstruction(r[1],r[2]),a+2):-1}return-1}function h(){this.attributeNames={}}return a.prototype=new Error,a.prototype.name=a.name,r.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),d(t,t={}),function(e,t,n,r,s){function i(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function d(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?i(parseInt(t.substr(1).replace("x","0x"))):(s.error("entity not found:"+e),e)}function g(t){if(t>T){var n=e.substring(T,t).replace(/&#?\w+;/g,d);N&&v(T),r.characters(n,0,t-T),T=t}}function v(t,n){for(;t>=b&&(n=y.exec(e));)w=n.index,b=w+n[0].length,N.lineNumber++;N.columnNumber=t-w+1}var w=0,b=0,y=/.*(?:\r\n?|\n)|.*$/g,N=r.locator,I=[{currentNSMap:t}],S={},T=0;for(;;){try{var E=e.indexOf("<",T);if(E<0){if(!e.substr(T).match(/^\s*$/)){var $=r.doc,D=$.createTextNode(e.substr(T));$.appendChild(D),r.currentElement=D}return}switch(E>T&&g(E),e.charAt(E+1)){case"/":var x=e.indexOf(">",E+3),A=e.substring(E+2,x),O=I.pop();x<0?(A=e.substring(E+2).replace(/[\s<].*/,""),s.error("end tag name: "+A+" is not complete:"+O.tagName),x=E+1+A.length):A.match(/\s</)&&(A=A.replace(/[\s<].*/,""),s.error("end tag name: "+A+" maybe not complete"),x=E+1+A.length);var _=O.localNSMap,C=O.tagName==A;if(C||O.tagName&&O.tagName.toLowerCase()==A.toLowerCase()){if(r.endElement(O.uri,O.localName,A),_)for(var R in _)r.endPrefixMapping(R);C||s.fatalError("end tag name: "+A+" is not match the current start tagName:"+O.tagName)}else I.push(O);x++;break;case"?":N&&v(E),x=p(e,E,r);break;case"!":N&&v(E),x=f(e,E,r,s);break;default:N&&v(E);var k=new h,M=I[I.length-1].currentNSMap,P=(x=l(e,E,k,M,d,s),k.length);if(!k.closed&&m(e,x,k.tagName,S)&&(k.closed=!0,n.nbsp||s.warning("unclosed xml attribute")),N&&P){for(var V=o(N,{}),U=0;U<P;U++){var j=k[U];v(j.offset),j.locator=o(N,{})}r.locator=V,c(k,r,M)&&I.push(k),r.locator=N}else c(k,r,M)&&I.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?x++:x=u(e,x,k.tagName,d,r)}}catch(e){if(e instanceof a)throw e;s.error("element parse error: "+e),x=-1}x>T?T=x:g(Math.max(E,T)+1)}}(e,t,n,r,this.errorHandler),r.endDocument()}},h.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,a){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:a}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},i.XMLReader=r,i.ParseError=a,i}var c,u,m={};function d(){if(c)return m;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var a=t.prototype;if(!(a instanceof n)){function r(){}r.prototype=n.prototype,e(a,r=new r),t.prototype=a=r}a.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),a.constructor=t)}c=1;var n={},a=n.ELEMENT_NODE=1,r=n.ATTRIBUTE_NODE=2,o=n.TEXT_NODE=3,s=n.CDATA_SECTION_NODE=4,i=n.ENTITY_REFERENCE_NODE=5,l=n.ENTITY_NODE=6,u=n.PROCESSING_INSTRUCTION_NODE=7,d=n.COMMENT_NODE=8,f=n.DOCUMENT_NODE=9,p=n.DOCUMENT_TYPE_NODE=10,h=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,v={},w={};v.INDEX_SIZE_ERR=(w[1]="Index size error",1),v.DOMSTRING_SIZE_ERR=(w[2]="DOMString size error",2);var b=v.HIERARCHY_REQUEST_ERR=(w[3]="Hierarchy request error",3);v.WRONG_DOCUMENT_ERR=(w[4]="Wrong document",4),v.INVALID_CHARACTER_ERR=(w[5]="Invalid character",5),v.NO_DATA_ALLOWED_ERR=(w[6]="No data allowed",6),v.NO_MODIFICATION_ALLOWED_ERR=(w[7]="No modification allowed",7);var y=v.NOT_FOUND_ERR=(w[8]="Not found",8);v.NOT_SUPPORTED_ERR=(w[9]="Not supported",9);var N=v.INUSE_ATTRIBUTE_ERR=(w[10]="Attribute in use",10);function I(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,w[e]),this.message=w[e],Error.captureStackTrace&&Error.captureStackTrace(this,I);return n.code=e,t&&(this.message=this.message+": "+t),n}function S(){}function T(e,t){this._node=e,this._refresh=t,E(this)}function E(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var a=t._refresh(t._node);ae(t,"length",a.length),e(a,t),t._inc=n}}function $(){}function D(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function x(e,t,n,a){if(a?t[D(t,a)]=n:t[t.length++]=n,e){n.ownerElement=e;var r=e.ownerDocument;r&&(a&&M(r,e,a),function(e,t,n){e&&e._inc++;var a=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==a&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(r,e,n))}}function A(e,t,n){var a=D(t,n);if(!(a>=0))throw I(y,new Error(e.tagName+"@"+n));for(var r=t.length-1;a<r;)t[a]=t[++a];if(t.length=r,e){var o=e.ownerDocument;o&&(M(o,e,n),n.ownerElement=null)}}function O(e){if(this._features={},e)for(var t in e)this._features=e[t]}function _(){}function C(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function R(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(R(e,t))return!0}while(e=e.nextSibling)}function k(){}function M(e,t,n,a){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function P(e,t,n){if(e&&e._inc){e._inc++;var a=t.childNodes;if(n)a[a.length++]=n;else{for(var r=t.firstChild,o=0;r;)a[o++]=r,r=r.nextSibling;a.length=o}}}function V(e,t){var n=t.previousSibling,a=t.nextSibling;return n?n.nextSibling=a:e.firstChild=a,a?a.previousSibling=n:e.lastChild=n,P(e.ownerDocument,e),t}function U(e,t,n){var a=t.parentNode;if(a&&a.removeChild(t),t.nodeType===h){var r=t.firstChild;if(null==r)return t;var o=t.lastChild}else r=o=t;var s=n?n.previousSibling:e.lastChild;r.previousSibling=s,o.nextSibling=n,s?s.nextSibling=r:e.firstChild=r,null==n?e.lastChild=o:n.previousSibling=o;do{r.parentNode=e}while(r!==o&&(r=r.nextSibling));return P(e.ownerDocument||e,e),t.nodeType==h&&(t.firstChild=t.lastChild=null),t}function j(){this._nsMap={}}function F(){}function L(){}function B(){}function q(){}function z(){}function W(){}function H(){}function Y(){}function X(){}function G(){}function J(){}function Q(){}function Z(e,t){var n=[],a=9==this.nodeType&&this.documentElement||this,r=a.prefix,o=a.namespaceURI;if(o&&null==r&&null==(r=a.lookupPrefix(o)))var s=[{namespace:o,prefix:null}];return ee(this,n,e,t,s),n.join("")}function K(e,t,n){var a=e.prefix||"",r=e.namespaceURI;if(!a&&!r)return!1;if("xml"===a&&"http://www.w3.org/XML/1998/namespace"===r||"http://www.w3.org/2000/xmlns/"==r)return!1;for(var o=n.length;o--;){var s=n[o];if(s.prefix==a)return s.namespace!=r}return!0}function ee(e,t,n,l,c){if(l){if(!(e=l(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case a:c||(c=[]),c.length;var m=e.attributes,g=m.length,v=e.firstChild,w=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",w);for(var b=0;b<g;b++){"xmlns"==(y=m.item(b)).prefix?c.push({prefix:y.localName,namespace:y.value}):"xmlns"==y.nodeName&&c.push({prefix:"",namespace:y.value})}for(b=0;b<g;b++){var y;if(K(y=m.item(b),0,c)){var N=y.prefix||"",I=y.namespaceURI,S=N?" xmlns:"+N:" xmlns";t.push(S,'="',I,'"'),c.push({prefix:N,namespace:I})}ee(y,t,n,l,c)}if(K(e,0,c)){N=e.prefix||"";if(I=e.namespaceURI){S=N?" xmlns:"+N:" xmlns";t.push(S,'="',I,'"'),c.push({prefix:N,namespace:I})}}if(v||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(w)){if(t.push(">"),n&&/^script$/i.test(w))for(;v;)v.data?t.push(v.data):ee(v,t,n,l,c),v=v.nextSibling;else for(;v;)ee(v,t,n,l,c),v=v.nextSibling;t.push("</",w,">")}else t.push("/>");return;case f:case h:for(v=e.firstChild;v;)ee(v,t,n,l,c),v=v.nextSibling;return;case r:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,C),'"');case o:return t.push(e.data.replace(/[<&]/g,C).replace(/]]>/g,"]]&gt;"));case s:return t.push("<![CDATA[",e.data,"]]>");case d:return t.push("\x3c!--",e.data,"--\x3e");case p:var T=e.publicId,E=e.systemId;if(t.push("<!DOCTYPE ",e.name),T)t.push(" PUBLIC ",T),E&&"."!=E&&t.push(" ",E),t.push(">");else if(E&&"."!=E)t.push(" SYSTEM ",E,">");else{var $=e.internalSubset;$&&t.push(" [",$,"]"),t.push(">")}return;case u:return t.push("<?",e.target," ",e.data,"?>");case i:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,n){var o;switch(t.nodeType){case a:(o=t.cloneNode(!1)).ownerDocument=e;case h:break;case r:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var s=t.firstChild;s;)o.appendChild(te(e,s,n)),s=s.nextSibling;return o}function ne(e,t,n){var o=new t.constructor;for(var s in t){var i=t[s];"object"!=typeof i&&i!=o[s]&&(o[s]=i)}switch(t.childNodes&&(o.childNodes=new S),o.ownerDocument=e,o.nodeType){case a:var l=t.attributes,c=o.attributes=new $,u=l.length;c._ownerElement=o;for(var m=0;m<u;m++)o.setAttributeNode(ne(e,l.item(m),!0));break;case r:n=!0}if(n)for(var d=t.firstChild;d;)o.appendChild(ne(e,d,n)),d=d.nextSibling;return o}function ae(e,t,n){e[t]=n}v.INVALID_STATE_ERR=(w[11]="Invalid state",11),v.SYNTAX_ERR=(w[12]="Syntax error",12),v.INVALID_MODIFICATION_ERR=(w[13]="Invalid modification",13),v.NAMESPACE_ERR=(w[14]="Invalid namespace",14),v.INVALID_ACCESS_ERR=(w[15]="Invalid access",15),I.prototype=Error.prototype,e(v,I),S.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],a=0;a<this.length;a++)ee(this[a],n,e,t);return n.join("")}},T.prototype.item=function(e){return E(this),this[e]},t(T,S),$.prototype={length:0,item:S.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new I(N);var n=this.getNamedItem(e.nodeName);return x(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new I(N);return t=this.getNamedItemNS(e.namespaceURI,e.localName),x(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return A(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return A(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var a=this[n];if(a.localName==t&&a.namespaceURI==e)return a}return null}},O.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var a=new k;if(a.implementation=this,a.childNodes=new S,a.doctype=n,n&&a.appendChild(n),t){var r=a.createElementNS(e,t);a.appendChild(r)}return a},createDocumentType:function(e,t,n){var a=new W;return a.name=e,a.nodeName=e,a.publicId=t,a.systemId=n,a}},_.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return U(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return V(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ne(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==o&&e.nodeType==o?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var a in n)if(n[a]==e)return a;t=t.nodeType==r?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==r?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,_),e(n,_.prototype),k.prototype={nodeName:"#document",nodeType:f,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==h){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return null==this.documentElement&&e.nodeType==a&&(this.documentElement=e),U(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),V(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return R(this.documentElement,function(n){if(n.nodeType==a&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new T(this,function(e){var n=[];return R(e.documentElement,function(r){r!==e&&r.nodeType==a&&t.test(r.getAttribute("class"))&&n.push(r)}),n})},createElement:function(e){var t=new j;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new S,(t.attributes=new $)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new S,e},createTextNode:function(e){var t=new B;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new J;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new F;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new X;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new j,a=t.split(":"),r=n.attributes=new $;return n.childNodes=new S,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==a.length?(n.prefix=a[0],n.localName=a[1]):n.localName=t,r._ownerElement=n,n},createAttributeNS:function(e,t){var n=new F,a=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==a.length?(n.prefix=a[0],n.localName=a[1]):n.localName=t,n}},t(k,_),j.prototype={nodeType:a,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===h?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var a=e.lastChild;n.removeChild(t),a=e.lastChild}return a=e.lastChild,t.parentNode=e,t.previousSibling=a,t.nextSibling=null,a?a.nextSibling=t:e.firstChild=t,e.lastChild=t,P(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var a=this.ownerDocument.createAttributeNS(e,t);a.value=a.nodeValue=""+n,this.setAttributeNode(a)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new T(this,function(t){var n=[];return R(t,function(r){r===t||r.nodeType!=a||"*"!==e&&r.tagName!=e||n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new T(this,function(n){var r=[];return R(n,function(o){o===n||o.nodeType!==a||"*"!==e&&o.namespaceURI!==e||"*"!==t&&o.localName!=t||r.push(o)}),r})}},k.prototype.getElementsByTagName=j.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=j.prototype.getElementsByTagNameNS,t(j,_),F.prototype.nodeType=r,t(F,_),L.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(w[b])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},t(L,_),B.prototype={nodeName:"#text",nodeType:o,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var a=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling),a}},t(B,L),q.prototype={nodeName:"#comment",nodeType:d},t(q,L),z.prototype={nodeName:"#cdata-section",nodeType:s},t(z,L),W.prototype.nodeType=p,t(W,_),H.prototype.nodeType=g,t(H,_),Y.prototype.nodeType=l,t(Y,_),X.prototype.nodeType=i,t(X,_),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=h,t(G,_),J.prototype.nodeType=u,t(J,_),Q.prototype.serializeToString=function(e,t,n){return Z.call(e,t,n)},_.prototype.toString=Z;try{if(Object.defineProperty){function re(e){switch(e.nodeType){case a:case h:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(re(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(T.prototype,"length",{get:function(){return E(this),this.$$length}}),Object.defineProperty(_.prototype,"textContent",{get:function(){return re(this)},set:function(e){switch(this.nodeType){case a:case h:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ae=function(e,t,n){e["$$"+t]=n}}}catch(oe){}return m.Node=_,m.DOMException=I,m.DOMImplementation=O,m.XMLSerializer=Q,m}var f=function(){if(u)return r;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function a(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function s(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function i(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function c(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}u=1,e.prototype.parseFromString=function(e,n){var a=this.options,r=new p,o=a.domBuilder||new t,i=a.errorHandler,l=a.locator,c=a.xmlns||{},u=/\/x?html?$/.test(n),d=u?m.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return l&&o.setDocumentLocator(l),r.errorHandler=function(e,n,a){if(!e){if(n instanceof t)return n;e=n}var r={},o=e instanceof Function;function i(t){var n=e[t];!n&&o&&(n=2==e.length?function(n){e(t,n)}:e),r[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+s(a))}||function(){}}return a=a||{},i("warning"),i("error"),i("fatalError"),r}(i,o,l),r.domBuilder=a.domBuilder||o,u&&(c[""]="http://www.w3.org/1999/xhtml"),c.xml=c.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?r.parse(e,c,d):r.errorHandler.error("invalid doc source"),o.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var o=this.doc,s=o.createElementNS(e,n||t),i=r.length;c(this,s),this.currentElement=s,this.locator&&a(this.locator,s);for(var l=0;l<i;l++){e=r.getURI(l);var u=r.getValue(l),m=(n=r.getQName(l),o.createAttributeNS(e,n));this.locator&&a(r.getLocator(l),m),m.value=m.nodeValue=u,s.setAttributeNode(m)}},endElement:function(e,t,n){var a=this.currentElement;a.tagName,this.currentElement=a.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&a(this.locator,n),c(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=i.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&a(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=i.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&a(this.locator,r),c(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var o=r.createDocumentType(e,t,n);this.locator&&a(this.locator,o),c(this,o)}},warning:function(e){console.warn("[xmldom warning]\t"+e,s(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,s(this.locator))},fatalError:function(e){throw new h(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){t.prototype[e]=function(){return null}});var m=(n||(n=1,o.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),o),f=l(),p=f.XMLReader,h=f.ParseError,g=r.DOMImplementation=d().DOMImplementation;return r.XMLSerializer=d().XMLSerializer,r.DOMParser=e,r.__DOMHandler=t,r}();const p="plugin-items";function h(){return new Promise((e,t)=>{const n=indexedDB.open("OFSC_Plugin_npm_browser",1);n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(p)||e.createObjectStore(p,{keyPath:"id"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var g=Object.freeze({__proto__:null,add:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).add(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},clear:async function(){const e=(await h()).transaction(p,"readwrite");return e.objectStore(p).clear(),new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error)})},get:async function(e){const t=(await h()).transaction(p,"readonly").objectStore(p).get(e);return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})},getAll:async function(){const e=(await h()).transaction(p,"readonly").objectStore(p).getAll();return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})},remove:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).delete(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},update:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).put(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})}});const v=async(e,n,a,r,o,s)=>{const i=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let l=await i(o);if(401===l.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,a,r),l=await i(o)),!l.ok)throw new Error(`HTTP ${l.status}: ${await l.text()}`);return{data:await l.json(),token:o}},w=async(e,n,a,r,o,s=5,i=500)=>{const l=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let c=await l(o);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,a,r),c=await l(o)),404===c.status)return console.log(JSON.stringify(await c.text())),{data:[],token:o};if(console.info(c.status),429===c.status&&s>0||422===c.status&&s>0){const t=c.headers.get("Retry-After");console.log("⚠️ 429 / 422 received. Retrying...",t);const l=t?1e3*Number(t):i;return console.warn(`⚠️ 429 / 422 received. Retrying in ${l}ms... (${s} left)`),await new Promise(e=>setTimeout(e,l)),w(e,n,a,r,o,s-1,2*i)}if(!c.ok){const e=await c.text();throw new Error(`❌ Request failed: ${c.status} ${c.statusText}\n${e}`)}return{data:await c.json(),token:o}};function b(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const y=(e,t="data")=>{if(!e.length)return n="No data to download",a="error",void console.log(`[${a.toUpperCase()}] ${n}`);var n,a;const r=b(e),o=new Blob([r],{type:"text/csv;charset=utf-8;"}),s=document.createElement("a");s.href=URL.createObjectURL(o),s.download=`${t}_${Date.now()}.csv`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),100)};const N=e=>e.toISOString().split("T")[0],I=()=>{const e=[],t=new Date;t.setHours(0,0,0,0);const n=new Date(t);n.setDate(t.getDate()-89);for(let a=0;a<3;a++){const r=new Date(n);r.setDate(n.getDate()+30*a);const o=new Date(r);o.setDate(r.getDate()+29),o>t&&o.setTime(t.getTime()),e.push({start:N(r),end:N(o)})}return e};var S=Object.freeze({__proto__:null,downloadCSV:y,fetchWithRetry:w,getLast90DaysChunks:I,localStorage:g,patchWithRetry:v,stringCsv:b,xmlNodeToObjects:function(e,t){const n=(new f.DOMParser).parseFromString(e,"application/xml"),a=Array.from(n.getElementsByTagName(t));if(0===a.length)throw new Error(`No <${t}> nodes found`);return a.map(e=>{var t,n;const a={},r=Array.from(e.getElementsByTagName("Field"));for(const e of r){const r=e.getAttribute("name");r&&(a[r]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return a})}});const T=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);const E=(e,t,n)=>`https://${e}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/${t}?${new URLSearchParams(Object.entries(n).reduce((e,[t,n])=>(e[t]=String(n),e),{}))}`;var $=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,a,r=""){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(a)}/`;return console.log(`➡️ Fetching activity by ID: ${o}`),await w(o,e,t,n,r)},getAllActivities:async function(e,n,a,r,o,s,i,l,c=!1){if(!T(o)||!T(s))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let u=1e3,m=0;const d=[],f=await t(e,n,a);for(;;){const t=new URLSearchParams({offset:m.toString(),limit:u.toString()});i&&t.append("q",i),r&&t.append("resources",r),l&&t.append("fields",l),o&&t.append("dateFrom",o),s&&t.append("dateTo",s),c&&t.append("includeNonScheduled","true");const p=`https://${a}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(p),console.log(`➡️ Fetching offset=${m}, limit=${u}`);const h=(await w(p,e,n,a,f)).data;if(!h.items||0===h.items.length){console.log("✔ No more items found. Stopping pagination.");break}d.push(...h.items),console.log(` ✔ Received ${h.items.length} items (Total: ${d.length})`),u=h.limit,m+=u}return d},searchActivitybyQueryParameter:async function(e,t,n,a,r,o,s=""){var i,l,c,u;const m={data:[],token:""},d=I();console.log(`Date chunks: ${JSON.stringify(d,void 0,2)}`);for(const{start:c,end:u}of d){const d=E(n,"activities",{q:r,resources:a,dateFrom:c,dateTo:u,fields:o});console.log(`➡️ Fetching activity ${r} by query(Scheduled): ${d}`);const f=await w(d,e,t,n,s);s=f.token;const p=null!==(l=null===(i=null==f?void 0:f.data)||void 0===i?void 0:i.items)&&void 0!==l?l:[];if(p.length>0)return m.data.push(...p),m.token=f.token,m}const f=E(n,"activities",{q:r,resources:a,includeNonScheduled:!0,fields:o});console.log(`➡️ Fetching activity ${r} by query(NonScheduled): ${f}`);const p=await w(f,e,t,n,s);s=p.token;const h=null!==(u=null===(c=null==p?void 0:p.data)||void 0===c?void 0:c.items)&&void 0!==u?u:[];return m.token=p.token,h.length>0&&(m.data.push(...h),m.token=p.token),m}});var D=Object.freeze({__proto__:null,AllFiles:async function(e,t,n,a=""){let r=0;return(async()=>{var o,s,i;r++,r%20==0&&(console.warn(`Waiting 10 seconds after ${r} API calls to avoid rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/folders/dailyExtract/folders/${a}/files`;return null===(s=null===(o=(await w(l,e,t,n,"")).data)||void 0===o?void 0:o.files)||void 0===s?void 0:s.items})()}});var x=Object.freeze({__proto__:null,resourcePositionHistoryRange:async function(e,t,n,a,r,o,s=""){let i=0;const l=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,c=async(r,o,s)=>{var l;i++,i%20==0&&(console.warn(`Waiting 10 seconds after ${i} API calls...`),await(l=1e4,new Promise(e=>setTimeout(e,l)))),console.log(`Calling API for date=${r}, offset=${o}`);const u=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${a}/positionHistory/?date=${r}&offset=${o}&limit=100`,m=await w(u,e,t,n,s);s=m.token;const{items:d=[],totalResults:f=0}=m.data||{},p=(null==d?void 0:d.length)||0;if(console.log(`[${r}] Received ${p} items (Total: ${o+p}/${f})`),o+p>=f)return{items:d,token:m.token};const h=await c(r,o+p,m.token);return{items:[...d,...h],token:m.token}},u=((e,t)=>{const n=[];let a=new Date(e);const r=new Date(t);if(a>r)throw new Error("fromDate cannot be greater than toDate");for(;a<=r;)n.push(l(a)),a.setDate(a.getDate()+1);return n})(r,o);console.log(`Total dates to process: ${u.length}`);let m=[],d=s;for(let e=0;e<u.length;e++){const t=u[e];console.log(`\nProcessing ${e+1}/${u.length}: ${t}`);const n=await c(t,0,d);m=[...m,...n.items.map(e=>{const{acc:t,alt:n,dir:r,i:o,s:s,spd:i,...l}=e;return{ResourceId:a,"Accuracy of the position in meters":t,Altitude:n,"direction (in degrees) in which the vehicle is headed":r,"Duration of the position":o,Status:s,Speed:i,...l}})],d=n.token}return console.log(`\n✅ Completed. Total records fetched: ${m.length}`),m}});var A=Object.freeze({__proto__:null,ActivityType:async function(e,t,n,a=""){let r=0;const o=async(a,s)=>{var i;r++,r%20==0&&(console.warn(` Waiting 10 seconds after ${r} API calls to avoid server rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/activityTypes?offset=${a}&limit=100`,c=await w(l,e,t,n,s),{items:u,totalResults:m}=c.data,d=u.length;if(console.log(`Received ${d} items (Total: ${a+d})`),a+d>=m)return u;const f=await o(a+d,c.token);return[...u,...f]};return o(0,a)},ActivityTypeGroups:async function(e,t,n,a=""){let r=0;const o=async(a,s)=>{var i;r++,r%20==0&&(console.warn(` Waiting 10 seconds after ${r} API calls to avoid server rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/activityTypeGroups?offset=${a}&limit=100`,c=await w(l,e,t,n,s),{items:u,totalResults:m}=c.data,d=u.length;if(console.log(`Received ${d} items (Total: ${a+d})`),a+d>=m)return u;const f=await o(a+d,c.token);return[...u,...f]};return o(0,a)},AllProperties:async function(e,t,n,a=""){let r=0;const o=async(a,s)=>{var i;r++,r%20==0&&(console.warn(` Waiting 10 seconds after ${r} API calls to avoid server rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/properties/?offset=${a}&limit=100`,c=await w(l,e,t,n,s),{items:u,totalResults:m}=c.data,d=u.length;if(console.log(`Received ${d} items (Total: ${a+d})`),a+d>=m)return u;const f=await o(a+d,c.token);return[...u,...f]};return o(0,a)},AllResourceType:async function(e,t,n,a=""){let r=0;const o=async(a,s)=>{var i;r++,r%20==0&&(console.warn(` Waiting 10 seconds after ${r} API calls to avoid server rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/resourceTypes?offset=${a}&limit=100`,c=await w(l,e,t,n,s),{items:u,totalResults:m}=c.data,d=u.length;if(console.log(`Received ${d} items (Total: ${a+d})`),a+d>=m)return u;const f=await o(a+d,c.token);return[...u,...f]};return o(0,a)},compareProperties:async function(e,t,n,a){const r=[],o=new Map(t.map(e=>[e.label,e]));for(const t of e){const e=o.get(t.label);if(!e){r.push({label:t.label,message:`Missing in ${a}`,env1Value:t.label});continue}const s=["name","type","entity","gui"];for(const o of s)t[o]!==e[o]&&r.push({label:t.label,field:o,message:`${o} mismatch`,env1Value:t[o],env2Value:e[o],env1Instance:n,env2Instance:a});const i=new Map(e.translations.map(e=>[e.languageISO,e]));for(const e of t.translations){const o=i.get(e.languageISO);o?(e.name!==o.name&&r.push({label:t.label,field:`translations.name[${e.languageISO}]`,message:"Translation name mismatch",env1Value:e.name,env2Value:o.name,env1Instance:n,env2Instance:a}),e.language!==o.language&&r.push({label:t.label,field:`translations.language[${e.languageISO}]`,message:"Translation language mismatch",env1Value:e.language,env2Value:o.language,env1Instance:n,env2Instance:a})):r.push({label:t.label,field:"translations",message:`Translation missing in ${a} - (${e.languageISO})`,env1Value:e})}const l=new Set(t.translations.map(e=>e.languageISO));for(const o of e.translations)l.has(o.languageISO)||r.push({label:t.label,field:"translations",message:`Translation missing in ${n} - (${o.languageISO})`,env2Value:o,env1Instance:n,env2Instance:a})}const s=new Set(e.map(e=>e.label));for(const e of t)s.has(e.label)||r.push({label:e.label,message:`Missing in ${n}`,env2Value:e.label,env1Instance:n,env2Instance:a});return r},deepCompareActivityGroups:function(e,t,n,a){var r,o,s,i;const l=[],c=new Map(t.map(e=>[e.label,e])),u=new Map(e.map(e=>[e.label,e]));for(const t of e){const e=c.get(t.label);if(!e){l.push({label:t.label,message:"Missing in env2",env1Value:t,env1Instance:n,env2Instance:a});continue}t.name!==e.name&&l.push({label:t.label,field:"name",message:"Name mismatch",env1Value:t.name,env2Value:e.name,env1Instance:n,env2Instance:a});const u=null!==(r=t.activityTypes)&&void 0!==r?r:[],m=null!==(o=e.activityTypes)&&void 0!==o?o:[],d=new Map(m.map(e=>[e.label,e])),f=new Set(u.map(e=>e.label));for(const e of u)d.has(e.label)||l.push({label:t.label,field:"activityTypes",message:`ActivityType missing in env2 (${e.label})`,env1Value:e.label,env1Instance:n,env2Instance:a});for(const e of m)f.has(e.label)||l.push({label:t.label,field:"activityTypes",message:`ActivityType missing in env1 (${e.label})`,env2Value:e.label,env1Instance:n,env2Instance:a});const p=null!==(s=t.translations)&&void 0!==s?s:[],h=null!==(i=e.translations)&&void 0!==i?i:[],g=new Map(h.map(e=>[e.languageISO,e])),v=new Set(p.map(e=>e.languageISO));for(const e of p){const r=g.get(e.languageISO);r?(e.name!==r.name&&l.push({label:t.label,field:`translation.name[${e.languageISO}]`,message:"Translation name mismatch",env1Value:e.name,env2Value:r.name,env1Instance:n,env2Instance:a}),e.language!==r.language&&l.push({label:t.label,field:`translation.language[${e.languageISO}]`,message:"Translation language mismatch",env1Value:e.language,env2Value:r.language,env1Instance:n,env2Instance:a})):l.push({label:t.label,field:"translations",message:`Translation missing in env2 (${e.languageISO})`,env1Value:e,env1Instance:n,env2Instance:a})}for(const e of h)v.has(e.languageISO)||l.push({label:t.label,field:"translations",message:`Translation missing in env1 (${e.languageISO})`,env2Value:e,env1Instance:n,env2Instance:a})}for(const e of t)u.has(e.label)||l.push({label:e.label,message:"Missing in env1",env2Value:e,env1Instance:n,env2Instance:a});return l},deepCompareActivityTypes:function(e,t,n,a){var r,o,s,i,l,c,u,m;const d=[],f=new Map(t.map(e=>[e.label,e])),p=new Map(e.map(e=>[e.label,e]));for(const t of e){const e=f.get(t.label);if(!e){d.push({label:t.label,message:"Missing in env2",env1Value:t,env1Instance:n,env2Instance:a});continue}const p=["name","active","groupLabel","defaultDuration"];for(const r of p)t[r]!==e[r]&&d.push({label:t.label,field:String(r),message:`${r} mismatch`,env1Value:t[r],env2Value:e[r],env1Instance:n,env2Instance:a});const h=null!==(r=t.timeSlots)&&void 0!==r?r:[],g=null!==(o=e.timeSlots)&&void 0!==o?o:[],v=new Set(g.map(e=>e.label)),w=new Set(h.map(e=>e.label));for(const e of h)v.has(e.label)||d.push({label:t.label,field:"timeSlots",message:`Missing timeslot in env2 (${e.label})`,env1Value:e.label,env1Instance:n,env2Instance:a});for(const e of g)w.has(e.label)||d.push({label:t.label,field:"timeSlots",message:`Missing timeslot in env1 (${e.label})`,env2Value:e.label,env1Instance:n,env2Instance:a});const b=null!==(s=t.colors)&&void 0!==s?s:{},y=null!==(i=e.colors)&&void 0!==i?i:{},N=new Set([...Object.keys(b),...Object.keys(y)]);for(const e of N)b[e]!==y[e]&&d.push({label:t.label,field:`colors.${e}`,message:"Color mismatch",env1Value:b[e],env2Value:y[e],env1Instance:n,env2Instance:a});const I=null!==(l=t.features)&&void 0!==l?l:{},S=null!==(c=e.features)&&void 0!==c?c:{},T=new Set([...Object.keys(I),...Object.keys(S)]);for(const e of T)I[e]!==S[e]&&d.push({label:t.label,field:`features.${e}`,message:"Feature mismatch",env1Value:I[e],env2Value:S[e],env1Instance:n,env2Instance:a});const E=null!==(u=t.translations)&&void 0!==u?u:[],$=null!==(m=e.translations)&&void 0!==m?m:[],D=new Map($.map(e=>[e.languageISO,e])),x=new Set(E.map(e=>e.languageISO));for(const e of E){const r=D.get(e.languageISO);r?(e.name!==r.name&&d.push({label:t.label,field:`translations.name[${e.languageISO}]`,message:"Translation name mismatch",env1Value:e.name,env2Value:r.name,env1Instance:n,env2Instance:a}),e.language!==r.language&&d.push({label:t.label,field:`translations.language[${e.languageISO}]`,message:"Translation language mismatch",env1Value:e.language,env2Value:r.language,env1Instance:n,env2Instance:a})):d.push({label:t.label,field:"translations",message:`Missing translation in env2 (${e.languageISO})`,env1Value:e,env1Instance:n,env2Instance:a})}for(const e of $)x.has(e.languageISO)||d.push({label:t.label,field:"translations",message:`Missing translation in env1 (${e.languageISO})`,env2Value:e,env1Instance:n,env2Instance:a})}for(const e of t)p.has(e.label)||d.push({label:e.label,message:"Missing in env1",env2Value:e,env1Instance:n,env2Instance:a});return d},deepCompareResourceTypes:function(e,t,n,a){var r,o;const s=[],i=new Map(t.map(e=>[e.label,e])),l=new Map(e.map(e=>[e.label,e]));for(const t of e){const e=i.get(t.label);if(!e){s.push({label:t.label,message:"Missing in env2",env1Value:t,env1Instance:n,env2Instance:a});continue}const l=["name","active","role"];for(const r of l)t[r]!==e[r]&&s.push({label:t.label,field:String(r),message:`${r} mismatch`,env1Value:t[r],env2Value:e[r],env1Instance:n,env2Instance:a});const c=null!==(r=t.translations)&&void 0!==r?r:[],u=null!==(o=e.translations)&&void 0!==o?o:[],m=new Map(u.map(e=>[e.languageISO,e])),d=new Set(c.map(e=>e.languageISO));for(const e of c){const r=m.get(e.languageISO);r?(e.name!==r.name&&s.push({label:t.label,field:`translations.name[${e.languageISO}]`,message:"Translation name mismatch",env1Value:e.name,env2Value:r.name,env1Instance:n,env2Instance:a}),e.language!==r.language&&s.push({label:t.label,field:`translations.language[${e.languageISO}]`,message:"Translation language mismatch",env1Value:e.language,env2Value:r.language,env1Instance:n,env2Instance:a})):s.push({label:t.label,field:"translations",message:`Missing translation in env2 (${e.languageISO})`,env1Value:e,env1Instance:n,env2Instance:a})}for(const e of u)d.has(e.languageISO)||s.push({label:t.label,field:"translations",message:`Missing translation in env1 (${e.languageISO})`,env2Value:e,env1Instance:n,env2Instance:a})}for(const e of t)l.has(e.label)||s.push({label:e.label,message:"Missing in env1",env2Value:e,env1Instance:n,env2Instance:a});return s}});async function O(e,t,n,a="",r=""){let o=0;const s=async(r,i)=>{var l;o++,o%20==0&&(console.warn(` Waiting 10 seconds after ${o} API calls to avoid server rate limits.`),await(l=1e4,new Promise(e=>setTimeout(e,l))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${r}&limit=100`,u=await w(c,e,t,n,i),{items:m,totalResults:d}=u.data,f=m.length;if(console.log(`Resources: Received ${f} items (Total: ${r+f})`),r+f>=d)return m;const p=await s(r+f,u.token);return""!==a?[...m,...p].filter(e=>e.resourceType===a&&"active"===e.status):[...m,...p]};return s(0,r)}async function _(e,t,n,a,r,o=""){return v(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${a}`,e,t,n,o,r)}async function C(e,t,n,a,r=""){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${encodeURIComponent(a)}/workSkills`;console.log(`➡️ Fetching workSkills by resourceID: ${a}`);const s=await w(o,e,t,n,r);return{token:s.token,data:s.data.items}}var R=Object.freeze({__proto__:null,AllDescendantsOfResource:async function(e,t,n,a,r=""){let o=0;if(!a)throw new Error("Resource ID is required");const s=async(r,i)=>{var l;o++,o%20==0&&(console.warn(` Waiting 10 seconds after ${o} API calls to avoid server rate limits.`),await(l=1e4,new Promise(e=>setTimeout(e,l))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${a}/descendants?offset=${r}&limit=100`,u=await w(c,e,t,n,i),{items:m,totalResults:d}=u.data,f=m.length;if(console.log(`Resources: Received ${f} items (Total: ${r+f})`),r+f>=d)return m;const p=await s(r+f,u.token);return[...m,...p]};return s(0,r)},AllResources:O,getAllResourcesWorkSkills:async function(e,t,n,a="",r=""){const o=[];let s=0;const i=e=>new Promise(t=>setTimeout(t,e)),l=await O(e,t,n,a),c=new Set(l.filter(e=>null!==e.parentResourceId).map(e=>e.parentResourceId));let u=l.filter(e=>!c.has(e.resourceId)).filter(e=>"active"===e.status).filter(e=>"Bucket"!==e.resourceType);""!=r&&(u=u.filter(e=>e.resourceType===r)),console.log(`➡️ Number of resourceID: ${u.length}`);const m=u.length;for(const r of u){if("active"!==r.status)continue;s++,s%50==0&&(console.warn(`⏳ ${s} API calls reached(Total: ${m}). Waiting 5s...`),await i(5e3));const l=await C(e,t,n,r.resourceId,a);for(const e of l.data)o.push({resourceId:r.resourceId,name:r.name,parentResourceId:r.parentResourceId,resourceStatus:r.status,resourceType:r.resourceType,...e});a=l.token}return o},getworkSkillsOfResource:C,resetResourcesEmail:async function(e,t,n,a="noreply.com",r=""){const o=(await O(e,t,n,r)).filter(e=>e.email),s=[];for(let i=0;i<o.length;i+=200){const l=o.slice(i,i+200);for(const i of l){if(console.log(`Total : ${o.length}`,`Total updated: ${s.length}`),!i.email)continue;if(!i.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(i)}`);continue}let l=i.email;if(l.includes("@")||(l=l.replace(a,`@${a}`)),l.includes(a)){s.push({id:i.resourceId,email:i.email,newEmail:"",comment:"Email already updated"});continue}l=i.email.replace(/@.*/,`@${a}`),console.log(`Updating email for ${i.resourceId} (${i.email} -> ${l}) on ${n}`);const c={email:l},u=await _(e,t,n,i.resourceId,c,r);r=u.token,s.push({id:u.data.resourceId,email:i.email,newEmail:u.data.email})}i+200<o.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return s},updateResource:_});var k=Object.freeze({__proto__:null,AllUsers:async function(e,t,n,a=""){let r=0;const o=async(a,s)=>{var i;r++,r%20==0&&(console.warn(` Waiting 10 seconds after ${r} API calls to avoid server rate limits.`),await(i=1e4,new Promise(e=>setTimeout(e,i))));const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${a}&limit=100`,c=await w(l,e,t,n,s),{items:u,totalResults:m}=c.data,d=u.length;if(console.log(`Received ${d} items (Total: ${a+d})`),a+d>=m)return u;const f=await o(a+d,c.token);return[...u,...f]};return o(0,a)}}),M={Activity:$,OauthTokenService:a,Utilities:S,Resources:R,downloadCSV:y,Users:k,DailyExtract:D,GPS:x,MetaData:A};e.Activity=$,e.DailyExtract=D,e.GPS=x,e.MetaData=A,e.OauthTokenService=a,e.Resources=R,e.Users=k,e.Utilities=S,e.default=M,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=ofsc-utilities-min.js.map