@sap-ux/generator-odata-downloader 0.3.1 → 0.3.3
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
|
@@ -656,7 +656,7 @@ PGHZoN9jcvvvWDLUGtJkEotMgdFpEA2XWR83H4fVFVc=
|
|
|
656
656
|
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"]&&_Q({msg:c.headers["sap-message"],log:this.log,host:u,isDest:this.isDest}),n)SQ({error:bQ(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 rP({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"]&&_Q({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 rP({error:o,host:i,log:this.log}),o}}getAbapFrontendUrl(){let t=new URL(this.publicUrl);return lgr.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=sUe(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>${sUe(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}}};import{readFileSync as dgr}from"node:fs";import{URLSearchParams as YQ}from"node:url";var aUe=je(HQ(),1),XQ;(function(e){e.ON_PREMISE="onPremise",e.CLOUD_READY="cloudReady"})(XQ||(XQ={}));function zQ(e){return typeof e!="string"?`apps/${e.reference}/appVariants/${e.id}/`:e}function hgr(e){return e.BYTES_PER_ELEMENT!==void 0}var oUe=e=>decodeURIComponent(e.toString());function KQ(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}var QU="/dta_folder/",J0=class extends Ca{static PATH="/sap/bc/lrep";log;async getCsrfToken(){try{return await this.get("/actions/getcsrftoken/")}catch(t){throw gc(t)&&this.tryLogResponse(t.response),t}}async mergeAppDescriptorVariant(t,r){let n="/appdescr_variant_preview/",i=new YQ(this.defaults?.params);r&&i.append("workspacePath",r);try{let s=await this.put(n,t,{paramsSerializer:oUe,params:i,headers:{"Content-Type":"application/zip"}});return JSON.parse(s.data)}catch(s){throw gc(s)&&this.tryLogResponse(s.response),s}}async isExistingVariant(t,r="CUSTOMER_BASE"){try{let n=await this.get(QU,{params:{name:zQ(t),layer:r,timestamp:Date.now()}});return this.tryLogResponse(n),n}catch(n){if(gc(n)&&(this.tryLogResponse(n.response),n.response?.status===404))return n.response;throw n}}async deploy(t,r){let n=hgr(t)?t:dgr(t),i=await this.isExistingVariant(r.namespace),s={name:zQ(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:QU,data:n,params:s,headers:{"Content-Type":"application/octet-stream"}});return this.tryLogResponse(o,"Deployment successful."),o}catch(o){throw rP({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:zQ(t.namespace),layer:t.layer??"CUSTOMER_BASE"};t.transport&&(n.changelist=t.transport);try{let i=await this.delete(QU,{params:n});return this.tryLogResponse(i,"Undeployment successful."),i}catch(i){throw this.log.error("Undeployment failed"),this.log.debug(i),gc(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:KQ});return this.tryLogResponse(n,`Successfully fetched adaptations for app ${t}`),n.data}catch(n){throw gc(n)&&this.tryLogResponse(n.response),n}}async getKeyUserData(t,r){let n=new YQ(this.defaults?.params);n.append("adaptationId",encodeURIComponent(r));try{let i=await this.get(`/flex/keyuserdata/${t}`,{params:n,paramsSerializer:oUe,transformResponse:KQ});return this.tryLogResponse(i,`Successfully fetched key user data for component ${t} and ${r} adaptation.`),i.data}catch(i){throw gc(i)&&this.tryLogResponse(i.response),i}}async getFlexVersions(t,r=2,n="EN"){try{let i=new YQ(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:KQ});return this.tryLogResponse(s,`Successfully fetched flex versions for component ${t}`),s.data}catch(i){throw gc(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(`${QU}system_info`,{params:i,paramsSerializer:o=>aUe.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"?io.Error:io.Info;this.log.log({level:r,message:t.text}),(t.details??[]).forEach(n=>{this.log.log({level:r,message:n})})}};import{join as $yr}from"node:path/posix";var ZU=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 uUe=":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",mgr=uUe+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ggr="["+uUe+"]["+mgr+"]*",ygr=new RegExp("^"+ggr+"$");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 JQ=function(e){let t=ygr.exec(e);return!(t===null||typeof t>"u")};function cUe(e){return typeof e<"u"}var gP=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],tk=["__proto__","constructor","prototype"];var vgr={allowBooleanAttributes:!1,unpairedTags:[]};function rk(e,t){t=Object.assign({},vgr,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=fUe(e,s),s.err)return s}else if(e[s]==="<"){let o=s;if(s++,e[s]==="!"){s=pUe(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]!==`
|
|
657
657
|
`&&e[s]!=="\r";s++)u+=e[s];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),s--),!wgr(u)){let f;return u.trim().length===0?f="Invalid space after '<'.":f="Tag '"+u+"' is an invalid name.",Ai("InvalidTag",f,Wo(e,s))}let c=Sgr(e,s);if(c===!1)return Ai("InvalidAttr","Attributes for '"+u+"' have open quote.",Wo(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=dUe(l,t);if(p===!0)n=!0;else return Ai(p.err.code,p.err.msg,Wo(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.",Wo(e,o));if(r.length===0)return Ai("InvalidTag","Closing tag '"+u+"' has not been opened.",Wo(e,o));{let f=r.pop();if(u!==f.tagName){let p=Wo(e,f.tagStartPos);return Ai("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+u+"'.",Wo(e,o))}r.length==0&&(i=!0)}}else return Ai("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",Wo(e,s));else{let f=dUe(l,t);if(f!==!0)return Ai(f.err.code,f.err.msg,Wo(e,s-l.length+f.err.line));if(i===!0)return Ai("InvalidXml","Multiple possible root nodes found.",Wo(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=pUe(e,s);continue}else if(e[s+1]==="?"){if(s=fUe(e,++s),s.err)return s}else break;else if(e[s]==="&"){let f=Agr(e,s);if(f==-1)return Ai("InvalidChar","char '&' is not expected.",Wo(e,s));s=f}else if(i===!0&&!lUe(e[s]))return Ai("InvalidXml","Extra text at the end",Wo(e,s));e[s]==="<"&&s--}}else{if(lUe(e[s]))continue;return Ai("InvalidChar","char '"+e[s]+"' is not expected.",Wo(e,s))}if(n){if(r.length==1)return Ai("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Wo(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 lUe(e){return e===" "||e===" "||e===`
|
|
658
658
|
`||e==="\r"}function fUe(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.",Wo(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function pUe(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 Egr='"',_gr="'";function Sgr(e,t){let r="",n="",i=!1;for(;t<e.length;t++){if(e[t]===Egr||e[t]===_gr)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 bgr=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function dUe(e,t){let r=ek(e,bgr),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.",yP(r[i]));if(r[i][3]!==void 0&&r[i][4]===void 0)return Ai("InvalidAttr","Attribute '"+r[i][2]+"' is without value.",yP(r[i]));if(r[i][3]===void 0&&!t.allowBooleanAttributes)return Ai("InvalidAttr","boolean attribute '"+r[i][2]+"' is not allowed.",yP(r[i]));let s=r[i][2];if(!xgr(s))return Ai("InvalidAttr","Attribute '"+s+"' is an invalid name.",yP(r[i]));if(!Object.prototype.hasOwnProperty.call(n,s))n[s]=1;else return Ai("InvalidAttr","Attribute '"+s+"' is repeated.",yP(r[i]))}return!0}function Tgr(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 Agr(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,Tgr(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 xgr(e){return JQ(e)}function wgr(e){return JQ(e)}function Wo(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function yP(e){return e.startIndex+e[1].length}var hUe={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"},mUe={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"},gUe={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"},yUe={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"},vUe={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"},EUe={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:"<"},_Ue={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"},SUe={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"},bUe={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"},TUe={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"},nk={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"},AUe={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"},xUe={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"},Cgr={...hUe,...mUe,...gUe,...yUe,...vUe,...EUe,..._Ue,...SUe,...bUe,...TUe,...nk,...AUe,...xUe},vP={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},QQ={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 Ogr=new Set("!?\\\\/[]$%{}^&*()<>|+");function wUe(e){if(e[0]==="#")throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(let t of e)if(Ogr.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function ZQ(...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 Gv="external",ik="base",eZ="all";function Pgr(e){return!e||e===Gv?new Set([Gv]):e===eZ?new Set([eZ]):e===ik?new Set([ik]):Array.isArray(e)?new Set(e):new Set([Gv])}var La=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Dgr=new Set([9,10,13]);function Rgr(e){if(!e)return{xmlVersion:1,onLevel:La.allow,nullLevel:La.remove};let t=e.xmlVersion===1.1?1.1:1,r=La[e.onNCR]??La.allow,n=La[e.nullNCR]??La.remove,i=Math.max(n,La.remove);return{xmlVersion:t,onLevel:r,nullLevel:i}}var Q0=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=Pgr(this._limit.applyLimitsTo??Gv),this._numericAllowed=t.numericAllowed??!0,this._baseMap=ZQ(vP,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=Rgr(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))wUe(r);this._externalMap=ZQ(t)}addExternalEntity(t,r){wUe(t),typeof r=="string"&&r.indexOf("&")===-1&&(this._externalMap[t]=r)}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputMap=ZQ(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=Gv);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=ik}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(eZ)?!0:this._limitTiers.has(t)}_resolveName(t){if(t in this._inputMap)return{value:this._inputMap[t],tier:Gv};if(t in this._externalMap)return{value:this._externalMap[t],tier:Gv};if(t in this._baseMap)return{value:this._baseMap[t],tier:ik}}_classifyNCR(t){return t===0?this._ncrNullLevel:t>=55296&&t<=57343||this._ncrXmlVersion===1&&t>=1&&t<=31&&!Dgr.has(t)?La.remove:-1}_applyNCRAction(t,r,n){switch(t){case La.allow:return String.fromCodePoint(n);case La.remove:return"";case La.leave:return;case La.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<La.remove)return;let s=i===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,i);return this._applyNCRAction(s,t,n)}};var CUe=e=>gP.includes(e)?"__"+e:e,Ngr={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:CUe};function Igr(e,t){if(typeof e!="string")return;let r=e.toLowerCase();if(gP.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);if(tk.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function OUe(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"}:OUe(!0)}var PUe=function(e){let t=Object.assign({},Ngr,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&&Igr(n,i);return t.onDangerousProperty===null&&(t.onDangerousProperty=CUe),t.processEntities=OUe(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 sk;typeof Symbol!="function"?sk="@@xmlMetadata":sk=Symbol("XML Node Metadata");var Ma=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][sk]={startIndex:r})}static getMetaDataSymbol(){return sk}};var DUe=":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",Lgr=DUe+"\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040",RUe=":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}",Mgr=RUe+"\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040",NUe=(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)}},Fgr=NUe(DUe,Lgr),Ugr=NUe(RUe,Mgr,"u"),kgr=(e="1.0")=>e==="1.1"?Ugr:Fgr;var tZ=(e,{xmlVersion:t="1.0"}={})=>kgr(t).qName.test(e);var _P=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&&$v(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&&$v(t,"!ELEMENT",r)){r+=8;let{index:c}=this.readElementExp(t,r+1);r=c}else if(o&&$v(t,"!ATTLIST",r))r+=8;else if(o&&$v(t,"!NOTATION",r)){r+=9;let{index:c}=this.readNotationExp(t,r+1,this.suppressValidationErr);r=c}else if($v(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=Fa(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(EP(i,{xmlVersion:this.xmlVersion}),r=Fa(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=Fa(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let i=t.substring(n,r);!this.suppressValidationErr&&EP(i,{xmlVersion:this.xmlVersion}),r=Fa(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=Fa(t,r);let o=null,a=null;if(s==="PUBLIC")[r,o]=this.readIdentifierVal(t,r,"publicIdentifier"),r=Fa(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=Fa(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=Fa(t,r);let s="";if(t[r]==="E"&&$v(t,"MPTY",r))r+=4;else if(t[r]==="A"&&$v(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=Fa(t,r);let n=r;for(;r<t.length&&!/\s/.test(t[r]);)r++;let i=t.substring(n,r);for(EP(i,{xmlVersion:this.xmlVersion}),r=Fa(t,r),n=r;r<t.length&&!/\s/.test(t[r]);)r++;let s=t.substring(n,r);if(!EP(s,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${s}"`);r=Fa(t,r);let o="";if(t.substring(r,r+8).toUpperCase()==="NOTATION"){if(o="NOTATION",r+=8,r=Fa(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(),!EP(l,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${l}"`);u.push(l),t[r]==="|"&&(r++,r=Fa(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=Fa(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}}},Fa=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function $v(e,t,r){for(let n=0;n<t.length;n++)if(t[n]!==e[r+n+1])return!1;return!0}function EP(e,t){if(tZ(e,{xmlVersion:t}))return e;throw new Error(`Invalid entity name ${e}`)}var Bgr=/^[-+]?0x[a-fA-F0-9]+$/,qgr=/^0b[01]+$/,jgr=/^0o[0-7]+$/,Vgr=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Ggr={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function nZ(e,t={}){if(t=Object.assign({},Ggr,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&&Bgr.test(r))return rZ(r,16);if(t.binary&&qgr.test(r))return rZ(r,2);if(t.octal&&jgr.test(r))return rZ(r,8);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return Hgr(e,r,t);{let n=Vgr.exec(r);if(n){let i=n[1]||"",s=n[2],o=Wgr(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 Ygr(e,Number(r),t)}var $gr=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Hgr(e,t,r){if(!r.eNotation)return e;let n=t.match($gr);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 Wgr(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 rZ(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 Ygr(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 iZ(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 Hv=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 Z0=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 sZ=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)}},eb=class{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new sZ(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 zgr(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 Kgr(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 SP=class{constructor(t,r){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=eyr,this.parseTextData=Xgr,this.resolveNameSpace=Jgr,this.buildAttributesMap=Zgr,this.isItStopNode=iyr,this.replaceEntitiesValue=ryr,this.readStopNodeData=ayr,this.saveTextToParentTag=nyr,this.addChild=tyr,this.ignoreAttributesFn=iZ(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let n={...vP};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities=="object"?n=this.options.htmlEntities:this.options.htmlEntities===!0&&(n={...QQ,...nk}),this.entityDecoder=new Q0({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 eb,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Z0;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 Hv(o)):o instanceof Hv&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}};function Xgr(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?uZ(e,a.parseTagValue,a.numberParseOptions):e}}function Jgr(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 Qgr=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Zgr(e,t,r,n=!1){let i=this.options;if(n===!0||i.ignoreAttributes!==!0&&typeof e=="string"){let s=ek(e,Qgr),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=IUe(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]=uZ(_,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 eyr=function(e){e=e.replace(/\r\n?/g,`
|
|
659
|
-
`);let t=new Ma("!xml"),r=t,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,s=new _P(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=tb(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=aZ(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 Ma(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=tb(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=tb(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=aZ(e,a,i.removeNSPrefix);if(!l){let I=e.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${I}"`)}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=Kgr(p),f!==t.tagname&&this.matcher.push(f,{},w),f!==d&&h&&(T=this.buildAttributesMap(d,this.matcher,f),T&&(A=zgr(T,i))),f!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let x=a;if(this.isCurrentNodeStopNode){let I="";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,I=D.tagContent}let U=new Ma(f);T&&(U[":@"]=T),U.add(i.textNodeName,I),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,U,this.readonlyMatcher,x)}else{if(S){({tagName:f,tagExp:d}=oZ(i.transformTagName,f,d,i));let I=new Ma(f);T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(f)){let I=new Ma(f);T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=l.closeIndex;continue}else{let I=new Ma(f);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),r=I}n="",a=g}}}else n+=e[a];return t.child};function tyr(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 ryr(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 nyr(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 iyr(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function syr(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 tb(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i+t.length-1}function oyr(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i}function aZ(e,t,r,n=">"){let i=syr(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 ayr(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=oyr(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=tb(e,"?>",r+1,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===45&&e.charCodeAt(r+3)===45)r=tb(e,"-->",r+3,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===91)r=tb(e,"]]>",r,"StopNode is not closed.")-2;else{let a=aZ(e,r,!1);a&&((a&&a.tagName)===t&&a.tagExp[a.tagExp.length-1]!=="/"&&i++,r=a.closeIndex)}}}function uZ(e,t,r){if(t&&typeof e=="string"){let n=e.trim();return n==="true"?!0:n==="false"?!1:nZ(e,r)}else return cUe(e)?e:""}function oZ(e,t,r,n){if(e){let i=e(t);r===t&&(r=i),t=i}return t=IUe(t,n),{tagName:t,tagExp:r}}function IUe(e,t){if(tk.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return gP.includes(e)?t.onDangerousProperty(e):e}var cZ=Ma.getMetaDataSymbol();function uyr(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 lZ(e,t,r,n){return LUe(e,t,r,n)}function LUe(e,t,r,n){let i,s={};for(let o=0;o<e.length;o++){let a=e[o],u=cyr(a);if(u!==void 0&&u!==t.textNodeName){let c=uyr(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=LUe(a[u],t,r,n),l=fyr(c,t);if(Object.keys(c).length===0&&t.alwaysCreateTextNode&&(c[t.textNodeName]=""),a[":@"]?lyr(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[cZ]!==void 0&&typeof c=="object"&&c!==null&&(c[cZ]=a[cZ]),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 cyr(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(n!==":@")return n}}function lyr(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 fyr(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 Gf=class{constructor(t){this.externalEntities={},this.options=PUe(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=rk(t,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new SP(this.options,this.externalEntities),i=n.parseXml(t);return this.options.preserveOrder||i===void 0?i:lZ(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 Ma.getMetaDataSymbol()}};var rb={validate:rk};var Rm=class extends Ca{static ADT_DISCOVERY_SERVICE_PATH="/sap/bc/adt/discovery";schemaStore=new ZU;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(rb.validate(t)!==!0)return null;let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new Gf(r).parse(t,!0);return i.service?i:null}};var Ed=class extends Ca{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 rF(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 bP={UI:"UI",NotClassified:"Not Classified",WebApi:"WEB_API",NotDetermined:"Not Determined"},nb=class extends hm{entitySet;services;isS4Cloud;async listServices(t=!1){return this.services||(this.services=await this.fetchServices(t)),this.services}};var MUe="ServiceCollection",FUe="RecommendedServiceCollection",pyr="((IsSapService%20eq%20true)and(ReleaseStatus%20eq%20%27RELEASED%27))or((IsSapService%20eq%20false))",Nm=class extends nb{static PATH="/sap/opu/odata/IWFND/CATALOGSERVICE;v=2";async determineEntitySet(){let t=await this.document();this.entitySet=t.EntitySets.includes(FUe)?FUe:MUe}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===MUe&&await this.isS4Cloud&&(t.$filter=pyr);let n=(await this.get(`/${this.entitySet}`,{params:t})).odata();if(Of.containsError(n))throw new Of(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 UUe="RecommendedServices",kUe="Services",ib=class extends nb{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"')?UUe:kUe}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.`),Of.containsError(i))throw new Of(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"')?UUe:kUe}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.`),Of.containsError(s))throw new Of(s);return this.mapServices(s,this.entitySet,!0)}getAnnotations(){return Promise.resolve([])}getServiceType(){return Promise.resolve(void 0)}};var TP;(function(e){e.SAP="SAP",e.Customer="CUSTOMER"})(TP||(TP={}));var ti=class extends Ca{log;serviceSchema;static getAdtCatagory(){throw new Error("NEEDS TO BE IMPLEMENTED BY AdtService SUBCLASSES")}attachAdtSchema(t){this.serviceSchema=t}parseResponse(t){if(rb.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0};return new Gf(r).parse(t,!0)}};var AP=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(rb.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new Gf(r).parse(t,!0);return i.settings?i.settings:{}}};var Nke=je(BUe(),1),Gyr=je(Rke(),1);var UP=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 kP=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 BP=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 hb=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 vk=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 qP=class extends Ca{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 qa=class extends Dm{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("",vk);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(AP),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===TP.Customer&&this.atoSettings.operationsType==="C"}getAdtCatalogService(){if(!this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]){let t=this.createService(Rm.ADT_DISCOVERY_SERVICE_PATH,Rm);this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]=t}return this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]}catalog(t){let r;if(t===Er.v2)r=this.services[Nm.PATH]??this.createService(Nm.PATH,Nm);else if(t===Er.v4)r=this.services[ib.PATH]??this.createService(ib.PATH,ib);else throw new Error("not implemented yet");return Object.defineProperty(r,"isAbapCloud",{get:this.isAbapCloud.bind(this)}),r}getUi5AbapRepository(t){let r=t??X0.PATH;return this.services[r]||(this.services[r]=this.createService(r,X0)),this.services[r]}getAppIndex(){return this.services[Ed.PATH]||(this.services[Ed.PATH]=this.createService(Ed.PATH,Ed)),this.services[Ed.PATH]}getLayeredRepository(t){let r=t??J0.PATH;return this.services[r]||(this.services[r]=this.createService(r,J0)),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=qP.PATH;return this.services[t]||(this.services[t]=this.createService(t,qP)),this.services[t]}async getUiServiceGenerator(t){let r=await this.getAdtService(UP);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),hb);return i.configure(n,t,this.getContentType(n)),i}async getODataServiceGenerator(t){let r=await this.getAdtService(kP);if(!r)throw new Error("RAP Generator are not support on this system");let n=await r.getRAPGeneratorConfig(),i=this.createService(this.getServiceUrlFromConfig(n),BP);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=$yr(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,hb)}};var k$e=je(sGe(),1),rp=je(kB(),1);var Hb;(function(e){e.PROXY_URL="HTTP_PROXY",e.H2O_URL="H2O_URL"})(Hb||(Hb={}));var BB;(function(e){e.HTTP="HTTP",e.LDAP="LDAP",e.MAIL="MAIL",e.RFC="RFC"})(BB||(BB={}));var qB;(function(e){e.DEDICATED="Dedicated",e.COMMON="Common"})(qB||(qB={}));var tp;(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"})(tp||(tp={}));var jB;(function(e){e.S4HC="S4HC",e.BTP="BTP"})(jB||(jB={}));var Hte;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(Hte||(Hte={}));var fE;(function(e){e.ODATA_GENERIC="odata_gen",e.ODATA_ABAP="odata_abap",e.DEV_ABAP="dev_abap",e.ABAP_CLOUD="abap_cloud"})(fE||(fE={}));var VB;(function(e){e.FULL_URL="full_url",e.API_MGMT="api_mgmt"})(VB||(VB={}));var TD;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(TD||(TD={}));function L$e(e){return!!(e.WebIDEUsage?.includes("abap")||e["sap-client"]||e["sap-platform"]?.toLocaleLowerCase()==="abap"||e.ProxyType==="OnPremise")}function gOr(e){return!!(e.WebIDEUsage?.includes(fE.ABAP_CLOUD)||e["sap-platform"]?.toLocaleLowerCase()==="abap")}function GB(e){return!!(e.WebIDEUsage?.includes(fE.ODATA_GENERIC)&&!e.WebIDEUsage.includes(fE.ODATA_ABAP))}function Vl(e){return!!(!e.WebIDEAdditionalData?.includes(VB.FULL_URL)&&GB(e))}function Wm(e){return!!(e.WebIDEAdditionalData?.includes(VB.FULL_URL)&&GB(e))}function M$e(e){return!!e.ProxyType.includes(TD.ON_PREMISE)}function F$e(e){return!!e["HTML5.DynamicDestination"]}function yOr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I$e(e,t){let r=` (${t})`;return RegExp(`${yOr(r)}$`).exec(e.trim())?e:`${e} (${t})`}function U$e(e,t){let r=t?` [${t}]`:"",n;return gOr(e)?n=I$e(e.Name,jB.BTP):Wte(e)?n=I$e(e.Name,jB.S4HC):n=e.Name,`${n}${r}`}function Wte(e){return!!(e.WebIDEUsage?.includes(fE.ODATA_ABAP)&&e.Authentication===tp.SAML_ASSERTION&&e.ProxyType===Hte.INTERNET)}function $B(e){return!!e.WebIDEUsage?.includes(fE.ODATA_ABAP)}var Md={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 Yte="abap-cloud-destination-instance",B$e="bas-destination-instance-cred";function Hr(){return!!process.env[Hb.H2O_URL]}async function q$e(e){try{let t=await(0,rp.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 Wb(e,t){let r=`https://${e}.dest`;return t&&t.length>1?new URL(t,r).toString():r}function vOr(e){let[t,...r]=e.split(".");return[t.replace(/-api$/,""),...r].join(".")}async function zte(e){let t={};await wa.get("/reload",{baseURL:process.env[Hb.PROXY_URL]});let r=await wa.get("/api/listDestinations",{baseURL:process.env[Hb.H2O_URL]});return(Array.isArray(r.data)?r.data:[]).forEach(i=>{e?.stripS4HCApiHosts&&Wte(i)&&(i.Host=vOr(i.Host)),i.WebIDEEnabled&&(t[i.Name]=i)}),t}function EOr(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:qB.DEDICATED};return{name:e,description:t,url:new URL(n),type:BB.HTTP,proxyType:TD.INTERNET,basProperties:i,credentials:{authentication:tp.OAUTH2_USER_TOKEN_EXCHANGE,oauth2UserTokenExchange:s}}}async function Kte(e){let t=await(0,rp.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 _Or(e,t,r,n){let i=await Kte(e);return(await(0,rp.apiGetServicesInstancesFilteredByType)(["destination"])).find(a=>a.label===Yte)||(await(0,rp.apiCreateServiceInstance)("destination","lite",Yte,null),n?.info(`New ABAP destination instance ${Yte} created.`)),EOr(i,`Destination generated by App Studio for Cloud Foundry Abap service instance: '${e}', Do not remove.`,t,r)}async function j$e(e,t,r){if(!Hr())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,rp.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 _Or(e,n.uaaCredentials,n.hostUrl,r);await k$e.destinations.createDestination(i),r?.debug(`SAP BTP destination ${JSON.stringify(i,null,2)} created.`);let o=(await zte())?.[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 iHe=je(Qte(),1),sHe=je(Zte(),1),oHe=je(vF(),1),aHe=je(nHe(),1);import{Agent as rPr}from"node:https";import{inspect as nPr}from"node:util";var ere=class extends sHe.HttpsProxyAgent{extraOptions;constructor(t,r){super(t,r),this.extraOptions=r}async connect(t,r){return super.connect(t,{...this.extraOptions,...r})}};function pE(e,t){let r=(0,oHe.default)(t),n={rejectUnauthorized:!r.ignoreCertErrors};r.httpsAgent||(r.httpsAgent=new rPr(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,aHe.getProxyForUrl)(o);return a&&!Hr()&&(s.httpsAgent=new ere(a,n),s.httpAgent=new iHe.HttpProxyAgent(a),s.proxy=!1),s}),i.defaults.headers=i.defaults.headers??{common:{},delete:{},put:{},get:{},post:{},head:{},patch:{}},tFe(i),r.auth?.password&&tUe(i),t.cookies&&t.cookies.split(";").forEach(s=>{i.cookies.addCookie(s.trim())}),mP.isPatchRequired(t.baseURL)&&mP.apply(),i}function uHe(e){return typeof e=="string"?pE(Dm,{baseURL:e}):pE(Dm,e)}function hE(e){return pE(qa,e)}var dE;(function(e){e.Standalone="Standalone",e.EmbeddedSteampunk="EmbeddedSteampunk"})(dE||(dE={}));function tre(e){let t;switch(e.environment){case dE.Standalone:{let{service:r,refreshToken:n,refreshTokenChangedCb:i,cookies:s,...o}=e;t=pE(qa,{baseURL:r.url,cookies:s,...o}),s||(e.service?.uaa?.username&&e.service.uaa.password?rUe(t,r,n,i):WQ({provider:t}));break}case dE.EmbeddedSteampunk:{let{url:r,cookies:n,...i}=e;t=pE(qa,{baseURL:r,cookies:n,...i}),n||WQ({provider:t});break}default:{let r=e;throw new Error(`Unknown environment type supplied: ${nPr(r)}`)}}return t}function cHe(e,t,r){let{cookies:n,...i}=e,s={...i,baseURL:Wb(t.Name,t.Host?new URL(t.Host).pathname:void 0),cookies:n};s.params=s.params??{},s.params.saml2="disabled";let o;if(L$e(t)?(o=pE(qa,s),o.publicUrl=t.Host):o=pE(Dm,s),r){let a=o.interceptors.request.use(async u=>{let c=await q$e(r);return o.defaults.headers.common[B$e]=c,o.interceptors.request.eject(a),u})}return o}var lHe;(function(e){e.FF_SIMPLE="basic"})(lHe||(lHe={}));var fHe;(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"})(fHe||(fHe={}));var ln={vscode:{name:"Visual Studio Code",technical:"VSCode"},bas:{name:"SAP Business Application Studio",technical:"SBAS"},cli:{name:"CLI",technical:"CLI"}};var pHe;(function(e){e.CF="CF",e.ABAP="ABAP"})(pHe||(pHe={}));function iPr(){return!!(process.argv[1]?.includes("yo")||process.stdin.isTTY)}function Ic(){return iPr()?ln.cli:Hr()?ln.bas:ln.vscode}var kt=e=>typeof e=="string",xD=()=>{let e,t,r=new Promise((n,i)=>{e=n,t=i});return r.resolve=e,r.reject=t,r},dHe=e=>e==null?"":""+e,sPr=(e,t,r)=>{e.forEach(n=>{t[n]&&(r[n]=t[n])})},oPr=/###/g,hHe=e=>e&&e.indexOf("###")>-1?e.replace(oPr,"."):e,mHe=e=>!e||kt(e),wD=(e,t,r)=>{let n=kt(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(mHe(e))return{};let s=hHe(n[i]);!e[s]&&r&&(e[s]=new r),Object.prototype.hasOwnProperty.call(e,s)?e=e[s]:e={},++i}return mHe(e)?{}:{obj:e,k:hHe(n[i])}},gHe=(e,t,r)=>{let{obj:n,k:i}=wD(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=wD(e,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=wD(e,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=r},aPr=(e,t,r,n)=>{let{obj:i,k:s}=wD(e,t,Object);i[s]=i[s]||[],i[s].push(r)},XB=(e,t)=>{let{obj:r,k:n}=wD(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},uPr=(e,t,r)=>{let n=XB(e,r);return n!==void 0?n:XB(t,r)},THe=(e,t,r)=>{for(let n in t)n!=="__proto__"&&n!=="constructor"&&(n in e?kt(e[n])||e[n]instanceof String||kt(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):THe(e[n],t[n],r):e[n]=t[n]);return e},mE=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),cPr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},lPr=e=>kt(e)?e.replace(/[&<>"'\/]/g,t=>cPr[t]):e,sre=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}},fPr=[" ",",","?","!",";"],pPr=new sre(20),dPr=(e,t,r)=>{t=t||"",r=r||"";let n=fPr.filter(o=>t.indexOf(o)<0&&r.indexOf(o)<0);if(n.length===0)return!0;let i=pPr.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},CD=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)}},are=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:(kt(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)}},ip=new are,Jb=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])})}},JB=class extends Jb{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):kt(n)&&s?a.push(...n.split(s)):a.push(n)));let u=XB(this.data,a);return!u&&!r&&!n&&t.indexOf(".")>-1&&(t=a[0],r=a[1],n=a.slice(2).join(".")),u||!o||!kt(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),gHe(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)(kt(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=XB(this.data,a)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?THe(u,n,s):u={...u,...n},gHe(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}},AHe={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}},xHe=Symbol("i18next/PATH_KEY");function mPr(){let e=[],t=Object.create(null),r;return t.get=(n,i)=>(r?.revoke?.(),i===xHe?e:(e.push(i),r=Proxy.revocable(n,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Xb(e,t){let{[xHe]:r}=e(mPr()),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 yHe={},rre=e=>!kt(e)&&typeof e!="boolean"&&typeof e!="number",QB=class e extends Jb{constructor(t,r={}){super(),sPr(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ip.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=rre(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&&!dPr(t,n,i);if(o&&!a){let u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:kt(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:kt(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=Xb(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(he=>typeof he=="function"?Xb(he,{...this.options,...i}):String(he));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&&!kt(i.count),x=e.hasDefaultValue(i),I=w?this.pluralResolver.getSuffix(f,i.count,i):"",U=i.ordinal&&w?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=w&&!i.ordinal&&i.count===0,G=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${I}`]||i[`defaultValue${U}`]||i.defaultValue,K=h;A&&!h&&x&&(K=G);let M=rre(K),Q=Object.prototype.toString.apply(K);if(A&&K&&M&&S.indexOf(Q)<0&&!(kt(T)&&Array.isArray(K))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let he=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,K,{...i,ns:u}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(d.res=he,d.usedParams=this.getUsedParamsDetails(i),d):he}if(o){let he=Array.isArray(K),se=he?[]:{},W=he?_:g;for(let $ in K)if(Object.prototype.hasOwnProperty.call(K,$)){let ve=`${W}${o}${$}`;x&&!h?se[$]=this.translate(ve,{...i,defaultValue:rre(G)?G[$]:void 0,joinArrays:!1,ns:u}):se[$]=this.translate(ve,{...i,joinArrays:!1,ns:u}),se[$]===ve&&(se[$]=K[$])}h=se}}else if(A&&kt(T)&&Array.isArray(h))h=h.join(T),h&&(h=this.extendTranslation(h,t,i,n));else{let he=!1,se=!1;!this.isValidLookup(h)&&x&&(he=!0,h=G),this.isValidLookup(h)||(se=!0,h=a);let $=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&se?void 0:h,ve=x&&G!==h&&this.options.updateMissing;if(se||he||ve){if(this.logger.log(ve?"updateKey":"missingKey",f,c,a,ve?G:h),o){let Je=this.resolve(a,{...i,keySeparator:!1});Je&&Je.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 Je=0;Je<Ce.length;Je++)xe.push(Ce[Je]);else this.options.saveMissingTo==="all"?xe=this.languageUtils.toResolveHierarchy(i.lng||this.language):xe.push(i.lng||this.language);let Ie=(Je,Se,Ve)=>{let gt=x&&Ve!==h?Ve:$;this.options.missingKeyHandler?this.options.missingKeyHandler(Je,c,Se,gt,ve,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Je,c,Se,gt,ve,i),this.emit("missingKey",Je,c,Se,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?xe.forEach(Je=>{let Se=this.pluralResolver.getSuffixes(Je,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&Se.indexOf(`${this.options.pluralSeparator}zero`)<0&&Se.push(`${this.options.pluralSeparator}zero`),Se.forEach(Ve=>{Ie([Je],a+Ve,i[`defaultValue${Ve}`]||G)})}):Ie(xe,a,G))}h=this.extendTranslation(h,t,i,d,n),se&&h===a&&this.options.appendNamespaceToMissingKey&&(h=`${c}${l}${a}`),(se||he)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${l}${a}`:a,he?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=kt(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&&!kt(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=kt(o)?[o]:o;return t!=null&&a?.length&&n.applyPostProcessor!==!1&&(t=AHe.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 kt(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(u=>typeof u=="function"?Xb(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&&!kt(r.count),d=p&&!r.ordinal&&r.count===0,h=r.context!==void 0&&(kt(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=_,!yHe[`${g[0]}-${_}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(yHe[`${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`,I=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&w.indexOf(I)===0&&T.push(l+w.replace(I,this.options.pluralSeparator)),T.push(l+w),d&&T.push(l+x)),h){let U=`${l}${this.options.contextSeparator||"_"}${r.context}`;T.push(U),p&&(r.ordinal&&w.indexOf(I)===0&&T.push(U+w.replace(I,this.options.pluralSeparator)),T.push(U+w),d&&T.push(U+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&&!kt(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}},ZB=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ip.create("languageUtils")}getScriptPartFromCode(t){if(t=CD(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=CD(t),!t||t.indexOf("-")<0)return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(kt(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)),kt(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 kt(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))):kt(t)&&s(this.formatLanguageCode(t)),n.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}},vHe={zero:0,one:1,two:2,few:3,many:4,other:5},EHe={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},ure=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=ip.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,r={}){let n=CD(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!"),EHe;if(!t.match(/-|_/))return EHe;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)=>vHe[i]-vHe[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))}},_He=(e,t,r,n=".",i=!0)=>{let s=uPr(e,t,r);return!s&&i&&kt(r)&&(s=ore(e,r,n),s===void 0&&(s=ore(t,r,n))),s},nre=e=>e.replace(/\$/g,"$$$$"),eq=class{constructor(t={}){this.logger=ip.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:lPr,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?mE(s):o||"{{",this.suffix=a?mE(a):u||"}}",this.formatSeparator=c||",",this.unescapePrefix=l?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=p?mE(p):d||mE("$t("),this.nestingSuffix=h?mE(h):g||mE(")"),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=_He(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(_He(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=>nre(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?nre(this.escape(d)):nre(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=kt(_)?_:""}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!kt(o)&&!this.useRawValueToEscape&&(o=dHe(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(`${mE(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&&!kt(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&&!kt(s))return s;kt(s)||(s=dHe(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}},gPr=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}},SHe=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(CD(n),i),t[o]=a),a(r)}},yPr=e=>(t,r,n)=>e(CD(r),n)(t),cre=class{constructor(t={}){this.logger=ip.create("formatter"),this.options=t,this.init(t)}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let n=r.cacheInBuiltFormats?SHe:yPr;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()]=SHe(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}=gPr(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)}},vPr=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},lre=class extends Jb{constructor(t,r,n,i={}){super(),this.backend=t,this.store=r,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=ip.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=>{aPr(u.loaded,[s],o),vPr(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();kt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),kt(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)}}},ire=()=>({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]),kt(e[1])&&(t.defaultValue=e[1]),kt(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}),bHe=e=>(kt(e.ns)&&(e.ns=[e.ns]),kt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),kt(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),KB=()=>{},EPr=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})},wHe="__i18next_supportNoticeShown",_Pr=()=>!!(typeof globalThis<"u"&&globalThis[wHe]||typeof process<"u"&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&process.env&&process.env.NODE_ENV==="production"),SPr=()=>{typeof globalThis<"u"&&(globalThis[wHe]=!0)},bPr=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)),fre=class e extends Jb{constructor(t={},r){if(super(),this.options=bHe(t),this.services={},this.logger=ip,this.modules={external:[]},EPr(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&&(kt(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));let n=ire();this.options={...n,...this.options,...bHe(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&&!bPr(this)&&!_Pr()&&(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}"),SPr());let i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?ip.init(i(this.modules.logger),this.options):ip.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=cre;let l=new ZB(this.options);this.store=new JB(this.options.resources,this.options);let f=this.services;f.logger=ip,f.resourceStore=this.store,f.languageUtils=l,f.pluralResolver=new ure(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 lre(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 QB(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=KB),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=xD(),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=KB){let n=r,i=kt(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=xD();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=KB),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"&&AHe.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=xD();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=kt(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(u)?u:this.services.languageUtils.getBestMatchFromCodes(kt(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=Xb(u.keyPrefix,c));let l=this.options.keySeparator||".",f;return u.keyPrefix&&Array.isArray(s)?f=s.map(p=>(typeof p=="function"&&(p=Xb(p,c)),`${u.keyPrefix}${l}${p}`)):(typeof s=="function"&&(s=Xb(s,c)),f=u.keyPrefix?`${u.keyPrefix}${l}${s}`:s),this.t(f,u)};return kt(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=xD();return this.options.ns?(kt(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=xD();kt(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 ZB(ire());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=KB){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 JB(a,i),s.services.resourceStore=s.store}if(t.interpolation){let u={...ire().interpolation,...this.options.interpolation,...t.interpolation},c={...i,interpolation:u};s.services.interpolator=new eq(c)}return s.translator=new QB(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=fre.createInstance(),Fvi=kr.createInstance,Uvi=kr.dir,kvi=kr.init,Bvi=kr.loadResources,qvi=kr.reloadResources,jvi=kr.use,Vvi=kr.changeLanguage,Gvi=kr.getFixedT,$vi=kr.t,Hvi=kr.exists,Wvi=kr.setDefaultNamespace,Yvi=kr.hasLoadedNamespace,zvi=kr.loadNamespaces,Kvi=kr.loadLanguages;var CHe={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 pre="fiori-freestyle-writer",OHe=kr.createInstance();async function APr(){await OHe.init({resources:{en:{[pre]:CHe}},lng:"en",fallbackLng:"en",defaultNS:pre,ns:[pre],showSupportNotice:!1})}function Ym(e,t){return OHe.t(e,t)}APr().catch(()=>{});function PHe(e){return xPr(e.name,e.userDisplayName,e.systemType)}function xPr(e,t,r){let n=t?` [${t}]`:"";return`${e}${wPr(r)}${n}`}function wPr(e){let t="",r=` (${Ym("texts.systemTypeLabel.abapCloud")})`;return(e==="AbapCloud"||e==="S4HC"||e==="BTP")&&(t=r),t}var OD=class{applicationKey="";extensionName="";extensionVersion="";getApplicationKey(){return this.applicationKey}getExtensionVersion(){return this.extensionVersion}getExtensionName(){return this.extensionName}};var oct=je(hue(),1);var CR=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 YV(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 mue={name:"@sap-ux/telemetry",version:"1.0.1",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 vo={azureInstrumentationKey:"",telemetryEnabled:!0,telemetryLibName:mue.name,telemetryLibVersion:mue.version,consumerModuleName:"",consumerModuleVersion:""};var OR=class extends OD{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||vo.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||!vo.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 CR(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 oct.TelemetryClient(this.applicationKey);return n.config.samplingPercentage=r,YV(n),n}};var gue=()=>{let e=new Date().getTime();return new Date(e).toISOString()};var PR=class extends OR{constructor(t,r,n){super(t,r,n)}async report(t,r,n,i,s,o){let a=await zV(s),u={v:this.extensionVersion,datetime:gue()},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 zV(r),i={v:this.extensionVersion,datetime:gue()},s={...t.properties,...n,...i},o={...t.measurements};return{finalProperties:s,finalMeasurements:o}}};import{spawn as fJr}from"node:child_process";var DR=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=fJr(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 ann=je(TG(),1);var unn=je(Rle(),1),Ile=je(Zo(),1);var Wdt={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}}'.",executingNpmListCmd:"Running: {{npmCmd}} returned an error: {{- error}}. Check that `npm` 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 Nle="nodejs-utils",snn=kr.createInstance();async function onn(){await snn.init({lng:"en",fallbackLng:"en",defaultNS:Nle,ns:[Nle],resources:{en:{[Nle]:Wdt}},interpolation:{escapeValue:!1},showSupportNotice:!1})}onn().catch(()=>{});import UG from"node:https";function NA(e){UG.globalAgent.options&&(UG.globalAgent.options.rejectUnauthorized=e),UG.globalAgent.fallbackAgent?.options&&(UG.globalAgent.fallbackAgent.options.rejectUnauthorized=e)}var Zc=je(hpe(),1),_yt=je(Eyt(),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"}),To=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 Qc(e,t){try{return t?e?.replace(/{{-?([^{}]*)}}/g,(r,n)=>{let i=n?.trim();return t[i]?.toString()||r}):e}catch{return""}}var EN=class e{documents;static async newInstance(t){return new e(t)}constructor(t){this.documents=Zc.default.parseAllDocuments(t),this.documents.length===0&&this.documents.push(Zc.default.parseDocument(t));let r=this.documents.filter(n=>n.errors.length>0);if(r.length>0)throw new yi(To.yamlParsing+`
|
|
659
|
+
`);let t=new Ma("!xml"),r=t,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let i=this.options,s=new _P(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=tb(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=aZ(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 Ma(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=tb(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=tb(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=aZ(e,a,i.removeNSPrefix);if(!l){let I=e.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${I}"`)}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=Kgr(p),f!==t.tagname&&this.matcher.push(f,{},w),f!==d&&h&&(T=this.buildAttributesMap(d,this.matcher,f),T&&(A=zgr(T,i))),f!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let x=a;if(this.isCurrentNodeStopNode){let I="";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,I=D.tagContent}let U=new Ma(f);T&&(U[":@"]=T),U.add(i.textNodeName,I),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,U,this.readonlyMatcher,x)}else{if(S){({tagName:f,tagExp:d}=oZ(i.transformTagName,f,d,i));let I=new Ma(f);T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(f)){let I=new Ma(f);T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=l.closeIndex;continue}else{let I=new Ma(f);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),T&&(I[":@"]=T),this.addChild(r,I,this.readonlyMatcher,x),r=I}n="",a=g}}}else n+=e[a];return t.child};function tyr(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 ryr(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 nyr(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 iyr(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function syr(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 tb(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i+t.length-1}function oyr(e,t,r,n){let i=e.indexOf(t,r);if(i===-1)throw new Error(n);return i}function aZ(e,t,r,n=">"){let i=syr(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 ayr(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=oyr(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=tb(e,"?>",r+1,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===45&&e.charCodeAt(r+3)===45)r=tb(e,"-->",r+3,"StopNode is not closed.");else if(o===33&&e.charCodeAt(r+2)===91)r=tb(e,"]]>",r,"StopNode is not closed.")-2;else{let a=aZ(e,r,!1);a&&((a&&a.tagName)===t&&a.tagExp[a.tagExp.length-1]!=="/"&&i++,r=a.closeIndex)}}}function uZ(e,t,r){if(t&&typeof e=="string"){let n=e.trim();return n==="true"?!0:n==="false"?!1:nZ(e,r)}else return cUe(e)?e:""}function oZ(e,t,r,n){if(e){let i=e(t);r===t&&(r=i),t=i}return t=IUe(t,n),{tagName:t,tagExp:r}}function IUe(e,t){if(tk.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return gP.includes(e)?t.onDangerousProperty(e):e}var cZ=Ma.getMetaDataSymbol();function uyr(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 lZ(e,t,r,n){return LUe(e,t,r,n)}function LUe(e,t,r,n){let i,s={};for(let o=0;o<e.length;o++){let a=e[o],u=cyr(a);if(u!==void 0&&u!==t.textNodeName){let c=uyr(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=LUe(a[u],t,r,n),l=fyr(c,t);if(Object.keys(c).length===0&&t.alwaysCreateTextNode&&(c[t.textNodeName]=""),a[":@"]?lyr(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[cZ]!==void 0&&typeof c=="object"&&c!==null&&(c[cZ]=a[cZ]),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 cyr(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(n!==":@")return n}}function lyr(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 fyr(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 Gf=class{constructor(t){this.externalEntities={},this.options=PUe(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=rk(t,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new SP(this.options,this.externalEntities),i=n.parseXml(t);return this.options.preserveOrder||i===void 0?i:lZ(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 Ma.getMetaDataSymbol()}};var rb={validate:rk};var Rm=class extends Ca{static ADT_DISCOVERY_SERVICE_PATH="/sap/bc/adt/discovery";schemaStore=new ZU;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(rb.validate(t)!==!0)return null;let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new Gf(r).parse(t,!0);return i.service?i:null}};var Ed=class extends Ca{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 rF(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 bP={UI:"UI",NotClassified:"Not Classified",WebApi:"WEB_API",NotDetermined:"Not Determined"},nb=class extends hm{entitySet;services;isS4Cloud;async listServices(t=!1){return this.services||(this.services=await this.fetchServices(t)),this.services}};var MUe="ServiceCollection",FUe="RecommendedServiceCollection",pyr="((IsSapService%20eq%20true)and(ReleaseStatus%20eq%20%27RELEASED%27))or((IsSapService%20eq%20false))",Nm=class extends nb{static PATH="/sap/opu/odata/IWFND/CATALOGSERVICE;v=2";async determineEntitySet(){let t=await this.document();this.entitySet=t.EntitySets.includes(FUe)?FUe:MUe}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===MUe&&await this.isS4Cloud&&(t.$filter=pyr);let n=(await this.get(`/${this.entitySet}`,{params:t})).odata();if(Of.containsError(n))throw new Of(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 UUe="RecommendedServices",kUe="Services",ib=class extends nb{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"')?UUe:kUe}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.`),Of.containsError(i))throw new Of(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"')?UUe:kUe}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.`),Of.containsError(s))throw new Of(s);return this.mapServices(s,this.entitySet,!0)}getAnnotations(){return Promise.resolve([])}getServiceType(){return Promise.resolve(void 0)}};var TP;(function(e){e.SAP="SAP",e.Customer="CUSTOMER"})(TP||(TP={}));var ti=class extends Ca{log;serviceSchema;static getAdtCatagory(){throw new Error("NEEDS TO BE IMPLEMENTED BY AdtService SUBCLASSES")}attachAdtSchema(t){this.serviceSchema=t}parseResponse(t){if(rb.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0};return new Gf(r).parse(t,!0)}};var AP=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(rb.validate(t)!==!0)return this.log.warn(`Invalid XML: ${t}`),{};let r={attributeNamePrefix:"",ignoreAttributes:!1,ignoreNameSpace:!0,parseAttributeValue:!0,removeNSPrefix:!0},i=new Gf(r).parse(t,!0);return i.settings?i.settings:{}}};var Nke=je(BUe(),1),Gyr=je(Rke(),1);var UP=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 kP=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 BP=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 hb=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 vk=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 qP=class extends Ca{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 qa=class extends Dm{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("",vk);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(AP),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===TP.Customer&&this.atoSettings.operationsType==="C"}getAdtCatalogService(){if(!this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]){let t=this.createService(Rm.ADT_DISCOVERY_SERVICE_PATH,Rm);this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]=t}return this.services[Rm.ADT_DISCOVERY_SERVICE_PATH]}catalog(t){let r;if(t===Er.v2)r=this.services[Nm.PATH]??this.createService(Nm.PATH,Nm);else if(t===Er.v4)r=this.services[ib.PATH]??this.createService(ib.PATH,ib);else throw new Error("not implemented yet");return Object.defineProperty(r,"isAbapCloud",{get:this.isAbapCloud.bind(this)}),r}getUi5AbapRepository(t){let r=t??X0.PATH;return this.services[r]||(this.services[r]=this.createService(r,X0)),this.services[r]}getAppIndex(){return this.services[Ed.PATH]||(this.services[Ed.PATH]=this.createService(Ed.PATH,Ed)),this.services[Ed.PATH]}getLayeredRepository(t){let r=t??J0.PATH;return this.services[r]||(this.services[r]=this.createService(r,J0)),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=qP.PATH;return this.services[t]||(this.services[t]=this.createService(t,qP)),this.services[t]}async getUiServiceGenerator(t){let r=await this.getAdtService(UP);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),hb);return i.configure(n,t,this.getContentType(n)),i}async getODataServiceGenerator(t){let r=await this.getAdtService(kP);if(!r)throw new Error("RAP Generator are not support on this system");let n=await r.getRAPGeneratorConfig(),i=this.createService(this.getServiceUrlFromConfig(n),BP);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=$yr(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,hb)}};var k$e=je(sGe(),1),rp=je(kB(),1);var Hb;(function(e){e.PROXY_URL="HTTP_PROXY",e.H2O_URL="H2O_URL"})(Hb||(Hb={}));var BB;(function(e){e.HTTP="HTTP",e.LDAP="LDAP",e.MAIL="MAIL",e.RFC="RFC"})(BB||(BB={}));var qB;(function(e){e.DEDICATED="Dedicated",e.COMMON="Common"})(qB||(qB={}));var tp;(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"})(tp||(tp={}));var jB;(function(e){e.S4HC="S4HC",e.BTP="BTP"})(jB||(jB={}));var Hte;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(Hte||(Hte={}));var fE;(function(e){e.ODATA_GENERIC="odata_gen",e.ODATA_ABAP="odata_abap",e.DEV_ABAP="dev_abap",e.ABAP_CLOUD="abap_cloud"})(fE||(fE={}));var VB;(function(e){e.FULL_URL="full_url",e.API_MGMT="api_mgmt"})(VB||(VB={}));var TD;(function(e){e.ON_PREMISE="OnPremise",e.INTERNET="Internet",e.PRIVATE_LINK="PrivateLink"})(TD||(TD={}));function L$e(e){return!!(e.WebIDEUsage?.includes("abap")||e["sap-client"]||e["sap-platform"]?.toLocaleLowerCase()==="abap"||e.ProxyType==="OnPremise")}function gOr(e){return!!(e.WebIDEUsage?.includes(fE.ABAP_CLOUD)||e["sap-platform"]?.toLocaleLowerCase()==="abap")}function GB(e){return!!(e.WebIDEUsage?.includes(fE.ODATA_GENERIC)&&!e.WebIDEUsage.includes(fE.ODATA_ABAP))}function Vl(e){return!!(!e.WebIDEAdditionalData?.includes(VB.FULL_URL)&&GB(e))}function Wm(e){return!!(e.WebIDEAdditionalData?.includes(VB.FULL_URL)&&GB(e))}function M$e(e){return!!e.ProxyType.includes(TD.ON_PREMISE)}function F$e(e){return!!e["HTML5.DynamicDestination"]}function yOr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I$e(e,t){let r=` (${t})`;return RegExp(`${yOr(r)}$`).exec(e.trim())?e:`${e} (${t})`}function U$e(e,t){let r=t?` [${t}]`:"",n;return gOr(e)?n=I$e(e.Name,jB.BTP):Wte(e)?n=I$e(e.Name,jB.S4HC):n=e.Name,`${n}${r}`}function Wte(e){return!!(e.WebIDEUsage?.includes(fE.ODATA_ABAP)&&e.Authentication===tp.SAML_ASSERTION&&e.ProxyType===Hte.INTERNET)}function $B(e){return!!e.WebIDEUsage?.includes(fE.ODATA_ABAP)}var Md={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 Yte="abap-cloud-destination-instance",B$e="bas-destination-instance-cred";function Hr(){return!!process.env[Hb.H2O_URL]}async function q$e(e){try{let t=await(0,rp.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 Wb(e,t){let r=`https://${e}.dest`;return t&&t.length>1?new URL(t,r).toString():r}function vOr(e){let[t,...r]=e.split(".");return[t.replace(/-api$/,""),...r].join(".")}async function zte(e){let t={};await wa.get("/reload",{baseURL:process.env[Hb.PROXY_URL]});let r=await wa.get("/api/listDestinations",{baseURL:process.env[Hb.H2O_URL]});return(Array.isArray(r.data)?r.data:[]).forEach(i=>{e?.stripS4HCApiHosts&&Wte(i)&&(i.Host=vOr(i.Host)),i.WebIDEEnabled&&(t[i.Name]=i)}),t}function EOr(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:qB.DEDICATED};return{name:e,description:t,url:new URL(n),type:BB.HTTP,proxyType:TD.INTERNET,basProperties:i,credentials:{authentication:tp.OAUTH2_USER_TOKEN_EXCHANGE,oauth2UserTokenExchange:s}}}async function Kte(e){let t=await(0,rp.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 _Or(e,t,r,n){let i=await Kte(e);return(await(0,rp.apiGetServicesInstancesFilteredByType)(["destination"])).find(a=>a.label===Yte)||(await(0,rp.apiCreateServiceInstance)("destination","lite",Yte,null),n?.info(`New ABAP destination instance ${Yte} created.`)),EOr(i,`Destination generated by App Studio for Cloud Foundry Abap service instance: '${e}', Do not remove.`,t,r)}async function j$e(e,t,r){if(!Hr())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,rp.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 _Or(e,n.uaaCredentials,n.hostUrl,r);await k$e.destinations.createDestination(i),r?.debug(`SAP BTP destination ${JSON.stringify(i,null,2)} created.`);let o=(await zte())?.[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 iHe=je(Qte(),1),sHe=je(Zte(),1),oHe=je(vF(),1),aHe=je(nHe(),1);import{Agent as rPr}from"node:https";import{inspect as nPr}from"node:util";var ere=class extends sHe.HttpsProxyAgent{extraOptions;constructor(t,r){super(t,r),this.extraOptions=r}async connect(t,r){return super.connect(t,{...this.extraOptions,...r})}};function pE(e,t){let r=(0,oHe.default)(t),n={rejectUnauthorized:!r.ignoreCertErrors};r.httpsAgent||(r.httpsAgent=new rPr(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,aHe.getProxyForUrl)(o);return a&&!Hr()&&(s.httpsAgent=new ere(a,n),s.httpAgent=new iHe.HttpProxyAgent(a),s.proxy=!1),s}),i.defaults.headers=i.defaults.headers??{common:{},delete:{},put:{},get:{},post:{},head:{},patch:{}},tFe(i),r.auth?.password&&tUe(i),t.cookies&&t.cookies.split(";").forEach(s=>{i.cookies.addCookie(s.trim())}),mP.isPatchRequired(t.baseURL)&&mP.apply(),i}function uHe(e){return typeof e=="string"?pE(Dm,{baseURL:e}):pE(Dm,e)}function hE(e){return pE(qa,e)}var dE;(function(e){e.Standalone="Standalone",e.EmbeddedSteampunk="EmbeddedSteampunk"})(dE||(dE={}));function tre(e){let t;switch(e.environment){case dE.Standalone:{let{service:r,refreshToken:n,refreshTokenChangedCb:i,cookies:s,...o}=e;t=pE(qa,{baseURL:r.url,cookies:s,...o}),s||(e.service?.uaa?.username&&e.service.uaa.password?rUe(t,r,n,i):WQ({provider:t}));break}case dE.EmbeddedSteampunk:{let{url:r,cookies:n,...i}=e;t=pE(qa,{baseURL:r,cookies:n,...i}),n||WQ({provider:t});break}default:{let r=e;throw new Error(`Unknown environment type supplied: ${nPr(r)}`)}}return t}function cHe(e,t,r){let{cookies:n,...i}=e,s={...i,baseURL:Wb(t.Name,t.Host?new URL(t.Host).pathname:void 0),cookies:n};s.params=s.params??{},s.params.saml2="disabled";let o;if(L$e(t)?(o=pE(qa,s),o.publicUrl=t.Host):o=pE(Dm,s),r){let a=o.interceptors.request.use(async u=>{let c=await q$e(r);return o.defaults.headers.common[B$e]=c,o.interceptors.request.eject(a),u})}return o}var lHe;(function(e){e.FF_SIMPLE="basic"})(lHe||(lHe={}));var fHe;(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"})(fHe||(fHe={}));var ln={vscode:{name:"Visual Studio Code",technical:"VSCode"},bas:{name:"SAP Business Application Studio",technical:"SBAS"},cli:{name:"CLI",technical:"CLI"}};var pHe;(function(e){e.CF="CF",e.ABAP="ABAP"})(pHe||(pHe={}));function iPr(){return!!(process.argv[1]?.includes("yo")||process.stdin.isTTY)}function Ic(){return iPr()?ln.cli:Hr()?ln.bas:ln.vscode}var kt=e=>typeof e=="string",xD=()=>{let e,t,r=new Promise((n,i)=>{e=n,t=i});return r.resolve=e,r.reject=t,r},dHe=e=>e==null?"":""+e,sPr=(e,t,r)=>{e.forEach(n=>{t[n]&&(r[n]=t[n])})},oPr=/###/g,hHe=e=>e&&e.indexOf("###")>-1?e.replace(oPr,"."):e,mHe=e=>!e||kt(e),wD=(e,t,r)=>{let n=kt(t)?t.split("."):t,i=0;for(;i<n.length-1;){if(mHe(e))return{};let s=hHe(n[i]);!e[s]&&r&&(e[s]=new r),Object.prototype.hasOwnProperty.call(e,s)?e=e[s]:e={},++i}return mHe(e)?{}:{obj:e,k:hHe(n[i])}},gHe=(e,t,r)=>{let{obj:n,k:i}=wD(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=wD(e,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=wD(e,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=r},aPr=(e,t,r,n)=>{let{obj:i,k:s}=wD(e,t,Object);i[s]=i[s]||[],i[s].push(r)},XB=(e,t)=>{let{obj:r,k:n}=wD(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},uPr=(e,t,r)=>{let n=XB(e,r);return n!==void 0?n:XB(t,r)},THe=(e,t,r)=>{for(let n in t)n!=="__proto__"&&n!=="constructor"&&(n in e?kt(e[n])||e[n]instanceof String||kt(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):THe(e[n],t[n],r):e[n]=t[n]);return e},mE=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),cPr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},lPr=e=>kt(e)?e.replace(/[&<>"'\/]/g,t=>cPr[t]):e,sre=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}},fPr=[" ",",","?","!",";"],pPr=new sre(20),dPr=(e,t,r)=>{t=t||"",r=r||"";let n=fPr.filter(o=>t.indexOf(o)<0&&r.indexOf(o)<0);if(n.length===0)return!0;let i=pPr.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},CD=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)}},are=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:(kt(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)}},ip=new are,Jb=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])})}},JB=class extends Jb{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):kt(n)&&s?a.push(...n.split(s)):a.push(n)));let u=XB(this.data,a);return!u&&!r&&!n&&t.indexOf(".")>-1&&(t=a[0],r=a[1],n=a.slice(2).join(".")),u||!o||!kt(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),gHe(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)(kt(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=XB(this.data,a)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?THe(u,n,s):u={...u,...n},gHe(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}},AHe={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}},xHe=Symbol("i18next/PATH_KEY");function mPr(){let e=[],t=Object.create(null),r;return t.get=(n,i)=>(r?.revoke?.(),i===xHe?e:(e.push(i),r=Proxy.revocable(n,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Xb(e,t){let{[xHe]:r}=e(mPr()),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 yHe={},rre=e=>!kt(e)&&typeof e!="boolean"&&typeof e!="number",QB=class e extends Jb{constructor(t,r={}){super(),sPr(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ip.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=rre(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&&!dPr(t,n,i);if(o&&!a){let u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:kt(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:kt(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=Xb(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(he=>typeof he=="function"?Xb(he,{...this.options,...i}):String(he));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&&!kt(i.count),x=e.hasDefaultValue(i),I=w?this.pluralResolver.getSuffix(f,i.count,i):"",U=i.ordinal&&w?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=w&&!i.ordinal&&i.count===0,G=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${I}`]||i[`defaultValue${U}`]||i.defaultValue,K=h;A&&!h&&x&&(K=G);let M=rre(K),Q=Object.prototype.toString.apply(K);if(A&&K&&M&&S.indexOf(Q)<0&&!(kt(T)&&Array.isArray(K))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let he=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,K,{...i,ns:u}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(d.res=he,d.usedParams=this.getUsedParamsDetails(i),d):he}if(o){let he=Array.isArray(K),se=he?[]:{},W=he?_:g;for(let $ in K)if(Object.prototype.hasOwnProperty.call(K,$)){let ve=`${W}${o}${$}`;x&&!h?se[$]=this.translate(ve,{...i,defaultValue:rre(G)?G[$]:void 0,joinArrays:!1,ns:u}):se[$]=this.translate(ve,{...i,joinArrays:!1,ns:u}),se[$]===ve&&(se[$]=K[$])}h=se}}else if(A&&kt(T)&&Array.isArray(h))h=h.join(T),h&&(h=this.extendTranslation(h,t,i,n));else{let he=!1,se=!1;!this.isValidLookup(h)&&x&&(he=!0,h=G),this.isValidLookup(h)||(se=!0,h=a);let $=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&se?void 0:h,ve=x&&G!==h&&this.options.updateMissing;if(se||he||ve){if(this.logger.log(ve?"updateKey":"missingKey",f,c,a,ve?G:h),o){let Je=this.resolve(a,{...i,keySeparator:!1});Je&&Je.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 Je=0;Je<Ce.length;Je++)xe.push(Ce[Je]);else this.options.saveMissingTo==="all"?xe=this.languageUtils.toResolveHierarchy(i.lng||this.language):xe.push(i.lng||this.language);let Ie=(Je,Se,Ve)=>{let gt=x&&Ve!==h?Ve:$;this.options.missingKeyHandler?this.options.missingKeyHandler(Je,c,Se,gt,ve,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Je,c,Se,gt,ve,i),this.emit("missingKey",Je,c,Se,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?xe.forEach(Je=>{let Se=this.pluralResolver.getSuffixes(Je,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&Se.indexOf(`${this.options.pluralSeparator}zero`)<0&&Se.push(`${this.options.pluralSeparator}zero`),Se.forEach(Ve=>{Ie([Je],a+Ve,i[`defaultValue${Ve}`]||G)})}):Ie(xe,a,G))}h=this.extendTranslation(h,t,i,d,n),se&&h===a&&this.options.appendNamespaceToMissingKey&&(h=`${c}${l}${a}`),(se||he)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${l}${a}`:a,he?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=kt(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&&!kt(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=kt(o)?[o]:o;return t!=null&&a?.length&&n.applyPostProcessor!==!1&&(t=AHe.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 kt(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(u=>typeof u=="function"?Xb(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&&!kt(r.count),d=p&&!r.ordinal&&r.count===0,h=r.context!==void 0&&(kt(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=_,!yHe[`${g[0]}-${_}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(yHe[`${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`,I=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&w.indexOf(I)===0&&T.push(l+w.replace(I,this.options.pluralSeparator)),T.push(l+w),d&&T.push(l+x)),h){let U=`${l}${this.options.contextSeparator||"_"}${r.context}`;T.push(U),p&&(r.ordinal&&w.indexOf(I)===0&&T.push(U+w.replace(I,this.options.pluralSeparator)),T.push(U+w),d&&T.push(U+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&&!kt(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}},ZB=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ip.create("languageUtils")}getScriptPartFromCode(t){if(t=CD(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=CD(t),!t||t.indexOf("-")<0)return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(kt(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)),kt(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 kt(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))):kt(t)&&s(this.formatLanguageCode(t)),n.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}},vHe={zero:0,one:1,two:2,few:3,many:4,other:5},EHe={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},ure=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=ip.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,r={}){let n=CD(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!"),EHe;if(!t.match(/-|_/))return EHe;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)=>vHe[i]-vHe[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))}},_He=(e,t,r,n=".",i=!0)=>{let s=uPr(e,t,r);return!s&&i&&kt(r)&&(s=ore(e,r,n),s===void 0&&(s=ore(t,r,n))),s},nre=e=>e.replace(/\$/g,"$$$$"),eq=class{constructor(t={}){this.logger=ip.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:lPr,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?mE(s):o||"{{",this.suffix=a?mE(a):u||"}}",this.formatSeparator=c||",",this.unescapePrefix=l?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=p?mE(p):d||mE("$t("),this.nestingSuffix=h?mE(h):g||mE(")"),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=_He(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(_He(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=>nre(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?nre(this.escape(d)):nre(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=kt(_)?_:""}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!kt(o)&&!this.useRawValueToEscape&&(o=dHe(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(`${mE(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&&!kt(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&&!kt(s))return s;kt(s)||(s=dHe(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}},gPr=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}},SHe=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(CD(n),i),t[o]=a),a(r)}},yPr=e=>(t,r,n)=>e(CD(r),n)(t),cre=class{constructor(t={}){this.logger=ip.create("formatter"),this.options=t,this.init(t)}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let n=r.cacheInBuiltFormats?SHe:yPr;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()]=SHe(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}=gPr(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)}},vPr=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},lre=class extends Jb{constructor(t,r,n,i={}){super(),this.backend=t,this.store=r,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=ip.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=>{aPr(u.loaded,[s],o),vPr(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();kt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),kt(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)}}},ire=()=>({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]),kt(e[1])&&(t.defaultValue=e[1]),kt(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}),bHe=e=>(kt(e.ns)&&(e.ns=[e.ns]),kt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),kt(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),KB=()=>{},EPr=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})},wHe="__i18next_supportNoticeShown",_Pr=()=>!!(typeof globalThis<"u"&&globalThis[wHe]||typeof process<"u"&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&process.env&&process.env.NODE_ENV==="production"),SPr=()=>{typeof globalThis<"u"&&(globalThis[wHe]=!0)},bPr=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)),fre=class e extends Jb{constructor(t={},r){if(super(),this.options=bHe(t),this.services={},this.logger=ip,this.modules={external:[]},EPr(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&&(kt(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));let n=ire();this.options={...n,...this.options,...bHe(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&&!bPr(this)&&!_Pr()&&(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}"),SPr());let i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?ip.init(i(this.modules.logger),this.options):ip.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=cre;let l=new ZB(this.options);this.store=new JB(this.options.resources,this.options);let f=this.services;f.logger=ip,f.resourceStore=this.store,f.languageUtils=l,f.pluralResolver=new ure(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 lre(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 QB(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=KB),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=xD(),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=KB){let n=r,i=kt(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=xD();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=KB),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"&&AHe.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=xD();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=kt(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(u)?u:this.services.languageUtils.getBestMatchFromCodes(kt(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=Xb(u.keyPrefix,c));let l=this.options.keySeparator||".",f;return u.keyPrefix&&Array.isArray(s)?f=s.map(p=>(typeof p=="function"&&(p=Xb(p,c)),`${u.keyPrefix}${l}${p}`)):(typeof s=="function"&&(s=Xb(s,c)),f=u.keyPrefix?`${u.keyPrefix}${l}${s}`:s),this.t(f,u)};return kt(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=xD();return this.options.ns?(kt(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=xD();kt(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 ZB(ire());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=KB){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 JB(a,i),s.services.resourceStore=s.store}if(t.interpolation){let u={...ire().interpolation,...this.options.interpolation,...t.interpolation},c={...i,interpolation:u};s.services.interpolator=new eq(c)}return s.translator=new QB(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=fre.createInstance(),Fvi=kr.createInstance,Uvi=kr.dir,kvi=kr.init,Bvi=kr.loadResources,qvi=kr.reloadResources,jvi=kr.use,Vvi=kr.changeLanguage,Gvi=kr.getFixedT,$vi=kr.t,Hvi=kr.exists,Wvi=kr.setDefaultNamespace,Yvi=kr.hasLoadedNamespace,zvi=kr.loadNamespaces,Kvi=kr.loadLanguages;var CHe={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 pre="fiori-freestyle-writer",OHe=kr.createInstance();async function APr(){await OHe.init({resources:{en:{[pre]:CHe}},lng:"en",fallbackLng:"en",defaultNS:pre,ns:[pre],showSupportNotice:!1})}function Ym(e,t){return OHe.t(e,t)}APr().catch(()=>{});function PHe(e){return xPr(e.name,e.userDisplayName,e.systemType)}function xPr(e,t,r){let n=t?` [${t}]`:"";return`${e}${wPr(r)}${n}`}function wPr(e){let t="",r=` (${Ym("texts.systemTypeLabel.abapCloud")})`;return(e==="AbapCloud"||e==="S4HC"||e==="BTP")&&(t=r),t}var OD=class{applicationKey="";extensionName="";extensionVersion="";getApplicationKey(){return this.applicationKey}getExtensionVersion(){return this.extensionVersion}getExtensionName(){return this.extensionName}};var oct=je(hue(),1);var CR=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 YV(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 mue={name:"@sap-ux/telemetry",version:"1.0.3",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 vo={azureInstrumentationKey:"",telemetryEnabled:!0,telemetryLibName:mue.name,telemetryLibVersion:mue.version,consumerModuleName:"",consumerModuleVersion:""};var OR=class extends OD{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||vo.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||!vo.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 CR(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 oct.TelemetryClient(this.applicationKey);return n.config.samplingPercentage=r,YV(n),n}};var gue=()=>{let e=new Date().getTime();return new Date(e).toISOString()};var PR=class extends OR{constructor(t,r,n){super(t,r,n)}async report(t,r,n,i,s,o){let a=await zV(s),u={v:this.extensionVersion,datetime:gue()},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 zV(r),i={v:this.extensionVersion,datetime:gue()},s={...t.properties,...n,...i},o={...t.measurements};return{finalProperties:s,finalMeasurements:o}}};import{spawn as fJr}from"node:child_process";var DR=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=fJr(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 ann=je(TG(),1);var unn=je(Rle(),1),Ile=je(Zo(),1);var Wdt={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 Nle="nodejs-utils",snn=kr.createInstance();async function onn(){await snn.init({lng:"en",fallbackLng:"en",defaultNS:Nle,ns:[Nle],resources:{en:{[Nle]:Wdt}},interpolation:{escapeValue:!1},showSupportNotice:!1})}onn().catch(()=>{});import UG from"node:https";function NA(e){UG.globalAgent.options&&(UG.globalAgent.options.rejectUnauthorized=e),UG.globalAgent.fallbackAgent?.options&&(UG.globalAgent.fallbackAgent.options.rejectUnauthorized=e)}var Zc=je(hpe(),1),_yt=je(Eyt(),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"}),To=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 Qc(e,t){try{return t?e?.replace(/{{-?([^{}]*)}}/g,(r,n)=>{let i=n?.trim();return t[i]?.toString()||r}):e}catch{return""}}var EN=class e{documents;static async newInstance(t){return new e(t)}constructor(t){this.documents=Zc.default.parseAllDocuments(t),this.documents.length===0&&this.documents.push(Zc.default.parseDocument(t));let r=this.documents.filter(n=>n.errors.length>0);if(r.length>0)throw new yi(To.yamlParsing+`
|
|
660
660
|
`+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(Qc(To.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,Zc.isSeq)(u))throw new yi(Qc(To.tryingToAppendToNonSequence,{path:t}),ss.tryingToAppendToNonSequence)}else{if(!n)throw new yi(Qc(To.seqDoesNotExist,{path:t}),ss.seqDoesNotExist);u=new Zc.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(To.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(Qc(To.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(Qc(To.seqDoesNotExist,{path:t}),ss.seqDoesNotExist);let a=o.items.find(l=>l.toJSON()[r.key]===r.value);if(!a)throw new yi(Qc(To.nodeNotFoundMatching,{path:t,key:r.key,value:r.value}),ss.nodeNotFoundMatching);let u=i==="merge"?(0,_yt.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(Qc(To.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(Qc(To.propertyNotFound,{path:t}),ss.propertyNotFound);return this}getNode({start:t,path:r}){if(t&&!((0,Zc.isSeq)(t)||(0,Zc.isMap)(t)))throw new yi(To.startNodeMustBeCollection,ss.startNodeMustBeCollection);let n=this.toPathArray(r),s=(t||this.documents[0])?.getIn(n);if(s)return s;throw new yi(Qc(To.nodeNotFound,{path:r}),ss.nodeNotFound)}getSequence({start:t,path:r}){let n=this.getNode({start:t,path:r});if((0,Zc.isSeq)(n))return n;throw new yi(Qc(To.seqDoesNotExist,{path:r}),ss.seqDoesNotExist)}getMap({start:t,path:r}){let n=this.getNode({start:t,path:r});if((0,Zc.isMap)(n))return n;throw new yi(Qc(To.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(To.pathCannotBeEmpty,ss.pathCannotBeEmpty);return r}};import{join as ecn,posix as Syt,relative as tcn,sep as rcn}from"node:path";function byt(){return{name:"fiori-tools-appreload",afterMiddleware:"compression",configuration:{port:35729,path:"webapp",delay:300}}}function M$(e,t){let r=[];return e.authenticationType==="reentranceTicket"&&r.push({path:`configuration.backend.${t}.authenticationType`,comment:" SAML support for vscode",key:"authenticationType"}),r}function Tyt(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=M$(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 Ayt=(e,t,r,n)=>{let i=[];return r.forEach(s=>{let o=`.${Syt.sep}${tcn(e,ecn(t,"localService",s.serviceName)).replaceAll(rcn,Syt.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 $A="fiori-tools-servestatic",uh="fiori-tools-proxy";var cSt=je(r_t(),1);import{dirname as oyn,join as aSt,posix as uSt,relative as ayn,sep as uyn}from"node:path";import{fileURLToPath as cyn}from"node:url";import{readFile as lyn}from"node:fs/promises";function v_t(e){return typeof e>"u"||e===null}function jhn(e){return typeof e=="object"&&e!==null}function Vhn(e){return Array.isArray(e)?e:v_t(e)?[]:[e]}function Ghn(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 $hn(e,t){var r="",n;for(n=0;n<t;n+=1)r+=e;return r}function Hhn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Whn=v_t,Yhn=jhn,zhn=Vhn,Khn=$hn,Xhn=Hhn,Jhn=Ghn,os={isNothing:Whn,isObject:Yhn,toArray:zhn,repeat:Khn,isNegativeZero:Xhn,extend:Jhn};function E_t(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+=`
|
|
661
661
|
|
|
662
662
|
`+e.mark.snippet),n+" "+r):n}function KN(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=E_t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}KN.prototype=Object.create(Error.prototype);KN.prototype.constructor=KN;KN.prototype.toString=function(t){return this.name+": "+E_t(this,t)};var aa=KN;function ahe(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 uhe(e,t){return os.repeat(" ",t-e.length)+e}function Qhn(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=ahe(e.buffer,n[o-u],i[o-u],e.position-(n[o]-n[o-u]),f),a=os.repeat(" ",t.indent)+uhe((e.line-u+1).toString(),l)+" | "+c.str+`
|
|
@@ -688,7 +688,7 @@ PGHZoN9jcvvvWDLUGtJkEotMgdFpEA2XWR83H4fVFVc=
|
|
|
688
688
|
`+e.slice(i,s),i=s+1),o=a;return u+=`
|
|
689
689
|
`,e.length-i>t&&o>i?u+=e.slice(i,o)+`
|
|
690
690
|
`+e.slice(o+1):u+=e.slice(i),u.slice(1)}function kgn(e){for(var t="",r=0,n,i=0;i<e.length;r>=65536?i+=2:i++)r=zN(e,i),n=Co[r],!n&&QN(r)?(t+=e[i],r>=65536&&(t+=e[i+1])):t+=n||Pgn(r);return t}function Bgn(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)),(dh(e,t,a,!1,!1)||typeof a>"u"&&dh(e,t,null,!1,!1))&&(n!==""&&(n+=","+(e.condenseFlow?"":" ")),n+=e.dump);e.tag=i,e.dump="["+n+"]"}function g_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)),(dh(e,t+1,u,!0,!0,!1,!0)||typeof u>"u"&&dh(e,t+1,null,!0,!0,!1,!0))&&((!n||i!=="")&&(i+=phe(e,t)),e.dump&&XN===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=s,e.dump=i||"[]"}function qgn(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)),dh(e,t,u,!1,!1)&&(e.dump.length>1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),dh(e,t,c,!1,!1)&&(l+=e.dump,n+=l));e.tag=i,e.dump="{"+n+"}"}function jgn(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 aa("sortKeys must be a boolean or a function");for(a=0,u=o.length;a<u;a+=1)p="",(!n||i!=="")&&(p+=phe(e,t)),c=o[a],l=r[c],e.replacer&&(l=e.replacer.call(r,c,l)),dh(e,t+1,c,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&XN===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,f&&(p+=phe(e,t)),dh(e,t+1,l,!0,f)&&(e.dump&&XN===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=s,e.dump=i||"{}"}function y_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,K_t.call(a.represent)==="[object Function]")n=a.represent(t,u);else if(X_t.call(a.represent,u))n=a.represent[u](t,u);else throw new aa("!<"+a.tag+'> tag resolver accepts not "'+u+'" style');e.dump=n}return!0}return!1}function dh(e,t,r,n,i,s,o){e.tag=null,e.dump=r,y_t(e,r,!1)||y_t(e,r,!0);var a=K_t.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?(jgn(e,t,e.dump,i),p&&(e.dump="&ref_"+f+e.dump)):(qgn(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?g_t(e,t-1,e.dump,i):g_t(e,t,e.dump,i),p&&(e.dump="&ref_"+f+e.dump)):(Bgn(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(a==="[object String]")e.tag!=="?"&&Fgn(e,e.dump,t,s,u);else{if(a==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new aa("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 Vgn(e,t){var r=[],n=[],i,s;for(hhe(e,r,n),i=0,s=n.length;i<s;i+=1)t.duplicates.push(r[n[i]]);t.usedDuplicates=new Array(s)}function hhe(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)hhe(e[i],t,r);else for(n=Object.keys(e),i=0,s=n.length;i<s;i+=1)hhe(e[n[i]],t,r)}function Ggn(e,t){t=t||{};var r=new Rgn(t);r.noRefs||Vgn(e,r);var n=e;return r.replacer&&(n=r.replacer.call({"":n},"",n)),dh(r,0,n,!0,!0)?r.dump+`
|
|
691
|
-
`:""}var $gn=Ggn,Hgn={dump:$gn};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 Wgn=Ws,Ygn=__t,zgn=A_t,Kgn=P_t,Xgn=D_t,Jgn=ghe,Qgn=z_t.load,Zgn=z_t.loadAll,eyn=Hgn.dump,tyn=aa,ryn={binary:M_t,float:O_t,map:T_t,null:x_t,pairs:U_t,set:k_t,timestamp:I_t,bool:w_t,int:C_t,merge:L_t,omap:F_t,seq:b_t,str:S_t},nyn=_he("safeLoad","load"),iyn=_he("safeLoadAll","loadAll"),syn=_he("safeDump","dump"),oSt={Type:Wgn,Schema:Ygn,FAILSAFE_SCHEMA:zgn,JSON_SCHEMA:Kgn,CORE_SCHEMA:Xgn,DEFAULT_SCHEMA:Jgn,load:Qgn,loadAll:Zgn,dump:eyn,YAMLException:tyn,types:ryn,safeLoad:nyn,safeLoadAll:iyn,safeDump:syn};var fyn=oyn(cyn(import.meta.url)),Oo=class e{document;static validate;async validateSchema(){if(!e.validate){let r=aSt(fyn,"..","dist","schema","ui5.yaml.json"),n=JSON.parse(await lyn(r,"utf8"));if(!n)throw Error("The schema file was not found. Validation is not possible.");e.validate=new cSt.Ajv({strict:!1}).compile(n)}let t=!1;try{t=oSt.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 EN.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:byt()}),this}addFioriToolsProxyMiddleware(t,r){let n=t?.ignoreCertErrors??t?.ignoreCertError??!1,{config:i,comments:s}=Tyt(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===uh);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=M$(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=M$(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(uh);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===uh),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===uh);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:Ayt(t,r,n,i)}),this}addServiceToMockserverMiddleware(t,r,n,i=[]){let s=this.findCustomMiddleware("sap-fe-mockserver");if(s){let o=`.${uSt.sep}${ayn(t,aSt(r,"localService",n.serviceName)).replaceAll(uyn,uSt.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={target:t,app:r,exclude:i,lrep:o};return s&&(u.index=!0),this.document.appendTo({path:"builder.customTasks",value:{name:n?"deploy-to-abap":"abap-deploy-task",afterTask:"generateCachebusterInfo",configuration:u},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:$A,beforeMiddleware:uh,configuration:{paths:r}}:{name:$A,afterMiddleware:"compression",configuration:{paths:r}}}addServeStaticConfig(t){let r=this.findCustomMiddleware($A),n=this.findCustomMiddleware(uh);if(r)r.afterMiddleware==="compression"&&n?this.updateCustomMiddleware({name:$A,beforeMiddleware:uh,configuration:{paths:[...r.configuration.paths,...t]}}):this.mergeCustomMiddleware({name:$A,configuration:{paths:[...r.configuration.paths,...t]}});else{let i=this.getServeStaticConfig(!!n,t);this.addCustomMiddleware([i])}return this}toString(){return this.document.toString()}};var gyn=je(fSt(),1),yyn=je(Zo(),1);var vwt=je(hpe(),1);import ff from"node:fs";import Th from"node:path";import{homedir as vyn}from"node:os";import{join as pSt}from"node:path";var bt={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"},dSt={dir:".fioritools",migrationSettingsFile:"migrationSettings.json"};var fx=pSt(vyn(),dSt.dir),ZN=pSt(fx,ai.ModuleCache);var ESt=je(vSt(),1);import{promises as TH}from"node:fs";async function af(e,t){return t?t.read(e):TH.readFile(e,{encoding:"utf8"})}async function zr(e,t){return t?t.readJSON(e):JSON.parse(await af(e))}async function F_(e,t,r){return r?r.write(e,t):TH.writeFile(e,t,{encoding:"utf8"})}async function as(e,t){try{return t?t.exists(e):(await TH.access(e),!0)}catch{return!1}}async function px(e,t,r){await _St(e,t,r)}async function bhe(e,t,r){await _St(e,t,r)}async function _St(e,t,r){let n=await af(e,r),i=(0,ESt.default)(n),o=JSON.stringify(t,null,i[Symbol.for("indent")])+`
|
|
691
|
+
`:""}var $gn=Ggn,Hgn={dump:$gn};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 Wgn=Ws,Ygn=__t,zgn=A_t,Kgn=P_t,Xgn=D_t,Jgn=ghe,Qgn=z_t.load,Zgn=z_t.loadAll,eyn=Hgn.dump,tyn=aa,ryn={binary:M_t,float:O_t,map:T_t,null:x_t,pairs:U_t,set:k_t,timestamp:I_t,bool:w_t,int:C_t,merge:L_t,omap:F_t,seq:b_t,str:S_t},nyn=_he("safeLoad","load"),iyn=_he("safeLoadAll","loadAll"),syn=_he("safeDump","dump"),oSt={Type:Wgn,Schema:Ygn,FAILSAFE_SCHEMA:zgn,JSON_SCHEMA:Kgn,CORE_SCHEMA:Xgn,DEFAULT_SCHEMA:Jgn,load:Qgn,loadAll:Zgn,dump:eyn,YAMLException:tyn,types:ryn,safeLoad:nyn,safeLoadAll:iyn,safeDump:syn};var fyn=oyn(cyn(import.meta.url)),Oo=class e{document;static validate;async validateSchema(){if(!e.validate){let r=aSt(fyn,"..","dist","schema","ui5.yaml.json"),n=JSON.parse(await lyn(r,"utf8"));if(!n)throw Error("The schema file was not found. Validation is not possible.");e.validate=new cSt.Ajv({strict:!1}).compile(n)}let t=!1;try{t=oSt.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 EN.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:byt()}),this}addFioriToolsProxyMiddleware(t,r){let n=t?.ignoreCertErrors??t?.ignoreCertError??!1,{config:i,comments:s}=Tyt(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===uh);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=M$(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=M$(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(uh);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===uh),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===uh);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:Ayt(t,r,n,i)}),this}addServiceToMockserverMiddleware(t,r,n,i=[]){let s=this.findCustomMiddleware("sap-fe-mockserver");if(s){let o=`.${uSt.sep}${ayn(t,aSt(r,"localService",n.serviceName)).replaceAll(uyn,uSt.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:$A,beforeMiddleware:uh,configuration:{paths:r}}:{name:$A,afterMiddleware:"compression",configuration:{paths:r}}}addServeStaticConfig(t){let r=this.findCustomMiddleware($A),n=this.findCustomMiddleware(uh);if(r)r.afterMiddleware==="compression"&&n?this.updateCustomMiddleware({name:$A,beforeMiddleware:uh,configuration:{paths:[...r.configuration.paths,...t]}}):this.mergeCustomMiddleware({name:$A,configuration:{paths:[...r.configuration.paths,...t]}});else{let i=this.getServeStaticConfig(!!n,t);this.addCustomMiddleware([i])}return this}toString(){return this.document.toString()}};var gyn=je(fSt(),1),yyn=je(Zo(),1);var vwt=je(hpe(),1);import ff from"node:fs";import Th from"node:path";import{homedir as vyn}from"node:os";import{join as pSt}from"node:path";var bt={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"},dSt={dir:".fioritools",migrationSettingsFile:"migrationSettings.json"};var fx=pSt(vyn(),dSt.dir),ZN=pSt(fx,ai.ModuleCache);var ESt=je(vSt(),1);import{promises as TH}from"node:fs";async function af(e,t){return t?t.read(e):TH.readFile(e,{encoding:"utf8"})}async function zr(e,t){return t?t.readJSON(e):JSON.parse(await af(e))}async function F_(e,t,r){return r?r.write(e,t):TH.writeFile(e,t,{encoding:"utf8"})}async function as(e,t){try{return t?t.exists(e):(await TH.access(e),!0)}catch{return!1}}async function px(e,t,r){await _St(e,t,r)}async function bhe(e,t,r){await _St(e,t,r)}async function _St(e,t,r){let n=await af(e,r),i=(0,ESt.default)(n),o=JSON.stringify(t,null,i[Symbol.for("indent")])+`
|
|
692
692
|
`;await F_(e,o,r)}async function AH(e){return TH.readdir(e,{encoding:"utf8"})}var xSt=je(bSt(),1);import{basename as The,dirname as TSt,extname as ASt,join as Ahe,sep as Ryn,posix as Nyn}from"node:path";function Iyn(e,t,r,n){let i=[],s=[],o=Object.keys(e).filter(a=>a.startsWith(n.replaceAll(Ryn,Nyn.sep))&&(t.includes(The(a))||r.includes(ASt(a))||t.length===0&&r.length===0));for(let a of o)e[a].state==="deleted"&&i.push(Ahe(a)),e[a].state==="modified"&&s.push(Ahe(a));return{deleted:i,modified:s}}function Lyn(e,t,r,n,i,s){let o=e,a=i;if(s){let{modified:u,deleted:c}=Iyn(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 U_(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,xSt.default)(e.root);c.on("directory",(l,f,p)=>{let d=The(l);(o.includes(d)||a&&l!==e.root)&&p()}),c.on("file",l=>{(s.includes(ASt(l))||i.includes(The(l))||i.length===0&&s.length===0)&&n.push(l)}),c.on("end",()=>{let{searchResult:l,fatalErrors:f}=Lyn(n,i,s,e.root,u,e.memFs);f.length===0?t(l):r(f)}),c.on("error",l=>{u.push(l)})})}function dx(e,t,r,n,i){return U_({extensionNames:[e],root:t,excludeFolders:r,noTraversal:i,memFs:n})}async function uf(e,t,r){let n=Ahe(t,e);return await as(n,r)?n:TSt(t)!==t?uf(e,TSt(t),r):void 0}import{realpathSync as Byn}from"node:fs";var xhe;function wH(e){if(process.platform==="win32"){if(xhe===void 0){let r=Byn.native("\\")[0];xhe=r===r.toUpperCase()}return(xhe?e.charAt(0).toUpperCase():e.charAt(0).toLowerCase())+e.slice(1)}return e}import{spawn as N0n}from"node:child_process";import{basename as gBi,dirname as yBi,join as ay,normalize as vBi,relative as EBi,sep as jAt}from"node:path";import{existsSync as OH}from"node:fs";import{mkdir as Hyn,rm as CSt}from"node:fs/promises";import{join as PH}from"node:path";import{createRequire as Wyn}from"node:module";import{existsSync as qyn}from"node:fs";import{dirname as jyn,isAbsolute as Vyn,join as wSt,parse as Gyn}from"node:path";var eI=(e,t)=>!!(e.dependencies?.[t]??e.devDependencies?.[t]);function CH(e,t){if(!Vyn(e))return;let{root:r}=Gyn(e),n=e,i;for(;n!==r;){let s=wSt(n,"node_modules");if(t&&(s=wSt(s,t,bt.Package)),qyn(s)){i=n;break}n=jyn(n)}return i}import{spawn as $yn}from"node:child_process";async function k_(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=$yn(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(`
|
|
693
693
|
`),S=_?`:
|
|
694
694
|
${_}`:"";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)})})}import{pathToFileURL as Yyn}from"node:url";var zyn=Wyn(import.meta.url);async function OSt(e,t){if(!CH(e,t))throw Error("Path to module not found.");return zyn.resolve(t,{paths:[e]})}async function hh(e,t){let r;try{let n=await OSt(e,t);r=await import(Yyn(n).href)}catch(n){throw Error(`Module '${t}' not installed in project '${e}'.
|
|
@@ -729,7 +729,7 @@ specVersion: "2.5"`);return s.setMetadata({name:e}),s.setType("application"),s.a
|
|
|
729
729
|
${i}`);let s=[" getReferentialConstraints: function (navigationProperty) {",`${i}`," return undefined;"," }"].join(`
|
|
730
730
|
`),o=e.lastIndexOf(`
|
|
731
731
|
};`);return o!==-1?`${e.slice(0,o)},
|
|
732
|
-
${s}${e.slice(o)}`:e}var kM=je(t8t());import{readFile as _ei}from"node:fs/promises";import{join as Sei}from"node:path";var n8t=je(S8());import{randomUUID as sei}from"node:crypto";var r8t={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.1",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 oei="@sap-ux/odata-download-sub-generator",aei="0a65e45d-6bf4-421d-b845-61e888c50e9e",ga=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=sei(),mr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:oei,version:r8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:aei,...t};try{await aL(r)}catch(n){mr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=Lt("telemetry.unknownOs");try{r=(0,n8t.default)()}catch{}this._telemetryData={Platform:Hr()?"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 tc.getTelemetryClient().reportEvent(i,Pi.NoSampling)}};var uei=["eq","ne","gt","ge","lt","le"],l7=["and","or","not"],cei=["any","all"],lei=["startswith","endswith","contains","matchespattern"],fei=["expand","levels","select","skip","top","count","orderby","filter"],i8t=/\((.*)\)/,s8t=/(?!indexof)\((\w+)\)/;var Xh="";function Ybe({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+=`(${ed(c,g)})`),(o||typeof l=="object")&&(_.$filter=p7(typeof l=="object"?l:o,g)),a&&(_.$apply=a8t(a)),f&&(_.$expand=f7(f)),u&&(_.$orderby=zbe(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=ed(d[S],g);h+=`/${S}`,T!==""&&(h+=`(${T})`)}}return g.length>0&&Object.assign(_,g.reduce((S,T)=>Object.assign(S,{[`@${T.name}`]:ed(T.value)}),{})),gei(h,{$select:e,$search:t,$skiptoken:r,$format:n,..._})}function Wbe(e,t,r=[]){return`${e} eq ${ed(t,r)}`}function p7(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===Xh?p=a:s8t.test(l)?p=l.replace(s8t,(d,h)=>h.trim()===Xh?`(${a})`:`(${a}/${h.trim()})`):i8t.test(l)?p=l.replace(i8t,(d,h)=>h.trim()===Xh?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===Xh&&Array.isArray(f))return c.concat(f.map(d=>Wbe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(Wbe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>p7(g,o,a)).filter(g=>g).map(g=>l7.indexOf(d)!==-1?`(${g})`:g);h.length&&(l7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(o8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(l7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(o8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(Wbe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(uei.indexOf(d)!==-1)c.push(`${p} ${d} ${ed(f[d],o)}`);else if(l7.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(cei.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${ed(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=>ed(g,o)).join(",")+")")}else if(lei.indexOf(d)!==-1)c.push(`${d}(${p},${ed(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=pei(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(Xh)?(p.hasOwnProperty(Xh)||(p[Xh]=[]),p[Xh].push(d[Xh]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function pei(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function dei(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 ed(e,t){if(typeof e=="string")return`'${dei(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>ed(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}=${ed(n,t)}`).join(",")}return e}function f7(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=>f7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>fei.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=p7(e[r]);break;case"orderBy":n=zbe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=f7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=f7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function a8t(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(${hei(i)})`);break}case"filter":{let i=r[n];if(i){let s=p7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${mei(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function hei(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 mei(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${a8t(e.transform)}`),t}function zbe(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])=>zbe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function gei(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 o8t(e){return`not (${e.join(" and ")})`}function yei(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 vei(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=yei(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);mr.logger.info(Lt("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 I=String(x.value).split(","),U=["Edm.UUID","Edm.Guid"].includes(x.type),D=G=>U?G.trim():`'${G.trim()}'`;if(I.length===1)d.push(`${x.name} eq ${D(I[0])}`);else{let G=I.map(K=>`${x.name} eq ${D(K)}`);d.push(`(${G.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?Ybe(s):"",A=T?`&${T.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return mr.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=Ybe(l),p=`${u.entitySetName}${f}`;return mr.logger.debug(`Query for odata: ${p}`),{query:p}}function Eei(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){mr.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]}`)),mr.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 mr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function c8t(e,t,r,n,i,s=[]){let o=vei(e,r,n,i),a=await u8t(t,o.query);for(let u of s){let c=r.find(_=>_.entity.entitySetName===u.entitySetName);if(!c){mr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=Eei(e,c.entity.entityPath,u);if(!l){mr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await u8t(t,l);if(!f.entityData||!a.entityData){mr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}mr.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++)}}mr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function u8t(e,t){try{mr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),mr.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 mr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=Lt("errors.odataQueryError",{error:r});return mr.logger.error(n),{error:n}}}var Tu=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 l8t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=mr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();ga.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 c8t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return ga.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),mr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return ga.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return Lt("errors.dataNotFetched")}function f8t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type===kM.UIAnnotationTypes.ReferenceFacet&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type===kM.UIAnnotationTypes.CollectionFacet&&t.push(...f8t(r))}),t}function bei(e){if(Tu.entityTypeRefFacetCache[e.name])return Tu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type===kM.UIAnnotationTypes.ReferenceFacet&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type===kM.UIAnnotationTypes.CollectionFacet&&t.push(...f8t(r))}),Tu.entityTypeRefFacetCache[e.name]=t,t??[]}function p8t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?bei(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,p8t(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 d8t(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=p8t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function h8t(e,t){let n=(await Oo.newInstance(await _ei(Sei(e,bt.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=Hr()?n?.destination:await X5t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function m8t(e){let t=await XI(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(mr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),Lt("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var g8t,Tei=(...e)=>new Promise(t=>{clearTimeout(g8t),g8t=setTimeout(async()=>t(await l8t(...e)),1e3)}),_l={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},Aei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,y8t=["."];async function E8t(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 Lt("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[_l.relatedEntitySelection]);let o=await Tei(t,r,s);return o}function xei(e){return Tu.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 _8t(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=wei(r,n,e?.appPath),s=await cGt({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:Kn.v4}},Ic()!==ln.cli,mr.logger);s.prompts=Ds(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=Oei(r,r.relatedEntityChoices),u=Pei(5,r,s.answers,o),c=Cei(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,Rei(s.answers,r),Dei(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function wei(e,t,r){return{type:"input",guiType:"folder-browser",name:_l.appSelection,message:Lt("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:Lt("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,xei(e);let i;try{i=await M5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),mr.logger.error(Lt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${Lt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${Lt("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return Lt("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await m8t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await h8t(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 Cei(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:_l.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:Lt("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[_l.skipDataDownload]?.[0]){if(i=await E8t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:Lt("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:v8t.information}}}}function Oei(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=d8t(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:_l.toggleSelection,type:"confirm",message:Lt("prompts.toggleSelection.message"),labelTrue:Lt("prompts.toggleSelection.labelTrue"),labelFalse:Lt("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 Pei(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:()=>Lt("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:Lt("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,y8t.includes(c))return Lt("prompts.entityKey.validation.invalidKeyValueChars",{chars:y8t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return Lt("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!Aei.test(h.trim()))return Lt("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,Lt("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[_l.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await E8t(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 Dei(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:_l.skipDataDownload,type:"checkbox",message:Lt("prompts.skipDataDownload.message"),guiOptions:{hint:Lt("prompts.skipDataDownload.hint")},default:!1,choices:[{name:Lt("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function Rei(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await Q5t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:_l.updateMainServiceMetadata,type:"confirm",message:Lt("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:v8t.error}}}}function S8t(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 w8t=je(Ey()),C8t=je(Sy());var O8t=je(x8t());import{join as Hei}from"node:path";function P8t(e,t,r){Tu.resetExternalServiceCache();let n=zei(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:Lt("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return Tu.resetExternalServiceCache(),!0;let a=await Yei(o,r),u=(0,O8t.default)(i,a);return i.length=0,i.push(...u),await Wei(i,r),!0}}],valueHelpData:i}}async function Wei(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(";");Tu.externalServiceRequestCache[a]??=[];let l=(0,w8t.convert)((0,C8t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(Tu.externalServiceRequestCache[a].includes(p))return;Tu.externalServiceRequestCache[a].push(p);let d=await t.get(Hei(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 Yei(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function zei(e,t){let r=KL(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(W5t.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 mr=class e extends R8t.default{vscode;appWizard;static _logger=X8;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),zve(this.env,!0),this.options.force=!0,this.prompts=new Xei([{description:Lt("steps.odataDownloader.description"),name:Lt("steps.odataDownloader.name")},{description:Lt("steps.valueHelpSelection.description"),name:Lt("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(Lt("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await e_e(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await ga.initTelemetrySettings(),ga.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await _8t(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 mx(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??TC(ai.Webapp,ai.LocalService,ai.Mockdata)}if(this.state.updateMainServiceMetadata=s[_l.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[_l.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof qa){let{questions:o,valueHelpData:a}=P8t(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();ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot(TC(this.state.appRootPath));let r=Hbe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(Lt("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON(TC(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=TC(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=e8t(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=Z5t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),ga.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Lt("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=TC(this.state.appRootPath,ai.Webapp);if(await E4(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 Z8(this.state.appRootPath,n,this.fs))}ga.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),ga.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Lt("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=TC(this.state.appRootPath,ai.Webapp,ai.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,D8t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[_l.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:Lt("steps.addConstraints.name"),description:Lt("steps.addConstraints.description")}]);let o=S8t(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 Ic()!==ln.cli&&this.appWizard?.showError(t,Kei.notification),new Error(t)}_configureLogging(t,r,n){let i=new K8(this.rootGeneratorName(),this.log,t,r,n);return i.info(Lt("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};export{mr as default};
|
|
732
|
+
${s}${e.slice(o)}`:e}var kM=je(t8t());import{readFile as _ei}from"node:fs/promises";import{join as Sei}from"node:path";var n8t=je(S8());import{randomUUID as sei}from"node:crypto";var r8t={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.3",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 oei="@sap-ux/odata-download-sub-generator",aei="0a65e45d-6bf4-421d-b845-61e888c50e9e",ga=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=sei(),mr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:oei,version:r8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:aei,...t};try{await aL(r)}catch(n){mr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=Lt("telemetry.unknownOs");try{r=(0,n8t.default)()}catch{}this._telemetryData={Platform:Hr()?"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 tc.getTelemetryClient().reportEvent(i,Pi.NoSampling)}};var uei=["eq","ne","gt","ge","lt","le"],l7=["and","or","not"],cei=["any","all"],lei=["startswith","endswith","contains","matchespattern"],fei=["expand","levels","select","skip","top","count","orderby","filter"],i8t=/\((.*)\)/,s8t=/(?!indexof)\((\w+)\)/;var Xh="";function Ybe({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+=`(${ed(c,g)})`),(o||typeof l=="object")&&(_.$filter=p7(typeof l=="object"?l:o,g)),a&&(_.$apply=a8t(a)),f&&(_.$expand=f7(f)),u&&(_.$orderby=zbe(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=ed(d[S],g);h+=`/${S}`,T!==""&&(h+=`(${T})`)}}return g.length>0&&Object.assign(_,g.reduce((S,T)=>Object.assign(S,{[`@${T.name}`]:ed(T.value)}),{})),gei(h,{$select:e,$search:t,$skiptoken:r,$format:n,..._})}function Wbe(e,t,r=[]){return`${e} eq ${ed(t,r)}`}function p7(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===Xh?p=a:s8t.test(l)?p=l.replace(s8t,(d,h)=>h.trim()===Xh?`(${a})`:`(${a}/${h.trim()})`):i8t.test(l)?p=l.replace(i8t,(d,h)=>h.trim()===Xh?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===Xh&&Array.isArray(f))return c.concat(f.map(d=>Wbe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(Wbe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>p7(g,o,a)).filter(g=>g).map(g=>l7.indexOf(d)!==-1?`(${g})`:g);h.length&&(l7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(o8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(l7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(o8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(Wbe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(uei.indexOf(d)!==-1)c.push(`${p} ${d} ${ed(f[d],o)}`);else if(l7.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(cei.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${ed(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=>ed(g,o)).join(",")+")")}else if(lei.indexOf(d)!==-1)c.push(`${d}(${p},${ed(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=pei(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(Xh)?(p.hasOwnProperty(Xh)||(p[Xh]=[]),p[Xh].push(d[Xh]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function pei(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function dei(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 ed(e,t){if(typeof e=="string")return`'${dei(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>ed(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}=${ed(n,t)}`).join(",")}return e}function f7(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=>f7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>fei.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=p7(e[r]);break;case"orderBy":n=zbe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=f7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=f7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function a8t(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(${hei(i)})`);break}case"filter":{let i=r[n];if(i){let s=p7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${mei(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function hei(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 mei(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${a8t(e.transform)}`),t}function zbe(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])=>zbe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function gei(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 o8t(e){return`not (${e.join(" and ")})`}function yei(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 vei(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=yei(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);mr.logger.info(Lt("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 I=String(x.value).split(","),U=["Edm.UUID","Edm.Guid"].includes(x.type),D=G=>U?G.trim():`'${G.trim()}'`;if(I.length===1)d.push(`${x.name} eq ${D(I[0])}`);else{let G=I.map(K=>`${x.name} eq ${D(K)}`);d.push(`(${G.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?Ybe(s):"",A=T?`&${T.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return mr.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=Ybe(l),p=`${u.entitySetName}${f}`;return mr.logger.debug(`Query for odata: ${p}`),{query:p}}function Eei(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){mr.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]}`)),mr.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 mr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function c8t(e,t,r,n,i,s=[]){let o=vei(e,r,n,i),a=await u8t(t,o.query);for(let u of s){let c=r.find(_=>_.entity.entitySetName===u.entitySetName);if(!c){mr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=Eei(e,c.entity.entityPath,u);if(!l){mr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await u8t(t,l);if(!f.entityData||!a.entityData){mr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}mr.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++)}}mr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function u8t(e,t){try{mr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),mr.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 mr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=Lt("errors.odataQueryError",{error:r});return mr.logger.error(n),{error:n}}}var Tu=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 l8t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=mr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();ga.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 c8t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return ga.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),mr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return ga.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return Lt("errors.dataNotFetched")}function f8t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type===kM.UIAnnotationTypes.ReferenceFacet&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type===kM.UIAnnotationTypes.CollectionFacet&&t.push(...f8t(r))}),t}function bei(e){if(Tu.entityTypeRefFacetCache[e.name])return Tu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type===kM.UIAnnotationTypes.ReferenceFacet&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type===kM.UIAnnotationTypes.CollectionFacet&&t.push(...f8t(r))}),Tu.entityTypeRefFacetCache[e.name]=t,t??[]}function p8t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?bei(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,p8t(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 d8t(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=p8t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function h8t(e,t){let n=(await Oo.newInstance(await _ei(Sei(e,bt.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=Hr()?n?.destination:await X5t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function m8t(e){let t=await XI(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(mr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),Lt("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var g8t,Tei=(...e)=>new Promise(t=>{clearTimeout(g8t),g8t=setTimeout(async()=>t(await l8t(...e)),1e3)}),_l={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},Aei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,y8t=["."];async function E8t(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 Lt("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[_l.relatedEntitySelection]);let o=await Tei(t,r,s);return o}function xei(e){return Tu.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 _8t(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=wei(r,n,e?.appPath),s=await cGt({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:Kn.v4}},Ic()!==ln.cli,mr.logger);s.prompts=Ds(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=Oei(r,r.relatedEntityChoices),u=Pei(5,r,s.answers,o),c=Cei(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,Rei(s.answers,r),Dei(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function wei(e,t,r){return{type:"input",guiType:"folder-browser",name:_l.appSelection,message:Lt("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:Lt("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,xei(e);let i;try{i=await M5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),mr.logger.error(Lt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${Lt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${Lt("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return Lt("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await m8t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await h8t(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 Cei(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:_l.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:Lt("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[_l.skipDataDownload]?.[0]){if(i=await E8t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:Lt("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:v8t.information}}}}function Oei(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=d8t(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:_l.toggleSelection,type:"confirm",message:Lt("prompts.toggleSelection.message"),labelTrue:Lt("prompts.toggleSelection.labelTrue"),labelFalse:Lt("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 Pei(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:()=>Lt("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:Lt("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,y8t.includes(c))return Lt("prompts.entityKey.validation.invalidKeyValueChars",{chars:y8t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return Lt("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!Aei.test(h.trim()))return Lt("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,Lt("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[_l.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await E8t(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 Dei(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:_l.skipDataDownload,type:"checkbox",message:Lt("prompts.skipDataDownload.message"),guiOptions:{hint:Lt("prompts.skipDataDownload.hint")},default:!1,choices:[{name:Lt("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function Rei(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await Q5t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:_l.updateMainServiceMetadata,type:"confirm",message:Lt("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:v8t.error}}}}function S8t(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 w8t=je(Ey()),C8t=je(Sy());var O8t=je(x8t());import{join as Hei}from"node:path";function P8t(e,t,r){Tu.resetExternalServiceCache();let n=zei(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:Lt("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return Tu.resetExternalServiceCache(),!0;let a=await Yei(o,r),u=(0,O8t.default)(i,a);return i.length=0,i.push(...u),await Wei(i,r),!0}}],valueHelpData:i}}async function Wei(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(";");Tu.externalServiceRequestCache[a]??=[];let l=(0,w8t.convert)((0,C8t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(Tu.externalServiceRequestCache[a].includes(p))return;Tu.externalServiceRequestCache[a].push(p);let d=await t.get(Hei(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 Yei(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function zei(e,t){let r=KL(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(W5t.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 mr=class e extends R8t.default{vscode;appWizard;static _logger=X8;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),zve(this.env,!0),this.options.force=!0,this.prompts=new Xei([{description:Lt("steps.odataDownloader.description"),name:Lt("steps.odataDownloader.name")},{description:Lt("steps.valueHelpSelection.description"),name:Lt("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(Lt("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await e_e(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await ga.initTelemetrySettings(),ga.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await _8t(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 mx(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??TC(ai.Webapp,ai.LocalService,ai.Mockdata)}if(this.state.updateMainServiceMetadata=s[_l.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[_l.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof qa){let{questions:o,valueHelpData:a}=P8t(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();ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot(TC(this.state.appRootPath));let r=Hbe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(Lt("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON(TC(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=TC(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=e8t(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=Z5t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),ga.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Lt("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();ga.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=TC(this.state.appRootPath,ai.Webapp);if(await E4(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 Z8(this.state.appRootPath,n,this.fs))}ga.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),ga.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Lt("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=TC(this.state.appRootPath,ai.Webapp,ai.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,D8t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[_l.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:Lt("steps.addConstraints.name"),description:Lt("steps.addConstraints.description")}]);let o=S8t(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 Ic()!==ln.cli&&this.appWizard?.showError(t,Kei.notification),new Error(t)}_configureLogging(t,r,n){let i=new K8(this.rootGeneratorName(),this.log,t,r,n);return i.info(Lt("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};export{mr as default};
|
|
733
733
|
/*! Bundled license information:
|
|
734
734
|
|
|
735
735
|
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.3",
|
|
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.0",
|
|
48
48
|
"@sap-ux/btp-utils": "2.0.0",
|
|
49
|
-
"@sap-ux/fiori-generator-shared": "1.0.
|
|
50
|
-
"@sap-ux/inquirer-common": "1.0.
|
|
49
|
+
"@sap-ux/fiori-generator-shared": "1.0.3",
|
|
50
|
+
"@sap-ux/inquirer-common": "1.0.3",
|
|
51
51
|
"@sap-ux/logger": "1.0.0",
|
|
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.0.
|
|
52
|
+
"@sap-ux/mockserver-config-writer": "1.0.2",
|
|
53
|
+
"@sap-ux/odata-service-inquirer": "3.0.3",
|
|
54
|
+
"@sap-ux/odata-service-writer": "1.0.2",
|
|
55
|
+
"@sap-ux/project-access": "2.0.2",
|
|
56
56
|
"@sap-ux/store": "2.0.0",
|
|
57
|
-
"@sap-ux/telemetry": "1.0.
|
|
58
|
-
"@sap-ux/ui5-config": "1.0.
|
|
57
|
+
"@sap-ux/telemetry": "1.0.3",
|
|
58
|
+
"@sap-ux/ui5-config": "1.0.1"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22.x"
|