@sap-ux/generator-odata-downloader 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/app/index.js +3 -3
- package/package.json +9 -9
package/generators/app/index.js
CHANGED
|
@@ -657,7 +657,7 @@ PGHZoN9jcvvvWDLUGtJkEotMgdFpEA2XWR83H4fVFVc=
|
|
|
657
657
|
ABAP Package: ${s?s.Package:r.package}`);let a=this.createConfig(r.transport,n,i),u=this.getAbapFrontendUrl();try{let c=await this.updateRepoRequest(!!s,r.name,o,a);if(c?.headers?.["sap-message"]&&VQ({msg:c.headers["sap-message"],log:this.log,host:u,isDest:this.isDest}),n)GQ({error:$Q(c?.data),log:this.log,host:u,isDest:this.isDest},!1);else{let l="/sap/bc/ui5_ui5"+(r.name.startsWith("/")?"":"/sap/")+r.name.toLowerCase(),f=this.defaults.params?.["sap-client"]?"?sap-client="+this.defaults.params["sap-client"]:"";this.log.info(`App available at ${u}${l}${f}`)}return s&&s.Package!==r.package&&this.log.warn(`Cannot change package assignment from ${s.Package} to ${r.package}.`),c}catch(c){throw fP({error:c,host:u,log:this.log,isDest:this.isDest}),c}}async undeploy({bsp:t,testMode:r=!1}){let n=this.createConfig(t.transport,r),i=this.getAbapFrontendUrl(),s=await this.getInfo(t.name);try{if(s){let o=await this.deleteRepoRequest(t.name,n);return o?.headers?.["sap-message"]&&VQ({msg:o.headers["sap-message"],log:this.log,host:i,isDest:this.isDest}),o}else{this.log.warn(`Application ${t.name} not found, nothing to undeploy.`);return}}catch(o){throw fP({error:o,host:i,log:this.log}),o}}getAbapFrontendUrl(){let t=new URL(this.publicUrl);return $gr.forEach((r,n)=>{t.hostname=t.hostname.replace(n,r)}),`${t.protocol}//${t.host}`}createConfig(t,r,n){let i={"Content-Type":"application/atom+xml",type:"entry",charset:"UTF8"},s={CodePage:"'UTF8'",CondenseMessagesInHttpResponseHeader:"X",format:"json"};return t&&(s.TransportRequest=t),r&&(s.TestMode=!0),n!==void 0&&(s.SafeMode=n),{headers:i,params:s,maxBodyLength:1/0,maxContentLength:1/0}}createPayload(t,r,n,i){let s=t.toString("base64"),o=new Date().toISOString(),a=UUe(r);return`<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="${this.publicUrl}"> <id>${this.publicUrl}/Repositories('${a}')</id> <title type="text">Repositories('${a}')</title> <updated>${o}</updated> <category term="/UI5/ABAP_REPOSITORY_SRV.Repository" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/> <link href="Repositories('${a}')" rel="edit" title="Repository"/> <content type="application/xml"> <m:properties> <d:Name>${a}</d:Name> <d:Package>${i?.toUpperCase()}</d:Package> <d:Description>${UUe(n)}</d:Description> <d:ZipArchive>${s}</d:ZipArchive> <d:Info/> </m:properties> </content></entry>`}async updateRepoRequest(t,r,n,i,s=1){try{s===2&&this.log.warn("Warning: The BSP application deployment timed out while waiting for a response from the backend. This may indicate the deployment was not finished. To resolve this, consider increasing the value of the HTML5.Timeout property for the destination.");let o=t;return s!==1&&(o=await this.getInfo(r)!==void 0),this.log.info(`${r} found on target system: ${o}`),o?await this.put(`/Repositories('${encodeURIComponent(r)}')`,n,i):await this.post("/Repositories",n,i)}catch(o){if([504,408].includes(o?.response?.status)){if(s>=3)throw o;return this.updateRepoRequest(t,r,n,i,s+1)}else{if(i?.params?.TestMode)return o.response;throw o}}}async deleteRepoRequest(t,r,n=1){try{return n===2&&this.log.warn("Warning: retry undeploy to handle a backend rejection..."),await this.delete(`/Repositories('${encodeURIComponent(t)}')`,r)}catch(i){if(i?.response?.status===400){if(n>=2)throw i;return this.deleteRepoRequest(t,r,n+1)}else throw i}}};var BUe=require("node:fs"),yk=require("node:url");var qUe=be(dZ(),1),vZ;(function(e){e.ON_PREMISE="onPremise",e.CLOUD_READY="cloudReady"})(vZ||(vZ={}));function gZ(e){return typeof e!="string"?`apps/${e.reference}/appVariants/${e.id}/`:e}function Ygr(e){return e.BYTES_PER_ELEMENT!==void 0}var kUe=e=>decodeURIComponent(e.toString());function yZ(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}var gk="/dta_folder/",ub=class extends Pa{static PATH="/sap/bc/lrep";log;async getCsrfToken(){try{return await this.get("/actions/getcsrftoken/")}catch(t){throw _c(t)&&this.tryLogResponse(t.response),t}}async mergeAppDescriptorVariant(t,r){let n="/appdescr_variant_preview/",i=new yk.URLSearchParams(this.defaults?.params);r&&i.append("workspacePath",r);try{let s=await this.put(n,t,{paramsSerializer:kUe,params:i,headers:{"Content-Type":"application/zip"}});return JSON.parse(s.data)}catch(s){throw _c(s)&&this.tryLogResponse(s.response),s}}async isExistingVariant(t,r="CUSTOMER_BASE"){try{let n=await this.get(gk,{params:{name:gZ(t),layer:r,timestamp:Date.now()}});return this.tryLogResponse(n),n}catch(n){if(_c(n)&&(this.tryLogResponse(n.response),n.response?.status===404))return n.response;throw n}}async deploy(t,r){let n=Ygr(t)?t:(0,BUe.readFileSync)(t),i=await this.isExistingVariant(r.namespace),s={name:gZ(r.namespace),layer:r.layer??"CUSTOMER_BASE"};s.package=r.package??"$TMP",s.package.toUpperCase()!=="$TMP"&&(s.changelist=r.transport);try{let o=await this.request({method:i.status===200?"PUT":"POST",url:gk,data:n,params:s,headers:{"Content-Type":"application/octet-stream"}});return this.tryLogResponse(o,"Deployment successful."),o}catch(o){throw fP({error:o,log:this.log}),o}}async undeploy(t){if((await this.isExistingVariant(t.namespace)).status!==200)throw new Error("Undeploy failed because the given project does not exist.");let n={name:gZ(t.namespace),layer:t.layer??"CUSTOMER_BASE"};t.transport&&(n.changelist=t.transport);try{let i=await this.delete(gk,{params:n});return this.tryLogResponse(i,"Undeployment successful."),i}catch(i){throw this.log.error("Undeployment failed"),this.log.debug(i),_c(i)&&i.response?.status===405&&this.log.error("Newer version of SAP_UI required, please check https://help.sap.com/docs/bas/developing-sap-fiori-app-in-sap-business-application-studio/delete-adaptation-project"),i}}async listAdaptations(t,r){try{let n=await this.get(`/flex/apps/${encodeURIComponent(t)}/adaptations/?version=${encodeURIComponent(r)}`,{transformResponse:yZ});return this.tryLogResponse(n,`Successfully fetched adaptations for app ${t}`),n.data}catch(n){throw _c(n)&&this.tryLogResponse(n.response),n}}async getKeyUserData(t,r){let n=new yk.URLSearchParams(this.defaults?.params);n.append("adaptationId",encodeURIComponent(r));try{let i=await this.get(`/flex/keyuserdata/${t}`,{params:n,paramsSerializer:kUe,transformResponse:yZ});return this.tryLogResponse(i,`Successfully fetched key user data for component ${t} and ${r} adaptation.`),i.data}catch(i){throw _c(i)&&this.tryLogResponse(i.response),i}}async getFlexVersions(t,r=2,n="EN"){try{let i=new yk.URLSearchParams(this.defaults?.params);i.append("sap-language",n),i.append("limit",r.toString());let s=await this.get(`/flex/versions/${encodeURIComponent(t)}`,{params:i,transformResponse:yZ});return this.tryLogResponse(s,`Successfully fetched flex versions for component ${t}`),s.data}catch(i){throw _c(i)&&this.tryLogResponse(i.response),i}}async getSystemInfo(t="EN",r,n){try{let i={"sap-language":t};r&&(i.package=r),n&&(i["sap-app-id"]=n);let s=await this.get(`${gk}system_info`,{params:i,paramsSerializer:o=>qUe.default.stringify(o,{encode:!1})});return this.tryLogResponse(s,"Successful getting system info."),JSON.parse(s.data)}catch(i){throw this.log.error("Getting system data failed."),this.log.debug(i),i}}tryLogResponse(t,r){try{let n=t.data?JSON.parse(t.data):{};n.result&&this.logMessage(n.result),(n.messages??[]).forEach(i=>{this.logMessage(i)})}catch{r&&this.log.info(r),this.log.warn("Could not parse returned messages.")}}logMessage(t){let r=t.severity==="Error"?so.Error:so.Info;this.log.log({level:r,message:t.text}),(t.details??[]).forEach(n=>{this.log.log({level:r,message:n})})}};var pBe=require("node:path/posix");var vk=class{adtSchema;getAdtCollection(t){if(!this.adtSchema)return null;let r=this.serializeAdtCategory(t);return this.adtSchema[r]}updateSchemaData(t){if(t){this.adtSchema={};let r=t.service.workspace;for(let n of r){let i=n.collection;if(i)if(Array.isArray(i))i.forEach(s=>{s.workspaceTitle=n.title;let o=this.serializeAdtCategory(s.category);this.adtSchema[o]=s});else{let s=i,o=this.serializeAdtCategory(s.category);this.adtSchema[o]=i}}}}isAdtSchemaEmpty(){return!this.adtSchema}serializeAdtCategory(t){return`${t.scheme},${t.term}`}};var jUe=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",zgr=jUe+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",Kgr="["+jUe+"]["+zgr+"]*",Xgr=new RegExp("^"+Kgr+"$");function Ek(e,t){let r=[],n=t.exec(e);for(;n;){let i=[];i.startIndex=t.lastIndex-n[0].length;let s=n.length;for(let o=0;o<s;o++)i.push(n[o]);r.push(i),n=t.exec(e)}return r}var EZ=function(e){let t=Xgr.exec(e);return!(t===null||typeof t>"u")};function VUe(e){return typeof e<"u"}var xP=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],_k=["__proto__","constructor","prototype"];var Jgr={allowBooleanAttributes:!1,unpairedTags:[]};function Sk(e,t){t=Object.assign({},Jgr,t);let r=[],n=!1,i=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let s=0;s<e.length;s++)if(e[s]==="<"&&e[s+1]==="?"){if(s+=2,s=$Ue(e,s),s.err)return s}else if(e[s]==="<"){let o=s;if(s++,e[s]==="!"){s=HUe(e,s);continue}else{let a=!1;e[s]==="/"&&(a=!0,s++);let u="";for(;s<e.length&&e[s]!==">"&&e[s]!==" "&&e[s]!==" "&&e[s]!==`
|
|
658
658
|
`&&e[s]!=="\r";s++)u+=e[s];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),s--),!syr(u)){let f;return u.trim().length===0?f="Invalid space after '<'.":f="Tag '"+u+"' is an invalid name.",Ai("InvalidTag",f,zo(e,s))}let c=eyr(e,s);if(c===!1)return Ai("InvalidAttr","Attributes for '"+u+"' have open quote.",zo(e,s));let l=c.value;if(s=c.index,l[l.length-1]==="/"){let f=s-l.length;l=l.substring(0,l.length-1);let p=WUe(l,t);if(p===!0)n=!0;else return Ai(p.err.code,p.err.msg,zo(e,f+p.err.line))}else if(a)if(c.tagClosed){if(l.trim().length>0)return Ai("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",zo(e,o));if(r.length===0)return Ai("InvalidTag","Closing tag '"+u+"' has not been opened.",zo(e,o));{let f=r.pop();if(u!==f.tagName){let p=zo(e,f.tagStartPos);return Ai("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+u+"'.",zo(e,o))}r.length==0&&(i=!0)}}else return Ai("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",zo(e,s));else{let f=WUe(l,t);if(f!==!0)return Ai(f.err.code,f.err.msg,zo(e,s-l.length+f.err.line));if(i===!0)return Ai("InvalidXml","Multiple possible root nodes found.",zo(e,s));t.unpairedTags.indexOf(u)!==-1||r.push({tagName:u,tagStartPos:o}),n=!0}for(s++;s<e.length;s++)if(e[s]==="<")if(e[s+1]==="!"){s++,s=HUe(e,s);continue}else if(e[s+1]==="?"){if(s=$Ue(e,++s),s.err)return s}else break;else if(e[s]==="&"){let f=nyr(e,s);if(f==-1)return Ai("InvalidChar","char '&' is not expected.",zo(e,s));s=f}else if(i===!0&&!GUe(e[s]))return Ai("InvalidXml","Extra text at the end",zo(e,s));e[s]==="<"&&s--}}else{if(GUe(e[s]))continue;return Ai("InvalidChar","char '"+e[s]+"' is not expected.",zo(e,s))}if(n){if(r.length==1)return Ai("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",zo(e,r[0].tagStartPos));if(r.length>0)return Ai("InvalidXml","Invalid '"+JSON.stringify(r.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return Ai("InvalidXml","Start tag expected.",1);return!0}function GUe(e){return e===" "||e===" "||e===`
|
|
659
659
|
`||e==="\r"}function $Ue(e,t){let r=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let n=e.substr(r,t-r);if(t>5&&n==="xml")return Ai("InvalidXml","XML declaration allowed only at the start of the document.",zo(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function HUe(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let r=1;for(t+=8;t<e.length;t++)if(e[t]==="<")r++;else if(e[t]===">"&&(r--,r===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var Qgr='"',Zgr="'";function eyr(e,t){let r="",n="",i=!1;for(;t<e.length;t++){if(e[t]===Qgr||e[t]===Zgr)n===""?n=e[t]:n!==e[t]||(n="");else if(e[t]===">"&&n===""){i=!0;break}r+=e[t]}return n!==""?!1:{value:r,index:t,tagClosed:i}}var tyr=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function WUe(e,t){let r=Ek(e,tyr),n={};for(let i=0;i<r.length;i++){if(r[i][1].length===0)return Ai("InvalidAttr","Attribute '"+r[i][2]+"' has no space in starting.",wP(r[i]));if(r[i][3]!==void 0&&r[i][4]===void 0)return Ai("InvalidAttr","Attribute '"+r[i][2]+"' is without value.",wP(r[i]));if(r[i][3]===void 0&&!t.allowBooleanAttributes)return Ai("InvalidAttr","boolean attribute '"+r[i][2]+"' is not allowed.",wP(r[i]));let s=r[i][2];if(!iyr(s))return Ai("InvalidAttr","Attribute '"+s+"' is an invalid name.",wP(r[i]));if(!Object.prototype.hasOwnProperty.call(n,s))n[s]=1;else return Ai("InvalidAttr","Attribute '"+s+"' is repeated.",wP(r[i]))}return!0}function ryr(e,t){let r=/\d/;for(e[t]==="x"&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(r))break}return-1}function nyr(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,ryr(e,t);let r=0;for(;t<e.length;t++,r++)if(!(e[t].match(/\w/)&&r<20)){if(e[t]===";")break;return-1}return t}function Ai(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function iyr(e){return EZ(e)}function syr(e){return EZ(e)}function zo(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function wP(e){return e.startIndex+e[1].length}var YUe={amp:"&",AMP:"&",lt:"<",LT:"<",gt:">",GT:">",quot:'"',QUOT:'"',apos:"'",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",lsquor:"\u201A",rsquor:"\u2019",ldquor:"\u201E",bdquo:"\u201E",comma:",",period:".",colon:":",semi:";",excl:"!",quest:"?",num:"#",dollar:"$",percent:"%",amp:"&",ast:"*",commat:"@",lowbar:"_",verbar:"|",vert:"|",sol:"/",bsol:"\\",lbrace:"{",rbrace:"}",lbrack:"[",rbrack:"]",lpar:"(",rpar:")",nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",COPY:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",REG:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",half:"\xBD",frac34:"\xBE",iquest:"\xBF",times:"\xD7",div:"\xF7",divide:"\xF7"},zUe={Agrave:"\xC0",agrave:"\xE0",Aacute:"\xC1",aacute:"\xE1",Acirc:"\xC2",acirc:"\xE2",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",Aring:"\xC5",aring:"\xE5",AElig:"\xC6",aelig:"\xE6",Ccedil:"\xC7",ccedil:"\xE7",Egrave:"\xC8",egrave:"\xE8",Eacute:"\xC9",eacute:"\xE9",Ecirc:"\xCA",ecirc:"\xEA",Euml:"\xCB",euml:"\xEB",Igrave:"\xCC",igrave:"\xEC",Iacute:"\xCD",iacute:"\xED",Icirc:"\xCE",icirc:"\xEE",Iuml:"\xCF",iuml:"\xEF",ETH:"\xD0",eth:"\xF0",Ntilde:"\xD1",ntilde:"\xF1",Ograve:"\xD2",ograve:"\xF2",Oacute:"\xD3",oacute:"\xF3",Ocirc:"\xD4",ocirc:"\xF4",Otilde:"\xD5",otilde:"\xF5",Ouml:"\xD6",ouml:"\xF6",Oslash:"\xD8",oslash:"\xF8",Ugrave:"\xD9",ugrave:"\xF9",Uacute:"\xDA",uacute:"\xFA",Ucirc:"\xDB",ucirc:"\xFB",Uuml:"\xDC",uuml:"\xFC",Yacute:"\xDD",yacute:"\xFD",THORN:"\xDE",thorn:"\xFE",szlig:"\xDF",yuml:"\xFF",Yuml:"\u0178"},KUe={Amacr:"\u0100",amacr:"\u0101",Abreve:"\u0102",abreve:"\u0103",Aogon:"\u0104",aogon:"\u0105",Cacute:"\u0106",cacute:"\u0107",Ccirc:"\u0108",ccirc:"\u0109",Cdot:"\u010A",cdot:"\u010B",Ccaron:"\u010C",ccaron:"\u010D",Dcaron:"\u010E",dcaron:"\u010F",Dstrok:"\u0110",dstrok:"\u0111",Emacr:"\u0112",emacr:"\u0113",Ecaron:"\u011A",ecaron:"\u011B",Edot:"\u0116",edot:"\u0117",Eogon:"\u0118",eogon:"\u0119",Gcirc:"\u011C",gcirc:"\u011D",Gbreve:"\u011E",gbreve:"\u011F",Gdot:"\u0120",gdot:"\u0121",Gcedil:"\u0122",Hcirc:"\u0124",hcirc:"\u0125",Hstrok:"\u0126",hstrok:"\u0127",Itilde:"\u0128",itilde:"\u0129",Imacr:"\u012A",imacr:"\u012B",Iogon:"\u012E",iogon:"\u012F",Idot:"\u0130",IJlig:"\u0132",ijlig:"\u0133",Jcirc:"\u0134",jcirc:"\u0135",Kcedil:"\u0136",kcedil:"\u0137",kgreen:"\u0138",Lacute:"\u0139",lacute:"\u013A",Lcedil:"\u013B",lcedil:"\u013C",Lcaron:"\u013D",lcaron:"\u013E",Lmidot:"\u013F",lmidot:"\u0140",Lstrok:"\u0141",lstrok:"\u0142",Nacute:"\u0143",nacute:"\u0144",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ENG:"\u014A",eng:"\u014B",Omacr:"\u014C",omacr:"\u014D",Odblac:"\u0150",odblac:"\u0151",OElig:"\u0152",oelig:"\u0153",Racute:"\u0154",racute:"\u0155",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",Sacute:"\u015A",sacute:"\u015B",Scirc:"\u015C",scirc:"\u015D",Scedil:"\u015E",scedil:"\u015F",Scaron:"\u0160",scaron:"\u0161",Tcedil:"\u0162",tcedil:"\u0163",Tcaron:"\u0164",tcaron:"\u0165",Tstrok:"\u0166",tstrok:"\u0167",Utilde:"\u0168",utilde:"\u0169",Umacr:"\u016A",umacr:"\u016B",Ubreve:"\u016C",ubreve:"\u016D",Uring:"\u016E",uring:"\u016F",Udblac:"\u0170",udblac:"\u0171",Uogon:"\u0172",uogon:"\u0173",Wcirc:"\u0174",wcirc:"\u0175",Ycirc:"\u0176",ycirc:"\u0177",Zacute:"\u0179",zacute:"\u017A",Zdot:"\u017B",zdot:"\u017C",Zcaron:"\u017D",zcaron:"\u017E"},XUe={Alpha:"\u0391",alpha:"\u03B1",Beta:"\u0392",beta:"\u03B2",Gamma:"\u0393",gamma:"\u03B3",Delta:"\u0394",delta:"\u03B4",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",varepsilon:"\u03F5",Zeta:"\u0396",zeta:"\u03B6",Eta:"\u0397",eta:"\u03B7",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",vartheta:"\u03D1",Iota:"\u0399",iota:"\u03B9",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",varkappa:"\u03F0",Lambda:"\u039B",lambda:"\u03BB",Mu:"\u039C",mu:"\u03BC",Nu:"\u039D",nu:"\u03BD",Xi:"\u039E",xi:"\u03BE",Omicron:"\u039F",omicron:"\u03BF",Pi:"\u03A0",pi:"\u03C0",piv:"\u03D6",varpi:"\u03D6",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",varrho:"\u03F1",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",varsigma:"\u03C2",Tau:"\u03A4",tau:"\u03C4",Upsilon:"\u03A5",upsilon:"\u03C5",upsi:"\u03C5",Upsi:"\u03D2",upsih:"\u03D2",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",varphi:"\u03D5",Chi:"\u03A7",chi:"\u03C7",Psi:"\u03A8",psi:"\u03C8",Omega:"\u03A9",omega:"\u03C9",ohm:"\u03A9",Gammad:"\u03DC",gammad:"\u03DD",digamma:"\u03DD"},JUe={Afr:"\u{1D504}",afr:"\u{1D51E}",Acy:"\u0410",acy:"\u0430",Bcy:"\u0411",bcy:"\u0431",Vcy:"\u0412",vcy:"\u0432",Gcy:"\u0413",gcy:"\u0433",Dcy:"\u0414",dcy:"\u0434",IEcy:"\u0415",iecy:"\u0435",IOcy:"\u0401",iocy:"\u0451",ZHcy:"\u0416",zhcy:"\u0436",Zcy:"\u0417",zcy:"\u0437",Icy:"\u0418",icy:"\u0438",Jcy:"\u0419",jcy:"\u0439",Kcy:"\u041A",kcy:"\u043A",Lcy:"\u041B",lcy:"\u043B",Mcy:"\u041C",mcy:"\u043C",Ncy:"\u041D",ncy:"\u043D",Ocy:"\u041E",ocy:"\u043E",Pcy:"\u041F",pcy:"\u043F",Rcy:"\u0420",rcy:"\u0440",Scy:"\u0421",scy:"\u0441",Tcy:"\u0422",tcy:"\u0442",Ucy:"\u0423",ucy:"\u0443",Fcy:"\u0424",fcy:"\u0444",KHcy:"\u0425",khcy:"\u0445",TScy:"\u0426",tscy:"\u0446",CHcy:"\u0427",chcy:"\u0447",SHcy:"\u0428",shcy:"\u0448",SHCHcy:"\u0429",shchcy:"\u0449",HARDcy:"\u042A",hardcy:"\u044A",Ycy:"\u042B",ycy:"\u044B",SOFTcy:"\u042C",softcy:"\u044C",Ecy:"\u042D",ecy:"\u044D",YUcy:"\u042E",yucy:"\u044E",YAcy:"\u042F",yacy:"\u044F",DJcy:"\u0402",djcy:"\u0452",GJcy:"\u0403",gjcy:"\u0453",Jukcy:"\u0404",jukcy:"\u0454",DScy:"\u0405",dscy:"\u0455",Iukcy:"\u0406",iukcy:"\u0456",YIcy:"\u0407",yicy:"\u0457",Jsercy:"\u0408",jsercy:"\u0458",LJcy:"\u0409",ljcy:"\u0459",NJcy:"\u040A",njcy:"\u045A",TSHcy:"\u040B",tshcy:"\u045B",KJcy:"\u040C",kjcy:"\u045C",Ubrcy:"\u040E",ubrcy:"\u045E",DZcy:"\u040F",dzcy:"\u045F"},QUe={plus:"+",minus:"\u2212",mnplus:"\u2213",mp:"\u2213",pm:"\xB1",times:"\xD7",div:"\xF7",divide:"\xF7",sdot:"\u22C5",star:"\u2606",starf:"\u2605",bigstar:"\u2605",lowast:"\u2217",ast:"*",midast:"*",compfn:"\u2218",smallcircle:"\u2218",bullet:"\u2022",bull:"\u2022",nbsp:"\xA0",hellip:"\u2026",mldr:"\u2026",prime:"\u2032",Prime:"\u2033",tprime:"\u2034",bprime:"\u2035",backprime:"\u2035",minus:"\u2212",minusd:"\u2238",dotminus:"\u2238",plusdo:"\u2214",dotplus:"\u2214",plusmn:"\xB1",minusplus:"\u2213",mnplus:"\u2213",mp:"\u2213",setminus:"\u2216",smallsetminus:"\u2216",Backslash:"\u2216",setmn:"\u2216",ssetmn:"\u2216",lowbar:"_",verbar:"|",vert:"|",VerticalLine:"|",colon:":",Colon:"\u2237",Proportion:"\u2237",ratio:"\u2236",equals:"=",ne:"\u2260",nequiv:"\u2262",equiv:"\u2261",Congruent:"\u2261",sim:"\u223C",thicksim:"\u223C",thksim:"\u223C",sime:"\u2243",simeq:"\u2243",TildeEqual:"\u2243",asymp:"\u2248",approx:"\u2248",thickapprox:"\u2248",thkap:"\u2248",TildeTilde:"\u2248",ncong:"\u2247",cong:"\u2245",TildeFullEqual:"\u2245",asympeq:"\u224D",CupCap:"\u224D",bump:"\u224E",Bumpeq:"\u224E",HumpDownHump:"\u224E",bumpe:"\u224F",bumpeq:"\u224F",HumpEqual:"\u224F",dotminus:"\u2238",minusd:"\u2238",plusdo:"\u2214",dotplus:"\u2214",le:"\u2264",LessEqual:"\u2264",ge:"\u2265",GreaterEqual:"\u2265",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",greater:">",less:"<"},ZUe={alefsym:"\u2135",aleph:"\u2135",beth:"\u2136",gimel:"\u2137",daleth:"\u2138",forall:"\u2200",ForAll:"\u2200",part:"\u2202",PartialD:"\u2202",exist:"\u2203",Exists:"\u2203",nexist:"\u2204",nexists:"\u2204",empty:"\u2205",emptyset:"\u2205",emptyv:"\u2205",varnothing:"\u2205",nabla:"\u2207",Del:"\u2207",isin:"\u2208",isinv:"\u2208",in:"\u2208",Element:"\u2208",notin:"\u2209",notinva:"\u2209",ni:"\u220B",niv:"\u220B",SuchThat:"\u220B",ReverseElement:"\u220B",notni:"\u220C",notniva:"\u220C",prod:"\u220F",Product:"\u220F",coprod:"\u2210",Coproduct:"\u2210",sum:"\u2211",Sum:"\u2211",minus:"\u2212",mp:"\u2213",plusdo:"\u2214",dotplus:"\u2214",setminus:"\u2216",lowast:"\u2217",radic:"\u221A",Sqrt:"\u221A",prop:"\u221D",propto:"\u221D",Proportional:"\u221D",varpropto:"\u221D",infin:"\u221E",infintie:"\u29DD",ang:"\u2220",angle:"\u2220",angmsd:"\u2221",measuredangle:"\u2221",angsph:"\u2222",mid:"\u2223",VerticalBar:"\u2223",nmid:"\u2224",nsmid:"\u2224",npar:"\u2226",parallel:"\u2225",spar:"\u2225",nparallel:"\u2226",nspar:"\u2226",and:"\u2227",wedge:"\u2227",or:"\u2228",vee:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",Integral:"\u222B",conint:"\u222E",ContourIntegral:"\u222E",Conint:"\u222F",DoubleContourIntegral:"\u222F",Cconint:"\u2230",there4:"\u2234",therefore:"\u2234",Therefore:"\u2234",becaus:"\u2235",because:"\u2235",Because:"\u2235",ratio:"\u2236",Proportion:"\u2237",minusd:"\u2238",dotminus:"\u2238",mDDot:"\u223A",homtht:"\u223B",sim:"\u223C",bsimg:"\u223D",backsim:"\u223D",ac:"\u223E",mstpos:"\u223E",acd:"\u223F",VerticalTilde:"\u2240",wr:"\u2240",wreath:"\u2240",nsime:"\u2244",nsimeq:"\u2244",nsimeq:"\u2244",ncong:"\u2247",simne:"\u2246",ncongdot:"\u2A6D\u0338",ngsim:"\u2275",nsim:"\u2241",napprox:"\u2249",nap:"\u2249",ngeq:"\u2271",nge:"\u2271",nleq:"\u2270",nle:"\u2270",ngtr:"\u226F",ngt:"\u226F",nless:"\u226E",nlt:"\u226E",nprec:"\u2280",npr:"\u2280",nsucc:"\u2281",nsc:"\u2281"},eke={larr:"\u2190",leftarrow:"\u2190",LeftArrow:"\u2190",uarr:"\u2191",uparrow:"\u2191",UpArrow:"\u2191",rarr:"\u2192",rightarrow:"\u2192",RightArrow:"\u2192",darr:"\u2193",downarrow:"\u2193",DownArrow:"\u2193",harr:"\u2194",leftrightarrow:"\u2194",LeftRightArrow:"\u2194",varr:"\u2195",updownarrow:"\u2195",UpDownArrow:"\u2195",nwarr:"\u2196",nwarrow:"\u2196",UpperLeftArrow:"\u2196",nearr:"\u2197",nearrow:"\u2197",UpperRightArrow:"\u2197",searr:"\u2198",searrow:"\u2198",LowerRightArrow:"\u2198",swarr:"\u2199",swarrow:"\u2199",LowerLeftArrow:"\u2199",lArr:"\u21D0",Leftarrow:"\u21D0",uArr:"\u21D1",Uparrow:"\u21D1",rArr:"\u21D2",Rightarrow:"\u21D2",dArr:"\u21D3",Downarrow:"\u21D3",hArr:"\u21D4",Leftrightarrow:"\u21D4",iff:"\u21D4",vArr:"\u21D5",Updownarrow:"\u21D5",lAarr:"\u21DA",Lleftarrow:"\u21DA",rAarr:"\u21DB",Rrightarrow:"\u21DB",lrarr:"\u21C6",leftrightarrows:"\u21C6",rlarr:"\u21C4",rightleftarrows:"\u21C4",lrhar:"\u21CB",leftrightharpoons:"\u21CB",ReverseEquilibrium:"\u21CB",rlhar:"\u21CC",rightleftharpoons:"\u21CC",Equilibrium:"\u21CC",udarr:"\u21C5",UpArrowDownArrow:"\u21C5",duarr:"\u21F5",DownArrowUpArrow:"\u21F5",llarr:"\u21C7",leftleftarrows:"\u21C7",rrarr:"\u21C9",rightrightarrows:"\u21C9",ddarr:"\u21CA",downdownarrows:"\u21CA",har:"\u21BD",lhard:"\u21BD",leftharpoondown:"\u21BD",lharu:"\u21BC",leftharpoonup:"\u21BC",rhard:"\u21C1",rightharpoondown:"\u21C1",rharu:"\u21C0",rightharpoonup:"\u21C0",lsh:"\u21B0",Lsh:"\u21B0",rsh:"\u21B1",Rsh:"\u21B1",ldsh:"\u21B2",rdsh:"\u21B3",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",mapstoleft:"\u21A4",mapstoup:"\u21A5",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",crarr:"\u21B5",nwarrow:"\u2196",nearrow:"\u2197",searrow:"\u2198",swarrow:"\u2199",nleftarrow:"\u219A",nleftrightarrow:"\u21AE",nrightarrow:"\u219B",nrarr:"\u219B",larrtl:"\u21A2",rarrtl:"\u21A3",leftarrowtail:"\u21A2",rightarrowtail:"\u21A3",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Larr:"\u219E",Rarr:"\u21A0",larrhk:"\u21A9",rarrhk:"\u21AA",larrlp:"\u21AB",looparrowleft:"\u21AB",rarrlp:"\u21AC",looparrowright:"\u21AC",harrw:"\u21AD",leftrightsquigarrow:"\u21AD",nrarrw:"\u219D\u0338",rarrw:"\u219D",rightsquigarrow:"\u219D",larrbfs:"\u291F",rarrbfs:"\u2920",nvHarr:"\u2904",nvlArr:"\u2902",nvrArr:"\u2903",larrfs:"\u291D",rarrfs:"\u291E",Map:"\u2905",larrsim:"\u2973",rarrsim:"\u2974",harrcir:"\u2948",Uarrocir:"\u2949",lurdshar:"\u294A",ldrdhar:"\u2967",ldrushar:"\u294B",rdldhar:"\u2969",lrhard:"\u296D",rlhar:"\u21CC",uharr:"\u21BE",uharl:"\u21BF",dharr:"\u21C2",dharl:"\u21C3",Uarr:"\u219F",Darr:"\u21A1",zigrarr:"\u21DD",nwArr:"\u21D6",neArr:"\u21D7",seArr:"\u21D8",swArr:"\u21D9",nharr:"\u21AE",nhArr:"\u21CE",nlarr:"\u219A",nlArr:"\u21CD",nrarr:"\u219B",nrArr:"\u21CF",larrb:"\u21E4",LeftArrowBar:"\u21E4",rarrb:"\u21E5",RightArrowBar:"\u21E5"},tke={square:"\u25A1",Square:"\u25A1",squ:"\u25A1",squf:"\u25AA",squarf:"\u25AA",blacksquar:"\u25AA",blacksquare:"\u25AA",FilledVerySmallSquare:"\u25AA",blk34:"\u2593",blk12:"\u2592",blk14:"\u2591",block:"\u2588",srect:"\u25AD",rect:"\u25AD",sdot:"\u22C5",sdotb:"\u22A1",dotsquare:"\u22A1",triangle:"\u25B5",tri:"\u25B5",trine:"\u25B5",utri:"\u25B5",triangledown:"\u25BF",dtri:"\u25BF",tridown:"\u25BF",triangleleft:"\u25C3",ltri:"\u25C3",triangleright:"\u25B9",rtri:"\u25B9",blacktriangle:"\u25B4",utrif:"\u25B4",blacktriangledown:"\u25BE",dtrif:"\u25BE",blacktriangleleft:"\u25C2",ltrif:"\u25C2",blacktriangleright:"\u25B8",rtrif:"\u25B8",loz:"\u25CA",lozenge:"\u25CA",blacklozenge:"\u29EB",lozf:"\u29EB",bigcirc:"\u25EF",xcirc:"\u25EF",circ:"\u02C6",Circle:"\u25CB",cir:"\u25CB",o:"\u25CB",bullet:"\u2022",bull:"\u2022",hellip:"\u2026",mldr:"\u2026",nldr:"\u2025",boxh:"\u2500",HorizontalLine:"\u2500",boxv:"\u2502",boxdr:"\u250C",boxdl:"\u2510",boxur:"\u2514",boxul:"\u2518",boxvr:"\u251C",boxvl:"\u2524",boxhd:"\u252C",boxhu:"\u2534",boxvh:"\u253C",boxH:"\u2550",boxV:"\u2551",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxDl:"\u2555",boxdL:"\u2556",boxDL:"\u2557",boxuR:"\u2558",boxUr:"\u2559",boxUR:"\u255A",boxUl:"\u255C",boxuL:"\u255B",boxUL:"\u255D",boxvR:"\u255E",boxVr:"\u255F",boxVR:"\u2560",boxVl:"\u2562",boxvL:"\u2561",boxVL:"\u2563",boxHd:"\u2564",boxhD:"\u2565",boxHD:"\u2566",boxHu:"\u2567",boxhU:"\u2568",boxHU:"\u2569",boxvH:"\u256A",boxVh:"\u256B",boxVH:"\u256C"},rke={excl:"!",iexcl:"\xA1",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",nbsp:"\xA0",comma:",",period:".",colon:":",semi:";",vert:"|",Verbar:"\u2016",verbar:"|",dblac:"\u02DD",circ:"\u02C6",caron:"\u02C7",breve:"\u02D8",dot:"\u02D9",ring:"\u02DA",ogon:"\u02DB",tilde:"\u02DC",DiacriticalGrave:"`",DiacriticalAcute:"\xB4",DiacriticalTilde:"\u02DC",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",grave:"`",acute:"\xB4"},bk={cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",euro:"\u20AC",dollar:"$",euro:"\u20AC",fnof:"\u0192",inr:"\u20B9",af:"\u060B",birr:"\u1265\u122D",peso:"\u20B1",rub:"\u20BD",won:"\u20A9",yuan:"\xA5",cedil:"\xB8"},nke={frac12:"\xBD",half:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044"},ike={trade:"\u2122",TRADE:"\u2122",telrec:"\u2315",target:"\u2316",ulcorn:"\u231C",ulcorner:"\u231C",urcorn:"\u231D",urcorner:"\u231D",dlcorn:"\u231E",llcorner:"\u231E",drcorn:"\u231F",lrcorner:"\u231F",intercal:"\u22BA",intcal:"\u22BA",oplus:"\u2295",CirclePlus:"\u2295",ominus:"\u2296",CircleMinus:"\u2296",otimes:"\u2297",CircleTimes:"\u2297",osol:"\u2298",odot:"\u2299",CircleDot:"\u2299",oast:"\u229B",circledast:"\u229B",odash:"\u229D",circleddash:"\u229D",ocirc:"\u229A",circledcirc:"\u229A",boxplus:"\u229E",plusb:"\u229E",boxminus:"\u229F",minusb:"\u229F",boxtimes:"\u22A0",timesb:"\u22A0",boxdot:"\u22A1",sdotb:"\u22A1",veebar:"\u22BB",vee:"\u2228",barvee:"\u22BD",and:"\u2227",wedge:"\u2227",Cap:"\u22D2",Cup:"\u22D3",Fork:"\u22D4",pitchfork:"\u22D4",epar:"\u22D5",ltlarr:"\u2976",nvap:"\u224D\u20D2",nvsim:"\u223C\u20D2",nvge:"\u2265\u20D2",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvgt:">\u20D2",nvltrie:"\u22B4\u20D2",nvrtrie:"\u22B5\u20D2",Vdash:"\u22A9",dashv:"\u22A3",vDash:"\u22A8",Vdash:"\u22A9",Vvdash:"\u22AA",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF"},oyr={...YUe,...zUe,...KUe,...XUe,...JUe,...QUe,...ZUe,...eke,...tke,...rke,...bk,...nke,...ike},CP={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},_Z={nbsp:"\xA0",copy:"\xA9",reg:"\xAE",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xAB",raquo:"\xBB",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",bull:"\u2022",para:"\xB6",sect:"\xA7",deg:"\xB0",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE"};var ayr=new Set("!?\\\\/[]$%{}^&*()<>|+");function ske(e){if(e[0]==="#")throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(let t of e)if(ayr.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function SZ(...e){let t=Object.create(null);for(let r of e)if(r)for(let n of Object.keys(r)){let i=r[n];if(typeof i=="string")t[n]=i;else if(i&&typeof i=="object"&&i.val!==void 0){let s=i.val;typeof s=="string"&&(t[n]=s)}}return t}var Zv="external",Tk="base",bZ="all";function uyr(e){return!e||e===Zv?new Set([Zv]):e===bZ?new Set([bZ]):e===Tk?new Set([Tk]):Array.isArray(e)?new Set(e):new Set([Zv])}var Fa=Object.freeze({allow:0,leave:1,remove:2,throw:3}),cyr=new Set([9,10,13]);function lyr(e){if(!e)return{xmlVersion:1,onLevel:Fa.allow,nullLevel:Fa.remove};let t=e.xmlVersion===1.1?1.1:1,r=Fa[e.onNCR]??Fa.allow,n=Fa[e.nullNCR]??Fa.remove,i=Math.max(n,Fa.remove);return{xmlVersion:t,onLevel:r,nullLevel:i}}var cb=class{constructor(t={}){this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof t.postCheck=="function"?t.postCheck:n=>n,this._limitTiers=uyr(this._limit.applyLimitsTo??Zv),this._numericAllowed=t.numericAllowed??!0,this._baseMap=SZ(CP,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);let r=lyr(t.ncr);this._ncrXmlVersion=r.xmlVersion,this._ncrOnLevel=r.onLevel,this._ncrNullLevel=r.nullLevel}setExternalEntities(t){if(t)for(let r of Object.keys(t))ske(r);this._externalMap=SZ(t)}addExternalEntity(t,r){ske(t),typeof r=="string"&&r.indexOf("&")===-1&&(this._externalMap[t]=r)}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputMap=SZ(t)}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=t===1.1?1.1:1}decode(t){if(typeof t!="string"||t.length===0)return t;let r=t,n=[],i=t.length,s=0,o=0,a=this._maxTotalExpansions>0,u=this._maxExpandedLength>0,c=a||u;for(;o<i;){if(t.charCodeAt(o)!==38){o++;continue}let f=o+1;for(;f<i&&t.charCodeAt(f)!==59&&f-o<=32;)f++;if(f>=i||t.charCodeAt(f)!==59){o++;continue}let p=t.slice(o+1,f);if(p.length===0){o++;continue}let d,h;if(this._removeSet.has(p))d="",h===void 0&&(h=Zv);else if(this._leaveSet.has(p)){o++;continue}else if(p.charCodeAt(0)===35){let g=this._resolveNCR(p);if(g===void 0){o++;continue}d=g,h=Tk}else{let g=this._resolveName(p);d=g?.value,h=g?.tier}if(d===void 0){o++;continue}if(o>s&&n.push(t.slice(s,o)),n.push(d),s=f+1,o=s,c&&this._tierCounts(h)){if(a&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(u){let g=d.length-(p.length+2);if(g>0&&(this._expandedLength+=g,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}s<i&&n.push(t.slice(s));let l=n.length===0?t:n.join("");return this._postCheck(l,r)}_tierCounts(t){return this._limitTiers.has(bZ)?!0:this._limitTiers.has(t)}_resolveName(t){if(t in this._inputMap)return{value:this._inputMap[t],tier:Zv};if(t in this._externalMap)return{value:this._externalMap[t],tier:Zv};if(t in this._baseMap)return{value:this._baseMap[t],tier:Tk}}_classifyNCR(t){return t===0?this._ncrNullLevel:t>=55296&&t<=57343||this._ncrXmlVersion===1&&t>=1&&t<=31&&!cyr.has(t)?Fa.remove:-1}_applyNCRAction(t,r,n){switch(t){case Fa.allow:return String.fromCodePoint(n);case Fa.remove:return"";case Fa.leave:return;case Fa.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${r}; (U+${n.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(n)}}_resolveNCR(t){let r=t.charCodeAt(1),n;if(r===120||r===88?n=parseInt(t.slice(2),16):n=parseInt(t.slice(1),10),Number.isNaN(n)||n<0||n>1114111)return;let i=this._classifyNCR(n);if(!this._numericAllowed&&i<Fa.remove)return;let s=i===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,i);return this._applyNCRAction(s,t,n)}};var oke=e=>xP.includes(e)?"__"+e:e,fyr={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:oke};function pyr(e,t){if(typeof e!="string")return;let r=e.toLowerCase();if(xP.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);if(_k.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function ake(e,t){return typeof e=="boolean"?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:typeof e=="object"&&e!==null?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null,appliesTo:e.appliesTo??"all"}:ake(!0)}var uke=function(e){let t=Object.assign({},fyr,e),r=[{value:t.attributeNamePrefix,name:"attributeNamePrefix"},{value:t.attributesGroupName,name:"attributesGroupName"},{value:t.textNodeName,name:"textNodeName"},{value:t.cdataPropName,name:"cdataPropName"},{value:t.commentPropName,name:"commentPropName"}];for(let{value:n,name:i}of r)n&&pyr(n,i);return t.onDangerousProperty===null&&(t.onDangerousProperty=oke),t.processEntities=ake(t.processEntities,t.htmlEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(n=>typeof n=="string"&&n.startsWith("*.")?".."+n.substring(2):n)),t};var Ak;typeof Symbol!="function"?Ak="@@xmlMetadata":Ak=Symbol("XML Node Metadata");var Ua=class{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,r){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:r})}addChild(t,r){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),r!==void 0&&(this.child[this.child.length-1][Ak]={startIndex:r})}static getMetaDataSymbol(){return Ak}};var cke=":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",dyr=cke+"\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040",lke=":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}",hyr=lke+"\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040",fke=(e,t,r="")=>{let n=e.replace(":",""),i=t.replace(":",""),s=`[${n}][${i}]*`;return{name:new RegExp(`^[${e}][${t}]*$`,r),ncName:new RegExp(`^${s}$`,r),qName:new RegExp(`^${s}(?::${s})?$`,r),nmToken:new RegExp(`^[${t}]+$`,r),nmTokens:new RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,r)}},myr=fke(cke,dyr),gyr=fke(lke,hyr,"u"),yyr=(e="1.0")=>e==="1.1"?gyr:myr;var TZ=(e,{xmlVersion:t="1.0"}={})=>yyr(t).qName.test(e);var PP=class{constructor(t,r){this.suppressValidationErr=!t,this.options=t,this.xmlVersion=r||1}setXmlVersion(t=1){this.xmlVersion=t}readDocType(t,r){let n=Object.create(null),i=0;if(t[r+3]==="O"&&t[r+4]==="C"&&t[r+5]==="T"&&t[r+6]==="Y"&&t[r+7]==="P"&&t[r+8]==="E"){r=r+9;let s=1,o=!1,a=!1,u="";for(;r<t.length;r++)if(t[r]==="<"&&!a){if(o&&eE(t,"!ENTITY",r)){r+=7;let c,l;if([c,l,r]=this.readEntityExp(t,r+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[c]=l,i++}}else if(o&&eE(t,"!ELEMENT",r)){r+=8;let{index:c}=this.readElementExp(t,r+1);r=c}else if(o&&eE(t,"!ATTLIST",r))r+=8;else if(o&&eE(t,"!NOTATION",r)){r+=9;let{index:c}=this.readNotationExp(t,r+1,this.suppressValidationErr);r=c}else if(eE(t,"!--",r))a=!0;else throw new Error("Invalid DOCTYPE");s++,u=""}else if(t[r]===">"){if(a?t[r-1]==="-"&&t[r-2]==="-"&&(a=!1,s--):s--,s===0)break}else t[r]==="["?o=!0:u+=t[r];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:r}}readEntityExp(t,r){r=ka(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r])&&t[r]!=='"'&&t[r]!=="'";)r++;let i=t.substring(n,r);if(OP(i,{xmlVersion:this.xmlVersion}),r=ka(t,r),!this.suppressValidationErr){if(t.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(t[r]==="%")throw new Error("Parameter entities are not supported")}let s="";if([r,s]=this.readIdentifierVal(t,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[i,s,r]}readNotationExp(t,r){r=ka(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let i=t.substring(n,r);!this.suppressValidationErr&&OP(i,{xmlVersion:this.xmlVersion}),r=ka(t,r);let s=t.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&s!=="SYSTEM"&&s!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);r+=s.length,r=ka(t,r);let o=null,a=null;if(s==="PUBLIC")[r,o]=this.readIdentifierVal(t,r,"publicIdentifier"),r=ka(t,r),(t[r]==='"'||t[r]==="'")&&([r,a]=this.readIdentifierVal(t,r,"systemIdentifier"));else if(s==="SYSTEM"&&([r,a]=this.readIdentifierVal(t,r,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:o,systemIdentifier:a,index:--r}}readIdentifierVal(t,r,n){let i="",s=t[r];if(s!=='"'&&s!=="'")throw new Error(`Expected quoted string, found "${s}"`);r++;let o=r;for(;r<t.length&&t[r]!==s;)r++;if(i=t.substring(o,r),t[r]!==s)throw new Error(`Unterminated ${n} value`);return r++,[r,i]}readElementExp(t,r){r=ka(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let i=t.substring(n,r);if(!this.suppressValidationErr&&!TZ(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${i}"`);r=ka(t,r);let s="";if(t[r]==="E"&&eE(t,"MPTY",r))r+=4;else if(t[r]==="A"&&eE(t,"NY",r))r+=2;else if(t[r]==="("){r++;let o=r;for(;r<t.length&&t[r]!==")";)r++;if(s=t.substring(o,r),t[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[r]}"`);return{elementName:i,contentModel:s.trim(),index:r}}readAttlistExp(t,r){r=ka(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let i=t.substring(n,r);for(OP(i,{xmlVersion:this.xmlVersion}),r=ka(t,r),n=r;r<t.length&&!/\s/.test(t[r]);)r++;let s=t.substring(n,r);if(!OP(s,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${s}"`);r=ka(t,r);let o="";if(t.substring(r,r+8).toUpperCase()==="NOTATION"){if(o="NOTATION",r+=8,r=ka(t,r),t[r]!=="(")throw new Error(`Expected '(', found "${t[r]}"`);r++;let u=[];for(;r<t.length&&t[r]!==")";){let c=r;for(;r<t.length&&t[r]!=="|"&&t[r]!==")";)r++;let l=t.substring(c,r);if(l=l.trim(),!OP(l,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${l}"`);u.push(l),t[r]==="|"&&(r++,r=ka(t,r))}if(t[r]!==")")throw new Error("Unterminated list of notations");r++,o+=" ("+u.join("|")+")"}else{let u=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;o+=t.substring(u,r);let c=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!c.includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}r=ka(t,r);let a="";return t.substring(r,r+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",r+=8):t.substring(r,r+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",r+=7):[r,a]=this.readIdentifierVal(t,r,"ATTLIST"),{elementName:i,attributeName:s,attributeType:o,defaultValue:a,index:r}}},ka=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function eE(e,t,r){for(let n=0;n<t.length;n++)if(t[n]!==e[r+n+1])return!1;return!0}function OP(e,t){if(TZ(e,{xmlVersion:t}))return e;throw new Error(`Invalid entity name ${e}`)}var vyr=/^[-+]?0x[a-fA-F0-9]+$/,Eyr=/^0b[01]+$/,_yr=/^0o[0-7]+$/,Syr=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,byr={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function xZ(e,t={}){if(t=Object.assign({},byr,t),!e||typeof e!="string")return e;let r=e.trim();if(r.length===0)return e;if(t.skipLike!==void 0&&t.skipLike.test(r))return e;if(r==="0")return 0;if(t.hex&&vyr.test(r))return AZ(r,16);if(t.binary&&Eyr.test(r))return AZ(r,2);if(t.octal&&_yr.test(r))return AZ(r,8);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return Ayr(e,r,t);{let n=Syr.exec(r);if(n){let i=n[1]||"",s=n[2],o=xyr(n[3]),a=i?e[s.length+1]===".":e[s.length]===".";if(!t.leadingZeros&&(s.length>1||s.length===1&&!a))return e;{let u=Number(r),c=String(u);if(u===0)return u;if(c.search(/[eE]/)!==-1)return t.eNotation?u:e;if(r.indexOf(".")!==-1)return c==="0"||c===o||c===`${i}${o}`?u:e;let l=s?o:r;return s?l===c||i+l===c?u:e:l===c||l===i+c?u:e}}else return e}}else return wyr(e,Number(r),t)}var Tyr=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Ayr(e,t,r){if(!r.eNotation)return e;let n=t.match(Tyr);if(n){let i=n[1]||"",s=n[3].indexOf("e")===-1?"E":"e",o=n[2],a=i?e[o.length+1]===s:e[o.length]===s;return o.length>1&&a?e:o.length===1&&(n[3].startsWith(`.${s}`)||n[3][0]===s)?Number(t):o.length>0?r.leadingZeros&&!a?(t=(n[1]||"")+n[3],Number(t)):e:Number(t)}else return e}function xyr(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substring(0,e.length-1))),e}function AZ(e,t){let r=e.trim();if((t===2||t===8)&&(e=r.substring(2)),parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function wyr(e,t,r){let n=t===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return n?"Infinity":"-Infinity";default:return e}}function wZ(e){return typeof e=="function"?e:Array.isArray(e)?t=>{for(let r of e)if(typeof r=="string"&&t===r||r instanceof RegExp&&r.test(t))return!0}:()=>!1}var tE=class{constructor(t,r={},n){this.pattern=t,this.separator=r.separator||".",this.segments=this._parse(t),this.data=n,this._hasDeepWildcard=this.segments.some(i=>i.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(i=>i.attrName!==void 0),this._hasPositionSelector=this.segments.some(i=>i.position!==void 0)}_parse(t){let r=[],n=0,i="";for(;n<t.length;)t[n]===this.separator?n+1<t.length&&t[n+1]===this.separator?(i.trim()&&(r.push(this._parseSegment(i.trim())),i=""),r.push({type:"deep-wildcard"}),n+=2):(i.trim()&&r.push(this._parseSegment(i.trim())),i="",n++):(i+=t[n],n++);return i.trim()&&r.push(this._parseSegment(i.trim())),r}_parseSegment(t){let r={type:"tag"},n=null,i=t,s=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(i=s[1]+s[3],s[2])){let l=s[2].slice(1,-1);l&&(n=l)}let o,a=i;if(i.includes("::")){let l=i.indexOf("::");if(o=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!o)throw new Error(`Invalid namespace in pattern: ${t}`)}let u,c=null;if(a.includes(":")){let l=a.lastIndexOf(":"),f=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(u=f,c=p):u=a}else u=a;if(!u)throw new Error(`Invalid segment pattern: ${t}`);if(r.tag=u,o&&(r.namespace=o),n)if(n.includes("=")){let l=n.indexOf("=");r.attrName=n.substring(0,l).trim(),r.attrValue=n.substring(l+1).trim()}else r.attrName=n.trim();if(c){let l=c.match(/^nth\((\d+)\)$/);l?(r.position="nth",r.positionValue=parseInt(l[1],10)):r.position=c}return r}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var lb=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;let r=t.length,i=t.segments[t.segments.length-1]?.tag;if(!i||i==="*")this._wildcardByDepth.has(r)||this._wildcardByDepth.set(r,[]),this._wildcardByDepth.get(r).push(t);else{let s=`${r}:${i}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}return this}addAll(t){for(let r of t)this.add(r);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return this.findMatch(t)!==null}findMatch(t){let r=t.getDepth(),n=t.getCurrentTag(),i=`${r}:${n}`,s=this._byDepthAndTag.get(i);if(s){for(let a=0;a<s.length;a++)if(t.matches(s[a]))return s[a]}let o=this._wildcardByDepth.get(r);if(o){for(let a=0;a<o.length;a++)if(t.matches(o[a]))return o[a]}for(let a=0;a<this._deepWildcards.length;a++)if(t.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}};var CZ=class{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){let t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){let t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){let r=this._matcher.path;if(r.length!==0)return r[r.length-1].values?.[t]}hasAttr(t){let r=this._matcher.path;if(r.length===0)return!1;let n=r[r.length-1];return n.values!==void 0&&t in n.values}getPosition(){let t=this._matcher.path;return t.length===0?-1:t[t.length-1].position??0}getCounter(){let t=this._matcher.path;return t.length===0?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,r=!0){return this._matcher.toString(t,r)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}},fb=class{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new CZ(this)}push(t,r=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);let s=this.siblingStacks[i],o=n?`${n}:${t}`:t,a=s.get(o)||0,u=0;for(let l of s.values())u+=l;s.set(o,a+1);let c={tag:t,position:u,counter:a};n!=null&&(c.namespace=n),r!=null&&(c.values=r),this.path.push(c)}pop(){if(this.path.length===0)return;this._pathStringCache=null;let t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){let r=this.path[this.path.length-1];t!=null&&(r.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(this.path.length!==0)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(this.path.length===0)return!1;let r=this.path[this.path.length-1];return r.values!==void 0&&t in r.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,r=!0){let n=t||this.separator;if(n===this.separator&&r===!0){if(this._pathStringCache!==null)return this._pathStringCache;let s=this.path.map(o=>o.namespace?`${o.namespace}:${o.tag}`:o.tag).join(n);return this._pathStringCache=s,s}return this.path.map(s=>r&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(n)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){let r=t.segments;return r.length===0?!1:t.hasDeepWildcard()?this._matchWithDeepWildcard(r):this._matchSimple(r)}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let r=0;r<t.length;r++)if(!this._matchSegment(t[r],this.path[r],r===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let r=this.path.length-1,n=t.length-1;for(;n>=0&&r>=0;){let i=t[n];if(i.type==="deep-wildcard"){if(n--,n<0)return!0;let s=t[n],o=!1;for(let a=r;a>=0;a--)if(this._matchSegment(s,this.path[a],a===this.path.length-1)){r=a-1,n--,o=!0;break}if(!o)return!1}else{if(!this._matchSegment(i,this.path[r],r===this.path.length-1))return!1;r--,n--}}return n<0}_matchSegment(t,r,n){if(t.tag!=="*"&&t.tag!==r.tag||t.namespace!==void 0&&t.namespace!=="*"&&t.namespace!==r.namespace||t.attrName!==void 0&&(!n||!r.values||!(t.attrName in r.values)||t.attrValue!==void 0&&String(r.values[t.attrName])!==String(t.attrValue)))return!1;if(t.position!==void 0){if(!n)return!1;let i=r.counter??0;if(t.position==="first"&&i!==0)return!1;if(t.position==="odd"&&i%2!==1)return!1;if(t.position==="even"&&i%2!==0)return!1;if(t.position==="nth"&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(r=>({...r})),this.siblingStacks=t.siblingStacks.map(r=>new Map(r))}readOnly(){return this._view}};function Cyr(e,t){if(!e)return{};let r=t.attributesGroupName?e[t.attributesGroupName]:e;if(!r)return{};let n={};for(let i in r)if(i.startsWith(t.attributeNamePrefix)){let s=i.substring(t.attributeNamePrefix.length);n[s]=r[i]}else n[i]=r[i];return n}function Oyr(e){if(!e||typeof e!="string")return;let t=e.indexOf(":");if(t!==-1&&t>0){let r=e.substring(0,t);if(r!=="xmlns")return r}}var DP=class{constructor(t,r){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Iyr,this.parseTextData=Pyr,this.resolveNameSpace=Dyr,this.buildAttributesMap=Nyr,this.isItStopNode=Uyr,this.replaceEntitiesValue=Myr,this.readStopNodeData=qyr,this.saveTextToParentTag=Fyr,this.addChild=Lyr,this.ignoreAttributesFn=wZ(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let n={...CP};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities=="object"?n=this.options.htmlEntities:this.options.htmlEntities===!0&&(n={..._Z,...bk}),this.entityDecoder=new cb({namedEntities:{...n,...r},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo}})),this.matcher=new fb,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new lb;let i=this.options.stopNodes;if(i&&i.length>0){for(let s=0;s<i.length;s++){let o=i[s];typeof o=="string"?this.stopNodeExpressionsSet.add(new tE(o)):o instanceof tE&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}};function Pyr(e,t,r,n,i,s,o){let a=this.options;if(e!==void 0&&(a.trimValues&&!n&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,r));let u=a.jPath?r.toString():r,c=a.tagValueProcessor(t,e,u,i,s);return c==null?e:typeof c!=typeof e||c!==e?c:a.trimValues||e.trim()===e?DZ(e,a.parseTagValue,a.numberParseOptions):e}}function Dyr(e){if(this.options.removeNSPrefix){let t=e.split(":"),r=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=r+t[1])}return e}var Ryr=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Nyr(e,t,r,n=!1){let i=this.options;if(n===!0||i.ignoreAttributes!==!0&&typeof e=="string"){let s=Ek(e,Ryr),o=s.length,a={},u=new Array(o),c=!1,l={};for(let d=0;d<o;d++){let h=this.resolveNameSpace(s[d][1]),g=s[d][4];if(h.length&&g!==void 0){let _=g;i.trimValues&&(_=_.trim()),_=this.replaceEntitiesValue(_,r,this.readonlyMatcher),u[d]=_,l[h]=_,c=!0}}c&&typeof t=="object"&&t.updateCurrent&&t.updateCurrent(l);let f=i.jPath?t.toString():this.readonlyMatcher,p=!1;for(let d=0;d<o;d++){let h=this.resolveNameSpace(s[d][1]);if(this.ignoreAttributesFn(h,f))continue;let g=i.attributeNamePrefix+h;if(h.length)if(i.transformAttributeName&&(g=i.transformAttributeName(g)),g=pke(g,i),s[d][4]!==void 0){let _=u[d],S=i.attributeValueProcessor(h,_,f);S==null?a[g]=_:typeof S!=typeof _||S!==_?a[g]=S:a[g]=DZ(_,i.parseAttributeValue,i.numberParseOptions),p=!0}else i.allowBooleanAttributes&&(a[g]=!0,p=!0)}if(!p)return;if(i.attributesGroupName&&!i.preserveOrder){let d={};return d[i.attributesGroupName]=a,d}return a}}var Iyr=function(e){e=e.replace(/\r\n?/g,`
|
|
660
|
-
`);let t=new Ua("!xml"),r=t,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,s=new PP(i.processEntities),o=e.length;for(let a=0;a<o;a++)if(e[a]==="<"){let c=e.charCodeAt(a+1);if(c===47){let l=pb(e,">",a,"Closing Tag is not closed."),f=e.substring(a+2,l).trim();if(i.removeNSPrefix){let d=f.indexOf(":");d!==-1&&(f=f.substr(d+1))}f=OZ(i.transformTagName,f,"",i).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));let p=this.matcher.getCurrentTag();if(f&&i.unpairedTagsSet.has(f))throw new Error(`Unpaired tag can not be used as closing tag: </${f}>`);p&&i.unpairedTagsSet.has(p)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),n="",a=l}else if(c===63){let l=PZ(e,a,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let f=this.buildAttributesMap(l.tagExp,this.matcher,l.tagName,!0);if(f){let p=f[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(p)||1),s.setXmlVersion(Number(p)||1)}if(!(i.ignoreDeclaration&&l.tagName==="?xml"||i.ignorePiTags)){let p=new Ua(l.tagName);p.add(i.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&i.ignoreAttributes!==!0&&(p[":@"]=f),this.addChild(r,p,this.readonlyMatcher,a)}a=l.closeIndex+1}else if(c===33&&e.charCodeAt(a+2)===45&&e.charCodeAt(a+3)===45){let l=pb(e,"-->",a+4,"Comment is not closed.");if(i.commentPropName){let f=e.substring(a+4,l-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(i.commentPropName,[{[i.textNodeName]:f}])}a=l}else if(c===33&&e.charCodeAt(a+2)===68){let l=s.readDocType(e,a);this.entityDecoder.addInputEntities(l.entities),a=l.i}else if(c===33&&e.charCodeAt(a+2)===91){let l=pb(e,"]]>",a,"CDATA is not closed.")-2,f=e.substring(a+9,l);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let p=this.parseTextData(f,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);p==null&&(p=""),i.cdataPropName?r.add(i.cdataPropName,[{[i.textNodeName]:f}]):r.add(i.textNodeName,p),a=l+2}else{let l=PZ(e,a,i.removeNSPrefix);if(!l){let N=e.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${N}"`)}let f=l.tagName,p=l.rawTagName,d=l.tagExp,h=l.attrExpPresent,g=l.closeIndex;if({tagName:f,tagExp:d}=OZ(i.transformTagName,f,d,i),i.strictReservedNames&&(f===i.commentPropName||f===i.cdataPropName||f===i.textNodeName||f===i.attributesGroupName))throw new Error(`Invalid tag name: ${f}`);r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));let _=r;_&&i.unpairedTagsSet.has(_.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let S=!1;d.length>0&&d.lastIndexOf("/")===d.length-1&&(S=!0,f[f.length-1]==="/"?(f=f.substr(0,f.length-1),d=f):d=d.substr(0,d.length-1),h=f!==d);let T=null,A={},w;w=Oyr(p),f!==t.tagname&&this.matcher.push(f,{},w),f!==d&&h&&(T=this.buildAttributesMap(d,this.matcher,f),T&&(A=Cyr(T,i))),f!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let x=a;if(this.isCurrentNodeStopNode){let N="";if(S)a=l.closeIndex;else if(i.unpairedTagsSet.has(f))a=l.closeIndex;else{let D=this.readStopNodeData(e,p,g+1);if(!D)throw new Error(`Unexpected end of ${p}`);a=D.i,N=D.tagContent}let F=new Ua(f);T&&(F[":@"]=T),F.add(i.textNodeName,N),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,F,this.readonlyMatcher,x)}else{if(S){({tagName:f,tagExp:d}=OZ(i.transformTagName,f,d,i));let N=new Ua(f);T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(f)){let N=new Ua(f);T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=l.closeIndex;continue}else{let N=new Ua(f);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),r=N}n="",a=g}}}else n+=e[a];return t.child};function Lyr(e,t,r,n){this.options.captureMetaData||(n=void 0);let i=this.options.jPath?r.toString():r,s=this.options.updateTag(t.tagname,i,t[":@"]);s===!1||(typeof s=="string"&&(t.tagname=s),e.addChild(t,n))}function Myr(e,t,r){let n=this.options.processEntities;if(!n||!n.enabled)return e;if(n.allowedTags){let i=this.options.jPath?r.toString():r;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(t):n.allowedTags(t,i)))return e}if(n.tagFilter){let i=this.options.jPath?r.toString():r;if(!n.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function Fyr(e,t,r,n){return e&&(n===void 0&&(n=t.child.length===0),e=this.parseTextData(e,t.tagname,r,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,n),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Uyr(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function kyr(e,t,r=">"){let n=0,i=e.length,s=r.charCodeAt(0),o=r.length>1?r.charCodeAt(1):-1,a="",u=t;for(let c=t;c<i;c++){let l=e.charCodeAt(c);if(n)l===n&&(n=0);else if(l===34||l===39)n=l;else if(l===s)if(o!==-1){if(e.charCodeAt(c+1)===o)return a+=e.substring(u,c),{data:a,index:c}}else return a+=e.substring(u,c),{data:a,index:c};else l===9&&!n&&(a+=e.substring(u,c)+" ",u=c+1)}}function pb(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i+t.length-1}function Byr(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i}function PZ(e,t,r,n=">"){let i=kyr(e,t+1,n);if(!i)return;let s=i.data,o=i.index,a=s.search(/\s/),u=s,c=!0;a!==-1&&(u=s.substring(0,a),s=s.substring(a+1).trimStart());let l=u;if(r){let f=u.indexOf(":");f!==-1&&(u=u.substr(f+1),c=u!==i.data.substr(f+1))}return{tagName:u,tagExp:s,closeIndex:o,attrExpPresent:c,rawTagName:l}}function qyr(e,t,r){let n=r,i=1,s=e.length;for(;r<s;r++)if(e[r]==="<"){let o=e.charCodeAt(r+1);if(o===47){let a=Byr(e,">",r,`${t} is not closed`);if(e.substring(r+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(n,r),i:a};r=a}else if(o===63)r=pb(e,"?>",r+1,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===45&&e.charCodeAt(r+3)===45)r=pb(e,"-->",r+3,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===91)r=pb(e,"]]>",r,"StopNode is not closed.")-2;else{let a=PZ(e,r,!1);a&&((a&&a.tagName)===t&&a.tagExp[a.tagExp.length-1]!=="/"&&i++,r=a.closeIndex)}}}function DZ(e,t,r){if(t&&typeof e=="string"){let n=e.trim();return n==="true"?!0:n==="false"?!1:xZ(e,r)}else return VUe(e)?e:""}function OZ(e,t,r,n){if(e){let i=e(t);r===t&&(r=i),t=i}return t=pke(t,n),{tagName:t,tagExp:r}}function pke(e,t){if(_k.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return xP.includes(e)?t.onDangerousProperty(e):e}var RZ=Ua.getMetaDataSymbol();function jyr(e,t){if(!e||typeof e!="object")return{};if(!t)return e;let r={};for(let n in e)if(n.startsWith(t)){let i=n.substring(t.length);r[i]=e[n]}else r[n]=e[n];return r}function NZ(e,t,r,n){return dke(e,t,r,n)}function dke(e,t,r,n){let i,s={};for(let o=0;o<e.length;o++){let a=e[o],u=Vyr(a);if(u!==void 0&&u!==t.textNodeName){let c=jyr(a[":@"]||{},t.attributeNamePrefix);r.push(u,c)}if(u===t.textNodeName)i===void 0?i=a[u]:i+=""+a[u];else{if(u===void 0)continue;if(a[u]){let c=dke(a[u],t,r,n),l=$yr(c,t);if(Object.keys(c).length===0&&t.alwaysCreateTextNode&&(c[t.textNodeName]=""),a[":@"]?Gyr(c,a[":@"],n,t):Object.keys(c).length===1&&c[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?c=c[t.textNodeName]:Object.keys(c).length===0&&(t.alwaysCreateTextNode?c[t.textNodeName]="":c=""),a[RZ]!==void 0&&typeof c=="object"&&c!==null&&(c[RZ]=a[RZ]),s[u]!==void 0&&Object.prototype.hasOwnProperty.call(s,u))Array.isArray(s[u])||(s[u]=[s[u]]),s[u].push(c);else{let f=t.jPath?n.toString():n;t.isArray(u,f,l)?s[u]=[c]:s[u]=c}u!==void 0&&u!==t.textNodeName&&r.pop()}}}return typeof i=="string"?i.length>0&&(s[t.textNodeName]=i):i!==void 0&&(s[t.textNodeName]=i),s}function Vyr(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(n!==":@")return n}}function Gyr(e,t,r,n){if(t){let i=Object.keys(t),s=i.length;for(let o=0;o<s;o++){let a=i[o],u=a.startsWith(n.attributeNamePrefix)?a.substring(n.attributeNamePrefix.length):a,c=n.jPath?r.toString()+"."+u:r;n.isArray(a,c,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function $yr(e,t){let{textNodeName:r}=t,n=Object.keys(e).length;return!!(n===0||n===1&&(e[r]||typeof e[r]=="boolean"||e[r]===0))}var zf=class{constructor(t){this.externalEntities={},this.options=uke(t)}parse(t,r){if(typeof t!="string"&&t.toString)t=t.toString();else if(typeof t!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=Sk(t,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new DP(this.options,this.externalEntities),i=n.parseXml(t);return this.options.preserveOrder||i===void 0?i:NZ(i,this.options,n.matcher,n.readonlyMatcher)}addEntity(t,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=r}static getMetaDataSymbol(){return Ua.getMetaDataSymbol()}};var db={validate:Sk};var Bm=class extends Pa{static ADT_DISCOVERY_SERVICE_PATH="/sap/bc/adt/discovery";schemaStore=new vk;log;async getServiceDefinition(t){await this.checkOrLoadAdtDiscoverySchema();let r=this.schemaStore.getAdtCollection(t);return this.validateServiceSchema(t,r)?r:(this.log.warn("Invalid Discovery Schema"),null)}validateServiceSchema(t,r){return r?r.href?!0:(this.log.warn(`Empty href in schema: ${t.term} - ${t.scheme}`),!1):(this.log.warn(`Schema Not Found: ${t.term} - ${t.scheme}`),!1)}async checkOrLoadAdtDiscoverySchema(){if(!this.schemaStore.isAdtSchemaEmpty())return;let t=await this.get("",{headers:{Accept:"application/*"}}),r=this.parseAdtSchemaData(t.data);this.schemaStore.updateSchemaData(r)}parseAdtSchemaData(t){if(db.validate(t)!==!0)return null;let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new zf(r).parse(t,!0);return i.service?i:null}};var Cd=class extends Pa{static PATH="/sap/bc/ui2/app_index";log;async search(t={},r){let n={...t};r&&(n.fields=r.join(","));let i=await this.get("/",{params:n});return JSON.parse(i.data).results}async getIsManiFirstSupported(t){try{let r={id:t},n=await this.get("/ui5_app_mani_first_supported",{params:r});return JSON.parse(n.data)}catch(r){throw this.log.error(`Fail fetching ui5_app_mani_first_supported for app with id: ${t}.`),this.log.debug(r),r}}async getAppInfo(t){try{let r=await this.get("/ui5_app_info_json",{params:{id:t}});return JSON.parse(r.data)}catch(r){throw vF(r)?this.log.error(`Failed fetching ui5_app_info_json for app with id ${t}.`):this.log.error(`Parsing error: ui5_app_info_json is not in expected format for app with id ${t}.`),this.log.debug(r),r}}};var RP={UI:"UI",NotClassified:"Not Classified",WebApi:"WEB_API",NotDetermined:"Not Determined"},hb=class extends bm{entitySet;services;isS4Cloud;async listServices(t=!1){return this.services||(this.services=await this.fetchServices(t)),this.services}};var hke="ServiceCollection",mke="RecommendedServiceCollection",Hyr="((IsSapService%20eq%20true)and(ReleaseStatus%20eq%20%27RELEASED%27))or((IsSapService%20eq%20false))",qm=class extends hb{static PATH="/sap/opu/odata/IWFND/CATALOGSERVICE;v=2";async determineEntitySet(){let t=await this.document();this.entitySet=t.EntitySets.includes(mke)?mke:hke}getServicePath(t,r){let n;try{n=new URL(t)}catch{n=new URL(t,r)}return n.pathname}mapServices(t){return t.map(r=>{let n=this.getServicePath(r.ServiceUrl,this.defaults.baseURL);return{id:r.ID,name:r.TechnicalServiceName,path:n,serviceVersion:r.TechnicalServiceVersion+"",odataVersion:Er.v2,serviceType:r.ServiceType}})}async fetchServices(){let t={$format:"json"};this.entitySet||await this.determineEntitySet(),this.entitySet===hke&&await this.isS4Cloud&&(t.$filter=Hyr);let n=(await this.get(`/${this.entitySet}`,{params:t})).odata();if(If.containsError(n))throw new If(n);return this.mapServices(n)}async findService({title:t,path:r}){let n=1;if(!t){let u=r.replace(/\/$/,"").split("/").pop().split(";");if(t=u[0].toUpperCase(),!t)throw new Error(`Cannot determine service title from path: ${r}`);u.slice(1).forEach(l=>{let[f,p]=l.split("=");f==="v"&&(n=Number.parseInt(p,10))})}let i={$format:"json",$filter:`Title eq '${t}' and TechnicalServiceVersion eq ${n}`},s=this.entitySet?`/${this.entitySet}`:"/ServiceCollection",a=(await this.get(s,{params:i})).odata();if(a.length>1){let u=a.filter(c=>c.ServiceUrl?.toUpperCase().includes((r||t).toUpperCase()));if(u.length>1)this.log.warn("Service filter was not sufficient to identify one service.");else if(u.length>0)return this.log.info(`Service filter chose service: ${u[0].TechnicalServiceName}`),u[0]}return a.length>0?a[0]:void 0}async getServiceAnnotations({id:t,title:r,path:n}){if(!t){let i=await this.findService({title:r,path:n});i&&(t=i.ID)}return t?(await this.get(`/ServiceCollection('${encodeURIComponent(t)}')/Annotations`,{params:{$format:"json"}})).odata():[]}async getAnnotations({id:t,title:r,path:n}){if(!t&&!r&&!n)throw new Error("No filter parameters passed in");let i=await this.getServiceAnnotations({id:t,title:r,path:n}),s=[];for(let o of i){let a=`/Annotations(TechnicalName='${encodeURIComponent(o.TechnicalName)}',Version='${o.Version}')/$value/`,u=await this.get(a,{headers:{Accept:"application/xml"}});u.data?s.push({TechnicalName:o.TechnicalName,Version:o.Version,Definitions:u.data,Uri:this.defaults.baseURL+a}):this.log.warn(`No annotations found for TechnicalName=${o.TechnicalName}, Version=${o.Version}`)}return s}async getServiceType(t){let r,{ID:n}=await this.findService({path:t});if(n){let i=await this.get(`/ServiceTypeForHUBServices('${encodeURIComponent(n)}')`);i&&(r=i.odata().ServiceType)}return r}};var gke="RecommendedServices",yke="Services",mb=class extends hb{logger=new vs;static PATH="/sap/opu/odata4/iwfnd/config/default/iwfnd/catalog/0002";mapServices(t,r,n=!1){let i=[],s=new Set;return t.filter(o=>o?.DefaultSystem?.[r]?.length>0).forEach(o=>{i.push(...o.DefaultSystem[r].flatMap(a=>{let u=a.ServiceUrl.split("?").shift();if(n){let c=`${a.ServiceId}|${u}`;if(s.has(c))return[];s.add(c)}return{id:a.ServiceId,group:o.GroupId,path:u,name:`${o.GroupId} > ${a.ServiceAlias||a.ServiceId}`,serviceVersion:a.ServiceVersion,odataVersion:Er.v4,serviceType:a.ServiceType}}))}),i}async fetchServicesNextLink(){if(this.entitySet===void 0){let o=await this.metadata();this.entitySet=o.includes('Name="RecommendedServices"')?gke:yke}let t=new URLSearchParams([["$count","true"],["$expand",`DefaultSystem($expand=${this.entitySet})`]]),n=(await this.get("/ServiceGroups",{params:t},!0)).odata(),i=n.value,s=1;for(;n["@odata.nextLink"];){let o=new URL(n["@odata.nextLink"],this.defaults.baseURL);n=(await this.get("/ServiceGroups",{params:o.searchParams},!0)).odata(),s++,i.push(...n.value)}if(this.logger.log(`Fetched ${i.length} service groups in ${s} requests.`),If.containsError(i))throw new If(i);return this.mapServices(i,this.entitySet)}async fetchServices(t=!1){return t?this.fetchServicesNextLink():this.fetchServicesParallel()}async fetchServicesParallel(){if(this.entitySet===void 0){let c=await this.metadata();this.entitySet=c.includes('Name="RecommendedServices"')?gke:yke}let r=new URLSearchParams([["$count","true"],["$top","1000"],["$expand",`DefaultSystem($expand=${this.entitySet})`]]),i=(await this.get("/ServiceGroups",{params:r},!0)).odata(),s=i.value,o=i["@odata.count"],a=Number.parseInt(i["@odata.nextLink"]?.split("skiptoken=")[1],10),u=1;if(!Number.isNaN(a)){let c=Math.ceil(o/a),l=Array.from({length:c-1},(p,d)=>{let h=new URLSearchParams([["$count","true"],["$skip",String((d+1)*a)],["$top",a.toString()],["$expand",`DefaultSystem($expand=${this.entitySet})`]]);return u++,this.get("/ServiceGroups",{params:h},!0)});(await Promise.all(l)).forEach(p=>{let d=p.odata();s.push(...d.value)})}if(this.logger.log(`Fetched ${s.length} service groups in ${u} requests.`),If.containsError(s))throw new If(s);return this.mapServices(s,this.entitySet,!0)}getAnnotations(){return Promise.resolve([])}getServiceType(){return Promise.resolve(void 0)}};var NP;(function(e){e.SAP="SAP",e.Customer="CUSTOMER"})(NP||(NP={}));var ti=class extends Pa{log;serviceSchema;static getAdtCatagory(){throw new Error("NEEDS TO BE IMPLEMENTED BY AdtService SUBCLASSES")}attachAdtSchema(t){this.serviceSchema=t}parseResponse(t){if(db.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0};return new zf(r).parse(t,!0)}};var IP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/ato",term:"settings"};static getAdtCatagory(){return e.adtCategory}async getAtoInfo(){let t={headers:{Accept:"application/*"}},r=await this.get("",t);return this.parseAtoResponse(r.data)}parseAtoResponse(t){if(db.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new zf(r).parse(t,!0);return i.settings?i.settings:{}}};var fBe=be(vke(),1),bvr=be(lBe(),1);var WP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/respository",term:"generators"};static getAdtCatagory(){return e.adtCategory}async getUIServiceGeneratorConfig(t){let r=await this.get("",{headers:{Accept:"application/atom+xml;type=feed"},params:{referencedObject:t,type:"webapi"}}),n=this.parseResponse(r.data).feed?.entry;if(n?.id==="published-ui-service")return n;throw new Error("UI Service Generator not found")}};var YP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/respository",term:"generators"};static getAdtCatagory(){return e.adtCategory}id;async getRAPGeneratorConfig(){let t=await this.get("",{headers:{Accept:"application/atom+xml;type=feed"},params:{type:"webapi",fetchAllGenerators:!0}}),r=this.parseResponse(t.data).feed?.entry??[];r&&!Array.isArray(r)&&(r=[r]);let n=r.find(i=>i.id==="published-x-ui-service");if(n)return n;throw new Error("OData Service Generator not found")}};var zP=class extends ti{packageName;contentType;configure(t,r){this.packageName=r}setContentType(t){this.contentType=t}async validate(t){let r=await this.post("/validation",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.validationMessages.v1+xml, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage"},params:{package:this.packageName}});return this.parseValidateResponse(r.data)}async getTechnicalDetails(t){let r=await this.post("/preview",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.objects.massoperation.v1+xml"},params:{package:this.packageName}});return this.parsePreviewResponse(r.data)}async generate(t){return(await this.post("",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.generator.v1+json"},params:{package:this.packageName}})).status}parseValidateResponse(t){let n=this.parseResponse(t).validationMessages;return Array.isArray(n)||(n=[n]),n.map(i=>i.validationMessage||{})||[]}parsePreviewResponse(t){let n=(this.parseResponse(t).group.group||[]).find(a=>a.name==="Business Service Layer");if(!n)return;let i=Array.isArray(n.object)?n.object:[n.object],s=i.find(a=>a.objectReference?.type==="SRVD/SRV"),o=i.find(a=>a.objectReference?.type==="SRVB/SVB");if(!(!s||!o))return{serviceName:o.objectReference?.name||"",serviceDefinitionName:s.objectReference?.name||"",serviceVersion:"0001"}}};var xb=class extends ti{referencedObject;contentType;configure(t,r,n){this.referencedObject=r,this.contentType=n}async getSchema(){let t=await this.get("/schema",{headers:{Accept:"application/vnd.sap.adt.repository.generator.schema.v1+json"},params:{referencedObject:this.referencedObject.uri}});return JSON.parse(t.data)}async getContent(t){let n=(await this.get("/content",{headers:{Accept:this.contentType},params:{referencedObject:this.referencedObject.uri,package:t}})).data,i=JSON.parse(n);return i.metadata||(i.metadata={package:t}),JSON.stringify(i)}async validatePackage(t){let r=await this.get("/validation",{headers:{Accept:"application/vnd.sap.adt.validationMessages.v1+xml"},params:{referencedObject:this.referencedObject.uri,package:t,checks:"package"}});return this.parseResponse(r.data)}async validateContent(t){let r=await this.post("/validation",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.validationMessages.v1+xml"},params:{referencedObject:this.referencedObject.uri,checks:"package,referencedobject,authorization"}});return this.parseResponse(r.data).validationMessages?.validationMessage}async generate(t,r){let n=await this.post("",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.generator.v1+json, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage"},params:{referencedObject:this.referencedObject.uri,corrNr:r}});return this.parseResponse(n.data)}};var Uk=class extends ti{async getSystemInfo(){let t={headers:{Accept:"application/vnd.sap.adt.core.http.systeminformation.v1+json"}},r=await this.get("/sap/bc/adt/core/http/systeminformation",t);if(typeof r.data=="string")try{return JSON.parse(r.data)}catch(n){this.log.error(`System info could not be parsed from response. Error: ${n.message}`)}else return r.data}};var KP=class extends Pa{static PATH="/sap/public/bc/ui5_ui5";log;async getUI5Version(){try{let t=await this.get("/bootstrap_info.json",{transformResponse:n=>JSON.parse(n)}),{Version:r}=t.data;if(!r)throw new Error("UI5 version not provided.");return r}catch(t){throw this.log.error("Could not get UI5 Version."),this.log.debug(t),t}}};var Va=class extends km{atoSettings;_publicUrl;_systemInfo;async user(){return await Promise.resolve(this.defaults.auth?.username)||(await this.getSystemInfo())?.userName}async getSystemInfo(){if(this._systemInfo)return this._systemInfo;try{let t=this.createService("",Uk);this._systemInfo=await t.getSystemInfo()}catch(t){this.log.error(`An error occurred retrieving system info: ${t}`)}return this._systemInfo}setAtoInfo(t){this.atoSettings=t}async getAtoInfo(){if(this.atoSettings)return this.atoSettings;let t;try{t=await this.getAdtService(IP),t?this.atoSettings=await t.getAtoInfo():this.atoSettings={}}catch{this.atoSettings={}}return this.atoSettings}set publicUrl(t){this._publicUrl=t}get publicUrl(){return this._publicUrl||this.defaults.baseURL}async isAbapCloud(){return this.atoSettings===void 0&&await this.getAtoInfo(),this.atoSettings.tenantType===NP.Customer&&this.atoSettings.operationsType==="C"}getAdtCatalogService(){if(!this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]){let t=this.createService(Bm.ADT_DISCOVERY_SERVICE_PATH,Bm);this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]=t}return this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]}catalog(t){let r;if(t===Er.v2)r=this.services[qm.PATH]??this.createService(qm.PATH,qm);else if(t===Er.v4)r=this.services[mb.PATH]??this.createService(mb.PATH,mb);else throw new Error("not implemented yet");return Object.defineProperty(r,"isAbapCloud",{get:this.isAbapCloud.bind(this)}),r}getUi5AbapRepository(t){let r=t??ab.PATH;return this.services[r]||(this.services[r]=this.createService(r,ab)),this.services[r]}getAppIndex(){return this.services[Cd.PATH]||(this.services[Cd.PATH]=this.createService(Cd.PATH,Cd)),this.services[Cd.PATH]}getLayeredRepository(t){let r=t??ub.PATH;return this.services[r]||(this.services[r]=this.createService(r,ub)),this.services[r]}async getAdtService(t){let r=t.name;if(!this.services[r]){let i=await this.getAdtCatalogService().getServiceDefinition(t.getAdtCatagory());if(!i)return null;this.services[r]=this.createService(i.href,t),this.services[r].attachAdtSchema(i)}return this.services[r]}getUI5VersionService(){let t=KP.PATH;return this.services[t]||(this.services[t]=this.createService(t,KP)),this.services[t]}async getUiServiceGenerator(t){let r=await this.getAdtService(WP);if(!r)throw new Error("Generators are not supported on this system");let n=await r.getUIServiceGeneratorConfig(t.uri),i=this.createService(this.getServiceUrlFromConfig(n),xb);return i.configure(n,t,this.getContentType(n)),i}async getODataServiceGenerator(t){let r=await this.getAdtService(YP);if(!r)throw new Error("RAP Generator are not support on this system");let n=await r.getRAPGeneratorConfig(),i=this.createService(this.getServiceUrlFromConfig(n),zP);return i.setContentType(this.getContentType(n)),i.configure(n,t||"$TMP"),i}async fetchExternalServices(t){let r=[],n=t.map(async i=>{let{serviceRootPath:s,value:o}=i,a=(0,pBe.join)(s,o).replace("/$metadata",""),u=this.service(a);try{let c=await u.metadata();i.type==="value-list"?r.push({type:"value-list",path:a,target:i.target,metadata:c}):i.type==="code-list"&&r.push({type:"code-list",path:a,metadata:c})}catch(c){this.log.warn(`Could not fetch value list reference metadata from ${a}, ${c.message}`)}});return await Promise.allSettled(n),r}getServiceUrlFromConfig(t){if(Array.isArray(t.link)&&!t.link[0]?.href)throw new Error("No service URL found in the generator config");let r=t.link[0].href.indexOf(t.id)+t.id.length;return t.link[0].href.substring(0,r)}getContentType(t){return(t.link?.find(n=>typeof n.href=="string"&&n.href.includes("/content"))).type}async createLockServiceBindingGenerator(t){return this.createService(t,xb)}};var vHe=be(BGe(),1),ap=be(nq(),1);var eg;(function(e){e.H2O_URL="H2O_URL",e.HTTP_PROXY="HTTP_PROXY",e.HTTPS_PROXY="HTTPS_PROXY"})(eg||(eg={}));var iq;(function(e){e.HTTP="HTTP",e.LDAP="LDAP",e.MAIL="MAIL",e.RFC="RFC"})(iq||(iq={}));var sq;(function(e){e.DEDICATED="Dedicated",e.COMMON="Common"})(sq||(sq={}));var op;(function(e){e.BASIC_AUTHENTICATION="BasicAuthentication",e.CLIENT_CERT_AUTHENTICATION="ClientCertificateAuthentication",e.NO_AUTHENTICATION="NoAuthentication",e.OAUTH2_CLIENT_CREDENTIALS="OAuth2ClientCredentials",e.OAUTH2_JWT_BEARER="OAuth2JWTBearer",e.OAUTH2_PASSWORD="OAuth2Password",e.OAUTH2_REFRESH_TOKEN="OAuth2RefreshToken",e.OAUTH2_SAML_BEARER_ASSERTION="OAuth2SAMLBearerAssertion",e.OAUTH2_USER_TOKEN_EXCHANGE="OAuth2UserTokenExchange",e.SAML_ASSERTION="SAMLAssertion"})(op||(op={}));var oq;(function(e){e.S4HC="S4HC",e.BTP="BTP"})(oq||(oq={}));var dre;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(dre||(dre={}));var SE;(function(e){e.ODATA_GENERIC="odata_gen",e.ODATA_ABAP="odata_abap",e.DEV_ABAP="dev_abap",e.ABAP_CLOUD="abap_cloud"})(SE||(SE={}));var aq;(function(e){e.FULL_URL="full_url",e.API_MGMT="api_mgmt"})(aq||(aq={}));var ND;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(ND||(ND={}));function hHe(e){return!!(e.WebIDEUsage?.includes("abap")||e["sap-client"]||e["sap-platform"]?.toLocaleLowerCase()==="abap"||e.ProxyType==="OnPremise")}function zOr(e){return!!(e.WebIDEUsage?.includes(SE.ABAP_CLOUD)||e["sap-platform"]?.toLocaleLowerCase()==="abap")}function uq(e){return!!(e.WebIDEUsage?.includes(SE.ODATA_GENERIC)&&!e.WebIDEUsage.includes(SE.ODATA_ABAP))}function Kl(e){return!!(!e.WebIDEAdditionalData?.includes(aq.FULL_URL)&&uq(e))}function tg(e){return!!(e.WebIDEAdditionalData?.includes(aq.FULL_URL)&&uq(e))}function mHe(e){return!!e.ProxyType.includes(ND.ON_PREMISE)}function gHe(e){return!!e["HTML5.DynamicDestination"]}function KOr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dHe(e,t){let r=` (${t})`;return RegExp(`${KOr(r)}$`).exec(e.trim())?e:`${e} (${t})`}function yHe(e,t){let r=t?` [${t}]`:"",n;return zOr(e)?n=dHe(e.Name,oq.BTP):hre(e)?n=dHe(e.Name,oq.S4HC):n=e.Name,`${n}${r}`}function hre(e){return!!(e.WebIDEUsage?.includes(SE.ODATA_ABAP)&&e.Authentication===op.SAML_ASSERTION&&e.ProxyType===dre.INTERNET)}function cq(e){return!!e.WebIDEUsage?.includes(SE.ODATA_ABAP)}var Gd={ABAP:"abap",ABAP_TRIAL:"abap-trial",ABAP_CANARY:"abap-canary",ABAP_OEM:"abap-oem",ABAP_OEM_CANARY:"abap-oem-canary",ABAP_HAAS:"abap-haas",DESTINATION:"destination",ABAP_STAGING:"abap-staging",ABAP_INTERNAL_STAGING:"abap-internal-staging"};var mre="abap-cloud-destination-instance",EHe="bas-destination-instance-cred";function Vr(){return!!process.env[eg.H2O_URL]}async function _He(e){try{let t=await(0,ap.cfGetInstanceKeyParameters)(e);if(!t)throw new Error(`No destination instance ${e} found`);let r=t.credentials;if(!r)throw new Error(`No credentials for destination instance ${e} found`);let n=r.uaa?.clientid||r.clientid,i=r.uaa?.clientsecret||r.clientsecret;return Buffer.from(`${encodeURIComponent(n)}:${encodeURIComponent(i)}`).toString("base64")}catch(t){throw new Error(`An error occurred while retrieving service key for the destination instance ${e}: ${t}`)}}function rT(e,t){let r=`https://${e}.dest`;return t&&t.length>1?new URL(t,r).toString():r}function XOr(e){let[t,...r]=e.split(".");return[t.replace(/-api$/,""),...r].join(".")}async function gre(e){let t={};await Oa.get("/reload",{baseURL:process.env[eg.HTTP_PROXY]}),JOr();let r=await Oa.get("/api/listDestinations",{baseURL:process.env[eg.H2O_URL]});return(Array.isArray(r.data)?r.data:[]).forEach(i=>{e?.stripS4HCApiHosts&&hre(i)&&(i.Host=XOr(i.Host)),i.WebIDEEnabled&&(t[i.Name]=i)}),t}function JOr(){!Vr()||!globalThis.GLOBAL_AGENT||(globalThis.GLOBAL_AGENT.HTTP_PROXY||(globalThis.GLOBAL_AGENT.HTTP_PROXY=process.env[eg.HTTP_PROXY]??null),globalThis.GLOBAL_AGENT.HTTPS_PROXY||(globalThis.GLOBAL_AGENT.HTTPS_PROXY=process.env[eg.HTTPS_PROXY]??null))}function QOr(e,t,r,n){let i={usage:"odata_abap,dev_abap,abap_cloud",html5DynamicDestination:"true",html5Timeout:"60000"},s={clientId:r.clientid,clientSecret:r.clientsecret,tokenServiceURL:new URL("/oauth/token",r.url).toString(),tokenServiceURLType:sq.DEDICATED};return{name:e,description:t,url:new URL(n),type:iq.HTTP,proxyType:ND.INTERNET,basProperties:i,credentials:{authentication:op.OAUTH2_USER_TOKEN_EXCHANGE,oauth2UserTokenExchange:s}}}async function yre(e){let t=await(0,ap.cfGetTarget)(!0);if(!t.space)throw new Error("No Dev Space has been created for the subaccount.");return`abap-cloud-${`${e}-${t.org}-${t.space}`.replace(/\W/gi,"-").toLowerCase()}`.substring(0,199)}async function ZOr(e,t,r,n){let i=await yre(e);return(await(0,ap.apiGetServicesInstancesFilteredByType)(["destination"])).find(a=>a.label===mre)||(await(0,ap.apiCreateServiceInstance)("destination","lite",mre,null),n?.info(`New ABAP destination instance ${mre} created.`)),QOr(i,`Destination generated by App Studio for Cloud Foundry Abap service instance: '${e}', Do not remove.`,t,r)}async function SHe(e,t,r){if(!Vr())throw new Error("Creating a SAP BTP destinations is only supported on SAP Business Application Studio.");let n=t;try{if(!n){let a=await(0,ap.apiGetInstanceCredentials)(e);if(!a?.credentials)throw new Error(`Could not retrieve SAP BTP credentials for ${e}.`);n={uaaCredentials:a.credentials.uaa,hostUrl:a.credentials.url}}let i=await ZOr(e,n.uaaCredentials,n.hostUrl,r);await vHe.destinations.createDestination(i),r?.debug(`SAP BTP destination ${JSON.stringify(i,null,2)} created.`);let o=(await gre())?.[i.name];if(!o)throw new Error("Destination not found on SAP BTP.");return o}catch(i){throw new Error(`An error occurred while generating destination ${e}: ${i}`)}}var kHe=be(_re(),1),BHe=require("node:https"),qHe=be(Sre(),1),jHe=be(LF(),1),VHe=be(UHe(),1),GHe=require("node:util");var bre=class extends qHe.HttpsProxyAgent{extraOptions;constructor(t,r){super(t,r),this.extraOptions=r}async connect(t,r){return super.connect(t,{...this.extraOptions,...r})}};function bE(e,t){let r=(0,jHe.default)(t),n={rejectUnauthorized:!r.ignoreCertErrors};r.httpsAgent||(r.httpsAgent=new BHe.Agent(n)),delete r.ignoreCertErrors,r.withCredentials=r?.auth&&Object.keys(r.auth).length>0,r.validateStatus=s=>s<400;let i=new e(r);return i.interceptors.request.use(s=>{let o=i.getUri(s),a=(0,VHe.getProxyForUrl)(o);return a&&!Vr()&&(s.httpsAgent=new bre(a,n),s.httpAgent=new kHe.HttpProxyAgent(a),s.proxy=!1),s}),i.defaults.headers=i.defaults.headers??{common:{},delete:{},put:{},get:{},post:{},head:{},patch:{}},IFe(i),r.auth?.password&&LUe(i),t.cookies&&t.cookies.split(";").forEach(s=>{i.cookies.addCookie(s.trim())}),AP.isPatchRequired(t.baseURL)&&AP.apply(),i}function $He(e){return typeof e=="string"?bE(km,{baseURL:e}):bE(km,e)}function AE(e){return bE(Va,e)}var TE;(function(e){e.Standalone="Standalone",e.EmbeddedSteampunk="EmbeddedSteampunk"})(TE||(TE={}));function Tre(e){let t;switch(e.environment){case TE.Standalone:{let{service:r,refreshToken:n,refreshTokenChangedCb:i,cookies:s,...o}=e;t=bE(Va,{baseURL:r.url,cookies:s,...o}),s||(e.service?.uaa?.username&&e.service.uaa.password?MUe(t,r,n,i):hZ({provider:t}));break}case TE.EmbeddedSteampunk:{let{url:r,cookies:n,...i}=e;t=bE(Va,{baseURL:r,cookies:n,...i}),n||hZ({provider:t});break}default:{let r=e;throw new Error(`Unknown environment type supplied: ${(0,GHe.inspect)(r)}`)}}return t}function HHe(e,t,r){let{cookies:n,...i}=e,s={...i,baseURL:rT(t.Name,t.Host?new URL(t.Host).pathname:void 0),cookies:n};s.params=s.params??{},s.params.saml2="disabled";let o;if(hHe(t)?(o=bE(Va,s),o.publicUrl=t.Host):o=bE(km,s),r){let a=o.interceptors.request.use(async u=>{let c=await _He(r);return o.defaults.headers.common[EHe]=c,o.interceptors.request.eject(a),u})}return o}var WHe;(function(e){e.FF_SIMPLE="basic"})(WHe||(WHe={}));var YHe;(function(e){e.FE_FPM="fpm",e.FE_LROP="lrop",e.FE_OVP="ovp",e.FE_ALP="alp",e.FE_FEOP="feop",e.FE_WORKLIST="worklist"})(YHe||(YHe={}));var cn={vscode:{name:"Visual Studio Code",technical:"VSCode"},bas:{name:"SAP Business Application Studio",technical:"SBAS"},cli:{name:"CLI",technical:"CLI"}};var zHe;(function(e){e.CF="CF",e.ABAP="ABAP"})(zHe||(zHe={}));function MPr(){return!!(process.argv[1]?.includes("yo")||process.stdin.isTTY)}function kc(){return MPr()?cn.cli:Vr()?cn.bas:cn.vscode}var Ut=e=>typeof e=="string",LD=()=>{let e,t,r=new Promise((n,i)=>{e=n,t=i});return r.resolve=e,r.reject=t,r},KHe=e=>e==null?"":""+e,FPr=(e,t,r)=>{e.forEach(n=>{t[n]&&(r[n]=t[n])})},UPr=/###/g,XHe=e=>e&&e.indexOf("###")>-1?e.replace(UPr,"."):e,JHe=e=>!e||Ut(e),MD=(e,t,r)=>{let n=Ut(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(JHe(e))return{};let s=XHe(n[i]);!e[s]&&r&&(e[s]=new r),Object.prototype.hasOwnProperty.call(e,s)?e=e[s]:e={},++i}return JHe(e)?{}:{obj:e,k:XHe(n[i])}},QHe=(e,t,r)=>{let{obj:n,k:i}=MD(e,t,Object);if(n!==void 0||t.length===1){n[i]=r;return}let s=t[t.length-1],o=t.slice(0,t.length-1),a=MD(e,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=MD(e,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=r},kPr=(e,t,r,n)=>{let{obj:i,k:s}=MD(e,t,Object);i[s]=i[s]||[],i[s].push(r)},mq=(e,t)=>{let{obj:r,k:n}=MD(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},BPr=(e,t,r)=>{let n=mq(e,r);return n!==void 0?n:mq(t,r)},s5e=(e,t,r)=>{for(let n in t)n!=="__proto__"&&n!=="constructor"&&(n in e?Ut(e[n])||e[n]instanceof String||Ut(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):s5e(e[n],t[n],r):e[n]=t[n]);return e},xE=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),qPr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},jPr=e=>Ut(e)?e.replace(/[&<>"'\/]/g,t=>qPr[t]):e,Cre=class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){let r=this.regExpMap.get(t);if(r!==void 0)return r;let n=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,n),this.regExpQueue.push(t),n}},VPr=[" ",",","?","!",";"],GPr=new Cre(20),$Pr=(e,t,r)=>{t=t||"",r=r||"";let n=VPr.filter(o=>t.indexOf(o)<0&&r.indexOf(o)<0);if(n.length===0)return!0;let i=GPr.getRegExp(`(${n.map(o=>o==="?"?"\\?":o).join("|")})`),s=!i.test(e);if(!s){let o=e.indexOf(r);o>0&&!i.test(e.substring(0,o))&&(s=!0)}return s},Ore=(e,t,r=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let n=t.split(r),i=e;for(let s=0;s<n.length;){if(!i||typeof i!="object")return;let o,a="";for(let u=s;u<n.length;++u)if(u!==s&&(a+=r),a+=n[u],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&u<n.length-1)continue;s+=u-s+1;break}i=o}return i},FD=e=>e?.replace(/_/g,"-"),HPr={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}},Pre=class e{constructor(t,r={}){this.init(t,r)}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||HPr,this.options=r,this.debug=r.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,r,n,i){return i&&!this.debug?null:(Ut(t[0])&&(t[0]=`${n}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},cp=new Pre,aT=class{constructor(){this.observers={}}on(t,r){return t.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);let i=this.observers[n].get(r)||0;this.observers[n].set(r,i+1)}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t].delete(r)}}emit(t,...r){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[t,...r])})}},gq=class extends aT{constructor(t,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){let r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1)}getResource(t,r,n,i={}){let s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure,a;t.indexOf(".")>-1?a=t.split("."):(a=[t,r],n&&(Array.isArray(n)?a.push(...n):Ut(n)&&s?a.push(...n.split(s)):a.push(n)));let u=mq(this.data,a);return!u&&!r&&!n&&t.indexOf(".")>-1&&(t=a[0],r=a[1],n=a.slice(2).join(".")),u||!o||!Ut(n)?u:Ore(this.data?.[t]?.[r],n,s)}addResource(t,r,n,i,s={silent:!1}){let o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=[t,r];n&&(a=a.concat(o?n.split(o):n)),t.indexOf(".")>-1&&(a=t.split("."),i=r,r=a[1]),this.addNamespaces(r),QHe(this.data,a,i),s.silent||this.emit("added",t,r,n,i)}addResources(t,r,n,i={silent:!1}){for(let s in n)(Ut(n[s])||Array.isArray(n[s]))&&this.addResource(t,r,s,n[s],{silent:!0});i.silent||this.emit("added",t,r,n)}addResourceBundle(t,r,n,i,s,o={silent:!1,skipCopy:!1}){let a=[t,r];t.indexOf(".")>-1&&(a=t.split("."),i=n,n=r,r=a[1]),this.addNamespaces(r);let u=mq(this.data,a)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?s5e(u,n,s):u={...u,...n},QHe(this.data,a,u),o.silent||this.emit("added",t,r,n)}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r)}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){let r=this.getDataByLanguage(t);return!!(r&&Object.keys(r)||[]).find(i=>r[i]&&Object.keys(r[i]).length>0)}toJSON(){return this.data}},o5e={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,i){return e.forEach(s=>{t=this.processors[s]?.process(t,r,n,i)??t}),t}},a5e=Symbol("i18next/PATH_KEY");function WPr(){let e=[],t=Object.create(null),r;return t.get=(n,i)=>(r?.revoke?.(),i===a5e?e:(e.push(i),r=Proxy.revocable(n,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function oT(e,t){let{[a5e]:r}=e(WPr()),n=t?.keySeparator??".",i=t?.nsSeparator??":";if(r.length>1&&i){let s=t?.ns,o=Array.isArray(s)?s:null;if(o&&o.length>1&&o.slice(1).includes(r[0]))return`${r[0]}${i}${r.slice(1).join(n)}`}return r.join(n)}var ZHe={},Are=e=>!Ut(e)&&typeof e!="boolean"&&typeof e!="number",yq=class e extends aT{constructor(t,r={}){super(),FPr(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=cp.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,r={interpolation:{}}){let n={...r};if(t==null)return!1;let i=this.resolve(t,n);if(i?.res===void 0)return!1;let s=Are(i.res);return!(n.returnObjects===!1&&s)}extractFromKey(t,r){let n=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");let i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,s=r.ns||this.options.defaultNS||[],o=n&&t.indexOf(n)>-1,a=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!$Pr(t,n,i);if(o&&!a){let u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:Ut(s)?[s]:s};let c=t.split(n);(n!==i||n===i&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),t=c.join(i)}return{key:t,namespaces:Ut(s)?[s]:s}}translate(t,r,n){let i=typeof r=="object"?{...r}:r;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),t==null)return"";typeof t=="function"&&(t=oT(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(de=>typeof de=="function"?oT(de,{...this.options,...i}):String(de));let s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:u}=this.extractFromKey(t[t.length-1],i),c=u[u.length-1],l=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;l===void 0&&(l=":");let f=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?s?{res:`${c}${l}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${l}${a}`:s?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;let d=this.resolve(t,i),h=d?.res,g=d?.usedKey||a,_=d?.exactUsedKey||a,S=["[object Number]","[object Function]","[object RegExp]"],T=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,A=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!Ut(i.count),x=e.hasDefaultValue(i),N=w?this.pluralResolver.getSuffix(f,i.count,i):"",F=i.ordinal&&w?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=w&&!i.ordinal&&i.count===0,V=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${N}`]||i[`defaultValue${F}`]||i.defaultValue,z=h;A&&!h&&x&&(z=V);let L=Are(z),J=Object.prototype.toString.apply(z);if(A&&z&&L&&S.indexOf(J)<0&&!(Ut(T)&&Array.isArray(z))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let de=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,z,{...i,ns:u}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(d.res=de,d.usedParams=this.getUsedParamsDetails(i),d):de}if(o){let de=Array.isArray(z),ie=de?[]:{},H=de?_:g;for(let G in z)if(Object.prototype.hasOwnProperty.call(z,G)){let ye=`${H}${o}${G}`;x&&!h?ie[G]=this.translate(ye,{...i,defaultValue:Are(V)?V[G]:void 0,joinArrays:!1,ns:u}):ie[G]=this.translate(ye,{...i,joinArrays:!1,ns:u}),ie[G]===ye&&(ie[G]=z[G])}h=ie}}else if(A&&Ut(T)&&Array.isArray(h))h=h.join(T),h&&(h=this.extendTranslation(h,t,i,n));else{let de=!1,ie=!1;!this.isValidLookup(h)&&x&&(de=!0,h=V),this.isValidLookup(h)||(ie=!0,h=a);let G=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ie?void 0:h,ye=x&&V!==h&&this.options.updateMissing;if(ie||de||ye){if(this.logger.log(ye?"updateKey":"missingKey",f,c,a,ye?V:h),o){let Xe=this.resolve(a,{...i,keySeparator:!1});Xe&&Xe.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let xe=[],Ce=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Ce&&Ce[0])for(let Xe=0;Xe<Ce.length;Xe++)xe.push(Ce[Xe]);else this.options.saveMissingTo==="all"?xe=this.languageUtils.toResolveHierarchy(i.lng||this.language):xe.push(i.lng||this.language);let Ie=(Xe,_e,je)=>{let mt=x&&je!==h?je:G;this.options.missingKeyHandler?this.options.missingKeyHandler(Xe,c,_e,mt,ye,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Xe,c,_e,mt,ye,i),this.emit("missingKey",Xe,c,_e,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?xe.forEach(Xe=>{let _e=this.pluralResolver.getSuffixes(Xe,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&_e.indexOf(`${this.options.pluralSeparator}zero`)<0&&_e.push(`${this.options.pluralSeparator}zero`),_e.forEach(je=>{Ie([Xe],a+je,i[`defaultValue${je}`]||V)})}):Ie(xe,a,V))}h=this.extendTranslation(h,t,i,d,n),ie&&h===a&&this.options.appendNamespaceToMissingKey&&(h=`${c}${l}${a}`),(ie||de)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${l}${a}`:a,de?h:void 0,i))}return s?(d.res=h,d.usedParams=this.getUsedParamsDetails(i),d):h}extendTranslation(t,r,n,i,s){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let u=Ut(t)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),c;if(u){let f=t.match(this.interpolator.nestingRegexp);c=f&&f.length}let l=n.replace&&!Ut(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,n.lng||this.language||i.usedLng,n),u){let f=t.match(this.interpolator.nestingRegexp),p=f&&f.length;c<p&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),n.nest!==!1&&(t=this.interpolator.nest(t,(...f)=>s?.[0]===f[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${r[0]}`),null):this.translate(...f,r),n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,a=Ut(o)?[o]:o;return t!=null&&a?.length&&n.applyPostProcessor!==!1&&(t=o5e.handle(a,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),t}resolve(t,r={}){let n,i,s,o,a;return Ut(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(u=>typeof u=="function"?oT(u,{...this.options,...r}):u)),t.forEach(u=>{if(this.isValidLookup(n))return;let c=this.extractFromKey(u,r),l=c.key;i=l;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));let p=r.count!==void 0&&!Ut(r.count),d=p&&!r.ordinal&&r.count===0,h=r.context!==void 0&&(Ut(r.context)||typeof r.context=="number")&&r.context!=="",g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);f.forEach(_=>{this.isValidLookup(n)||(a=_,!ZHe[`${g[0]}-${_}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(ZHe[`${g[0]}-${_}`]=!0,this.logger.warn(`key "${i}" for languages "${g.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(S=>{if(this.isValidLookup(n))return;o=S;let T=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(T,l,S,_,r);else{let w;p&&(w=this.pluralResolver.getSuffix(S,r.count,r));let x=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&w.indexOf(N)===0&&T.push(l+w.replace(N,this.options.pluralSeparator)),T.push(l+w),d&&T.push(l+x)),h){let F=`${l}${this.options.contextSeparator||"_"}${r.context}`;T.push(F),p&&(r.ordinal&&w.indexOf(N)===0&&T.push(F+w.replace(N,this.options.pluralSeparator)),T.push(F+w),d&&T.push(F+x))}}let A;for(;A=T.pop();)this.isValidLookup(n)||(s=A,n=this.getResource(S,_,A,r))}))})}),{res:n,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,n,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,r,n,i):this.resourceStore.getResource(t,r,n,i)}getUsedParamsDetails(t={}){let r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=t.replace&&!Ut(t.replace),i=n?t.replace:t;if(n&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!n){i={...i};for(let s of r)delete i[s]}return i}static hasDefaultValue(t){let r="defaultValue";for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&r===n.substring(0,r.length)&&t[n]!==void 0)return!0;return!1}},vq=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=cp.create("languageUtils")}getScriptPartFromCode(t){if(t=FD(t),!t||t.indexOf("-")<0)return null;let r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=FD(t),!t||t.indexOf("-")<0)return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(Ut(t)&&t.indexOf("-")>-1){let r;try{r=Intl.getCanonicalLocales(t)[0]}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(n=>{if(r)return;let i=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(i))&&(r=i)}),!r&&this.options.supportedLngs&&t.forEach(n=>{if(r)return;let i=this.getScriptPartFromCode(n);if(this.isSupportedCode(i))return r=i;let s=this.getLanguagePartFromCode(n);if(this.isSupportedCode(s))return r=s;r=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),Ut(t)&&(t=[t]),Array.isArray(t))return t;if(!r)return t.default||[];let n=t[r];return n||(n=t[this.getScriptPartFromCode(r)]),n||(n=t[this.formatLanguageCode(r)]),n||(n=t[this.getLanguagePartFromCode(r)]),n||(n=t.default),n||[]}toResolveHierarchy(t,r){let n=this.getFallbackCodes((r===!1?[]:r)||this.options.fallbackLng||[],t),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return Ut(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(t))):Ut(t)&&s(this.formatLanguageCode(t)),n.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}},e5e={zero:0,one:1,two:2,few:3,many:4,other:5},t5e={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},Dre=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=cp.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,r={}){let n=FD(t==="dev"?"en":t),i=r.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:n,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(n,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),t5e;if(!t.match(/-|_/))return t5e;let u=this.languageUtils.getLanguagePartFromCode(t);o=this.getRule(u,r)}return this.pluralRulesCache[s]=o,o}needsPlural(t,r={}){let n=this.getRule(t,r);return n||(n=this.getRule("dev",r)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,r,n={}){return this.getSuffixes(t,n).map(i=>`${r}${i}`)}getSuffixes(t,r={}){let n=this.getRule(t,r);return n||(n=this.getRule("dev",r)),n?n.resolvedOptions().pluralCategories.sort((i,s)=>e5e[i]-e5e[s]).map(i=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(t,r,n={}){let i=this.getRule(t,n);return i?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i.select(r)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",r,n))}},r5e=(e,t,r,n=".",i=!0)=>{let s=BPr(e,t,r);return!s&&i&&Ut(r)&&(s=Ore(e,r,n),s===void 0&&(s=Ore(t,r,n))),s},xre=e=>e.replace(/\$/g,"$$$$"),Eq=class{constructor(t={}){this.logger=cp.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(r=>r),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});let{escape:r,escapeValue:n,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:a,suffixEscaped:u,formatSeparator:c,unescapeSuffix:l,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:h,nestingSuffixEscaped:g,nestingOptionsSeparator:_,maxReplaces:S,alwaysFormat:T}=t.interpolation;this.escape=r!==void 0?r:jPr,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?xE(s):o||"{{",this.suffix=a?xE(a):u||"}}",this.formatSeparator=c||",",this.unescapePrefix=l?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=p?xE(p):d||xE("$t("),this.nestingSuffix=h?xE(h):g||xE(")"),this.nestingOptionsSeparator=_||",",this.maxReplaces=S||1e3,this.alwaysFormat=T!==void 0?T:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let t=(r,n)=>r?.source===n?(r.lastIndex=0,r):new RegExp(n,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,r,n,i){let s,o,a,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=d=>{if(d.indexOf(this.formatSeparator)<0){let S=r5e(r,u,d,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(S,void 0,n,{...i,...r,interpolationkey:d}):S}let h=d.split(this.formatSeparator),g=h.shift().trim(),_=h.join(this.formatSeparator).trim();return this.format(r5e(r,u,g,this.options.keySeparator,this.options.ignoreJSONStructure),_,n,{...i,...r,interpolationkey:g})};this.resetRegExp();let l=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:d=>xre(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?xre(this.escape(d)):xre(d)}].forEach(d=>{for(a=0;s=d.regex.exec(t);){let h=s[1].trim();if(o=c(h),o===void 0)if(typeof l=="function"){let _=l(t,s,i);o=Ut(_)?_:""}else if(i&&Object.prototype.hasOwnProperty.call(i,h))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${h} for interpolating ${t}`),o="";else!Ut(o)&&!this.useRawValueToEscape&&(o=KHe(o));let g=d.safeValue(o);if(t=t.replace(s[0],g),f?(d.regex.lastIndex+=o.length,d.regex.lastIndex-=s[0].length):d.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),t}nest(t,r,n={}){let i,s,o,a=(u,c)=>{let l=this.nestingOptionsSeparator;if(u.indexOf(l)<0)return u;let f=u.split(new RegExp(`${xE(l)}[ ]*{`)),p=`{${f[1]}`;u=f[0],p=this.interpolate(p,o);let d=p.match(/'/g),h=p.match(/"/g);((d?.length??0)%2===0&&!h||(h?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),c&&(o={...c,...o})}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,g),`${u}${l}${p}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,u};for(;i=this.nestingRegexp.exec(t);){let u=[];o={...n},o=o.replace&&!Ut(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(u=i[1].slice(c).split(this.formatSeparator).map(l=>l.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),s=r(a.call(this,i[1].trim(),o),o),s&&i[0]===t&&!Ut(s))return s;Ut(s)||(s=KHe(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),s=""),u.length&&(s=u.reduce((l,f)=>this.format(l,f,n.lng,{...n,interpolationkey:i[1].trim()}),s.trim())),t=t.replace(i[0],s),this.regexp.lastIndex=0}return t}},YPr=e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let i=n[1].substring(0,n[1].length-1);t==="currency"&&i.indexOf(":")<0?r.currency||(r.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?r.range||(r.range=i.trim()):i.split(";").forEach(o=>{if(o){let[a,...u]=o.split(":"),c=u.join(":").trim().replace(/^'+|'+$/g,""),l=a.trim();r[l]||(r[l]=c),c==="false"&&(r[l]=!1),c==="true"&&(r[l]=!0),isNaN(c)||(r[l]=parseInt(c,10))}})}return{formatName:t,formatOptions:r}},n5e=e=>{let t={};return(r,n,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});let o=n+JSON.stringify(s),a=t[o];return a||(a=e(FD(n),i),t[o]=a),a(r)}},zPr=e=>(t,r,n)=>e(FD(r),n)(t),Rre=class{constructor(t={}){this.logger=cp.create("formatter"),this.options=t,this.init(t)}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let n=r.cacheInBuiltFormats?n5e:zPr;this.formats={number:n((i,s)=>{let o=new Intl.NumberFormat(i,{...s});return a=>o.format(a)}),currency:n((i,s)=>{let o=new Intl.NumberFormat(i,{...s,style:"currency"});return a=>o.format(a)}),datetime:n((i,s)=>{let o=new Intl.DateTimeFormat(i,{...s});return a=>o.format(a)}),relativetime:n((i,s)=>{let o=new Intl.RelativeTimeFormat(i,{...s});return a=>o.format(a,s.range||"day")}),list:n((i,s)=>{let o=new Intl.ListFormat(i,{...s});return a=>o.format(a)})}}add(t,r){this.formats[t.toLowerCase().trim()]=r}addCached(t,r){this.formats[t.toLowerCase().trim()]=n5e(r)}format(t,r,n,i={}){let s=r.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(a=>a.indexOf(")")>-1)){let a=s.findIndex(u=>u.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,a)].join(this.formatSeparator)}return s.reduce((a,u)=>{let{formatName:c,formatOptions:l}=YPr(u);if(this.formats[c]){let f=a;try{let p=i?.formatParams?.[i.interpolationkey]||{},d=p.locale||p.lng||i.locale||i.lng||n;f=this.formats[c](a,d,{...l,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${c}`);return a},t)}},KPr=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},Nre=class extends aT{constructor(t,r,n,i={}){super(),this.backend=t,this.store=r,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=cp.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,i.backend,i)}queueLoad(t,r,n,i){let s={},o={},a={},u={};return t.forEach(c=>{let l=!0;r.forEach(f=>{let p=`${c}|${f}`;!n.reload&&this.store.hasResourceBundle(c,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,l=!1,o[p]===void 0&&(o[p]=!0),s[p]===void 0&&(s[p]=!0),u[f]===void 0&&(u[f]=!0)))}),l||(a[c]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(u)}}loaded(t,r,n){let i=t.split("|"),s=i[0],o=i[1];r&&this.emit("failedLoading",s,o,r),!r&&n&&this.store.addResourceBundle(s,o,n,void 0,void 0,{skipCopy:!0}),this.state[t]=r?-1:2,r&&n&&(this.state[t]=0);let a={};this.queue.forEach(u=>{kPr(u.loaded,[s],o),KPr(u,t),r&&u.errors.push(r),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(c=>{a[c]||(a[c]={});let l=u.loaded[c];l.length&&l.forEach(f=>{a[c][f]===void 0&&(a[c][f]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(u=>!u.done)}read(t,r,n,i=0,s=this.retryTimeout,o){if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:n,tried:i,wait:s,callback:o});return}this.readingCalls++;let a=(c,l)=>{if(this.readingCalls--,this.waitingReads.length>0){let f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&l&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,r,n,i+1,s*2,o)},s);return}o(c,l)},u=this.backend[n].bind(this.backend);if(u.length===2){try{let c=u(t,r);c&&typeof c.then=="function"?c.then(l=>a(null,l)).catch(a):a(null,c)}catch(c){a(c)}return}return u(t,r,a)}prepareLoading(t,r,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Ut(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ut(r)&&(r=[r]);let s=this.queueLoad(t,r,n,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(t,r,n){this.prepareLoading(t,r,{},n)}reload(t,r,n){this.prepareLoading(t,r,{reload:!0},n)}loadOne(t,r=""){let n=t.split("|"),i=n[0],s=n[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${r}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${r}loaded namespace ${s} for language ${i}`,a),this.loaded(t,o,a)})}saveMissing(t,r,n,i,s,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${n}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(n==null||n==="")){if(this.backend?.create){let u={...o,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let l;c.length===5?l=c(t,r,n,i,u):l=c(t,r,n,i),l&&typeof l.then=="function"?l.then(f=>a(null,f)).catch(a):a(null,l)}catch(l){a(l)}else c(t,r,n,i,a,u)}!t||!t[0]||this.store.addResource(t[0],r,n,i)}}},wre=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ut(e[1])&&(t.defaultValue=e[1]),Ut(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){let r=e[3]||e[2];Object.keys(r).forEach(n=>{t[n]=r[n]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),i5e=e=>(Ut(e.ns)&&(e.ns=[e.ns]),Ut(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ut(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),hq=()=>{},XPr=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})},u5e="__i18next_supportNoticeShown",JPr=()=>!!(typeof globalThis<"u"&&globalThis[u5e]||typeof process<"u"&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&process.env&&process.env.NODE_ENV==="production"),QPr=()=>{typeof globalThis<"u"&&(globalThis[u5e]=!0)},ZPr=e=>!!(e?.modules?.backend?.name?.indexOf("Locize")>0||e?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||e?.options?.backend?.backends&&e.options.backend.backends.some(t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0)||e?.options?.backend?.projectId||e?.options?.backend?.backendOptions&&e.options.backend.backendOptions.some(t=>t?.projectId)),Ire=class e extends aT{constructor(t={},r){if(super(),this.options=i5e(t),this.services={},this.logger=cp,this.modules={external:[]},XPr(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,r),this;setTimeout(()=>{this.init(t,r)},0)}}init(t={},r){this.isInitializing=!0,typeof t=="function"&&(r=t,t={}),t.defaultNS==null&&t.ns&&(Ut(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));let n=wre();this.options={...n,...this.options,...i5e(t)},this.options.interpolation={...n.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!ZPr(this)&&!JPr()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("\u{1F310} i18next is made possible by our own product, Locize \u2014 consider powering your project with managed localization (AI, CDN, integrations): https://locize.com \u{1F499}"),QPr());let i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?cp.init(i(this.modules.logger),this.options):cp.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=Rre;let l=new vq(this.options);this.store=new gq(this.options.resources,this.options);let f=this.services;f.logger=cp,f.resourceStore=this.store,f.languageUtils=l,f.pluralResolver=new Dre(l,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(f.formatter=i(c),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Eq(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Nre(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...h)=>{this.emit(d,...h)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new yq(this.services,this.options),this.translator.on("*",(d,...h)=>{this.emit(d,...h)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,r||(r=hq),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...l)=>this.store[c](...l)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...l)=>(this.store[c](...l),this)});let a=LD(),u=()=>{let c=(l,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(f),r(l,f)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),a}loadResources(t,r=hq){let n=r,i=Ut(t)?t:this.language;if(typeof t=="function"&&(n=t),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();let s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>o(u)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(a)})}else n(null)}reloadResources(t,r,n){let i=LD();return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=void 0),t||(t=this.languages),r||(r=this.options.ns),n||(n=hq),this.services.backendConnector.reload(t,r,s=>{i.resolve(),n(s)}),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&o5e.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let r=0;r<this.languages.length;r++){let n=this.languages[r];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,r){this.isLanguageChangingTo=t;let n=LD();this.emit("languageChanging",t);let i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},s=(a,u)=>{u?this.isLanguageChangingTo===t&&(i(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,n.resolve((...c)=>this.t(...c)),r&&r(a,(...c)=>this.t(...c))},o=a=>{!t&&!a&&this.services.languageDetector&&(a=[]);let u=Ut(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(u)?u:this.services.languageUtils.getBestMatchFromCodes(Ut(a)?[a]:a);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,l=>{s(l,c)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(t),n}getFixedT(t,r,n){let i=(s,o,...a)=>{let u;typeof o!="object"?u=this.options.overloadTranslationOptionHandler([s,o].concat(a)):u={...o},u.lng=u.lng||i.lng,u.lngs=u.lngs||i.lngs,u.ns=u.ns||i.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||n||i.keyPrefix);let c={...this.options,...u};typeof u.keyPrefix=="function"&&(u.keyPrefix=oT(u.keyPrefix,c));let l=this.options.keySeparator||".",f;return u.keyPrefix&&Array.isArray(s)?f=s.map(p=>(typeof p=="function"&&(p=oT(p,c)),`${u.keyPrefix}${l}${p}`)):(typeof s=="function"&&(s=oT(s,c)),f=u.keyPrefix?`${u.keyPrefix}${l}${s}`:s),this.t(f,u)};return Ut(t)?i.lng=t:i.lngs=t,i.ns=r,i.keyPrefix=n,i}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let n=r.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;let o=(a,u)=>{let c=this.services.backendConnector.state[`${a}|${u}`];return c===-1||c===0||c===2};if(r.precheck){let a=r.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(n,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(n,t)&&(!i||o(s,t)))}loadNamespaces(t,r){let n=LD();return this.options.ns?(Ut(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{n.resolve(),r&&r(i)}),n):(r&&r(),Promise.resolve())}loadLanguages(t,r){let n=LD();Ut(t)&&(t=[t]);let i=this.options.preload||[],s=t.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{n.resolve(),r&&r(o)}),n):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{let i=new Intl.Locale(t);if(i&&i.getTextInfo){let s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}let r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],n=this.services?.languageUtils||new vq(wre());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.indexOf(n.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},r){let n=new e(t,r);return n.createInstance=e.createInstance,n}cloneInstance(t={},r=hq){let n=t.forkResourceStore;n&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},s=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(s.logger=s.logger.clone(t)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},n){let a=Object.keys(this.store.data).reduce((u,c)=>(u[c]={...this.store.data[c]},u[c]=Object.keys(u[c]).reduce((l,f)=>(l[f]={...u[c][f]},l),u[c]),u),{});s.store=new gq(a,i),s.services.resourceStore=s.store}if(t.interpolation){let u={...wre().interpolation,...this.options.interpolation,...t.interpolation},c={...i,interpolation:u};s.services.interpolator=new Eq(c)}return s.translator=new yq(s.services,i),s.translator.on("*",(a,...u)=>{s.emit(a,...u)}),s.init(i,r),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},kr=Ire.createInstance(),gyi=kr.createInstance,yyi=kr.dir,vyi=kr.init,Eyi=kr.loadResources,_yi=kr.reloadResources,Syi=kr.use,byi=kr.changeLanguage,Tyi=kr.getFixedT,Ayi=kr.t,xyi=kr.exists,wyi=kr.setDefaultNamespace,Cyi=kr.hasLoadedNamespace,Oyi=kr.loadNamespaces,Pyi=kr.loadLanguages;var c5e={logMessages:{info:{mockOnlyWarning:"This application was generated with a local metadata file and does not reference a live server. Please add the required server configuration or start this application with mock data using the target: `npm run start-mock`."},error:{logWrapperNotInitialised:"`LogWrapper` is not initialised."},debug:{loggingConfigured:"Logging has been configured at log level: {{logLevel}}."}},telemetry:{unknownOs:"Unknown"},texts:{systemTypeLabel:{abapCloud:"ABAP Cloud"}}};var Lre="fiori-freestyle-writer",l5e=kr.createInstance();async function tDr(){await l5e.init({resources:{en:{[Lre]:c5e}},lng:"en",fallbackLng:"en",defaultNS:Lre,ns:[Lre],showSupportNotice:!1})}function rg(e,t){return l5e.t(e,t)}tDr().catch(()=>{});function f5e(e){return rDr(e.name,e.userDisplayName,e.systemType)}function rDr(e,t,r){let n=t?` [${t}]`:"";return`${e}${nDr(r)}${n}`}function nDr(e){let t="",r=` (${rg("texts.systemTypeLabel.abapCloud")})`;return(e==="AbapCloud"||e==="S4HC"||e==="BTP")&&(t=r),t}var UD=class{applicationKey="";extensionName="";extensionVersion="";getApplicationKey(){return this.applicationKey}getExtensionVersion(){return this.extensionVersion}getExtensionName(){return this.extensionName}};var Vct=be(kue(),1);var UR=class{extensionName;eventName;constructor(t,r){this.extensionName=t,this.eventName=r}getExtensionName(){return this.extensionName}getEventName(){return this.eventName}toString(){return`${this.extensionName}/${this.eventName}`}};var Pi;(function(e){e[e.OnePercent=0]="OnePercent",e[e.TenPercent=1]="TenPercent",e[e.NoSampling=2]="NoSampling"})(Pi||(Pi={}));function fG(e){e.channel.setUseDiskRetryCaching(!0),e.addTelemetryProcessor(t=>(t.tags["ai.location.ip"]="0.0.0.0",t.tags["ai.cloud.roleInstance"]="masked",t.tags["ai.cloud.role"]="masked",t.tags["ai.device.type"]="masked",!0))}var Bue={name:"@sap-ux/telemetry",version:"1.0.7",description:"Library for sending usage telemetry data",type:"module",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/telemetry"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Atelemetry"},license:"Apache-2.0",private:!1,main:"dist/index.js",scripts:{build:"tsc --build",watch:"tsc --watch",clean:"rimraf --glob dist coverage *.tsbuildinfo",format:"prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",example:"ts-node example/index.ts"},dependencies:{"@sap-ux/store":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/nodejs-utils":"workspace:*",applicationinsights:"2.9.8",axios:"1.16.0","performance-now":"2.1.0",yaml:"2.8.3"},devDependencies:{"@jest/globals":"30.3.0","jest-extended":"7.0.0",memfs:"3.4.13",unionfs:"4.6.0",dotenv:"17.4.2"},files:["dist","LICENSE","!dist/*.map","!dist/**/*.map"],engines:{node:">=22.x"}};var Eo={azureInstrumentationKey:"",telemetryEnabled:!0,telemetryLibName:Bue.name,telemetryLibVersion:Bue.version,consumerModuleName:"",consumerModuleVersion:""};var kR=class extends UD{clients;constructor(t,r,n){super(),this.clients=new Map,this.applicationKey=t,this.extensionVersion=n,this.extensionName=r;let i=this.createTelemetryClient(Pi.OnePercent),s=this.createTelemetryClient(Pi.TenPercent),o=this.createTelemetryClient(Pi.NoSampling);this.clients.set(Pi.OnePercent,i),this.clients.set(Pi.TenPercent,s),this.clients.set(Pi.NoSampling,o)}reportBlocking(t,r,n,i,s=!1){if(!s||Eo.telemetryEnabled){let{client:o,event:a}=this.prepareClientAndEvent(t,r,n,i);return this.trackEventBlocking(o,a)}return Promise.resolve()}async report(t,r,n,i,s,o){if(o!==void 0&&!o||!Eo.telemetryEnabled)return;let{client:a,event:u}=this.prepareClientAndEvent(t,r,n,i);this.trackEvent(a,u)}prepareClientAndEvent(t,r,n,i=Pi.NoSampling){let s=this.clients.get(i),a={name:new UR(this.extensionName,t).toString(),properties:r,measurements:n};return{client:s,event:a}}async trackEventBlocking(t,r){if(process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY!=="true")return new Promise((n,i)=>{try{t.trackEvent(r),t.flush({callback:()=>n()})}catch(s){i(s)}})}trackEvent(t,r){return process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY!=="true"?(t.trackEvent(r),!0):!1}createTelemetryClient(t){let r;switch(t){case Pi.OnePercent:r=1;break;case Pi.TenPercent:r=10;break;case Pi.NoSampling:default:r=100;break}let n=new Vct.TelemetryClient(this.applicationKey);return n.config.samplingPercentage=r,fG(n),n}};var que=()=>{let e=new Date().getTime();return new Date(e).toISOString()};var BR=class extends kR{constructor(t,r,n){super(t,r,n)}async report(t,r,n,i,s,o){let a=await pG(s),u={v:this.extensionVersion,datetime:que()},c={...r,...a,...u};await super.report(t,c,n,i,s,o)}async reportEvent(t,r,n,i){let{finalProperties:s,finalMeasurements:o}=await this.collectToolsSuiteTelemetry(t,n);return super.report(t.eventName,s,o,r,n,i)}async reportEventBlocking(t,r,n,i){let{finalProperties:s,finalMeasurements:o}=await this.collectToolsSuiteTelemetry(t,n);return super.reportBlocking(t.eventName,s,o,r,i)}async collectToolsSuiteTelemetry(t,r){let n=await pG(r),i={v:this.extensionVersion,datetime:que()},s={...t.properties,...n,...i},o={...t.measurements};return{finalProperties:s,finalMeasurements:o}}};var Gct=require("node:child_process"),qR=class{run(t,r=[],n={},i){return i&&i.debug(`Running command: ${t} ${r.join(" ")}`),new Promise((s,o)=>{let a=[],u=process.platform==="win32"?{...n,shell:!0}:n,c=(0,Gct.spawn)(t,r,u);c.stdout.setEncoding("utf8");let l;c.stdout.on("data",f=>{i?.info(f.toString().replace(/[\r\n]$/,"")),l=f.toString()}),c.stderr.on("data",f=>{i?.info(f.toString().replace(/[\r\n]$/,"")),a.push(f.toString())}),c.on("error",f=>{let p=`Command failed with error: ${f.message}`;i?.error(p),o(f)}),c.on("close",f=>{if(f!==0){let p=`Command failed, \`${t} ${r.join(" ")}\`, ${a.join(", ")}`;i?.debug(p),o(p)}s(l)})})}};var Mnn=be(jG(),1);var Fnn=be(tfe(),1),nfe=be(ta(),1);var Pht={error:{unsupportedYoVersion:"The installed version of the `Yo` CLI tool: {{installedYoVersion}} is not supported. Please use `npm` or `yarn` to globally install the latest supported version by running: 'npm i -g yo@{{latestSupportedYoVer}}'.",executingYoVersionCmd:"Running: {{yoCmd}} returned an error: {{- error}}. Check that `yo` is installed and available on the path. If `yo@{{latestSupportedYoVer}}` is not installed, use `npm` or `yarn` to globally install the latest required version by running: 'npm i -g yo@{{latestSupportedYoVer}}'."}};var rfe="nodejs-utils",Inn=kr.createInstance();async function Lnn(){await Inn.init({lng:"en",fallbackLng:"en",defaultNS:rfe,ns:[rfe],resources:{en:{[rfe]:Pht}},interpolation:{escapeValue:!1},showSupportNotice:!1})}Lnn().catch(()=>{});var QR=be(require("node:https"),1);function VA(e){QR.default.globalAgent.options&&(QR.default.globalAgent.options.rejectUnauthorized=e),QR.default.globalAgent.fallbackAgent?.options&&(QR.default.globalAgent.fallbackAgent.options.rejectUnauthorized=e)}var il=be(kpe(),1),nvt=be(rvt(),1);var yi=class extends Error{code;constructor(t,r){super(t),this.code=r,this.name=this.constructor.name}};var ss=Object.freeze({yamlParsing:"yamlParsing",nodeNotFound:"nodeNotFound",nodeNotFoundMatching:"nodeNotFoundMatching",nodeNotAMap:"nodeNotAMap",propertyNotFound:"propertyNotFound",pathCannotBeEmpty:"pathCannotBeEmpty",pathDoesNotExist:"pathDoesNotExist",seqDoesNotExist:"seqDoesNotExist",tryingToAppendToNonSequence:"tryingToAppendToNonSequence",startNodeMustBeCollection:"startNodeMustBeCollection",scalarValuesDoNotHaveProperties:"scalarValuesDoNotHaveProperties"}),Ao=Object.freeze({yamlParsing:"Error parsing YAML document",nodeNotFound:"Node not found at path: [{{- path }}]",nodeNotFoundMatching:"Node not found at path: [{{- path }}, matching [{{- key }} = {{- value }}]",nodeNotAMap:"Node path: [{{- path }}, matching [{{- key }} = {{- value }}], is not a map",propertyNotFound:"Node not found at path: [{{- path }}]",pathCannotBeEmpty:"Path cannot be empty",pathDoesNotExist:"Parent node does not exist at: [{{- path }}]",seqDoesNotExist:"Sequence does not exist at: [{{- path }}]",tryingToAppendToNonSequence:"Cannot append to non-sequence at: [{{- path }}]",startNodeMustBeCollection:"Starting node must be an array or an object",scalarValuesDoNotHaveProperties:"Scalar values do not have properties"});function nl(e,t){try{return t?e?.replace(/{{-?([^{}]*)}}/g,(r,n)=>{let i=n?.trim();return t[i]?.toString()||r}):e}catch{return""}}var DN=class e{documents;static async newInstance(t){return new e(t)}constructor(t){this.documents=il.default.parseAllDocuments(t),this.documents.length===0&&this.documents.push(il.default.parseDocument(t));let r=this.documents.filter(n=>n.errors.length>0);if(r.length>0)throw new yi(Ao.yamlParsing+`
|
|
660
|
+
`);let t=new Ua("!xml"),r=t,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,s=new PP(i.processEntities),o=e.length;for(let a=0;a<o;a++)if(e[a]==="<"){let c=e.charCodeAt(a+1);if(c===47){let l=pb(e,">",a,"Closing Tag is not closed."),f=e.substring(a+2,l).trim();if(i.removeNSPrefix){let d=f.indexOf(":");d!==-1&&(f=f.substr(d+1))}f=OZ(i.transformTagName,f,"",i).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));let p=this.matcher.getCurrentTag();if(f&&i.unpairedTagsSet.has(f))throw new Error(`Unpaired tag can not be used as closing tag: </${f}>`);p&&i.unpairedTagsSet.has(p)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),n="",a=l}else if(c===63){let l=PZ(e,a,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let f=this.buildAttributesMap(l.tagExp,this.matcher,l.tagName,!0);if(f){let p=f[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(p)||1),s.setXmlVersion(Number(p)||1)}if(!(i.ignoreDeclaration&&l.tagName==="?xml"||i.ignorePiTags)){let p=new Ua(l.tagName);p.add(i.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&i.ignoreAttributes!==!0&&(p[":@"]=f),this.addChild(r,p,this.readonlyMatcher,a)}a=l.closeIndex+1}else if(c===33&&e.charCodeAt(a+2)===45&&e.charCodeAt(a+3)===45){let l=pb(e,"-->",a+4,"Comment is not closed.");if(i.commentPropName){let f=e.substring(a+4,l-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(i.commentPropName,[{[i.textNodeName]:f}])}a=l}else if(c===33&&e.charCodeAt(a+2)===68){let l=s.readDocType(e,a);this.entityDecoder.addInputEntities(l.entities),a=l.i}else if(c===33&&e.charCodeAt(a+2)===91){let l=pb(e,"]]>",a,"CDATA is not closed.")-2,f=e.substring(a+9,l);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let p=this.parseTextData(f,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);p==null&&(p=""),i.cdataPropName?r.add(i.cdataPropName,[{[i.textNodeName]:f}]):r.add(i.textNodeName,p),a=l+2}else{let l=PZ(e,a,i.removeNSPrefix);if(!l){let N=e.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${N}"`)}let f=l.tagName,p=l.rawTagName,d=l.tagExp,h=l.attrExpPresent,g=l.closeIndex;if({tagName:f,tagExp:d}=OZ(i.transformTagName,f,d,i),i.strictReservedNames&&(f===i.commentPropName||f===i.cdataPropName||f===i.textNodeName||f===i.attributesGroupName))throw new Error(`Invalid tag name: ${f}`);r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));let _=r;_&&i.unpairedTagsSet.has(_.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let S=!1;d.length>0&&d.lastIndexOf("/")===d.length-1&&(S=!0,f[f.length-1]==="/"?(f=f.substr(0,f.length-1),d=f):d=d.substr(0,d.length-1),h=f!==d);let T=null,A={},w;w=Oyr(p),f!==t.tagname&&this.matcher.push(f,{},w),f!==d&&h&&(T=this.buildAttributesMap(d,this.matcher,f),T&&(A=Cyr(T,i))),f!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let x=a;if(this.isCurrentNodeStopNode){let N="";if(S)a=l.closeIndex;else if(i.unpairedTagsSet.has(f))a=l.closeIndex;else{let D=this.readStopNodeData(e,p,g+1);if(!D)throw new Error(`Unexpected end of ${p}`);a=D.i,N=D.tagContent}let F=new Ua(f);T&&(F[":@"]=T),F.add(i.textNodeName,N),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,F,this.readonlyMatcher,x)}else{if(S){({tagName:f,tagExp:d}=OZ(i.transformTagName,f,d,i));let N=new Ua(f);T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(f)){let N=new Ua(f);T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=l.closeIndex;continue}else{let N=new Ua(f);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),T&&(N[":@"]=T),this.addChild(r,N,this.readonlyMatcher,x),r=N}n="",a=g}}}else n+=e[a];return t.child};function Lyr(e,t,r,n){this.options.captureMetaData||(n=void 0);let i=this.options.jPath?r.toString():r,s=this.options.updateTag(t.tagname,i,t[":@"]);s===!1||(typeof s=="string"&&(t.tagname=s),e.addChild(t,n))}function Myr(e,t,r){let n=this.options.processEntities;if(!n||!n.enabled)return e;if(n.allowedTags){let i=this.options.jPath?r.toString():r;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(t):n.allowedTags(t,i)))return e}if(n.tagFilter){let i=this.options.jPath?r.toString():r;if(!n.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function Fyr(e,t,r,n){return e&&(n===void 0&&(n=t.child.length===0),e=this.parseTextData(e,t.tagname,r,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,n),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Uyr(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function kyr(e,t,r=">"){let n=0,i=e.length,s=r.charCodeAt(0),o=r.length>1?r.charCodeAt(1):-1,a="",u=t;for(let c=t;c<i;c++){let l=e.charCodeAt(c);if(n)l===n&&(n=0);else if(l===34||l===39)n=l;else if(l===s)if(o!==-1){if(e.charCodeAt(c+1)===o)return a+=e.substring(u,c),{data:a,index:c}}else return a+=e.substring(u,c),{data:a,index:c};else l===9&&!n&&(a+=e.substring(u,c)+" ",u=c+1)}}function pb(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i+t.length-1}function Byr(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i}function PZ(e,t,r,n=">"){let i=kyr(e,t+1,n);if(!i)return;let s=i.data,o=i.index,a=s.search(/\s/),u=s,c=!0;a!==-1&&(u=s.substring(0,a),s=s.substring(a+1).trimStart());let l=u;if(r){let f=u.indexOf(":");f!==-1&&(u=u.substr(f+1),c=u!==i.data.substr(f+1))}return{tagName:u,tagExp:s,closeIndex:o,attrExpPresent:c,rawTagName:l}}function qyr(e,t,r){let n=r,i=1,s=e.length;for(;r<s;r++)if(e[r]==="<"){let o=e.charCodeAt(r+1);if(o===47){let a=Byr(e,">",r,`${t} is not closed`);if(e.substring(r+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(n,r),i:a};r=a}else if(o===63)r=pb(e,"?>",r+1,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===45&&e.charCodeAt(r+3)===45)r=pb(e,"-->",r+3,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===91)r=pb(e,"]]>",r,"StopNode is not closed.")-2;else{let a=PZ(e,r,!1);a&&((a&&a.tagName)===t&&a.tagExp[a.tagExp.length-1]!=="/"&&i++,r=a.closeIndex)}}}function DZ(e,t,r){if(t&&typeof e=="string"){let n=e.trim();return n==="true"?!0:n==="false"?!1:xZ(e,r)}else return VUe(e)?e:""}function OZ(e,t,r,n){if(e){let i=e(t);r===t&&(r=i),t=i}return t=pke(t,n),{tagName:t,tagExp:r}}function pke(e,t){if(_k.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return xP.includes(e)?t.onDangerousProperty(e):e}var RZ=Ua.getMetaDataSymbol();function jyr(e,t){if(!e||typeof e!="object")return{};if(!t)return e;let r={};for(let n in e)if(n.startsWith(t)){let i=n.substring(t.length);r[i]=e[n]}else r[n]=e[n];return r}function NZ(e,t,r,n){return dke(e,t,r,n)}function dke(e,t,r,n){let i,s={};for(let o=0;o<e.length;o++){let a=e[o],u=Vyr(a);if(u!==void 0&&u!==t.textNodeName){let c=jyr(a[":@"]||{},t.attributeNamePrefix);r.push(u,c)}if(u===t.textNodeName)i===void 0?i=a[u]:i+=""+a[u];else{if(u===void 0)continue;if(a[u]){let c=dke(a[u],t,r,n),l=$yr(c,t);if(Object.keys(c).length===0&&t.alwaysCreateTextNode&&(c[t.textNodeName]=""),a[":@"]?Gyr(c,a[":@"],n,t):Object.keys(c).length===1&&c[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?c=c[t.textNodeName]:Object.keys(c).length===0&&(t.alwaysCreateTextNode?c[t.textNodeName]="":c=""),a[RZ]!==void 0&&typeof c=="object"&&c!==null&&(c[RZ]=a[RZ]),s[u]!==void 0&&Object.prototype.hasOwnProperty.call(s,u))Array.isArray(s[u])||(s[u]=[s[u]]),s[u].push(c);else{let f=t.jPath?n.toString():n;t.isArray(u,f,l)?s[u]=[c]:s[u]=c}u!==void 0&&u!==t.textNodeName&&r.pop()}}}return typeof i=="string"?i.length>0&&(s[t.textNodeName]=i):i!==void 0&&(s[t.textNodeName]=i),s}function Vyr(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(n!==":@")return n}}function Gyr(e,t,r,n){if(t){let i=Object.keys(t),s=i.length;for(let o=0;o<s;o++){let a=i[o],u=a.startsWith(n.attributeNamePrefix)?a.substring(n.attributeNamePrefix.length):a,c=n.jPath?r.toString()+"."+u:r;n.isArray(a,c,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function $yr(e,t){let{textNodeName:r}=t,n=Object.keys(e).length;return!!(n===0||n===1&&(e[r]||typeof e[r]=="boolean"||e[r]===0))}var zf=class{constructor(t){this.externalEntities={},this.options=uke(t)}parse(t,r){if(typeof t!="string"&&t.toString)t=t.toString();else if(typeof t!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=Sk(t,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new DP(this.options,this.externalEntities),i=n.parseXml(t);return this.options.preserveOrder||i===void 0?i:NZ(i,this.options,n.matcher,n.readonlyMatcher)}addEntity(t,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=r}static getMetaDataSymbol(){return Ua.getMetaDataSymbol()}};var db={validate:Sk};var Bm=class extends Pa{static ADT_DISCOVERY_SERVICE_PATH="/sap/bc/adt/discovery";schemaStore=new vk;log;async getServiceDefinition(t){await this.checkOrLoadAdtDiscoverySchema();let r=this.schemaStore.getAdtCollection(t);return this.validateServiceSchema(t,r)?r:(this.log.warn("Invalid Discovery Schema"),null)}validateServiceSchema(t,r){return r?r.href?!0:(this.log.warn(`Empty href in schema: ${t.term} - ${t.scheme}`),!1):(this.log.warn(`Schema Not Found: ${t.term} - ${t.scheme}`),!1)}async checkOrLoadAdtDiscoverySchema(){if(!this.schemaStore.isAdtSchemaEmpty())return;let t=await this.get("",{headers:{Accept:"application/*"}}),r=this.parseAdtSchemaData(t.data);this.schemaStore.updateSchemaData(r)}parseAdtSchemaData(t){if(db.validate(t)!==!0)return null;let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new zf(r).parse(t,!0);return i.service?i:null}};var Cd=class extends Pa{static PATH="/sap/bc/ui2/app_index";log;async search(t={},r){let n={...t};r&&(n.fields=r.join(","));let i=await this.get("/",{params:n});return JSON.parse(i.data).results}async getIsManiFirstSupported(t){try{let r={id:t},n=await this.get("/ui5_app_mani_first_supported",{params:r});return JSON.parse(n.data)}catch(r){throw this.log.error(`Fail fetching ui5_app_mani_first_supported for app with id: ${t}.`),this.log.debug(r),r}}async getAppInfo(t){try{let r=await this.get("/ui5_app_info_json",{params:{id:t}});return JSON.parse(r.data)}catch(r){throw vF(r)?this.log.error(`Failed fetching ui5_app_info_json for app with id ${t}.`):this.log.error(`Parsing error: ui5_app_info_json is not in expected format for app with id ${t}.`),this.log.debug(r),r}}};var RP={UI:"UI",NotClassified:"Not Classified",WebApi:"WEB_API",NotDetermined:"Not Determined"},hb=class extends bm{entitySet;services;isS4Cloud;async listServices(t=!1){return this.services||(this.services=await this.fetchServices(t)),this.services}};var hke="ServiceCollection",mke="RecommendedServiceCollection",Hyr="((IsSapService%20eq%20true)and(ReleaseStatus%20eq%20%27RELEASED%27))or((IsSapService%20eq%20false))",qm=class extends hb{static PATH="/sap/opu/odata/IWFND/CATALOGSERVICE;v=2";async determineEntitySet(){let t=await this.document();this.entitySet=t.EntitySets.includes(mke)?mke:hke}getServicePath(t,r){let n;try{n=new URL(t)}catch{n=new URL(t,r)}return n.pathname}mapServices(t){return t.map(r=>{let n=this.getServicePath(r.ServiceUrl,this.defaults.baseURL);return{id:r.ID,name:r.TechnicalServiceName,path:n,serviceVersion:r.TechnicalServiceVersion+"",odataVersion:Er.v2,serviceType:r.ServiceType}})}async fetchServices(){let t={$format:"json"};this.entitySet||await this.determineEntitySet(),this.entitySet===hke&&await this.isS4Cloud&&(t.$filter=Hyr);let n=(await this.get(`/${this.entitySet}`,{params:t})).odata();if(If.containsError(n))throw new If(n);return this.mapServices(n)}async findService({title:t,path:r}){let n=1;if(!t){let u=r.replace(/\/$/,"").split("/").pop().split(";");if(t=u[0].toUpperCase(),!t)throw new Error(`Cannot determine service title from path: ${r}`);u.slice(1).forEach(l=>{let[f,p]=l.split("=");f==="v"&&(n=Number.parseInt(p,10))})}let i={$format:"json",$filter:`Title eq '${t}' and TechnicalServiceVersion eq ${n}`},s=this.entitySet?`/${this.entitySet}`:"/ServiceCollection",a=(await this.get(s,{params:i})).odata();if(a.length>1){let u=a.filter(c=>c.ServiceUrl?.toUpperCase().includes((r||t).toUpperCase()));if(u.length>1)this.log.warn("Service filter was not sufficient to identify one service.");else if(u.length>0)return this.log.info(`Service filter chose service: ${u[0].TechnicalServiceName}`),u[0]}return a.length>0?a[0]:void 0}async getServiceAnnotations({id:t,title:r,path:n}){if(!t){let i=await this.findService({title:r,path:n});i&&(t=i.ID)}return t?(await this.get(`/ServiceCollection('${encodeURIComponent(t)}')/Annotations`,{params:{$format:"json"}})).odata():[]}async getAnnotations({id:t,title:r,path:n}){if(!t&&!r&&!n)throw new Error("No filter parameters passed in");let i=await this.getServiceAnnotations({id:t,title:r,path:n}),s=[];for(let o of i){let a=`/Annotations(TechnicalName='${encodeURIComponent(o.TechnicalName)}',Version='${o.Version}')/$value/`,u=await this.get(a,{headers:{Accept:"application/xml"}});u.data?s.push({TechnicalName:o.TechnicalName,Version:o.Version,Definitions:u.data,Uri:this.defaults.baseURL+a}):this.log.warn(`No annotations found for TechnicalName=${o.TechnicalName}, Version=${o.Version}`)}return s}async getServiceType(t){let r,{ID:n}=await this.findService({path:t});if(n){let i=await this.get(`/ServiceTypeForHUBServices('${encodeURIComponent(n)}')`);i&&(r=i.odata().ServiceType)}return r}};var gke="RecommendedServices",yke="Services",mb=class extends hb{logger=new vs;static PATH="/sap/opu/odata4/iwfnd/config/default/iwfnd/catalog/0002";mapServices(t,r,n=!1){let i=[],s=new Set;return t.filter(o=>o?.DefaultSystem?.[r]?.length>0).forEach(o=>{i.push(...o.DefaultSystem[r].flatMap(a=>{let u=a.ServiceUrl.split("?").shift();if(n){let c=`${a.ServiceId}|${u}`;if(s.has(c))return[];s.add(c)}return{id:a.ServiceId,group:o.GroupId,path:u,name:`${o.GroupId} > ${a.ServiceAlias||a.ServiceId}`,serviceVersion:a.ServiceVersion,odataVersion:Er.v4,serviceType:a.ServiceType}}))}),i}async fetchServicesNextLink(){if(this.entitySet===void 0){let o=await this.metadata();this.entitySet=o.includes('Name="RecommendedServices"')?gke:yke}let t=new URLSearchParams([["$count","true"],["$expand",`DefaultSystem($expand=${this.entitySet})`]]),n=(await this.get("/ServiceGroups",{params:t},!0)).odata(),i=n.value,s=1;for(;n["@odata.nextLink"];){let o=new URL(n["@odata.nextLink"],this.defaults.baseURL);n=(await this.get("/ServiceGroups",{params:o.searchParams},!0)).odata(),s++,i.push(...n.value)}if(this.logger.log(`Fetched ${i.length} service groups in ${s} requests.`),If.containsError(i))throw new If(i);return this.mapServices(i,this.entitySet)}async fetchServices(t=!1){return t?this.fetchServicesNextLink():this.fetchServicesParallel()}async fetchServicesParallel(){if(this.entitySet===void 0){let c=await this.metadata();this.entitySet=c.includes('Name="RecommendedServices"')?gke:yke}let r=new URLSearchParams([["$count","true"],["$top","1000"],["$expand",`DefaultSystem($expand=${this.entitySet})`]]),i=(await this.get("/ServiceGroups",{params:r},!0)).odata(),s=i.value,o=i["@odata.count"],a=Number.parseInt(i["@odata.nextLink"]?.split("skiptoken=")[1],10),u=1;if(!Number.isNaN(a)){let c=Math.ceil(o/a),l=Array.from({length:c-1},(p,d)=>{let h=new URLSearchParams([["$count","true"],["$skip",String((d+1)*a)],["$top",a.toString()],["$expand",`DefaultSystem($expand=${this.entitySet})`]]);return u++,this.get("/ServiceGroups",{params:h},!0)});(await Promise.all(l)).forEach(p=>{let d=p.odata();s.push(...d.value)})}if(this.logger.log(`Fetched ${s.length} service groups in ${u} requests.`),If.containsError(s))throw new If(s);return this.mapServices(s,this.entitySet,!0)}getAnnotations(){return Promise.resolve([])}getServiceType(){return Promise.resolve(void 0)}};var NP;(function(e){e.SAP="SAP",e.Customer="CUSTOMER"})(NP||(NP={}));var ti=class extends Pa{log;serviceSchema;static getAdtCatagory(){throw new Error("NEEDS TO BE IMPLEMENTED BY AdtService SUBCLASSES")}attachAdtSchema(t){this.serviceSchema=t}parseResponse(t){if(db.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0};return new zf(r).parse(t,!0)}};var IP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/ato",term:"settings"};static getAdtCatagory(){return e.adtCategory}async getAtoInfo(){let t={headers:{Accept:"application/*"}},r=await this.get("",t);return this.parseAtoResponse(r.data)}parseAtoResponse(t){if(db.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new zf(r).parse(t,!0);return i.settings?i.settings:{}}};var fBe=be(vke(),1),bvr=be(lBe(),1);var WP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/respository",term:"generators"};static getAdtCatagory(){return e.adtCategory}async getUIServiceGeneratorConfig(t){let r=await this.get("",{headers:{Accept:"application/atom+xml;type=feed"},params:{referencedObject:t,type:"webapi"}}),n=this.parseResponse(r.data).feed?.entry;if(n?.id==="published-ui-service")return n;throw new Error("UI Service Generator not found")}};var YP=class e extends ti{static adtCategory={scheme:"http://www.sap.com/adt/categories/respository",term:"generators"};static getAdtCatagory(){return e.adtCategory}id;async getRAPGeneratorConfig(){let t=await this.get("",{headers:{Accept:"application/atom+xml;type=feed"},params:{type:"webapi",fetchAllGenerators:!0}}),r=this.parseResponse(t.data).feed?.entry??[];r&&!Array.isArray(r)&&(r=[r]);let n=r.find(i=>i.id==="published-x-ui-service");if(n)return n;throw new Error("OData Service Generator not found")}};var zP=class extends ti{packageName;contentType;configure(t,r){this.packageName=r}setContentType(t){this.contentType=t}async validate(t){let r=await this.post("/validation",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.validationMessages.v1+xml, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage"},params:{package:this.packageName}});return this.parseValidateResponse(r.data)}async getTechnicalDetails(t){let r=await this.post("/preview",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.objects.massoperation.v1+xml"},params:{package:this.packageName}});return this.parsePreviewResponse(r.data)}async generate(t){return(await this.post("",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.generator.v1+json"},params:{package:this.packageName}})).status}parseValidateResponse(t){let n=this.parseResponse(t).validationMessages;return Array.isArray(n)||(n=[n]),n.map(i=>i.validationMessage||{})||[]}parsePreviewResponse(t){let n=(this.parseResponse(t).group.group||[]).find(a=>a.name==="Business Service Layer");if(!n)return;let i=Array.isArray(n.object)?n.object:[n.object],s=i.find(a=>a.objectReference?.type==="SRVD/SRV"),o=i.find(a=>a.objectReference?.type==="SRVB/SVB");if(!(!s||!o))return{serviceName:o.objectReference?.name||"",serviceDefinitionName:s.objectReference?.name||"",serviceVersion:"0001"}}};var xb=class extends ti{referencedObject;contentType;configure(t,r,n){this.referencedObject=r,this.contentType=n}async getSchema(){let t=await this.get("/schema",{headers:{Accept:"application/vnd.sap.adt.repository.generator.schema.v1+json"},params:{referencedObject:this.referencedObject.uri}});return JSON.parse(t.data)}async getContent(t){let n=(await this.get("/content",{headers:{Accept:this.contentType},params:{referencedObject:this.referencedObject.uri,package:t}})).data,i=JSON.parse(n);return i.metadata||(i.metadata={package:t}),JSON.stringify(i)}async validatePackage(t){let r=await this.get("/validation",{headers:{Accept:"application/vnd.sap.adt.validationMessages.v1+xml"},params:{referencedObject:this.referencedObject.uri,package:t,checks:"package"}});return this.parseResponse(r.data)}async validateContent(t){let r=await this.post("/validation",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.validationMessages.v1+xml"},params:{referencedObject:this.referencedObject.uri,checks:"package,referencedobject,authorization"}});return this.parseResponse(r.data).validationMessages?.validationMessage}async generate(t,r){let n=await this.post("",t,{headers:{"Content-Type":this.contentType,Accept:"application/vnd.sap.adt.repository.generator.v1+json, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage"},params:{referencedObject:this.referencedObject.uri,corrNr:r}});return this.parseResponse(n.data)}};var Uk=class extends ti{async getSystemInfo(){let t={headers:{Accept:"application/vnd.sap.adt.core.http.systeminformation.v1+json"}},r=await this.get("/sap/bc/adt/core/http/systeminformation",t);if(typeof r.data=="string")try{return JSON.parse(r.data)}catch(n){this.log.error(`System info could not be parsed from response. Error: ${n.message}`)}else return r.data}};var KP=class extends Pa{static PATH="/sap/public/bc/ui5_ui5";log;async getUI5Version(){try{let t=await this.get("/bootstrap_info.json",{transformResponse:n=>JSON.parse(n)}),{Version:r}=t.data;if(!r)throw new Error("UI5 version not provided.");return r}catch(t){throw this.log.error("Could not get UI5 Version."),this.log.debug(t),t}}};var Va=class extends km{atoSettings;_publicUrl;_systemInfo;async user(){return await Promise.resolve(this.defaults.auth?.username)||(await this.getSystemInfo())?.userName}async getSystemInfo(){if(this._systemInfo)return this._systemInfo;try{let t=this.createService("",Uk);this._systemInfo=await t.getSystemInfo()}catch(t){this.log.error(`An error occurred retrieving system info: ${t}`)}return this._systemInfo}setAtoInfo(t){this.atoSettings=t}async getAtoInfo(){if(this.atoSettings)return this.atoSettings;let t;try{t=await this.getAdtService(IP),t?this.atoSettings=await t.getAtoInfo():this.atoSettings={}}catch{this.atoSettings={}}return this.atoSettings}set publicUrl(t){this._publicUrl=t}get publicUrl(){return this._publicUrl||this.defaults.baseURL}async isAbapCloud(){return this.atoSettings===void 0&&await this.getAtoInfo(),this.atoSettings.tenantType===NP.Customer&&this.atoSettings.operationsType==="C"}getAdtCatalogService(){if(!this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]){let t=this.createService(Bm.ADT_DISCOVERY_SERVICE_PATH,Bm);this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]=t}return this.services[Bm.ADT_DISCOVERY_SERVICE_PATH]}catalog(t){let r;if(t===Er.v2)r=this.services[qm.PATH]??this.createService(qm.PATH,qm);else if(t===Er.v4)r=this.services[mb.PATH]??this.createService(mb.PATH,mb);else throw new Error("not implemented yet");return Object.defineProperty(r,"isAbapCloud",{get:this.isAbapCloud.bind(this)}),r}getUi5AbapRepository(t){let r=t??ab.PATH;return this.services[r]||(this.services[r]=this.createService(r,ab)),this.services[r]}getAppIndex(){return this.services[Cd.PATH]||(this.services[Cd.PATH]=this.createService(Cd.PATH,Cd)),this.services[Cd.PATH]}getLayeredRepository(t){let r=t??ub.PATH;return this.services[r]||(this.services[r]=this.createService(r,ub)),this.services[r]}async getAdtService(t){let r=t.name;if(!this.services[r]){let i=await this.getAdtCatalogService().getServiceDefinition(t.getAdtCatagory());if(!i)return null;this.services[r]=this.createService(i.href,t),this.services[r].attachAdtSchema(i)}return this.services[r]}getUI5VersionService(){let t=KP.PATH;return this.services[t]||(this.services[t]=this.createService(t,KP)),this.services[t]}async getUiServiceGenerator(t){let r=await this.getAdtService(WP);if(!r)throw new Error("Generators are not supported on this system");let n=await r.getUIServiceGeneratorConfig(t.uri),i=this.createService(this.getServiceUrlFromConfig(n),xb);return i.configure(n,t,this.getContentType(n)),i}async getODataServiceGenerator(t){let r=await this.getAdtService(YP);if(!r)throw new Error("RAP Generator are not support on this system");let n=await r.getRAPGeneratorConfig(),i=this.createService(this.getServiceUrlFromConfig(n),zP);return i.setContentType(this.getContentType(n)),i.configure(n,t||"$TMP"),i}async fetchExternalServices(t){let r=[],n=t.map(async i=>{let{serviceRootPath:s,value:o}=i,a=(0,pBe.join)(s,o).replace("/$metadata",""),u=this.service(a);try{let c=await u.metadata();i.type==="value-list"?r.push({type:"value-list",path:a,target:i.target,metadata:c}):i.type==="code-list"&&r.push({type:"code-list",path:a,metadata:c})}catch(c){this.log.warn(`Could not fetch value list reference metadata from ${a}, ${c.message}`)}});return await Promise.allSettled(n),r}getServiceUrlFromConfig(t){if(Array.isArray(t.link)&&!t.link[0]?.href)throw new Error("No service URL found in the generator config");let r=t.link[0].href.indexOf(t.id)+t.id.length;return t.link[0].href.substring(0,r)}getContentType(t){return(t.link?.find(n=>typeof n.href=="string"&&n.href.includes("/content"))).type}async createLockServiceBindingGenerator(t){return this.createService(t,xb)}};var vHe=be(BGe(),1),ap=be(nq(),1);var eg;(function(e){e.H2O_URL="H2O_URL",e.HTTP_PROXY="HTTP_PROXY",e.HTTPS_PROXY="HTTPS_PROXY"})(eg||(eg={}));var iq;(function(e){e.HTTP="HTTP",e.LDAP="LDAP",e.MAIL="MAIL",e.RFC="RFC"})(iq||(iq={}));var sq;(function(e){e.DEDICATED="Dedicated",e.COMMON="Common"})(sq||(sq={}));var op;(function(e){e.BASIC_AUTHENTICATION="BasicAuthentication",e.CLIENT_CERT_AUTHENTICATION="ClientCertificateAuthentication",e.NO_AUTHENTICATION="NoAuthentication",e.OAUTH2_CLIENT_CREDENTIALS="OAuth2ClientCredentials",e.OAUTH2_JWT_BEARER="OAuth2JWTBearer",e.OAUTH2_PASSWORD="OAuth2Password",e.OAUTH2_REFRESH_TOKEN="OAuth2RefreshToken",e.OAUTH2_SAML_BEARER_ASSERTION="OAuth2SAMLBearerAssertion",e.OAUTH2_USER_TOKEN_EXCHANGE="OAuth2UserTokenExchange",e.SAML_ASSERTION="SAMLAssertion"})(op||(op={}));var oq;(function(e){e.S4HC="S4HC",e.BTP="BTP"})(oq||(oq={}));var dre;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(dre||(dre={}));var SE;(function(e){e.ODATA_GENERIC="odata_gen",e.ODATA_ABAP="odata_abap",e.DEV_ABAP="dev_abap",e.ABAP_CLOUD="abap_cloud"})(SE||(SE={}));var aq;(function(e){e.FULL_URL="full_url",e.API_MGMT="api_mgmt"})(aq||(aq={}));var ND;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(ND||(ND={}));function hHe(e){return!!(e.WebIDEUsage?.includes("abap")||e["sap-client"]||e["sap-platform"]?.toLocaleLowerCase()==="abap"||e.ProxyType==="OnPremise")}function zOr(e){return!!(e.WebIDEUsage?.includes(SE.ABAP_CLOUD)||e["sap-platform"]?.toLocaleLowerCase()==="abap")}function uq(e){return!!(e.WebIDEUsage?.includes(SE.ODATA_GENERIC)&&!e.WebIDEUsage.includes(SE.ODATA_ABAP))}function Kl(e){return!!(!e.WebIDEAdditionalData?.includes(aq.FULL_URL)&&uq(e))}function tg(e){return!!(e.WebIDEAdditionalData?.includes(aq.FULL_URL)&&uq(e))}function mHe(e){return!!e.ProxyType.includes(ND.ON_PREMISE)}function gHe(e){return!!e["HTML5.DynamicDestination"]}function KOr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dHe(e,t){let r=` (${t})`;return RegExp(`${KOr(r)}$`).exec(e.trim())?e:`${e} (${t})`}function yHe(e,t){let r=t?` [${t}]`:"",n;return zOr(e)?n=dHe(e.Name,oq.BTP):hre(e)?n=dHe(e.Name,oq.S4HC):n=e.Name,`${n}${r}`}function hre(e){return!!(e.WebIDEUsage?.includes(SE.ODATA_ABAP)&&e.Authentication===op.SAML_ASSERTION&&e.ProxyType===dre.INTERNET)}function cq(e){return!!e.WebIDEUsage?.includes(SE.ODATA_ABAP)}var Gd={ABAP:"abap",ABAP_TRIAL:"abap-trial",ABAP_CANARY:"abap-canary",ABAP_OEM:"abap-oem",ABAP_OEM_CANARY:"abap-oem-canary",ABAP_HAAS:"abap-haas",DESTINATION:"destination",ABAP_STAGING:"abap-staging",ABAP_INTERNAL_STAGING:"abap-internal-staging"};var mre="abap-cloud-destination-instance",EHe="bas-destination-instance-cred";function Vr(){return!!process.env[eg.H2O_URL]}async function _He(e){try{let t=await(0,ap.cfGetInstanceKeyParameters)(e);if(!t)throw new Error(`No destination instance ${e} found`);let r=t.credentials;if(!r)throw new Error(`No credentials for destination instance ${e} found`);let n=r.uaa?.clientid||r.clientid,i=r.uaa?.clientsecret||r.clientsecret;return Buffer.from(`${encodeURIComponent(n)}:${encodeURIComponent(i)}`).toString("base64")}catch(t){throw new Error(`An error occurred while retrieving service key for the destination instance ${e}: ${t}`)}}function rT(e,t){let r=`https://${e}.dest`;return t&&t.length>1?new URL(t,r).toString():r}function XOr(e){let[t,...r]=e.split(".");return[t.replace(/-api$/,""),...r].join(".")}async function gre(e){let t={};await Oa.get("/reload",{baseURL:process.env[eg.HTTP_PROXY]}),JOr();let r=await Oa.get("/api/listDestinations",{baseURL:process.env[eg.H2O_URL]});return(Array.isArray(r.data)?r.data:[]).forEach(i=>{e?.stripS4HCApiHosts&&hre(i)&&(i.Host=XOr(i.Host)),i.WebIDEEnabled&&(t[i.Name]=i)}),t}function JOr(){!Vr()||!globalThis.GLOBAL_AGENT||(globalThis.GLOBAL_AGENT.HTTP_PROXY||(globalThis.GLOBAL_AGENT.HTTP_PROXY=process.env[eg.HTTP_PROXY]??null),globalThis.GLOBAL_AGENT.HTTPS_PROXY||(globalThis.GLOBAL_AGENT.HTTPS_PROXY=process.env[eg.HTTPS_PROXY]??null))}function QOr(e,t,r,n){let i={usage:"odata_abap,dev_abap,abap_cloud",html5DynamicDestination:"true",html5Timeout:"60000"},s={clientId:r.clientid,clientSecret:r.clientsecret,tokenServiceURL:new URL("/oauth/token",r.url).toString(),tokenServiceURLType:sq.DEDICATED};return{name:e,description:t,url:new URL(n),type:iq.HTTP,proxyType:ND.INTERNET,basProperties:i,credentials:{authentication:op.OAUTH2_USER_TOKEN_EXCHANGE,oauth2UserTokenExchange:s}}}async function yre(e){let t=await(0,ap.cfGetTarget)(!0);if(!t.space)throw new Error("No Dev Space has been created for the subaccount.");return`abap-cloud-${`${e}-${t.org}-${t.space}`.replace(/\W/gi,"-").toLowerCase()}`.substring(0,199)}async function ZOr(e,t,r,n){let i=await yre(e);return(await(0,ap.apiGetServicesInstancesFilteredByType)(["destination"])).find(a=>a.label===mre)||(await(0,ap.apiCreateServiceInstance)("destination","lite",mre,null),n?.info(`New ABAP destination instance ${mre} created.`)),QOr(i,`Destination generated by App Studio for Cloud Foundry Abap service instance: '${e}', Do not remove.`,t,r)}async function SHe(e,t,r){if(!Vr())throw new Error("Creating a SAP BTP destinations is only supported on SAP Business Application Studio.");let n=t;try{if(!n){let a=await(0,ap.apiGetInstanceCredentials)(e);if(!a?.credentials)throw new Error(`Could not retrieve SAP BTP credentials for ${e}.`);n={uaaCredentials:a.credentials.uaa,hostUrl:a.credentials.url}}let i=await ZOr(e,n.uaaCredentials,n.hostUrl,r);await vHe.destinations.createDestination(i),r?.debug(`SAP BTP destination ${JSON.stringify(i,null,2)} created.`);let o=(await gre())?.[i.name];if(!o)throw new Error("Destination not found on SAP BTP.");return o}catch(i){throw new Error(`An error occurred while generating destination ${e}: ${i}`)}}var kHe=be(_re(),1),BHe=require("node:https"),qHe=be(Sre(),1),jHe=be(LF(),1),VHe=be(UHe(),1),GHe=require("node:util");var bre=class extends qHe.HttpsProxyAgent{extraOptions;constructor(t,r){super(t,r),this.extraOptions=r}async connect(t,r){return super.connect(t,{...this.extraOptions,...r})}};function bE(e,t){let r=(0,jHe.default)(t),n={rejectUnauthorized:!r.ignoreCertErrors};r.httpsAgent||(r.httpsAgent=new BHe.Agent(n)),delete r.ignoreCertErrors,r.withCredentials=r?.auth&&Object.keys(r.auth).length>0,r.validateStatus=s=>s<400;let i=new e(r);return i.interceptors.request.use(s=>{let o=i.getUri(s),a=(0,VHe.getProxyForUrl)(o);return a&&!Vr()&&(s.httpsAgent=new bre(a,n),s.httpAgent=new kHe.HttpProxyAgent(a),s.proxy=!1),s}),i.defaults.headers=i.defaults.headers??{common:{},delete:{},put:{},get:{},post:{},head:{},patch:{}},IFe(i),r.auth?.password&&LUe(i),t.cookies&&t.cookies.split(";").forEach(s=>{i.cookies.addCookie(s.trim())}),AP.isPatchRequired(t.baseURL)&&AP.apply(),i}function $He(e){return typeof e=="string"?bE(km,{baseURL:e}):bE(km,e)}function AE(e){return bE(Va,e)}var TE;(function(e){e.Standalone="Standalone",e.EmbeddedSteampunk="EmbeddedSteampunk"})(TE||(TE={}));function Tre(e){let t;switch(e.environment){case TE.Standalone:{let{service:r,refreshToken:n,refreshTokenChangedCb:i,cookies:s,...o}=e;t=bE(Va,{baseURL:r.url,cookies:s,...o}),s||(e.service?.uaa?.username&&e.service.uaa.password?MUe(t,r,n,i):hZ({provider:t}));break}case TE.EmbeddedSteampunk:{let{url:r,cookies:n,...i}=e;t=bE(Va,{baseURL:r,cookies:n,...i}),n||hZ({provider:t});break}default:{let r=e;throw new Error(`Unknown environment type supplied: ${(0,GHe.inspect)(r)}`)}}return t}function HHe(e,t,r){let{cookies:n,...i}=e,s={...i,baseURL:rT(t.Name,t.Host?new URL(t.Host).pathname:void 0),cookies:n};s.params=s.params??{},s.params.saml2="disabled";let o;if(hHe(t)?(o=bE(Va,s),o.publicUrl=t.Host):o=bE(km,s),r){let a=o.interceptors.request.use(async u=>{let c=await _He(r);return o.defaults.headers.common[EHe]=c,o.interceptors.request.eject(a),u})}return o}var WHe;(function(e){e.FF_SIMPLE="basic"})(WHe||(WHe={}));var YHe;(function(e){e.FE_FPM="fpm",e.FE_LROP="lrop",e.FE_OVP="ovp",e.FE_ALP="alp",e.FE_FEOP="feop",e.FE_WORKLIST="worklist"})(YHe||(YHe={}));var cn={vscode:{name:"Visual Studio Code",technical:"VSCode"},bas:{name:"SAP Business Application Studio",technical:"SBAS"},cli:{name:"CLI",technical:"CLI"}};var zHe;(function(e){e.CF="CF",e.ABAP="ABAP"})(zHe||(zHe={}));function MPr(){return!!(process.argv[1]?.includes("yo")||process.stdin.isTTY)}function kc(){return MPr()?cn.cli:Vr()?cn.bas:cn.vscode}var Ut=e=>typeof e=="string",LD=()=>{let e,t,r=new Promise((n,i)=>{e=n,t=i});return r.resolve=e,r.reject=t,r},KHe=e=>e==null?"":""+e,FPr=(e,t,r)=>{e.forEach(n=>{t[n]&&(r[n]=t[n])})},UPr=/###/g,XHe=e=>e&&e.indexOf("###")>-1?e.replace(UPr,"."):e,JHe=e=>!e||Ut(e),MD=(e,t,r)=>{let n=Ut(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(JHe(e))return{};let s=XHe(n[i]);!e[s]&&r&&(e[s]=new r),Object.prototype.hasOwnProperty.call(e,s)?e=e[s]:e={},++i}return JHe(e)?{}:{obj:e,k:XHe(n[i])}},QHe=(e,t,r)=>{let{obj:n,k:i}=MD(e,t,Object);if(n!==void 0||t.length===1){n[i]=r;return}let s=t[t.length-1],o=t.slice(0,t.length-1),a=MD(e,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=MD(e,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=r},kPr=(e,t,r,n)=>{let{obj:i,k:s}=MD(e,t,Object);i[s]=i[s]||[],i[s].push(r)},mq=(e,t)=>{let{obj:r,k:n}=MD(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},BPr=(e,t,r)=>{let n=mq(e,r);return n!==void 0?n:mq(t,r)},s5e=(e,t,r)=>{for(let n in t)n!=="__proto__"&&n!=="constructor"&&(n in e?Ut(e[n])||e[n]instanceof String||Ut(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):s5e(e[n],t[n],r):e[n]=t[n]);return e},xE=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),qPr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},jPr=e=>Ut(e)?e.replace(/[&<>"'\/]/g,t=>qPr[t]):e,Cre=class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){let r=this.regExpMap.get(t);if(r!==void 0)return r;let n=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,n),this.regExpQueue.push(t),n}},VPr=[" ",",","?","!",";"],GPr=new Cre(20),$Pr=(e,t,r)=>{t=t||"",r=r||"";let n=VPr.filter(o=>t.indexOf(o)<0&&r.indexOf(o)<0);if(n.length===0)return!0;let i=GPr.getRegExp(`(${n.map(o=>o==="?"?"\\?":o).join("|")})`),s=!i.test(e);if(!s){let o=e.indexOf(r);o>0&&!i.test(e.substring(0,o))&&(s=!0)}return s},Ore=(e,t,r=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let n=t.split(r),i=e;for(let s=0;s<n.length;){if(!i||typeof i!="object")return;let o,a="";for(let u=s;u<n.length;++u)if(u!==s&&(a+=r),a+=n[u],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&u<n.length-1)continue;s+=u-s+1;break}i=o}return i},FD=e=>e?.replace(/_/g,"-"),HPr={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}},Pre=class e{constructor(t,r={}){this.init(t,r)}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||HPr,this.options=r,this.debug=r.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,r,n,i){return i&&!this.debug?null:(Ut(t[0])&&(t[0]=`${n}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},cp=new Pre,aT=class{constructor(){this.observers={}}on(t,r){return t.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);let i=this.observers[n].get(r)||0;this.observers[n].set(r,i+1)}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t].delete(r)}}emit(t,...r){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[t,...r])})}},gq=class extends aT{constructor(t,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){let r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1)}getResource(t,r,n,i={}){let s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure,a;t.indexOf(".")>-1?a=t.split("."):(a=[t,r],n&&(Array.isArray(n)?a.push(...n):Ut(n)&&s?a.push(...n.split(s)):a.push(n)));let u=mq(this.data,a);return!u&&!r&&!n&&t.indexOf(".")>-1&&(t=a[0],r=a[1],n=a.slice(2).join(".")),u||!o||!Ut(n)?u:Ore(this.data?.[t]?.[r],n,s)}addResource(t,r,n,i,s={silent:!1}){let o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=[t,r];n&&(a=a.concat(o?n.split(o):n)),t.indexOf(".")>-1&&(a=t.split("."),i=r,r=a[1]),this.addNamespaces(r),QHe(this.data,a,i),s.silent||this.emit("added",t,r,n,i)}addResources(t,r,n,i={silent:!1}){for(let s in n)(Ut(n[s])||Array.isArray(n[s]))&&this.addResource(t,r,s,n[s],{silent:!0});i.silent||this.emit("added",t,r,n)}addResourceBundle(t,r,n,i,s,o={silent:!1,skipCopy:!1}){let a=[t,r];t.indexOf(".")>-1&&(a=t.split("."),i=n,n=r,r=a[1]),this.addNamespaces(r);let u=mq(this.data,a)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?s5e(u,n,s):u={...u,...n},QHe(this.data,a,u),o.silent||this.emit("added",t,r,n)}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r)}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){let r=this.getDataByLanguage(t);return!!(r&&Object.keys(r)||[]).find(i=>r[i]&&Object.keys(r[i]).length>0)}toJSON(){return this.data}},o5e={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,i){return e.forEach(s=>{t=this.processors[s]?.process(t,r,n,i)??t}),t}},a5e=Symbol("i18next/PATH_KEY");function WPr(){let e=[],t=Object.create(null),r;return t.get=(n,i)=>(r?.revoke?.(),i===a5e?e:(e.push(i),r=Proxy.revocable(n,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function oT(e,t){let{[a5e]:r}=e(WPr()),n=t?.keySeparator??".",i=t?.nsSeparator??":";if(r.length>1&&i){let s=t?.ns,o=Array.isArray(s)?s:null;if(o&&o.length>1&&o.slice(1).includes(r[0]))return`${r[0]}${i}${r.slice(1).join(n)}`}return r.join(n)}var ZHe={},Are=e=>!Ut(e)&&typeof e!="boolean"&&typeof e!="number",yq=class e extends aT{constructor(t,r={}){super(),FPr(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=cp.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,r={interpolation:{}}){let n={...r};if(t==null)return!1;let i=this.resolve(t,n);if(i?.res===void 0)return!1;let s=Are(i.res);return!(n.returnObjects===!1&&s)}extractFromKey(t,r){let n=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");let i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,s=r.ns||this.options.defaultNS||[],o=n&&t.indexOf(n)>-1,a=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!$Pr(t,n,i);if(o&&!a){let u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:Ut(s)?[s]:s};let c=t.split(n);(n!==i||n===i&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),t=c.join(i)}return{key:t,namespaces:Ut(s)?[s]:s}}translate(t,r,n){let i=typeof r=="object"?{...r}:r;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),t==null)return"";typeof t=="function"&&(t=oT(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(de=>typeof de=="function"?oT(de,{...this.options,...i}):String(de));let s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:u}=this.extractFromKey(t[t.length-1],i),c=u[u.length-1],l=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;l===void 0&&(l=":");let f=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?s?{res:`${c}${l}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${l}${a}`:s?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;let d=this.resolve(t,i),h=d?.res,g=d?.usedKey||a,_=d?.exactUsedKey||a,S=["[object Number]","[object Function]","[object RegExp]"],T=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,A=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!Ut(i.count),x=e.hasDefaultValue(i),N=w?this.pluralResolver.getSuffix(f,i.count,i):"",F=i.ordinal&&w?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=w&&!i.ordinal&&i.count===0,V=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${N}`]||i[`defaultValue${F}`]||i.defaultValue,z=h;A&&!h&&x&&(z=V);let L=Are(z),J=Object.prototype.toString.apply(z);if(A&&z&&L&&S.indexOf(J)<0&&!(Ut(T)&&Array.isArray(z))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let de=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,z,{...i,ns:u}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(d.res=de,d.usedParams=this.getUsedParamsDetails(i),d):de}if(o){let de=Array.isArray(z),ie=de?[]:{},H=de?_:g;for(let G in z)if(Object.prototype.hasOwnProperty.call(z,G)){let ye=`${H}${o}${G}`;x&&!h?ie[G]=this.translate(ye,{...i,defaultValue:Are(V)?V[G]:void 0,joinArrays:!1,ns:u}):ie[G]=this.translate(ye,{...i,joinArrays:!1,ns:u}),ie[G]===ye&&(ie[G]=z[G])}h=ie}}else if(A&&Ut(T)&&Array.isArray(h))h=h.join(T),h&&(h=this.extendTranslation(h,t,i,n));else{let de=!1,ie=!1;!this.isValidLookup(h)&&x&&(de=!0,h=V),this.isValidLookup(h)||(ie=!0,h=a);let G=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ie?void 0:h,ye=x&&V!==h&&this.options.updateMissing;if(ie||de||ye){if(this.logger.log(ye?"updateKey":"missingKey",f,c,a,ye?V:h),o){let Xe=this.resolve(a,{...i,keySeparator:!1});Xe&&Xe.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let xe=[],Ce=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Ce&&Ce[0])for(let Xe=0;Xe<Ce.length;Xe++)xe.push(Ce[Xe]);else this.options.saveMissingTo==="all"?xe=this.languageUtils.toResolveHierarchy(i.lng||this.language):xe.push(i.lng||this.language);let Ie=(Xe,_e,je)=>{let mt=x&&je!==h?je:G;this.options.missingKeyHandler?this.options.missingKeyHandler(Xe,c,_e,mt,ye,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Xe,c,_e,mt,ye,i),this.emit("missingKey",Xe,c,_e,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?xe.forEach(Xe=>{let _e=this.pluralResolver.getSuffixes(Xe,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&_e.indexOf(`${this.options.pluralSeparator}zero`)<0&&_e.push(`${this.options.pluralSeparator}zero`),_e.forEach(je=>{Ie([Xe],a+je,i[`defaultValue${je}`]||V)})}):Ie(xe,a,V))}h=this.extendTranslation(h,t,i,d,n),ie&&h===a&&this.options.appendNamespaceToMissingKey&&(h=`${c}${l}${a}`),(ie||de)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${l}${a}`:a,de?h:void 0,i))}return s?(d.res=h,d.usedParams=this.getUsedParamsDetails(i),d):h}extendTranslation(t,r,n,i,s){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let u=Ut(t)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),c;if(u){let f=t.match(this.interpolator.nestingRegexp);c=f&&f.length}let l=n.replace&&!Ut(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,n.lng||this.language||i.usedLng,n),u){let f=t.match(this.interpolator.nestingRegexp),p=f&&f.length;c<p&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),n.nest!==!1&&(t=this.interpolator.nest(t,(...f)=>s?.[0]===f[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${r[0]}`),null):this.translate(...f,r),n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,a=Ut(o)?[o]:o;return t!=null&&a?.length&&n.applyPostProcessor!==!1&&(t=o5e.handle(a,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),t}resolve(t,r={}){let n,i,s,o,a;return Ut(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(u=>typeof u=="function"?oT(u,{...this.options,...r}):u)),t.forEach(u=>{if(this.isValidLookup(n))return;let c=this.extractFromKey(u,r),l=c.key;i=l;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));let p=r.count!==void 0&&!Ut(r.count),d=p&&!r.ordinal&&r.count===0,h=r.context!==void 0&&(Ut(r.context)||typeof r.context=="number")&&r.context!=="",g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);f.forEach(_=>{this.isValidLookup(n)||(a=_,!ZHe[`${g[0]}-${_}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(ZHe[`${g[0]}-${_}`]=!0,this.logger.warn(`key "${i}" for languages "${g.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(S=>{if(this.isValidLookup(n))return;o=S;let T=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(T,l,S,_,r);else{let w;p&&(w=this.pluralResolver.getSuffix(S,r.count,r));let x=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&w.indexOf(N)===0&&T.push(l+w.replace(N,this.options.pluralSeparator)),T.push(l+w),d&&T.push(l+x)),h){let F=`${l}${this.options.contextSeparator||"_"}${r.context}`;T.push(F),p&&(r.ordinal&&w.indexOf(N)===0&&T.push(F+w.replace(N,this.options.pluralSeparator)),T.push(F+w),d&&T.push(F+x))}}let A;for(;A=T.pop();)this.isValidLookup(n)||(s=A,n=this.getResource(S,_,A,r))}))})}),{res:n,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,n,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,r,n,i):this.resourceStore.getResource(t,r,n,i)}getUsedParamsDetails(t={}){let r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=t.replace&&!Ut(t.replace),i=n?t.replace:t;if(n&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!n){i={...i};for(let s of r)delete i[s]}return i}static hasDefaultValue(t){let r="defaultValue";for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&r===n.substring(0,r.length)&&t[n]!==void 0)return!0;return!1}},vq=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=cp.create("languageUtils")}getScriptPartFromCode(t){if(t=FD(t),!t||t.indexOf("-")<0)return null;let r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=FD(t),!t||t.indexOf("-")<0)return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(Ut(t)&&t.indexOf("-")>-1){let r;try{r=Intl.getCanonicalLocales(t)[0]}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(n=>{if(r)return;let i=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(i))&&(r=i)}),!r&&this.options.supportedLngs&&t.forEach(n=>{if(r)return;let i=this.getScriptPartFromCode(n);if(this.isSupportedCode(i))return r=i;let s=this.getLanguagePartFromCode(n);if(this.isSupportedCode(s))return r=s;r=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),Ut(t)&&(t=[t]),Array.isArray(t))return t;if(!r)return t.default||[];let n=t[r];return n||(n=t[this.getScriptPartFromCode(r)]),n||(n=t[this.formatLanguageCode(r)]),n||(n=t[this.getLanguagePartFromCode(r)]),n||(n=t.default),n||[]}toResolveHierarchy(t,r){let n=this.getFallbackCodes((r===!1?[]:r)||this.options.fallbackLng||[],t),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return Ut(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(t))):Ut(t)&&s(this.formatLanguageCode(t)),n.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}},e5e={zero:0,one:1,two:2,few:3,many:4,other:5},t5e={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},Dre=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=cp.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,r={}){let n=FD(t==="dev"?"en":t),i=r.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:n,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(n,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),t5e;if(!t.match(/-|_/))return t5e;let u=this.languageUtils.getLanguagePartFromCode(t);o=this.getRule(u,r)}return this.pluralRulesCache[s]=o,o}needsPlural(t,r={}){let n=this.getRule(t,r);return n||(n=this.getRule("dev",r)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,r,n={}){return this.getSuffixes(t,n).map(i=>`${r}${i}`)}getSuffixes(t,r={}){let n=this.getRule(t,r);return n||(n=this.getRule("dev",r)),n?n.resolvedOptions().pluralCategories.sort((i,s)=>e5e[i]-e5e[s]).map(i=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(t,r,n={}){let i=this.getRule(t,n);return i?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i.select(r)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",r,n))}},r5e=(e,t,r,n=".",i=!0)=>{let s=BPr(e,t,r);return!s&&i&&Ut(r)&&(s=Ore(e,r,n),s===void 0&&(s=Ore(t,r,n))),s},xre=e=>e.replace(/\$/g,"$$$$"),Eq=class{constructor(t={}){this.logger=cp.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(r=>r),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});let{escape:r,escapeValue:n,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:a,suffixEscaped:u,formatSeparator:c,unescapeSuffix:l,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:h,nestingSuffixEscaped:g,nestingOptionsSeparator:_,maxReplaces:S,alwaysFormat:T}=t.interpolation;this.escape=r!==void 0?r:jPr,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?xE(s):o||"{{",this.suffix=a?xE(a):u||"}}",this.formatSeparator=c||",",this.unescapePrefix=l?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=p?xE(p):d||xE("$t("),this.nestingSuffix=h?xE(h):g||xE(")"),this.nestingOptionsSeparator=_||",",this.maxReplaces=S||1e3,this.alwaysFormat=T!==void 0?T:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let t=(r,n)=>r?.source===n?(r.lastIndex=0,r):new RegExp(n,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,r,n,i){let s,o,a,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=d=>{if(d.indexOf(this.formatSeparator)<0){let S=r5e(r,u,d,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(S,void 0,n,{...i,...r,interpolationkey:d}):S}let h=d.split(this.formatSeparator),g=h.shift().trim(),_=h.join(this.formatSeparator).trim();return this.format(r5e(r,u,g,this.options.keySeparator,this.options.ignoreJSONStructure),_,n,{...i,...r,interpolationkey:g})};this.resetRegExp();let l=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:d=>xre(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?xre(this.escape(d)):xre(d)}].forEach(d=>{for(a=0;s=d.regex.exec(t);){let h=s[1].trim();if(o=c(h),o===void 0)if(typeof l=="function"){let _=l(t,s,i);o=Ut(_)?_:""}else if(i&&Object.prototype.hasOwnProperty.call(i,h))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${h} for interpolating ${t}`),o="";else!Ut(o)&&!this.useRawValueToEscape&&(o=KHe(o));let g=d.safeValue(o);if(t=t.replace(s[0],g),f?(d.regex.lastIndex+=o.length,d.regex.lastIndex-=s[0].length):d.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),t}nest(t,r,n={}){let i,s,o,a=(u,c)=>{let l=this.nestingOptionsSeparator;if(u.indexOf(l)<0)return u;let f=u.split(new RegExp(`${xE(l)}[ ]*{`)),p=`{${f[1]}`;u=f[0],p=this.interpolate(p,o);let d=p.match(/'/g),h=p.match(/"/g);((d?.length??0)%2===0&&!h||(h?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),c&&(o={...c,...o})}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,g),`${u}${l}${p}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,u};for(;i=this.nestingRegexp.exec(t);){let u=[];o={...n},o=o.replace&&!Ut(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(u=i[1].slice(c).split(this.formatSeparator).map(l=>l.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),s=r(a.call(this,i[1].trim(),o),o),s&&i[0]===t&&!Ut(s))return s;Ut(s)||(s=KHe(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),s=""),u.length&&(s=u.reduce((l,f)=>this.format(l,f,n.lng,{...n,interpolationkey:i[1].trim()}),s.trim())),t=t.replace(i[0],s),this.regexp.lastIndex=0}return t}},YPr=e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let i=n[1].substring(0,n[1].length-1);t==="currency"&&i.indexOf(":")<0?r.currency||(r.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?r.range||(r.range=i.trim()):i.split(";").forEach(o=>{if(o){let[a,...u]=o.split(":"),c=u.join(":").trim().replace(/^'+|'+$/g,""),l=a.trim();r[l]||(r[l]=c),c==="false"&&(r[l]=!1),c==="true"&&(r[l]=!0),isNaN(c)||(r[l]=parseInt(c,10))}})}return{formatName:t,formatOptions:r}},n5e=e=>{let t={};return(r,n,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});let o=n+JSON.stringify(s),a=t[o];return a||(a=e(FD(n),i),t[o]=a),a(r)}},zPr=e=>(t,r,n)=>e(FD(r),n)(t),Rre=class{constructor(t={}){this.logger=cp.create("formatter"),this.options=t,this.init(t)}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let n=r.cacheInBuiltFormats?n5e:zPr;this.formats={number:n((i,s)=>{let o=new Intl.NumberFormat(i,{...s});return a=>o.format(a)}),currency:n((i,s)=>{let o=new Intl.NumberFormat(i,{...s,style:"currency"});return a=>o.format(a)}),datetime:n((i,s)=>{let o=new Intl.DateTimeFormat(i,{...s});return a=>o.format(a)}),relativetime:n((i,s)=>{let o=new Intl.RelativeTimeFormat(i,{...s});return a=>o.format(a,s.range||"day")}),list:n((i,s)=>{let o=new Intl.ListFormat(i,{...s});return a=>o.format(a)})}}add(t,r){this.formats[t.toLowerCase().trim()]=r}addCached(t,r){this.formats[t.toLowerCase().trim()]=n5e(r)}format(t,r,n,i={}){let s=r.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(a=>a.indexOf(")")>-1)){let a=s.findIndex(u=>u.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,a)].join(this.formatSeparator)}return s.reduce((a,u)=>{let{formatName:c,formatOptions:l}=YPr(u);if(this.formats[c]){let f=a;try{let p=i?.formatParams?.[i.interpolationkey]||{},d=p.locale||p.lng||i.locale||i.lng||n;f=this.formats[c](a,d,{...l,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${c}`);return a},t)}},KPr=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},Nre=class extends aT{constructor(t,r,n,i={}){super(),this.backend=t,this.store=r,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=cp.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,i.backend,i)}queueLoad(t,r,n,i){let s={},o={},a={},u={};return t.forEach(c=>{let l=!0;r.forEach(f=>{let p=`${c}|${f}`;!n.reload&&this.store.hasResourceBundle(c,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,l=!1,o[p]===void 0&&(o[p]=!0),s[p]===void 0&&(s[p]=!0),u[f]===void 0&&(u[f]=!0)))}),l||(a[c]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(u)}}loaded(t,r,n){let i=t.split("|"),s=i[0],o=i[1];r&&this.emit("failedLoading",s,o,r),!r&&n&&this.store.addResourceBundle(s,o,n,void 0,void 0,{skipCopy:!0}),this.state[t]=r?-1:2,r&&n&&(this.state[t]=0);let a={};this.queue.forEach(u=>{kPr(u.loaded,[s],o),KPr(u,t),r&&u.errors.push(r),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(c=>{a[c]||(a[c]={});let l=u.loaded[c];l.length&&l.forEach(f=>{a[c][f]===void 0&&(a[c][f]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(u=>!u.done)}read(t,r,n,i=0,s=this.retryTimeout,o){if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:n,tried:i,wait:s,callback:o});return}this.readingCalls++;let a=(c,l)=>{if(this.readingCalls--,this.waitingReads.length>0){let f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&l&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,r,n,i+1,s*2,o)},s);return}o(c,l)},u=this.backend[n].bind(this.backend);if(u.length===2){try{let c=u(t,r);c&&typeof c.then=="function"?c.then(l=>a(null,l)).catch(a):a(null,c)}catch(c){a(c)}return}return u(t,r,a)}prepareLoading(t,r,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Ut(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ut(r)&&(r=[r]);let s=this.queueLoad(t,r,n,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(t,r,n){this.prepareLoading(t,r,{},n)}reload(t,r,n){this.prepareLoading(t,r,{reload:!0},n)}loadOne(t,r=""){let n=t.split("|"),i=n[0],s=n[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${r}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${r}loaded namespace ${s} for language ${i}`,a),this.loaded(t,o,a)})}saveMissing(t,r,n,i,s,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${n}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(n==null||n==="")){if(this.backend?.create){let u={...o,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let l;c.length===5?l=c(t,r,n,i,u):l=c(t,r,n,i),l&&typeof l.then=="function"?l.then(f=>a(null,f)).catch(a):a(null,l)}catch(l){a(l)}else c(t,r,n,i,a,u)}!t||!t[0]||this.store.addResource(t[0],r,n,i)}}},wre=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ut(e[1])&&(t.defaultValue=e[1]),Ut(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){let r=e[3]||e[2];Object.keys(r).forEach(n=>{t[n]=r[n]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),i5e=e=>(Ut(e.ns)&&(e.ns=[e.ns]),Ut(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ut(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),hq=()=>{},XPr=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})},u5e="__i18next_supportNoticeShown",JPr=()=>!!(typeof globalThis<"u"&&globalThis[u5e]||typeof process<"u"&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&process.env&&process.env.NODE_ENV==="production"),QPr=()=>{typeof globalThis<"u"&&(globalThis[u5e]=!0)},ZPr=e=>!!(e?.modules?.backend?.name?.indexOf("Locize")>0||e?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||e?.options?.backend?.backends&&e.options.backend.backends.some(t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0)||e?.options?.backend?.projectId||e?.options?.backend?.backendOptions&&e.options.backend.backendOptions.some(t=>t?.projectId)),Ire=class e extends aT{constructor(t={},r){if(super(),this.options=i5e(t),this.services={},this.logger=cp,this.modules={external:[]},XPr(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,r),this;setTimeout(()=>{this.init(t,r)},0)}}init(t={},r){this.isInitializing=!0,typeof t=="function"&&(r=t,t={}),t.defaultNS==null&&t.ns&&(Ut(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));let n=wre();this.options={...n,...this.options,...i5e(t)},this.options.interpolation={...n.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!ZPr(this)&&!JPr()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("\u{1F310} i18next is made possible by our own product, Locize \u2014 consider powering your project with managed localization (AI, CDN, integrations): https://locize.com \u{1F499}"),QPr());let i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?cp.init(i(this.modules.logger),this.options):cp.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=Rre;let l=new vq(this.options);this.store=new gq(this.options.resources,this.options);let f=this.services;f.logger=cp,f.resourceStore=this.store,f.languageUtils=l,f.pluralResolver=new Dre(l,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(f.formatter=i(c),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Eq(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Nre(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...h)=>{this.emit(d,...h)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new yq(this.services,this.options),this.translator.on("*",(d,...h)=>{this.emit(d,...h)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,r||(r=hq),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...l)=>this.store[c](...l)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...l)=>(this.store[c](...l),this)});let a=LD(),u=()=>{let c=(l,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(f),r(l,f)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),a}loadResources(t,r=hq){let n=r,i=Ut(t)?t:this.language;if(typeof t=="function"&&(n=t),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();let s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>o(u)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(a)})}else n(null)}reloadResources(t,r,n){let i=LD();return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=void 0),t||(t=this.languages),r||(r=this.options.ns),n||(n=hq),this.services.backendConnector.reload(t,r,s=>{i.resolve(),n(s)}),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&o5e.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let r=0;r<this.languages.length;r++){let n=this.languages[r];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,r){this.isLanguageChangingTo=t;let n=LD();this.emit("languageChanging",t);let i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},s=(a,u)=>{u?this.isLanguageChangingTo===t&&(i(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,n.resolve((...c)=>this.t(...c)),r&&r(a,(...c)=>this.t(...c))},o=a=>{!t&&!a&&this.services.languageDetector&&(a=[]);let u=Ut(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(u)?u:this.services.languageUtils.getBestMatchFromCodes(Ut(a)?[a]:a);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,l=>{s(l,c)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(t),n}getFixedT(t,r,n){let i=(s,o,...a)=>{let u;typeof o!="object"?u=this.options.overloadTranslationOptionHandler([s,o].concat(a)):u={...o},u.lng=u.lng||i.lng,u.lngs=u.lngs||i.lngs,u.ns=u.ns||i.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||n||i.keyPrefix);let c={...this.options,...u};typeof u.keyPrefix=="function"&&(u.keyPrefix=oT(u.keyPrefix,c));let l=this.options.keySeparator||".",f;return u.keyPrefix&&Array.isArray(s)?f=s.map(p=>(typeof p=="function"&&(p=oT(p,c)),`${u.keyPrefix}${l}${p}`)):(typeof s=="function"&&(s=oT(s,c)),f=u.keyPrefix?`${u.keyPrefix}${l}${s}`:s),this.t(f,u)};return Ut(t)?i.lng=t:i.lngs=t,i.ns=r,i.keyPrefix=n,i}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let n=r.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;let o=(a,u)=>{let c=this.services.backendConnector.state[`${a}|${u}`];return c===-1||c===0||c===2};if(r.precheck){let a=r.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(n,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(n,t)&&(!i||o(s,t)))}loadNamespaces(t,r){let n=LD();return this.options.ns?(Ut(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{n.resolve(),r&&r(i)}),n):(r&&r(),Promise.resolve())}loadLanguages(t,r){let n=LD();Ut(t)&&(t=[t]);let i=this.options.preload||[],s=t.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{n.resolve(),r&&r(o)}),n):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{let i=new Intl.Locale(t);if(i&&i.getTextInfo){let s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}let r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],n=this.services?.languageUtils||new vq(wre());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.indexOf(n.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},r){let n=new e(t,r);return n.createInstance=e.createInstance,n}cloneInstance(t={},r=hq){let n=t.forkResourceStore;n&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},s=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(s.logger=s.logger.clone(t)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},n){let a=Object.keys(this.store.data).reduce((u,c)=>(u[c]={...this.store.data[c]},u[c]=Object.keys(u[c]).reduce((l,f)=>(l[f]={...u[c][f]},l),u[c]),u),{});s.store=new gq(a,i),s.services.resourceStore=s.store}if(t.interpolation){let u={...wre().interpolation,...this.options.interpolation,...t.interpolation},c={...i,interpolation:u};s.services.interpolator=new Eq(c)}return s.translator=new yq(s.services,i),s.translator.on("*",(a,...u)=>{s.emit(a,...u)}),s.init(i,r),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},kr=Ire.createInstance(),gyi=kr.createInstance,yyi=kr.dir,vyi=kr.init,Eyi=kr.loadResources,_yi=kr.reloadResources,Syi=kr.use,byi=kr.changeLanguage,Tyi=kr.getFixedT,Ayi=kr.t,xyi=kr.exists,wyi=kr.setDefaultNamespace,Cyi=kr.hasLoadedNamespace,Oyi=kr.loadNamespaces,Pyi=kr.loadLanguages;var c5e={logMessages:{info:{mockOnlyWarning:"This application was generated with a local metadata file and does not reference a live server. Please add the required server configuration or start this application with mock data using the target: `npm run start-mock`."},error:{logWrapperNotInitialised:"`LogWrapper` is not initialised."},debug:{loggingConfigured:"Logging has been configured at log level: {{logLevel}}."}},telemetry:{unknownOs:"Unknown"},texts:{systemTypeLabel:{abapCloud:"ABAP Cloud"}}};var Lre="fiori-freestyle-writer",l5e=kr.createInstance();async function tDr(){await l5e.init({resources:{en:{[Lre]:c5e}},lng:"en",fallbackLng:"en",defaultNS:Lre,ns:[Lre],showSupportNotice:!1})}function rg(e,t){return l5e.t(e,t)}tDr().catch(()=>{});function f5e(e){return rDr(e.name,e.userDisplayName,e.systemType)}function rDr(e,t,r){let n=t?` [${t}]`:"";return`${e}${nDr(r)}${n}`}function nDr(e){let t="",r=` (${rg("texts.systemTypeLabel.abapCloud")})`;return(e==="AbapCloud"||e==="S4HC"||e==="BTP")&&(t=r),t}var UD=class{applicationKey="";extensionName="";extensionVersion="";getApplicationKey(){return this.applicationKey}getExtensionVersion(){return this.extensionVersion}getExtensionName(){return this.extensionName}};var Vct=be(kue(),1);var UR=class{extensionName;eventName;constructor(t,r){this.extensionName=t,this.eventName=r}getExtensionName(){return this.extensionName}getEventName(){return this.eventName}toString(){return`${this.extensionName}/${this.eventName}`}};var Pi;(function(e){e[e.OnePercent=0]="OnePercent",e[e.TenPercent=1]="TenPercent",e[e.NoSampling=2]="NoSampling"})(Pi||(Pi={}));function fG(e){e.channel.setUseDiskRetryCaching(!0),e.addTelemetryProcessor(t=>(t.tags["ai.location.ip"]="0.0.0.0",t.tags["ai.cloud.roleInstance"]="masked",t.tags["ai.cloud.role"]="masked",t.tags["ai.device.type"]="masked",!0))}var Bue={name:"@sap-ux/telemetry",version:"1.0.8",description:"Library for sending usage telemetry data",type:"module",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/telemetry"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Atelemetry"},license:"Apache-2.0",private:!1,main:"dist/index.js",scripts:{build:"tsc --build",watch:"tsc --watch",clean:"rimraf --glob dist coverage *.tsbuildinfo",format:"prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",example:"ts-node example/index.ts"},dependencies:{"@sap-ux/store":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/nodejs-utils":"workspace:*",applicationinsights:"2.9.8",axios:"1.16.0","performance-now":"2.1.0",yaml:"2.8.3"},devDependencies:{"@jest/globals":"30.3.0","jest-extended":"7.0.0",memfs:"3.4.13",unionfs:"4.6.0",dotenv:"17.4.2"},files:["dist","LICENSE","!dist/*.map","!dist/**/*.map"],engines:{node:">=22.x"}};var Eo={azureInstrumentationKey:"",telemetryEnabled:!0,telemetryLibName:Bue.name,telemetryLibVersion:Bue.version,consumerModuleName:"",consumerModuleVersion:""};var kR=class extends UD{clients;constructor(t,r,n){super(),this.clients=new Map,this.applicationKey=t,this.extensionVersion=n,this.extensionName=r;let i=this.createTelemetryClient(Pi.OnePercent),s=this.createTelemetryClient(Pi.TenPercent),o=this.createTelemetryClient(Pi.NoSampling);this.clients.set(Pi.OnePercent,i),this.clients.set(Pi.TenPercent,s),this.clients.set(Pi.NoSampling,o)}reportBlocking(t,r,n,i,s=!1){if(!s||Eo.telemetryEnabled){let{client:o,event:a}=this.prepareClientAndEvent(t,r,n,i);return this.trackEventBlocking(o,a)}return Promise.resolve()}async report(t,r,n,i,s,o){if(o!==void 0&&!o||!Eo.telemetryEnabled)return;let{client:a,event:u}=this.prepareClientAndEvent(t,r,n,i);this.trackEvent(a,u)}prepareClientAndEvent(t,r,n,i=Pi.NoSampling){let s=this.clients.get(i),a={name:new UR(this.extensionName,t).toString(),properties:r,measurements:n};return{client:s,event:a}}async trackEventBlocking(t,r){if(process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY!=="true")return new Promise((n,i)=>{try{t.trackEvent(r),t.flush({callback:()=>n()})}catch(s){i(s)}})}trackEvent(t,r){return process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY!=="true"?(t.trackEvent(r),!0):!1}createTelemetryClient(t){let r;switch(t){case Pi.OnePercent:r=1;break;case Pi.TenPercent:r=10;break;case Pi.NoSampling:default:r=100;break}let n=new Vct.TelemetryClient(this.applicationKey);return n.config.samplingPercentage=r,fG(n),n}};var que=()=>{let e=new Date().getTime();return new Date(e).toISOString()};var BR=class extends kR{constructor(t,r,n){super(t,r,n)}async report(t,r,n,i,s,o){let a=await pG(s),u={v:this.extensionVersion,datetime:que()},c={...r,...a,...u};await super.report(t,c,n,i,s,o)}async reportEvent(t,r,n,i){let{finalProperties:s,finalMeasurements:o}=await this.collectToolsSuiteTelemetry(t,n);return super.report(t.eventName,s,o,r,n,i)}async reportEventBlocking(t,r,n,i){let{finalProperties:s,finalMeasurements:o}=await this.collectToolsSuiteTelemetry(t,n);return super.reportBlocking(t.eventName,s,o,r,i)}async collectToolsSuiteTelemetry(t,r){let n=await pG(r),i={v:this.extensionVersion,datetime:que()},s={...t.properties,...n,...i},o={...t.measurements};return{finalProperties:s,finalMeasurements:o}}};var Gct=require("node:child_process"),qR=class{run(t,r=[],n={},i){return i&&i.debug(`Running command: ${t} ${r.join(" ")}`),new Promise((s,o)=>{let a=[],u=process.platform==="win32"?{...n,shell:!0}:n,c=(0,Gct.spawn)(t,r,u);c.stdout.setEncoding("utf8");let l;c.stdout.on("data",f=>{i?.info(f.toString().replace(/[\r\n]$/,"")),l=f.toString()}),c.stderr.on("data",f=>{i?.info(f.toString().replace(/[\r\n]$/,"")),a.push(f.toString())}),c.on("error",f=>{let p=`Command failed with error: ${f.message}`;i?.error(p),o(f)}),c.on("close",f=>{if(f!==0){let p=`Command failed, \`${t} ${r.join(" ")}\`, ${a.join(", ")}`;i?.debug(p),o(p)}s(l)})})}};var Mnn=be(jG(),1);var Fnn=be(tfe(),1),nfe=be(ta(),1);var Pht={error:{unsupportedYoVersion:"The installed version of the `Yo` CLI tool: {{installedYoVersion}} is not supported. Please use `npm` or `yarn` to globally install the latest supported version by running: 'npm i -g yo@{{latestSupportedYoVer}}'.",executingYoVersionCmd:"Running: {{yoCmd}} returned an error: {{- error}}. Check that `yo` is installed and available on the path. If `yo@{{latestSupportedYoVer}}` is not installed, use `npm` or `yarn` to globally install the latest required version by running: 'npm i -g yo@{{latestSupportedYoVer}}'."}};var rfe="nodejs-utils",Inn=kr.createInstance();async function Lnn(){await Inn.init({lng:"en",fallbackLng:"en",defaultNS:rfe,ns:[rfe],resources:{en:{[rfe]:Pht}},interpolation:{escapeValue:!1},showSupportNotice:!1})}Lnn().catch(()=>{});var QR=be(require("node:https"),1);function VA(e){QR.default.globalAgent.options&&(QR.default.globalAgent.options.rejectUnauthorized=e),QR.default.globalAgent.fallbackAgent?.options&&(QR.default.globalAgent.fallbackAgent.options.rejectUnauthorized=e)}var il=be(kpe(),1),nvt=be(rvt(),1);var yi=class extends Error{code;constructor(t,r){super(t),this.code=r,this.name=this.constructor.name}};var ss=Object.freeze({yamlParsing:"yamlParsing",nodeNotFound:"nodeNotFound",nodeNotFoundMatching:"nodeNotFoundMatching",nodeNotAMap:"nodeNotAMap",propertyNotFound:"propertyNotFound",pathCannotBeEmpty:"pathCannotBeEmpty",pathDoesNotExist:"pathDoesNotExist",seqDoesNotExist:"seqDoesNotExist",tryingToAppendToNonSequence:"tryingToAppendToNonSequence",startNodeMustBeCollection:"startNodeMustBeCollection",scalarValuesDoNotHaveProperties:"scalarValuesDoNotHaveProperties"}),Ao=Object.freeze({yamlParsing:"Error parsing YAML document",nodeNotFound:"Node not found at path: [{{- path }}]",nodeNotFoundMatching:"Node not found at path: [{{- path }}, matching [{{- key }} = {{- value }}]",nodeNotAMap:"Node path: [{{- path }}, matching [{{- key }} = {{- value }}], is not a map",propertyNotFound:"Node not found at path: [{{- path }}]",pathCannotBeEmpty:"Path cannot be empty",pathDoesNotExist:"Parent node does not exist at: [{{- path }}]",seqDoesNotExist:"Sequence does not exist at: [{{- path }}]",tryingToAppendToNonSequence:"Cannot append to non-sequence at: [{{- path }}]",startNodeMustBeCollection:"Starting node must be an array or an object",scalarValuesDoNotHaveProperties:"Scalar values do not have properties"});function nl(e,t){try{return t?e?.replace(/{{-?([^{}]*)}}/g,(r,n)=>{let i=n?.trim();return t[i]?.toString()||r}):e}catch{return""}}var DN=class e{documents;static async newInstance(t){return new e(t)}constructor(t){this.documents=il.default.parseAllDocuments(t),this.documents.length===0&&this.documents.push(il.default.parseDocument(t));let r=this.documents.filter(n=>n.errors.length>0);if(r.length>0)throw new yi(Ao.yamlParsing+`
|
|
661
661
|
`+r.map(n=>n.errors.map(i=>i.message).join("")),ss.yamlParsing)}toString(){return this.documents.map(t=>t.toString({singleQuote:!0})).join("")}addDocumentComment({comment:t,location:r="beginning"}){switch(r){case"beginning":this.documents[0].commentBefore=t;break;case"end":this.documents[0].comment=t;break;default:break}return this}createNode({value:t,comments:r}){let n=this.documents[0].createNode(t);if(r?.length)for(let i of r){let s=n.items.findIndex(o=>o.key.value===i.key);n.items[s].value.comment=i.comment}return n}setIn({path:t,value:r,createIntermediateKeys:n,comment:i}){let s=this.toPathArray(t);if(s.length>1){let a=s.slice(0,-1);if(!this.documents[0].getIn(a)&&!n)throw new yi(nl(Ao.pathDoesNotExist,{path:a}),ss.pathDoesNotExist)}let o=this.documents[0].createNode(r);return i&&(o.commentBefore=i),this.documents[0].setIn(s,o),this}appendTo({path:t,value:r,createIntermediateKeys:n=!0,nodeComment:i,comments:s}){let o=this.toPathArray(t),a=this.documents[0].clone(),u=a.getIn(o);if(u){if(!(0,il.isSeq)(u))throw new yi(nl(Ao.tryingToAppendToNonSequence,{path:t}),ss.tryingToAppendToNonSequence)}else{if(!n)throw new yi(nl(Ao.seqDoesNotExist,{path:t}),ss.seqDoesNotExist);u=new il.YAMLSeq,a.setIn(o,u)}let c=a.createNode(r);if(i&&(c.commentBefore=i),u.items.push(c),s&&s.length>0){if(typeof r!="object")throw new yi(Ao.scalarValuesDoNotHaveProperties,ss.scalarValuesDoNotHaveProperties);let l=u.items.length-1;for(let f of s){let p=this.toPathArray(f.path),d=a.getIn([...o,l,...p],!0);if(!d)throw new yi(nl(Ao.propertyNotFound,{path:f.path}),ss.propertyNotFound);d.comment=f.comment}}return this.documents[0]=a,this}updateAt({path:t,matcher:r,value:n,mode:i="merge"}){let s=this.toPathArray(t),o=this.documents[0].getIn(s);if(!o)throw new yi(nl(Ao.seqDoesNotExist,{path:t}),ss.seqDoesNotExist);let a=o.items.find(l=>l.toJSON()[r.key]===r.value);if(!a)throw new yi(nl(Ao.nodeNotFoundMatching,{path:t,key:r.key,value:r.value}),ss.nodeNotFoundMatching);let u=i==="merge"?(0,nvt.default)(a.toJSON(),n):n,c=this.documents[0].createNode(u);return o.items.splice(o.items.indexOf(a),1,c),this}delete(t){return this.documents[0].delete(t)}deleteAt({path:t,matcher:r}){let n=this.toPathArray(t),i=this.documents[0].getIn(n);if(!i?.items)throw new yi(nl(Ao.seqDoesNotExist,{path:t}),ss.seqDoesNotExist);if(!i.items.find((o,a)=>o.toJSON()[r.key]===r.value?(i.items.splice(a,1),!0):!1))throw new yi(nl(Ao.propertyNotFound,{path:t}),ss.propertyNotFound);return this}getNode({start:t,path:r}){if(t&&!((0,il.isSeq)(t)||(0,il.isMap)(t)))throw new yi(Ao.startNodeMustBeCollection,ss.startNodeMustBeCollection);let n=this.toPathArray(r),s=(t||this.documents[0])?.getIn(n);if(s)return s;throw new yi(nl(Ao.nodeNotFound,{path:r}),ss.nodeNotFound)}getSequence({start:t,path:r}){let n=this.getNode({start:t,path:r});if((0,il.isSeq)(n))return n;throw new yi(nl(Ao.seqDoesNotExist,{path:r}),ss.seqDoesNotExist)}getMap({start:t,path:r}){let n=this.getNode({start:t,path:r});if((0,il.isMap)(n))return n;throw new yi(nl(Ao.nodeNotAMap,{path:r}),ss.nodeNotAMap)}findItem(t,r){let n=i=>i!==void 0&&typeof i.toJSON=="function"&&i.toJSON.call(i)||{};return t.items.find(i=>r(n(i)))}toPathArray(t){let r=t?.toString().split(".").filter(n=>n!=="").map(n=>Number.isNaN(Number(n))?n:Number(n));if(!r||r.length===0)throw new yi(Ao.pathCannotBeEmpty,ss.pathCannotBeEmpty);return r}};var gh=require("node:path");function ivt(){return{name:"fiori-tools-appreload",afterMiddleware:"compression",configuration:{port:35729,path:"webapp",delay:300}}}function Q$(e,t){let r=[];return e.authenticationType==="reentranceTicket"&&r.push({path:`configuration.backend.${t}.authenticationType`,comment:" SAML support for vscode",key:"authenticationType"}),r}function svt(e,t,r="compression",n=!1){let i={name:"fiori-tools-proxy",afterMiddleware:r,configuration:{ignoreCertErrors:n}},s=[{path:"configuration.ignoreCertErrors",comment:" If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted"}];return e&&e.length>0&&(e.forEach((o,a)=>{o.path=o.path??"/";let u=Q$(o,a);u&&(s=[...s,...u])}),i.configuration.backend=e),t!==void 0&&(i.configuration.ui5={path:t.path??["/resources","/test-resources"],url:t.url??"https://ui5.sap.com"},t.version!==void 0&&(i.configuration.ui5.version=t.version),t.directLoad&&(i.configuration.ui5.directLoad=!0)),{config:i,comments:s}}var ovt=(e,t,r,n)=>{let i=[];return r.forEach(s=>{let o=`.${gh.posix.sep}${(0,gh.relative)(e,(0,gh.join)(t,"localService",s.serviceName)).replaceAll(gh.sep,gh.posix.sep)}`,a={urlPath:s.servicePath.replace(/\/$/,""),metadataPath:s.metadataPath??`${o}/metadata.xml`,mockdataPath:`${o}/data`,generateMockData:!0};s.resolveExternalServiceReferences===!0&&(a.resolveExternalServiceReferences=!0),i.push(a)}),{name:"sap-fe-mockserver",beforeMiddleware:"csp",configuration:{mountPath:"/",services:i,annotations:n}}};var ex="fiori-tools-servestatic",yh="fiori-tools-proxy";var GSt=be(k_t(),1),cl=require("node:path"),$St=require("node:url"),HSt=require("node:fs/promises");function eSt(e){return typeof e>"u"||e===null}function pmn(e){return typeof e=="object"&&e!==null}function dmn(e){return Array.isArray(e)?e:eSt(e)?[]:[e]}function hmn(e,t){var r,n,i,s;if(t)for(s=Object.keys(t),r=0,n=s.length;r<n;r+=1)i=s[r],e[i]=t[i];return e}function mmn(e,t){var r="",n;for(n=0;n<t;n+=1)r+=e;return r}function gmn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var ymn=eSt,vmn=pmn,Emn=dmn,_mn=mmn,Smn=gmn,bmn=hmn,os={isNothing:ymn,isObject:vmn,toArray:Emn,repeat:_mn,isNegativeZero:Smn,extend:bmn};function tSt(e,t){var r="",n=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(r+=`
|
|
662
662
|
|
|
663
663
|
`+e.mark.snippet),n+" "+r):n}function oI(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=tSt(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}oI.prototype=Object.create(Error.prototype);oI.prototype.constructor=oI;oI.prototype.toString=function(t){return this.name+": "+tSt(this,t)};var ca=oI;function Rhe(e,t,r,n,i){var s="",o="",a=Math.floor(i/2)-1;return n-t>a&&(s=" ... ",t=n-a+s.length),r-n>a&&(o=" ...",r=n+a-o.length),{str:s+e.slice(t,r).replace(/\t/g,"\u2192")+o,pos:n-t+s.length}}function Nhe(e,t){return os.repeat(" ",t-e.length)+e}function Tmn(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var r=/\r?\n|\r|\0/g,n=[0],i=[],s,o=-1;s=r.exec(e.buffer);)i.push(s.index),n.push(s.index+s[0].length),e.position<=s.index&&o<0&&(o=n.length-2);o<0&&(o=n.length-1);var a="",u,c,l=Math.min(e.line+t.linesAfter,i.length).toString().length,f=t.maxLength-(t.indent+l+3);for(u=1;u<=t.linesBefore&&!(o-u<0);u++)c=Rhe(e.buffer,n[o-u],i[o-u],e.position-(n[o]-n[o-u]),f),a=os.repeat(" ",t.indent)+Nhe((e.line-u+1).toString(),l)+" | "+c.str+`
|
|
@@ -689,7 +689,7 @@ PGHZoN9jcvvvWDLUGtJkEotMgdFpEA2XWR83H4fVFVc=
|
|
|
689
689
|
`+e.slice(i,s),i=s+1),o=a;return u+=`
|
|
690
690
|
`,e.length-i>t&&o>i?u+=e.slice(i,o)+`
|
|
691
691
|
`+e.slice(o+1):u+=e.slice(i),u.slice(1)}function cyn(e){for(var t="",r=0,n,i=0;i<e.length;r>=65536?i+=2:i++)r=sI(e,i),n=Oo[r],!n&&cI(r)?(t+=e[i],r>=65536&&(t+=e[i+1])):t+=n||eyn(r);return t}function lyn(e,t,r){var n="",i=e.tag,s,o,a;for(s=0,o=r.length;s<o;s+=1)a=r[s],e.replacer&&(a=e.replacer.call(r,String(s),a)),(bh(e,t,a,!1,!1)||typeof a>"u"&&bh(e,t,null,!1,!1))&&(n!==""&&(n+=","+(e.condenseFlow?"":" ")),n+=e.dump);e.tag=i,e.dump="["+n+"]"}function Q_t(e,t,r,n){var i="",s=e.tag,o,a,u;for(o=0,a=r.length;o<a;o+=1)u=r[o],e.replacer&&(u=e.replacer.call(r,String(o),u)),(bh(e,t+1,u,!0,!0,!1,!0)||typeof u>"u"&&bh(e,t+1,null,!0,!0,!1,!0))&&((!n||i!=="")&&(i+=Fhe(e,t)),e.dump&&aI===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=s,e.dump=i||"[]"}function fyn(e,t,r){var n="",i=e.tag,s=Object.keys(r),o,a,u,c,l;for(o=0,a=s.length;o<a;o+=1)l="",n!==""&&(l+=", "),e.condenseFlow&&(l+='"'),u=s[o],c=r[u],e.replacer&&(c=e.replacer.call(r,u,c)),bh(e,t,u,!1,!1)&&(e.dump.length>1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),bh(e,t,c,!1,!1)&&(l+=e.dump,n+=l));e.tag=i,e.dump="{"+n+"}"}function pyn(e,t,r,n){var i="",s=e.tag,o=Object.keys(r),a,u,c,l,f,p;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys=="function")o.sort(e.sortKeys);else if(e.sortKeys)throw new ca("sortKeys must be a boolean or a function");for(a=0,u=o.length;a<u;a+=1)p="",(!n||i!=="")&&(p+=Fhe(e,t)),c=o[a],l=r[c],e.replacer&&(l=e.replacer.call(r,c,l)),bh(e,t+1,c,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&aI===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,f&&(p+=Fhe(e,t)),bh(e,t+1,l,!0,f)&&(e.dump&&aI===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=s,e.dump=i||"{}"}function Z_t(e,t,r){var n,i,s,o,a,u;for(i=r?e.explicitTypes:e.implicitTypes,s=0,o=i.length;s<o;s+=1)if(a=i[s],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof t=="object"&&t instanceof a.instanceOf)&&(!a.predicate||a.predicate(t))){if(r?a.multi&&a.representName?e.tag=a.representName(t):e.tag=a.tag:e.tag="?",a.represent){if(u=e.styleMap[a.tag]||a.defaultStyle,RSt.call(a.represent)==="[object Function]")n=a.represent(t,u);else if(NSt.call(a.represent,u))n=a.represent[u](t,u);else throw new ca("!<"+a.tag+'> tag resolver accepts not "'+u+'" style');e.dump=n}return!0}return!1}function bh(e,t,r,n,i,s,o){e.tag=null,e.dump=r,Z_t(e,r,!1)||Z_t(e,r,!0);var a=RSt.call(e.dump),u=n,c;n&&(n=e.flowLevel<0||e.flowLevel>t);var l=a==="[object Object]"||a==="[object Array]",f,p;if(l&&(f=e.duplicates.indexOf(r),p=f!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(i=!1),p&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(l&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),a==="[object Object]")n&&Object.keys(e.dump).length!==0?(pyn(e,t,e.dump,i),p&&(e.dump="&ref_"+f+e.dump)):(fyn(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(a==="[object Array]")n&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?Q_t(e,t-1,e.dump,i):Q_t(e,t,e.dump,i),p&&(e.dump="&ref_"+f+e.dump)):(lyn(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(a==="[object String]")e.tag!=="?"&&ayn(e,e.dump,t,s,u);else{if(a==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ca("unacceptable kind of an object to dump "+a)}e.tag!==null&&e.tag!=="?"&&(c=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",e.dump=c+" "+e.dump)}return!0}function dyn(e,t){var r=[],n=[],i,s;for(khe(e,r,n),i=0,s=n.length;i<s;i+=1)t.duplicates.push(r[n[i]]);t.usedDuplicates=new Array(s)}function khe(e,t,r){var n,i,s;if(e!==null&&typeof e=="object")if(i=t.indexOf(e),i!==-1)r.indexOf(i)===-1&&r.push(i);else if(t.push(e),Array.isArray(e))for(i=0,s=e.length;i<s;i+=1)khe(e[i],t,r);else for(n=Object.keys(e),i=0,s=n.length;i<s;i+=1)khe(e[n[i]],t,r)}function hyn(e,t){t=t||{};var r=new ryn(t);r.noRefs||dyn(e,r);var n=e;return r.replacer&&(n=r.replacer.call({"":n},"",n)),bh(r,0,n,!0,!0)?r.dump+`
|
|
692
|
-
`:""}var myn=hyn,gyn={dump:myn};function $he(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var yyn=Ws,vyn=rSt,Eyn=oSt,_yn=fSt,Syn=pSt,byn=qhe,Tyn=DSt.load,Ayn=DSt.loadAll,xyn=gyn.dump,wyn=ca,Cyn={binary:ySt,float:lSt,map:sSt,null:aSt,pairs:ESt,set:_St,timestamp:mSt,bool:uSt,int:cSt,merge:gSt,omap:vSt,seq:iSt,str:nSt},Oyn=$he("safeLoad","load"),Pyn=$he("safeLoadAll","loadAll"),Dyn=$he("safeDump","dump"),VSt={Type:yyn,Schema:vyn,FAILSAFE_SCHEMA:Eyn,JSON_SCHEMA:_yn,CORE_SCHEMA:Syn,DEFAULT_SCHEMA:byn,load:Tyn,loadAll:Ayn,dump:xyn,YAMLException:wyn,types:Cyn,safeLoad:Oyn,safeLoadAll:Pyn,safeDump:Dyn};var Ryn=(0,cl.dirname)((0,$St.fileURLToPath)(__importMetaUrl)),Po=class e{document;static validate;async validateSchema(){if(!e.validate){let r=(0,cl.join)(Ryn,"..","dist","schema","ui5.yaml.json"),n=JSON.parse(await(0,HSt.readFile)(r,"utf8"));if(!n)throw Error("The schema file was not found. Validation is not possible.");e.validate=new GSt.Ajv({strict:!1}).compile(n)}let t=!1;try{t=VSt.loadAll(this.document.toString()).every(r=>e.validate(r))}catch(r){throw Error(`No validation possible. Error: ${r}`)}return t}static async newInstance(t,r){let n=new e;if(n.document=await DN.newInstance(t),(r?.validateSchema??!1)&&!await n.validateSchema())throw new Error("This file does not comply with the schema.");return n}getMetadata(){try{return this.document.getMap({path:"metadata"}).toJSON()}catch{return}}getConfiguration(){let t;try{t=this.document.getMap({path:"resources"}).toJSON()}catch{t={}}return t.configuration??{}}setConfiguration(t){return this.document.setIn({path:"resources",value:{configuration:t}}),this}setMetadata(t){return this.document.setIn({path:"metadata",value:t}),this}getType(){return this.document.getNode({path:"type"})}setType(t){return this.document.setIn({path:"type",value:t}),this}addCustomConfiguration(t,r){try{this.document.getMap({path:"customConfiguration"}).setIn([t],r)}catch{this.document.setIn({path:"customConfiguration",value:{[t]:r}})}}getCustomConfiguration(t){try{let r=this.document.getMap({path:"customConfiguration"}).get(t);return r?.toJSON?.()??r?.toString()}catch{return}}getUi5Framework(){return this.document.getMap({path:"framework"}).toJSON()}addUI5Framework(t,r,n,i="sap_fiori_3"){let s=[];for(let o of n)s.push({name:o});return s.push({name:`themelib_${i.replace(/_dark$|_hcw$|_hcb$/,"")}`}),this.document.setIn({path:"framework",value:{name:t,version:r,libraries:s}}),this}addCustomTasks(t,r){for(let n of t)this.document.appendTo({path:"builder.customTasks",value:n,comments:r});return this}addCustomMiddleware(t,r){for(let n of t)this.document.appendTo({path:"server.customMiddleware",value:n,comments:r});return this}addFioriToolsAppReloadMiddleware(){return this.document.appendTo({path:"server.customMiddleware",value:ivt()}),this}addFioriToolsProxyMiddleware(t,r){let n=t?.ignoreCertErrors??t?.ignoreCertError??!1,{config:i,comments:s}=svt(t.backend,t.ui5,r,n);return this.document.appendTo({path:"server.customMiddleware",value:i,comments:s}),this}getFioriToolsProxyMiddlewareConfiguration(){let t=this.document.getSequence({path:"server.customMiddleware"}),r=this.document.findItem(t,n=>n.name===yh);if(!r)throw new Error("Could not find fiori-tools-proxy");return this.document.getMap({start:r,path:"configuration"})}addBackendToFioriToolsProxyMiddleware(t,r=!1){let n=this.getFioriToolsProxyMiddlewareConfiguration(),i=n.toJSON(),s=Q$(t),o=this.document.createNode({value:t,comments:s});if((i?.ignoreCertErrors??i?.ignoreCertError??!1)!==r&&(n.set("ignoreCertErrors",r),i?.ignoreCertError!==void 0&&n.delete("ignoreCertError")),i?.backend){if(!i?.backend.find(u=>u.path===t.path)){let u=this.document.getSequence({start:n,path:"backend"});u.items.length===0?n.set("backend",[o]):u.add(o)}}else n.set("backend",[o]);return this}updateBackendToFioriToolsProxyMiddleware(t){let r=this.getFioriToolsProxyMiddlewareConfiguration(),n=r.toJSON(),i=Q$(t),s=this.document.createNode({value:t,comments:i});if(n?.backend){let o=n?.backend.findIndex(a=>a.path&&a.path===t.path);o!==-1&&this.document.getSequence({start:r,path:"backend"}).set(o,s)}return this}removeBackendFromFioriToolsProxyMiddleware(t){let r=this.findCustomMiddleware(yh);if(r){let n=r?.configuration;if(n?.backend){let i="/sap",s=n.backend.findIndex(o=>o.path===i);n.backend=n.backend.filter((o,a)=>a===s?!0:o.path!==t),this.updateCustomMiddleware(r)}}else throw new Error("Could not find fiori-tools-proxy");return this}getBackendConfigFromFioriToolsProxyMiddleware(t){return this.getBackendConfigsFromFioriToolsProxyMiddleware().find(n=>n.path===t)}getBackendConfigsFromFioriToolsProxyMiddleware(){let t;try{let r=this.document.getSequence({path:"server.customMiddleware"}),n=this.document.findItem(r,s=>s.name===yh),i=this.document.getMap({start:n,path:"configuration"});t=this.document.getSequence({start:i,path:"backend"}).toJSON()}catch{return[]}return t}addUi5ToFioriToolsProxyMiddleware(t){let r=this.document.getSequence({path:"server.customMiddleware"}),n=this.document.findItem(r,i=>i.name===yh);if(!n)throw new Error("Could not find fiori-tools-proxy");return this.document.getMap({start:n,path:"configuration"}).set("ui5",[t]),this}addMockServerMiddleware(t,r,n,i){return this.document.appendTo({path:"server.customMiddleware",value:ovt(t,r,n,i)}),this}addServiceToMockserverMiddleware(t,r,n,i=[]){let s=this.findCustomMiddleware("sap-fe-mockserver");if(s){let o=`.${cl.posix.sep}${(0,cl.relative)(t,(0,cl.join)(r,"localService",n.serviceName)).replaceAll(cl.sep,cl.posix.sep)}`,a=s?.configuration;if(a?.services){let u=n.servicePath.replace(/\/$/,""),c={urlPath:u,metadataPath:n.metadataPath??`${o}/metadata.xml`,mockdataPath:`${o}/data`,generateMockData:!0};n.resolveExternalServiceReferences===!0&&(c.resolveExternalServiceReferences=!0),a.services.findIndex(f=>f.urlPath===u)===-1&&(a.services=[...a.services,c])}if(a?.annotations){let u=a.annotations;i.forEach(c=>{u.find(l=>l.urlPath===c.urlPath)||u.push(c)})}this.updateCustomMiddleware(s)}else throw new Error("Could not find sap-fe-mockserver");return this}removeServiceFromMockServerMiddleware(t,r){let n=this.findCustomMiddleware("sap-fe-mockserver");if(n){let i=n?.configuration;if(i?.services&&(i.services=i?.services.filter(s=>s.urlPath!==t.replace(/\/$/,""))),i?.annotations){let s=i.annotations;r.forEach(o=>{i.annotations=s.filter(a=>a.urlPath!==o)})}this.updateCustomMiddleware(n)}else throw new Error("Could not find sap-fe-mockserver");return this}addAbapDeployTask(t,r,n=!0,i,s=!1,o,a=[]){this.document.appendTo({path:"builder.resources.excludes",value:"/test/**"}),this.document.appendTo({path:"builder.resources.excludes",value:"/localService/**"});let u=Array.from(new Set([...i??[],"/test/","/localService/"])),c={target:t,app:r,exclude:u,lrep:o};return s&&(c.index=!0),this.document.appendTo({path:"builder.customTasks",value:{name:n?"deploy-to-abap":"abap-deploy-task",afterTask:"generateCachebusterInfo",configuration:c},comments:a}),this}addCloudFoundryDeployTask(t,r=!1,n=!1){return this.document.appendTo({path:"builder.resources.excludes",value:"/test/**"}),this.document.appendTo({path:"builder.resources.excludes",value:"/localService/**"}),this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-task-zipper",afterTask:"generateCachebusterInfo",configuration:{archiveName:t,relativePaths:!0,additionalFiles:["xs-app.json"]}}}),r&&this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-tooling-modules-task",afterTask:"replaceVersion",configuration:{}}}),n&&this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-tooling-transpile-task",afterTask:"replaceVersion",configuration:{debug:!0,removeConsoleStatements:!0,transpileAsync:!0,transpileTypeScript:!0}}}),this}removeCustomMiddleware(t){return this.document.deleteAt({path:"server.customMiddleware",matcher:{key:"name",value:t}}),this}removeCustomTask(t){return this.document.deleteAt({path:"builder.customTasks",matcher:{key:"name",value:t}}),this}removeConfig(t){return this.document.delete(t),this}addComment({comment:t,location:r="beginning"}){return this.document.addDocumentComment({comment:t,location:r}),this}findCustomActivity(t,r){let n;try{n=this.document.getSequence({path:r})}catch{}let i;return n&&(i=this.document.findItem(n,s=>s.name===t)),i?i.toJSON():void 0}findCustomMiddleware(t){return this.findCustomActivity(t,"server.customMiddleware")}findCustomTask(t){return this.findCustomActivity(t,"builder.customTasks")}updateCustomMiddleware(t){let r=t.name;return this.findCustomMiddleware(r)?this.document.updateAt({path:"server.customMiddleware",matcher:{key:"name",value:r},value:t,mode:"overwrite"}):this.addCustomMiddleware([t]),this}mergeCustomMiddleware(t){let r=t.name;return this.findCustomMiddleware(r)&&this.document.updateAt({path:"server.customMiddleware",matcher:{key:"name",value:r},value:t,mode:"merge"}),this}getServeStaticConfig(t,r){return t?{name:ex,beforeMiddleware:yh,configuration:{paths:r}}:{name:ex,afterMiddleware:"compression",configuration:{paths:r}}}addServeStaticConfig(t){let r=this.findCustomMiddleware(ex),n=this.findCustomMiddleware(yh);if(r)r.afterMiddleware==="compression"&&n?this.updateCustomMiddleware({name:ex,beforeMiddleware:yh,configuration:{paths:[...r.configuration.paths,...t]}}):this.mergeCustomMiddleware({name:ex,configuration:{paths:[...r.configuration.paths,...t]}});else{let i=this.getServeStaticConfig(!!n,t);this.addCustomMiddleware([i])}return this}toString(){return this.document.toString()}};var Fyn=be(YSt(),1),Uyn=be(ta(),1);var dl=be(require("node:fs"),1),$p=be(require("node:path"),1),oCt=be(kpe(),1);var zSt=require("node:os"),Hhe=require("node:path"),St={AdaptationConfig:"config.json",CapJavaApplicationYaml:"application.yaml",ExtConfigJson:".extconfig.json",IndexCds:"index.cds",Library:".library",Manifest:"manifest.json",ManifestAppDescrVar:"manifest.appdescr_variant",MtaYaml:"mta.yaml",Package:"package.json",Pom:"pom.xml",SpecificationDistTags:"specification-dist-tags.json",ServiceCds:"services.cds",Tsconfig:"tsconfig.json",Ui5Yaml:"ui5.yaml",Ui5LocalYaml:"ui5-local.yaml",Ui5MockYaml:"ui5-mock.yaml",UI5DeployYaml:"ui5-deploy.yaml",PackageLock:"package-lock.json",XSAppJson:"xs-app.json",XSSecurityJson:"xs-security.json",DotGitIgnore:".gitignore",MtaExtYaml:"mta-ext.mtaext"},ai={Changes:"changes",ModuleCache:"module-cache",Schemas:".schemas",Pages:"pages",Webapp:"webapp",Temp:".tmp",LocalService:"localService",Controller:"controller",View:"view",Fragment:"fragment",Fragments:"fragments",Ext:"ext",VSCode:".vscode",AppConfig:"appconfig",Db:"db",Csv:"csv",Data:"data",Mockdata:"mockdata",Dist:"dist",Coding:"coding",Manifest:"manifest",Annotations:"annotations"},KSt={dir:".fioritools",migrationSettingsFile:"migrationSettings.json"};var Sx=(0,Hhe.join)((0,zSt.homedir)(),KSt.dir),lI=(0,Hhe.join)(Sx,ai.ModuleCache);var fI=require("node:fs"),t0t=be(e0t(),1);async function hf(e,t){return t?t.read(e):fI.promises.readFile(e,{encoding:"utf8"})}async function zr(e,t){return t?t.readJSON(e):JSON.parse(await hf(e))}async function W_(e,t,r){return r?r.write(e,t):fI.promises.writeFile(e,t,{encoding:"utf8"})}async function as(e,t){try{return t?t.exists(e):(await fI.promises.access(e),!0)}catch{return!1}}async function bx(e,t,r){await r0t(e,t,r)}async function Yhe(e,t,r){await r0t(e,t,r)}async function r0t(e,t,r){let n=await hf(e,r),i=(0,t0t.default)(n),o=JSON.stringify(t,null,i[Symbol.for("indent")])+`
|
|
692
|
+
`:""}var myn=hyn,gyn={dump:myn};function $he(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var yyn=Ws,vyn=rSt,Eyn=oSt,_yn=fSt,Syn=pSt,byn=qhe,Tyn=DSt.load,Ayn=DSt.loadAll,xyn=gyn.dump,wyn=ca,Cyn={binary:ySt,float:lSt,map:sSt,null:aSt,pairs:ESt,set:_St,timestamp:mSt,bool:uSt,int:cSt,merge:gSt,omap:vSt,seq:iSt,str:nSt},Oyn=$he("safeLoad","load"),Pyn=$he("safeLoadAll","loadAll"),Dyn=$he("safeDump","dump"),VSt={Type:yyn,Schema:vyn,FAILSAFE_SCHEMA:Eyn,JSON_SCHEMA:_yn,CORE_SCHEMA:Syn,DEFAULT_SCHEMA:byn,load:Tyn,loadAll:Ayn,dump:xyn,YAMLException:wyn,types:Cyn,safeLoad:Oyn,safeLoadAll:Pyn,safeDump:Dyn};var Ryn=(0,cl.dirname)((0,$St.fileURLToPath)(__importMetaUrl)),Po=class e{document;static validate;async validateSchema(){if(!e.validate){let r=(0,cl.join)(Ryn,"..","dist","schema","ui5.yaml.json"),n=JSON.parse(await(0,HSt.readFile)(r,"utf8"));if(!n)throw Error("The schema file was not found. Validation is not possible.");e.validate=new GSt.Ajv({strict:!1}).compile(n)}let t=!1;try{t=VSt.loadAll(this.document.toString()).every(r=>e.validate(r))}catch(r){throw Error(`No validation possible. Error: ${r}`)}return t}static async newInstance(t,r){let n=new e;if(n.document=await DN.newInstance(t),(r?.validateSchema??!1)&&!await n.validateSchema())throw new Error("This file does not comply with the schema.");return n}getMetadata(){try{return this.document.getMap({path:"metadata"}).toJSON()}catch{return}}getConfiguration(){let t;try{t=this.document.getMap({path:"resources"}).toJSON()}catch{t={}}return t.configuration??{}}setConfiguration(t){return this.document.setIn({path:"resources",value:{configuration:t}}),this}setMetadata(t){return this.document.setIn({path:"metadata",value:t}),this}getType(){return this.document.getNode({path:"type"})}setType(t){return this.document.setIn({path:"type",value:t}),this}addCustomConfiguration(t,r){try{this.document.getMap({path:"customConfiguration"}).setIn([t],r)}catch{this.document.setIn({path:"customConfiguration",value:{[t]:r}})}}getCustomConfiguration(t){try{let r=this.document.getMap({path:"customConfiguration"}).get(t);return r?.toJSON?.()??r?.toString()}catch{return}}getUi5Framework(){return this.document.getMap({path:"framework"}).toJSON()}addUI5Framework(t,r,n,i="sap_fiori_3"){let s=[];for(let o of n)s.push({name:o});return s.push({name:`themelib_${i.replace(/_dark$|_hcw$|_hcb$/,"")}`}),this.document.setIn({path:"framework",value:{name:t,version:r,libraries:s}}),this}addCustomTasks(t,r){for(let n of t)this.document.appendTo({path:"builder.customTasks",value:n,comments:r});return this}addCustomMiddleware(t,r){for(let n of t)this.document.appendTo({path:"server.customMiddleware",value:n,comments:r});return this}addFioriToolsAppReloadMiddleware(){return this.document.appendTo({path:"server.customMiddleware",value:ivt()}),this}addFioriToolsProxyMiddleware(t,r){let n=t?.ignoreCertErrors??t?.ignoreCertError??!1,{config:i,comments:s}=svt(t.backend,t.ui5,r,n);return this.document.appendTo({path:"server.customMiddleware",value:i,comments:s}),this}getFioriToolsProxyMiddlewareConfiguration(){let t=this.document.getSequence({path:"server.customMiddleware"}),r=this.document.findItem(t,n=>n.name===yh);if(!r)throw new Error("Could not find fiori-tools-proxy");return this.document.getMap({start:r,path:"configuration"})}addBackendToFioriToolsProxyMiddleware(t,r=!1){let n=this.getFioriToolsProxyMiddlewareConfiguration(),i=n.toJSON(),s=Q$(t),o=this.document.createNode({value:t,comments:s});if((i?.ignoreCertErrors??i?.ignoreCertError??!1)!==r&&(n.set("ignoreCertErrors",r),i?.ignoreCertError!==void 0&&n.delete("ignoreCertError")),i?.backend){if(!i?.backend.find(u=>u.path===t.path)){let u=this.document.getSequence({start:n,path:"backend"});u.items.length===0?n.set("backend",[o]):u.add(o)}}else n.set("backend",[o]);return this}updateBackendToFioriToolsProxyMiddleware(t){let r=this.getFioriToolsProxyMiddlewareConfiguration(),n=r.toJSON(),i=Q$(t),s=this.document.createNode({value:t,comments:i});if(n?.backend){let o=n?.backend.findIndex(a=>a.path&&a.path===t.path);o!==-1&&this.document.getSequence({start:r,path:"backend"}).set(o,s)}return this}removeBackendFromFioriToolsProxyMiddleware(t){let r=this.findCustomMiddleware(yh);if(r){let n=r?.configuration;if(n?.backend){let i="/sap",s=n.backend.findIndex(o=>o.path===i);n.backend=n.backend.filter((o,a)=>a===s?!0:o.path!==t),this.updateCustomMiddleware(r)}}else throw new Error("Could not find fiori-tools-proxy");return this}getBackendConfigFromFioriToolsProxyMiddleware(t){return this.getBackendConfigsFromFioriToolsProxyMiddleware().find(n=>n.path===t)}getBackendConfigsFromFioriToolsProxyMiddleware(){let t;try{let r=this.document.getSequence({path:"server.customMiddleware"}),n=this.document.findItem(r,s=>s.name===yh),i=this.document.getMap({start:n,path:"configuration"});t=this.document.getSequence({start:i,path:"backend"}).toJSON()}catch{return[]}return t}addUi5ToFioriToolsProxyMiddleware(t){let r=this.document.getSequence({path:"server.customMiddleware"}),n=this.document.findItem(r,i=>i.name===yh);if(!n)throw new Error("Could not find fiori-tools-proxy");return this.document.getMap({start:n,path:"configuration"}).set("ui5",[t]),this}addMockServerMiddleware(t,r,n,i){return this.document.appendTo({path:"server.customMiddleware",value:ovt(t,r,n,i)}),this}addServiceToMockserverMiddleware(t,r,n,i=[]){let s=this.findCustomMiddleware("sap-fe-mockserver");if(s){let o=`.${cl.posix.sep}${(0,cl.relative)(t,(0,cl.join)(r,"localService",n.serviceName)).replaceAll(cl.sep,cl.posix.sep)}`,a=s?.configuration;if(a?.services){let u=n.servicePath.replace(/\/$/,""),c={urlPath:u,metadataPath:n.metadataPath??`${o}/metadata.xml`,mockdataPath:`${o}/data`,generateMockData:!0};n.resolveExternalServiceReferences===!0&&(c.resolveExternalServiceReferences=!0),a.services.findIndex(f=>f.urlPath===u)===-1&&(a.services=[...a.services,c])}if(a?.annotations){let u=a.annotations;i.forEach(c=>{u.find(l=>l.urlPath===c.urlPath)||u.push(c)})}this.updateCustomMiddleware(s)}else throw new Error("Could not find sap-fe-mockserver");return this}removeServiceFromMockServerMiddleware(t,r){let n=this.findCustomMiddleware("sap-fe-mockserver");if(n){let i=n?.configuration;if(i?.services&&(i.services=i?.services.filter(s=>s.urlPath!==t.replace(/\/$/,""))),i?.annotations){let s=i.annotations;r.forEach(o=>{i.annotations=s.filter(a=>a.urlPath!==o)})}this.updateCustomMiddleware(n)}else throw new Error("Could not find sap-fe-mockserver");return this}addBuilderResourceExcludes(){let t=["/test/**","/localService/**"],r=[];try{r=this.document.getSequence({path:"builder.resources.excludes"}).toJSON().filter(n=>typeof n=="string")}catch{}for(let n of t)r.includes(n)||(this.document.appendTo({path:"builder.resources.excludes",value:n}),r.push(n));return this}addAbapDeployTask(t,r,n=!0,i,s=!1,o,a=[]){this.addBuilderResourceExcludes();let u=Array.from(new Set([...i??[],"/test/","/localService/"])),c={target:t,app:r,exclude:u,lrep:o};return s&&(c.index=!0),this.document.appendTo({path:"builder.customTasks",value:{name:n?"deploy-to-abap":"abap-deploy-task",afterTask:"generateCachebusterInfo",configuration:c},comments:a}),this}addCloudFoundryDeployTask(t,r=!1,n=!1){return this.addBuilderResourceExcludes(),this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-task-zipper",afterTask:"generateCachebusterInfo",configuration:{archiveName:t,relativePaths:!0,additionalFiles:["xs-app.json"]}}}),r&&this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-tooling-modules-task",afterTask:"replaceVersion",configuration:{}}}),n&&this.document.appendTo({path:"builder.customTasks",value:{name:"ui5-tooling-transpile-task",afterTask:"replaceVersion",configuration:{debug:!0,removeConsoleStatements:!0,transpileAsync:!0,transpileTypeScript:!0}}}),this}removeCustomMiddleware(t){return this.document.deleteAt({path:"server.customMiddleware",matcher:{key:"name",value:t}}),this}removeCustomTask(t){return this.document.deleteAt({path:"builder.customTasks",matcher:{key:"name",value:t}}),this}removeConfig(t){return this.document.delete(t),this}addComment({comment:t,location:r="beginning"}){return this.document.addDocumentComment({comment:t,location:r}),this}findCustomActivity(t,r){let n;try{n=this.document.getSequence({path:r})}catch{}let i;return n&&(i=this.document.findItem(n,s=>s.name===t)),i?i.toJSON():void 0}findCustomMiddleware(t){return this.findCustomActivity(t,"server.customMiddleware")}findCustomTask(t){return this.findCustomActivity(t,"builder.customTasks")}updateCustomMiddleware(t){let r=t.name;return this.findCustomMiddleware(r)?this.document.updateAt({path:"server.customMiddleware",matcher:{key:"name",value:r},value:t,mode:"overwrite"}):this.addCustomMiddleware([t]),this}mergeCustomMiddleware(t){let r=t.name;return this.findCustomMiddleware(r)&&this.document.updateAt({path:"server.customMiddleware",matcher:{key:"name",value:r},value:t,mode:"merge"}),this}getServeStaticConfig(t,r){return t?{name:ex,beforeMiddleware:yh,configuration:{paths:r}}:{name:ex,afterMiddleware:"compression",configuration:{paths:r}}}addServeStaticConfig(t){let r=this.findCustomMiddleware(ex),n=this.findCustomMiddleware(yh);if(r)r.afterMiddleware==="compression"&&n?this.updateCustomMiddleware({name:ex,beforeMiddleware:yh,configuration:{paths:[...r.configuration.paths,...t]}}):this.mergeCustomMiddleware({name:ex,configuration:{paths:[...r.configuration.paths,...t]}});else{let i=this.getServeStaticConfig(!!n,t);this.addCustomMiddleware([i])}return this}toString(){return this.document.toString()}};var Fyn=be(YSt(),1),Uyn=be(ta(),1);var dl=be(require("node:fs"),1),$p=be(require("node:path"),1),oCt=be(kpe(),1);var zSt=require("node:os"),Hhe=require("node:path"),St={AdaptationConfig:"config.json",CapJavaApplicationYaml:"application.yaml",ExtConfigJson:".extconfig.json",IndexCds:"index.cds",Library:".library",Manifest:"manifest.json",ManifestAppDescrVar:"manifest.appdescr_variant",MtaYaml:"mta.yaml",Package:"package.json",Pom:"pom.xml",SpecificationDistTags:"specification-dist-tags.json",ServiceCds:"services.cds",Tsconfig:"tsconfig.json",Ui5Yaml:"ui5.yaml",Ui5LocalYaml:"ui5-local.yaml",Ui5MockYaml:"ui5-mock.yaml",UI5DeployYaml:"ui5-deploy.yaml",PackageLock:"package-lock.json",XSAppJson:"xs-app.json",XSSecurityJson:"xs-security.json",DotGitIgnore:".gitignore",MtaExtYaml:"mta-ext.mtaext"},ai={Changes:"changes",ModuleCache:"module-cache",Schemas:".schemas",Pages:"pages",Webapp:"webapp",Temp:".tmp",LocalService:"localService",Controller:"controller",View:"view",Fragment:"fragment",Fragments:"fragments",Ext:"ext",VSCode:".vscode",AppConfig:"appconfig",Db:"db",Csv:"csv",Data:"data",Mockdata:"mockdata",Dist:"dist",Coding:"coding",Manifest:"manifest",Annotations:"annotations"},KSt={dir:".fioritools",migrationSettingsFile:"migrationSettings.json"};var Sx=(0,Hhe.join)((0,zSt.homedir)(),KSt.dir),lI=(0,Hhe.join)(Sx,ai.ModuleCache);var fI=require("node:fs"),t0t=be(e0t(),1);async function hf(e,t){return t?t.read(e):fI.promises.readFile(e,{encoding:"utf8"})}async function zr(e,t){return t?t.readJSON(e):JSON.parse(await hf(e))}async function W_(e,t,r){return r?r.write(e,t):fI.promises.writeFile(e,t,{encoding:"utf8"})}async function as(e,t){try{return t?t.exists(e):(await fI.promises.access(e),!0)}catch{return!1}}async function bx(e,t,r){await r0t(e,t,r)}async function Yhe(e,t,r){await r0t(e,t,r)}async function r0t(e,t,r){let n=await hf(e,r),i=(0,t0t.default)(n),o=JSON.stringify(t,null,i[Symbol.for("indent")])+`
|
|
693
693
|
`;await W_(e,o,r)}async function qH(e){return fI.promises.readdir(e,{encoding:"utf8"})}var ws=require("node:path"),s0t=be(i0t(),1);function Xyn(e,t,r,n){let i=[],s=[],o=Object.keys(e).filter(a=>a.startsWith(n.replaceAll(ws.sep,ws.posix.sep))&&(t.includes((0,ws.basename)(a))||r.includes((0,ws.extname)(a))||t.length===0&&r.length===0));for(let a of o)e[a].state==="deleted"&&i.push((0,ws.join)(a)),e[a].state==="modified"&&s.push((0,ws.join)(a));return{deleted:i,modified:s}}function Jyn(e,t,r,n,i,s){let o=e,a=i;if(s){let{modified:u,deleted:c}=Xyn(s.dump(""),t,r,n);o=Array.from(new Set([...e,...u])).filter(f=>!c.includes(f)),a=i.filter(f=>f.code!=="ENOENT"||typeof f.path=="string"&&!u.some(p=>p.startsWith(f.path)))}return{searchResult:o,fatalErrors:a}}function Y_(e){return new Promise((t,r)=>{let n=[],i=Array.isArray(e.fileNames)?e.fileNames:[],s=Array.isArray(e.extensionNames)?e.extensionNames:[],o=Array.isArray(e.excludeFolders)?e.excludeFolders:[],a=e.noTraversal??!1,u=[],c=(0,s0t.default)(e.root);c.on("directory",(l,f,p)=>{let d=(0,ws.basename)(l);(o.includes(d)||a&&l!==e.root)&&p()}),c.on("file",l=>{(s.includes((0,ws.extname)(l))||i.includes((0,ws.basename)(l))||i.length===0&&s.length===0)&&n.push(l)}),c.on("end",()=>{let{searchResult:l,fatalErrors:f}=Jyn(n,i,s,e.root,u,e.memFs);f.length===0?t(l):r(f)}),c.on("error",l=>{u.push(l)})})}function Tx(e,t,r,n,i){return Y_({extensionNames:[e],root:t,excludeFolders:r,noTraversal:i,memFs:n})}async function mf(e,t,r){let n=(0,ws.join)(t,e);return await as(n,r)?n:(0,ws.dirname)(t)!==t?mf(e,(0,ws.dirname)(t),r):void 0}var o0t=require("node:fs"),zhe;function VH(e){if(process.platform==="win32"){if(zhe===void 0){let r=o0t.realpathSync.native("\\")[0];zhe=r===r.toUpperCase()}return(zhe?e.charAt(0).toUpperCase():e.charAt(0).toLowerCase())+e.slice(1)}return e}var wxt=require("node:child_process"),Do=require("node:path");var dI=require("node:fs"),mI=require("node:fs/promises"),hI=require("node:path"),c0t=require("node:module");var a0t=require("node:fs"),Th=require("node:path");var pI=(e,t)=>!!(e.dependencies?.[t]??e.devDependencies?.[t]);function GH(e,t){if(!(0,Th.isAbsolute)(e))return;let{root:r}=(0,Th.parse)(e),n=e,i;for(;n!==r;){let s=(0,Th.join)(n,"node_modules");if(t&&(s=(0,Th.join)(s,t,St.Package)),(0,a0t.existsSync)(s)){i=n;break}n=(0,Th.dirname)(n)}return i}var u0t=require("node:child_process");async function z_(e,t){return new Promise((r,n)=>{let i=process.platform.startsWith("win"),s=i?"npm.cmd":"npm",o=i?{windowsVerbatimArguments:!0,shell:!0}:{},a=t?.logger,u=t?.cwd,c=typeof u=="string"?{...o,cwd:u}:o,l=(0,u0t.spawn)(s,e,c),f="",p="";l.stdout.on("data",h=>{f+=h.toString()}),l.stderr.on("data",h=>{p+=h.toString()});let d=`${s} ${e.join(" ")}`;l.on("exit",(h,g)=>{if(h===null)a?.warn(`Command '${d}' was killed by signal: ${g}`);else if(h===0){let _=[f,p].filter(Boolean).join(`
|
|
694
694
|
`),S=_?`:
|
|
695
695
|
${_}`:"";a?.info(`Command '${d}' successful${S}`)}else if(t?.throwOnError){f&&a?.info(f),n(new Error(`Command '${d}' failed with exit code ${h}. Stderr: ${p}`));return}else a?.error(`Command '${d}' not successful, stderr: ${p}`);r(f)}),l.on("error",h=>{a?.error(`Error executing npm command '${d}': ${h}`),n(h)})})}var l0t=require("node:url"),rvn=(0,c0t.createRequire)(__importMetaUrl);async function f0t(e,t){if(!GH(e,t))throw Error("Path to module not found.");return rvn.resolve(t,{paths:[e]})}async function Ah(e,t){let r;try{let n=await f0t(e,t);r=await import((0,l0t.pathToFileURL)(n).href)}catch(n){throw Error(`Module '${t}' not installed in project '${e}'.
|
|
@@ -730,7 +730,7 @@ specVersion: "2.5"`);return s.setMetadata({name:e}),s.setType("application"),s.a
|
|
|
730
730
|
${i}`);let s=[" getReferentialConstraints: function (navigationProperty) {",`${i}`," return undefined;"," }"].join(`
|
|
731
731
|
`),o=e.lastIndexOf(`
|
|
732
732
|
};`);return o!==-1?`${e.slice(0,o)},
|
|
733
|
-
${s}${e.slice(o)}`:e}var e2=be(W8t()),r4t=require("node:fs/promises"),n4t=require("node:path");var z8t=require("node:crypto"),K8t=be(k8());var Y8t={name:"@sap-ux/generator-odata-downloader",displayName:"Fiori Elements Data Downloader",description:"Yeoman generator that supports download of app data, typically for mock data server use.",version:"0.3.9",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/generator-odata-downloader"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-download"},license:"Apache-2.0",main:"generators/app/index.js",keywords:["yeoman-generator"],scripts:{build:"npm-run-all clean bundle:prod",compile:"tsc --build",clean:"rimraf --glob generators prebuilds test/test-output coverage *.tsbuildinfo",watch:"tsc --watch",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",bundle:"node esbuild.mjs","bundle:dev":"pnpm clean && node esbuild.mjs --development && pnpm pack","bundle:prod":"node esbuild.mjs --production"},files:["LICENSE","generators","!generators/*.map","!generators/**/*.map","prebuilds","yeoman.png"],devDependencies:{"@jest/globals":"30.3.0"},dependencies:{"@sap-devx/yeoman-ui-types":"1.25.0","@sap-ux/annotation-converter":"0.10.21","@sap-ux/axios-extension":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-generator-shared":"workspace:*","@sap-ux/inquirer-common":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/mockserver-config-writer":"workspace:*","@sap-ux/odata-service-inquirer":"workspace:*","@sap-ux/odata-service-writer":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/store":"workspace:*","@sap-ux/telemetry":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/vocabularies-types":"0.15.0","@sap/ux-specification":"1.144.0","@types/inquirer":"8.2.6","@types/yeoman-generator":"5.2.14","@vscode-logging/logger":"2.0.9",deepmerge:"4.3.1",i18next:"25.10.10",inquirer:"8.2.7","odata-query":"8.0.5","os-name":"4.0.1","prettify-xml":"1.2.0",rimraf:"6.1.3","yeoman-generator":"5.10.0"},engines:{node:">=22.x"}};var EZn="@sap-ux/odata-download-sub-generator",_Zn="0a65e45d-6bf4-421d-b845-61e888c50e9e",va=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=(0,z8t.randomUUID)(),lr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:EZn,version:Y8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:_Zn,...t};try{await AL(r)}catch(n){lr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=It("telemetry.unknownOs");try{r=(0,K8t.default)()}catch{}this._telemetryData={Platform:Vr()?"SBAS":"VSCode",OperatingSystem:r,SessionId:this._sessionId}}return this._telemetryData=Object.assign(this._telemetryData,t),this._telemetryData}static prepareTelemetryEvent(t,r){return{eventName:t,properties:r,measurements:{}}}static async sendTelemetry(t,r){let n=this.createTelemetryData(r),i=this.prepareTelemetryEvent(t,n);await ic.getTelemetryClient().reportEvent(i,Pi.NoSampling)}};var SZn=["eq","ne","gt","ge","lt","le"],O7=["and","or","not"],bZn=["any","all"],TZn=["startswith","endswith","contains","matchespattern"],AZn=["expand","levels","select","skip","top","count","orderby","filter"],X8t=/\((.*)\)/,J8t=/(?!indexof)\((\w+)\)/;var sm="";function gTe({select:e,search:t,skiptoken:r,format:n,top:i,skip:s,filter:o,transform:a,orderBy:u,key:c,count:l,expand:f,action:p,func:d}={}){let h="",g=[],_={};if(c!=null&&(h+=`(${ad(c,g)})`),(o||typeof l=="object")&&(_.$filter=D7(typeof l=="object"?l:o,g)),a&&(_.$apply=Z8t(a)),f&&(_.$expand=P7(f)),u&&(_.$orderby=yTe(u)),l&&(typeof l=="boolean"?_.$count=!0:h+="/$count"),typeof i=="number"&&(_.$top=i),typeof s=="number"&&(_.$skip=s),p&&(h+=`/${p}`),d){if(typeof d=="string")h+=`/${d}`;else if(typeof d=="object"){let[S]=Object.keys(d),T=ad(d[S],g);h+=`/${S}`,T!==""&&(h+=`(${T})`)}}return g.length>0&&Object.assign(_,g.reduce((S,T)=>Object.assign(S,{[`@${T.name}`]:ad(T.value)}),{})),PZn(h,{$select:e,$search:t,$skiptoken:r,$format:n,..._})}function mTe(e,t,r=[]){return`${e} eq ${ad(t,r)}`}function D7(e={},t=[],r=""){return(Array.isArray(e)?e:[e]).reduce((s,o)=>{if(o){let a=n(o,t,r);a&&s.push(a)}return s},[]).join(" and ");function n(s={},o=[],a=""){let u="";return typeof s=="string"?u=s:s&&typeof s=="object"&&(u=Object.keys(s).reduce((c,l)=>{let f=s[l];if(f===void 0)return c;let p="";if(a?l===sm?p=a:J8t.test(l)?p=l.replace(J8t,(d,h)=>h.trim()===sm?`(${a})`:`(${a}/${h.trim()})`):X8t.test(l)?p=l.replace(X8t,(d,h)=>h.trim()===sm?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===sm&&Array.isArray(f))return c.concat(f.map(d=>mTe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(mTe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>D7(g,o,a)).filter(g=>g).map(g=>O7.indexOf(d)!==-1?`(${g})`:g);h.length&&(O7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(Q8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(O7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(Q8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(mTe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(SZn.indexOf(d)!==-1)c.push(`${p} ${d} ${ad(f[d],o)}`);else if(O7.indexOf(d)!==-1)Array.isArray(f[d])?c.push(f[d].map(h=>"("+n(h,o,p)+")").join(` ${d} `)):c.push("("+n(f[d],o,p)+")");else if(bZn.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${ad(f[d],o)}`);else if(d==="in"){let h=Array.isArray(f[d])?f[d]:f[d].value.map(g=>({type:f[d].type,value:g}));c.push(p+" in ("+h.map(g=>ad(g,o)).join(",")+")")}else if(TZn.indexOf(d)!==-1)c.push(`${d}(${p},${ad(f[d],o)})`);else{let h=n({[d]:f[d]},o,p);h&&c.push(h)}});else throw new Error(`Unexpected value type: ${f}`);return c},[]).join(" and ")),u}function i(s,o,a,u){let c="";if(typeof o=="string"||o instanceof String)c=xZn(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(sm)?(p.hasOwnProperty(sm)||(p[sm]=[]),p[sm].push(d[sm]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function xZn(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function wZn(e){return e=e.replace(/%/g,"%25"),e=e.replace(/\+/g,"%2B"),e=e.replace(/\//g,"%2F"),e=e.replace(/\?/g,"%3F"),e=e.replace(/#/g,"%23"),e=e.replace(/&/g,"%26"),e=e.replace(/'/g,"''"),e}function ad(e,t){if(typeof e=="string")return`'${wZn(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>ad(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(t)&&t.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${ad(n,t)}`).join(",")}return e}function P7(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((t,r,n,i)=>n===0?`$expand=${r}`:n===i.length-1?`${r}(${t})`:`$expand=${r}(${t})`,"");if(Array.isArray(e))return`${e.map(t=>P7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>AZn.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=D7(e[r]);break;case"orderBy":n=yTe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=P7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=P7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function Z8t(e){return(Array.isArray(e)?e:[e]).reduce((t,r)=>{for(let n of Object.keys(r))switch(n){case"aggregate":{let i=r[n];i&&t.push(`aggregate(${CZn(i)})`);break}case"filter":{let i=r[n];if(i){let s=D7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${OZn(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function CZn(e){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?t:Object.keys(t).map(r=>{let n=t[r];if(!n.with&&n.as)return`${r} as ${n.as}`;if(!n.with)throw new Error(`'with' property required for '${r}'`);if(!n.as)throw new Error(`'as' property required for '${r}'`);return`${r} with ${n.with} as ${n.as}`})).join(",")}function OZn(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${Z8t(e.transform)}`),t}function yTe(e,t=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${t}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>yTe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function PZn(e,t){let r=Object.getOwnPropertyNames(t).filter(n=>t[n]!==void 0&&t[n]!=="").map(n=>`${n}=${t[n]}`);return r.length?`${e}?${r.join("&")}`:e}function Q8t(e){return`not (${e.join(" and ")})`}function DZn(e){let t=[];return{expands:e.reduce((n,{entityPath:i})=>{let s=i.split("/"),o=n;return s.forEach((a,u)=>{o.expand||(o.expand={}),o.expand[a]??=u===s.length-1?{}:{expand:{}},o=o.expand[a],t.includes(a)||t.push(a)}),n},{expand:{}}),entityPathParts:t}}function RZn(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=DZn(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);lr.logger.info(It("info.entityFilesToBeGenerated",{entities:a.join(", ")}));let u=e;if(n){let d=[];u.semanticKeys.forEach(x=>{if(x.value!==void 0&&x.value!=="")if(x.type==="Edm.Boolean")d.push(`${x.name} eq ${x.value}`);else{let N=String(x.value).split(","),F=["Edm.UUID","Edm.Guid"].includes(x.type),D=V=>F?V.trim():`'${V.trim()}'`;if(N.length===1)d.push(`${x.name} eq ${D(N[0])}`);else{let V=N.map(z=>`${x.name} eq ${D(z)}`);d.push(`(${V.join(" or ")})`)}}});let h=d.length>0?`,filter(${d.join(" and ")})`:"",g=`$root/${u.entitySetName},${n.qualifier},${n.nodeProperty}`,_=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/${u.entitySetName},HierarchyQualifier='${n.qualifier}',NodeProperty='${n.nodeProperty}')`,S=n.isDraft?`$apply=ancestors(${g}${h},keep start)/${_}`:`$apply=${_}`,T=s?gTe(s):"",A=T?`&${T.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return lr.logger.debug(`Query for odata: ${w}`),{query:w}}let c=[];u.semanticKeys.forEach(d=>{if(d.value!==void 0&&d.value!=="")if(["Edm.UUID","Edm.Guid"].includes(d.type)){let g=String(d.value).split(",").map(_=>({[d.name]:{type:"guid",value:_.trim()}}));c.push(g.length===1?g[0]:{or:g})}else if(d.type==="Edm.Boolean")c.push({[d.name]:String(d.value)==="true"});else if(d.type==="Edm.String"){let h=String(d.value).split(","),g=[];h.forEach(_=>{let S=_.trim().split("-");S.length===1?g.push({[d.name]:_.trim()}):S.length===2&&g.push({[d.name]:{ge:S[0].trim(),le:S[1].trim()}})}),c.push(g.length==1?g[0]:{or:g})}else c.push({[d.name]:d.value})});let l={};s&&Object.assign(l,s),c.length>0?Object.assign(l,{filter:c.length===1?c[0]:c,count:!0}):r&&Object.assign(l,{top:r});let f=gTe(l),p=`${u.entitySetName}${f}`;return lr.logger.debug(`Query for odata: ${p}`),{query:p}}function NZn(e,t,r){let n=new Set(["DraftUUID","IsActiveEntity"]),i=[];for(let f of e.semanticKeys){if(f.value===void 0||f.value===""||n.has(f.name))continue;let p=f.keyName??f.name,d=String(f.value).split(",")[0].trim(),h=["Edm.UUID","Edm.Guid"].includes(f.type),g=f.type==="Edm.Boolean";i.push(`${p}=${h||g?d:`'${d}'`}`)}if(i.length===0){lr.logger.debug(`buildNavPropHierarchyQuery: no key values available for '${e.entitySetName}', skipping nav-prop hierarchy query for '${t}'`);return}let s={DraftUUID:"00000000-0000-0000-0000-000000000000",IsActiveEntity:"true"};e.entityType?.keys?.filter(f=>f.name in s).forEach(f=>i.push(`${f.name}=${s[f.name]}`)),lr.logger.debug(`buildNavPropHierarchyQuery: key segment for '${e.entitySetName}': (${i.join(",")})`);let a=`${`${e.entitySetName}(${i.join(",")})`}/${t}`,c=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=${`$root/${a}`},HierarchyQualifier='${r.qualifier}',NodeProperty='${r.nodeProperty}')`,l=`${a}?$apply=${c}`;return lr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function t4t(e,t,r,n,i,s=[]){let o=RZn(e,r,n,i),a=await e4t(t,o.query);for(let u of s){let c=r.find(_=>_.entity.entitySetName===u.entitySetName);if(!c){lr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=NZn(e,c.entity.entityPath,u);if(!l){lr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await e4t(t,l);if(!f.entityData||!a.entityData){lr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}lr.logger.debug(`fetchData: merging ${f.entityData.length} hierarchy records into '${c.entity.entityPath}' expanded items`);let p=c.entity.entityPath,d=u.nodeProperty.split("/")[0],h=f.entityData,g=0;for(let _ of a.entityData){let S=_[p];if(Array.isArray(S))for(let T of S){let A=h.find(w=>u.entityTypeKeys.every(x=>w[x]===T[x]));A&&(T[d]=A[d],g++)}}lr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function e4t(e,t){try{lr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),lr.logger.debug(`OData query request headers: ${JSON.stringify(e.defaults.headers)}`);let r=await e.get(t),n=r?.data?.match(/"@odata\.count":(\d+)/)?.[1];return lr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=It("errors.odataQueryError",{error:r});return lr.logger.error(n),{error:n}}}var wu=class e{static externalServiceRequestCache={};static entityTypeRefFacetCache={};static resetExternalServiceCache(t){if(t){delete e.externalServiceRequestCache[t];return}e.externalServiceRequestCache={}}static resetRefFacetCache(){e.entityTypeRefFacetCache={}}static resetServiceCaches(){e.resetExternalServiceCache(),e.resetRefFacetCache()}};async function i4t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=lr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();va.sendTelemetry("ODATA_DOWNLOAD_SEND_QUERY",{time:Date()});let s=t.referencedEntities.hierarchyEntities?.find(u=>u.entitySetName===t.referencedEntities.listEntity.entitySetName),o=t.referencedEntities.hierarchyEntities?.filter(u=>u.entitySetName!==t.referencedEntities.listEntity.entitySetName&&r.some(c=>c.entity.entitySetName===u.entitySetName))??[],{odataResult:a}=await t4t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return va.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),lr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return va.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return It("errors.dataNotFetched")}function s4t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type===e2.UIAnnotationTypes.ReferenceFacet&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type===e2.UIAnnotationTypes.CollectionFacet&&t.push(...s4t(r))}),t}function IZn(e){if(wu.entityTypeRefFacetCache[e.name])return wu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type===e2.UIAnnotationTypes.ReferenceFacet&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type===e2.UIAnnotationTypes.CollectionFacet&&t.push(...s4t(r))}),wu.entityTypeRefFacetCache[e.name]=t,t??[]}function o4t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?IZn(e.entityType):[];for(let u of o){let c=u.entityPath,l=i??e;if(u.entityType?.name===l?.entityType?.name||t.includes(c))continue;let f=t.concat(`${t?"/":""}${c}`);u.navPropEntities&&u.navPropEntities.length>0&&Object.assign(s,o4t(u,f,r,n,i??e).entitySetsFlat);let p={fullPath:f,entity:{entityPath:u.entityPath,entitySetName:u.entitySetName,defaultSelected:a.includes(u.entityPath)||!!n?.includes(f)}},d=`${f}`;r||(r=[]),r.push({name:d,value:p,checked:p.entity.defaultSelected}),s[f]=u.entitySetName}}return{entitySetsFlat:s,choices:r}}function a4t(e,t){let r=t?.map(n=>{let i=n.page?.contextPath??n.page?.routePattern?.replace(":?query:","").replaceAll(/\(\{[^}]*\}\)/g,"");return i?.startsWith(`/${e.entityPath}/`)?i.replace(`/${e.entityPath}/`,""):i}).filter(n=>n!==void 0);if(e.navPropEntities){let n=o4t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function u4t(e,t){let n=(await Po.newInstance(await(0,r4t.readFile)((0,n4t.join)(e,St.Ui5Yaml),"utf-8"))).getBackendConfigsFromFioriToolsProxyMiddleware()[0],i;if(n){let s=n.url;if(n.connectPath){let o=n.connectPath.startsWith("/")?n.connectPath:`/${n.connectPath}`;s=new URL(o,n.url).href}i=Vr()?n?.destination:await j8t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function c4t(e){let t=await pL(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(lr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),It("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var l4t,LZn=(...e)=>new Promise(t=>{clearTimeout(l4t),l4t=setTimeout(async()=>t(await i4t(...e)),1e3)}),Ol={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},MZn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,f4t=["."];async function p4t(e,t,r){let n=!1;if(!r.referencedEntities?.listEntity.semanticKeys.every((a,u)=>(a.name!=="IsActiveEntity"&&!n&&(n=!!a.value),a.value!==void 0&&a.value!==""||!e[`entityKeyIdx:${u}`]))||!n)return It("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[Ol.relatedEntitySelection]);let o=await LZn(t,r,s);return o}function FZn(e){return wu.resetServiceCaches(),e.appAccess=void 0,e.referencedEntities=void 0,e.servicePath=void 0,e.systemName&&(e.systemName.value=void 0),e.relatedEntityChoices.choices=[],e.relatedEntityChoices.entitySetsFlat={},e}async function d4t(e){let t=[],r={appAccess:void 0,referencedEntities:void 0,servicePath:void 0,systemName:{value:void 0},connectPath:{value:void 0},relatedEntityChoices:{choices:[],entitySetsFlat:{}}},n=[],i=UZn(r,n,e?.appPath),s=await ZGt({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:Kn.v4}},kc()!==cn.cli,lr.logger);s.prompts=Ds(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=BZn(r,r.relatedEntityChoices),u=qZn(5,r,s.answers,o),c=kZn(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,VZn(s.answers,r),jZn(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function UZn(e,t,r){return{type:"input",guiType:"folder-browser",name:Ol.appSelection,message:It("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:It("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,FZn(e);let i;try{i=await Q5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),lr.logger.error(It("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${It("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${It("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return It("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await c4t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await u4t(i.app.appRoot,s);return a&&(e.servicePath=a,t.push(a)),e.systemName&&(e.systemName.value=u),e.connectPath&&(e.connectPath.value=a),!0}}}function kZn(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:Ol.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:It("prompts.relatedEntitySelection.message"),choices:()=>e.choices,validate:async(s,o)=>{if(e.choices.forEach(a=>{a.disabled||(a.checked=s.some(u=>u.fullPath===a.value.fullPath))}),o&&!o[Ol.skipDataDownload]?.[0]){if(i=await p4t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:It("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:vTe.Severity.information}}}}function BZn(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=a4t(e.referencedEntities.listEntity,e.referencedEntities.pageObjectEntities);o&&(t.choices=o.choices,Object.assign(t.entitySetsFlat,o.entitySetsFlat)),r=e.servicePath,n=e.systemName?.value}return t.choices.length>0},name:Ol.toggleSelection,type:"confirm",message:It("prompts.toggleSelection.message"),labelTrue:It("prompts.toggleSelection.labelTrue"),labelFalse:It("prompts.toggleSelection.labelFalse"),default:!1,validate:o=>(o!==i&&(t.choices.forEach(a=>{if(a.disabled)return;let u=a.value;a.checked=o===!1?u.entity.defaultSelected:!1}),i=o),!0)}}function qZn(e,t,r,n){let i=[],s,o=0,a=u=>({when:async()=>{let c=t.referencedEntities?.listEntity.semanticKeys[u],l=!!c?.name&&c.name!=="IsActiveEntity";return l&&u>o&&(o=u),l},name:`entityKeyIdx:${u}`,message:()=>It("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:It("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,f4t.includes(c))return It("prompts.entityKey.validation.invalidKeyValueChars",{chars:f4t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return It("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!MZn.test(h.trim()))return It("prompts.entityKey.validation.invalidGuidValue");f.value=c.trim()}else f.value=c.trim();let p=c.split(",");if(f?.type&&!["Edm.UUID","Edm.Guid"].includes(f.type)){for(let d of p)if(d.split("-").length>2)return f&&delete f.value,It("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[Ol.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await p4t(l,r,t),typeof s=="string")return s;n.odata=s.odataQueryResult}return!0}});for(let u=0;u<e;u++)i.push(a(u));return i}function jZn(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:Ol.skipDataDownload,type:"checkbox",message:It("prompts.skipDataDownload.message"),guiOptions:{hint:It("prompts.skipDataDownload.hint")},default:!1,choices:[{name:It("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function VZn(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await G8t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:Ol.updateMainServiceMetadata,type:"confirm",message:It("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:vTe.Severity.error}}}}function h4t(e){let t=[],r=n=>[{name:`${n.entitySetName}/${n.nodeProperty}/source`,type:"list",message:`Source: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))},{name:`${n.entitySetName}/${n.nodeProperty}/target`,type:"list",message:`Target: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))}];return e.forEach(n=>{!n.parentProperty&&n.missingReferentialConstraints?.navPropName&&t.push(...r(n))}),t}var E4t=be(Oy()),_4t=be(Dy());var S4t=be(v4t()),b4t=require("node:path");function T4t(e,t,r){wu.resetExternalServiceCache();let n=iei(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:It("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return wu.resetExternalServiceCache(),!0;let a=await nei(o,r),u=(0,S4t.default)(i,a);return i.length=0,i.push(...u),await rei(i,r),!0}}],valueHelpData:i}}async function rei(e,t){let r=[],n={transformResponse:s=>typeof s=="string"?JSON.parse(s):s},i=e.map(async s=>{let o=s,[a]=o.path.split(";");wu.externalServiceRequestCache[a]??=[];let l=(0,E4t.convert)((0,_4t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(wu.externalServiceRequestCache[a].includes(p))return;wu.externalServiceRequestCache[a].push(p);let d=await t.get((0,b4t.join)(o.path,p),n);o.entityData=o.entityData??[],o.entityData?.push({entitySetName:p,items:d.data.value})});await Promise.allSettled(l),o.entityData&&r.push(o)});return await Promise.allSettled(i),r}async function nei(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function iei(e,t){let r=fM(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(F8t.includes(s.target))continue;let[o]=s.value.split(";"),a=s.target.split("/").pop();a&&(n[o]??={},n[o][a]??=[],n[o][a].push(s))}else s.type==="code-list"&&(n[s.value]??={},n[s.value]["Code list"]??=[],n[s.value]["Code list"].push(s));let i=[];for(let s of Object.values(n))for(let[o,a]of Object.entries(s)){let u=a.map(c=>{if(c.type==="value-list")return c.target.replace(/\/[^/]*$/,"");if(c.type==="code-list"&&c.collectionPath)return c.collectionPath}).filter(c=>c!==void 0);i.push({name:`${o} (${u.join()})`,value:a})}return i.sort((s,o)=>s.name.localeCompare(o.name))}var lr=class e extends x4t.default{vscode;appWizard;static _logger=d4;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),hEe(this.env,!0),this.options.force=!0,this.prompts=new R7.Prompts([{description:It("steps.odataDownloader.description"),name:It("steps.odataDownloader.name")},{description:It("steps.valueHelpSelection.description"),name:It("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(It("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await S_e(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await va.initTelemetrySettings(),va.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await d4t(this.options?.data),s=await this.prompt(i);if(this.state.entityOData=r.odata,this.state.entityPropertyToEntitySet=t.relatedEntityChoices.entitySetsFlat,this.state.appRootPath=t.appAccess?.getAppRoot(),this.state.mainServicePath=n.servicePath,this.state.mainServiceName=t.appAccess?.app.mainService,this.state.appEntities=t.referencedEntities,this.state.appRootPath){this.state.mockServerConfig=await xx(this.state.appRootPath);let o;this.state.mockServerConfig?.services&&(e.logger.debug(`Mock config: ${JSON.stringify(this.state.mockServerConfig)}`),o=this.state.mockServerConfig.services.find(a=>a.urlPath.replaceAll(/(^\/)|(\/$)/g,"")===this.state.mainServicePath?.replaceAll(/(^\/)|(\/$)/g,""))),this.state.mockDataRootPath=o?.mockdataPath??(0,e0.join)(ai.Webapp,ai.LocalService,ai.Mockdata)}if(this.state.updateMainServiceMetadata=s[Ol.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[Ol.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof Va){let{questions:o,valueHelpData:a}=T4t(n.servicePath,n.metadata,n.connectedSystem?.serviceProvider);await this.prompt(o),this.state.valueHelpData=a}}catch(t){e.logger.error(t),this._exitOnError(t)}}async writing(){if(this.state.appRootPath){if(this.state.entityOData&&this.state.entityPropertyToEntitySet&&this.state.appEntities)try{let t=Date.now();va.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot((0,e0.join)(this.state.appRootPath));let r=hTe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(It("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON((0,e0.join)(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=(0,e0.join)(this.state.mockDataRootPath,`${i.entitySetName}.js`),o=this.destinationPath(s),{navPropName:a,constraints:u}=i.missingReferentialConstraints;if(this.fs.exists(o)){let c=this.fs.read(o),l=H8t(c,a,u);l!==c?(this.writeDestination(s,l),e.logger.info(`Updated referential constraint file: ${i.entitySetName}.js`)):e.logger.debug(`Referential constraint for '${a}' already present in ${i.entitySetName}.js \u2014 skipping`)}else{let c=$8t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),va.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),va.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(It("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();va.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=(0,e0.join)(this.state.appRootPath,ai.Webapp);if(await M4(this.fs,r,this.state.valueHelpData,this.state.mainServiceName,this.state.mainServicePath),this.state.mockServerConfig){let n={webappPath:r,packageJsonConfig:{skip:!0},ui5MockYamlConfig:{overwrite:!0}};n.ui5MockYamlConfig&&this.state.mainServiceName&&(n.ui5MockYamlConfig.resolveExternalServiceReferences={[this.state.mainServiceName]:!0},await m4(this.state.appRootPath,n,this.fs))}va.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfExternalServices:`${this.state.valueHelpData.length}`})}catch(t){e.logger.error(t),va.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(It("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=(0,e0.join)(this.state.appRootPath,ai.Webapp,ai.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,A4t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[Ol.relatedEntitySelection]??[]).map(o=>o.entity.entitySetName)]),s=t.referencedEntities?.hierarchyEntities?.filter(o=>!o.parentProperty&&o.missingReferentialConstraints&&i.has(o.entitySetName))??[];if(s.length>0){this.prompts.splice(1,0,[{name:It("steps.addConstraints.name"),description:It("steps.addConstraints.description")}]);let o=h4t(s),a=await this.prompt(o),u=[t.referencedEntities?.listEntity,...t.referencedEntities?.pageObjectEntities??[]];s.forEach(c=>{let l=a[`${c.entitySetName}/${c.nodeProperty}/source`],f=a[`${c.entitySetName}/${c.nodeProperty}/target`];if(l&&f){c.missingReferentialConstraints.constraints=[{sourceProperty:l,targetProperty:f}],c.parentProperty=l;let p=u.find(d=>d?.entitySetName===c.entitySetName)?.entityType;c.parentPropertyType=p?.entityProperties.find(d=>d.name===l)?.type??"Edm.String"}})}}_exitOnError(t){throw kc()!==cn.cli&&this.appWizard?.showError(t,R7.MessageType.notification),new Error(t)}_configureLogging(t,r,n){let i=new p4(this.rootGeneratorName(),this.log,t,r,n);return i.info(It("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};
|
|
733
|
+
${s}${e.slice(o)}`:e}var e2=be(W8t()),r4t=require("node:fs/promises"),n4t=require("node:path");var z8t=require("node:crypto"),K8t=be(k8());var Y8t={name:"@sap-ux/generator-odata-downloader",displayName:"Fiori Elements Data Downloader",description:"Yeoman generator that supports download of app data, typically for mock data server use.",version:"0.3.10",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/generator-odata-downloader"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-download"},license:"Apache-2.0",main:"generators/app/index.js",keywords:["yeoman-generator"],scripts:{build:"npm-run-all clean bundle:prod",compile:"tsc --build",clean:"rimraf --glob generators prebuilds test/test-output coverage *.tsbuildinfo",watch:"tsc --watch",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",bundle:"node esbuild.mjs","bundle:dev":"pnpm clean && node esbuild.mjs --development && pnpm pack","bundle:prod":"node esbuild.mjs --production"},files:["LICENSE","generators","!generators/*.map","!generators/**/*.map","prebuilds","yeoman.png"],devDependencies:{"@jest/globals":"30.3.0"},dependencies:{"@sap-devx/yeoman-ui-types":"1.25.0","@sap-ux/annotation-converter":"0.10.21","@sap-ux/axios-extension":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-generator-shared":"workspace:*","@sap-ux/inquirer-common":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/mockserver-config-writer":"workspace:*","@sap-ux/odata-service-inquirer":"workspace:*","@sap-ux/odata-service-writer":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/store":"workspace:*","@sap-ux/telemetry":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/vocabularies-types":"0.15.0","@sap/ux-specification":"1.144.0","@types/inquirer":"8.2.6","@types/yeoman-generator":"5.2.14","@vscode-logging/logger":"2.0.9",deepmerge:"4.3.1",i18next:"25.10.10",inquirer:"8.2.7","odata-query":"8.0.5","os-name":"4.0.1","prettify-xml":"1.2.0",rimraf:"6.1.3","yeoman-generator":"5.10.0"},engines:{node:">=22.x"}};var EZn="@sap-ux/odata-download-sub-generator",_Zn="0a65e45d-6bf4-421d-b845-61e888c50e9e",va=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=(0,z8t.randomUUID)(),lr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:EZn,version:Y8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:_Zn,...t};try{await AL(r)}catch(n){lr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=It("telemetry.unknownOs");try{r=(0,K8t.default)()}catch{}this._telemetryData={Platform:Vr()?"SBAS":"VSCode",OperatingSystem:r,SessionId:this._sessionId}}return this._telemetryData=Object.assign(this._telemetryData,t),this._telemetryData}static prepareTelemetryEvent(t,r){return{eventName:t,properties:r,measurements:{}}}static async sendTelemetry(t,r){let n=this.createTelemetryData(r),i=this.prepareTelemetryEvent(t,n);await ic.getTelemetryClient().reportEvent(i,Pi.NoSampling)}};var SZn=["eq","ne","gt","ge","lt","le"],O7=["and","or","not"],bZn=["any","all"],TZn=["startswith","endswith","contains","matchespattern"],AZn=["expand","levels","select","skip","top","count","orderby","filter"],X8t=/\((.*)\)/,J8t=/(?!indexof)\((\w+)\)/;var sm="";function gTe({select:e,search:t,skiptoken:r,format:n,top:i,skip:s,filter:o,transform:a,orderBy:u,key:c,count:l,expand:f,action:p,func:d}={}){let h="",g=[],_={};if(c!=null&&(h+=`(${ad(c,g)})`),(o||typeof l=="object")&&(_.$filter=D7(typeof l=="object"?l:o,g)),a&&(_.$apply=Z8t(a)),f&&(_.$expand=P7(f)),u&&(_.$orderby=yTe(u)),l&&(typeof l=="boolean"?_.$count=!0:h+="/$count"),typeof i=="number"&&(_.$top=i),typeof s=="number"&&(_.$skip=s),p&&(h+=`/${p}`),d){if(typeof d=="string")h+=`/${d}`;else if(typeof d=="object"){let[S]=Object.keys(d),T=ad(d[S],g);h+=`/${S}`,T!==""&&(h+=`(${T})`)}}return g.length>0&&Object.assign(_,g.reduce((S,T)=>Object.assign(S,{[`@${T.name}`]:ad(T.value)}),{})),PZn(h,{$select:e,$search:t,$skiptoken:r,$format:n,..._})}function mTe(e,t,r=[]){return`${e} eq ${ad(t,r)}`}function D7(e={},t=[],r=""){return(Array.isArray(e)?e:[e]).reduce((s,o)=>{if(o){let a=n(o,t,r);a&&s.push(a)}return s},[]).join(" and ");function n(s={},o=[],a=""){let u="";return typeof s=="string"?u=s:s&&typeof s=="object"&&(u=Object.keys(s).reduce((c,l)=>{let f=s[l];if(f===void 0)return c;let p="";if(a?l===sm?p=a:J8t.test(l)?p=l.replace(J8t,(d,h)=>h.trim()===sm?`(${a})`:`(${a}/${h.trim()})`):X8t.test(l)?p=l.replace(X8t,(d,h)=>h.trim()===sm?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===sm&&Array.isArray(f))return c.concat(f.map(d=>mTe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(mTe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>D7(g,o,a)).filter(g=>g).map(g=>O7.indexOf(d)!==-1?`(${g})`:g);h.length&&(O7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(Q8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(O7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(Q8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(mTe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(SZn.indexOf(d)!==-1)c.push(`${p} ${d} ${ad(f[d],o)}`);else if(O7.indexOf(d)!==-1)Array.isArray(f[d])?c.push(f[d].map(h=>"("+n(h,o,p)+")").join(` ${d} `)):c.push("("+n(f[d],o,p)+")");else if(bZn.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${ad(f[d],o)}`);else if(d==="in"){let h=Array.isArray(f[d])?f[d]:f[d].value.map(g=>({type:f[d].type,value:g}));c.push(p+" in ("+h.map(g=>ad(g,o)).join(",")+")")}else if(TZn.indexOf(d)!==-1)c.push(`${d}(${p},${ad(f[d],o)})`);else{let h=n({[d]:f[d]},o,p);h&&c.push(h)}});else throw new Error(`Unexpected value type: ${f}`);return c},[]).join(" and ")),u}function i(s,o,a,u){let c="";if(typeof o=="string"||o instanceof String)c=xZn(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(sm)?(p.hasOwnProperty(sm)||(p[sm]=[]),p[sm].push(d[sm]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function xZn(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function wZn(e){return e=e.replace(/%/g,"%25"),e=e.replace(/\+/g,"%2B"),e=e.replace(/\//g,"%2F"),e=e.replace(/\?/g,"%3F"),e=e.replace(/#/g,"%23"),e=e.replace(/&/g,"%26"),e=e.replace(/'/g,"''"),e}function ad(e,t){if(typeof e=="string")return`'${wZn(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>ad(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(t)&&t.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${ad(n,t)}`).join(",")}return e}function P7(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((t,r,n,i)=>n===0?`$expand=${r}`:n===i.length-1?`${r}(${t})`:`$expand=${r}(${t})`,"");if(Array.isArray(e))return`${e.map(t=>P7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>AZn.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=D7(e[r]);break;case"orderBy":n=yTe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=P7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=P7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function Z8t(e){return(Array.isArray(e)?e:[e]).reduce((t,r)=>{for(let n of Object.keys(r))switch(n){case"aggregate":{let i=r[n];i&&t.push(`aggregate(${CZn(i)})`);break}case"filter":{let i=r[n];if(i){let s=D7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${OZn(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function CZn(e){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?t:Object.keys(t).map(r=>{let n=t[r];if(!n.with&&n.as)return`${r} as ${n.as}`;if(!n.with)throw new Error(`'with' property required for '${r}'`);if(!n.as)throw new Error(`'as' property required for '${r}'`);return`${r} with ${n.with} as ${n.as}`})).join(",")}function OZn(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${Z8t(e.transform)}`),t}function yTe(e,t=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${t}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>yTe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function PZn(e,t){let r=Object.getOwnPropertyNames(t).filter(n=>t[n]!==void 0&&t[n]!=="").map(n=>`${n}=${t[n]}`);return r.length?`${e}?${r.join("&")}`:e}function Q8t(e){return`not (${e.join(" and ")})`}function DZn(e){let t=[];return{expands:e.reduce((n,{entityPath:i})=>{let s=i.split("/"),o=n;return s.forEach((a,u)=>{o.expand||(o.expand={}),o.expand[a]??=u===s.length-1?{}:{expand:{}},o=o.expand[a],t.includes(a)||t.push(a)}),n},{expand:{}}),entityPathParts:t}}function RZn(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=DZn(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);lr.logger.info(It("info.entityFilesToBeGenerated",{entities:a.join(", ")}));let u=e;if(n){let d=[];u.semanticKeys.forEach(x=>{if(x.value!==void 0&&x.value!=="")if(x.type==="Edm.Boolean")d.push(`${x.name} eq ${x.value}`);else{let N=String(x.value).split(","),F=["Edm.UUID","Edm.Guid"].includes(x.type),D=V=>F?V.trim():`'${V.trim()}'`;if(N.length===1)d.push(`${x.name} eq ${D(N[0])}`);else{let V=N.map(z=>`${x.name} eq ${D(z)}`);d.push(`(${V.join(" or ")})`)}}});let h=d.length>0?`,filter(${d.join(" and ")})`:"",g=`$root/${u.entitySetName},${n.qualifier},${n.nodeProperty}`,_=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/${u.entitySetName},HierarchyQualifier='${n.qualifier}',NodeProperty='${n.nodeProperty}')`,S=n.isDraft?`$apply=ancestors(${g}${h},keep start)/${_}`:`$apply=${_}`,T=s?gTe(s):"",A=T?`&${T.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return lr.logger.debug(`Query for odata: ${w}`),{query:w}}let c=[];u.semanticKeys.forEach(d=>{if(d.value!==void 0&&d.value!=="")if(["Edm.UUID","Edm.Guid"].includes(d.type)){let g=String(d.value).split(",").map(_=>({[d.name]:{type:"guid",value:_.trim()}}));c.push(g.length===1?g[0]:{or:g})}else if(d.type==="Edm.Boolean")c.push({[d.name]:String(d.value)==="true"});else if(d.type==="Edm.String"){let h=String(d.value).split(","),g=[];h.forEach(_=>{let S=_.trim().split("-");S.length===1?g.push({[d.name]:_.trim()}):S.length===2&&g.push({[d.name]:{ge:S[0].trim(),le:S[1].trim()}})}),c.push(g.length==1?g[0]:{or:g})}else c.push({[d.name]:d.value})});let l={};s&&Object.assign(l,s),c.length>0?Object.assign(l,{filter:c.length===1?c[0]:c,count:!0}):r&&Object.assign(l,{top:r});let f=gTe(l),p=`${u.entitySetName}${f}`;return lr.logger.debug(`Query for odata: ${p}`),{query:p}}function NZn(e,t,r){let n=new Set(["DraftUUID","IsActiveEntity"]),i=[];for(let f of e.semanticKeys){if(f.value===void 0||f.value===""||n.has(f.name))continue;let p=f.keyName??f.name,d=String(f.value).split(",")[0].trim(),h=["Edm.UUID","Edm.Guid"].includes(f.type),g=f.type==="Edm.Boolean";i.push(`${p}=${h||g?d:`'${d}'`}`)}if(i.length===0){lr.logger.debug(`buildNavPropHierarchyQuery: no key values available for '${e.entitySetName}', skipping nav-prop hierarchy query for '${t}'`);return}let s={DraftUUID:"00000000-0000-0000-0000-000000000000",IsActiveEntity:"true"};e.entityType?.keys?.filter(f=>f.name in s).forEach(f=>i.push(`${f.name}=${s[f.name]}`)),lr.logger.debug(`buildNavPropHierarchyQuery: key segment for '${e.entitySetName}': (${i.join(",")})`);let a=`${`${e.entitySetName}(${i.join(",")})`}/${t}`,c=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=${`$root/${a}`},HierarchyQualifier='${r.qualifier}',NodeProperty='${r.nodeProperty}')`,l=`${a}?$apply=${c}`;return lr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function t4t(e,t,r,n,i,s=[]){let o=RZn(e,r,n,i),a=await e4t(t,o.query);for(let u of s){let c=r.find(_=>_.entity.entitySetName===u.entitySetName);if(!c){lr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=NZn(e,c.entity.entityPath,u);if(!l){lr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await e4t(t,l);if(!f.entityData||!a.entityData){lr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}lr.logger.debug(`fetchData: merging ${f.entityData.length} hierarchy records into '${c.entity.entityPath}' expanded items`);let p=c.entity.entityPath,d=u.nodeProperty.split("/")[0],h=f.entityData,g=0;for(let _ of a.entityData){let S=_[p];if(Array.isArray(S))for(let T of S){let A=h.find(w=>u.entityTypeKeys.every(x=>w[x]===T[x]));A&&(T[d]=A[d],g++)}}lr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function e4t(e,t){try{lr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),lr.logger.debug(`OData query request headers: ${JSON.stringify(e.defaults.headers)}`);let r=await e.get(t),n=r?.data?.match(/"@odata\.count":(\d+)/)?.[1];return lr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=It("errors.odataQueryError",{error:r});return lr.logger.error(n),{error:n}}}var wu=class e{static externalServiceRequestCache={};static entityTypeRefFacetCache={};static resetExternalServiceCache(t){if(t){delete e.externalServiceRequestCache[t];return}e.externalServiceRequestCache={}}static resetRefFacetCache(){e.entityTypeRefFacetCache={}}static resetServiceCaches(){e.resetExternalServiceCache(),e.resetRefFacetCache()}};async function i4t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=lr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();va.sendTelemetry("ODATA_DOWNLOAD_SEND_QUERY",{time:Date()});let s=t.referencedEntities.hierarchyEntities?.find(u=>u.entitySetName===t.referencedEntities.listEntity.entitySetName),o=t.referencedEntities.hierarchyEntities?.filter(u=>u.entitySetName!==t.referencedEntities.listEntity.entitySetName&&r.some(c=>c.entity.entitySetName===u.entitySetName))??[],{odataResult:a}=await t4t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return va.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),lr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return va.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return It("errors.dataNotFetched")}function s4t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type===e2.UIAnnotationTypes.ReferenceFacet&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type===e2.UIAnnotationTypes.CollectionFacet&&t.push(...s4t(r))}),t}function IZn(e){if(wu.entityTypeRefFacetCache[e.name])return wu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type===e2.UIAnnotationTypes.ReferenceFacet&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type===e2.UIAnnotationTypes.CollectionFacet&&t.push(...s4t(r))}),wu.entityTypeRefFacetCache[e.name]=t,t??[]}function o4t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?IZn(e.entityType):[];for(let u of o){let c=u.entityPath,l=i??e;if(u.entityType?.name===l?.entityType?.name||t.includes(c))continue;let f=t.concat(`${t?"/":""}${c}`);u.navPropEntities&&u.navPropEntities.length>0&&Object.assign(s,o4t(u,f,r,n,i??e).entitySetsFlat);let p={fullPath:f,entity:{entityPath:u.entityPath,entitySetName:u.entitySetName,defaultSelected:a.includes(u.entityPath)||!!n?.includes(f)}},d=`${f}`;r||(r=[]),r.push({name:d,value:p,checked:p.entity.defaultSelected}),s[f]=u.entitySetName}}return{entitySetsFlat:s,choices:r}}function a4t(e,t){let r=t?.map(n=>{let i=n.page?.contextPath??n.page?.routePattern?.replace(":?query:","").replaceAll(/\(\{[^}]*\}\)/g,"");return i?.startsWith(`/${e.entityPath}/`)?i.replace(`/${e.entityPath}/`,""):i}).filter(n=>n!==void 0);if(e.navPropEntities){let n=o4t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function u4t(e,t){let n=(await Po.newInstance(await(0,r4t.readFile)((0,n4t.join)(e,St.Ui5Yaml),"utf-8"))).getBackendConfigsFromFioriToolsProxyMiddleware()[0],i;if(n){let s=n.url;if(n.connectPath){let o=n.connectPath.startsWith("/")?n.connectPath:`/${n.connectPath}`;s=new URL(o,n.url).href}i=Vr()?n?.destination:await j8t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function c4t(e){let t=await pL(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(lr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),It("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var l4t,LZn=(...e)=>new Promise(t=>{clearTimeout(l4t),l4t=setTimeout(async()=>t(await i4t(...e)),1e3)}),Ol={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},MZn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,f4t=["."];async function p4t(e,t,r){let n=!1;if(!r.referencedEntities?.listEntity.semanticKeys.every((a,u)=>(a.name!=="IsActiveEntity"&&!n&&(n=!!a.value),a.value!==void 0&&a.value!==""||!e[`entityKeyIdx:${u}`]))||!n)return It("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[Ol.relatedEntitySelection]);let o=await LZn(t,r,s);return o}function FZn(e){return wu.resetServiceCaches(),e.appAccess=void 0,e.referencedEntities=void 0,e.servicePath=void 0,e.systemName&&(e.systemName.value=void 0),e.relatedEntityChoices.choices=[],e.relatedEntityChoices.entitySetsFlat={},e}async function d4t(e){let t=[],r={appAccess:void 0,referencedEntities:void 0,servicePath:void 0,systemName:{value:void 0},connectPath:{value:void 0},relatedEntityChoices:{choices:[],entitySetsFlat:{}}},n=[],i=UZn(r,n,e?.appPath),s=await ZGt({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:Kn.v4}},kc()!==cn.cli,lr.logger);s.prompts=Ds(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=BZn(r,r.relatedEntityChoices),u=qZn(5,r,s.answers,o),c=kZn(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,VZn(s.answers,r),jZn(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function UZn(e,t,r){return{type:"input",guiType:"folder-browser",name:Ol.appSelection,message:It("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:It("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,FZn(e);let i;try{i=await Q5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),lr.logger.error(It("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${It("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${It("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return It("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await c4t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await u4t(i.app.appRoot,s);return a&&(e.servicePath=a,t.push(a)),e.systemName&&(e.systemName.value=u),e.connectPath&&(e.connectPath.value=a),!0}}}function kZn(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:Ol.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:It("prompts.relatedEntitySelection.message"),choices:()=>e.choices,validate:async(s,o)=>{if(e.choices.forEach(a=>{a.disabled||(a.checked=s.some(u=>u.fullPath===a.value.fullPath))}),o&&!o[Ol.skipDataDownload]?.[0]){if(i=await p4t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:It("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:vTe.Severity.information}}}}function BZn(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=a4t(e.referencedEntities.listEntity,e.referencedEntities.pageObjectEntities);o&&(t.choices=o.choices,Object.assign(t.entitySetsFlat,o.entitySetsFlat)),r=e.servicePath,n=e.systemName?.value}return t.choices.length>0},name:Ol.toggleSelection,type:"confirm",message:It("prompts.toggleSelection.message"),labelTrue:It("prompts.toggleSelection.labelTrue"),labelFalse:It("prompts.toggleSelection.labelFalse"),default:!1,validate:o=>(o!==i&&(t.choices.forEach(a=>{if(a.disabled)return;let u=a.value;a.checked=o===!1?u.entity.defaultSelected:!1}),i=o),!0)}}function qZn(e,t,r,n){let i=[],s,o=0,a=u=>({when:async()=>{let c=t.referencedEntities?.listEntity.semanticKeys[u],l=!!c?.name&&c.name!=="IsActiveEntity";return l&&u>o&&(o=u),l},name:`entityKeyIdx:${u}`,message:()=>It("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:It("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,f4t.includes(c))return It("prompts.entityKey.validation.invalidKeyValueChars",{chars:f4t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return It("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!MZn.test(h.trim()))return It("prompts.entityKey.validation.invalidGuidValue");f.value=c.trim()}else f.value=c.trim();let p=c.split(",");if(f?.type&&!["Edm.UUID","Edm.Guid"].includes(f.type)){for(let d of p)if(d.split("-").length>2)return f&&delete f.value,It("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[Ol.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await p4t(l,r,t),typeof s=="string")return s;n.odata=s.odataQueryResult}return!0}});for(let u=0;u<e;u++)i.push(a(u));return i}function jZn(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:Ol.skipDataDownload,type:"checkbox",message:It("prompts.skipDataDownload.message"),guiOptions:{hint:It("prompts.skipDataDownload.hint")},default:!1,choices:[{name:It("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function VZn(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await G8t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:Ol.updateMainServiceMetadata,type:"confirm",message:It("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:vTe.Severity.error}}}}function h4t(e){let t=[],r=n=>[{name:`${n.entitySetName}/${n.nodeProperty}/source`,type:"list",message:`Source: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))},{name:`${n.entitySetName}/${n.nodeProperty}/target`,type:"list",message:`Target: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))}];return e.forEach(n=>{!n.parentProperty&&n.missingReferentialConstraints?.navPropName&&t.push(...r(n))}),t}var E4t=be(Oy()),_4t=be(Dy());var S4t=be(v4t()),b4t=require("node:path");function T4t(e,t,r){wu.resetExternalServiceCache();let n=iei(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:It("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return wu.resetExternalServiceCache(),!0;let a=await nei(o,r),u=(0,S4t.default)(i,a);return i.length=0,i.push(...u),await rei(i,r),!0}}],valueHelpData:i}}async function rei(e,t){let r=[],n={transformResponse:s=>typeof s=="string"?JSON.parse(s):s},i=e.map(async s=>{let o=s,[a]=o.path.split(";");wu.externalServiceRequestCache[a]??=[];let l=(0,E4t.convert)((0,_4t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(wu.externalServiceRequestCache[a].includes(p))return;wu.externalServiceRequestCache[a].push(p);let d=await t.get((0,b4t.join)(o.path,p),n);o.entityData=o.entityData??[],o.entityData?.push({entitySetName:p,items:d.data.value})});await Promise.allSettled(l),o.entityData&&r.push(o)});return await Promise.allSettled(i),r}async function nei(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function iei(e,t){let r=fM(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(F8t.includes(s.target))continue;let[o]=s.value.split(";"),a=s.target.split("/").pop();a&&(n[o]??={},n[o][a]??=[],n[o][a].push(s))}else s.type==="code-list"&&(n[s.value]??={},n[s.value]["Code list"]??=[],n[s.value]["Code list"].push(s));let i=[];for(let s of Object.values(n))for(let[o,a]of Object.entries(s)){let u=a.map(c=>{if(c.type==="value-list")return c.target.replace(/\/[^/]*$/,"");if(c.type==="code-list"&&c.collectionPath)return c.collectionPath}).filter(c=>c!==void 0);i.push({name:`${o} (${u.join()})`,value:a})}return i.sort((s,o)=>s.name.localeCompare(o.name))}var lr=class e extends x4t.default{vscode;appWizard;static _logger=d4;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),hEe(this.env,!0),this.options.force=!0,this.prompts=new R7.Prompts([{description:It("steps.odataDownloader.description"),name:It("steps.odataDownloader.name")},{description:It("steps.valueHelpSelection.description"),name:It("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(It("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await S_e(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await va.initTelemetrySettings(),va.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await d4t(this.options?.data),s=await this.prompt(i);if(this.state.entityOData=r.odata,this.state.entityPropertyToEntitySet=t.relatedEntityChoices.entitySetsFlat,this.state.appRootPath=t.appAccess?.getAppRoot(),this.state.mainServicePath=n.servicePath,this.state.mainServiceName=t.appAccess?.app.mainService,this.state.appEntities=t.referencedEntities,this.state.appRootPath){this.state.mockServerConfig=await xx(this.state.appRootPath);let o;this.state.mockServerConfig?.services&&(e.logger.debug(`Mock config: ${JSON.stringify(this.state.mockServerConfig)}`),o=this.state.mockServerConfig.services.find(a=>a.urlPath.replaceAll(/(^\/)|(\/$)/g,"")===this.state.mainServicePath?.replaceAll(/(^\/)|(\/$)/g,""))),this.state.mockDataRootPath=o?.mockdataPath??(0,e0.join)(ai.Webapp,ai.LocalService,ai.Mockdata)}if(this.state.updateMainServiceMetadata=s[Ol.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[Ol.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof Va){let{questions:o,valueHelpData:a}=T4t(n.servicePath,n.metadata,n.connectedSystem?.serviceProvider);await this.prompt(o),this.state.valueHelpData=a}}catch(t){e.logger.error(t),this._exitOnError(t)}}async writing(){if(this.state.appRootPath){if(this.state.entityOData&&this.state.entityPropertyToEntitySet&&this.state.appEntities)try{let t=Date.now();va.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot((0,e0.join)(this.state.appRootPath));let r=hTe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(It("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON((0,e0.join)(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=(0,e0.join)(this.state.mockDataRootPath,`${i.entitySetName}.js`),o=this.destinationPath(s),{navPropName:a,constraints:u}=i.missingReferentialConstraints;if(this.fs.exists(o)){let c=this.fs.read(o),l=H8t(c,a,u);l!==c?(this.writeDestination(s,l),e.logger.info(`Updated referential constraint file: ${i.entitySetName}.js`)):e.logger.debug(`Referential constraint for '${a}' already present in ${i.entitySetName}.js \u2014 skipping`)}else{let c=$8t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),va.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),va.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(It("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();va.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=(0,e0.join)(this.state.appRootPath,ai.Webapp);if(await M4(this.fs,r,this.state.valueHelpData,this.state.mainServiceName,this.state.mainServicePath),this.state.mockServerConfig){let n={webappPath:r,packageJsonConfig:{skip:!0},ui5MockYamlConfig:{overwrite:!0}};n.ui5MockYamlConfig&&this.state.mainServiceName&&(n.ui5MockYamlConfig.resolveExternalServiceReferences={[this.state.mainServiceName]:!0},await m4(this.state.appRootPath,n,this.fs))}va.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfExternalServices:`${this.state.valueHelpData.length}`})}catch(t){e.logger.error(t),va.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(It("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=(0,e0.join)(this.state.appRootPath,ai.Webapp,ai.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,A4t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[Ol.relatedEntitySelection]??[]).map(o=>o.entity.entitySetName)]),s=t.referencedEntities?.hierarchyEntities?.filter(o=>!o.parentProperty&&o.missingReferentialConstraints&&i.has(o.entitySetName))??[];if(s.length>0){this.prompts.splice(1,0,[{name:It("steps.addConstraints.name"),description:It("steps.addConstraints.description")}]);let o=h4t(s),a=await this.prompt(o),u=[t.referencedEntities?.listEntity,...t.referencedEntities?.pageObjectEntities??[]];s.forEach(c=>{let l=a[`${c.entitySetName}/${c.nodeProperty}/source`],f=a[`${c.entitySetName}/${c.nodeProperty}/target`];if(l&&f){c.missingReferentialConstraints.constraints=[{sourceProperty:l,targetProperty:f}],c.parentProperty=l;let p=u.find(d=>d?.entitySetName===c.entitySetName)?.entityType;c.parentPropertyType=p?.entityProperties.find(d=>d.name===l)?.type??"Edm.String"}})}}_exitOnError(t){throw kc()!==cn.cli&&this.appWizard?.showError(t,R7.MessageType.notification),new Error(t)}_configureLogging(t,r,n){let i=new p4(this.rootGeneratorName(),this.log,t,r,n);return i.info(It("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};
|
|
734
734
|
/*! Bundled license information:
|
|
735
735
|
|
|
736
736
|
mime-db/index.js:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sap-ux/generator-odata-downloader",
|
|
3
3
|
"displayName": "Fiori Elements Data Downloader",
|
|
4
4
|
"description": "Yeoman generator that supports download of app data, typically for mock data server use.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.10",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"yeoman-generator": "5.10.0",
|
|
47
47
|
"@sap-ux/axios-extension": "2.0.2",
|
|
48
48
|
"@sap-ux/btp-utils": "2.0.2",
|
|
49
|
-
"@sap-ux/
|
|
50
|
-
"@sap-ux/
|
|
49
|
+
"@sap-ux/fiori-generator-shared": "1.0.9",
|
|
50
|
+
"@sap-ux/inquirer-common": "1.0.9",
|
|
51
51
|
"@sap-ux/logger": "1.0.1",
|
|
52
|
-
"@sap-ux/mockserver-config-writer": "1.0.
|
|
53
|
-
"@sap-ux/odata-service-inquirer": "3.0.
|
|
54
|
-
"@sap-ux/odata-service-writer": "1.0.
|
|
55
|
-
"@sap-ux/project-access": "2.1.
|
|
56
|
-
"@sap-ux/telemetry": "1.0.7",
|
|
52
|
+
"@sap-ux/mockserver-config-writer": "1.0.6",
|
|
53
|
+
"@sap-ux/odata-service-inquirer": "3.0.9",
|
|
54
|
+
"@sap-ux/odata-service-writer": "1.0.6",
|
|
55
|
+
"@sap-ux/project-access": "2.1.2",
|
|
57
56
|
"@sap-ux/store": "2.0.1",
|
|
58
|
-
"@sap-ux/
|
|
57
|
+
"@sap-ux/telemetry": "1.0.8",
|
|
58
|
+
"@sap-ux/ui5-config": "1.0.3"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22.x"
|