@aventusjs/cli 0.0.34 → 0.0.36

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
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("fs"),d=require("vscode-languageserver-textdocument"),f=require("path"),p=require("typescript"),m=require("vscode-languageserver"),h=require("vscode-json-languageservice"),g=require("process"),_=require("connect");_=l(_);let v=require("send");v=l(v);let y=require("url");y=l(y);let b=require("http"),x=require("net"),ee=require("serve-index");ee=l(ee);let te=require("ws"),ne=require("open");ne=l(ne);let S=require("vscode-html-languageservice"),re=require("postcss");re=l(re);let ie=require("vscode-css-languageservice"),ae=require("sass"),oe=require("https"),se=require("unzipper"),ce=require("child_process"),le=require("crypto"),ue=require("os"),de=require("archiver"),fe=require("terser"),pe=require("esbuild"),me=require("chokidar"),he=require("util"),ge=require("sudo-prompt"),_e=require("readline");_e=l(_e);const C={Base:`Aventus`,TypeScript:`Aventus Ts`,HTML:`Aventus HTML`,SCSS:`Aventus SCSS`,WebComponent:`Aventus WebComponent`,Package:`Aventus Ts`,I18n:`Aventus I18n`},w={Base:`.avt`,Config:`aventus.conf.avt`,CsharpConfig:`aventus.sharp.avt`,PhpConfig:`aventus.php.avt`,ComponentLogic:`.wcl.avt`,ComponentView:`.wcv.avt`,ComponentStyle:`.wcs.avt`,Component:`.wc.avt`,GlobalStyle:`.gs.avt`,Data:`.data.avt`,Lib:`.lib.avt`,RAM:`.ram.avt`,State:`.state.avt`,Static:`.static.avt`,Definition:`.def.avt`,DefinitionNpm:`.defnpm.avt`,Template:`template.avt.ts`,ConfigTemplate:`!aventus.conf.avt`,Package:`.package.avt`,I18n:`.i18n.avt`},ve={$schema:`foo://aventus/conf.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for all your builds (x.x.x)`},description:{type:`string`,description:`Description of the package`},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},hideWarnings:{type:`boolean`,description:`Hide warnings for all your builds`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},dependencies:{$ref:`#/$defs/dependencies`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},build:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:"Part name for the module. The export file will be ${module}@${name}",pattern:`^[a-zA-Z0-9_]+$`},description:{type:`string`,description:`Description of the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for this build (x.x.x)`},disabled:{type:`boolean`,description:`Disable auto-build`,default:!0},hideWarnings:{type:`boolean`,description:`Hide warnings for this build`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},src:{type:`array`,items:{type:`string`},description:`List of all pathes to listen watch`},stories:{type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define where to export your stories`},workspace:{type:`string`,description:`Define where to add the .storybook`},live:{type:`boolean`,description:`Define if the story content must be recompiled on change`},format:{type:`string`,enum:[`all`,`public`,`protected`,`manual`],default:`all`,description:`All will export all elements, public only public elements, protected only public and protected elements, manual only elements with tag Storybook`},prefix:{type:`string`,description:`Define a prefix for all your stories name. Allow to group stories`},srcBaseUrl:{type:`string`,description:`Define a base url to link file to your repo`}}},outsideModule:{type:`array`,items:{type:`string`},description:`List of all pathes to import outside the module`},compile:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{input:{type:[`string`,`array`],items:{type:`string`},description:`List of all pathes to import inside this build`},output:{type:[`string`,`array`,`object`],description:`The script file generated path`,pattern:`^\\S+\\.js`,items:{type:[`string`,`object`],pattern:`^\\S+\\.js`,properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},outputNpm:{type:[`string`,`array`,`object`],additionalProperties:!1,properties:{path:{type:[`string`,`array`]},packageJson:{type:`boolean`,description:`Define if you need to generate a package.json`},npmName:{type:`string`,description:`Define the name set inside your package.json`},manifest:{type:`boolean`,description:`Define if you need to generate manifest for your components`},live:{type:`boolean`,description:`Define if the npm content must be recompiled on change. Default is false`}},items:{type:`string`},description:`Define where to export as npm files`},compressed:{type:`boolean`},package:{type:[`string`,`array`],items:{type:`string`,pattern:`^\\S+\\.package\\.avt`},pattern:`^\\S+\\.package\\.avt`,description:`The package file generated path (for lib)`},i18n:{type:[`string`,`array`],items:{type:`object`,additionalProperties:!1,properties:{output:{type:[`string`,`array`],items:{type:`string`}},mount:{type:`string`},mode:{type:`string`,enum:[`singleFile`,`oneToOne`,`groupComponent`,`basedOnAttribute`,`include`],default:`singleFile`}},required:[`output`]}}}}},dependencies:{$ref:`#/$defs/dependencies`},module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module for this build`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},nodeModulesDir:{type:[`string`,`array`],items:{type:`string`},description:`The dirs where node_modules are located`},i18n:{type:`object`,properties:{locales:{type:`array`,items:{type:`string`},description:`Locales that is required inside your project`},fallback:{type:`string`},autoRegister:{type:`boolean`}},description:`Define options for i18n`}},required:[`src`]},minItems:1},static:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:`Part name for the static export`,pattern:`^[a-zA-Z0-9_]+$`},input:{type:`string`,description:`Input path to watch to export as static files`},output:{type:[`string`,`array`],items:{type:`string`},description:`Define where to export static files`}},required:[`name`,`input`,`output`]}},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},aliases:{type:`object`}},required:[`build`,`module`],$defs:{dependencies:{type:`object`,description:`List of dependencies for this build`,patternProperties:{"^\\S+$":{type:[`object`,`string`],additionalProperties:!1,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,properties:{uri:{type:`string`,description:`Where to find the package or the json file`},npm:{type:`string`,description:`The npm package name`},version:{type:`string`,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,description:`The version to use for this file. (default is x.x.x)`,default:`x.x.x`},isLocal:{type:`boolean`,description:`Define if you want to use a local package`},include:{type:`string`,description:`Determine if the package must be included inside the final export. (default is need)`,enum:[`none`,`need`,`full`],default:`need`},subDependenciesInclude:{type:`object`,description:`Inclusion pattern for each lib. You can use a star to select everythink. If nothink find for a lib, the need value ll be used`,patternProperties:{"^\\S+$":{type:`string`,enum:[`none`,`need`,`full`],default:`need`}}}}}}},compileOutput:{type:[`string`,`object`],pattern:`^\\S+\\.js`,additionalProperties:!1,properties:{path:{type:`string`,pattern:`^\\S+\\.js`},compressed:{type:`boolean`}}}}},ye={$schema:`foo://aventus/sharp.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{csProj:{type:`string`,pattern:`^\\S+\\.csproj`,description:`Path to your csproj file`},outputPath:{type:`string`,description:`Define the folder where to export the code`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if errors must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEndPointByDefault:{type:`boolean`,default:!0,description:`Define if websocket endpoint must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEventByDefault:{type:`boolean`,default:!0,description:`Define if websocket event must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsRouteByDefault:{type:`boolean`,default:!0,description:`Define if websocket route must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},wsEndPoint:{$ref:`#/$defs/replacerPart`},wsEvent:{$ref:`#/$defs/replacerPart`},wsRouter:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to use for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`},addFormData:{type:`boolean`,default:!0,description:"Add ` | FormData` to the route body"},cacheByDefault:{type:`boolean`,default:!1,description:`Add cache to the function generated`},clearCacheFct:{type:`boolean`,default:!1,description:`Add function to clear cache to the function generated`}}},wsEndpoint:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},prefix:{type:`string`,default:`Define a prefix for your websocket events`},host:{type:`string`,description:`The host to connect to the websocket`},port:{type:`number`,description:`The port to connect to the websocket`},useHttps:{type:`boolean`,description:`Define if you want to use http or https. Be default, Aventus will check if your connection is secure to use https or not`},parent:{type:`string`,default:`AventusSharp.WebSocket.EndPoint`,description:`Define the parent type to use for your router`}}}},required:[`csProj`,`outputPath`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}},be={$schema:`foo://aventus/php.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define the folder where to export the code`},exportAsTs:{type:`boolean`,description:`Define if the code must be compiled as typescript`},useNamespace:{type:`boolean`,description:`Define if the compiler must used namespace`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRequestByDefault:{type:`boolean`,default:!0,description:`Define if request must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpResourceByDefault:{type:`boolean`,default:!0,description:`Define if resource must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if erros must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},httpRequest:{$ref:`#/$defs/replacerPart`},httpResource:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to load for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`}}}},required:[`output`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}};var xe=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({schemaRequestService:async e=>JSON.stringify(ve)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.Config],uri:ve.$schema??``,schema:ve},{fileMatch:[`**`+w.CsharpConfig],uri:ye.$schema??``,schema:ye},{fileMatch:[`**`+w.PhpConfig],uri:be.$schema??``,schema:be}]})}async format(e,t,n){let r=e.documentUser;return await this.languageService.format(r,t,n)}async doComplete(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doComplete(e.documentUser,t,r),a=r.getNodeFromOffset(n.offsetAt(t));return this.isKeyOfObject(a,`dependencies`)&&(i||={isIncomplete:!1,items:[]},i?.items.push({label:`Aventus@Main`},{label:`Aventus@UI`},{label:`Aventus@I18n`},{label:`Aventus@Sharp`},{label:`Aventus@Php`})),i||{isIncomplete:!1,items:[]}}async doResolve(e){return await this.languageService.doResolve(e)}async doHover(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n);return await this.languageService.doHover(n,t,r)}async validate(e){let t=e.documentUser,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=this.removeComments(t.getText());try{return JSON.parse(e),r}catch{r.push(Li(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}isKeyOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.keyNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}isValueOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.valueNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}async getConfig(e){let t=`documentUser`in e?e.documentUser:e,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n,void 0,ve);if(r.length==0){let e=this.removeComments(t.getText());try{let n=JSON.parse(e);return n=this.prepareConfigFile(t.uri,n),n}catch{r.push(Li(t,`Can't parse the json`,1001))}}return null}prepareConfigFile(e,t){if(t={...this.defaultConfigValue(),...t},t.componentPrefix==``){let e=t.module.match(/([A-Z][a-z]*)|([0-9][a-z]*)/g);e?t.componentPrefix=e.join(`-`).toLowerCase():t.componentPrefix=`av`}let n=[];for(let r of t.build)n.push(this.prepareBuild(e,r,t));if(t.build=n,t.static){let n=[];for(let r of t.static)n.push(this.prepareStatic(e,r));t.static=n}return t}replaceEnvVar(e,t){if(!e||e.startsWith(`@`)||e.startsWith(`Aventus@`))return e;let n=/%(.*?)%/gm,r;for(;r=n.exec(e);){let t=g.env[r[1]]??`undefined`;e=e.replace(r[0],t)}return/^https?:\/\/.*/.exec(e)||(!e.startsWith(`/`)&&!/^[a-zA-Z]:/gm.test(e)?(e=`/`+e,e=(0,f.normalize)(I(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=Gi(e);t={...this.defaultConfigBuildValue(n),...t},t.name?t.fullname=t.module+`@`+t.name:t.fullname=t.module;let i=e=>this.replaceEnvVar(e,r),a=t.compile;for(let e of a){if(!e.input)e.inputPathRegex=RegExp(`.*`);else{Array.isArray(e.input)||(e.input=[e.input]);let t=[];for(let n of e.input){let e=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(e=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(I(r)+e+n).replace(/\\/g,`/`);a=Ji(a,!0).replace(`*`,`.*`),t.push(`(^`+a+`$)`)}let n=t.join(`|`);n==``&&(n=`(?!)`),e.inputPathRegex=new RegExp(n)}if(!e.output)e.output=[];else{Array.isArray(e.output)||(e.output=[e.output]);for(let t=0;t<e.output.length;t++){let n=e.output[t];typeof n==`string`&&(e.output[t]={"@default":{path:n}},n=e.output[t]);let r=!1;for(let a in n){a==`@default`&&(r=!0);let o=n[a];typeof o==`string`&&(e.output[t][a]={path:o}),e.output[t][a].path=n[a].path.trim(),n[a].path.length>0&&(e.output[t][a].path=i(n[a].path))}r||(e.output[t][`@default`]={path:`./dist/script.js`})}}if(!e.outputNpm)e.outputNpm={path:[],packageJson:!1,npmName:``,live:!1};else{typeof e.outputNpm==`string`?e.outputNpm={path:[e.outputNpm],packageJson:!0,npmName:``,manifest:{},live:!1}:Array.isArray(e.outputNpm)&&(e.outputNpm={path:e.outputNpm,packageJson:!0,npmName:``,manifest:{},live:!1}),Array.isArray(e.outputNpm.path)||(e.outputNpm.path=[e.outputNpm.path]),e.outputNpm.packageJson===void 0&&(e.outputNpm.packageJson=!0),e.outputNpm.manifest===void 0&&(e.outputNpm.manifest={}),e.outputNpm.npmName===void 0&&(e.outputNpm.npmName=``),e.outputNpm.live===void 0&&(e.outputNpm.live=!1);for(let t=0;t<e.outputNpm.path.length;t++){let n=i(e.outputNpm.path[t]);n.endsWith(`*`)&&(n=n.slice(0,-1)),n.endsWith(`/`)&&(n=n.slice(0,-1)),n=n.replace(/\\/g,`/`),e.outputNpm.path[t]=n}}if(!e.package)e.package=[];else{Array.isArray(e.package)||(e.package=[e.package]);for(let t=0;t<e.package.length;t++)e.package[t]=e.package[t].trim(),e.package[t].length>0&&(e.package[t]=i(e.package[t]))}if(t.i18n)if(e.i18n){Array.isArray(e.i18n)||(e.i18n=[{output:[e.i18n],mount:``,mode:`singleFile`}]);for(let t=0;t<e.i18n.length;t++){if(!Array.isArray(e.i18n[t].output)){let n=e.i18n[t].output;e.i18n[t].output=[n]}for(let n=0;n<e.i18n[t].output.length;n++)e.i18n[t].output[n].endsWith(`/`)&&(e.i18n[t].output[n]=e.i18n[t].output[n].slice(0,-1)),e.i18n[t].output[n]=e.i18n[t].output[n].trim(),e.i18n[t].output[n].length>0&&(e.i18n[t].output[n]=i(e.i18n[t].output[n]));if(!e.i18n[t].mount&&e.i18n[t].output.length>0){let n=(0,f.normalize)(I($.getWorkspaceUri())),r=e.i18n[t].output[0].replace(n,``).replace(/\\/g,`/`);r.startsWith(`/dist`)&&(r=r.replace(`/dist`,``)),e.i18n[t].mount=r}e.i18n[t].mount.endsWith(`/`)&&(e.i18n[t].mount=e.i18n[t].mount.slice(0,-1))}}else{e.i18n=[];for(let t of e.output){let n=t[`@default`].path.split(f.sep);n.pop();let r=(0,f.join)(n.join(f.sep),`locales`),i=(0,f.normalize)(I($.getWorkspaceUri())),a=r.replace(i,``).replace(/\\/g,`/`);a.startsWith(`/dist`)&&(a=a.replace(`/dist`,``)),e.i18n.push({output:[r],mount:a,mode:`singleFile`})}}}let o=[];for(let e of t.src){let n=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(n=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(I(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=Ji(a,!0).replace(`*`,`.*`),o.push(`(^`+a+`$)`)}if(t.stories){t.stories={...this.defaultConfigBuildStories(r,n),...t.stories};let e=i(t.stories.output);e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.stories.output=e}let s=o.join(`|`);s==``&&(s=`(?!)`),t.srcPathRegex=new RegExp(s),t.nodeModulesDir=t.nodeModulesDir.trim(),t.nodeModulesDir==``?t.nodeModulesDir=(0,f.normalize)(I(r)+`/node_modules`):t.nodeModulesDir=i(t.nodeModulesDir);let c={};t.rawDependencies=JSON.parse(JSON.stringify(t.dependencies));for(let e in t.dependencies){let n=t.dependencies[e];typeof n==`string`&&(n={version:n}),c[e]={...this.defaultConfigBuildDependencyValue(n),...n};let r=c[e];r.subDependenciesInclude||={},r.subDependenciesInclude[`*`]||(r.subDependenciesInclude[`*`]=n.include??`need`),r.uri&&=i(r.uri)}if(t.dependencies=c,t.outsideModule){let e=[];for(let n of t.outsideModule){let t=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(t=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(I(r)+t+n).replace(/\\/g,`/`);a=Ji(a,!0).replace(`*`,`.*`),e.push(`(^`+a+`$)`)}let n=e.join(`|`);n==``&&(n=`(?!)`),t.outsideModulePathRegex=new RegExp(n)}if(t.namespaceStrategy==`rules`)for(let e in t.namespaceRules){let n=[],i=t.namespaceRules[e];for(let e of i){let t=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(t=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(I(r)+t+e).replace(/\\/g,`/`);a=Ji(a,!0).replace(`*`,`.*`),n.push(`(^`+a+`$)`)}let a=n.join(`|`);a==``&&(a=`(?!)`),t.namespaceRulesRegex[e]=new RegExp(a)}else if(t.namespaceStrategy==`followFolders`||t.namespaceStrategy==`followFoldersCamelCase`){let e=``;t.namespaceRoot.startsWith(`/`)||(e=`/`),t.namespaceRoot=(0,f.normalize)(I(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=Gi(e),r=``;t.input.startsWith(`/`)||(r=`/`),t.input.endsWith(`*`)&&(t.input=t.input.slice(0,-1)),t.input.endsWith(`/`)&&(t.input=t.input.slice(0,-1)),t.inputPathFolder=(0,f.normalize)(I(n)+r+t.input),t.inputPathFolder=t.inputPathFolder.replace(/\\/g,`/`),r=``,Array.isArray(t.output)||(t.output=[t.output]),t.outputPathFolder=[];for(let e of t.output)e=this.replaceEnvVar(e,n),e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:P.getInstance().settings.defaultHideWarnings,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`}}defaultConfigBuildValue(e){return{fullname:``,name:``,tags:e.tags,version:e.version,organization:e.organization,description:e.description,readme:e.readme,repository:e.repository,documentation:e.documentation,disabled:!1,hideWarnings:e.hideWarnings,src:[],srcPath:[],stories:void 0,compile:[],srcPathRegex:RegExp(`(?!)`),outsideModule:[],outsideModulePathRegex:RegExp(`(?!)`),module:e.module,componentPrefix:e.componentPrefix,namespaceStrategy:e.namespaceStrategy,namespaceRules:{...e.namespaceRules},namespaceRulesRegex:{...e.namespaceRulesRegex},namespaceRoot:e.namespaceRoot,dependencies:{...e.dependencies},rawDependencies:{},avoidParsingInsideTags:[...e.avoidParsingInsideTags],nodeModulesDir:``}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}};const Se=new Uint8Array(16);function Ce(){return crypto.getRandomValues(Se)}const we=[];for(let e=0;e<256;++e)we.push((e+256).toString(16).slice(1));function Te(e,t=0){return(we[e[t+0]]+we[e[t+1]]+we[e[t+2]]+we[e[t+3]]+`-`+we[e[t+4]]+we[e[t+5]]+`-`+we[e[t+6]]+we[e[t+7]]+`-`+we[e[t+8]]+we[e[t+9]]+`-`+we[e[t+10]]+we[e[t+11]]+we[e[t+12]]+we[e[t+13]]+we[e[t+14]]+we[e[t+15]]).toLowerCase()}function T(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Ee(e,t,n)}function Ee(e,t,n){e||={};let r=e.random??e.rng?.()??Ce();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Te(r)}var E=class{_documentUser;_documentInternal;get documentUser(){return this._documentUser}get documentInternal(){return this._documentInternal}linkInternalAndUser=!0;setDocumentInternal(e){this._documentInternal=e,this._versionInternal=e.version}constructor(e){this._documentUser=e,this._documentInternal=e,this._versionUser=e.version,this._versionInternal=e.version}get uri(){return this.documentUser.uri}get path(){return I(this.uri)}get name(){return this.path.split(`/`).pop()??``}_versionUser=0;get versionUser(){return this._versionUser}_versionInternal=0;get versionInternal(){return this._versionInternal}get contentUser(){return this.documentUser.getText()}get contentInternal(){return this.documentInternal.getText()}get folderUri(){return Gi(this.uri)}get folderPath(){return Gi(this.path)}_shortname=``;get shortname(){if(!this._shortname){let e=this.uri.split(`/`);this._shortname=e[e.length-1]}return this._shortname}onGetBuildCb={};getBuild(){let e=[],t=!1;for(let n in this.onGetBuildCb){let r=this.onGetBuildCb[n]();if(r===null)t=!0;else for(let t of r)e.indexOf(t)==-1&&e.push(t)}return e.length==0&&t?null:e}onGetBuild(e){let t=T();for(;this.onGetBuildCb[t]!=null;)t=T();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};async validate(e=!0){let t={};for(let e in this.onValidateCb){let n=await this.onValidateCb[e](this);for(let e of n){let n=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;t[n]||(t[n]=e)}}if(e)if(P.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});else for(let n of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)},n)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});return Object.values(t)}onValidate(e){let t=T();for(;this.onValidateCb[t]!=null;)t=T();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};triggerContentChange(e){return new Promise(t=>{if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{this.waitingDocContentChange[e.uri]?(this.resolveContentChange[e.uri]||(this.resolveContentChange[e.uri]={}),this.resolveContentChange[e.uri][e.version]||(this.resolveContentChange[e.uri][e.version]=[]),this.resolveContentChange[e.uri][e.version].push(t),this.waitingDocContentChange[e.uri]=e):(this.waitingDocContentChange[e.uri]=!0,this.resolveContentChange[e.uri]={[e.version]:[t]},this.triggerContentChangeNoBuffer(e))},0)})}async triggerContentChangeNoBuffer(e){let t=e.version;this._documentUser=e,this._versionUser=e.version,this.linkInternalAndUser&&(this._documentInternal=e,this._versionInternal=e.version);let n=[];for(let e in this.onContentChangeCb)n.push(this.onContentChangeCb[e](this));if(await Promise.all(n),this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(async()=>{this.validate()},500),this.resolveContentChange[e.uri]){let n=Object.keys(this.resolveContentChange[e.uri]);for(let r of n){if(Number(r)>t)break;if(this.resolveContentChange[e.uri][r]){for(let t of this.resolveContentChange[e.uri][r])t();delete this.resolveContentChange[e.uri][r]}}Object.keys(this.resolveContentChange[e.uri]).length==0&&delete this.resolveContentChange[e.uri]}let r=this.waitingDocContentChange[e.uri];r&&typeof r!=`boolean`?(this.waitingDocContentChange[e.uri]=!0,this.triggerContentChangeNoBuffer(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=T();for(;this.onContentChangeCb[t]!=null;)t=T();return this.onContentChangeCb[t]=e,t}removeOnContentChange(e){delete this.onContentChangeCb[e]}onCanContentChangeCb={};triggerCanContentChange(e){for(let t in this.onCanContentChangeCb)if(!this.onCanContentChangeCb[t](e))return!1;return!0}onCanContentChange(e){let t=T();for(;this.onCanContentChangeCb[t]!=null;)t=T();return this.onCanContentChangeCb[t]=e,t}removeOnCanContentChange(e){delete this.onCanContentChangeCb[e]}async applyTextEdits(e){let t=this.contentUser;e.sort((e,t)=>this.documentUser.offsetAt(t.range.end)-this.documentUser.offsetAt(e.range.end));for(let n of e){let e=this.documentUser.offsetAt(n.range.start),r=this.documentUser.offsetAt(n.range.end);t=t.slice(0,e)+n.newText+t.slice(r,t.length)}let n=d.TextDocument.create(this.uri,C.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb)await this.onSaveCb[e](this)}onSave(e){let t=T();for(;this.onSaveCb[t]!=null;)t=T();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));await Promise.all(e),this.removeAllCallbacks()}removeAllCallbacks(){this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=T();for(;this.onDeleteCb[t]!=null;)t=T();return this.onDeleteCb[t]=e,t}removeOnDelete(e){delete this.onDeleteCb[e]}onCompletionCb={};async getCompletion(e){let t={isIncomplete:!1,items:[]},n=[];for(let t in this.onCompletionCb)n.push(this.onCompletionCb[t](this,e));let r=await Promise.all(n),i={};for(let e of r)for(let t of e.items){let e=JSON.stringify(t);i[e]||(i[e]=t)}return t.items=Object.values(i),t}onCompletion(e){let t=T();for(;this.onCompletionCb[t]!=null;)t=T();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e,n=[];for(let t in this.onCompletionResolveCb)n.push(this.onCompletionResolveCb[t](this,e));return t}onCompletionResolve(e){let t=T();for(;this.onCompletionResolveCb[t]!=null;)t=T();return this.onCompletionResolveCb[t]=e,t}removeOnCompletionResolve(e){delete this.onCompletionResolveCb[e]}onHoverCb={};async getHover(e){let t=[];for(let n in this.onHoverCb)t.push(this.onHoverCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onHover(e){let t=T();for(;this.onHoverCb[t]!=null;)t=T();return this.onHoverCb[t]=e,t}removeOnHover(e){delete this.onHoverCb[e]}onDefinitionCb={};async getDefinition(e){let t=[];for(let n in this.onDefinitionCb)t.push(this.onDefinitionCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onDefinition(e){let t=T();for(;this.onDefinitionCb[t]!=null;)t=T();return this.onDefinitionCb[t]=e,t}removeOnDefinition(e){delete this.onDefinitionCb[e]}onFormattingCb={};async getFormatting(e){e||={insertSpaces:!0,tabSize:4};let t={},n=[],r={start:this.documentUser.positionAt(0),end:this.documentUser.positionAt(this.documentUser.getText().length)};for(let t in this.onFormattingCb)n.push(this.onFormattingCb[t](this,r,e));let i=await Promise.all(n);for(let e of i)for(let n of e){let e=JSON.stringify(n);t[e]||(t[e]=n)}return Object.values(t)}onFormatting(e){let t=T();for(;this.onFormattingCb[t]!=null;)t=T();return this.onFormattingCb[t]=e,t}removeOnFormatting(e){delete this.onFormattingCb[e]}onCodeActionCb={};async getCodeAction(e){let t=[],n=[];for(let t in this.onCodeActionCb)n.push(this.onCodeActionCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onCodeAction(e){let t=T();for(;this.onCodeActionCb[t]!=null;)t=T();return this.onCodeActionCb[t]=e,t}removeOnCodeAction(e){delete this.onCodeActionCb[e]}onReferencesCb={};async getReferences(e){let t=[],n=[];for(let t in this.onReferencesCb)n.push(this.onReferencesCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onReferences(e){let t=T();for(;this.onReferencesCb[t]!=null;)t=T();return this.onReferencesCb[t]=e,t}removeOnReferences(e){delete this.onReferencesCb[e]}onCodeLensCb={};async getCodeLens(){let e=[],t=[];for(let e in this.onCodeLensCb)t.push(this.onCodeLensCb[e](this));let n=await Promise.all(t);for(let t of n)e=[...e,...t];return e}onCodeLens(e){let t=T();for(;this.onCodeLensCb[t]!=null;)t=T();return this.onCodeLensCb[t]=e,t}removeOnCodeLens(e){delete this.onCodeLensCb[e]}onRenameCb={};async getRename(e,t){let n=[];for(let r in this.onRenameCb)n.push(this.onRenameCb[r](this,e,t));let r=await Promise.all(n);for(let e of r)if(e)return e;return null}onRename(e){let t=T();for(;this.onRenameCb[t]!=null;)t=T();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},De=class{_file;_build;get file(){return this._file}get build(){if(this._build)return this._build;throw`No build found`}constructor(e,t){this._file=e,this._build=t,this.addEvents()}uuidEvents={onCanContentChange:``,onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onGetBuild:``,onRename:``};addEvents(){this.uuidEvents.onCanContentChange=this.file.onCanContentChange(this.onCanContentChange.bind(this)),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.onGetBuild=this.file.onGetBuild(this.onGetBuild.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnCanContentChange(this.uuidEvents.onCanContentChange),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.removeOnGetBuild(this.uuidEvents.onGetBuild),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof E&&await this.file.validate()}async triggerSave(){this.file instanceof E&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof E&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof E&&await this.file.triggerContentChange(e)}onCanContentChange(e){return this._file.versionUser!=e.version}oldResult=[];async _onValidate(){let e=this._build?.diagnostics.get(this)??[];return e=[...e,...await this.onValidate()],this._build&&this.build.hideWarnings&&(e=e.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},Oe=o(((e,t)=>{var n=require("stream");e=t.exports=r,r.through=r;function r(e,t,r){e||=function(e){this.queue(e)},t||=function(){this.queue(null)};var i=!1,a=!1,o=[],s=!1,c=new n;c.readable=c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&r.autoDestroy===!1),c.write=function(t){return e.call(this,t),!c.paused};function l(){for(;o.length&&!c.paused;){var e=o.shift();if(e===null)return c.emit(`end`);c.emit(`data`,e)}}c.queue=c.push=function(e){return s?c:(e===null&&(s=!0),o.push(e),l(),c)},c.on(`end`,function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick(function(){c.destroy()})});function u(){c.writable=!1,t.call(c),!c.readable&&c.autoDestroy&&c.destroy()}return c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),u(),c},c.destroy=function(){if(!a)return a=!0,i=!0,o.length=0,c.writable=c.readable=!1,c.emit(`close`),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit(`resume`)),l(),c.paused||c.emit(`drain`),c},c}})),ke=o(((e,t)=>{var n=require("stream");t.exports=function e(t){if(Array.isArray(t)){var r=0,i=t.length;return e(function(e){return r<i?this.emit(`data`,t[r++]):this.emit(`end`),!0})}var a=new n,o=0;a.ended=!1,a.started=!1,a.readable=!0,a.writable=!1,a.paused=!1,a.ended=!1,a.pause=function(){a.started=!0,a.paused=!0};function s(){if(a.started=!0,!a.ended)for(;!a.ended&&!a.paused&&t.call(a,o++,function(){!a.ended&&!a.paused&&process.nextTick(s)}););}return a.resume=function(){a.started=!0,a.paused=!1,s()},a.on(`end`,function(){a.ended=!0,a.readable=!1,process.nextTick(a.destroy)}),a.destroy=function(){a.ended=!0,a.emit(`close`)},process.nextTick(function(){a.started||a.resume()}),a}})),Ae=o(((e,t)=>{var n=require("stream"),r=[`write`,`end`,`destroy`],i=[`resume`,`pause`],a=[`data`,`close`],o=Array.prototype.slice;t.exports=c;function s(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n)}function c(e,t){var c=new n,l=!1;return s(r,u),s(i,d),s(a,f),t.on(`end`,p),e.on(`drain`,function(){c.emit(`drain`)}),e.on(`error`,m),t.on(`error`,m),c.writable=e.writable,c.readable=t.readable,c;function u(t){c[t]=n;function n(){return e[t].apply(e,arguments)}}function d(e){c[e]=n;function n(){c.emit(e);var n=t[e];if(n)return n.apply(t,arguments);t.emit(e)}}function f(e){t.on(e,n);function n(){var t=o.call(arguments);t.unshift(e),c.emit.apply(c,t)}}function p(){if(!l){l=!0;var e=o.call(arguments);e.unshift(`end`),c.emit.apply(c,e)}}function m(e){c.emit(`error`,e)}}})),je=o(((e,t)=>{var n=require("stream").Stream;t.exports=function(e,t){var r=new n,i=0,a=0,o=!1,s=!1,c=!1,l=0,u=!1;t||={};var d=t.failures?`failure`:`error`,f={};r.writable=!0,r.readable=!0;function p(e,t){var n=l+1;if(t===n?(e!==void 0&&r.emit.apply(r,[`data`,e]),l++,n++):f[t]=e,f.hasOwnProperty(n)){var c=f[n];return delete f[n],p(c,n)}a++,i===a&&(s&&(s=!1,r.emit(`drain`)),o&&g())}function m(e,n,i){c||(u=!0,(!e||t.failures)&&p(n,i),e&&r.emit.apply(r,[d,e]),u=!1)}function h(t,n,r){return e.call(null,t,function(e,t){r(e,t,n)})}r.write=function(e){if(o)throw Error(`map stream is not writable`);u=!1,i++;try{return s=h(e,i,m)===!1,!s}catch(e){if(u)throw e;return m(e),!s}};function g(e){if(o=!0,r.writable=!1,e!==void 0)return p(e,i);i==a&&(r.readable=!1,r.emit(`end`),r.destroy())}return r.end=function(e){o||g(e)},r.destroy=function(){o=c=!0,r.writable=r.readable=s=!1,process.nextTick(function(){r.emit(`close`)})},r.pause=function(){s=!0},r.resume=function(){s=!1},r}})),Me=o(((e,t)=>{t.exports=Oe()})),Ne=o(((e,t)=>{var n=Oe(),r=require("string_decoder").StringDecoder;t.exports=i;function i(e,t,i){var a=new r,o=``,s=i&&i.maxLength,c=!(i&&i.trailing===!1);typeof e==`function`&&(t=e,e=null),e||=/\r?\n/;function l(e,n){if(t){try{n=t(n)}catch(t){return e.emit(`error`,t)}n!==void 0&&e.queue(n)}else e.queue(n)}function u(t,n){var r=((o??``)+n).split(e);if(o=r.pop(),s&&o.length>s)return t.emit(`error`,Error(`maximum buffer reached`));for(var i=0;i<r.length;i++){var a=r[i];l(t,a)}}return n(function(e){u(this,a.write(e))},function(){a.end&&u(this,a.end()),c&&o!=null&&l(this,o),this.queue(null)})}})),Pe=o(((e,t)=>{var n=Ae(),r=Oe();t.exports=function(){var e=arguments.length==1&&Array.isArray(arguments[0])?arguments[0]:[].slice.call(arguments);if(e.length==0)return r();if(e.length==1)return e[0];var t=e[0],i=e[e.length-1],a=n(t,i);function o(e){e.length<2||(e[0].pipe(e[1]),o(e.slice(1)))}o(e);function s(){var e=[].slice.call(arguments);e.unshift(`error`),a.emit.apply(a,e)}for(var c=1;c<e.length-1;c++)e[c].on(`error`,s);return a}})),Fe=o((e=>{var t=require("stream").Stream,n=e,r=Oe(),i=ke(),a=Ae(),o=je(),s=Me(),c=Ne(),l=Pe(),u=global.setImmediate||process.nextTick;n.Stream=t,n.through=r,n.from=i,n.duplex=a,n.map=o,n.pause=s,n.split=c,n.pipeline=n.connect=n.pipe=l,n.concat=n.merge=function(){var e=[].slice.call(arguments);e.length===1&&e[0]instanceof Array&&(e=e[0]);var n=new t;n.setMaxListeners(0);var r=0;return n.writable=n.readable=!0,e.length?e.forEach(function(t){t.pipe(n,{end:!1});var i=!1;t.on(`end`,function(){i||(i=!0,r++,r==e.length&&n.emit(`end`))})}):process.nextTick(function(){n.emit(`end`)}),n.write=function(e){this.emit(`data`,e)},n.destroy=function(){e.forEach(function(e){e.destroy&&e.destroy()})},n},n.collect=n.writeArray=function(e){if(typeof e!=`function`)throw Error(`function writeArray (done): done must be function`);var n=new t,r=[],i=!1;return n.write=function(e){r.push(e)},n.end=function(){i=!0,e(null,r)},n.writable=!0,n.readable=!1,n.destroy=function(){n.writable=n.readable=!1,!i&&e(Error(`destroyed before end`),r)},n},n.readArray=function(e){var n=new t,r=0,i=!1,a=!1;if(n.readable=!0,n.writable=!1,!Array.isArray(e))throw Error(`event-stream.read expects an array`);return n.resume=function(){if(!a){i=!1;for(var t=e.length;r<t&&!i&&!a;)n.emit(`data`,e[r++]);r==t&&!a&&(a=!0,n.readable=!1,n.emit(`end`))}},process.nextTick(n.resume),n.pause=function(){i=!0},n.destroy=function(){a=!0,n.emit(`close`)},n},n.readable=function(e,n){var r=new t,i=0,a=!1,o=!1,s=!1;if(r.readable=!0,r.writable=!1,typeof e!=`function`)throw Error(`event-stream.readable expects async function`);r.on(`end`,function(){o=!0});function c(t,l){t?(r.emit(`error`,t),n||r.emit(`end`)):arguments.length>1&&r.emit(`data`,l),u(function(){if(!(o||a||s))try{s=!0,e.call(r,i++,function(){s=!1,c.apply(null,arguments)})}catch(e){r.emit(`error`,e)}})}return r.resume=function(){a=!1,c()},process.nextTick(c),r.pause=function(){a=!0},r.destroy=function(){r.emit(`end`),r.emit(`close`),o=!0},r},n.mapSync=function(e){return n.through(function(t){var n;try{n=e(t)}catch(e){return this.emit(`error`,e)}n!==void 0&&this.emit(`data`,n)})},n.filterSync=function(e){return n.through(function(t){var n=this;e(t)&&n.queue(t)})},n.flatmapSync=function(e){return n.through(function(t){var n=this;t.forEach(function(t){n.queue(e(t))})})},n.log=function(e){return n.through(function(t){[].slice.call(arguments),e?console.error(e,t):console.error(t),this.emit(`data`,t)})},n.child=function(e){return n.duplex(e.stdin,e.stdout)},n.parse=function(e){var t=!!(e&&e.error);return n.through(function(e){var n;try{e&&(n=JSON.parse(e.toString()))}catch(n){return t?this.emit(`error`,n):console.error(n,`attempting to parse:`,e)}n!==void 0&&this.emit(`data`,n)})},n.stringify=function(){var e=require("buffer").Buffer;return n.mapSync(function(t){return JSON.stringify(e.isBuffer(t)?t.toString():t)+`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("fs"),d=require("vscode-languageserver-textdocument"),f=require("path"),p=require("typescript"),m=require("vscode-languageserver"),h=require("vscode-json-languageservice"),g=require("process"),_=require("connect");_=l(_);let v=require("send");v=l(v);let y=require("url");y=l(y);let b=require("http"),x=require("net"),ee=require("serve-index");ee=l(ee);let te=require("ws"),ne=require("open");ne=l(ne);let S=require("vscode-html-languageservice"),re=require("postcss");re=l(re);let ie=require("vscode-css-languageservice"),ae=require("sass"),oe=require("https"),se=require("unzipper"),ce=require("child_process"),le=require("crypto"),ue=require("os"),de=require("archiver"),fe=require("terser"),pe=require("esbuild"),me=require("chokidar"),he=require("util"),ge=require("sudo-prompt"),_e=require("readline");_e=l(_e);const C={Base:`Aventus`,TypeScript:`Aventus Ts`,HTML:`Aventus HTML`,SCSS:`Aventus SCSS`,WebComponent:`Aventus WebComponent`,Package:`Aventus Ts`,I18n:`Aventus I18n`},w={Base:`.avt`,Config:`aventus.conf.avt`,CsharpConfig:`aventus.sharp.avt`,PhpConfig:`aventus.php.avt`,ComponentLogic:`.wcl.avt`,ComponentView:`.wcv.avt`,ComponentStyle:`.wcs.avt`,Component:`.wc.avt`,GlobalStyle:`.gs.avt`,Data:`.data.avt`,Lib:`.lib.avt`,RAM:`.ram.avt`,State:`.state.avt`,Static:`.static.avt`,Definition:`.def.avt`,DefinitionNpm:`.defnpm.avt`,Template:`template.avt.ts`,ConfigTemplate:`!aventus.conf.avt`,Package:`.package.avt`,I18n:`.i18n.avt`},ve={$schema:`foo://aventus/conf.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for all your builds (x.x.x)`},description:{type:`string`,description:`Description of the package`},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},hideWarnings:{type:`boolean`,description:`Hide warnings for all your builds`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},dependencies:{$ref:`#/$defs/dependencies`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},build:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:"Part name for the module. The export file will be ${module}@${name}",pattern:`^[a-zA-Z0-9_]+$`},description:{type:`string`,description:`Description of the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for this build (x.x.x)`},disabled:{type:`boolean`,description:`Disable auto-build`,default:!0},hideWarnings:{type:`boolean`,description:`Hide warnings for this build`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},src:{type:`array`,items:{type:`string`},description:`List of all pathes to listen watch`},stories:{type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define where to export your stories`},workspace:{type:`string`,description:`Define where to add the .storybook`},live:{type:`boolean`,description:`Define if the story content must be recompiled on change`},format:{type:`string`,enum:[`all`,`public`,`protected`,`manual`],default:`all`,description:`All will export all elements, public only public elements, protected only public and protected elements, manual only elements with tag Storybook`},prefix:{type:`string`,description:`Define a prefix for all your stories name. Allow to group stories`},srcBaseUrl:{type:`string`,description:`Define a base url to link file to your repo`}}},outsideModule:{type:`array`,items:{type:`string`},description:`List of all pathes to import outside the module`},compile:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{input:{type:[`string`,`array`],items:{type:`string`},description:`List of all pathes to import inside this build`},output:{type:[`string`,`array`,`object`],description:`The script file generated path`,pattern:`^\\S+\\.js`,items:{type:[`string`,`object`],pattern:`^\\S+\\.js`,properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},outputNpm:{type:[`string`,`array`,`object`],additionalProperties:!1,properties:{path:{type:[`string`,`array`]},packageJson:{type:`boolean`,description:`Define if you need to generate a package.json`},npmName:{type:`string`,description:`Define the name set inside your package.json`},manifest:{type:`boolean`,description:`Define if you need to generate manifest for your components`},live:{type:`boolean`,description:`Define if the npm content must be recompiled on change. Default is false`}},items:{type:`string`},description:`Define where to export as npm files`},compressed:{type:`boolean`},package:{type:[`string`,`array`],items:{type:`string`,pattern:`^\\S+\\.package\\.avt`},pattern:`^\\S+\\.package\\.avt`,description:`The package file generated path (for lib)`},i18n:{type:[`string`,`array`],items:{type:`object`,additionalProperties:!1,properties:{output:{type:[`string`,`array`],items:{type:`string`}},mount:{type:`string`},mode:{type:`string`,enum:[`singleFile`,`oneToOne`,`groupComponent`,`basedOnAttribute`,`include`],default:`singleFile`}},required:[`output`]}}}}},dependencies:{$ref:`#/$defs/dependencies`},module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module for this build`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},nodeModulesDir:{type:[`string`,`array`],items:{type:`string`},description:`The dirs where node_modules are located`},i18n:{type:`object`,properties:{locales:{type:`array`,items:{type:`string`},description:`Locales that is required inside your project`},fallback:{type:`string`},autoRegister:{type:`boolean`}},description:`Define options for i18n`}},required:[`src`]},minItems:1},static:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:`Part name for the static export`,pattern:`^[a-zA-Z0-9_]+$`},input:{type:`string`,description:`Input path to watch to export as static files`},output:{type:[`string`,`array`],items:{type:`string`},description:`Define where to export static files`}},required:[`name`,`input`,`output`]}},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},aliases:{type:`object`}},required:[`build`,`module`],$defs:{dependencies:{type:`object`,description:`List of dependencies for this build`,patternProperties:{"^\\S+$":{type:[`object`,`string`],additionalProperties:!1,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,properties:{uri:{type:`string`,description:`Where to find the package or the json file`},npm:{type:`string`,description:`The npm package name`},version:{type:`string`,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,description:`The version to use for this file. (default is x.x.x)`,default:`x.x.x`},isLocal:{type:`boolean`,description:`Define if you want to use a local package`},include:{type:`string`,description:`Determine if the package must be included inside the final export. (default is need)`,enum:[`none`,`need`,`full`],default:`need`},subDependenciesInclude:{type:`object`,description:`Inclusion pattern for each lib. You can use a star to select everythink. If nothink find for a lib, the need value ll be used`,patternProperties:{"^\\S+$":{type:`string`,enum:[`none`,`need`,`full`],default:`need`}}}}}}},compileOutput:{type:[`string`,`object`],pattern:`^\\S+\\.js`,additionalProperties:!1,properties:{path:{type:`string`,pattern:`^\\S+\\.js`},compressed:{type:`boolean`}}}}},ye={$schema:`foo://aventus/sharp.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{csProj:{type:`string`,pattern:`^\\S+\\.csproj`,description:`Path to your csproj file`},outputPath:{type:`string`,description:`Define the folder where to export the code`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if errors must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEndPointByDefault:{type:`boolean`,default:!0,description:`Define if websocket endpoint must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEventByDefault:{type:`boolean`,default:!0,description:`Define if websocket event must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsRouteByDefault:{type:`boolean`,default:!0,description:`Define if websocket route must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},wsEndPoint:{$ref:`#/$defs/replacerPart`},wsEvent:{$ref:`#/$defs/replacerPart`},wsRouter:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to use for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`},addFormData:{type:`boolean`,default:!0,description:"Add ` | FormData` to the route body"},cacheByDefault:{type:`boolean`,default:!1,description:`Add cache to the function generated`},clearCacheFct:{type:`boolean`,default:!1,description:`Add function to clear cache to the function generated`}}},wsEndpoint:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},prefix:{type:`string`,default:`Define a prefix for your websocket events`},host:{type:`string`,description:`The host to connect to the websocket`},port:{type:`number`,description:`The port to connect to the websocket`},useHttps:{type:`boolean`,description:`Define if you want to use http or https. Be default, Aventus will check if your connection is secure to use https or not`},parent:{type:`string`,default:`AventusSharp.WebSocket.EndPoint`,description:`Define the parent type to use for your router`}}}},required:[`csProj`,`outputPath`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}},be={$schema:`foo://aventus/php.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define the folder where to export the code`},exportAsTs:{type:`boolean`,description:`Define if the code must be compiled as typescript`},useNamespace:{type:`boolean`,description:`Define if the compiler must used namespace`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRequestByDefault:{type:`boolean`,default:!0,description:`Define if request must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpResourceByDefault:{type:`boolean`,default:!0,description:`Define if resource must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if erros must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},httpRequest:{$ref:`#/$defs/replacerPart`},httpResource:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to load for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`}}}},required:[`output`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}};var xe=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({schemaRequestService:async e=>JSON.stringify(ve)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.Config],uri:ve.$schema??``,schema:ve},{fileMatch:[`**`+w.CsharpConfig],uri:ye.$schema??``,schema:ye},{fileMatch:[`**`+w.PhpConfig],uri:be.$schema??``,schema:be}]})}async format(e,t,n){let r=e.documentUser;return await this.languageService.format(r,t,n)}async doComplete(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doComplete(e.documentUser,t,r),a=r.getNodeFromOffset(n.offsetAt(t));return this.isKeyOfObject(a,`dependencies`)&&(i||={isIncomplete:!1,items:[]},i?.items.push({label:`Aventus@Main`},{label:`Aventus@UI`},{label:`Aventus@I18n`},{label:`Aventus@Sharp`},{label:`Aventus@Php`})),i||{isIncomplete:!1,items:[]}}async doResolve(e){return await this.languageService.doResolve(e)}async doHover(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n);return await this.languageService.doHover(n,t,r)}async validate(e){let t=e.documentUser,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=this.removeComments(t.getText());try{return JSON.parse(e),r}catch{r.push(Ri(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}isKeyOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.keyNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}isValueOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.valueNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}async getConfig(e){let t=`documentUser`in e?e.documentUser:e,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n,void 0,ve);if(r.length==0){let e=this.removeComments(t.getText());try{let n=JSON.parse(e);return n=this.prepareConfigFile(t.uri,n),n}catch{r.push(Ri(t,`Can't parse the json`,1001))}}return null}prepareConfigFile(e,t){if(t={...this.defaultConfigValue(),...t},t.componentPrefix==``){let e=t.module.match(/([A-Z][a-z]*)|([0-9][a-z]*)/g);e?t.componentPrefix=e.join(`-`).toLowerCase():t.componentPrefix=`av`}let n=[];for(let r of t.build)n.push(this.prepareBuild(e,r,t));if(t.build=n,t.static){let n=[];for(let r of t.static)n.push(this.prepareStatic(e,r));t.static=n}return t}replaceEnvVar(e,t){if(!e||e.startsWith(`@`)||e.startsWith(`Aventus@`))return e;let n=/%(.*?)%/gm,r;for(;r=n.exec(e);){let t=g.env[r[1]]??`undefined`;e=e.replace(r[0],t)}return/^https?:\/\/.*/.exec(e)||(!e.startsWith(`/`)&&!/^[a-zA-Z]:/gm.test(e)?(e=`/`+e,e=(0,f.normalize)(I(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=Ki(e);t={...this.defaultConfigBuildValue(n),...t},t.name?t.fullname=t.module+`@`+t.name:t.fullname=t.module;let i=e=>this.replaceEnvVar(e,r),a=t.compile;for(let e of a){if(!e.input)e.inputPathRegex=RegExp(`.*`);else{Array.isArray(e.input)||(e.input=[e.input]);let t=[];for(let n of e.input){let e=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(e=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(I(r)+e+n).replace(/\\/g,`/`);a=Yi(a,!0).replace(`*`,`.*`),t.push(`(^`+a+`$)`)}let n=t.join(`|`);n==``&&(n=`(?!)`),e.inputPathRegex=new RegExp(n)}if(!e.output)e.output=[];else{Array.isArray(e.output)||(e.output=[e.output]);for(let t=0;t<e.output.length;t++){let n=e.output[t];typeof n==`string`&&(e.output[t]={"@default":{path:n}},n=e.output[t]);let r=!1;for(let a in n){a==`@default`&&(r=!0);let o=n[a];typeof o==`string`&&(e.output[t][a]={path:o}),e.output[t][a].path=n[a].path.trim(),n[a].path.length>0&&(e.output[t][a].path=i(n[a].path))}r||(e.output[t][`@default`]={path:`./dist/script.js`})}}if(!e.outputNpm)e.outputNpm={path:[],packageJson:!1,npmName:``,live:!1};else{typeof e.outputNpm==`string`?e.outputNpm={path:[e.outputNpm],packageJson:!0,npmName:``,manifest:{},live:!1}:Array.isArray(e.outputNpm)&&(e.outputNpm={path:e.outputNpm,packageJson:!0,npmName:``,manifest:{},live:!1}),Array.isArray(e.outputNpm.path)||(e.outputNpm.path=[e.outputNpm.path]),e.outputNpm.packageJson===void 0&&(e.outputNpm.packageJson=!0),e.outputNpm.manifest===void 0&&(e.outputNpm.manifest={}),e.outputNpm.npmName===void 0&&(e.outputNpm.npmName=``),e.outputNpm.live===void 0&&(e.outputNpm.live=!1);for(let t=0;t<e.outputNpm.path.length;t++){let n=i(e.outputNpm.path[t]);n.endsWith(`*`)&&(n=n.slice(0,-1)),n.endsWith(`/`)&&(n=n.slice(0,-1)),n=n.replace(/\\/g,`/`),e.outputNpm.path[t]=n}}if(!e.package)e.package=[];else{Array.isArray(e.package)||(e.package=[e.package]);for(let t=0;t<e.package.length;t++)e.package[t]=e.package[t].trim(),e.package[t].length>0&&(e.package[t]=i(e.package[t]))}if(t.i18n)if(e.i18n){Array.isArray(e.i18n)||(e.i18n=[{output:[e.i18n],mount:``,mode:`singleFile`}]);for(let t=0;t<e.i18n.length;t++){if(!Array.isArray(e.i18n[t].output)){let n=e.i18n[t].output;e.i18n[t].output=[n]}for(let n=0;n<e.i18n[t].output.length;n++)e.i18n[t].output[n].endsWith(`/`)&&(e.i18n[t].output[n]=e.i18n[t].output[n].slice(0,-1)),e.i18n[t].output[n]=e.i18n[t].output[n].trim(),e.i18n[t].output[n].length>0&&(e.i18n[t].output[n]=i(e.i18n[t].output[n]));if(!e.i18n[t].mount&&e.i18n[t].output.length>0){let n=(0,f.normalize)(I($.getWorkspaceUri())),r=e.i18n[t].output[0].replace(n,``).replace(/\\/g,`/`);r.startsWith(`/dist`)&&(r=r.replace(`/dist`,``)),e.i18n[t].mount=r}e.i18n[t].mount.endsWith(`/`)&&(e.i18n[t].mount=e.i18n[t].mount.slice(0,-1))}}else{e.i18n=[];for(let t of e.output){let n=t[`@default`].path.split(f.sep);n.pop();let r=(0,f.join)(n.join(f.sep),`locales`),i=(0,f.normalize)(I($.getWorkspaceUri())),a=r.replace(i,``).replace(/\\/g,`/`);a.startsWith(`/dist`)&&(a=a.replace(`/dist`,``)),e.i18n.push({output:[r],mount:a,mode:`singleFile`})}}}let o=[];for(let e of t.src){let n=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(n=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(I(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=Yi(a,!0).replace(`*`,`.*`),o.push(`(^`+a+`$)`)}if(t.stories){t.stories={...this.defaultConfigBuildStories(r,n),...t.stories};let e=i(t.stories.output);e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.stories.output=e}let s=o.join(`|`);s==``&&(s=`(?!)`),t.srcPathRegex=new RegExp(s),t.nodeModulesDir=t.nodeModulesDir.trim(),t.nodeModulesDir==``?t.nodeModulesDir=(0,f.normalize)(I(r)+`/node_modules`):t.nodeModulesDir=i(t.nodeModulesDir);let c={};t.rawDependencies=JSON.parse(JSON.stringify(t.dependencies));for(let e in t.dependencies){let n=t.dependencies[e];typeof n==`string`&&(n={version:n}),c[e]={...this.defaultConfigBuildDependencyValue(n),...n};let r=c[e];r.subDependenciesInclude||={},r.subDependenciesInclude[`*`]||(r.subDependenciesInclude[`*`]=n.include??`need`),r.uri&&=i(r.uri)}if(t.dependencies=c,t.outsideModule){let e=[];for(let n of t.outsideModule){let t=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(t=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(I(r)+t+n).replace(/\\/g,`/`);a=Yi(a,!0).replace(`*`,`.*`),e.push(`(^`+a+`$)`)}let n=e.join(`|`);n==``&&(n=`(?!)`),t.outsideModulePathRegex=new RegExp(n)}if(t.namespaceStrategy==`rules`)for(let e in t.namespaceRules){let n=[],i=t.namespaceRules[e];for(let e of i){let t=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(t=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(I(r)+t+e).replace(/\\/g,`/`);a=Yi(a,!0).replace(`*`,`.*`),n.push(`(^`+a+`$)`)}let a=n.join(`|`);a==``&&(a=`(?!)`),t.namespaceRulesRegex[e]=new RegExp(a)}else if(t.namespaceStrategy==`followFolders`||t.namespaceStrategy==`followFoldersCamelCase`){let e=``;t.namespaceRoot.startsWith(`/`)||(e=`/`),t.namespaceRoot=(0,f.normalize)(I(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=Ki(e),r=``;t.input.startsWith(`/`)||(r=`/`),t.input.endsWith(`*`)&&(t.input=t.input.slice(0,-1)),t.input.endsWith(`/`)&&(t.input=t.input.slice(0,-1)),t.inputPathFolder=(0,f.normalize)(I(n)+r+t.input),t.inputPathFolder=t.inputPathFolder.replace(/\\/g,`/`),r=``,Array.isArray(t.output)||(t.output=[t.output]),t.outputPathFolder=[];for(let e of t.output)e=this.replaceEnvVar(e,n),e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:P.getInstance().settings.defaultHideWarnings,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`}}defaultConfigBuildValue(e){return{fullname:``,name:``,tags:e.tags,version:e.version,organization:e.organization,description:e.description,readme:e.readme,repository:e.repository,documentation:e.documentation,disabled:!1,hideWarnings:e.hideWarnings,src:[],srcPath:[],stories:void 0,compile:[],srcPathRegex:RegExp(`(?!)`),outsideModule:[],outsideModulePathRegex:RegExp(`(?!)`),module:e.module,componentPrefix:e.componentPrefix,namespaceStrategy:e.namespaceStrategy,namespaceRules:{...e.namespaceRules},namespaceRulesRegex:{...e.namespaceRulesRegex},namespaceRoot:e.namespaceRoot,dependencies:{...e.dependencies},rawDependencies:{},avoidParsingInsideTags:[...e.avoidParsingInsideTags],nodeModulesDir:``}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}};const Se=new Uint8Array(16);function Ce(){return crypto.getRandomValues(Se)}const we=[];for(let e=0;e<256;++e)we.push((e+256).toString(16).slice(1));function Te(e,t=0){return(we[e[t+0]]+we[e[t+1]]+we[e[t+2]]+we[e[t+3]]+`-`+we[e[t+4]]+we[e[t+5]]+`-`+we[e[t+6]]+we[e[t+7]]+`-`+we[e[t+8]]+we[e[t+9]]+`-`+we[e[t+10]]+we[e[t+11]]+we[e[t+12]]+we[e[t+13]]+we[e[t+14]]+we[e[t+15]]).toLowerCase()}function T(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Ee(e,t,n)}function Ee(e,t,n){e||={};let r=e.random??e.rng?.()??Ce();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Te(r)}var E=class{_documentUser;_documentInternal;get documentUser(){return this._documentUser}get documentInternal(){return this._documentInternal}linkInternalAndUser=!0;setDocumentInternal(e){this._documentInternal=e,this._versionInternal=e.version}constructor(e){this._documentUser=e,this._documentInternal=e,this._versionUser=e.version,this._versionInternal=e.version}get uri(){return this.documentUser.uri}get path(){return I(this.uri)}get name(){return this.path.split(`/`).pop()??``}_versionUser=0;get versionUser(){return this._versionUser}_versionInternal=0;get versionInternal(){return this._versionInternal}get contentUser(){return this.documentUser.getText()}get contentInternal(){return this.documentInternal.getText()}get folderUri(){return Ki(this.uri)}get folderPath(){return Ki(this.path)}_shortname=``;get shortname(){if(!this._shortname){let e=this.uri.split(`/`);this._shortname=e[e.length-1]}return this._shortname}onGetBuildCb={};getBuild(){let e=[],t=!1;for(let n in this.onGetBuildCb){let r=this.onGetBuildCb[n]();if(r===null)t=!0;else for(let t of r)e.indexOf(t)==-1&&e.push(t)}return e.length==0&&t?null:e}onGetBuild(e){let t=T();for(;this.onGetBuildCb[t]!=null;)t=T();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};async validate(e=!0){let t={};for(let e in this.onValidateCb){let n=await this.onValidateCb[e](this);for(let e of n){let n=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;t[n]||(t[n]=e)}}if(e)if(P.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});else for(let n of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)},n)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});return Object.values(t)}onValidate(e){let t=T();for(;this.onValidateCb[t]!=null;)t=T();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};triggerContentChange(e){return new Promise(t=>{if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{this.waitingDocContentChange[e.uri]?(this.resolveContentChange[e.uri]||(this.resolveContentChange[e.uri]={}),this.resolveContentChange[e.uri][e.version]||(this.resolveContentChange[e.uri][e.version]=[]),this.resolveContentChange[e.uri][e.version].push(t),this.waitingDocContentChange[e.uri]=e):(this.waitingDocContentChange[e.uri]=!0,this.resolveContentChange[e.uri]={[e.version]:[t]},this.triggerContentChangeNoBuffer(e))},0)})}async triggerContentChangeNoBuffer(e){let t=e.version;this._documentUser=e,this._versionUser=e.version,this.linkInternalAndUser&&(this._documentInternal=e,this._versionInternal=e.version);let n=[];for(let e in this.onContentChangeCb)n.push(this.onContentChangeCb[e](this));if(await Promise.all(n),this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(async()=>{this.validate()},500),this.resolveContentChange[e.uri]){let n=Object.keys(this.resolveContentChange[e.uri]);for(let r of n){if(Number(r)>t)break;if(this.resolveContentChange[e.uri][r]){for(let t of this.resolveContentChange[e.uri][r])t();delete this.resolveContentChange[e.uri][r]}}Object.keys(this.resolveContentChange[e.uri]).length==0&&delete this.resolveContentChange[e.uri]}let r=this.waitingDocContentChange[e.uri];r&&typeof r!=`boolean`?(this.waitingDocContentChange[e.uri]=!0,this.triggerContentChangeNoBuffer(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=T();for(;this.onContentChangeCb[t]!=null;)t=T();return this.onContentChangeCb[t]=e,t}removeOnContentChange(e){delete this.onContentChangeCb[e]}onCanContentChangeCb={};triggerCanContentChange(e){for(let t in this.onCanContentChangeCb)if(!this.onCanContentChangeCb[t](e))return!1;return!0}onCanContentChange(e){let t=T();for(;this.onCanContentChangeCb[t]!=null;)t=T();return this.onCanContentChangeCb[t]=e,t}removeOnCanContentChange(e){delete this.onCanContentChangeCb[e]}async applyTextEdits(e){let t=this.contentUser;e.sort((e,t)=>this.documentUser.offsetAt(t.range.end)-this.documentUser.offsetAt(e.range.end));for(let n of e){let e=this.documentUser.offsetAt(n.range.start),r=this.documentUser.offsetAt(n.range.end);t=t.slice(0,e)+n.newText+t.slice(r,t.length)}let n=d.TextDocument.create(this.uri,C.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb)await this.onSaveCb[e](this)}onSave(e){let t=T();for(;this.onSaveCb[t]!=null;)t=T();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));await Promise.all(e),this.removeAllCallbacks()}removeAllCallbacks(){this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=T();for(;this.onDeleteCb[t]!=null;)t=T();return this.onDeleteCb[t]=e,t}removeOnDelete(e){delete this.onDeleteCb[e]}onCompletionCb={};async getCompletion(e){let t={isIncomplete:!1,items:[]},n=[];for(let t in this.onCompletionCb)n.push(this.onCompletionCb[t](this,e));let r=await Promise.all(n),i={};for(let e of r)for(let t of e.items){let e=JSON.stringify(t);i[e]||(i[e]=t)}return t.items=Object.values(i),t}onCompletion(e){let t=T();for(;this.onCompletionCb[t]!=null;)t=T();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e,n=[];for(let t in this.onCompletionResolveCb)n.push(this.onCompletionResolveCb[t](this,e));return t}onCompletionResolve(e){let t=T();for(;this.onCompletionResolveCb[t]!=null;)t=T();return this.onCompletionResolveCb[t]=e,t}removeOnCompletionResolve(e){delete this.onCompletionResolveCb[e]}onHoverCb={};async getHover(e){let t=[];for(let n in this.onHoverCb)t.push(this.onHoverCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onHover(e){let t=T();for(;this.onHoverCb[t]!=null;)t=T();return this.onHoverCb[t]=e,t}removeOnHover(e){delete this.onHoverCb[e]}onDefinitionCb={};async getDefinition(e){let t=[];for(let n in this.onDefinitionCb)t.push(this.onDefinitionCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onDefinition(e){let t=T();for(;this.onDefinitionCb[t]!=null;)t=T();return this.onDefinitionCb[t]=e,t}removeOnDefinition(e){delete this.onDefinitionCb[e]}onFormattingCb={};async getFormatting(e){e||={insertSpaces:!0,tabSize:4};let t={},n=[],r={start:this.documentUser.positionAt(0),end:this.documentUser.positionAt(this.documentUser.getText().length)};for(let t in this.onFormattingCb)n.push(this.onFormattingCb[t](this,r,e));let i=await Promise.all(n);for(let e of i)for(let n of e){let e=JSON.stringify(n);t[e]||(t[e]=n)}return Object.values(t)}onFormatting(e){let t=T();for(;this.onFormattingCb[t]!=null;)t=T();return this.onFormattingCb[t]=e,t}removeOnFormatting(e){delete this.onFormattingCb[e]}onCodeActionCb={};async getCodeAction(e){let t=[],n=[];for(let t in this.onCodeActionCb)n.push(this.onCodeActionCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onCodeAction(e){let t=T();for(;this.onCodeActionCb[t]!=null;)t=T();return this.onCodeActionCb[t]=e,t}removeOnCodeAction(e){delete this.onCodeActionCb[e]}onReferencesCb={};async getReferences(e){let t=[],n=[];for(let t in this.onReferencesCb)n.push(this.onReferencesCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onReferences(e){let t=T();for(;this.onReferencesCb[t]!=null;)t=T();return this.onReferencesCb[t]=e,t}removeOnReferences(e){delete this.onReferencesCb[e]}onCodeLensCb={};async getCodeLens(){let e=[],t=[];for(let e in this.onCodeLensCb)t.push(this.onCodeLensCb[e](this));let n=await Promise.all(t);for(let t of n)e=[...e,...t];return e}onCodeLens(e){let t=T();for(;this.onCodeLensCb[t]!=null;)t=T();return this.onCodeLensCb[t]=e,t}removeOnCodeLens(e){delete this.onCodeLensCb[e]}onRenameCb={};async getRename(e,t){let n=[];for(let r in this.onRenameCb)n.push(this.onRenameCb[r](this,e,t));let r=await Promise.all(n);for(let e of r)if(e)return e;return null}onRename(e){let t=T();for(;this.onRenameCb[t]!=null;)t=T();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},De=class{_file;_build;get file(){return this._file}get build(){if(this._build)return this._build;throw`No build found`}constructor(e,t){this._file=e,this._build=t,this.addEvents()}uuidEvents={onCanContentChange:``,onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onGetBuild:``,onRename:``};addEvents(){this.uuidEvents.onCanContentChange=this.file.onCanContentChange(this.onCanContentChange.bind(this)),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.onGetBuild=this.file.onGetBuild(this.onGetBuild.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnCanContentChange(this.uuidEvents.onCanContentChange),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.removeOnGetBuild(this.uuidEvents.onGetBuild),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof E&&await this.file.validate()}async triggerSave(){this.file instanceof E&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof E&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof E&&await this.file.triggerContentChange(e)}onCanContentChange(e){return this._file.versionUser!=e.version}oldResult=[];async _onValidate(){let e=this._build?.diagnostics.get(this)??[];return e=[...e,...await this.onValidate()],this._build&&this.build.hideWarnings&&(e=e.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},Oe=o(((e,t)=>{var n=require("stream");e=t.exports=r,r.through=r;function r(e,t,r){e||=function(e){this.queue(e)},t||=function(){this.queue(null)};var i=!1,a=!1,o=[],s=!1,c=new n;c.readable=c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&r.autoDestroy===!1),c.write=function(t){return e.call(this,t),!c.paused};function l(){for(;o.length&&!c.paused;){var e=o.shift();if(e===null)return c.emit(`end`);c.emit(`data`,e)}}c.queue=c.push=function(e){return s?c:(e===null&&(s=!0),o.push(e),l(),c)},c.on(`end`,function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick(function(){c.destroy()})});function u(){c.writable=!1,t.call(c),!c.readable&&c.autoDestroy&&c.destroy()}return c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),u(),c},c.destroy=function(){if(!a)return a=!0,i=!0,o.length=0,c.writable=c.readable=!1,c.emit(`close`),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit(`resume`)),l(),c.paused||c.emit(`drain`),c},c}})),ke=o(((e,t)=>{var n=require("stream");t.exports=function e(t){if(Array.isArray(t)){var r=0,i=t.length;return e(function(e){return r<i?this.emit(`data`,t[r++]):this.emit(`end`),!0})}var a=new n,o=0;a.ended=!1,a.started=!1,a.readable=!0,a.writable=!1,a.paused=!1,a.ended=!1,a.pause=function(){a.started=!0,a.paused=!0};function s(){if(a.started=!0,!a.ended)for(;!a.ended&&!a.paused&&t.call(a,o++,function(){!a.ended&&!a.paused&&process.nextTick(s)}););}return a.resume=function(){a.started=!0,a.paused=!1,s()},a.on(`end`,function(){a.ended=!0,a.readable=!1,process.nextTick(a.destroy)}),a.destroy=function(){a.ended=!0,a.emit(`close`)},process.nextTick(function(){a.started||a.resume()}),a}})),Ae=o(((e,t)=>{var n=require("stream"),r=[`write`,`end`,`destroy`],i=[`resume`,`pause`],a=[`data`,`close`],o=Array.prototype.slice;t.exports=c;function s(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n)}function c(e,t){var c=new n,l=!1;return s(r,u),s(i,d),s(a,f),t.on(`end`,p),e.on(`drain`,function(){c.emit(`drain`)}),e.on(`error`,m),t.on(`error`,m),c.writable=e.writable,c.readable=t.readable,c;function u(t){c[t]=n;function n(){return e[t].apply(e,arguments)}}function d(e){c[e]=n;function n(){c.emit(e);var n=t[e];if(n)return n.apply(t,arguments);t.emit(e)}}function f(e){t.on(e,n);function n(){var t=o.call(arguments);t.unshift(e),c.emit.apply(c,t)}}function p(){if(!l){l=!0;var e=o.call(arguments);e.unshift(`end`),c.emit.apply(c,e)}}function m(e){c.emit(`error`,e)}}})),je=o(((e,t)=>{var n=require("stream").Stream;t.exports=function(e,t){var r=new n,i=0,a=0,o=!1,s=!1,c=!1,l=0,u=!1;t||={};var d=t.failures?`failure`:`error`,f={};r.writable=!0,r.readable=!0;function p(e,t){var n=l+1;if(t===n?(e!==void 0&&r.emit.apply(r,[`data`,e]),l++,n++):f[t]=e,f.hasOwnProperty(n)){var c=f[n];return delete f[n],p(c,n)}a++,i===a&&(s&&(s=!1,r.emit(`drain`)),o&&g())}function m(e,n,i){c||(u=!0,(!e||t.failures)&&p(n,i),e&&r.emit.apply(r,[d,e]),u=!1)}function h(t,n,r){return e.call(null,t,function(e,t){r(e,t,n)})}r.write=function(e){if(o)throw Error(`map stream is not writable`);u=!1,i++;try{return s=h(e,i,m)===!1,!s}catch(e){if(u)throw e;return m(e),!s}};function g(e){if(o=!0,r.writable=!1,e!==void 0)return p(e,i);i==a&&(r.readable=!1,r.emit(`end`),r.destroy())}return r.end=function(e){o||g(e)},r.destroy=function(){o=c=!0,r.writable=r.readable=s=!1,process.nextTick(function(){r.emit(`close`)})},r.pause=function(){s=!0},r.resume=function(){s=!1},r}})),Me=o(((e,t)=>{t.exports=Oe()})),Ne=o(((e,t)=>{var n=Oe(),r=require("string_decoder").StringDecoder;t.exports=i;function i(e,t,i){var a=new r,o=``,s=i&&i.maxLength,c=!(i&&i.trailing===!1);typeof e==`function`&&(t=e,e=null),e||=/\r?\n/;function l(e,n){if(t){try{n=t(n)}catch(t){return e.emit(`error`,t)}n!==void 0&&e.queue(n)}else e.queue(n)}function u(t,n){var r=((o??``)+n).split(e);if(o=r.pop(),s&&o.length>s)return t.emit(`error`,Error(`maximum buffer reached`));for(var i=0;i<r.length;i++){var a=r[i];l(t,a)}}return n(function(e){u(this,a.write(e))},function(){a.end&&u(this,a.end()),c&&o!=null&&l(this,o),this.queue(null)})}})),Pe=o(((e,t)=>{var n=Ae(),r=Oe();t.exports=function(){var e=arguments.length==1&&Array.isArray(arguments[0])?arguments[0]:[].slice.call(arguments);if(e.length==0)return r();if(e.length==1)return e[0];var t=e[0],i=e[e.length-1],a=n(t,i);function o(e){e.length<2||(e[0].pipe(e[1]),o(e.slice(1)))}o(e);function s(){var e=[].slice.call(arguments);e.unshift(`error`),a.emit.apply(a,e)}for(var c=1;c<e.length-1;c++)e[c].on(`error`,s);return a}})),Fe=o((e=>{var t=require("stream").Stream,n=e,r=Oe(),i=ke(),a=Ae(),o=je(),s=Me(),c=Ne(),l=Pe(),u=global.setImmediate||process.nextTick;n.Stream=t,n.through=r,n.from=i,n.duplex=a,n.map=o,n.pause=s,n.split=c,n.pipeline=n.connect=n.pipe=l,n.concat=n.merge=function(){var e=[].slice.call(arguments);e.length===1&&e[0]instanceof Array&&(e=e[0]);var n=new t;n.setMaxListeners(0);var r=0;return n.writable=n.readable=!0,e.length?e.forEach(function(t){t.pipe(n,{end:!1});var i=!1;t.on(`end`,function(){i||(i=!0,r++,r==e.length&&n.emit(`end`))})}):process.nextTick(function(){n.emit(`end`)}),n.write=function(e){this.emit(`data`,e)},n.destroy=function(){e.forEach(function(e){e.destroy&&e.destroy()})},n},n.collect=n.writeArray=function(e){if(typeof e!=`function`)throw Error(`function writeArray (done): done must be function`);var n=new t,r=[],i=!1;return n.write=function(e){r.push(e)},n.end=function(){i=!0,e(null,r)},n.writable=!0,n.readable=!1,n.destroy=function(){n.writable=n.readable=!1,!i&&e(Error(`destroyed before end`),r)},n},n.readArray=function(e){var n=new t,r=0,i=!1,a=!1;if(n.readable=!0,n.writable=!1,!Array.isArray(e))throw Error(`event-stream.read expects an array`);return n.resume=function(){if(!a){i=!1;for(var t=e.length;r<t&&!i&&!a;)n.emit(`data`,e[r++]);r==t&&!a&&(a=!0,n.readable=!1,n.emit(`end`))}},process.nextTick(n.resume),n.pause=function(){i=!0},n.destroy=function(){a=!0,n.emit(`close`)},n},n.readable=function(e,n){var r=new t,i=0,a=!1,o=!1,s=!1;if(r.readable=!0,r.writable=!1,typeof e!=`function`)throw Error(`event-stream.readable expects async function`);r.on(`end`,function(){o=!0});function c(t,l){t?(r.emit(`error`,t),n||r.emit(`end`)):arguments.length>1&&r.emit(`data`,l),u(function(){if(!(o||a||s))try{s=!0,e.call(r,i++,function(){s=!1,c.apply(null,arguments)})}catch(e){r.emit(`error`,e)}})}return r.resume=function(){a=!1,c()},process.nextTick(c),r.pause=function(){a=!0},r.destroy=function(){r.emit(`end`),r.emit(`close`),o=!0},r},n.mapSync=function(e){return n.through(function(t){var n;try{n=e(t)}catch(e){return this.emit(`error`,e)}n!==void 0&&this.emit(`data`,n)})},n.filterSync=function(e){return n.through(function(t){var n=this;e(t)&&n.queue(t)})},n.flatmapSync=function(e){return n.through(function(t){var n=this;t.forEach(function(t){n.queue(e(t))})})},n.log=function(e){return n.through(function(t){[].slice.call(arguments),e?console.error(e,t):console.error(t),this.emit(`data`,t)})},n.child=function(e){return n.duplex(e.stdin,e.stdout)},n.parse=function(e){var t=!!(e&&e.error);return n.through(function(e){var n;try{e&&(n=JSON.parse(e.toString()))}catch(n){return t?this.emit(`error`,n):console.error(n,`attempting to parse:`,e)}n!==void 0&&this.emit(`data`,n)})},n.stringify=function(){var e=require("buffer").Buffer;return n.mapSync(function(t){return JSON.stringify(e.isBuffer(t)?t.toString():t)+`
2
2
  `})},n.replace=function(e,t){return n.pipeline(n.split(e),n.join(t))},n.join=function(e){if(typeof e==`function`)return n.wait(e);var t=!0;return n.through(function(n){return t||this.emit(`data`,e),t=!1,this.emit(`data`,n),!0})},n.wait=function(e){var t=[];return n.through(function(e){t.push(e)},function(){var n=Buffer.isBuffer(t[0])?Buffer.concat(t):t.join(``);this.emit(`data`,n),this.emit(`end`),e&&e(null,n)})},n.pipeable=function(){throw Error(`[EVENT-STREAM] es.pipeable is deprecated`)}}))();const Ie=`<script type="text/javascript">
3
3
  if ('WebSocket' in window) {
4
4
  (function () {
@@ -123,7 +123,7 @@ if ('WebSocket' in window) {
123
123
  })();
124
124
  }
125
125
  <\/script>`;var Le=class{static send(e,t){$.sendNotification(`aventus/server/start`,`http://`+e+`:`+t)}},Re=class{static send(){$.sendNotification(`aventus/server/stop`,{})}},D=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}static get isRunning(){return!!(this.instance?.server&&this.instance.server.listening)}config;server;wss;reloadTimeout;clients=[];port=8080;constructor(){this.config=P.getInstance().settings.liveserver}toggle(){this.server&&this.server.listening?this.stop():this.start()}async start(){if(!this.server||!this.server.listening){this.config=P.getInstance().settings.liveserver,this.port=this.config.port;var e=(0,_.default)();let t=this.createStaticServer();if(e.use(t).use(this.entryPoint(t,this.config.indexFile)).use((0,ee.default)(this.config.rootFolder,{icons:!0})),this.server=(0,b.createServer)(e),this.server.addListener(`listening`,()=>{let e=this.config.host;if(e==`0.0.0.0`&&(e=`127.0.0.1`),Le.send(e,this.port),this.config.launch_browser){let t={};this.config.browser&&(t={app:{name:this.config.browser}}),(0,ne.default)(`http://${e}:${this.port}`,t)}else{let e=`http://${this.config.host}:${this.port}`;$.showInformationMessage(`Liver server started on `+e)}}),this.clients=[],this.wss=new te.WebSocketServer({server:this.server}),this.wss.on(`connection`,e=>{e.onclose=()=>{this.clients=this.clients.filter(function(t){return t!==e})},this.clients.push(e)}),this.config.autoIncrementPort)for(;await this.portInUse(this.config.host,this.port);)this.port++;else if(await this.portInUse(this.config.host,this.port)){$.showErrorMessage(`The port `+this.port+` is already in use`);return}this.server.listen(this.port,this.config.host)}}stop(){for(let e of this.clients)e.close();this.clients=[],this.server&&=(this.server.close(),void 0),this.wss&&=(this.wss.close(),void 0),Re.send()}portInUse(e,t){return new Promise((n,r)=>{var i=(0,x.createServer)(function(e){e.write(`Echo server
126
- `),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==te.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=y.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=Ie.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=y.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,v.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=Ie;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,Fe.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const ze={},Be=()=>$.extensionPath;let Ve;const He=()=>{if(Ve!==void 0)return Ve;let e=Be();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return Ve=e,Ve;e=(0,f.resolve)(e,`..`)}return Be()},Ue=()=>(0,f.join)(He(),`node_modules/typescript/lib`),We=()=>(0,f.join)(Be(),`lib/Aventus@Main.package.avt`),Ge=()=>(0,f.join)(Be(),`lib/Aventus@UI.package.avt`),Ke=()=>(0,f.join)(Be(),`lib/Aventus@I18n.package.avt`),qe=()=>(0,f.join)(Be(),`lib/Aventus@Sharp.package.avt`),Je=()=>(0,f.join)(Be(),`lib/Aventus@Php.package.avt`),Ye=()=>(0,f.join)(He(),`node_modules`),Xe=[];function Ze(){if(Xe.length>0)return;let e=(0,u.readdirSync)(Ue());for(let t of e)t.endsWith(`.d.ts`)&&Xe.push(t)}function Qe(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(F(e));else for(let e of i)n.push(F(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function $e(e){let t=ze[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(Ye(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=Xe.includes(e)?(0,f.join)(Ue(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(ze[e]=t)),t}var et=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(Ue(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},O=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function tt(e,t){return(e&t)!=0}function nt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function rt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:nt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:nt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const it=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var at=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(it.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=rt(e);t&&o.arguments.push(t)}r.push(o)}else A.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},ot=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},st=class e{static is(t){return t.name==`Internal`?new e:null}},ct=class e{static is(t){return t.name==`InternalProtected`?new e:null}},lt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},ut=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
126
+ `),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==te.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=y.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=Ie.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=y.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,v.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=Ie;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,Fe.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const ze={},Be=()=>$.extensionPath;let Ve;const He=()=>{if(Ve!==void 0)return Ve;let e=Be();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return Ve=e,Ve;e=(0,f.resolve)(e,`..`)}return Be()},Ue=()=>(0,f.join)(He(),`node_modules/typescript/lib`),We=()=>(0,f.join)(Be(),`lib/Aventus@Main.package.avt`),Ge=()=>(0,f.join)(Be(),`lib/Aventus@UI.package.avt`),Ke=()=>(0,f.join)(Be(),`lib/Aventus@I18n.package.avt`),qe=()=>(0,f.join)(Be(),`lib/Aventus@Sharp.package.avt`),Je=()=>(0,f.join)(Be(),`lib/Aventus@Php.package.avt`),Ye=()=>(0,f.join)(He(),`node_modules`),Xe=[];function Ze(){if(Xe.length>0)return;let e=(0,u.readdirSync)(Ue());for(let t of e)t.endsWith(`.d.ts`)&&Xe.push(t)}function Qe(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(F(e));else for(let e of i)n.push(F(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function $e(e){let t=ze[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(Ye(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=Xe.includes(e)?(0,f.join)(Ue(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(ze[e]=t)),t}var et=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(Ue(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},O=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function tt(e,t){return(e&t)!=0}function nt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function rt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:nt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:nt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const it=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.NoType.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var at=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(it.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=rt(e);t&&o.arguments.push(t)}r.push(o)}else A.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},ot=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},st=class e{static is(t){return t.name==`Internal`?new e:null}},ct=class e{static is(t){return t.name==`InternalProtected`?new e:null}},lt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},ut=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
127
127
  `)),typeof t.comment==`string`&&this.definitions.push(t.comment),t.tags){for(let e of t.tags)if(e.kind==p.SyntaxKind.JSDocParameterTag){let t=e;typeof t.comment==`string`&&(this.documentationParameters[t.name.getText()]=t.comment)}else if(e.kind==p.SyntaxKind.JSDocReturnTag){let t=e;typeof t.comment==`string`&&(this.documentationReturn=t.comment)}else if(e.kind==p.SyntaxKind.JSDocTemplateTag){let t=e;if(typeof t.comment==`string`)for(let e of t.typeParameters)this.documentationTemplates[e.name.getText()]=t.comment}else if(e.kind==p.SyntaxKind.JSDocTag){let t=e.getText().trim();if(t.startsWith(`@slot`)){let e=/@slot\s*([a-zA-z\-]*)\s*?(-|$)(.*)/gm.exec(t);if(e){let t=e[1];t||=`default`;let n=e[3];n&&(this.documentationSlots[t]=n.trim())}}}}}}};function dt(){return`import type { StorybookConfig } from "@storybook/web-components-vite";
128
128
  import remarkGfm from 'remark-gfm';
129
129
 
@@ -220,7 +220,7 @@ const preview: Preview = {
220
220
  },
221
221
  };
222
222
 
223
- export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){this.readEnvStoryBook()}write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,f.join)(this.buildConfig.stories.output,`auto`)}writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=I(Gi(F(a)));(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=()=>{let e=!1;return t.storieDecorator&&(t.storieDecorator.noLive||t.storieDecorator.noDefaultStory)&&(e=!0),n instanceof j&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=()=>{let e=ft();e=this.replaceVariable(e,`name`,t.name);let n=`<av-story-${r.kind}-render json={JSON.stringify(Meta.aventus)}></av-story-${r.kind}-render>`;e=this.replaceVariable(e,`tag`,n),e=s()?this.replaceVariable(e,`live`,`
223
+ export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){this.readEnvStoryBook()}write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,f.join)(this.buildConfig.stories.output,`auto`)}writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=I(Ki(F(a)));(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=()=>{let e=!1;return t.storieDecorator&&(t.storieDecorator.noLive||t.storieDecorator.noDefaultStory)&&(e=!0),n instanceof j&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=()=>{let e=ft();e=this.replaceVariable(e,`name`,t.name);let n=`<av-story-${r.kind}-render json={JSON.stringify(Meta.aventus)}></av-story-${r.kind}-render>`;e=this.replaceVariable(e,`tag`,n),e=s()?this.replaceVariable(e,`live`,`
224
224
  <div>
225
225
  <Title>Live</Title>
226
226
  <Canvas />
@@ -228,12 +228,12 @@ export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.r
228
228
  </div>`):this.replaceVariable(e,`live`,``),e=this.replaceVariable(e,`blocks`,`import { Canvas, Controls, Title } from '@storybook/addon-docs/blocks'`);let i=r.kind[0].toUpperCase()+r.kind.slice(1);e=this.replaceVariable(e,`render`,`import { Story${i}Render } from '@aventusjs/storybook-render/AventusStorybook'`),this.writeFile(a+`_.mdx`,e)},l=e=>{let t=`{
229
229
  `;for(let n in e){let r=e[n];typeof r==`string`&&(r=r.replace(/\\"/g,``)),r==``&&(r=`""`),t+=` "`+n+`":`+r+`,
230
230
  `}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?mt():pt(),u=t.name,d=e.getFullname(t);if(c=this.replaceVariable(c,`name`,u),c=this.replaceVariable(c,`fullname`,d),c=this.replaceVariable(c,`description`,t.documentation?.definitions.join(`
231
- `).replace(/`/g,"\\`")??``),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof j){c=this.replaceVariable(c,`argTypes`,`argTypes: `+JSON.stringify(n.storyBookInfo.argsTypes,null,2)+`,`),c=this.replaceVariable(c,`args`,`args: `+l(n.storyBookInfo.args)+`,`);let e=n.fileParsed?.classes[n.componentClassName].storieInject??{},t=Qi(F((0,f.join)(i,...r.namespace.split(`.`))),F(a));e[t]?e[t].includes(u)||e[t].push(u):e[t]=[u];let o=[];for(let t in e)o.push(`import { ${e[t].join(`, `)} } from '${t}';`);c=this.replaceVariable(c,`importPathes`,o.join(`
232
- `))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);this.writeFile(a+`.stories.ts`,c)})()}readEnvStoryBook(){if(!this.buildConfig.stories)return;(0,u.existsSync)(this.buildConfig.stories.output)||(0,u.mkdirSync)(this.buildConfig.stories.output,{recursive:!0});let e=this.buildConfig.stories.output,t=`@`+this.buildConfig.module,n=this.buildConfig.module;this.buildConfig.name&&(t+=`/`+this.buildConfig.name,n+=` `+this.buildConfig.name);let r={name:(t+`_storybook`).toLowerCase(),displayName:n+`_storybook`,description:`Aventus storybook for `+t,version:this.buildConfig.version};if((0,u.readdirSync)(this.buildConfig.stories.output).length==0){let t=$.extensionPath+f.sep+`templates`+f.sep+`storybook`,n=(0,u.readdirSync)(t),i=``,a=t=>{let n=(0,u.readdirSync)(t);for(let o of n){let n=t+f.sep+o,s=n.replace(i,e);for(let e in r){let t=RegExp(`\\$\\{\\{`+e+`\\}\\}`,`gm`);s=s.replace(t,r[e])}if(s=(0,f.normalize)(s),(0,u.statSync)(n).isDirectory()){if(o==`.git`)continue;(0,u.mkdirSync)(s),a(n)}else if(/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(n.toLowerCase()))(0,u.copyFileSync)(n,s);else{let e=(0,u.readFileSync)(n,`utf-8`);for(let t in r){let n=RegExp(`\\$\\{\\{`+t+`\\}\\}`,`gm`);e=e.replace(n,r[t])}if(o==`package.json`){let t=JSON.parse(e);t.devDependencies||={};for(let e of this.build.externalPackageInformation.filesUri){let n=this.build.externalPackageInformation.getByUri(e);n&&n.npmUri&&n.name!=this.buildConfig.fullname&&(t.devDependencies[n.npmUri]=`^`+n.versionTxt)}t.devDependencies=Object.keys(t.devDependencies).sort().reduce((e,n)=>(e[n]=t.devDependencies[n],e),{}),e=JSON.stringify(t,null,4)}this.writeFile(s,e)}}};if(n.length==1)i=t+f.sep+n[0];else throw`TODO code multiple template`;a(i)}let i=(0,f.join)(this.buildConfig.stories.workspace?(0,f.resolve)(this.build.project.getConfigFile().folderPath,this.buildConfig.stories.workspace):e,`.storybook`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`main.ts`);if(!(0,u.existsSync)(a)){let e=dt(),t=Qi(F(this.buildConfig.stories.output),F(a));e=this.replaceVariable(e,`path`,t),this.writeFile(a,e)}let o=(0,f.join)(i,`preview.ts`);if(!(0,u.existsSync)(o)){let e=ht();this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}writeFile(e,t){ta(e,t,`storybook`)}},_t=class e{static Parse(t,n,r){if(t.importClause){if(t.importClause.namedBindings){if(t.importClause.namedBindings.kind==p.SyntaxKind.NamespaceImport){let e=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(e=r.build.project.resolveAlias(e,n),e.startsWith(`.`))r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
231
+ `).replace(/`/g,"\\`")??``),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof j){c=this.replaceVariable(c,`argTypes`,`argTypes: `+JSON.stringify(n.storyBookInfo.argsTypes,null,2)+`,`),c=this.replaceVariable(c,`args`,`args: `+l(n.storyBookInfo.args)+`,`);let e=n.fileParsed?.classes[n.componentClassName].storieInject??{},t=$i(F((0,f.join)(i,...r.namespace.split(`.`))),F(a));e[t]?e[t].includes(u)||e[t].push(u):e[t]=[u];let o=[];for(let t in e)o.push(`import { ${e[t].join(`, `)} } from '${t}';`);c=this.replaceVariable(c,`importPathes`,o.join(`
232
+ `))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);this.writeFile(a+`.stories.ts`,c)})()}readEnvStoryBook(){if(!this.buildConfig.stories)return;(0,u.existsSync)(this.buildConfig.stories.output)||(0,u.mkdirSync)(this.buildConfig.stories.output,{recursive:!0});let e=this.buildConfig.stories.output,t=`@`+this.buildConfig.module,n=this.buildConfig.module;this.buildConfig.name&&(t+=`/`+this.buildConfig.name,n+=` `+this.buildConfig.name);let r={name:(t+`_storybook`).toLowerCase(),displayName:n+`_storybook`,description:`Aventus storybook for `+t,version:this.buildConfig.version};if((0,u.readdirSync)(this.buildConfig.stories.output).length==0){let t=$.extensionPath+f.sep+`templates`+f.sep+`storybook`,n=(0,u.readdirSync)(t),i=``,a=t=>{let n=(0,u.readdirSync)(t);for(let o of n){let n=t+f.sep+o,s=n.replace(i,e);for(let e in r){let t=RegExp(`\\$\\{\\{`+e+`\\}\\}`,`gm`);s=s.replace(t,r[e])}if(s=(0,f.normalize)(s),(0,u.statSync)(n).isDirectory()){if(o==`.git`)continue;(0,u.mkdirSync)(s),a(n)}else if(/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(n.toLowerCase()))(0,u.copyFileSync)(n,s);else{let e=(0,u.readFileSync)(n,`utf-8`);for(let t in r){let n=RegExp(`\\$\\{\\{`+t+`\\}\\}`,`gm`);e=e.replace(n,r[t])}if(o==`package.json`){let t=JSON.parse(e);t.devDependencies||={};for(let e of this.build.externalPackageInformation.filesUri){let n=this.build.externalPackageInformation.getByUri(e);n&&n.npmUri&&n.name!=this.buildConfig.fullname&&(t.devDependencies[n.npmUri]=`^`+n.versionTxt)}t.devDependencies=Object.keys(t.devDependencies).sort().reduce((e,n)=>(e[n]=t.devDependencies[n],e),{}),e=JSON.stringify(t,null,4)}this.writeFile(s,e)}}};if(n.length==1)i=t+f.sep+n[0];else throw`TODO code multiple template`;a(i)}let i=(0,f.join)(this.buildConfig.stories.workspace?(0,f.resolve)(this.build.project.getConfigFile().folderPath,this.buildConfig.stories.workspace):e,`.storybook`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`main.ts`);if(!(0,u.existsSync)(a)){let e=dt(),t=$i(F(this.buildConfig.stories.output),F(a));e=this.replaceVariable(e,`path`,t),this.writeFile(a,e)}let o=(0,f.join)(i,`preview.ts`);if(!(0,u.existsSync)(o)){let e=ht();this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}writeFile(e,t){na(e,t,`storybook`)}},_t=class e{static Parse(t,n,r){if(t.importClause){if(t.importClause.namedBindings){if(t.importClause.namedBindings.kind==p.SyntaxKind.NamespaceImport){let e=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(e=r.build.project.resolveAlias(e,n),e.startsWith(`.`))r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
233
233
  `)});else{let n=t.importClause.namedBindings.name.getText();t.importClause.isTypeOnly||(r.build.npmBuilder.register(r.document.uri,{libName:`*`,uri:e,alias:n}),r.npmImports[n]={uri:e,nameInsideLib:`*`})}}else if(t.importClause.namedBindings.kind==p.SyntaxKind.NamedImports){let i=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(i=r.build.project.resolveAlias(i,n),i.startsWith(`.`))for(let n of t.importClause.namedBindings.elements){let a=n.isTypeOnly||t.importClause.isTypeOnly,o=new e({parserInfo:r,moduleName:i,identifier:n.propertyName?n.propertyName:n.name,alias:n.propertyName?n.name.getText():void 0,isTypeImport:a});r.importsLocal[o.alias??o.name]=o}else if(!i.startsWith(`.`)&&i.includes(w.Package))for(let e of t.importClause.namedBindings.elements)if(e.propertyName)r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use renamed import`,`
234
234
  `)});else{let n=e.name.getText(),a=i.split(`:`);if(a.length>1){let e=a[1].replace(w.Package,``)+`.`+n;r.packages[n]={fullname:e}}else r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`The package import is malformated`,`
235
- `)})}else for(let e of t.importClause.namedBindings.elements){let n=e.name.getText(),a=n;e.propertyName&&(a=e.propertyName.getText()),!t.importClause.isTypeOnly&&!e.isTypeOnly&&(r.build.npmBuilder.register(r.document.uri,{libName:a,uri:i,alias:n}),r.npmImports[n]={uri:i,nameInsideLib:a})}}}else if(t.importClause.name){let i=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(i=r.build.project.resolveAlias(i,n),i.startsWith(`.`)){let n=new e({parserInfo:r,moduleName:i,identifier:t.importClause.name,isTypeImport:t.importClause.isTypeOnly});r.importsLocal[n.alias??n.name]=n}else t.importClause.isTypeOnly||(r.build.npmBuilder.register(r.document.uri,{libName:`default`,uri:i,alias:this.name}),r.npmImports[this.name]={uri:i,nameInsideLib:`default`})}}}static manualLocalImport(t,n,r){let i=t.parserInfo,a=n.split(`.`).pop();if(!a)return;let o=new e({parserInfo:t.parserInfo,name:a,moduleUri:r});if(i.manualImportLocal[o.alias??o.name]){let e=0,t=a+e;for(;i.manualImportLocal[t];)e++,t=a+e;a=t,o.alias=a}return i.manualImportLocal[a]=o,o}nameStart=0;nameEnd=0;name=``;info;realName;isTypeImport;alias;_parserInfo;get parserInfo(){return this._parserInfo}isCst1(e){return!!e.identifier}constructor(e){this._parserInfo=e.parserInfo;let t;if(this.isCst1(e)?(this.name=e.identifier.getText(),this.nameStart=e.identifier.getStart(),this.nameEnd=e.identifier.getEnd(),this.isTypeImport=e.isTypeImport,this.alias=e.alias,t=F((0,f.normalize)(Gi(I(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!A.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)A.parse(e,!1,this.parserInfo.build);else{let e=I(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new E(d.TextDocument.create(t,C.TypeScript,1,n));A.parse(r,!1,this.parserInfo.build)}}if(A.parsedDoc[t]?.result.isReady){let e=A.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:A.addError(this.nameStart,this.nameEnd,`Can't load `+t+` `+this.name+` from `+this.parserInfo.document.uri)}else{if(this.parserInfo.waitingImports[this.alias??this.name])return;this.parserInfo.waitingImports[this.alias??this.name]=[],A.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=A.parsedDoc[e].result.getBaseInfo(t);if(n){this.info=n;let e=[this.parserInfo.classes,this.parserInfo.enums,this.parserInfo.aliases,this.parserInfo.functions,this.parserInfo.variables];for(let r of e)for(let e in r){let i=r[e],a=Object.values(i.dependencies);for(let e of a)e.uri==`@external`&&e.fullName==t&&(e.uri=`@local`,e.fullName=`$namespace$`+n.fullName)}for(let e of this.parserInfo.waitingImports[t])e(n);delete this.parserInfo.waitingImports[t]}else A.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},vt=class e{msg=`This code is deprecated`;static is(t){if(t.name==`Deprecated`){let n=new e;if(t.arguments.length>0)try{n.msg=t.arguments[0].value}catch{}return n}return null}},k=class e{static infoByShortName={};static infoByFullName={};static getInfoByShortName(e){return this.infoByShortName[e]}static getInfoByFullName(e,t){e=e.replace(/<.*>/,``);let n=this.infoByFullName[e];return n||=this.infoByFullName[t.fullName.split(`.`)[0]+`.`+e],n}static isExported(e){if(e.modifiers){for(let t of e.modifiers)if(t.kind==p.SyntaxKind.ExportKeyword)return!0}return!1}static isStoryExported(e,t){if(!t.buildConfig.stories)return!1;let n=at.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=lt.is(n);if(e)return e.exportType?e.exportType==`all`||e.exportType==`public`||e.exportType==`protected`:!0}return t.buildConfig.stories.format==`all`||t.buildConfig.stories.format==`public`||t.buildConfig.stories.format==`protected`}name=``;nameStart=0;nameEnd=0;start=0;end=0;fullName=``;namespace=``;decorators=[];useNormalDecorator=!1;storieContent;storieInject={};storieDecorator;storyType=`none`;dependencies={};compiled=``;documentation;isExported=!1;isInternalExported=!1;_parserInfo;content=``;deprecated=!1;deprecatedMsg=``;compileTransformations={};get compiledContent(){return e.getContent(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentHotReload(){return e.getContentHotReload(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentNpm(){return e.getContentNpm(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentDoc(){return e.getContentDoc(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get fileUri(){return this.document.uri}document;dependenciesPrevented=[];dependenciesLocations={};infoType=0;build;willBeCompiled;get parserInfo(){return this._parserInfo}constructor(t,n,r,i=!0){if(this._parserInfo=r,this.document=r.document,this.decorators=at.buildDecorator(t,this),this.dependenciesLocations={},this.build=r.build,this.willBeCompiled=t.kind!=p.SyntaxKind.InterfaceDeclaration&&t.kind!=p.SyntaxKind.TypeAliasDeclaration,t.name){this.start=t.getStart(),this.end=t.getEnd(),this.name=t.name.getText(),this.nameStart=t.name.getStart(),this.nameEnd=t.name.getEnd(),this.namespace=n.join(`.`),this.fullName=[...n,this.name].join(`.`),this.content=t.getText(),r.isExternal||(e.infoByShortName[this.name]=this);let a=new ut(t);if(a.hasDoc&&(this.documentation=a),i&&this.loadDecorators(),t.kind!=p.SyntaxKind.VariableDeclaration){this.isExported=e.isExported(t),this.isInternalExported=this.isExported;for(let e of this.decorators)if(st.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=ot.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=vt.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}preventDependencyAdd(e){this.dependenciesPrevented.includes(e)||this.dependenciesPrevented.push(e)}loadExpression(e,t=0,n=!1){if($.debug(`***`+t+`. `+e.getText()),$.debug(p.SyntaxKind[e.kind]),e.kind==p.SyntaxKind.ExpressionWithTypeArguments)this.addDependency(e,n);else if(e.kind==p.SyntaxKind.NewExpression){let r=e;this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.PropertyAccessExpression){let r=e,i=r.name.getText(),a=A.getBaseInfo(i);if(a&&r.expression.getText()+`.`+i==a.fullName)this.addDependencyName(a.fullName,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(A.hasLocal(e)||A.hasImport(e))&&this.addDependencyName(e,n,r.expression.getStart(),r.expression.getEnd())}this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind==p.SyntaxKind.PropertyAccessExpression||e.parent.kind==p.SyntaxKind.GetAccessor||e.parent.kind==p.SyntaxKind.SetAccessor||!this.checkParentIdentifier(e))return;let t=e.getText();t!=`this`&&!t.includes(`.`)&&(A.getBaseInfo(t)||A.hasLocal(t)||A.hasImport(t))&&this.addDependencyName(t,n,e.getStart(),e.getEnd())}else if(e.kind==p.SyntaxKind.CallExpression){let r=e;this.loadExpression(r.expression,t+1,n)}}checkParentIdentifier(e){let t=[p.SyntaxKind.VariableDeclaration,p.SyntaxKind.FunctionDeclaration,p.SyntaxKind.ClassDeclaration,p.SyntaxKind.InterfaceDeclaration,p.SyntaxKind.TypeAliasDeclaration,p.SyntaxKind.EnumDeclaration,p.SyntaxKind.ModuleDeclaration,p.SyntaxKind.NamespaceExportDeclaration,p.SyntaxKind.ImportEqualsDeclaration,p.SyntaxKind.ExportAssignment,p.SyntaxKind.ExportDeclaration,p.SyntaxKind.NamespaceExport,p.SyntaxKind.ExportSpecifier,p.SyntaxKind.MissingDeclaration,p.SyntaxKind.MethodDeclaration,p.SyntaxKind.ClassStaticBlockDeclaration],n=[p.SyntaxKind.ImportDeclaration,p.SyntaxKind.ImportClause,p.SyntaxKind.NamespaceImport,p.SyntaxKind.NamedImports,p.SyntaxKind.ImportSpecifier];return t.includes(e.parent.kind)?e.parent.name!=e:n.includes(e.parent.kind)?!1:!(e.parent.kind>=p.SyntaxKind.JsxElement&&e.parent.kind<=p.SyntaxKind.JsxExpression)}loadDependencyContext=void 0;maybeDependencies={};loadOnlyDependenciesRecu(e,t=0,n=!1){this.parserInfo.isExternal||(e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=`Decorator`),(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.TypeReference){this.addDependency(e,n);return}else this.loadExpression(e,t,n);this.loadOnlyDependenciesRecu(e,t+1,n)}),e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=void 0))}addDependency(e,t){if(this.parserInfo.isExternal)return;let n=e=>{if(e.kind==`type`){this.addDependencyName(e.value,t,e.start,e.endNonGeneric);for(let t of e.nested)n(t);for(let t of e.genericValue)n(t)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)n(t);else if(e.kind==`union`)for(let t of e.nested)n(t)};n(new O(e))}addDependencyWaitName(e,t,n){if(this.parserInfo.isExternal){n([e.getText()],[e.getText()]);return}let r=[],i=[],a=0,o=!1,s=()=>{!o&&a==0&&(o=!0,n(r,i))},c=(e,n)=>{if(e.kind==`type`){a++,this.addDependencyName(e.value,t,e.start,e.endNonGeneric,(e,t)=>{n==0&&(e&&r.push(e),t&&i.push(t)),a--,s()});for(let t of e.nested)c(t,n+1);for(let r of e.genericValue)t=!1,c(r,n+1)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)c(t,n+1);else if(e.kind==`union`)for(let t of e.nested)c(t,n+1)};c(new O(e),0),s()}loadStoryBookInject(){let e=this.build.buildConfig.stories;if(!e)return;let t=this.storieContent;if(!t)return;let n=(e,t)=>{this.storieInject[e]?this.storieInject[e].includes(t)||this.storieInject[e].push(t):this.storieInject[e]=[t]},r=r=>{let i=(0,f.join)(e.output,`generated`),a=(0,f.join)(e.output,`auto`,...this.fullName.split(`.`)),o=Qi(F((0,f.join)(i,...t.namespace.split(`.`))),F(a)),s=this.fullName.split(`.`);s.pop();let c=r.split(`.`),l=c.pop()??``;for(let e=0;e<s.length;e++)if(c.length>e)if(c[e]==s[e])c.splice(e,1),s.splice(e,1),e--;else break;let u=``;for(let e=0;e<s.length;e++)u+=`../`;u==``&&(u+=`./`),u+=c.join(`/`),u=(0,f.normalize)((0,f.join)(o,u)).replace(/\\/g,`/`),n(u,l)};if(this.storieDecorator?.slots?.inject)for(let e of this.storieDecorator.slots.inject)if(e.includes(`.`)){let t=this.build.externalPackageInformation.getNpmUri(e);t&&n(t.uri,t.name)}else this.parserInfo.internalObjects[e]?r(this.parserInfo.internalObjects[e].fullname):this.parserInfo.importsLocal[e]?.info?r(this.parserInfo.importsLocal[e].info.fullName):this.parserInfo.packages[e]||this.parserInfo.npmImports[e]&&n(this.parserInfo.npmImports[e].uri,e)}getNpmReplacementName(e){let t=[this.build.module,this.fullName].join(`.`);return this.parserInfo.getNpmReplacementName(t,e)}addDependencyTag(e,t){let n=this.build.getWebComponentTagDependency(e);if(n){for(let e of t.dependencies)if(e.fullName==n.fullName)return;let e=n.uri;if(e==`@external`){let e=n.fullName,t=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);t&&this._parserInfo.registerGeneratedImport({uri:t.uri,name:t.name,compiled:t.compiled,alias:r,forced:!0})}else if(e==`@npm`){let e=n.fullName,t=na(this.parserInfo.npmImports[e].uri),r=this.getNpmReplacementName(t+`.`+e);this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:r,forced:!0})}else{let e=_t.manualLocalImport(this,n.fullName,n.uri),t=n.fullName,r=this.fullName.split(`.`);r.pop();let i=t.split(`.`),a=i.pop()??``;for(let e=0;e<r.length;e++)if(i.length>e)if(i[e]==r[e])i.splice(e,1),r.splice(e,1),e--;else break;let o=r.length==0&&i.length==0,s=``;for(let e=0;e<r.length;e++)s+=`../`;s==``&&(s+=`./`),s+=i.join(`/`);let c=this.getNpmReplacementName([this.build.module,t].join(`.`));this._parserInfo.registerGeneratedImport({uri:s,nameAlias:e?.alias,name:a,compiled:!0,alias:c,onlySrc:o,forced:!0})}t.dependencies.push(n)}}addDependencyName(e,t,n,r,i){if(this.parserInfo.isExternal)return;let a;if(a=i||(()=>{}),!e||e==`constructor`||e==`toString`){a();return}$.debug(`try add dendency `+e);let o=/<.*>/g.exec(e);if(o&&(r-=o[0].length,e=e.replace(o[0],``)),e==this.fullName){a();return}if(et.exists(e)&&!this.parserInfo.internalObjects[e]&&!this.parserInfo.importsLocal[e]&&!this.parserInfo.waitingImports[e]&&!this.parserInfo.npmImports[e]&&!this.parserInfo.packages[e]){a();return}if(n>0&&r>0){this.dependenciesLocations[e]||(this.dependenciesLocations[e]={locations:{},typeRemplacement:null,replacement:null,docReplacement:null,hotReloadReplacement:null,npmReplacement:null});let t=n+`_`+r;if(!this.dependenciesLocations[e].locations){$.showErrorMessage(`For the admin : you can add `+e+` as dependency to avoid`),a();return}if(!this.dependenciesLocations[e].locations[t]){let i=(0,p.getTokenAtPosition)(this.parserInfo.srcFile,(n+r)/2),a=(0,p.isTypeReferenceNode)(i)||(0,p.isTypeReferenceNode)(i.parent);this.dependenciesLocations[e].locations[t]={start:n,end:r,isType:a}}}if(!this.addDependencyNameCustomCheck(e)){a();return}if(this.dependenciesPrevented.includes(e)){a();return}if(this.dependencies[e]){if(a(),this.loadDependencyContext===void 0&&this.maybeDependencies[e]){let t=this.getNpmReplacementName(this.maybeDependencies[e].name);this._parserInfo.registerGeneratedImport({uri:this.maybeDependencies[e].uri,name:this.maybeDependencies[e].name,compiled:this.maybeDependencies[e].compiled,alias:t,forced:!1})}return}if(e.includes(`.`)){this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t};let n=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);n&&(this.dependenciesLocations[e].npmReplacement=r,this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:n.uri,name:n.name,compiled:n.compiled,alias:r,forced:!1}):this.maybeDependencies[e]=n),a(e,r);return}let s=(t,n,r)=>{let i=this.fullName.split(`.`);i.pop();let a=t.split(`.`),o=a.pop()??``;for(let e=0;e<i.length;e++)if(a.length>e)if(a[e]==i[e])a.splice(e,1),i.splice(e,1),e--;else break;let s=i.length==0&&a.length==0,c=``;for(let e=0;e<i.length;e++)c+=`../`;c==``&&(c+=`./`),c+=a.join(`/`),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:c,name:o,compiled:n,alias:r,onlySrc:s,forced:!1}):this.maybeDependencies[e]={uri:c,name:o,compiled:n}};if(this.parserInfo.internalObjects[e]){let n=this.parserInfo.internalObjects[e].fullname,r=[this.build.module,...this.build.namespaces,n].join(`.`);if(n==this.fullName&&(t=!1),this.dependencies[e]={fullName:`$namespace$`+n,uri:`@local`,isStrong:t},$.debug(`add dependence `+e+` : same file`),this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=this.parserInfo.internalObjects[e].isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=e,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,this.parserInfo.internalObjects[e].isCompiled,e)}a(n,e);return}let c=this.parserInfo.importsLocal[e]?.info;if(c){let n=c.fullName,r=[this.build.module,...this.build.namespaces,n].join(`.`);this.dependencies[e]={fullName:`$namespace$`+n,uri:c.fileUri,isStrong:t},$.debug(`add dependency `+e+` : imported file`);let i=this.getNpmReplacementName([this.build.module,n].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=c.isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`));let a=n,o=this.fullName.split(`.`);o.slice(0,1);let l=n.split(`.`)[0];o.includes(l)&&(a=`_.`+a),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=a,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,c.willBeCompiled,i)}a(n,i);return}else if(this.parserInfo.waitingImports[e]){$.debug(`add dependency `+e+` : but waiting import file`),this.parserInfo.waitingImports[e].push(n=>{let r=n.fullName,i=[this.build.module,...this.build.namespaces,r].join(`.`),o=this.getNpmReplacementName([this.build.module,r].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+r;this.isExported!=n.isExported&&(t=this.isExported?[`___`+this.build.module,r].join(`.`):[`globalThis`,this.build.module,r].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=r,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+r,this.dependenciesLocations[e].npmReplacement=o,this.dependenciesLocations[e].hotReloadReplacement=i,s(r,n.willBeCompiled,o)}this.dependencies[e]={fullName:`$namespace$`+r,uri:n.fileUri,isStrong:t},a(r,o)});return}else if(this.parserInfo.packages[e]){let n=this.parserInfo.packages[e].fullname,r=this.build.externalPackageInformation.getNpmUri(n);this.dependencies[e]={fullName:n,uri:`@external`,isStrong:t};let i=this.getNpmReplacementName(n);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].typeRemplacement=n,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=n),r&&this._parserInfo.registerGeneratedImport({uri:r.uri,name:r.name,compiled:r.compiled,alias:i,forced:!1}),a(n,i);return}if(this.parserInfo.npmImports[e]){this.dependencies[e]={fullName:e,uri:`@npm`,isStrong:t},$.debug(`add dependency `+e+` : npm`);let i=na(this.parserInfo.npmImports[e].uri),o=this.getNpmReplacementName(i+`.`+e);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].replacement=`npmCompilation['`+i+`'].`+e,this.dependenciesLocations[e].docReplacement=`npmCompilation['`+i+`'].`+e,o!=e&&(this.dependenciesLocations[e].npmReplacement=o),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:o,forced:!1}):this.maybeDependencies[e]={uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0}),n>0&&r>0&&(this.dependenciesLocations[e].locations[n+`_`+r].isNpm=!0),a(e,o);return}this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t},$.debug(`add dependency `+e+` : external`),a(e,e)}addDependencyNameCustomCheck(e){return!0}static getContent(e,t,n,r,i){return this._getContent(e,t,n,r,i,1)}static getContentHotReload(e,t,n,r,i){return this._getContent(e,t,n,r,i,2)}static getContentNpm(e,t,n,r,i){return this._getContent(e,t,n,r,i,3)}static getContentDoc(e,t,n,r,i){return this._getContent(e,t,n,r,i,4)}static _getContent(e,t,n,r,i,a){let o=[];for(let e in r){let i=null;a==1?i=r[e].replacement:a==2?i=r[e].hotReloadReplacement:a==3?i=r[e].npmReplacement:a==4&&(i=r[e].docReplacement);let s=r[e].typeRemplacement;if(i)for(let c in r[e].locations){let l=r[e].locations[c];if(l.start>=t&&l.end<=n)if(l.isType&&s&&a!=3)o.push({newText:s,start:l.start-t,end:l.end-t});else if(l.isNpm&&l.isType)continue;else o.push({newText:i,start:l.start-t,end:l.end-t})}}for(let e in i){let r=i[e];r.start>=t&&r.end<=n&&o.push({newText:r.newText,start:r.start-t,end:r.end-t})}o.sort((e,t)=>t.end-e.end);let s=e.length;for(let t of o)t.end>s||(e=e.slice(0,t.start)+t.newText+e.slice(t.end,e.length),s=t.start);return e.replace(/^\s*export\s+(class|interface|enum|type|abstract|function|async)/m,`$1`)}loadStorieContent(){if(this.build.buildConfig.stories&&!this._parserInfo.isExternal){for(let e of this.decorators){let t=lt.is(e);if(t){this.storieDecorator=t;break}}let e=this.build.buildConfig.stories.format;if(this.storieDecorator?this.storieDecorator.exportType?this.storyType=this.storieDecorator.exportType:e?this.storyType=e==`manual`?`all`:e:this.storyType=`none`:e?this.storyType=e==`manual`?`none`:e:this.storyType=`none`,this.storyType==`public`||this.storyType==`protected`?(this.storieDecorator||this.isExported)&&(this.storieContent=this.defineStoryContent(this.storieDecorator)):this.storyType==`all`&&(this.storieContent=this.defineStoryContent(this.storieDecorator)),this.storieContent&&this.build.buildConfig.stories.srcBaseUrl){let e=this.build.project.getConfigFile().uri.replace(w.Config,``),t=I(this.fileUri.replace(e,``)).replace(/\\/g,`/`);this.storieContent.srcUrl=this.build.buildConfig.stories.srcBaseUrl+`/`+t}}}transformTypeForStory(e,t){if(e){if(e.kind==`type`){let n={kind:`simple`,name:e.value};if(e.isArray&&(n.isArray=!0),e.genericValue.length>0){let r=[];for(let n of e.genericValue){let e=this.transformTypeForStory(n,t);e&&r.push(e)}r.length>0&&(n.generics=r)}let r=t.parserInfo.importsLocal[e.value]?.info;if(r)r.storyType!=`none`&&(n.ref=gt.getFullname(r));else{let r=t.parserInfo.internalObjects[e.value];r?.isStoryExported&&(n.ref=r.fullname)}return n}if(e.kind==`any`||e.kind==`never`||e.kind==`unknown`||e.kind==`boolean`||e.kind==`null`||e.kind==`number`||e.kind==`string`||e.kind==`undefined`||e.kind==`void`||e.kind==`object`||e.kind==`symbol`||e.kind==`this`)return{kind:`simple`,name:e.kind};if(e.kind==`literal`)return{kind:`simple`,name:e.value.slice(1,-1)};if(e.kind==`function`||e.kind==`constructor`){if(!e.fctType)return;let t={kind:`function`};if(Object.keys(e.fctType.parameters).length>0){t.parameters=[];for(let n in e.fctType.parameters){let r={name:n},i=this.transformTypeForStory(e.fctType.parameters[n],this);i&&(r.type=i),t.parameters.push(r)}}let n=this.transformTypeForStory(e.fctType.return,this);n&&(t.return=n),e.kind==`constructor`&&(t.isConstructor=!0);let r=e.node;if(r.typeParameters){t.generics=[];for(let e of r.typeParameters){let n={name:e.name.getText()},r=this.transformTypeForStory(new O(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new O(e.constraint),this);i&&(n.constraint=i),t.generics.push(n)}}return t}if(e.kind==`tuple`){let n={kind:`tupple`,tupples:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.tupples.push(e)}return n}if(e.kind==`typeLiteral`){let n={kind:`object`},r=e.node;return(0,p.forEachChild)(r,e=>{if(e.kind==p.SyntaxKind.PropertySignature){let r=e;if(r.type){let e=r.name.getText(),i=new O(r.type),a=this.transformTypeForStory(i,t);a&&(n.keys||={},n.keys[e]=a)}else $.error(`need implements property signature no type `+p.SyntaxKind[e.kind]+` `+t.fileUri)}else if(e.kind==p.SyntaxKind.IndexSignature){let r=e;if(r.parameters.length>0&&r.parameters[0].type){n.indexSignatures||=[];let e=this.transformTypeForStory(new O(r.type),t),i=this.transformTypeForStory(new O(r.parameters[0].type),t);e&&i&&n.indexSignatures.push({keyName:r.parameters[0].name.getText(),keyType:i,type:e})}}else if(e.kind==p.SyntaxKind.TypeLiteral){let r=e,i=this.transformTypeForStory(new O(r),t);i&&(n.array=i)}else $.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri)}),n}if(e.kind==`union`){let n={kind:`union`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`intersection`){let n={kind:`intersection`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`typeOperator`){if(e.nested.length>0){let n=this.transformTypeForStory(e.nested[0],t);if(n)return{kind:`typeOperator`,value:e.value,type:n}}return}if(e.kind==`indexedAccess`){if(e.nested.length==2){let n=this.transformTypeForStory(e.nested[0],t),r=this.transformTypeForStory(e.nested[1],t);if(r&&n)return{kind:`indexAccess`,obj:n,key:r}}return}if(e.kind==`mappedType`){if(e.mappedType){let n=this.transformTypeForStory(e.mappedType.parameterType,t),r=this.transformTypeForStory(e.mappedType.type,t);if(n&&r){let t={kind:`mappedType`,parameterName:e.mappedType.parameterName,parameterType:n,type:r};return e.mappedType.modifier&&(t.modifier=e.mappedType.modifier),t}}return}if(e.kind==`infer`)return{kind:`infer`,name:e.value};if(e.kind==`conditional`){if(e.conditionalType){let n=this.transformTypeForStory(e.conditionalType.check,t),r=this.transformTypeForStory(e.conditionalType.extends,t),i=this.transformTypeForStory(e.conditionalType.true,t),a=this.transformTypeForStory(e.conditionalType.false,t);if(r&&i&&a&&n)return{kind:`conditional`,check:n,extends:r,true:i,false:a}}return}e.kind==`mock`&&$.warning(`mock type`)}}loadGenericForStory(e,t){let n=e.name.getText(),r={name:n};if(t||=this.documentation,t?.documentationTemplates[n]&&(r.documentation=t.documentationTemplates[n]),e.constraint){let t=this.transformTypeForStory(new O(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new O(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new O(e.type),this);return i&&(r.type=i),t||=this.documentation,t?.documentationParameters[n]&&(r.documentation=t.documentationParameters[n]),r}setAccessibilityForStroy(e){this.isExported||(e.accessibility=`internal`)}setNamespaceForStroy(e){this.build.noNamespaceUri[this.fileUri]?this.namespace.length>0&&(e.namespace=this.namespace):(e.namespace=this.build.module,this.namespace.length>0&&(e.namespace+=`.`+this.namespace))}setDocumentationForStroy(e){this.documentation&&(e.documentation=this.documentation.definitions.join(`
236
- `))}},yt=class extends k{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new O(this.node.type),this.loadOnlyDependenciesRecu(e)}defineStoryContent(){let e={kind:`type`,name:this.name};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=this.transformTypeForStory(new O(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},bt=class e{static is(t){return t.name==`NoCompile`?new e:null}},xt=class e{static is(t){return t.name==`BindThis`?new e:null}},St=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=at.buildDecorator(e,t),this.returnType=new O(e.type);let n=new ut(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)bt.is(e)?this.mustBeCompiled=!1:(r=vt.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;continue}let r=ct.is(e);if(r){n=r;continue}if(xt.is(e)){this.isBindThis=!0;continue}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof st?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof st?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&A.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},Ct=class e{static is(t){if(t.name==`StoryValue`){if(t.arguments.length>0){let n=t.arguments[0].value;return new e(n)}return null}return null}value;constructor(e){this.value=e}},wt=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;deprecatedMsg=``;get compiledContent(){return k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:k.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:k.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:k.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=at.buildDecorator(e,n),e.kind==p.SyntaxKind.GetAccessor?this.isGet=!0:e.kind==p.SyntaxKind.SetAccessor?this.isSet=!0:this.isGetSet=!0;let r=new ut(e);r.hasDoc&&(this.documentation=r),e.questionToken&&(this.isNullable=!0),e.exclamationToken&&(this.overrideNullable=!0),this.loadAccessibilityModifier(e),this.type=this.loadType(e),this.loadInitializer(e);for(let e of this.decorators){let t=Ct.is(e);t&&(this.defaultValueStory=t.value);let n=vt.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;break}let r=ct.is(e);if(r){n=r;break}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof st?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof st?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&A.addError(e.getStart(),e.getEnd(),`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}loadType(e){let t=e,n;return n=t.type?new O(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new O(t.initializer):new O(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},Tt=class e{name=`Fullname`;static is(t){if(t.name==`Convertible`){let n=new e;if(t.arguments.length>0)try{n.name=t.arguments[0].value}catch{}return n}return null}};const Et=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var Dt=class extends wt{propType=`Simple`;inParent=!1;arguments},Ot=class e extends k{extends=[];extendsNpm=[];implements=[];parentClass=null;methods={};methodsStatic={};properties={};propertiesStatic={};isInterface=!1;isAbstract=!1;constructorBody;constructorParams=[];parameters=[];methodParameters=[];convertibleName=``;extendsType;implementsType=[];extraConstructorCode=[];get isWebcomponent(){return this.implements.includes(`Aventus.DefaultComponent`)&&!this.isInterface}get constructorContent(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
235
+ `)})}else for(let e of t.importClause.namedBindings.elements){let n=e.name.getText(),a=n;e.propertyName&&(a=e.propertyName.getText()),!t.importClause.isTypeOnly&&!e.isTypeOnly&&(r.build.npmBuilder.register(r.document.uri,{libName:a,uri:i,alias:n}),r.npmImports[n]={uri:i,nameInsideLib:a})}}}else if(t.importClause.name){let i=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(i=r.build.project.resolveAlias(i,n),i.startsWith(`.`)){let n=new e({parserInfo:r,moduleName:i,identifier:t.importClause.name,isTypeImport:t.importClause.isTypeOnly});r.importsLocal[n.alias??n.name]=n}else t.importClause.isTypeOnly||(r.build.npmBuilder.register(r.document.uri,{libName:`default`,uri:i,alias:this.name}),r.npmImports[this.name]={uri:i,nameInsideLib:`default`})}}}static manualLocalImport(t,n,r){let i=t.parserInfo,a=n.split(`.`).pop();if(!a)return;let o=new e({parserInfo:t.parserInfo,name:a,moduleUri:r});if(i.manualImportLocal[o.alias??o.name]){let e=0,t=a+e;for(;i.manualImportLocal[t];)e++,t=a+e;a=t,o.alias=a}return i.manualImportLocal[a]=o,o}nameStart=0;nameEnd=0;name=``;info;realName;isTypeImport;alias;_parserInfo;get parserInfo(){return this._parserInfo}isCst1(e){return!!e.identifier}constructor(e){this._parserInfo=e.parserInfo;let t;if(this.isCst1(e)?(this.name=e.identifier.getText(),this.nameStart=e.identifier.getStart(),this.nameEnd=e.identifier.getEnd(),this.isTypeImport=e.isTypeImport,this.alias=e.alias,t=F((0,f.normalize)(Ki(I(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!A.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)A.parse(e,!1,this.parserInfo.build);else{let e=I(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new E(d.TextDocument.create(t,C.TypeScript,1,n));A.parse(r,!1,this.parserInfo.build)}}if(A.parsedDoc[t]?.result.isReady){let e=A.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:A.addError(this.nameStart,this.nameEnd,`Can't load `+t+` `+this.name+` from `+this.parserInfo.document.uri)}else{if(this.parserInfo.waitingImports[this.alias??this.name])return;this.parserInfo.waitingImports[this.alias??this.name]=[],A.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=A.parsedDoc[e].result.getBaseInfo(t);if(n){this.info=n;let e=[this.parserInfo.classes,this.parserInfo.enums,this.parserInfo.aliases,this.parserInfo.functions,this.parserInfo.variables];for(let r of e)for(let e in r){let i=r[e],a=Object.values(i.dependencies);for(let e of a)e.uri==`@external`&&e.fullName==t&&(e.uri=`@local`,e.fullName=`$namespace$`+n.fullName)}for(let e of this.parserInfo.waitingImports[t])e(n);delete this.parserInfo.waitingImports[t]}else A.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},vt=class e{msg=`This code is deprecated`;static is(t){if(t.name==`Deprecated`){let n=new e;if(t.arguments.length>0)try{n.msg=t.arguments[0].value}catch{}return n}return null}},k=class e{static infoByShortName={};static infoByFullName={};static getInfoByShortName(e){return this.infoByShortName[e]}static getInfoByFullName(e,t){e=e.replace(/<.*>/,``);let n=this.infoByFullName[e];return n||=this.infoByFullName[t.fullName.split(`.`)[0]+`.`+e],n}static isExported(e){if(e.modifiers){for(let t of e.modifiers)if(t.kind==p.SyntaxKind.ExportKeyword)return!0}return!1}static isStoryExported(e,t){if(!t.buildConfig.stories)return!1;let n=at.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=lt.is(n);if(e)return e.exportType?e.exportType==`all`||e.exportType==`public`||e.exportType==`protected`:!0}return t.buildConfig.stories.format==`all`||t.buildConfig.stories.format==`public`||t.buildConfig.stories.format==`protected`}name=``;nameStart=0;nameEnd=0;start=0;end=0;fullName=``;namespace=``;decorators=[];useNormalDecorator=!1;storieContent;storieInject={};storieDecorator;storyType=`none`;dependencies={};compiled=``;documentation;isExported=!1;isInternalExported=!1;_parserInfo;content=``;deprecated=!1;deprecatedMsg=``;compileTransformations={};get compiledContent(){return e.getContent(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentHotReload(){return e.getContentHotReload(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentNpm(){return e.getContentNpm(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentDoc(){return e.getContentDoc(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get fileUri(){return this.document.uri}document;dependenciesPrevented=[];dependenciesLocations={};infoType=0;build;willBeCompiled;get parserInfo(){return this._parserInfo}constructor(t,n,r,i=!0){if(this._parserInfo=r,this.document=r.document,this.decorators=at.buildDecorator(t,this),this.dependenciesLocations={},this.build=r.build,this.willBeCompiled=t.kind!=p.SyntaxKind.InterfaceDeclaration&&t.kind!=p.SyntaxKind.TypeAliasDeclaration,t.name){this.start=t.getStart(),this.end=t.getEnd(),this.name=t.name.getText(),this.nameStart=t.name.getStart(),this.nameEnd=t.name.getEnd(),this.namespace=n.join(`.`),this.fullName=[...n,this.name].join(`.`),this.content=t.getText(),r.isExternal||(e.infoByShortName[this.name]=this);let a=new ut(t);if(a.hasDoc&&(this.documentation=a),i&&this.loadDecorators(),t.kind!=p.SyntaxKind.VariableDeclaration){this.isExported=e.isExported(t),this.isInternalExported=this.isExported;for(let e of this.decorators)if(st.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=ot.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=vt.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}preventDependencyAdd(e){this.dependenciesPrevented.includes(e)||this.dependenciesPrevented.push(e)}loadExpression(e,t=0,n=!1){if($.debug(`***`+t+`. `+e.getText()),$.debug(p.SyntaxKind[e.kind]),e.kind==p.SyntaxKind.ExpressionWithTypeArguments)this.addDependency(e,n);else if(e.kind==p.SyntaxKind.NewExpression){let r=e;this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.PropertyAccessExpression){let r=e,i=r.name.getText(),a=A.getBaseInfo(i);if(a&&r.expression.getText()+`.`+i==a.fullName)this.addDependencyName(a.fullName,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(A.hasLocal(e)||A.hasImport(e))&&this.addDependencyName(e,n,r.expression.getStart(),r.expression.getEnd())}this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind==p.SyntaxKind.PropertyAccessExpression||e.parent.kind==p.SyntaxKind.GetAccessor||e.parent.kind==p.SyntaxKind.SetAccessor||!this.checkParentIdentifier(e))return;let t=e.getText();t!=`this`&&!t.includes(`.`)&&(A.getBaseInfo(t)||A.hasLocal(t)||A.hasImport(t))&&this.addDependencyName(t,n,e.getStart(),e.getEnd())}else if(e.kind==p.SyntaxKind.CallExpression){let r=e;this.loadExpression(r.expression,t+1,n)}}checkParentIdentifier(e){let t=[p.SyntaxKind.VariableDeclaration,p.SyntaxKind.FunctionDeclaration,p.SyntaxKind.ClassDeclaration,p.SyntaxKind.InterfaceDeclaration,p.SyntaxKind.TypeAliasDeclaration,p.SyntaxKind.EnumDeclaration,p.SyntaxKind.ModuleDeclaration,p.SyntaxKind.NamespaceExportDeclaration,p.SyntaxKind.ImportEqualsDeclaration,p.SyntaxKind.ExportAssignment,p.SyntaxKind.ExportDeclaration,p.SyntaxKind.NamespaceExport,p.SyntaxKind.ExportSpecifier,p.SyntaxKind.MissingDeclaration,p.SyntaxKind.MethodDeclaration,p.SyntaxKind.ClassStaticBlockDeclaration],n=[p.SyntaxKind.ImportDeclaration,p.SyntaxKind.ImportClause,p.SyntaxKind.NamespaceImport,p.SyntaxKind.NamedImports,p.SyntaxKind.ImportSpecifier];return t.includes(e.parent.kind)?e.parent.name!=e:n.includes(e.parent.kind)?!1:!(e.parent.kind>=p.SyntaxKind.JsxElement&&e.parent.kind<=p.SyntaxKind.JsxExpression)}loadDependencyContext=void 0;maybeDependencies={};loadOnlyDependenciesRecu(e,t=0,n=!1){this.parserInfo.isExternal||(e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=`Decorator`),(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.TypeReference){this.addDependency(e,n);return}else this.loadExpression(e,t,n);this.loadOnlyDependenciesRecu(e,t+1,n)}),e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=void 0))}addDependency(e,t){if(this.parserInfo.isExternal)return;let n=e=>{if(e.kind==`type`){this.addDependencyName(e.value,t,e.start,e.endNonGeneric);for(let t of e.nested)n(t);for(let t of e.genericValue)n(t)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)n(t);else if(e.kind==`union`)for(let t of e.nested)n(t)};n(new O(e))}addDependencyWaitName(e,t,n){if(this.parserInfo.isExternal){n([e.getText()],[e.getText()]);return}let r=[],i=[],a=0,o=!1,s=()=>{!o&&a==0&&(o=!0,n(r,i))},c=(e,n)=>{if(e.kind==`type`){a++,this.addDependencyName(e.value,t,e.start,e.endNonGeneric,(e,t)=>{n==0&&(e&&r.push(e),t&&i.push(t)),a--,s()});for(let t of e.nested)c(t,n+1);for(let r of e.genericValue)t=!1,c(r,n+1)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)c(t,n+1);else if(e.kind==`union`)for(let t of e.nested)c(t,n+1)};c(new O(e),0),s()}loadStoryBookInject(){let e=this.build.buildConfig.stories;if(!e)return;let t=this.storieContent;if(!t)return;let n=(e,t)=>{this.storieInject[e]?this.storieInject[e].includes(t)||this.storieInject[e].push(t):this.storieInject[e]=[t]},r=r=>{let i=(0,f.join)(e.output,`generated`),a=(0,f.join)(e.output,`auto`,...this.fullName.split(`.`)),o=$i(F((0,f.join)(i,...t.namespace.split(`.`))),F(a)),s=this.fullName.split(`.`);s.pop();let c=r.split(`.`),l=c.pop()??``;for(let e=0;e<s.length;e++)if(c.length>e)if(c[e]==s[e])c.splice(e,1),s.splice(e,1),e--;else break;let u=``;for(let e=0;e<s.length;e++)u+=`../`;u==``&&(u+=`./`),u+=c.join(`/`),u=(0,f.normalize)((0,f.join)(o,u)).replace(/\\/g,`/`),n(u,l)};if(this.storieDecorator?.slots?.inject)for(let e of this.storieDecorator.slots.inject)if(e.includes(`.`)){let t=this.build.externalPackageInformation.getNpmUri(e);t&&n(t.uri,t.name)}else this.parserInfo.internalObjects[e]?r(this.parserInfo.internalObjects[e].fullname):this.parserInfo.importsLocal[e]?.info?r(this.parserInfo.importsLocal[e].info.fullName):this.parserInfo.packages[e]||this.parserInfo.npmImports[e]&&n(this.parserInfo.npmImports[e].uri,e)}getNpmReplacementName(e){let t=[this.build.module,this.fullName].join(`.`);return this.parserInfo.getNpmReplacementName(t,e)}addDependencyTag(e,t){let n=this.build.getWebComponentTagDependency(e);if(n){for(let e of t.dependencies)if(e.fullName==n.fullName)return;let e=n.uri;if(e==`@external`){let e=n.fullName,t=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);t&&this._parserInfo.registerGeneratedImport({uri:t.uri,name:t.name,compiled:t.compiled,alias:r,forced:!0})}else if(e==`@npm`){let e=n.fullName,t=ra(this.parserInfo.npmImports[e].uri),r=this.getNpmReplacementName(t+`.`+e);this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:r,forced:!0})}else{let e=_t.manualLocalImport(this,n.fullName,n.uri),t=n.fullName,r=this.fullName.split(`.`);r.pop();let i=t.split(`.`),a=i.pop()??``;for(let e=0;e<r.length;e++)if(i.length>e)if(i[e]==r[e])i.splice(e,1),r.splice(e,1),e--;else break;let o=r.length==0&&i.length==0,s=``;for(let e=0;e<r.length;e++)s+=`../`;s==``&&(s+=`./`),s+=i.join(`/`);let c=this.getNpmReplacementName([this.build.module,t].join(`.`));this._parserInfo.registerGeneratedImport({uri:s,nameAlias:e?.alias,name:a,compiled:!0,alias:c,onlySrc:o,forced:!0})}t.dependencies.push(n)}}addDependencyName(e,t,n,r,i){if(this.parserInfo.isExternal)return;let a;if(a=i||(()=>{}),!e||e==`constructor`||e==`toString`){a();return}$.debug(`try add dendency `+e);let o=/<.*>/g.exec(e);if(o&&(r-=o[0].length,e=e.replace(o[0],``)),e==this.fullName){a();return}if(et.exists(e)&&!this.parserInfo.internalObjects[e]&&!this.parserInfo.importsLocal[e]&&!this.parserInfo.waitingImports[e]&&!this.parserInfo.npmImports[e]&&!this.parserInfo.packages[e]){a();return}if(n>0&&r>0){this.dependenciesLocations[e]||(this.dependenciesLocations[e]={locations:{},typeRemplacement:null,replacement:null,docReplacement:null,hotReloadReplacement:null,npmReplacement:null});let t=n+`_`+r;if(!this.dependenciesLocations[e].locations){$.showErrorMessage(`For the admin : you can add `+e+` as dependency to avoid`),a();return}if(!this.dependenciesLocations[e].locations[t]){let i=(0,p.getTokenAtPosition)(this.parserInfo.srcFile,(n+r)/2),a=(0,p.isTypeReferenceNode)(i)||(0,p.isTypeReferenceNode)(i.parent);this.dependenciesLocations[e].locations[t]={start:n,end:r,isType:a}}}if(!this.addDependencyNameCustomCheck(e)){a();return}if(this.dependenciesPrevented.includes(e)){a();return}if(this.dependencies[e]){if(a(),this.loadDependencyContext===void 0&&this.maybeDependencies[e]){let t=this.getNpmReplacementName(this.maybeDependencies[e].name);this._parserInfo.registerGeneratedImport({uri:this.maybeDependencies[e].uri,name:this.maybeDependencies[e].name,compiled:this.maybeDependencies[e].compiled,alias:t,forced:!1})}return}if(e.includes(`.`)){this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t};let n=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);n&&(this.dependenciesLocations[e].npmReplacement=r,this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:n.uri,name:n.name,compiled:n.compiled,alias:r,forced:!1}):this.maybeDependencies[e]=n),a(e,r);return}let s=(t,n,r)=>{let i=this.fullName.split(`.`);i.pop();let a=t.split(`.`),o=a.pop()??``;for(let e=0;e<i.length;e++)if(a.length>e)if(a[e]==i[e])a.splice(e,1),i.splice(e,1),e--;else break;let s=i.length==0&&a.length==0,c=``;for(let e=0;e<i.length;e++)c+=`../`;c==``&&(c+=`./`),c+=a.join(`/`),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:c,name:o,compiled:n,alias:r,onlySrc:s,forced:!1}):this.maybeDependencies[e]={uri:c,name:o,compiled:n}};if(this.parserInfo.internalObjects[e]){let n=this.parserInfo.internalObjects[e].fullname,r=[this.build.module,...this.build.namespaces,n].join(`.`);if(n==this.fullName&&(t=!1),this.dependencies[e]={fullName:`$namespace$`+n,uri:`@local`,isStrong:t},$.debug(`add dependence `+e+` : same file`),this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=this.parserInfo.internalObjects[e].isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=e,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,this.parserInfo.internalObjects[e].isCompiled,e)}a(n,e);return}let c=this.parserInfo.importsLocal[e]?.info;if(c){let n=c.fullName,r=[this.build.module,...this.build.namespaces,n].join(`.`);this.dependencies[e]={fullName:`$namespace$`+n,uri:c.fileUri,isStrong:t},$.debug(`add dependency `+e+` : imported file`);let i=this.getNpmReplacementName([this.build.module,n].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=c.isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`));let a=n,o=this.fullName.split(`.`);o.slice(0,1);let l=n.split(`.`)[0];o.includes(l)&&(a=`_.`+a),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=a,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,c.willBeCompiled,i)}a(n,i);return}else if(this.parserInfo.waitingImports[e]){$.debug(`add dependency `+e+` : but waiting import file`),this.parserInfo.waitingImports[e].push(n=>{let r=n.fullName,i=[this.build.module,...this.build.namespaces,r].join(`.`),o=this.getNpmReplacementName([this.build.module,r].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+r;this.isExported!=n.isExported&&(t=this.isExported?[`___`+this.build.module,r].join(`.`):[`globalThis`,this.build.module,r].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=r,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+r,this.dependenciesLocations[e].npmReplacement=o,this.dependenciesLocations[e].hotReloadReplacement=i,s(r,n.willBeCompiled,o)}this.dependencies[e]={fullName:`$namespace$`+r,uri:n.fileUri,isStrong:t},a(r,o)});return}else if(this.parserInfo.packages[e]){let n=this.parserInfo.packages[e].fullname,r=this.build.externalPackageInformation.getNpmUri(n);this.dependencies[e]={fullName:n,uri:`@external`,isStrong:t};let i=this.getNpmReplacementName(n);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].typeRemplacement=n,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=n),r&&this._parserInfo.registerGeneratedImport({uri:r.uri,name:r.name,compiled:r.compiled,alias:i,forced:!1}),a(n,i);return}if(this.parserInfo.npmImports[e]){this.dependencies[e]={fullName:e,uri:`@npm`,isStrong:t},$.debug(`add dependency `+e+` : npm`);let i=ra(this.parserInfo.npmImports[e].uri),o=this.getNpmReplacementName(i+`.`+e);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].replacement=`npmCompilation['`+i+`'].`+e,this.dependenciesLocations[e].docReplacement=`npmCompilation['`+i+`'].`+e,o!=e&&(this.dependenciesLocations[e].npmReplacement=o),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:o,forced:!1}):this.maybeDependencies[e]={uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0}),n>0&&r>0&&(this.dependenciesLocations[e].locations[n+`_`+r].isNpm=!0),a(e,o);return}this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t},$.debug(`add dependency `+e+` : external`),a(e,e)}addDependencyNameCustomCheck(e){return!0}static getContent(e,t,n,r,i){return this._getContent(e,t,n,r,i,1)}static getContentHotReload(e,t,n,r,i){return this._getContent(e,t,n,r,i,2)}static getContentNpm(e,t,n,r,i){return this._getContent(e,t,n,r,i,3)}static getContentDoc(e,t,n,r,i){return this._getContent(e,t,n,r,i,4)}static _getContent(e,t,n,r,i,a){let o=[];for(let e in r){let i=null;a==1?i=r[e].replacement:a==2?i=r[e].hotReloadReplacement:a==3?i=r[e].npmReplacement:a==4&&(i=r[e].docReplacement);let s=r[e].typeRemplacement;if(i)for(let c in r[e].locations){let l=r[e].locations[c];if(l.start>=t&&l.end<=n)if(l.isType&&s&&a!=3)o.push({newText:s,start:l.start-t,end:l.end-t});else if(l.isNpm&&l.isType)continue;else o.push({newText:i,start:l.start-t,end:l.end-t})}}for(let e in i){let r=i[e];r.start>=t&&r.end<=n&&o.push({newText:r.newText,start:r.start-t,end:r.end-t})}o.sort((e,t)=>t.end-e.end);let s=e.length;for(let t of o)t.end>s||(e=e.slice(0,t.start)+t.newText+e.slice(t.end,e.length),s=t.start);return e.replace(/^\s*export\s+(class|interface|enum|type|abstract|function|async)/m,`$1`)}loadStorieContent(){if(this.build.buildConfig.stories&&!this._parserInfo.isExternal){for(let e of this.decorators){let t=lt.is(e);if(t){this.storieDecorator=t;break}}let e=this.build.buildConfig.stories.format;if(this.storieDecorator?this.storieDecorator.exportType?this.storyType=this.storieDecorator.exportType:e?this.storyType=e==`manual`?`all`:e:this.storyType=`none`:e?this.storyType=e==`manual`?`none`:e:this.storyType=`none`,this.storyType==`public`||this.storyType==`protected`?(this.storieDecorator||this.isExported)&&(this.storieContent=this.defineStoryContent(this.storieDecorator)):this.storyType==`all`&&(this.storieContent=this.defineStoryContent(this.storieDecorator)),this.storieContent&&this.build.buildConfig.stories.srcBaseUrl){let e=this.build.project.getConfigFile().uri.replace(w.Config,``),t=I(this.fileUri.replace(e,``)).replace(/\\/g,`/`);this.storieContent.srcUrl=this.build.buildConfig.stories.srcBaseUrl+`/`+t}}}transformTypeForStory(e,t){if(e){if(e.kind==`type`){let n={kind:`simple`,name:e.value};if(e.isArray&&(n.isArray=!0),e.genericValue.length>0){let r=[];for(let n of e.genericValue){let e=this.transformTypeForStory(n,t);e&&r.push(e)}r.length>0&&(n.generics=r)}let r=t.parserInfo.importsLocal[e.value]?.info;if(r)r.storyType!=`none`&&(n.ref=gt.getFullname(r));else{let r=t.parserInfo.internalObjects[e.value];r?.isStoryExported&&(n.ref=r.fullname)}return n}if(e.kind==`any`||e.kind==`never`||e.kind==`unknown`||e.kind==`boolean`||e.kind==`null`||e.kind==`number`||e.kind==`string`||e.kind==`undefined`||e.kind==`void`||e.kind==`object`||e.kind==`symbol`||e.kind==`this`)return{kind:`simple`,name:e.kind};if(e.kind==`literal`)return{kind:`simple`,name:e.value.slice(1,-1)};if(e.kind==`function`||e.kind==`constructor`){if(!e.fctType)return;let t={kind:`function`};if(Object.keys(e.fctType.parameters).length>0){t.parameters=[];for(let n in e.fctType.parameters){let r={name:n},i=this.transformTypeForStory(e.fctType.parameters[n],this);i&&(r.type=i),t.parameters.push(r)}}let n=this.transformTypeForStory(e.fctType.return,this);n&&(t.return=n),e.kind==`constructor`&&(t.isConstructor=!0);let r=e.node;if(r.typeParameters){t.generics=[];for(let e of r.typeParameters){let n={name:e.name.getText()},r=this.transformTypeForStory(new O(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new O(e.constraint),this);i&&(n.constraint=i),t.generics.push(n)}}return t}if(e.kind==`tuple`){let n={kind:`tupple`,tupples:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.tupples.push(e)}return n}if(e.kind==`typeLiteral`){let n={kind:`object`},r=e.node;return(0,p.forEachChild)(r,e=>{if(e.kind==p.SyntaxKind.PropertySignature){let r=e;if(r.type){let e=r.name.getText(),i=new O(r.type),a=this.transformTypeForStory(i,t);a&&(n.keys||={},n.keys[e]=a)}else $.error(`need implements property signature no type `+p.SyntaxKind[e.kind]+` `+t.fileUri)}else if(e.kind==p.SyntaxKind.IndexSignature){let r=e;if(r.parameters.length>0&&r.parameters[0].type){n.indexSignatures||=[];let e=this.transformTypeForStory(new O(r.type),t),i=this.transformTypeForStory(new O(r.parameters[0].type),t);e&&i&&n.indexSignatures.push({keyName:r.parameters[0].name.getText(),keyType:i,type:e})}}else if(e.kind==p.SyntaxKind.TypeLiteral){let r=e,i=this.transformTypeForStory(new O(r),t);i&&(n.array=i)}else $.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri)}),n}if(e.kind==`union`){let n={kind:`union`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`intersection`){let n={kind:`intersection`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`typeOperator`){if(e.nested.length>0){let n=this.transformTypeForStory(e.nested[0],t);if(n)return{kind:`typeOperator`,value:e.value,type:n}}return}if(e.kind==`indexedAccess`){if(e.nested.length==2){let n=this.transformTypeForStory(e.nested[0],t),r=this.transformTypeForStory(e.nested[1],t);if(r&&n)return{kind:`indexAccess`,obj:n,key:r}}return}if(e.kind==`mappedType`){if(e.mappedType){let n=this.transformTypeForStory(e.mappedType.parameterType,t),r=this.transformTypeForStory(e.mappedType.type,t);if(n&&r){let t={kind:`mappedType`,parameterName:e.mappedType.parameterName,parameterType:n,type:r};return e.mappedType.modifier&&(t.modifier=e.mappedType.modifier),t}}return}if(e.kind==`infer`)return{kind:`infer`,name:e.value};if(e.kind==`conditional`){if(e.conditionalType){let n=this.transformTypeForStory(e.conditionalType.check,t),r=this.transformTypeForStory(e.conditionalType.extends,t),i=this.transformTypeForStory(e.conditionalType.true,t),a=this.transformTypeForStory(e.conditionalType.false,t);if(r&&i&&a&&n)return{kind:`conditional`,check:n,extends:r,true:i,false:a}}return}e.kind==`mock`&&$.warning(`mock type`)}}loadGenericForStory(e,t){let n=e.name.getText(),r={name:n};if(t||=this.documentation,t?.documentationTemplates[n]&&(r.documentation=t.documentationTemplates[n]),e.constraint){let t=this.transformTypeForStory(new O(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new O(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new O(e.type),this);return i&&(r.type=i),t||=this.documentation,t?.documentationParameters[n]&&(r.documentation=t.documentationParameters[n]),r}setAccessibilityForStroy(e){this.isExported||(e.accessibility=`internal`)}setNamespaceForStroy(e){this.build.noNamespaceUri[this.fileUri]?this.namespace.length>0&&(e.namespace=this.namespace):(e.namespace=this.build.module,this.namespace.length>0&&(e.namespace+=`.`+this.namespace))}setDocumentationForStroy(e){this.documentation&&(e.documentation=this.documentation.definitions.join(`
236
+ `))}},yt=class extends k{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new O(this.node.type),this.loadOnlyDependenciesRecu(e)}defineStoryContent(){let e={kind:`type`,name:this.name};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=this.transformTypeForStory(new O(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},bt=class e{static is(t){return t.name==`NoCompile`?new e:null}},xt=class e{static is(t){return t.name==`BindThis`?new e:null}},St=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=at.buildDecorator(e,t),this.returnType=new O(e.type);let n=new ut(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)bt.is(e)?this.mustBeCompiled=!1:(r=vt.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;continue}let r=ct.is(e);if(r){n=r;continue}if(xt.is(e)){this.isBindThis=!0;continue}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof st?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof st?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&A.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},Ct=class e{static is(t){if(t.name==`StoryValue`){if(t.arguments.length>0){let n=t.arguments[0].value;return new e(n)}return null}return null}value;constructor(e){this.value=e}},wt=class e{static is(t){return t.name==`NoType`?new e:null}},Tt=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;noType=!1;deprecatedMsg=``;get compiledContent(){return k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:k.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:k.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:k.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=at.buildDecorator(e,n),e.kind==p.SyntaxKind.GetAccessor?this.isGet=!0:e.kind==p.SyntaxKind.SetAccessor?this.isSet=!0:this.isGetSet=!0;let r=new ut(e);r.hasDoc&&(this.documentation=r),e.questionToken&&(this.isNullable=!0),e.exclamationToken&&(this.overrideNullable=!0),this.loadAccessibilityModifier(e),this.type=this.loadType(e),this.loadInitializer(e);for(let e of this.decorators){let t=Ct.is(e);if(t){this.defaultValueStory=t.value;continue}let n=vt.is(e);if(n){this.deprecated=!0,this.deprecatedMsg=n.msg;continue}if(wt.is(e)){this.noType=!0;continue}}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;break}let r=ct.is(e);if(r){n=r;break}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof st?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof st?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&A.addError(e.getStart(),e.getEnd(),`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}loadType(e){let t=e,n;return n=t.type?new O(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new O(t.initializer):new O(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},Et=class e{name=`Fullname`;static is(t){if(t.name==`Convertible`){let n=new e;if(t.arguments.length>0)try{n.name=t.arguments[0].value}catch{}return n}return null}};const Dt=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var Ot=class extends Tt{propType=`Simple`;inParent=!1;arguments},kt=class e extends k{extends=[];extendsNpm=[];implements=[];parentClass=null;methods={};methodsStatic={};properties={};propertiesStatic={};isInterface=!1;isAbstract=!1;constructorBody;constructorParams=[];parameters=[];methodParameters=[];convertibleName=``;extendsType;implementsType=[];extraConstructorCode=[];get isWebcomponent(){return this.implements.includes(`Aventus.DefaultComponent`)&&!this.isInterface}get constructorContent(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
237
237
  `+this.extraConstructorCode.join(`
238
238
  `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
239
239
  `)+` }`}return``}let e=this.constructorBody.getText();return e=k.getContent(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentHotReload(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
@@ -242,18 +242,18 @@ export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.r
242
242
  `)+` }`}return``}let e=this.constructorBody.getText();return e=k.getContentHotReload(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentNpm(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
243
243
  `+this.extraConstructorCode.join(`
244
244
  `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
245
- `)+` }`}return``}let e=this.constructorBody.getText();return e=k.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new wt(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||A.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.GetAccessor){let t=e,r=new wt(t,this.isInterface,this);r.isStatic?this.propertiesStatic[r.name]=r:this.properties[r.name]=r,t.type||A.addError(t.getStart(),t.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.SetAccessor){let t=new wt(e,this.isInterface,this);t.isStatic?this.propertiesStatic[`°set°`+t.name]=t:this.properties[`°set°`+t.name]=t,n=t}else if(e.kind==p.SyntaxKind.MethodDeclaration){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new St(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.MethodSignature){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new St(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.PropertySignature){let r=new wt(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||A.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}if(n&&n.accessibilityModifierTransformation){let e=n.accessibilityModifierTransformation.start+`_`+n.accessibilityModifierTransformation.end;this.compileTransformations[e]=n.accessibilityModifierTransformation}this.loadOnlyDependenciesRecu(e,0,t)}),this.loadConvertible(),this.loadDecorators(),this.addConstructor()}getClassInheritance(t){t.token==p.SyntaxKind.ExtendsKeyword?(0,p.forEachChild)(t,t=>{t.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&(this.extendsType=new O(t)),this.addDependencyWaitName(t,!0,(t,n)=>{if(t.length>0&&(this.extends.push(t[0]),this.extends.length==1)){let n=k.getInfoByFullName(t[0],this);if(n&&n instanceof e&&(this.parentClass=n,this.parentClass==this))throw this.parentClass=null,`The parent is the child => impossible. Please send it to an admin`}n.length>0&&this.extendsNpm.push(n[0])}),(0,p.forEachChild)(t,e=>{this.loadOnlyDependenciesRecu(e,0,!0)}))}):t.token==p.SyntaxKind.ImplementsKeyword&&(0,p.forEachChild)(t,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&this.implementsType.push(new O(e)),this.addDependencyWaitName(e,!0,e=>{if(e.length>0)for(let t of e)this.implements.push(t)}))})}addConstructor(){this.extraConstructorCode=[];let e=this.build.isCoreBuild?`DefaultComponent`:`Aventus.DefaultComponent`;this.implements.includes(e)&&!this.isInterface&&this.isAbstract&&this.extraConstructorCode.push(`if (this.constructor == `+this.name+`) { throw "can't instanciate an abstract class"; }`);for(let e in this.methods)this.methods[e].isBindThis&&this.extraConstructorCode.push(`this.${e}=this.${e}.bind(this)`);if(this.extraConstructorCode.length>0)if(this.constructorBody){let e=this.constructorBody.getEnd()-1,t=e+`_`+e;this.compileTransformations[t]={start:e,end:e,newText:`
245
+ `)+` }`}return``}let e=this.constructorBody.getText();return e=k.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new Tt(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||r.noType||A.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.GetAccessor){let t=e,r=new Tt(t,this.isInterface,this);r.isStatic?this.propertiesStatic[r.name]=r:this.properties[r.name]=r,t.type||r.noType||A.addError(t.getStart(),t.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.SetAccessor){let t=new Tt(e,this.isInterface,this);t.isStatic?this.propertiesStatic[`°set°`+t.name]=t:this.properties[`°set°`+t.name]=t,n=t}else if(e.kind==p.SyntaxKind.MethodDeclaration){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new St(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.MethodSignature){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new St(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.PropertySignature){let r=new Tt(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||r.noType||A.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}if(n&&n.accessibilityModifierTransformation){let e=n.accessibilityModifierTransformation.start+`_`+n.accessibilityModifierTransformation.end;this.compileTransformations[e]=n.accessibilityModifierTransformation}this.loadOnlyDependenciesRecu(e,0,t)}),this.loadConvertible(),this.loadDecorators(),this.addConstructor()}getClassInheritance(t){t.token==p.SyntaxKind.ExtendsKeyword?(0,p.forEachChild)(t,t=>{t.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&(this.extendsType=new O(t)),this.addDependencyWaitName(t,!0,(t,n)=>{if(t.length>0&&(this.extends.push(t[0]),this.extends.length==1)){let n=k.getInfoByFullName(t[0],this);if(n&&n instanceof e&&(this.parentClass=n,this.parentClass==this))throw this.parentClass=null,`The parent is the child => impossible. Please send it to an admin`}n.length>0&&this.extendsNpm.push(n[0])}),(0,p.forEachChild)(t,e=>{this.loadOnlyDependenciesRecu(e,0,!0)}))}):t.token==p.SyntaxKind.ImplementsKeyword&&(0,p.forEachChild)(t,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&this.implementsType.push(new O(e)),this.addDependencyWaitName(e,!0,e=>{if(e.length>0)for(let t of e)this.implements.push(t)}))})}addConstructor(){this.extraConstructorCode=[];let e=this.build.isCoreBuild?`DefaultComponent`:`Aventus.DefaultComponent`;this.implements.includes(e)&&!this.isInterface&&this.isAbstract&&this.extraConstructorCode.push(`if (this.constructor == `+this.name+`) { throw "can't instanciate an abstract class"; }`);for(let e in this.methods)this.methods[e].isBindThis&&this.extraConstructorCode.push(`this.${e}=this.${e}.bind(this)`);if(this.extraConstructorCode.length>0)if(this.constructorBody){let e=this.constructorBody.getEnd()-1,t=e+`_`+e;this.compileTransformations[t]={start:e,end:e,newText:`
246
246
  `+this.extraConstructorCode.join(`
247
247
  `)}}else{let e=this.node.getChildren().find(e=>e.kind==p.SyntaxKind.OpenBraceToken)?.end??0,t=e+`_`+e;if(this.parentClass){let n=this.parentClass.constructorParams.map(e=>e.getText()).join(),r=this.parentClass.constructorParams.map(e=>e.name.getText()).join();this.compileTransformations[t]={start:e,end:e,newText:`constructor(`+n+`) { super(`+r+`);
248
248
  `+this.extraConstructorCode.join(`
249
249
  `)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(`
250
- `)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=Tt.is(t);if(e){this.convertibleName=e.name;return}}e=e.parentClass}}addDependencyNameCustomCheck(e){return!(this.parameters.includes(e)||this.methodParameters.includes(e))}hasStaticField(e){let t=this;for(;t!=null;){if(t.propertiesStatic[e]!=null)return!0;t=t.parentClass}return!1}getStaticFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.propertiesStatic[e]!=null)return t;t=t.parentClass}return null}hasField(e){return this.getField(e)!=null}getField(e){let t=this;for(;t!=null;){if(t.properties[e]!=null)return t.properties[e];t=t.parentClass}return null}getFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.properties[e]!=null)return t;t=t.parentClass}return null}getMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methods[e]!=null)return t;t=t.parentClass}return null}getStaticMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methodsStatic[e]!=null)return t;t=t.parentClass}return null}getEvent(e){let t;e.startsWith(`@`)&&(e=e.slice(1)),t=e.startsWith(`on`)?[e]:[e,`on`+e,`on`+e.charAt(0).toUpperCase()+e.slice(1)];for(let e of t){let t=this;for(;t!=null;){if(t.properties[e]!=null){let n=t.properties[e].type.value;if(Et.includes(n))return t.properties[e]}t=t.parentClass}}return null}defineStoryContent(e){let t={kind:this.isInterface?`interface`:`class`,name:this.name};if(this.setNamespaceForStroy(t),this.setDocumentationForStroy(t),this.setAccessibilityForStroy(t),this.isAbstract&&t.kind==`class`&&(t.modifier=`abstract`),this.extendsType){let e=this.transformTypeForStory(this.extendsType,this);e&&(t.extends=e)}if(this.implementsType.length>0&&t.kind==`class`){t.implements=[];for(let e of this.implementsType){let n=this.transformTypeForStory(e,this);n&&t.implements.push(n)}}if(this.node.typeParameters){t.generics=[];for(let e of this.node.typeParameters)t.generics.push(this.loadGenericForStory(e))}for(let e in this.methods)this.addMethodStoryContent(t,this.methods[e]);for(let e in this.methodsStatic)this.addMethodStoryContent(t,this.methodsStatic[e]);for(let e in this.properties)this.addPropertyStoryContent(t,this.properties[e]);for(let e in this.propertiesStatic)this.addPropertyStoryContent(t,this.propertiesStatic[e]);return t}addMethodStoryContent(e,t){if(!this.canAddToStory(t))return;let n=[this.build.module,this.fullName].join(`.`);if(t.name.startsWith(`__`+na(n)+`method`))return;e.methods||=[];let r={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.methods.push(r);let i=e=>{r.modifiers||=[],r.modifiers.push(e)};if(t.documentation&&(r.documentation=t.documentation.definitions.join(`
250
+ `)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=Et.is(t);if(e){this.convertibleName=e.name;return}}e=e.parentClass}}addDependencyNameCustomCheck(e){return!(this.parameters.includes(e)||this.methodParameters.includes(e))}hasStaticField(e){let t=this;for(;t!=null;){if(t.propertiesStatic[e]!=null)return!0;t=t.parentClass}return!1}getStaticFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.propertiesStatic[e]!=null)return t;t=t.parentClass}return null}hasField(e){return this.getField(e)!=null}getField(e){let t=this;for(;t!=null;){if(t.properties[e]!=null)return t.properties[e];t=t.parentClass}return null}getFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.properties[e]!=null)return t;t=t.parentClass}return null}getMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methods[e]!=null)return t;t=t.parentClass}return null}getStaticMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methodsStatic[e]!=null)return t;t=t.parentClass}return null}getEvent(e){let t;e.startsWith(`@`)&&(e=e.slice(1)),t=e.startsWith(`on`)?[e]:[e,`on`+e,`on`+e.charAt(0).toUpperCase()+e.slice(1)];for(let e of t){let t=this;for(;t!=null;){if(t.properties[e]!=null){let n=t.properties[e].type.value;if(Dt.includes(n))return t.properties[e]}t=t.parentClass}}return null}defineStoryContent(e){let t={kind:this.isInterface?`interface`:`class`,name:this.name};if(this.setNamespaceForStroy(t),this.setDocumentationForStroy(t),this.setAccessibilityForStroy(t),this.isAbstract&&t.kind==`class`&&(t.modifier=`abstract`),this.extendsType){let e=this.transformTypeForStory(this.extendsType,this);e&&(t.extends=e)}if(this.implementsType.length>0&&t.kind==`class`){t.implements=[];for(let e of this.implementsType){let n=this.transformTypeForStory(e,this);n&&t.implements.push(n)}}if(this.node.typeParameters){t.generics=[];for(let e of this.node.typeParameters)t.generics.push(this.loadGenericForStory(e))}for(let e in this.methods)this.addMethodStoryContent(t,this.methods[e]);for(let e in this.methodsStatic)this.addMethodStoryContent(t,this.methodsStatic[e]);for(let e in this.properties)this.addPropertyStoryContent(t,this.properties[e]);for(let e in this.propertiesStatic)this.addPropertyStoryContent(t,this.propertiesStatic[e]);return t}addMethodStoryContent(e,t){if(!this.canAddToStory(t))return;let n=[this.build.module,this.fullName].join(`.`);if(t.name.startsWith(`__`+ra(n)+`method`))return;e.methods||=[];let r={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.methods.push(r);let i=e=>{r.modifiers||=[],r.modifiers.push(e)};if(t.documentation&&(r.documentation=t.documentation.definitions.join(`
251
251
  `)),t.isAbstract&&i(`abstract`),t.isOverride&&i(`override`),t.isStatic&&i(`static`),t.node.typeParameters){r.generics=[];for(let e of t.node.typeParameters)r.generics.push(this.loadGenericForStory(e,t.documentation))}if(t.node.parameters.length>0){r.parameters=[];for(let e of t.node.parameters)r.parameters.push(this.loadParameterForStory(e,t.documentation))}if(t.node.type){let e=new O(t.node.type),n=this.transformTypeForStory(e,this);if(n){let e={type:n};t.documentation?.documentationReturn&&(e.documentation=t.documentation?.documentationReturn),r.return=e}}}addPropertyStoryContent(e,t){if(!this.canAddToStory(t))return;e.properties||=[];let n={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.properties.push(n),t.documentation&&(n.documentation=t.documentation.definitions.join(`
252
- `));let r=e=>{n.modifiers||=[],n.modifiers.push(e)};t.isOverride&&r(`override`),t.isAbstract&&r(`abstract`),t.isGet&&r(`readonly`),t.isSet&&r(`writeonly`),t.isStatic&&r(`static`);let i=this.transformTypeForStory(t.type,this);i&&(n.type=i)}canAddToStory(e){if(!this.build.buildConfig.stories)return!1;let t=this.storyType;return t==`public`?e.isPrivate||e.isProtected?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`protected`?e.isPrivate?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`all`?e.decorators.find(e=>e.name==`NoStory`)===void 0:!1}mergeClassInfo(e){for(let t of e.extends)this.extends.includes(t)||this.extends.push(t);for(let t of e.implements)this.implements.includes(t)||this.implements.push(t);this.methods={...e.methods,...this.methods},this.methodsStatic={...e.methodsStatic,...this.methodsStatic},this.properties={...e.properties,...this.properties},this.propertiesStatic={...e.propertiesStatic,...this.propertiesStatic},this.useNormalDecorator=e.useNormalDecorator}},kt=class extends k{node;constructor(e,t,n){super(e,t,n,!1),this.infoType=6,this.node=e}defineStoryContent(){let e={kind:`enum`,name:this.name,properties:[]};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=0;for(let n of this.node.members){let r={name:n.name.getText()},i;n.initializer?(i=(0,eval)(n.initializer.getText()),t=i+1):i=t++,r.value=i+``;let a=new ut(n);a.hasDoc&&(r.documentation=a.definitions.join(`
253
- `)),e.properties.push(r)}return e}},At=class{start=0;end=0;name=``;bodyStart=0;bodyEnd=0;constructor(e){this.name=e.name.getText(),this.start=e.getStart(),this.end=e.getEnd(),e.body&&(this.bodyStart=e.body.getStart()+1,this.bodyEnd=e.body.getEnd()-1)}},jt=class extends k{node;constructor(e,t,n){if(super(e,t,n),this.node=e,this.infoType=4,e.typeParameters)for(let t of e.typeParameters)this.preventDependencyAdd(t.name.getText()),t.constraint&&this.addDependency(t.constraint,!0);for(let t of e.parameters)t.type&&this.addDependency(t.type,!1);(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.Block&&this.loadOnlyDependenciesRecu(e,0,!1)})}defineStoryContent(){let e={kind:`function`,name:this.name};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}if(this.node.parameters.length>0){e.parameters=[];for(let t of this.node.parameters)e.parameters.push(this.loadParameterForStory(t))}if(this.node.type){let t=new O(this.node.type),n=this.transformTypeForStory(t,this);if(n){let t={type:n};this.documentation?.documentationReturn&&(t.documentation=this.documentation.documentationReturn),e.return=t}}return e}},Mt=class extends k{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=at.buildDecorator(r,this),this.node=e,this.infoType=5,e.parent.flags==p.NodeFlags.Let?this.type=`let`:e.parent.flags==p.NodeFlags.Const&&(this.type=`const`),this.isExported=k.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(st.is(e)){this.isExported=!1;break}this.loadOnlyDependenciesRecu(e,0,!0)}defineStoryContent(){let e={kind:`variable`,name:this.name,modifier:this.type==`const`?`const`:this.type==`let`?`let`:`var`};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.type){let t=new O(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},A=class e{static waitingUri={};static parsedDoc={};static parse(t,n,r){return e.parsedDoc[t.uri]&&this.parsedDoc[t.uri].version==t.versionInternal?this.parsedDoc[t.uri].result:(new e(t,n,r),e.parsedDoc[t.uri].result)}static parsingDocs=[];static get currentParsingDoc(){return this.parsingDocs.length>0?this.parsingDocs[this.parsingDocs.length-1]:null}static addError(e,t,n){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
252
+ `));let r=e=>{n.modifiers||=[],n.modifiers.push(e)};t.isOverride&&r(`override`),t.isAbstract&&r(`abstract`),t.isGet&&r(`readonly`),t.isSet&&r(`writeonly`),t.isStatic&&r(`static`);let i=this.transformTypeForStory(t.type,this);i&&(n.type=i)}canAddToStory(e){if(!this.build.buildConfig.stories)return!1;let t=this.storyType;return t==`public`?e.isPrivate||e.isProtected?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`protected`?e.isPrivate?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`all`?e.decorators.find(e=>e.name==`NoStory`)===void 0:!1}mergeClassInfo(e){for(let t of e.extends)this.extends.includes(t)||this.extends.push(t);for(let t of e.implements)this.implements.includes(t)||this.implements.push(t);this.methods={...e.methods,...this.methods},this.methodsStatic={...e.methodsStatic,...this.methodsStatic},this.properties={...e.properties,...this.properties},this.propertiesStatic={...e.propertiesStatic,...this.propertiesStatic},this.useNormalDecorator=e.useNormalDecorator}},At=class extends k{node;constructor(e,t,n){super(e,t,n,!1),this.infoType=6,this.node=e}defineStoryContent(){let e={kind:`enum`,name:this.name,properties:[]};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=0;for(let n of this.node.members){let r={name:n.name.getText()},i;n.initializer?(i=(0,eval)(n.initializer.getText()),t=i+1):i=t++,r.value=i+``;let a=new ut(n);a.hasDoc&&(r.documentation=a.definitions.join(`
253
+ `)),e.properties.push(r)}return e}},jt=class{start=0;end=0;name=``;bodyStart=0;bodyEnd=0;constructor(e){this.name=e.name.getText(),this.start=e.getStart(),this.end=e.getEnd(),e.body&&(this.bodyStart=e.body.getStart()+1,this.bodyEnd=e.body.getEnd()-1)}},Mt=class extends k{node;constructor(e,t,n){if(super(e,t,n),this.node=e,this.infoType=4,e.typeParameters)for(let t of e.typeParameters)this.preventDependencyAdd(t.name.getText()),t.constraint&&this.addDependency(t.constraint,!0);for(let t of e.parameters)t.type&&this.addDependency(t.type,!1);(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.Block&&this.loadOnlyDependenciesRecu(e,0,!1)})}defineStoryContent(){let e={kind:`function`,name:this.name};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}if(this.node.parameters.length>0){e.parameters=[];for(let t of this.node.parameters)e.parameters.push(this.loadParameterForStory(t))}if(this.node.type){let t=new O(this.node.type),n=this.transformTypeForStory(t,this);if(n){let t={type:n};this.documentation?.documentationReturn&&(t.documentation=this.documentation.documentationReturn),e.return=t}}return e}},Nt=class extends k{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=at.buildDecorator(r,this),this.node=e,this.infoType=5,e.parent.flags==p.NodeFlags.Let?this.type=`let`:e.parent.flags==p.NodeFlags.Const&&(this.type=`const`),this.isExported=k.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(st.is(e)){this.isExported=!1;break}this.loadOnlyDependenciesRecu(e,0,!0)}defineStoryContent(){let e={kind:`variable`,name:this.name,modifier:this.type==`const`?`const`:this.type==`let`?`let`:`var`};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.type){let t=new O(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},A=class e{static waitingUri={};static parsedDoc={};static parse(t,n,r){return e.parsedDoc[t.uri]&&this.parsedDoc[t.uri].version==t.versionInternal?this.parsedDoc[t.uri].result:(new e(t,n,r),e.parsedDoc[t.uri].result)}static parsingDocs=[];static get currentParsingDoc(){return this.parsingDocs.length>0?this.parsingDocs[this.parsingDocs.length-1]:null}static addError(e,t,n){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
254
254
  `)};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
255
- `)};this.currentParsingDoc.errors.push(r)}}static getBaseInfo(t,n){let r;if(n)r=this.parsedDoc[n]?.result;else{if(!e.currentParsingDoc)return null;r=e.currentParsingDoc}if(!r)return null;if(r.internalObjects[t]){let e=r.getBaseInfo(t);if(e)return e}if(r.importsLocal[t]?.info)return r.importsLocal[t].info;if(r.packages[t]){let e=r.packages[t].fullname,n=r.build.externalPackageInformation.getByFullName(e);if(n){let t=this.parsedDoc[n.uri].result.getBaseInfo(e);if(t)return t}}for(let e in this.parsedDoc){let n=this.parsedDoc[e].result.getBaseInfo(t);if(n)return n}return null}static hasImport(t){return e.currentParsingDoc?!!(e.currentParsingDoc.importsLocal[t]||e.currentParsingDoc.waitingImports[t]||e.currentParsingDoc.npmImports[t]||e.currentParsingDoc.packages[t]):!1}static hasLocal(t){return e.currentParsingDoc?!!e.currentParsingDoc.internalObjects[t]:!1}content;errors=[];_document;get document(){return this._document}currentNamespace=[];namespaces=[];classes={};functions={};enums={};importsLocal={};manualImportLocal={};packages={};npmImports={};npmGeneratedImport={};internalObjects={};waitingImports={};aliases={};variables={};isExternal=!1;isReady=!1;build;file;srcFile;npmAliases={};deprecated=[];constructor(t,n,r){this.build=r,this.build.npmBuilder.unregister(t.documentUser.uri),this.file=t,e.parsedDoc[t.uri]={version:t.versionInternal,result:this},e.parsingDocs.push(this),this.content=t.documentInternal.getText(),this._document=t.documentInternal,this.isExternal=n;let i=(0,p.createSourceFile)(`sample.ts`,this.content,p.ScriptTarget.ESNext,!0);this.srcFile=i,this.quickLoadRoot(i),this.loadRoot(i),e.parsingDocs.pop(),this.isReady=!0;for(let e of this.readyCb)e();if(this.readyCb=[],e.waitingUri[t.uri]){for(let n of e.waitingUri[t.uri])n();delete e.waitingUri[t.uri]}}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}quickLoadRoot(e){(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration){let t=e;tt(t.flags,p.NodeFlags.Namespace)&&t.body?(this.currentNamespace.push(t.name.getText()),this.quickLoadRoot(t),this.currentNamespace.splice(this.currentNamespace.length-1,1)):tt(t.flags,p.NodeFlags.GlobalAugmentation)&&t.body&&this.quickLoadRoot(t)}else if(e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration){let t=e;if(t.name){let n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:e.kind==p.SyntaxKind.ClassDeclaration}}}else if(e.kind==p.SyntaxKind.EnumDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!1}}else if(e.kind==p.SyntaxKind.FunctionDeclaration){let t=e;if(t.name){let e=t.name.getText();this.internalObjects[e]={fullname:[...this.currentNamespace,e].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}}else if(e.kind==p.SyntaxKind.VariableStatement){let t=e;for(let e of t.declarationList.declarations)if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}}else e.kind==p.SyntaxKind.ModuleBlock&&this.quickLoadRoot(e)})}loadRoot(e){(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ImportDeclaration?this.loadImport(e):e.kind==p.SyntaxKind.ModuleDeclaration?this.loadNamespace(e):e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration?this.loadClass(e):e.kind==p.SyntaxKind.EnumDeclaration?this.loadEnum(e):e.kind==p.SyntaxKind.TypeAliasDeclaration?this.loadAlias(e):e.kind==p.SyntaxKind.FunctionDeclaration?this.loadFunction(e):e.kind==p.SyntaxKind.VariableStatement?this.loadVariableStatement(e):e.kind==p.SyntaxKind.ModuleBlock?this.loadRoot(e):(e.kind,p.SyntaxKind.EndOfFileToken)})}loadImport(e){_t.Parse(e,this.file,this)}loadNamespace(e){tt(e.flags,p.NodeFlags.Namespace)&&e.body?(this.namespaces.push(new At(e)),this.currentNamespace.push(e.name.getText()),this.loadRoot(e),this.currentNamespace.splice(this.currentNamespace.length-1,1)):tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body?this.loadRoot(e):this.errors.push({range:m.Range.create(this.document.positionAt(e.getStart()),this.document.positionAt(e.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`Can't use a module, use namespace instead`,`
256
- `)})}loadDeprecated(e){for(let t in e){let n=e[t];n.deprecated&&this.deprecated.push({start:n.nameStart,end:n.nameEnd,msg:n.deprecatedMsg})}}loadClass(e){if(e.name){let t=new Ot(e,this.currentNamespace,this),n=this.isExternal?t.fullName:t.name;this.classes[n]?t.isInterface?this.classes[n].mergeClassInfo(t):(t.mergeClassInfo(this.classes[n]),this.classes[n]=t):this.classes[n]=t,this.defineStorie(this.classes[n]),this.loadDeprecated({[t.name]:t}),this.loadDeprecated(t.methods),this.loadDeprecated(t.methodsStatic),this.loadDeprecated(t.properties),this.loadDeprecated(t.propertiesStatic)}}loadFunction(e){if(e.name){let t=new jt(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.functions[n]=t,this.loadDeprecated({[t.name]:t})}}loadEnum(e){let t=new kt(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.enums[n]=t,this.loadDeprecated({[t.name]:t})}loadAlias(e){let t=new yt(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.aliases[n]=t,this.loadDeprecated({[t.name]:t})}loadVariableStatement(e){k.isExported(e);for(let t of e.declarationList.declarations)t.kind==p.SyntaxKind.VariableDeclaration&&(t.jsDoc=e.jsDoc,this.loadVariable(t,e))}loadVariable(e,t){let n=new Mt(e,this.currentNamespace,this,t);this.defineStorie(n);let r=this.isExternal?n.fullName:n.name;this.variables[r]=n,this.loadDeprecated({[n.name]:n})}defineStorie(e){e.loadStorieContent()}getBaseInfo(e){return this.classes[e]?this.classes[e]:this.aliases[e]?this.aliases[e]:this.enums[e]?this.enums[e]:this.functions[e]?this.functions[e]:this.variables[e]?this.variables[e]:null}getBaseInfoFullName(e){let t=e.split(`.`).pop()??e;return this.getBaseInfo(t)}registerGeneratedImport(e){if(!this.build.hasNpmOutput)return;let{uri:t,name:n,compiled:r,alias:i,onlySrc:a,nameAlias:o,forced:s}=e,c=n==i?void 0:i;this.npmGeneratedImport[t]?this.npmGeneratedImport[t].findIndex(e=>e.name==n)==-1&&this.npmGeneratedImport[t].push({name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}):this.npmGeneratedImport[t]=[{name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}]}getNpmReplacementName(e,t){return this.build.getNpmReplacementName(e,t)}},Nt=class extends De{get tsLanguageService(){return this.build.tsLanguageService}_compileResult=[];get compileResult(){return this._compileResult}diagnostics=[];getDiagnostics(){return[...this.diagnostics]}get version(){return this.file.versionUser}get versionInternal(){return this.file.versionInternal}fileParsed=null;get contentForLanguageService(){return this._contentForLanguageService}_contentForLanguageService=``;buildNamespace=``;deprecated={};deprecatedUris=[];constructor(e,t){super(e,t),this.buildNamespace=this.build.getNamespace(e.uri),this.mustBeAddedToLanguageService()&&this.tsLanguageService.addFile(this)}refreshFileParsed(e=!1){this.fileParsed=A.parse(this.file,e,this.build),this._contentForLanguageService=this.file.documentInternal.getText(),this.refreshDeprecated(!0),e||this.replaceNamespace()}async refreshDeprecated(e){}getDeprecated(){let e=[];for(let t in this.deprecated)for(let n of this.deprecated[t])e.push({message:n.msg,range:n.range});return e}replaceNamespace(){if(this.fileParsed)for(let e of this.fileParsed.namespaces){let t=e.bodyStart-e.start,n=``;for(let e=0;e<t;e++)n+=` `;let r=this._contentForLanguageService.substring(0,e.start),i=this._contentForLanguageService.substring(e.bodyStart,this._contentForLanguageService.length);this._contentForLanguageService=r+n+i,t=e.end-e.bodyEnd,n=``;for(let e=0;e<t;e++)n+=` `;r=this._contentForLanguageService.substring(0,e.bodyEnd),i=this._contentForLanguageService.substring(e.end,this._contentForLanguageService.length),this._contentForLanguageService=r+n+i}}validateRules(e){let t=this.fileParsed;if(t){if(!e.allow_function)for(let e in t.functions){let n=t.functions[e];this.diagnostics.push(L(this.file.documentInternal,`Function can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1020))}if(!e.allow_variables)for(let e in t.variables){let n=t.variables[e];this.diagnostics.push(L(this.file.documentInternal,`Variables can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1021))}if(e.class_extend||e.class_implement||e.interface||e.customClassRules){e.class_extend||=[],e.class_implement||=[],e.interface||=[],e.customClassRules||=[];for(let n in t.classes){let r=t.classes[n];for(let t of e.customClassRules)t(r);if(r.isInterface){let t=e.interface.length==0;for(let n of r.extends)if(e.interface.indexOf(n)!=-1){t=!0;break}t||this.diagnostics.push(L(this.file.documentInternal,`Interface `+r.name+` must extend `+e.interface.join(` or `),r.nameStart,r.nameEnd,1017))}else{let t=e.class_extend.length==0,n=e.class_implement.length==0;for(let t of r.implements)if(e.class_implement.indexOf(t)!=-1){n=!0;break}for(let n of r.extends)if(e.class_extend.indexOf(n)!=-1){t=!0;break}n||this.diagnostics.push(L(this.file.documentInternal,`Class `+r.name+` must implement `+e.class_implement.join(` or `),r.nameStart,r.nameEnd,1018)),t||this.diagnostics.push(L(this.file.documentInternal,`Class `+r.name+` must extend `+e.class_extend.join(` or `),r.nameStart,r.nameEnd,1017))}}}e.enum,e.alias}}async onDelete(){this.mustBeAddedToLanguageService()&&this.tsLanguageService.removeFile(this),this.build.npmBuilder.unregister(this.file.uri)}oldFullSrc=[];oldFullDocVisible=``;oldFullDocInvisible=``;oldFullClassScript=``;setCompileResult(e){let t=!1,n=``,r=[],i=``,a=``,o=``;for(let t of e)n+=t.compiled,t.classScript!=``&&r.push({name:t.classScript,src:t.compiled}),i+=t.docVisible,a+=t.docInvisible,o+=t.classScript+`#`;let s=``;for(let e of this.oldFullSrc)s+=e.src;e.length==this.compileResult.length&&this.oldFullClassScript==o&&s==n&&this.oldFullDocVisible==i?this.oldFullDocInvisible!=a&&(t=!0):t=!0;let c=this.oldFullSrc;t&&(this.oldFullDocInvisible=a,this.oldFullDocVisible=i,this.oldFullSrc=r,this.oldFullClassScript=o),this._compileResult=e,t&&(this.emitToHtttpServer(c),this.build.build())}mustBeAddedToLanguageService(){return!0}emitToHtttpServer(e){this.build.reloadPage=!0}onGetBuild(){return[this.build]}};function Pt(){return`$namespaceStart$$fullname$ = class $classname$ extends $parentClass$ {
255
+ `)};this.currentParsingDoc.errors.push(r)}}static getBaseInfo(t,n){let r;if(n)r=this.parsedDoc[n]?.result;else{if(!e.currentParsingDoc)return null;r=e.currentParsingDoc}if(!r)return null;if(r.internalObjects[t]){let e=r.getBaseInfo(t);if(e)return e}if(r.importsLocal[t]?.info)return r.importsLocal[t].info;if(r.packages[t]){let e=r.packages[t].fullname,n=r.build.externalPackageInformation.getByFullName(e);if(n){let t=this.parsedDoc[n.uri].result.getBaseInfo(e);if(t)return t}}for(let e in this.parsedDoc){let n=this.parsedDoc[e].result.getBaseInfo(t);if(n)return n}return null}static hasImport(t){return e.currentParsingDoc?!!(e.currentParsingDoc.importsLocal[t]||e.currentParsingDoc.waitingImports[t]||e.currentParsingDoc.npmImports[t]||e.currentParsingDoc.packages[t]):!1}static hasLocal(t){return e.currentParsingDoc?!!e.currentParsingDoc.internalObjects[t]:!1}content;errors=[];_document;get document(){return this._document}currentNamespace=[];namespaces=[];classes={};functions={};enums={};importsLocal={};manualImportLocal={};packages={};npmImports={};npmGeneratedImport={};internalObjects={};waitingImports={};aliases={};variables={};isExternal=!1;isReady=!1;build;file;srcFile;npmAliases={};deprecated=[];constructor(t,n,r){this.build=r,this.build.npmBuilder.unregister(t.documentUser.uri),this.file=t,e.parsedDoc[t.uri]={version:t.versionInternal,result:this},e.parsingDocs.push(this),this.content=t.documentInternal.getText(),this._document=t.documentInternal,this.isExternal=n;let i=(0,p.createSourceFile)(`sample.ts`,this.content,p.ScriptTarget.ESNext,!0);this.srcFile=i,this.quickLoadRoot(i),this.loadRoot(i),e.parsingDocs.pop(),this.isReady=!0;for(let e of this.readyCb)e();if(this.readyCb=[],e.waitingUri[t.uri]){for(let n of e.waitingUri[t.uri])n();delete e.waitingUri[t.uri]}}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}quickLoadRoot(e){(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration){let t=e;tt(t.flags,p.NodeFlags.Namespace)&&t.body?(this.currentNamespace.push(t.name.getText()),this.quickLoadRoot(t),this.currentNamespace.splice(this.currentNamespace.length-1,1)):tt(t.flags,p.NodeFlags.GlobalAugmentation)&&t.body&&this.quickLoadRoot(t)}else if(e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration){let t=e;if(t.name){let n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:e.kind==p.SyntaxKind.ClassDeclaration}}}else if(e.kind==p.SyntaxKind.EnumDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!1}}else if(e.kind==p.SyntaxKind.FunctionDeclaration){let t=e;if(t.name){let e=t.name.getText();this.internalObjects[e]={fullname:[...this.currentNamespace,e].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}}else if(e.kind==p.SyntaxKind.VariableStatement){let t=e;for(let e of t.declarationList.declarations)if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:k.isExported(t),isStoryExported:this.build.buildConfig.stories?k.isStoryExported(t,this.build):!1,isCompiled:!0}}}else e.kind==p.SyntaxKind.ModuleBlock&&this.quickLoadRoot(e)})}loadRoot(e){(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ImportDeclaration?this.loadImport(e):e.kind==p.SyntaxKind.ModuleDeclaration?this.loadNamespace(e):e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration?this.loadClass(e):e.kind==p.SyntaxKind.EnumDeclaration?this.loadEnum(e):e.kind==p.SyntaxKind.TypeAliasDeclaration?this.loadAlias(e):e.kind==p.SyntaxKind.FunctionDeclaration?this.loadFunction(e):e.kind==p.SyntaxKind.VariableStatement?this.loadVariableStatement(e):e.kind==p.SyntaxKind.ModuleBlock?this.loadRoot(e):(e.kind,p.SyntaxKind.EndOfFileToken)})}loadImport(e){_t.Parse(e,this.file,this)}loadNamespace(e){tt(e.flags,p.NodeFlags.Namespace)&&e.body?(this.namespaces.push(new jt(e)),this.currentNamespace.push(e.name.getText()),this.loadRoot(e),this.currentNamespace.splice(this.currentNamespace.length-1,1)):tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body?this.loadRoot(e):this.errors.push({range:m.Range.create(this.document.positionAt(e.getStart()),this.document.positionAt(e.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`Can't use a module, use namespace instead`,`
256
+ `)})}loadDeprecated(e){for(let t in e){let n=e[t];n.deprecated&&this.deprecated.push({start:n.nameStart,end:n.nameEnd,msg:n.deprecatedMsg})}}loadClass(e){if(e.name){let t=new kt(e,this.currentNamespace,this),n=this.isExternal?t.fullName:t.name;this.classes[n]?t.isInterface?this.classes[n].mergeClassInfo(t):(t.mergeClassInfo(this.classes[n]),this.classes[n]=t):this.classes[n]=t,this.defineStorie(this.classes[n]),this.loadDeprecated({[t.name]:t}),this.loadDeprecated(t.methods),this.loadDeprecated(t.methodsStatic),this.loadDeprecated(t.properties),this.loadDeprecated(t.propertiesStatic)}}loadFunction(e){if(e.name){let t=new Mt(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.functions[n]=t,this.loadDeprecated({[t.name]:t})}}loadEnum(e){let t=new At(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.enums[n]=t,this.loadDeprecated({[t.name]:t})}loadAlias(e){let t=new yt(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.aliases[n]=t,this.loadDeprecated({[t.name]:t})}loadVariableStatement(e){k.isExported(e);for(let t of e.declarationList.declarations)t.kind==p.SyntaxKind.VariableDeclaration&&(t.jsDoc=e.jsDoc,this.loadVariable(t,e))}loadVariable(e,t){let n=new Nt(e,this.currentNamespace,this,t);this.defineStorie(n);let r=this.isExternal?n.fullName:n.name;this.variables[r]=n,this.loadDeprecated({[n.name]:n})}defineStorie(e){e.loadStorieContent()}getBaseInfo(e){return this.classes[e]?this.classes[e]:this.aliases[e]?this.aliases[e]:this.enums[e]?this.enums[e]:this.functions[e]?this.functions[e]:this.variables[e]?this.variables[e]:null}getBaseInfoFullName(e){let t=e.split(`.`).pop()??e;return this.getBaseInfo(t)}registerGeneratedImport(e){if(!this.build.hasNpmOutput)return;let{uri:t,name:n,compiled:r,alias:i,onlySrc:a,nameAlias:o,forced:s}=e,c=n==i?void 0:i;this.npmGeneratedImport[t]?this.npmGeneratedImport[t].findIndex(e=>e.name==n)==-1&&this.npmGeneratedImport[t].push({name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}):this.npmGeneratedImport[t]=[{name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}]}getNpmReplacementName(e,t){return this.build.getNpmReplacementName(e,t)}},Pt=class extends De{get tsLanguageService(){return this.build.tsLanguageService}_compileResult=[];get compileResult(){return this._compileResult}diagnostics=[];getDiagnostics(){return[...this.diagnostics]}get version(){return this.file.versionUser}get versionInternal(){return this.file.versionInternal}fileParsed=null;get contentForLanguageService(){return this._contentForLanguageService}_contentForLanguageService=``;buildNamespace=``;deprecated={};deprecatedUris=[];constructor(e,t){super(e,t),this.buildNamespace=this.build.getNamespace(e.uri),this.mustBeAddedToLanguageService()&&this.tsLanguageService.addFile(this)}refreshFileParsed(e=!1){this.fileParsed=A.parse(this.file,e,this.build),this._contentForLanguageService=this.file.documentInternal.getText(),this.refreshDeprecated(!0),e||this.replaceNamespace()}async refreshDeprecated(e){}getDeprecated(){let e=[];for(let t in this.deprecated)for(let n of this.deprecated[t])e.push({message:n.msg,range:n.range});return e}replaceNamespace(){if(this.fileParsed)for(let e of this.fileParsed.namespaces){let t=e.bodyStart-e.start,n=``;for(let e=0;e<t;e++)n+=` `;let r=this._contentForLanguageService.substring(0,e.start),i=this._contentForLanguageService.substring(e.bodyStart,this._contentForLanguageService.length);this._contentForLanguageService=r+n+i,t=e.end-e.bodyEnd,n=``;for(let e=0;e<t;e++)n+=` `;r=this._contentForLanguageService.substring(0,e.bodyEnd),i=this._contentForLanguageService.substring(e.end,this._contentForLanguageService.length),this._contentForLanguageService=r+n+i}}validateRules(e){let t=this.fileParsed;if(t){if(!e.allow_function)for(let e in t.functions){let n=t.functions[e];this.diagnostics.push(L(this.file.documentInternal,`Function can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1020))}if(!e.allow_variables)for(let e in t.variables){let n=t.variables[e];this.diagnostics.push(L(this.file.documentInternal,`Variables can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1021))}if(e.class_extend||e.class_implement||e.interface||e.customClassRules){e.class_extend||=[],e.class_implement||=[],e.interface||=[],e.customClassRules||=[];for(let n in t.classes){let r=t.classes[n];for(let t of e.customClassRules)t(r);if(r.isInterface){let t=e.interface.length==0;for(let n of r.extends)if(e.interface.indexOf(n)!=-1){t=!0;break}t||this.diagnostics.push(L(this.file.documentInternal,`Interface `+r.name+` must extend `+e.interface.join(` or `),r.nameStart,r.nameEnd,1017))}else{let t=e.class_extend.length==0,n=e.class_implement.length==0;for(let t of r.implements)if(e.class_implement.indexOf(t)!=-1){n=!0;break}for(let n of r.extends)if(e.class_extend.indexOf(n)!=-1){t=!0;break}n||this.diagnostics.push(L(this.file.documentInternal,`Class `+r.name+` must implement `+e.class_implement.join(` or `),r.nameStart,r.nameEnd,1018)),t||this.diagnostics.push(L(this.file.documentInternal,`Class `+r.name+` must extend `+e.class_extend.join(` or `),r.nameStart,r.nameEnd,1017))}}}e.enum,e.alias}}async onDelete(){this.mustBeAddedToLanguageService()&&this.tsLanguageService.removeFile(this),this.build.npmBuilder.unregister(this.file.uri)}oldFullSrc=[];oldFullDocVisible=``;oldFullDocInvisible=``;oldFullClassScript=``;setCompileResult(e){let t=!1,n=``,r=[],i=``,a=``,o=``;for(let t of e)n+=t.compiled,t.classScript!=``&&r.push({name:t.classScript,src:t.compiled}),i+=t.docVisible,a+=t.docInvisible,o+=t.classScript+`#`;let s=``;for(let e of this.oldFullSrc)s+=e.src;e.length==this.compileResult.length&&this.oldFullClassScript==o&&s==n&&this.oldFullDocVisible==i?this.oldFullDocInvisible!=a&&(t=!0):t=!0;let c=this.oldFullSrc;t&&(this.oldFullDocInvisible=a,this.oldFullDocVisible=i,this.oldFullSrc=r,this.oldFullClassScript=o),this._compileResult=e,t&&(this.emitToHtttpServer(c),this.build.build())}mustBeAddedToLanguageService(){return!0}emitToHtttpServer(e){this.build.reloadPage=!0}onGetBuild(){return[this.build]}};function Ft(){return`$namespaceStart$$fullname$ = class $classname$ extends $parentClass$ {
257
257
  $watchingAttributes$
258
258
 
259
259
  $getterSetterAttr$
@@ -298,18 +298,18 @@ $tag$
298
298
  $exported$
299
299
  $definition$
300
300
  $namespaceEnd$
301
- `}var Ft=class e{writeCompiled=!1;enableWatchHistory=!1;writeHTML=!1;writeComponentTs=!1;static is(t){if(t.name==`Debugger`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);n.writeCompiled=e.writeCompiled==1,n.enableWatchHistory=e.enableWatchHistory==1,n.writeHTML=e.writeHTML==1,n.writeComponentTs=e.writeComponentTs==1}catch{}return n}return null}},It=class e{static is(t){return t.name==`Required`?new e:null}},Lt=class{static allChanges=[];static currentElement;static correct(e,t){var n=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0);if(this.allChanges=[],t instanceof Ot&&!this.currentElement){this.currentElement=t,(0,p.forEachChild)(n,e=>{var n=e.kind===p.SyntaxKind.InterfaceDeclaration,r=e.kind===p.SyntaxKind.ClassDeclaration;if(!(!n&&!r)){var i=e;for(let e of t.decorators)e.name!=`Debugger`&&this.addChange(e.content+`
301
+ `}var It=class e{writeCompiled=!1;enableWatchHistory=!1;writeHTML=!1;writeComponentTs=!1;static is(t){if(t.name==`Debugger`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);n.writeCompiled=e.writeCompiled==1,n.enableWatchHistory=e.enableWatchHistory==1,n.writeHTML=e.writeHTML==1,n.writeComponentTs=e.writeComponentTs==1}catch{}return n}return null}},Lt=class e{static is(t){return t.name==`Required`?new e:null}},Rt=class{static allChanges=[];static currentElement;static correct(e,t){var n=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0);if(this.allChanges=[],t instanceof kt&&!this.currentElement){this.currentElement=t,(0,p.forEachChild)(n,e=>{var n=e.kind===p.SyntaxKind.InterfaceDeclaration,r=e.kind===p.SyntaxKind.ClassDeclaration;if(!(!n&&!r)){var i=e;for(let e of t.decorators)e.name!=`Debugger`&&this.addChange(e.content+`
302
302
  `,i.getStart(),i.getStart());if(i.typeParameters&&i.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),i.heritageClauses)for(let e of i.heritageClauses)this.correctClassInheritance(e);(0,p.forEachChild)(i,e=>{e.kind==p.SyntaxKind.Constructor||e.kind==p.SyntaxKind.MethodDeclaration?this.correctMethod(e):(e.kind==p.SyntaxKind.PropertyDeclaration||e.kind==p.SyntaxKind.GetAccessor||e.kind==p.SyntaxKind.SetAccessor)&&this.correctProperty(e)})}}),this.allChanges.sort((e,t)=>t.end-e.end);for(let t of this.allChanges)e=e.slice(0,t.start)+t.value+e.slice(t.end,e.length);this.currentElement=null}return e}static correctClassInheritance(e){(e.token==p.SyntaxKind.ExtendsKeyword||e.token==p.SyntaxKind.ImplementsKeyword)&&(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&this.correctType(e)})}static correctMethod(e){if(e.type&&this.correctType(e.type),e.typeParameters&&e.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),e.parameters.forEach(e=>{this.correctType(e.type)}),e.name){if(!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.methods[t]??this.currentElement.methodsStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`
303
303
  `,e.getStart(),e.getStart())}}}static correctProperty(e){if(e.type&&this.correctType(e.type),!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.properties[t]??this.currentElement.propertiesStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`
304
- `,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},Rt=class e{refType=``;constructor(e){this.refType=e}static is(t){if(t.name==`ForeignKey`&&t.arguments.length>0)try{if(t.arguments[0].type==`identifier`)return new e(t.arguments[0].value)}catch{}return null}},zt=class extends De{static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(e.contentUser);if(t)return{name:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])}}}}catch(e){console.error(e)}}tsFile=null;tsDef=null;srcInfo={namespace:``,available:[],existing:[]};externalCSS={};name=``;npmUri=``;description=``;version={major:1,minor:0,patch:0};get versionTxt(){return this.version.major+`.`+this.version.minor+`.`+this.version.patch}get classInfoByName(){return this.tsDef?.classInfoByName||{}}get fileParsed(){return this.tsDef?.fileParsed||null}get definition(){return this.tsFile.contentUser}dependencies={};constructor(e,t){super(e,t),this.prepareFile()}async refreshDeprecated(e){this.tsDef&&await this.tsDef.refreshDeprecated(e)}loadWebComponents(){this.tsDef?.loadWebComponents()}prepareFile(){let e=this.separeSection();if(e){let t=d.TextDocument.create(this.file.uri,C.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new E(t),this.tsDef=new Bt(this.tsFile,this.build));try{this.srcInfo=JSON.parse(e.jsSrc)}catch{}try{let t=JSON.parse(e.scssDefTxt);this.build.scssLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.externalCSS=JSON.parse(e.scssTxt)}catch{}try{let t=JSON.parse(e.htmlTxt);this.build.htmlLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.dependencies=JSON.parse(e.depsTxt)}catch{}this.build.externalPackageInformation.rebuild()}}separeSection(){if(this.file.contentUser.match(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//g)){let e=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(this.file.contentUser);e&&(this.name=e[1],this.version.major=Number(e[2]),this.version.minor=Number(e[3]),this.version.patch=Number(e[4]));let t=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),n=``;t&&(n=t[0]);let r=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),i=``;r&&(i=r[1]);let a=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),o=``;a&&(o=a[1]);let s=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),c=``;s&&(c=s[1]);let l=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),u=``;l&&(u=l[1]);let d=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),f=``;return d&&(f=d[1]),{jsDef:n,jsSrc:i,scssDefTxt:c,scssTxt:o,htmlTxt:u,depsTxt:f}}return null}async onContentChange(){this.prepareFile(),this.build.reloadPage=!0,this.build.build()}async onValidate(){return[]}async onSave(){}async onDelete(){this.build.scssLanguageService.removeExternalDefinition(this.file.uri),this.build.htmlLanguageService.removeExternalDefinition(this.file.uri),this.tsFile&&this.tsFile.triggerDelete()}async onCompletion(e,t){return{isIncomplete:!0,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.tsFile?this.tsFile.getHover(t):null}async onDefinition(e,t){return this.tsFile?await this.tsFile.getDefinition(t):null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return this.tsFile?this.tsFile.getReferences(t):[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}transformPosition(e,t,n,r){let i=e.file.documentUser.offsetAt(t);return n.file.documentUser.positionAt(i-r)}},Bt=class extends Nt{_classInfoByName={};packagesFiles=[];get extension(){return w.Package}get classInfoByName(){return this._classInfoByName}constructor(e,t){super(e,t)}loadWebComponents(){try{this.refreshFileParsed(!0);let e=this.fileParsed;if(e){this.loadFilePackage();for(let t in e.classes){let n=e.classes[t],r=!1;for(let e of n.implements){if(e==`Aventus.DefaultComponent`){r=!0;break}if(e==`Aventus.IData`)break}r&&(this._classInfoByName[n.fullName]=n)}}}catch(e){let t=this.file.uri.split(`/`),n=t[t.length-1];$.showErrorMessage(`There is an error inside file :`+n),$.error(e)}}loadFilePackage(){try{this.deletePackageFile();let e=this.fileParsed;if(e){let t={},n=e=>{for(let n in e){let r=e[n],i=r.fullName.split(`.`);i.pop();let a=i.join(`.`);t[a]||(t[a]={text:``,parts:[]});let o=t[a].text.length;t[a].text+=`export import ${r.name} = ${r.fullName};
305
- `,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(w.Package,``)+`:`+e+w.Package;this.packagesFiles.push(new Vt(t[e],n,this.build,this))}}}catch(e){$.error(e)}}deletePackageFile(){let e=[...this.packagesFiles];this.packagesFiles=[];for(let t of e)t.internalFile.triggerDelete()}async onContentChange(){this.loadWebComponents()}async onValidate(){return[]}async onSave(){}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 this.tsLanguageService.findDefinition(e,t)}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}async onDelete(){await super.onDelete()}},Vt=class extends Nt{get extension(){return w.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new E(d.TextDocument.create(`file:///`+t,C.TypeScript,1,e.text));i.triggerDelete(),super(i,n),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}async goToDefinition(e){let t=this.file.documentInternal.offsetAt(e.start),n=this.file.documentInternal.offsetAt(e.end),r=n-t;for(let e of this.info.parts)if(t>=e.startVirtual&&n<=e.endVirtual){let n=t-e.startVirtual,i=e.startDef+n-7,a=i+r,o=this.packageFile.file.documentInternal.positionAt(i),s=this.packageFile.file.documentInternal.positionAt(a);return[{uri:this.packageFile.file.uri,range:{start:o,end:s}}]}return null}async onContentChange(){}async onValidate(){return[]}async onSave(){}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}},Ht=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Ze(),this.onSettingsChanged(e),P.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=P.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Qe((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>Ut,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),fileExists:e=>(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!$e(e)),directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>Ut,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=$e(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!$e(e);return t},directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(!r.startsWith(`.`)&&r.endsWith(w.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=R.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,Ut,e);if(i.resolvedModule)i.resolvedModule.resolvedFileName.endsWith(`.avt.ts`)&&(i.resolvedModule.resolvedFileName=i.resolvedModule.resolvedFileName.replace(`.avt.ts`,`.avt`)),s.push(i.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.file.uri)==-1&&(this.filesNeeded.push(e.file.uri),this.filesLoaded[e.file.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.file.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.file.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
306
- `)}`;r.reportsUnnecessary?n.push({range:Ki(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Ki(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=Ki(n,Zi(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Gt)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:qt(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){try{if(e.data){let t=this.build.tsFiles[e.data.uri];if(t!=null){let n={languageId:e.data.languageIdJs,offset:e.data.offset,uri:e.data.uri};delete e.data.languageId,delete e.data.offset,delete e.data.uri,Object.keys(e.data).length==0&&(e.data=void 0);let r=this.languageService.getCompletionEntryDetails(n.uri,n.offset,e.label,{},t.file.contentInternal,Gt,e.data);if(r){if(e.detail=(0,p.displayPartsToString)(r.displayParts),e.documentation=(0,p.displayPartsToString)(r.documentation),e.additionalTextEdits=[],r.codeActions)for(let n=0;n<r.codeActions.length;n++)for(let i of r.codeActions[n].changes)for(let n of i.textChanges){n.newText=Ni(n.newText.replace(/'/g,`"`));let r=/"(.*)"/g.exec(n.newText);if(r&&r.length>1){if(r[0].includes(w.Package)){let e=r[1];e=this.filesNeeded.find(t=>t.toLowerCase()==e)??e,e=e.replace(`file:///`,``).replace(/\.\.\//g,``),n.newText=n.newText.replace(r[1],e)}else if(r[1].startsWith(`.`)){let i=this.simplifyPath(r[1],t.file.uri);e.detail+=`
307
- import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:Ki(t.file.documentInternal,n.span)})}delete e.data}}}}catch(e){this.printCatchError(e)}return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(`&nbsp;`);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
304
+ `,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},zt=class e{refType=``;constructor(e){this.refType=e}static is(t){if(t.name==`ForeignKey`&&t.arguments.length>0)try{if(t.arguments[0].type==`identifier`)return new e(t.arguments[0].value)}catch{}return null}},Bt=class extends De{static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(e.contentUser);if(t)return{name:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])}}}}catch(e){console.error(e)}}tsFile=null;tsDef=null;srcInfo={namespace:``,available:[],existing:[]};externalCSS={};name=``;npmUri=``;description=``;version={major:1,minor:0,patch:0};get versionTxt(){return this.version.major+`.`+this.version.minor+`.`+this.version.patch}get classInfoByName(){return this.tsDef?.classInfoByName||{}}get fileParsed(){return this.tsDef?.fileParsed||null}get definition(){return this.tsFile.contentUser}dependencies={};constructor(e,t){super(e,t),this.prepareFile()}async refreshDeprecated(e){this.tsDef&&await this.tsDef.refreshDeprecated(e)}loadWebComponents(){this.tsDef?.loadWebComponents()}prepareFile(){let e=this.separeSection();if(e){let t=d.TextDocument.create(this.file.uri,C.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new E(t),this.tsDef=new Vt(this.tsFile,this.build));try{this.srcInfo=JSON.parse(e.jsSrc)}catch{}try{let t=JSON.parse(e.scssDefTxt);this.build.scssLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.externalCSS=JSON.parse(e.scssTxt)}catch{}try{let t=JSON.parse(e.htmlTxt);this.build.htmlLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.dependencies=JSON.parse(e.depsTxt)}catch{}this.build.externalPackageInformation.rebuild()}}separeSection(){if(this.file.contentUser.match(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//g)){let e=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(this.file.contentUser);e&&(this.name=e[1],this.version.major=Number(e[2]),this.version.minor=Number(e[3]),this.version.patch=Number(e[4]));let t=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),n=``;t&&(n=t[0]);let r=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),i=``;r&&(i=r[1]);let a=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),o=``;a&&(o=a[1]);let s=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),c=``;s&&(c=s[1]);let l=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),u=``;l&&(u=l[1]);let d=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),f=``;return d&&(f=d[1]),{jsDef:n,jsSrc:i,scssDefTxt:c,scssTxt:o,htmlTxt:u,depsTxt:f}}return null}async onContentChange(){this.prepareFile(),this.build.reloadPage=!0,this.build.build()}async onValidate(){return[]}async onSave(){}async onDelete(){this.build.scssLanguageService.removeExternalDefinition(this.file.uri),this.build.htmlLanguageService.removeExternalDefinition(this.file.uri),this.tsFile&&this.tsFile.triggerDelete()}async onCompletion(e,t){return{isIncomplete:!0,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.tsFile?this.tsFile.getHover(t):null}async onDefinition(e,t){return this.tsFile?await this.tsFile.getDefinition(t):null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return this.tsFile?this.tsFile.getReferences(t):[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}transformPosition(e,t,n,r){let i=e.file.documentUser.offsetAt(t);return n.file.documentUser.positionAt(i-r)}},Vt=class extends Pt{_classInfoByName={};packagesFiles=[];get extension(){return w.Package}get classInfoByName(){return this._classInfoByName}constructor(e,t){super(e,t)}loadWebComponents(){try{this.refreshFileParsed(!0);let e=this.fileParsed;if(e){this.loadFilePackage();for(let t in e.classes){let n=e.classes[t],r=!1;for(let e of n.implements){if(e==`Aventus.DefaultComponent`){r=!0;break}if(e==`Aventus.IData`)break}r&&(this._classInfoByName[n.fullName]=n)}}}catch(e){let t=this.file.uri.split(`/`),n=t[t.length-1];$.showErrorMessage(`There is an error inside file :`+n),$.error(e)}}loadFilePackage(){try{this.deletePackageFile();let e=this.fileParsed;if(e){let t={},n=e=>{for(let n in e){let r=e[n],i=r.fullName.split(`.`);i.pop();let a=i.join(`.`);t[a]||(t[a]={text:``,parts:[]});let o=t[a].text.length;t[a].text+=`export import ${r.name} = ${r.fullName};
305
+ `,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(w.Package,``)+`:`+e+w.Package;this.packagesFiles.push(new Ht(t[e],n,this.build,this))}}}catch(e){$.error(e)}}deletePackageFile(){let e=[...this.packagesFiles];this.packagesFiles=[];for(let t of e)t.internalFile.triggerDelete()}async onContentChange(){this.loadWebComponents()}async onValidate(){return[]}async onSave(){}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 this.tsLanguageService.findDefinition(e,t)}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}async onDelete(){await super.onDelete()}},Ht=class extends Pt{get extension(){return w.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new E(d.TextDocument.create(`file:///`+t,C.TypeScript,1,e.text));i.triggerDelete(),super(i,n),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}async goToDefinition(e){let t=this.file.documentInternal.offsetAt(e.start),n=this.file.documentInternal.offsetAt(e.end),r=n-t;for(let e of this.info.parts)if(t>=e.startVirtual&&n<=e.endVirtual){let n=t-e.startVirtual,i=e.startDef+n-7,a=i+r,o=this.packageFile.file.documentInternal.positionAt(i),s=this.packageFile.file.documentInternal.positionAt(a);return[{uri:this.packageFile.file.uri,range:{start:o,end:s}}]}return null}async onContentChange(){}async onValidate(){return[]}async onSave(){}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}},Ut=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Ze(),this.onSettingsChanged(e),P.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=P.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Qe((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>Wt,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),fileExists:e=>(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!$e(e)),directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>Wt,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=$e(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!$e(e);return t},directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(!r.startsWith(`.`)&&r.endsWith(w.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=R.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,Wt,e);if(i.resolvedModule)i.resolvedModule.resolvedFileName.endsWith(`.avt.ts`)&&(i.resolvedModule.resolvedFileName=i.resolvedModule.resolvedFileName.replace(`.avt.ts`,`.avt`)),s.push(i.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.file.uri)==-1&&(this.filesNeeded.push(e.file.uri),this.filesLoaded[e.file.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.file.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.file.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
306
+ `)}`;r.reportsUnnecessary?n.push({range:qi(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:qi(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=qi(n,Qi(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Kt)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Jt(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){try{if(e.data){let t=this.build.tsFiles[e.data.uri];if(t!=null){let n={languageId:e.data.languageIdJs,offset:e.data.offset,uri:e.data.uri};delete e.data.languageId,delete e.data.offset,delete e.data.uri,Object.keys(e.data).length==0&&(e.data=void 0);let r=this.languageService.getCompletionEntryDetails(n.uri,n.offset,e.label,{},t.file.contentInternal,Kt,e.data);if(r){if(e.detail=(0,p.displayPartsToString)(r.displayParts),e.documentation=(0,p.displayPartsToString)(r.documentation),e.additionalTextEdits=[],r.codeActions)for(let n=0;n<r.codeActions.length;n++)for(let i of r.codeActions[n].changes)for(let n of i.textChanges){n.newText=Pi(n.newText.replace(/'/g,`"`));let r=/"(.*)"/g.exec(n.newText);if(r&&r.length>1){if(r[0].includes(w.Package)){let e=r[1];e=this.filesNeeded.find(t=>t.toLowerCase()==e)??e,e=e.replace(`file:///`,``).replace(/\.\.\//g,``),n.newText=n.newText.replace(r[1],e)}else if(r[1].startsWith(`.`)){let i=this.simplifyPath(r[1],t.file.uri);e.detail+=`
307
+ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:qi(t.file.documentInternal,n.span)})}delete e.data}}}}catch(e){this.printCatchError(e)}return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(`&nbsp;`);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
308
308
  \`\`\`
309
309
  ***
310
310
  `),i+=t.join(`
311
311
 
312
- `),{range:Ki(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}getType(e,t){try{let n=this.languageService.getProgram();if(!n)return;let r=n.getSourceFile(e.file.uri);if(!r)return;let i=n.getTypeChecker(),a=(0,p.getTokenAtPosition)(r,t),o=i.getTypeAtLocation(a),s=e=>{if(e.isUnion()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` | `)}else if(e.isIntersection()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` & `)}else if(e.isNumberLiteral())return e.value+``;else if(e.isStringLiteral())return`"`+e.value+`"`;else if(e.isLiteral())return e.value+``;return i.typeToString(e,a,p.TypeFormatFlags.UseFullyQualifiedType)},c=s(o);if(c.includes(`.`))return c;if(e.fileParsed)for(let t in e.fileParsed.importsLocal){if(t==c)return c;let n=e.fileParsed.importsLocal[t];if(n.realName===void 0){let e=(0,p.getTokenAtPosition)(r,(n.nameEnd+n.nameStart)/2),t=i.getTypeAtLocation(e);n.realName=i.typeToString(t)}if(c==n.realName)return t}return c}catch(e){this.printCatchError(e)}}async findDefinition(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.getDefinitionAtPosition(e.uri,r);if(i&&i.length>0){for(let e of i){e.fileName.endsWith(`.avt.ts`)&&(e.fileName=e.fileName.replace(`.avt.ts`,`.avt`));let t=this.filesLoaded[e.fileName];if(t instanceof Vt){let r=await t.goToDefinition(Ki(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:Ki(t.file.documentInternal,e.textSpan)});else{let t=$e(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:Ki(r,e.textSpan)})}}}return n}else if(i&&i.length==0){let t=this.languageService.getProgram();if(t){let i=t.getSourceFile(e.uri);if(i){let a=t.getTypeChecker(),o=(0,p.getTokenAtPosition)(i,r),s=a.getTypeAtLocation(o);if(s.isStringLiteral()){let t=e=>{for(let t in this.i18nFiles){let r=this.i18nFiles[t];if(r.parsed&&r.parsed[e]){let i=r.file.documentUser.positionAt(r.parsed[e].keyStart),a=r.file.documentUser.positionAt(r.parsed[e].keyEnd);n.push({uri:t,range:m.Range.create(i,a)})}}},r=o.parent.getText();if(r.startsWith(`t(`)){let e=s.value;t(e)}else if(r.startsWith(`this.t(`)){let r=s.value,i=this.build.tsFiles[e.uri];if(i instanceof j&&i.I18nFile?.parsed&&i.I18nFile?.parsed[r]){let e=i.I18nFile,t=i.I18nFile.parsed[r],a=e.file.documentUser.positionAt(t.keyStart),o=e.file.documentUser.positionAt(t.keyEnd);n.push({uri:i.I18nFile.file.uri,range:m.Range.create(a,o)})}t(r)}}}}}}catch(e){this.printCatchError(e)}return n}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||Jt(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...Kt};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageServiceNamespace.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:Ki(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Yt(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=A.parse(e,!1,this.build),i=e.documentInternal,a=this.languageService.getSyntacticDiagnostics(i.uri),o=this.languageService.getSemanticDiagnostics(i.uri),s=[];for(let e of a)s.push(e.code);for(let e of o)e.code!=6133&&s.push(e.code);let c=[];try{c=this.languageService.getCodeFixesAtPosition(i.uri,i.offsetAt(t.start),i.offsetAt(t.end),s,Kt,Gt)}catch{}for(let t of c){let a=[],o={changes:{[i.uri]:a}};for(let n of t.changes)for(let o of n.textChanges){if(t.description.startsWith(`Add import from`)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,o.newText=o.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Zt(e,`methods`);t!=-1&&(o.span.start=t),o.newText.match(/ (public|protected) /g)||(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText.match(/(public|protected)[ ]*?override/g)||(o.newText=o.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Zt(e,`methods`);t!=-1&&(o.span.start=t),!o.newText.includes(` protected `)&&!o.newText.includes(` public `)&&(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}a.push({newText:o.newText,range:Ki(i,o.span)})}n.push({title:t.description,edit:o})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.findReferences(e.uri,r);if(i){for(let e of i)for(let t of e.references)if(this.filesLoaded[t.fileName]){let e=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start),r=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start+t.textSpan.length);n.push(m.Location.create(t.fileName,{start:e,end:r}))}}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){let t=[];try{let n=this.filesLoaded[e.uri];if(n&&n.fileParsed){let r=async n=>{for(let r of n){let n=e.documentInternal.positionAt(r.start),i=await this.onReferences(e,n),a=i.length>1?i.length+` references`:i.length+` reference`;t.push({range:{start:n,end:n},command:{title:a,command:i.length?`editor.action.showReferences`:``,arguments:[e.uri,n,i]}})}};await r(Object.values(n.fileParsed.classes)),await r(Object.values(n.fileParsed.enums)),await r(Object.values(n.fileParsed.aliases))}let r=Zt(e,`props`);if(r!=-1){let n=e.documentInternal.positionAt(r);t.push({range:{start:n,end:n},command:{title:`Add property | attribute`,command:`editor.action.showReferences`,arguments:[e.uri]}})}}catch(e){this.printCatchError(e)}return t}async onRename(e,t,n){this.languageService.getFileReferences(e.uri);let r=e.documentInternal.offsetAt(t),i={};if(!this.languageService.getRenameInfo(e.uri,r,i).canRename)return null;let a=this.languageService.findRenameLocations(e.uri,r,!1,!1,i);if(!a)return null;let o={changes:{}};if(o.changes){for(let e of a)if(this.filesLoaded[e.fileName]){o.changes[e.fileName]||(o.changes[e.fileName]=[]);let t={newText:n,range:{start:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start),end:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}};o.changes[e.fileName].push(t)}}return o}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=R.getInstance().getByUri(e.fileName);if(r){let i=[],a=r.folderUri.split(`/`),o=t.split(`/`);for(;a.length>0&&o.length>0&&a[0]==o[0];)a.splice(0,1),o.splice(0,1);let s=[];if(a.length>0)for(let e=0;e<a.length;e++)s.push(`..`);else s.push(`.`);for(let e of o)s.push(e);i.push({newText:s.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}}),n[r.uri]=i}}return n}static removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>n?``:t),e}static removeEmptyComments(e){return e=e.replace(/\/\*. \*\//gm,(e,t,n)=>n?``:t),e}static prepareDataSchema(e,t,n){let r={},i=r=>{let i=(()=>{if(r.kind==`boolean`)return`boolean`;if(r.kind==`number`)return`number`;if(r.kind==`string`)return`string`;if(r.kind==`type`){if(r.value.includes(`.`))return r.value;{let i=e.parserInfo.importsLocal[r.value]?.info;return i?n?i.name:t+`.`+i.fullName:r.value}}else if(r.kind==`literal`||r.kind==`typeLiteral`)return`literal`;return null})();return i&&r.isArray&&(i+=`[]`),i};for(let a in e.properties){let o=e.properties[a];if(o.isStatic)continue;let s=!1;for(let i of o.decorators){let o=Rt.is(i);if(o){s=!0;let i=e.parserInfo.importsLocal[o.refType]?.info;o.refType.includes(`.`)?r[a]=`ref:`+o.refType:i?r[a]=`ref:`+(n?i.name:t+`.`+i.fullName):r[a]=`ref:`+o.refType}}if(!s){let e=i(o.type);e&&(r[a]=e)}}let a=JSON.stringify(r).replace(/\\"/g,`"`);return e.parentClass&&(a=`{...(${n?e.extendsNpm[0]:e.parentClass.fullName}?.$schema ?? {}), ${a.slice(1)}`),a}static compileTs(e,t){let n={compiled:``,hotReload:``,docVisible:``,docInvisible:``,dependencies:Object.values(e.dependencies),classScript:``,classDoc:``,debugTxt:``,uri:t.file.uri,required:!1,type:e.infoType,isExported:{external:e.isExported,internal:e.isInternalExported},convertibleName:``,npm:{defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},useDecorator:!1};try{let r=``,i=``,a=e.compiledContent,o=e.compiledContentDoc,s=e.compiledContentHotReload,c=t.build.module;if(e instanceof Ot&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
312
+ `),{range:qi(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}getType(e,t){try{let n=this.languageService.getProgram();if(!n)return;let r=n.getSourceFile(e.file.uri);if(!r)return;let i=n.getTypeChecker(),a=(0,p.getTokenAtPosition)(r,t),o=i.getTypeAtLocation(a),s=e=>{if(e.isUnion()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` | `)}else if(e.isIntersection()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` & `)}else if(e.isNumberLiteral())return e.value+``;else if(e.isStringLiteral())return`"`+e.value+`"`;else if(e.isLiteral())return e.value+``;return i.typeToString(e,a,p.TypeFormatFlags.UseFullyQualifiedType)},c=s(o);if(c.includes(`.`))return c;if(e.fileParsed)for(let t in e.fileParsed.importsLocal){if(t==c)return c;let n=e.fileParsed.importsLocal[t];if(n.realName===void 0){let e=(0,p.getTokenAtPosition)(r,(n.nameEnd+n.nameStart)/2),t=i.getTypeAtLocation(e);n.realName=i.typeToString(t)}if(c==n.realName)return t}return c}catch(e){this.printCatchError(e)}}async findDefinition(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.getDefinitionAtPosition(e.uri,r);if(i&&i.length>0){for(let e of i){e.fileName.endsWith(`.avt.ts`)&&(e.fileName=e.fileName.replace(`.avt.ts`,`.avt`));let t=this.filesLoaded[e.fileName];if(t instanceof Ht){let r=await t.goToDefinition(qi(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:qi(t.file.documentInternal,e.textSpan)});else{let t=$e(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:qi(r,e.textSpan)})}}}return n}else if(i&&i.length==0){let t=this.languageService.getProgram();if(t){let i=t.getSourceFile(e.uri);if(i){let a=t.getTypeChecker(),o=(0,p.getTokenAtPosition)(i,r),s=a.getTypeAtLocation(o);if(s.isStringLiteral()){let t=e=>{for(let t in this.i18nFiles){let r=this.i18nFiles[t];if(r.parsed&&r.parsed[e]){let i=r.file.documentUser.positionAt(r.parsed[e].keyStart),a=r.file.documentUser.positionAt(r.parsed[e].keyEnd);n.push({uri:t,range:m.Range.create(i,a)})}}},r=o.parent.getText();if(r.startsWith(`t(`)){let e=s.value;t(e)}else if(r.startsWith(`this.t(`)){let r=s.value,i=this.build.tsFiles[e.uri];if(i instanceof j&&i.I18nFile?.parsed&&i.I18nFile?.parsed[r]){let e=i.I18nFile,t=i.I18nFile.parsed[r],a=e.file.documentUser.positionAt(t.keyStart),o=e.file.documentUser.positionAt(t.keyEnd);n.push({uri:i.I18nFile.file.uri,range:m.Range.create(a,o)})}t(r)}}}}}}catch(e){this.printCatchError(e)}return n}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||Yt(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...qt};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageServiceNamespace.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:qi(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Xt(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=A.parse(e,!1,this.build),i=e.documentInternal,a=this.languageService.getSyntacticDiagnostics(i.uri),o=this.languageService.getSemanticDiagnostics(i.uri),s=[];for(let e of a)s.push(e.code);for(let e of o)e.code!=6133&&s.push(e.code);let c=[];try{c=this.languageService.getCodeFixesAtPosition(i.uri,i.offsetAt(t.start),i.offsetAt(t.end),s,qt,Kt)}catch{}for(let t of c){let a=[],o={changes:{[i.uri]:a}};for(let n of t.changes)for(let o of n.textChanges){if(t.description.startsWith(`Add import from`)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,o.newText=o.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Qt(e,`methods`);t!=-1&&(o.span.start=t),o.newText.match(/ (public|protected) /g)||(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText.match(/(public|protected)[ ]*?override/g)||(o.newText=o.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Qt(e,`methods`);t!=-1&&(o.span.start=t),!o.newText.includes(` protected `)&&!o.newText.includes(` public `)&&(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}a.push({newText:o.newText,range:qi(i,o.span)})}n.push({title:t.description,edit:o})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.findReferences(e.uri,r);if(i){for(let e of i)for(let t of e.references)if(this.filesLoaded[t.fileName]){let e=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start),r=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start+t.textSpan.length);n.push(m.Location.create(t.fileName,{start:e,end:r}))}}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){let t=[];try{let n=this.filesLoaded[e.uri];if(n&&n.fileParsed){let r=async n=>{for(let r of n){let n=e.documentInternal.positionAt(r.start),i=await this.onReferences(e,n),a=i.length>1?i.length+` references`:i.length+` reference`;t.push({range:{start:n,end:n},command:{title:a,command:i.length?`editor.action.showReferences`:``,arguments:[e.uri,n,i]}})}};await r(Object.values(n.fileParsed.classes)),await r(Object.values(n.fileParsed.enums)),await r(Object.values(n.fileParsed.aliases))}let r=Qt(e,`props`);if(r!=-1){let n=e.documentInternal.positionAt(r);t.push({range:{start:n,end:n},command:{title:`Add property | attribute`,command:`editor.action.showReferences`,arguments:[e.uri]}})}}catch(e){this.printCatchError(e)}return t}async onRename(e,t,n){this.languageService.getFileReferences(e.uri);let r=e.documentInternal.offsetAt(t),i={};if(!this.languageService.getRenameInfo(e.uri,r,i).canRename)return null;let a=this.languageService.findRenameLocations(e.uri,r,!1,!1,i);if(!a)return null;let o={changes:{}};if(o.changes){for(let e of a)if(this.filesLoaded[e.fileName]){o.changes[e.fileName]||(o.changes[e.fileName]=[]);let t={newText:n,range:{start:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start),end:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}};o.changes[e.fileName].push(t)}}return o}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=R.getInstance().getByUri(e.fileName);if(r){let i=[],a=r.folderUri.split(`/`),o=t.split(`/`);for(;a.length>0&&o.length>0&&a[0]==o[0];)a.splice(0,1),o.splice(0,1);let s=[];if(a.length>0)for(let e=0;e<a.length;e++)s.push(`..`);else s.push(`.`);for(let e of o)s.push(e);i.push({newText:s.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}}),n[r.uri]=i}}return n}static removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>n?``:t),e}static removeEmptyComments(e){return e=e.replace(/\/\*. \*\//gm,(e,t,n)=>n?``:t),e}static prepareDataSchema(e,t,n){let r={},i=r=>{let i=(()=>{if(r.kind==`boolean`)return`boolean`;if(r.kind==`number`)return`number`;if(r.kind==`string`)return`string`;if(r.kind==`type`){if(r.value.includes(`.`))return r.value;{let i=e.parserInfo.importsLocal[r.value]?.info;return i?n?i.name:t+`.`+i.fullName:r.value}}else if(r.kind==`literal`||r.kind==`typeLiteral`)return`literal`;return null})();return i&&r.isArray&&(i+=`[]`),i};for(let a in e.properties){let o=e.properties[a];if(o.isStatic)continue;let s=!1;for(let i of o.decorators){let o=zt.is(i);if(o){s=!0;let i=e.parserInfo.importsLocal[o.refType]?.info;o.refType.includes(`.`)?r[a]=`ref:`+o.refType:i?r[a]=`ref:`+(n?i.name:t+`.`+i.fullName):r[a]=`ref:`+o.refType}}if(!s){let e=i(o.type);e&&(r[a]=e)}}let a=JSON.stringify(r).replace(/\\"/g,`"`);return e.parentClass&&(a=`{...(${n?e.extendsNpm[0]:e.parentClass.fullName}?.$schema ?? {}), ${a.slice(1)}`),a}static compileTs(e,t){let n={compiled:``,hotReload:``,docVisible:``,docInvisible:``,dependencies:Object.values(e.dependencies),classScript:``,classDoc:``,debugTxt:``,uri:t.file.uri,required:!1,type:e.infoType,isExported:{external:e.isExported,internal:e.isInternalExported},convertibleName:``,npm:{defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},useDecorator:!1};try{let r=``,i=``,a=e.compiledContent,o=e.compiledContentDoc,s=e.compiledContentHotReload,c=t.build.module;if(e instanceof kt&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
313
313
  `,i+=e.name+".Namespace=`"+c+a+`\`;
314
314
  `,e.implements.includes(t+`IData`)&&(n.type=2),e.convertibleName?(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;
315
315
  `,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
@@ -319,29 +319,29 @@ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push(
319
319
  `,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
320
320
  `,r+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
321
321
  `,i+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
322
- `),n.convertibleName=e.convertibleName}else e instanceof Mt&&(a=e.type+` `+e.compiledContent,o=e.type+` `+e.compiledContentDoc,s=e.type+` `+e.compiledContentHotReload);if(e.name==`MainState`)debugger;a=this.removeComments(a);let l=(0,p.transpile)(a,Wt);if(e.useNormalDecorator){let t=RegExp(`^var(\\s|\\S)*?let `+e.name+` = `,`gm`);l=l.replace(t,``),n.useDecorator=!0}n.compiled=l+r,D.isRunning&&(s=this.removeComments(s),n.hotReload=(0,p.transpile)(s,Wt)),o=this.removeEmptyComments(o);let u=this.compileDocTs(o,e),d=Lt.correct(u,e),f=this.compileTsToNpm(e,t);if(f&&(n.npm=f),d.length>0){let t=e.namespace;t.length>0&&(u=`namespace `+t+` {
322
+ `),n.convertibleName=e.convertibleName}else e instanceof Nt&&(a=e.type+` `+e.compiledContent,o=e.type+` `+e.compiledContentDoc,s=e.type+` `+e.compiledContentHotReload);if(e.name==`MainState`)debugger;a=this.removeComments(a);let l=(0,p.transpile)(a,Gt);if(e.useNormalDecorator){let t=RegExp(`^var(\\s|\\S)*?let `+e.name+` = `,`gm`);l=l.replace(t,``),n.useDecorator=!0}n.compiled=l+r,D.isRunning&&(s=this.removeComments(s),n.hotReload=(0,p.transpile)(s,Gt)),o=this.removeEmptyComments(o);let u=this.compileDocTs(o,e),d=Rt.correct(u,e),f=this.compileTsToNpm(e,t);if(f&&(n.npm=f),d.length>0){let t=e.namespace;t.length>0&&(u=`namespace `+t+` {
323
323
  `+u+`}
324
324
  `,d=`namespace `+t+` {
325
325
  `+d+`}
326
326
  `),e.isExported?n.docVisible=d:n.docInvisible=d}let m=()=>{let r=``,i=t.build.namespaces.includes(e.fullName);i&&(r+=`_n = `+e.fullName+`;
327
- `);let a=n.compiled;if(e instanceof Mt)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof kt){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.replace(/\r\n?/g,`
327
+ `);let a=n.compiled;if(e instanceof Nt)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof At){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.replace(/\r\n?/g,`
328
328
  `).split(`
329
329
  `);e.splice(0,1),a=e.join(`
330
330
  `)}}else a=e.fullName+`=`+n.compiled,e.fullName.includes(`.`)||(a=`let ${a}`);return e.isExported&&(a+=`__as1(_${e.namespace==``?``:`.`+e.namespace}, '${e.name}', ${e.fullName});`,a+=`
331
331
  `),r+=a,i&&(r+=`
332
332
  Object.assign(`+e.fullName+`, _n);
333
- `),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=Ft.is(t);e&&e.writeCompiled&&(n.debugTxt=h),It.is(t)&&(n.required=!0)}}catch(e){this.printCatchError(e)}return n}static compileTsToNpm(e,t){try{if(!t.build.hasNpmOutput)return null;let n={defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},r=``,i=e.compiledContentNpm,a=t.build.module;if(e instanceof Ot&&!e.isInterface){let n=`Aventus.`;e.build.isCoreBuild&&(n=``);let i=``;if(e.namespace&&(i=`.`+e.namespace),r+=e.name+".Namespace=`"+a+i+`\`;
333
+ `),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=It.is(t);e&&e.writeCompiled&&(n.debugTxt=h),Lt.is(t)&&(n.required=!0)}}catch(e){this.printCatchError(e)}return n}static compileTsToNpm(e,t){try{if(!t.build.hasNpmOutput)return null;let n={defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},r=``,i=e.compiledContentNpm,a=t.build.module;if(e instanceof kt&&!e.isInterface){let n=`Aventus.`;e.build.isCoreBuild&&(n=``);let i=``;if(e.namespace&&(i=`.`+e.namespace),r+=e.name+".Namespace=`"+a+i+`\`;
334
334
  `,e.convertibleName){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
335
335
  `;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.`+e.convertibleName+`, `+e.name+`);
336
336
  `,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}else if(e.implements.includes(n+`IData`)){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
337
337
  `;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.Fullname, `+e.name+`);
338
- `,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof Mt&&(i=e.type+` `+e.compiledContentNpm);i=this.removeComments(i);let o=(0,p.transpile)(i,Wt),s=this.compileDocTs(i,e);n.namespace=t.build.module,e.namespace.length>0&&(n.namespace+=`.`+e.namespace),n.defTs=s,n.src=o+r;let c=t.file.path.replace(t.build.project.getConfigFile().path.replace(w.Config,``),``);return c=c.replace(w.Base,`.js`),n.exportPath=c,n}catch(e){this.printCatchError(e)}return null}static compileDocTs(e,t){try{let n=(0,p.createLanguageService)({getCompilationSettings:()=>({allowJs:!0,declaration:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>e,fileExists:e=>!0,directoryExists:e=>!e.startsWith(`node_modules`)}).getEmitOutput(`temp.js`,!0,!0).outputFiles[0].text.replace(/^declare /g,``);if(t instanceof Ot&&!t.constructorBody&&t.extraConstructorCode.length>0&&(n=n.replace(/^ *constructor\(.*\);$/gm,``)),t instanceof Ot&&t.isWebcomponent){let e=t.build.tsFiles[t.fileUri];if(e instanceof j){let t=RegExp(`^ *private `+e.viewMethodName+`[0-9]+?;
338
+ `,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof Nt&&(i=e.type+` `+e.compiledContentNpm);i=this.removeComments(i);let o=(0,p.transpile)(i,Gt),s=this.compileDocTs(i,e);n.namespace=t.build.module,e.namespace.length>0&&(n.namespace+=`.`+e.namespace),n.defTs=s,n.src=o+r;let c=t.file.path.replace(t.build.project.getConfigFile().path.replace(w.Config,``),``);return c=c.replace(w.Base,`.js`),n.exportPath=c,n}catch(e){this.printCatchError(e)}return null}static compileDocTs(e,t){try{let n=(0,p.createLanguageService)({getCompilationSettings:()=>({allowJs:!0,declaration:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>e,fileExists:e=>!0,directoryExists:e=>!e.startsWith(`node_modules`)}).getEmitOutput(`temp.js`,!0,!0).outputFiles[0].text.replace(/^declare /g,``);if(t instanceof kt&&!t.constructorBody&&t.extraConstructorCode.length>0&&(n=n.replace(/^ *constructor\(.*\);$/gm,``)),t instanceof kt&&t.isWebcomponent){let e=t.build.tsFiles[t.fileUri];if(e instanceof j){let t=RegExp(`^ *private `+e.viewMethodName+`[0-9]+?;
339
339
  `,`gm`);n=n.replace(t,``)}}return t?.documentation&&(n=t.documentation.fullDefinitions.join(`
340
340
  `)+`
341
- `+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return Wt}simplifyPath(e,t){if(e=decodeURIComponent(e),e.startsWith(`custom://`))return e;let n=[];n=f.sep===`/`?decodeURIComponent(t).replace(`file://`,``).split(`/`):decodeURIComponent(t).replace(`file:///`,``).split(`/`),n.pop();let r=(0,f.normalize)(n.join(`/`)).split(f.sep),i=(0,f.normalize)(n.join(`/`)+`/`+e).split(f.sep);for(let e=0;e<r.length;e++)if(i.length>e)if(r[e]==i[e])r.splice(e,1),i.splice(e,1),e--;else break;let a=``;for(let e=0;e<r.length;e++)a+=`../`;a==``&&(a+=`./`),a+=i.join(`/`);let o=(0,f.normalize)((0,f.join)(...n,a)),s=this.build.getAliases();for(let e in s){let t=s[e],n=(0,f.normalize)((0,f.join)(this.build.project.getConfigFile().folderPath,t));if(o.startsWith(n)){a=o.replace(n,e).replace(/\\/g,`/`);break}}return a}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Ut={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Wt={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Auto,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Gt={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},Kt={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
342
- `,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};function qt(e){switch(e){case`primitive type`:case`keyword`:return m.CompletionItemKind.Keyword;case`const`:case`let`:case`var`:case`local var`:case`alias`:case`parameter`:return m.CompletionItemKind.Variable;case`property`:case`getter`:case`setter`:return m.CompletionItemKind.Field;case`function`:case`local function`:return m.CompletionItemKind.Function;case`method`:case`construct`:case`call`:case`index`:return m.CompletionItemKind.Method;case`enum`:return m.CompletionItemKind.Enum;case`enum member`:return m.CompletionItemKind.EnumMember;case`module`:case`external module name`:return m.CompletionItemKind.Module;case`class`:case`type`:return m.CompletionItemKind.Class;case`interface`:return m.CompletionItemKind.Interface;case`warning`:return m.CompletionItemKind.Text;case`script`:return m.CompletionItemKind.File;case`directory`:return m.CompletionItemKind.Folder;case`string`:return m.CompletionItemKind.Constant;default:return m.CompletionItemKind.Property}}function Jt(e){return/^\s*$/.test(e)}function Yt(e,t){return t.insertSpaces?Xt(` `,e*t.tabSize):Xt(` `,e)}function Xt(e,t){let n=``;for(;t>0;)(t&1)==1&&(n+=e),e+=e,t>>>=1;return n}function Zt(e,t){let n=RegExp(`//#region `+t+`(\\s|\\S)*?//#endregion`).exec(e.documentInternal.getText());return n?n.index+10+t.length:-1}var Qt=class e{removeViewVariables=[];static is(t){if(t.name==`OverrideView`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.removeViewVariables&&(n.removeViewVariables=e.removeViewVariables)}catch{}return n}return null}},$t=class e{tagName=``;static is(t){if(t.name==`TagName`){let n=new e;return t.arguments.length>0&&(n.tagName=t.arguments[0].value),n}return null}},en=class e{fctTxt=null;static is(t){if(t.name==`Property`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},tn=class e{useLive=void 0;static is(t){if(t.name==`ViewElement`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.useLive===!0?n.useLive=!0:e.useLive===!1&&(n.useLive=!1)}catch{}return n}return null}},nn=class e{stateName=``;managerName=``;functionName=`active`;static is(t){if(t.name==`StateActive`){let n=new e;if(t.arguments.length>0)try{let e=rn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},rn=class{static parse(e){let t={stateName:``};try{let n=e.arguments[0].value;if(e.arguments[0].type==`identifier`){let t=e.arguments[0].value.split(`.`),r=e.baseInfo?.dependenciesLocations[t[0]]?.replacement;r&&(t[0]=r),n=t.join(`.`)}if(t.stateName=n,e.arguments.length>1){let n=e.arguments[1].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}}catch{}return t}},an=class e{stateName=``;managerName=``;functionName=`askChange`;static is(t){if(t.name==`StateChange`){let n=new e;if(t.arguments.length>0)try{let e=rn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},on=class e{stateName=``;managerName=``;functionName=`inactive`;static is(t){if(t.name==`StateInactive`){let n=new e;if(t.arguments.length>0)try{let e=rn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},sn=class e{fctTxt=null;static is(t){if(t.name==`Watch`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}};const cn={"@press":`onPress`,"@press-start":`onPressStart`,"@press-stop":`onPressEnd`,"@longpress":`onLongPress`,"@longpress-delay":`delayLongPress`,"@dblpress":`onDblPress`,"@dblpress-delay":`delayDblPress`,"@drag":`onDrag`,"@drag-start":`onDragStart`,"@drag-end":`onDragEnd`};var ln=class e{managerName=``;static is(t){if(t.name==`DefaultStateActive`){let n=new e;if(t.arguments.length>0)try{n.managerName=un.parse(t).managerName}catch{}return n}return null}},un=class{static parse(e){let t={managerName:``};try{let n=e.arguments[0].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}catch{}return t}},dn=class e{managerName=``;static is(t){if(t.name==`DefaultStateInactive`){let n=new e;if(t.arguments.length>0)try{n.managerName=un.parse(t).managerName}catch{}return n}return null}},fn=class e{options={autoInit:!0};static is(t){if(t.name==`Effect`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.autoInit!==void 0&&(n.options.autoInit=e.autoInit)}catch{}return n}return null}},pn=class e{fctTxt=null;static is(t){if(t.name==`Signal`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},mn=class e{static is(t){return t.name==`Injectable`?new e:null}},hn=class{static getVersion(e,t){let n={ts:e.file.documentUser.version,scss:-1,html:-1,i18n:-1},r,i,a;return e.file.uri.endsWith(w.Component)?(r=t.wcFiles[e.file.uri].style,i=t.wcFiles[e.file.uri].view,a=t.wcFiles[e.file.uri].i18n):(r=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],i=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)],a=t.i18nComponentsFiles[e.file.uri.replace(w.ComponentLogic,w.I18n)]),r&&(n.scss=r.compiledVersion),i&&(n.html=i.compiledVersion),a&&(n.i18n=a.file.versionUser),n}file;logicalFile;scssTxt=``;template;templateHotReload;templateNpm;document;build;fileParsed;classInfo;className=``;fullName=``;tagName=``;htmlParsed;htmlParsedResult;htmlDoc;htmlFile;scssFile;allFields={};methodsName=[];listBoolProperties=[];defaultValueTxt=``;defaultValueHotReloadTxt=``;defaultValueNpmTxt=``;result={diagnostics:[],writeCompiled:!1,missingViewElements:{position:-1,elements:{}},missingMethods:{position:-1,elements:[]},componentName:``,result:[],htmlDoc:{},scssDoc:{},debug:``,needRebuild:!1};componentResult={hotReload:``,compiled:``,docVisible:``,npm:{defTs:``,namespace:``,exportPath:``,uri:``,src:``},docInvisible:``,dependencies:[],classScript:``,classDoc:``,debugTxt:``,uri:``,required:!1,type:1,isExported:{internal:!0,external:!0},convertibleName:``,tagName:``,useDecorator:!1};parentClassName=``;parentClassNameNpm=``;overrideViewDecorator=null;debuggerDecorator=null;AventusWebComponent=`Aventus.WebComponent`;AventusDefaultComponent=`Aventus.DefaultComponent`;hasStory;constructor(e,t){this.logicalFile=e,this.hasStory=t.hasStories,t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`,this.AventusWebComponent=`WebComponent`);let n,r;e.file.uri.endsWith(w.Component)?(this.file=t.wcFiles[e.file.uri].logic.file,n=t.wcFiles[e.file.uri].style,r=t.wcFiles[e.file.uri].view):(this.file=e.file,n=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],r=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)]),this.scssFile=n,this.scssTxt=n?n.compileResult:``,this.htmlFile=r,this.htmlFile&&(this.htmlParsed=this.htmlFile.fileParsed,this.htmlFile.tsErrors=[]);let i=t.tsLanguageService.doValidation(this.file),a=this.logicalFile.viewMethodName;for(let e=0;e<i.length;e++)i[e].message.startsWith(`'`+a)&&(i.splice(e,1),e--);this.result.diagnostics=i,this.template=Pt(),this.templateHotReload=Pt(),t.hasNpmOutput&&(this.templateNpm=Pt()),this.document=e.file.documentInternal,this.build=t,this.fileParsed=e.fileParsed}compile(){if(this.fileParsed){for(let e in this.fileParsed.aliases)this.result.result.push(Ht.compileTs(this.fileParsed.aliases[e],this.logicalFile));for(let e in this.fileParsed.enums)this.result.result.push(Ht.compileTs(this.fileParsed.enums[e],this.logicalFile));for(let e in this.fileParsed.classes){let t=this.fileParsed.classes[e];if(this.isComponentClassInfo(t))if(this.classInfo!=null){let e=`Only one class is allowed inside a file. Get `+t.name+` and `+this.classInfo.name;this.result.diagnostics.push(L(this.document,e,t.nameStart,t.nameEnd,1003)),this.result.diagnostics.push(L(this.document,e,this.classInfo.nameStart,this.classInfo.nameEnd,1003))}else this.classInfo=t;else this.result.result.push(Ht.compileTs(t,this.logicalFile))}}if(this.classInfo){this.logicalFile.build.addNamespace(this.classInfo.namespace),this.compileComponentClassInfo(),this.result.htmlDoc=this.htmlDoc??{},this.result.scssDoc=this.prepareDocSCSS(),this.result.componentName=this.className,this.result.writeCompiled=this.debuggerDecorator!==null&&this.debuggerDecorator.writeCompiled;for(let e of this.result.result)e.debugTxt&&(this.result.debug+=e.debugTxt+`
343
- `);if(this.htmlParsed&&this.hasStory&&this.classInfo.storieContent){let e=this.classInfo.storieContent;delete e.slots;let t=[];this.classInfo.storieDecorator?.slots?.inject&&this.classInfo.storieDecorator.slots.inject;for(let e in this.htmlParsed.slotsInfo){let n={name:e};this.storyArgTypes[`@`+e]={control:`text`,table:{category:`Slot`}},this.classInfo.documentation?.documentationSlots[e]&&(n.documentation=this.classInfo.documentation.documentationSlots[e],this.storyArgTypes[`@`+e].description=n.documentation),this.classInfo.storieDecorator?.slots?.values&&this.classInfo.storieDecorator.slots.values[e]?this.storyArgs[`@`+e]=this.classInfo.storieDecorator.slots.values[e]:this.storyArgs[`@`+e]=``,t.push(n)}this.classInfo.loadStoryBookInject(),t.length>0&&(e.slots=t)}}else this.result.diagnostics.push(Li(this.document,`Can't found a web component class to compile inside`,1002));return this.result}isComponentClassInfo(e){return e instanceof Ot&&e.isWebcomponent}compileComponentClassInfo(){if(this.classInfo){this.prepareComponentClassInfo(this.classInfo);let e=Ht.compileTs(this.classInfo,this.logicalFile);this.componentResult.classScript=e.classScript,this.componentResult.classDoc=e.classDoc,this.componentResult.dependencies=e.dependencies,this.componentResult.docInvisible=e.docInvisible,this.componentResult.docVisible=e.docVisible,this.componentResult.npm=e.npm,this.componentResult.type=e.type,this.componentResult.isExported=e.isExported,this.componentResult.uri=e.uri,this.prepareHTMLDocObject(),this.loadParent(this.classInfo),this.addViewElementToDependency(),this.writeFile(),!this.classInfo.isAbstract&&!this.classInfo.isInterface&&(this.componentResult.tagName=this.tagName),this.componentResult.slots=this.htmlFile?.slotsInfo,this.componentResult.compiled=this.template.replace(`//todelete for hmr °`,``),this.componentResult.npm.src=this.templateNpm?.replace(`//todelete for hmr °`,``)??``,D.isRunning&&(this.componentResult.hotReload=this.templateHotReload.split(`//todelete for hmr °`)[0],this.componentResult.hotReload=this.componentResult.hotReload.slice(this.componentResult.hotReload.indexOf(`=`)+1)),this.debuggerDecorator&&this.debuggerDecorator.writeCompiled&&(this.componentResult.debugTxt=this.componentResult.compiled),this.result.result.push(this.componentResult)}}prepareComponentClassInfo(e){for(let t of e.decorators){let e=Qt.is(t);if(e){this.overrideViewDecorator=e;continue}let n=Ft.is(t);if(n){this.debuggerDecorator=n;continue}let r=$t.is(t);if(r&&r.tagName){r.tagName.indexOf(`-`)==-1||r.tagName.toLowerCase()!=r.tagName?this.result.diagnostics.push(L(this.document,`tag name must be in lower case and have a - inside`,t.contentStart,t.contentEnd,1004)):this.tagName=r.tagName;continue}It.is(t)&&(this.componentResult.required=!0)}if(e.extends.length>0&&e.extends[0]==this.AventusWebComponent&&(this.overrideViewDecorator=new Qt),this.getClassName(e),this.htmlParsed){let e=this.className.toLowerCase(),t=[],n=null,r=this.classInfo?.parentClass;for(;r;){let i=r.name.toLowerCase();if(t.push(i),n==null&&t.includes(e)&&(n=e+`1`),n&&t.includes(n)){let r=1;for(;t.includes(n);)r++,n=e+r}r=r.parentClass}n&&this.htmlParsed.replaceId(n),this.htmlParsedResult=this.htmlParsed.getParsedInfo(this.className)}}prepareHTMLDocObject(){this.classInfo&&!this.classInfo.isAbstract&&(this.htmlDoc={[this.tagName]:{class:this.classInfo.fullName,name:this.tagName,description:this.classInfo.documentation?.fullDefinitions.join(`
344
- `)??``,attributes:{}}})}getClassName(e){let t=e.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(t){let n=this.build.getComponentPrefix().split(`-`);for(let e=0;e<n.length;e++){let r=n[e];if(r.length>0&&t[e].toLowerCase()!=r.toLowerCase()){t.splice(0,0,n.join(`-`).toLowerCase());break}}this.tagName==``&&(this.tagName=t.join(`-`).toLowerCase()),this.className=e.name,this.fullName=e.fullName,this.parentClassName=`Aventus.WebComponent`,this.parentClassNameNpm=this.build.getNpmReplacementName([this.build.module,this.fullName].join(`.`),`Aventus.WebComponent`),e.extends.length>0&&e.extends[0]&&(this.parentClassName=e.extends[0],this.parentClassNameNpm=e.extendsNpm[0])}}loadParent(e,t=!0){let n=this.loadFields(e,t);this.allFields={...n,...this.allFields};for(let t in e.methods)this.methodsName.includes(t)||this.methodsName.push(t);if(e.extends.length>0&&e.extends[0]!=this.AventusWebComponent){let t=e.parentClass;t?this.loadParent(t,!1):this.classInfo&&this.result.diagnostics.push(L(this.document,`can't found the path for parent `+e.extends[0],this.classInfo.nameStart,this.classInfo.nameEnd,1007))}}loadFields(e,t){let n={};for(let r in e.properties){let i=e.properties[r];if(this.allFields[i.name])continue;let a=!1,o=new Dt(i.prop,i.isInsideInterface,e);for(let e of i.decorators)if([`Attribute`,`Property`,`Watch`,`Signal`,`ViewElement`].includes(e.name)&&(o.propType=e.name,a=!0),a){n[i.name]=o,o.inParent=!t;break}a||(o.propType=`Simple`,o.inParent=!t,n[r]=o)}return n}addViewElementToDependency(){if(this.htmlParsed&&this.htmlFile&&this.classInfo){this.logicalFile.resetViewClassInfoDep();let e=[],t={};for(let n of this.htmlParsed.interestPoints)if(n.type==`tag`){if(e.includes(n.name)||(e.push(n.name),this.classInfo.addDependencyTag(n.name,this.componentResult)),!t.hasOwnProperty(n.name)){let e=this.build.getWebComponentDefinitionFile(n.name);e instanceof j?t[n.name]=e:(this.build.htmlLanguageService.getInternalTagUri(n.name)&&(this.result.needRebuild=!0),t[n.name]=null)}let r=t[n.name];r&&this.logicalFile.addViewClassInfoDep(r,n.start,n.end)}}}writeFile(){this.writeFileName(),this.writeFileTemplateHtml(),this.writeFileReplaceVar(`style`,this.scssTxt),this.writeFileHotReloadReplaceVar(`style`,this.scssTxt),this.writeFileNpmReplaceVar(`style`,this.scssTxt),this.writeFileFields(),this.writeFileMethods(),this.writeWatchableElements(),this.writeFileConstructor(),this.template=this.template.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.template=this.removeWhiteSpaceLines(this.template),this.templateHotReload=this.templateHotReload.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.templateHotReload=this.removeWhiteSpaceLines(this.templateHotReload),this.templateNpm&&=(this.templateNpm=this.templateNpm.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.removeWhiteSpaceLines(this.templateNpm))}writeFileName(){this.writeFileReplaceVar(`classname`,this.className),this.writeFileHotReloadReplaceVar(`classname`,this.className),this.writeFileNpmReplaceVar(`classname`,this.className),this.writeFileReplaceVar(`parentClass`,this.parentClassName),this.writeFileHotReloadReplaceVar(`parentClass`,this.parentClassName),this.writeFileNpmReplaceVar(`parentClass`,this.parentClassNameNpm);let e=this.build.module;if(this.fullName.includes(`.`)){this.writeFileReplaceVar(`fullname`,this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.className);let t=`.`+this.classInfo?.namespace;this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+t+"`;")}else this.writeFileReplaceVar(`fullname`,`const `+this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,`const `+this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.fullName),this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+"`;");if(this.classInfo?.isAbstract?(this.writeFileReplaceVar(`tag`,``),this.writeFileHotReloadReplaceVar(`tag`,``),this.writeFileNpmReplaceVar(`tag`,``)):(this.writeFileReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileHotReloadReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileNpmReplaceVar(`tag`,this.className+".Tag=`"+this.tagName+"`;")),this.build.namespaces.includes(this.fullName)?(this.writeFileReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
341
+ `+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return Gt}simplifyPath(e,t){if(e=decodeURIComponent(e),e.startsWith(`custom://`))return e;let n=[];n=f.sep===`/`?decodeURIComponent(t).replace(`file://`,``).split(`/`):decodeURIComponent(t).replace(`file:///`,``).split(`/`),n.pop();let r=(0,f.normalize)(n.join(`/`)).split(f.sep),i=(0,f.normalize)(n.join(`/`)+`/`+e).split(f.sep);for(let e=0;e<r.length;e++)if(i.length>e)if(r[e]==i[e])r.splice(e,1),i.splice(e,1),e--;else break;let a=``;for(let e=0;e<r.length;e++)a+=`../`;a==``&&(a+=`./`),a+=i.join(`/`);let o=(0,f.normalize)((0,f.join)(...n,a)),s=this.build.getAliases();for(let e in s){let t=s[e],n=(0,f.normalize)((0,f.join)(this.build.project.getConfigFile().folderPath,t));if(o.startsWith(n)){a=o.replace(n,e).replace(/\\/g,`/`);break}}return a}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Wt={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Gt={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Auto,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Kt={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},qt={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
342
+ `,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};function Jt(e){switch(e){case`primitive type`:case`keyword`:return m.CompletionItemKind.Keyword;case`const`:case`let`:case`var`:case`local var`:case`alias`:case`parameter`:return m.CompletionItemKind.Variable;case`property`:case`getter`:case`setter`:return m.CompletionItemKind.Field;case`function`:case`local function`:return m.CompletionItemKind.Function;case`method`:case`construct`:case`call`:case`index`:return m.CompletionItemKind.Method;case`enum`:return m.CompletionItemKind.Enum;case`enum member`:return m.CompletionItemKind.EnumMember;case`module`:case`external module name`:return m.CompletionItemKind.Module;case`class`:case`type`:return m.CompletionItemKind.Class;case`interface`:return m.CompletionItemKind.Interface;case`warning`:return m.CompletionItemKind.Text;case`script`:return m.CompletionItemKind.File;case`directory`:return m.CompletionItemKind.Folder;case`string`:return m.CompletionItemKind.Constant;default:return m.CompletionItemKind.Property}}function Yt(e){return/^\s*$/.test(e)}function Xt(e,t){return t.insertSpaces?Zt(` `,e*t.tabSize):Zt(` `,e)}function Zt(e,t){let n=``;for(;t>0;)(t&1)==1&&(n+=e),e+=e,t>>>=1;return n}function Qt(e,t){let n=RegExp(`//#region `+t+`(\\s|\\S)*?//#endregion`).exec(e.documentInternal.getText());return n?n.index+10+t.length:-1}var $t=class e{removeViewVariables=[];static is(t){if(t.name==`OverrideView`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.removeViewVariables&&(n.removeViewVariables=e.removeViewVariables)}catch{}return n}return null}},en=class e{tagName=``;static is(t){if(t.name==`TagName`){let n=new e;return t.arguments.length>0&&(n.tagName=t.arguments[0].value),n}return null}},tn=class e{fctTxt=null;static is(t){if(t.name==`Property`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},nn=class e{useLive=void 0;static is(t){if(t.name==`ViewElement`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.useLive===!0?n.useLive=!0:e.useLive===!1&&(n.useLive=!1)}catch{}return n}return null}},rn=class e{stateName=``;managerName=``;functionName=`active`;static is(t){if(t.name==`StateActive`){let n=new e;if(t.arguments.length>0)try{let e=an.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},an=class{static parse(e){let t={stateName:``};try{let n=e.arguments[0].value;if(e.arguments[0].type==`identifier`){let t=e.arguments[0].value.split(`.`),r=e.baseInfo?.dependenciesLocations[t[0]]?.replacement;r&&(t[0]=r),n=t.join(`.`)}if(t.stateName=n,e.arguments.length>1){let n=e.arguments[1].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}}catch{}return t}},on=class e{stateName=``;managerName=``;functionName=`askChange`;static is(t){if(t.name==`StateChange`){let n=new e;if(t.arguments.length>0)try{let e=an.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},sn=class e{stateName=``;managerName=``;functionName=`inactive`;static is(t){if(t.name==`StateInactive`){let n=new e;if(t.arguments.length>0)try{let e=an.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},cn=class e{fctTxt=null;static is(t){if(t.name==`Watch`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}};const ln={"@press":`onPress`,"@press-start":`onPressStart`,"@press-stop":`onPressEnd`,"@longpress":`onLongPress`,"@longpress-delay":`delayLongPress`,"@dblpress":`onDblPress`,"@dblpress-delay":`delayDblPress`,"@drag":`onDrag`,"@drag-start":`onDragStart`,"@drag-end":`onDragEnd`};var un=class e{managerName=``;static is(t){if(t.name==`DefaultStateActive`){let n=new e;if(t.arguments.length>0)try{n.managerName=dn.parse(t).managerName}catch{}return n}return null}},dn=class{static parse(e){let t={managerName:``};try{let n=e.arguments[0].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}catch{}return t}},fn=class e{managerName=``;static is(t){if(t.name==`DefaultStateInactive`){let n=new e;if(t.arguments.length>0)try{n.managerName=dn.parse(t).managerName}catch{}return n}return null}},pn=class e{options={autoInit:!0};static is(t){if(t.name==`Effect`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.autoInit!==void 0&&(n.options.autoInit=e.autoInit)}catch{}return n}return null}},mn=class e{fctTxt=null;static is(t){if(t.name==`Signal`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},hn=class e{static is(t){return t.name==`Injectable`?new e:null}},gn=class{static getVersion(e,t){let n={ts:e.file.documentUser.version,scss:-1,html:-1,i18n:-1},r,i,a;return e.file.uri.endsWith(w.Component)?(r=t.wcFiles[e.file.uri].style,i=t.wcFiles[e.file.uri].view,a=t.wcFiles[e.file.uri].i18n):(r=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],i=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)],a=t.i18nComponentsFiles[e.file.uri.replace(w.ComponentLogic,w.I18n)]),r&&(n.scss=r.compiledVersion),i&&(n.html=i.compiledVersion),a&&(n.i18n=a.file.versionUser),n}file;logicalFile;scssTxt=``;template;templateHotReload;templateNpm;document;build;fileParsed;classInfo;className=``;fullName=``;tagName=``;htmlParsed;htmlParsedResult;htmlDoc;htmlFile;scssFile;allFields={};methodsName=[];listBoolProperties=[];defaultValueTxt=``;defaultValueHotReloadTxt=``;defaultValueNpmTxt=``;result={diagnostics:[],writeCompiled:!1,missingViewElements:{position:-1,elements:{}},missingMethods:{position:-1,elements:[]},componentName:``,result:[],htmlDoc:{},scssDoc:{},debug:``,needRebuild:!1};componentResult={hotReload:``,compiled:``,docVisible:``,npm:{defTs:``,namespace:``,exportPath:``,uri:``,src:``},docInvisible:``,dependencies:[],classScript:``,classDoc:``,debugTxt:``,uri:``,required:!1,type:1,isExported:{internal:!0,external:!0},convertibleName:``,tagName:``,useDecorator:!1};parentClassName=``;parentClassNameNpm=``;overrideViewDecorator=null;debuggerDecorator=null;AventusWebComponent=`Aventus.WebComponent`;AventusDefaultComponent=`Aventus.DefaultComponent`;hasStory;constructor(e,t){this.logicalFile=e,this.hasStory=t.hasStories,t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`,this.AventusWebComponent=`WebComponent`);let n,r;e.file.uri.endsWith(w.Component)?(this.file=t.wcFiles[e.file.uri].logic.file,n=t.wcFiles[e.file.uri].style,r=t.wcFiles[e.file.uri].view):(this.file=e.file,n=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],r=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)]),this.scssFile=n,this.scssTxt=n?n.compileResult:``,this.htmlFile=r,this.htmlFile&&(this.htmlParsed=this.htmlFile.fileParsed,this.htmlFile.tsErrors=[]);let i=t.tsLanguageService.doValidation(this.file),a=this.logicalFile.viewMethodName;for(let e=0;e<i.length;e++)i[e].message.startsWith(`'`+a)&&(i.splice(e,1),e--);this.result.diagnostics=i,this.template=Ft(),this.templateHotReload=Ft(),t.hasNpmOutput&&(this.templateNpm=Ft()),this.document=e.file.documentInternal,this.build=t,this.fileParsed=e.fileParsed}compile(){if(this.fileParsed){for(let e in this.fileParsed.aliases)this.result.result.push(Ut.compileTs(this.fileParsed.aliases[e],this.logicalFile));for(let e in this.fileParsed.enums)this.result.result.push(Ut.compileTs(this.fileParsed.enums[e],this.logicalFile));for(let e in this.fileParsed.classes){let t=this.fileParsed.classes[e];if(this.isComponentClassInfo(t))if(this.classInfo!=null){let e=`Only one class is allowed inside a file. Get `+t.name+` and `+this.classInfo.name;this.result.diagnostics.push(L(this.document,e,t.nameStart,t.nameEnd,1003)),this.result.diagnostics.push(L(this.document,e,this.classInfo.nameStart,this.classInfo.nameEnd,1003))}else this.classInfo=t;else this.result.result.push(Ut.compileTs(t,this.logicalFile))}}if(this.classInfo){this.logicalFile.build.addNamespace(this.classInfo.namespace),this.compileComponentClassInfo(),this.result.htmlDoc=this.htmlDoc??{},this.result.scssDoc=this.prepareDocSCSS(),this.result.componentName=this.className,this.result.writeCompiled=this.debuggerDecorator!==null&&this.debuggerDecorator.writeCompiled;for(let e of this.result.result)e.debugTxt&&(this.result.debug+=e.debugTxt+`
343
+ `);if(this.htmlParsed&&this.hasStory&&this.classInfo.storieContent){let e=this.classInfo.storieContent;delete e.slots;let t=[];this.classInfo.storieDecorator?.slots?.inject&&this.classInfo.storieDecorator.slots.inject;for(let e in this.htmlParsed.slotsInfo){let n={name:e};this.storyArgTypes[`@`+e]={control:`text`,table:{category:`Slot`}},this.classInfo.documentation?.documentationSlots[e]&&(n.documentation=this.classInfo.documentation.documentationSlots[e],this.storyArgTypes[`@`+e].description=n.documentation),this.classInfo.storieDecorator?.slots?.values&&this.classInfo.storieDecorator.slots.values[e]?this.storyArgs[`@`+e]=this.classInfo.storieDecorator.slots.values[e]:this.storyArgs[`@`+e]=``,t.push(n)}this.classInfo.loadStoryBookInject(),t.length>0&&(e.slots=t)}}else this.result.diagnostics.push(Ri(this.document,`Can't found a web component class to compile inside`,1002));return this.result}isComponentClassInfo(e){return e instanceof kt&&e.isWebcomponent}compileComponentClassInfo(){if(this.classInfo){this.prepareComponentClassInfo(this.classInfo);let e=Ut.compileTs(this.classInfo,this.logicalFile);this.componentResult.classScript=e.classScript,this.componentResult.classDoc=e.classDoc,this.componentResult.dependencies=e.dependencies,this.componentResult.docInvisible=e.docInvisible,this.componentResult.docVisible=e.docVisible,this.componentResult.npm=e.npm,this.componentResult.type=e.type,this.componentResult.isExported=e.isExported,this.componentResult.uri=e.uri,this.prepareHTMLDocObject(),this.loadParent(this.classInfo),this.addViewElementToDependency(),this.writeFile(),!this.classInfo.isAbstract&&!this.classInfo.isInterface&&(this.componentResult.tagName=this.tagName),this.componentResult.slots=this.htmlFile?.slotsInfo,this.componentResult.compiled=this.template.replace(`//todelete for hmr °`,``),this.componentResult.npm.src=this.templateNpm?.replace(`//todelete for hmr °`,``)??``,D.isRunning&&(this.componentResult.hotReload=this.templateHotReload.split(`//todelete for hmr °`)[0],this.componentResult.hotReload=this.componentResult.hotReload.slice(this.componentResult.hotReload.indexOf(`=`)+1)),this.debuggerDecorator&&this.debuggerDecorator.writeCompiled&&(this.componentResult.debugTxt=this.componentResult.compiled),this.result.result.push(this.componentResult)}}prepareComponentClassInfo(e){for(let t of e.decorators){let e=$t.is(t);if(e){this.overrideViewDecorator=e;continue}let n=It.is(t);if(n){this.debuggerDecorator=n;continue}let r=en.is(t);if(r&&r.tagName){r.tagName.indexOf(`-`)==-1||r.tagName.toLowerCase()!=r.tagName?this.result.diagnostics.push(L(this.document,`tag name must be in lower case and have a - inside`,t.contentStart,t.contentEnd,1004)):this.tagName=r.tagName;continue}Lt.is(t)&&(this.componentResult.required=!0)}if(e.extends.length>0&&e.extends[0]==this.AventusWebComponent&&(this.overrideViewDecorator=new $t),this.getClassName(e),this.htmlParsed){let e=this.className.toLowerCase(),t=[],n=null,r=this.classInfo?.parentClass;for(;r;){let i=r.name.toLowerCase();if(t.push(i),n==null&&t.includes(e)&&(n=e+`1`),n&&t.includes(n)){let r=1;for(;t.includes(n);)r++,n=e+r}r=r.parentClass}n&&this.htmlParsed.replaceId(n),this.htmlParsedResult=this.htmlParsed.getParsedInfo(this.className)}}prepareHTMLDocObject(){this.classInfo&&!this.classInfo.isAbstract&&(this.htmlDoc={[this.tagName]:{class:this.classInfo.fullName,name:this.tagName,description:this.classInfo.documentation?.fullDefinitions.join(`
344
+ `)??``,attributes:{}}})}getClassName(e){let t=e.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(t){let n=this.build.getComponentPrefix().split(`-`);for(let e=0;e<n.length;e++){let r=n[e];if(r.length>0&&t[e].toLowerCase()!=r.toLowerCase()){t.splice(0,0,n.join(`-`).toLowerCase());break}}this.tagName==``&&(this.tagName=t.join(`-`).toLowerCase()),this.className=e.name,this.fullName=e.fullName,this.parentClassName=`Aventus.WebComponent`,this.parentClassNameNpm=this.build.getNpmReplacementName([this.build.module,this.fullName].join(`.`),`Aventus.WebComponent`),e.extends.length>0&&e.extends[0]&&(this.parentClassName=e.extends[0],this.parentClassNameNpm=e.extendsNpm[0])}}loadParent(e,t=!0){let n=this.loadFields(e,t);this.allFields={...n,...this.allFields};for(let t in e.methods)this.methodsName.includes(t)||this.methodsName.push(t);if(e.extends.length>0&&e.extends[0]!=this.AventusWebComponent){let t=e.parentClass;t?this.loadParent(t,!1):this.classInfo&&this.result.diagnostics.push(L(this.document,`can't found the path for parent `+e.extends[0],this.classInfo.nameStart,this.classInfo.nameEnd,1007))}}loadFields(e,t){let n={};for(let r in e.properties){let i=e.properties[r];if(this.allFields[i.name])continue;let a=!1,o=new Ot(i.prop,i.isInsideInterface,e);for(let e of i.decorators)if([`Attribute`,`Property`,`Watch`,`Signal`,`ViewElement`].includes(e.name)&&(o.propType=e.name,a=!0),a){n[i.name]=o,o.inParent=!t;break}a||(o.propType=`Simple`,o.inParent=!t,n[r]=o)}return n}addViewElementToDependency(){if(this.htmlParsed&&this.htmlFile&&this.classInfo){this.logicalFile.resetViewClassInfoDep();let e=[],t={};for(let n of this.htmlParsed.interestPoints)if(n.type==`tag`){if(e.includes(n.name)||(e.push(n.name),this.classInfo.addDependencyTag(n.name,this.componentResult)),!t.hasOwnProperty(n.name)){let e=this.build.getWebComponentDefinitionFile(n.name);e instanceof j?t[n.name]=e:(this.build.htmlLanguageService.getInternalTagUri(n.name)&&(this.result.needRebuild=!0),t[n.name]=null)}let r=t[n.name];r&&this.logicalFile.addViewClassInfoDep(r,n.start,n.end)}}}writeFile(){this.writeFileName(),this.writeFileTemplateHtml(),this.writeFileReplaceVar(`style`,this.scssTxt),this.writeFileHotReloadReplaceVar(`style`,this.scssTxt),this.writeFileNpmReplaceVar(`style`,this.scssTxt),this.writeFileFields(),this.writeFileMethods(),this.writeWatchableElements(),this.writeFileConstructor(),this.template=this.template.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.template=this.removeWhiteSpaceLines(this.template),this.templateHotReload=this.templateHotReload.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.templateHotReload=this.removeWhiteSpaceLines(this.templateHotReload),this.templateNpm&&=(this.templateNpm=this.templateNpm.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.removeWhiteSpaceLines(this.templateNpm))}writeFileName(){this.writeFileReplaceVar(`classname`,this.className),this.writeFileHotReloadReplaceVar(`classname`,this.className),this.writeFileNpmReplaceVar(`classname`,this.className),this.writeFileReplaceVar(`parentClass`,this.parentClassName),this.writeFileHotReloadReplaceVar(`parentClass`,this.parentClassName),this.writeFileNpmReplaceVar(`parentClass`,this.parentClassNameNpm);let e=this.build.module;if(this.fullName.includes(`.`)){this.writeFileReplaceVar(`fullname`,this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.className);let t=`.`+this.classInfo?.namespace;this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+t+"`;")}else this.writeFileReplaceVar(`fullname`,`const `+this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,`const `+this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.fullName),this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+"`;");if(this.classInfo?.isAbstract?(this.writeFileReplaceVar(`tag`,``),this.writeFileHotReloadReplaceVar(`tag`,``),this.writeFileNpmReplaceVar(`tag`,``)):(this.writeFileReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileHotReloadReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileNpmReplaceVar(`tag`,this.className+".Tag=`"+this.tagName+"`;")),this.build.namespaces.includes(this.fullName)?(this.writeFileReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
345
345
  `),this.writeFileHotReloadReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
346
346
  `),this.writeFileNpmReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
347
347
  `),this.writeFileReplaceVar(`namespaceEnd`,`
@@ -356,14 +356,14 @@ super.__getHtml();`,i=``,a=``;t.length>0&&(i=`slots: { ${t} },`),n.length>0&&(a=
356
356
  ${i}
357
357
  ${a}
358
358
  });
359
- }`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,Ht.getCompilerOptionsCompile()),i=/\{([\s\S]*)\}/gm.exec(r);if(i&&(e=i[1].trim()),D.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentHotReload}}`,Ht.getCompilerOptionsCompile()),n=/\{([\s\S]*)\}/gm.exec(e);n&&(t=n[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentNpm}}`,Ht.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}this.writeFileReplaceVar(`constructor`,e),this.writeFileHotReloadReplaceVar(`constructor`,t),this.writeFileNpmReplaceVar(`constructor`,n)}}viewsElements={};upgradeAttributes=``;storyArgTypes={};storyArgs={};addStoryField(e){if(e.propType==`Simple`||!this.hasStory||!this.classInfo?.storieContent)return;let t=``;if(e.propType==`Attribute`?t=`Attributes`:e.propType==`Property`?t=`Properties`:e.propType==`Watch`?t=`Watches`:e.propType==`Signal`&&(t=`Signals`),this.classInfo.storieContent.kind==`class`){let t=this.classInfo.storieContent.properties?.find(t=>t.name==e.name);t&&(t.modifiers?t.modifiers.includes(e.propType)||t.modifiers.push(e.propType):t.modifiers=[e.propType])}if(e.propType==`ViewElement`)return;let n=e.type;if(!n)return;let r=`text`,i=[],a=e.defaultValue??void 0,o,s=e=>{if(e.kind==`string`)r=`text`,o=`string`;else if(e.kind==`literal`){r=`select`;let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),i.push(t),o=`string`}else if(e.kind==`union`){r=`select`;for(let t of e.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),i.push(e)}o=`string`}else if(e.kind==`number`)r=`number`,o=`number`;else if(e.kind==`boolean`)r=`boolean`,o=`boolean`;else if(e.kind==`type`)if(e.value==`Date`||e.value==`DateTime`)r=`date`;else{let t=A.getBaseInfo(e.value,this.document.uri);t&&t instanceof yt?s(t.type):r=`object`}else r=`object`};s(n),this.storyArgTypes[e.name]={control:r,table:{category:t}},o&&(this.storyArgTypes[e.name].type=o),i.length>0&&(this.storyArgTypes[e.name].options=i),e.defaultValueStory!==null&&(a=e.defaultValueStory),this.storyArgs[e.name]=a}writeFileFields(){let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s={};for(let c in this.allFields){let l=this.allFields[c];for(let e of l.decorators)mn.is(e)&&a.push(l);if(Et.includes(l.type.value)&&o.push(l),l.inParent){(l.propType==`Attribute`||l.propType==`Property`)&&this.createHtmlDoc(l,l.type);continue}if(this.addStoryField(l),l.propType==`Attribute`){t.push(l);continue}else if(l.propType==`Property`){for(let e of l.decorators){let t=en.is(e);t&&n.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Signal`){for(let e of l.decorators){let t=pn.is(e);t&&r.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Watch`)for(let e of l.decorators){let t=sn.is(e);t&&i.push({field:l,fctTxt:t.fctTxt})}else l.propType==`ViewElement`?(s[l.name]=l,!l.overrideNullable&&l.defaultValue===null&&!l.isNullable&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,l.nameStart,l.nameEnd,1025))):l.propType==`Simple`&&e.push(l)}if(this.viewsElements=s,this.writeFileFieldsSimpleVariable(e),this.writeFileFieldsAttribute(t),this.writeFileFieldsProperty(n),this.writeFileFieldsSignal(r),this.writeFileFieldsWatch(i),this.createInjectableHtmlDoc(a),this.createEventsHtmlDoc(o),this.upgradeAttributes.length>0&&(this.upgradeAttributes=`__upgradeAttributes() { super.__upgradeAttributes(); ${this.upgradeAttributes} }`),this.writeFileReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileHotReloadReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileNpmReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.htmlParsedResult){this.writeViewInfo(this.htmlParsedResult,!0);for(let e in s)this.createUnusedViewElement(s[e])}else this.writeFileReplaceVar(`templateAction`,``),this.writeFileHotReloadReplaceVar(`templateAction`,``),this.writeFileNpmReplaceVar(`templateAction`,``),this.writeFileReplaceVar(`variablesInViewDynamic`,``),this.writeFileHotReloadReplaceVar(`variablesInViewDynamic`,``),this.writeFileNpmReplaceVar(`variablesInViewDynamic`,``);this.writeViewGlobalVariables()}writeFileFieldsSimpleVariable(e){if(!this.htmlParsedResult){this.writeFileReplaceVar(`variables`,``),this.writeFileHotReloadReplaceVar(`variables`,``),this.writeFileNpmReplaceVar(`variables`,``);return}let t=``,n=``,r=``,i=[],a=``,o=``,s=``;if(this.classInfo)for(let e in this.classInfo.propertiesStatic){let t=this.classInfo.propertiesStatic[e];a+=t.compiledContent+`
359
+ }`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,Ut.getCompilerOptionsCompile()),i=/\{([\s\S]*)\}/gm.exec(r);if(i&&(e=i[1].trim()),D.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentHotReload}}`,Ut.getCompilerOptionsCompile()),n=/\{([\s\S]*)\}/gm.exec(e);n&&(t=n[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentNpm}}`,Ut.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}this.writeFileReplaceVar(`constructor`,e),this.writeFileHotReloadReplaceVar(`constructor`,t),this.writeFileNpmReplaceVar(`constructor`,n)}}viewsElements={};upgradeAttributes=``;storyArgTypes={};storyArgs={};addStoryField(e){if(e.propType==`Simple`||!this.hasStory||!this.classInfo?.storieContent)return;let t=``;if(e.propType==`Attribute`?t=`Attributes`:e.propType==`Property`?t=`Properties`:e.propType==`Watch`?t=`Watches`:e.propType==`Signal`&&(t=`Signals`),this.classInfo.storieContent.kind==`class`){let t=this.classInfo.storieContent.properties?.find(t=>t.name==e.name);t&&(t.modifiers?t.modifiers.includes(e.propType)||t.modifiers.push(e.propType):t.modifiers=[e.propType])}if(e.propType==`ViewElement`)return;let n=e.type;if(!n)return;let r=`text`,i=[],a=e.defaultValue??void 0,o,s=e=>{if(e.kind==`string`)r=`text`,o=`string`;else if(e.kind==`literal`){r=`select`;let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),i.push(t),o=`string`}else if(e.kind==`union`){r=`select`;for(let t of e.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),i.push(e)}o=`string`}else if(e.kind==`number`)r=`number`,o=`number`;else if(e.kind==`boolean`)r=`boolean`,o=`boolean`;else if(e.kind==`type`)if(e.value==`Date`||e.value==`DateTime`)r=`date`;else{let t=A.getBaseInfo(e.value,this.document.uri);t&&t instanceof yt?s(t.type):r=`object`}else r=`object`};s(n),this.storyArgTypes[e.name]={control:r,table:{category:t}},o&&(this.storyArgTypes[e.name].type=o),i.length>0&&(this.storyArgTypes[e.name].options=i),e.defaultValueStory!==null&&(a=e.defaultValueStory),this.storyArgs[e.name]=a}writeFileFields(){let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s={};for(let c in this.allFields){let l=this.allFields[c];for(let e of l.decorators)hn.is(e)&&a.push(l);if(Dt.includes(l.type.value)&&o.push(l),l.inParent){(l.propType==`Attribute`||l.propType==`Property`)&&this.createHtmlDoc(l,l.type);continue}if(this.addStoryField(l),l.propType==`Attribute`){t.push(l);continue}else if(l.propType==`Property`){for(let e of l.decorators){let t=tn.is(e);t&&n.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Signal`){for(let e of l.decorators){let t=mn.is(e);t&&r.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Watch`)for(let e of l.decorators){let t=cn.is(e);t&&i.push({field:l,fctTxt:t.fctTxt})}else l.propType==`ViewElement`?(s[l.name]=l,!l.overrideNullable&&l.defaultValue===null&&!l.isNullable&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,l.nameStart,l.nameEnd,1025))):l.propType==`Simple`&&e.push(l)}if(this.viewsElements=s,this.writeFileFieldsSimpleVariable(e),this.writeFileFieldsAttribute(t),this.writeFileFieldsProperty(n),this.writeFileFieldsSignal(r),this.writeFileFieldsWatch(i),this.createInjectableHtmlDoc(a),this.createEventsHtmlDoc(o),this.upgradeAttributes.length>0&&(this.upgradeAttributes=`__upgradeAttributes() { super.__upgradeAttributes(); ${this.upgradeAttributes} }`),this.writeFileReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileHotReloadReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileNpmReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.htmlParsedResult){this.writeViewInfo(this.htmlParsedResult,!0);for(let e in s)this.createUnusedViewElement(s[e])}else this.writeFileReplaceVar(`templateAction`,``),this.writeFileHotReloadReplaceVar(`templateAction`,``),this.writeFileNpmReplaceVar(`templateAction`,``),this.writeFileReplaceVar(`variablesInViewDynamic`,``),this.writeFileHotReloadReplaceVar(`variablesInViewDynamic`,``),this.writeFileNpmReplaceVar(`variablesInViewDynamic`,``);this.writeViewGlobalVariables()}writeFileFieldsSimpleVariable(e){if(!this.htmlParsedResult){this.writeFileReplaceVar(`variables`,``),this.writeFileHotReloadReplaceVar(`variables`,``),this.writeFileNpmReplaceVar(`variables`,``);return}let t=``,n=``,r=``,i=[],a=``,o=``,s=``;if(this.classInfo)for(let e in this.classInfo.propertiesStatic){let t=this.classInfo.propertiesStatic[e];a+=t.compiledContent+`
360
360
  `,o+=t.compiledContentHotReload+`
361
361
  `,this.templateNpm&&(s+=t.compiledContentNpm+`
362
362
  `)}for(let t of e)a+=t.compiledContent+`
363
363
  `,o+=t.compiledContentHotReload+`
364
364
  `,this.templateNpm&&(s+=t.compiledContentNpm+`
365
365
  `),(t.isGet||t.isSet)&&(i.includes(t.name)||(i.push(t.name),this.upgradeAttributes+=`this.__correctGetter('`+t.name+`');
366
- `));let c=`class MyCompilationClassAventus {${a}}`,l=``;try{l=(0,p.transpile)(c,Ht.getCompilerOptionsCompile())}catch{}let u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),this.writeFileReplaceVar(`variables`,t),D.isRunning){let e=`class MyCompilationClassAventus {${o}}`,t=``;try{t=(0,p.transpile)(e,Ht.getCompilerOptionsCompile())}catch{}let r=/\{([\s\S]*)\}/gm.exec(t);r&&(n=r[1].trim()),this.writeFileHotReloadReplaceVar(`variables`,n)}if(this.templateNpm){let e=`class MyCompilationClassAventus {${s}}`,t=``;try{t=(0,p.transpile)(e,Ht.getCompilerOptionsCompile())}catch{}let n=/\{([\s\S]*)\}/gm.exec(t);n&&(r=n[1].trim()),this.writeFileNpmReplaceVar(`variables`,r)}}getGetterAndSetter(e,t,n){let r=``,i=e.name,a=n?`Prop`:`Attr`;return t.kind==`string`||t.kind==`literal`||t.kind==`union`?r+=`get '${i}'() { return this.getString${a}('${i}') }
366
+ `));let c=`class MyCompilationClassAventus {${a}}`,l=``;try{l=(0,p.transpile)(c,Ut.getCompilerOptionsCompile())}catch{}let u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),this.writeFileReplaceVar(`variables`,t),D.isRunning){let e=`class MyCompilationClassAventus {${o}}`,t=``;try{t=(0,p.transpile)(e,Ut.getCompilerOptionsCompile())}catch{}let r=/\{([\s\S]*)\}/gm.exec(t);r&&(n=r[1].trim()),this.writeFileHotReloadReplaceVar(`variables`,n)}if(this.templateNpm){let e=`class MyCompilationClassAventus {${s}}`,t=``;try{t=(0,p.transpile)(e,Ut.getCompilerOptionsCompile())}catch{}let n=/\{([\s\S]*)\}/gm.exec(t);n&&(r=n[1].trim()),this.writeFileNpmReplaceVar(`variables`,r)}}getGetterAndSetter(e,t,n){let r=``,i=e.name,a=n?`Prop`:`Attr`;return t.kind==`string`||t.kind==`literal`||t.kind==`union`?r+=`get '${i}'() { return this.getString${a}('${i}') }
367
367
  set '${i}'(val) { this.setStringAttr('${i}', val) }
368
368
  `:t.kind==`number`?r+=`get '${i}'() { return this.getNumber${a}('${i}') }
369
369
  set '${i}'(val) { this.setNumberAttr('${i}', val) }
@@ -406,15 +406,15 @@ super.__getHtml();`,i=``,a=``;t.length>0&&(i=`slots: { ${t} },`),n.length>0&&(a=
406
406
  `)}n.length>0&&(n=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${n} }`),this.writeFileReplaceVar(`defaultValueWatch`,n),r.length>0&&(r=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${r} }`),this.writeFileHotReloadReplaceVar(`defaultValueWatch`,r),i.length>0&&(i=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${i} }`),this.writeFileNpmReplaceVar(`defaultValueWatch`,i),this.writeFileReplaceVar(`getterSetterWatch`,t),this.writeFileHotReloadReplaceVar(`getterSetterWatch`,t),this.writeFileNpmReplaceVar(`getterSetterWatch`,t)}writeViewGlobalVariables(){let e=``;if(this.defaultValueTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueTxt} }`),this.writeFileReplaceVar(`defaultValue`,e),D.isRunning){let e=``;this.defaultValueHotReloadTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueHotReloadTxt} }`),this.writeFileHotReloadReplaceVar(`defaultValue`,e)}if(this.templateNpm){let e=``;this.defaultValueNpmTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueNpmTxt} }`),this.writeFileNpmReplaceVar(`defaultValue`,e)}let t=``;this.listBoolProperties.length>0&&(t=`__listBoolProps() { return [${this.listBoolProperties.join(`,`)}].concat(super.__listBoolProps()).filter((v, i, a) => a.indexOf(v) === i); }`),this.writeFileReplaceVar(`listBool`,t),this.writeFileHotReloadReplaceVar(`listBool`,t),this.writeFileNpmReplaceVar(`listBool`,t)}writeFileMethods(){try{let e={},t=``,n=``,r=``,i=``;if(this.classInfo){let a=``,o=``,s=``,c=[...Object.values(this.classInfo.methods),...Object.values(this.classInfo.methodsStatic)];for(let t of c){if(!t.mustBeCompiled)continue;let n=t.name;if(a+=t.compiledContent+`
407
407
  `,D.isRunning&&(o+=t.compiledContentHotReload+`
408
408
  `),this.templateNpm&&(s+=t.compiledContentNpm+`
409
- `),!t.isStatic)for(let r of t.decorators){let a=fn.is(r);if(a){this.watchFunctions[n]=a.options;continue}let o=null,s=an.is(r);if(s)o=s;else{let e=nn.is(r);if(e)o=e;else{let e=on.is(r);e&&(o=e)}}let c,l;o===null?(c=ln.is(r))?i+=`this.__addActiveDefState(${c.managerName}, this.${t.name});
410
- `:(l=dn.is(r))&&(i+=`this.__addInactiveDefState(${l.managerName}, this.${t.name});
411
- `):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,Ht.getCompilerOptionsCompile()),u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),D.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${o}}`,Ht.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${s}}`,Ht.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(r=t[1].trim())}}this.writeFileReplaceVar(`methods`,t),this.writeFileHotReloadReplaceVar(`methods`,n),this.writeFileNpmReplaceVar(`methods`,r);let a=``;for(let t in e)for(let n in e[t]){let r=e[t][n];if(a+=`this.__createStatesList(${t}, ${n});`,r.active.length>0){let e=``;for(let t of r.active)e+=`that.`+t+`(state, slugs);`;a+=`this.__addActiveState(${t}, ${n}, (state, slugs) => { that.__inactiveDefaultState(${n}); ${e}})
409
+ `),!t.isStatic)for(let r of t.decorators){let a=pn.is(r);if(a){this.watchFunctions[n]=a.options;continue}let o=null,s=on.is(r);if(s)o=s;else{let e=rn.is(r);if(e)o=e;else{let e=sn.is(r);e&&(o=e)}}let c,l;o===null?(c=un.is(r))?i+=`this.__addActiveDefState(${c.managerName}, this.${t.name});
410
+ `:(l=fn.is(r))&&(i+=`this.__addInactiveDefState(${l.managerName}, this.${t.name});
411
+ `):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,Ut.getCompilerOptionsCompile()),u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),D.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${o}}`,Ut.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${s}}`,Ut.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(r=t[1].trim())}}this.writeFileReplaceVar(`methods`,t),this.writeFileHotReloadReplaceVar(`methods`,n),this.writeFileNpmReplaceVar(`methods`,r);let a=``;for(let t in e)for(let n in e[t]){let r=e[t][n];if(a+=`this.__createStatesList(${t}, ${n});`,r.active.length>0){let e=``;for(let t of r.active)e+=`that.`+t+`(state, slugs);`;a+=`this.__addActiveState(${t}, ${n}, (state, slugs) => { that.__inactiveDefaultState(${n}); ${e}})
412
412
  `}if(r.inactive.length>0){let e=``;for(let t of r.inactive)e+=`that.`+t+`(state, nextState, slugs);`;a+=`this.__addInactiveState(${t}, ${n}, (state, nextState, slugs) => { ${e}that.__activeDefaultState(nextState, ${n});})
413
413
  `}if(r.askChange.length>0){let e=``;for(let t of r.askChange)e+=`if(!await that.`+t+`(state, nextState, slugs)){return false;}
414
414
  `;a+=`this.__addAskChangeState(${t}, ${n}, async (state, nextState, slugs) => { ${e} return true;})
415
- `}}(a.length>0||i.length>0)&&(a=`__createStates() { super.__createStates(); let that = this; ${i} ${a} }`),this.writeFileReplaceVar(`states`,a),this.writeFileHotReloadReplaceVar(`states`,a),this.writeFileNpmReplaceVar(`states`,a)}catch{}}variablesInViewDynamic=``;writeViewInfo(e,t,n,r){let i={},a=``,o=``,s=e.elements,c=[];for(let e of s){let n=e.name;if(this.allFields[n]){let r=this.allFields[n];if(r.propType==`ViewElement`){e.useLive=!t;for(let t of r.decorators){let n=tn.is(t);if(n&&n.useLive!==void 0){e.useLive=n.useLive;break}}if(e.useLive){let t=e.ids.map(e=>`[_id="${e}"]`).join(`|`);r.type.isArray||e.isArray?this.variablesInViewDynamic+=`get ${n} () { var list = Array.from(this.shadowRoot.querySelectorAll('${t}')); return list; }
415
+ `}}(a.length>0||i.length>0)&&(a=`__createStates() { super.__createStates(); let that = this; ${i} ${a} }`),this.writeFileReplaceVar(`states`,a),this.writeFileHotReloadReplaceVar(`states`,a),this.writeFileNpmReplaceVar(`states`,a)}catch{}}variablesInViewDynamic=``;writeViewInfo(e,t,n,r){let i={},a=``,o=``,s=e.elements,c=[];for(let e of s){let n=e.name;if(this.allFields[n]){let r=this.allFields[n];if(r.propType==`ViewElement`){e.useLive=!t;for(let t of r.decorators){let n=nn.is(t);if(n&&n.useLive!==void 0){e.useLive=n.useLive;break}}if(e.useLive){let t=e.ids.map(e=>`[_id="${e}"]`).join(`|`);r.type.isArray||e.isArray?this.variablesInViewDynamic+=`get ${n} () { var list = Array.from(this.shadowRoot.querySelectorAll('${t}')); return list; }
416
416
  `:this.variablesInViewDynamic+=`get ${n} () { return this.shadowRoot.querySelector('${t}'); }
417
- `}else e.isArray?c.push({name:e.name,ids:e.ids,isArray:!0}):c.push({name:e.name,ids:e.ids})}else this.result.diagnostics.push(L(this.document,`You must add the decorator @ViewElement for `+n,r.nameStart,r.nameEnd,1011));delete this.viewsElements[n]}else this.createMissingViewElement(e)}c.length>0&&(i.elements=c);let l=e.content,u={};for(let e in l)u[e]={fct:`@_@${l[e].fct}@_@`},l[e].once&&(u[e].once=!0);Object.keys(u).length>0&&(i.content=u),e.injection.length>0&&(i.injection=e.injection);let d=e.bindings,f=[];for(let e of d){let t={id:e.id,injectionName:e.injectionName,eventNames:e.eventNames,inject:e.inject,extract:e.extract};if(e.once&&(t.once=e.once),e.eventNames.length==1&&e.tagName){let n=this.build.getWebComponentDefinition(e.tagName);if(n){let r=this.isCallback(n.class,e.eventNames[0]);r!=null&&(t.isCallback=!0,t.eventNames[0]=r)}else this.build.htmlLanguageService.getInternalTagUri(e.tagName)&&(this.result.needRebuild=!0)}f.push(t)}f.length>0&&(i.bindings=f);let p=[];for(let t of e.events)if(this.methodsName.includes(t.fct)){let e={eventName:t.eventName,id:t.id,fct:`@_@(e, c) => c.comp.${t.fct}(e)@_@`};if(t.tagName){let n=this.build.getWebComponentDefinition(t.tagName);if(n){let r=this.isCallback(n.class,t.eventName);r!=null&&(e.isCallback=!0,e.eventName=r,e.fct=`@_@(c, ...args) => c.comp.${t.fct}.apply(c.comp, ...args)@_@`)}else this.build.htmlLanguageService.getInternalTagUri(t.tagName)&&(this.result.needRebuild=!0)}p.push(e)}else t.position&&this.createMissingMethod(t.fct,t.position.start,t.position.end);p.length>0&&(i.events=p);let m=[],h=[cn[`@dblpress`],cn[`@drag`],cn[`@drag-end`],cn[`@drag-start`],cn[`@longpress`],cn[`@press`],cn[`@press-start`],cn[`@press-stop`]],g=[cn[`@dblpress-delay`],cn[`@longpress-delay`]];for(let t of e.pressEvents){let e={id:t.id};for(let n in t){let r=t[n];r instanceof Object&&(h.includes(n)?this.methodsName.includes(r.value)?e[n]=`@_@(e, pressInstance, c) => { c.comp.${r.value}(e, pressInstance); }@_@`:this.createMissingMethod(r.value,r.start,r.end):g.includes(n)&&(e[n]=`@_@${r.value}@_@`))}m.push(e)}if(m.length>0&&(i.pressEvents=m),e.contextEdits.length>0&&(i.contextEdits=e.contextEdits),Object.keys(i).length>0||n||r){let e=JSON.stringify(i,null,2).replace(/"@_@(.*?)@_@"/g,`$1`).replace(/\\"/g,`"`);if(t)a=`this.__getStatic().__template.setActions(${e});
417
+ `}else e.isArray?c.push({name:e.name,ids:e.ids,isArray:!0}):c.push({name:e.name,ids:e.ids})}else this.result.diagnostics.push(L(this.document,`You must add the decorator @ViewElement for `+n,r.nameStart,r.nameEnd,1011));delete this.viewsElements[n]}else this.createMissingViewElement(e)}c.length>0&&(i.elements=c);let l=e.content,u={};for(let e in l)u[e]={fct:`@_@${l[e].fct}@_@`},l[e].once&&(u[e].once=!0);Object.keys(u).length>0&&(i.content=u),e.injection.length>0&&(i.injection=e.injection);let d=e.bindings,f=[];for(let e of d){let t={id:e.id,injectionName:e.injectionName,eventNames:e.eventNames,inject:e.inject,extract:e.extract};if(e.once&&(t.once=e.once),e.eventNames.length==1&&e.tagName){let n=this.build.getWebComponentDefinition(e.tagName);if(n){let r=this.isCallback(n.class,e.eventNames[0]);r!=null&&(t.isCallback=!0,t.eventNames[0]=r)}else this.build.htmlLanguageService.getInternalTagUri(e.tagName)&&(this.result.needRebuild=!0)}f.push(t)}f.length>0&&(i.bindings=f);let p=[];for(let t of e.events)if(this.methodsName.includes(t.fct)){let e={eventName:t.eventName,id:t.id,fct:`@_@(e, c) => c.comp.${t.fct}(e)@_@`};if(t.tagName){let n=this.build.getWebComponentDefinition(t.tagName);if(n){let r=this.isCallback(n.class,t.eventName);r!=null&&(e.isCallback=!0,e.eventName=r,e.fct=`@_@(c, ...args) => c.comp.${t.fct}.apply(c.comp, ...args)@_@`)}else this.build.htmlLanguageService.getInternalTagUri(t.tagName)&&(this.result.needRebuild=!0)}p.push(e)}else t.position&&this.createMissingMethod(t.fct,t.position.start,t.position.end);p.length>0&&(i.events=p);let m=[],h=[ln[`@dblpress`],ln[`@drag`],ln[`@drag-end`],ln[`@drag-start`],ln[`@longpress`],ln[`@press`],ln[`@press-start`],ln[`@press-stop`]],g=[ln[`@dblpress-delay`],ln[`@longpress-delay`]];for(let t of e.pressEvents){let e={id:t.id};for(let n in t){let r=t[n];r instanceof Object&&(h.includes(n)?this.methodsName.includes(r.value)?e[n]=`@_@(e, pressInstance, c) => { c.comp.${r.value}(e, pressInstance); }@_@`:this.createMissingMethod(r.value,r.start,r.end):g.includes(n)&&(e[n]=`@_@${r.value}@_@`))}m.push(e)}if(m.length>0&&(i.pressEvents=m),e.contextEdits.length>0&&(i.contextEdits=e.contextEdits),Object.keys(i).length>0||n||r){let e=JSON.stringify(i,null,2).replace(/"@_@(.*?)@_@"/g,`$1`).replace(/\\"/g,`"`);if(t)a=`this.__getStatic().__template.setActions(${e});
418
418
  `;else if(n){a=`const templ${n.templateId} = new Aventus.Template(this);
419
419
  `,a+=`templ${n.templateId}.setTemplate(\`${n.template}\`);
420
420
  `,Object.keys(i).length>0&&(a+=`templ${n.templateId}.setActions(${e});
@@ -460,7 +460,7 @@ this.clearWatchHistory = () => {
460
460
  }`),this.writeFileReplaceVar(`watchesChangeCb`,e),this.writeFileHotReloadReplaceVar(`watchesChangeCb`,e),this.writeFileNpmReplaceVar(`watchesChangeCb`,e)}createHtmlDoc(e,t){if(this.htmlDoc){let n=[];if(e.isProtected||e.isPrivate)return;let r=`string`;if(t.kind==`literal`){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),n.push({name:e,description:``})}else if(t.kind==`union`)for(let e of t.nested){let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),n.push({name:t,description:``})}else t.kind==`boolean`?r=`boolean`:t.kind==`number`?r=`number`:t.kind==`type`&&t.value==`Date`?r=`Date`:t.kind==`type`&&t.value==`DateTime`&&(r=`DateTime`);this.htmlDoc[this.tagName].attributes[e.name]={name:e.name,description:e.documentation?.definitions.join(`
461
461
  `)??``,type:r,values:n}}}createInjectableHtmlDoc(e){if(this.htmlDoc)for(let t of e)this.htmlDoc[this.tagName].attributes[t.name]={name:`:`+t.name,description:t.documentation?.fullDefinitions.join(`
462
462
  `)??``,values:[]}}createEventsHtmlDoc(e){if(this.htmlDoc)for(let t of e){let e=t.name;e.startsWith(`on`)&&(e=e.slice(2),e=e.charAt(0).toLowerCase()+e.slice(1)),this.htmlDoc[this.tagName].attributes[t.name]={name:`@`+e,description:t.documentation?.fullDefinitions.join(`
463
- `)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(D.isRunning){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateHotReload=this.templateHotReload.replace(n,t+``)}}writeFileNpmReplaceVar(e,t){if(this.templateNpm){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateNpm=this.templateNpm.replace(n,t+``)}}createMissingMethod(e,t,n){if(!this.htmlParsed)return;if(this.result.missingMethods.position==-1){let e=Zt(this.file,`methods`);this.result.missingMethods.position=e}let r=`missing method `+e;this.result.missingMethods.elements.includes(e)||(this.result.missingMethods.elements.push(e),this.result.diagnostics.push(Ri(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Vi(this.htmlFile.file.documentUser,r,t,n))}createMissingViewElement(e){let t=[];for(let n in e.tags){let r=this.build.htmlLanguageService.getClassByTag(n),i=``;i=r||this.build.htmlLanguageService.getGenericHTML(n)||`HTMLElement`,e.tags[n]>1&&(i+=`[]`),t.push(i)}let n=``;if(t.length==1)n=t[0];else if(t.length>1){for(let e=0;e<t.length;e++)t[e]=t[e].replace(`[]`,``);n=`(`+t.join(` | `)+`)[]`}let r=`Missing variable view element`+e.name;if(this.result.missingViewElements.elements[e.name]=n,this.result.diagnostics.push(Ri(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Vi(this.htmlFile.file.documentUser,r,t.start,t.end))}createUnusedViewElement(e){let t=e.name;this.overrideViewDecorator?this.overrideViewDecorator.removeViewVariables.indexOf(t)==-1&&this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end})):this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end}))}isCallback(e,t){let n;n=t.startsWith(`on`)?[t]:[t,`on`+t,`on`+t.charAt(0).toUpperCase()+t.slice(1)];for(let t of n){let n=e.getField(t);if(n){let e=n.type.value;if(Et.includes(e))return t}}return null}prepareDocSCSS(){let e=this.scssFile?.customProperties??[],t={[this.tagName]:e};if(this.hasStory&&this.classInfo?.storieContent){let t=this.classInfo.storieContent;delete t.style;let n=[];for(let t of e){this.storyArgTypes[t.name]={table:{category:`Style`}};let e={name:t.name};t.documentation&&(this.storyArgTypes[t.name].description=t.documentation,e.documentation=t.documentation),t.type&&(e.type=t.type),t.type==`color`?(this.storyArgTypes[t.name].control=`color`,this.storyArgTypes[t.name].type=`color`):(this.storyArgTypes[t.name].type=`string`,this.storyArgTypes[t.name].control=`text`),t.defaultValue&&(this.storyArgs[t.name]=`"${t.defaultValue}"`),t.chainValues&&(e.value=t.chainValues.join(` | `)),n.push(e)}n.length>0&&(t.style=n)}return t}prepareMethodToTranspile(e){if(e=e.trim(),e.startsWith(`function`)&&(e=e.replace(`function`,``),e=e.trim()),!e.match(/^\(.*?\)( *?)=>/g)&&!e.match(/^\S*?( *?)=>/g)){e=e.replace(/^.*?\(/g,`(`);let t=e.match(/^\(.*?\)/g);t&&(e=e.replace(t[0],t[0]+` => `))}return e}transpileMethodNoRun(e){try{e=this.prepareMethodToTranspile(e);let t=(0,p.transpile)(e,Ht.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`)return n;{let r=A.getBaseInfo(n.value,e.uri);if(r&&r instanceof yt)return this._validateTypeForProp(e,t,r.type)}}else if(n.kind==`literal`)return n;else if(n.kind==`union`){let r;for(let e of n.nested)if(e.kind==`undefined`&&(t.isNullable=!0),!r)e.kind!=`undefined`&&(r=e);else if(e.kind!=r.kind&&e.kind!=`undefined`){r=void 0;break}if(r)return r.kind==`literal`?n:this._validateTypeForProp(e,t,r)}else if(n.kind==`typeOperator`&&n.value==`keyof`)return n;return this.result.diagnostics.push(L(e,`Can't use the the type `+n.kind+` (`+n.value+`) as attribute / property`,t.nameStart,t.nameEnd,1016)),null}validateTypeForProp(e,t){t.name.toLowerCase()!=t.name&&this.result.diagnostics.push(L(this.document,`An attribute must be in lower case`,t.nameStart,t.nameEnd,1005));let n=this._validateTypeForProp(e,t,t.type);return n&&(n.kind==`boolean`||n.kind==`number`?!t.overrideNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,t.nameStart,t.nameEnd,1025)):!t.isNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ? after the name to allow undefined value`,t.nameStart,t.nameEnd,1026))),n}removeWhiteSpaceLines(e){return e.replace(/^(?:[\t ]*(?:\r?\n|\r))+/gm,``)}},gn=class e{static parse(t,n){return new e(t,n)}AventusDefaultComponent=`Aventus.DefaultComponent`;end=-1;currentNamespace=[];fullname=``;className=``;tagName=null;whiteSpaceBefore=0;writeHtml=!1;writeTs=!1;prefixes;isAbstract=!1;constructor(e,t){this.currentNamespace.push(t.module),t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`),this.prefixes=t.getComponentPrefix().split(`-`),this.loadRoot((0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0))}loadRoot(e){if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if((0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if(e.kind==p.SyntaxKind.ClassDeclaration)return this.loadClass(e)}),this.end)return!0}loadNamespace(e){if(tt(e.flags,p.NodeFlags.Namespace)&&e.body){this.currentNamespace.push(e.name.getText());let t=this.loadRoot(e.body);return this.currentNamespace.splice(this.currentNamespace.length-1,1),t}else if(tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body)return this.loadRoot(e.body)}loadClass(e){let t=/^(\s)*/.exec(e.getText());if(t&&(this.whiteSpaceBefore=t[0].length),e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.name&&e.heritageClauses){let t=e.name;for(let n of e.heritageClauses)if(n.token==p.SyntaxKind.ImplementsKeyword&&((0,p.forEachChild)(n,n=>{if(n.kind==p.SyntaxKind.ExpressionWithTypeArguments&&n.getText()==this.AventusDefaultComponent){this.end=e.getEnd(),this.fullname=[...this.currentNamespace,t.getText()].join(`.`),this.className=t.getText();let n=at.buildDecorator(e);for(let e of n){let t=Ft.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=$t.is(e);t&&(this.tagName=t.tagName)}}if(!this.isAbstract&&this.tagName==null){let e=this.className.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(e){for(let t=0;t<this.prefixes.length;t++){let n=this.prefixes[t];if(n.length>0&&e[t].toLowerCase()!=n.toLowerCase()){e.splice(0,0,this.prefixes.join(`-`).toLowerCase());break}}this.tagName=e.join(`-`).toLowerCase()}}return!0}}),this.end))return!0}}},j=class e extends Nt{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=hn.getVersion(this,this.build);return e.html=e.html==-1?0:e.html,e.i18n=e.i18n==-1?0:e.i18n,e.scss=e.scss==-1?0:e.scss,e.ts=e.ts==-1?0:e.ts,e.html+e.i18n+e.scss+e.ts}get HTMLFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(w.ComponentLogic,w.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+na(this.fullName)+`method`}_componentEnd=0;get componentEnd(){return this._componentEnd}_componentClassName=``;get componentClassName(){return this._componentClassName}_space=``;writeHtml=!1;writeTs=!1;needRebuild=!1;htmlDiagnostics=[];constructor(e,t){super(e,t),e.linkInternalAndUser=!1,this.quickParse(),this.refreshFileParsed()}waitingFct={};mergedVersion=`-1_-1_-1_-1`;isCompiling=!1;runWebCompiler(){return new Promise(e=>{let t=hn.getVersion(this,this.build),n=t.ts+`_`+t.scss+`_`+t.html+`_`+t.i18n,r=this.build.insideRebuildAll||this.needRebuild;if(n==this.mergedVersion&&!r)e();else if(this.isCompiling)this.waitingFct[n]||(this.waitingFct[n]=[]),this.waitingFct[n].push(()=>{e()});else{this.isCompiling=!0,this.needRebuild=!1,this.recreateFileContent();let t=new hn(this,this.build);if(this._compilationResult=t.compile(),this.build.scssLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.scssDoc),this.build.htmlLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.htmlDoc,this),this.needRebuild=this._compilationResult.needRebuild,this.isCompiling=!1,this.mergedVersion=n,this.storyBookInfo.argsTypes=t.storyArgTypes,this.storyBookInfo.args=t.storyArgs,this.I18nFile&&this.I18nFile.transformForExport(),this.waitingFct[n])for(let e of this.waitingFct[n])e();e()}})}lastFileVersionCreated={html:-1,js:-1,i18n:-1};typeInfered={};recreateFileContent(){let e=this.HTMLFile,t=e?.file.versionUser??0,n=this.I18nFile,r=n?.file.versionUser??0,i=this.file.documentUser.version+t+r+1;if(e){let a=!1,o=!1;if(this.lastFileVersionCreated.js==this.file.documentUser.version?this.lastFileVersionCreated.html==t?this.lastFileVersionCreated.i18n!=r&&(a=!0):a=!0:(a=!0,o=!0),a){this.lastFileVersionCreated={html:t,js:this.file.documentUser.version,i18n:r};let a=``;if(this.componentEnd>=0){let t=this.file.documentUser.getText(),r=1;for(;[`}`,` `,` `].includes(t[this.componentEnd-r]);)r++;a=t.slice(0,this.componentEnd-r),this.viewMethodsInfo=[];let s=0,c=``,l=e=>{let t=[];for(let n of e){let e=this.typeInfered[n]??`any`;t.push(n+`:`+e)}return t};o&&(()=>{if(!e)return;let t=e.fileParsed?.loops??[],n=0;for(let e of t){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.loopName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.loopTxt+`
463
+ `)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(D.isRunning){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateHotReload=this.templateHotReload.replace(n,t+``)}}writeFileNpmReplaceVar(e,t){if(this.templateNpm){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateNpm=this.templateNpm.replace(n,t+``)}}createMissingMethod(e,t,n){if(!this.htmlParsed)return;if(this.result.missingMethods.position==-1){let e=Qt(this.file,`methods`);this.result.missingMethods.position=e}let r=`missing method `+e;this.result.missingMethods.elements.includes(e)||(this.result.missingMethods.elements.push(e),this.result.diagnostics.push(zi(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Hi(this.htmlFile.file.documentUser,r,t,n))}createMissingViewElement(e){let t=[];for(let n in e.tags){let r=this.build.htmlLanguageService.getClassByTag(n),i=``;i=r||this.build.htmlLanguageService.getGenericHTML(n)||`HTMLElement`,e.tags[n]>1&&(i+=`[]`),t.push(i)}let n=``;if(t.length==1)n=t[0];else if(t.length>1){for(let e=0;e<t.length;e++)t[e]=t[e].replace(`[]`,``);n=`(`+t.join(` | `)+`)[]`}let r=`Missing variable view element`+e.name;if(this.result.missingViewElements.elements[e.name]=n,this.result.diagnostics.push(zi(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Hi(this.htmlFile.file.documentUser,r,t.start,t.end))}createUnusedViewElement(e){let t=e.name;this.overrideViewDecorator?this.overrideViewDecorator.removeViewVariables.indexOf(t)==-1&&this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end})):this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end}))}isCallback(e,t){let n;n=t.startsWith(`on`)?[t]:[t,`on`+t,`on`+t.charAt(0).toUpperCase()+t.slice(1)];for(let t of n){let n=e.getField(t);if(n){let e=n.type.value;if(Dt.includes(e))return t}}return null}prepareDocSCSS(){let e=this.scssFile?.customProperties??[],t={[this.tagName]:e};if(this.hasStory&&this.classInfo?.storieContent){let t=this.classInfo.storieContent;delete t.style;let n=[];for(let t of e){this.storyArgTypes[t.name]={table:{category:`Style`}};let e={name:t.name};t.documentation&&(this.storyArgTypes[t.name].description=t.documentation,e.documentation=t.documentation),t.type&&(e.type=t.type),t.type==`color`?(this.storyArgTypes[t.name].control=`color`,this.storyArgTypes[t.name].type=`color`):(this.storyArgTypes[t.name].type=`string`,this.storyArgTypes[t.name].control=`text`),t.defaultValue&&(this.storyArgs[t.name]=`"${t.defaultValue}"`),t.chainValues&&(e.value=t.chainValues.join(` | `)),n.push(e)}n.length>0&&(t.style=n)}return t}prepareMethodToTranspile(e){if(e=e.trim(),e.startsWith(`function`)&&(e=e.replace(`function`,``),e=e.trim()),!e.match(/^\(.*?\)( *?)=>/g)&&!e.match(/^\S*?( *?)=>/g)){e=e.replace(/^.*?\(/g,`(`);let t=e.match(/^\(.*?\)/g);t&&(e=e.replace(t[0],t[0]+` => `))}return e}transpileMethodNoRun(e){try{e=this.prepareMethodToTranspile(e);let t=(0,p.transpile)(e,Ut.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`)return n;{let r=A.getBaseInfo(n.value,e.uri);if(r&&r instanceof yt)return this._validateTypeForProp(e,t,r.type)}}else if(n.kind==`literal`)return n;else if(n.kind==`union`){let r;for(let e of n.nested)if(e.kind==`undefined`&&(t.isNullable=!0),!r)e.kind!=`undefined`&&(r=e);else if(e.kind!=r.kind&&e.kind!=`undefined`){r=void 0;break}if(r)return r.kind==`literal`?n:this._validateTypeForProp(e,t,r)}else if(n.kind==`typeOperator`&&n.value==`keyof`)return n;return this.result.diagnostics.push(L(e,`Can't use the the type `+n.kind+` (`+n.value+`) as attribute / property`,t.nameStart,t.nameEnd,1016)),null}validateTypeForProp(e,t){t.name.toLowerCase()!=t.name&&this.result.diagnostics.push(L(this.document,`An attribute must be in lower case`,t.nameStart,t.nameEnd,1005));let n=this._validateTypeForProp(e,t,t.type);return n&&(n.kind==`boolean`||n.kind==`number`?!t.overrideNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,t.nameStart,t.nameEnd,1025)):!t.isNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ? after the name to allow undefined value`,t.nameStart,t.nameEnd,1026))),n}removeWhiteSpaceLines(e){return e.replace(/^(?:[\t ]*(?:\r?\n|\r))+/gm,``)}},_n=class e{static parse(t,n){return new e(t,n)}AventusDefaultComponent=`Aventus.DefaultComponent`;end=-1;currentNamespace=[];fullname=``;className=``;tagName=null;whiteSpaceBefore=0;writeHtml=!1;writeTs=!1;prefixes;isAbstract=!1;constructor(e,t){this.currentNamespace.push(t.module),t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`),this.prefixes=t.getComponentPrefix().split(`-`),this.loadRoot((0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0))}loadRoot(e){if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if((0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if(e.kind==p.SyntaxKind.ClassDeclaration)return this.loadClass(e)}),this.end)return!0}loadNamespace(e){if(tt(e.flags,p.NodeFlags.Namespace)&&e.body){this.currentNamespace.push(e.name.getText());let t=this.loadRoot(e.body);return this.currentNamespace.splice(this.currentNamespace.length-1,1),t}else if(tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body)return this.loadRoot(e.body)}loadClass(e){let t=/^(\s)*/.exec(e.getText());if(t&&(this.whiteSpaceBefore=t[0].length),e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.name&&e.heritageClauses){let t=e.name;for(let n of e.heritageClauses)if(n.token==p.SyntaxKind.ImplementsKeyword&&((0,p.forEachChild)(n,n=>{if(n.kind==p.SyntaxKind.ExpressionWithTypeArguments&&n.getText()==this.AventusDefaultComponent){this.end=e.getEnd(),this.fullname=[...this.currentNamespace,t.getText()].join(`.`),this.className=t.getText();let n=at.buildDecorator(e);for(let e of n){let t=It.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=en.is(e);t&&(this.tagName=t.tagName)}}if(!this.isAbstract&&this.tagName==null){let e=this.className.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(e){for(let t=0;t<this.prefixes.length;t++){let n=this.prefixes[t];if(n.length>0&&e[t].toLowerCase()!=n.toLowerCase()){e.splice(0,0,this.prefixes.join(`-`).toLowerCase());break}}this.tagName=e.join(`-`).toLowerCase()}}return!0}}),this.end))return!0}}},j=class e extends Pt{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=gn.getVersion(this,this.build);return e.html=e.html==-1?0:e.html,e.i18n=e.i18n==-1?0:e.i18n,e.scss=e.scss==-1?0:e.scss,e.ts=e.ts==-1?0:e.ts,e.html+e.i18n+e.scss+e.ts}get HTMLFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(w.ComponentLogic,w.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+ra(this.fullName)+`method`}_componentEnd=0;get componentEnd(){return this._componentEnd}_componentClassName=``;get componentClassName(){return this._componentClassName}_space=``;writeHtml=!1;writeTs=!1;needRebuild=!1;htmlDiagnostics=[];constructor(e,t){super(e,t),e.linkInternalAndUser=!1,this.quickParse(),this.refreshFileParsed()}waitingFct={};mergedVersion=`-1_-1_-1_-1`;isCompiling=!1;runWebCompiler(){return new Promise(e=>{let t=gn.getVersion(this,this.build),n=t.ts+`_`+t.scss+`_`+t.html+`_`+t.i18n,r=this.build.insideRebuildAll||this.needRebuild;if(n==this.mergedVersion&&!r)e();else if(this.isCompiling)this.waitingFct[n]||(this.waitingFct[n]=[]),this.waitingFct[n].push(()=>{e()});else{this.isCompiling=!0,this.needRebuild=!1,this.recreateFileContent();let t=new gn(this,this.build);if(this._compilationResult=t.compile(),this.build.scssLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.scssDoc),this.build.htmlLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.htmlDoc,this),this.needRebuild=this._compilationResult.needRebuild,this.isCompiling=!1,this.mergedVersion=n,this.storyBookInfo.argsTypes=t.storyArgTypes,this.storyBookInfo.args=t.storyArgs,this.I18nFile&&this.I18nFile.transformForExport(),this.waitingFct[n])for(let e of this.waitingFct[n])e();e()}})}lastFileVersionCreated={html:-1,js:-1,i18n:-1};typeInfered={};recreateFileContent(){let e=this.HTMLFile,t=e?.file.versionUser??0,n=this.I18nFile,r=n?.file.versionUser??0,i=this.file.documentUser.version+t+r+1;if(e){let a=!1,o=!1;if(this.lastFileVersionCreated.js==this.file.documentUser.version?this.lastFileVersionCreated.html==t?this.lastFileVersionCreated.i18n!=r&&(a=!0):a=!0:(a=!0,o=!0),a){this.lastFileVersionCreated={html:t,js:this.file.documentUser.version,i18n:r};let a=``;if(this.componentEnd>=0){let t=this.file.documentUser.getText(),r=1;for(;[`}`,` `,` `].includes(t[this.componentEnd-r]);)r++;a=t.slice(0,this.componentEnd-r),this.viewMethodsInfo=[];let s=0,c=``,l=e=>{let t=[];for(let n of e){let e=this.typeInfered[n]??`any`;t.push(n+`:`+e)}return t};o&&(()=>{if(!e)return;let t=e.fileParsed?.loops??[],n=0;for(let e of t){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.loopName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.loopTxt+`
464
464
  `,r+=`}
465
465
  `,r+=`}`,this.file instanceof E&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=e.loopTxt.slice(t.start-e.start,t.end-e.start),i=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[r]=i}n++}let r=e.fileParsed?.contextEdits??[];for(let e of r){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.editName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.fctTs+`
466
466
  `,r+=`}
@@ -497,7 +497,7 @@ this.clearWatchHistory = () => {
497
497
  `;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
498
498
  `);c+=`\ntype ${this.componentClassName}__Generated = {
499
499
  ${n}
500
- }`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof E&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let s=(0,f.join)(this.file.folderPath,`compiled.html`),c=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(s,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(s)&&ra(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&ra(c)}}else this.file instanceof E&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,this.file.contentUser)),this.refreshFileParsed()}async onValidate(){return await this.runWebCompiler(),this.diagnostics=this.compilationResult?.diagnostics||[],this.transformDiagnosticForView(),this.HTMLFile?.validate(),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}transformDiagnosticForView(){let e=this.HTMLFile;if(e){let t=[],n=[],r=[];for(let i of this.diagnostics){let a=this.file.documentInternal.offsetAt(i.range.start),o=this.file.documentInternal.offsetAt(i.range.end),s=!1,c=a>=this.file.contentUser.length;for(let t=0;t<this.viewMethodsInfo.length;t++){let c=this.viewMethodsInfo[t].fullStart,l=this.viewMethodsInfo[t].end;if(a>c&&o<l){i.source=C.HTML;let c=this.viewMethodsInfo[t].fct,l=this.viewMethodsInfo[t].offsetAfter,u=this.viewMethodsInfo[t].offsetBefore;if(r.indexOf(i.range)==-1){let s=this.viewMethodsInfo[t].transform(a,0);r.push(i.range);let d=a-this.viewMethodsInfo[t].start-s,f=o-this.viewMethodsInfo[t].start-s;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start,a=c.positions[t].end,o=i;t>0&&(o={...i});let s=r+u+d,p=r+u+f;s<r||p>a-l?o.range={start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(a)}:o.range={start:e.file.documentInternal.positionAt(s),end:e.file.documentInternal.positionAt(p)},t>0&&n.push(o)}}s=!0;break}}s?n.push(i):c||t.push(i)}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=gn.parse(this.file.documentUser.getText(),this.build);this._componentEnd=e.end,this._fullname=e.fullname,this._componentClassName=e.className,this.writeHtml=e.writeHtml,this.writeTs=e.writeTs,e.tagName&&this.build.htmlLanguageService.addInternalTagUri(e.tagName,this.file.uri,this._fullname);let t=``;for(let n=0;n<e.whiteSpaceBefore+4;n++)t+=` `;this._space=t}async onContentChange(){this.quickParse(),await this.runWebCompiler()}async onSave(){await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,qi(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&ra(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),D.getInstance().updateComponent(r,e+i,[])}}async onDelete(){await super.onDelete(),this.build.scssLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalTagUri(this.file.uri)}async doViewCompletion(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onCompletion(this.file,o),c=[],l=[];for(let n of s.items)if(!(this.viewMethodName&&n.label.startsWith(this.viewMethodName))){if(n.data&&n.data.uri&&(n.data.languageId=C.HTML,n.data.uri=t.file.uri),n.textEdit){let i=n.textEdit;if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}if(n.additionalTextEdits){for(let i of n.additionalTextEdits)if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}c.push(n)}return s.items=c,s}return null}async onCompletion(e,t){return await this.runWebCompiler(),this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}async doHover(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onHover(this.file,o);if(s&&s.range){let n=this.file.documentInternal.offsetAt(s.range.start),i=this.file.documentInternal.offsetAt(s.range.end),a=e.transform(n,0),o=n-e.start-a,c=i-e.start-a;s.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+o),s.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}return s}return null}onHover(e,t){return this.tsLanguageService.doHover(e,t)}async doDefinition(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(r,i);let a=this.file.documentInternal.positionAt(i);return await this.onDefinition(this.file,a)}return null}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async doFormatting(e,t){return await this.runWebCompiler(),this.HTMLFile?(await this.getFormatting(t,!1)).html:null}async onFormatting(e,t,n){return(await this.getFormatting(n,!0)).js}async getFormatting(e,t){let n={js:[],html:[]},r={start:{character:0,line:0},end:this.file.documentInternal.positionAt(this.file.contentInternal.length)},i=await this.tsLanguageService.format(this.file,r,e,t),a=this.HTMLFile,o=[];for(let e of i){let t=this.file.documentInternal.offsetAt(e.range.start),r=this.file.documentInternal.offsetAt(e.range.end),i=!1,s=t>=this.file.contentUser.length;if(a)for(let a=0;a<this.viewMethodsInfo.length;a++){let s=this.viewMethodsInfo[a].start,c=this.viewMethodsInfo[a].end,l=this.viewMethodsInfo[a].transform(t,0);if(t>=s+l&&r<c){if(t==s&&!/\S/.test(e.newText)){i=!0;break}let c=this.viewMethodsInfo[a].fct,u=this.viewMethodsInfo[a].offsetBefore;if(o.indexOf(e.range)==-1){o.push(e.range);let i=t-this.viewMethodsInfo[a].start-l,s=r-this.viewMethodsInfo[a].start-l;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start+u+i,o=c.positions[t].start+u+s;n.html.push({edit:{newText:e.newText,range:{start:r,end:o}},start:c.positions[t].start,end:c.positions[t].end,kind:this.viewMethodsInfo[a].kind})}}i=!0;break}else if(t>=this.viewMethodsInfo[a].fullStart&&r<=c){i=!0;break}}!i&&!s&&n.js.push(e)}return n}async onCodeAction(e,t){let n=await this.tsLanguageService.doCodeAction(e,t);return this.addCustomCodeAction(n),n}async doReferences(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(i,i);let a=this.file.documentInternal.positionAt(i);return await this.onReferences(this.file,a)}return null}async onReferences(e,t){let n=[],r=await this.tsLanguageService.onReferences(e,t)||[];if(this._compilationResult?.componentName&&this.fileParsed?.classes[this._compilationResult.componentName]){let e=this.file.documentInternal.offsetAt(t),r=this.fileParsed?.classes[this._compilationResult.componentName];if(e>=r.nameStart&&e<=r.nameEnd)for(let[e,t]of this.reverseViewClassInfoDependencies)for(let r of t)n.push({uri:e.file.uri,range:{start:e.file.documentInternal.positionAt(r.start),end:e.file.documentInternal.positionAt(r.end)}})}let i=[...r,...n];return i=this.transformRefrencesToView(i),i}transformRefrencesToView(t){let n=[];for(let r of t){if(r.uri.endsWith(w.ComponentLogic)){let t=this.build.tsFiles[r.uri];if(!t)continue;if(t instanceof e){let e=t.HTMLFile;if(e){let i=[],a=t._file.documentInternal.offsetAt(r.range.start),o=t._file.documentInternal.offsetAt(r.range.end);for(let t=0;t<this.viewMethodsInfo.length;t++){let s=this.viewMethodsInfo[t].fullStart,c=this.viewMethodsInfo[t].end;if(a>s&&o<c){r.uri=e.file.uri;let s=this.viewMethodsInfo[t].fct,c=this.viewMethodsInfo[t].offsetBefore;if(this.viewMethodsInfo[t].offsetAfter,i.indexOf(r.range)==-1){let l=this.viewMethodsInfo[t].transform(a,0);i.push(r.range);let u=a-this.viewMethodsInfo[t].start-l,d=o-this.viewMethodsInfo[t].start-l;for(let t=0;t<s.positions.length;t++){let i=s.positions[t].start+c+u,a=s.positions[t].start+c+d,o=r;t>0&&(o={...o}),o.range={start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(a)},t>0&&n.push(o)}}break}}}}}n.push(r)}return n}async onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async doRename(e,t){let n=this.HTMLFile;if(!n)return null;let r=n.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let n of e.fct.positions)if(r>=n.start+e.offsetBefore&&r<=n.end){let i=r-n.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a);return await this.onRename(this.file,o,t)}return null}async onRename(e,t,n){let r=await this.tsLanguageService.onRename(e,t,n);return r&&this.transformRenameToView(r),r}transformRenameToView(t){if(t.changes){let n={};for(let r in t.changes)if(r.endsWith(w.ComponentLogic)){let i=t.changes[r],a=this.build.tsFiles[r];if(!a)continue;if(a instanceof e){let e=a.HTMLFile;if(e)for(let t=0;t<i.length;t++){let r=i[t],o=a._file.documentInternal.offsetAt(r.range.start),s=a._file.documentInternal.offsetAt(r.range.end);for(let a=0;a<this.viewMethodsInfo.length;a++){let c=this.viewMethodsInfo[a].fullStart,l=this.viewMethodsInfo[a].end;if(o>c&&s<l){n[e.file.uri]||(n[e.file.uri]=[]);let c=this.viewMethodsInfo[a].fct,l=this.viewMethodsInfo[a].transform(o,0),u=o-this.viewMethodsInfo[a].start-l,d=s-this.viewMethodsInfo[a].start-l;for(let t of c.positions){let i=t.start+this.viewMethodsInfo[a].offsetBefore+u,o=t.start+this.viewMethodsInfo[a].offsetBefore+d;n[e.file.uri].push({newText:r.newText,range:{start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(o)}})}i.splice(t,1),t--;break}}}}}for(let e in n)if(!t.changes[e])t.changes[e]=n[e];else for(let r of n[e])t.changes[e].push(r)}}addCustomCodeAction(e){let t=!1,n=!1;for(let r of this.diagnostics)if(r.code==1011&&!t)t=!0,e.push({title:`Import missing view elements`,command:{command:`aventus.wc.import.viewElement`,title:`Import missing view elements`}});else if(r.code==1014){let t=r.message.match(/#[a-zA-Z0-9_]+/g);if(t){let n=t[0].replace(`#`,``);e.push({title:`Import missing property `+n,command:{command:`aventus.wc.create.property`,title:`Create property`,arguments:[`prefill:`+n]}})}}else if(r.code==1019&&!n)n=!0,e.push({title:`Import missing methods`,command:{command:`aventus.wc.import.viewMethod`,title:`Import missing methods`}});else if(r.code==1012&&r.data){let t=r.data;e.push({title:`Remove element`,edit:{changes:{[this.file.uri]:[{newText:``,range:{start:this.file.documentInternal.positionAt(t.start),end:this.file.documentInternal.positionAt(t.end)}}]}}})}}getMissingVariablesInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingViewElements.position;for(let t in this.compilationResult.missingViewElements.elements)e+=`@ViewElement()
500
+ }`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof E&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let s=(0,f.join)(this.file.folderPath,`compiled.html`),c=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(s,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(s)&&ia(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&ia(c)}}else this.file instanceof E&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,this.file.contentUser)),this.refreshFileParsed()}async onValidate(){return await this.runWebCompiler(),this.diagnostics=this.compilationResult?.diagnostics||[],this.transformDiagnosticForView(),this.HTMLFile?.validate(),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}transformDiagnosticForView(){let e=this.HTMLFile;if(e){let t=[],n=[],r=[];for(let i of this.diagnostics){let a=this.file.documentInternal.offsetAt(i.range.start),o=this.file.documentInternal.offsetAt(i.range.end),s=!1,c=a>=this.file.contentUser.length;for(let t=0;t<this.viewMethodsInfo.length;t++){let c=this.viewMethodsInfo[t].fullStart,l=this.viewMethodsInfo[t].end;if(a>c&&o<l){i.source=C.HTML;let c=this.viewMethodsInfo[t].fct,l=this.viewMethodsInfo[t].offsetAfter,u=this.viewMethodsInfo[t].offsetBefore;if(r.indexOf(i.range)==-1){let s=this.viewMethodsInfo[t].transform(a,0);r.push(i.range);let d=a-this.viewMethodsInfo[t].start-s,f=o-this.viewMethodsInfo[t].start-s;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start,a=c.positions[t].end,o=i;t>0&&(o={...i});let s=r+u+d,p=r+u+f;s<r||p>a-l?o.range={start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(a)}:o.range={start:e.file.documentInternal.positionAt(s),end:e.file.documentInternal.positionAt(p)},t>0&&n.push(o)}}s=!0;break}}s?n.push(i):c||t.push(i)}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=_n.parse(this.file.documentUser.getText(),this.build);this._componentEnd=e.end,this._fullname=e.fullname,this._componentClassName=e.className,this.writeHtml=e.writeHtml,this.writeTs=e.writeTs,e.tagName&&this.build.htmlLanguageService.addInternalTagUri(e.tagName,this.file.uri,this._fullname);let t=``;for(let n=0;n<e.whiteSpaceBefore+4;n++)t+=` `;this._space=t}async onContentChange(){this.quickParse(),await this.runWebCompiler()}async onSave(){await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,Ji(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&ia(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),D.getInstance().updateComponent(r,e+i,[])}}async onDelete(){await super.onDelete(),this.build.scssLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalTagUri(this.file.uri)}async doViewCompletion(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onCompletion(this.file,o),c=[],l=[];for(let n of s.items)if(!(this.viewMethodName&&n.label.startsWith(this.viewMethodName))){if(n.data&&n.data.uri&&(n.data.languageId=C.HTML,n.data.uri=t.file.uri),n.textEdit){let i=n.textEdit;if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}if(n.additionalTextEdits){for(let i of n.additionalTextEdits)if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}c.push(n)}return s.items=c,s}return null}async onCompletion(e,t){return await this.runWebCompiler(),this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}async doHover(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onHover(this.file,o);if(s&&s.range){let n=this.file.documentInternal.offsetAt(s.range.start),i=this.file.documentInternal.offsetAt(s.range.end),a=e.transform(n,0),o=n-e.start-a,c=i-e.start-a;s.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+o),s.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}return s}return null}onHover(e,t){return this.tsLanguageService.doHover(e,t)}async doDefinition(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(r,i);let a=this.file.documentInternal.positionAt(i);return await this.onDefinition(this.file,a)}return null}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async doFormatting(e,t){return await this.runWebCompiler(),this.HTMLFile?(await this.getFormatting(t,!1)).html:null}async onFormatting(e,t,n){return(await this.getFormatting(n,!0)).js}async getFormatting(e,t){let n={js:[],html:[]},r={start:{character:0,line:0},end:this.file.documentInternal.positionAt(this.file.contentInternal.length)},i=await this.tsLanguageService.format(this.file,r,e,t),a=this.HTMLFile,o=[];for(let e of i){let t=this.file.documentInternal.offsetAt(e.range.start),r=this.file.documentInternal.offsetAt(e.range.end),i=!1,s=t>=this.file.contentUser.length;if(a)for(let a=0;a<this.viewMethodsInfo.length;a++){let s=this.viewMethodsInfo[a].start,c=this.viewMethodsInfo[a].end,l=this.viewMethodsInfo[a].transform(t,0);if(t>=s+l&&r<c){if(t==s&&!/\S/.test(e.newText)){i=!0;break}let c=this.viewMethodsInfo[a].fct,u=this.viewMethodsInfo[a].offsetBefore;if(o.indexOf(e.range)==-1){o.push(e.range);let i=t-this.viewMethodsInfo[a].start-l,s=r-this.viewMethodsInfo[a].start-l;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start+u+i,o=c.positions[t].start+u+s;n.html.push({edit:{newText:e.newText,range:{start:r,end:o}},start:c.positions[t].start,end:c.positions[t].end,kind:this.viewMethodsInfo[a].kind})}}i=!0;break}else if(t>=this.viewMethodsInfo[a].fullStart&&r<=c){i=!0;break}}!i&&!s&&n.js.push(e)}return n}async onCodeAction(e,t){let n=await this.tsLanguageService.doCodeAction(e,t);return this.addCustomCodeAction(n),n}async doReferences(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(i,i);let a=this.file.documentInternal.positionAt(i);return await this.onReferences(this.file,a)}return null}async onReferences(e,t){let n=[],r=await this.tsLanguageService.onReferences(e,t)||[];if(this._compilationResult?.componentName&&this.fileParsed?.classes[this._compilationResult.componentName]){let e=this.file.documentInternal.offsetAt(t),r=this.fileParsed?.classes[this._compilationResult.componentName];if(e>=r.nameStart&&e<=r.nameEnd)for(let[e,t]of this.reverseViewClassInfoDependencies)for(let r of t)n.push({uri:e.file.uri,range:{start:e.file.documentInternal.positionAt(r.start),end:e.file.documentInternal.positionAt(r.end)}})}let i=[...r,...n];return i=this.transformRefrencesToView(i),i}transformRefrencesToView(t){let n=[];for(let r of t){if(r.uri.endsWith(w.ComponentLogic)){let t=this.build.tsFiles[r.uri];if(!t)continue;if(t instanceof e){let e=t.HTMLFile;if(e){let i=[],a=t._file.documentInternal.offsetAt(r.range.start),o=t._file.documentInternal.offsetAt(r.range.end);for(let t=0;t<this.viewMethodsInfo.length;t++){let s=this.viewMethodsInfo[t].fullStart,c=this.viewMethodsInfo[t].end;if(a>s&&o<c){r.uri=e.file.uri;let s=this.viewMethodsInfo[t].fct,c=this.viewMethodsInfo[t].offsetBefore;if(this.viewMethodsInfo[t].offsetAfter,i.indexOf(r.range)==-1){let l=this.viewMethodsInfo[t].transform(a,0);i.push(r.range);let u=a-this.viewMethodsInfo[t].start-l,d=o-this.viewMethodsInfo[t].start-l;for(let t=0;t<s.positions.length;t++){let i=s.positions[t].start+c+u,a=s.positions[t].start+c+d,o=r;t>0&&(o={...o}),o.range={start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(a)},t>0&&n.push(o)}}break}}}}}n.push(r)}return n}async onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async doRename(e,t){let n=this.HTMLFile;if(!n)return null;let r=n.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let n of e.fct.positions)if(r>=n.start+e.offsetBefore&&r<=n.end){let i=r-n.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a);return await this.onRename(this.file,o,t)}return null}async onRename(e,t,n){let r=await this.tsLanguageService.onRename(e,t,n);return r&&this.transformRenameToView(r),r}transformRenameToView(t){if(t.changes){let n={};for(let r in t.changes)if(r.endsWith(w.ComponentLogic)){let i=t.changes[r],a=this.build.tsFiles[r];if(!a)continue;if(a instanceof e){let e=a.HTMLFile;if(e)for(let t=0;t<i.length;t++){let r=i[t],o=a._file.documentInternal.offsetAt(r.range.start),s=a._file.documentInternal.offsetAt(r.range.end);for(let a=0;a<this.viewMethodsInfo.length;a++){let c=this.viewMethodsInfo[a].fullStart,l=this.viewMethodsInfo[a].end;if(o>c&&s<l){n[e.file.uri]||(n[e.file.uri]=[]);let c=this.viewMethodsInfo[a].fct,l=this.viewMethodsInfo[a].transform(o,0),u=o-this.viewMethodsInfo[a].start-l,d=s-this.viewMethodsInfo[a].start-l;for(let t of c.positions){let i=t.start+this.viewMethodsInfo[a].offsetBefore+u,o=t.start+this.viewMethodsInfo[a].offsetBefore+d;n[e.file.uri].push({newText:r.newText,range:{start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(o)}})}i.splice(t,1),t--;break}}}}}for(let e in n)if(!t.changes[e])t.changes[e]=n[e];else for(let r of n[e])t.changes[e].push(r)}}addCustomCodeAction(e){let t=!1,n=!1;for(let r of this.diagnostics)if(r.code==1011&&!t)t=!0,e.push({title:`Import missing view elements`,command:{command:`aventus.wc.import.viewElement`,title:`Import missing view elements`}});else if(r.code==1014){let t=r.message.match(/#[a-zA-Z0-9_]+/g);if(t){let n=t[0].replace(`#`,``);e.push({title:`Import missing property `+n,command:{command:`aventus.wc.create.property`,title:`Create property`,arguments:[`prefill:`+n]}})}}else if(r.code==1019&&!n)n=!0,e.push({title:`Import missing methods`,command:{command:`aventus.wc.import.viewMethod`,title:`Import missing methods`}});else if(r.code==1012&&r.data){let t=r.data;e.push({title:`Remove element`,edit:{changes:{[this.file.uri]:[{newText:``,range:{start:this.file.documentInternal.positionAt(t.start),end:this.file.documentInternal.positionAt(t.end)}}]}}})}}getMissingVariablesInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingViewElements.position;for(let t in this.compilationResult.missingViewElements.elements)e+=`@ViewElement()
501
501
  protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;
502
502
  `}return{start:t,text:e}}getMissingMethodsInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingMethods.position;for(let t of this.compilationResult.missingMethods.elements)e+=`/**
503
503
  *
@@ -506,12 +506,12 @@ protected ${t}(){
506
506
  throw new Error("Method not implemented.");
507
507
  }
508
508
  `}return e!=``&&(e=`
509
- `+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},_n=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==Sn.tagName}get isIf(){return this.tagName==Cn.tagName}get isContextEditing(){return this.tagName==wn.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),vn.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(this.openTagEnd)},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);M.mergeTemplateResult(n,e)}}return n}};const vn=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],yn=[`_id`];var bn=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):yn.includes(this.name)&&(M.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new En(this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new Tn(this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(cn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[cn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=Dn(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},xn=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=Dn(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},Sn=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=On(this.loopTxt,M.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},Cn=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=M.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:kn(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=On(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},wn=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=M.getCustomFctName()??``,this.id=M.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=kn(this.fctTs)}}),this.variables=On(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},Tn=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=kn(t),this.variables=On(t,M.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},En=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=kn(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=On(t,M.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function Dn(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=M.createChange({txt:r[1],start:e,end:n});if(i.once&&!kn(r[1])&&(i.once=!1),a){a.variables=On(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t).replace(/\r\n?/g,`
510
- `),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function On(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function kn(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var M=class e{static languageService=(0,S.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:C.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=na(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof Sn||!(t instanceof _n))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof Sn||t instanceof _n)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`&#123;&#123;$1&#125;&#125;`),t=t.replace(/\\if/g,`&#105;f`),t=t.replace(/\\else/g,`&#101;lse`),t=t.replace(/\\for/g,`&#102;or`),t=t.replace(/\\@Context/g,`&#64;Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<\/?[A-Za-z][A-Za-z0-9:_-]*(?:\s+(?:[^"'<>]|"[^"]*"|'[^']*')*)?\s*\/?>/g,e=>`'`+e.slice(1,-1)+`'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new Cn(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new Sn(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new wn(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new xn(i,n,r,e,!1))}}else if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new _n(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Vi(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Vi(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new bn(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new xn(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>([\s\S]*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>[\s\S]*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},An=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),jn=o(((e,t)=>{let n=An();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),Mn=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),Nn=o(((e,t)=>{let n=An();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),Pn=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),Fn=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),In=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),Ln=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),Rn=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),zn=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),Bn=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Vn=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Hn=o(((e,t)=>{let n=In(),r=Ln(),i=Rn(),a=zn(),o=Bn(),s=Vn();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),Un=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
509
+ `+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},vn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==Cn.tagName}get isIf(){return this.tagName==wn.tagName}get isContextEditing(){return this.tagName==Tn.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),yn.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(this.openTagEnd)},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);M.mergeTemplateResult(n,e)}}return n}};const yn=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],bn=[`_id`];var xn=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):bn.includes(this.name)&&(M.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new Dn(this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new En(this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(ln.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[ln[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=On(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},Sn=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=On(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},Cn=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=kn(this.loopTxt,M.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},wn=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=M.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:An(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=kn(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},Tn=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=M.getCustomFctName()??``,this.id=M.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=An(this.fctTs)}}),this.variables=kn(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},En=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=An(t),this.variables=kn(t,M.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},Dn=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=An(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=kn(t,M.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function On(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=M.createChange({txt:r[1],start:e,end:n});if(i.once&&!An(r[1])&&(i.once=!1),a){a.variables=kn(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t).replace(/\r\n?/g,`
510
+ `),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function kn(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function An(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var M=class e{static languageService=(0,S.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:C.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=ra(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof Cn||!(t instanceof vn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof Cn||t instanceof vn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`&#123;&#123;$1&#125;&#125;`),t=t.replace(/\\if/g,`&#105;f`),t=t.replace(/\\else/g,`&#101;lse`),t=t.replace(/\\for/g,`&#102;or`),t=t.replace(/\\@Context/g,`&#64;Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<\/?[A-Za-z][A-Za-z0-9:_-]*(?:\s+(?:[^"'<>]|"[^"]*"|'[^']*')*)?\s*\/?>/g,e=>`'`+e.slice(1,-1)+`'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new wn(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new Cn(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new Tn(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new Sn(i,n,r,e,!1))}}else if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new vn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Hi(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Hi(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new xn(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new Sn(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>([\s\S]*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>[\s\S]*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},jn=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),Mn=o(((e,t)=>{let n=jn();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),Nn=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),Pn=o(((e,t)=>{let n=jn();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),Fn=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),In=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),Ln=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),Rn=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),zn=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),Bn=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),Vn=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Hn=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Un=o(((e,t)=>{let n=Ln(),r=Rn(),i=zn(),a=Bn(),o=Vn(),s=Hn();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),Wn=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
511
511
  `)&&t.prev())return e;let a=i||r.initialIndex;return t.position=r.position,t.initialIndex=a-1e-4,n([t,...e],t.prev(),r,t.initialIndex)}function r(e,t,n,i){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
512
512
  `))return e;let a=i||n.initialIndex;return t.position=n.position,t.initialIndex=a+1e-4,r([...e,t],t.next(),n,t.initialIndex)}function i(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
513
513
  `))return e;let a=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=a-1e-4,i([o,...e],t.prev(),n,o.initialIndex)}function a(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
514
- `))return e;let i=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=i+1e-4,a([...e,o],t.next(),n,o.initialIndex)}})),Wn=o(((e,t)=>{let n=Hn(),r=Un();t.exports=function(e,t,i,a){if(e.type===`comment`)return a;let o=n(i,e);e.position=o&&o.position?o.position:1/0,e.initialIndex=t;let s=r.beforeNode([],e.prev(),e),c=r.afterNode([],e.next(),e);return[...a,...s,e,...c]}})),Gn=o(((e,t)=>{t.exports=function(e,t){return e.position===t.position?e.initialIndex-t.initialIndex:e.position-t.position}})),Kn=o(((e,t)=>{let n=Nn(),r=Pn(),i=Fn(),a=Wn(),o=Gn();t.exports=function(e,t){if(!r(e))return;let s=n(t),c=[];e.each((e,t)=>{c=a(e,t,s,c)}),e.each((e,t)=>{c=i(e,t,c)}),c.sort(o),e.raws.semicolon=!0,e.removeAll(),e.append(c)}})),qn=o(((e,t)=>{t.exports=function(e){let t={};return e.forEach((e,n)=>{t[e]={propertyIndex:n}}),t}})),Jn=o(((e,t)=>{t.exports=function(e,t){return e[t]}})),Yn=o(((e,t)=>{t.exports={margin:[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`,`margin-block`,`margin-inline`],"margin-block":[`margin-block-start`,`margin-block-end`],"margin-block-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-block-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline":[`margin-inline-start`,`margin-inline-end`],"margin-inline-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],padding:[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`,`padding-block`,`padding-block-start`,`padding-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`],"padding-block":[`padding-block-start`,`padding-block-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline":[`padding-inline-start`,`padding-inline-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],background:[`background-image`,`background-size`,`background-position`,`background-repeat`,`background-origin`,`background-clip`,`background-attachment`,`background-color`],font:[`font-style`,`font-variant`,`font-weight`,`font-stretch`,`font-size`,`font-family`,`line-height`],border:[`border-inline`,`border-block`,`border-top`,`border-bottom`,`border-left`,`border-right`,`border-width`,`border-style`,`border-color`],"border-inline":[`border-inline-start`,`border-inline-end`,`border-inline-width`,`border-inline-style`,`border-inline-color`],"border-inline-width":[`border-inline-start-width`,`border-inline-end-width`],"border-inline-style":[`border-inline-start-style`,`border-inline-end-style`],"border-inline-color":[`border-inline-start-color`,`border-inline-end-color`],"border-inline-start":[`border-inline-start-width`,`border-inline-start-style`,`border-inline-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-inline-end":[`border-inline-end-width`,`border-inline-end-style`,`border-inline-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block":[`border-block-start`,`border-block-end`,`border-block-width`,`border-block-style`,`border-block-color`],"border-block-width":[`border-block-start-width`,`border-block-end-width`],"border-block-style":[`border-block-start-style`,`border-block-end-style`],"border-block-color":[`border-block-start-color`,`border-block-end-color`],"border-block-start":[`border-block-start-width`,`border-block-start-style`,`border-block-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block-end":[`border-block-end-width`,`border-block-end-style`,`border-block-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-top":[`border-top-width`,`border-top-style`,`border-top-color`],"border-bottom":[`border-bottom-width`,`border-bottom-style`,`border-bottom-color`],"border-left":[`border-left-width`,`border-left-style`,`border-left-color`],"border-right":[`border-right-width`,`border-right-style`,`border-right-color`],"border-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-image":[`border-image-source`,`border-image-slice`,`border-image-width`,`border-image-outset`,`border-image-repeat`],"border-radius":[`border-top-right-radius`,`border-top-left-radius`,`border-bottom-right-radius`,`border-bottom-left-radius`],"list-style":[`list-style-type`,`list-style-position`,`list-style-image`],transition:[`transition-delay`,`transition-duration`,`transition-property`,`transition-timing-function`],animation:[`animation-name`,`animation-duration`,`animation-timing-function`,`animation-delay`,`animation-iteration-count`,`animation-direction`,`animation-fill-mode`,`animation-play-state`],"column-rule":[`column-rule-width`,`column-rule-style`,`column-rule-color`],columns:[`column-width`,`column-count`],flex:[`flex-grow`,`flex-shrink`,`flex-basis`],"flex-flow":[`flex-direction`,`flex-wrap`],grid:[`grid-template-rows`,`grid-template-columns`,`grid-template-areas`,`grid-auto-rows`,`grid-auto-columns`,`grid-auto-flow`,`grid-column-gap`,`grid-row-gap`],"grid-area":[`grid-row-start`,`grid-column-start`,`grid-row-end`,`grid-column-end`],"grid-column":[`grid-column-start`,`grid-column-end`],"grid-gap":[`grid-row-gap`,`grid-column-gap`],"grid-row":[`grid-row-start`,`grid-row-end`],"grid-template":[`grid-template-columns`,`grid-template-rows`,`grid-template-areas`],offset:[`offset-anchor`,`offset-distance`,`offset-path`,`offset-position`,`offset-rotate`],outline:[`outline-color`,`outline-style`,`outline-width`],overflow:[`overflow-block`,`overflow-inline`,`overflow-x`,`overflow-y`],"overflow-block":[`overflow-x`,`overflow-y`],"overflow-inline":[`overflow-x`,`overflow-y`],"overscroll-behavior":[`overscroll-behavior-x`,`overscroll-behavior-y`,`overscroll-behavior-block`,`overscroll-behavior-inline`],"overscroll-behavior-block":[`overscroll-behavior-x`,`overscroll-behavior-y`],"overscroll-behavior-inline":[`overscroll-behavior-x`,`overscroll-behavior-y`],"text-decoration":[`text-decoration-color`,`text-decoration-style`,`text-decoration-line`],"text-emphasis":[`text-emphasis-style`,`text-emphasis-color`],mask:[`mask-image`,`mask-mode`,`mask-position`,`mask-size`,`mask-repeat`,`mask-origin`,`mask-clip`,`mask-composite`],"mask-border":[`mask-border-mode`,`mask-border-outset`,`mask-border-repeat`,`mask-border-slice`,`mask-border-source`,`mask-border-width`],inset:[`top`,`right`,`bottom`,`left`,`inset-block`,`inset-inline`],"inset-block":[`inset-block-end`,`inset-block-start`],"inset-inline":[`inset-inline-end`,`inset-inline-start`],"inset-block-start":[`top`,`bottom`,`left`,`right`],"inset-block-end":[`top`,`bottom`,`left`,`right`],"inset-inline-start":[`top`,`bottom`,`left`,`right`],"inset-inline-end":[`top`,`bottom`,`left`,`right`]}})),Xn=o((e=>{let t=Yn();e.isShorthand=function e(n,r){if(!t[n])return!1;if(t[n].includes(r))return!0;for(let i of t[n])if(e(i,r))return!0;return!1}})),Zn=o(((e,t)=>{t.exports={prefix(e){let t=e.match(/^(-\w+-)/);return t?t[0]:``},unprefixed(e){return e.replace(/^-\w+-/,``)}}})),Qn=o(((e,t)=>{let{isShorthand:n}=Xn(),r=Zn();t.exports=function(e,t){if(n(e.unprefixedName,t.unprefixedName))return-1;if(n(t.unprefixedName,e.unprefixedName))return 1;if(e.unprefixedName===t.unprefixedName){if(e.node.type===`decl`&&t.node.type===`decl`){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}return e.initialIndex-t.initialIndex}return e.unprefixedName<=t.unprefixedName?-1:1}})),$n=o(((e,t)=>{let n=Qn(),r=Zn();t.exports=function(e,t){if(e.node.type===`decl`&&t.node.type===`decl`&&e.unprefixedName===t.unprefixedName){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}if(e.orderData&&t.orderData!==void 0&&e.orderData.propertyIndex!==t.orderData.propertyIndex)return e.orderData.propertyIndex-t.orderData.propertyIndex;if(e.unspecifiedPropertiesPosition===`bottom`||e.unspecifiedPropertiesPosition===`bottomAlphabetical`||t.unspecifiedPropertiesPosition===`bottomAlphabetical`){if(e.orderData!==void 0&&t.orderData===void 0)return-1;if(e.orderData===void 0&&t.orderData!==void 0)return 1}if(e.unspecifiedPropertiesPosition===`top`){if(e.orderData!==void 0&&t.orderData===void 0)return 1;if(e.orderData===void 0&&t.orderData!==void 0)return-1}return e.unspecifiedPropertiesPosition===`bottomAlphabetical`&&e.orderData===void 0&&t.orderData===void 0?n(e,t):e.initialIndex-t.initialIndex}})),er=o(((e,t)=>{let n=qn(),r=Un(),i=Jn(),a=Ln(),o=Pn(),s=In(),c=$n(),l=Qn(),u=Zn();function d(e){return e.type===`decl`&&s(e.prop)&&!a(e.prop)}function f(e){let t=u.unprefixed(e).toLowerCase();return t.indexOf(`osx-`)===0?t.slice(4):t}function p(e,t,n,r){if(n.length)for(let r=1;r<=n.length;r++)e.add(t-r);if(r.length)for(let n=1;n<=r.length;n++)e.add(t+n)}function m(e,t){e.removeAll(),e.append(t)}t.exports=function(e,{order:t,unspecifiedPropertiesPosition:a}){if(!o(e,{ignoreInterpolations:!0}))return;let s=t===`alphabetical`,u=s?null:n(t),h=[],g=new Set,_=new Map;if(e.each((e,t)=>{if(!d(e))return;let n=f(e.prop),o={name:e.prop,unprefixedName:n,orderData:s?null:i(u,n),node:e,initialIndex:t,unspecifiedPropertiesPosition:a};g.add(t),_.set(t,o);let c=r.beforeDeclaration([],e.prev(),o),l=r.afterDeclaration([],e.next(),o);p(g,t,c,l),h=[...h,...c,o,...l]}),o(e)){s?h.sort(l):h.sort(c);let t=[],n=!1;e.each((e,r)=>{g.has(r)?n||(n=!0,h.forEach(e=>{t.push(e.node)})):t.push(e)}),m(e,t);return}let v=[],y=[];function b(){if(!y.length)return;let e=y[0].node,t=e.raws.before;s?y.sort(l):y.sort(c);let n=y[0].node;if(n!==e){let r=n.raws.before;n.raws.before=t,e.raws.before=r}y.forEach(e=>{v.push(e.node)}),y=[]}e.each((e,t)=>{let n=_.get(t);n&&e.type===`decl`?(e.raws.before&&e.raws.before.includes("${")&&b(),y.push(n)):(b(),v.push(e))}),b(),m(e,v)}})),tr=o(((e,t)=>{let n=jn(),r=An(),i=Mn(),a=Kn(),o=er();t.exports=function(e){return{postcssPlugin:`postcss-sorting`,Root(t){s(t,e)}}},t.exports.postcss=!0;function s(e,t){let s=n(t);if(s!==!0){if(t&&t[`throw-validate-errors`])throw r(s)?Error(s):Error(`postcss-sorting: Invalid config.`);console&&console.warn&&r(s)&&console.warn(s);return}t.order&&e.walk(e=>{a(i(e),t.order)}),t[`properties-order`]&&e.walk(e=>{o(i(e),{order:t[`properties-order`],unspecifiedPropertiesPosition:t[`unspecified-properties-position`]||`bottom`})})}})),nr=o(((e,t)=>{let n=/(<)(\/?style\b)/gi,r=/(<)(!--)/g;function i(e){return typeof e!=`string`||!e.includes(`<`)?e:e.replace(n,`\\3c $2`).replace(r,`\\3c $2`)}let a={after:`
514
+ `))return e;let i=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=i+1e-4,a([...e,o],t.next(),n,o.initialIndex)}})),Gn=o(((e,t)=>{let n=Un(),r=Wn();t.exports=function(e,t,i,a){if(e.type===`comment`)return a;let o=n(i,e);e.position=o&&o.position?o.position:1/0,e.initialIndex=t;let s=r.beforeNode([],e.prev(),e),c=r.afterNode([],e.next(),e);return[...a,...s,e,...c]}})),Kn=o(((e,t)=>{t.exports=function(e,t){return e.position===t.position?e.initialIndex-t.initialIndex:e.position-t.position}})),qn=o(((e,t)=>{let n=Pn(),r=Fn(),i=In(),a=Gn(),o=Kn();t.exports=function(e,t){if(!r(e))return;let s=n(t),c=[];e.each((e,t)=>{c=a(e,t,s,c)}),e.each((e,t)=>{c=i(e,t,c)}),c.sort(o),e.raws.semicolon=!0,e.removeAll(),e.append(c)}})),Jn=o(((e,t)=>{t.exports=function(e){let t={};return e.forEach((e,n)=>{t[e]={propertyIndex:n}}),t}})),Yn=o(((e,t)=>{t.exports=function(e,t){return e[t]}})),Xn=o(((e,t)=>{t.exports={margin:[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`,`margin-block`,`margin-inline`],"margin-block":[`margin-block-start`,`margin-block-end`],"margin-block-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-block-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline":[`margin-inline-start`,`margin-inline-end`],"margin-inline-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],padding:[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`,`padding-block`,`padding-block-start`,`padding-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`],"padding-block":[`padding-block-start`,`padding-block-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline":[`padding-inline-start`,`padding-inline-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],background:[`background-image`,`background-size`,`background-position`,`background-repeat`,`background-origin`,`background-clip`,`background-attachment`,`background-color`],font:[`font-style`,`font-variant`,`font-weight`,`font-stretch`,`font-size`,`font-family`,`line-height`],border:[`border-inline`,`border-block`,`border-top`,`border-bottom`,`border-left`,`border-right`,`border-width`,`border-style`,`border-color`],"border-inline":[`border-inline-start`,`border-inline-end`,`border-inline-width`,`border-inline-style`,`border-inline-color`],"border-inline-width":[`border-inline-start-width`,`border-inline-end-width`],"border-inline-style":[`border-inline-start-style`,`border-inline-end-style`],"border-inline-color":[`border-inline-start-color`,`border-inline-end-color`],"border-inline-start":[`border-inline-start-width`,`border-inline-start-style`,`border-inline-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-inline-end":[`border-inline-end-width`,`border-inline-end-style`,`border-inline-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block":[`border-block-start`,`border-block-end`,`border-block-width`,`border-block-style`,`border-block-color`],"border-block-width":[`border-block-start-width`,`border-block-end-width`],"border-block-style":[`border-block-start-style`,`border-block-end-style`],"border-block-color":[`border-block-start-color`,`border-block-end-color`],"border-block-start":[`border-block-start-width`,`border-block-start-style`,`border-block-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block-end":[`border-block-end-width`,`border-block-end-style`,`border-block-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-top":[`border-top-width`,`border-top-style`,`border-top-color`],"border-bottom":[`border-bottom-width`,`border-bottom-style`,`border-bottom-color`],"border-left":[`border-left-width`,`border-left-style`,`border-left-color`],"border-right":[`border-right-width`,`border-right-style`,`border-right-color`],"border-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-image":[`border-image-source`,`border-image-slice`,`border-image-width`,`border-image-outset`,`border-image-repeat`],"border-radius":[`border-top-right-radius`,`border-top-left-radius`,`border-bottom-right-radius`,`border-bottom-left-radius`],"list-style":[`list-style-type`,`list-style-position`,`list-style-image`],transition:[`transition-delay`,`transition-duration`,`transition-property`,`transition-timing-function`],animation:[`animation-name`,`animation-duration`,`animation-timing-function`,`animation-delay`,`animation-iteration-count`,`animation-direction`,`animation-fill-mode`,`animation-play-state`],"column-rule":[`column-rule-width`,`column-rule-style`,`column-rule-color`],columns:[`column-width`,`column-count`],flex:[`flex-grow`,`flex-shrink`,`flex-basis`],"flex-flow":[`flex-direction`,`flex-wrap`],grid:[`grid-template-rows`,`grid-template-columns`,`grid-template-areas`,`grid-auto-rows`,`grid-auto-columns`,`grid-auto-flow`,`grid-column-gap`,`grid-row-gap`],"grid-area":[`grid-row-start`,`grid-column-start`,`grid-row-end`,`grid-column-end`],"grid-column":[`grid-column-start`,`grid-column-end`],"grid-gap":[`grid-row-gap`,`grid-column-gap`],"grid-row":[`grid-row-start`,`grid-row-end`],"grid-template":[`grid-template-columns`,`grid-template-rows`,`grid-template-areas`],offset:[`offset-anchor`,`offset-distance`,`offset-path`,`offset-position`,`offset-rotate`],outline:[`outline-color`,`outline-style`,`outline-width`],overflow:[`overflow-block`,`overflow-inline`,`overflow-x`,`overflow-y`],"overflow-block":[`overflow-x`,`overflow-y`],"overflow-inline":[`overflow-x`,`overflow-y`],"overscroll-behavior":[`overscroll-behavior-x`,`overscroll-behavior-y`,`overscroll-behavior-block`,`overscroll-behavior-inline`],"overscroll-behavior-block":[`overscroll-behavior-x`,`overscroll-behavior-y`],"overscroll-behavior-inline":[`overscroll-behavior-x`,`overscroll-behavior-y`],"text-decoration":[`text-decoration-color`,`text-decoration-style`,`text-decoration-line`],"text-emphasis":[`text-emphasis-style`,`text-emphasis-color`],mask:[`mask-image`,`mask-mode`,`mask-position`,`mask-size`,`mask-repeat`,`mask-origin`,`mask-clip`,`mask-composite`],"mask-border":[`mask-border-mode`,`mask-border-outset`,`mask-border-repeat`,`mask-border-slice`,`mask-border-source`,`mask-border-width`],inset:[`top`,`right`,`bottom`,`left`,`inset-block`,`inset-inline`],"inset-block":[`inset-block-end`,`inset-block-start`],"inset-inline":[`inset-inline-end`,`inset-inline-start`],"inset-block-start":[`top`,`bottom`,`left`,`right`],"inset-block-end":[`top`,`bottom`,`left`,`right`],"inset-inline-start":[`top`,`bottom`,`left`,`right`],"inset-inline-end":[`top`,`bottom`,`left`,`right`]}})),Zn=o((e=>{let t=Xn();e.isShorthand=function e(n,r){if(!t[n])return!1;if(t[n].includes(r))return!0;for(let i of t[n])if(e(i,r))return!0;return!1}})),Qn=o(((e,t)=>{t.exports={prefix(e){let t=e.match(/^(-\w+-)/);return t?t[0]:``},unprefixed(e){return e.replace(/^-\w+-/,``)}}})),$n=o(((e,t)=>{let{isShorthand:n}=Zn(),r=Qn();t.exports=function(e,t){if(n(e.unprefixedName,t.unprefixedName))return-1;if(n(t.unprefixedName,e.unprefixedName))return 1;if(e.unprefixedName===t.unprefixedName){if(e.node.type===`decl`&&t.node.type===`decl`){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}return e.initialIndex-t.initialIndex}return e.unprefixedName<=t.unprefixedName?-1:1}})),er=o(((e,t)=>{let n=$n(),r=Qn();t.exports=function(e,t){if(e.node.type===`decl`&&t.node.type===`decl`&&e.unprefixedName===t.unprefixedName){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}if(e.orderData&&t.orderData!==void 0&&e.orderData.propertyIndex!==t.orderData.propertyIndex)return e.orderData.propertyIndex-t.orderData.propertyIndex;if(e.unspecifiedPropertiesPosition===`bottom`||e.unspecifiedPropertiesPosition===`bottomAlphabetical`||t.unspecifiedPropertiesPosition===`bottomAlphabetical`){if(e.orderData!==void 0&&t.orderData===void 0)return-1;if(e.orderData===void 0&&t.orderData!==void 0)return 1}if(e.unspecifiedPropertiesPosition===`top`){if(e.orderData!==void 0&&t.orderData===void 0)return 1;if(e.orderData===void 0&&t.orderData!==void 0)return-1}return e.unspecifiedPropertiesPosition===`bottomAlphabetical`&&e.orderData===void 0&&t.orderData===void 0?n(e,t):e.initialIndex-t.initialIndex}})),tr=o(((e,t)=>{let n=Jn(),r=Wn(),i=Yn(),a=Rn(),o=Fn(),s=Ln(),c=er(),l=$n(),u=Qn();function d(e){return e.type===`decl`&&s(e.prop)&&!a(e.prop)}function f(e){let t=u.unprefixed(e).toLowerCase();return t.indexOf(`osx-`)===0?t.slice(4):t}function p(e,t,n,r){if(n.length)for(let r=1;r<=n.length;r++)e.add(t-r);if(r.length)for(let n=1;n<=r.length;n++)e.add(t+n)}function m(e,t){e.removeAll(),e.append(t)}t.exports=function(e,{order:t,unspecifiedPropertiesPosition:a}){if(!o(e,{ignoreInterpolations:!0}))return;let s=t===`alphabetical`,u=s?null:n(t),h=[],g=new Set,_=new Map;if(e.each((e,t)=>{if(!d(e))return;let n=f(e.prop),o={name:e.prop,unprefixedName:n,orderData:s?null:i(u,n),node:e,initialIndex:t,unspecifiedPropertiesPosition:a};g.add(t),_.set(t,o);let c=r.beforeDeclaration([],e.prev(),o),l=r.afterDeclaration([],e.next(),o);p(g,t,c,l),h=[...h,...c,o,...l]}),o(e)){s?h.sort(l):h.sort(c);let t=[],n=!1;e.each((e,r)=>{g.has(r)?n||(n=!0,h.forEach(e=>{t.push(e.node)})):t.push(e)}),m(e,t);return}let v=[],y=[];function b(){if(!y.length)return;let e=y[0].node,t=e.raws.before;s?y.sort(l):y.sort(c);let n=y[0].node;if(n!==e){let r=n.raws.before;n.raws.before=t,e.raws.before=r}y.forEach(e=>{v.push(e.node)}),y=[]}e.each((e,t)=>{let n=_.get(t);n&&e.type===`decl`?(e.raws.before&&e.raws.before.includes("${")&&b(),y.push(n)):(b(),v.push(e))}),b(),m(e,v)}})),nr=o(((e,t)=>{let n=Mn(),r=jn(),i=Nn(),a=qn(),o=tr();t.exports=function(e){return{postcssPlugin:`postcss-sorting`,Root(t){s(t,e)}}},t.exports.postcss=!0;function s(e,t){let s=n(t);if(s!==!0){if(t&&t[`throw-validate-errors`])throw r(s)?Error(s):Error(`postcss-sorting: Invalid config.`);console&&console.warn&&r(s)&&console.warn(s);return}t.order&&e.walk(e=>{a(i(e),t.order)}),t[`properties-order`]&&e.walk(e=>{o(i(e),{order:t[`properties-order`],unspecifiedPropertiesPosition:t[`unspecified-properties-position`]||`bottom`})})}})),rr=o(((e,t)=>{let n=/(<)(\/?style\b)/gi,r=/(<)(!--)/g;function i(e){return typeof e!=`string`||!e.includes(`<`)?e:e.replace(n,`\\3c $2`).replace(r,`\\3c $2`)}let a={after:`
515
515
  `,beforeClose:`
516
516
  `,beforeComment:`
517
517
  `,beforeDecl:`
@@ -522,35 +522,35 @@ protected ${t}(){
522
522
  `)&&(n=n.replace(/[^\n]+$/,``)),!1}),n===void 0?n=this.raw(t,null,`beforeDecl`):n&&=n.replace(/\S/g,``),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(e.raws.before!==void 0)return n=e.raws.before,n.includes(`
523
523
  `)&&(n=n.replace(/[^\n]+$/,``)),!1}),n===void 0?n=this.raw(t,null,`beforeRule`):n&&=n.replace(/\S/g,``),n}rawBeforeOpen(e){let t;return e.walk(e=>{if(e.type!==`decl`&&(t=e.raws.between,t!==void 0))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&n.raws.before!==void 0)return t=n.raws.before,t.includes(`
524
524
  `)&&(t=t.replace(/[^\n]+$/,``)),!1}),t&&=t.replace(/\S/g,``),t}rawColon(e){let t;return e.walkDecls(e=>{if(e.raws.between!==void 0)return t=e.raws.between.replace(/[^\s:]/g,``),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length===0&&(t=e.raws.after,t!==void 0))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&n.raws.before!==void 0){let e=n.raws.before.split(`
525
- `);return t=e[e.length-1],t=t.replace(/\S/g,``),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&e.last.type===`decl`&&(t=e.raws.semicolon,t!==void 0))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){if(this.body(e),e.raws.after){let t=e.raws.after,n=e.parent&&e.parent.type===`document`;this.builder(n?t:i(t))}}rule(e){this.block(e,this.rawValue(e,`selector`)),e.raws.ownSemicolon&&this.builder(i(e.raws.ownSemicolon),e,`end`)}stringify(e,t){if(!this[e.type])throw Error(`Unknown AST node type `+e.type+`. Maybe you need to change PostCSS stringifier.`);this[e.type](e,t)}};t.exports=s,s.default=s})),rr=o(((e,t)=>{let n=nr();t.exports=class extends n{comment(e){let t=this.raw(e,`left`,`commentLeft`),n=this.raw(e,`right`,`commentRight`);if(e.raws.inline){let r=e.raws.text||e.text;this.builder(`//`+t+r+n,e)}else this.builder(`/*`+t+e.text+n+`*/`,e)}decl(e,t){if(!e.isNested)super.decl(e,t);else{let t=this.raw(e,`between`,`colon`),n=e.prop+t+this.rawValue(e,`value`);e.important&&(n+=e.raws.important||` !important`),this.builder(n+`{`,e,`start`);let r;e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,`after`)):r=this.raw(e,`after`,`emptyBody`),r&&this.builder(r),this.builder(`}`,e,`end`)}}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.scss?r.scss:r.raw:n}}})),ir=o(((e,t)=>{let n=rr();t.exports=function(e,t){new n(t).stringify(e)}})),ar=o(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),or=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i;t.exports=function(e,t={}){let o=e.css.valueOf(),s=t.ignoreErrors,c,l,u,d,f,p,m,h,g,_,v=o.length,y=0,b=[],x=[],ee=-1;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function S(){return x.length===0&&y>=v}function re(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(c=o.charCodeAt(y),c){case 10:case 32:case 9:case 13:case 12:d=y;do d+=1,c=o.charCodeAt(d);while(c===32||c===10||c===9||c===13||c===12);p=[`space`,o.slice(y,d)],y=d-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(c);p=[e,e,y];break}case 40:if(_=b.length?b.pop()[1]:``,g=o.charCodeAt(y+1),_===`url`&&g!==39&&g!==34&&g!==32&&g!==10&&g!==9&&g!==12&&g!==13){d=y;do{if(m=!1,d=o.indexOf(`)`,d+1),d===-1)if(s||t){d=y;break}else ne(`bracket`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`brackets`,o.slice(y,d+1),y,d],y=d}else y<=ee?p=[`(`,`(`,y]:(d=o.indexOf(`)`,y+1),l=o.slice(y,d+1),d===-1||i.test(l)?(ee=d===-1?v:d,p=[`(`,`(`,y]):(p=[`brackets`,l,y,d],y=d));break;case 39:case 34:f=c===39?`'`:`"`,d=y;do{if(m=!1,d=o.indexOf(f,d+1),d===-1)if(s||t){d=y+1;break}else ne(`string`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`string`,o.slice(y,d+1),y,d],y=d;break;case 64:n.lastIndex=y+1,n.test(o),d=n.lastIndex===0?o.length-1:n.lastIndex-2,p=[`at-word`,o.slice(y,d+1),y,d],y=d;break;case 92:for(d=y,u=!0;o.charCodeAt(d+1)===92;)d+=1,u=!u;if(c=o.charCodeAt(d+1),u&&c!==47&&c!==32&&c!==10&&c!==9&&c!==13&&c!==12&&(d+=1,a.test(o.charAt(d)))){for(;a.test(o.charAt(d+1));)d+=1;o.charCodeAt(d+1)===32&&(d+=1)}p=[`word`,o.slice(y,d+1),y,d],y=d;break;default:c===47&&o.charCodeAt(y+1)===42?(d=o.indexOf(`*/`,y+2)+1,d===0&&(s||t?d=o.length:ne(`comment`)),p=[`comment`,o.slice(y,d+1),y,d],y=d):(r.lastIndex=y+1,r.test(o),d=r.lastIndex===0?o.length-1:r.lastIndex-2,p=[`word`,o.slice(y,d+1),y,d],b.push(p),y=d);break}return y++,p}function ie(e){x.push(e)}return{back:ie,endOfFile:S,nextToken:re,position:te}}})),sr=o(((e,t)=>{let n=ar(),r=or(),i;function a(e){i=e}let o={";":n.yellow,":":n.yellow,"(":n.cyan,")":n.cyan,"[":n.yellow,"]":n.yellow,"{":n.yellow,"}":n.yellow,"at-word":n.cyan,brackets:n.cyan,call:n.cyan,class:n.yellow,comment:n.gray,hash:n.magenta,string:n.green};function s([e,t],n){if(e===`word`){if(t[0]===`.`)return`class`;if(t[0]===`#`)return`hash`}if(!n.endOfFile()){let e=n.nextToken();if(n.back(e),e[0]===`brackets`||e[0]===`(`)return`call`}return e}function c(e){let t=r(new i(e),{ignoreErrors:!0}),n=``;for(;!t.endOfFile();){let e=t.nextToken(),r=o[s(e,t)];r?n+=e[1].split(/\r?\n/).map(e=>r(e)).join(`
526
- `):n+=e[1]}return n}c.registerInput=a,t.exports=c})),cr=o(((e,t)=>{let n=ar(),r=sr();var i=class e extends Error{constructor(t,n,r,i,a,o){super(t),this.name=`CssSyntaxError`,this.reason=t,a&&(this.file=a),i&&(this.source=i),o&&(this.plugin=o),n!==void 0&&r!==void 0&&(typeof n==`number`?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+`: `:``,this.message+=this.file?this.file:`<css input>`,this.line!==void 0&&(this.message+=`:`+this.line+`:`+this.column),this.message+=`: `+this.reason}showSourceCode(e){if(!this.source)return``;let t=this.source;e??=n.isColorSupported;let i=e=>e,a=e=>e,o=e=>e;if(e){let{bold:e,gray:t,red:s}=n.createColors(!0);a=t=>e(s(t)),i=e=>t(e),r&&(o=e=>r(e))}let s=t.split(/\r?\n/),c=Math.max(this.line-3,0),l=Math.min(this.line+2,s.length),u=String(l).length;return s.slice(c,l).map((e,t)=>{let n=c+1+t,r=` `+(` `+n).slice(-u)+` | `;if(n===this.line){if(e.length>160){let t=Math.max(0,this.column-20),n=Math.max(this.column+20,this.endColumn+20),s=e.slice(t,n),c=i(r.replace(/\d/g,` `))+e.slice(0,Math.min(this.column-1,19)).replace(/[^\t]/g,` `);return a(`>`)+i(r)+o(s)+`
525
+ `);return t=e[e.length-1],t=t.replace(/\S/g,``),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&e.last.type===`decl`&&(t=e.raws.semicolon,t!==void 0))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){if(this.body(e),e.raws.after){let t=e.raws.after,n=e.parent&&e.parent.type===`document`;this.builder(n?t:i(t))}}rule(e){this.block(e,this.rawValue(e,`selector`)),e.raws.ownSemicolon&&this.builder(i(e.raws.ownSemicolon),e,`end`)}stringify(e,t){if(!this[e.type])throw Error(`Unknown AST node type `+e.type+`. Maybe you need to change PostCSS stringifier.`);this[e.type](e,t)}};t.exports=s,s.default=s})),ir=o(((e,t)=>{let n=rr();t.exports=class extends n{comment(e){let t=this.raw(e,`left`,`commentLeft`),n=this.raw(e,`right`,`commentRight`);if(e.raws.inline){let r=e.raws.text||e.text;this.builder(`//`+t+r+n,e)}else this.builder(`/*`+t+e.text+n+`*/`,e)}decl(e,t){if(!e.isNested)super.decl(e,t);else{let t=this.raw(e,`between`,`colon`),n=e.prop+t+this.rawValue(e,`value`);e.important&&(n+=e.raws.important||` !important`),this.builder(n+`{`,e,`start`);let r;e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,`after`)):r=this.raw(e,`after`,`emptyBody`),r&&this.builder(r),this.builder(`}`,e,`end`)}}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.scss?r.scss:r.raw:n}}})),ar=o(((e,t)=>{let n=ir();t.exports=function(e,t){new n(t).stringify(e)}})),or=o(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),sr=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i;t.exports=function(e,t={}){let o=e.css.valueOf(),s=t.ignoreErrors,c,l,u,d,f,p,m,h,g,_,v=o.length,y=0,b=[],x=[],ee=-1;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function S(){return x.length===0&&y>=v}function re(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(c=o.charCodeAt(y),c){case 10:case 32:case 9:case 13:case 12:d=y;do d+=1,c=o.charCodeAt(d);while(c===32||c===10||c===9||c===13||c===12);p=[`space`,o.slice(y,d)],y=d-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(c);p=[e,e,y];break}case 40:if(_=b.length?b.pop()[1]:``,g=o.charCodeAt(y+1),_===`url`&&g!==39&&g!==34&&g!==32&&g!==10&&g!==9&&g!==12&&g!==13){d=y;do{if(m=!1,d=o.indexOf(`)`,d+1),d===-1)if(s||t){d=y;break}else ne(`bracket`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`brackets`,o.slice(y,d+1),y,d],y=d}else y<=ee?p=[`(`,`(`,y]:(d=o.indexOf(`)`,y+1),l=o.slice(y,d+1),d===-1||i.test(l)?(ee=d===-1?v:d,p=[`(`,`(`,y]):(p=[`brackets`,l,y,d],y=d));break;case 39:case 34:f=c===39?`'`:`"`,d=y;do{if(m=!1,d=o.indexOf(f,d+1),d===-1)if(s||t){d=y+1;break}else ne(`string`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`string`,o.slice(y,d+1),y,d],y=d;break;case 64:n.lastIndex=y+1,n.test(o),d=n.lastIndex===0?o.length-1:n.lastIndex-2,p=[`at-word`,o.slice(y,d+1),y,d],y=d;break;case 92:for(d=y,u=!0;o.charCodeAt(d+1)===92;)d+=1,u=!u;if(c=o.charCodeAt(d+1),u&&c!==47&&c!==32&&c!==10&&c!==9&&c!==13&&c!==12&&(d+=1,a.test(o.charAt(d)))){for(;a.test(o.charAt(d+1));)d+=1;o.charCodeAt(d+1)===32&&(d+=1)}p=[`word`,o.slice(y,d+1),y,d],y=d;break;default:c===47&&o.charCodeAt(y+1)===42?(d=o.indexOf(`*/`,y+2)+1,d===0&&(s||t?d=o.length:ne(`comment`)),p=[`comment`,o.slice(y,d+1),y,d],y=d):(r.lastIndex=y+1,r.test(o),d=r.lastIndex===0?o.length-1:r.lastIndex-2,p=[`word`,o.slice(y,d+1),y,d],b.push(p),y=d);break}return y++,p}function ie(e){x.push(e)}return{back:ie,endOfFile:S,nextToken:re,position:te}}})),cr=o(((e,t)=>{let n=or(),r=sr(),i;function a(e){i=e}let o={";":n.yellow,":":n.yellow,"(":n.cyan,")":n.cyan,"[":n.yellow,"]":n.yellow,"{":n.yellow,"}":n.yellow,"at-word":n.cyan,brackets:n.cyan,call:n.cyan,class:n.yellow,comment:n.gray,hash:n.magenta,string:n.green};function s([e,t],n){if(e===`word`){if(t[0]===`.`)return`class`;if(t[0]===`#`)return`hash`}if(!n.endOfFile()){let e=n.nextToken();if(n.back(e),e[0]===`brackets`||e[0]===`(`)return`call`}return e}function c(e){let t=r(new i(e),{ignoreErrors:!0}),n=``;for(;!t.endOfFile();){let e=t.nextToken(),r=o[s(e,t)];r?n+=e[1].split(/\r?\n/).map(e=>r(e)).join(`
526
+ `):n+=e[1]}return n}c.registerInput=a,t.exports=c})),lr=o(((e,t)=>{let n=or(),r=cr();var i=class e extends Error{constructor(t,n,r,i,a,o){super(t),this.name=`CssSyntaxError`,this.reason=t,a&&(this.file=a),i&&(this.source=i),o&&(this.plugin=o),n!==void 0&&r!==void 0&&(typeof n==`number`?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+`: `:``,this.message+=this.file?this.file:`<css input>`,this.line!==void 0&&(this.message+=`:`+this.line+`:`+this.column),this.message+=`: `+this.reason}showSourceCode(e){if(!this.source)return``;let t=this.source;e??=n.isColorSupported;let i=e=>e,a=e=>e,o=e=>e;if(e){let{bold:e,gray:t,red:s}=n.createColors(!0);a=t=>e(s(t)),i=e=>t(e),r&&(o=e=>r(e))}let s=t.split(/\r?\n/),c=Math.max(this.line-3,0),l=Math.min(this.line+2,s.length),u=String(l).length;return s.slice(c,l).map((e,t)=>{let n=c+1+t,r=` `+(` `+n).slice(-u)+` | `;if(n===this.line){if(e.length>160){let t=Math.max(0,this.column-20),n=Math.max(this.column+20,this.endColumn+20),s=e.slice(t,n),c=i(r.replace(/\d/g,` `))+e.slice(0,Math.min(this.column-1,19)).replace(/[^\t]/g,` `);return a(`>`)+i(r)+o(s)+`
527
527
  `+c+a(`^`)}let t=i(r.replace(/\d/g,` `))+e.slice(0,this.column-1).replace(/[^\t]/g,` `);return a(`>`)+i(r)+o(e)+`
528
528
  `+t+a(`^`)}return` `+i(r)+o(e)}).join(`
529
529
  `)}toString(){let e=this.showSourceCode();return e&&=`
530
530
 
531
531
  `+e+`
532
- `,this.name+`: `+this.message+e}};t.exports=i,i.default=i})),lr=o(((e,t)=>{let n=nr();function r(e,t){new n(t).stringify(e)}t.exports=r,r.default=r})),ur=o(((e,t)=>{t.exports.isClean=Symbol(`isClean`),t.exports.my=Symbol(`my`)})),dr=o(((e,t)=>{let n=cr(),r=nr(),i=lr(),{isClean:a,my:o}=ur();function s(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r)||r===`proxyCache`)continue;let i=e[r],a=typeof i;r===`parent`&&a===`object`?t&&(n[r]=t):r===`source`?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>s(e,n)):(a===`object`&&i!==null&&(i=s(i)),n[r]=i)}return n}function c(e,t){if(t&&t.offset!==void 0)return t.offset;let n=1,r=1,i=0;for(let a=0;a<e.length;a++){if(r===t.line&&n===t.column){i=a;break}e[a]===`
532
+ `,this.name+`: `+this.message+e}};t.exports=i,i.default=i})),ur=o(((e,t)=>{let n=rr();function r(e,t){new n(t).stringify(e)}t.exports=r,r.default=r})),dr=o(((e,t)=>{t.exports.isClean=Symbol(`isClean`),t.exports.my=Symbol(`my`)})),fr=o(((e,t)=>{let n=lr(),r=rr(),i=ur(),{isClean:a,my:o}=dr();function s(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r)||r===`proxyCache`)continue;let i=e[r],a=typeof i;r===`parent`&&a===`object`?t&&(n[r]=t):r===`source`?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>s(e,n)):(a===`object`&&i!==null&&(i=s(i)),n[r]=i)}return n}function c(e,t){if(t&&t.offset!==void 0)return t.offset;let n=1,r=1,i=0;for(let a=0;a<e.length;a++){if(r===t.line&&n===t.column){i=a;break}e[a]===`
533
533
  `?(n=1,r+=1):n+=1}return i}var l=class{get proxyOf(){return this}constructor(e={}){this.raws={},this[a]=!1,this[o]=!0;for(let t in e)if(t===`nodes`){this.nodes=[];for(let n of e[t])typeof n.clone==`function`?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=s(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new n(e)}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:t===`root`?()=>e.root().toProxy():e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`prop`||t===`value`||t===`name`||t===`params`||t===`important`||t===`text`)&&e.markDirty(),!0)}}}markClean(){this[a]=!0}markDirty(){if(this[a]){this[a]=!1;let e=this;for(;e=e.parent;)e[a]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e={}){let t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){let n=`document`in this.source.input?this.source.input.document:this.source.input.css,r=n.slice(c(n,this.source.start),c(n,this.source.end)).indexOf(e.word);r!==-1&&(t=this.positionInside(r))}return t}positionInside(e){let t=this.source.start.column,n=this.source.start.line,r=`document`in this.source.input?this.source.input.document:this.source.input.css,i=c(r,this.source.start),a=i+e;for(let e=i;e<a;e++)r[e]===`
534
- `?(t=1,n+=1):t+=1;return{column:t,line:n,offset:a}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t=`document`in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:c(t,this.source.start)},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset==`number`?this.source.end.offset:c(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let i=t.slice(c(t,this.source.start),c(t,this.source.end)).indexOf(e.word);i!==-1&&(n=this.positionInside(i),r=this.positionInside(i+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:c(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line,offset:c(t,e.end)}:typeof e.endIndex==`number`?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<n.line||r.line===n.line&&r.column<=n.column)&&(r={column:n.column+1,line:n.line,offset:n.offset+1}),{end:r,start:n}}raw(e,t){return new r().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!==`document`;)e=e.parent;return e}toJSON(e,t){let n={},r=t==null;t||=new Map;let i=0;for(let e in this){if(!Object.prototype.hasOwnProperty.call(this,e)||e===`parent`||e===`proxyCache`)continue;let r=this[e];if(Array.isArray(r))n[e]=r.map(e=>typeof e==`object`&&e.toJSON?e.toJSON(null,t):e);else if(typeof r==`object`&&r.toJSON)n[e]=r.toJSON(null,t);else if(e===`source`){if(r==null)continue;let a=t.get(r.input);a??(a=i,t.set(r.input,i),i++),n[e]={end:r.end,inputId:a,start:r.start}}else n[e]=r}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||=new Proxy(this,this.getProxyProcessor()),this.proxyCache}toString(e=i){e.stringify&&(e=e.stringify);let t=``;return e(this,e=>{t+=e}),t}warn(e,t,n={}){let r={node:this};for(let e in n)r[e]=n[e];return e.warn(t,r)}};t.exports=l,l.default=l})),fr=o(((e,t)=>{let n=dr();var r=class extends n{constructor(e){super(e),this.type=`comment`}};t.exports=r,r.default=r})),pr=o(((e,t)=>{let n=dr();var r=class extends n{get variable(){return this.prop.startsWith(`--`)||this.prop[0]===`$`}constructor(e){e&&e.value!==void 0&&typeof e.value!=`string`&&(e={...e,value:String(e.value)}),super(e),this.type=`decl`}};t.exports=r,r.default=r})),mr=o(((e,t)=>{let n=fr(),r=pr(),i=dr(),{isClean:a,my:o}=ur(),s,c,l,u;function d(e){return e.map(e=>(e.nodes&&=d(e.nodes),delete e.source,e))}function f(e){if(e[a]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)f(t)}var p=class e extends i{get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t=this.getIterator(),n,r;for(;this.indexes[t]<this.proxyOf.nodes.length&&(n=this.indexes[t],r=e(this.proxyOf.nodes[n],n),r!==!1);)this.indexes[t]+=1;return delete this.indexes[t],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||=0,this.indexes||={},this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:e[t]?t===`each`||typeof t==`string`&&t.startsWith(`walk`)?(...n)=>e[t](...n.map(e=>typeof e==`function`?(t,n)=>e(t.toProxy(),n):e)):t===`every`||t===`some`?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):t===`root`?()=>e.root().toProxy():t===`nodes`?e.nodes.map(e=>e.toProxy()):t===`first`||t===`last`?e[t].toProxy():e[t]:e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`name`||t===`params`||t===`selector`)&&e.markDirty(),!0)}}}index(e){return typeof e==`number`?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n=this.index(e),r=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let e of r)this.proxyOf.nodes.splice(n+1,0,e);let i;for(let e in this.indexes)i=this.indexes[e],n<i&&(this.indexes[e]=i+r.length);return this.markDirty(),this}insertBefore(e,t){let n=this.index(e),r=n===0?`prepend`:!1,i=this.normalize(t,this.proxyOf.nodes[n],r).reverse();n=this.index(e);for(let e of i)this.proxyOf.nodes.splice(n,0,e);let a;for(let e in this.indexes)a=this.indexes[e],n<=a&&(this.indexes[e]=a+i.length);return this.markDirty(),this}normalize(t,i){if(typeof t==`string`)t=d(c(t).nodes);else if(t===void 0)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type===`root`&&this.type!==`document`){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type)t=[t];else if(t.prop){if(t.value===void 0)throw Error(`Value field is missed in node creation`);typeof t.value!=`string`&&(t.value=String(t.value)),t=[new r(t)]}else if(t.selector||t.selectors)t=[new u(t)];else if(t.name)t=[new s(t)];else if(t.text)t=[new n(t)];else throw Error(`Unknown node type in node creation`);return t.map(t=>(t[o]||e.rebuild(t),t=t.proxyOf,t.parent&&t.parent.removeChild(t),t[a]&&f(t),t.raws||={},t.raws.before===void 0&&i&&i.raws.before!==void 0&&(t.raws.before=i.raws.before.replace(/\S/g,``)),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,`prepend`).reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);let t;for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return r!==!1&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`atrule`&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if(n.type===`atrule`&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`atrule`)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if(t.type===`comment`)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`decl`&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if(n.type===`decl`&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`decl`)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`rule`&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if(n.type===`rule`&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`rule`)return t(e,n)}))}};p.registerParse=e=>{c=e},p.registerRule=e=>{u=e},p.registerAtRule=e=>{s=e},p.registerRoot=e=>{l=e},t.exports=p,p.default=p,p.rebuild=e=>{e.type===`atrule`?Object.setPrototypeOf(e,s.prototype):e.type===`rule`?Object.setPrototypeOf(e,u.prototype):e.type===`decl`?Object.setPrototypeOf(e,r.prototype):e.type===`comment`?Object.setPrototypeOf(e,n.prototype):e.type===`root`&&Object.setPrototypeOf(e,l.prototype),e[o]=!0,e.nodes&&e.nodes.forEach(e=>{p.rebuild(e)})}})),hr=o(((e,t)=>{let n=mr();var r=class extends n{constructor(e){super(e),this.type=`atrule`}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}};t.exports=r,r.default=r,n.registerAtRule(r)})),gr=o(((e,t)=>{let n=mr(),r,i;var a=class extends n{constructor(e){super(e),this.type=`root`,this.nodes||=[]}normalize(e,t,n){let r=super.normalize(e);if(t){if(n===`prepend`)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let e of r)e.raws.before=t.raws.before}return r}removeChild(e,t){let n=this.index(e);return!t&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new r(new i,this,e).stringify()}};a.registerLazyResult=e=>{r=e},a.registerProcessor=e=>{i=e},t.exports=a,a.default=a,n.registerRoot(a)})),_r=o(((e,t)=>{let n={comma(e){return n.split(e,[`,`],!0)},space(e){return n.split(e,[` `,`
535
- `,` `])},split(e,t,n){let r=[],i=``,a=!1,o=0,s=!1,c=``,l=!1;for(let n of e)l?l=!1:n===`\\`?l=!0:s?n===c&&(s=!1):n===`"`||n===`'`?(s=!0,c=n):n===`(`?o+=1:n===`)`?o>0&&--o:o===0&&t.includes(n)&&(a=!0),a?(i!==``&&r.push(i.trim()),i=``,a=!1):i+=n;return(n||i!==``)&&r.push(i.trim()),r}};t.exports=n,n.default=n})),vr=o(((e,t)=>{let n=mr(),r=_r();var i=class extends n{get selectors(){return r.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:`,`+this.raw(`between`,`beforeOpen`);this.selector=e.join(n)}constructor(e){super(e),this.type=`rule`,this.nodes||=[]}};t.exports=i,i.default=i,n.registerRule(i)})),yr=o(((e,t)=>{let n=hr(),r=fr(),i=pr(),a=gr(),o=vr(),s=or(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}function u(e,t,n){let r=``;for(let i=t;i<n;i++)r+=e[i][1];return r}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;let a=0;for(;e[a][0]!==`word`;)a===e.length-1&&this.unknownWord([e[a]]),a++;n.raws.before+=u(e,0,a),n.source.start=this.getPosition(e[a][2]);let o=a;for(;a<e.length;){let t=e[a][0];if(t===`:`||t===`space`||t===`comment`)break;a++}n.prop=u(e,o,a);let s=a,c;for(;a<e.length&&(c=e[a],a++,c[0]!==`:`);)c[0]===`word`&&/\w/.test(c[1])&&this.unknownWord([c]);n.raws.between=u(e,s,a),(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let d=a;for(;a<e.length;){let t=e[a][0];if(t!==`space`&&t!==`comment`)break;a++}let f=e.slice(d,a);e=e.slice(a),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(c=e[t],c[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(c[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(c[0]!==`space`&&c[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=f.map(e=>e[1]).join(``),f=[]),this.raw(n,`value`,f.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),br=o(((e,t)=>{let{Container:n}=require("postcss");t.exports=class extends n{constructor(e){super(e),this.type=`decl`,this.isNested=!0,this.nodes||=[]}}})),xr=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[,\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i,o=/[\n\f\r]/g;t.exports=function(e,t={}){let s=e.css.valueOf(),c=t.ignoreErrors,l,u,d,f,p,m,h,g,_,v=s.length,y=0,b=[],x=[],ee;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function S(){return x.length===0&&y>=v}function re(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ne(`interpolation`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),t?!n&&l===t?(t=!1,n=!1):l===92?n=!n:n&&=!1:l===39||l===34?t=l:l===125?--e:l===35&&g===123&&(e+=1)}function ie(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(l=s.charCodeAt(y),l){case 10:case 32:case 9:case 13:case 12:u=y;do u+=1,l=s.charCodeAt(u);while(l===32||l===10||l===9||l===13||l===12);_=[`space`,s.slice(y,u)],y=u-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(l);_=[e,e,y];break}case 44:_=[`word`,`,`,y,y+1];break;case 40:if(h=b.length?b.pop()[1]:``,g=s.charCodeAt(y+1),h===`url`&&g!==39&&g!==34){for(ee=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)ee+=1;else if(g===41&&(--ee,ee===0))break;u+=1}f=s.slice(y,u+1),_=[`brackets`,f,y,u],y=u}else u=s.indexOf(`)`,y+1),f=s.slice(y,u+1),u===-1||i.test(f)?_=[`(`,`(`,y]:(_=[`brackets`,f,y,u],y=u);break;case 39:case 34:for(d=l,u=y,m=!1;u<v&&(u++,u===v&&ne(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&re();_=[`string`,s.slice(y,u+1),y,u],y=u;break;case 64:n.lastIndex=y+1,n.test(s),u=n.lastIndex===0?s.length-1:n.lastIndex-2,_=[`at-word`,s.slice(y,u+1),y,u],y=u;break;case 92:for(u=y,p=!0;s.charCodeAt(u+1)===92;)u+=1,p=!p;if(l=s.charCodeAt(u+1),p&&l!==47&&l!==32&&l!==10&&l!==9&&l!==13&&l!==12&&(u+=1,a.test(s.charAt(u)))){for(;a.test(s.charAt(u+1));)u+=1;s.charCodeAt(u+1)===32&&(u+=1)}_=[`word`,s.slice(y,u+1),y,u],y=u;break;default:g=s.charCodeAt(y+1),l===35&&g===123?(u=y,re(),f=s.slice(y,u+1),_=[`word`,f,y,u],y=u):l===47&&g===42?(u=s.indexOf(`*/`,y+2)+1,u===0&&(c||t?u=s.length:ne(`comment`)),_=[`comment`,s.slice(y,u+1),y,u],y=u):l===47&&g===47?(o.lastIndex=y+1,o.test(s),u=o.lastIndex===0?s.length-1:o.lastIndex-2,f=s.slice(y,u+1),_=[`comment`,f,y,u,`inline`],y=u):(r.lastIndex=y+1,r.test(s),u=r.lastIndex===0?s.length-1:r.lastIndex-2,_=[`word`,s.slice(y,u+1),y,u],b.push(_),y=u);break}return y++,_}function ae(e){x.push(e)}return{back:ae,endOfFile:S,nextToken:ie,position:te}}})),Sr=o(((e,t)=>{let{Comment:n}=require("postcss"),r=yr(),i=br(),a=xr();t.exports=class extends r{atrule(e){let t=e[1],n=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if(e[0]===`word`&&e[2]===n[3]+1)t+=e[1],n=e;else{this.tokenizer.back(e);break}}super.atrule([`at-word`,t,e[2],n[3]])}comment(e){if(e[4]===`inline`){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let i=e[1].slice(2);if(/^\s*$/.test(i))t.text=``,t.raws.left=i,t.raws.right=``;else{let e=i.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2].replace(/(\*\/|\/\*)/g,`*//*`),t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=a(this.input)}raw(e,t,n,r){if(super.raw(e,t,n,r),e.raws[t]){let r=e.raws[t].raw;e.raws[t].raw=n.reduce((e,t)=>{if(t[0]===`comment`&&t[4]===`inline`){let n=t[1].slice(2).replace(/(\*\/|\/\*)/g,`*//*`);return e+`/*`+n+`*/`}else return e+t[1]},``),r!==e.raws[t].raw&&(e.raws[t].scss=r)}}rule(e){let t=!1,n=0,r=``;for(let i of e)if(t)i[0]!==`comment`&&i[0]!==`{`&&(r+=i[1]);else if(i[0]===`space`&&i[1].includes(`
536
- `))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),Cr=o(((e,t)=>{let{Input:n}=require("postcss"),r=Sr();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),wr=o(((e,t)=>{let n=ir();t.exports={parse:Cr(),stringify:n}})),Tr=l(tr()),Er=s({default:()=>Or,parse:()=>Ar,stringify:()=>kr}),Dr=l(wr(),1),Or=Dr.default;const kr=Dr.default.stringify,Ar=Dr.default.parse;function jr(e,t){let n=null;return!e||t<e.offset||t>e.end?null:(e.accept(e=>e.offset===-1&&e.length===-1?!0:e.offset<=t&&e.end>=t?(n?e.length<=n.length&&(n=e):n=e,!0):!1),n)}function Mr(e,t){let n=jr(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var Nr=class{languageService;documentationInfo={};externalDocumentation={};internalDocumentation={};build;_allowRebuildDefinition=!0;getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}constructor(e){this.build=e,this.languageService=(0,ie.getSCSSLanguageService)()}async doValidation(e){let t=[];t=this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser));for(let e=0;e<t.length;e++)t[e].code==`emptyRules`&&(t.splice(e,1),e--);return t}async doComplete(e,t){let n=[],r={isIncomplete:!1,items:[]};r=this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));let i={};for(let e of r.items)i[e.label]=e;let a=this.getTree(e,t).reverse()[0];if(this.documentationInfo[a])for(let e of this.documentationInfo[a])n.indexOf(e.name)==-1&&(n.push(e.name),i[e.name]={label:e.name});let o=/^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;for(let e in this.build.globalSCSSLanguageService.variablesByName)this.build.globalSCSSLanguageService.variablesByName[e].value.match(o)?i[e]={label:e}:i[``+e]={label:``+e};return r.items=Object.values(i),r}async doHover(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return[{uri:e.uri,range:e.range}]}let r=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return r&&[r]}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,re.default)([(0,Tr.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Er,syntax:Er,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)}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(this._allowRebuildDefinition){this.documentationInfo={};for(let e in this.externalDocumentation){let t=this.externalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}}}addExternalDefinition(e,t){this.externalDocumentation[e]=t,this.rebuildDefinition()}getExternalDefinition(e){return this.externalDocumentation[e]}removeExternalDefinition(e){delete this.externalDocumentation[e],this.rebuildDefinition()}addInternalDefinition(e,t){this.internalDocumentation[e]=t,this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.rebuildDefinition()}getLinkToHtml(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.htmlFile;if(i&&i.fileParsed)for(let e of i.fileParsed.styleLinks){let t=e[1];r>=t.start&&r<=t.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(e[0].start),end:i.file.documentUser.positionAt(e[0].end)}})}return n}getTree(e,t){let n=[];if(this.languageService){let r=Mr(this.languageService.parseStylesheet(e.documentUser),e.documentUser.offsetAt(t));for(let e of r)if(e.type==3){let t=e.getChild(0);if(t){let e=t.getText();n.push(e)}}}return n}getRules(e){let t=new Map,n=this.languageService.parseStylesheet(e.documentUser),r=e=>t=>{let n=e.getText().replace(`.`,``),r=RegExp(`((?:^|\\W))(`+n+`)(?:$|\\W)`,`gi`);return!!t.attributes.class?.value?.match(r)},i=e=>t=>{let n=e.getText();return t.tagName==n},a=(e=null,t)=>n=>{if(e){let t=!1,r=n.parent;for(;r;){if(e(r)){t=!0;break}r=r.parent}if(!t)return!1}for(let e of t)if(!e(n))return!1;return!0},o=(e,n=null)=>{if(e.type==3){let o=e.getChildren();if(o.length>1){for(let e of o[1].getChildren())if(e.type==19||e.type==69||e.type==34||e.type==58||e.type==37)break}if(o.length>0){let e=o[0]?.getChildren()[0],s=null;if(e){for(let t of e.getChildren())if(t.type==5){s?s.start>t.offset?s.start=t.offset:s.end<t.offset+t.length&&(s.end=t.offset+t.length):s={start:t.offset,end:t.offset+t.length};let e=[];for(let n of t.getChildren())n.type==14?e.push(r(n)):n.type==16&&e.push(i(n));e.length>0&&(n=a(n,e))}else t.getText(),$.warning(`css node to implement`);n&&s&&t.set(n,s)}}}else if(e.type==21)return;if(e.hasChildren())for(let t of e.getChildren())o(t,n)},s=Mr(n,0);return s.length>0&&o(s[0]),t}getElementAtPosition(e,t){if(this.languageService){let n=this.languageService.parseStylesheet(e.documentUser),r=e.documentUser.offsetAt(t),i=e=>{let t=e.getChildren();for(let e of t)if(e.offset<=r&&e.end>=r)return e.hasChildren()?i(e):e;return null};return i(n)}return null}static getCustomProperty(e){let t=d.TextDocument.create(`temp.scss`,`scss`,1,e),n={},r=(e,t)=>{let n=e.parent?.getText()??``,r=RegExp(`\/\\*([\\s\\S]*?)\\*\/\\s*${t}\\s*:\\s*[^;]+;`,`g`).exec(n);if(r&&r[1]){let e={documentation:[],type:`*`},t=r[1].trim().replace(/\r\n?/g,`
534
+ `?(t=1,n+=1):t+=1;return{column:t,line:n,offset:a}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t=`document`in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:c(t,this.source.start)},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset==`number`?this.source.end.offset:c(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let i=t.slice(c(t,this.source.start),c(t,this.source.end)).indexOf(e.word);i!==-1&&(n=this.positionInside(i),r=this.positionInside(i+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:c(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line,offset:c(t,e.end)}:typeof e.endIndex==`number`?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<n.line||r.line===n.line&&r.column<=n.column)&&(r={column:n.column+1,line:n.line,offset:n.offset+1}),{end:r,start:n}}raw(e,t){return new r().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!==`document`;)e=e.parent;return e}toJSON(e,t){let n={},r=t==null;t||=new Map;let i=0;for(let e in this){if(!Object.prototype.hasOwnProperty.call(this,e)||e===`parent`||e===`proxyCache`)continue;let r=this[e];if(Array.isArray(r))n[e]=r.map(e=>typeof e==`object`&&e.toJSON?e.toJSON(null,t):e);else if(typeof r==`object`&&r.toJSON)n[e]=r.toJSON(null,t);else if(e===`source`){if(r==null)continue;let a=t.get(r.input);a??(a=i,t.set(r.input,i),i++),n[e]={end:r.end,inputId:a,start:r.start}}else n[e]=r}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||=new Proxy(this,this.getProxyProcessor()),this.proxyCache}toString(e=i){e.stringify&&(e=e.stringify);let t=``;return e(this,e=>{t+=e}),t}warn(e,t,n={}){let r={node:this};for(let e in n)r[e]=n[e];return e.warn(t,r)}};t.exports=l,l.default=l})),pr=o(((e,t)=>{let n=fr();var r=class extends n{constructor(e){super(e),this.type=`comment`}};t.exports=r,r.default=r})),mr=o(((e,t)=>{let n=fr();var r=class extends n{get variable(){return this.prop.startsWith(`--`)||this.prop[0]===`$`}constructor(e){e&&e.value!==void 0&&typeof e.value!=`string`&&(e={...e,value:String(e.value)}),super(e),this.type=`decl`}};t.exports=r,r.default=r})),hr=o(((e,t)=>{let n=pr(),r=mr(),i=fr(),{isClean:a,my:o}=dr(),s,c,l,u;function d(e){return e.map(e=>(e.nodes&&=d(e.nodes),delete e.source,e))}function f(e){if(e[a]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)f(t)}var p=class e extends i{get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t=this.getIterator(),n,r;for(;this.indexes[t]<this.proxyOf.nodes.length&&(n=this.indexes[t],r=e(this.proxyOf.nodes[n],n),r!==!1);)this.indexes[t]+=1;return delete this.indexes[t],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||=0,this.indexes||={},this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:e[t]?t===`each`||typeof t==`string`&&t.startsWith(`walk`)?(...n)=>e[t](...n.map(e=>typeof e==`function`?(t,n)=>e(t.toProxy(),n):e)):t===`every`||t===`some`?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):t===`root`?()=>e.root().toProxy():t===`nodes`?e.nodes.map(e=>e.toProxy()):t===`first`||t===`last`?e[t].toProxy():e[t]:e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`name`||t===`params`||t===`selector`)&&e.markDirty(),!0)}}}index(e){return typeof e==`number`?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n=this.index(e),r=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let e of r)this.proxyOf.nodes.splice(n+1,0,e);let i;for(let e in this.indexes)i=this.indexes[e],n<i&&(this.indexes[e]=i+r.length);return this.markDirty(),this}insertBefore(e,t){let n=this.index(e),r=n===0?`prepend`:!1,i=this.normalize(t,this.proxyOf.nodes[n],r).reverse();n=this.index(e);for(let e of i)this.proxyOf.nodes.splice(n,0,e);let a;for(let e in this.indexes)a=this.indexes[e],n<=a&&(this.indexes[e]=a+i.length);return this.markDirty(),this}normalize(t,i){if(typeof t==`string`)t=d(c(t).nodes);else if(t===void 0)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type===`root`&&this.type!==`document`){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type)t=[t];else if(t.prop){if(t.value===void 0)throw Error(`Value field is missed in node creation`);typeof t.value!=`string`&&(t.value=String(t.value)),t=[new r(t)]}else if(t.selector||t.selectors)t=[new u(t)];else if(t.name)t=[new s(t)];else if(t.text)t=[new n(t)];else throw Error(`Unknown node type in node creation`);return t.map(t=>(t[o]||e.rebuild(t),t=t.proxyOf,t.parent&&t.parent.removeChild(t),t[a]&&f(t),t.raws||={},t.raws.before===void 0&&i&&i.raws.before!==void 0&&(t.raws.before=i.raws.before.replace(/\S/g,``)),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,`prepend`).reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);let t;for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return r!==!1&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`atrule`&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if(n.type===`atrule`&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`atrule`)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if(t.type===`comment`)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`decl`&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if(n.type===`decl`&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`decl`)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`rule`&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if(n.type===`rule`&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`rule`)return t(e,n)}))}};p.registerParse=e=>{c=e},p.registerRule=e=>{u=e},p.registerAtRule=e=>{s=e},p.registerRoot=e=>{l=e},t.exports=p,p.default=p,p.rebuild=e=>{e.type===`atrule`?Object.setPrototypeOf(e,s.prototype):e.type===`rule`?Object.setPrototypeOf(e,u.prototype):e.type===`decl`?Object.setPrototypeOf(e,r.prototype):e.type===`comment`?Object.setPrototypeOf(e,n.prototype):e.type===`root`&&Object.setPrototypeOf(e,l.prototype),e[o]=!0,e.nodes&&e.nodes.forEach(e=>{p.rebuild(e)})}})),gr=o(((e,t)=>{let n=hr();var r=class extends n{constructor(e){super(e),this.type=`atrule`}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}};t.exports=r,r.default=r,n.registerAtRule(r)})),_r=o(((e,t)=>{let n=hr(),r,i;var a=class extends n{constructor(e){super(e),this.type=`root`,this.nodes||=[]}normalize(e,t,n){let r=super.normalize(e);if(t){if(n===`prepend`)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let e of r)e.raws.before=t.raws.before}return r}removeChild(e,t){let n=this.index(e);return!t&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new r(new i,this,e).stringify()}};a.registerLazyResult=e=>{r=e},a.registerProcessor=e=>{i=e},t.exports=a,a.default=a,n.registerRoot(a)})),vr=o(((e,t)=>{let n={comma(e){return n.split(e,[`,`],!0)},space(e){return n.split(e,[` `,`
535
+ `,` `])},split(e,t,n){let r=[],i=``,a=!1,o=0,s=!1,c=``,l=!1;for(let n of e)l?l=!1:n===`\\`?l=!0:s?n===c&&(s=!1):n===`"`||n===`'`?(s=!0,c=n):n===`(`?o+=1:n===`)`?o>0&&--o:o===0&&t.includes(n)&&(a=!0),a?(i!==``&&r.push(i.trim()),i=``,a=!1):i+=n;return(n||i!==``)&&r.push(i.trim()),r}};t.exports=n,n.default=n})),yr=o(((e,t)=>{let n=hr(),r=vr();var i=class extends n{get selectors(){return r.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:`,`+this.raw(`between`,`beforeOpen`);this.selector=e.join(n)}constructor(e){super(e),this.type=`rule`,this.nodes||=[]}};t.exports=i,i.default=i,n.registerRule(i)})),br=o(((e,t)=>{let n=gr(),r=pr(),i=mr(),a=_r(),o=yr(),s=sr(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}function u(e,t,n){let r=``;for(let i=t;i<n;i++)r+=e[i][1];return r}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;let a=0;for(;e[a][0]!==`word`;)a===e.length-1&&this.unknownWord([e[a]]),a++;n.raws.before+=u(e,0,a),n.source.start=this.getPosition(e[a][2]);let o=a;for(;a<e.length;){let t=e[a][0];if(t===`:`||t===`space`||t===`comment`)break;a++}n.prop=u(e,o,a);let s=a,c;for(;a<e.length&&(c=e[a],a++,c[0]!==`:`);)c[0]===`word`&&/\w/.test(c[1])&&this.unknownWord([c]);n.raws.between=u(e,s,a),(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let d=a;for(;a<e.length;){let t=e[a][0];if(t!==`space`&&t!==`comment`)break;a++}let f=e.slice(d,a);e=e.slice(a),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(c=e[t],c[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(c[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(c[0]!==`space`&&c[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=f.map(e=>e[1]).join(``),f=[]),this.raw(n,`value`,f.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),xr=o(((e,t)=>{let{Container:n}=require("postcss");t.exports=class extends n{constructor(e){super(e),this.type=`decl`,this.isNested=!0,this.nodes||=[]}}})),Sr=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[,\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i,o=/[\n\f\r]/g;t.exports=function(e,t={}){let s=e.css.valueOf(),c=t.ignoreErrors,l,u,d,f,p,m,h,g,_,v=s.length,y=0,b=[],x=[],ee;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function S(){return x.length===0&&y>=v}function re(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ne(`interpolation`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),t?!n&&l===t?(t=!1,n=!1):l===92?n=!n:n&&=!1:l===39||l===34?t=l:l===125?--e:l===35&&g===123&&(e+=1)}function ie(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(l=s.charCodeAt(y),l){case 10:case 32:case 9:case 13:case 12:u=y;do u+=1,l=s.charCodeAt(u);while(l===32||l===10||l===9||l===13||l===12);_=[`space`,s.slice(y,u)],y=u-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(l);_=[e,e,y];break}case 44:_=[`word`,`,`,y,y+1];break;case 40:if(h=b.length?b.pop()[1]:``,g=s.charCodeAt(y+1),h===`url`&&g!==39&&g!==34){for(ee=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)ee+=1;else if(g===41&&(--ee,ee===0))break;u+=1}f=s.slice(y,u+1),_=[`brackets`,f,y,u],y=u}else u=s.indexOf(`)`,y+1),f=s.slice(y,u+1),u===-1||i.test(f)?_=[`(`,`(`,y]:(_=[`brackets`,f,y,u],y=u);break;case 39:case 34:for(d=l,u=y,m=!1;u<v&&(u++,u===v&&ne(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&re();_=[`string`,s.slice(y,u+1),y,u],y=u;break;case 64:n.lastIndex=y+1,n.test(s),u=n.lastIndex===0?s.length-1:n.lastIndex-2,_=[`at-word`,s.slice(y,u+1),y,u],y=u;break;case 92:for(u=y,p=!0;s.charCodeAt(u+1)===92;)u+=1,p=!p;if(l=s.charCodeAt(u+1),p&&l!==47&&l!==32&&l!==10&&l!==9&&l!==13&&l!==12&&(u+=1,a.test(s.charAt(u)))){for(;a.test(s.charAt(u+1));)u+=1;s.charCodeAt(u+1)===32&&(u+=1)}_=[`word`,s.slice(y,u+1),y,u],y=u;break;default:g=s.charCodeAt(y+1),l===35&&g===123?(u=y,re(),f=s.slice(y,u+1),_=[`word`,f,y,u],y=u):l===47&&g===42?(u=s.indexOf(`*/`,y+2)+1,u===0&&(c||t?u=s.length:ne(`comment`)),_=[`comment`,s.slice(y,u+1),y,u],y=u):l===47&&g===47?(o.lastIndex=y+1,o.test(s),u=o.lastIndex===0?s.length-1:o.lastIndex-2,f=s.slice(y,u+1),_=[`comment`,f,y,u,`inline`],y=u):(r.lastIndex=y+1,r.test(s),u=r.lastIndex===0?s.length-1:r.lastIndex-2,_=[`word`,s.slice(y,u+1),y,u],b.push(_),y=u);break}return y++,_}function ae(e){x.push(e)}return{back:ae,endOfFile:S,nextToken:ie,position:te}}})),Cr=o(((e,t)=>{let{Comment:n}=require("postcss"),r=br(),i=xr(),a=Sr();t.exports=class extends r{atrule(e){let t=e[1],n=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if(e[0]===`word`&&e[2]===n[3]+1)t+=e[1],n=e;else{this.tokenizer.back(e);break}}super.atrule([`at-word`,t,e[2],n[3]])}comment(e){if(e[4]===`inline`){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let i=e[1].slice(2);if(/^\s*$/.test(i))t.text=``,t.raws.left=i,t.raws.right=``;else{let e=i.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2].replace(/(\*\/|\/\*)/g,`*//*`),t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=a(this.input)}raw(e,t,n,r){if(super.raw(e,t,n,r),e.raws[t]){let r=e.raws[t].raw;e.raws[t].raw=n.reduce((e,t)=>{if(t[0]===`comment`&&t[4]===`inline`){let n=t[1].slice(2).replace(/(\*\/|\/\*)/g,`*//*`);return e+`/*`+n+`*/`}else return e+t[1]},``),r!==e.raws[t].raw&&(e.raws[t].scss=r)}}rule(e){let t=!1,n=0,r=``;for(let i of e)if(t)i[0]!==`comment`&&i[0]!==`{`&&(r+=i[1]);else if(i[0]===`space`&&i[1].includes(`
536
+ `))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),wr=o(((e,t)=>{let{Input:n}=require("postcss"),r=Cr();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),Tr=o(((e,t)=>{let n=ar();t.exports={parse:wr(),stringify:n}})),Er=l(nr()),Dr=s({default:()=>kr,parse:()=>jr,stringify:()=>Ar}),Or=l(Tr(),1),kr=Or.default;const Ar=Or.default.stringify,jr=Or.default.parse;function Mr(e,t){let n=null;return!e||t<e.offset||t>e.end?null:(e.accept(e=>e.offset===-1&&e.length===-1?!0:e.offset<=t&&e.end>=t?(n?e.length<=n.length&&(n=e):n=e,!0):!1),n)}function Nr(e,t){let n=Mr(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var Pr=class{languageService;documentationInfo={};externalDocumentation={};internalDocumentation={};build;_allowRebuildDefinition=!0;getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}constructor(e){this.build=e,this.languageService=(0,ie.getSCSSLanguageService)()}async doValidation(e){let t=[];t=this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser));for(let e=0;e<t.length;e++)t[e].code==`emptyRules`&&(t.splice(e,1),e--);return t}async doComplete(e,t){let n=[],r={isIncomplete:!1,items:[]};r=this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));let i={};for(let e of r.items)i[e.label]=e;let a=this.getTree(e,t).reverse()[0];if(this.documentationInfo[a])for(let e of this.documentationInfo[a])n.indexOf(e.name)==-1&&(n.push(e.name),i[e.name]={label:e.name});let o=/^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;for(let e in this.build.globalSCSSLanguageService.variablesByName)this.build.globalSCSSLanguageService.variablesByName[e].value.match(o)?i[e]={label:e}:i[``+e]={label:``+e};return r.items=Object.values(i),r}async doHover(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return[{uri:e.uri,range:e.range}]}let r=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return r&&[r]}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,re.default)([(0,Er.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Dr,syntax:Dr,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)}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(this._allowRebuildDefinition){this.documentationInfo={};for(let e in this.externalDocumentation){let t=this.externalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}}}addExternalDefinition(e,t){this.externalDocumentation[e]=t,this.rebuildDefinition()}getExternalDefinition(e){return this.externalDocumentation[e]}removeExternalDefinition(e){delete this.externalDocumentation[e],this.rebuildDefinition()}addInternalDefinition(e,t){this.internalDocumentation[e]=t,this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.rebuildDefinition()}getLinkToHtml(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.htmlFile;if(i&&i.fileParsed)for(let e of i.fileParsed.styleLinks){let t=e[1];r>=t.start&&r<=t.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(e[0].start),end:i.file.documentUser.positionAt(e[0].end)}})}return n}getTree(e,t){let n=[];if(this.languageService){let r=Nr(this.languageService.parseStylesheet(e.documentUser),e.documentUser.offsetAt(t));for(let e of r)if(e.type==3){let t=e.getChild(0);if(t){let e=t.getText();n.push(e)}}}return n}getRules(e){let t=new Map,n=this.languageService.parseStylesheet(e.documentUser),r=e=>t=>{let n=e.getText().replace(`.`,``),r=RegExp(`((?:^|\\W))(`+n+`)(?:$|\\W)`,`gi`);return!!t.attributes.class?.value?.match(r)},i=e=>t=>{let n=e.getText();return t.tagName==n},a=(e=null,t)=>n=>{if(e){let t=!1,r=n.parent;for(;r;){if(e(r)){t=!0;break}r=r.parent}if(!t)return!1}for(let e of t)if(!e(n))return!1;return!0},o=(e,n=null)=>{if(e.type==3){let o=e.getChildren();if(o.length>1){for(let e of o[1].getChildren())if(e.type==19||e.type==69||e.type==34||e.type==58||e.type==37)break}if(o.length>0){let e=o[0]?.getChildren()[0],s=null;if(e){for(let t of e.getChildren())if(t.type==5){s?s.start>t.offset?s.start=t.offset:s.end<t.offset+t.length&&(s.end=t.offset+t.length):s={start:t.offset,end:t.offset+t.length};let e=[];for(let n of t.getChildren())n.type==14?e.push(r(n)):n.type==16&&e.push(i(n));e.length>0&&(n=a(n,e))}else t.getText(),$.warning(`css node to implement`);n&&s&&t.set(n,s)}}}else if(e.type==21)return;if(e.hasChildren())for(let t of e.getChildren())o(t,n)},s=Nr(n,0);return s.length>0&&o(s[0]),t}getElementAtPosition(e,t){if(this.languageService){let n=this.languageService.parseStylesheet(e.documentUser),r=e.documentUser.offsetAt(t),i=e=>{let t=e.getChildren();for(let e of t)if(e.offset<=r&&e.end>=r)return e.hasChildren()?i(e):e;return null};return i(n)}return null}static getCustomProperty(e){let t=d.TextDocument.create(`temp.scss`,`scss`,1,e),n={},r=(e,t)=>{let n=e.parent?.getText()??``,r=RegExp(`\/\\*([\\s\\S]*?)\\*\/\\s*${t}\\s*:\\s*[^;]+;`,`g`).exec(n);if(r&&r[1]){let e={documentation:[],type:`*`},t=r[1].trim().replace(/\r\n?/g,`
537
537
  `).split(`
538
538
  `);for(let n of t){let t=!1;n=n.replace(`*`,``).trim(),n.startsWith(`@`)?(t=!0,n.startsWith(`@type`)&&(e.type=n.replace(`@type`,``).trim()),n.startsWith(`@default`)&&(e.default=n.replace(`@default`,``).trim())):t||e.documentation.push(n.trim())}return e}return null},i=e=>{if(e.type==69){let t=e;for(;t&&t.selectors==null;)t=t.parent;if(t&&t.selectors.getText()==`:host`){let t=e.getChild(0),i=e.getChild(1);if(t&&i){let a=null;t.getText().startsWith(`--internal`)?a=t.getText().replace(`--internal-`,`--`):t.getText().startsWith(`--_`)&&(a=t.getText().replace(`--_`,`--`));let o=r(e,t.getText());if(a&&i.getText().indexOf(a)!=-1){let e={name:a};o?.documentation&&(e.documentation=o.documentation.join(`
539
- `).trim()),o?.type&&(e.type=o.type),o?.default&&(e.defaultValue=o.default);let t=i,r=[],s=``;for(;t&&t.getChildren().length>0;){let e=t.getChildren(),n=t.getText();n&&n.startsWith(`--`)&&(n=n.split(`,`)[0],s!=n&&n!=a&&(s=n,r.push(n))),t=e[e.length-1]}let c=t.getText()??``;c&&(c.startsWith(`--`)||r.push(c)),r.length>0&&(e.chainValues=r,e.defaultValue??=e.chainValues[e.chainValues.length-1]),n[e.name]=e}}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=Mr((0,ie.getSCSSLanguageService)().parseStylesheet(t),0);for(let e of a)i(e);return Object.values(n)}},Pr=class e extends De{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;namespace=``;_rules=new Map;customProperties=[];get compileResult(){return this.compiledTxt}get rules(){return this._rules}get htmlFile(){let e=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];return e instanceof Fr?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(w.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}async init(){await this.loadDependencies(),await this.compile(!1)}async onValidate(){return this.diagnostics=await this.build.scssLanguageService.doValidation(this.file),await this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onContentChange(){}async onSave(){await this.compileRoot()}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(e=!0){try{let t=this.compiledTxt,n=`|error|`,r=async e=>{let t=e.contentUser;t=t.replace(/\/\*[\s\S]*?@import[\s\S]*?\*\/|\/\/.*@import.*/g,``);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(t);){let i=a[2],o=await this.resolvePath(i,e.folderPath);if(o){let e=await r(o);if(e==n)return e;t=t.replace(a[0],e)}else return n}return t},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=Nr.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,ae.compileString)(i,{style:`compressed`}).css.toString().trim();e=e.replace(/\\/g,`\\\\`),t=e,this.diagnosticCompile&&(this.diagnosticCompile=void 0,$.sendDiagnostics({uri:this.file.uri,diagnostics:this.diagnostics},this.build))}catch(e){if(e instanceof ae.Exception){this.diagnosticCompile=zi(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)D.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentLogic)];if(t instanceof j&&e&&(t.canUpdateComponent=!1,await t.triggerSave(),t.compilationResult)){let e=this.namespace,n=t.fileParsed?.classes[t.compilationResult.componentName].namespace;n&&(e+=n),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),D.getInstance().updateCSS(this.compiledTxt,e+t.compilationResult.componentName,[])}}this._rules=this.build.scssLanguageService.getRules(this.file);let a=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];a instanceof Fr&&M.refreshStyle(a,this.build)}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()}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.build.scssLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.build.scssLanguageService.doHover(e,t)}async onDefinition(e,t){return this.build.scssLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.build.scssLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.build.scssLanguageService.doCodeAction(e,t)}async onReferences(e,t){let n=await this.build.scssLanguageService.onReferences(e,t);return n=[...n,...this.build.scssLanguageService.getLinkToHtml(this,t)],n}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return null}async 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=await this.resolvePath(t,this.file.folderPath);if(n)await this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Bi(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])}async addDependency(t){this.build.scssFiles[t.uri]?(this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.ComponentStyle)&&(this.build.scssFiles[t.uri]=new e(t,this.build),await this.build.scssFiles[t.uri].init(),this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this)}async getByPath(e){let t=R.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(F(e),C.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await R.getInstance().registerFile(t),R.getInstance().getByPath(e)}}async resolvePath(e,t){e=this.build.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=await this.getByPath(e);if(n)return n;let r=e+w.ComponentStyle;if(n=await this.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=await this.getByPath(a),n)return n;let o=a+w.ComponentStyle;if(n=await this.getByPath(o),n)return n}},Fr=class extends De{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(w.ComponentView,w.ComponentLogic)];return e instanceof j?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(w.ComponentView,w.ComponentStyle)];return e instanceof Pr?e:null}_slotsInfo;slotsInfoVersion=0;get slotsInfo(){return(this.slotsInfoVersion!=this.file.versionInternal||!this._slotsInfo)&&(this._slotsInfo=this.getSlotsInfo(),this.slotsInfoVersion=this.file.versionInternal),this._slotsInfo}constructor(e,t){super(e,t)}async init(){await this.refreshFileParsed()}refreshFileParsed(){this.fileParsed=M.parse(this,this.build);let e=M.getVersion(this);return this.version==e?!1:(this.version=e,this.file.validate(),!0)}async onValidate(){let e=await this.build.htmlLanguageService.doValidation(this.file);this.fileParsed&&(e=[...e,...this.fileParsed.errors]),e=[...e,...this.tsErrors],this.tsFile&&(e=[...e,...this.tsFile.htmlDiagnostics]),this.codeactions=[];let t=e=>{let t=this.file.documentUser.offsetAt(e.range.start),n=this.file.contentUser.slice(t-3,t-1),r=n==`.t`;if(n!=` t`&&n!=`.t`&&n!=`{t`)return;let i=this.file.documentUser.getText(e.range).slice(1,-1),a={title:`Add value into translation file`,command:{command:`aventus.i18n.add`,title:`Add value into translation file`,arguments:[this.file.uri,i,r]},diagnostics:[e],range:{start:t,end:this.file.documentUser.offsetAt(e.range.end)}};this.codeactions.push(a)};for(let n of e)(n.message.endsWith(`keyof AventusI18n'.`)||/Argument of type .*? is not assignable to parameter of type .*?\./.test(n.message))&&t(n);return e}async onContentChange(){await this.compile()}async onSave(){await this.tsFile?.triggerSave()}async compile(){try{this.refreshFileParsed()&&await this.tsFile?.validate()}catch(e){console.error(e)}}async onDelete(){}async onCompletion(e,t){return await this.tsFile?.doViewCompletion(t)||this.build.htmlLanguageService.doComplete(this,t)}async onCompletionResolve(e,t){return t}async getHover(e){return this.onHover(this.file,this.file.documentUser.positionAt(e))}async onHover(e,t){return await this.tsFile?.doHover(t)||await this.build.htmlLanguageService.doHover(this,t)}async onDefinition(e,t){return await this.tsFile?.doDefinition(t)||this.build.htmlLanguageService.onDefinition(this,t)}async onFormatting(e,t,n){await this.compile();let r=await this.applyJsFormatting(t,n);return this.applyHtmlFormatting(e,t,n,r)}async applyJsFormatting(e,t){let n=await this.tsFile?.doFormatting(e,t)??[];if(!this.fileParsed)return{};let r=new Map,i=new Map,a=new Map;for(let e of n)if(e.kind==`fct`)for(let t in this.fileParsed.fcts){let n=this.fileParsed.fcts[t];if(n.positions.find(t=>t.start==e.start&&t.end==e.end)){let t=r.get(n);t||(t=[],r.set(n,t));let i={start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText};t.some(e=>e.start==i.start&&e.end==i.end&&e.txt==i.txt)||t.push(i);break}}else if(e.kind==`loop`){for(let t of this.fileParsed.loops)if(t.start==e.start&&t.startBlock==e.end){let n=i.get(t);n||(n=[],i.set(t,n)),n.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}else if(e.kind==`if`){for(let t of this.fileParsed.ifs)for(let n of t.conditions)if(n.start==e.start&&n.end==e.end){let t=a.get(n);t||(t=[],a.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}let o={};for(let[e,t]of r){let n=`{{`+e.txt+`}}`;o[n]=n,t.sort((e,t)=>t.end-e.end);for(let e of t)o[n]=o[n].slice(0,e.start)+e.txt+o[n].slice(e.end)}for(let[e,t]of i){let n=e.idTemplate,r=e.loopTxt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);r=r.slice(0,r.length-1),o[`<`+Sn.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+Sn.tagName+` id="`+e.idTemplate+`">`]=e.loopTxt.slice(0,e.loopTxt.length-1));for(let[e,t]of a){let n=e.idTemplate,r=e.txt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);e.type==`if`?r=`if(`+r+`) {`:e.type==`elif`&&(r=`else if(`+r+`) {`),o[`<`+Cn.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.ifs){for(let t of e.conditions)if(!a.has(t)){let e=t.txt;t.type==`if`?e=`if(`+e+`) {`:t.type==`elif`&&(e=`else if(`+e+`) {`),o[`<`+Cn.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+Cn.tagName+` id="`+e.idsTemplate[e.idsTemplate.length-1]+`">`]=`else {`)}for(let e of this.fileParsed.contextEdits){let t=e.mapping.length>0?e.mapping[0]:``,n=e.mapping.length>1?e.mapping[1]:``,r=`@Context(`+t+`, `+n+`)`;o[`<`+wn.tagName+` id="`+e.id+`"></`+wn.tagName+`>`]=r}return o[`</`+Sn.tagName+`>`]=`}`,o[`</`+Cn.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt;for(let e in r)if(e.startsWith(`{{`)){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);i=i.replace(t,r[e])}let a=[];i=i.replace(/\{\{[\s\S]*?\}\}/g,e=>`___AVENTUS_INTERPOLATION_${a.push(e)-1}___`);let o=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),s={start:o.positionAt(0),end:o.positionAt(i.length)},c=(await this.build.htmlLanguageService.format(o,s,n))[0].newText;for(let e in r){if(e.startsWith(`{{`))continue;let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);c=c.replace(t,r[e])}return c=c.replace(/___AVENTUS_INTERPOLATION_(\d+)___/g,(e,t)=>a[Number(t)]),c=c.replace(/\{\{\s*([\s\S]*?\S)\s*\}\}/g,`{{ $1 }}`),[{newText:c,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}async onCodeAction(e,t){let n=e.documentUser.offsetAt(t.start),r=e.documentUser.offsetAt(t.end);return this.codeactions.filter(e=>e.range.start<=n&&e.range.end>=r)}async onReferences(e,t){return await this.tsFile?.doReferences(t)||this.build.htmlLanguageService.getLinkToStyle(this,t)}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return await this.tsFile?.doRename(t,n)||null}getSlotsInfo(){let e=this.tsFile?.fileParsed?.classes[this.tsFile.componentClassName]??null;return e?this.build.getSlotsInfo(e):{}}};const Ir=[{name:`@element`,description:`Add a selector for the element inside your logical part`},{name:`@bind`,description:`Bind a watcher to a variable`},{name:`@press`,description:`Add an event for when the element is clicked`},{name:`@press-start`,description:`Add an event for when mouse down or touch start on the element`},{name:`@press-stop`,description:`Add an event for when mouse up or touch start on the element`},{name:`@longpress`,description:`Add an event for when the element is long pressed`},{name:`@longpress-delay`,description:`Add the delay for the long press`},{name:`@dblpress`,description:`Add an event for when the element is double press`},{name:`@dblpress-delay`,description:`Add the delay for the double press`},{name:`@drag`,description:`Add an event for when the element is dragged`},{name:`@drag-start`,description:`Add an event for when the element first drag`},{name:`@drag-end`,description:`Add an event for when the element drag end`}],Lr={a:`HTMLAnchorElement`,abbr:`HTMLElement`,address:`HTMLElement`,area:`HTMLAreaElement`,article:`HTMLElement`,aside:`HTMLElement`,audio:`HTMLAudioElement`,b:`HTMLElement`,base:`HTMLBaseElement`,bdi:`HTMLElement`,bdo:`HTMLElement`,blockquote:`HTMLQuoteElement`,body:`HTMLBodyElement`,br:`HTMLBRElement`,button:`HTMLButtonElement`,canvas:`HTMLCanvasElement`,caption:`HTMLTableCaptionElement`,cite:`HTMLElement`,code:`HTMLElement`,col:`HTMLTableColElement`,colgroup:`HTMLTableColElement`,data:`HTMLDataElement`,datalist:`HTMLDataListElement`,dd:`HTMLElement`,del:`HTMLModElement`,details:`HTMLDetailsElement`,dfn:`HTMLElement`,dialog:`HTMLDialogElement`,div:`HTMLDivElement`,dl:`HTMLDListElement`,dt:`HTMLElement`,em:`HTMLElement`,embed:`HTMLEmbedElement`,fieldset:`HTMLFieldSetElement`,figcaption:`HTMLElement`,figure:`HTMLElement`,footer:`HTMLElement`,form:`HTMLFormElement`,h1:`HTMLHeadingElement`,h2:`HTMLHeadingElement`,h3:`HTMLHeadingElement`,h4:`HTMLHeadingElement`,h5:`HTMLHeadingElement`,h6:`HTMLHeadingElement`,head:`HTMLHeadElement`,header:`HTMLElement`,hgroup:`HTMLElement`,hr:`HTMLHRElement`,html:`HTMLHtmlElement`,i:`HTMLElement`,iframe:`HTMLIFrameElement`,img:`HTMLImageElement`,input:`HTMLInputElement`,ins:`HTMLModElement`,kbd:`HTMLElement`,label:`HTMLLabelElement`,legend:`HTMLLegendElement`,li:`HTMLLIElement`,link:`HTMLLinkElement`,main:`HTMLElement`,map:`HTMLMapElement`,mark:`HTMLElement`,menu:`HTMLMenuElement`,meta:`HTMLMetaElement`,meter:`HTMLMeterElement`,nav:`HTMLElement`,noscript:`HTMLElement`,object:`HTMLObjectElement`,ol:`HTMLOListElement`,optgroup:`HTMLOptGroupElement`,option:`HTMLOptionElement`,output:`HTMLOutputElement`,p:`HTMLParagraphElement`,picture:`HTMLPictureElement`,pre:`HTMLPreElement`,progress:`HTMLProgressElement`,q:`HTMLQuoteElement`,rp:`HTMLElement`,rt:`HTMLElement`,ruby:`HTMLElement`,s:`HTMLElement`,samp:`HTMLElement`,script:`HTMLScriptElement`,section:`HTMLElement`,select:`HTMLSelectElement`,slot:`HTMLSlotElement`,small:`HTMLElement`,source:`HTMLSourceElement`,span:`HTMLSpanElement`,strong:`HTMLElement`,style:`HTMLStyleElement`,sub:`HTMLElement`,summary:`HTMLElement`,sup:`HTMLElement`,table:`HTMLTableElement`,tbody:`HTMLTableSectionElement`,td:`HTMLTableCellElement`,template:`HTMLTemplateElement`,textarea:`HTMLTextAreaElement`,tfoot:`HTMLTableSectionElement`,th:`HTMLTableCellElement`,thead:`HTMLTableSectionElement`,time:`HTMLTimeElement`,title:`HTMLTitleElement`,tr:`HTMLTableRowElement`,track:`HTMLTrackElement`,u:`HTMLElement`,ul:`HTMLUListElement`,var:`HTMLElement`,video:`HTMLVideoElement`,wbr:`HTMLElement`,acronym:`HTMLElement`,applet:`HTMLUnknownElement`,basefont:`HTMLElement`,bgsound:`HTMLUnknownElement`,big:`HTMLElement`,blink:`HTMLUnknownElement`,center:`HTMLElement`,dir:`HTMLDirectoryElement`,font:`HTMLFontElement`,frame:`HTMLFrameElement`,frameset:`HTMLFrameSetElement`,isindex:`HTMLUnknownElement`,keygen:`HTMLUnknownElement`,listing:`HTMLPreElement`,marquee:`HTMLMarqueeElement`,menuitem:`HTMLElement`,multicol:`HTMLUnknownElement`,nextid:`HTMLUnknownElement`,nobr:`HTMLElement`,noembed:`HTMLElement`,noframes:`HTMLElement`,param:`HTMLParamElement`,plaintext:`HTMLElement`,rb:`HTMLElement`,rtc:`HTMLElement`,spacer:`HTMLUnknownElement`,strike:`HTMLElement`,tt:`HTMLElement`,xmp:`HTMLPreElement`,animate:`SVGAnimateElement`,animateMotion:`SVGAnimateMotionElement`,animateTransform:`SVGAnimateTransformElement`,circle:`SVGCircleElement`,clipPath:`SVGClipPathElement`,defs:`SVGDefsElement`,desc:`SVGDescElement`,ellipse:`SVGEllipseElement`,feBlend:`SVGFEBlendElement`,feColorMatrix:`SVGFEColorMatrixElement`,feComponentTransfer:`SVGFEComponentTransferElement`,feComposite:`SVGFECompositeElement`,feConvolveMatrix:`SVGFEConvolveMatrixElement`,feDiffuseLighting:`SVGFEDiffuseLightingElement`,feDisplacementMap:`SVGFEDisplacementMapElement`,feDistantLight:`SVGFEDistantLightElement`,feDropShadow:`SVGFEDropShadowElement`,feFlood:`SVGFEFloodElement`,feFuncA:`SVGFEFuncAElement`,feFuncB:`SVGFEFuncBElement`,feFuncG:`SVGFEFuncGElement`,feFuncR:`SVGFEFuncRElement`,feGaussianBlur:`SVGFEGaussianBlurElement`,feImage:`SVGFEImageElement`,feMerge:`SVGFEMergeElement`,feMergeNode:`SVGFEMergeNodeElement`,feMorphology:`SVGFEMorphologyElement`,feOffset:`SVGFEOffsetElement`,fePointLight:`SVGFEPointLightElement`,feSpecularLighting:`SVGFESpecularLightingElement`,feSpotLight:`SVGFESpotLightElement`,feTile:`SVGFETileElement`,feTurbulence:`SVGFETurbulenceElement`,filter:`SVGFilterElement`,foreignObject:`SVGForeignObjectElement`,g:`SVGGElement`,image:`SVGImageElement`,line:`SVGLineElement`,linearGradient:`SVGLinearGradientElement`,marker:`SVGMarkerElement`,mask:`SVGMaskElement`,metadata:`SVGMetadataElement`,mpath:`SVGMPathElement`,path:`SVGPathElement`,pattern:`SVGPatternElement`,polygon:`SVGPolygonElement`,polyline:`SVGPolylineElement`,radialGradient:`SVGRadialGradientElement`,rect:`SVGRectElement`,set:`SVGSetElement`,stop:`SVGStopElement`,svg:`SVGSVGElement`,switch:`SVGSwitchElement`,symbol:`SVGSymbolElement`,text:`SVGTextElement`,textPath:`SVGTextPathElement`,tspan:`SVGTSpanElement`,use:`SVGUseElement`,view:`SVGViewElement`},Rr={for:"for(let ${1:i} = 0; ${1:i} < ${2:this.elements}; ${1:i}++) {\n ${3}\n}",forIn:"for(let ${1:index} in ${2:this.elements}) {\n ${3}\n}",forOf:"for(let ${1:element} of ${2:this.elements}) {\n ${3}\n}",if:`if(\${1:true}) {
539
+ `).trim()),o?.type&&(e.type=o.type),o?.default&&(e.defaultValue=o.default);let t=i,r=[],s=``;for(;t&&t.getChildren().length>0;){let e=t.getChildren(),n=t.getText();n&&n.startsWith(`--`)&&(n=n.split(`,`)[0],s!=n&&n!=a&&(s=n,r.push(n))),t=e[e.length-1]}let c=t.getText()??``;c&&(c.startsWith(`--`)||r.push(c)),r.length>0&&(e.chainValues=r,e.defaultValue??=e.chainValues[e.chainValues.length-1]),n[e.name]=e}}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=Nr((0,ie.getSCSSLanguageService)().parseStylesheet(t),0);for(let e of a)i(e);return Object.values(n)}},Fr=class e extends De{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;namespace=``;_rules=new Map;customProperties=[];get compileResult(){return this.compiledTxt}get rules(){return this._rules}get htmlFile(){let e=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];return e instanceof Ir?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(w.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}async init(){await this.loadDependencies(),await this.compile(!1)}async onValidate(){return this.diagnostics=await this.build.scssLanguageService.doValidation(this.file),await this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onContentChange(){}async onSave(){await this.compileRoot()}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(e=!0){try{let t=this.compiledTxt,n=`|error|`,r=async e=>{let t=e.contentUser;t=t.replace(/\/\*[\s\S]*?@import[\s\S]*?\*\/|\/\/.*@import.*/g,``);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(t);){let i=a[2],o=await this.resolvePath(i,e.folderPath);if(o){let e=await r(o);if(e==n)return e;t=t.replace(a[0],e)}else return n}return t},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=Pr.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,ae.compileString)(i,{style:`compressed`}).css.toString().trim();e=e.replace(/\\/g,`\\\\`),t=e,this.diagnosticCompile&&(this.diagnosticCompile=void 0,$.sendDiagnostics({uri:this.file.uri,diagnostics:this.diagnostics},this.build))}catch(e){if(e instanceof ae.Exception){this.diagnosticCompile=Bi(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)D.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentLogic)];if(t instanceof j&&e&&(t.canUpdateComponent=!1,await t.triggerSave(),t.compilationResult)){let e=this.namespace,n=t.fileParsed?.classes[t.compilationResult.componentName].namespace;n&&(e+=n),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),D.getInstance().updateCSS(this.compiledTxt,e+t.compilationResult.componentName,[])}}this._rules=this.build.scssLanguageService.getRules(this.file);let a=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];a instanceof Ir&&M.refreshStyle(a,this.build)}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()}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.build.scssLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.build.scssLanguageService.doHover(e,t)}async onDefinition(e,t){return this.build.scssLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.build.scssLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.build.scssLanguageService.doCodeAction(e,t)}async onReferences(e,t){let n=await this.build.scssLanguageService.onReferences(e,t);return n=[...n,...this.build.scssLanguageService.getLinkToHtml(this,t)],n}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return null}async 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=await this.resolvePath(t,this.file.folderPath);if(n)await this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Vi(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])}async addDependency(t){this.build.scssFiles[t.uri]?(this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.ComponentStyle)&&(this.build.scssFiles[t.uri]=new e(t,this.build),await this.build.scssFiles[t.uri].init(),this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this)}async getByPath(e){let t=R.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(F(e),C.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await R.getInstance().registerFile(t),R.getInstance().getByPath(e)}}async resolvePath(e,t){e=this.build.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=await this.getByPath(e);if(n)return n;let r=e+w.ComponentStyle;if(n=await this.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=await this.getByPath(a),n)return n;let o=a+w.ComponentStyle;if(n=await this.getByPath(o),n)return n}},Ir=class extends De{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(w.ComponentView,w.ComponentLogic)];return e instanceof j?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(w.ComponentView,w.ComponentStyle)];return e instanceof Fr?e:null}_slotsInfo;slotsInfoVersion=0;get slotsInfo(){return(this.slotsInfoVersion!=this.file.versionInternal||!this._slotsInfo)&&(this._slotsInfo=this.getSlotsInfo(),this.slotsInfoVersion=this.file.versionInternal),this._slotsInfo}constructor(e,t){super(e,t)}async init(){await this.refreshFileParsed()}refreshFileParsed(){this.fileParsed=M.parse(this,this.build);let e=M.getVersion(this);return this.version==e?!1:(this.version=e,this.file.validate(),!0)}async onValidate(){let e=await this.build.htmlLanguageService.doValidation(this.file);this.fileParsed&&(e=[...e,...this.fileParsed.errors]),e=[...e,...this.tsErrors],this.tsFile&&(e=[...e,...this.tsFile.htmlDiagnostics]),this.codeactions=[];let t=e=>{let t=this.file.documentUser.offsetAt(e.range.start),n=this.file.contentUser.slice(t-3,t-1),r=n==`.t`;if(n!=` t`&&n!=`.t`&&n!=`{t`)return;let i=this.file.documentUser.getText(e.range).slice(1,-1),a={title:`Add value into translation file`,command:{command:`aventus.i18n.add`,title:`Add value into translation file`,arguments:[this.file.uri,i,r]},diagnostics:[e],range:{start:t,end:this.file.documentUser.offsetAt(e.range.end)}};this.codeactions.push(a)};for(let n of e)(n.message.endsWith(`keyof AventusI18n'.`)||/Argument of type .*? is not assignable to parameter of type .*?\./.test(n.message))&&t(n);return e}async onContentChange(){await this.compile()}async onSave(){await this.tsFile?.triggerSave()}async compile(){try{this.refreshFileParsed()&&await this.tsFile?.validate()}catch(e){console.error(e)}}async onDelete(){}async onCompletion(e,t){return await this.tsFile?.doViewCompletion(t)||this.build.htmlLanguageService.doComplete(this,t)}async onCompletionResolve(e,t){return t}async getHover(e){return this.onHover(this.file,this.file.documentUser.positionAt(e))}async onHover(e,t){return await this.tsFile?.doHover(t)||await this.build.htmlLanguageService.doHover(this,t)}async onDefinition(e,t){return await this.tsFile?.doDefinition(t)||this.build.htmlLanguageService.onDefinition(this,t)}async onFormatting(e,t,n){await this.compile();let r=await this.applyJsFormatting(t,n);return this.applyHtmlFormatting(e,t,n,r)}async applyJsFormatting(e,t){let n=await this.tsFile?.doFormatting(e,t)??[];if(!this.fileParsed)return{};let r=new Map,i=new Map,a=new Map;for(let e of n)if(e.kind==`fct`)for(let t in this.fileParsed.fcts){let n=this.fileParsed.fcts[t];if(n.positions.find(t=>t.start==e.start&&t.end==e.end)){let t=r.get(n);t||(t=[],r.set(n,t));let i={start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText};t.some(e=>e.start==i.start&&e.end==i.end&&e.txt==i.txt)||t.push(i);break}}else if(e.kind==`loop`){for(let t of this.fileParsed.loops)if(t.start==e.start&&t.startBlock==e.end){let n=i.get(t);n||(n=[],i.set(t,n)),n.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}else if(e.kind==`if`){for(let t of this.fileParsed.ifs)for(let n of t.conditions)if(n.start==e.start&&n.end==e.end){let t=a.get(n);t||(t=[],a.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}let o={};for(let[e,t]of r){let n=`{{`+e.txt+`}}`;o[n]=n,t.sort((e,t)=>t.end-e.end);for(let e of t)o[n]=o[n].slice(0,e.start)+e.txt+o[n].slice(e.end)}for(let[e,t]of i){let n=e.idTemplate,r=e.loopTxt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);r=r.slice(0,r.length-1),o[`<`+Cn.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+Cn.tagName+` id="`+e.idTemplate+`">`]=e.loopTxt.slice(0,e.loopTxt.length-1));for(let[e,t]of a){let n=e.idTemplate,r=e.txt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);e.type==`if`?r=`if(`+r+`) {`:e.type==`elif`&&(r=`else if(`+r+`) {`),o[`<`+wn.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.ifs){for(let t of e.conditions)if(!a.has(t)){let e=t.txt;t.type==`if`?e=`if(`+e+`) {`:t.type==`elif`&&(e=`else if(`+e+`) {`),o[`<`+wn.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+wn.tagName+` id="`+e.idsTemplate[e.idsTemplate.length-1]+`">`]=`else {`)}for(let e of this.fileParsed.contextEdits){let t=e.mapping.length>0?e.mapping[0]:``,n=e.mapping.length>1?e.mapping[1]:``,r=`@Context(`+t+`, `+n+`)`;o[`<`+Tn.tagName+` id="`+e.id+`"></`+Tn.tagName+`>`]=r}return o[`</`+Cn.tagName+`>`]=`}`,o[`</`+wn.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt;for(let e in r)if(e.startsWith(`{{`)){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);i=i.replace(t,r[e])}let a=[];i=i.replace(/\{\{[\s\S]*?\}\}/g,e=>`___AVENTUS_INTERPOLATION_${a.push(e)-1}___`);let o=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),s={start:o.positionAt(0),end:o.positionAt(i.length)},c=(await this.build.htmlLanguageService.format(o,s,n))[0].newText;for(let e in r){if(e.startsWith(`{{`))continue;let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);c=c.replace(t,r[e])}return c=c.replace(/___AVENTUS_INTERPOLATION_(\d+)___/g,(e,t)=>a[Number(t)]),c=c.replace(/\{\{\s*([\s\S]*?\S)\s*\}\}/g,`{{ $1 }}`),[{newText:c,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}async onCodeAction(e,t){let n=e.documentUser.offsetAt(t.start),r=e.documentUser.offsetAt(t.end);return this.codeactions.filter(e=>e.range.start<=n&&e.range.end>=r)}async onReferences(e,t){return await this.tsFile?.doReferences(t)||this.build.htmlLanguageService.getLinkToStyle(this,t)}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return await this.tsFile?.doRename(t,n)||null}getSlotsInfo(){let e=this.tsFile?.fileParsed?.classes[this.tsFile.componentClassName]??null;return e?this.build.getSlotsInfo(e):{}}};const Lr=[{name:`@element`,description:`Add a selector for the element inside your logical part`},{name:`@bind`,description:`Bind a watcher to a variable`},{name:`@press`,description:`Add an event for when the element is clicked`},{name:`@press-start`,description:`Add an event for when mouse down or touch start on the element`},{name:`@press-stop`,description:`Add an event for when mouse up or touch start on the element`},{name:`@longpress`,description:`Add an event for when the element is long pressed`},{name:`@longpress-delay`,description:`Add the delay for the long press`},{name:`@dblpress`,description:`Add an event for when the element is double press`},{name:`@dblpress-delay`,description:`Add the delay for the double press`},{name:`@drag`,description:`Add an event for when the element is dragged`},{name:`@drag-start`,description:`Add an event for when the element first drag`},{name:`@drag-end`,description:`Add an event for when the element drag end`}],Rr={a:`HTMLAnchorElement`,abbr:`HTMLElement`,address:`HTMLElement`,area:`HTMLAreaElement`,article:`HTMLElement`,aside:`HTMLElement`,audio:`HTMLAudioElement`,b:`HTMLElement`,base:`HTMLBaseElement`,bdi:`HTMLElement`,bdo:`HTMLElement`,blockquote:`HTMLQuoteElement`,body:`HTMLBodyElement`,br:`HTMLBRElement`,button:`HTMLButtonElement`,canvas:`HTMLCanvasElement`,caption:`HTMLTableCaptionElement`,cite:`HTMLElement`,code:`HTMLElement`,col:`HTMLTableColElement`,colgroup:`HTMLTableColElement`,data:`HTMLDataElement`,datalist:`HTMLDataListElement`,dd:`HTMLElement`,del:`HTMLModElement`,details:`HTMLDetailsElement`,dfn:`HTMLElement`,dialog:`HTMLDialogElement`,div:`HTMLDivElement`,dl:`HTMLDListElement`,dt:`HTMLElement`,em:`HTMLElement`,embed:`HTMLEmbedElement`,fieldset:`HTMLFieldSetElement`,figcaption:`HTMLElement`,figure:`HTMLElement`,footer:`HTMLElement`,form:`HTMLFormElement`,h1:`HTMLHeadingElement`,h2:`HTMLHeadingElement`,h3:`HTMLHeadingElement`,h4:`HTMLHeadingElement`,h5:`HTMLHeadingElement`,h6:`HTMLHeadingElement`,head:`HTMLHeadElement`,header:`HTMLElement`,hgroup:`HTMLElement`,hr:`HTMLHRElement`,html:`HTMLHtmlElement`,i:`HTMLElement`,iframe:`HTMLIFrameElement`,img:`HTMLImageElement`,input:`HTMLInputElement`,ins:`HTMLModElement`,kbd:`HTMLElement`,label:`HTMLLabelElement`,legend:`HTMLLegendElement`,li:`HTMLLIElement`,link:`HTMLLinkElement`,main:`HTMLElement`,map:`HTMLMapElement`,mark:`HTMLElement`,menu:`HTMLMenuElement`,meta:`HTMLMetaElement`,meter:`HTMLMeterElement`,nav:`HTMLElement`,noscript:`HTMLElement`,object:`HTMLObjectElement`,ol:`HTMLOListElement`,optgroup:`HTMLOptGroupElement`,option:`HTMLOptionElement`,output:`HTMLOutputElement`,p:`HTMLParagraphElement`,picture:`HTMLPictureElement`,pre:`HTMLPreElement`,progress:`HTMLProgressElement`,q:`HTMLQuoteElement`,rp:`HTMLElement`,rt:`HTMLElement`,ruby:`HTMLElement`,s:`HTMLElement`,samp:`HTMLElement`,script:`HTMLScriptElement`,section:`HTMLElement`,select:`HTMLSelectElement`,slot:`HTMLSlotElement`,small:`HTMLElement`,source:`HTMLSourceElement`,span:`HTMLSpanElement`,strong:`HTMLElement`,style:`HTMLStyleElement`,sub:`HTMLElement`,summary:`HTMLElement`,sup:`HTMLElement`,table:`HTMLTableElement`,tbody:`HTMLTableSectionElement`,td:`HTMLTableCellElement`,template:`HTMLTemplateElement`,textarea:`HTMLTextAreaElement`,tfoot:`HTMLTableSectionElement`,th:`HTMLTableCellElement`,thead:`HTMLTableSectionElement`,time:`HTMLTimeElement`,title:`HTMLTitleElement`,tr:`HTMLTableRowElement`,track:`HTMLTrackElement`,u:`HTMLElement`,ul:`HTMLUListElement`,var:`HTMLElement`,video:`HTMLVideoElement`,wbr:`HTMLElement`,acronym:`HTMLElement`,applet:`HTMLUnknownElement`,basefont:`HTMLElement`,bgsound:`HTMLUnknownElement`,big:`HTMLElement`,blink:`HTMLUnknownElement`,center:`HTMLElement`,dir:`HTMLDirectoryElement`,font:`HTMLFontElement`,frame:`HTMLFrameElement`,frameset:`HTMLFrameSetElement`,isindex:`HTMLUnknownElement`,keygen:`HTMLUnknownElement`,listing:`HTMLPreElement`,marquee:`HTMLMarqueeElement`,menuitem:`HTMLElement`,multicol:`HTMLUnknownElement`,nextid:`HTMLUnknownElement`,nobr:`HTMLElement`,noembed:`HTMLElement`,noframes:`HTMLElement`,param:`HTMLParamElement`,plaintext:`HTMLElement`,rb:`HTMLElement`,rtc:`HTMLElement`,spacer:`HTMLUnknownElement`,strike:`HTMLElement`,tt:`HTMLElement`,xmp:`HTMLPreElement`,animate:`SVGAnimateElement`,animateMotion:`SVGAnimateMotionElement`,animateTransform:`SVGAnimateTransformElement`,circle:`SVGCircleElement`,clipPath:`SVGClipPathElement`,defs:`SVGDefsElement`,desc:`SVGDescElement`,ellipse:`SVGEllipseElement`,feBlend:`SVGFEBlendElement`,feColorMatrix:`SVGFEColorMatrixElement`,feComponentTransfer:`SVGFEComponentTransferElement`,feComposite:`SVGFECompositeElement`,feConvolveMatrix:`SVGFEConvolveMatrixElement`,feDiffuseLighting:`SVGFEDiffuseLightingElement`,feDisplacementMap:`SVGFEDisplacementMapElement`,feDistantLight:`SVGFEDistantLightElement`,feDropShadow:`SVGFEDropShadowElement`,feFlood:`SVGFEFloodElement`,feFuncA:`SVGFEFuncAElement`,feFuncB:`SVGFEFuncBElement`,feFuncG:`SVGFEFuncGElement`,feFuncR:`SVGFEFuncRElement`,feGaussianBlur:`SVGFEGaussianBlurElement`,feImage:`SVGFEImageElement`,feMerge:`SVGFEMergeElement`,feMergeNode:`SVGFEMergeNodeElement`,feMorphology:`SVGFEMorphologyElement`,feOffset:`SVGFEOffsetElement`,fePointLight:`SVGFEPointLightElement`,feSpecularLighting:`SVGFESpecularLightingElement`,feSpotLight:`SVGFESpotLightElement`,feTile:`SVGFETileElement`,feTurbulence:`SVGFETurbulenceElement`,filter:`SVGFilterElement`,foreignObject:`SVGForeignObjectElement`,g:`SVGGElement`,image:`SVGImageElement`,line:`SVGLineElement`,linearGradient:`SVGLinearGradientElement`,marker:`SVGMarkerElement`,mask:`SVGMaskElement`,metadata:`SVGMetadataElement`,mpath:`SVGMPathElement`,path:`SVGPathElement`,pattern:`SVGPatternElement`,polygon:`SVGPolygonElement`,polyline:`SVGPolylineElement`,radialGradient:`SVGRadialGradientElement`,rect:`SVGRectElement`,set:`SVGSetElement`,stop:`SVGStopElement`,svg:`SVGSVGElement`,switch:`SVGSwitchElement`,symbol:`SVGSymbolElement`,text:`SVGTextElement`,textPath:`SVGTextPathElement`,tspan:`SVGTSpanElement`,use:`SVGUseElement`,view:`SVGViewElement`},zr={for:"for(let ${1:i} = 0; ${1:i} < ${2:this.elements}; ${1:i}++) {\n ${3}\n}",forIn:"for(let ${1:index} in ${2:this.elements}) {\n ${3}\n}",forOf:"for(let ${1:element} of ${2:this.elements}) {\n ${3}\n}",if:`if(\${1:true}) {
540
540
  \${2}
541
541
  }`,"else if":`else if(\${1:true}) {
542
542
  \${2}
543
543
  }`,else:`else {
544
544
  \${1}
545
- }`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var zr=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),P.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 Lr[e]?Lr[e]:null}getHTMLLanguageService(){return(0,S.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==C.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=P.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(I($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,S.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=[...Ir],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=Ki(r,Zi(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in Rr)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:Rr[e],insertTextFormat:S.InsertTextFormat.Snippet,insertTextMode:S.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(`
546
- `)??``}};{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){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof St||n instanceof wt){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 Ot)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 Br(e){let t=``,n=[],r=r=>{for(let i of r){let r=Ht.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)&&ra(i):(0,u.writeFileSync)(i,t),n}var Vr=class extends Nt{get extension(){return w.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(L(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(L(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(L(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(Br(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)}},Hr=class extends Nt{get extension(){return w.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)}},Ur=class extends Nt{get extension(){return w.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(L(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(Br(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)}},Wr=class extends Nt{get extension(){return w.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(Br(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)}},Gr=class extends Nt{get extension(){return w.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(Br(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)}},Kr=class extends Nt{get extension(){return w.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,w.Definition),n=``,r=``;t.endsWith(w.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,w.DefinitionNpm);r=i.endsWith(w.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=na(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(w.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 qr(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new j(e,t):e.uri.endsWith(w.Data)?n=new Vr(e,t):e.uri.endsWith(w.Lib)?n=new Ur(e,t):e.uri.endsWith(w.RAM)?n=new Wr(e,t):e.uri.endsWith(w.State)?n=new Gr(e,t):e.uri.endsWith(w.Static)?n=new Kr(e,t):e.uri.endsWith(w.Definition)&&(n=new Hr(e,t)),n}var Jr=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Yr=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},Xr=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Zr=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,ne,S=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,se=oe[f]||oe[m]||y&&oe[y],ce=se||S(y),le=y?ie?S(`entries`):ce:void 0,ue=t==`Array`&&oe.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,re,!0),r||s(ne,f)||o(ne,f,_))),ie&&se&&se.name!==g&&(ae=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,ce),c[t]=ce,c[re]=_,y)if(ee={values:ie?ce:S(g),keys:b?ce:S(h),entries:le},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(`
547
- `)[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(){},ne=!!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{}}(),S=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 S(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}}},se=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&&ue(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&&ce(e)})}},ce=function(e){g.call(s,function(){var t,n,r,i=e._v;if(le(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||le(e)?2:1),e._a=void 0,t)throw t.error})},le=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||!le(t.promise))return!1;return!0},ue=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},de=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(),se(t,!0))},fe=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(fe,r,1),c(de,r,1))}catch(e){de.call(r,e)}}):(n._v=e,n._s=1,se(n,!1))}catch(e){de.call({_w:n,_d:!1},e)}}};ne||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(fe,this,1),c(de,this,1))}catch(e){de.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&&se(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(fe,e,1),this.reject=c(de,e,1)}),u(u.G+u.W+u.F*!ne,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!ne,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&S(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(ne&&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")}])})}))(),Qr=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=P.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};P.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Zr.machineId)(),r=(0,ue.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+w.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+w.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 $r([{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 $r([{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 ra(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof $r){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,Zr.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 $r([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new $r([{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 $r(s.errors):s.result:new $r([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new $r([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,de.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()})}},$r=class{errors;constructor(e){this.errors=e}},ei=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},ti=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)(I($.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}),ta(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new ni(this.files[e]).getContent():``}},ni=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 O||(e=new O(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(`
545
+ }`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var Br=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),P.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 Rr[e]?Rr[e]:null}getHTMLLanguageService(){return(0,S.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==C.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=P.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(I($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,S.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=[...Lr],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=qi(r,Qi(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in zr)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:zr[e],insertTextFormat:S.InsertTextFormat.Snippet,insertTextMode:S.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(`
546
+ `)??``}};{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){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof St||n instanceof Tt){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 kt)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 Vr(e){let t=``,n=[],r=r=>{for(let i of r){let r=Ut.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)&&ia(i):(0,u.writeFileSync)(i,t),n}var Hr=class extends Pt{get extension(){return w.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(L(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(L(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(L(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(Vr(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)}},Ur=class extends Pt{get extension(){return w.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)}},Wr=class extends Pt{get extension(){return w.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(L(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(Vr(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)}},Gr=class extends Pt{get extension(){return w.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(Vr(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)}},Kr=class extends Pt{get extension(){return w.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(Vr(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)}},qr=class extends Pt{get extension(){return w.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,w.Definition),n=``,r=``;t.endsWith(w.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,w.DefinitionNpm);r=i.endsWith(w.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=ra(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(w.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 Jr(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new j(e,t):e.uri.endsWith(w.Data)?n=new Hr(e,t):e.uri.endsWith(w.Lib)?n=new Wr(e,t):e.uri.endsWith(w.RAM)?n=new Gr(e,t):e.uri.endsWith(w.State)?n=new Kr(e,t):e.uri.endsWith(w.Static)?n=new qr(e,t):e.uri.endsWith(w.Definition)&&(n=new Ur(e,t)),n}var Yr=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Xr=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},Zr=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Qr=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,ne,S=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,se=oe[f]||oe[m]||y&&oe[y],ce=se||S(y),le=y?ie?S(`entries`):ce:void 0,ue=t==`Array`&&oe.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,re,!0),r||s(ne,f)||o(ne,f,_))),ie&&se&&se.name!==g&&(ae=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,ce),c[t]=ce,c[re]=_,y)if(ee={values:ie?ce:S(g),keys:b?ce:S(h),entries:le},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(`
547
+ `)[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(){},ne=!!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{}}(),S=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 S(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}}},se=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&&ue(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&&ce(e)})}},ce=function(e){g.call(s,function(){var t,n,r,i=e._v;if(le(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||le(e)?2:1),e._a=void 0,t)throw t.error})},le=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||!le(t.promise))return!1;return!0},ue=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},de=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(),se(t,!0))},fe=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(fe,r,1),c(de,r,1))}catch(e){de.call(r,e)}}):(n._v=e,n._s=1,se(n,!1))}catch(e){de.call({_w:n,_d:!1},e)}}};ne||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(fe,this,1),c(de,this,1))}catch(e){de.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&&se(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(fe,e,1),this.reject=c(de,e,1)}),u(u.G+u.W+u.F*!ne,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!ne,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&S(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(ne&&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")}])})}))(),$r=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=P.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};P.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Qr.machineId)(),r=(0,ue.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)(ii.getInstance().getPath(),`@locals`,e.buildConfig.fullname+w.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+w.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 ei([{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 ei([{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 ia(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof ei){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,Qr.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 ei([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new ei([{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 ei(s.errors):s.result:new ei([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new ei([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,de.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()})}},ei=class{errors;constructor(e){this.errors=e}},ti=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},ni=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)(I($.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}),na(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new ri(this.files[e]).getContent():``}},ri=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 O||(e=new O(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(`
548
548
  `)??``,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(`
549
- `)??``,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=>en.is(e))&&(t=`@Property()`),e.decorators.find(e=>ei.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>sn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>pn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(`
549
+ `)??``,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=>tn.is(e))&&(t=`@Property()`),e.decorators.find(e=>ti.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>cn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>mn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(`
550
550
  `)??``,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(`
551
551
  `)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(`
552
- `)}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":We(),"Aventus@UI":Ge(),"Aventus@Sharp":qe(),"Aventus@Php":Je(),"Aventus@I18n":Ke()};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=F(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=F(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)}ti.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=F((0,f.join)(this.path,`@locals`,e));n.endsWith(w.Package)||(n+=w.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,Qr.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=F(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,se.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),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(w.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=zt.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new zt(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&ra(e)}catch{}};(t.startsWith(`https:`)?oe.get:b.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(`
553
- `),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}},ii=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},ai=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:na(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&&(Jr.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),Jr.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
552
+ `)}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)}},ii=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":We(),"Aventus@UI":Ge(),"Aventus@Sharp":qe(),"Aventus@Php":Je(),"Aventus@I18n":Ke()};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=F(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=F(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)}ni.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=F((0,f.join)(this.path,`@locals`,e));n.endsWith(w.Package)||(n+=w.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,$r.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=F(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,se.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),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(w.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=Bt.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new Bt(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&ia(e)}catch{}};(t.startsWith(`https:`)?oe.get:b.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(`
553
+ `),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}},ai=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},oi=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:ra(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&&(Yr.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),Yr.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
554
554
  `,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));
555
555
  `,this.npmBuildTxt+=`(function (npmCompilation) {
556
556
  ${this.npmDepBuildTxt.result+`
@@ -563,37 +563,37 @@ protected ${t}(){
563
563
  `;for(let e in r.part)for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.all.internalAlias}'];
564
564
  `}else{let a=[],o=Object.keys(r.part);o.sort();for(let e of o){a.push(`${e} as ${r.part[e].internalAlias}`),n.push(r.part[e].internalAlias);for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.part[e].internalAlias}'];
565
565
  `}e+=`import {${Object.values(a).join(`, `)}} from "${i}";
566
- `}}return e+=`export default { ${n.join(`, `)} }`,{buildTxt:e,toExport:t}}async esbuildBuild(e){let t={result:``,errors:[]};try{let n=(0,f.dirname)(this.build.nodeModulesDir),r=this.getPotentialNodeModulesPaths(n);t.result=(await(0,pe.build)({stdin:{contents:e,resolveDir:n,sourcefile:`index.js`},bundle:!0,format:`iife`,globalName:`_`,nodePaths:r,minify:!0,define:{"process.env.NODE_ENV":`"production"`},legalComments:`none`,write:!1})).outputFiles?.[0].text||``}catch(e){let n=this.build.fullname+`_npmErrors`,r=(e+``).replace(/\0/g,``);ii.send(n,r),t.errors.push({title:`Npm compilation errors`,file:n})}return t}getPotentialNodeModulesPaths(e){let t=[],n=(0,f.resolve)(e);for(;;){let e=(0,f.join)(n,`node_modules`);(0,u.existsSync)(e)&&t.push(e);let r=(0,f.dirname)(n);if(r===n)break;n=r}return t}},oi=class extends De{regionLogic={start:0,end:0};regionStyle={start:0,end:0};regionView={start:0,end:0};regionI18n={start:0,end:0};get logic(){if(this.regionLogic.file)return this.regionLogic.file;throw`should not append`}get style(){return this.regionStyle.file}get view(){return this.regionView.file}get i18n(){return this.regionI18n.file}get extension(){return w.Component}constructor(e,t){super(e,t);let n=this.getDocuments();this.regionLogic.file=n.ts,this.regionStyle.file=n.scss,this.regionView.file=n.html}async init(){await this.regionView.file?.init(),await this.regionStyle.file?.init(),(!this.regionView.file||!this.regionStyle.file)&&await this.file.validate()}async onValidate(){await this.transformDocument();let e=[],t=[],n=async n=>{if(n.file){let r=await n.file.file.validate(),i=n.file.file.documentInternal;for(let a of r)a.source=C.WebComponent,t.indexOf(a.range)==-1&&(t.push(a.range),a.range.start=this.file.documentInternal.positionAt(i.offsetAt(a.range.start)+n.start),a.range.end=this.file.documentInternal.positionAt(i.offsetAt(a.range.end)+n.start)),e.push(a)}};return await n(this.regionStyle),await n(this.regionView),await n(this.regionLogic),e}waitingFct={};currentVersion=``;isCompiling=!1;transformDocument(){return new Promise(async e=>{let t=this.file.versionInternal+``,n=this.build.insideRebuildAll;if(t==this.currentVersion&&!n)e();else if(this.isCompiling)this.waitingFct[t]||(this.waitingFct[t]=[]),this.waitingFct[t].push(()=>{e()});else{this.isCompiling=!0;let n=this.splitDocument(),r=async(e,t,n)=>{let r=d.TextDocument.create(this.file.uri,t,this.file.versionUser,n);if(e.file)await e.file.triggerContentChange(r);else if(t==C.HTML){let t=new Fr(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,n)),this.build);e.file=t,await t.init()}else if(t==C.SCSS){let t=new Pr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,n)),this.build);e.file=t,await t.init()}};if(n.cssText===null?this.regionStyle.file&&(this.regionStyle.file.triggerDelete(),this.regionStyle.file=void 0):await r(this.regionStyle,C.SCSS,n.cssText),n.htmlText===null?this.regionView.file&&(this.regionView.file.triggerDelete(),this.regionView.file=void 0):await r(this.regionView,C.HTML,n.htmlText),n.scriptText!==null&&await r(this.regionLogic,C.TypeScript,n.scriptText),this.isCompiling=!1,this.currentVersion=t,this.waitingFct[t])for(let e of this.waitingFct[t])e();e()}})}async onContentChange(){await this.transformDocument()}async onSave(){this.build.disableBuild(),this.style&&await this.style.file.triggerSave(),this.view&&await this.view.file.triggerSave(),this.build.enableBuild(),await this.logic.file.triggerSave()}async onCompletion(e,t){await this.transformDocument();let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await(e.file?.file).getCompletion(e.file.file.documentInternal.positionAt(n-e.start));for(let n of t.items)if(n.data&&n.data.uri&&(n.data.previousLanguageId=n.data.languageId,n.data.languageId=C.WebComponent),n.textEdit){let t=n.textEdit;t.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1))}return t}};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){let n=[];if(t.data&&t.data.previousLanguageId){let e=t.data.previousLanguageId;delete t.data.previousLanguageId;let r=async(r,i)=>{if(e==i){let e=r.file;if(e){let i=await e.file.getCompletionResolve(t);if(i.additionalTextEdits)for(let t of i.additionalTextEdits)e.file.documentInternal.offsetAt(t.range.start)==0&&(t.newText=`
566
+ `}}return e+=`export default { ${n.join(`, `)} }`,{buildTxt:e,toExport:t}}async esbuildBuild(e){let t={result:``,errors:[]};try{let n=(0,f.dirname)(this.build.nodeModulesDir),r=this.getPotentialNodeModulesPaths(n);t.result=(await(0,pe.build)({stdin:{contents:e,resolveDir:n,sourcefile:`index.js`},bundle:!0,format:`iife`,globalName:`_`,nodePaths:r,minify:!0,define:{"process.env.NODE_ENV":`"production"`},legalComments:`none`,write:!1})).outputFiles?.[0].text||``}catch(e){let n=this.build.fullname+`_npmErrors`,r=(e+``).replace(/\0/g,``);ai.send(n,r),t.errors.push({title:`Npm compilation errors`,file:n})}return t}getPotentialNodeModulesPaths(e){let t=[],n=(0,f.resolve)(e);for(;;){let e=(0,f.join)(n,`node_modules`);(0,u.existsSync)(e)&&t.push(e);let r=(0,f.dirname)(n);if(r===n)break;n=r}return t}},si=class extends De{regionLogic={start:0,end:0};regionStyle={start:0,end:0};regionView={start:0,end:0};regionI18n={start:0,end:0};get logic(){if(this.regionLogic.file)return this.regionLogic.file;throw`should not append`}get style(){return this.regionStyle.file}get view(){return this.regionView.file}get i18n(){return this.regionI18n.file}get extension(){return w.Component}constructor(e,t){super(e,t);let n=this.getDocuments();this.regionLogic.file=n.ts,this.regionStyle.file=n.scss,this.regionView.file=n.html}async init(){await this.regionView.file?.init(),await this.regionStyle.file?.init(),(!this.regionView.file||!this.regionStyle.file)&&await this.file.validate()}async onValidate(){await this.transformDocument();let e=[],t=[],n=async n=>{if(n.file){let r=await n.file.file.validate(),i=n.file.file.documentInternal;for(let a of r)a.source=C.WebComponent,t.indexOf(a.range)==-1&&(t.push(a.range),a.range.start=this.file.documentInternal.positionAt(i.offsetAt(a.range.start)+n.start),a.range.end=this.file.documentInternal.positionAt(i.offsetAt(a.range.end)+n.start)),e.push(a)}};return await n(this.regionStyle),await n(this.regionView),await n(this.regionLogic),e}waitingFct={};currentVersion=``;isCompiling=!1;transformDocument(){return new Promise(async e=>{let t=this.file.versionInternal+``,n=this.build.insideRebuildAll;if(t==this.currentVersion&&!n)e();else if(this.isCompiling)this.waitingFct[t]||(this.waitingFct[t]=[]),this.waitingFct[t].push(()=>{e()});else{this.isCompiling=!0;let n=this.splitDocument(),r=async(e,t,n)=>{let r=d.TextDocument.create(this.file.uri,t,this.file.versionUser,n);if(e.file)await e.file.triggerContentChange(r);else if(t==C.HTML){let t=new Ir(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,n)),this.build);e.file=t,await t.init()}else if(t==C.SCSS){let t=new Fr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,n)),this.build);e.file=t,await t.init()}};if(n.cssText===null?this.regionStyle.file&&(this.regionStyle.file.triggerDelete(),this.regionStyle.file=void 0):await r(this.regionStyle,C.SCSS,n.cssText),n.htmlText===null?this.regionView.file&&(this.regionView.file.triggerDelete(),this.regionView.file=void 0):await r(this.regionView,C.HTML,n.htmlText),n.scriptText!==null&&await r(this.regionLogic,C.TypeScript,n.scriptText),this.isCompiling=!1,this.currentVersion=t,this.waitingFct[t])for(let e of this.waitingFct[t])e();e()}})}async onContentChange(){await this.transformDocument()}async onSave(){this.build.disableBuild(),this.style&&await this.style.file.triggerSave(),this.view&&await this.view.file.triggerSave(),this.build.enableBuild(),await this.logic.file.triggerSave()}async onCompletion(e,t){await this.transformDocument();let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await(e.file?.file).getCompletion(e.file.file.documentInternal.positionAt(n-e.start));for(let n of t.items)if(n.data&&n.data.uri&&(n.data.previousLanguageId=n.data.languageId,n.data.languageId=C.WebComponent),n.textEdit){let t=n.textEdit;t.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1))}return t}};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){let n=[];if(t.data&&t.data.previousLanguageId){let e=t.data.previousLanguageId;delete t.data.previousLanguageId;let r=async(r,i)=>{if(e==i){let e=r.file;if(e){let i=await e.file.getCompletionResolve(t);if(i.additionalTextEdits)for(let t of i.additionalTextEdits)e.file.documentInternal.offsetAt(t.range.start)==0&&(t.newText=`
567
567
  `+t.newText),n.indexOf(t.range)==-1&&!t.range.wc_transformed&&(n.push(t.range),t.range.wc_transformed=!0,t.range.start=this.transformPosition(e,t.range.start,this,r.start*-1),t.range.end=this.transformPosition(e,t.range.end,this,r.start*-1));return i}}},i=await r(this.regionStyle,C.SCSS);if(i)return i;let a=await r(this.regionView,C.HTML);if(a)return a;let o=await r(this.regionLogic,C.TypeScript);if(o)return o}return t}async onHover(e,t){let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await e.file.file.getHover(e.file.file.documentInternal.positionAt(n-e.start));return t?.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1)),t}return null};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||null}async onDefinition(e,t){let n=e.documentInternal.offsetAt(t),r=null;return this.style&&n>=this.regionStyle.start&&n<=this.regionStyle.end?r=await this.style.file.getDefinition(this.style.file.documentInternal.positionAt(n-this.regionStyle.start)):this.view&&n>=this.regionView.start&&n<=this.regionView.end?r=await this.view.file.getDefinition(this.view.file.documentInternal.positionAt(n-this.regionView.start)):n>=this.regionLogic.start&&n<=this.regionLogic.end&&(r=await this.logic.file.getDefinition(this.logic.file.documentInternal.positionAt(n-this.regionLogic.start))),r}async onFormatting(e,t,n){let r=[],i=[],a=e=>{let t=``;for(let n=0;n<e*4;n++)t+=` `;return t},o=async(e,t)=>{if(e.file){let o=await e.file.file.getFormatting(n);for(let n of o)t.tab&&(n.newText=n.newText.split(`
568
568
  `).join(`
569
569
  `+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?`
570
570
  `+a(1)+n.newText:`
571
571
  `+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=`
572
- `)),i.indexOf(n.range)==-1&&(i.push(n.range),n.range.start=this.transformPosition(e.file,n.range.start,this,e.start*-1),n.range.end=this.transformPosition(e.file,n.range.end,this,e.start*-1)),r.push(n)}};return await o(this.regionStyle,{firstLast:!0,tab:!0}),await o(this.regionView,{firstLast:!0,tab:!0}),await o(this.regionLogic,{firstLast:!1,tab:!1}),r}async onCodeAction(e,t){let n={start:e.documentInternal.offsetAt(t.start),end:e.documentInternal.offsetAt(t.end)},r=[],i=async i=>{if(this.isOverlapping(n,i)&&i.file){let n=await i.file.file.getCodeAction({start:this.transformPosition(this,t.start,i.file,i.start),end:this.transformPosition(this,t.end,i.file,i.start)});for(let t of n)if(t.edit&&t.edit.changes){let n=[];for(let e in t.edit.changes){let a=t.edit.changes[e];for(let e of a)r.indexOf(e.range)==-1&&(r.push(e.range),e.range.start=this.transformPosition(i.file,e.range.start,this,i.start*-1),e.range.end=this.transformPosition(i.file,e.range.end,this,i.start*-1)),n.push(e)}n.length>0&&(delete t.edit.changes[i.file.file.uri],t.edit.changes[e.uri]=n)}return n}},a;return a=await i(this.regionStyle),a||(a=await i(this.regionView),a)||(a=await i(this.regionLogic),a)?a:[]}async onDelete(){delete this.build.tsFiles[this.file.uri]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}getDocuments(){let e=this.splitDocument();e.htmlText!==null&&new Fr(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new Pr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new j(new E(d.TextDocument.create(this.file.uri,C.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),r={html:void 0,scss:t,ts:n};return this.build.tsFiles[r.ts.file.uri]=r.ts,r}splitDocument(){let e=/<script>([\s\S]*)<\/script>/g,t=/<template>([\s\S]*)<\/template>/g,n=/<style>([\s\S]*)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=e.exec(this.file.contentInternal);if(i){let e=i.index+8;this.regionLogic.start=e;let t=i.index+i[0].length-9;this.regionLogic.end=t,r.scriptText=this.file.contentInternal.substring(e,t)}let a=n.exec(this.file.contentInternal);if(a){let e=a.index+7;this.regionStyle.start=e;let t=a.index+a[0].length-8;this.regionStyle.end=t,r.cssText=this.file.contentInternal.substring(e,t)}let o=t.exec(this.file.contentInternal);if(o){let e=o.index+10;this.regionView.start=e;let t=o.index+o[0].length-11;this.regionView.end=t,r.htmlText=this.file.contentInternal.substring(e,t)}return r}transformPosition(e,t,n,r){let i=e.file.documentInternal.offsetAt(t);return n.file.documentInternal.positionAt(i-r)}isOverlapping(e,t){return t.start<e.start&&t.end>e.start||t.start<e.end&&t.end>e.end||t.start>e.start&&t.end<e.end}static getRegion(e){let t=/<script>([\s\S]*?)<\/script>/g,n=/<template>([\s\S]*?)<\/template>/g,r=/<style>([\s\S]*?)<\/style>/g,i={cssText:null,htmlText:null,scriptText:null},a=t.exec(e.contentInternal);if(a){let t=a.index+8,n=a.index+a[0].length-9;i.scriptText=e.contentInternal.substring(t,n)}let o=r.exec(e.contentInternal);if(o){let t=o.index+7,n=o.index+o[0].length-8;i.cssText=e.contentInternal.substring(t,n)}let s=n.exec(e.contentInternal);if(s){let t=s.index+10,n=s.index+s[0].length-11;i.htmlText=e.contentInternal.substring(t,n)}return i}onGetBuild(){return[this.build]}},si=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}write(e){ta((0,f.join)(e,`custom-elements.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!r)return;let i={kind:`javascript-module`,path:this.getLocalUri(e.file.uri),declarations:[],exports:[]},a={kind:`class`,description:``,name:n.name,customElement:!0};if(n.documentation&&(a.summary=n.documentation?.definitions.join(`
573
- `)),r.tagName&&(a.tagName=r.tagName),this.manifest.manifestConfig.srcBaseUrl&&(a.source={href:this.getSourceUri(e.file.uri)}),n.extends&&n.extends.length>0){let e=k.getInfoByFullName(n.extends[0],n);if(e&&e instanceof Ot)if(a.superclass={name:e.name},e.fileUri.endsWith(w.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(a.superclass.package=t.npmUri)}else a.superclass.module=this.getLocalUri(e.fileUri)}let o=[];for(let e of t.cssProperties){if(!e.local)continue;let t={name:e.name};e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation),e.type&&(t.syntax=e.type),o.push(t)}o.length>0&&(a.cssProperties=o);let s=[];for(let e of t.attributes){if(!e.local)continue;let t={name:e.name,fieldName:e.name,type:{text:this.getTypeTxt(e.type)}};if(e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation.definitions.join(`
572
+ `)),i.indexOf(n.range)==-1&&(i.push(n.range),n.range.start=this.transformPosition(e.file,n.range.start,this,e.start*-1),n.range.end=this.transformPosition(e.file,n.range.end,this,e.start*-1)),r.push(n)}};return await o(this.regionStyle,{firstLast:!0,tab:!0}),await o(this.regionView,{firstLast:!0,tab:!0}),await o(this.regionLogic,{firstLast:!1,tab:!1}),r}async onCodeAction(e,t){let n={start:e.documentInternal.offsetAt(t.start),end:e.documentInternal.offsetAt(t.end)},r=[],i=async i=>{if(this.isOverlapping(n,i)&&i.file){let n=await i.file.file.getCodeAction({start:this.transformPosition(this,t.start,i.file,i.start),end:this.transformPosition(this,t.end,i.file,i.start)});for(let t of n)if(t.edit&&t.edit.changes){let n=[];for(let e in t.edit.changes){let a=t.edit.changes[e];for(let e of a)r.indexOf(e.range)==-1&&(r.push(e.range),e.range.start=this.transformPosition(i.file,e.range.start,this,i.start*-1),e.range.end=this.transformPosition(i.file,e.range.end,this,i.start*-1)),n.push(e)}n.length>0&&(delete t.edit.changes[i.file.file.uri],t.edit.changes[e.uri]=n)}return n}},a;return a=await i(this.regionStyle),a||(a=await i(this.regionView),a)||(a=await i(this.regionLogic),a)?a:[]}async onDelete(){delete this.build.tsFiles[this.file.uri]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}getDocuments(){let e=this.splitDocument();e.htmlText!==null&&new Ir(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new Fr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new j(new E(d.TextDocument.create(this.file.uri,C.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),r={html:void 0,scss:t,ts:n};return this.build.tsFiles[r.ts.file.uri]=r.ts,r}splitDocument(){let e=/<script>([\s\S]*)<\/script>/g,t=/<template>([\s\S]*)<\/template>/g,n=/<style>([\s\S]*)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=e.exec(this.file.contentInternal);if(i){let e=i.index+8;this.regionLogic.start=e;let t=i.index+i[0].length-9;this.regionLogic.end=t,r.scriptText=this.file.contentInternal.substring(e,t)}let a=n.exec(this.file.contentInternal);if(a){let e=a.index+7;this.regionStyle.start=e;let t=a.index+a[0].length-8;this.regionStyle.end=t,r.cssText=this.file.contentInternal.substring(e,t)}let o=t.exec(this.file.contentInternal);if(o){let e=o.index+10;this.regionView.start=e;let t=o.index+o[0].length-11;this.regionView.end=t,r.htmlText=this.file.contentInternal.substring(e,t)}return r}transformPosition(e,t,n,r){let i=e.file.documentInternal.offsetAt(t);return n.file.documentInternal.positionAt(i-r)}isOverlapping(e,t){return t.start<e.start&&t.end>e.start||t.start<e.end&&t.end>e.end||t.start>e.start&&t.end<e.end}static getRegion(e){let t=/<script>([\s\S]*?)<\/script>/g,n=/<template>([\s\S]*?)<\/template>/g,r=/<style>([\s\S]*?)<\/style>/g,i={cssText:null,htmlText:null,scriptText:null},a=t.exec(e.contentInternal);if(a){let t=a.index+8,n=a.index+a[0].length-9;i.scriptText=e.contentInternal.substring(t,n)}let o=r.exec(e.contentInternal);if(o){let t=o.index+7,n=o.index+o[0].length-8;i.cssText=e.contentInternal.substring(t,n)}let s=n.exec(e.contentInternal);if(s){let t=s.index+10,n=s.index+s[0].length-11;i.htmlText=e.contentInternal.substring(t,n)}return i}onGetBuild(){return[this.build]}},ci=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}write(e){na((0,f.join)(e,`custom-elements.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!r)return;let i={kind:`javascript-module`,path:this.getLocalUri(e.file.uri),declarations:[],exports:[]},a={kind:`class`,description:``,name:n.name,customElement:!0};if(n.documentation&&(a.summary=n.documentation?.definitions.join(`
573
+ `)),r.tagName&&(a.tagName=r.tagName),this.manifest.manifestConfig.srcBaseUrl&&(a.source={href:this.getSourceUri(e.file.uri)}),n.extends&&n.extends.length>0){let e=k.getInfoByFullName(n.extends[0],n);if(e&&e instanceof kt)if(a.superclass={name:e.name},e.fileUri.endsWith(w.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(a.superclass.package=t.npmUri)}else a.superclass.module=this.getLocalUri(e.fileUri)}let o=[];for(let e of t.cssProperties){if(!e.local)continue;let t={name:e.name};e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation),e.type&&(t.syntax=e.type),o.push(t)}o.length>0&&(a.cssProperties=o);let s=[];for(let e of t.attributes){if(!e.local)continue;let t={name:e.name,fieldName:e.name,type:{text:this.getTypeTxt(e.type)}};if(e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation.definitions.join(`
574
574
  `)),e.isOverride){let r=n.getFieldParentClass(e.name);if(r)if(t.inheritedFrom={name:r.name},r.fileUri.endsWith(w.Package)){let e=this.manifest.build.externalPackageInformation.getByUri(r.fileUri);e&&e.npmUri&&(t.inheritedFrom.package=e.npmUri)}else t.inheritedFrom.module=this.getLocalUri(r.fileUri)}s.push(t)}s.length>0&&(a.attributes=s);let c=[],l=(e,t)=>{if(!e.local)return;let r=e.name,i={kind:`field`,name:e.name,static:t};if(e.defaultValue&&(i.default=e.defaultValue),e.documentation&&(i.description=e.documentation.definitions.join(`
575
575
  `)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.isOverride){let e=t?n.getStaticFieldParentClass(r):n.getFieldParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(w.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(i.inheritedFrom.package=t.npmUri)}else i.inheritedFrom.module=this.getLocalUri(e.fileUri)}i.type={text:this.getTypeTxt(e.type)},c.push(i)};for(let e of t.props)l(e,!1);for(let e of t.propsStatic)l(e,!0);let u=(e,t)=>{if(!e.local)return;let r=e.name,i={kind:`method`,name:e.name,static:t};if(e.documentation&&(i.description=e.documentation.definitions.join(`
576
- `)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new O(e.node.type);i.return={type:{text:this.getTypeTxt(t)}},e.documentation?.documentationReturn&&(i.return.description=e.documentation.documentationReturn)}if(e.node.parameters.length>0){i.parameters=[];for(let t of e.node.parameters){let n=t.name.getText(),r={name:n};t.type&&(r.type={text:this.getTypeTxt(new O(t.type))}),e.documentation?.documentationParameters[n]&&(r.description=e.documentation?.documentationParameters[n]),t.questionToken&&(r.optional=!0),t.initializer&&(r.default=t.initializer.getText()),i.parameters.push(r)}}if(e.isOverride){let e=t?n.getStaticMethodParentClass(r):n.getMethodParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(w.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(i.inheritedFrom.package=t.npmUri)}else i.inheritedFrom.module=this.getLocalUri(e.fileUri)}};for(let e of t.methods)u(e,!1);for(let e of t.methodsStatic)u(e,!0);c.length>0&&(a.members=c);let d=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};d.push(n)}d.length>0&&(a.slots=d),i.declarations.push(a);let f={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(f),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this._package.modules.push(i)}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(w.Config,``),n=I(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},ci=class{manifest;_package;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}write(e){ta((0,f.join)(e,`emmet`,`snippets.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i=r.tagName;this._package.html.snippets[i]=`<${i}>\${1}</${i}>`}},li=class{manifest;_package;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}write(e){ta((0,f.join)(e,`vscode.html-custom-data.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i={name:r.tagName},{attributes:a}=t,o=[];for(let e of a){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
576
+ `)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new O(e.node.type);i.return={type:{text:this.getTypeTxt(t)}},e.documentation?.documentationReturn&&(i.return.description=e.documentation.documentationReturn)}if(e.node.parameters.length>0){i.parameters=[];for(let t of e.node.parameters){let n=t.name.getText(),r={name:n};t.type&&(r.type={text:this.getTypeTxt(new O(t.type))}),e.documentation?.documentationParameters[n]&&(r.description=e.documentation?.documentationParameters[n]),t.questionToken&&(r.optional=!0),t.initializer&&(r.default=t.initializer.getText()),i.parameters.push(r)}}if(e.isOverride){let e=t?n.getStaticMethodParentClass(r):n.getMethodParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(w.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(i.inheritedFrom.package=t.npmUri)}else i.inheritedFrom.module=this.getLocalUri(e.fileUri)}};for(let e of t.methods)u(e,!1);for(let e of t.methodsStatic)u(e,!0);c.length>0&&(a.members=c);let d=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};d.push(n)}d.length>0&&(a.slots=d),i.declarations.push(a);let f={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(f),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this._package.modules.push(i)}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(w.Config,``),n=I(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},li=class{manifest;_package;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}write(e){na((0,f.join)(e,`emmet`,`snippets.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i=r.tagName;this._package.html.snippets[i]=`<${i}>\${1}</${i}>`}},ui=class{manifest;_package;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}write(e){na((0,f.join)(e,`vscode.html-custom-data.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i={name:r.tagName},{attributes:a}=t,o=[];for(let e of a){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
577
577
  `),i=``;n&&(i=n),r&&(i&&(i+=`
578
578
 
579
- `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({name:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({name:e})}a.length>0&&(t.values=a),o.push(t)}o.length>0&&(i.attributes=o);let s=this.manifest.generateDescription(t);s&&(i.description=s),this._package.tags.push(i)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},ui=class{manifest;_package;constructor(e){this.manifest=e,this._package={$schema:`https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json`,name:``,version:`2.20.0`,"description-markup":`markdown`,contributions:{html:{elements:[]}}}}write(e){ta((0,f.join)(e,`web-types.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!this._package.contributions?.html?.elements)return;let n=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n)return;let r={name:n.tagName,description:this.manifest.generateDescription(t),"doc-url":``};t.class.isAbstract&&(r.abstract=!0);let i=[];for(let e of t.attributes){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
579
+ `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({name:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({name:e})}a.length>0&&(t.values=a),o.push(t)}o.length>0&&(i.attributes=o);let s=this.manifest.generateDescription(t);s&&(i.description=s),this._package.tags.push(i)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},di=class{manifest;_package;constructor(e){this.manifest=e,this._package={$schema:`https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json`,name:``,version:`2.20.0`,"description-markup":`markdown`,contributions:{html:{elements:[]}}}}write(e){na((0,f.join)(e,`web-types.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!this._package.contributions?.html?.elements)return;let n=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n)return;let r={name:n.tagName,description:this.manifest.generateDescription(t),"doc-url":``};t.class.isAbstract&&(r.abstract=!0);let i=[];for(let e of t.attributes){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
580
580
  `),i=``;n&&(i=n),r&&(i&&(i+=`
581
581
 
582
582
  `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({type:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({type:e})}a.length>0&&(t.values=a)}i.length>0&&(r.attributes=i);let a=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};t.slots[e].doc&&(n.description=t.slots[e].doc),a.push(n)}a.length>0&&(r.slots=a);let o=[];for(let e of t.props){let t={};t.name=e.name,e.isAbstract&&(t.abstract=e.isAbstract),e.documentation&&(t.description=e.documentation.definitions.join(`
583
- `)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this._package.contributions.html.elements.push(r)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},di=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new si(this),this.htmlCustomData=new li(this),this.emmetCustomData=new ci(this),this.webTypes=new ui(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof j&&e.fileParsed){let t=e.fileParsed.classes[e.componentClassName];if(!t)return;let n=[],r=[],i=[],a=[],o=[],s=[],c={},l=[],u=!1,d=t;for(;d&&d.fullName!=`Aventus.WebComponent`;){for(let e in d.properties){let i={...d.properties[e]};i.local=d==t,!(i.isPrivate||i.isProtected)&&(i.decorators.find(e=>en.is(e)||ei.is(e))?n.push(i):r.push(i))}for(let e in d.propertiesStatic){let n={...d.propertiesStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&i.push(n)}for(let e in d.methods){let n={...d.methods[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&a.push(n)}for(let e in d.methodsStatic){let n={...d.methodsStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&o.push(n)}let e=this.build.tsFiles[d.fileUri];if(e instanceof j){if(e.SCSSFile)for(let n of e.SCSSFile.customProperties){let e={...n};e.local=d==t,s.push(e)}if(e.HTMLFile?.fileParsed?.slotsInfo&&!u){for(let n in e.HTMLFile.fileParsed.slotsInfo)l.includes(n)||(c[n]||(c[n]={local:d==t}),!c[n].doc&&d.documentation?.documentationSlots[n]&&(c[n].doc=d.documentation?.documentationSlots[n]));for(let t in e.HTMLFile.fileParsed.blocksInfo)c[t]||l.push(t)}}d.decorators.find(e=>Qt.is(e))&&(u=!0),d=d.parentClass}let f=this.build.noNamespaceUri[e.file.uri]?t.fullName:this.build.buildConfig.module+`.`+t.fullName;n.sort((e,t)=>e.name.localeCompare(t.name)),r.sort((e,t)=>e.name.localeCompare(t.name)),i.sort((e,t)=>e.name.localeCompare(t.name)),a.sort((e,t)=>e.name.localeCompare(t.name)),o.sort((e,t)=>e.name.localeCompare(t.name)),s.sort((e,t)=>e.name.localeCompare(t.name)),c=Object.keys(c).sort().reduce((e,t)=>(e[t]=c[t],e),{});let p={fullName:f,class:t,attributes:n,props:r,propsStatic:i,methods:a,methodsStatic:o,slots:c,cssProperties:s};this.customElements.register(e,p),this.htmlCustomData.register(e,p),this.emmetCustomData.register(e,p),this.webTypes.register(e,p)}}write(e){this.customElements.write(e),this.htmlCustomData.write(e),this.emmetCustomData.write(e)}getTypeTxt(e){let t=``;if(e.kind==`union`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` | `)}else if(e.kind==`intersection`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` & `)}else if(e.kind==`literal`)t=e.value;else if(e.kind==`type`){t=e.value;let n=[];for(let t of e.genericValue)n.push(this.getTypeTxt(t));n.length>0&&(t+=`<${n.join(`, `)}>`)}else if(e.kind==`typeOperator`)t=e.value,e.nested.length>0&&(t+=`typeof ${this.getTypeTxt(e.nested[0])}`);else if(e.kind==`tuple`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=`[${n.join(`, `)}]`}else if(e.kind==`conditional`){let n=e.conditionalType;t=`${this.getTypeTxt(n.check)} extends ${this.getTypeTxt(n.extends)} ? ${this.getTypeTxt(n.true)} : ${this.getTypeTxt(n.false)}`}else if(e.kind==`mappedType`){let n=e.mappedType;t=`{ [${n.parameterName} in ${this.getTypeTxt(n.parameterType)}]${n.modifier??``}: ${this.getTypeTxt(n.type)} }`}else t=e.kind==`indexedAccess`?`${this.getTypeTxt(e.nested[0])}[${this.getTypeTxt(e.nested[1])}]`:e.kind==`infer`?`infer ${e.value}]`:e.kind==`typeLiteral`||e.kind==`constructor`||e.kind==`function`?e.value:e.kind;return e.isArray&&(t+=`[]`),t}generateDescription(e){let t=`## `+e.fullName;e.class.documentation&&(t+=`
583
+ `)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this._package.contributions.html.elements.push(r)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},fi=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new ci(this),this.htmlCustomData=new ui(this),this.emmetCustomData=new li(this),this.webTypes=new di(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof j&&e.fileParsed){let t=e.fileParsed.classes[e.componentClassName];if(!t)return;let n=[],r=[],i=[],a=[],o=[],s=[],c={},l=[],u=!1,d=t;for(;d&&d.fullName!=`Aventus.WebComponent`;){for(let e in d.properties){let i={...d.properties[e]};i.local=d==t,!(i.isPrivate||i.isProtected)&&(i.decorators.find(e=>tn.is(e)||ti.is(e))?n.push(i):r.push(i))}for(let e in d.propertiesStatic){let n={...d.propertiesStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&i.push(n)}for(let e in d.methods){let n={...d.methods[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&a.push(n)}for(let e in d.methodsStatic){let n={...d.methodsStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&o.push(n)}let e=this.build.tsFiles[d.fileUri];if(e instanceof j){if(e.SCSSFile)for(let n of e.SCSSFile.customProperties){let e={...n};e.local=d==t,s.push(e)}if(e.HTMLFile?.fileParsed?.slotsInfo&&!u){for(let n in e.HTMLFile.fileParsed.slotsInfo)l.includes(n)||(c[n]||(c[n]={local:d==t}),!c[n].doc&&d.documentation?.documentationSlots[n]&&(c[n].doc=d.documentation?.documentationSlots[n]));for(let t in e.HTMLFile.fileParsed.blocksInfo)c[t]||l.push(t)}}d.decorators.find(e=>$t.is(e))&&(u=!0),d=d.parentClass}let f=this.build.noNamespaceUri[e.file.uri]?t.fullName:this.build.buildConfig.module+`.`+t.fullName;n.sort((e,t)=>e.name.localeCompare(t.name)),r.sort((e,t)=>e.name.localeCompare(t.name)),i.sort((e,t)=>e.name.localeCompare(t.name)),a.sort((e,t)=>e.name.localeCompare(t.name)),o.sort((e,t)=>e.name.localeCompare(t.name)),s.sort((e,t)=>e.name.localeCompare(t.name)),c=Object.keys(c).sort().reduce((e,t)=>(e[t]=c[t],e),{});let p={fullName:f,class:t,attributes:n,props:r,propsStatic:i,methods:a,methodsStatic:o,slots:c,cssProperties:s};this.customElements.register(e,p),this.htmlCustomData.register(e,p),this.emmetCustomData.register(e,p),this.webTypes.register(e,p)}}write(e){this.customElements.write(e),this.htmlCustomData.write(e),this.emmetCustomData.write(e)}getTypeTxt(e){let t=``;if(e.kind==`union`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` | `)}else if(e.kind==`intersection`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` & `)}else if(e.kind==`literal`)t=e.value;else if(e.kind==`type`){t=e.value;let n=[];for(let t of e.genericValue)n.push(this.getTypeTxt(t));n.length>0&&(t+=`<${n.join(`, `)}>`)}else if(e.kind==`typeOperator`)t=e.value,e.nested.length>0&&(t+=`typeof ${this.getTypeTxt(e.nested[0])}`);else if(e.kind==`tuple`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=`[${n.join(`, `)}]`}else if(e.kind==`conditional`){let n=e.conditionalType;t=`${this.getTypeTxt(n.check)} extends ${this.getTypeTxt(n.extends)} ? ${this.getTypeTxt(n.true)} : ${this.getTypeTxt(n.false)}`}else if(e.kind==`mappedType`){let n=e.mappedType;t=`{ [${n.parameterName} in ${this.getTypeTxt(n.parameterType)}]${n.modifier??``}: ${this.getTypeTxt(n.type)} }`}else t=e.kind==`indexedAccess`?`${this.getTypeTxt(e.nested[0])}[${this.getTypeTxt(e.nested[1])}]`:e.kind==`infer`?`infer ${e.value}]`:e.kind==`typeLiteral`||e.kind==`constructor`||e.kind==`function`?e.value:e.kind;return e.isArray&&(t+=`[]`),t}generateDescription(e){let t=`## `+e.fullName;e.class.documentation&&(t+=`
584
584
  `+e.class.documentation?.definitions.join(`
585
585
  `)),t+=`
586
586
  `;let n=e=>{t+=`\n### **${e}:**\n`},r=(e,n)=>{n?t+=` - **${e}** - ${n}\n`:t+=` - **${e}**\n`},{attributes:i,methods:a,methodsStatic:o,props:s,propsStatic:c,slots:l,cssProperties:u}=e,d=(e,t)=>{if(e.length>0){n(t);for(let t of e){let e=this.getTypeTxt(t.type),n=t.documentation?.definitions.join(`
587
587
  `);r(e?t.name+`: `+e:t.name,n)}}};if(d(i,`Attributes`),d(s,`Properties`),d(c,`Static Properties`),Object.keys(l).length>0){n(`Slots`);for(let e in l)r(e,l[e].doc)}if(u.length>0){n(`CSS Variables`);for(let e of u){let n=e.name;e.type&&(e.type==`literal`&&e.typeValues?n+=`: `+e.typeValues.join(` | `):n+=`: `+e.type),r(n,e.documentation),e.chainValues&&(t+=` - ${e.chainValues.join(` < `)}\n`)}}let f=(e,t)=>{if(e.length>0){n(t);for(let t of e){let e=[];if(t.node.parameters.length>0)for(let n of t.node.parameters){let t=n.name.getText();n.questionToken&&(t+=`?`),n.type&&(t+=`: `+this.getTypeTxt(new O(n.type))),n.initializer&&(t+=` = `+n.initializer.getText()),e.push(t)}let n=`${t.name}(${e.join(`, `)})`;if(t.node.type){let e=this.getTypeTxt(new O(t.node.type));n+=`: `+e}r(n,t.documentation?.definitions.join(`
588
588
  `))}}};return f(a,`Methods`),f(o,`Static Methods`),t.endsWith(`
589
- `)&&(t=t.substring(0,t.length-1)),t}};const fi={$schema:`foo://aventus/i18n.json`,title:`JSON Schema for Aventus I18n`,description:`JSON Schema for Aventus I18n`,type:`object`};var pi=class e{static empty=`ⵌⵌ`;static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.I18n],uri:fi.$schema??``,schema:fi}]})}async validate(t){let n=t.file.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r);if(i.length==0){let r=this.removeComments(n.getText());try{JSON.parse(r);let n=t.parsed??{},a=t.build.buildConfig.i18n?.locales??[];for(let r in n){for(let o in n[r].locales){let s=n[r].locales[o];a.includes(o)||i.push(Wi(t.file.documentUser,`Locale not needed`,s.localeStart,s.localeEnd)),s.value==e.empty&&i.push(Wi(t.file.documentUser,`Translation not set`,s.valueStart,s.valueEnd))}let o=[];for(let e of a)n[r].locales[e]===void 0&&o.push(e);o.length>0&&i.push(Ui(t.file.documentUser,`Missing locales `+o.join(`, `),n[r].keyStart,n[r].keyEnd))}return i}catch{i.push(Hi(n,`Can't parse the json`))}}for(let e of i)e.severity=h.DiagnosticSeverity.Error;return i}async format(e,t,n){try{let t=JSON.parse(e.contentUser);return[{newText:JSON.stringify(this.sortObj(t),null,4),range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}catch{}return[]}async codeAction(e,t){let n=[];try{let t=this.actionImportMissingLocales(e);t&&n.push(t)}catch{}return n}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}sortObj(t){return e.sortObj(t)}static sortObj(e){return Object.keys(e).sort().reduce((t,n)=>{let r=e[n];return t[n]=Object.keys(r).sort().reduce((e,t)=>(e[t]=r[t],e),{}),t},{})}actionImportMissingLocales(t){let n=!1,r=JSON.parse(JSON.stringify(t.parsedSrc));for(let i in t.parsedSrc){let a=t.parsedSrc[i],o=t.build.buildConfig.i18n?.locales??[];for(let t of o)a[t]===void 0&&(n=!0,r[i][t]=e.empty)}if(n){let e=JSON.stringify(this.sortObj(r),null,4);return{title:`Import missing locales`,edit:{changes:{[t.file.uri]:[{newText:e,range:{start:t.file.documentUser.positionAt(0),end:t.file.documentUser.positionAt(t.file.contentUser.length)}}]}}}}}addValueToFile(t,n){let r=JSON.parse(JSON.stringify(t.parsedSrc));r[n]={};let i=t.build.buildConfig.i18n?.locales??[],a=t.build.buildConfig.i18n?.fallback??`en-GB`;for(let t of i)r[n][t]=t==a?n:e.empty;let o=JSON.stringify(this.sortObj(r),null,4);h.TextDocument.create(t.file.uri,C.I18n,t.file.versionUser+1,o)}},mi=class{static parse(e){let t={},n=(0,h.getLanguageService)({}).parseJSONDocument(e).root?.children??[];for(let e of n)if(e.type==`property`){let n=e.children[0],r=e.children[1].children??[],i={key:n.value+``,keyStart:n.offset,keyEnd:n.offset+n.length,locales:{}};for(let e of r)if(e.type==`property`){let t=e.children[0].value+``,n=e.children[0].offset,r=n+e.children[0].length,a=e.children[1].value+``,o=e.children[1].offset,s=o+e.children[1].length;i.locales[t]={locale:t,localeStart:n,localeEnd:r,value:a,valueStart:o,valueEnd:s}}t[i.key]=i}return t}},hi=class extends De{parsedSrc={};parsed;exported={};get classInfo(){var e=this.build.tsFiles[this.file.uri.replace(w.I18n,w.ComponentLogic)];if(e instanceof j&&e.fileParsed)return e.fileParsed.classes[e.componentClassName]}isGlobal=!1;get keys(){return Object.keys(this.parsedSrc)}constructor(e,t,n){super(e,n),this.isGlobal=t,this.onContentChange()}async onContentChange(){try{if(this.parsedSrc=JSON.parse(this.file.contentUser),this.parsed=mi.parse(this.file.documentUser),this.transformForExport(),this.file instanceof E&&this.isGlobal){let e=`declare global {
589
+ `)&&(t=t.substring(0,t.length-1)),t}};const pi={$schema:`foo://aventus/i18n.json`,title:`JSON Schema for Aventus I18n`,description:`JSON Schema for Aventus I18n`,type:`object`};var mi=class e{static empty=`ⵌⵌ`;static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.I18n],uri:pi.$schema??``,schema:pi}]})}async validate(t){let n=t.file.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r);if(i.length==0){let r=this.removeComments(n.getText());try{JSON.parse(r);let n=t.parsed??{},a=t.build.buildConfig.i18n?.locales??[];for(let r in n){for(let o in n[r].locales){let s=n[r].locales[o];a.includes(o)||i.push(Gi(t.file.documentUser,`Locale not needed`,s.localeStart,s.localeEnd)),s.value==e.empty&&i.push(Gi(t.file.documentUser,`Translation not set`,s.valueStart,s.valueEnd))}let o=[];for(let e of a)n[r].locales[e]===void 0&&o.push(e);o.length>0&&i.push(Wi(t.file.documentUser,`Missing locales `+o.join(`, `),n[r].keyStart,n[r].keyEnd))}return i}catch{i.push(Ui(n,`Can't parse the json`))}}for(let e of i)e.severity=h.DiagnosticSeverity.Error;return i}async format(e,t,n){try{let t=JSON.parse(e.contentUser);return[{newText:JSON.stringify(this.sortObj(t),null,4),range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}catch{}return[]}async codeAction(e,t){let n=[];try{let t=this.actionImportMissingLocales(e);t&&n.push(t)}catch{}return n}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}sortObj(t){return e.sortObj(t)}static sortObj(e){return Object.keys(e).sort().reduce((t,n)=>{let r=e[n];return t[n]=Object.keys(r).sort().reduce((e,t)=>(e[t]=r[t],e),{}),t},{})}actionImportMissingLocales(t){let n=!1,r=JSON.parse(JSON.stringify(t.parsedSrc));for(let i in t.parsedSrc){let a=t.parsedSrc[i],o=t.build.buildConfig.i18n?.locales??[];for(let t of o)a[t]===void 0&&(n=!0,r[i][t]=e.empty)}if(n){let e=JSON.stringify(this.sortObj(r),null,4);return{title:`Import missing locales`,edit:{changes:{[t.file.uri]:[{newText:e,range:{start:t.file.documentUser.positionAt(0),end:t.file.documentUser.positionAt(t.file.contentUser.length)}}]}}}}}addValueToFile(t,n){let r=JSON.parse(JSON.stringify(t.parsedSrc));r[n]={};let i=t.build.buildConfig.i18n?.locales??[],a=t.build.buildConfig.i18n?.fallback??`en-GB`;for(let t of i)r[n][t]=t==a?n:e.empty;let o=JSON.stringify(this.sortObj(r),null,4);h.TextDocument.create(t.file.uri,C.I18n,t.file.versionUser+1,o)}},hi=class{static parse(e){let t={},n=(0,h.getLanguageService)({}).parseJSONDocument(e).root?.children??[];for(let e of n)if(e.type==`property`){let n=e.children[0],r=e.children[1].children??[],i={key:n.value+``,keyStart:n.offset,keyEnd:n.offset+n.length,locales:{}};for(let e of r)if(e.type==`property`){let t=e.children[0].value+``,n=e.children[0].offset,r=n+e.children[0].length,a=e.children[1].value+``,o=e.children[1].offset,s=o+e.children[1].length;i.locales[t]={locale:t,localeStart:n,localeEnd:r,value:a,valueStart:o,valueEnd:s}}t[i.key]=i}return t}},gi=class extends De{parsedSrc={};parsed;exported={};get classInfo(){var e=this.build.tsFiles[this.file.uri.replace(w.I18n,w.ComponentLogic)];if(e instanceof j&&e.fileParsed)return e.fileParsed.classes[e.componentClassName]}isGlobal=!1;get keys(){return Object.keys(this.parsedSrc)}constructor(e,t,n){super(e,n),this.isGlobal=t,this.onContentChange()}async onContentChange(){try{if(this.parsedSrc=JSON.parse(this.file.contentUser),this.parsed=hi.parse(this.file.documentUser),this.transformForExport(),this.file instanceof E&&this.isGlobal){let e=`declare global {
590
590
  namespace Aventus {
591
591
  interface AventusI18n {
592
592
  ${this.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
593
593
  `)}
594
594
  }
595
595
  }
596
- }`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{}}transformForExport(){let e={},t=this.build.buildConfig.i18n?.locales??[];for(let n of t)e[n]={};if(this.isGlobal)for(let n in this.parsedSrc)for(let r in this.parsedSrc[n])t.includes(r)&&(e[r][n]=this.parsedSrc[n][r]);else{let n=this.build.module+`°`+(this.classInfo?.fullName.replace(/\./g,`°`)??``);n&&(n+=`°`),this.build.module;for(let r in this.parsedSrc)for(let i in this.parsedSrc[r])t.includes(i)&&(e[i][n+r]=this.parsedSrc[r][i])}this.exported=e}async onValidate(){return await pi.getInstance().validate(this)}async onSave(){this.build.build()}async onDelete(){this.build.build()}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 await pi.getInstance().format(e,t,n)}async onCodeAction(e,t){return await pi.getInstance().codeAction(this,t)}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}getKeyFromLocation(e){if(!this.parsed)return null;let t=this.file.documentUser.offsetAt(e[0]),n=this.file.documentUser.offsetAt(e[1]);for(let e in this.parsed){let r=this.parsed[e];if(r.keyStart<=t&&r.keyEnd>=n)return e}return null}},gi=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new _i(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;_allowBuild=!0;get allowBuild(){if($.isIDE){let e=P.getInstance().settings;return this._allowBuild&&e.ideBuild}return this._allowBuild}set allowBuild(e){this._allowBuild=e}initDone=!1;_filesLoaded=!1;reloadPage=!1;_outputPathes=[];npmBuilder;get fullname(){return this.buildConfig.fullname}get module(){return this.buildConfig.module}get isCoreBuild(){return this.project.isCoreBuild}get hideWarnings(){return this.buildConfig.hideWarnings}get nodeModulesDir(){return this.buildConfig.nodeModulesDir}get outputPathes(){return this._outputPathes}_hasNpmOutput;get hasNpmOutput(){if(this._hasNpmOutput===void 0){let e=this.buildConfig.compile.findIndex(e=>e.outputNpm.path.length>0)!=-1;e?this._hasNpmOutput=e:this._hasNpmOutput=this.hasStories}return this._hasNpmOutput}get hasStories(){return this.buildConfig.stories!==void 0}get filesLoaded(){return this._filesLoaded}constructor(e,t){this.project=e,this.buildConfig=t,this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),this.tsLanguageService=new Ht(this),this.scssLanguageService=new Nr(this),this.htmlLanguageService=new zr(this),this.stories=new gt(this,t),this._outputPathes=[(0,f.join)(ri.getInstance().getPath(),`@locals`,t.fullname+w.Package).replace(/\\/g,`/`)];for(let e of t.compile)for(let t of e.package)this._outputPathes.push(t.replace(/\\/g,`/`));this.npmBuilder=new ai(this),Yr.send(e.getConfigFile().path,t.fullname)}async init(){await this.loadFiles(),this.initDone=!0}getComponentPrefix(){return this.buildConfig.componentPrefix}getAvoidParsingTags(){return this.buildConfig.avoidParsingInsideTags}getAliases(){return this.project.getConfig()?.aliases??{}}isFileInside(e){return I(e).match(this.buildConfig.srcPathRegex)!=null}getNamespace(e){return this.noNamespaceUri[e]||this.buildConfig.module==``?``:this.buildConfig.module+`.`}enableBuild(){this.allowBuild=!0}disableBuild(){this.allowBuild=!1}get isBuildAllowed(){return this.allowBuild}timerBuild=void 0;insideRebuildAll=!1;async rebuildAll(e=!1){if(this.allowBuild=!1,this.insideRebuildAll=!0,this.scssLanguageService.allowRebuildDefinition(!1),this.htmlLanguageService.allowRebuildDefinition(!1),e){for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.wcFiles)await this.wcFiles[e].init();for(let e in this.scssFiles)await this.scssFiles[e].init(),await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].init(),await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}else{for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.scssFiles)await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}this.scssLanguageService.allowRebuildDefinition(!0),this.htmlLanguageService.allowRebuildDefinition(!0),this.insideRebuildAll=!1;for(let e in this.scssFiles)await this.scssFiles[e].triggerSave();for(let e in this.wcFiles)await this.wcFiles[e].triggerSave();for(let e in this.tsFiles)await this.tsFiles[e].triggerSave();this.allowBuild=!0,this.npmBuilder.rebuildInfo(),this.initDone?await this.build():await this._build()}async build(){if(!this.initDone||$.noBuild)return;let e=$.delayBetweenBuild();e==0?await this._build():(this.timerBuild&&clearTimeout(this.timerBuild),this.timerBuild=setTimeout(async()=>{await this._build()},e))}addDiagnostic(e,t){this.diagnostics.has(e)||this.diagnostics.set(e,[]),this.diagnostics.get(e)?.push(t)}clearDiagnostics(){for(let[e,t]of this.diagnostics.entries())e instanceof Nt&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof Nt){let n=[...t,...e.getDiagnostics()];this.hideWarnings&&(n=n.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),$.sendDiagnostics({uri:e.file.uri,diagnostics:n},this)}}async _build(){if(!this.allowBuild)return;$.debug(`building `+this.buildConfig.fullname),this.clearDiagnostics();let e=[];for(let t of this.buildConfig.compile){t.i18n&&this.writeBuildI18n(t.i18n);let n=await this.buildOrderCompilationInfo(t),r=await this.buildLocalCode(n.toCompile,this.buildConfig.module);e=await this.writeBuildCode(r,n.libSrc,t.output,t.compressed),e=[...e,...n.errors];let i={namespace:this.buildConfig.module,available:r.codeRenderInJs,existing:r.codeNotRenderInJs};this.writeBuildDocumentation(t.package,r,i,t.outputNpm),t.outputNpm.live&&this.writeBuildNpm(t.outputNpm,r),this.buildConfig.stories&&this.buildConfig.stories.live&&(await this.stories.check(),this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},r),this.stories.write(this.tsFiles))}Jr.send(this.buildConfig.fullname,e),this.reloadPage&&(this.reloadPage=!1,D.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a){let o=``,s=e.split(`.`);if(o+=t.join(`
596
+ }`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{}}transformForExport(){let e={},t=this.build.buildConfig.i18n?.locales??[];for(let n of t)e[n]={};if(this.isGlobal)for(let n in this.parsedSrc)for(let r in this.parsedSrc[n])t.includes(r)&&(e[r][n]=this.parsedSrc[n][r]);else{let n=this.build.module+`°`+(this.classInfo?.fullName.replace(/\./g,`°`)??``);n&&(n+=`°`),this.build.module;for(let r in this.parsedSrc)for(let i in this.parsedSrc[r])t.includes(i)&&(e[i][n+r]=this.parsedSrc[r][i])}this.exported=e}async onValidate(){return await mi.getInstance().validate(this)}async onSave(){this.build.build()}async onDelete(){this.build.build()}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 await mi.getInstance().format(e,t,n)}async onCodeAction(e,t){return await mi.getInstance().codeAction(this,t)}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}getKeyFromLocation(e){if(!this.parsed)return null;let t=this.file.documentUser.offsetAt(e[0]),n=this.file.documentUser.offsetAt(e[1]);for(let e in this.parsed){let r=this.parsed[e];if(r.keyStart<=t&&r.keyEnd>=n)return e}return null}},_i=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new vi(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;_allowBuild=!0;get allowBuild(){if($.isIDE){let e=P.getInstance().settings;return this._allowBuild&&e.ideBuild}return this._allowBuild}set allowBuild(e){this._allowBuild=e}initDone=!1;_filesLoaded=!1;reloadPage=!1;_outputPathes=[];npmBuilder;get fullname(){return this.buildConfig.fullname}get module(){return this.buildConfig.module}get isCoreBuild(){return this.project.isCoreBuild}get hideWarnings(){return this.buildConfig.hideWarnings}get nodeModulesDir(){return this.buildConfig.nodeModulesDir}get outputPathes(){return this._outputPathes}_hasNpmOutput;get hasNpmOutput(){if(this._hasNpmOutput===void 0){let e=this.buildConfig.compile.findIndex(e=>e.outputNpm.path.length>0)!=-1;e?this._hasNpmOutput=e:this._hasNpmOutput=this.hasStories}return this._hasNpmOutput}get hasStories(){return this.buildConfig.stories!==void 0}get filesLoaded(){return this._filesLoaded}constructor(e,t){this.project=e,this.buildConfig=t,this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),this.tsLanguageService=new Ut(this),this.scssLanguageService=new Pr(this),this.htmlLanguageService=new Br(this),this.stories=new gt(this,t),this._outputPathes=[(0,f.join)(ii.getInstance().getPath(),`@locals`,t.fullname+w.Package).replace(/\\/g,`/`)];for(let e of t.compile)for(let t of e.package)this._outputPathes.push(t.replace(/\\/g,`/`));this.npmBuilder=new oi(this),Xr.send(e.getConfigFile().path,t.fullname)}async init(){await this.loadFiles(),this.initDone=!0}getComponentPrefix(){return this.buildConfig.componentPrefix}getAvoidParsingTags(){return this.buildConfig.avoidParsingInsideTags}getAliases(){return this.project.getConfig()?.aliases??{}}isFileInside(e){return I(e).match(this.buildConfig.srcPathRegex)!=null}getNamespace(e){return this.noNamespaceUri[e]||this.buildConfig.module==``?``:this.buildConfig.module+`.`}enableBuild(){this.allowBuild=!0}disableBuild(){this.allowBuild=!1}get isBuildAllowed(){return this.allowBuild}timerBuild=void 0;insideRebuildAll=!1;async rebuildAll(e=!1){if(this.allowBuild=!1,this.insideRebuildAll=!0,this.scssLanguageService.allowRebuildDefinition(!1),this.htmlLanguageService.allowRebuildDefinition(!1),e){for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.wcFiles)await this.wcFiles[e].init();for(let e in this.scssFiles)await this.scssFiles[e].init(),await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].init(),await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}else{for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.scssFiles)await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}this.scssLanguageService.allowRebuildDefinition(!0),this.htmlLanguageService.allowRebuildDefinition(!0),this.insideRebuildAll=!1;for(let e in this.scssFiles)await this.scssFiles[e].triggerSave();for(let e in this.wcFiles)await this.wcFiles[e].triggerSave();for(let e in this.tsFiles)await this.tsFiles[e].triggerSave();this.allowBuild=!0,this.npmBuilder.rebuildInfo(),this.initDone?await this.build():await this._build()}async build(){if(!this.initDone||$.noBuild)return;let e=$.delayBetweenBuild();e==0?await this._build():(this.timerBuild&&clearTimeout(this.timerBuild),this.timerBuild=setTimeout(async()=>{await this._build()},e))}addDiagnostic(e,t){this.diagnostics.has(e)||this.diagnostics.set(e,[]),this.diagnostics.get(e)?.push(t)}clearDiagnostics(){for(let[e,t]of this.diagnostics.entries())e instanceof Pt&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof Pt){let n=[...t,...e.getDiagnostics()];this.hideWarnings&&(n=n.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),$.sendDiagnostics({uri:e.file.uri,diagnostics:n},this)}}async _build(){if(!this.allowBuild)return;$.debug(`building `+this.buildConfig.fullname),this.clearDiagnostics();let e=[];for(let t of this.buildConfig.compile){t.i18n&&this.writeBuildI18n(t.i18n);let n=await this.buildOrderCompilationInfo(t),r=await this.buildLocalCode(n.toCompile,this.buildConfig.module);e=await this.writeBuildCode(r,n.libSrc,t.output,t.compressed),e=[...e,...n.errors];let i={namespace:this.buildConfig.module,available:r.codeRenderInJs,existing:r.codeNotRenderInJs};this.writeBuildDocumentation(t.package,r,i,t.outputNpm),t.outputNpm.live&&this.writeBuildNpm(t.outputNpm,r),this.buildConfig.stories&&this.buildConfig.stories.live&&(await this.stories.check(),this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},r),this.stories.write(this.tsFiles))}Yr.send(this.buildConfig.fullname,e),this.reloadPage&&(this.reloadPage=!1,D.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a){let o=``,s=e.split(`.`);if(o+=t.join(`
597
597
  `)+`
598
598
  `,n.length>0){let t=``;o+=`var `+s[0]+`;
599
599
  `;for(let e=0;e<s.length;e++)t==``?t=s[e]:t+=`.`+s[e],o+=`(`+t+`||(`+t+` = {}));
@@ -651,7 +651,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
651
651
  };
652
652
  `);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+`
653
653
  `:n[e[`@default`].path].code+=r.code+`
654
- `;n[e[`@default`].path].code+=s;for(let e in n){let t=Gi(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,fe.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 {
654
+ `;n[e[`@default`].path].code+=s;for(let e in n){let t=Ki(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,fe.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 {
655
655
  `,i+=`
656
656
  namespace `+this.buildConfig.module+`{
657
657
  `,i+=t.doc.join(`
@@ -683,19 +683,19 @@ namespace `+this.buildConfig.module+`{
683
683
  `,a+=`//#region dependencies //
684
684
  `,a+=JSON.stringify(this.buildConfig.rawDependencies)+`
685
685
  `,a+=`//#endregion dependencies //
686
- `;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&ra(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+w.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 di(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}";
686
+ `;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&ia(t);let o=(0,f.join)(ii.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+w.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 fi(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}";
687
687
  `)}if(a!=``&&(a+=`
688
688
  `),a+=t.npmsrc[n].content.join(`
689
- `),a=Ht.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`,...Gi(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}";
689
+ `),a=Ut.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`,...Ki(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}";
690
690
  `,a+=`export { ${e} };
691
691
  `,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";
692
692
  `)}i+=`
693
693
  `+r.content.join(`
694
694
  `)+`
695
- `,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=Ht.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";
695
+ `,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=Ut.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";
696
696
  `,a+=`export { ${e} };
697
697
  `}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"
698
- `}i+=a,i=Ht.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}:Qr.isConnected&&(o.author={name:Qr.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(w.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(w.I18n,w.ComponentLogic)];if(i instanceof j&&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(w.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(w.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 j&&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:qi(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(qi(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:qi(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=Qi(i,s);c=c.replace(w.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,L(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,L(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=qi(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)})
698
+ `}i+=a,i=Ut.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}:$r.isConnected&&(o.author={name:$r.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(w.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(w.I18n,w.ComponentLogic)];if(i instanceof j&&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(w.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(w.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 j&&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:Ji(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(Ji(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:Ji(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=$i(i,s);c=c.replace(w.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,L(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,L(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=Ji(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)})
699
699
  `,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")
700
700
  `,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })
701
701
  `}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(w.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })
@@ -711,27 +711,27 @@ namespace `+this.buildConfig.module+`{
711
711
  `}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(w.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })
712
712
  `}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })
713
713
  `}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()
714
- `}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;ii.send(e,r.join(`
715
- `)),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(){Ai.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),Ai.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Pr(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(w.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new Fr(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new oi(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new hi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new hi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=qr(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(w.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(w.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(w.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(I(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 j&&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=>Qt.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=I(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(w.ComponentLogic),n=I(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(w.Component)||t.oldUri.endsWith(w.ComponentLogic)||t.oldUri.endsWith(w.Data)||t.oldUri.endsWith(w.Lib)||t.oldUri.endsWith(w.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]);Xr.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){ta(e,t,`build`,this.buildConfig.fullname)}},_i=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:C.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:C.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}}},vi=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){Ai.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,ae.compile)(e,{style:`compressed`}).css.toString().trim();ta(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Ai.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(w.Base)){if(e.endsWith(w.GlobalStyle)){r=r.replace(w.GlobalStyle,`.css`);let t=this.project.scssFiles[F(e)];if(!t){let n=d.TextDocument.create(F(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[F(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}D.getInstance().reload(),Ai.sendStaticTime(this.name)}}registerWatcher(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.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()}},yi=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ie.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,re.default)([(0,Tr.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Er,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=Mr((0,ie.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]}},bi=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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},xi=class e extends bi{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(P.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,ae.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 ae.Exception&&(this.diagnosticCompile=zi(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}),ta(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(Bi(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(w.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+w.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+w.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},Si=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}},Ci=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 yi,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await xe.getInstance().validate(this.configFile)}async loadConfig(){let e=await xe.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 Si;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 gi(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 vi(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await xe.getInstance().format(e,t,n)}async onCompletion(e,t){return await xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await xe.getInstance().doResolve(t)}async onHover(e,t){return await xe.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(w.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(w.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new xi(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(w.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}async buildAll(){let e=[];for(let t of this.builds)e.push(t.build());for(let t of this.statics)e.push(t.export());await Promise.all(e)}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()}},N=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(`/`+w.Config)){let n=t.documentUser.uri.replace(w.Config,w.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 Ci(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 buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}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}};const wi={liveserver:{host:`0.0.0.0`,autoIncrementPort:!0,port:8080,rootFolder:`./dist`,indexFile:`index.html`,delay:200,launch_browser:!0,browser:``,auto_close:!0},updateImportOnRename:!0,readNodeModules:!1,templatePath:[],projectPath:[],globalPath:[],readDirs:[],watchFiles:!0,buildOnly:!1,loadFiles:!0,logLevel:3,useStats:!1,useTemplates:!0,useCompilators:!0,useDefaultTemplate:!0,defaultHideWarnings:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function Ti(){return JSON.parse(JSON.stringify(wi))}const Ei={version:`1.3.7`,store:{token:``,username:``}};function Di(){return JSON.parse(JSON.stringify(Ei))}const Oi={customData:[]};function ki(){return JSON.parse(JSON.stringify(Oi))}var P=class e{static instance;_settings=Ti();_settingsHtml=ki();_hiddenSettings=Di();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(Ti(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&N.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){this._hiddenSettings={...this._hiddenSettings,...e},(0,u.writeFileSync)((0,f.join)($.savePath,`config.json`),JSON.stringify(this._hiddenSettings,null,4))}cbOnSettingsChange=[];onSettingsChange(e){this.cbOnSettingsChange.push(e)}setSettingsHtml(e){this._settingsHtml=this.mergeDeep(ki(),e);let t=[...this.cbOnSettingsChangeHtml];for(let e of t)e()}cbOnSettingsChangeHtml=[];onSettingsChangeHtml(e){this.cbOnSettingsChangeHtml.push(e)}isObject(e){return e&&typeof e==`object`&&!Array.isArray(e)}mergeDeep(e,...t){if(!t.length)return e;let n=t.shift();if(this.isObject(e)&&this.isObject(n))for(let t in n)this.isObject(n[t])?(e[t]||Object.assign(e,{[t]:{}}),this.mergeDeep(e[t],n[t])):Object.assign(e,{[t]:n[t]});return this.mergeDeep(e,...t)}},Ai=class{static get isEnable(){return P.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&ia.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,ia.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&ia.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,ia.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&ia.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,ia.stop(`full_static_`+e))}static sendFileSize(e,t,n,r){if(this.isEnable){let i=0;i=typeof t==`string`?Buffer.from(t).length:(0,u.statSync)(e).size,$.sendNotification(`aventus/statistics/fileSize`,e,i,n,r)}}};const ji=(0,he.promisify)(ce.exec);(0,he.promisify)(u.stat);function F(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Mi(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Mi(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function Ni(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function I(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Pi(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function Fi(e){let t=Object.keys(w).reverse();for(let n of t)if(e.endsWith(w[n]))return Ii(w[n]);return``}function Ii(e){return e==`.wcv.avt`?C.HTML:e==`.wcs.avt`?C.SCSS:C.TypeScript}function Li(e,t,n,r){return L(e,t,0,e.getText().length,n,r)}function Ri(e,t,n,r,i){let a=RegExp(`//#region `+n+`(\\s|\\S)*?//#endregion`).exec(e.getText());if(a){let o=a.index+10+n.length,s=a.index+a[0].length,c={range:m.Range.create(e.positionAt(o),e.positionAt(s)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
716
- `),code:r};return i&&(c.data=i),c}return Li(e,t,r)}function L(e,t,n,r,i,a){let o={range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
717
- `),code:i};return a&&(o.data=a),o}function zi(e,t){return Bi(e,t,0,e.getText().length)}function Bi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.SCSS,message:(0,p.flattenDiagnosticMessageText)(t,`
718
- `)}}function Vi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:(0,p.flattenDiagnosticMessageText)(t,`
719
- `)}}function Hi(e,t){return Ui(e,t,0,e.getText().length)}function Ui(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
720
- `)}}function Wi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Warning,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
721
- `)}}function Gi(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function Ki(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function qi(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Ji(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Ji(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function Yi(e){return e===13||e===10}const Xi=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function Zi(e,t){let n=Xi,r=t;for(;r>0&&!Yi(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function Qi(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function $i(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}const ea={};function ta(e,t,n,r){t=t.replace(/\r\n?/g,`
722
- `);let i=na(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!ea[e]||ea[e]!=i||!o)&&(ea[e]=i,Ai.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function na(e){return(0,le.createHash)(`md5`).update(e).digest(`hex`)}function ra(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var ia=class{static timers={};static start(e){this.timers[e]=process.hrtime()}static stop(e){let t=process.hrtime(this.timers[e]),n=t[1]/1e6;return delete this.timers[e],t[0]*1e3+Math.round(n)}static stopNano(e){let t=process.hrtime(this.timers[e]);return delete this.timers[e],t[0]*1e9+t[1]}},aa=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},oa=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onContentChange.bind(this)).on(`change`,this.onContentChange.bind(this)).on(`unlink`,this.onRemove.bind(this)))}watcheUris=[];watch(e){if(this.watcheUris.includes(e)||!this.watcher)return;this.watcheUris.push(e);let t=I(e);this.watcher.add(t)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&this.watcheUris.splice(t,1)}async onContentChange(e){$.debug(`onContentChange : `+e);let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}},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=Fi(e);if(t){let n=I(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=Fi(e),n=I(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(P.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],oa.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=I(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=F(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}aa.sendDone()}async loadConfigFile(e,t,n){N.autoLoad=!1;let r=I(e);e=F(r);let i=d.TextDocument.create(F(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=N.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=F(i),r=Fi(e);if(t[n]!=w.Config&&t[n].endsWith(w.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);Ai.startSendLoadFile(),a.loadFiles(),Ai.sendLoadFile(),this.loadingInProgress=!1,await a.init(),aa.sendDone()}}}async parseWorkspace(e,t){let n=I(e),r=P.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)(I(e)+r+a).replace(/\\/g,`/`);s=Ji(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=F(n),i=Fi(r);e==w.Config&&t.push(new E(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];aa.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=Fi(r);if(e==w.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(w.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});aa.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);aa.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],oa.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(w.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=I(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return oa.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||oa.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)(I(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(w.Config))return;this.files[e.uri]=new E(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=T();for(;this.onNewFileCb[t]!=null;)t=T();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=T();for(;this.onNewFileCb[t]!=null;)t=T();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[F(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},sa=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))}},ca=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}},la=class extends ca{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ua={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 da(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const fa=65533;function pa(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 ma(e){return e>=48&&e<=57}function ha(e){return e>=65&&e<=90}function ga(e){return e>=97&&e<=122}function _a(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function va(e){return ga(e)||ha(e)}function ya(e){return va(e)||xa(e)||e===95}function ba(e){return ya(e)||ma(e)||e===45}function xa(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||!!Ta(e)||e>=65536}function Sa(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function Ca(e){return e===10||e===13||e===12}function wa(e){return e===32||e===10||e===9||e===13||e===12}function Ta(e){return e>=55296&&e<=57343}function Ea(e){return e.source.codePointAt(e.cursor)===92&&!Ca(e.source.codePointAt(e.cursor+1)??-1)}function Da(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!ya(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!Ca(t.source.codePointAt(t.cursor+2)??-1):!!ya(t.source.codePointAt(t.cursor)??-1)||Ea(t)}function Oa(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!ma(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&ma(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?ma(e.source.codePointAt(e.cursor+1)??-1):ma(e.source.codePointAt(e.cursor)??-1)}function ka(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Aa(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,ja;function Ma(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 Na(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 Pa(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 la(ua.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 Fa(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new ca(ua.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),fa;if(_a(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&_a(r)&&e.length<6;)e.push(r),t.advanceCodePoint();wa(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||Ta(i)||i>1114111?fa:i}return n===0||Ta(n)?fa:n}function Ia(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ta(r))n.push(fa),t.advanceCodePoint(+(r>65535)+1);else if(ba(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Ea(t))return n;t.advanceCodePoint(),n.push(Fa(e,t))}}}function La(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(ba(n)||Ea(t))){let n=ja.Unrestricted;Da(0,t)&&(n=ja.ID);let r=Ia(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 Ra(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&ma(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(ma(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||!ma(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function za(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ra(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Da(0,t)){let a=Ia(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 Ba(e){for(;wa(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`}(ja||={});var Va=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 Ha(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 la(ua.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(Ca(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 la(ua.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||Ta(i)?n+=String.fromCodePoint(fa):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(Ca(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(Fa(e,t))}}}function Ua(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Wa(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Ea(t)?(t.advanceCodePoint(),Fa(e,t)):t.advanceCodePoint()}}function Ga(e,t){for(;wa(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 la(ua.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(wa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();wa(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 la(ua.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}]):(Wa(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||Sa(r??-1)){Wa(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new la(ua.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(Ea(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Fa(e,t));continue}Wa(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new la(ua.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||Ta(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(fa),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Ka(e,t){let n=Ia(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(Ua(n)){t.advanceCodePoint();let r=0;for(;;){let e=wa(t.source.codePointAt(t.cursor)??-1),i=wa(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 Ga(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function qa(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&&!_a(e.source.codePointAt(e.cursor+2)??-1))}function Ja(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&_a(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&&_a(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&_a(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 Ya(e,t){let n=Xa(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Xa(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Va(n),a={onParseError:t?.onParseError??Za};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&&ka(i))return Pa(a,i);if(r&&(e===117||e===85)&&qa(i))return Ja(0,i);if(ya(e))return Ka(a,i);if(ma(e))return za(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 Ha(a,i);case 35:return La(a,i);case 43:case 46:return Oa(i)?za(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 Ba(i);case 45:return Oa(i)?za(a,i):Aa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Da(0,i)?Ka(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return pa(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(),Da(0,i)){let e=Ia(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(Ea(i))return Ka(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new la(ua.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 Za(){}function Qa(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=$a(n);r[0]===101&&to(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 $a(e){let t=0;if(e[0]===0)e.splice(0,1,fa),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,ya(e[1])||(t+=to(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];ya(e[0])?t=1:(t=1,t+=to(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,fa),n++):ba(e[n])||(n+=eo(e,n,e[n]));return e}function eo(e,t,n){return e.splice(t,1,92,n),1}function to(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 no=Object.values(z);function ro(e){return!!Array.isArray(e)&&!(e.length<4)&&!!no.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 io(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function ao(e){return!!e&&e[0]===z.Colon}function oo(e){return!!e&&e[0]===z.Comma}function so(e){return!!e&&e[0]===z.Comment}function co(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function lo(e){return!!e&&e[0]===z.EOF}function uo(e){return!!e&&e[0]===z.Function}function fo(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 po(e){return!!e&&e[0]===z.Semicolon}function mo(e){return!!e&&e[0]===z.Whitespace}function ho(e){return!!e&&e[0]===z.OpenParen}function go(e){return!!e&&e[0]===z.CloseParen}function _o(e){return!!e&&e[0]===z.OpenSquare}function vo(e){return!!e&&e[0]===z.OpenCurly}function yo(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 bo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
714
+ `}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;ai.send(e,r.join(`
715
+ `)),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(){ji.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await ii.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),ji.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Fr(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(w.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new Ir(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new si(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new gi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new gi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Jr(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(w.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(w.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(w.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(I(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 j&&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=>$t.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=I(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(w.ComponentLogic),n=I(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(w.Component)||t.oldUri.endsWith(w.ComponentLogic)||t.oldUri.endsWith(w.Data)||t.oldUri.endsWith(w.Lib)||t.oldUri.endsWith(w.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]);Zr.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){na(e,t,`build`,this.buildConfig.fullname)}},vi=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:C.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:C.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}}},yi=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){ji.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,ae.compile)(e,{style:`compressed`}).css.toString().trim();na(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),ji.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(w.Base)){if(e.endsWith(w.GlobalStyle)){r=r.replace(w.GlobalStyle,`.css`);let t=this.project.scssFiles[F(e)];if(!t){let n=d.TextDocument.create(F(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[F(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}D.getInstance().reload(),ji.sendStaticTime(this.name)}}registerWatcher(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.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()}},bi=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ie.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,re.default)([(0,Er.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Dr,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=Nr((0,ie.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]}},xi=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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},Si=class e extends xi{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(P.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,ae.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 ae.Exception&&(this.diagnosticCompile=Bi(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}),na(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(Vi(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(w.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+w.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+w.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},Ci=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}},wi=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 bi,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await xe.getInstance().validate(this.configFile)}async loadConfig(){let e=await xe.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 Ci;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 _i(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 yi(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await xe.getInstance().format(e,t,n)}async onCompletion(e,t){return await xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await xe.getInstance().doResolve(t)}async onHover(e,t){return await xe.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(w.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(w.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Si(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(w.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}async buildAll(){let e=[];for(let t of this.builds)e.push(t.build());for(let t of this.statics)e.push(t.export());await Promise.all(e)}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()}},N=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(`/`+w.Config)){let n=t.documentUser.uri.replace(w.Config,w.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 wi(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 buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}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}};const Ti={liveserver:{host:`0.0.0.0`,autoIncrementPort:!0,port:8080,rootFolder:`./dist`,indexFile:`index.html`,delay:200,launch_browser:!0,browser:``,auto_close:!0},updateImportOnRename:!0,readNodeModules:!1,templatePath:[],projectPath:[],globalPath:[],readDirs:[],watchFiles:!0,buildOnly:!1,loadFiles:!0,logLevel:3,useStats:!1,useTemplates:!0,useCompilators:!0,useDefaultTemplate:!0,defaultHideWarnings:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function Ei(){return JSON.parse(JSON.stringify(Ti))}const Di={version:`1.3.7`,store:{token:``,username:``}};function Oi(){return JSON.parse(JSON.stringify(Di))}const ki={customData:[]};function Ai(){return JSON.parse(JSON.stringify(ki))}var P=class e{static instance;_settings=Ei();_settingsHtml=Ai();_hiddenSettings=Oi();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(Ei(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&N.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){this._hiddenSettings={...this._hiddenSettings,...e},(0,u.writeFileSync)((0,f.join)($.savePath,`config.json`),JSON.stringify(this._hiddenSettings,null,4))}cbOnSettingsChange=[];onSettingsChange(e){this.cbOnSettingsChange.push(e)}setSettingsHtml(e){this._settingsHtml=this.mergeDeep(Ai(),e);let t=[...this.cbOnSettingsChangeHtml];for(let e of t)e()}cbOnSettingsChangeHtml=[];onSettingsChangeHtml(e){this.cbOnSettingsChangeHtml.push(e)}isObject(e){return e&&typeof e==`object`&&!Array.isArray(e)}mergeDeep(e,...t){if(!t.length)return e;let n=t.shift();if(this.isObject(e)&&this.isObject(n))for(let t in n)this.isObject(n[t])?(e[t]||Object.assign(e,{[t]:{}}),this.mergeDeep(e[t],n[t])):Object.assign(e,{[t]:n[t]});return this.mergeDeep(e,...t)}},ji=class{static get isEnable(){return P.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&aa.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,aa.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&aa.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,aa.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&aa.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,aa.stop(`full_static_`+e))}static sendFileSize(e,t,n,r){if(this.isEnable){let i=0;i=typeof t==`string`?Buffer.from(t).length:(0,u.statSync)(e).size,$.sendNotification(`aventus/statistics/fileSize`,e,i,n,r)}}};const Mi=(0,he.promisify)(ce.exec);(0,he.promisify)(u.stat);function F(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Ni(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Ni(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function Pi(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function I(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Fi(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function Ii(e){let t=Object.keys(w).reverse();for(let n of t)if(e.endsWith(w[n]))return Li(w[n]);return``}function Li(e){return e==`.wcv.avt`?C.HTML:e==`.wcs.avt`?C.SCSS:C.TypeScript}function Ri(e,t,n,r){return L(e,t,0,e.getText().length,n,r)}function zi(e,t,n,r,i){let a=RegExp(`//#region `+n+`(\\s|\\S)*?//#endregion`).exec(e.getText());if(a){let o=a.index+10+n.length,s=a.index+a[0].length,c={range:m.Range.create(e.positionAt(o),e.positionAt(s)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
716
+ `),code:r};return i&&(c.data=i),c}return Ri(e,t,r)}function L(e,t,n,r,i,a){let o={range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
717
+ `),code:i};return a&&(o.data=a),o}function Bi(e,t){return Vi(e,t,0,e.getText().length)}function Vi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.SCSS,message:(0,p.flattenDiagnosticMessageText)(t,`
718
+ `)}}function Hi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:(0,p.flattenDiagnosticMessageText)(t,`
719
+ `)}}function Ui(e,t){return Wi(e,t,0,e.getText().length)}function Wi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
720
+ `)}}function Gi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Warning,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
721
+ `)}}function Ki(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function qi(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function Ji(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Yi(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Yi(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function Xi(e){return e===13||e===10}const Zi=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function Qi(e,t){let n=Zi,r=t;for(;r>0&&!Xi(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function $i(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function ea(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}const ta={};function na(e,t,n,r){t=t.replace(/\r\n?/g,`
722
+ `);let i=ra(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!ta[e]||ta[e]!=i||!o)&&(ta[e]=i,ji.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function ra(e){return(0,le.createHash)(`md5`).update(e).digest(`hex`)}function ia(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var aa=class{static timers={};static start(e){this.timers[e]=process.hrtime()}static stop(e){let t=process.hrtime(this.timers[e]),n=t[1]/1e6;return delete this.timers[e],t[0]*1e3+Math.round(n)}static stopNano(e){let t=process.hrtime(this.timers[e]);return delete this.timers[e],t[0]*1e9+t[1]}},oa=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},sa=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onContentChange.bind(this)).on(`change`,this.onContentChange.bind(this)).on(`unlink`,this.onRemove.bind(this)))}watcheUris=[];watch(e){if(this.watcheUris.includes(e)||!this.watcher)return;this.watcheUris.push(e);let t=I(e);this.watcher.add(t)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&this.watcheUris.splice(t,1)}async onContentChange(e){$.debug(`onContentChange : `+e);let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}},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=Ii(e);if(t){let n=I(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=Ii(e),n=I(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(P.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],sa.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=I(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=F(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}oa.sendDone()}async loadConfigFile(e,t,n){N.autoLoad=!1;let r=I(e);e=F(r);let i=d.TextDocument.create(F(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=N.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=F(i),r=Ii(e);if(t[n]!=w.Config&&t[n].endsWith(w.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);ji.startSendLoadFile(),a.loadFiles(),ji.sendLoadFile(),this.loadingInProgress=!1,await a.init(),oa.sendDone()}}}async parseWorkspace(e,t){let n=I(e),r=P.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)(I(e)+r+a).replace(/\\/g,`/`);s=Yi(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=F(n),i=Ii(r);e==w.Config&&t.push(new E(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];oa.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=Ii(r);if(e==w.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(w.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});oa.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);oa.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],sa.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(w.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=I(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return sa.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||sa.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)(I(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(w.Config))return;this.files[e.uri]=new E(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=T();for(;this.onNewFileCb[t]!=null;)t=T();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=T();for(;this.onNewFileCb[t]!=null;)t=T();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[F(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},ca=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))}},la=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}},ua=class extends la{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const da={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 fa(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const pa=65533;function ma(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 ha(e){return e>=48&&e<=57}function ga(e){return e>=65&&e<=90}function _a(e){return e>=97&&e<=122}function va(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ya(e){return _a(e)||ga(e)}function ba(e){return ya(e)||Sa(e)||e===95}function xa(e){return ba(e)||ha(e)||e===45}function Sa(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||!!Ea(e)||e>=65536}function Ca(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function wa(e){return e===10||e===13||e===12}function Ta(e){return e===32||e===10||e===9||e===13||e===12}function Ea(e){return e>=55296&&e<=57343}function Da(e){return e.source.codePointAt(e.cursor)===92&&!wa(e.source.codePointAt(e.cursor+1)??-1)}function Oa(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!ba(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!wa(t.source.codePointAt(t.cursor+2)??-1):!!ba(t.source.codePointAt(t.cursor)??-1)||Da(t)}function ka(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!ha(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&ha(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?ha(e.source.codePointAt(e.cursor+1)??-1):ha(e.source.codePointAt(e.cursor)??-1)}function Aa(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function ja(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,Ma;function Na(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 Pa(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 Fa(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 ua(da.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 Ia(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new la(da.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),pa;if(va(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&va(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Ta(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||Ea(i)||i>1114111?pa:i}return n===0||Ea(n)?pa:n}function La(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ea(r))n.push(pa),t.advanceCodePoint(+(r>65535)+1);else if(xa(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Da(t))return n;t.advanceCodePoint(),n.push(Ia(e,t))}}}function Ra(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(xa(n)||Da(t))){let n=Ma.Unrestricted;Oa(0,t)&&(n=Ma.ID);let r=La(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 za(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();ha(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&ha(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;ha(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(ha(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||!ha(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;ha(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function Ba(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=za(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Oa(0,t)){let a=La(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 Va(e){for(;Ta(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`}(Ma||={});var Ha=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 Ua(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 ua(da.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(wa(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 ua(da.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||Ea(i)?n+=String.fromCodePoint(pa):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(wa(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(Ia(e,t))}}}function Wa(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Ga(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Da(t)?(t.advanceCodePoint(),Ia(e,t)):t.advanceCodePoint()}}function Ka(e,t){for(;Ta(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 ua(da.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(Ta(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Ta(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 ua(da.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}]):(Ga(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||Ca(r??-1)){Ga(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ua(da.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(Da(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Ia(e,t));continue}Ga(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ua(da.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||Ea(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(pa),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function qa(e,t){let n=La(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(Wa(n)){t.advanceCodePoint();let r=0;for(;;){let e=Ta(t.source.codePointAt(t.cursor)??-1),i=Ta(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 Ka(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function Ja(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&&!va(e.source.codePointAt(e.cursor+2)??-1))}function Ya(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&va(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&&va(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&va(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 Xa(e,t){let n=Za(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Za(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Ha(n),a={onParseError:t?.onParseError??Qa};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&&Aa(i))return Fa(a,i);if(r&&(e===117||e===85)&&Ja(i))return Ya(0,i);if(ba(e))return qa(a,i);if(ha(e))return Ba(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 Ua(a,i);case 35:return Ra(a,i);case 43:case 46:return ka(i)?Ba(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 Va(i);case 45:return ka(i)?Ba(a,i):ja(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Oa(0,i)?qa(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return ma(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(),Oa(0,i)){let e=La(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(Da(i))return qa(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new ua(da.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 Qa(){}function $a(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=eo(n);r[0]===101&&no(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 eo(e){let t=0;if(e[0]===0)e.splice(0,1,pa),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,ba(e[1])||(t+=no(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];ba(e[0])?t=1:(t=1,t+=no(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,pa),n++):xa(e[n])||(n+=to(e,n,e[n]));return e}function to(e,t,n){return e.splice(t,1,92,n),1}function no(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 ro=Object.values(z);function io(e){return!!Array.isArray(e)&&!(e.length<4)&&!!ro.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 ao(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function oo(e){return!!e&&e[0]===z.Colon}function so(e){return!!e&&e[0]===z.Comma}function co(e){return!!e&&e[0]===z.Comment}function lo(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function uo(e){return!!e&&e[0]===z.EOF}function fo(e){return!!e&&e[0]===z.Function}function po(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 mo(e){return!!e&&e[0]===z.Semicolon}function ho(e){return!!e&&e[0]===z.Whitespace}function go(e){return!!e&&e[0]===z.OpenParen}function _o(e){return!!e&&e[0]===z.CloseParen}function vo(e){return!!e&&e[0]===z.OpenSquare}function yo(e){return!!e&&e[0]===z.OpenCurly}function bo(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 xo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
723
723
  /**
724
724
  * Bradford chromatic adaptation from D50 to D65
725
725
  *
726
726
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
727
727
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
728
- */function xo(e){return yo(bo,e)}const So=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
728
+ */function So(e){return bo(xo,e)}const Co=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
729
729
  /**
730
730
  * Bradford chromatic adaptation from D65 to D50
731
731
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
732
732
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
733
733
  * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
734
- */function Co(e){return yo(So,e)}
734
+ */function wo(e){return bo(Co,e)}
735
735
  /**
736
736
  * @param {number} hue - Hue as degrees 0..360
737
737
  * @param {number} sat - Saturation as percentage 0..100
@@ -741,7 +741,7 @@ namespace `+this.buildConfig.module+`{
741
741
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
742
742
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
743
743
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js
744
- */function wo(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[To(0,t,n,r),To(8,t,n,r),To(4,t,n,r)]}function To(e,t,n,r){let i=(e+t/30)%12;return r-n*Math.min(r,1-r)*Math.max(-1,Math.min(i-3,9-i,1))}
744
+ */function To(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[Eo(0,t,n,r),Eo(8,t,n,r),Eo(4,t,n,r)]}function Eo(e,t,n,r){let i=(e+t/30)%12;return r-n*Math.min(r,1-r)*Math.max(-1,Math.min(i-3,9-i,1))}
745
745
  /**
746
746
  * @param {number} hue - Hue as degrees 0..360
747
747
  * @param {number} white - Whiteness as percentage 0..100
@@ -751,31 +751,31 @@ namespace `+this.buildConfig.module+`{
751
751
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
752
752
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
753
753
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js
754
- */function Eo(e){let t=e[0],n=e[1]/100,r=e[2]/100;if(n+r>=1){let e=n/(n+r);return[e,e,e]}let i=wo([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
754
+ */function Do(e){let t=e[0],n=e[1]/100,r=e[2]/100;if(n+r>=1){let e=n/(n+r);return[e,e,e]}let i=To([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
755
755
  /**
756
756
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
757
757
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
758
- */function Do(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
758
+ */function Oo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
759
759
  /**
760
760
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
761
761
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
762
- */function Oo(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=.0015&&(n=NaN),[e[0],t,n]}const ko=[.3457/.3585,1,.2958/.3585];
762
+ */function ko(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=.0015&&(n=NaN),[e[0],t,n]}const Ao=[.3457/.3585,1,.2958/.3585];
763
763
  /**
764
764
  * Convert Lab to D50-adapted XYZ
765
765
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
766
766
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
767
767
  * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
768
- */function Ao(e){let t=24389/27,n=216/24389,r=(e[0]+16)/116,i=e[1]/500+r,a=r-e[2]/200;return[(i**3>n?i**3:(116*i-16)/t)*ko[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*ko[1],(a**3>n?a**3:(116*a-16)/t)*ko[2]]}
768
+ */function jo(e){let t=24389/27,n=216/24389,r=(e[0]+16)/116,i=e[1]/500+r,a=r-e[2]/200;return[(i**3>n?i**3:(116*i-16)/t)*Ao[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*Ao[1],(a**3>n?a**3:(116*a-16)/t)*Ao[2]]}
769
769
  /**
770
770
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
771
771
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
772
772
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
773
- */function jo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
773
+ */function Mo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
774
774
  /**
775
775
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
776
776
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
777
777
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
778
- */function Mo(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=4e-6&&(n=NaN),[e[0],t,n]}const No=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],Po=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
778
+ */function No(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=4e-6&&(n=NaN),[e[0],t,n]}const Po=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],Fo=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
779
779
  /**
780
780
  * Given OKLab, convert to XYZ relative to D65
781
781
  *
@@ -783,14 +783,14 @@ namespace `+this.buildConfig.module+`{
783
783
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
784
784
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
785
785
  */
786
- function Fo(e){let t=yo(Po,e);return yo(No,[t[0]**3,t[1]**3,t[2]**3])}
786
+ function Io(e){let t=bo(Fo,e);return bo(Po,[t[0]**3,t[1]**3,t[2]**3])}
787
787
  /**
788
788
  * Assuming XYZ is relative to D50, convert to CIE Lab
789
789
  * from CIE standard, which now defines these as a rational fraction
790
790
  *
791
791
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
792
792
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
793
- */function Io(e){let t=Lo(e[0]/ko[0]),n=Lo(e[1]/ko[1]);return[116*n-16,500*(t-n),200*(n-Lo(e[2]/ko[2]))]}function Lo(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const Ro=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],zo=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
793
+ */function Lo(e){let t=Ro(e[0]/Ao[0]),n=Ro(e[1]/Ao[1]);return[116*n-16,500*(t-n),200*(n-Ro(e[2]/Ao[2]))]}function Ro(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const zo=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],Bo=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
794
794
  /**
795
795
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
796
796
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
@@ -798,7 +798,7 @@ function Fo(e){let t=yo(Po,e);return yo(No,[t[0]**3,t[1]**3,t[2]**3])}
798
798
  * XYZ <-> LMS matrices recalculated for consistent reference white
799
799
  * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
800
800
  */
801
- function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const Vo=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],Ho=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
801
+ function Vo(e){let t=bo(zo,e);return bo(Bo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const Ho=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],Uo=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
802
802
  /**
803
803
  * Convert XYZ to linear-light rec2020
804
804
  *
@@ -811,7 +811,7 @@ function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
811
811
  *
812
812
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
813
813
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
814
- */function Uo(e){return yo(Ho,e)}const Wo=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],Go=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],Ko=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
814
+ */function Wo(e){return bo(Uo,e)}const Go=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],Ko=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],qo=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
815
815
  /**
816
816
  * Convert D50 XYZ to linear-light prophoto-rgb
817
817
  *
@@ -829,14 +829,14 @@ function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
829
829
  /**
830
830
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
831
831
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
832
- */function qo(e){return yo(Ko,e)}
832
+ */function Jo(e){return bo(qo,e)}
833
833
  /**
834
834
  * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0
835
835
  * to gamma corrected form ITU-R BT.2020-2 p.4
836
836
  *
837
837
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
838
838
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
839
- */function Jo(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
839
+ */function Yo(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
840
840
  /**
841
841
  * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
842
842
  * Extended transfer function:
@@ -846,14 +846,14 @@ function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
846
846
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
847
847
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
848
848
  * @see https://en.wikipedia.org/wiki/SRGB
849
- */function Yo(e){return[Xo(e[0]),Xo(e[1]),Xo(e[2])]}function Xo(e){let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}
849
+ */function Xo(e){return[Zo(e[0]),Zo(e[1]),Zo(e[2])]}function Zo(e){let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}
850
850
  /**
851
851
  * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
852
852
  * to gamma corrected form
853
853
  *
854
854
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
855
855
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
856
- */function Zo(e){return Yo(e)}
856
+ */function Qo(e){return Xo(e)}
857
857
  /**
858
858
  * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0
859
859
  * to gamma corrected form.
@@ -862,14 +862,14 @@ function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
862
862
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
863
863
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
864
864
  */
865
- function Qo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
865
+ function $o(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
866
866
  /**
867
867
  * Convert an array of linear-light a98-rgb in the range 0.0-1.0
868
868
  * to gamma corrected form. Negative values are also now accepted
869
869
  *
870
870
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
871
871
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
872
- */function $o(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
872
+ */function es(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
873
873
  /**
874
874
  * Convert an array of rec2020 RGB values in the range 0.0 - 1.0
875
875
  * to linear light (un-companded) form.
@@ -877,7 +877,7 @@ function Qo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
877
877
  *
878
878
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
879
879
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
880
- */function es(e){return(e<0?-1:1)*Math.abs(e)**2.4}const ts=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
880
+ */function ts(e){return(e<0?-1:1)*Math.abs(e)**2.4}const ns=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
881
881
  /**
882
882
  * Convert an array of linear-light rec2020 values to CIE XYZ
883
883
  * using D65 (no chromatic adaptation)
@@ -897,14 +897,14 @@ function Qo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
897
897
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
898
898
  * @see https://en.wikipedia.org/wiki/SRGB
899
899
  */
900
- function ns(e){return[rs(e[0]),rs(e[1]),rs(e[2])]}function rs(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
900
+ function rs(e){return[is(e[0]),is(e[1]),is(e[2])]}function is(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
901
901
  /**
902
902
  * Convert an array of display-p3 RGB values in the range 0.0 - 1.0
903
903
  * to linear light (un-companded) form.
904
904
  *
905
905
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
906
906
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
907
- */function is(e){return ns(e)}const as=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
907
+ */function as(e){return rs(e)}const os=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
908
908
  /**
909
909
  * Convert an array of linear-light display-p3 values to CIE XYZ
910
910
  * using D65 (no chromatic adaptation)
@@ -912,7 +912,7 @@ function ns(e){return[rs(e[0]),rs(e[1]),rs(e[2])]}function rs(e){let t=e<0?-1:1,
912
912
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
913
913
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
914
914
  * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
915
- */function os(e){return yo(as,e)}
915
+ */function ss(e){return bo(os,e)}
916
916
  /**
917
917
  * Convert an array of prophoto-rgb values where in-gamut Colors are in the
918
918
  * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is
@@ -921,7 +921,7 @@ function ns(e){return[rs(e[0]),rs(e[1]),rs(e[2])]}function rs(e){let t=e<0?-1:1,
921
921
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
922
922
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
923
923
  */
924
- function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const cs=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
924
+ function cs(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const ls=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
925
925
  /**
926
926
  * Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ.
927
927
  * Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy.
@@ -929,7 +929,7 @@ function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
929
929
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
930
930
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
931
931
  * @see see https://github.com/w3c/csswg-drafts/issues/7675
932
- */function ls(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const us=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],ds=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
932
+ */function us(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const ds=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],fs=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
933
933
  /**
934
934
  * Convert an array of linear-light a98-rgb values to CIE XYZ
935
935
  * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
@@ -951,7 +951,7 @@ function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
951
951
  *
952
952
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
953
953
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
954
- */function fs(e){return yo(ds,e)}
954
+ */function ps(e){return bo(fs,e)}
955
955
  /**
956
956
  * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL.
957
957
  *
@@ -965,7 +965,7 @@ function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
965
965
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
966
966
  *
967
967
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js
968
- */function ps(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(a+i)/2,s=i-a,c=NaN,l=0;if(Math.round(1e5*s)!==0){let e=Math.round(1e5*o);switch(l=e===0||e===1e5?0:(i-o)/Math.min(o,1-o),i){case t:c=(n-r)/s+(n<r?6:0);break;case n:c=(r-t)/s+2;break;case r:c=(t-n)/s+4}c*=60}return l<0&&(c+=180,l=Math.abs(l)),c>=360&&(c-=360),l<=1e-5&&(c=NaN),[c,100*l,100*o]}function ms(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=NaN,s=i-a;if(s!==0){switch(i){case t:o=(n-r)/s+(n<r?6:0);break;case n:o=(r-t)/s+2;break;case r:o=(t-n)/s+4}o*=60}return o>=360&&(o-=360),o}function hs(e){let t=e;return t=ns(t),t=fs(t),t=Co(t),t}function gs(e){let t=e;return t=xo(t),t=qo(t),t=Yo(t),t}function _s(e){let t=e;return t=wo(t),t=ns(t),t=fs(t),t=Co(t),t}function vs(e){let t=e;return t=xo(t),t=qo(t),t=Yo(t),t=ps(t),t}function ys(e){let t=e;return t=Eo(t),t=ns(t),t=fs(t),t=Co(t),t}function bs(e){let t=e;t=xo(t),t=qo(t);let n=Yo(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=ms(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function xs(e){let t=e;return t=Ao(t),t}function Ss(e){let t=e;return t=Io(t),t}function Cs(e){let t=e;return t=Do(t),t=Ao(t),t}function ws(e){let t=e;return t=Io(t),t=Oo(t),t}function Ts(e){let t=e;return t=Fo(t),t=Co(t),t}function Es(e){let t=e;return t=xo(t),t=Bo(t),t}function Ds(e){let t=e;return t=jo(t),t=Fo(t),t=Co(t),t}function Os(e){let t=e;return t=xo(t),t=Bo(t),t=Mo(t),t}function ks(e){let t=e;return t=fs(t),t=Co(t),t}function As(e){let t=e;return t=xo(t),t=qo(t),t}function js(e){let t=e;
968
+ */function ms(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(a+i)/2,s=i-a,c=NaN,l=0;if(Math.round(1e5*s)!==0){let e=Math.round(1e5*o);switch(l=e===0||e===1e5?0:(i-o)/Math.min(o,1-o),i){case t:c=(n-r)/s+(n<r?6:0);break;case n:c=(r-t)/s+2;break;case r:c=(t-n)/s+4}c*=60}return l<0&&(c+=180,l=Math.abs(l)),c>=360&&(c-=360),l<=1e-5&&(c=NaN),[c,100*l,100*o]}function hs(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=NaN,s=i-a;if(s!==0){switch(i){case t:o=(n-r)/s+(n<r?6:0);break;case n:o=(r-t)/s+2;break;case r:o=(t-n)/s+4}o*=60}return o>=360&&(o-=360),o}function gs(e){let t=e;return t=rs(t),t=ps(t),t=wo(t),t}function _s(e){let t=e;return t=So(t),t=Jo(t),t=Xo(t),t}function vs(e){let t=e;return t=To(t),t=rs(t),t=ps(t),t=wo(t),t}function ys(e){let t=e;return t=So(t),t=Jo(t),t=Xo(t),t=ms(t),t}function bs(e){let t=e;return t=Do(t),t=rs(t),t=ps(t),t=wo(t),t}function xs(e){let t=e;t=So(t),t=Jo(t);let n=Xo(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=hs(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function Ss(e){let t=e;return t=jo(t),t}function Cs(e){let t=e;return t=Lo(t),t}function ws(e){let t=e;return t=Oo(t),t=jo(t),t}function Ts(e){let t=e;return t=Lo(t),t=ko(t),t}function Es(e){let t=e;return t=Io(t),t=wo(t),t}function Ds(e){let t=e;return t=So(t),t=Vo(t),t}function Os(e){let t=e;return t=Mo(t),t=Io(t),t=wo(t),t}function ks(e){let t=e;return t=So(t),t=Vo(t),t=No(t),t}function As(e){let t=e;return t=ps(t),t=wo(t),t}function js(e){let t=e;return t=So(t),t=Jo(t),t}function Ms(e){let t=e;
969
969
  /**
970
970
  * Convert an array of a98-rgb values in the range 0.0 - 1.0
971
971
  * to linear light (un-companded) form. Negative values are also now accepted
@@ -973,7 +973,7 @@ function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
973
973
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
974
974
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
975
975
  */
976
- var n;return t=[ls((n=t)[0]),ls(n[1]),ls(n[2])],t=yo(us,t),t=Co(t),t}function Ms(e){let t=e;var n;return t=xo(t),t=yo(Go,t),t=[$o((n=t)[0]),$o(n[1]),$o(n[2])],t}function Ns(e){let t=e;return t=is(t),t=os(t),t=Co(t),t}function Ps(e){let t=e;return t=xo(t),t=Uo(t),t=Zo(t),t}function Fs(e){let t=e;return t=os(t),t=Co(t),t}function Is(e){let t=e;return t=xo(t),t=Uo(t),t}function Ls(e){let t=e;var n;return t=[es((n=t)[0]),es(n[1]),es(n[2])],t=yo(ts,t),t=Co(t),t}function Rs(e){let t=e;var n;return t=xo(t),t=yo(Vo,t),t=[Jo((n=t)[0]),Jo(n[1]),Jo(n[2])],t}function zs(e){let t=e;var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=yo(cs,t),t}function Bs(e){let t=e;var n;return t=yo(Wo,t),t=[Qo((n=t)[0]),Qo(n[1]),Qo(n[2])],t}function Vs(e){let t=e;return t=Co(t),t}function Hs(e){let t=e;return t=xo(t),t}function Us(e){return e}function Ws(e){return e[0]>=-1e-4&&e[0]<=1.0001&&e[1]>=-1e-4&&e[1]<=1.0001&&e[2]>=-1e-4&&e[2]<=1.0001}function Gs(e){return[e[0]<0?0:e[0]>1?1:e[0],e[1]<0?0:e[1]>1?1:e[1],e[2]<0?0:e[2]>1?1:e[2]]}
976
+ var n;return t=[us((n=t)[0]),us(n[1]),us(n[2])],t=bo(ds,t),t=wo(t),t}function Ns(e){let t=e;var n;return t=So(t),t=bo(Ko,t),t=[es((n=t)[0]),es(n[1]),es(n[2])],t}function Ps(e){let t=e;return t=as(t),t=ss(t),t=wo(t),t}function Fs(e){let t=e;return t=So(t),t=Wo(t),t=Qo(t),t}function Is(e){let t=e;return t=ss(t),t=wo(t),t}function Ls(e){let t=e;return t=So(t),t=Wo(t),t}function Rs(e){let t=e;var n;return t=[ts((n=t)[0]),ts(n[1]),ts(n[2])],t=bo(ns,t),t=wo(t),t}function zs(e){let t=e;var n;return t=So(t),t=bo(Ho,t),t=[Yo((n=t)[0]),Yo(n[1]),Yo(n[2])],t}function Bs(e){let t=e;var n;return t=[cs((n=t)[0]),cs(n[1]),cs(n[2])],t=bo(ls,t),t}function Vs(e){let t=e;var n;return t=bo(Go,t),t=[$o((n=t)[0]),$o(n[1]),$o(n[2])],t}function Hs(e){let t=e;return t=wo(t),t}function Us(e){let t=e;return t=So(t),t}function Ws(e){return e}function Gs(e){return e[0]>=-1e-4&&e[0]<=1.0001&&e[1]>=-1e-4&&e[1]<=1.0001&&e[2]>=-1e-4&&e[2]<=1.0001}function Ks(e){return[e[0]<0?0:e[0]>1?1:e[0],e[1]<0?0:e[1]>1?1:e[1],e[2]<0?0:e[2]>1?1:e[2]]}
977
977
  /**
978
978
  * @description Calculate deltaE OK which is the simple root sum of squares
979
979
  * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1
@@ -986,32 +986,32 @@ var n;return t=[ls((n=t)[0]),ls(n[1]),ls(n[2])],t=yo(us,t),t=Co(t),t}function Ms
986
986
  */
987
987
  /**
988
988
  * @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
989
- */function Ks(e,t,n){let r=e[0],i=e[2],a=t(e),o=t([r,0,i]);for(let e=0;e<4;e++){if(e>0){let e=n(a);e[0]=r,e[2]=i,a=t(e)}let s=qs(o,a);if(!s)break;a=s}return Gs(a)}function qs(e,t){let n=1/0,r=-1/0,i=[0,0,0];for(let a=0;a<3;a++){let o=e[a],s=t[a]-o;if(i[a]=s,Math.abs(s)>1e-15){let e=1/s,t=(0-o)*e,i=(1-o)*e;r=Math.max(Math.min(t,i),r),n=Math.min(Math.max(t,i),n)}else if(o<0||o>1)return!1}return!(r>n||n<0)&&(r<0&&(r=n),!!isFinite(r)&&[e[0]+i[0]*r,e[1]+i[1]*r,e[2]+i[2]*r])}const Js={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ys(e){let[t,n,r]=e.map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r}function Xs(e,t){let n=Ys(e),r=Ys(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Zs;function Qs(e){let t=e.slice();return(e,n,r)=>{let i=-1;for(let a=t.indexOf(n);a<t.length&&(i=e.indexOf(t[a]),i===-1||i<r);a++);return i===-1||i===r&&n===e[r]&&(i++,i>=e.length)?-1:(t=e.slice(),i)}}function $s(e,t){let n=t[0];if(ho(n)||vo(n)||_o(n)){let n=ic(e,t);return{advance:n.advance,node:n.node}}if(uo(n)){let n=nc(e,t);return{advance:n.advance,node:n.node}}if(mo(n)){let n=oc(e,t);return{advance:n.advance,node:n.node}}if(so(n)){let n=cc(e,t);return{advance:n.advance,node:n.node}}return{advance:1,node:new K(n)}}(function(e){e.Function=`function`,e.SimpleBlock=`simple-block`,e.Whitespace=`whitespace`,e.Comment=`comment`,e.Token=`token`})(Zs||={});var ec=class{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if(typeof e==`number`)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,t){if(this.value.length===0)return;let n=Qs(this.value),r=0;for(;r<this.value.length;){let i=this.value[r],a;if(t&&(a={...t}),!1===e({node:i,parent:this,state:a},r))return!1;if(r=n(this.value,i,r),r===-1)break}}walk(e,t){this.value.length!==0&&this.forEach((t,n)=>!1!==e(t,n)&&(!(`walk`in t.node)||!this.value.includes(t.node)||!1!==t.node.walk(e,t.state))&&void 0,t)}},tc=class e extends ec{type=Zs.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){lo(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return lo(this.endToken)?[this.name,...this.value.flatMap(e=>e.tokens())]:[this.name,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>ro(e)?da(e):e.toString()).join(``);return da(this.name)+e+da(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isFunctionNode(){return e.isFunctionNode(this)}static isFunctionNode(t){return!!t&&t instanceof e&&t.type===Zs.Function}};function nc(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||lo(i))return e.onParseError(new ca(`Unexpected EOF while consuming a function.`,t[0][2],t[t.length-1][3],[`5.4.9. Consume a function`,`Unexpected EOF`])),{advance:t.length,node:new tc(t[0],i,n)};if(go(i))return{advance:r+1,node:new tc(t[0],i,n)};if(io(i)){let i=lc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=$s(e,t.slice(r));r+=a.advance,n.push(a.node)}}var rc=class e extends ec{type=Zs.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(lo(this.endToken)){let e=Na(this.startToken);e&&(this.endToken=e)}}tokens(){return lo(this.endToken)?[this.startToken,...this.value.flatMap(e=>e.tokens())]:[this.startToken,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>ro(e)?da(e):e.toString()).join(``);return da(this.startToken)+e+da(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isSimpleBlockNode(){return e.isSimpleBlockNode(this)}static isSimpleBlockNode(t){return!!t&&t instanceof e&&t.type===Zs.SimpleBlock}};function ic(e,t){let n=Ma(t[0][0]);if(!n)throw Error(`Failed to parse, a mirror variant must exist for all block open tokens.`);let r=[],i=1;for(;;){let a=t[i];if(!a||lo(a))return e.onParseError(new ca(`Unexpected EOF while consuming a simple block.`,t[0][2],t[t.length-1][3],[`5.4.8. Consume a simple block`,`Unexpected EOF`])),{advance:t.length,node:new rc(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new rc(t[0],a,r)};if(io(a)){let n=lc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=$s(e,t.slice(i));i+=o.advance,r.push(o.node)}}var ac=class e{type=Zs.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return da(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return e.isWhitespaceNode(this)}static isWhitespaceNode(t){return!!t&&t instanceof e&&t.type===Zs.Whitespace}};function oc(e,t){let n=0;for(;;){let e=t[n];if(!mo(e))return{advance:n,node:new ac(t.slice(0,n))};n++}}var sc=class e{type=Zs.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return da(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return e.isCommentNode(this)}static isCommentNode(t){return!!t&&t instanceof e&&t.type===Zs.Comment}};function cc(e,t){return{advance:1,node:new sc(t[0])}}function lc(e,t){let n=[],r=0;for(;;){if(mo(t[r])){let e=oc(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!so(t[r]))return{advance:r,nodes:n};n.push(new sc(t[r])),r++}}var K=class e{type=Zs.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return e.isTokenNode(this)}static isTokenNode(t){return!!t&&t instanceof e&&t.type===Zs.Token}};function uc(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];lo(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=$s(n,r);if(lo(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new ca(`Expected EOF after parsing a component value.`,e[0][2],e[e.length-1][3],[`5.3.9. Parse a component value`,`Expected EOF`]))}function dc(e,t,n){if(e.length===0)return;let r=Qs(e),i=0;for(;i<e.length;){let a=e[i],o;if(n&&(o={...n}),!1===t({node:a,parent:{value:e},state:o},i))return!1;if(i=r(e,a,i),i===-1)break}}function fc(e,t,n){e.length!==0&&dc(e,(n,r)=>!1!==t(n,r)&&(!(`walk`in n.node)||!e.includes(n.node)||!1!==n.node.walk(t,n.state))&&void 0,n)}function pc(e,t){for(let n=0;n<e.length;n++)fc(e[n],(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);r&&(Array.isArray(r)?e.parent.value.splice(n,1,...r):e.parent.value.splice(n,1,r))});return e}function mc(e){return rc.isSimpleBlockNode(e)}function hc(e){return tc.isFunctionNode(e)}function gc(e){return ac.isWhitespaceNode(e)}function _c(e){return sc.isCommentNode(e)}function vc(e){return gc(e)||_c(e)}function q(e){return K.isTokenNode(e)}function yc(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[yc(t)[0],yc(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var bc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},xc=class extends bc{componentValues;constructor(e,t){super(e,...yc(t)),this.componentValues=t}};const Sc={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},Cc=/[A-Z]/g;function wc(e){return e.replace(Cc,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Tc={cm:`px`,in:`px`,mm:`px`,pc:`px`,pt:`px`,px:`px`,q:`px`,deg:`deg`,grad:`deg`,rad:`deg`,turn:`deg`,ms:`s`,s:`s`,hz:`hz`,khz:`hz`},Ec=new Map([[`cm`,e=>e],[`mm`,e=>10*e],[`q`,e=>40*e],[`in`,e=>e/2.54],[`pc`,e=>e/2.54*6],[`pt`,e=>e/2.54*72],[`px`,e=>e/2.54*96]]),Dc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Oc=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),kc=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),Ac=new Map([[`cm`,e=>2.54*e],[`mm`,e=>25.4*e],[`q`,e=>25.4*e*4],[`in`,e=>e],[`pc`,e=>6*e],[`pt`,e=>72*e],[`px`,e=>96*e]]),jc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),Mc=new Map([[`cm`,e=>e/10],[`mm`,e=>e],[`q`,e=>4*e],[`in`,e=>e/25.4],[`pc`,e=>e/25.4*6],[`pt`,e=>e/25.4*72],[`px`,e=>e/25.4*96]]),Nc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Pc=new Map([[`cm`,e=>e/6*2.54],[`mm`,e=>e/6*25.4],[`q`,e=>e/6*25.4*4],[`in`,e=>e/6],[`pc`,e=>e],[`pt`,e=>e/6*72],[`px`,e=>e/6*96]]),Fc=new Map([[`cm`,e=>e/72*2.54],[`mm`,e=>e/72*25.4],[`q`,e=>e/72*25.4*4],[`in`,e=>e/72],[`pc`,e=>e/72*6],[`pt`,e=>e],[`px`,e=>e/72*96]]),Ic=new Map([[`cm`,e=>e/96*2.54],[`mm`,e=>e/96*25.4],[`q`,e=>e/96*25.4*4],[`in`,e=>e/96],[`pc`,e=>e/96*6],[`pt`,e=>e/96*72],[`px`,e=>e]]),Lc=new Map([[`cm`,e=>e/4/10],[`mm`,e=>e/4],[`q`,e=>e],[`in`,e=>e/4/25.4],[`pc`,e=>e/4/25.4*6],[`pt`,e=>e/4/25.4*72],[`px`,e=>e/4/25.4*96]]),Rc=new Map([[`deg`,e=>180*e/Math.PI],[`grad`,e=>180*e/Math.PI/.9],[`rad`,e=>e],[`turn`,e=>180*e/Math.PI/360]]),zc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),Bc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),Vc=new Map([[`cm`,Ec],[`mm`,Mc],[`q`,Lc],[`in`,Ac],[`pc`,Pc],[`pt`,Fc],[`px`,Ic],[`ms`,Nc],[`s`,zc],[`deg`,Dc],[`grad`,Oc],[`rad`,Rc],[`turn`,Bc],[`hz`,kc],[`khz`,jc]]);function Hc(e,t){if(!H(e)||!H(t))return t;let n=wc(e[4].unit),r=wc(t[4].unit);if(n===r)return t;let i=Vc.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[z.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?B.Integer:B.Number,value:o}];return Qa(s,e[4].unit),s}function Uc(e){if(!H(e))return e;let t=wc(e[4].unit),n=Tc[t];if(t===n)return e;let r=Vc.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[z.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?B.Integer:B.Number,value:a}];return Qa(o,n),o}function Wc(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value+r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Hc(n,r),wc(n[4].unit)===wc(r[4].unit))){let e=n[4].value+r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new xc(Sc.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Gc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number,unit:t[4].unit}])}return-1}function Kc(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function qc(e,t){if(e===-1)return-1;let n=[];for(let r=0;r<e.inputs.length;r++){let i=e.inputs[r];if(q(i)){n.push(i);continue}let a=qc(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function Jc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(W(t)&&G(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return-1}function Yc(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!q(r))continue;let i=r.value;if(!U(i))continue;let a=wc(i[4].value);switch(a){case`e`:e.splice(n,1,new K([z.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:B.Number}]));break;case`pi`:e.splice(n,1,new K([z.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:B.Number}]));break;case`infinity`:e.splice(n,1,new K([z.Number,`infinity`,i[2],i[3],{value:1/0,type:B.Number}]));break;case`-infinity`:e.splice(n,1,new K([z.Number,`-infinity`,i[2],i[3],{value:-1/0,type:B.Number}]));break;case`nan`:e.splice(n,1,new K([z.Number,`NaN`,i[2],i[3],{value:NaN,type:B.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function Xc(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function Zc(e,t,n){return H(t)?Qc(e,t[4].unit,n):G(t)?$c(e,n):W(t)?el(e,n):-1}function Qc(e,t,n){let r=e.tokens();return{inputs:[new K([z.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?B.Integer:B.Number,unit:t}])],operation:Xc}}function $c(e,t){let n=e.tokens();return{inputs:[new K([z.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:Xc}}function el(e,t){let n=e.tokens();return{inputs:[new K([z.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?B.Integer:B.Number}])],operation:Xc}}function tl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.acos(n[4].value)):-1}function nl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.asin(n[4].value)):-1}function rl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.atan(n[4].value)):-1}function il(e){return H(e)||W(e)}function al(e){if(e.length===0)return!0;let t=e[0];if(!V(t))return!1;if(e.length===1)return!0;if(H(t)){let n=wc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==wc(i[4].unit))return!1}return!0}for(let n=1;n<e.length;n++){let r=e[n];if(t[0]!==r[0])return!1}return!0}function ol(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&wc(e[4].unit)===wc(t[4].unit):e[0]===t[0])}function sl(e,t,n){let r=t.value;if(!il(r))return-1;let i=Hc(r,n.value);return ol(r,i)?Qc(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function cl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:Zc(e,r,Math.abs(r[4].value))}function ll(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!V(a)||!i.rawPercentages&&G(a))return-1;let o=Hc(a,n.value);if(!ol(a,o))return-1;let s=Hc(a,r.value);return ol(a,s)?Zc(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function ul(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Dc.get(`rad`)(n[4].value);break;case`grad`:r=Oc.get(`rad`)(n[4].value);break;case`turn`:r=Bc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),el(e,r)}function dl(e,t){let n=t.value;return W(n)?el(e,Math.exp(n[4].value)):-1}function fl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.hypot(...a))}function pl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.max(...a))}function ml(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.min(...a))}function hl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Hc(r,n.value);if(!ol(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)&&(Number.isFinite(i[4].value)||(i[4].value!==1/0||r[4].value!==-1/0&&!Object.is(0*r[4].value,-0))&&(i[4].value!==-1/0||r[4].value!==1/0&&!Object.is(0*r[4].value,0)))?Number.isFinite(i[4].value)?(r[4].value%i[4].value+i[4].value)%i[4].value:r[4].value:NaN,Zc(e,r,a)}function gl(e,t,n){let r=t.value,i=n.value;return!W(r)||!ol(r,i)?-1:el(e,r[4].value**+i[4].value)}function _l(e,t,n){let r=t.value;if(!V(r))return-1;let i=Hc(r,n.value);if(!ol(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)?Number.isFinite(i[4].value)?r[4].value%i[4].value:r[4].value:NaN,Zc(e,r,a)}function vl(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[z.Dimension,`${r}px`,t[2],t[3],{value:r,type:B.Integer,unit:`px`}],a=Hc(i,t);if(!ol(a,i))return-1;if(Number.isInteger(a[4].value/r))return Zc(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return Zc(e,t,Hc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,Zc(e,t,Hc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return Zc(e,t,-1*Hc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,Zc(e,t,Hc(t,a)[4].value)}function yl(e,t,n,r,i){let a=n.value;if(!V(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=Hc(a,r.value);if(!ol(a,o))return-1;let s;if(o[4].value===0)s=NaN;else if(Number.isFinite(a[4].value)||Number.isFinite(o[4].value))if(!Number.isFinite(a[4].value)&&Number.isFinite(o[4].value))s=a[4].value;else if(Number.isFinite(a[4].value)&&!Number.isFinite(o[4].value))switch(t){case`down`:s=a[4].value<0?-1/0:Object.is(-0,0*a[4].value)?-0:0;break;case`up`:s=a[4].value>0?1/0:Object.is(0,0*a[4].value)?0:-0;break;default:s=Object.is(0,0*a[4].value)?0:-0}else switch(t){case`down`:s=Math.floor(a[4].value/o[4].value)*o[4].value;break;case`up`:s=Math.ceil(a[4].value/o[4].value)*o[4].value;break;case`to-zero`:s=Math.trunc(a[4].value/o[4].value)*o[4].value;break;default:{let n=Math.floor(a[4].value/o[4].value)*o[4].value,r=Math.ceil(a[4].value/o[4].value)*o[4].value;if(n>r){let e=n;n=r,r=e}let c=Math.abs(a[4].value-n),l=Math.abs(a[4].value-r);if(s=t===`line-width`&&a[4].value>=0&&(r===0||n===0)?r===0?n:r:c===l?r:c<l?n:r,t===`line-width`){let t=qc(Zc(e,a,s),i);return t===-1?-1:vl(e,t.value,i)}break}}else s=NaN;return Zc(e,a,s)}function bl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:el(e,Math.sign(r[4].value))}function xl(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value;if(H(n))switch(wc(n[4].unit)){case`rad`:break;case`deg`:r=Dc.get(`rad`)(n[4].value);break;case`grad`:r=Oc.get(`rad`)(n[4].value);break;case`turn`:r=Bc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),el(e,r)}function Sl(e,t){let n=t.value;return W(n)?el(e,Math.sqrt(n[4].value)):-1}function Cl(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(wc(n[4].unit)){case`rad`:i=Rc.get(`deg`)(r);break;case`deg`:i=r,a=Dc.get(`rad`)(r);break;case`grad`:i=Oc.get(`deg`)(r),a=Oc.get(`rad`)(r);break;case`turn`:i=Bc.get(`deg`)(r),a=Bc.get(`rad`)(r);break;default:return-1}let o=i/90;return a=i%90==0&&o%2!=0?o>0?1/0:-1/0:Math.tan(a),el(e,a)}function wl(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value-r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Hc(n,r),wc(n[4].unit)===wc(r[4].unit))){let e=n[4].value-r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new xc(Sc.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Tl(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?el(e,Math.log(r[4].value)):-1}if(t.length===2){let n=t[0];if(!n||!q(n))return-1;let r=n.value;if(!W(r))return-1;let i=t[1];if(!i||!q(i))return-1;let a=i.value;return W(a)?el(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const El=/^none$/i;function Dl(e){if(Array.isArray(e)){let t=e.filter(e=>!(gc(e)&&_c(e)));return t.length===1&&Dl(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&El.test(t[4].value)}const Ol=String.fromCodePoint(0);function kl(e,t,n,r,i,a){if(t.fixed===-1&&!a.randomCaching)return-1;a.randomCaching||={propertyName:``,propertyN:0,elementID:``,documentID:``},a.randomCaching&&!a.randomCaching.propertyN&&(a.randomCaching.propertyN=0);let o=n.value;if(!V(o))return-1;let s=Hc(o,r.value);if(!ol(o,s))return-1;let c=null;if(i&&(c=Hc(o,i.value),!ol(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return Zc(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return Zc(e,o,o[4].value);let l=t.fixed===-1?Al(jl([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(Ol))):()=>t.fixed,u=o[4].value,d=s[4].value;if(u>d&&([u,d]=[d,u]),c&&(c[4].value<=0||Math.abs(u-d)/c[4].value>1e10)&&(c=null),c){let t=Math.max(c[4].value/1e3,1e-9),n=[u],r=0;for(;;){r+=c[4].value;let e=u+r;if(!(e+t<d)){n.push(d);break}if(n.push(e),e+c[4].value-t>d)break}let i=l();return Zc(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return Zc(e,o,Number((f*(d-u)+u).toFixed(5)))}function Al(e=.34944106645296036,t=.19228640875738723,n=.8784393832007205,r=.04850964319275053){return()=>{let i=((e|=0)+(t|=0)|0)+(r|=0)|0;return r=r+1|0,e=t^t>>>9,t=(n|=0)+(n<<3)|0,n=(n=n<<21|n>>>11)+i|0,(i>>>0)/4294967296}}function jl(e){let t,n,r=0;r^=-1;for(let i=0,a=e.length;i<a;i++)n=255&(r^e.charCodeAt(i)),t=Number(`0x`+`00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D`.substring(9*n,9*n+8)),r=r>>>8^t;return(-1^r)>>>0}const Ml=new Map([[`abs`,function(e,t,n){return Pl(e,t,n,cl)}],[`acos`,function(e,t,n){return Pl(e,t,n,tl)}],[`asin`,function(e,t,n){return Pl(e,t,n,nl)}],[`atan`,function(e,t,n){return Pl(e,t,n,rl)}],[`atan2`,function(e,t,n){return Il(e,t,n,sl)}],[`calc`,Nl],[`clamp`,function(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&oo(n.value)){if(e===o)return-1;if(e===a){e=o;continue}if(e===i){e=a;continue}return-1}e.push(n)}}let s=Dl(i),c=Dl(o);if(s&&c)return Nl(Hl(e,a),t,n);let l=qc(Nl(Hl(e,a),t,n),n);if(l===-1)return-1;if(s){let r=qc(Nl(Hl(e,o),t,n),n);return r===-1?-1:ml((u=e,d=l,f=r,new tc([z.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[z.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([z.Comma,`,`,...yc(d),void 0]),f])),[l,r],n)}if(c){let r=qc(Nl(Hl(e,i),t,n),n);return r===-1?-1:pl(Ul(e,r,l),[r,l],n)}var u,d,f;let p=qc(Nl(Hl(e,i),t,n),n);if(p===-1)return-1;let m=qc(Nl(Hl(e,o),t,n),n);return m===-1?-1:ll(e,p,l,m,n)}],[`cos`,function(e,t,n){return Pl(e,t,n,ul)}],[`exp`,function(e,t,n){return Pl(e,t,n,dl)}],[`hypot`,function(e,t,n){return Rl(e,t,n,fl)}],[`log`,function(e,t,n){return Rl(e,t,n,Tl)}],[`max`,function(e,t,n){return Rl(e,t,n,pl)}],[`min`,function(e,t,n){return Rl(e,t,n,ml)}],[`mod`,function(e,t,n){return Il(e,t,n,hl)}],[`pow`,function(e,t,n){return Il(e,t,n,gl)}],[`random`,function(e,t,n){let r=Vl(e,e.value.filter(e=>!vc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=zl(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:kl(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Il(e,t,n,_l)}],[`round`,function(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t),i=``,a=!1,o=[],s=[];{let e=o;for(let t=0;t<r.length;t++){let n=r[t];if(!i&&o.length===0&&s.length===0&&q(n)&&U(n.value)){let e=n.value[4].value.toLowerCase();if(Bl.has(e)){i=e;continue}}if(q(n)&&oo(n.value)){if(e===s)return-1;if(e===o&&i&&o.length===0)continue;if(e===o){a=!0,e=s;continue}return-1}e.push(n)}}let c=qc(Nl(Hl(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Hc([z.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:B.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return vl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=qc(Nl(Hl(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,yl(e,i,c,l,n))}],[`sign`,function(e,t,n){return Pl(e,t,n,bl)}],[`sin`,function(e,t,n){return Pl(e,t,n,xl)}],[`sqrt`,function(e,t,n){return Pl(e,t,n,Sl)}],[`tan`,function(e,t,n){return Pl(e,t,n,Cl)}]]);function Nl(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:Xc};let i=0;for(;i<r.length;){let e=r[i];if(mc(e)&&ho(e.startToken)){let a=Nl(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(hc(e)){let a=Ml.get(e.getName().toLowerCase());if(!a)return-1;let o=a(e,t,n);if(o===-1)return-1;r.splice(i,1,o);continue}i++}if(i=0,r.length===1&&Kc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Kc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!co(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Kc(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:Jc}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:Gc}):i++}if(i=0,r.length===1&&Kc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Kc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!co(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Kc(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Wc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:wl}):i++}return r.length===1&&Kc(r[0])?r[0]:-1}function Pl(e,t,n,r){let i=Fl(e,t,n);return i===-1?-1:r(e,i,n)}function Fl(e,t,n){let r=qc(Nl(Hl(e,Yc([...e.value.filter(e=>!vc(e))],t)),t,n),n);return r===-1?-1:r}function Il(e,t,n,r){let i=Ll(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Ll(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&oo(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=qc(Nl(Hl(e,i),t,n),n);if(o===-1)return-1;let s=qc(Nl(Hl(e,a),t,n),n);return s===-1?-1:[o,s]}function Rl(e,t,n,r){let i=zl(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function zl(e,t,n,r){let i=Yc([...t.filter(e=>!vc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&oo(n.value)?(t.push(o),o=[]):o.push(n)}t.push(o);for(let i=0;i<t.length;i++){if(t[i].length===0)return-1;let o=qc(Nl(Hl(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const Bl=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function Vl(e,t,n,r){let i={isAuto:!1,dashedIdent:``,fixed:-1,elementShared:!1},a=t[0];if(!q(a)||!U(a.value))return[i,t];for(let a=0;a<t.length;a++){let o=t[a];if(!q(o))return-1;if(oo(o.value))return[i,t.slice(a+1)];if(!U(o.value))return-1;let s=o.value[4].value.toLowerCase();if(s!==`element-shared`){if(s===`fixed`){if(i.elementShared||i.dashedIdent||i.isAuto)return-1;a++;let o=t[a];if(!o)return-1;let s=qc(Nl(Hl(e,[o]),n,r),r);if(s===-1||!W(s.value)||s.value[4].value<0||s.value[4].value>1)return-1;i.fixed=Math.max(0,Math.min(s.value[4].value,.999999999));continue}if(s!==`auto`){if(s.startsWith(`--`)){if(i.fixed!==-1||i.isAuto)return-1;i.dashedIdent=s}}else{if(i.fixed!==-1||i.dashedIdent)return-1;i.isAuto=!0}}else{if(i.fixed!==-1)return-1;i.elementShared=!0}}return-1}function Hl(e,t){return new tc([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function Ul(e,t,n){return new tc([z.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([z.Comma,`,`,...yc(t),void 0]),n])}function Wl(e){if(e===-1)return-1;if(hc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):G(t)?new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Gl(e){if(e===-1)return-1;if(hc(e))return e;let t=e.value;if(!V(t)||Number.isFinite(t[4].value)||Number.isNaN(t[4].value))return e;let n=``;return t[4].value===-1/0&&(n=`-`),W(t)?new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):new tc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function Kl(e){if(e===-1)return-1;if(hc(e))return e;let t=e.value;return V(t)&&Object.is(-0,t[4].value)&&(t[1]===`-0`||(G(t)?t[1]=`-0%`:H(t)?t[1]=`-0`+t[4].unit:t[1]=`-0`)),e}function ql(e,t=13){if(e===-1)return-1;if(t<=0||hc(e))return e;let n=e.value;if(!V(n)||Number.isInteger(n[4].value))return e;let r=Number(n[4].value.toFixed(t)).toString();return W(n)?n[1]=r:G(n)?n[1]=r+`%`:H(n)&&(n[1]=r+n[4].unit),e}function Jl(e){return e===-1?-1:(hc(e)||H(e.value)&&(e.value=Uc(e.value)),e)}function Yl(e,t){let n=e;return t?.toCanonicalUnits&&(n=Jl(n)),n=ql(n,t?.precision),n=Kl(n),t?.censorIntoStandardRepresentableValues||(n=Wl(n),n=Gl(n)),n}function Xl(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(ro(r))t.set(n,r);else if(typeof r==`string`){let e=Xa({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function Zl(e,t){let n=Xl(t?.globals);return Ql(e,e=>{if(!hc(e))return;let r=Ml.get(e.getName().toLowerCase());if(!r)return;let i=Yl(qc(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function Ql(e,t){for(let n=0;n<e.length;n++){let r=e[n];fc(r,(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);if(!r)return;let i=[r],a=e.parent.value[n-1];q(a)&&co(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new ac([[z.Whitespace,` `,...yc(e.node),void 0]]));let o=e.parent.value[n+1];!o||vc(o)||q(o)&&(oo(o.value)||ao(o.value)||po(o.value)||co(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new ac([[z.Whitespace,` `,...yc(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const $l=new Set(Ml.keys());var J,Y;function eu(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function tu(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:hs(eu(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:ks(eu(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Ns(eu(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Fs(eu(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Ls(eu(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:js(eu(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:zs(eu(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:_s(eu(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:ys(eu(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:xs(eu(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Ts(eu(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:Cs(eu(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Ds(eu(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:Us(eu(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:Vs(eu(e.channels))};default:throw Error(`Unsupported color notation`)}}(function(e){e.A98_RGB=`a98-rgb`,e.Display_P3=`display-p3`,e.Linear_Display_P3=`display-p3-linear`,e.HEX=`hex`,e.HSL=`hsl`,e.HWB=`hwb`,e.LCH=`lch`,e.Lab=`lab`,e.Linear_sRGB=`srgb-linear`,e.OKLCH=`oklch`,e.OKLab=`oklab`,e.ProPhoto_RGB=`prophoto-rgb`,e.RGB=`rgb`,e.sRGB=`srgb`,e.Rec2020=`rec2020`,e.XYZ_D50=`xyz-d50`,e.XYZ_D65=`xyz-d65`})(J||={}),function(e){e.ColorKeyword=`color-keyword`,e.HasAlpha=`has-alpha`,e.HasDimensionValues=`has-dimension-values`,e.HasNoneKeywords=`has-none-keywords`,e.HasNumberValues=`has-number-values`,e.HasPercentageAlpha=`has-percentage-alpha`,e.HasPercentageValues=`has-percentage-values`,e.HasVariableAlpha=`has-variable-alpha`,e.Hex=`hex`,e.LegacyHSL=`legacy-hsl`,e.LegacyRGB=`legacy-rgb`,e.NamedColor=`named-color`,e.RelativeColorSyntax=`relative-color-syntax`,e.ColorMix=`color-mix`,e.ColorMixVariadic=`color-mix-variadic`,e.ContrastColor=`contrast-color`,e.RelativeAlphaSyntax=`relative-alpha-syntax`,e.Experimental=`experimental`}(Y||={});const nu=new Set([J.A98_RGB,J.Display_P3,J.Linear_Display_P3,J.HEX,J.Linear_sRGB,J.ProPhoto_RGB,J.RGB,J.sRGB,J.Rec2020,J.XYZ_D50,J.XYZ_D65]);function ru(e,t){let n={...e};if(e.colorNotation!==t){let e=tu(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=gs(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=gs(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=As(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Ps(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Is(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=Rs(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=Bs(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=Ms(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=vs(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=bs(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Ss(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=ws(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Os(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Es(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=Us(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Hs(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=eu(e.channels);if(t===e.colorNotation)n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(nu.has(t)&&nu.has(e.colorNotation))n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=au(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}return n.channels=iu(n.channels,t),n}function iu(e,t){let n=[...e];switch(t){case J.HSL:!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=NaN);break;case J.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=NaN);break;case J.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=NaN);break;case J.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=NaN)}return n}function au(e,t,n,r,i,a){if(t.length<3&&e.every(Number.isNaN))return[NaN,NaN,NaN];let o=[...r];for(let n=0;n<t.length;n++)Number.isNaN(e[t[n]])&&(o[i[n]]=NaN);if(n.length&&n.every(t=>Number.isNaN(e[t])))for(let e=0;e<a.length;e++)o[a[e]]=NaN;return o}function ou(e){let t=new Map;switch(e.colorNotation){case J.RGB:case J.HEX:t.set(`r`,X(255*e.channels[0])),t.set(`g`,X(255*e.channels[1])),t.set(`b`,X(255*e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HSL:t.set(`h`,X(e.channels[0])),t.set(`s`,X(e.channels[1])),t.set(`l`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HWB:t.set(`h`,X(e.channels[0])),t.set(`w`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.Lab:case J.OKLab:t.set(`l`,X(e.channels[0])),t.set(`a`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.LCH:case J.OKLCH:t.set(`l`,X(e.channels[0])),t.set(`c`,X(e.channels[1])),t.set(`h`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.sRGB:case J.A98_RGB:case J.Display_P3:case J.Linear_Display_P3:case J.Rec2020:case J.Linear_sRGB:case J.ProPhoto_RGB:t.set(`r`,X(e.channels[0])),t.set(`g`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.XYZ_D50:case J.XYZ_D65:t.set(`x`,X(e.channels[0])),t.set(`y`,X(e.channels[1])),t.set(`z`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha))}return t}function su(e){let t=new Map(e);for(let[n,r]of e)Number.isNaN(r[4].value)&&t.set(n,X(0));return t}function X(e){return Number.isNaN(e)?[z.Number,`none`,-1,-1,{value:NaN,type:B.Number}]:[z.Number,e.toString(),-1,-1,{value:e,type:B.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const cu=/[A-Z]/g;function Q(e){return e.replace(cu,e=>String.fromCharCode(e.charCodeAt(0)+32))}function lu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}const uu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function du(e,t){let n=[],r=[],i=[],a=[],o,s,c=!1,l=!1,u={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])},d=n;for(let f=0;f<e.value.length;f++){let p=e.value[f];if(gc(p)||_c(p))for(;gc(e.value[f+1])||_c(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&co(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(hc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!$l.has(Q(p.getName())))return!1;let[[e]]=Zl([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),p=e}if(d===n&&n.length===0&&q(p)&&U(p.value)&&uu.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=fu(c),l&&(l.colorNotation!==u.colorNotation&&(l=ru(l,u.colorNotation)),o=ou(l),s=su(o))}else if(d===n&&n.length===0&&q(p)&&U(p.value)&&Q(p.value[4].value)===`from`){if(l||c)return!1;for(;gc(e.value[f+1])||_c(e.value[f+1]);)f++;if(f++,p=e.value[f],l=t(p),!1===l)return!1;l.syntaxFlags.has(Y.Experimental)&&u.syntaxFlags.add(Y.Experimental),u.syntaxFlags.add(Y.RelativeColorSyntax)}else{if(!q(p))return!1;if(U(p.value)&&o&&o.has(Q(p.value[4].value))){d.push(new K(o.get(Q(p.value[4].value))));continue}d.push(p)}}}if(!c||d.length!==1||n.length!==1||r.length!==1||i.length!==1||!q(n[0])||!q(r[0])||!q(i[0])||o&&!o.has(`alpha`))return!1;let f=lu(n[0].value,0,u);if(!f||!W(f))return!1;let p=lu(r[0].value,1,u);if(!p||!W(p))return!1;let m=lu(i[0].value,2,u);if(!m||!W(m))return!1;let h=[f,p,m];if(a.length===1)if(u.syntaxFlags.add(Y.HasAlpha),q(a[0])){let e=lu(a[0].value,3,u);if(!e||!W(e))return!1;h.push(e)}else u.alpha=a[0];else if(o&&o.has(`alpha`)){let e=lu(o.get(`alpha`),3,u);if(!e||!W(e))return!1;h.push(e)}return u.channels=[h[0][4].value,h[1][4].value,h[2][4].value],h.length===4&&(u.alpha=h[3][4].value),u}function fu(e){switch(e){case`srgb`:return J.sRGB;case`srgb-linear`:return J.Linear_sRGB;case`display-p3`:return J.Display_P3;case`display-p3-linear`:return J.Linear_Display_P3;case`a98-rgb`:return J.A98_RGB;case`prophoto-rgb`:return J.ProPhoto_RGB;case`rec2020`:return J.Rec2020;case`xyz`:case`xyz-d65`:return J.XYZ_D65;case`xyz-d50`:return J.XYZ_D50;default:throw Error(`Unknown color space name: `+e)}}const pu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),mu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),hu=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function gu(e,t){let n=null,r=null,i=null,a=!1;for(let o=0;o<e.value.length;o++){let s=e.value[o];if(!vc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return vu(`oklab`,_u(e.value,t));if(q(s)&&U(s.value)){if(!n&&Q(s.value[4].value)===`in`){n=s;continue}if(n&&!r){r=Q(s.value[4].value);continue}if(n&&r&&!i&&mu.has(r)){i=Q(s.value[4].value);continue}if(n&&r&&i&&!a&&Q(s.value[4].value)===`hue`){a=!0;continue}return!1}return!(!q(s)||!oo(s.value))&&!!r&&(i||a?!!(i&&a&&mu.has(r)&&hu.has(i))&&bu(r,i,_u(e.value.slice(o+1),t)):pu.has(r)?vu(r,_u(e.value.slice(o+1),t)):!!mu.has(r)&&bu(r,`shorter`,_u(e.value.slice(o+1),t)))}}return!1}function _u(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!vc(o)){if(!q(o)||!oo(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(hc(o)&&$l.has(Q(o.getName()))){if([[o]]=Zl([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!V(o.value))return!1;Number.isNaN(o.value[4].value)&&(o.value[4].value=0)}if(q(o)&&G(o.value)&&o.value[4].value>=0){i=o.value[4].value;continue}}return!1}if(!r)return!1;n.push({color:r,percentage:i}),r=!1,i=!1}}return!!r&&(n.push({color:r,percentage:i}),n)}function vu(e,t){if(!t||!t.length)return!1;for(let e of t)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:n,leftover:r}=Eu(t,!0),i=1-r/100,a;switch(e){case`srgb`:a=J.RGB;break;case`srgb-linear`:a=J.Linear_sRGB;break;case`display-p3`:a=J.Display_P3;break;case`display-p3-linear`:a=J.Linear_Display_P3;break;case`a98-rgb`:a=J.A98_RGB;break;case`prophoto-rgb`:a=J.ProPhoto_RGB;break;case`rec2020`:a=J.Rec2020;break;case`lab`:a=J.Lab;break;case`oklab`:a=J.OKLab;break;case`xyz-d50`:a=J.XYZ_D50;break;case`xyz`:case`xyz-d65`:a=J.XYZ_D65;break;default:return!1}if(n.length===1){let e=ru(n[0].color,a);return e.colorNotation=a,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=i,e):!1}for(n.reverse();n.length>=2;){let e=n.pop(),t=n.pop();if(!e||!t)return!1;let r=e.percentage+t.percentage,i=r>0?t.percentage/r:.5,o=yu(a,e.color,t.color,i);if(!o)return!1;n.push({color:o,percentage:r})}let o=n[0]?.color;return!!o&&typeof o.alpha==`number`&&(o.alpha*=i,t.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&o.syntaxFlags.add(Y.Experimental),t.length!==2&&o.syntaxFlags.add(Y.ColorMixVariadic),o)}function yu(e,t,n,r){let i=t.alpha;if(typeof i!=`number`)return!1;let a=n.alpha;if(typeof a!=`number`)return!1;i=Number.isNaN(i)?a:i,a=Number.isNaN(a)?i:a;let o=ru(t,e).channels,s=ru(n,e).channels;o[0]=Su(o[0],s[0]),s[0]=Su(s[0],o[0]),o[1]=Su(o[1],s[1]),s[1]=Su(s[1],o[1]),o[2]=Su(o[2],s[2]),s[2]=Su(s[2],o[2]),o[0]=wu(o[0],i),o[1]=wu(o[1],i),o[2]=wu(o[2],i),s[0]=wu(s[0],a),s[1]=wu(s[1],a),s[2]=wu(s[2],a);let c=Cu(i,a,r);return{colorNotation:e,channels:[Tu(Cu(o[0],s[0],r),c),Tu(Cu(o[1],s[1],r),c),Tu(Cu(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function bu(e,t,n){if(!n||!n.length)return!1;for(let e of n)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:r,leftover:i}=Eu(n,!0),a=1-i/100,o;switch(e){case`hsl`:o=J.HSL;break;case`hwb`:o=J.HWB;break;case`lch`:o=J.LCH;break;case`oklch`:o=J.OKLCH;break;default:return!1}if(r.length===1){let e=ru(r[0].color,o);return e.colorNotation=o,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=a,e):!1}for(r.reverse();r.length>=2;){let e=r.pop(),n=r.pop();if(!e||!n)return!1;let i=e.percentage+n.percentage,a=i>0?n.percentage/i:.5,s=xu(o,t,e.color,n.color,a);if(!s)return!1;r.push({color:s,percentage:i})}let s=r[0]?.color;return!!s&&typeof s.alpha==`number`&&(s.alpha*=a,n.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&s.syntaxFlags.add(Y.Experimental),n.length!==2&&s.syntaxFlags.add(Y.ColorMixVariadic),s)}function xu(e,t,n,r,i){let a=0,o=0,s=0,c=0,l=0,u=0,d=n.alpha;if(typeof d!=`number`)return!1;let f=r.alpha;if(typeof f!=`number`)return!1;d=Number.isNaN(d)?f:d,f=Number.isNaN(f)?d:f;let p=ru(n,e).channels,m=ru(r,e).channels;switch(e){case J.HSL:case J.HWB:a=p[0],o=m[0],s=p[1],c=m[1],l=p[2],u=m[2];break;case J.LCH:case J.OKLCH:s=p[0],c=m[0],l=p[1],u=m[1],a=p[2],o=m[2]}a=Su(a,o),Number.isNaN(a)&&(a=0),o=Su(o,a),Number.isNaN(o)&&(o=0),s=Su(s,c),c=Su(c,s),l=Su(l,u),u=Su(u,l);let h=o-a;switch(t){case`shorter`:h>180?a+=360:h<-180&&(o+=360);break;case`longer`:-180<h&&h<180&&(h>0?a+=360:o+=360);break;case`increasing`:h<0&&(o+=360);break;case`decreasing`:h>0&&(a+=360);break;default:throw Error(`Unknown hue interpolation method`)}s=wu(s,d),l=wu(l,d),c=wu(c,f),u=wu(u,f);let g=[0,0,0],_=Cu(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Cu(a,o,i),Tu(Cu(s,c,i),_),Tu(Cu(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Tu(Cu(s,c,i),_),Tu(Cu(l,u,i),_),Cu(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function Su(e,t){return Number.isNaN(e)?t:e}function Cu(e,t,n){return e*(1-n)+t*n}function wu(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Tu(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Eu(e,t=!1){let n=0,r=0;for(let t of e)t.percentage&&(n+=t.percentage),!1===t.percentage&&r++;n=Math.min(100,n);for(let t of e)!1===t.percentage&&(t.percentage=(100-n)/r);let i=e.slice(),a=0;for(let e of i)a+=e.percentage;if(a>100||a>0&&t)for(let e of i)e.percentage*=100/a;let o=0;return a<100&&(o=100-a),{items:i,leftover:o}}function Du(e){let t=Q(e[4].value);if(t.match(/[^a-f0-9]/))return!1;let n={colorNotation:J.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.Hex])},r=t.length;if(r===3){let e=t[0],r=t[1],i=t[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n}if(r===6){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n}if(r===4){let e=t[0],r=t[1],i=t[2],a=t[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n.alpha=parseInt(a+a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}if(r===8){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5],a=t[6]+t[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n.alpha=parseInt(a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}return!1}function Ou(e){if(W(e))return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(H(e)){let t=e[4].value;switch(Q(e[4].unit)){case`deg`:break;case`rad`:t=180*e[4].value/Math.PI;break;case`grad`:t=.9*e[4].value;break;case`turn`:t=360*e[4].value;break;default:return!1}return t%=360,[z.Number,t.toString(),e[2],e[3],{value:t,type:B.Number}]}return!1}function ku(e,t,n){if(t===0){let t=Ou(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){if(t!==3)return!1;let n=Z(e[4].value,1,0,100);return t===3&&(n=Z(e[4].value,1,0,1)),[z.Number,n.toString(),e[2],e[3],{value:n,type:B.Number}]}return!1}function Au(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Ou(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3?r=Z(e[4].value,100,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3?r=Z(e[4].value,1,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function ju(e,t,n,r){let i=[],a=[],o=[],s=[],c={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},l=i;for(let t=0;t<e.value.length;t++){let n=e.value[t];if(!gc(n)&&!_c(n)){if(q(n)&&oo(n.value)){if(l===i){l=a;continue}if(l===a){l=o;continue}if(l===o){l=s;continue}if(l===s)return!1}if(hc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!$l.has(n.getName().toLowerCase()))return!1;let[[e]]=Zl([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),n=e}if(!q(n))return!1;l.push(n)}}if(l.length!==1||i.length!==1||a.length!==1||o.length!==1||!q(i[0])||!q(a[0])||!q(o[0]))return!1;let u=t(i[0].value,0,c);if(!u||!W(u))return!1;let d=t(a[0].value,1,c);if(!d||!W(d))return!1;let f=t(o[0].value,2,c);if(!f||!W(f))return!1;let p=[u,d,f];if(s.length===1)if(c.syntaxFlags.add(Y.HasAlpha),q(s[0])){let e=t(s[0].value,3,c);if(!e||!W(e))return!1;p.push(e)}else c.alpha=s[0];return c.channels=[p[0][4].value,p[1][4].value,p[2][4].value],p.length===4&&(c.alpha=p[3][4].value),c}function Mu(e,t,n,r,i){let a=[],o=[],s=[],c=[],l,u,d=!1,f={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},p=a;for(let t=0;t<e.value.length;t++){let r=e.value[t];if(gc(r)||_c(r))for(;gc(e.value[t+1])||_c(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&co(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(hc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!$l.has(r.getName().toLowerCase()))return!1;let[[e]]=Zl([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),r=e}if(p===a&&a.length===0&&q(r)&&U(r.value)&&r.value[4].value.toLowerCase()===`from`){if(d)return!1;for(;gc(e.value[t+1])||_c(e.value[t+1]);)t++;if(t++,r=e.value[t],d=i(r),!1===d)return!1;d.syntaxFlags.has(Y.Experimental)&&f.syntaxFlags.add(Y.Experimental),f.syntaxFlags.add(Y.RelativeColorSyntax),d.colorNotation!==n&&(d=ru(d,n)),l=ou(d),u=su(l)}else{if(!q(r))return!1;if(U(r.value)&&l){let e=r.value[4].value.toLowerCase();if(l.has(e)){p.push(new K(l.get(e)));continue}}p.push(r)}}}if(p.length!==1||a.length!==1||o.length!==1||s.length!==1||!q(a[0])||!q(o[0])||!q(s[0])||l&&!l.has(`alpha`))return!1;let m=t(a[0].value,0,f);if(!m||!W(m))return!1;let h=t(o[0].value,1,f);if(!h||!W(h))return!1;let g=t(s[0].value,2,f);if(!g||!W(g))return!1;let _=[m,h,g];if(c.length===1)if(f.syntaxFlags.add(Y.HasAlpha),q(c[0])){let e=t(c[0].value,3,f);if(!e||!W(e))return!1;_.push(e)}else f.alpha=c[0];else if(l&&l.has(`alpha`)){let e=t(l.get(`alpha`),3,f);if(!e||!W(e))return!1;_.push(e)}return f.channels=[_[0][4].value,_[1][4].value,_[2][4].value],_.length===4&&(f.alpha=_[3][4].value),f}function Nu(e,t){if(e.value.some(e=>q(e)&&oo(e.value))){let t=Pu(e);if(!1!==t)return t}{let n=Fu(e,t);if(!1!==n)return n}return!1}function Pu(e){return ju(e,ku,J.HSL,[Y.LegacyHSL])}function Fu(e,t){return Mu(e,Au,J.HSL,[],t)}function Iu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Ou(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Lu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,.8,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ru(e,t){return Mu(e,Lu,J.Lab,[],t)}function zu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Ou(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,100/150,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Bu(e,t){return Mu(e,zu,J.LCH,[],t)}const Vu=new Map;for(let[e,t]of Object.entries(Js))Vu.set(e,t);function Hu(e){let t=Vu.get(Q(e));return!!t&&{colorNotation:J.RGB,channels:[t[0]/255,t[1]/255,t[2]/255],alpha:1,syntaxFlags:new Set([Y.ColorKeyword,Y.NamedColor])}}function Uu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1||t===2?r=Z(e[4].value,250,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Wu(e,t){return Mu(e,Uu,J.OKLab,[],t)}function Gu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Ou(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1?r=Z(e[4].value,250,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ku(e,t){return Mu(e,Gu,J.OKLCH,[],t)}function qu(e,t,n){if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,0,1);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ju(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Yu(e,t){if(e.value.some(e=>q(e)&&oo(e.value))){let t=Xu(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=Zu(e,t);if(!1!==n)return n}return!1}function Xu(e){return ju(e,qu,J.RGB,[Y.LegacyRGB])}function Zu(e,t){return Mu(e,Ju,J.RGB,[],t)}function Qu(e){let t=gs(e);if(Ws(t))return Gs(t);let n=e;return n=Os(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Yo(Ks(n,$u,ed))}function $u(e){return e=jo(e),e=Fo(e),qo(e)}function ed(e){return e=fs(e),e=Bo(e),Mo(e)}function td(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!gc(i)&&!_c(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=eu(n.channels),n.channels=Qu(tu(n).channels),n.colorNotation=J.sRGB;let r={colorNotation:J.RGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.ContrastColor,Y.Experimental])};return r.channels=Xs(n.channels,[1,1,1])>Xs(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function nd(e,t){let n,r,i=!1,a=!1,o=!1,s={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let c=0;c<e.value.length;c++){let l=e.value[c];if(gc(l)||_c(l))for(;gc(e.value[c+1])||_c(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&co(l.value)&&l.value[4].value===`/`)i=!0;else{if(hc(l)&&$l.has(Q(l.getName()))){let[[e]]=Zl([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),l=e}if(i||a||!q(l)||!U(l.value)||Q(l.value[4].value)!==`from`){if(!i||a)return!1;if(q(l)){if(U(l.value)&&Q(l.value[4].value)===`alpha`&&n&&n.has(`alpha`)){s.alpha=n.get(`alpha`)[4].value,a=!0;continue}let e=lu(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(hc(l)){s.alpha=pc([[l]],e=>{if(q(e)&&U(e.value)&&Q(e.value[4].value)===`alpha`&&n&&n.has(`alpha`))return new K(n.get(`alpha`))})[0][0],a=!0;continue}return!1}if(o)return!1;for(;gc(e.value[c+1])||_c(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=ou(o),r=su(n),s.syntaxFlags=new Set(o.syntaxFlags),s.syntaxFlags.add(Y.RelativeAlphaSyntax),s.channels=[...o.channels],s.colorNotation=o.colorNotation,s.alpha=o.alpha}}return!!n&&s}function rd(e){if(hc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return Yu(e,rd);case`hsl`:case`hsla`:return Nu(e,rd);case`hwb`:return t=rd,Mu(e,Iu,J.HWB,[],t);case`lab`:return Ru(e,rd);case`lch`:return Bu(e,rd);case`oklab`:return Wu(e,rd);case`oklch`:return Ku(e,rd);case`color`:return du(e,rd);case`color-mix`:return gu(e,rd);case`contrast-color`:return td(e,rd);case`alpha`:return nd(e,rd)}var t;if(q(e)){if(fo(e.value))return Du(e.value);if(U(e.value)){let t=Hu(e.value[4].value);return!1===t?Q(e.value[4].value)===`transparent`&&{colorNotation:J.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([Y.ColorKeyword])}:t}}return!1}function id(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function ad(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:hs(id(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:ks(id(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:Ns(id(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:Fs(id(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Ls(id(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:js(id(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:zs(id(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:_s(id(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:ys(id(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:xs(id(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Ts(id(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:Cs(id(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Ds(id(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:Us(id(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:Vs(id(e.channels))};default:throw Error(`Unsupported color notation`)}}function od(e,t=7){e=+e,t=+t;let n=(Math.floor(Math.abs(e))+``).length;if(t>n)return+e.toFixed(t-n);{let r=10**(n-t);return Math.round(e/r)*r}}function sd(e){let t=gs(e);if(Ws(t))return Gs(t);let n=e;return n=Os(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Yo(Ks(n,cd,ld))}function cd(e){return e=jo(e),e=Fo(e),qo(e)}function ld(e){return e=fs(e),e=Bo(e),Mo(e)}var ud=class e{static colorTxtList=[];static parseColorString(e){try{let t=uc(Ya({css:e}));if(!t)return null;let n=rd(t);if(n===!1)return null;let r=sd(ad(n).channels),i=Math.min(255,Math.max(0,Math.round(od(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(od(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(od(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,od(Number.isNaN(n.alpha)?0:n.alpha)))),m.Color.create(i/255,a/255,o/255,s)}catch(e){return $.error(e),null}}static getPos(e,t){let n=Array.from(e.slice(0,t).matchAll(/\n/g)),r=n.length,i=n[r-1],a=0;i.index&&(a=i.index);let o=t-a;return m.Position.create(r,o-1)}static getMatches(e){let t=[],n=e.matchAll(/(#(?:[\da-f]{3,4}){2}|#(?:[\da-f]{3})|rgb\((?:\d{1,3},\s*){2}\d{1,3}\)|rgba\((?:\d{1,3},\s*){3}\d*\.?\d+\)|hsl\(\d{1,3}(?:,\s*\d{1,3}%){2}\)|hsla\(\d{1,3}(?:,\s*\d{1,3}%){2},\s*\d*\.?\d+\|oklab\(\s*\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*\)|oklch\(\s*\d*\.?\d+%?\s*(,| )\s*\d*\.?\d+\s*(,| )\s*\d*\.?\d+\s*\))/gi);if(n)for(let r of n){let n=r[0];if(!r.index)continue;let i=n.length,a=``;n.startsWith(`hsl(`)?a=`hsl`:n.startsWith(`hsla(`)?a=`hsla`:n.startsWith(`rgb(`)?a=`rgb`:n.startsWith(`rgba(`)?a=`rgba`:n.startsWith(`#`)?a=`hex`:n.startsWith(`oklch(`)?a=`oklch`:n.startsWith(`oklab(`)&&(a=`oklab`);let o=m.Range.create(this.getPos(e,r.index),this.getPos(e,r.index+n.length)),s=this.parseColorString(n);s&&t.push({color:s,type:a,length:i,range:o})}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(sa.Colors),t=[];for(let n of e)n!=`name`&&n!=`length`&&n!=`prototype`&&t.push(n);this.colorTxtList=t}let r=RegExp(`(?<![\\w\\d."'&$-])(`+this.colorTxtList.join(`|`)+`)(?![-\\w\\d])`,`gi`),i=e.matchAll(r);if(i)for(let n of i){let r=n[0];if(!n.index)continue;let i=r.length,a=m.Range.create(this.getPos(e,n.index),this.getPos(e,n.index+r.length)),o=this.parseColorString(sa.fromName(r).toHex());o&&t.push({color:o,type:`hex`,length:i,range:a})}return t}static onDocumentColor(t){return e.getMatches(t.getText()).map(e=>m.ColorInformation.create(e.range,e.color))}static onColorPresentations(e,t,n){let r=sa.fromRgb(n.red*255,n.green*255,n.blue*255);r.alpha=n.alpha;let i=e.getText(t),a=m.ColorPresentation.create(r.toString(`hex`)),o=m.ColorPresentation.create(r.toString(`hexa`)),s=m.ColorPresentation.create(r.toString(`hsl`)),c=m.ColorPresentation.create(r.toString(`hsla`)),l=m.ColorPresentation.create(r.toString(`rgb`)),u=m.ColorPresentation.create(r.toString(`rgba`)),d=!1;return i.startsWith(`#`)&&i.length===9&&(d=!0),i.startsWith(`hsla`)&&(d=!0),i.startsWith(`rgba`)&&(d=!0),n.alpha!==1&&(d=!0),d?[o,c,u]:[a,s,l]}},dd=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},fd=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=N.getInstance().getAllConfigFiles();for(let e of n)t.push({label:e});if(t.length>1){let n=await $.Select(t,{title:`Select a project to add section`});if(!n)return;e=n.label}else e=t[0].label}let t=await $.Select([{label:`Build`},{label:`Static`}],{title:`Section type`});if(!t)return;let n=(0,u.readFileSync)(I(e),`utf8`),r=JSON.parse(n);if(t.label==`Build`){let e=await $.Input({title:`Provide a name for your build section`});if(!e)return;let t={name:e,src:[],compile:{output:`./dist/`+e.replace(/ /g,`-`)+`.js`}};r.build.push(t)}else if(t.label==`Static`){let e=await $.Input({title:`Provide a name for your static section`});if(!e)return;let t={name:e,input:``,output:``};r.static.push(t)}(0,u.writeFileSync)(I(e),JSON.stringify(r,null,4)),dd.send(e)}catch(e){console.error(e)}}},pd=class{static cmd=`aventus.compile`;static async run(){let e=[],t=N.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},md=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(I(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=I(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=N.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},hd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},gd=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},_d=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},vd=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},yd=class{static cmd=`aventus.component.merge`;static async run(e){if(!e)return;let t=RegExp(`(`+w.ComponentLogic+`)|(`+w.ComponentView+`)|(`+w.ComponentView+`)$`),n=e.replace(t,``),r=n.split(`/`),i=r.pop(),a=r.pop(),o=r.join(`/`)+`/`+i,s=0,c=R.getInstance().getByUri(n+w.ComponentLogic);c&&c.versionUser>s&&(s=c.versionUser);let l=c?c.contentUser:``,f=R.getInstance().getByUri(n+w.ComponentStyle);f&&f.versionUser>s&&(s=f.versionUser);let p=f?f.contentUser:``,m=R.getInstance().getByUri(n+w.ComponentView);m&&m.versionUser>s&&(s=m.versionUser);let h=m?m.contentUser:``,g=`
989
+ */function qs(e,t,n){let r=e[0],i=e[2],a=t(e),o=t([r,0,i]);for(let e=0;e<4;e++){if(e>0){let e=n(a);e[0]=r,e[2]=i,a=t(e)}let s=Js(o,a);if(!s)break;a=s}return Ks(a)}function Js(e,t){let n=1/0,r=-1/0,i=[0,0,0];for(let a=0;a<3;a++){let o=e[a],s=t[a]-o;if(i[a]=s,Math.abs(s)>1e-15){let e=1/s,t=(0-o)*e,i=(1-o)*e;r=Math.max(Math.min(t,i),r),n=Math.min(Math.max(t,i),n)}else if(o<0||o>1)return!1}return!(r>n||n<0)&&(r<0&&(r=n),!!isFinite(r)&&[e[0]+i[0]*r,e[1]+i[1]*r,e[2]+i[2]*r])}const Ys={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Xs(e){let[t,n,r]=e.map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r}function Zs(e,t){let n=Xs(e),r=Xs(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Qs;function $s(e){let t=e.slice();return(e,n,r)=>{let i=-1;for(let a=t.indexOf(n);a<t.length&&(i=e.indexOf(t[a]),i===-1||i<r);a++);return i===-1||i===r&&n===e[r]&&(i++,i>=e.length)?-1:(t=e.slice(),i)}}function ec(e,t){let n=t[0];if(go(n)||yo(n)||vo(n)){let n=ac(e,t);return{advance:n.advance,node:n.node}}if(fo(n)){let n=rc(e,t);return{advance:n.advance,node:n.node}}if(ho(n)){let n=sc(e,t);return{advance:n.advance,node:n.node}}if(co(n)){let n=lc(e,t);return{advance:n.advance,node:n.node}}return{advance:1,node:new K(n)}}(function(e){e.Function=`function`,e.SimpleBlock=`simple-block`,e.Whitespace=`whitespace`,e.Comment=`comment`,e.Token=`token`})(Qs||={});var tc=class{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if(typeof e==`number`)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,t){if(this.value.length===0)return;let n=$s(this.value),r=0;for(;r<this.value.length;){let i=this.value[r],a;if(t&&(a={...t}),!1===e({node:i,parent:this,state:a},r))return!1;if(r=n(this.value,i,r),r===-1)break}}walk(e,t){this.value.length!==0&&this.forEach((t,n)=>!1!==e(t,n)&&(!(`walk`in t.node)||!this.value.includes(t.node)||!1!==t.node.walk(e,t.state))&&void 0,t)}},nc=class e extends tc{type=Qs.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){uo(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return uo(this.endToken)?[this.name,...this.value.flatMap(e=>e.tokens())]:[this.name,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>io(e)?fa(e):e.toString()).join(``);return fa(this.name)+e+fa(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isFunctionNode(){return e.isFunctionNode(this)}static isFunctionNode(t){return!!t&&t instanceof e&&t.type===Qs.Function}};function rc(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||uo(i))return e.onParseError(new la(`Unexpected EOF while consuming a function.`,t[0][2],t[t.length-1][3],[`5.4.9. Consume a function`,`Unexpected EOF`])),{advance:t.length,node:new nc(t[0],i,n)};if(_o(i))return{advance:r+1,node:new nc(t[0],i,n)};if(ao(i)){let i=uc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=ec(e,t.slice(r));r+=a.advance,n.push(a.node)}}var ic=class e extends tc{type=Qs.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(uo(this.endToken)){let e=Pa(this.startToken);e&&(this.endToken=e)}}tokens(){return uo(this.endToken)?[this.startToken,...this.value.flatMap(e=>e.tokens())]:[this.startToken,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>io(e)?fa(e):e.toString()).join(``);return fa(this.startToken)+e+fa(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isSimpleBlockNode(){return e.isSimpleBlockNode(this)}static isSimpleBlockNode(t){return!!t&&t instanceof e&&t.type===Qs.SimpleBlock}};function ac(e,t){let n=Na(t[0][0]);if(!n)throw Error(`Failed to parse, a mirror variant must exist for all block open tokens.`);let r=[],i=1;for(;;){let a=t[i];if(!a||uo(a))return e.onParseError(new la(`Unexpected EOF while consuming a simple block.`,t[0][2],t[t.length-1][3],[`5.4.8. Consume a simple block`,`Unexpected EOF`])),{advance:t.length,node:new ic(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new ic(t[0],a,r)};if(ao(a)){let n=uc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=ec(e,t.slice(i));i+=o.advance,r.push(o.node)}}var oc=class e{type=Qs.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return fa(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return e.isWhitespaceNode(this)}static isWhitespaceNode(t){return!!t&&t instanceof e&&t.type===Qs.Whitespace}};function sc(e,t){let n=0;for(;;){let e=t[n];if(!ho(e))return{advance:n,node:new oc(t.slice(0,n))};n++}}var cc=class e{type=Qs.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return fa(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return e.isCommentNode(this)}static isCommentNode(t){return!!t&&t instanceof e&&t.type===Qs.Comment}};function lc(e,t){return{advance:1,node:new cc(t[0])}}function uc(e,t){let n=[],r=0;for(;;){if(ho(t[r])){let e=sc(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!co(t[r]))return{advance:r,nodes:n};n.push(new cc(t[r])),r++}}var K=class e{type=Qs.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return e.isTokenNode(this)}static isTokenNode(t){return!!t&&t instanceof e&&t.type===Qs.Token}};function dc(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];uo(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=ec(n,r);if(uo(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new la(`Expected EOF after parsing a component value.`,e[0][2],e[e.length-1][3],[`5.3.9. Parse a component value`,`Expected EOF`]))}function fc(e,t,n){if(e.length===0)return;let r=$s(e),i=0;for(;i<e.length;){let a=e[i],o;if(n&&(o={...n}),!1===t({node:a,parent:{value:e},state:o},i))return!1;if(i=r(e,a,i),i===-1)break}}function pc(e,t,n){e.length!==0&&fc(e,(n,r)=>!1!==t(n,r)&&(!(`walk`in n.node)||!e.includes(n.node)||!1!==n.node.walk(t,n.state))&&void 0,n)}function mc(e,t){for(let n=0;n<e.length;n++)pc(e[n],(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);r&&(Array.isArray(r)?e.parent.value.splice(n,1,...r):e.parent.value.splice(n,1,r))});return e}function hc(e){return ic.isSimpleBlockNode(e)}function gc(e){return nc.isFunctionNode(e)}function _c(e){return oc.isWhitespaceNode(e)}function vc(e){return cc.isCommentNode(e)}function yc(e){return _c(e)||vc(e)}function q(e){return K.isTokenNode(e)}function bc(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[bc(t)[0],bc(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var xc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},Sc=class extends xc{componentValues;constructor(e,t){super(e,...bc(t)),this.componentValues=t}};const Cc={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},wc=/[A-Z]/g;function Tc(e){return e.replace(wc,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Ec={cm:`px`,in:`px`,mm:`px`,pc:`px`,pt:`px`,px:`px`,q:`px`,deg:`deg`,grad:`deg`,rad:`deg`,turn:`deg`,ms:`s`,s:`s`,hz:`hz`,khz:`hz`},Dc=new Map([[`cm`,e=>e],[`mm`,e=>10*e],[`q`,e=>40*e],[`in`,e=>e/2.54],[`pc`,e=>e/2.54*6],[`pt`,e=>e/2.54*72],[`px`,e=>e/2.54*96]]),Oc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),kc=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),Ac=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),jc=new Map([[`cm`,e=>2.54*e],[`mm`,e=>25.4*e],[`q`,e=>25.4*e*4],[`in`,e=>e],[`pc`,e=>6*e],[`pt`,e=>72*e],[`px`,e=>96*e]]),Mc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),Nc=new Map([[`cm`,e=>e/10],[`mm`,e=>e],[`q`,e=>4*e],[`in`,e=>e/25.4],[`pc`,e=>e/25.4*6],[`pt`,e=>e/25.4*72],[`px`,e=>e/25.4*96]]),Pc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Fc=new Map([[`cm`,e=>e/6*2.54],[`mm`,e=>e/6*25.4],[`q`,e=>e/6*25.4*4],[`in`,e=>e/6],[`pc`,e=>e],[`pt`,e=>e/6*72],[`px`,e=>e/6*96]]),Ic=new Map([[`cm`,e=>e/72*2.54],[`mm`,e=>e/72*25.4],[`q`,e=>e/72*25.4*4],[`in`,e=>e/72],[`pc`,e=>e/72*6],[`pt`,e=>e],[`px`,e=>e/72*96]]),Lc=new Map([[`cm`,e=>e/96*2.54],[`mm`,e=>e/96*25.4],[`q`,e=>e/96*25.4*4],[`in`,e=>e/96],[`pc`,e=>e/96*6],[`pt`,e=>e/96*72],[`px`,e=>e]]),Rc=new Map([[`cm`,e=>e/4/10],[`mm`,e=>e/4],[`q`,e=>e],[`in`,e=>e/4/25.4],[`pc`,e=>e/4/25.4*6],[`pt`,e=>e/4/25.4*72],[`px`,e=>e/4/25.4*96]]),zc=new Map([[`deg`,e=>180*e/Math.PI],[`grad`,e=>180*e/Math.PI/.9],[`rad`,e=>e],[`turn`,e=>180*e/Math.PI/360]]),Bc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),Vc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),Hc=new Map([[`cm`,Dc],[`mm`,Nc],[`q`,Rc],[`in`,jc],[`pc`,Fc],[`pt`,Ic],[`px`,Lc],[`ms`,Pc],[`s`,Bc],[`deg`,Oc],[`grad`,kc],[`rad`,zc],[`turn`,Vc],[`hz`,Ac],[`khz`,Mc]]);function Uc(e,t){if(!H(e)||!H(t))return t;let n=Tc(e[4].unit),r=Tc(t[4].unit);if(n===r)return t;let i=Hc.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[z.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?B.Integer:B.Number,value:o}];return $a(s,e[4].unit),s}function Wc(e){if(!H(e))return e;let t=Tc(e[4].unit),n=Ec[t];if(t===n)return e;let r=Hc.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[z.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?B.Integer:B.Number,value:a}];return $a(o,n),o}function Gc(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value+r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Uc(n,r),Tc(n[4].unit)===Tc(r[4].unit))){let e=n[4].value+r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Sc(Cc.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Kc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number,unit:t[4].unit}])}return-1}function qc(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function Jc(e,t){if(e===-1)return-1;let n=[];for(let r=0;r<e.inputs.length;r++){let i=e.inputs[r];if(q(i)){n.push(i);continue}let a=Jc(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function Yc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(W(t)&&G(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return-1}function Xc(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!q(r))continue;let i=r.value;if(!U(i))continue;let a=Tc(i[4].value);switch(a){case`e`:e.splice(n,1,new K([z.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:B.Number}]));break;case`pi`:e.splice(n,1,new K([z.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:B.Number}]));break;case`infinity`:e.splice(n,1,new K([z.Number,`infinity`,i[2],i[3],{value:1/0,type:B.Number}]));break;case`-infinity`:e.splice(n,1,new K([z.Number,`-infinity`,i[2],i[3],{value:-1/0,type:B.Number}]));break;case`nan`:e.splice(n,1,new K([z.Number,`NaN`,i[2],i[3],{value:NaN,type:B.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function Zc(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function Qc(e,t,n){return H(t)?$c(e,t[4].unit,n):G(t)?el(e,n):W(t)?tl(e,n):-1}function $c(e,t,n){let r=e.tokens();return{inputs:[new K([z.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?B.Integer:B.Number,unit:t}])],operation:Zc}}function el(e,t){let n=e.tokens();return{inputs:[new K([z.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:Zc}}function tl(e,t){let n=e.tokens();return{inputs:[new K([z.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?B.Integer:B.Number}])],operation:Zc}}function nl(e,t){let n=t.value;return W(n)?$c(e,`rad`,Math.acos(n[4].value)):-1}function rl(e,t){let n=t.value;return W(n)?$c(e,`rad`,Math.asin(n[4].value)):-1}function il(e,t){let n=t.value;return W(n)?$c(e,`rad`,Math.atan(n[4].value)):-1}function al(e){return H(e)||W(e)}function ol(e){if(e.length===0)return!0;let t=e[0];if(!V(t))return!1;if(e.length===1)return!0;if(H(t)){let n=Tc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==Tc(i[4].unit))return!1}return!0}for(let n=1;n<e.length;n++){let r=e[n];if(t[0]!==r[0])return!1}return!0}function sl(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&Tc(e[4].unit)===Tc(t[4].unit):e[0]===t[0])}function cl(e,t,n){let r=t.value;if(!al(r))return-1;let i=Uc(r,n.value);return sl(r,i)?$c(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function ll(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:Qc(e,r,Math.abs(r[4].value))}function ul(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!V(a)||!i.rawPercentages&&G(a))return-1;let o=Uc(a,n.value);if(!sl(a,o))return-1;let s=Uc(a,r.value);return sl(a,s)?Qc(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function dl(e,t){let n=t.value;if(!al(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Oc.get(`rad`)(n[4].value);break;case`grad`:r=kc.get(`rad`)(n[4].value);break;case`turn`:r=Vc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),tl(e,r)}function fl(e,t){let n=t.value;return W(n)?tl(e,Math.exp(n[4].value)):-1}function pl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Uc(r,e.value));if(!ol(i))return-1;let a=i.map(e=>e[4].value);return Qc(e,r,Math.hypot(...a))}function ml(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Uc(r,e.value));if(!ol(i))return-1;let a=i.map(e=>e[4].value);return Qc(e,r,Math.max(...a))}function hl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Uc(r,e.value));if(!ol(i))return-1;let a=i.map(e=>e[4].value);return Qc(e,r,Math.min(...a))}function gl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Uc(r,n.value);if(!sl(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)&&(Number.isFinite(i[4].value)||(i[4].value!==1/0||r[4].value!==-1/0&&!Object.is(0*r[4].value,-0))&&(i[4].value!==-1/0||r[4].value!==1/0&&!Object.is(0*r[4].value,0)))?Number.isFinite(i[4].value)?(r[4].value%i[4].value+i[4].value)%i[4].value:r[4].value:NaN,Qc(e,r,a)}function _l(e,t,n){let r=t.value,i=n.value;return!W(r)||!sl(r,i)?-1:tl(e,r[4].value**+i[4].value)}function vl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Uc(r,n.value);if(!sl(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)?Number.isFinite(i[4].value)?r[4].value%i[4].value:r[4].value:NaN,Qc(e,r,a)}function yl(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[z.Dimension,`${r}px`,t[2],t[3],{value:r,type:B.Integer,unit:`px`}],a=Uc(i,t);if(!sl(a,i))return-1;if(Number.isInteger(a[4].value/r))return Qc(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return Qc(e,t,Uc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,Qc(e,t,Uc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return Qc(e,t,-1*Uc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,Qc(e,t,Uc(t,a)[4].value)}function bl(e,t,n,r,i){let a=n.value;if(!V(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=Uc(a,r.value);if(!sl(a,o))return-1;let s;if(o[4].value===0)s=NaN;else if(Number.isFinite(a[4].value)||Number.isFinite(o[4].value))if(!Number.isFinite(a[4].value)&&Number.isFinite(o[4].value))s=a[4].value;else if(Number.isFinite(a[4].value)&&!Number.isFinite(o[4].value))switch(t){case`down`:s=a[4].value<0?-1/0:Object.is(-0,0*a[4].value)?-0:0;break;case`up`:s=a[4].value>0?1/0:Object.is(0,0*a[4].value)?0:-0;break;default:s=Object.is(0,0*a[4].value)?0:-0}else switch(t){case`down`:s=Math.floor(a[4].value/o[4].value)*o[4].value;break;case`up`:s=Math.ceil(a[4].value/o[4].value)*o[4].value;break;case`to-zero`:s=Math.trunc(a[4].value/o[4].value)*o[4].value;break;default:{let n=Math.floor(a[4].value/o[4].value)*o[4].value,r=Math.ceil(a[4].value/o[4].value)*o[4].value;if(n>r){let e=n;n=r,r=e}let c=Math.abs(a[4].value-n),l=Math.abs(a[4].value-r);if(s=t===`line-width`&&a[4].value>=0&&(r===0||n===0)?r===0?n:r:c===l?r:c<l?n:r,t===`line-width`){let t=Jc(Qc(e,a,s),i);return t===-1?-1:yl(e,t.value,i)}break}}else s=NaN;return Qc(e,a,s)}function xl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:tl(e,Math.sign(r[4].value))}function Sl(e,t){let n=t.value;if(!al(n))return-1;let r=n[4].value;if(H(n))switch(Tc(n[4].unit)){case`rad`:break;case`deg`:r=Oc.get(`rad`)(n[4].value);break;case`grad`:r=kc.get(`rad`)(n[4].value);break;case`turn`:r=Vc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),tl(e,r)}function Cl(e,t){let n=t.value;return W(n)?tl(e,Math.sqrt(n[4].value)):-1}function wl(e,t){let n=t.value;if(!al(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(Tc(n[4].unit)){case`rad`:i=zc.get(`deg`)(r);break;case`deg`:i=r,a=Oc.get(`rad`)(r);break;case`grad`:i=kc.get(`deg`)(r),a=kc.get(`rad`)(r);break;case`turn`:i=Vc.get(`deg`)(r),a=Vc.get(`rad`)(r);break;default:return-1}let o=i/90;return a=i%90==0&&o%2!=0?o>0?1/0:-1/0:Math.tan(a),tl(e,a)}function Tl(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value-r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Uc(n,r),Tc(n[4].unit)===Tc(r[4].unit))){let e=n[4].value-r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Sc(Cc.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function El(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?tl(e,Math.log(r[4].value)):-1}if(t.length===2){let n=t[0];if(!n||!q(n))return-1;let r=n.value;if(!W(r))return-1;let i=t[1];if(!i||!q(i))return-1;let a=i.value;return W(a)?tl(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const Dl=/^none$/i;function Ol(e){if(Array.isArray(e)){let t=e.filter(e=>!(_c(e)&&vc(e)));return t.length===1&&Ol(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&Dl.test(t[4].value)}const kl=String.fromCodePoint(0);function Al(e,t,n,r,i,a){if(t.fixed===-1&&!a.randomCaching)return-1;a.randomCaching||={propertyName:``,propertyN:0,elementID:``,documentID:``},a.randomCaching&&!a.randomCaching.propertyN&&(a.randomCaching.propertyN=0);let o=n.value;if(!V(o))return-1;let s=Uc(o,r.value);if(!sl(o,s))return-1;let c=null;if(i&&(c=Uc(o,i.value),!sl(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return Qc(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return Qc(e,o,o[4].value);let l=t.fixed===-1?jl(Ml([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(kl))):()=>t.fixed,u=o[4].value,d=s[4].value;if(u>d&&([u,d]=[d,u]),c&&(c[4].value<=0||Math.abs(u-d)/c[4].value>1e10)&&(c=null),c){let t=Math.max(c[4].value/1e3,1e-9),n=[u],r=0;for(;;){r+=c[4].value;let e=u+r;if(!(e+t<d)){n.push(d);break}if(n.push(e),e+c[4].value-t>d)break}let i=l();return Qc(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return Qc(e,o,Number((f*(d-u)+u).toFixed(5)))}function jl(e=.34944106645296036,t=.19228640875738723,n=.8784393832007205,r=.04850964319275053){return()=>{let i=((e|=0)+(t|=0)|0)+(r|=0)|0;return r=r+1|0,e=t^t>>>9,t=(n|=0)+(n<<3)|0,n=(n=n<<21|n>>>11)+i|0,(i>>>0)/4294967296}}function Ml(e){let t,n,r=0;r^=-1;for(let i=0,a=e.length;i<a;i++)n=255&(r^e.charCodeAt(i)),t=Number(`0x`+`00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D`.substring(9*n,9*n+8)),r=r>>>8^t;return(-1^r)>>>0}const Nl=new Map([[`abs`,function(e,t,n){return Fl(e,t,n,ll)}],[`acos`,function(e,t,n){return Fl(e,t,n,nl)}],[`asin`,function(e,t,n){return Fl(e,t,n,rl)}],[`atan`,function(e,t,n){return Fl(e,t,n,il)}],[`atan2`,function(e,t,n){return Ll(e,t,n,cl)}],[`calc`,Pl],[`clamp`,function(e,t,n){let r=Xc([...e.value.filter(e=>!yc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&so(n.value)){if(e===o)return-1;if(e===a){e=o;continue}if(e===i){e=a;continue}return-1}e.push(n)}}let s=Ol(i),c=Ol(o);if(s&&c)return Pl(Ul(e,a),t,n);let l=Jc(Pl(Ul(e,a),t,n),n);if(l===-1)return-1;if(s){let r=Jc(Pl(Ul(e,o),t,n),n);return r===-1?-1:hl((u=e,d=l,f=r,new nc([z.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[z.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([z.Comma,`,`,...bc(d),void 0]),f])),[l,r],n)}if(c){let r=Jc(Pl(Ul(e,i),t,n),n);return r===-1?-1:ml(Wl(e,r,l),[r,l],n)}var u,d,f;let p=Jc(Pl(Ul(e,i),t,n),n);if(p===-1)return-1;let m=Jc(Pl(Ul(e,o),t,n),n);return m===-1?-1:ul(e,p,l,m,n)}],[`cos`,function(e,t,n){return Fl(e,t,n,dl)}],[`exp`,function(e,t,n){return Fl(e,t,n,fl)}],[`hypot`,function(e,t,n){return zl(e,t,n,pl)}],[`log`,function(e,t,n){return zl(e,t,n,El)}],[`max`,function(e,t,n){return zl(e,t,n,ml)}],[`min`,function(e,t,n){return zl(e,t,n,hl)}],[`mod`,function(e,t,n){return Ll(e,t,n,gl)}],[`pow`,function(e,t,n){return Ll(e,t,n,_l)}],[`random`,function(e,t,n){let r=Hl(e,e.value.filter(e=>!yc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=Bl(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:Al(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Ll(e,t,n,vl)}],[`round`,function(e,t,n){let r=Xc([...e.value.filter(e=>!yc(e))],t),i=``,a=!1,o=[],s=[];{let e=o;for(let t=0;t<r.length;t++){let n=r[t];if(!i&&o.length===0&&s.length===0&&q(n)&&U(n.value)){let e=n.value[4].value.toLowerCase();if(Vl.has(e)){i=e;continue}}if(q(n)&&so(n.value)){if(e===s)return-1;if(e===o&&i&&o.length===0)continue;if(e===o){a=!0,e=s;continue}return-1}e.push(n)}}let c=Jc(Pl(Ul(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Uc([z.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:B.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return yl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=Jc(Pl(Ul(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,bl(e,i,c,l,n))}],[`sign`,function(e,t,n){return Fl(e,t,n,xl)}],[`sin`,function(e,t,n){return Fl(e,t,n,Sl)}],[`sqrt`,function(e,t,n){return Fl(e,t,n,Cl)}],[`tan`,function(e,t,n){return Fl(e,t,n,wl)}]]);function Pl(e,t,n){let r=Xc([...e.value.filter(e=>!yc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:Zc};let i=0;for(;i<r.length;){let e=r[i];if(hc(e)&&go(e.startToken)){let a=Pl(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(gc(e)){let a=Nl.get(e.getName().toLowerCase());if(!a)return-1;let o=a(e,t,n);if(o===-1)return-1;r.splice(i,1,o);continue}i++}if(i=0,r.length===1&&qc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!qc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!lo(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!qc(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:Yc}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:Kc}):i++}if(i=0,r.length===1&&qc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!qc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!lo(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!qc(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Gc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:Tl}):i++}return r.length===1&&qc(r[0])?r[0]:-1}function Fl(e,t,n,r){let i=Il(e,t,n);return i===-1?-1:r(e,i,n)}function Il(e,t,n){let r=Jc(Pl(Ul(e,Xc([...e.value.filter(e=>!yc(e))],t)),t,n),n);return r===-1?-1:r}function Ll(e,t,n,r){let i=Rl(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Rl(e,t,n){let r=Xc([...e.value.filter(e=>!yc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&so(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=Jc(Pl(Ul(e,i),t,n),n);if(o===-1)return-1;let s=Jc(Pl(Ul(e,a),t,n),n);return s===-1?-1:[o,s]}function zl(e,t,n,r){let i=Bl(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function Bl(e,t,n,r){let i=Xc([...t.filter(e=>!yc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&so(n.value)?(t.push(o),o=[]):o.push(n)}t.push(o);for(let i=0;i<t.length;i++){if(t[i].length===0)return-1;let o=Jc(Pl(Ul(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const Vl=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function Hl(e,t,n,r){let i={isAuto:!1,dashedIdent:``,fixed:-1,elementShared:!1},a=t[0];if(!q(a)||!U(a.value))return[i,t];for(let a=0;a<t.length;a++){let o=t[a];if(!q(o))return-1;if(so(o.value))return[i,t.slice(a+1)];if(!U(o.value))return-1;let s=o.value[4].value.toLowerCase();if(s!==`element-shared`){if(s===`fixed`){if(i.elementShared||i.dashedIdent||i.isAuto)return-1;a++;let o=t[a];if(!o)return-1;let s=Jc(Pl(Ul(e,[o]),n,r),r);if(s===-1||!W(s.value)||s.value[4].value<0||s.value[4].value>1)return-1;i.fixed=Math.max(0,Math.min(s.value[4].value,.999999999));continue}if(s!==`auto`){if(s.startsWith(`--`)){if(i.fixed!==-1||i.isAuto)return-1;i.dashedIdent=s}}else{if(i.fixed!==-1||i.dashedIdent)return-1;i.isAuto=!0}}else{if(i.fixed!==-1)return-1;i.elementShared=!0}}return-1}function Ul(e,t){return new nc([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function Wl(e,t,n){return new nc([z.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([z.Comma,`,`,...bc(t),void 0]),n])}function Gl(e){if(e===-1)return-1;if(gc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):G(t)?new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Kl(e){if(e===-1)return-1;if(gc(e))return e;let t=e.value;if(!V(t)||Number.isFinite(t[4].value)||Number.isNaN(t[4].value))return e;let n=``;return t[4].value===-1/0&&(n=`-`),W(t)?new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):new nc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new oc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function ql(e){if(e===-1)return-1;if(gc(e))return e;let t=e.value;return V(t)&&Object.is(-0,t[4].value)&&(t[1]===`-0`||(G(t)?t[1]=`-0%`:H(t)?t[1]=`-0`+t[4].unit:t[1]=`-0`)),e}function Jl(e,t=13){if(e===-1)return-1;if(t<=0||gc(e))return e;let n=e.value;if(!V(n)||Number.isInteger(n[4].value))return e;let r=Number(n[4].value.toFixed(t)).toString();return W(n)?n[1]=r:G(n)?n[1]=r+`%`:H(n)&&(n[1]=r+n[4].unit),e}function Yl(e){return e===-1?-1:(gc(e)||H(e.value)&&(e.value=Wc(e.value)),e)}function Xl(e,t){let n=e;return t?.toCanonicalUnits&&(n=Yl(n)),n=Jl(n,t?.precision),n=ql(n),t?.censorIntoStandardRepresentableValues||(n=Gl(n),n=Kl(n)),n}function Zl(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(io(r))t.set(n,r);else if(typeof r==`string`){let e=Za({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function Ql(e,t){let n=Zl(t?.globals);return $l(e,e=>{if(!gc(e))return;let r=Nl.get(e.getName().toLowerCase());if(!r)return;let i=Xl(Jc(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function $l(e,t){for(let n=0;n<e.length;n++){let r=e[n];pc(r,(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);if(!r)return;let i=[r],a=e.parent.value[n-1];q(a)&&lo(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new oc([[z.Whitespace,` `,...bc(e.node),void 0]]));let o=e.parent.value[n+1];!o||yc(o)||q(o)&&(so(o.value)||oo(o.value)||mo(o.value)||lo(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new oc([[z.Whitespace,` `,...bc(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const eu=new Set(Nl.keys());var J,Y;function tu(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function nu(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:gs(tu(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:As(tu(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Ps(tu(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Is(tu(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Rs(tu(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Ms(tu(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Bs(tu(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:vs(tu(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:bs(tu(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:Ss(tu(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Es(tu(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:ws(tu(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Os(tu(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:Ws(tu(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:Hs(tu(e.channels))};default:throw Error(`Unsupported color notation`)}}(function(e){e.A98_RGB=`a98-rgb`,e.Display_P3=`display-p3`,e.Linear_Display_P3=`display-p3-linear`,e.HEX=`hex`,e.HSL=`hsl`,e.HWB=`hwb`,e.LCH=`lch`,e.Lab=`lab`,e.Linear_sRGB=`srgb-linear`,e.OKLCH=`oklch`,e.OKLab=`oklab`,e.ProPhoto_RGB=`prophoto-rgb`,e.RGB=`rgb`,e.sRGB=`srgb`,e.Rec2020=`rec2020`,e.XYZ_D50=`xyz-d50`,e.XYZ_D65=`xyz-d65`})(J||={}),function(e){e.ColorKeyword=`color-keyword`,e.HasAlpha=`has-alpha`,e.HasDimensionValues=`has-dimension-values`,e.HasNoneKeywords=`has-none-keywords`,e.HasNumberValues=`has-number-values`,e.HasPercentageAlpha=`has-percentage-alpha`,e.HasPercentageValues=`has-percentage-values`,e.HasVariableAlpha=`has-variable-alpha`,e.Hex=`hex`,e.LegacyHSL=`legacy-hsl`,e.LegacyRGB=`legacy-rgb`,e.NamedColor=`named-color`,e.RelativeColorSyntax=`relative-color-syntax`,e.ColorMix=`color-mix`,e.ColorMixVariadic=`color-mix-variadic`,e.ContrastColor=`contrast-color`,e.RelativeAlphaSyntax=`relative-alpha-syntax`,e.Experimental=`experimental`}(Y||={});const ru=new Set([J.A98_RGB,J.Display_P3,J.Linear_Display_P3,J.HEX,J.Linear_sRGB,J.ProPhoto_RGB,J.RGB,J.sRGB,J.Rec2020,J.XYZ_D50,J.XYZ_D65]);function iu(e,t){let n={...e};if(e.colorNotation!==t){let e=nu(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=_s(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=_s(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=js(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Fs(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Ls(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=zs(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=Vs(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=Ns(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=ys(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=xs(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Cs(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=Ts(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=ks(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Ds(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=Ws(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Us(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=tu(e.channels);if(t===e.colorNotation)n.channels=ou(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(ru.has(t)&&ru.has(e.colorNotation))n.channels=ou(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=ou(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=ou(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=ou(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=ou(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=ou(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=ou(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=ou(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=ou(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=ou(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=ou(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=ou(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=ou(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=ou(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=ou(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=ou(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=ou(e.channels,[],[],n.channels,[],[])}break;default:n.channels=ou(e.channels,[],[],n.channels,[],[])}return n.channels=au(n.channels,t),n}function au(e,t){let n=[...e];switch(t){case J.HSL:!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=NaN);break;case J.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=NaN);break;case J.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=NaN);break;case J.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=NaN)}return n}function ou(e,t,n,r,i,a){if(t.length<3&&e.every(Number.isNaN))return[NaN,NaN,NaN];let o=[...r];for(let n=0;n<t.length;n++)Number.isNaN(e[t[n]])&&(o[i[n]]=NaN);if(n.length&&n.every(t=>Number.isNaN(e[t])))for(let e=0;e<a.length;e++)o[a[e]]=NaN;return o}function su(e){let t=new Map;switch(e.colorNotation){case J.RGB:case J.HEX:t.set(`r`,X(255*e.channels[0])),t.set(`g`,X(255*e.channels[1])),t.set(`b`,X(255*e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HSL:t.set(`h`,X(e.channels[0])),t.set(`s`,X(e.channels[1])),t.set(`l`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HWB:t.set(`h`,X(e.channels[0])),t.set(`w`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.Lab:case J.OKLab:t.set(`l`,X(e.channels[0])),t.set(`a`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.LCH:case J.OKLCH:t.set(`l`,X(e.channels[0])),t.set(`c`,X(e.channels[1])),t.set(`h`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.sRGB:case J.A98_RGB:case J.Display_P3:case J.Linear_Display_P3:case J.Rec2020:case J.Linear_sRGB:case J.ProPhoto_RGB:t.set(`r`,X(e.channels[0])),t.set(`g`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.XYZ_D50:case J.XYZ_D65:t.set(`x`,X(e.channels[0])),t.set(`y`,X(e.channels[1])),t.set(`z`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha))}return t}function cu(e){let t=new Map(e);for(let[n,r]of e)Number.isNaN(r[4].value)&&t.set(n,X(0));return t}function X(e){return Number.isNaN(e)?[z.Number,`none`,-1,-1,{value:NaN,type:B.Number}]:[z.Number,e.toString(),-1,-1,{value:e,type:B.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const lu=/[A-Z]/g;function Q(e){return e.replace(lu,e=>String.fromCharCode(e.charCodeAt(0)+32))}function uu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}const du=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function fu(e,t){let n=[],r=[],i=[],a=[],o,s,c=!1,l=!1,u={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])},d=n;for(let f=0;f<e.value.length;f++){let p=e.value[f];if(_c(p)||vc(p))for(;_c(e.value[f+1])||vc(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&lo(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(gc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!eu.has(Q(p.getName())))return!1;let[[e]]=Ql([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),p=e}if(d===n&&n.length===0&&q(p)&&U(p.value)&&du.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=pu(c),l&&(l.colorNotation!==u.colorNotation&&(l=iu(l,u.colorNotation)),o=su(l),s=cu(o))}else if(d===n&&n.length===0&&q(p)&&U(p.value)&&Q(p.value[4].value)===`from`){if(l||c)return!1;for(;_c(e.value[f+1])||vc(e.value[f+1]);)f++;if(f++,p=e.value[f],l=t(p),!1===l)return!1;l.syntaxFlags.has(Y.Experimental)&&u.syntaxFlags.add(Y.Experimental),u.syntaxFlags.add(Y.RelativeColorSyntax)}else{if(!q(p))return!1;if(U(p.value)&&o&&o.has(Q(p.value[4].value))){d.push(new K(o.get(Q(p.value[4].value))));continue}d.push(p)}}}if(!c||d.length!==1||n.length!==1||r.length!==1||i.length!==1||!q(n[0])||!q(r[0])||!q(i[0])||o&&!o.has(`alpha`))return!1;let f=uu(n[0].value,0,u);if(!f||!W(f))return!1;let p=uu(r[0].value,1,u);if(!p||!W(p))return!1;let m=uu(i[0].value,2,u);if(!m||!W(m))return!1;let h=[f,p,m];if(a.length===1)if(u.syntaxFlags.add(Y.HasAlpha),q(a[0])){let e=uu(a[0].value,3,u);if(!e||!W(e))return!1;h.push(e)}else u.alpha=a[0];else if(o&&o.has(`alpha`)){let e=uu(o.get(`alpha`),3,u);if(!e||!W(e))return!1;h.push(e)}return u.channels=[h[0][4].value,h[1][4].value,h[2][4].value],h.length===4&&(u.alpha=h[3][4].value),u}function pu(e){switch(e){case`srgb`:return J.sRGB;case`srgb-linear`:return J.Linear_sRGB;case`display-p3`:return J.Display_P3;case`display-p3-linear`:return J.Linear_Display_P3;case`a98-rgb`:return J.A98_RGB;case`prophoto-rgb`:return J.ProPhoto_RGB;case`rec2020`:return J.Rec2020;case`xyz`:case`xyz-d65`:return J.XYZ_D65;case`xyz-d50`:return J.XYZ_D50;default:throw Error(`Unknown color space name: `+e)}}const mu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),hu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),gu=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function _u(e,t){let n=null,r=null,i=null,a=!1;for(let o=0;o<e.value.length;o++){let s=e.value[o];if(!yc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return yu(`oklab`,vu(e.value,t));if(q(s)&&U(s.value)){if(!n&&Q(s.value[4].value)===`in`){n=s;continue}if(n&&!r){r=Q(s.value[4].value);continue}if(n&&r&&!i&&hu.has(r)){i=Q(s.value[4].value);continue}if(n&&r&&i&&!a&&Q(s.value[4].value)===`hue`){a=!0;continue}return!1}return!(!q(s)||!so(s.value))&&!!r&&(i||a?!!(i&&a&&hu.has(r)&&gu.has(i))&&xu(r,i,vu(e.value.slice(o+1),t)):mu.has(r)?yu(r,vu(e.value.slice(o+1),t)):!!hu.has(r)&&xu(r,`shorter`,vu(e.value.slice(o+1),t)))}}return!1}function vu(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!yc(o)){if(!q(o)||!so(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(gc(o)&&eu.has(Q(o.getName()))){if([[o]]=Ql([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!V(o.value))return!1;Number.isNaN(o.value[4].value)&&(o.value[4].value=0)}if(q(o)&&G(o.value)&&o.value[4].value>=0){i=o.value[4].value;continue}}return!1}if(!r)return!1;n.push({color:r,percentage:i}),r=!1,i=!1}}return!!r&&(n.push({color:r,percentage:i}),n)}function yu(e,t){if(!t||!t.length)return!1;for(let e of t)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:n,leftover:r}=Du(t,!0),i=1-r/100,a;switch(e){case`srgb`:a=J.RGB;break;case`srgb-linear`:a=J.Linear_sRGB;break;case`display-p3`:a=J.Display_P3;break;case`display-p3-linear`:a=J.Linear_Display_P3;break;case`a98-rgb`:a=J.A98_RGB;break;case`prophoto-rgb`:a=J.ProPhoto_RGB;break;case`rec2020`:a=J.Rec2020;break;case`lab`:a=J.Lab;break;case`oklab`:a=J.OKLab;break;case`xyz-d50`:a=J.XYZ_D50;break;case`xyz`:case`xyz-d65`:a=J.XYZ_D65;break;default:return!1}if(n.length===1){let e=iu(n[0].color,a);return e.colorNotation=a,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=i,e):!1}for(n.reverse();n.length>=2;){let e=n.pop(),t=n.pop();if(!e||!t)return!1;let r=e.percentage+t.percentage,i=r>0?t.percentage/r:.5,o=bu(a,e.color,t.color,i);if(!o)return!1;n.push({color:o,percentage:r})}let o=n[0]?.color;return!!o&&typeof o.alpha==`number`&&(o.alpha*=i,t.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&o.syntaxFlags.add(Y.Experimental),t.length!==2&&o.syntaxFlags.add(Y.ColorMixVariadic),o)}function bu(e,t,n,r){let i=t.alpha;if(typeof i!=`number`)return!1;let a=n.alpha;if(typeof a!=`number`)return!1;i=Number.isNaN(i)?a:i,a=Number.isNaN(a)?i:a;let o=iu(t,e).channels,s=iu(n,e).channels;o[0]=Cu(o[0],s[0]),s[0]=Cu(s[0],o[0]),o[1]=Cu(o[1],s[1]),s[1]=Cu(s[1],o[1]),o[2]=Cu(o[2],s[2]),s[2]=Cu(s[2],o[2]),o[0]=Tu(o[0],i),o[1]=Tu(o[1],i),o[2]=Tu(o[2],i),s[0]=Tu(s[0],a),s[1]=Tu(s[1],a),s[2]=Tu(s[2],a);let c=wu(i,a,r);return{colorNotation:e,channels:[Eu(wu(o[0],s[0],r),c),Eu(wu(o[1],s[1],r),c),Eu(wu(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function xu(e,t,n){if(!n||!n.length)return!1;for(let e of n)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:r,leftover:i}=Du(n,!0),a=1-i/100,o;switch(e){case`hsl`:o=J.HSL;break;case`hwb`:o=J.HWB;break;case`lch`:o=J.LCH;break;case`oklch`:o=J.OKLCH;break;default:return!1}if(r.length===1){let e=iu(r[0].color,o);return e.colorNotation=o,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=a,e):!1}for(r.reverse();r.length>=2;){let e=r.pop(),n=r.pop();if(!e||!n)return!1;let i=e.percentage+n.percentage,a=i>0?n.percentage/i:.5,s=Su(o,t,e.color,n.color,a);if(!s)return!1;r.push({color:s,percentage:i})}let s=r[0]?.color;return!!s&&typeof s.alpha==`number`&&(s.alpha*=a,n.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&s.syntaxFlags.add(Y.Experimental),n.length!==2&&s.syntaxFlags.add(Y.ColorMixVariadic),s)}function Su(e,t,n,r,i){let a=0,o=0,s=0,c=0,l=0,u=0,d=n.alpha;if(typeof d!=`number`)return!1;let f=r.alpha;if(typeof f!=`number`)return!1;d=Number.isNaN(d)?f:d,f=Number.isNaN(f)?d:f;let p=iu(n,e).channels,m=iu(r,e).channels;switch(e){case J.HSL:case J.HWB:a=p[0],o=m[0],s=p[1],c=m[1],l=p[2],u=m[2];break;case J.LCH:case J.OKLCH:s=p[0],c=m[0],l=p[1],u=m[1],a=p[2],o=m[2]}a=Cu(a,o),Number.isNaN(a)&&(a=0),o=Cu(o,a),Number.isNaN(o)&&(o=0),s=Cu(s,c),c=Cu(c,s),l=Cu(l,u),u=Cu(u,l);let h=o-a;switch(t){case`shorter`:h>180?a+=360:h<-180&&(o+=360);break;case`longer`:-180<h&&h<180&&(h>0?a+=360:o+=360);break;case`increasing`:h<0&&(o+=360);break;case`decreasing`:h>0&&(a+=360);break;default:throw Error(`Unknown hue interpolation method`)}s=Tu(s,d),l=Tu(l,d),c=Tu(c,f),u=Tu(u,f);let g=[0,0,0],_=wu(d,f,i);switch(e){case J.HSL:case J.HWB:g=[wu(a,o,i),Eu(wu(s,c,i),_),Eu(wu(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Eu(wu(s,c,i),_),Eu(wu(l,u,i),_),wu(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function Cu(e,t){return Number.isNaN(e)?t:e}function wu(e,t,n){return e*(1-n)+t*n}function Tu(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Eu(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Du(e,t=!1){let n=0,r=0;for(let t of e)t.percentage&&(n+=t.percentage),!1===t.percentage&&r++;n=Math.min(100,n);for(let t of e)!1===t.percentage&&(t.percentage=(100-n)/r);let i=e.slice(),a=0;for(let e of i)a+=e.percentage;if(a>100||a>0&&t)for(let e of i)e.percentage*=100/a;let o=0;return a<100&&(o=100-a),{items:i,leftover:o}}function Ou(e){let t=Q(e[4].value);if(t.match(/[^a-f0-9]/))return!1;let n={colorNotation:J.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.Hex])},r=t.length;if(r===3){let e=t[0],r=t[1],i=t[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n}if(r===6){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n}if(r===4){let e=t[0],r=t[1],i=t[2],a=t[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n.alpha=parseInt(a+a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}if(r===8){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5],a=t[6]+t[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n.alpha=parseInt(a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}return!1}function ku(e){if(W(e))return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(H(e)){let t=e[4].value;switch(Q(e[4].unit)){case`deg`:break;case`rad`:t=180*e[4].value/Math.PI;break;case`grad`:t=.9*e[4].value;break;case`turn`:t=360*e[4].value;break;default:return!1}return t%=360,[z.Number,t.toString(),e[2],e[3],{value:t,type:B.Number}]}return!1}function Au(e,t,n){if(t===0){let t=ku(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){if(t!==3)return!1;let n=Z(e[4].value,1,0,100);return t===3&&(n=Z(e[4].value,1,0,1)),[z.Number,n.toString(),e[2],e[3],{value:n,type:B.Number}]}return!1}function ju(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=ku(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3?r=Z(e[4].value,100,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3?r=Z(e[4].value,1,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Mu(e,t,n,r){let i=[],a=[],o=[],s=[],c={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},l=i;for(let t=0;t<e.value.length;t++){let n=e.value[t];if(!_c(n)&&!vc(n)){if(q(n)&&so(n.value)){if(l===i){l=a;continue}if(l===a){l=o;continue}if(l===o){l=s;continue}if(l===s)return!1}if(gc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!eu.has(n.getName().toLowerCase()))return!1;let[[e]]=Ql([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),n=e}if(!q(n))return!1;l.push(n)}}if(l.length!==1||i.length!==1||a.length!==1||o.length!==1||!q(i[0])||!q(a[0])||!q(o[0]))return!1;let u=t(i[0].value,0,c);if(!u||!W(u))return!1;let d=t(a[0].value,1,c);if(!d||!W(d))return!1;let f=t(o[0].value,2,c);if(!f||!W(f))return!1;let p=[u,d,f];if(s.length===1)if(c.syntaxFlags.add(Y.HasAlpha),q(s[0])){let e=t(s[0].value,3,c);if(!e||!W(e))return!1;p.push(e)}else c.alpha=s[0];return c.channels=[p[0][4].value,p[1][4].value,p[2][4].value],p.length===4&&(c.alpha=p[3][4].value),c}function Nu(e,t,n,r,i){let a=[],o=[],s=[],c=[],l,u,d=!1,f={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},p=a;for(let t=0;t<e.value.length;t++){let r=e.value[t];if(_c(r)||vc(r))for(;_c(e.value[t+1])||vc(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&lo(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(gc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!eu.has(r.getName().toLowerCase()))return!1;let[[e]]=Ql([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),r=e}if(p===a&&a.length===0&&q(r)&&U(r.value)&&r.value[4].value.toLowerCase()===`from`){if(d)return!1;for(;_c(e.value[t+1])||vc(e.value[t+1]);)t++;if(t++,r=e.value[t],d=i(r),!1===d)return!1;d.syntaxFlags.has(Y.Experimental)&&f.syntaxFlags.add(Y.Experimental),f.syntaxFlags.add(Y.RelativeColorSyntax),d.colorNotation!==n&&(d=iu(d,n)),l=su(d),u=cu(l)}else{if(!q(r))return!1;if(U(r.value)&&l){let e=r.value[4].value.toLowerCase();if(l.has(e)){p.push(new K(l.get(e)));continue}}p.push(r)}}}if(p.length!==1||a.length!==1||o.length!==1||s.length!==1||!q(a[0])||!q(o[0])||!q(s[0])||l&&!l.has(`alpha`))return!1;let m=t(a[0].value,0,f);if(!m||!W(m))return!1;let h=t(o[0].value,1,f);if(!h||!W(h))return!1;let g=t(s[0].value,2,f);if(!g||!W(g))return!1;let _=[m,h,g];if(c.length===1)if(f.syntaxFlags.add(Y.HasAlpha),q(c[0])){let e=t(c[0].value,3,f);if(!e||!W(e))return!1;_.push(e)}else f.alpha=c[0];else if(l&&l.has(`alpha`)){let e=t(l.get(`alpha`),3,f);if(!e||!W(e))return!1;_.push(e)}return f.channels=[_[0][4].value,_[1][4].value,_[2][4].value],_.length===4&&(f.alpha=_[3][4].value),f}function Pu(e,t){if(e.value.some(e=>q(e)&&so(e.value))){let t=Fu(e);if(!1!==t)return t}{let n=Iu(e,t);if(!1!==n)return n}return!1}function Fu(e){return Mu(e,Au,J.HSL,[Y.LegacyHSL])}function Iu(e,t){return Nu(e,ju,J.HSL,[],t)}function Lu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=ku(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ru(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,.8,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function zu(e,t){return Nu(e,Ru,J.Lab,[],t)}function Bu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=ku(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,100/150,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Vu(e,t){return Nu(e,Bu,J.LCH,[],t)}const Hu=new Map;for(let[e,t]of Object.entries(Ys))Hu.set(e,t);function Uu(e){let t=Hu.get(Q(e));return!!t&&{colorNotation:J.RGB,channels:[t[0]/255,t[1]/255,t[2]/255],alpha:1,syntaxFlags:new Set([Y.ColorKeyword,Y.NamedColor])}}function Wu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1||t===2?r=Z(e[4].value,250,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Gu(e,t){return Nu(e,Wu,J.OKLab,[],t)}function Ku(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=ku(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1?r=Z(e[4].value,250,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function qu(e,t){return Nu(e,Ku,J.OKLCH,[],t)}function Ju(e,t,n){if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,0,1);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Yu(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Xu(e,t){if(e.value.some(e=>q(e)&&so(e.value))){let t=Zu(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=Qu(e,t);if(!1!==n)return n}return!1}function Zu(e){return Mu(e,Ju,J.RGB,[Y.LegacyRGB])}function Qu(e,t){return Nu(e,Yu,J.RGB,[],t)}function $u(e){let t=_s(e);if(Gs(t))return Ks(t);let n=e;return n=ks(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Xo(qs(n,ed,td))}function ed(e){return e=Mo(e),e=Io(e),Jo(e)}function td(e){return e=ps(e),e=Vo(e),No(e)}function nd(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!_c(i)&&!vc(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=tu(n.channels),n.channels=$u(nu(n).channels),n.colorNotation=J.sRGB;let r={colorNotation:J.RGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.ContrastColor,Y.Experimental])};return r.channels=Zs(n.channels,[1,1,1])>Zs(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function rd(e,t){let n,r,i=!1,a=!1,o=!1,s={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let c=0;c<e.value.length;c++){let l=e.value[c];if(_c(l)||vc(l))for(;_c(e.value[c+1])||vc(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&lo(l.value)&&l.value[4].value===`/`)i=!0;else{if(gc(l)&&eu.has(Q(l.getName()))){let[[e]]=Ql([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),l=e}if(i||a||!q(l)||!U(l.value)||Q(l.value[4].value)!==`from`){if(!i||a)return!1;if(q(l)){if(U(l.value)&&Q(l.value[4].value)===`alpha`&&n&&n.has(`alpha`)){s.alpha=n.get(`alpha`)[4].value,a=!0;continue}let e=uu(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(gc(l)){s.alpha=mc([[l]],e=>{if(q(e)&&U(e.value)&&Q(e.value[4].value)===`alpha`&&n&&n.has(`alpha`))return new K(n.get(`alpha`))})[0][0],a=!0;continue}return!1}if(o)return!1;for(;_c(e.value[c+1])||vc(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=su(o),r=cu(n),s.syntaxFlags=new Set(o.syntaxFlags),s.syntaxFlags.add(Y.RelativeAlphaSyntax),s.channels=[...o.channels],s.colorNotation=o.colorNotation,s.alpha=o.alpha}}return!!n&&s}function id(e){if(gc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return Xu(e,id);case`hsl`:case`hsla`:return Pu(e,id);case`hwb`:return t=id,Nu(e,Lu,J.HWB,[],t);case`lab`:return zu(e,id);case`lch`:return Vu(e,id);case`oklab`:return Gu(e,id);case`oklch`:return qu(e,id);case`color`:return fu(e,id);case`color-mix`:return _u(e,id);case`contrast-color`:return nd(e,id);case`alpha`:return rd(e,id)}var t;if(q(e)){if(po(e.value))return Ou(e.value);if(U(e.value)){let t=Uu(e.value[4].value);return!1===t?Q(e.value[4].value)===`transparent`&&{colorNotation:J.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([Y.ColorKeyword])}:t}}return!1}function ad(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function od(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:gs(ad(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:As(ad(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:Ps(ad(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:Is(ad(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Rs(ad(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Ms(ad(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Bs(ad(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:vs(ad(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:bs(ad(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:Ss(ad(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Es(ad(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:ws(ad(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Os(ad(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:Ws(ad(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:Hs(ad(e.channels))};default:throw Error(`Unsupported color notation`)}}function sd(e,t=7){e=+e,t=+t;let n=(Math.floor(Math.abs(e))+``).length;if(t>n)return+e.toFixed(t-n);{let r=10**(n-t);return Math.round(e/r)*r}}function cd(e){let t=_s(e);if(Gs(t))return Ks(t);let n=e;return n=ks(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Xo(qs(n,ld,ud))}function ld(e){return e=Mo(e),e=Io(e),Jo(e)}function ud(e){return e=ps(e),e=Vo(e),No(e)}var dd=class e{static colorTxtList=[];static parseColorString(e){try{let t=dc(Xa({css:e}));if(!t)return null;let n=id(t);if(n===!1)return null;let r=cd(od(n).channels),i=Math.min(255,Math.max(0,Math.round(sd(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(sd(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(sd(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,sd(Number.isNaN(n.alpha)?0:n.alpha)))),m.Color.create(i/255,a/255,o/255,s)}catch(e){return $.error(e),null}}static getPos(e,t){let n=Array.from(e.slice(0,t).matchAll(/\n/g)),r=n.length,i=n[r-1],a=0;i.index&&(a=i.index);let o=t-a;return m.Position.create(r,o-1)}static getMatches(e){let t=[],n=e.matchAll(/(#(?:[\da-f]{3,4}){2}|#(?:[\da-f]{3})|rgb\((?:\d{1,3},\s*){2}\d{1,3}\)|rgba\((?:\d{1,3},\s*){3}\d*\.?\d+\)|hsl\(\d{1,3}(?:,\s*\d{1,3}%){2}\)|hsla\(\d{1,3}(?:,\s*\d{1,3}%){2},\s*\d*\.?\d+\|oklab\(\s*\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*\)|oklch\(\s*\d*\.?\d+%?\s*(,| )\s*\d*\.?\d+\s*(,| )\s*\d*\.?\d+\s*\))/gi);if(n)for(let r of n){let n=r[0];if(!r.index)continue;let i=n.length,a=``;n.startsWith(`hsl(`)?a=`hsl`:n.startsWith(`hsla(`)?a=`hsla`:n.startsWith(`rgb(`)?a=`rgb`:n.startsWith(`rgba(`)?a=`rgba`:n.startsWith(`#`)?a=`hex`:n.startsWith(`oklch(`)?a=`oklch`:n.startsWith(`oklab(`)&&(a=`oklab`);let o=m.Range.create(this.getPos(e,r.index),this.getPos(e,r.index+n.length)),s=this.parseColorString(n);s&&t.push({color:s,type:a,length:i,range:o})}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(ca.Colors),t=[];for(let n of e)n!=`name`&&n!=`length`&&n!=`prototype`&&t.push(n);this.colorTxtList=t}let r=RegExp(`(?<![\\w\\d."'&$-])(`+this.colorTxtList.join(`|`)+`)(?![-\\w\\d])`,`gi`),i=e.matchAll(r);if(i)for(let n of i){let r=n[0];if(!n.index)continue;let i=r.length,a=m.Range.create(this.getPos(e,n.index),this.getPos(e,n.index+r.length)),o=this.parseColorString(ca.fromName(r).toHex());o&&t.push({color:o,type:`hex`,length:i,range:a})}return t}static onDocumentColor(t){return e.getMatches(t.getText()).map(e=>m.ColorInformation.create(e.range,e.color))}static onColorPresentations(e,t,n){let r=ca.fromRgb(n.red*255,n.green*255,n.blue*255);r.alpha=n.alpha;let i=e.getText(t),a=m.ColorPresentation.create(r.toString(`hex`)),o=m.ColorPresentation.create(r.toString(`hexa`)),s=m.ColorPresentation.create(r.toString(`hsl`)),c=m.ColorPresentation.create(r.toString(`hsla`)),l=m.ColorPresentation.create(r.toString(`rgb`)),u=m.ColorPresentation.create(r.toString(`rgba`)),d=!1;return i.startsWith(`#`)&&i.length===9&&(d=!0),i.startsWith(`hsla`)&&(d=!0),i.startsWith(`rgba`)&&(d=!0),n.alpha!==1&&(d=!0),d?[o,c,u]:[a,s,l]}},fd=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},pd=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=N.getInstance().getAllConfigFiles();for(let e of n)t.push({label:e});if(t.length>1){let n=await $.Select(t,{title:`Select a project to add section`});if(!n)return;e=n.label}else e=t[0].label}let t=await $.Select([{label:`Build`},{label:`Static`}],{title:`Section type`});if(!t)return;let n=(0,u.readFileSync)(I(e),`utf8`),r=JSON.parse(n);if(t.label==`Build`){let e=await $.Input({title:`Provide a name for your build section`});if(!e)return;let t={name:e,src:[],compile:{output:`./dist/`+e.replace(/ /g,`-`)+`.js`}};r.build.push(t)}else if(t.label==`Static`){let e=await $.Input({title:`Provide a name for your static section`});if(!e)return;let t={name:e,input:``,output:``};r.static.push(t)}(0,u.writeFileSync)(I(e),JSON.stringify(r,null,4)),fd.send(e)}catch(e){console.error(e)}}},md=class{static cmd=`aventus.compile`;static async run(){let e=[],t=N.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},hd=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(I(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=I(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=N.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},gd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},_d=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},vd=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},yd=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},bd=class{static cmd=`aventus.component.merge`;static async run(e){if(!e)return;let t=RegExp(`(`+w.ComponentLogic+`)|(`+w.ComponentView+`)|(`+w.ComponentView+`)$`),n=e.replace(t,``),r=n.split(`/`),i=r.pop(),a=r.pop(),o=r.join(`/`)+`/`+i,s=0,c=R.getInstance().getByUri(n+w.ComponentLogic);c&&c.versionUser>s&&(s=c.versionUser);let l=c?c.contentUser:``,f=R.getInstance().getByUri(n+w.ComponentStyle);f&&f.versionUser>s&&(s=f.versionUser);let p=f?f.contentUser:``,m=R.getInstance().getByUri(n+w.ComponentView);m&&m.versionUser>s&&(s=m.versionUser);let h=m?m.contentUser:``,g=`
990
990
  <script>
991
- ${bd(l)}
991
+ ${xd(l)}
992
992
  <\/script>
993
993
 
994
994
  <template>
995
- ${bd(h)}
995
+ ${xd(h)}
996
996
  </template>
997
997
 
998
998
  <style>
999
- ${bd(p)}
999
+ ${xd(p)}
1000
1000
  </style>
1001
- `,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(I(_.uri),g),f&&(ra(f.path),R.getInstance().onClose(f.documentUser),vd.send(f.uri)),c&&(ra(c.path),R.getInstance().onClose(c.documentUser),vd.send(c.uri)),m&&(ra(m.path),R.getInstance().onClose(m.documentUser),vd.send(m.uri)),(0,u.rmdirSync)(I(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),dd.send(_.uri)}};function bd(e){return e.replace(/\r\n?/g,`
1001
+ `,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(I(_.uri),g),f&&(ia(f.path),R.getInstance().onClose(f.documentUser),yd.send(f.uri)),c&&(ia(c.path),R.getInstance().onClose(c.documentUser),yd.send(c.uri)),m&&(ia(m.path),R.getInstance().onClose(m.documentUser),yd.send(m.uri)),(0,u.rmdirSync)(I(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),fd.send(_.uri)}};function xd(e){return e.replace(/\r\n?/g,`
1002
1002
  `).split(`
1003
1003
  `).join(`
1004
- `)}var xd=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(w.Component,``),n=R.getInstance().getByUri(e);if(n){let r=I(e.replace(w.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(w.Component,``)+`/`+t,a=oi.getRegion(n),o=i+w.ComponentStyle,s=d.TextDocument.create(o,C.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(I(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(I(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(I(f),p.getText()),ra(n.path),R.getInstance().onClose(n.documentUser),vd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),dd.send(p.uri)}}},Sd=class{static cmd=`aventus.liveserver.start`;static run(){D.getInstance().start()}},Cd=class{static cmd=`aventus.liveserver.toggle`;static run(){D.getInstance().toggle()}},wd=class{static cmd=`aventus.static`;static async run(){let e=[],t=N.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Static to export`});if(n){let e=n.detail??``,t=n.label;await N.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Td=class{static cmd=`aventus.liveserver.stop`;static run(){D.getInstance().stop()}},Ed=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Dd=class e{static cmd=`aventus.wc.create.attribute`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n){if(!t||typeof n!=`number`)return;let r=await $.Input({title:`Provide a name for your Attribute`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}]});if(!r)return;let i=await $.Select(e.attrType,{title:`Choose a type?`});if(!i)return;Pi(e.attrType,i);let a=i.detail,o=R.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()
1004
+ `)}var Sd=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(w.Component,``),n=R.getInstance().getByUri(e);if(n){let r=I(e.replace(w.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(w.Component,``)+`/`+t,a=si.getRegion(n),o=i+w.ComponentStyle,s=d.TextDocument.create(o,C.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(I(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(I(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(I(f),p.getText()),ia(n.path),R.getInstance().onClose(n.documentUser),yd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),fd.send(p.uri)}}},Cd=class{static cmd=`aventus.liveserver.start`;static run(){D.getInstance().start()}},wd=class{static cmd=`aventus.liveserver.toggle`;static run(){D.getInstance().toggle()}},Td=class{static cmd=`aventus.static`;static async run(){let e=[],t=N.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Static to export`});if(n){let e=n.detail??``,t=n.label;await N.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Ed=class{static cmd=`aventus.liveserver.stop`;static run(){D.getInstance().stop()}},Dd=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Od=class e{static cmd=`aventus.wc.create.attribute`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n){if(!t||typeof n!=`number`)return;let r=await $.Input({title:`Provide a name for your Attribute`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}]});if(!r)return;let i=await $.Select(e.attrType,{title:`Choose a type?`});if(!i)return;Fi(e.attrType,i);let a=i.detail,o=R.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()
1005
1005
  public `+r+e+`:`+a+`;
1006
- `,c=o.contentUser.slice(0,n),l=o.contentUser.slice(n+1,o.contentUser.length),u=c+s+l,f=d.TextDocument.create(o.uri,C.TypeScript,o.versionUser+1,u);await o.triggerContentChange(f);let p=await o.getFormatting({insertSpaces:!0,tabSize:4});await o.applyTextEdits(p);let m=[{newText:o.contentUser,range:{start:{character:0,line:0},end:i}}];Ed.send(t,[m])}}},Od=class e{static cmd=`aventus.wc.create.property`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n,r){if(!t||typeof n!=`number`)return;let i=await $.Input({title:`Provide a name for your Property`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}],value:r});if(!i)return;let a=await $.Select(e.attrType,{title:`Choose a type?`});if(!a)return;Pi(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{title:`Do you need a callback function?`});if(!s)return;let c=s.label==`Yes`,l=R.getInstance().getByUri(t);if(l){let e=l.documentUser.positionAt(l.contentUser.length),r=R.getInstance().getBuild(l.documentUser),a=``;if(r&&r.length>0){let e=r[0].tsFiles[t];e instanceof j&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
1006
+ `,c=o.contentUser.slice(0,n),l=o.contentUser.slice(n+1,o.contentUser.length),u=c+s+l,f=d.TextDocument.create(o.uri,C.TypeScript,o.versionUser+1,u);await o.triggerContentChange(f);let p=await o.getFormatting({insertSpaces:!0,tabSize:4});await o.applyTextEdits(p);let m=[{newText:o.contentUser,range:{start:{character:0,line:0},end:i}}];Dd.send(t,[m])}}},kd=class e{static cmd=`aventus.wc.create.property`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n,r){if(!t||typeof n!=`number`)return;let i=await $.Input({title:`Provide a name for your Property`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}],value:r});if(!i)return;let a=await $.Select(e.attrType,{title:`Choose a type?`});if(!a)return;Fi(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{title:`Do you need a callback function?`});if(!s)return;let c=s.label==`Yes`,l=R.getInstance().getByUri(t);if(l){let e=l.documentUser.positionAt(l.contentUser.length),r=R.getInstance().getBuild(l.documentUser),a=``;if(r&&r.length>0){let e=r[0].tsFiles[t];e instanceof j&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
1007
1007
 
1008
1008
  }`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)
1009
1009
  public `+i+u+`:`+o+`;
1010
- `,p=l.contentUser.slice(0,n),m=l.contentUser.slice(n+1,l.contentUser.length),h=p+f+m,g=d.TextDocument.create(l.uri,C.TypeScript,l.versionUser+1,h);await l.triggerContentChange(g);let _=await l.getFormatting({insertSpaces:!0,tabSize:4});await l.applyTextEdits(_);let v=[{newText:l.contentUser,range:{start:l.documentUser.positionAt(0),end:e}}];Ed.send(t,[v])}}},kd=class{static cmd=`aventus.wc.create.watch`;static async run(e,t,n){if(!e||typeof t!=`number`)return;let r=await $.Input({title:`Provide a name for your Watch variable`,value:n});if(!r)return;let i=await $.Input({title:`Provide a type for your Watch`});if(!i)return;let a=await $.Select([{label:`Yes`},{label:`No`}],{title:`Do you need a callback function?`});if(!a)return;let o=a.label==`Yes`,s=R.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=R.getInstance().getBuild(s.documentUser),c=``;if(a&&a.length>0){let t=a[0].tsFiles[e];t instanceof j&&(c=t.getComponentName())}if(c==``)return;let l=``;if(o){let e=`Aventus.`;a&&a.length>0&&a[0].isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {
1010
+ `,p=l.contentUser.slice(0,n),m=l.contentUser.slice(n+1,l.contentUser.length),h=p+f+m,g=d.TextDocument.create(l.uri,C.TypeScript,l.versionUser+1,h);await l.triggerContentChange(g);let _=await l.getFormatting({insertSpaces:!0,tabSize:4});await l.applyTextEdits(_);let v=[{newText:l.contentUser,range:{start:l.documentUser.positionAt(0),end:e}}];Dd.send(t,[v])}}},Ad=class{static cmd=`aventus.wc.create.watch`;static async run(e,t,n){if(!e||typeof t!=`number`)return;let r=await $.Input({title:`Provide a name for your Watch variable`,value:n});if(!r)return;let i=await $.Input({title:`Provide a type for your Watch`});if(!i)return;let a=await $.Select([{label:`Yes`},{label:`No`}],{title:`Do you need a callback function?`});if(!a)return;let o=a.label==`Yes`,s=R.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=R.getInstance().getBuild(s.documentUser),c=``;if(a&&a.length>0){let t=a[0].tsFiles[e];t instanceof j&&(c=t.getComponentName())}if(c==``)return;let l=``;if(o){let e=`Aventus.`;a&&a.length>0&&a[0].isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {
1011
1011
 
1012
1012
  }`}let u=`@Watch(`+l+`)
1013
1013
  public `+r+`?:`+i+`;
1014
- `,f=s.contentUser.slice(0,t),p=s.contentUser.slice(t+1,s.contentUser.length),m=f+u+p,h=d.TextDocument.create(s.uri,C.TypeScript,s.versionUser+1,m);await s.triggerContentChange(h);let g=await s.getFormatting({insertSpaces:!0,tabSize:4});await s.applyTextEdits(g);let _=[{newText:s.contentUser,range:{start:s.documentUser.positionAt(0),end:n}}];Ed.send(e,[_])}}},Ad=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof j){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,C.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];Ed.send(e,[u])}}}}}},jd=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof j){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,C.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];Ed.send(e,[u])}}}}}},Md=class{static cmd=`aventus.rename`;static async run(e){if(!P.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=I(e),a=I(r),o,s=!0;if((0,u.existsSync)(i)?o=i:(s=!1,o=a),(0,u.statSync)(o).isDirectory()){let n=i=>{let a=(0,u.readdirSync)(i);for(let o of a){let a=(0,f.join)(i,o);if((0,u.statSync)(a).isDirectory())n(a);else{let n=F(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await N.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[I(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},Nd=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString().replace(/\.wcv\.avt$/,`.wcl.avt`).replace(/\.wcs\.avt$/,`.wcl.avt`);let t=e.split(`/`),n=t[t.length-1].replace(`.wcl.avt`,``),r=await $.Input({title:`New name`,value:n,validations:[{message:`Your name isn't valid`,regex:`^[_A-Za-z0-9-]+$`}]});if(!r)return;let i=R.getInstance().getByUri(e);if(i&&i instanceof E){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=Ji(n),o=i.folderUri,s=o.replace(RegExp(a+`$`),r),c=RegExp(`(class +)`+a+` `).exec(i.contentUser),l={};if(c){let t=c.index+c[1].length,n=i.documentUser.positionAt(t),a=await i.getRename(n,r);if(a&&a.changes)for(let t in a.changes){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}let n=a.changes[t];await l[t].applyTextEdits(n)}}let f=[],p=e=>{let t=o+`/`+n+e;if((0,u.existsSync)(I(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await N.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(I(e),l[e].contentUser);(0,u.mkdirSync)(I(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(I(n),I(r)),vd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,Fi(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=I(o),n=(0,u.readdirSync)(t);n.length==0?(0,u.rmdirSync)(t):n.length==1&&n[0].endsWith(`.js`)&&(0,u.rmSync)(t,{recursive:!0,force:!0})},500)}}},Pd=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,ue.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},Fd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/popup`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Id=class{static cmd=`aventus.popupresponse`;static run(e,t){Fd.resolve(e,t)}},Ld=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=T();for(;this.waitingResponse[n]!=null;)n=T();this.waitingResponse[n]=e=>{t(e)},$.sendNotification(`aventus/askinput`,n,e)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Rd=class{static cmd=`aventus.receiveinput`;static run(e,t){Ld.resolve(e,t)}},zd=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingOptions[r]=e,this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselect`,r,e,t)})}static resolve(e,t){if(this.waitingResponse[e]){if(t)for(let n of this.waitingOptions[e])n.label==t.label&&(t=n);this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e]}}},Bd=class{static cmd=`aventus.receiveselect`;static run(e,t){zd.resolve(e,t)}},Vd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselectmultiple`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Hd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){Vd.resolve(e,t)}},Ud=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Wd=o(((e,t)=>{var n=require("child_process").exec,r=require("child_process").execSync,i=require("fs"),a=require("path"),o=i.access,s=i.accessSync,c=i.constants||i,l=process.platform==`win32`,u=function(e,t){o(e,c.F_OK,function(e){t(!e)})},d=function(e){try{return s(e,c.F_OK),!1}catch{return!0}},f=function(e,t){o(e,c.F_OK|c.X_OK,function(e){t(null,!e)})},p=function(e){try{return s(e,c.F_OK|c.X_OK),!0}catch{return!1}},m=function(e,t,r){u(e,function(i){if(!i){n(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`,function(e,t,n){r(null,!!t)});return}f(e,r)})},h=function(e,t,r){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){r(null,!1);return}n(`where `+t,function(e){e===null?r(null,!0):r(null,!1)})},g=function(e,t){if(d(e))try{return!!r(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`)}catch{return!1}return p(e)},_=function(e,t,n){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e))return!1;try{return!!r(`where `+t,{stdio:[]})}catch{return!1}},v=function(e){return/[^A-Za-z0-9_\/:=-]/.test(e)&&(e=`'`+e.replace(/'/g,`'\\''`)+`'`,e=e.replace(/^(?:'')+/g,``).replace(/\\'''/g,`\\'`)),e};l&&(v=function(e){if(/[\\]/.test(e)){var t=`"`+a.dirname(e)+`"`,n=`"`+a.basename(e)+`"`;return t+`:`+n}return`"`+e+`"`}),t.exports=function e(t,n){var r=v(t);if(!n&&typeof Promise<`u`)return new Promise(function(n,r){e(t,function(e,i){i?n(t):r(e)})});l?h(t,r,n):m(t,r,n)},t.exports.sync=function(e){var t=v(e);return l?_(e,t):g(e,t)}})),Gd=o(((e,t)=>{t.exports=Wd()}))(),Kd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},qd=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.CsharpConfig)&&(this.files[e.uri]=new Jd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Jd=class{_file;get file(){return this._file}constructor(e){this._file=e,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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},Yd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Gd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Gd.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await ji(`dotnet tool install --global AventusSharp.Converter`)}),!(0,Gd.sync)(`csharp-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : dotnet tool install --global AventusSharp.Converter`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.CsharpConfig)){let t=Object.keys(qd.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.sharp.avt found`);return}}let t=``;try{let n=(0,u.readFileSync)(I(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Kd.send(t,`compiling`);try{let{stdout:n}=await ji(`csharp-converter `+I(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Kd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;ii.send(e,r),Kd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Xd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Zd=class{static cmd=`aventus.wc.create.cssvar`;static async run(e,t){if(!e||typeof t!=`number`)return;let n=await $.Input({title:`Provide a name for your variable`});if(!n)return;let r=await $.Input({title:`Provide a default value for your variable`}),i=R.getInstance().getByUri(e);if(i){let a=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,o=n.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??n,s=r?`, `+r:``,c=i.documentUser.positionAt(i.contentUser.length),l=`--_${a}-${o}: var(--${a}-${o}${s});`,u=i.contentUser.slice(0,t),f=i.contentUser.slice(t+1,i.contentUser.length),p=u+l+f,m=d.TextDocument.create(i.uri,C.SCSS,i.versionUser+1,p);await i.triggerContentChange(m);let h=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(h);let g=[{newText:i.contentUser,range:{start:{character:0,line:0},end:c}}];Ed.send(e,[g])}}},Qd=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Story to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},$d=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},ef=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{title:`Package to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},tf=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=N.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=I(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=I(e);o.push({label:(0,f.basename)(t),detail:t})}let s=await $.Select(o,{title:`Where should I insert the transalation?`});if(s){let n=F(s.detail),r=i.i18nComponentsFiles[n]??i.tsLanguageService.i18nFiles[n],a=JSON.parse(JSON.stringify(r.parsedSrc));a[t]={};let o=r.build.buildConfig.i18n?.locales??[],c=r.build.buildConfig.i18n?.fallback??`en-GB`;for(let e of o)a[t][e]=e==c?t:pi.empty;let l=[{newText:JSON.stringify(pi.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];Ed.send(n,[l]),setTimeout(async()=>{let t=e.replace(w.ComponentView,w.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},nf=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new rf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},rf=class{_file;get file(){return this._file}constructor(e){this._file=e,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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},af=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Gd.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Gd.sync)(`php-converter`))try{if(!(0,Gd.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await ji(`composer global require aventus/transpiler`),!(0,Gd.sync)(`php-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : composer global require aventus/transpiler`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.PhpConfig)){let t=Object.keys(nf.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=I(e.replace(w.PhpConfig,`composer.json`));if((0,u.existsSync)(n)){let e=(0,u.readFileSync)(n,`utf-8`);t=JSON.parse(e).name}}catch(e){$.error(e)}this.isCompiling=!0,Kd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=I(e),{stdout:i}=await ji(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Kd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;ii.send(e,a),Kd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},of=class{static cmd=`aventus.store.connect`;static async run(e,t){if(Qr.isConnected){await $.showInformationMessage(`You are already connected with account `+Qr.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(console.log(e),console.log(t),await Qr.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},sf=class{static cmd=`aventus.store.disconnect`;static async run(){Qr.isConnected&&(await Qr.disconnect(),$.showInformationMessage(`You are disconnected`))}},cf=class{static cmd=`aventus.store.publish_package`;static async run(){if(!Qr.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=N.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=N.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await Qr.publishPackage(r);if(e instanceof $r)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},lf=class{static send(e){let t=T();return $.sendNotification(`aventus/progress_start`,t,e),t}},uf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},df=class e{config;folderPath;name=``;version=`1.0.0`;description=``;organization;tags=[];lastModified;allowQuick=!1;isProject=!1;isGlobal=!1;hasIsAllow=!1;containsError=!1;installationFolder;documentation;repository;static memory={};static async create(t){let n=(0,f.dirname)(t);if(this.memory[t]){if((0,u.statSync)(t).mtime.getTime()>this.memory[t].lastModified.getTime()){let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}}else{let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}return this.memory[t]}constructor(e,t){this.config=e,this.folderPath=t,this.lastModified=(0,u.statSync)(this.config).mtime}async postConstructor(){let e=await this.prepareScript();for(let t in e)e[t]&&(this[t]=e[t]);this.lastModified=(0,u.statSync)(this.config).mtime}init(e,t){return new Promise(n=>{try{let r=`
1014
+ `,f=s.contentUser.slice(0,t),p=s.contentUser.slice(t+1,s.contentUser.length),m=f+u+p,h=d.TextDocument.create(s.uri,C.TypeScript,s.versionUser+1,m);await s.triggerContentChange(h);let g=await s.getFormatting({insertSpaces:!0,tabSize:4});await s.applyTextEdits(g);let _=[{newText:s.contentUser,range:{start:s.documentUser.positionAt(0),end:n}}];Dd.send(e,[_])}}},jd=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof j){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,C.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];Dd.send(e,[u])}}}}}},Md=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof j){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,C.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];Dd.send(e,[u])}}}}}},Nd=class{static cmd=`aventus.rename`;static async run(e){if(!P.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=I(e),a=I(r),o,s=!0;if((0,u.existsSync)(i)?o=i:(s=!1,o=a),(0,u.statSync)(o).isDirectory()){let n=i=>{let a=(0,u.readdirSync)(i);for(let o of a){let a=(0,f.join)(i,o);if((0,u.statSync)(a).isDirectory())n(a);else{let n=F(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await N.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[I(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},Pd=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString().replace(/\.wcv\.avt$/,`.wcl.avt`).replace(/\.wcs\.avt$/,`.wcl.avt`);let t=e.split(`/`),n=t[t.length-1].replace(`.wcl.avt`,``),r=await $.Input({title:`New name`,value:n,validations:[{message:`Your name isn't valid`,regex:`^[_A-Za-z0-9-]+$`}]});if(!r)return;let i=R.getInstance().getByUri(e);if(i&&i instanceof E){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=Yi(n),o=i.folderUri,s=o.replace(RegExp(a+`$`),r),c=RegExp(`(class +)`+a+` `).exec(i.contentUser),l={};if(c){let t=c.index+c[1].length,n=i.documentUser.positionAt(t),a=await i.getRename(n,r);if(a&&a.changes)for(let t in a.changes){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}let n=a.changes[t];await l[t].applyTextEdits(n)}}let f=[],p=e=>{let t=o+`/`+n+e;if((0,u.existsSync)(I(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await N.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(I(e),l[e].contentUser);(0,u.mkdirSync)(I(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(I(n),I(r)),yd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,Ii(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=I(o),n=(0,u.readdirSync)(t);n.length==0?(0,u.rmdirSync)(t):n.length==1&&n[0].endsWith(`.js`)&&(0,u.rmSync)(t,{recursive:!0,force:!0})},500)}}},Fd=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,ue.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},Id=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/popup`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Ld=class{static cmd=`aventus.popupresponse`;static run(e,t){Id.resolve(e,t)}},Rd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=T();for(;this.waitingResponse[n]!=null;)n=T();this.waitingResponse[n]=e=>{t(e)},$.sendNotification(`aventus/askinput`,n,e)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},zd=class{static cmd=`aventus.receiveinput`;static run(e,t){Rd.resolve(e,t)}},Bd=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingOptions[r]=e,this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselect`,r,e,t)})}static resolve(e,t){if(this.waitingResponse[e]){if(t)for(let n of this.waitingOptions[e])n.label==t.label&&(t=n);this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e]}}},Vd=class{static cmd=`aventus.receiveselect`;static run(e,t){Bd.resolve(e,t)}},Hd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselectmultiple`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Ud=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){Hd.resolve(e,t)}},Wd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Gd=o(((e,t)=>{var n=require("child_process").exec,r=require("child_process").execSync,i=require("fs"),a=require("path"),o=i.access,s=i.accessSync,c=i.constants||i,l=process.platform==`win32`,u=function(e,t){o(e,c.F_OK,function(e){t(!e)})},d=function(e){try{return s(e,c.F_OK),!1}catch{return!0}},f=function(e,t){o(e,c.F_OK|c.X_OK,function(e){t(null,!e)})},p=function(e){try{return s(e,c.F_OK|c.X_OK),!0}catch{return!1}},m=function(e,t,r){u(e,function(i){if(!i){n(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`,function(e,t,n){r(null,!!t)});return}f(e,r)})},h=function(e,t,r){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){r(null,!1);return}n(`where `+t,function(e){e===null?r(null,!0):r(null,!1)})},g=function(e,t){if(d(e))try{return!!r(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`)}catch{return!1}return p(e)},_=function(e,t,n){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e))return!1;try{return!!r(`where `+t,{stdio:[]})}catch{return!1}},v=function(e){return/[^A-Za-z0-9_\/:=-]/.test(e)&&(e=`'`+e.replace(/'/g,`'\\''`)+`'`,e=e.replace(/^(?:'')+/g,``).replace(/\\'''/g,`\\'`)),e};l&&(v=function(e){if(/[\\]/.test(e)){var t=`"`+a.dirname(e)+`"`,n=`"`+a.basename(e)+`"`;return t+`:`+n}return`"`+e+`"`}),t.exports=function e(t,n){var r=v(t);if(!n&&typeof Promise<`u`)return new Promise(function(n,r){e(t,function(e,i){i?n(t):r(e)})});l?h(t,r,n):m(t,r,n)},t.exports.sync=function(e){var t=v(e);return l?_(e,t):g(e,t)}})),Kd=o(((e,t)=>{t.exports=Gd()}))(),qd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Jd=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.CsharpConfig)&&(this.files[e.uri]=new Yd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Yd=class{_file;get file(){return this._file}constructor(e){this._file=e,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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},Xd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Kd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Kd.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await Mi(`dotnet tool install --global AventusSharp.Converter`)}),!(0,Kd.sync)(`csharp-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : dotnet tool install --global AventusSharp.Converter`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.CsharpConfig)){let t=Object.keys(Jd.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.sharp.avt found`);return}}let t=``;try{let n=(0,u.readFileSync)(I(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,qd.send(t,`compiling`);try{let{stdout:n}=await Mi(`csharp-converter `+I(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)qd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;ai.send(e,r),qd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Zd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Qd=class{static cmd=`aventus.wc.create.cssvar`;static async run(e,t){if(!e||typeof t!=`number`)return;let n=await $.Input({title:`Provide a name for your variable`});if(!n)return;let r=await $.Input({title:`Provide a default value for your variable`}),i=R.getInstance().getByUri(e);if(i){let a=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,o=n.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??n,s=r?`, `+r:``,c=i.documentUser.positionAt(i.contentUser.length),l=`--_${a}-${o}: var(--${a}-${o}${s});`,u=i.contentUser.slice(0,t),f=i.contentUser.slice(t+1,i.contentUser.length),p=u+l+f,m=d.TextDocument.create(i.uri,C.SCSS,i.versionUser+1,p);await i.triggerContentChange(m);let h=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(h);let g=[{newText:i.contentUser,range:{start:{character:0,line:0},end:c}}];Dd.send(e,[g])}}},$d=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Story to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},ef=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},tf=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{title:`Package to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},nf=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=N.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=I(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=I(e);o.push({label:(0,f.basename)(t),detail:t})}let s=await $.Select(o,{title:`Where should I insert the transalation?`});if(s){let n=F(s.detail),r=i.i18nComponentsFiles[n]??i.tsLanguageService.i18nFiles[n],a=JSON.parse(JSON.stringify(r.parsedSrc));a[t]={};let o=r.build.buildConfig.i18n?.locales??[],c=r.build.buildConfig.i18n?.fallback??`en-GB`;for(let e of o)a[t][e]=e==c?t:mi.empty;let l=[{newText:JSON.stringify(mi.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];Dd.send(n,[l]),setTimeout(async()=>{let t=e.replace(w.ComponentView,w.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},rf=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new af(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},af=class{_file;get file(){return this._file}constructor(e){this._file=e,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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},of=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Kd.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Kd.sync)(`php-converter`))try{if(!(0,Kd.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Mi(`composer global require aventus/transpiler`),!(0,Kd.sync)(`php-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : composer global require aventus/transpiler`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.PhpConfig)){let t=Object.keys(rf.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=I(e.replace(w.PhpConfig,`composer.json`));if((0,u.existsSync)(n)){let e=(0,u.readFileSync)(n,`utf-8`);t=JSON.parse(e).name}}catch(e){$.error(e)}this.isCompiling=!0,qd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=I(e),{stdout:i}=await Mi(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)qd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;ai.send(e,a),qd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},sf=class{static cmd=`aventus.store.connect`;static async run(e,t){if($r.isConnected){await $.showInformationMessage(`You are already connected with account `+$r.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(console.log(e),console.log(t),await $r.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},cf=class{static cmd=`aventus.store.disconnect`;static async run(){$r.isConnected&&(await $r.disconnect(),$.showInformationMessage(`You are disconnected`))}},lf=class{static cmd=`aventus.store.publish_package`;static async run(){if(!$r.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=N.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=N.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await $r.publishPackage(r);if(e instanceof ei)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},uf=class{static send(e){let t=T();return $.sendNotification(`aventus/progress_start`,t,e),t}},df=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},ff=class e{config;folderPath;name=``;version=`1.0.0`;description=``;organization;tags=[];lastModified;allowQuick=!1;isProject=!1;isGlobal=!1;hasIsAllow=!1;containsError=!1;installationFolder;documentation;repository;static memory={};static async create(t){let n=(0,f.dirname)(t);if(this.memory[t]){if((0,u.statSync)(t).mtime.getTime()>this.memory[t].lastModified.getTime()){let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}}else{let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}return this.memory[t]}constructor(e,t){this.config=e,this.folderPath=t,this.lastModified=(0,u.statSync)(this.config).mtime}async postConstructor(){let e=await this.prepareScript();for(let t in e)e[t]&&(this[t]=e[t]);this.lastModified=(0,u.statSync)(this.config).mtime}init(e,t){return new Promise(n=>{try{let r=`
1015
1015
  import { AventusTemplate } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1016
1016
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1017
1017
 
@@ -1020,10 +1020,10 @@ public `+r+`?:`+i+`;
1020
1020
  });
1021
1021
 
1022
1022
  const t = new Template();
1023
- await t._run(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`)`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,na(this.config)+`_1.ts`);(0,u.writeFileSync)(a,r);let o=(0,ce.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
1023
+ await t._run(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`)`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,ra(this.config)+`_1.ts`);(0,u.writeFileSync)(a,r);let o=(0,ce.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
1024
1024
  `;o.stdin.write(n)};o.stdin.on(`error`,function(e){console.log(e)}),o.stdout.on(`data`,async e=>{let t=e.toString().trim(),n=[t];if(t.indexOf(`}
1025
1025
  {`)!=-1){n=t.split(`}
1026
- {`);for(let e=1;e<n.length;e++)n[e-1]+=`}`,n[e]=`{`+n[e]}try{for(let e of n){let t=JSON.parse(e);if(t.cmd==`input`){let e=t.config,n=await $.Input(e);s(t.cmd,n)}else if(t.cmd==`select`){let e=t.config,n=await $.Select(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`selectMultiple`){let e=t.config,n=await $.SelectMultiple(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`registerFile`){let e=t.config;for(let t of e)R.getInstance().onCreatedUri(F(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,y.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=N.getInstance().getMatchingBuildsByUri(F(e));if(n.length>0){let r=n[0].getNamespaceForUri(F(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=I($.getWorkspaceUri());let n=t.config;try{await ji(n,e)}catch(e){$.error(e),$.showErrorMessage(`The command `+n+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`execAdmin`){let e=t.config,n=I($.getWorkspaceUri());try{`${n}`,process.platform==`darwin`&&`${n}`,(0,ge.exec)(`cd `+n+` && `+e,(e,t,n)=>{e&&($.error(`error: `+e),$.error(`stdout: `+t),$.error(`stderr: `+n))})}catch(t){$.error(t),$.showErrorMessage(`The command `+e+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`showErrorMessage`)$.showErrorMessage(t.config);else if(t.cmd==`showWarningMessage`)$.showWarningMessage(t.config);else if(t.cmd==`showInformationMessage`)$.showInformationMessage(t.config);else if(t.cmd==`progressStart`){let e=t.config,n=lf.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;uf.send(e)}else t.cmd==`log`?$.debug(t.config):t.cmd==`error`&&console.error(t.config)}}catch(e){$.error(e),$.error(`message `+t),$.error(n)}}),o.stderr.on(`data`,e=>{console.error(`Erreur with template : ${e.toString().trim()}`)}),o.on(`close`,e=>{ra(a),n()})}catch{n()}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
1026
+ {`);for(let e=1;e<n.length;e++)n[e-1]+=`}`,n[e]=`{`+n[e]}try{for(let e of n){let t=JSON.parse(e);if(t.cmd==`input`){let e=t.config,n=await $.Input(e);s(t.cmd,n)}else if(t.cmd==`select`){let e=t.config,n=await $.Select(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`selectMultiple`){let e=t.config,n=await $.SelectMultiple(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`registerFile`){let e=t.config;for(let t of e)R.getInstance().onCreatedUri(F(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,y.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=N.getInstance().getMatchingBuildsByUri(F(e));if(n.length>0){let r=n[0].getNamespaceForUri(F(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=I($.getWorkspaceUri());let n=t.config;try{await Mi(n,e)}catch(e){$.error(e),$.showErrorMessage(`The command `+n+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`execAdmin`){let e=t.config,n=I($.getWorkspaceUri());try{`${n}`,process.platform==`darwin`&&`${n}`,(0,ge.exec)(`cd `+n+` && `+e,(e,t,n)=>{e&&($.error(`error: `+e),$.error(`stdout: `+t),$.error(`stderr: `+n))})}catch(t){$.error(t),$.showErrorMessage(`The command `+e+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`showErrorMessage`)$.showErrorMessage(t.config);else if(t.cmd==`showWarningMessage`)$.showWarningMessage(t.config);else if(t.cmd==`showInformationMessage`)$.showInformationMessage(t.config);else if(t.cmd==`progressStart`){let e=t.config,n=uf.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;df.send(e)}else t.cmd==`log`?$.debug(t.config):t.cmd==`error`&&console.error(t.config)}}catch(e){$.error(e),$.error(`message `+t),$.error(n)}}),o.stderr.on(`data`,e=>{console.error(`Erreur with template : ${e.toString().trim()}`)}),o.on(`close`,e=>{ia(a),n()})}catch{n()}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
1027
1027
  import { AventusTemplate, log } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1028
1028
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1029
1029
 
@@ -1032,16 +1032,16 @@ public `+r+`?:`+i+`;
1032
1032
  });
1033
1033
 
1034
1034
  const t = new Template();
1035
- log(t._isAllowed(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`))`,r=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=(0,f.join)(r,na(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await ji(`node --no-warnings ${i}`,{cwd:this.folderPath});if(o=e.stderr.toString(),a=e.stdout.toString().trim(),a!==`true`&&a!==`false`)throw`Result isn't a boolean`;s=a.trim()==`true`}catch(e){$.error(e),$.error(o),$.error(a),this.containsError=!0}return ra(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=na(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
1035
+ log(t._isAllowed(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`))`,r=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=(0,f.join)(r,ra(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await Mi(`node --no-warnings ${i}`,{cwd:this.folderPath});if(o=e.stderr.toString(),a=e.stdout.toString().trim(),a!==`true`&&a!==`false`)throw`Result isn't a boolean`;s=a.trim()==`true`}catch(e){$.error(e),$.error(o),$.error(a),this.containsError=!0}return ia(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=ra(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
1036
1036
  import { AventusTemplate, log } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1037
1037
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1038
1038
  const t = new Template();
1039
- log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await ji(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}ra(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},ff=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=P.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof df)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){P.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}P.getInstance().setSettings({quickCreations:e},!0)}}},pf=class{static cmd=`aventus.template.quick`;static async run(){let e=P.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof df)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await df.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await df.create(r);i&&await i.init(n,n)}},mf=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!Qr.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=I(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await df.create(t);if(e){let t=await Qr.publishTemplate(e);if(t instanceof $r)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},hf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},gf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},_f=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},vf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris(),$.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof E)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(I(e),t.contentUser)}catch(e){console.error(e)}}})}},yf=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new Ci(t,!1);await e.init();for(let t of e.getBuilds())await ri.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=ri.getInstance().packages,t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=ti.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},bf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},xf=class{static cmd=`aventus.emmet`;static async run(){ti.write(!0)}},Sf=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,Gd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}let e={"csharp-converter":`dotnet tool update --global AventusSharp.Converter`,"db-query":`dotnet tool update --global AventusSharp.DatabaseQuery`},t=[];for(let n in e)(0,Gd.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{let r=await ji(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}};const Cf={allCommandes:{[pd.cmd]:pd,[Sd.cmd]:Sd,[Td.cmd]:Td,[Cd.cmd]:Cd,[md.cmd]:md,[Md.cmd]:Md,[Nd.cmd]:Nd,[yd.cmd]:yd,[xd.cmd]:xd,[wd.cmd]:wd,[fd.cmd]:fd,[Zd.cmd]:Zd,[Dd.cmd]:Dd,[Od.cmd]:Od,[kd.cmd]:kd,[Ad.cmd]:Ad,[jd.cmd]:jd,[hd.cmd]:hd,[_d.cmd]:_d,[gd.cmd]:gd,[Pd.cmd]:Pd,[Id.cmd]:Id,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Hd.cmd]:Hd,[Ud.cmd]:Ud,[$d.cmd]:$d,[Yd.cmd]:Yd,[Sf.cmd]:Sf,[af.cmd]:af,[Xd.cmd]:Xd,[Qd.cmd]:Qd,[ef.cmd]:ef,[tf.cmd]:tf,[of.cmd]:of,[sf.cmd]:sf,[cf.cmd]:cf,[mf.cmd]:mf,[hf.cmd]:hf,[pf.cmd]:pf,[ff.cmd]:ff,[gf.cmd]:gf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf,[bf.cmd]:bf,[xf.cmd]:xf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var wf=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Tf=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>I(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),P.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=P.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=P.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=P.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await df.create(a);r&&($i(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await df.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await ji(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await df.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await ji(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await df.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await ji(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof df?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof df?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof df?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof df){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{title:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${Qr.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+Qr.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await df.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?oe.get:b.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),ra(e),n(!1)})})}catch{r.close(),ra(e),n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Ef=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Ze(),this.filesNeeded=[F((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`))];let e=$e((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>Df,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!$e(e),t},directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(require("module").builtinModules.includes(r)){let e=(0,f.join)(Ye(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,Df,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
1040
- `)}`;r.reportsUnnecessary?n.push({range:Ki(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Ki(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=Ki(n,Zi(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Of)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:qt(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(`&nbsp;`);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
1039
+ log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await Mi(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}ia(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},pf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=P.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof ff)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){P.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}P.getInstance().setSettings({quickCreations:e},!0)}}},mf=class{static cmd=`aventus.template.quick`;static async run(){let e=P.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof ff)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await ff.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await ff.create(r);i&&await i.init(n,n)}},hf=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!$r.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=I(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await ff.create(t);if(e){let t=await $r.publishTemplate(e);if(t instanceof ei)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},gf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},_f=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},vf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},yf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris(),$.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof E)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(I(e),t.contentUser)}catch(e){console.error(e)}}})}},bf=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new wi(t,!1);await e.init();for(let t of e.getBuilds())await ii.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=ii.getInstance().packages,t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=ni.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},xf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},Sf=class{static cmd=`aventus.emmet`;static async run(){ni.write(!0)}},Cf=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,Kd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}let e={"csharp-converter":`dotnet tool update --global AventusSharp.Converter`,"db-query":`dotnet tool update --global AventusSharp.DatabaseQuery`},t=[];for(let n in e)(0,Kd.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{let r=await Mi(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}};const wf={allCommandes:{[md.cmd]:md,[Cd.cmd]:Cd,[Ed.cmd]:Ed,[wd.cmd]:wd,[hd.cmd]:hd,[Nd.cmd]:Nd,[Pd.cmd]:Pd,[bd.cmd]:bd,[Sd.cmd]:Sd,[Td.cmd]:Td,[pd.cmd]:pd,[Qd.cmd]:Qd,[Od.cmd]:Od,[kd.cmd]:kd,[Ad.cmd]:Ad,[jd.cmd]:jd,[Md.cmd]:Md,[gd.cmd]:gd,[vd.cmd]:vd,[_d.cmd]:_d,[Fd.cmd]:Fd,[Ld.cmd]:Ld,[zd.cmd]:zd,[Vd.cmd]:Vd,[Ud.cmd]:Ud,[Wd.cmd]:Wd,[ef.cmd]:ef,[Xd.cmd]:Xd,[Cf.cmd]:Cf,[of.cmd]:of,[Zd.cmd]:Zd,[$d.cmd]:$d,[tf.cmd]:tf,[nf.cmd]:nf,[sf.cmd]:sf,[cf.cmd]:cf,[lf.cmd]:lf,[hf.cmd]:hf,[gf.cmd]:gf,[mf.cmd]:mf,[pf.cmd]:pf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf,[bf.cmd]:bf,[xf.cmd]:xf,[Sf.cmd]:Sf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var Tf=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Ef=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>I(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),P.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=P.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=P.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=P.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await ff.create(a);r&&(ea(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await ff.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Mi(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await ff.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await Mi(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await ff.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Mi(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof ff?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof ff?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof ff?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof ff){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{title:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${$r.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+$r.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await ff.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?oe.get:b.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),ia(e),n(!1)})})}catch{r.close(),ia(e),n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Df=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Ze(),this.filesNeeded=[F((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`))];let e=$e((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>Of,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!$e(e),t},directoryExists:e=>(0,u.existsSync)(I(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(require("module").builtinModules.includes(r)){let e=(0,f.join)(Ye(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,Of,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
1040
+ `)}`;r.reportsUnnecessary?n.push({range:qi(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:qi(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=qi(n,Qi(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,kf)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Jt(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(`&nbsp;`);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
1041
1041
  \`\`\`
1042
1042
  ***
1043
1043
  `),i+=t.join(`
1044
1044
 
1045
- `),{range:Ki(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}async findDefinition(e,t){try{let n=this.languageService.getDefinitionAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n&&n.length>0){let e=n[0],t=$e(e.fileName);if(t){let n=d.TextDocument.create(e.fileName,`typescript`,1,t);return[{uri:e.fileName,range:Ki(n,e.textSpan)}]}}}catch(e){this.printCatchError(e)}return null}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||Jt(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...kf};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageService.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:Ki(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Yt(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=e.documentInternal,i=this.languageService.getSyntacticDiagnostics(r.uri),a=this.languageService.getSemanticDiagnostics(r.uri),o=[];for(let e of i)o.push(e.code);for(let e of a)e.code!=6133&&o.push(e.code);let s=[];try{s=this.languageService.getCodeFixesAtPosition(r.uri,r.offsetAt(t.start),r.offsetAt(t.end),o,kf,Of)}catch{}for(let e of s){let t=[],i={changes:{[r.uri]:t}};for(let n of e.changes)for(let e of n.textChanges)t.push({newText:e.newText,range:Ki(r,e.span)});n.push({title:e.description,edit:i})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Df={types:[`node`],module:p.ModuleKind.ES2022,allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`],target:p.ScriptTarget.ES2025,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,experimentalDecorators:!0,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!1},Of={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},kf={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
1046
- `,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};var Af=class extends De{languageService;constructor(e){super(e),this.languageService=new Ef,this.languageService.addFile(e)}async onValidate(){return this.languageService.doValidation(this.file)}async onContentChange(){}async onSave(){}onCompletion(e,t){return this.languageService.doComplete(e,t)}onCompletionResolve(e,t){return this.languageService.doResolve(t)}onHover(e,t){return this.languageService.doHover(e,t)}onDefinition(e,t){return this.languageService.findDefinition(e,t)}onFormatting(e,t,n){return this.languageService.format(e,t,n)}onCodeAction(e,t){return this.languageService.doCodeAction(e,t)}onReferences(e,t){return this.languageService.onReferences(e,t)}onCodeLens(e){return this.languageService.onCodeLens(e)}async onRename(e,t,n){return this.languageService.onRename(e,t,n)}async onDelete(){}onGetBuild(){return null}},jf=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(w.Template)&&(new Af(e),e instanceof E&&await e.validate())}},Mf=class{};const Nf={allCommunications:{},list:[class extends Mf{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let n of t){let t=n.i18nComponentsFiles[e.uri]?.getKeyFromLocation(e.range);if(t||(t=n.tsLanguageService.i18nFiles[e.uri]?.getKeyFromLocation(e.range),t))return t}}return null}},class extends Mf{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let e of t){let t=e.buildConfig.i18n?.locales,n=e.buildConfig.i18n?.fallback;if(t&&n)return{fallback:n,locales:t}}}return null}}],isInit:!1,init:function(){if(!this.isInit){for(let e of this.list){let t=new e;this.allCommunications[t.channel()]=t}this.isInit=!0}},execute:function(e,t){this.init();let n=this.allCommunications[e];if(n)return t?Array.isArray(t)?n.run.call(n,...t):n.run.call(n,t):n.run.call(n)}};var Pf=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof df?await n.init(e,this.templateManager.findWorkspace(e)):n&&await $.localProjectManager?.createProject(e)}async createProject(e){let t=await this.readProjects(),n=await this.templateManager.query(e,t.templates);n&&await n.init(e,this.templateManager.findWorkspace(e))}readProjects(){let e=this.templateManager.getGeneralProjects(),t=this.templateManager.getGeneralProjectsLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Ff(){let e=$.savePath,t=(0,u.readdirSync)(e);for(let n of t)try{(0,u.statSync)((0,f.join)(e,n)).isDirectory()&&(0,u.rmSync)((0,f.join)(e,n),{recursive:!0,force:!0})}catch{}}function If(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Lf(e)}function Lf(e){let t=(0,u.readdirSync)(e);for(let n of t)try{let t=(0,f.join)(e,n);if((0,u.lstatSync)(t).isDirectory())Lf(t);else if(n.endsWith(`.avt`)){let e=(0,u.readFileSync)(t,`utf8`);e=e.replace(/dependances/g,`dependencies`),(0,u.writeFileSync)(t,e)}}catch(e){console.error(e)}}const Rf={"1.4.0":Ff,"1.4.1":If};var $=class e{static instance;static delayBetweenBuild(){return this.instance.connection.delayBetweenBuild()}static logLevel(){return this.instance.logLevel}static get isIDE(){return this.instance.isIDE}static sendNotification(t,...n){e.debug(`sendNotification `+t),this.instance.connection.sendNotification(t,n)}static showErrorMessage(t){e.debug(`showErrorMessage `+t),this.instance.connection.showErrorMessage(t)}static showWarningMessage(t){e.debug(`showWarningMessage `+t),this.instance.connection.showWarningMessage(t)}static showInformationMessage(t){e.debug(`showInformationMessage `+t),this.instance.connection.showInformationMessage(t)}static async showLoadingMessage(t,n){e.debug(`showLoadingMessage `+t),await this.instance.connection.showLoadingMessage(t,n)}static async ask(t){return e.debug(`ask `+t),await this.instance.connection.ask(t)}static sendDiagnostics(t,n){e.debug(`sendDiagnostics`),e.debug(t.uri);for(let n of t.diagnostics)e.debug(` `+n.message);this.instance.connection.sendDiagnostics(t,n?.buildConfig.fullname)}static Input(e){return this.instance.connection.Input(e)}static Select(e,t){return this.instance.connection.Select(e,t)}static SelectMultiple(e,t){return this.instance.connection.SelectMultiple(e,t)}static SelectFolder(e,t){return this.instance.connection.SelectFolder(e,t)}static Popup(e,...t){return this.instance.connection.Popup(e,...t)}static setSettings(e,t){return this.instance.connection.setSettings(e,t)}static get noBuild(){return this.instance._noBuild}static get savePath(){return this.instance._savePath}static get extensionPath(){return this.instance._extensionPath}static getWorkspaceUri(){return this.instance.workspaces[0]??``}static get templateManager(){return this.instance._template}static get localTemplateManager(){return this.instance._localTemplate}static get localProjectManager(){return this.instance._localProject}static refreshSettings(){return this.instance.loadSettings()}static debug(e){this.log(e,0)}static information(e){this.log(e,1)}static warning(e){this.log(e,2)}static error(e){this.writeLog(e)}static log(t,n){n>=e.logLevel()&&this.writeLog(t)}static writeLog(e){console.log(e),this.instance._logFile&&((typeof e==`object`||Array.isArray(e))&&(e=JSON.stringify(e,null,4)),(0,u.appendFileSync)((0,f.join)(this.instance._logFile),`[${new Date().toISOString()}] ${e}\n`))}connection;isLoading=!0;isDown=!1;workspaces=[];get logLevel(){return P.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;constructor(t){e.instance=this,this.connection=t,this.bindEvent()}start(){this.connection.open()}bindEvent(){this.connection.onInitialize(t=>{this.onInitialize(t),e.debug(`onInitialize`)}),this.connection.onInitialized(async()=>{e.debug(`onInitialized`),await this.onInitialized()}),this.connection.onShutdown(async()=>{e.debug(`onShutdown`),await this.onShutdown()}),this.connection.onCompletion(async(t,n)=>(e.debug(`onCompletion`),await this.onCompletion(t,n))),this.connection.onCompletionResolve(async(t,n)=>(e.debug(`onCompletionResolve`),await this.onCompletionResolve(t,n))),this.connection.onHover(async(t,n)=>(e.debug(`onHover`),await this.onHover(t,n))),this.connection.onDefinition(async(t,n)=>(e.debug(`onDefinition`),await this.onDefinition(t,n))),this.connection.onDocumentFormatting(async(t,n)=>(e.debug(`onDocumentFormatting`),await this.onDocumentFormatting(t,n))),this.connection.onCodeAction(async(t,n)=>(e.debug(`onCodeAction`),await this.onCodeAction(t,n))),this.connection.onCodeLens(async t=>(e.debug(`onCodeLens`),await this.onCodeLens(t))),this.connection.onReferences(async(t,n)=>(e.debug(`onReferences`),await this.onReferences(t,n))),this.connection.onRenameRequest(async(t,n,r)=>(e.debug(`onRenameRequest`),await this.onRenameRequest(t,n,r))),this.connection.onDocumentColor(async t=>(e.debug(`onDocumentColor`),await this.onDocumentColor(t))),this.connection.onColorPresentation(async(t,n,r)=>(e.debug(`onColorPresentation`),await this.onColorPresentation(t,n,r))),this.connection.onExecuteCommand(async t=>(e.debug(`onExecuteCommand`),await this.onExecuteCommand(t))),this.connection.onDidChangeConfiguration(async()=>(e.debug(`onDidChangeConfiguration`),await this.onDidChangeConfiguration())),this.connection.onRequest(async(t,n)=>(e.debug(`onRequest`),await Nf.execute(t,n)))}onInitialize(t){if(t.workspaceFolders)for(let e of t.workspaceFolders)this.workspaces.push(e.uri);if(!t.savePath){let e=process.env.APPDATA||(process.platform==`darwin`?process.env.HOME+`/Library/Preferences`:process.env.HOME+`/.local/share`),n=(0,f.join)(e,`Code`,`User`,`globalStorage`,`cobwebsite.aventus`);(0,u.existsSync)(n)?t.savePath=n:t.savePath=(0,f.join)(e,`aventus`)}t.extensionPath||=(0,f.dirname)(__dirname),this._noBuild=t.noBuild??!1,this.isIDE=t.isIDE,this._savePath=t.savePath,this._extensionPath=t.extensionPath,this._logFile=t.logFile,this._logFile&&(0,u.writeFileSync)(this._logFile,``),this.isIDE&&this.runUpdate(),e.debug(t)}async onInitialized(){await this.checkNodeJs()&&(await this.loadSettings(),await this.startServer())}async onShutdown(){this.isDown=!0;let e=P.getInstance().settings;e.watchFiles&&await oa.getInstance().destroy(),e.useCompilators&&(qd.getInstance().destroy(),nf.getInstance().destroy()),N.getInstance().destroyAll(),await R.getInstance().onShutdown()}async onCompletion(e,t){return this.isAllowed(e)?await R.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await R.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await R.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await R.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await R.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await R.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await R.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await R.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await R.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?ud.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?ud.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await Cf.execute(e)}async onDidChangeConfiguration(){this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(w.Base)||e.uri.endsWith(w.Config)||e.uri.endsWith(w.Template))}isStyleDocument(e){return!!(e.uri.endsWith(w.ComponentStyle)||e.uri.endsWith(w.Component)||e.uri.endsWith(w.GlobalStyle))}async loadSettings(){let e=await this.connection.getSettings();e||={},P.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},P.getInstance().setSettingsHtml(t)}async startServer(){let t=P.getInstance().settings;t.useTemplates&&(this._template=new Tf(this.workspaces),await this._template.init(),this._localTemplate=new wf(this._template),this._localProject=new Pf(this._template)),t.useCompilators&&(qd.getInstance(),nf.getInstance()),N.getInstance(),jf.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await R.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await R.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await R.getInstance().loadAllAventusFiles(this.workspaces),ti.write()):aa.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=P.getInstance().hiddenSettings.version;if(t==n||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(t)||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(n))return;let r=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0},i=Rf;for(let a in i)if(/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(a)&&r(a,n)==1&&r(a,t)!=1)try{e.information(`Running update for `+a+` (old version : `+n+`, current version : 1.4.1)`),i[a]()}catch(e){console.error(e)}P.getInstance().setHiddenSettings({version:t})},5e3)}async checkNodeJs(){let t=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!0},{stdout:n}=await ji(`node -v`),r=n.toString().trim(),i=r.match(/^v?(\d+)\.(\d+)\.(\d+)$/),a=r.startsWith(`v`)?r.slice(1):r;return!i||!t(a,`22.18.0`)?(e.showErrorMessage(`To use Aventus, you need at least the nodejs version : 22.18.0`),!1):!0}},zf=class{static cmd=`aventus/closefile`;static action(e){}},Bf=class e{static cmd=`aventus/compiled`;static timeByBuild={};static removeBuild(t){delete e.timeByBuild[t]}static action(t){let n=new Date,r=n.getHours();r<10&&(r=`0`+r);let i=n.getMinutes();i<10&&(i=`0`+i);let a=n.getSeconds();a<10&&(a=`0`+a);let o=r+`:`+i+`:`+a,s=t+` compiled at `+o;e.timeByBuild[t]=s}},Vf=class{static cmd=`aventus/editFile`;static async action(e){}},Hf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},Uf=class{static cmd=`aventus/server/stop`;static action(){}},Wf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&sp.started()}},Gf=class{static cmd=`aventus/openfile`;static action(e){}},Kf=class{static cmd=`aventus/openpreview`;static action(e){}},qf=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},Jf=class{static cmd=`aventus/registerData`;static action(e){}},Yf=class{static cmd=`aventus/registerStatic`;static action(e){}},Xf=class e{static info={loadFileTime:0,builds:{},statics:{},files:{}};static loadFileTime={cmd:`aventus/statistics/loadFileTime`,action:t=>{e.info.loadFileTime=t}};static buildTime={cmd:`aventus/statistics/buildTime`,action:(t,n)=>{let r=e.info.builds;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static staticTime={cmd:`aventus/statistics/staticTime`,action:(t,n)=>{let r=e.info.statics;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static sizeFile={cmd:`aventus/statistics/fileSize`,action:(e,t,n,r)=>{this.info.files[e]={path:e,size:t,type:n,typeName:r}}}},Zf=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},Qf=class{static cmd=`aventus/unregisterData`;static action(e){}},$f=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const ep={allNotifications:{[zf.cmd]:zf,[Bf.cmd]:Bf,[Hf.cmd]:Hf,[Uf.cmd]:Uf,[Gf.cmd]:Gf,[Kf.cmd]:Kf,[qf.cmd]:qf,[Jf.cmd]:Jf,[Yf.cmd]:Yf,[Zf.cmd]:Zf,[Qf.cmd]:Qf,[$f.cmd]:$f,[Vf.cmd]:Vf,[Wf.cmd]:Wf,[Xf.loadFileTime.cmd]:Xf.loadFileTime,[Xf.buildTime.cmd]:Xf.buildTime,[Xf.sizeFile.cmd]:Xf.sizeFile,[Xf.staticTime.cmd]:Xf.staticTime}};function tp(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=np(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function np(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var rp=class{notifications=ep;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new ip,this.config=e}async open(){this._connection.open()}delayBetweenBuild(){return 0}sendNotification(e,t){this.notifications.allNotifications[e]&&this.notifications.allNotifications[e].action.call(this.notifications.allNotifications[e],...t)}showErrorMessage(e){console.log(`[error] : `+e)}showWarningMessage(e){console.log(`[warning] : `+e)}showInformationMessage(e){console.log(`[info] : `+e)}async showLoadingMessage(e,t){process.stdout.write(e);let n=process.stdout.columns||80,r=e.split(`
1047
- `),i=0;for(let e of r)i+=Math.max(1,Math.ceil(e.length/n));try{await t();for(let e=0;e<i;e++)_e.default.clearLine(process.stdout,0),_e.default.cursorTo(process.stdout,0),e<i-1&&_e.default.moveCursor(process.stdout,0,-1)}catch(e){console.error(e)}}async ask(e){return(await this.Select([{label:`Yes`},{label:`No`}],{title:e}))?.label==`Yes`}subscribeErrors(e){this.cbErrors.push(e)}unsubscribeErrors(e){let t=this.cbErrors.indexOf(e);t>-1&&this.cbErrors.splice(t,1)}emitErrors(){for(let e in this.errorsByBuildByFile)for(let t of this.cbErrors)t(this.errorsByBuildByFile[e],e)}sendDiagnostics(e,t){let n=t=>{e.diagnostics&&e.diagnostics.length>0?t[e.uri]=e.diagnostics:t[e.uri]&&delete t[e.uri]};if(t&&this.config.errorByBuild){this.errorsByBuildByFile[t]||(this.errorsByBuildByFile[t]={});let e=this.errorsByBuildByFile[t];n(e)}else this.errorsByBuildByFile[``]||(this.errorsByBuildByFile[``]={}),n(this.errorsByBuildByFile[``]);this.emitErrors()}onInitialize(e){let t={extensionPath:(0,f.dirname)(__dirname),isIDE:!1,noBuild:this.config.noBuild,workspaceFolders:[{name:``,uri:tp(process.cwd())}]};this._connection.onInitialize(()=>{e(t)})}onInitialized(e){this._connection.onInitialized(()=>{e()})}onShutdown(e){this._connection.onShutdown(()=>{e()})}async getSettings(){return{watchFiles:this.config.watchFiles??!1,useCompilators:this.config.useCompilators??!1,useTemplates:this.config.useTemplates??!1,buildOnly:this.config.buildOnly??!0,loadFiles:this.config.loadFiles??!1,builds:this.config.builds,statics:this.config.statics,configPath:this.config.configPath,logLevel:this.config.logLevel,errorByBuild:this.config.errorByBuild,useStats:this.config.useStats}}async getSettingsHtml(){return{}}async setSettings(e,t){}onRequest(e){}async onCompletion(e){}async onCompletionResolve(e){}async onHover(e){}async onDefinition(e){}async onDocumentFormatting(e){}async onCodeAction(e){}async onCodeLens(e){}async onReferences(e){}async onRenameRequest(e){}async onDocumentColor(e){}async onColorPresentation(e){}onExecuteCommand(e){this.executeCommand=e}onDidChangeConfiguration(e){}async Input(e){let t;if(e.validations){let n=[];if(e.validations){let t=e=>{n.push(t=>t.match(new RegExp(e.regex))?null:e.message)};for(let n of e.validations)t(n)}t=async e=>{for(let t of n){let n=t(e);if(n!==null)return n}return!0}}if(e.password)return await sp.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await sp.interaction.input(n,e.value,t)}async Select(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await sp.interaction.select(n,r);for(let t of e)if(t.label==i)return t;return null}async SelectMultiple(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await sp.interaction.selectMultiple(n,r);if(!i)return null;let a=[];for(let t of i)for(let n of e)n.label==t&&a.push(n);return a.length>0?a:null}async Popup(e,...t){if(t.length>0){let n=[];for(let e of t)n.push({value:e,name:e,checked:!1});return await sp.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await sp.interaction.tree(e,`directory`,t)}},ip=class{open(){this.run(this.onInitializeCb),this.run(this.onInitializedCb)}onInitializeCb=[];onInitialize(e){this.onInitializeCb.push(e)}onInitializedCb=[];onInitialized(e){this.onInitializedCb.push(e)}stop(){this.run(this.onShutdownCb)}onShutdownCb=[];onShutdown(e){this.onShutdownCb.push(e)}run(e){for(let t of e)t()}},ap=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new op;timeout;constructor(e){this.watcher=(0,me.watch)(e+`/**/*.avt`,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onCreate.bind(this)).on(`change`,this.onChange.bind(this)).on(`unlink`,this.onDelete.bind(this))}async onCreate(e){await this.mutex.waitOne();let t=e.toString();this.stack.created.includes(t)||this.stack.created.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.deleted.indexOf(t);r!=-1&&this.stack.deleted.splice(r,1),this.mutex.release(),this.triggerTimer()}async onChange(e){await this.mutex.waitOne();let t=e.toString();!this.stack.created.includes(t)&&!this.stack.updated.includes(t)&&this.stack.updated.push(t);let n=this.stack.deleted.indexOf(t);n!=-1&&this.stack.deleted.splice(n,1),this.mutex.release(),this.triggerTimer()}async onDelete(e){await this.mutex.waitOne();let t=e.toString();this.stack.deleted.includes(t)||this.stack.deleted.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.created.indexOf(t);r!=-1&&this.stack.created.splice(r,1),this.mutex.release(),this.triggerTimer()}triggerTimer(){clearTimeout(this.timeout),setTimeout(()=>{this.sendStack()},500)}async sendStack(){await this.mutex.waitOne();for(let e of this.stack.deleted)gd.run(F(e));for(let e of this.stack.created)hd.run(F(e));for(let e of this.stack.updated)_d.run(F(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},op=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}},sp=class{static _interaction;static get interaction(){return this._interaction}static server=null;static cliConnection=null;static get connection(){return this.cliConnection?this.cliConnection._connection:null}static get notifications(){return this.cliConnection?.notifications}static waitingStart=null;static start(e){return new Promise(t=>{try{this.server||(this.cliConnection=new rp(e),e.watchFiles&&new ap(process.cwd()),this.server=new $(this.cliConnection),e.noStart?t():(this.waitingStart=()=>{this.waitingStart=null,t()},this.server.start()))}catch(e){console.log(e)}})}static started(){this.waitingStart&&this.waitingStart()}static async create(){await md.run(F(process.cwd()))}static stop(){this.connection&&this.connection.stop()}static async log(){await this.interaction.log()}static subscribeErrors(e){this.cliConnection?.subscribeErrors(e)}static unsubscribeErrors(e){this.cliConnection?.unsubscribeErrors(e)}static async executeCommand(e,...t){await this.cliConnection.executeCommand({command:e,arguments:t})}static getErrors(){return this.cliConnection?.errorsByBuildByFile??{}}static getStatistics(){return Xf.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=sp;
1045
+ `),{range:qi(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}async findDefinition(e,t){try{let n=this.languageService.getDefinitionAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n&&n.length>0){let e=n[0],t=$e(e.fileName);if(t){let n=d.TextDocument.create(e.fileName,`typescript`,1,t);return[{uri:e.fileName,range:qi(n,e.textSpan)}]}}}catch(e){this.printCatchError(e)}return null}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||Yt(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...Af};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageService.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:qi(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Xt(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=e.documentInternal,i=this.languageService.getSyntacticDiagnostics(r.uri),a=this.languageService.getSemanticDiagnostics(r.uri),o=[];for(let e of i)o.push(e.code);for(let e of a)e.code!=6133&&o.push(e.code);let s=[];try{s=this.languageService.getCodeFixesAtPosition(r.uri,r.offsetAt(t.start),r.offsetAt(t.end),o,Af,kf)}catch{}for(let e of s){let t=[],i={changes:{[r.uri]:t}};for(let n of e.changes)for(let e of n.textChanges)t.push({newText:e.newText,range:qi(r,e.span)});n.push({title:e.description,edit:i})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Of={types:[`node`],module:p.ModuleKind.ES2022,allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`],target:p.ScriptTarget.ES2025,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,experimentalDecorators:!0,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!1},kf={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},Af={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
1046
+ `,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};var jf=class extends De{languageService;constructor(e){super(e),this.languageService=new Df,this.languageService.addFile(e)}async onValidate(){return this.languageService.doValidation(this.file)}async onContentChange(){}async onSave(){}onCompletion(e,t){return this.languageService.doComplete(e,t)}onCompletionResolve(e,t){return this.languageService.doResolve(t)}onHover(e,t){return this.languageService.doHover(e,t)}onDefinition(e,t){return this.languageService.findDefinition(e,t)}onFormatting(e,t,n){return this.languageService.format(e,t,n)}onCodeAction(e,t){return this.languageService.doCodeAction(e,t)}onReferences(e,t){return this.languageService.onReferences(e,t)}onCodeLens(e){return this.languageService.onCodeLens(e)}async onRename(e,t,n){return this.languageService.onRename(e,t,n)}async onDelete(){}onGetBuild(){return null}},Mf=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(w.Template)&&(new jf(e),e instanceof E&&await e.validate())}},Nf=class{};const Pf={allCommunications:{},list:[class extends Nf{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let n of t){let t=n.i18nComponentsFiles[e.uri]?.getKeyFromLocation(e.range);if(t||(t=n.tsLanguageService.i18nFiles[e.uri]?.getKeyFromLocation(e.range),t))return t}}return null}},class extends Nf{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let e of t){let t=e.buildConfig.i18n?.locales,n=e.buildConfig.i18n?.fallback;if(t&&n)return{fallback:n,locales:t}}}return null}}],isInit:!1,init:function(){if(!this.isInit){for(let e of this.list){let t=new e;this.allCommunications[t.channel()]=t}this.isInit=!0}},execute:function(e,t){this.init();let n=this.allCommunications[e];if(n)return t?Array.isArray(t)?n.run.call(n,...t):n.run.call(n,t):n.run.call(n)}};var Ff=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof ff?await n.init(e,this.templateManager.findWorkspace(e)):n&&await $.localProjectManager?.createProject(e)}async createProject(e){let t=await this.readProjects(),n=await this.templateManager.query(e,t.templates);n&&await n.init(e,this.templateManager.findWorkspace(e))}readProjects(){let e=this.templateManager.getGeneralProjects(),t=this.templateManager.getGeneralProjectsLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function If(){let e=$.savePath,t=(0,u.readdirSync)(e);for(let n of t)try{(0,u.statSync)((0,f.join)(e,n)).isDirectory()&&(0,u.rmSync)((0,f.join)(e,n),{recursive:!0,force:!0})}catch{}}function Lf(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Rf(e)}function Rf(e){let t=(0,u.readdirSync)(e);for(let n of t)try{let t=(0,f.join)(e,n);if((0,u.lstatSync)(t).isDirectory())Rf(t);else if(n.endsWith(`.avt`)){let e=(0,u.readFileSync)(t,`utf8`);e=e.replace(/dependances/g,`dependencies`),(0,u.writeFileSync)(t,e)}}catch(e){console.error(e)}}const zf={"1.4.0":If,"1.4.1":Lf};var $=class e{static instance;static delayBetweenBuild(){return this.instance.connection.delayBetweenBuild()}static logLevel(){return this.instance.logLevel}static get isIDE(){return this.instance.isIDE}static sendNotification(t,...n){e.debug(`sendNotification `+t),this.instance.connection.sendNotification(t,n)}static showErrorMessage(t){e.debug(`showErrorMessage `+t),this.instance.connection.showErrorMessage(t)}static showWarningMessage(t){e.debug(`showWarningMessage `+t),this.instance.connection.showWarningMessage(t)}static showInformationMessage(t){e.debug(`showInformationMessage `+t),this.instance.connection.showInformationMessage(t)}static async showLoadingMessage(t,n){e.debug(`showLoadingMessage `+t),await this.instance.connection.showLoadingMessage(t,n)}static async ask(t){return e.debug(`ask `+t),await this.instance.connection.ask(t)}static sendDiagnostics(t,n){e.debug(`sendDiagnostics`),e.debug(t.uri);for(let n of t.diagnostics)e.debug(` `+n.message);this.instance.connection.sendDiagnostics(t,n?.buildConfig.fullname)}static Input(e){return this.instance.connection.Input(e)}static Select(e,t){return this.instance.connection.Select(e,t)}static SelectMultiple(e,t){return this.instance.connection.SelectMultiple(e,t)}static SelectFolder(e,t){return this.instance.connection.SelectFolder(e,t)}static Popup(e,...t){return this.instance.connection.Popup(e,...t)}static setSettings(e,t){return this.instance.connection.setSettings(e,t)}static get noBuild(){return this.instance._noBuild}static get savePath(){return this.instance._savePath}static get extensionPath(){return this.instance._extensionPath}static getWorkspaceUri(){return this.instance.workspaces[0]??``}static get templateManager(){return this.instance._template}static get localTemplateManager(){return this.instance._localTemplate}static get localProjectManager(){return this.instance._localProject}static refreshSettings(){return this.instance.loadSettings()}static debug(e){this.log(e,0)}static information(e){this.log(e,1)}static warning(e){this.log(e,2)}static error(e){this.writeLog(e)}static log(t,n){n>=e.logLevel()&&this.writeLog(t)}static writeLog(e){console.log(e),this.instance._logFile&&((typeof e==`object`||Array.isArray(e))&&(e=JSON.stringify(e,null,4)),(0,u.appendFileSync)((0,f.join)(this.instance._logFile),`[${new Date().toISOString()}] ${e}\n`))}connection;isLoading=!0;isDown=!1;workspaces=[];get logLevel(){return P.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;constructor(t){e.instance=this,this.connection=t,this.bindEvent()}start(){this.connection.open()}bindEvent(){this.connection.onInitialize(t=>{this.onInitialize(t),e.debug(`onInitialize`)}),this.connection.onInitialized(async()=>{e.debug(`onInitialized`),await this.onInitialized()}),this.connection.onShutdown(async()=>{e.debug(`onShutdown`),await this.onShutdown()}),this.connection.onCompletion(async(t,n)=>(e.debug(`onCompletion`),await this.onCompletion(t,n))),this.connection.onCompletionResolve(async(t,n)=>(e.debug(`onCompletionResolve`),await this.onCompletionResolve(t,n))),this.connection.onHover(async(t,n)=>(e.debug(`onHover`),await this.onHover(t,n))),this.connection.onDefinition(async(t,n)=>(e.debug(`onDefinition`),await this.onDefinition(t,n))),this.connection.onDocumentFormatting(async(t,n)=>(e.debug(`onDocumentFormatting`),await this.onDocumentFormatting(t,n))),this.connection.onCodeAction(async(t,n)=>(e.debug(`onCodeAction`),await this.onCodeAction(t,n))),this.connection.onCodeLens(async t=>(e.debug(`onCodeLens`),await this.onCodeLens(t))),this.connection.onReferences(async(t,n)=>(e.debug(`onReferences`),await this.onReferences(t,n))),this.connection.onRenameRequest(async(t,n,r)=>(e.debug(`onRenameRequest`),await this.onRenameRequest(t,n,r))),this.connection.onDocumentColor(async t=>(e.debug(`onDocumentColor`),await this.onDocumentColor(t))),this.connection.onColorPresentation(async(t,n,r)=>(e.debug(`onColorPresentation`),await this.onColorPresentation(t,n,r))),this.connection.onExecuteCommand(async t=>(e.debug(`onExecuteCommand`),await this.onExecuteCommand(t))),this.connection.onDidChangeConfiguration(async()=>(e.debug(`onDidChangeConfiguration`),await this.onDidChangeConfiguration())),this.connection.onRequest(async(t,n)=>(e.debug(`onRequest`),await Pf.execute(t,n)))}onInitialize(t){if(t.workspaceFolders)for(let e of t.workspaceFolders)this.workspaces.push(e.uri);if(!t.savePath){let e=process.env.APPDATA||(process.platform==`darwin`?process.env.HOME+`/Library/Preferences`:process.env.HOME+`/.local/share`),n=(0,f.join)(e,`Code`,`User`,`globalStorage`,`cobwebsite.aventus`);(0,u.existsSync)(n)?t.savePath=n:t.savePath=(0,f.join)(e,`aventus`)}t.extensionPath||=(0,f.dirname)(__dirname),this._noBuild=t.noBuild??!1,this.isIDE=t.isIDE,this._savePath=t.savePath,this._extensionPath=t.extensionPath,this._logFile=t.logFile,this._logFile&&(0,u.writeFileSync)(this._logFile,``),this.isIDE&&this.runUpdate(),e.debug(t)}async onInitialized(){await this.checkNodeJs()&&(await this.loadSettings(),await this.startServer())}async onShutdown(){this.isDown=!0;let e=P.getInstance().settings;e.watchFiles&&await sa.getInstance().destroy(),e.useCompilators&&(Jd.getInstance().destroy(),rf.getInstance().destroy()),N.getInstance().destroyAll(),await R.getInstance().onShutdown()}async onCompletion(e,t){return this.isAllowed(e)?await R.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await R.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await R.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await R.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await R.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await R.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await R.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await R.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await R.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?dd.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?dd.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await wf.execute(e)}async onDidChangeConfiguration(){this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(w.Base)||e.uri.endsWith(w.Config)||e.uri.endsWith(w.Template))}isStyleDocument(e){return!!(e.uri.endsWith(w.ComponentStyle)||e.uri.endsWith(w.Component)||e.uri.endsWith(w.GlobalStyle))}async loadSettings(){let e=await this.connection.getSettings();e||={},P.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},P.getInstance().setSettingsHtml(t)}async startServer(){let t=P.getInstance().settings;t.useTemplates&&(this._template=new Ef(this.workspaces),await this._template.init(),this._localTemplate=new Tf(this._template),this._localProject=new Ff(this._template)),t.useCompilators&&(Jd.getInstance(),rf.getInstance()),N.getInstance(),Mf.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await R.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await R.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await R.getInstance().loadAllAventusFiles(this.workspaces),ni.write()):oa.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=P.getInstance().hiddenSettings.version;if(t==n||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(t)||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(n))return;let r=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0},i=zf;for(let a in i)if(/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(a)&&r(a,n)==1&&r(a,t)!=1)try{e.information(`Running update for `+a+` (old version : `+n+`, current version : 1.4.1)`),i[a]()}catch(e){console.error(e)}P.getInstance().setHiddenSettings({version:t})},5e3)}async checkNodeJs(){let t=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!0},{stdout:n}=await Mi(`node -v`),r=n.toString().trim(),i=r.match(/^v?(\d+)\.(\d+)\.(\d+)$/),a=r.startsWith(`v`)?r.slice(1):r;return!i||!t(a,`22.18.0`)?(e.showErrorMessage(`To use Aventus, you need at least the nodejs version : 22.18.0`),!1):!0}},Bf=class{static cmd=`aventus/closefile`;static action(e){}},Vf=class e{static cmd=`aventus/compiled`;static timeByBuild={};static removeBuild(t){delete e.timeByBuild[t]}static action(t){let n=new Date,r=n.getHours();r<10&&(r=`0`+r);let i=n.getMinutes();i<10&&(i=`0`+i);let a=n.getSeconds();a<10&&(a=`0`+a);let o=r+`:`+i+`:`+a,s=t+` compiled at `+o;e.timeByBuild[t]=s}},Hf=class{static cmd=`aventus/editFile`;static async action(e){}},Uf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},Wf=class{static cmd=`aventus/server/stop`;static action(){}},Gf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&cp.started()}},Kf=class{static cmd=`aventus/openfile`;static action(e){}},qf=class{static cmd=`aventus/openpreview`;static action(e){}},Jf=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},Yf=class{static cmd=`aventus/registerData`;static action(e){}},Xf=class{static cmd=`aventus/registerStatic`;static action(e){}},Zf=class e{static info={loadFileTime:0,builds:{},statics:{},files:{}};static loadFileTime={cmd:`aventus/statistics/loadFileTime`,action:t=>{e.info.loadFileTime=t}};static buildTime={cmd:`aventus/statistics/buildTime`,action:(t,n)=>{let r=e.info.builds;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static staticTime={cmd:`aventus/statistics/staticTime`,action:(t,n)=>{let r=e.info.statics;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static sizeFile={cmd:`aventus/statistics/fileSize`,action:(e,t,n,r)=>{this.info.files[e]={path:e,size:t,type:n,typeName:r}}}},Qf=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},$f=class{static cmd=`aventus/unregisterData`;static action(e){}},ep=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const tp={allNotifications:{[Bf.cmd]:Bf,[Vf.cmd]:Vf,[Uf.cmd]:Uf,[Wf.cmd]:Wf,[Kf.cmd]:Kf,[qf.cmd]:qf,[Jf.cmd]:Jf,[Yf.cmd]:Yf,[Xf.cmd]:Xf,[Qf.cmd]:Qf,[$f.cmd]:$f,[ep.cmd]:ep,[Hf.cmd]:Hf,[Gf.cmd]:Gf,[Zf.loadFileTime.cmd]:Zf.loadFileTime,[Zf.buildTime.cmd]:Zf.buildTime,[Zf.sizeFile.cmd]:Zf.sizeFile,[Zf.staticTime.cmd]:Zf.staticTime}};function np(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=rp(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function rp(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var ip=class{notifications=tp;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new ap,this.config=e}async open(){this._connection.open()}delayBetweenBuild(){return 0}sendNotification(e,t){this.notifications.allNotifications[e]&&this.notifications.allNotifications[e].action.call(this.notifications.allNotifications[e],...t)}showErrorMessage(e){console.log(`[error] : `+e)}showWarningMessage(e){console.log(`[warning] : `+e)}showInformationMessage(e){console.log(`[info] : `+e)}async showLoadingMessage(e,t){process.stdout.write(e);let n=process.stdout.columns||80,r=e.split(`
1047
+ `),i=0;for(let e of r)i+=Math.max(1,Math.ceil(e.length/n));try{await t();for(let e=0;e<i;e++)_e.default.clearLine(process.stdout,0),_e.default.cursorTo(process.stdout,0),e<i-1&&_e.default.moveCursor(process.stdout,0,-1)}catch(e){console.error(e)}}async ask(e){return(await this.Select([{label:`Yes`},{label:`No`}],{title:e}))?.label==`Yes`}subscribeErrors(e){this.cbErrors.push(e)}unsubscribeErrors(e){let t=this.cbErrors.indexOf(e);t>-1&&this.cbErrors.splice(t,1)}emitErrors(){for(let e in this.errorsByBuildByFile)for(let t of this.cbErrors)t(this.errorsByBuildByFile[e],e)}sendDiagnostics(e,t){let n=t=>{e.diagnostics&&e.diagnostics.length>0?t[e.uri]=e.diagnostics:t[e.uri]&&delete t[e.uri]};if(t&&this.config.errorByBuild){this.errorsByBuildByFile[t]||(this.errorsByBuildByFile[t]={});let e=this.errorsByBuildByFile[t];n(e)}else this.errorsByBuildByFile[``]||(this.errorsByBuildByFile[``]={}),n(this.errorsByBuildByFile[``]);this.emitErrors()}onInitialize(e){let t={extensionPath:(0,f.dirname)(__dirname),isIDE:!1,noBuild:this.config.noBuild,workspaceFolders:[{name:``,uri:np(process.cwd())}]};this._connection.onInitialize(()=>{e(t)})}onInitialized(e){this._connection.onInitialized(()=>{e()})}onShutdown(e){this._connection.onShutdown(()=>{e()})}async getSettings(){return{watchFiles:this.config.watchFiles??!1,useCompilators:this.config.useCompilators??!1,useTemplates:this.config.useTemplates??!1,buildOnly:this.config.buildOnly??!0,loadFiles:this.config.loadFiles??!1,builds:this.config.builds,statics:this.config.statics,configPath:this.config.configPath,logLevel:this.config.logLevel,errorByBuild:this.config.errorByBuild,useStats:this.config.useStats}}async getSettingsHtml(){return{}}async setSettings(e,t){}onRequest(e){}async onCompletion(e){}async onCompletionResolve(e){}async onHover(e){}async onDefinition(e){}async onDocumentFormatting(e){}async onCodeAction(e){}async onCodeLens(e){}async onReferences(e){}async onRenameRequest(e){}async onDocumentColor(e){}async onColorPresentation(e){}onExecuteCommand(e){this.executeCommand=e}onDidChangeConfiguration(e){}async Input(e){let t;if(e.validations){let n=[];if(e.validations){let t=e=>{n.push(t=>t.match(new RegExp(e.regex))?null:e.message)};for(let n of e.validations)t(n)}t=async e=>{for(let t of n){let n=t(e);if(n!==null)return n}return!0}}if(e.password)return await cp.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await cp.interaction.input(n,e.value,t)}async Select(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await cp.interaction.select(n,r);for(let t of e)if(t.label==i)return t;return null}async SelectMultiple(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await cp.interaction.selectMultiple(n,r);if(!i)return null;let a=[];for(let t of i)for(let n of e)n.label==t&&a.push(n);return a.length>0?a:null}async Popup(e,...t){if(t.length>0){let n=[];for(let e of t)n.push({value:e,name:e,checked:!1});return await cp.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await cp.interaction.tree(e,`directory`,t)}},ap=class{open(){this.run(this.onInitializeCb),this.run(this.onInitializedCb)}onInitializeCb=[];onInitialize(e){this.onInitializeCb.push(e)}onInitializedCb=[];onInitialized(e){this.onInitializedCb.push(e)}stop(){this.run(this.onShutdownCb)}onShutdownCb=[];onShutdown(e){this.onShutdownCb.push(e)}run(e){for(let t of e)t()}},op=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new sp;timeout;constructor(e){this.watcher=(0,me.watch)(e+`/**/*.avt`,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onCreate.bind(this)).on(`change`,this.onChange.bind(this)).on(`unlink`,this.onDelete.bind(this))}async onCreate(e){await this.mutex.waitOne();let t=e.toString();this.stack.created.includes(t)||this.stack.created.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.deleted.indexOf(t);r!=-1&&this.stack.deleted.splice(r,1),this.mutex.release(),this.triggerTimer()}async onChange(e){await this.mutex.waitOne();let t=e.toString();!this.stack.created.includes(t)&&!this.stack.updated.includes(t)&&this.stack.updated.push(t);let n=this.stack.deleted.indexOf(t);n!=-1&&this.stack.deleted.splice(n,1),this.mutex.release(),this.triggerTimer()}async onDelete(e){await this.mutex.waitOne();let t=e.toString();this.stack.deleted.includes(t)||this.stack.deleted.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.created.indexOf(t);r!=-1&&this.stack.created.splice(r,1),this.mutex.release(),this.triggerTimer()}triggerTimer(){clearTimeout(this.timeout),setTimeout(()=>{this.sendStack()},500)}async sendStack(){await this.mutex.waitOne();for(let e of this.stack.deleted)_d.run(F(e));for(let e of this.stack.created)gd.run(F(e));for(let e of this.stack.updated)vd.run(F(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},sp=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}},cp=class{static _interaction;static get interaction(){return this._interaction}static server=null;static cliConnection=null;static get connection(){return this.cliConnection?this.cliConnection._connection:null}static get notifications(){return this.cliConnection?.notifications}static waitingStart=null;static start(e){return new Promise(t=>{try{this.server||(this.cliConnection=new ip(e),e.watchFiles&&new op(process.cwd()),this.server=new $(this.cliConnection),e.noStart?t():(this.waitingStart=()=>{this.waitingStart=null,t()},this.server.start()))}catch(e){console.log(e)}})}static started(){this.waitingStart&&this.waitingStart()}static async create(){await hd.run(F(process.cwd()))}static stop(){this.connection&&this.connection.stop()}static async log(){await this.interaction.log()}static subscribeErrors(e){this.cliConnection?.subscribeErrors(e)}static unsubscribeErrors(e){this.cliConnection?.unsubscribeErrors(e)}static async executeCommand(e,...t){await this.cliConnection.executeCommand({command:e,arguments:t})}static getErrors(){return this.cliConnection?.errorsByBuildByFile??{}}static getStatistics(){return Zf.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=cp;