ofsc-utility-browser 1.0.21 → 1.0.22
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.
|
@@ -17,3 +17,9 @@ export declare function getActivitybyId(clientId: string, clientSecret: string,
|
|
|
17
17
|
token: string;
|
|
18
18
|
data: any;
|
|
19
19
|
}>;
|
|
20
|
+
type ActivityResponse = {
|
|
21
|
+
data: any[];
|
|
22
|
+
token: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function searchActivitybyQueryParameter(clientId: string, clientSecret: string, instanceUrl: string, parentResources: string, q: string, fields: string, token?: string): Promise<ActivityResponse>;
|
|
25
|
+
export {};
|
package/dist/activities/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOAuthToken } from "../oauthTokenService";
|
|
2
|
-
import { fetchWithRetry } from "../utilities";
|
|
2
|
+
import { fetchWithRetry, getLast90DaysChunks } from "../utilities";
|
|
3
3
|
// Validate YYYY-MM-DD format
|
|
4
4
|
const isValidDate = (date) => /^\d{4}-\d{2}-\d{2}$/.test(date);
|
|
5
5
|
/**
|
|
@@ -66,3 +66,53 @@ export async function getActivitybyId(clientId, clientSecret, instanceUrl, activ
|
|
|
66
66
|
const response = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
|
|
67
67
|
return response;
|
|
68
68
|
}
|
|
69
|
+
const buildUrl = (instanceUrl, endpoint, params) => {
|
|
70
|
+
const query = new URLSearchParams(Object.entries(params).reduce((acc, [key, value]) => {
|
|
71
|
+
acc[key] = String(value);
|
|
72
|
+
return acc;
|
|
73
|
+
}, {}));
|
|
74
|
+
return `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/${endpoint}?${query}`;
|
|
75
|
+
};
|
|
76
|
+
export async function searchActivitybyQueryParameter(clientId, clientSecret, instanceUrl, parentResources, q, fields, token = "") {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
const result = {
|
|
79
|
+
data: [],
|
|
80
|
+
token: ""
|
|
81
|
+
};
|
|
82
|
+
const dateRanges = getLast90DaysChunks();
|
|
83
|
+
console.log(`Date chunks: ${JSON.stringify(dateRanges, undefined, 2)}`);
|
|
84
|
+
for (const { start, end } of dateRanges) {
|
|
85
|
+
const url = buildUrl(instanceUrl, "activities", {
|
|
86
|
+
q,
|
|
87
|
+
resources: parentResources,
|
|
88
|
+
dateFrom: start,
|
|
89
|
+
dateTo: end,
|
|
90
|
+
fields: fields
|
|
91
|
+
});
|
|
92
|
+
console.log(`➡️ Fetching activity ${q} by query(Scheduled): ${url}`);
|
|
93
|
+
const response = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
|
|
94
|
+
token = response.token;
|
|
95
|
+
const items = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
|
|
96
|
+
if (items.length > 0) {
|
|
97
|
+
result.data.push(...items);
|
|
98
|
+
result.token = response.token;
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const nonScheduledUrl = buildUrl(instanceUrl, "activities", {
|
|
103
|
+
q,
|
|
104
|
+
resources: parentResources,
|
|
105
|
+
includeNonScheduled: true,
|
|
106
|
+
fields: fields
|
|
107
|
+
});
|
|
108
|
+
console.log(`➡️ Fetching activity ${q} by query(NonScheduled): ${nonScheduledUrl}`);
|
|
109
|
+
const nonScheduledResponse = await fetchWithRetry(nonScheduledUrl, clientId, clientSecret, instanceUrl, token);
|
|
110
|
+
token = nonScheduledResponse.token;
|
|
111
|
+
const nonScheduledItems = (_d = (_c = nonScheduledResponse === null || nonScheduledResponse === void 0 ? void 0 : nonScheduledResponse.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
|
|
112
|
+
result.token = nonScheduledResponse.token;
|
|
113
|
+
if (nonScheduledItems.length > 0) {
|
|
114
|
+
result.data.push(...nonScheduledItems);
|
|
115
|
+
result.token = nonScheduledResponse.token;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
@@ -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?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+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,"]]>"));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 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);b&&w(D),o.characters(n,0,t-D),D=t}}function w(t,n){for(;t>=N&&(n=y.exec(e));)v=n.index,N=v+n[0].length,b.lineNumber++;b.columnNumber=t-v+1}var v=0,N=0,y=/.*(?:\r\n?|\n)|.*$/g,b=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 $=I.localNSMap,R=I.tagName==C;if(R||I.tagName&&I.tagName.toLowerCase()==C.toLowerCase()){if(o.endElement(I.uri,I.localName,C),$)for(var O in $)o.endPrefixMapping(O);R||i.fatalError("end tag name: "+C+" is not match the current start tagName:"+I.tagName)}else E.push(I);_++;break;case"?":b&&w(S),_=h(e,S,o);break;case"!":b&&w(S),_=m(e,S,o,i);break;default:b&&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")),b&&M){for(var U=a(b,{}),F=0;F<M;F++){var j=k[F];w(j.offset),j.locator=a(b,{})}o.locator=U,u(k,o,P)&&E.push(k),o.locator=b}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 y=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var b=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(y,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 $(){}function R(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+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 J(){}function Q(){}function Z(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"==(y=d.item(N)).prefix?u.push({prefix:y.localName,namespace:y.value}):"xmlns"==y.nodeName&&u.push({prefix:"",namespace:y.value})}for(N=0;N<g;N++){var y;if(K(y=d.item(N),0,u)){var b=y.prefix||"",E=y.namespaceURI,T=b?" xmlns:"+b:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:b,namespace:E})}ee(y,t,n,c,u)}if(K(e,0,u)){b=e.prefix||"";if(E=e.namespaceURI){T=b?" xmlns:"+b:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:b,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,R),'"');case a:return t.push(e.data.replace(/[<&]/g,R).replace(/]]>/g,"]]>"));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(b);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(b);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}},$.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,$),e(n,$.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 J;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,$),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,$),L.prototype.nodeType=o,t(L,$),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,$),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,$),W.prototype.nodeType=g,t(W,$),Y.prototype.nodeType=c,t(Y,$),X.prototype.nodeType=s,t(X,$),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=p,t(G,$),J.prototype.nodeType=l,t(J,$),Q.prototype.serializeToString=function(e,t,n){return Z.call(e,t,n)},$.prototype.toString=Z;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($.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=$,d.DOMException=E,d.DOMImplementation=I,d.XMLSerializer=Q,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(console.info(u.status),429===u.status&&i>0||422===u.status&&i>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 / 422 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 / 422 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 y=(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)};const b=e=>e.toISOString().split("T")[0],E=()=>{const e=[],t=new Date;t.setHours(0,0,0,0);const n=new Date(t);n.setDate(t.getDate()-89);for(let r=0;r<3;r++){const o=new Date(n);o.setDate(n.getDate()+30*r);const a=new Date(o);a.setDate(o.getDate()+29),a>t&&a.setTime(t.getTime()),e.push({start:b(o),end:b(a)})}return e};var T=Object.freeze({__proto__:null,downloadCSV:y,fetchWithRetry:v,getLast90DaysChunks:E,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 D=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);const S=(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 x=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(!D(a)||!D(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},searchActivitybyQueryParameter:async function(e,t,n,r,o,a,i=""){var s,c,u,l;const d={data:[],token:""},f=E();console.log(`Date chunks: ${JSON.stringify(f,void 0,2)}`);for(const{start:u,end:l}of f){const f=S(n,"activities",{q:o,resources:r,dateFrom:u,dateTo:l,fields:a});console.log(`➡️ Fetching activity ${o} by query(Scheduled): ${f}`);const m=await v(f,e,t,n,i);i=m.token;const h=null!==(c=null===(s=null==m?void 0:m.data)||void 0===s?void 0:s.items)&&void 0!==c?c:[];if(h.length>0)return d.data.push(...h),d.token=m.token,d}const m=S(n,"activities",{q:o,resources:r,includeNonScheduled:!0,fields:a});console.log(`➡️ Fetching activity ${o} by query(NonScheduled): ${m}`);const h=await v(m,e,t,n,i);i=h.token;const p=null!==(l=null===(u=null==h?void 0:h.data)||void 0===u?void 0:u.items)&&void 0!==l?l:[];return d.token=h.token,p.length>0&&(d.data.push(...p),d.token=h.token),d}});var A=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 _=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 C(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 I(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 R=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:C,getAllResourcesWorkSkills:async function(e,t,n,r="",o=""){const a=[];let i=0;const s=e=>new Promise(t=>setTimeout(t,e)),c=await C(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 C(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 I(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:I});var O=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)}}),k={Activity:x,OauthTokenService:r,Utilities:T,Resources:R,downloadCSV:y,Users:O,DailyExtract:A,GPS:_};e.Activity=x,e.DailyExtract=A,e.GPS=_,e.OauthTokenService=r,e.Resources=R,e.Users=O,e.Utilities=T,e.default=k,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=ofsc-utilities-min.js.map
|