@aventusjs/cli 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/RealServer.js CHANGED
@@ -424,7 +424,7 @@ this.clearWatchHistory = () => {
424
424
  \${1}
425
425
  }`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var bi=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),E.getInstance().onSettingsChangeHtml(()=>{this.languageService.setDataProviders(!0,[this.defaultProvider(),...this.loadOthersProviders()])})}getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}getClassByTag(e){let t=this.documentationInfo[e];return t?t.class:null}getGenericHTML(e){return vi[e]?vi[e]:null}getHTMLLanguageService(){return(0,C.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==w.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=E.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(O($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,C.newHTMLDataProvider)(n,{version:r.version||1,tags:r.tags||[],globalAttributes:r.globalAttributes||[],valueSets:r.valueSets||[]});t.push(a)}catch{}}}return t}getId(){return this.id+``}provideTags(){return this.customTagsData}provideAttributes(e){let t=[];if(e==`block`){let e={name:`name`,values:[]},n=this.currentFile?.slotsInfo??{};for(let t in n)e.values?.push({name:t,description:n[t].doc});t.push(e)}else if(t=[..._i],this.documentationInfo[e]){let n=this.documentationInfo[e].attributes;for(let e in n){let r=n[e];this.isAutoComplete?t.push({name:`!!`+r.name,description:JSON.stringify({description:r.description,type:r.type})}):t.push({name:r.name,description:r.description})}}return t}provideValues(e,t){if(e==`block`&&t==`name`){let e=[],t=this.currentFile?.slotsInfo??{};for(let n in t)e.push({name:n,description:t[n].doc});return e}if(t==`slot`&&this.currentFile&&this.currentFileOffset){let e=this.getTag(this.currentFile,this.currentFileOffset);if(e?.parent){let t=this.currentFile.build.getWebComponentDefinition(e.parent.tagName);if(t?.class){let e=this.currentFile.build.getSlotsInfo(t?.class),n=[];for(let t in e)n.push({name:t,description:e[t].doc});return n}}}return this.documentationInfo[e]&&this.documentationInfo[e].attributes[t]?this.documentationInfo[e].attributes[t].values:[]}currentFile=void 0;currentFileOffset=void 0;async doValidation(e){return[]}async doComplete(e,t){this.currentFile=e,this.currentFileOffset=e.file.documentUser.offsetAt(t);let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n){this.isAutoComplete=!0;let r=this.languageService.doComplete(e.file.documentUser,t,n);this.isAutoComplete=!1;for(let e of r.items){if(e.label.startsWith(`!!`)&&(e.kind=m.CompletionItemKind.Snippet,e.textEdit)){let t=e.label.replace(`!!`,``);if(e.textEdit.newText=e.textEdit.newText.replace(e.label,t),e.documentation){let t=JSON.parse(e.documentation.value);t.description==``?delete e.documentation:e.documentation=t.description,t.type==`boolean`&&(e.textEdit.newText=e.textEdit.newText.split(`=`)[0])}e.label=t}e.kind==m.CompletionItemKind.Property&&e.textEdit&&(e.textEdit.newText.endsWith(`>`)||(e.textEdit.newText+=`></`+e.textEdit.newText+`>`))}return r.items=r.items.concat(this.doCustomComplete(e,t)),this.currentFile=void 0,this.currentFileOffset=void 0,r}return this.currentFile=void 0,this.currentFileOffset=void 0,{isIncomplete:!1,items:[]}}doCustomComplete(e,t){let n=[];if(!e.fileParsed)return n;let r=e.file.documentUser,i=r.offsetAt(t);for(let t of e.fileParsed.tags){if(i<t.start)break;if(i>=t.openTagStart&&i<=t.openTagEnd)return n}let a=Re(r,Ue(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in yi)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:yi[e],insertTextFormat:C.InsertTextFormat.Snippet,insertTextMode:C.InsertTextMode.adjustIndentation});return n}getTag(e,t){if(!e.fileParsed)return null;for(let n of e.fileParsed.tags){if(t<n.start)break;if(t>=n.openTagStart&&t<=n.openTagEnd)return n}return null}async doHover(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n)return this.currentFile=void 0,{contents:{kind:`markdown`,value:n.documentation?.definitions.join(`
426
426
  `)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){return this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof on){let t=e.build.tsFiles[n._class.fileUri];return this.currentFile=void 0,[{uri:t.file.uri,range:{start:t.file.documentUser.positionAt(n.nameStart),end:t.file.documentUser.positionAt(n.nameEnd)}}]}else if(n instanceof un)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else return this.currentFile=void 0,this.build.htmlLanguageService.getLinkToStyle(e,t)}getLinkToLogic(e,t){let n=e.file.documentUser.offsetAt(t),r=e.tsFile,i=r?.fileParsed?.classes[r.getComponentName()];if(r&&i&&e.fileParsed){for(let t of e.fileParsed.interestPoints)if(n>=t.start&&n<=t.end){let r=null;if(t.type==`event`){let r=this.getTag(e,n);if(r){let n=e.build.getWebComponentDefinition(r.tagName);if(n){let e=n.class.getEvent(t.name);if(e)return e}}}if(t.type==`method`)r=i.methods[t.name];else if(t.type==`property`)r=i.properties[t.name];else if(t.type==`tag`){let n=this.documentationInfo[t.name];if(n){let t=this.internalDocumentationReverse[n.class];if(t&&t.fileParsed){for(let e in t.fileParsed.classes)if(e==n.class)return t.fileParsed.classes[e]}let r=e.build.getWebComponentDefinition(n.name,!0);if(r)return r.class}}return r}else if(t.end>=n)return null}return null}getLinkToStyle(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.scssFile;if(i&&e.fileParsed)for(let t of e.fileParsed.styleLinks){let e=t[0];r>=e.start&&r<=e.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(t[1].start),end:i.file.documentUser.positionAt(t[1].end)}})}return n}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(!this._allowRebuildDefinition)return;this.documentationInfo={};for(let e in this.extenalDocumentation){let t=this.extenalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}this.customTagsData=[{name:`block`,attributes:[{name:`name`}]}];let e=[];for(let t in this.documentationInfo){let n=this.documentationInfo[t];if(e.indexOf(n.name)==-1){e.push(n.name);let t=[],r={name:n.name,description:n.description,attributes:t};for(let e in n.attributes){let r=n.attributes[e];t.push({name:r.name,description:r.description,values:r.values})}this.customTagsData.push(r)}}}addExternalDefinition(e,t){this.extenalDocumentation[e]=t,this.rebuildDefinition()}removeExternalDefinition(e){delete this.extenalDocumentation[e],this.rebuildDefinition()}getInternalDefinition(e){let t=this.documentationInfo[e];if(t)return this.internalDocumentationReverse[t.class]}addInternalDefinition(e,t,n){this.internalDocumentation[e]=t;for(let e in t)this.internalDocumentationReverse[t[e].class]=n;this.rebuildDefinition()}removeInternalDefinition(e){let t=this.internalDocumentation[e];if(t)for(let e in t)delete this.internalDocumentationReverse[t[e].class];delete this.internalDocumentation[e],this.rebuildDefinition()}getInternalTagUri(e){return this.internalTagUri[e]}addInternalTagUri(e,t,n){this.internalTagUri[e]={uri:t,fullname:n}}removeInternalTagUri(e){for(let t in this.internalTagUri)if(this.internalTagUri[t].uri==e){delete this.internalTagUri[t];return}}};function xi(e){let t=``,n=[],r=r=>{for(let i of r){let r=wn.compileTs(i,e);e.build.addNamespace(i.namespace),n.push(r),t+=r.debugTxt}};e.fileParsed&&(r(Object.values(e.fileParsed.classes)),r(Object.values(e.fileParsed.enums)),r(Object.values(e.fileParsed.aliases)),r(Object.values(e.fileParsed.functions)),r(Object.values(e.fileParsed.variables)));let i=e.file.path.replace(`.avt`,`.js`);return t==``?(0,u.existsSync)(i)&&(0,u.unlinkSync)(i):(0,u.writeFileSync)(i,t),n}var Si=class extends hn{get extension(){return T.Data}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){let e=this.file.documentUser;this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IData`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IData`],customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]});let t=this.fileParsed;if(t)for(let n in t.classes){let r=t.classes[n];if(!r.isInterface){for(let t in r.properties){let n=r.properties[t];!n.isAbstract&&n.isGetSet&&!n.overrideNullable&&n.defaultValue===null&&this.diagnostics.push(k(e,`Property '${n.name}' has no initializer and is not definitely assigned.`,n.nameStart,n.nameEnd,1013))}let t=r,n=!1;for(;t!=null;){if(t.propertiesStatic.Fullname!=null){n=!0;break}t=t.parentClass}n||this.diagnostics.push(k(e,`Missing static property Fullname`,r.nameStart,r.nameEnd,1022))}}return this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ci=class extends hn{get extension(){return T.Definition}constructor(e,t){super(e,t),this._contentForLanguageService=this.file.contentUser}async onContentChange(){this._contentForLanguageService=this.file.contentUser}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return this.build.tsLanguageService.doComplete(e,t)}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return this.build.tsLanguageService.format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return this.build.tsLanguageService.onRename(e,t,n)}},wi=class extends hn{get extension(){return T.Lib}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.validateRules({allow_variables:!0,allow_function:!0,customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ti=class extends hn{get extension(){return T.RAM}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IRam`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IRam`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ei=class extends hn{get extension(){return T.State}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.file.documentUser,this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IStateManager`,`IState`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IStateManager`,`Aventus.IState`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Di=class extends hn{get extension(){return T.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,T.Definition),n=``,r=``;t.endsWith(T.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*?)\}/gm,`$1`));let i=e.replace(this.extension,T.DefinitionNpm);r=i.endsWith(T.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=Je(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(T.Config,``),``);o=o.replace(this.extension,`.js`),this.setCompileResult([{classDoc:``,classScript:`!staticClass_`+a,compiled:this.file.contentUser,hotReload:``,docVisible:n,npm:{namespace:``,defTs:r,src:this.file.contentUser,exportPath:o,uri:this.file.uri},docInvisible:``,debugTxt:``,dependencies:[],uri:this.file.uri,required:!0,type:0,isExported:{external:!1,internal:!1},convertibleName:``,useDecorator:!1}])}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}};function Oi(e,t){let n=null;return e.uri.endsWith(T.ComponentLogic)?n=new F(e,t):e.uri.endsWith(T.Data)?n=new Si(e,t):e.uri.endsWith(T.Lib)?n=new wi(e,t):e.uri.endsWith(T.RAM)?n=new Ti(e,t):e.uri.endsWith(T.State)?n=new Ei(e,t):e.uri.endsWith(T.Static)?n=new Di(e,t):e.uri.endsWith(T.Definition)&&(n=new Ci(e,t)),n}var ki=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Ai=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ji=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Mi=o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(require("child_process"),require("crypto")):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],r):typeof e==`object`?e["electron-machine-id"]=r(require("child_process"),require("crypto")):n[`electron-machine-id`]=r(n.child_process,n.crypto)})(e,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),"a",{get:function(){return 7}}).a!=7})},function(e,t,n){"use strict";var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,te,S,ne=function(e){if(!p&&e in oe)return oe[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},re=t+` Iterator`,ie=y==g,ae=!1,oe=e.prototype,C=oe[f]||oe[m]||y&&oe[y],se=C||ne(y),ce=y?ie?ne(`entries`):se:void 0,le=t==`Array`&&oe.entries||C;if(le&&(S=d(le.call(new e)),S!==Object.prototype&&(u(S,re,!0),r||s(S,f)||o(S,f,_))),ie&&C&&C.name!==g&&(ae=!0,se=function(){return C.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,se),c[t]=se,c[re]=_,y)if(ee={values:ie?se:ne(g),keys:b?se:ne(h),entries:ce},x)for(te in ee)te in oe||a(oe,te,ee[te]);else i(i.P+i.F*(p||ae),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
427
- `)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,"__esModule",{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){"use strict";var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){"use strict";var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){"use strict";var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,te=function(){},S=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(te,te)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(te)instanceof t}catch{}}(),ne=function(e,t){return e===t||e===x&&t===a},re=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ie=function(e){return ne(x,e)?new ae(e):new i(e)},ae=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},oe=function(e){try{e()}catch(e){return{error:e}}},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&le(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=re(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&se(e)})}},se=function(e){g.call(s,function(){var t,n,r,i=e._v;if(ce(e)&&(t=oe(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||ce(e)?2:1),e._a=void 0,t)throw t.error})},ce=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!ce(t.promise))return!1;return!0},le=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},ue=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),C(t,!0))},de=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=re(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(de,r,1),c(ue,r,1))}catch(e){ue.call(r,e)}}):(n._v=e,n._s=1,C(n,!1))}catch(e){ue.call({_w:n,_d:!1},e)}}};S||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(de,this,1),c(ue,this,1))}catch(e){ue.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=ie(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),ae=function(){var e=new r;this.promise=e,this.resolve=c(de,e,1),this.reject=c(ue,e,1)}),u(u.G+u.W+u.F*!S,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!S,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!S),v,{resolve:function(e){if(e instanceof x&&ne(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(S&&n(46)(function(e){x.all(e).catch(te)})),v,{all:function(e){var t=this,n=ie(t),r=n.resolve,i=n.reject,a=oe(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=ie(t),r=n.reject,i=oe(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){"use strict";var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("crypto")}])})}))(),Ni=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=E.getInstance().hiddenSettings.store,this._settings}static get token(){return this.settings.token}static get isConnected(){return this.token!=``}static setSettings(e){let t={...this.settings,...e};E.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Mi.machineId)(),r=(0,x.hostname)(),i=await this.post(`/login`,{username:e,password:t,machineId:n,machineName:r},{withoutBearer:!0});return i?(this.setSettings({token:i,username:e}),!0):!1}static async disconnect(){await this.post(`/logout`),this.setSettings({token:``,username:void 0})}static async publishPackage(e){let t=new FormData;t.append(`name`,e.buildConfig.fullname),t.append(`description`,e.buildConfig.description??``),t.append(`version`,e.buildConfig.version),e.buildConfig.organization&&t.append(`organization`,e.buildConfig.organization),e.buildConfig.documentation&&t.append(`documentation`,e.buildConfig.documentation),e.buildConfig.repository&&t.append(`repository`,e.buildConfig.repository);for(let n of e.buildConfig.tags)t.append(`tags[]`,n);let n=(0,f.join)(Ri.getInstance().getPath(),`@locals`,e.buildConfig.fullname+T.Package);if(!(0,u.existsSync)(n))return!1;let r=new Blob([(0,u.readFileSync)(n)],{type:`text/plain`});t.append(`packageFile`,r,e.buildConfig.fullname+T.Package);let i=e.project.getConfigFile().folderPath;if(e.buildConfig.readme){let n;if(e.buildConfig.readme.startsWith(`.`)){let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}else if((0,u.existsSync)(e.buildConfig.readme))n=e.buildConfig.readme;else{let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)((0,f.join)(i,n))],{type:`text/plain`});t.append(`readMe`,r,`README.md`)}else{let e=(0,u.readdirSync)(i).find(e=>e.toLowerCase()===`readme.md`);if(e){let n=new Blob([(0,u.readFileSync)((0,f.join)(i,e))],{type:`text/plain`});t.append(`readMe`,n,`README.md`)}}return await this.postWithErrors(`/package/publish`,t)}static async publishTemplate(e){let t=new FormData;t.append(`name`,e.name),t.append(`description`,e.description),t.append(`version`,e.version),t.append(`is_project`,e.isProject?`1`:`0`),t.append(`is_global`,e.isGlobal?`1`:`0`),e.organization&&t.append(`organization`,e.organization),e.documentation&&t.append(`documentation`,e.documentation),e.repository&&t.append(`repository`,e.repository);for(let n of e.tags)t.append(`tags[]`,n);let n=e.folderPath,r=(0,u.readdirSync)(n).find(e=>e.toLowerCase()===`readme.md`);if(r){let e=new Blob([(0,u.readFileSync)((0,f.join)(n,r))],{type:`text/plain`});t.append(`readMe`,e,`README.md`)}let i=(0,f.dirname)(e.config),a=(0,f.join)($.savePath,`temp`,e.name+`.zip`);await this.zip(i,a);let o=new Blob([(0,u.readFileSync)(a)],{type:`application/zip`});t.append(`templateFile`,o,e.name+`.zip`);let s=await this.postWithErrors(`/template/publish`,t);return(0,u.unlinkSync)(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Pi){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null;try{let a={};if(n instanceof FormData||(a[`Content-Type`]=`application/json`),!r?.withoutBearer){let e=await(0,Mi.machineId)();a.Authorization=`Bearer `+(this.token+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:a}),i.status==401)return new Pi([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Pi([{code:403,message:`You must connect to your account first`}]);let o=await i.text(),s;try{s=JSON.parse(o)}catch(e){throw $.error(o),e}return s.errors?s.errors.length>0?new Pi(s.errors):s.result:new Pi([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Pi([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,fe.create)(`zip`,{zlib:{level:9}});i.on(`close`,()=>{n()}),a.on(`error`,e=>{r(e)}),a.pipe(i),a.directory(e,!1,e=>e.name.startsWith(`.git/`)||e.name===`.git`?!1:e),await a.finalize()})}},Pi=class{errors;constructor(e){this.errors=e}},Fi=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ii=class{static files={};static done=!1;static register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&this.write())}static write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}},n=!1;for(let e in this.files){let r=this.files[e].srcInfo.available;for(let e of r)if(e.tagName){let r=e.tagName;t.html.snippets[r]=`<${r}>\${1}</${r}>`,n=!0}}if(n){let n=(0,f.join)(O($.getWorkspaceUri()),`.aventus`,`emmet`),r=(0,f.join)(n,`snippets.json`);if(!e&&!(0,u.existsSync)(r)){this.done=!0;return}(0,u.existsSync)(n)||(0,u.mkdirSync)(n,{recursive:!0}),qe(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new Li(this.files[e]).getContent():``}},Li=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/\|/g,`&vert;`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(x.EOL)??``,isAbstract:!1};this.parts.push(i)}loadClass(e){let t=this.file.fileParsed.classes[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r={name:n,isWebComponent:t.isWebcomponent,tag:e.tagName?`&lt;${e.tagName}&gt;&lt;/${e.tagName}&gt;`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(x.EOL)??``,import:`import { ${t.name} } from "${this.file.name}:${t.namespace}.package.avt"`,parent:t.parentClass?.fullName,impl:t.implementsType.map(e=>this.getType(e)).join(`, `)};if(Object.keys(t.properties).length>0){r.jsProps=[];for(let e in t.properties){let n=this.loadProperty(t.properties[e]);n&&r.jsProps.push(n)}}if(Object.keys(t.propertiesStatic).length>0){r.jsPropsStatic=[];for(let e in t.propertiesStatic){let n=this.loadProperty(t.propertiesStatic[e]);n&&r.jsPropsStatic.push(n)}}if(Object.keys(t.methods).length>0){r.jsMethods=[];for(let e in t.methods){let n=this.loadMethod(t.methods[e]);n&&r.jsMethods.push(n)}}if(Object.keys(t.methodsStatic).length>0){r.jsMethodsStatic=[];for(let e in t.methodsStatic){let n=this.loadMethod(t.methodsStatic[e]);n&&r.jsMethodsStatic.push(n)}}if(t.isWebcomponent){if(e.tagName&&this.scss[e.tagName]&&this.scss[e.tagName].length>0){let t=this.scss[e.tagName];r.cssProps=[];for(let e of t)r.cssProps.push({name:e.name,type:e.type??``,description:e.documentation??``})}if(e.slots&&Object.keys(e.slots).length>0){r.htmlSlots=[];for(let t in e.slots)r.htmlSlots.push({name:t,description:e.slots[t].doc})}}this.overviews.push({name:t.fullName,type:r.isWebComponent?r.type+` (Webcomponent)`:r.type,description:r.tag?r.description+` (`+r.tag+`)`:r.description}),this.parts.push(r)}loadProperty(e){if(e.isPrivate||e.isProtected)return null;let t;return e.decorators.find(e=>In.is(e))&&(t=`@Property()`),e.decorators.find(e=>Fi.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Hn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Jn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(x.EOL)??``,decorator:t}}loadMethod(e){if(e.isPrivate||e.isProtected)return null;let t=e.name;if(e.node.typeParameters){let n=[];for(let t of e.node.typeParameters){let e=t.name.getText();t.constraint&&(e+=` extends `+this.getType(t.constraint)),t.default&&(e+=` = `+this.getType(t.default)),n.push(e)}n.length>0&&(t+=`<${n.join(`, `)}>`)}let n=[];for(let t of e.node.parameters){let e=t.name.getText();t.type?e+=`: `+this.getType(t.type):e+=`: any`,n.push(e)}return t+=`(${n.join(`, `)})`,{name:t,result:e.node.type?this.getType(e.node.type):`any`,description:e.documentation?.definitions.join(x.EOL)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(x.EOL)}writeOverview(){this.add(`# `+this.file.name),this.line(),this.file.description&&(this.add(this.file.description),this.line()),this.add(`## Overview`),this.line(),this.addColumnsHeader([`Nom`,`Type`,`Description`]),this.overviews.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.overviews)this.addColumns([`[${e.name}](${e.name.toLowerCase()})`,e.type,e.description??``]);this.line()}writeContent(){this.parts.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.parts)this.add(`## `+e.name),this.line(),e.description&&(this.add(`${e.description}`),this.line()),this.isManifestClass(e)?this.writeClass(e):this.isManifestFunction(e)&&this.writeFunction(e),e.example&&(this.add(`### Example`),this.line(),this.add(e.example))}writeClass(e){e.isWebComponent?this.add(` - Type : ${e.type} (Webcomponent)`):this.add(` - Type : ${e.type}`),e.tag&&this.add(` - Tag : ${e.tag}`),this.add(` - Import : ${e.import}`),e.parent&&this.add(` - Parent : ${e.parent}`),e.impl&&this.add(` - Implements : ${e.impl}`);let t=e.isWebComponent;if(this.line(),e.jsProps&&e.jsProps.length>0&&(this.add(`### JS Props`),this.line(),this.writeProps(e.jsProps,t),this.line()),e.jsMethods&&e.jsMethods.length>0&&(this.add(`### Methods`),this.line(),this.writeMethods(e.jsMethods),this.line()),e.jsPropsStatic&&e.jsPropsStatic.length>0&&(this.add(`### JS Props Static`),this.line(),this.writeProps(e.jsPropsStatic,t),this.line()),e.jsMethodsStatic&&e.jsMethodsStatic.length>0&&(this.add(`### Methods Static`),this.line(),this.writeMethods(e.jsMethodsStatic),this.line()),e.htmlSlots&&e.htmlSlots.length>0){this.add(`### HTML Slots`),this.line(),this.addColumnsHeader([`Name`,`Description`]);for(let t of e.htmlSlots)this.addColumns([t.name,t.description??``]);this.line()}e.cssProps&&e.cssProps.length>0&&(this.add(`### CSS Props`),this.line(),this.writeProps(e.cssProps,!1),this.line())}writeFunction(e){this.add(` - Return : ${e.result}`)}writeProps(e,t){if(e.length!=0)if(t){this.addColumnsHeader([`Name`,`Type`,`Description`,`Decorator`]);for(let t of e)this.addColumns([t.name,t.type,t.description,t.decorator??``])}else{this.addColumnsHeader([`Name`,`Type`,`Description`]);for(let t of e)this.addColumns([t.name,t.type,t.description])}}writeMethods(e){if(e.length!=0){this.addColumnsHeader([`Name`,`Return`,`Description`]);for(let t of e){let e=t.description??``;t.isAbstract&&(e=`(abstract) `+e),this.addColumns([t.name,t.result,e])}}}line(){this.content.push(``)}add(e){this.content.push(e)}addColumns(e){let t=`| ${e.map(e=>e.replace(/\r\n|\n/g,``).replace(/ {2,}/g,` `).trim()).join(` | `)} |`;this.add(t)}addColumnsHeader(e){this.addColumns(e);let t=[];for(let n=0;n<e.length;n++)t.push(`---`);let n=`| ${t.join(` | `)} |`;this.add(n)}},Ri=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={};for(let n in e.dependencies){let a=e.dependencies[n],o=await this.loadDependency(n,a,e,t,r);o&&(i[o.name]=a.include??`need`)}for(let e in r)i[e]||(i[e]=r[e].include);r[`Aventus@Main`]||await this.loadDependency(`Aventus@Main`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r),t?.buildConfig.i18n!==void 0&&!r[`Aventus@I18n`]&&await this.loadDependency(`Aventus@I18n`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r);let a=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,a)}for(let e of a){let t=r[e];t.file.loadWebComponents(),n.files.push(t.file);let a=i[e]??`need`;a==`full`?(n.dependencyFullUris.push(t.uri),n.dependencyUris.push(t.uri)):a==`need`&&(n.dependencyNeedUris.push(t.uri),n.dependencyUris.push(t.uri))}return n}orderLoop(e,t,n,r){let i=r.indexOf(e);if(i!=-1)return i+1;let a=0;for(let e of t.dependencies)if(n[e.name]){let t=this.orderLoop(e.name,n[e.name],n,r);t>=0&&t>a&&(a=t)}return r.splice(a,0,e),r.length}async loadDependency(e,t,n,r,i){let a,o;if(this.predefinedPaths[e]){t.uri=this.predefinedPaths[e];let n=D(t.uri);a=await this.loadByUri(r,n),o=n}else if(t.uri)if(t.uri.startsWith(`http`))$.showErrorMessage(`http package isn't supported right now. Plz use the store`);else{let e=D(t.uri);a=await this.loadByUri(r,e),o=e}else if(t.isLocal){let t=await this.loadLocal(e,r);a=t.file,o=t.uri}else if(t.version){let n=await this.loadStore(e,t.version,r);n?(a=n.file,o=n.uri):$.showErrorMessage(`Can't load `+e+` from the store`)}else $.showErrorMessage(`You need to define a version to load a package via the store (`+e+`)`);if(o&&a){let s=t.version?this.parseVersion(t.version):{major:-1,minor:-1,patch:-1};if(t.npm)a.npmUri=t.npm;else if(this.predefinedNpm[e])a.npmUri=this.predefinedNpm[e];else{let e=/\/\/ npm:(.*)$/m.exec(a.file.contentUser);e&&(a.npmUri=e[1])}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c&&(a.description=c[1]);let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let t in e.dependencies){let a=e.dependencies[t];typeof a==`string`&&(a={version:a});let o=await this.loadDependency(t,a,n,r,i);if(o){let t=i[e.name].dependencies.find(e=>e.name==o.name),n=`need`;a.subDependenciesInclude&&a.subDependenciesInclude[o.name]&&(n=a.subDependenciesInclude[o.name]),t?(t.include==`none`&&n!=`none`||t.include==`need`&&n==`full`)&&(t.include=n):i[e.name].dependencies.push({name:o.name,include:n})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}Ii.register(a)}return a}async loadByUri(e,t){let n=await R.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=D((0,f.join)(this.path,`@locals`,e));n.endsWith(T.Package)||(n+=T.Package);let r=await R.getInstance().registerFilePackage(n),i=this.loadPackage(r,t);return{uri:n,file:i}}async loadStore(e,t,n){let r=(0,f.join)(this.path,`store`,e,t),i=(0,u.existsSync)(r),{major:a,minor:o,patch:s}=this.parseVersion(t),c=null;if(i&&(c=this.findPackage(r),c||(i=!1)),!i){(0,u.existsSync)(r)&&(0,u.rmSync)(r,{force:!0,recursive:!0}),(0,u.mkdirSync)(r,{recursive:!0});let n=(0,f.join)(r,`temp.zip`);if(!await this.downloadFile(n,Ni.url+`/package/download/${e}/${t}`)||!await this.extractZip(n,r))return null;if((0,u.rmSync)(n,{force:!0}),c=this.findPackage(r),!c)return;let i=await this.readFirstLine(c),a=/\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)/g.exec(i);if(!a)return console.error(`Invalid package header for "${e}@${t}". First line:`,JSON.stringify(i)),null;let o=a[1],s=Number(a[2]),l=Number(a[3]),d=Number(a[4]),p=s+`.`+l+`.`+d;if(o!==e)return console.error(`Package name mismatch: requested "${e}", downloaded "${o}"`),null;if(p!==t)return console.error(`Package version mismatch: requested "${t}", downloaded "${p}"`),null}if(!c)return console.error(`Package file not found after extracting "${e}@${t}" into "${r}"`),null;let l=D(c),d=await R.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,de.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(T.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=xn.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new xn(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}};(t.startsWith(`https:`)?ue.get:ne.get)(t,i=>{let a=i.statusCode??0;if(a>=300&&a<400&&i.headers.location){i.resume(),this.downloadFile(e,i.headers.location).then(n).catch(()=>n(!1));return}if(a<200||a>=300){console.error(`Download failed: HTTP ${a} for ${t}`),i.resume(),r(),n(!1);return}let o=(0,u.createWriteStream)(e);o.on(`error`,t=>{console.error(`File write error for ${e}:`,t),i.destroy(),r(),n(!1)}),i.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),o.destroy(),r(),n(!1)}),o.on(`finish`,()=>{o.close(t=>{if(t){console.error(`File close error for ${e}:`,t),r(),n(!1);return}n(!0)})}),i.pipe(o)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),r(),n(!1)});let i=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?ue.get:ne.get)(t,function(t){t.pipe(i),i.on(`finish`,()=>{i.close(),n(!0)}),i.on(`error`,()=>{i.close(),(0,u.unlinkSync)(e),n(!1)})})}catch{i.close(),(0,u.unlinkSync)(e),n(!1)}})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``,a=0,o;r.on(`data`,function(e){o=e.indexOf(`
427
+ `)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,"__esModule",{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){"use strict";var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){"use strict";var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){"use strict";var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,te=function(){},S=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(te,te)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(te)instanceof t}catch{}}(),ne=function(e,t){return e===t||e===x&&t===a},re=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ie=function(e){return ne(x,e)?new ae(e):new i(e)},ae=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},oe=function(e){try{e()}catch(e){return{error:e}}},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&le(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=re(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&se(e)})}},se=function(e){g.call(s,function(){var t,n,r,i=e._v;if(ce(e)&&(t=oe(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||ce(e)?2:1),e._a=void 0,t)throw t.error})},ce=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!ce(t.promise))return!1;return!0},le=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},ue=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),C(t,!0))},de=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=re(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(de,r,1),c(ue,r,1))}catch(e){ue.call(r,e)}}):(n._v=e,n._s=1,C(n,!1))}catch(e){ue.call({_w:n,_d:!1},e)}}};S||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(de,this,1),c(ue,this,1))}catch(e){ue.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=ie(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),ae=function(){var e=new r;this.promise=e,this.resolve=c(de,e,1),this.reject=c(ue,e,1)}),u(u.G+u.W+u.F*!S,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!S,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!S),v,{resolve:function(e){if(e instanceof x&&ne(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(S&&n(46)(function(e){x.all(e).catch(te)})),v,{all:function(e){var t=this,n=ie(t),r=n.resolve,i=n.reject,a=oe(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=ie(t),r=n.reject,i=oe(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){"use strict";var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("crypto")}])})}))(),Ni=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=E.getInstance().hiddenSettings.store,this._settings}static get token(){return this.settings.token}static get isConnected(){return this.token!=``}static setSettings(e){let t={...this.settings,...e};E.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Mi.machineId)(),r=(0,x.hostname)(),i=await this.post(`/login`,{username:e,password:t,machineId:n,machineName:r},{withoutBearer:!0});return i?(this.setSettings({token:i,username:e}),!0):!1}static async disconnect(){await this.post(`/logout`),this.setSettings({token:``,username:void 0})}static async publishPackage(e){let t=new FormData;t.append(`name`,e.buildConfig.fullname),t.append(`description`,e.buildConfig.description??``),t.append(`version`,e.buildConfig.version),e.buildConfig.organization&&t.append(`organization`,e.buildConfig.organization),e.buildConfig.documentation&&t.append(`documentation`,e.buildConfig.documentation),e.buildConfig.repository&&t.append(`repository`,e.buildConfig.repository);for(let n of e.buildConfig.tags)t.append(`tags[]`,n);let n=(0,f.join)(Ri.getInstance().getPath(),`@locals`,e.buildConfig.fullname+T.Package);if(!(0,u.existsSync)(n))return!1;let r=new Blob([(0,u.readFileSync)(n)],{type:`text/plain`});t.append(`packageFile`,r,e.buildConfig.fullname+T.Package);let i=e.project.getConfigFile().folderPath;if(e.buildConfig.readme){let n;if(e.buildConfig.readme.startsWith(`.`)){let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}else if((0,u.existsSync)(e.buildConfig.readme))n=e.buildConfig.readme;else{let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)((0,f.join)(i,n))],{type:`text/plain`});t.append(`readMe`,r,`README.md`)}else{let e=(0,u.readdirSync)(i).find(e=>e.toLowerCase()===`readme.md`);if(e){let n=new Blob([(0,u.readFileSync)((0,f.join)(i,e))],{type:`text/plain`});t.append(`readMe`,n,`README.md`)}}return await this.postWithErrors(`/package/publish`,t)}static async publishTemplate(e){let t=new FormData;t.append(`name`,e.name),t.append(`description`,e.description),t.append(`version`,e.version),t.append(`is_project`,e.isProject?`1`:`0`),t.append(`is_global`,e.isGlobal?`1`:`0`),e.organization&&t.append(`organization`,e.organization),e.documentation&&t.append(`documentation`,e.documentation),e.repository&&t.append(`repository`,e.repository);for(let n of e.tags)t.append(`tags[]`,n);let n=e.folderPath,r=(0,u.readdirSync)(n).find(e=>e.toLowerCase()===`readme.md`);if(r){let e=new Blob([(0,u.readFileSync)((0,f.join)(n,r))],{type:`text/plain`});t.append(`readMe`,e,`README.md`)}let i=(0,f.dirname)(e.config),a=(0,f.join)($.savePath,`temp`,e.name+`.zip`);await this.zip(i,a);let o=new Blob([(0,u.readFileSync)(a)],{type:`application/zip`});t.append(`templateFile`,o,e.name+`.zip`);let s=await this.postWithErrors(`/template/publish`,t);return(0,u.unlinkSync)(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Pi){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null;try{let a={};if(n instanceof FormData||(a[`Content-Type`]=`application/json`),!r?.withoutBearer){let e=await(0,Mi.machineId)();a.Authorization=`Bearer `+(this.token+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:a}),i.status==401)return new Pi([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Pi([{code:403,message:`You must connect to your account first`}]);let o=await i.text(),s;try{s=JSON.parse(o)}catch(e){throw $.error(o),e}return s.errors?s.errors.length>0?new Pi(s.errors):s.result:new Pi([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Pi([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,fe.create)(`zip`,{zlib:{level:9}});i.on(`close`,()=>{n()}),a.on(`error`,e=>{r(e)}),a.pipe(i),a.directory(e,!1,e=>e.name.startsWith(`.git/`)||e.name===`.git`?!1:e),await a.finalize()})}},Pi=class{errors;constructor(e){this.errors=e}},Fi=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ii=class{static files={};static done=!1;static register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&this.write())}static write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}},n=!1;for(let e in this.files){let r=this.files[e].srcInfo.available;for(let e of r)if(e.tagName){let r=e.tagName;t.html.snippets[r]=`<${r}>\${1}</${r}>`,n=!0}}if(n){let n=(0,f.join)(O($.getWorkspaceUri()),`.aventus`,`emmet`),r=(0,f.join)(n,`snippets.json`);if(!e&&!(0,u.existsSync)(r)){this.done=!0;return}(0,u.existsSync)(n)||(0,u.mkdirSync)(n,{recursive:!0}),qe(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new Li(this.files[e]).getContent():``}},Li=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/\|/g,`&vert;`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(x.EOL)??``,isAbstract:!1};this.parts.push(i)}loadClass(e){let t=this.file.fileParsed.classes[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r={name:n,isWebComponent:t.isWebcomponent,tag:e.tagName?`&lt;${e.tagName}&gt;&lt;/${e.tagName}&gt;`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(x.EOL)??``,import:`import { ${t.name} } from "${this.file.name}:${t.namespace}.package.avt"`,parent:t.parentClass?.fullName,impl:t.implementsType.map(e=>this.getType(e)).join(`, `)};if(Object.keys(t.properties).length>0){r.jsProps=[];for(let e in t.properties){let n=this.loadProperty(t.properties[e]);n&&r.jsProps.push(n)}}if(Object.keys(t.propertiesStatic).length>0){r.jsPropsStatic=[];for(let e in t.propertiesStatic){let n=this.loadProperty(t.propertiesStatic[e]);n&&r.jsPropsStatic.push(n)}}if(Object.keys(t.methods).length>0){r.jsMethods=[];for(let e in t.methods){let n=this.loadMethod(t.methods[e]);n&&r.jsMethods.push(n)}}if(Object.keys(t.methodsStatic).length>0){r.jsMethodsStatic=[];for(let e in t.methodsStatic){let n=this.loadMethod(t.methodsStatic[e]);n&&r.jsMethodsStatic.push(n)}}if(t.isWebcomponent){if(e.tagName&&this.scss[e.tagName]&&this.scss[e.tagName].length>0){let t=this.scss[e.tagName];r.cssProps=[];for(let e of t)r.cssProps.push({name:e.name,type:e.type??``,description:e.documentation??``})}if(e.slots&&Object.keys(e.slots).length>0){r.htmlSlots=[];for(let t in e.slots)r.htmlSlots.push({name:t,description:e.slots[t].doc})}}this.overviews.push({name:t.fullName,type:r.isWebComponent?r.type+` (Webcomponent)`:r.type,description:r.tag?r.description+` (`+r.tag+`)`:r.description}),this.parts.push(r)}loadProperty(e){if(e.isPrivate||e.isProtected)return null;let t;return e.decorators.find(e=>In.is(e))&&(t=`@Property()`),e.decorators.find(e=>Fi.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Hn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Jn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(x.EOL)??``,decorator:t}}loadMethod(e){if(e.isPrivate||e.isProtected)return null;let t=e.name;if(e.node.typeParameters){let n=[];for(let t of e.node.typeParameters){let e=t.name.getText();t.constraint&&(e+=` extends `+this.getType(t.constraint)),t.default&&(e+=` = `+this.getType(t.default)),n.push(e)}n.length>0&&(t+=`<${n.join(`, `)}>`)}let n=[];for(let t of e.node.parameters){let e=t.name.getText();t.type?e+=`: `+this.getType(t.type):e+=`: any`,n.push(e)}return t+=`(${n.join(`, `)})`,{name:t,result:e.node.type?this.getType(e.node.type):`any`,description:e.documentation?.definitions.join(x.EOL)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(x.EOL)}writeOverview(){this.add(`# `+this.file.name),this.line(),this.file.description&&(this.add(this.file.description),this.line()),this.add(`## Overview`),this.line(),this.addColumnsHeader([`Nom`,`Type`,`Description`]),this.overviews.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.overviews)this.addColumns([`[${e.name}](${e.name.toLowerCase()})`,e.type,e.description??``]);this.line()}writeContent(){this.parts.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.parts)this.add(`## `+e.name),this.line(),e.description&&(this.add(`${e.description}`),this.line()),this.isManifestClass(e)?this.writeClass(e):this.isManifestFunction(e)&&this.writeFunction(e),e.example&&(this.add(`### Example`),this.line(),this.add(e.example))}writeClass(e){e.isWebComponent?this.add(` - Type : ${e.type} (Webcomponent)`):this.add(` - Type : ${e.type}`),e.tag&&this.add(` - Tag : ${e.tag}`),this.add(` - Import : ${e.import}`),e.parent&&this.add(` - Parent : ${e.parent}`),e.impl&&this.add(` - Implements : ${e.impl}`);let t=e.isWebComponent;if(this.line(),e.jsProps&&e.jsProps.length>0&&(this.add(`### JS Props`),this.line(),this.writeProps(e.jsProps,t),this.line()),e.jsMethods&&e.jsMethods.length>0&&(this.add(`### Methods`),this.line(),this.writeMethods(e.jsMethods),this.line()),e.jsPropsStatic&&e.jsPropsStatic.length>0&&(this.add(`### JS Props Static`),this.line(),this.writeProps(e.jsPropsStatic,t),this.line()),e.jsMethodsStatic&&e.jsMethodsStatic.length>0&&(this.add(`### Methods Static`),this.line(),this.writeMethods(e.jsMethodsStatic),this.line()),e.htmlSlots&&e.htmlSlots.length>0){this.add(`### HTML Slots`),this.line(),this.addColumnsHeader([`Name`,`Description`]);for(let t of e.htmlSlots)this.addColumns([t.name,t.description??``]);this.line()}e.cssProps&&e.cssProps.length>0&&(this.add(`### CSS Props`),this.line(),this.writeProps(e.cssProps,!1),this.line())}writeFunction(e){this.add(` - Return : ${e.result}`)}writeProps(e,t){if(e.length!=0)if(t){this.addColumnsHeader([`Name`,`Type`,`Description`,`Decorator`]);for(let t of e)this.addColumns([t.name,t.type,t.description,t.decorator??``])}else{this.addColumnsHeader([`Name`,`Type`,`Description`]);for(let t of e)this.addColumns([t.name,t.type,t.description])}}writeMethods(e){if(e.length!=0){this.addColumnsHeader([`Name`,`Return`,`Description`]);for(let t of e){let e=t.description??``;t.isAbstract&&(e=`(abstract) `+e),this.addColumns([t.name,t.result,e])}}}line(){this.content.push(``)}add(e){this.content.push(e)}addColumns(e){let t=`| ${e.map(e=>e.replace(/\r\n|\n/g,``).replace(/ {2,}/g,` `).trim()).join(` | `)} |`;this.add(t)}addColumnsHeader(e){this.addColumns(e);let t=[];for(let n=0;n<e.length;n++)t.push(`---`);let n=`| ${t.join(` | `)} |`;this.add(n)}},Ri=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={};for(let n in e.dependencies){let a=e.dependencies[n],o=await this.loadDependency(n,a,e,t,r);o&&(i[o.name]=a.include??`need`)}for(let e in r)i[e]||(i[e]=r[e].include);r[`Aventus@Main`]||await this.loadDependency(`Aventus@Main`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r),t?.buildConfig.i18n!==void 0&&!r[`Aventus@I18n`]&&await this.loadDependency(`Aventus@I18n`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r);let a=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,a)}for(let e of a){let t=r[e];t.file.loadWebComponents(),n.files.push(t.file);let a=i[e]??`need`;a==`full`?(n.dependencyFullUris.push(t.uri),n.dependencyUris.push(t.uri)):a==`need`&&(n.dependencyNeedUris.push(t.uri),n.dependencyUris.push(t.uri))}return n}orderLoop(e,t,n,r){let i=r.indexOf(e);if(i!=-1)return i+1;let a=0;for(let e of t.dependencies)if(n[e.name]){let t=this.orderLoop(e.name,n[e.name],n,r);t>=0&&t>a&&(a=t)}return r.splice(a,0,e),r.length}async loadDependency(e,t,n,r,i){let a,o;if(this.predefinedPaths[e]){t.uri=this.predefinedPaths[e];let n=D(t.uri);a=await this.loadByUri(r,n),o=n}else if(t.uri)if(t.uri.startsWith(`http`))$.showErrorMessage(`http package isn't supported right now. Plz use the store`);else{let e=D(t.uri);a=await this.loadByUri(r,e),o=e}else if(t.isLocal){let t=await this.loadLocal(e,r);a=t.file,o=t.uri}else if(t.version){let n=await this.loadStore(e,t.version,r);n?(a=n.file,o=n.uri):$.showErrorMessage(`Can't load `+e+` from the store`)}else $.showErrorMessage(`You need to define a version to load a package via the store (`+e+`)`);if(o&&a){let s=t.version?this.parseVersion(t.version):{major:-1,minor:-1,patch:-1};if(t.npm)a.npmUri=t.npm;else if(this.predefinedNpm[e])a.npmUri=this.predefinedNpm[e];else{let e=/\/\/ npm:(.*)$/m.exec(a.file.contentUser);e&&(a.npmUri=e[1])}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c&&(a.description=c[1]);let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let t in e.dependencies){let a=e.dependencies[t];typeof a==`string`&&(a={version:a});let o=await this.loadDependency(t,a,n,r,i);if(o){let t=i[e.name].dependencies.find(e=>e.name==o.name),n=`need`;a.subDependenciesInclude&&a.subDependenciesInclude[o.name]&&(n=a.subDependenciesInclude[o.name]),t?(t.include==`none`&&n!=`none`||t.include==`need`&&n==`full`)&&(t.include=n):i[e.name].dependencies.push({name:o.name,include:n})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}Ii.register(a)}return a}async loadByUri(e,t){let n=await R.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=D((0,f.join)(this.path,`@locals`,e));n.endsWith(T.Package)||(n+=T.Package);let r=await R.getInstance().registerFilePackage(n),i=this.loadPackage(r,t);return{uri:n,file:i}}async loadStore(e,t,n){let r=(0,f.join)(this.path,`store`,e,t),i=(0,u.existsSync)(r),{major:a,minor:o,patch:s}=this.parseVersion(t),c=null;if(i&&(c=this.findPackage(r),c||(i=!1)),!i){(0,u.existsSync)(r)&&(0,u.rmSync)(r,{force:!0,recursive:!0}),(0,u.mkdirSync)(r,{recursive:!0});let n=(0,f.join)(r,`temp.zip`);if(!await this.downloadFile(n,Ni.url+`/package/download/${e}/${t}`)||!await this.extractZip(n,r))return null;if((0,u.rmSync)(n,{force:!0}),c=this.findPackage(r),!c)return;let i=await this.readFirstLine(c),a=/\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)/g.exec(i);if(!a)return console.error(`Invalid package header for "${e}@${t}". First line:`,JSON.stringify(i)),null;let o=a[1],s=Number(a[2]),l=Number(a[3]),d=Number(a[4]),p=s+`.`+l+`.`+d;if(o!==e)return console.error(`Package name mismatch: requested "${e}", downloaded "${o}"`),null;if(p!==t)return console.error(`Package version mismatch: requested "${t}", downloaded "${p}"`),null}if(!c)return console.error(`Package file not found after extracting "${e}@${t}" into "${r}"`),null;let l=D(c),d=await R.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,de.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(T.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=xn.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new xn(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}};(t.startsWith(`https:`)?ue.get:ne.get)(t,i=>{let a=i.statusCode??0;if(a>=300&&a<400&&i.headers.location){i.resume(),this.downloadFile(e,i.headers.location).then(n).catch(()=>n(!1));return}if(a<200||a>=300){console.error(`Download failed: HTTP ${a} for ${t}`),i.resume(),r(),n(!1);return}let o=(0,u.createWriteStream)(e);o.on(`error`,t=>{console.error(`File write error for ${e}:`,t),i.destroy(),r(),n(!1)}),i.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),o.destroy(),r(),n(!1)}),o.on(`finish`,()=>{o.close(t=>{if(t){console.error(`File close error for ${e}:`,t),r(),n(!1);return}n(!0)})}),i.pipe(o)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),r(),n(!1)})})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``,a=0,o;r.on(`data`,function(e){o=e.indexOf(`
428
428
  `),i+=e,o===-1?a+=e.length:r.close()}).on(`close`,function(){t(i.slice(0,a+o))}).on(`error`,function(e){n(e)})})}parseVersion(e){let t=/([0-9xX]+)\.([0-9xX]+)\.([0-9xX]+)/g.exec(e)??[0,-1,-1,-1];return{major:isNaN(Number(t[1]))?-1:Number(t[1]),minor:isNaN(Number(t[2]))?-1:Number(t[2]),patch:isNaN(Number(t[3]))?-1:Number(t[3])}}compareVersion(e,t,n){let r=r=>{if(e[r]==-1)return t[r]==-1?null:t;if(t[r]==-1)return e;if(e[r]==t[r])return null;{let r=Object.values(e).join(`.`),i=Object.values(t).join(`.`);return $.showErrorMessage(`Can't resolve version for dependency ${n} between ${r} and ${i}`),-1}};for(let e of[`major`,`minor`,`patch`]){let t=r(e);if(typeof t==`number`)return null;if(t)return t}return e}},zi=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},Bi=class{infos={};lastInfo=``;lastInfoToCompile=``;internalNames=[];build;storedInfo={};constructor(e){this.build=e}getInternalName(e){if(e=="default"&&(e=`_default`),!this.internalNames.includes(e))return this.internalNames.push(e),e;let t=0,n=e+`_`+t;for(;this.internalNames.includes(n);)t++,n=e+`_`+t;return this.internalNames.push(n),n}register(e,t){this.storedInfo[e]||(this.storedInfo[e]=[]),this.storedInfo[e].push(t),this.rebuildInfo()}unregister(e){this.storedInfo[e]&&(delete this.storedInfo[e],this.rebuildInfo())}rebuildInfo(){if(this.build.isBuildAllowed){this.infos={},this.internalNames=[];for(let e in this.storedInfo)for(let t of this.storedInfo[e]){let n=t.uri;if(this.infos[n]||(this.infos[n]={md5:Je(n),part:{}}),t.libName==`*`){if(!t.alias)throw`The lib ${n} inside the file ${e} has no alias => impossible`;let r=this.infos[n].all;r||(r={externalAlias:[],internalAlias:this.getInternalName(`_default`)},this.infos[n].all=r),r.externalAlias.includes(t.alias)||r.externalAlias.push(t.alias)}else{let e=this.infos[n].part;e[t.libName]||(e[t.libName]={externalAlias:[],internalAlias:this.getInternalName(t.libName)});let r=t.alias?t.alias:t.libName;e[t.libName].externalAlias.includes(r)||e[t.libName].externalAlias.push(r)}}}}npmBuildTxt=``;npmDepBuildTxt={result:``,errors:[]};async compile(){if(Object.keys(this.infos).length==0)return{result:``,errors:[]};let e=JSON.stringify(this.infos);if(this.lastInfo!=e){this.lastInfo=e;let t=this.writeFileToCompile();this.lastInfoToCompile!=t.buildTxt&&(ki.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),ki.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;`+x.EOL,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));`+x.EOL,this.npmBuildTxt+=`(function (npmCompilation) {
429
429
  ${this.npmDepBuildTxt.result+x.EOL}
430
430
  ${t.toExport}
@@ -489,7 +489,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
489
489
  return useValue ? value : void 0;
490
490
  };
491
491
  `);let s=this._buildStringModule(this.buildConfig.module,e.codeNoNamespaceBefore,e.code,e.classesName,e.codeNoNamespaceAfter,a),c=await this.npmBuilder.compile();i=[...i,...c.errors];for(let e of n){let n={};for(let t in e){let i=e[t].path;n[i]||(n[i]={code:o,compressed:(`compressed`in e[t]?e[t].compressed:r)??!1})}e[`@npm`]?n[e[`@npm`].path].code+=c.result:n[e[`@default`].path].code+=c.result;for(let r of t)e[r.lib]?n[e[r.lib].path].code+=r.code+x.EOL:n[e[`@default`].path].code+=r.code+x.EOL;n[e[`@default`].path].code+=s;for(let e in n){let t=Le(e.replace(/\\/g,`/`));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let r=n[e];if(r.compressed)try{r.code=(await(0,pe.minify)({"file1.js":r.code},{compress:!0,format:{comments:!1}})).code??``}catch(e){$.error(e)}this.writeFile(e,r.code)}}}return i}writeBuildDocumentation(e,t,n,r){let i=``;i=`declare global {`+x.EOL,i+=`
492
- namespace `+this.buildConfig.module+`{`+x.EOL,i+=t.doc.join(x.EOL)+x.EOL,i+=` }`,t.docNoNamespace.length>0?i+=x.EOL+t.docNoNamespace.join(x.EOL)+x.EOL:i+=x.EOL,i+=`}`+x.EOL,t.docInvisible.length>0&&(i+=`declare module ___`+this.buildConfig.module+` {`+x.EOL,i+=t.docInvisible.join(x.EOL),i+=`}`);let a=`// `+this.buildConfig.fullname+`:`+this.buildConfig.version+x.EOL;if(r.path.length>0){let e=r.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():r.npmName;a+=`// npm:`+e+x.EOL}this.buildConfig.description&&(a+=`/* description:`+this.buildConfig.description+` */`+x.EOL),a+=`//#region js def //`+x.EOL+i,a+=`//#endregion js def //`+x.EOL,a+=`//#region js src //`+x.EOL+JSON.stringify(n)+x.EOL,a+=`//#endregion js src //`+x.EOL,a+=`//#region css def //`+x.EOL,a+=JSON.stringify(this.scssLanguageService.getInternalDocumentation())+x.EOL,a+=`//#endregion css def //`+x.EOL,a+=`//#region css //`+x.EOL,a+=JSON.stringify(t.stylesheets)+x.EOL,a+=`//#endregion css //`+x.EOL,a+=`//#region html //`+x.EOL,a+=JSON.stringify(t.htmlDoc)+x.EOL,a+=`//#endregion html //`+x.EOL,a+=`//#region dependencies //`+x.EOL,a+=JSON.stringify(this.buildConfig.rawDependencies)+x.EOL,a+=`//#endregion dependencies //`+x.EOL;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&(0,u.unlinkSync)(t);let o=(0,f.join)(Ri.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+T.Package),a)}writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new Ki(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";`+x.EOL)}if(a!=``&&(a+=x.EOL),a+=t.npmsrc[n].content.join(x.EOL),a=wn.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Le(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";`+x.EOL,a+=`export { ${e} };`+x.EOL,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";`+x.EOL)}i+=x.EOL+r.content.join(x.EOL)+x.EOL,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);this.writeFile(r,i)}},o=t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";`+x.EOL,a+=`export { ${e} };`+x.EOL}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"`+x.EOL}i+=a,i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:Ni.isConnected&&(o.author={name:Ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(ze(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*[\s\S]*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=We(i,s);c=c.replace(T.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,k(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,k(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`)for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=ze(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e],r=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(r instanceof F&&r.fileParsed){let e=r.fileParsed.classes[r.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let i=n.file.name.replace(T.I18n,``),o=(t.mount+`/`+e+i+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(t.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(t.mount+`/_components_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else t.mode==`basedOnAttribute`||t.mode;a+=`Aventus.I18n.init()`+x.EOL}let o=this.externalPackageInformation.getNameByUri(t);u.push({lib:o,code:a})}if(d){let t=``;if(this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,t+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,n.mode==`singleFile`){let e=(n.mount+`/$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(n.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[e],i=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let e=i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let a=r.file.name.replace(T.I18n,``),o=(n.mount+`/`+e+a+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()`+x.EOL}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;zi.send(e,r.join(`\r
492
+ namespace `+this.buildConfig.module+`{`+x.EOL,i+=t.doc.join(x.EOL)+x.EOL,i+=` }`,t.docNoNamespace.length>0?i+=x.EOL+t.docNoNamespace.join(x.EOL)+x.EOL:i+=x.EOL,i+=`}`+x.EOL,t.docInvisible.length>0&&(i+=`declare module ___`+this.buildConfig.module+` {`+x.EOL,i+=t.docInvisible.join(x.EOL),i+=`}`);let a=`// `+this.buildConfig.fullname+`:`+this.buildConfig.version+x.EOL;if(r.path.length>0){let e=r.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():r.npmName;a+=`// npm:`+e+x.EOL}this.buildConfig.description&&(a+=`/* description:`+this.buildConfig.description+` */`+x.EOL),a+=`//#region js def //`+x.EOL+i,a+=`//#endregion js def //`+x.EOL,a+=`//#region js src //`+x.EOL+JSON.stringify(n)+x.EOL,a+=`//#endregion js src //`+x.EOL,a+=`//#region css def //`+x.EOL,a+=JSON.stringify(this.scssLanguageService.getInternalDocumentation())+x.EOL,a+=`//#endregion css def //`+x.EOL,a+=`//#region css //`+x.EOL,a+=JSON.stringify(t.stylesheets)+x.EOL,a+=`//#endregion css //`+x.EOL,a+=`//#region html //`+x.EOL,a+=JSON.stringify(t.htmlDoc)+x.EOL,a+=`//#endregion html //`+x.EOL,a+=`//#region dependencies //`+x.EOL,a+=JSON.stringify(this.buildConfig.rawDependencies)+x.EOL,a+=`//#endregion dependencies //`+x.EOL;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&(0,u.unlinkSync)(t);let o=(0,f.join)(Ri.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+T.Package),a)}writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new Ki(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";`+x.EOL)}if(a!=``&&(a+=x.EOL),a+=t.npmsrc[n].content.join(x.EOL),a=wn.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Le(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";`+x.EOL,a+=`export { ${e} };`+x.EOL,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";`+x.EOL)}i+=x.EOL+r.content.join(x.EOL)+x.EOL,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);this.writeFile(r,i)}},o=t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";`+x.EOL,a+=`export { ${e} };`+x.EOL}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"`+x.EOL}i+=a,i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:Ni.isConnected&&(o.author={name:Ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(ze(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*[\s\S]*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=We(i,s);c=c.replace(T.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,k(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,k(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`){Array.isArray(h.content.dependencies)||(console.log(`Problem with `+h.content.fullName),console.log(h.content));for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=ze(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e],r=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(r instanceof F&&r.fileParsed){let e=r.fileParsed.classes[r.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let i=n.file.name.replace(T.I18n,``),o=(t.mount+`/`+e+i+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(t.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(t.mount+`/_components_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else t.mode==`basedOnAttribute`||t.mode;a+=`Aventus.I18n.init()`+x.EOL}let o=this.externalPackageInformation.getNameByUri(t);u.push({lib:o,code:a})}if(d){let t=``;if(this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,t+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,n.mode==`singleFile`){let e=(n.mount+`/$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(n.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[e],i=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let e=i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let a=r.file.name.replace(T.I18n,``),o=(n.mount+`/`+e+a+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()`+x.EOL}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;zi.send(e,r.join(`\r
493
493
  `)),t.errors.push({title:`Dependencies errors`,file:e})}return t}getAllFullnames(){let e={},t=t=>{if(t.startsWith(`!staticClass_`))return;let n=t.split(`.`)[0];e[n]||(e[n]=[]),e[n].push(t)};for(let e in this.tsFiles){let n=this.tsFiles[e];for(let e of n.compileResult)e.classScript!==``&&t(e.classScript)}for(let e of this.dependencyNeedUris){let n=this.externalPackageInformation.getInformationsRequired(e);for(let e of n)e.code&&t(e.fullName)}for(let e of this.dependencyFullUris){let n=this.externalPackageInformation.getFullInformations(e);for(let e of n)e.code&&t(e.fullName)}return e}async onNewFile(e){this.buildConfig.srcPathRegex&&e.path.match(this.buildConfig.srcPathRegex)&&this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){Se.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await Ri.getInstance().loadDependenciesFromBuild(this.buildConfig,this);this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=R.getInstance();if(this.buildConfig.srcPathRegex){let e=t.getFilesMatching(this.buildConfig.srcPathRegex);for(let t of e)this.registerFile(t,!0)}if(this.buildConfig.outsideModulePathRegex){let e=t.getFilesMatching(this.buildConfig.outsideModulePathRegex);for(let t of e)this.registerFile(t,!0),this.noNamespaceUri[t.uri]=!0}$.debug(`loaded all files needed`),this.allowBuild=!0,this._filesLoaded=!0,await this.rebuildAll(!0),Se.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(T.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new hi(e,this),t||await this.scssFiles[e.uri].init(),this.registerOnFileDelete(e),this.scssFiles[e.uri].isGlobal&&(this.globalComponentSCSSFiles[e.uri]=this.scssFiles[e.uri]));else if(e.uri.endsWith(T.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new gi(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(T.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new Vi(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(T.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new Xi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new Xi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Oi(e,this);t&&(this.tsFiles[e.uri]=t,this.registerOnFileDelete(e))}}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(T.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(T.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(T.Component)?delete this.wcFiles[e.uri]:delete this.tsFiles[e.uri],await this.rebuildAll()}getLocalWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return t}}}getWebComponentTagDependency(e){let t=this.htmlLanguageService.getInternalTagUri(e);if(t){let e=RegExp(`^`+this.module+`\\.`);return{fullName:t.fullname.replace(e,`$namespace$`),uri:t.uri,isStrong:!1}}let n=this.getWebComponentDefinition(e);if(n){let e=n.class.fileUri;return n.isLocal||(e=`@external`),{fullName:n.class.fullName,uri:e,isStrong:!1}}return null}getWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return{class:t,isLocal:!0}}}let r=this.htmlLanguageService.getClassByTag(e);if(r){let n=this.externalPackageInformation.getExternalWebComponentDefinition(r);if(n){if(t){let t=this.project.getInternalWebComponentDefinition(O(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof F&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>Pn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=O(e);for(let e in this.buildConfig.namespaceRulesRegex){let n=this.buildConfig.namespaceRulesRegex[e];if(t.match(n))return e}}else if(this.buildConfig.namespaceStrategy==`followFolders`||this.buildConfig.namespaceStrategy==`followFoldersCamelCase`){let t=e.endsWith(T.ComponentLogic),n=O(e),r=n.split(`/`);r.pop(),t&&r.pop(),n=r.join(`/`)+`/`;let i=n.replace(this.buildConfig.namespaceRoot,``).replace(/\//g,`.`);return i.endsWith(`.`)&&(i=i.slice(0,-1)),i.startsWith(`.`)&&(i=i.slice(1)),i.includes(`:`)?``:this.buildConfig.namespaceStrategy==`followFoldersCamelCase`?(i=i.slice(0,1).toUpperCase()+i.slice(1),i.replace(/(([-_\.]|^)[a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))):i}return``}addNamespace(e){if(!this.namespaces.includes(e)){let t=e.split(`.`),n=``;for(let e of t)n+=e,n&&!this.namespaces.includes(n)&&this.namespaces.push(n),n+=`.`}}async onRename(e){for(let t of e)if(t.oldUri.endsWith(T.Component)||t.oldUri.endsWith(T.ComponentLogic)||t.oldUri.endsWith(T.Data)||t.oldUri.endsWith(T.Lib)||t.oldUri.endsWith(T.RAM))return await this.tsLanguageService.onRenameFile(t.oldUri,t.newUri);return{}}npmAliases={};npmNameCount={};getNpmReplacementName(e,t){if(!this.hasNpmOutput)return``;let n=t.split(`.`),r=n.pop(),i=e.split(`.`);return i.pop(),n.join(`.`)==i.join(`.`)?r:this.npmAliases[t]?this.npmAliases[t]:(this.npmNameCount[r]||(this.npmNameCount[r]=0),this.npmNameCount[r]++,this.npmAliases[t]=r+this.npmNameCount[r],this.npmAliases[t])}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID);for(let e in this.scssFiles)this.scssFiles[e].removeEvents(),this.scssFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.htmlFiles)this.htmlFiles[e].removeEvents(),this.htmlFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsFiles)this.tsFiles[e].removeEvents(),this.tsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsLanguageService.i18nFiles)this.tsLanguageService.i18nFiles[e].removeEvents(),this.tsLanguageService.i18nFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.i18nComponentsFiles)this.i18nComponentsFiles[e].removeEvents(),this.i18nComponentsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);ji.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){qe(e,t,`build`,this.buildConfig.fullname)}},Qi=class{files={};informations={};informationsRequired={};webComponentByName={};build;constructor(e){this.build=e}get filesUri(){return Object.keys(this.files)}init(e){for(let t of e)this.files[t.file.uri]=t;this.rebuild()}getByFullName(e){return this.informations[e]}getByUri(e){return this.files[e]}getNpmUri(e){if(!this.build.hasNpmOutput)return null;if(this.informations[e]){let t=this.files[this.informations[e].uri];!t.npmUri&&this.build.initDone&&$.showErrorMessage(`Can't find a npm package for `+t.name+`. You must define the npm field inside the dependencies section of your aventus.conf.avt. Otherwise, you can disable storybook or remove npm export.`);let n=e.split(`.`),r=n.pop();n.splice(0,0,t.npmUri);let i=t.fileParsed?.getBaseInfo(r)?.willBeCompiled??!1;return{name:r,uri:n.join(`/`),compiled:i}}return null}getNamespaceByUri(e){return this.files[e].srcInfo.namespace}getNameByUri(e){return this.files[e].name}getInformationsRequired(e){return this.informationsRequired[e]}getFullInformations(e){return this.files[e]?.srcInfo.available||[]}getStyleByUri(e){return this.files[e]?this.files[e].externalCSS:{}}rebuild(){this.informations={},this.webComponentByName={};let e=[];for(let t in this.files){let n=this.files[t];this.informationsRequired[t]=[];for(let r of n.srcInfo.available)(r.required||this.build.buildConfig.i18n&&r.fullName==`Aventus.I18n`)&&this.informationsRequired[t].push(r),r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:r,uri:t});for(let r of n.srcInfo.existing)r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:`noCode`,uri:t});this.webComponentByName={...this.webComponentByName,...n.classInfoByName}}$.sendDiagnostics({uri:`@Import lib`,diagnostics:e},this.build)}getExternalWebComponentDefinition(e){return this.webComponentByName[e]}getExternalWebComponentDefinitionFile(e){let t=this.webComponentByName[e];if(t){let e=t.fileUri,n=this.files[e];if(n)return n}}},$i=class{staticConfig;watcher;isReady=!1;project;get name(){return this.staticConfig.name}constructor(e,t){this.project=e,this.staticConfig=t,this.registerWatcher(),this.isReady=!0}async export(){if(this.isReady){Se.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,le.compile)(e,{style:`compressed`}).css.toString().trim();qe(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Se.sendFileSize(t,void 0,`static`,this.name)}catch(e){$.error(e)}},n=e(this.staticConfig.inputPathFolder);for(let e of n){e=e.replace(/\\/g,`/`);for(let n of this.staticConfig.outputPathFolder){let r=e.replace(this.staticConfig.inputPathFolder,n);if(e.endsWith(T.Base)){if(e.endsWith(T.GlobalStyle)){r=r.replace(T.GlobalStyle,`.css`);let t=this.project.scssFiles[D(e)];if(!t){let n=d.TextDocument.create(D(e),T.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[D(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}yt.getInstance().reload(),Se.sendStaticTime(this.name)}}registerWatcher(){E.getInstance().settings.watchFiles&&(this.watcher=(0,v.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},ea=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,oi.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:si,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}loadVariables(e,t){let n=e.file.documentUser,r={},i=e=>{if(e.type==69){let i=e;for(;i&&i.selectors==null;)i=i.parent;if(i&&i.selectors.getText()==`:root`){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(i.offset,r[e]||(r[e]={name:e,uri:t,range:{start:n.positionAt(i.offset),end:n.positionAt(i.end)},value:a.getText()}))}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=pi((0,ce.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},ta=class{_file;_project;get file(){return this._file}get project(){return this._project}constructor(e,t){this._file=e,this._project=t,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof j&&await this.file.validate()}triggerSave(){this.file instanceof j&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof j&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},na=class e extends ta{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;savedOnce=!1;staticNamebyOutPath={};get resultCompiled(){return this.compiledTxt}constructor(e,t){super(e,t),this.loadDependencies(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onContentChange(){}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}compileRoot(){if(Object.values(this.usedBy).length==0)this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(E.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,le.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof le.Exception&&(this.diagnosticCompile=je(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),this.export())}export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),qe(t,this.compiledTxt,`static`,this.staticNamebyOutPath[e])}}loadDependencies(){let e=this.file.contentUser,t=e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`),n=/@import *?('|")(\S*?)('|");?/g,r=null;for(let e in this.dependencies)this.removeDependency(e);for(;r=n.exec(t);){let t=r[2],n=this.resolvePath(t,this.file.folderPath);if(n)this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Me(this.file.documentUser,`Can't load this file`,t,n))}}}removeDependency(e){this.dependencies[e]&&(delete this.dependencies[e].usedBy[this.file.uri],delete this.dependencies[e])}addDependency(t){this.project.scssFiles[t.uri]?(this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(T.GlobalStyle)&&(this.project.scssFiles[t.uri]=new e(t,this.project),this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this)}resolvePath(e,t){e=this.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=R.getInstance().getByPath(e);if(n)return n;let r=e+T.GlobalStyle;if(n=R.getInstance().getByPath(r),n)return n;let i=e.split(f.sep);i[i.length-1]=`_`+i[i.length-1];let a=i.join(f.sep);if(n=R.getInstance().getByPath(a),n)return n;let o=a+T.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},ra=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},ia=class{configFile;config=null;builds=[];statics=[];_isCoreBuild=!1;scssFiles={};onValidateUUID;onSaveUUID;onFormattingUUID;onCompletionUUID;onCompletionResolveUUID;onHoverUUID;onNewFileUUID;onFileDeleteUUIDs={};buildsAllowed;staticsAllowed;globalSCSSLanguageService;get isCoreBuild(){return this._isCoreBuild}getConfigFile(){return this.configFile}getConfig(){return this.config}resolveAlias(e,t){if(e.startsWith(`@`)){let n=e.split(`/`),r=n[0],i=this.config?.aliases[r];if(i){let e=(0,f.normalize)(this.configFile.folderPath+`/`+i);typeof t!=`string`&&(t=t.folderPath);let r=(0,f.normalize)(t);e.endsWith(f.sep)&&(e=e.substring(0,e.length-1)),r.endsWith(f.sep)&&(r=r.substring(0,r.length-1));let a=e.split(f.sep),o=r.split(f.sep);for(let e=0;e<a.length;e++)if(o.length>e)if(a[e]==o[e])a.splice(e,1),o.splice(e,1),e--;else break;let s=``;for(let e=0;e<o.length;e++)s+=`../`;return s==``&&(s+=`./`),s+=a.join(`/`),n.splice(0,1,s),n.join(`/`).replace(/\/\//g,`/`)}}return e}getInternalWebComponentDefinition(e,t){for(let n of this.builds)if(n.outputPathes.includes(e))return n.getLocalWebComponentDefinition(t)}constructor(e,t){this.configFile=e,this.onValidateUUID=this.configFile.onValidate(this.onValidate.bind(this)),this.onSaveUUID=this.configFile.onSave(this.onConfigSave.bind(this)),this.onFormattingUUID=this.configFile.onFormatting(this.onFormatting.bind(this)),this.onCompletionUUID=this.configFile.onCompletion(this.onCompletion.bind(this)),this.onCompletionResolveUUID=this.configFile.onCompletionResolve(this.onCompletionResolve.bind(this)),this.onHoverUUID=this.configFile.onHover(this.onHover.bind(this)),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new ea,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await ot.getInstance().validate(this.configFile)}async loadConfig(){let e=await ot.getInstance().getConfig(this.configFile);if(this.config){let t=JSON.stringify(this.config),n=``;if(e&&(n=JSON.stringify(e)),t==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=e}onConfigSaveMutex=new ra;async onConfigSave(){if(await this.onConfigSaveMutex.waitOne(),await this.loadConfig(),this.config){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();for(let e of this.config.build){if(this.buildsAllowed){if(!this.buildsAllowed.includes(e.name??``)){let t=this.builds.find(t=>t.buildConfig.name==e.name);t&&t.build();continue}}else if(e.disabled)continue;let t=new Zi(this,e);this.builds.push(t),await t.init()}if(this.config.static)for(let e of this.config.static){if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name))continue;let t=new $i(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await ot.getInstance().format(e,t,n)}async onCompletion(e,t){return await ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await ot.getInstance().doResolve(t)}async onHover(e,t){return await ot.getInstance().doHover(e,t)}getBuildsName(){let e=[];for(let t of this.builds)e.push(t.fullname);return e}getBuildsNameWithStory(){let e=[];for(let t of this.builds)t.hasStories&&e.push(t.fullname);return e}getBuildsNameWithNpm(){let e=[];for(let t of this.builds)t.hasNpmOutput&&e.push(t.fullname);return e}getBuild(e){for(let t of this.builds)if(t.fullname==e)return t}getBuilds(){return this.builds}getMatchingBuildsByUri(e){let t=[];for(let n of this.builds)n.isFileInside(e)&&t.push(n);return t}getStaticsName(){let e=[];for(let t of this.statics)e.push(t.name);return e}getStatic(e){for(let t of this.statics)if(t.name==e)return t}loadFiles(){let e=R.getInstance().getFilesWithExtension(T.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(T.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new na(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(T.GlobalStyle)&&delete this.scssFiles[e.uri]}async onRename(e){let t={};for(let n of this.builds){let r=await n.onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},L=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+T.Config)){let n=t.documentUser.uri.replace(T.Config,T.Template);if(R.getInstance().getByUri(n))return;this.projects[t.documentUser.uri]?console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`):(this.projects[t.documentUser.uri]=new ia(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=De(e);if(t){let n=O(e),r=d.TextDocument.create(e,t,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(r),this.onSave(r)}}}async onUpdatedUri(e){if(this.lockedUpdatedUri[e])return;let t=De(e),n=O(e),r=``;if((0,u.existsSync)(n))r=(0,u.readFileSync)(n,`utf8`);else{this.onDeletedUri(e);return}if(this.files[e]){let n=this.files[e].versionUser+1,i=d.TextDocument.create(e,t,n,r);await this.onContentChange(i),this.onSave(i)}else{let n=d.TextDocument.create(e,t,0,r);await this.registerFile(n),this.onSave(n)}}async onDeletedUri(e){if(this.files[e]){if(E.getInstance().settings.errorByBuild){let t=this.files[e].getBuild();if(t===null)$.sendDiagnostics({uri:e,diagnostics:[]});else for(let n of t)$.sendDiagnostics({uri:e,diagnostics:[]},n)}else $.sendDiagnostics({uri:e,diagnostics:[]});await this.files[e].triggerDelete(),delete this.files[e],nt.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=O(e[r]),a=async e=>{let r=(0,u.readdirSync)(e);for(let i=0;i<r.length;i++){let o=e+`/`+r[i];if((0,u.lstatSync)(o).isDirectory()){if(r[i]!=`node_modules`&&await a(o))return!0}else{let e=D(o);if(r[i]==T.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}tt.sendDone()}async loadConfigFile(e,t,n){L.autoLoad=!1;let r=O(e);e=D(r);let i=d.TextDocument.create(D(r),T.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=L.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=D(i),r=De(e);if(t[n]!=T.Config&&t[n].endsWith(T.Base)){let t=d.TextDocument.create(e,r,0,(0,u.readFileSync)(i,`utf8`));await this.registerFile(t)}}}};for(let n of e.build)if(!t||t.includes(n.name??``))for(let e of n.srcPath)await r(e);for(let t of e.static)(!n||n.includes(t.name??``))&&await r(t.inputPathFolder);Se.startSendLoadFile(),a.loadFiles(),Se.sendLoadFile(),this.loadingInProgress=!1,await a.init(),tt.sendDone()}}}async parseWorkspace(e,t){let n=O(e),r=E.getInstance().settings.readDirs,i=e=>!0;if(r.length>0){let t=[],n=[];for(let i of r){let r=``,a=i.replace(/\\/g,`/`);a.startsWith(`/`)||(r=`/`);let o=a.split(`/`);o[o.length-1]==``||o[o.length-1]==`*`?o[o.length-1]=`*`:o[o.length-1].indexOf(`.`)==-1&&o.push(`*`),a=o.join(`/`);let s=(0,f.normalize)(O(e)+r+a).replace(/\\/g,`/`);s=Be(s,!0).replace(`*`,`.*`);let c=s.split(`/`),l=``;for(let e of c)e!=`.*`&&(l==``?l=e:l+=`/`+e,n.includes(l)||n.push(l));t.push(`(^`+s+`$)`)}let a=t.join(`|`);a==``&&(a=`(?!)`);let o=new RegExp(a);i=e=>{let t=(e+`/`).match(o)!=null,r=n.includes(e);return t||r}}let a=async e=>{if(!i(e))return;let n=(0,u.readdirSync)(e);for(let r=0;r<n.length;r++){let i=e+`/`+n[r];(0,u.lstatSync)(i).isDirectory()?n[r]!=`node_modules`&&n[r]!=`.git`&&await a(i):await t(n[r],i)}};await a(n)}async loadAllAventusConfigFiles(e){let t=[];for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=D(n),i=De(r);e==T.Config&&t.push(new j(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];tt.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=D(n),i=De(r);if(e==T.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(T.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});tt.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);tt.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],nt.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(T.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=O(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,w.Package,0,n);return nt.getInstance().watch(e),await this.registerFile(r)}async registerFile(e){return $.debug(`registering `+e.uri),this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),$.isIDE||nt.getInstance().watch(e.uri),this.files[e.uri]}async onContentChange(e){this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e)}async onSave(e){this.files[e.uri]?await this.files[e.uri].triggerSave():await this.triggerOnNewFile(e)}async onClose(e){(0,u.existsSync)(O(e.uri))||this.onDeletedUri(e.uri)}async onCompletion(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletion(t):{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletionResolve(t):t}async onHover(e,t){return await this.fileExists(e)?this.files[e.uri].getHover(t):null}async onDefinition(e,t){return await this.fileExists(e)?this.files[e.uri].getDefinition(t):null}async onFormatting(e,t){return await this.fileExists(e)?this.files[e.uri].getFormatting(t):[]}async onCodeAction(e,t){return await this.fileExists(e)?this.files[e.uri].getCodeAction(t):[]}async onReferences(e,t){return await this.fileExists(e)?this.files[e.uri].getReferences(t):[]}async onCodeLens(e){return await this.fileExists(e)?this.files[e.uri].getCodeLens():[]}async onRename(e,t,n){return await this.fileExists(e)?this.files[e.uri].getRename(t,n):null}getBuild(e){return this.files[e.uri]?this.files[e.uri].getBuild():[]}onNewFileCb={};async triggerOnNewFile(e){if($.debug(`triggerOnNewFile `+e.uri),this.loadingInProgress&&e.uri.endsWith(T.Config))return;this.files[e.uri]=new j(e);let t=[];for(let n in this.onNewFileCb)t.push(this.onNewFileCb[n](this.files[e.uri]));await Promise.all(t)}onNewFile(e){let t=A();for(;this.onNewFileCb[t]!=null;)t=A();return this.onNewFileCb[t]=e,t}removeOnNewFile(e){delete this.onNewFileCb[e]}onFileRemoveCb={};async triggerOnFileRemove(e){$.debug(`triggerOnFileRemove `+e);let t=[];for(let n in this.onFileRemoveCb)t.push(this.onFileRemoveCb[n](e));await Promise.all(t)}onFileRemove(e){let t=A();for(;this.onNewFileCb[t]!=null;)t=A();return this.onFileRemoveCb[t]=e,t}removeOnFileRemove(e){delete this.onFileRemoveCb[e]}getFilesMatching(e){let t=[];for(let n in this.files)this.files[n].path.match(e)&&t.push(this.files[n]);return t}getFilesWithExtension(e){Array.isArray(e)||(e=[e]);let t=[];for(let n in this.files)for(let r of e)this.files[n].path.endsWith(r)&&t.push(this.files[n]);return t}getByPath(e){return this.files[D(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},aa=class e{static tc(e,t){if(typeof e!=t)throw TypeError(`required type ${t} got ${typeof e}`);return e}static ic(e,t){if(!(e instanceof t))throw TypeError(`required type ${t} got ${typeof e}`);return e}static nc(e){return isNaN(e)?0:e}static oc(e){return{angle:e&&e.angle?e.angle:15,results:e&&e.results?e.results:3}}static clmp(e,t,n){return n!==void 0&&e<n?n:e>t?t:e}static shift(e,t){for(e+=t;e>=360;)e-=360;for(;e<0;)e+=360;return e}#e;#t;#n;alpha;static Colors=class{static get BLACK(){return e.fromHex(`#000000`)}static get SILVER(){return e.fromHex(`#c0c0c0`)}static get GRAY(){return e.fromHex(`#808080`)}static get WHITE(){return e.fromHex(`#ffffff`)}static get MAROON(){return e.fromHex(`#800000`)}static get RED(){return e.fromHex(`#ff0000`)}static get PURPLE(){return e.fromHex(`#800080`)}static get GREEN(){return e.fromHex(`#008000`)}static get LIME(){return e.fromHex(`#00ff00`)}static get OLIVE(){return e.fromHex(`#808000`)}static get YELLOW(){return e.fromHex(`#ffff00`)}static get NAVY(){return e.fromHex(`#000080`)}static get BLUE(){return e.fromHex(`#0000ff`)}static get TEAL(){return e.fromHex(`#008080`)}static get AQUA(){return e.fromHex(`#00ffff`)}static get ORANGE(){return e.fromHex(`#ffa500`)}static get ALICEBLUE(){return e.fromHex(`#f0f8ff`)}static get ANTIQUEWHITE(){return e.fromHex(`#faebd7`)}static get AQUAMARINE(){return e.fromHex(`#7fffd4`)}static get AZURE(){return e.fromHex(`#f0ffff`)}static get BEIGE(){return e.fromHex(`#f5f5dc`)}static get BISQUE(){return e.fromHex(`#ffe4c4`)}static get BLANCHEDALMOND(){return e.fromHex(`#ffebcd`)}static get BLUEVIOLET(){return e.fromHex(`#8a2be2`)}static get BROWN(){return e.fromHex(`#a52a2a`)}static get BURLYWOOD(){return e.fromHex(`#deb887`)}static get CADETBLUE(){return e.fromHex(`#5f9ea0`)}static get CHARTREUSE(){return e.fromHex(`#7fff00`)}static get CHOCOLATE(){return e.fromHex(`#d2691e`)}static get CORAL(){return e.fromHex(`#ff7f50`)}static get CORNFLOWERBLUE(){return e.fromHex(`#6495ed`)}static get CORNSILK(){return e.fromHex(`#fff8dc`)}static get CRIMSON(){return e.fromHex(`#dc143c`)}static get CYAN(){return e.fromHex(`#00ffff`)}static get DARKBLUE(){return e.fromHex(`#00008b`)}static get DARKCYAN(){return e.fromHex(`#008b8b`)}static get DARKGOLDENROD(){return e.fromHex(`#b8860b`)}static get DARKGRAY(){return e.fromHex(`#a9a9a9`)}static get DARKGREEN(){return e.fromHex(`#006400`)}static get DARKGREY(){return e.fromHex(`#a9a9a9`)}static get DARKKHAKI(){return e.fromHex(`#bdb76b`)}static get DARKMAGENTA(){return e.fromHex(`#8b008b`)}static get DARKOLIVEGREEN(){return e.fromHex(`#556b2f`)}static get DARKORANGE(){return e.fromHex(`#ff8c00`)}static get DARKORCHID(){return e.fromHex(`#9932cc`)}static get DARKRED(){return e.fromHex(`#8b0000`)}static get DARKSALMON(){return e.fromHex(`#e9967a`)}static get DARKSEAGREEN(){return e.fromHex(`#8fbc8f`)}static get DARKSLATEBLUE(){return e.fromHex(`#483d8b`)}static get DARKSLATEGRAY(){return e.fromHex(`#2f4f4f`)}static get DARKSLATEGREY(){return e.fromHex(`#2f4f4f`)}static get DARKTURQUOISE(){return e.fromHex(`#00ced1`)}static get DARKVIOLET(){return e.fromHex(`#9400d3`)}static get DEEPPINK(){return e.fromHex(`#ff1493`)}static get DEEPSKYBLUE(){return e.fromHex(`#00bfff`)}static get DIMGRAY(){return e.fromHex(`#696969`)}static get DIMGREY(){return e.fromHex(`#696969`)}static get DODGERBLUE(){return e.fromHex(`#1e90ff`)}static get FIREBRICK(){return e.fromHex(`#b22222`)}static get FLORALWHITE(){return e.fromHex(`#fffaf0`)}static get FORESTGREEN(){return e.fromHex(`#228b22`)}static get GAINSBORO(){return e.fromHex(`#dcdcdc`)}static get GHOSTWHITE(){return e.fromHex(`#f8f8ff`)}static get GOLD(){return e.fromHex(`#ffd700`)}static get GOLDENROD(){return e.fromHex(`#daa520`)}static get GREENYELLOW(){return e.fromHex(`#adff2f`)}static get GREY(){return e.fromHex(`#808080`)}static get HONEYDEW(){return e.fromHex(`#f0fff0`)}static get HOTPINK(){return e.fromHex(`#ff69b4`)}static get INDIANRED(){return e.fromHex(`#cd5c5c`)}static get INDIGO(){return e.fromHex(`#4b0082`)}static get IVORY(){return e.fromHex(`#fffff0`)}static get KHAKI(){return e.fromHex(`#f0e68c`)}static get LAVENDER(){return e.fromHex(`#e6e6fa`)}static get LAVENDERBLUSH(){return e.fromHex(`#fff0f5`)}static get LAWNGREEN(){return e.fromHex(`#7cfc00`)}static get LEMONCHIFFON(){return e.fromHex(`#fffacd`)}static get LIGHTBLUE(){return e.fromHex(`#add8e6`)}static get LIGHTCORAL(){return e.fromHex(`#f08080`)}static get LIGHTCYAN(){return e.fromHex(`#e0ffff`)}static get LIGHTGOLDENRODYELLOW(){return e.fromHex(`#fafad2`)}static get LIGHTGRAY(){return e.fromHex(`#d3d3d3`)}static get LIGHTGREEN(){return e.fromHex(`#90ee90`)}static get LIGHTGREY(){return e.fromHex(`#d3d3d3`)}static get LIGHTPINK(){return e.fromHex(`#ffb6c1`)}static get LIGHTSALMON(){return e.fromHex(`#ffa07a`)}static get LIGHTSEAGREEN(){return e.fromHex(`#20b2aa`)}static get LIGHTSKYBLUE(){return e.fromHex(`#87cefa`)}static get LIGHTSLATEGRAY(){return e.fromHex(`#778899`)}static get LIGHTSLATEGREY(){return e.fromHex(`#778899`)}static get LIGHTSTEELBLUE(){return e.fromHex(`#b0c4de`)}static get LIGHTYELLOW(){return e.fromHex(`#ffffe0`)}static get LIMEGREEN(){return e.fromHex(`#32cd32`)}static get LINEN(){return e.fromHex(`#faf0e6`)}static get MAGENTA(){return e.fromHex(`#ff00ff`)}static get FUCHSIA(){return e.fromHex(`#ff00ff`)}static get MEDIUMAQUAMARINE(){return e.fromHex(`#66cdaa`)}static get MEDIUMBLUE(){return e.fromHex(`#0000cd`)}static get MEDIUMORCHID(){return e.fromHex(`#ba55d3`)}static get MEDIUMPURPLE(){return e.fromHex(`#9370db`)}static get MEDIUMSEAGREEN(){return e.fromHex(`#3cb371`)}static get MEDIUMSLATEBLUE(){return e.fromHex(`#7b68ee`)}static get MEDIUMSPRINGGREEN(){return e.fromHex(`#00fa9a`)}static get MEDIUMTURQUOISE(){return e.fromHex(`#48d1cc`)}static get MEDIUMVIOLETRED(){return e.fromHex(`#c71585`)}static get MIDNIGHTBLUE(){return e.fromHex(`#191970`)}static get MINTCREAM(){return e.fromHex(`#f5fffa`)}static get MISTYROSE(){return e.fromHex(`#ffe4e1`)}static get MOCCASIN(){return e.fromHex(`#ffe4b5`)}static get NAVAJOWHITE(){return e.fromHex(`#ffdead`)}static get OLDLACE(){return e.fromHex(`#fdf5e6`)}static get OLIVEDRAB(){return e.fromHex(`#6b8e23`)}static get ORANGERED(){return e.fromHex(`#ff4500`)}static get ORCHID(){return e.fromHex(`#da70d6`)}static get PALEGOLDENROD(){return e.fromHex(`#eee8aa`)}static get PALEGREEN(){return e.fromHex(`#98fb98`)}static get PALETURQUOISE(){return e.fromHex(`#afeeee`)}static get PALEVIOLETRED(){return e.fromHex(`#db7093`)}static get PAPAYAWHIP(){return e.fromHex(`#ffefd5`)}static get PEACHPUFF(){return e.fromHex(`#ffdab9`)}static get PERU(){return e.fromHex(`#cd853f`)}static get PINK(){return e.fromHex(`#ffc0cb`)}static get PLUM(){return e.fromHex(`#dda0dd`)}static get POWDERBLUE(){return e.fromHex(`#b0e0e6`)}static get ROSYBROWN(){return e.fromHex(`#bc8f8f`)}static get ROYALBLUE(){return e.fromHex(`#4169e1`)}static get SADDLEBROWN(){return e.fromHex(`#8b4513`)}static get SALMON(){return e.fromHex(`#fa8072`)}static get SANDYBROWN(){return e.fromHex(`#f4a460`)}static get SEAGREEN(){return e.fromHex(`#2e8b57`)}static get SEASHELL(){return e.fromHex(`#fff5ee`)}static get SIENNA(){return e.fromHex(`#a0522d`)}static get SKYBLUE(){return e.fromHex(`#87ceeb`)}static get SLATEBLUE(){return e.fromHex(`#6a5acd`)}static get SLATEGRAY(){return e.fromHex(`#708090`)}static get SLATEGREY(){return e.fromHex(`#708090`)}static get SNOW(){return e.fromHex(`#fffafa`)}static get SPRINGGREEN(){return e.fromHex(`#00ff7f`)}static get STEELBLUE(){return e.fromHex(`#4682b4`)}static get TAN(){return e.fromHex(`#d2b48c`)}static get THISTLE(){return e.fromHex(`#d8bfd8`)}static get TOMATO(){return e.fromHex(`#ff6347`)}static get TURQUOISE(){return e.fromHex(`#40e0d0`)}static get VIOLET(){return e.fromHex(`#ee82ee`)}static get WHEAT(){return e.fromHex(`#f5deb3`)}static get WHITESMOKE(){return e.fromHex(`#f5f5f5`)}static get YELLOWGREEN(){return e.fromHex(`#9acd32`)}static get REBECCAPURPLE(){return e.fromHex(`#663399`)}};getScheme(t,n){return e.createScheme(this,t,n)}static getScheme(t,n,r){return e.createScheme(t,n,r)}static monochromatic(t,n){this.ic(t,e);let r=this.oc(n).results||3,i=e.toHsv(t),a=i.h,o=i.s,s=i.v/100,c=[],l=1/r;for(;r--;)c.push(e.fromHsv(a,o,this.clmp(s*100,100,0))),s=(s-l)%1;return c}monochromatic(t){return e.monochromatic(this,t)}static complementary(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return e.fromHsl(this.shift(r,180),i,a)}complementary(){return e.complementary(this)}static splitComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180+i),o,s),e.fromHsl(this.shift(a,180-i),o,s)]}splitComplementary(t){return e.splitComplementary(this,t)}static doubleComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,i),o,s),e.fromHsl(this.shift(a,180+i),o,s)]}doubleComplementary(t){return e.doubleComplementary(this,t)}static square(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l,o=[t];for(let t=1;t<4;t++)r=this.shift(r,90),o.push(e.fromHsl(r,i,a));return o}square(){return e.square(this)}static tetradic(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,180-i),o,s),e.fromHsl(this.shift(a,-i),o,s)]}tetradic(t){return e.tetradic(this,t)}static triadic(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return[t,e.fromHsl(this.shift(r,120),i,a),e.fromHsl(this.shift(r,240),i,a)]}triadic(){return e.triadic(this)}static analogous(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,-i),o,s),e.fromHsl(this.shift(a,+i),o,s)]}analogous(t){return e.analogous(this,t)}static createScheme(t,n,r){switch(n.toLowerCase()){case`analogous`:case`analog`:return e.analogous(t,r);case`triadic`:case`triad`:return e.triadic(t);case`tetradic`:case`tetra`:return e.tetradic(t,r);case`monochromatic`:case`monochrome`:case`mono`:return e.monochromatic(t,r);case`complementary`:case`complement`:case`comp`:return e.complementary(t);case`double-complementary`:case`double-complement`:case`double`:return e.doubleComplementary(t,r);case`split-complementary`:case`split-complement`:case`split`:return e.splitComplementary(t,r);case`square`:return e.square(t)}return null}constructor(t,n,r){if(!(0<=t&&t<=255&&0<=n&&n<=255&&0<=r&&r<=255))throw Error(`Color values out of bounds (0 - 255)`);this.#e=e.nc(e.tc(t,`number`)),this.#t=e.nc(e.tc(n,`number`)),this.#n=e.nc(e.tc(r,`number`)),this.alpha=1}static saturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s+n,100,0),o=r.l;return e.fromHsl(i,a,o)}saturate(t){return e.saturate(this,t)}static desaturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s-n,100,0),o=r.l;return e.fromHsl(i,a,o)}desaturate(t){return e.desaturate(this,t)}static grayscale(t){return e.desaturate(t,100)}grayscale(){return e.greyscale(this)}static greyscale(t){return e.desaturate(t,100)}greyscale(){return e.greyscale(this)}static lighten(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=r.s,o=this.clmp(r.l+n,100,0);return e.fromHsl(i,a,o)}lighten(t){return e.lighten(this,t)}static darken(t,n){return e.lighten(t,-n)}darken(t){return e.darken(this,t)}static brighten(t,n){let r=t.toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),new e(r.r,r.g,r.b)}brighten(t){return e.brighten(this,t)}static shiftHue(t,n){this.ic(t,e),this.tc(n,Number);let{h:r,s:i,l:a}=t.toHsl();return r=this.shift(r,n),e.fromHsl(r,i,a)}shiftHue(t){return e.shiftHue(this,t)}static multiply(t,n){this.ic(t,e),this.ic(n,e);let{r1:r,g1:i,b1:a}=t.toRgb(),{r2:o,g2:s,b2:c}=n.toRgb();return e.fromRgb(r*o/255,i*s/255,a*c/255)}multiply(t){return e.multiply(this,t)}static mix(t,n,r=50){this.ic(t,e),this.ic(t,e),this.tc(r,`number`);let i=t.toRgb(),a=n.toRgb(),o=this.clmp(r,100,0)/100,s=Math.round((a.r-i.r)*o+i.r),c=Math.round((a.g-i.g)*o+i.g),l=Math.round((a.b-i.b)*o+i.b);return e.fromRgb(s,c,l)}mix(t,n){return e.mix(this,t,n)}static lerp(t,n,r=.5){this.tc(r,`number`),this.ic(t,e),this.ic(n,e),r=this.clmp(r,1,0);let i=t.toRgb(),a=n.toRgb(),o=i.r/255,s=i.g/255,c=i.b/255,l=a.r/255,u=a.g/255,d=a.b/255;return e.fromRgb((o+(l-o)*r)*255,(s+(u-s)*r)*255,(c+(d-c)*r)*255)}lerp(t,n){return e.lerp(this,t,n)}static add(t,n){this.ic(t,e),this.ic(n,e);let r=t.toRgb(),i=n.toRgb(),a=r.r,o=r.g,s=r.b,c=i.r,l=i.g,u=i.b;return e.fromRgb(Math.round((a+c)/2),Math.round((o+l)/2),Math.round((s+u)/2))}add(t){return e.add(this,t)}static fromHex(t){if(!t.match(/^#?(?:[0-9a-fA-F]{3}){1,2}$/i))throw Error(`Invalid Hex code: "`+t+`"`);let n=`0x00`,r=`0x00`,i=`0x00`;return t.length==4?(n=`0x`+t[1]+t[1],r=`0x`+t[2]+t[2],i=`0x`+t[3]+t[3]):t.length==3?(n=`0x`+t[0]+t[0],r=`0x`+t[1]+t[1],i=`0x`+t[2]+t[2]):t.length==7?(n=`0x`+t[1]+t[2],r=`0x`+t[3]+t[4],i=`0x`+t[5]+t[6]):t.length==6&&(n=`0x`+t[0]+t[1],r=`0x`+t[2]+t[3],i=`0x`+t[4]+t[5]),new e(parseInt(n,16),parseInt(r,16),parseInt(i,16))}static fromRgb(t,n,r){return new e(t,n,r)}static fromHsl(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i/2,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e(Math.round((s+o)*255),Math.round((c+o)*255),Math.round((l+o)*255))}static fromHsv(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=r*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e((s+o)*255,(c+o)*255,(l+o)*255)}static fromCssString(t){this.tc(t,`string`);var n=document.createElement(`canvas`).getContext(`2d`);let r;if(n&&(n.fillStyle=t,r=n.fillStyle),!r)throw Error(`Invalid Color string`);return e.fromHex(r)}static fromName(e){e=this.tc(e,`string`);let t=this.Colors[e.toUpperCase()];if(!t)throw Error(`Invalid Color name`);return t}static toHex(t){t=this.ic(t,e);let n=Math.round(t.#e).toString(16),r=Math.round(t.#t).toString(16),i=Math.round(t.#n).toString(16);return n.length==1&&(n=`0`+n),r.length==1&&(r=`0`+r),i.length==1&&(i=`0`+i),`#`+n+r+i}static toHsl(t){t=this.ic(t,e);let n=0,r=0,i=0,a=t.#e/255,o=t.#t/255,s=t.#n/255,c=Math.min(Math.min(a,o),s),l=Math.max(Math.max(a,o),s),u=l-c;return n=u===0?0:l===a?(o-s)/u%6:l===o?(s-a)/u+2:(a-o)/u+4,n=Math.round(n*60),n<0&&(n+=360),i=(l+c)/2,r=u===0?0:u/(1-Math.abs(2*i-1)),r=parseFloat(Math.abs(r*100)+``),i=parseFloat(Math.abs(i*100)+``),{h:this.nc(n),s:this.nc(r),l:this.nc(i)}}static toHsv(e){let t=0,n=0,r=0,i=e.#e/255,a=e.#t/255,o=e.#n/255,s=Math.min(Math.min(i,a),o),c=Math.max(Math.max(i,a),o),l=c-s;return t=l===0?0:c===i?(a-o)/l%6:c===a?(o-i)/l+2:(i-a)/l+4,t=Math.round(t*60),t<0&&(t+=360),c!==0&&(n=l/c*100),r=c*100,{h:this.nc(t),s:this.nc(n),v:this.nc(r)}}static toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}static toCmyk(t){this.ic(t,e);let{r:n,g:r,b:i}=t.toRgb(),a=1-n/255,o=1-r/255,s=1-i/255,c=Math.min(a,Math.min(o,s));return a=(a-c)/(1-c),o=(o-c)/(1-c),s=(s-c)/(1-c),a=this.nc(Math.round(a*1e4)/100),o=this.nc(Math.round(o*1e4)/100),s=this.nc(Math.round(s*1e4)/100),c=this.nc(Math.round(c*1e4)/100),{c:a,m:o,y:s,k:c}}toHsl(){return e.toHsl(this)}toHsv(){return e.toHsv(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}toCmyk(){return e.toCmyk(this)}static random(){return new e(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))}toString(t=`hex`){e.tc(t,`string`);let n=this.toRgb(),r=this.toHsl();switch(t.toLowerCase()){case`hex`:return this.toHex();case`hexa`:let e=Math.round(this.alpha*255).toString(16);return e.length===1&&(e=`0`+e),this.toHex()+e;case`rgb`:return`rgb(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)})`;case`rgba`:return`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${this.alpha})`;case`hsl`:return`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`;case`hsla`:return`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${this.alpha})`;case`hsv`:let t=this.toHsv();return`hsv(${Math.round(t.h)}, ${Math.round(t.s)}%, ${Math.round(t.v)}%)`;case`cmyk`:let i=this.toCmyk();return`cmyk(${Math.round(i.c)}%, ${Math.round(i.m)}%, ${Math.round(i.y)}%, ${Math.round(i.k)}%)`;default:}return``}valueOf(){return parseInt(`0x`+this.toHex().slice(1))}},oa=class extends Error{sourceStart;sourceEnd;parserState;constructor(e,t,n,r){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n,this.parserState=r}},sa=class extends oa{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ca={UnexpectedNewLineInString:`Unexpected newline while consuming a string token.`,UnexpectedEOFInString:`Unexpected EOF while consuming a string token.`,UnexpectedEOFInComment:`Unexpected EOF while consuming a comment.`,UnexpectedEOFInURL:`Unexpected EOF while consuming a url token.`,UnexpectedEOFInEscapedCodePoint:`Unexpected EOF while consuming an escaped code point.`,UnexpectedCharacterInURL:`Unexpected character while consuming a url token.`,InvalidEscapeSequenceInURL:`Invalid escape sequence while consuming a url token.`,InvalidEscapeSequenceAfterBackslash:`Invalid escape sequence after "\\"`};typeof globalThis<`u`&&`structuredClone`in globalThis;function la(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const ua=65533;function da(e){return e.source.codePointAt(e.cursor)===60&&e.source.codePointAt(e.cursor+1)===33&&e.source.codePointAt(e.cursor+2)===45&&e.source.codePointAt(e.cursor+3)===45}function fa(e){return e>=48&&e<=57}function pa(e){return e>=65&&e<=90}function ma(e){return e>=97&&e<=122}function ha(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ga(e){return ma(e)||pa(e)}function _a(e){return ga(e)||ya(e)||e===95}function va(e){return _a(e)||fa(e)||e===45}function ya(e){return e===183||e===8204||e===8205||e===8255||e===8256||e===8204||192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e===0||!!Ca(e)||e>=65536}function ba(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function xa(e){return e===10||e===13||e===12}function Sa(e){return e===32||e===10||e===9||e===13||e===12}function Ca(e){return e>=55296&&e<=57343}function wa(e){return e.source.codePointAt(e.cursor)===92&&!xa(e.source.codePointAt(e.cursor+1)??-1)}function Ta(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!_a(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!xa(t.source.codePointAt(t.cursor+2)??-1):!!_a(t.source.codePointAt(t.cursor)??-1)||wa(t)}function Ea(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!fa(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&fa(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?fa(e.source.codePointAt(e.cursor+1)??-1):fa(e.source.codePointAt(e.cursor)??-1)}function Da(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Oa(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var z,B,ka;function Aa(e){switch(e){case z.OpenParen:return z.CloseParen;case z.CloseParen:return z.OpenParen;case z.OpenCurly:return z.CloseCurly;case z.CloseCurly:return z.OpenCurly;case z.OpenSquare:return z.CloseSquare;case z.CloseSquare:return z.OpenSquare;default:return null}}function ja(e){switch(e[0]){case z.OpenParen:return[z.CloseParen,`)`,-1,-1,void 0];case z.CloseParen:return[z.OpenParen,`(`,-1,-1,void 0];case z.OpenCurly:return[z.CloseCurly,`}`,-1,-1,void 0];case z.CloseCurly:return[z.OpenCurly,`{`,-1,-1,void 0];case z.OpenSquare:return[z.CloseSquare,`]`,-1,-1,void 0];case z.CloseSquare:return[z.OpenSquare,`[`,-1,-1,void 0];default:return null}}function Ma(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedEOFInComment,t.representationStart,t.representationEnd,[`4.3.2. Consume comments`,`Unexpected EOF`],n)),n}if(n===42&&t.source.codePointAt(t.cursor)!==void 0&&t.source.codePointAt(t.cursor)===47){t.advanceCodePoint();break}}return[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function Na(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new oa(ca.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),ua;if(ha(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&ha(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint());let i=parseInt(String.fromCodePoint(...e),16);return i===0||Ca(i)||i>1114111?ua:i}return n===0||Ca(n)?ua:n}function Pa(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ca(r))n.push(ua),t.advanceCodePoint(+(r>65535)+1);else if(va(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!wa(t))return n;t.advanceCodePoint(),n.push(Na(e,t))}}}function Fa(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(va(n)||wa(t))){let n=ka.Unrestricted;Ta(0,t)&&(n=ka.ID);let r=Pa(e,t);return[z.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[z.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function Ia(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&fa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(fa(t.source.codePointAt(t.cursor+1)??-1))t.advanceCodePoint(2);else{if(t.source.codePointAt(t.cursor+1)!==45&&t.source.codePointAt(t.cursor+1)!==43||!fa(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function La(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ia(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Ta(0,t)){let a=Pa(e,t);return[z.Dimension,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r,unit:String.fromCodePoint(...a)}]}return t.source.codePointAt(t.cursor)===37?(t.advanceCodePoint(),[z.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[z.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function Ra(e){for(;Sa(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[z.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}(function(e){e.Comment=`comment`,e.AtKeyword=`at-keyword-token`,e.BadString=`bad-string-token`,e.BadURL=`bad-url-token`,e.CDC=`CDC-token`,e.CDO=`CDO-token`,e.Colon=`colon-token`,e.Comma=`comma-token`,e.Delim=`delim-token`,e.Dimension=`dimension-token`,e.EOF=`EOF-token`,e.Function=`function-token`,e.Hash=`hash-token`,e.Ident=`ident-token`,e.Number=`number-token`,e.Percentage=`percentage-token`,e.Semicolon=`semicolon-token`,e.String=`string-token`,e.URL=`url-token`,e.Whitespace=`whitespace-token`,e.OpenParen=`(-token`,e.CloseParen=`)-token`,e.OpenSquare=`[-token`,e.CloseSquare=`]-token`,e.OpenCurly=`{-token`,e.CloseCurly=`}-token`,e.UnicodeRange=`unicode-range-token`})(z||={}),function(e){e.Integer=`integer`,e.Number=`number`}(B||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(ka||={});var za=class{cursor=0;source=``;representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor+=e,this.representationEnd=this.cursor-1}readCodePoint(){let e=this.source.codePointAt(this.cursor);if(e!==void 0)return this.cursor+=1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor-=e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}};function Ba(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(xa(i)){t.unreadCodePoint();let n=[z.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10?t.representationEnd+2:t.representationEnd+1,[`4.3.5. Consume a string token`,`Unexpected newline`],n)),n}if(i===r)return[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Ca(i)?n+=String.fromCodePoint(ua):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(xa(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint();continue}n+=String.fromCodePoint(Na(e,t))}}}function Va(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Ha(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();wa(t)?(t.advanceCodePoint(),Na(e,t)):t.advanceCodePoint()}}function Ua(e,t){for(;Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected EOF`],r)),r}if(t.source.codePointAt(t.cursor)===41)return t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Sa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Consume as much whitespace as possible`,`Unexpected EOF`],r)),r}return t.source.codePointAt(t.cursor)===41?(t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(Ha(e,t),[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}let r=t.source.codePointAt(t.cursor);if(r===34||r===39||r===40||ba(r??-1)){Ha(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedCharacterInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point`],n)),n}if(r===92){if(wa(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Na(e,t));continue}Ha(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.InvalidEscapeSequenceInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],r)),r}t.source.codePointAt(t.cursor)===0||Ca(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(ua),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Wa(e,t){let n=Pa(e,t);if(t.source.codePointAt(t.cursor)!==40)return[z.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(Va(n)){t.advanceCodePoint();let r=0;for(;;){let e=Sa(t.source.codePointAt(t.cursor)??-1),i=Sa(t.source.codePointAt(t.cursor+1)??-1);if(e&&i){r+=1,t.advanceCodePoint(1);continue}let a=e?t.source.codePointAt(t.cursor+1):t.source.codePointAt(t.cursor);if(a===34||a===39)return r>0&&t.unreadCodePoint(r),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return Ua(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function Ga(e){return!(e.source.codePointAt(e.cursor)!==117&&e.source.codePointAt(e.cursor)!==85||e.source.codePointAt(e.cursor+1)!==43||e.source.codePointAt(e.cursor+2)!==63&&!ha(e.source.codePointAt(e.cursor+2)??-1))}function Ka(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&ha(i);)n.push(i),t.advanceCodePoint();for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&i===63;)r.length===0&&r.push(...n),n.push(48),r.push(70),t.advanceCodePoint();if(!r.length&&t.source.codePointAt(t.cursor)===45&&ha(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&ha(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:e,endOfRange:e}]}let a=parseInt(String.fromCodePoint(...n),16),o=parseInt(String.fromCodePoint(...r),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function qa(e,t){let n=Ja(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Ja(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new za(n),a={onParseError:t?.onParseError??Ya};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[z.EOF,``,-1,-1,void 0];if(e===47&&Da(i))return Ma(a,i);if(r&&(e===117||e===85)&&Ga(i))return Ka(0,i);if(_a(e))return Wa(a,i);if(fa(e))return La(a,i);switch(e){case 44:return i.advanceCodePoint(),[z.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[z.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[z.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[z.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[z.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[z.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[z.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[z.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[z.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return Ba(a,i);case 35:return Fa(a,i);case 43:case 46:return Ea(i)?La(a,i):(i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case 10:case 13:case 12:case 9:case 32:return Ra(i);case 45:return Ea(i)?La(a,i):Oa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Ta(0,i)?Wa(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return da(i)?(i.advanceCodePoint(4),[z.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[z.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),Ta(0,i)){let e=Pa(a,i);return[z.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[z.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(wa(i))return Wa(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new sa(ca.InvalidEscapeSequenceAfterBackslash,i.representationStart,i.representationEnd,[`4.3.1. Consume a token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],e)),e}}return i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function(){return i.source.codePointAt(i.cursor)===void 0}}}function Ya(){}function Xa(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=Za(n);r[0]===101&&$a(r,0,r[0]);let i=String.fromCodePoint(...r);e[1]=`${e[4].signCharacter===`+`?e[4].signCharacter:``}${e[4].value.toString()}${i}`,e[4].unit=t}function Za(e){let t=0;if(e[0]===0)e.splice(0,1,ua),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,_a(e[1])||(t+=$a(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];_a(e[0])?t=1:(t=1,t+=$a(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,ua),n++):va(e[n])||(n+=Qa(e,n,e[n]));return e}function Qa(e,t,n){return e.splice(t,1,92,n),1}function $a(e,t,n){let r=n.toString(16),i=[];for(let e of r)i.push(e.codePointAt(0));return e.splice(t,1,92,...i,32),1+i.length}const eo=Object.values(z);function to(e){return!!Array.isArray(e)&&!(e.length<4)&&!!eo.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function V(e){if(!e)return!1;switch(e[0]){case z.Dimension:case z.Number:case z.Percentage:return!0;default:return!1}}function no(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function ro(e){return!!e&&e[0]===z.Colon}function io(e){return!!e&&e[0]===z.Comma}function ao(e){return!!e&&e[0]===z.Comment}function oo(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function so(e){return!!e&&e[0]===z.EOF}function co(e){return!!e&&e[0]===z.Function}function lo(e){return!!e&&e[0]===z.Hash}function U(e){return!!e&&e[0]===z.Ident}function W(e){return!!e&&e[0]===z.Number}function G(e){return!!e&&e[0]===z.Percentage}function uo(e){return!!e&&e[0]===z.Semicolon}function fo(e){return!!e&&e[0]===z.Whitespace}function po(e){return!!e&&e[0]===z.OpenParen}function mo(e){return!!e&&e[0]===z.CloseParen}function ho(e){return!!e&&e[0]===z.OpenSquare}function go(e){return!!e&&e[0]===z.OpenCurly}function _o(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}const vo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
494
494
  /**
495
495
  * Bradford chromatic adaptation from D50 to D65
package/out/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.19`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
2
+ let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.21`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aventusjs/cli",
3
3
  "displayName": "Aventus CLI",
4
4
  "description": "This official CLI to compile Aventus Framework",
5
- "version": "0.0.20",
5
+ "version": "0.0.22",
6
6
  "icon": "icons/logo.png",
7
7
  "bin": {
8
8
  "aventus": "./out/cli.js",