+ 1}>{count} is bigger than is 1
+ {count} is smaller than 1
+
;
+ }
+ `)
+ ).toMatchInlineSnapshot();
+ });
+});
diff --git a/packages/transpiler/babel-preset-inula-next/test/index.test.tsx b/packages/transpiler/babel-preset-inula-next/test/index.test.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..b07ce5bc03e71d5ed45bac8dc0578bdc7ce4ba38
--- /dev/null
+++ b/packages/transpiler/babel-preset-inula-next/test/index.test.tsx
@@ -0,0 +1,233 @@
+import { describe, expect, it } from 'vitest';
+import { transform } from './presets';
+
+describe('fn2Class', () => {
+ it('should transform jsx', () => {
+ expect(
+ transform(`
+ @View
+ class A {
+ Body() {
+ return
+ }
+ }`)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class A extends View {
+ Body() {
+ let $node0;
+ $node0 = $$createElement("div");
+ return [$node0];
+ }
+ }"
+ `);
+ });
+
+ it('should transform jsx with reactive', () => {
+ expect(
+ transform(`
+ @Main
+ @View
+ class A {
+ count = 1
+ Body() {
+ return
this.count++}>{this.count}
+ }
+ }`)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class A extends View {
+ count = 1;
+ $$count = 1;
+ Body() {
+ let $node0, $node1;
+ this._$update = $changed => {
+ if ($changed & 1) {
+ $node1 && $node1.update(() => this.count, [this.count]);
+ }
+ };
+ $node0 = $$createElement("div");
+ $$delegateEvent($node0, "click", () => this._$ud(this.count++, "count"));
+ $node1 = new $$ExpNode(this.count, [this.count]);
+ $$insertNode($node0, $node1, 0);
+ $node0._$nodes = [$node1];
+ return [$node0];
+ }
+ }
+ $$render("main", A);"
+ `);
+ });
+
+ it('should transform fragment', () => {
+ expect(
+ transform(`
+ @View
+ class A {
+ Body() {
+ return <>
+
+ >
+ }
+ }`)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class A extends View {
+ Body() {
+ let $node0;
+ $node0 = $$createElement("div");
+ return [$node0];
+ }
+ }"
+ `);
+ });
+
+ it('should transform function component', () => {
+ expect(
+ transform(`
+ function MyApp() {
+ let count = 0;
+ return
count++}>{count}
+ }`)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class MyApp extends View {
+ count = 0;
+ $$count = 1;
+ Body() {
+ let $node0, $node1;
+ this._$update = $changed => {
+ if ($changed & 1) {
+ $node1 && $node1.update(() => this.count, [this.count]);
+ }
+ };
+ $node0 = $$createElement("div");
+ $$delegateEvent($node0, "click", () => this._$ud(this.count++, "count"));
+ $node1 = new $$ExpNode(this.count, [this.count]);
+ $$insertNode($node0, $node1, 0);
+ $node0._$nodes = [$node1];
+ return [$node0];
+ }
+ }"
+ `);
+ });
+
+ it('should transform function component reactively', () => {
+ expect(
+ transform(`
+ function MyComp() {
+ let count = 0
+ return <>
+
Hello dlight fn, {count}
+
+
+ >
+}`)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class MyComp extends View {
+ count = 0;
+ $$count = 1;
+ Body() {
+ let $node0, $node1, $node2, $node3, $node4;
+ this._$update = $changed => {
+ if ($changed & 1) {
+ $node2 && $node2.update(() => this.count, [this.count]);
+ }
+ };
+ $node0 = $$createElement("h1");
+ $node1 = $$createTextNode("Hello dlight fn, ", []);
+ $$insertNode($node0, $node1, 0);
+ $node2 = new $$ExpNode(this.count, [this.count]);
+ $$insertNode($node0, $node2, 1);
+ $node0._$nodes = [$node1, $node2];
+ $node3 = $$createElement("button");
+ $$delegateEvent($node3, "click", () => this._$ud(this.count += 1, "count"));
+ $node3.textContent = "Add";
+ $node4 = new Button();
+ $node4._$init(null, null, null, null);
+ return [$node0, $node3, $node4];
+ }
+ }"
+ `);
+ });
+
+ it('should transform children props', () => {
+ expect(
+ transform(`
+ function App({ children}) {
+ return
{children}
+ }
+ `)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class App extends View {
+ get children() {
+ return this._$children;
+ }
+ Body() {
+ let $node0, $node1;
+ $node0 = $$createElement("h1");
+ $node1 = new $$ExpNode(this.children, []);
+ $$insertNode($node0, $node1, 0);
+ $node0._$nodes = [$node1];
+ return [$node0];
+ }
+ }"
+ `);
+ });
+
+ it('should transform component composition', () => {
+ expect(
+ transform(`
+ function ArrayModification({name}) {
+ let arr = 1
+ return
+
{arr}
+
+ }
+
+ function MyComp() {
+ return <>
+
+ >
+ }
+ `)
+ ).toMatchInlineSnapshot(`
+ "import { createElement as $$createElement, setStyle as $$setStyle, setDataset as $$setDataset, setEvent as $$setEvent, delegateEvent as $$delegateEvent, setHTMLProp as $$setHTMLProp, setHTMLAttr as $$setHTMLAttr, setHTMLProps as $$setHTMLProps, setHTMLAttrs as $$setHTMLAttrs, createTextNode as $$createTextNode, updateText as $$updateText, insertNode as $$insertNode, ForNode as $$ForNode, CondNode as $$CondNode, ExpNode as $$ExpNode, EnvNode as $$EnvNode, TryNode as $$TryNode, SnippetNode as $$SnippetNode, PropView as $$PropView, render as $$render } from "@dlightjs/dlight";
+ class ArrayModification extends View {
+ $p$name;
+ name;
+ arr = 1;
+ $$arr = 2;
+ Body() {
+ let $node0, $node1, $node2;
+ this._$update = $changed => {
+ if ($changed & 2) {
+ $node2 && $node2.update(() => this.arr, [this.arr]);
+ }
+ };
+ $node0 = ArrayModification.$t0.cloneNode(true);
+ $node1 = $node0.firstChild;
+ $node2 = new $$ExpNode(this.arr, [this.arr]);
+ $$insertNode($node1, $node2, 0);
+ return [$node0];
+ }
+ static $t0 = (() => {
+ let $node0, $node1;
+ $node0 = $$createElement("section");
+ $node1 = $$createElement("div");
+ $node0.appendChild($node1);
+ return $node0;
+ })();
+ }
+ class MyComp extends View {
+ Body() {
+ let $node0;
+ $node0 = new ArrayModification();
+ $node0._$init([["name", "1", []]], null, null, null);
+ return [$node0];
+ }
+ }"
+ `);
+ });
+});
diff --git a/packages/transpiler/babel-preset-inula-next/test/presets.ts b/packages/transpiler/babel-preset-inula-next/test/presets.ts
new file mode 100644
index 0000000000000000000000000000000000000000..fce4800ddc1ac55c8608c6bff3a399e1db23e7fd
--- /dev/null
+++ b/packages/transpiler/babel-preset-inula-next/test/presets.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2024 Huawei Technologies Co.,Ltd.
+ *
+ * openInula is licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *
+ * http://license.coscl.org.cn/MulanPSL2
+ *
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ */
+
+import plugin from '../dist';
+import { transform as transformWithBabel } from '@babel/core';
+
+export function transform(code: string) {
+ return transformWithBabel(code, {
+ presets: [plugin],
+ filename: 'test.tsx',
+ })?.code;
+}
diff --git a/packages/transpiler/babel-preset-inula-next/tsconfig.json b/packages/transpiler/babel-preset-inula-next/tsconfig.json
new file mode 100644
index 0000000000000000000000000000000000000000..e0932d7828a8e6b8f5b2c7752a24057e6461adf0
--- /dev/null
+++ b/packages/transpiler/babel-preset-inula-next/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "module": "ESNext",
+ "lib": ["ESNext", "DOM"],
+ "moduleResolution": "Node",
+ "strict": true,
+ "esModuleInterop": true
+ },
+ "ts-node": {
+ "esm": true
+ }
+}
\ No newline at end of file
diff --git a/packages/transpiler/vite-plugin-inula-next/dist/index.js b/packages/transpiler/vite-plugin-inula-next/dist/index.js
deleted file mode 100644
index dd195ca28351785f9beadea66fd0318b9bc88782..0000000000000000000000000000000000000000
--- a/packages/transpiler/vite-plugin-inula-next/dist/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-var ut=Object.create;var _=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var H=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yt=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ft(e))!xt.call(t,r)&&r!==i&&_(t,r,{get:()=>e[r],enumerable:!(s=mt(e,r))||s.enumerable});return t};var gt=(t,e,i)=>(i=t!=null?ut(bt(t)):{},yt(e||!t||!t.__esModule?_(i,"default",{value:t,enumerable:!0}):i,t));var R=H(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.declare=G;v.declarePreset=void 0;var k={assertVersion:t=>e=>{vt(e,t.version)}};Object.assign(k,{targets:()=>()=>({}),assumption:()=>()=>{}});function G(t){return(e,i,s)=>{var r;let n;for(let a of Object.keys(k)){var o;e[a]||((o=n)!=null||(n=Et(e)),n[a]=k[a](n))}return t((r=n)!=null?r:e,i||{},s)}}var Zt=v.declarePreset=G;function Et(t){let e=null;return typeof t.version=="string"&&/^7\./.test(t.version)&&(e=Object.getPrototypeOf(t),e&&(!hasOwnProperty.call(e,"version")||!hasOwnProperty.call(e,"transform")||!hasOwnProperty.call(e,"template")||!hasOwnProperty.call(e,"types"))&&(e=null)),Object.assign({},e,t)}function vt(t,e){if(typeof t=="number"){if(!Number.isInteger(t))throw new Error("Expected string or integer value.");t=`^${t}.0.0-0`}if(typeof t!="string")throw new Error("Expected string or integer value.");let i=Error.stackTraceLimit;typeof i=="number"&&i<25&&(Error.stackTraceLimit=25);let s;throw e.slice(0,2)==="7."?s=new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${e}". You'll need to update your @babel/core version.`):s=new Error(`Requires Babel "${t}", but was loaded with "${e}". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.`),typeof i=="number"&&(Error.stackTraceLimit=i),Object.assign(s,{code:"BABEL_VERSION_UNSUPPORTED",version:e,range:t})}});var J=H(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.default=void 0;var Pt=R(),ee=w.default=(0,Pt.declare)((t,e)=>{t.assertVersion(7);let{version:i}=e;{let{legacy:r}=e;if(r!==void 0){if(typeof r!="boolean")throw new Error(".legacy must be a boolean.");if(i!==void 0)throw new Error("You can either use the .legacy or the .version option, not both.")}if(i===void 0)i=r?"legacy":"2018-09";else if(i!=="2023-11"&&i!=="2023-05"&&i!=="2023-01"&&i!=="2022-03"&&i!=="2021-12"&&i!=="2018-09"&&i!=="legacy")throw new Error("Unsupported decorators version: "+i);var{decoratorsBeforeExport:s}=e;if(s===void 0){if(i==="2021-12"||i==="2022-03")s=!1;else if(i==="2018-09")throw new Error("The decorators plugin, when .version is '2018-09' or not specified, requires a 'decoratorsBeforeExport' option, whose value must be a boolean.")}else{if(i==="legacy"||i==="2022-03"||i==="2023-01")throw new Error(`'decoratorsBeforeExport' can't be used with ${i} decorators.`);if(typeof s!="boolean")throw new Error("'decoratorsBeforeExport' must be a boolean.")}}return{name:"syntax-decorators",manipulateOptions({generatorOpts:r},n){i==="legacy"?n.plugins.push("decorators-legacy"):i==="2023-01"||i==="2023-05"||i==="2023-11"?n.plugins.push(["decorators",{allowCallParenthesized:!1}],"decoratorAutoAccessors"):i==="2022-03"?n.plugins.push(["decorators",{decoratorsBeforeExport:!1,allowCallParenthesized:!1}],"decoratorAutoAccessors"):i==="2021-12"?(n.plugins.push(["decorators",{decoratorsBeforeExport:s}],"decoratorAutoAccessors"),r.decoratorsBeforeExport=s):i==="2018-09"&&(n.plugins.push(["decorators",{decoratorsBeforeExport:s}]),r.decoratorsBeforeExport=s)}}})});import{transform as Yt}from"@babel/core";var V=gt(J(),1);import{minimatch as ot}from"minimatch";function E(t,e={},i={},s={}){function r(a,h,p){return Object.fromEntries(Object.entries(a).map(([l,d])=>[`${h}${l}`,(...c)=>(c.forEach((m,u)=>{d=d.replace(`$${u}`,m)}),p(`:D - ${t}[${h}${l}]: ${d}`))]))}let n={...r(e,"throw",a=>{throw new Error(a)}),...r(i,"error",console.error),...r(s,"warn",console.warn)};function o(a){return()=>`:D ${t}: ${a} not described`}return{...n,throwUnknown:o("throw"),errorUnknown:o("error"),warnUnknown:o("warn")}}var b=E("ViewParser",{1:"Invalid syntax in DLight's View, only accepts dot chain call expression",2:"First argument of $0() must be an expression",3:"Invalid syntax in DLight's View, only accepts expression as props",4:"Invalid Snippet calling, only accepts static snippet calling like `this.Snippet()`"},{1:"DLight only accepts ForOfStatement as for loop, skipping this statement",2:"EnvUnit must have at least one child, skipping this statement",3:"Only Env/Comp/HTMLUnit can have a statement block as its children, skipping this statement",4:"If you want to use a key in a for loop, make the first statement as a label statement like `key: item`, skipping this key for now",5:"ForUnit must have at least one child, skipping this statement",For:"ForUnit must have at least one child, skipping this statement"},{1:"EnvUnit must have at least one prop, skipping this statement and flattening its children"}),X=class{compWrapper="comp";htmlTagWrapper="tag";environmentTagName="env";expressionTagName="_";config;t;traverse;snippetNames;htmlTags;viewUnits=[];constructor(t){this.config=t,this.t=t.babelApi.types,this.traverse=t.babelApi.traverse,this.snippetNames=t.snippetNames,this.htmlTags=t.htmlTags}parse(t){return[...t.directives,...t.body].forEach(this.parseStatement.bind(this)),this.viewUnits.length===1&&this.viewUnits[0].type==="env"&&this.viewUnits[0].children.length===0?(b.error2(),[]):this.viewUnits}parseStatement(t){if(!this.isInvalidExpression(t)){if(this.t.isExpressionStatement(t)){this.parseExpression(t.expression);return}if(this.t.isTryStatement(t)){this.parseTry(t);return}if(this.t.isForOfStatement(t)){this.parseFor(t);return}if(this.t.isIfStatement(t)){this.parseIf(t);return}if(this.t.isSwitchStatement(t)){this.parseSwitch(t);return}if(this.t.isDirective(t)){this.parseText(t.value);return}if(this.t.isBlockStatement(t)){let e=this.viewUnits[this.viewUnits.length-1],i=e?.type,s=this.parseView(t);i==="html"?(delete e.props.textContent,e.children.push(...s)):i==="comp"||i==="snippet"?e.children.push(...s):i==="env"?s.length>0?e.children.push(...s):(this.viewUnits.pop(),b.error2()):b.error3()}}}parseExpression(t){if(this.t.isCallExpression(t)){this.parseTag(t);return}if(this.t.isStringLiteral(t)||this.t.isTemplateLiteral(t)){this.parseText(t);return}if(this.t.isTaggedTemplateExpression(t)){this.parseTaggedTemplate(t);return}this.viewUnits.push({type:"exp",content:this.parseProp(t),props:{}})}parseIfBranches(t){let e=[],i=t.test,s=this.t.isBlockStatement(t.consequent)?t.consequent:this.t.blockStatement([t.consequent]);if(e.push({condition:i,children:this.parseView(s)}),this.t.isIfStatement(t.alternate))e.push(...this.parseIfBranches(t.alternate));else if(t.alternate){let r=this.t.isBlockStatement(t.alternate)?t.alternate:this.t.blockStatement([t.alternate]);e.push({condition:this.t.booleanLiteral(!0),children:this.parseView(r)})}return e}parseIf(t){this.viewUnits.push({type:"if",branches:this.parseIfBranches(t)})}parseSwitch(t){let e=[];t.cases.forEach(i=>{let s=i.consequent,r=s.length===1&&this.t.isBlockStatement(s[0])?s[0]:this.t.blockStatement(s),n=this.t.isBreakStatement(r.body[r.body.length-1]);n&&r.body.pop();let o=this.parseView(r),a={case:i.test??this.t.booleanLiteral(!0),children:o,break:n};e.push(a)}),this.viewUnits.push({type:"switch",discriminant:t.discriminant,branches:e})}parseTry(t){let e=this.t.blockStatement(t.block.body),i=t.handler?.body??this.t.blockStatement([]);this.viewUnits.push({type:"try",children:this.parseView(e),exception:t.handler?.param??null,catchChildren:this.parseView(i)})}parseFor(t){let e=t.left;this.t.isVariableDeclaration(e)||b.throw1();let i=e.declarations[0].id,s=t.right,r=this.t.nullLiteral(),n=t.body,o;if(this.t.isExpressionStatement(n))o=[n];else if(this.t.isBlockStatement(n)){let l=n.body;if(l.length===0)return b.error5();let d=l[0];if(this.t.isLabeledStatement(d)&&this.t.isIdentifier(d.label)){if(d.label.name!=="key"||!this.t.isExpressionStatement(d.body))b.error4();else{let c=d.body.expression;this.t.isExpression(c)&&!(this.t.isNullLiteral(c)||this.t.isIdentifier(c)&&c.name==="undefined")&&(r=c)}o=l.slice(1)}else o=l}else return;let a=o.filter(l=>this.t.isDirective(l)),h=o.filter(l=>!this.t.isDirective(l)),p=this.t.blockStatement(h,a);this.viewUnits.push({type:"for",item:i,array:s,key:r,children:this.parseView(p)})}parseText(t){this.t.isDirectiveLiteral(t)&&(t=this.t.stringLiteral(t.value)),this.viewUnits.push({type:"text",content:t})}parseTaggedTemplate(t){if(this.t.isStringLiteral(t.tag)||this.t.isTemplateLiteral(t.tag)){this.viewUnits.push({type:"text",content:t.tag}),this.viewUnits.push({type:"text",content:t.quasi});return}this.viewUnits.push({type:"exp",content:this.parseProp(t),props:{}})}isPropView(t){if(!(this.t.isArrowFunctionExpression(t)&&(this.t.isIdentifier(t.params[0],{name:"View"})||this.t.isIdentifier(t.params[0],{name:"_View"}))))return null;let e=t.body;return this.t.isBlockStatement(e)?e:this.t.blockStatement([this.t.expressionStatement(e)])}parseProp(t){if(t&&!this.t.isExpression(t)&&b.throw3(),t=t,!t)return{value:this.t.booleanLiteral(!0),viewPropMap:{}};let e={};return this.traverse(this.valueWrapper(t),{ArrowFunctionExpression:i=>{let s=this.isPropView(i.node);if(!s)return;let r=this.uid();e[r]=this.parseView(s);let n=this.t.stringLiteral(r);i.node===t&&(t=n),i.replaceWith(n),i.skip()}}),{value:t,viewPropMap:e}}parseTag(t){let e={},i=t;for(;this.t.isMemberExpression(i?.callee)&&i?.callee?.object&&!this.isPureMemberExpression(i.callee);){let r=i.callee.property;if(!this.t.isIdentifier(r)||!this.t.isCallExpression(i.callee.object)){b.throw1();continue}let n=r.name,o=this.parseProp(i.arguments[0]);e[n]=o,i=i.callee.object}let s;if(i.arguments.length>0&&(s=this.parseProp(i.arguments[0])),this.t.isIdentifier(i.callee)){let r=i.callee.name;if(r===this.expressionTagName&&s){this.viewUnits.push({type:"exp",content:s,props:e});return}if(r===this.environmentTagName){if(Object.keys(e).length===0){b.warn1();return}this.viewUnits.push({type:"env",props:e,children:[]});return}if(this.htmlTags.includes(r)){let n=[];if(s){let o=!1;if(s.viewPropMap&&Object.keys(s.viewPropMap).length===1){let a=Object.keys(s.viewPropMap)[0];this.t.isStringLiteral(s.value,{value:a})&&(o=!0,n=s.viewPropMap[a])}o||(e.textContent=s)}this.viewUnits.push({type:"html",tag:this.t.stringLiteral(r),props:e,children:n});return}s&&(e._$content=s),this.viewUnits.push({type:"comp",tag:i.callee,props:e,children:[]});return}if(this.t.isMemberExpression(i.callee)&&this.t.isThisExpression(i.callee.object)&&this.t.isIdentifier(i.callee.property)&&this.snippetNames.includes(i.callee.property.name)){if(s&&(e.content=s),!(this.t.isMemberExpression(i.callee)&&this.t.isThisExpression(i.callee.object)&&this.t.isIdentifier(i.callee.property)))return b.throw4();this.viewUnits.push({type:"snippet",tag:i.callee.property.name,props:e,children:[]});return}if(this.t.isExpression(i.callee)){let[r,n]=this.alterTagType(i.callee);s&&(e[r==="html"?"textContent":"_$content"]=s),this.viewUnits.push({type:r,tag:n,props:e,children:[]})}}isPureMemberExpression(t){let e=!0;return this.traverse(this.valueWrapper(t),{CallExpression:()=>{e=!1}}),e}alterTagType(t){if(this.t.isCallExpression(t)&&this.t.isIdentifier(t.callee)){let e=t.callee.name,i=e===this.htmlTagWrapper?"html":e===this.compWrapper?"comp":void 0;if(i){let s=t.arguments[0];return this.t.isExpression(s)||b.throw2(e),[i,s]}}return["comp",t]}isInvalidExpression(t){return this.t.isForStatement(t)&&!this.t.isForOfStatement(t)?(b.error1(),!0):!1}valueWrapper(t){return this.t.file(this.t.program([this.t.expressionStatement(t)]))}parseView(t){return new X(this.config).parse(t)}uid(){return Math.random().toString(36).slice(2)}};function D(t,e){return new X(e).parse(t)}var q=class{htmlNamespace="html";htmlTagNamespace="tag";compTagNamespace="comp";envTagName="env";forTagName="for";ifTagName="if";elseIfTagName="else-if";elseTagName="else";customHTMLProps=["ref"];config;htmlTags;willParseTemplate;t;traverse;viewUnits=[];context;constructor(t,e={ifElseStack:[]}){this.config=t,this.t=t.babelApi.types,this.traverse=t.babelApi.traverse,this.htmlTags=t.htmlTags,this.willParseTemplate=t.parseTemplate??!0,this.context=e}parse(t){return this.t.isJSXText(t)?this.parseText(t):this.t.isJSXExpressionContainer(t)?this.parseExpression(t.expression):this.t.isJSXElement(t)?this.parseElement(t):this.t.isJSXFragment(t)&&t.children.forEach(e=>{this.parse(e)}),this.viewUnits}parseText(t){t.value.trim()&&this.viewUnits.push({type:"text",content:this.t.stringLiteral(t.value)})}parseExpression(t){if(!this.t.isJSXEmptyExpression(t)){if(this.t.isLiteral(t)&&!this.t.isTemplateLiteral(t)){this.viewUnits.push({type:"text",content:t});return}this.viewUnits.push({type:"exp",content:this.parseProp(t),props:{}})}}parseElement(t){let e,i,s=t.openingElement.name;if(this.t.isJSXIdentifier(s)){let h=s.name;if([this.ifTagName,this.elseIfTagName,this.elseTagName].includes(h))return this.parseIf(t);if(h===this.envTagName)return this.parseEnv(t);if(h===this.forTagName)return this.pareFor(t);this.htmlTags.includes(h)?(e="html",i=this.t.stringLiteral(h)):(e="comp",i=this.t.identifier(h))}else if(this.t.isJSXMemberExpression(s)){e="comp";let h=p=>this.t.isJSXMemberExpression(p.object)?this.t.memberExpression(h(p.object),this.t.identifier(p.property.name)):this.t.memberExpression(this.t.identifier(p.object.name),this.t.identifier(p.property.name));i=h(s)}else{let h=s.namespace.name;switch(h){case this.compTagNamespace:e="comp",i=this.t.identifier(s.name.name);break;case this.htmlNamespace:e="html",i=this.t.stringLiteral(s.name.name);break;case this.htmlTagNamespace:e="html",i=this.t.identifier(s.name.name);break;default:e="html",i=this.t.stringLiteral(`${h}:${s.name.name}`);break}}let r=t.openingElement.attributes,n=Object.fromEntries(r.map(h=>this.parseJSXProp(h))),o=t.children.map(h=>this.parseView(h)).flat(),a={type:e,tag:i,props:n,children:o};if(a.type==="html"&&o.length===1&&o[0].type==="text"){let h=o[0];a={...a,children:[],props:{...a.props,textContent:{value:h.content,viewPropMap:{}}}}}a.type==="html"&&(a=this.transformTemplate(a)),this.viewUnits.push(a)}parseEnv(t){let e=t.openingElement.attributes,i=Object.fromEntries(e.map(r=>this.parseJSXProp(r))),s=t.children.map(r=>this.parseView(r)).flat();this.viewUnits.push({type:"env",props:i,children:s})}parseIf(t){let e=t.openingElement.name.name;if(e===this.elseTagName){let r=this.context.ifElseStack[this.context.ifElseStack.length-1];if(!r||r.type!=="if")throw new Error(`Missing if for ${e}`);r.branches.push({condition:this.t.booleanLiteral(!0),children:t.children.map(n=>this.parseView(n)).flat()}),this.context.ifElseStack.pop();return}let i=t.openingElement.attributes.filter(r=>this.t.isJSXAttribute(r)&&r.name.name==="cond")[0];if(!i)throw new Error(`Missing condition for ${e}`);if(!this.t.isJSXAttribute(i))throw new Error(`JSXSpreadAttribute is not supported for ${e} condition`);if(!this.t.isJSXExpressionContainer(i.value)||!this.t.isExpression(i.value.expression))throw new Error(`Invalid condition for ${e}`);if(e===this.ifTagName){let r={type:"if",branches:[{condition:i.value.expression,children:t.children.map(n=>this.parseView(n)).flat()}]};this.viewUnits.push(r),this.context.ifElseStack.push(r);return}let s=this.context.ifElseStack[this.context.ifElseStack.length-1];if(!s||s.type!=="if")throw new Error(`Missing if for ${e}`);s.branches.push({condition:i.value.expression,children:t.children.map(r=>this.parseView(r)).flat()})}parseJSXProp(t){if(this.t.isJSXAttribute(t)){let e,i;this.t.isJSXNamespacedName(t.name)?(e=t.name.name.name,i=t.name.namespace.name):e=t.name.name;let s=this.t.isJSXExpressionContainer(t.value)?t.value.expression:t.value;return this.t.isJSXEmptyExpression(s)&&(s=void 0),[e,this.parseProp(s,i)]}return["*spread*",this.parseProp(t.argument)]}parseProp(t,e){if(!t)return{value:this.t.booleanLiteral(!0),viewPropMap:{}};let i={},s=r=>{let n=this.uid(),o=r.node;i[n]=this.parseView(o);let a=this.t.stringLiteral(n);o===t&&(t=a),r.replaceWith(a),r.skip()};return this.traverse(this.wrapWithFile(t),{JSXElement:s,JSXFragment:s}),{value:t,viewPropMap:i,specifier:e}}transformTemplate(t){return!this.willParseTemplate||!this.isHTMLTemplate(t)?t:(t=t,{type:"template",template:this.generateTemplate(t),mutableUnits:this.generateMutableUnits(t),props:this.parseTemplateProps(t)})}generateTemplate(t){let e=Object.fromEntries(this.filterTemplateProps(Object.entries(t.props??[]).filter(([,s])=>this.isStaticProp(s)&&!(this.t.isBooleanLiteral(s.value)&&!s.value.value)))),i=[];return t.children&&(i=t.children.map(s=>{if(s.type==="text")return s;if(s.type==="html"&&this.t.isStringLiteral(s.tag))return this.generateTemplate(s)}).filter(Boolean)),{type:"html",tag:t.tag,props:e,children:i}}generateMutableUnits(t){let e=[],i=(s,r=[])=>{let n=s.children?.filter(a=>a.type==="html"&&this.t.isStringLiteral(a.tag)||a.type==="text").length,o=-1;s.children?.forEach(a=>{if(!(a.type==="html"&&this.t.isStringLiteral(a.tag))&&a.type!=="text"){let h=o+1>=n?-1:o+1;e.push({path:[...r,h],...this.transformTemplate(a)})}else o++}),s.children?.filter(a=>a.type==="html"&&this.t.isStringLiteral(a.tag)).forEach((a,h)=>{i(a,[...r,h])})};return i(t),e}parseTemplateProps(t){let e=[],i=(s,r)=>{s.props&&Object.entries(s.props).filter(([,n])=>!this.isStaticProp(n)).forEach(([n,o])=>{e.push({tag:s.tag,name:s.tag.value,key:n,path:r,value:o.value})}),s.children?.filter(n=>n.type==="html"&&this.t.isStringLiteral(n.tag)).forEach((n,o)=>{i(n,[...r,o])})};return i(t,[]),e}isHTMLTemplate(t){return t.type==="html"&&this.t.isStringLiteral(t.tag)&&!!t.children?.some(e=>e.type==="html"&&this.t.isStringLiteral(e.tag))}isStaticProp(t){return this.t.isStringLiteral(t.value)||this.t.isNumericLiteral(t.value)||this.t.isBooleanLiteral(t.value)||this.t.isNullLiteral(t.value)}filterTemplateProps(t){return t.filter(([e])=>!e.startsWith("on")).filter(([e])=>!this.customHTMLProps.includes(e))}parseView(t){return new q({...this.config,parseTemplate:!1},this.context).parse(t)}wrapWithFile(t){return this.t.file(this.t.program([this.t.expressionStatement(t)]))}uid(){return Math.random().toString(36).slice(2)}findProp(t,e){return t.openingElement.attributes.find(s=>this.t.isJSXAttribute(s)&&s.name.name===e)}pareFor(t){let e=this.findProp(t,"each"),i=this.findProp(t,"key");if(!e)throw new Error("should clarify each prop for if");let s;if(!e.value.type!=="JSXExpressionContainer")throw new Error("each prop should be an expression");s=e.value.expression,i||console.warn("should clarify key prop for for, to improve performance");let r=left.declarations[0].id,n=t.body,o;if(this.t.isExpressionStatement(n))o=[n];else if(this.t.isBlockStatement(n)){let l=n.body;if(l.length===0)return DLError.error5();let d=l[0];if(this.t.isLabeledStatement(d)&&this.t.isIdentifier(d.label)){if(d.label.name!=="key"||!this.t.isExpressionStatement(d.body))DLError.error4();else{let c=d.body.expression;this.t.isExpression(c)&&!(this.t.isNullLiteral(c)||this.t.isIdentifier(c)&&c.name==="undefined")&&(key=c)}o=l.slice(1)}else o=l}else return;let a=o.filter(l=>this.t.isDirective(l)),h=o.filter(l=>!this.t.isDirective(l)),p=t.children.map(l=>this.parseView(l)).flat();this.viewUnits.push({type:"for",item:r,array:array.value,key,children:p})}};function K(t,e){return new q(e).parse(t)}var St=Object.defineProperty,wt=(t,e,i)=>e in t?St(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Mt=(t,e,i)=>(wt(t,typeof e!="symbol"?e+"":e,i),i),Nt=E("ReactivityParser",{1:"Invalid ViewUnit type"}),A=class{config;t;traverse;availableProperties;availableIdentifiers;dependencyMap;identifierDepMap;dependencyParseType;reactivityFuncNames;escapeNamings=["escape","$"];usedProperties=new Set;constructor(t){this.config=t,this.t=t.babelApi.types,this.traverse=t.babelApi.traverse,this.availableProperties=t.availableProperties,this.availableIdentifiers=t.availableIdentifiers,this.dependencyMap=t.dependencyMap,this.identifierDepMap=t.identifierDepMap??{},this.dependencyParseType=t.dependencyParseType??"property",this.reactivityFuncNames=t.reactivityFuncNames??[]}parse(t){return this.parseViewUnit(t)}parseViewUnit(t){return this.isHTMLTemplate(t)?this.parseTemplate(t):t.type==="text"?this.parseText(t):t.type==="html"?this.parseHTML(t):t.type==="comp"?this.parseComp(t):t.type==="for"?this.parseFor(t):t.type==="try"?this.parseTry(t):t.type==="if"?this.parseIf(t):t.type==="env"?this.parseEnv(t):t.type==="exp"?this.parseExp(t):t.type==="switch"?this.parseSwitch(t):t.type==="snippet"?this.parseSnippet(t):Nt.throw1()}parseTemplate(t){return{type:"template",template:this.generateTemplate(t),props:this.parseTemplateProps(t),mutableParticles:this.generateMutableParticles(t)}}generateTemplate(t){let e=this.filterTemplateProps(Object.entries(t.props).filter(([,s])=>this.isStaticProp(s)&&!(this.t.isBooleanLiteral(s.value)&&!s.value.value))).map(([s,r])=>[s,{...r,dependencyIndexArr:[],dependenciesNode:this.t.arrayExpression([]),dynamic:!1}]),i=[];return t.props.textContent||(i=t.children.map(s=>{if(s.type==="html"&&this.t.isStringLiteral(s.tag))return this.generateTemplate(s);if(s.type==="text"&&this.t.isStringLiteral(s.content))return this.parseText(s)}).filter(Boolean)),{type:"html",tag:t.tag,props:Object.fromEntries(e),children:i}}generateMutableParticles(t){let e=[],i=(s,r=[])=>{s.children?.forEach((n,o)=>{!(n.type==="html"&&this.t.isStringLiteral(n.tag))&&!(n.type==="text"&&this.t.isStringLiteral(n.content))&&e.push({path:[...r,o],...this.parseViewParticle(n)})}),s.children?.filter(n=>n.type==="html"&&this.t.isStringLiteral(n.tag)).forEach((n,o)=>{i(n,[...r,o])})};return i(t),e}parseTemplateProps(t){let e=[],i=(s,r)=>{Object.entries(s.props).filter(([,n])=>!this.isStaticProp(n)).forEach(([n,o])=>{e.push({tag:s.tag.value,key:n,path:r,value:o.value,...this.getDependencies(o.value)})}),s.children.filter(n=>n.type==="html"&&this.t.isStringLiteral(n.tag)||n.type==="text"&&this.t.isStringLiteral(n.content)).forEach((n,o)=>{n.type==="html"?i(n,[...r,o]):n.type==="text"&&e.push({tag:"text",key:"value",path:[...r,o],value:n.content,dependencyIndexArr:[],dependenciesNode:this.t.arrayExpression([]),dynamic:!1})})};return i(t,[]),e}parseText(t){return{type:"text",content:{value:t.content,...this.getDependencies(t.content)}}}parseHTML(t){let{dependencyIndexArr:e,dependenciesNode:i,dynamic:s}=this.getDependencies(t.tag),r={type:"html",tag:t.tag,props:{},children:[]};if(r.props=Object.fromEntries(Object.entries(t.props).map(([o,a])=>[o,this.generateDependencyProp(a)])),r.children=t.children.map(this.parseViewParticle.bind(this)),!s)return r;let n=this.uid();return{type:"exp",content:{value:this.t.stringLiteral(n),viewPropMap:{[n]:[r]},dependencyIndexArr:e,dependenciesNode:i,dynamic:s},props:{}}}parseComp(t){let{dependencyIndexArr:e,dependenciesNode:i,dynamic:s}=this.getDependencies(t.tag),r={type:"comp",tag:t.tag,props:{},children:[]};if(r.props=Object.fromEntries(Object.entries(t.props).map(([o,a])=>[o,this.generateDependencyProp(a)])),r.children=t.children.map(this.parseViewParticle.bind(this)),!s)return r;let n=this.uid();return{type:"exp",content:{value:this.t.stringLiteral(n),viewPropMap:{[n]:[r]},dependencyIndexArr:e,dependenciesNode:i,dynamic:s},props:{}}}parseFor(t){let{dependencyIndexArr:e,dependenciesNode:i,dynamic:s}=this.getDependencies(t.array),r=this.config.identifierDepMap,n=this.t.isIdentifier(t.key)&&t.key.name;this.config.identifierDepMap=Object.fromEntries(this.getIdentifiers(this.t.assignmentExpression("=",t.item,this.t.objectExpression([]))).filter(a=>!n||a!==n).map(a=>[a,e.map(h=>this.availableProperties[h])]));let o={type:"for",item:t.item,array:{value:t.array,dynamic:s,dependencyIndexArr:e,dependenciesNode:i},children:t.children.map(this.parseViewParticle.bind(this)),key:t.key};return this.config.identifierDepMap=r,o}parseIf(t){return{type:"if",branches:t.branches.map(e=>({condition:{value:e.condition,...this.getDependencies(e.condition)},children:e.children.map(this.parseViewParticle.bind(this))}))}}parseSwitch(t){return{type:"switch",discriminant:{value:t.discriminant,...this.getDependencies(t.discriminant)},branches:t.branches.map(e=>({case:{value:e.case,...this.getDependencies(e.case)},children:e.children.map(this.parseViewParticle.bind(this)),break:e.break}))}}parseTry(t){return{type:"try",children:t.children.map(this.parseViewParticle.bind(this)),exception:t.exception,catchChildren:t.catchChildren.map(this.parseViewParticle.bind(this))}}parseEnv(t){return{type:"env",props:Object.fromEntries(Object.entries(t.props).map(([e,i])=>[e,this.generateDependencyProp(i)])),children:t.children.map(this.parseViewParticle.bind(this))}}parseExp(t){return{type:"exp",content:this.generateDependencyProp(t.content),props:Object.fromEntries(Object.entries(t.props).map(([e,i])=>[e,this.generateDependencyProp(i)]))}}parseSnippet(t){let e={type:"snippet",tag:t.tag,props:{},children:[]};return t.props&&(e.props=Object.fromEntries(Object.entries(t.props).map(([i,s])=>[i,this.generateDependencyProp(s)]))),t.children&&(e.children=t.children.map(this.parseViewParticle.bind(this))),e}generateDependencyProp(t){return{value:t.value,...this.getDependencies(t.value),viewPropMap:Object.fromEntries(Object.entries(t.viewPropMap).map(([e,i])=>[e,i.map(this.parseViewParticle.bind(this))]))}}getDependencies(t){if(this.t.isFunctionExpression(t)||this.t.isArrowFunctionExpression(t))return{dynamic:!1,dependencyIndexArr:[],dependenciesNode:this.t.arrayExpression([])};let[e,i]=this.getIdentifierDependencies(t),[s,r]=this.getPropertyDependencies(t),n=this.dependencyParseType==="identifier"?e:s,o=this.getIdentifierMapDependencies(t),a=[...new Set([...n,...o])],h=[...i,...r];return{dynamic:h.length>0||a.length>0,dependencyIndexArr:a,dependenciesNode:this.t.arrayExpression(h)}}getIdentifierDependencies(t){let e=this.availableIdentifiers??this.availableProperties,i=new Set,s=new Set,r={},n=this.valueWrapper(t);this.traverse(n,{Identifier:a=>{let h=a.node.name;e.includes(h)&&(this.isAssignmentExpressionLeft(a)||this.isAssignmentFunction(a)?s.add(h):this.isStandAloneIdentifier(a)&&!this.isMemberInEscapeFunction(a)&&!this.isMemberInManualFunction(a)&&(i.add(h),this.dependencyMap[h]?.forEach(i.add.bind(i)),r[h]||(r[h]=[]),r[h].push(this.geneDependencyNode(a))))}}),s.forEach(a=>{i.delete(a),delete r[a]});let o=Object.values(r).flat();return o=o.filter((a,h)=>o.findIndex(p=>this.t.isNodesEquivalent(p,a))===h),i.forEach(this.usedProperties.add.bind(this.usedProperties)),[[...i].map(a=>this.availableProperties.indexOf(a)),o]}getPropertyDependencies(t){let e=new Set,i=new Set,s={},r=this.valueWrapper(t);this.traverse(r,{MemberExpression:o=>{if(!this.t.isIdentifier(o.node.property)||!this.t.isThisExpression(o.node.object))return;let a=o.node.property.name;this.isAssignmentExpressionLeft(o)||this.isAssignmentFunction(o)?i.add(a):this.availableProperties.includes(a)&&!this.isMemberInEscapeFunction(o)&&!this.isMemberInManualFunction(o)&&(e.add(a),this.dependencyMap[a]?.forEach(e.add.bind(e)),s[a]||(s[a]=[]),s[a].push(this.geneDependencyNode(o)))}}),i.forEach(o=>{e.delete(o),delete s[o]});let n=Object.values(s).flat();return n=n.filter((o,a)=>n.findIndex(h=>this.t.isNodesEquivalent(h,o))===a),e.forEach(this.usedProperties.add.bind(this.usedProperties)),[[...e].map(o=>this.availableProperties.indexOf(o)),n]}geneDependencyNode(t){let e=t;for(;e?.parentPath;){let s=e.parentPath;if(!(this.t.isMemberExpression(s.node,{computed:!1})||this.t.isOptionalMemberExpression(s.node)))break;e=s}let i=this.t.cloneNode(e.node);return this.traverse(this.valueWrapper(i),{MemberExpression:s=>{this.t.isThisExpression(s.node.object)||(s.node.optional=!0,s.node.type="OptionalMemberExpression")}}),i}getIdentifierMapDependencies(t){let e=new Set,i=this.valueWrapper(t);return this.traverse(i,{Identifier:s=>{let r=s.node.name;if(this.isAttrFromFunction(s,r))return;let n=this.identifierDepMap[r];!n||!Array.isArray(n)||this.isMemberInEscapeFunction(s)||this.isMemberInManualFunction(s)||n.forEach(e.add.bind(e))}}),e.forEach(this.usedProperties.add.bind(this.usedProperties)),[...e].map(s=>this.availableProperties.indexOf(s))}parseViewParticle(t){let e=new A(this.config),i=e.parse(t);return e.usedProperties.forEach(this.usedProperties.add.bind(this.usedProperties)),i}isHTMLTemplate(t){return t.type==="html"&&this.t.isStringLiteral(t.tag)&&!!t.children?.some(e=>e.type==="html"&&this.t.isStringLiteral(e.tag))}isStaticProp(t){let{value:e,viewPropMap:i}=t;return(!i||Object.keys(i).length===0)&&(this.t.isStringLiteral(e)||this.t.isNumericLiteral(e)||this.t.isBooleanLiteral(e))}filterTemplateProps(t){return t.filter(([e])=>!e.startsWith("on")).filter(([e])=>!A.customHTMLProps.includes(e))}valueWrapper(t){return this.t.file(this.t.program([this.t.isStatement(t)?t:this.t.expressionStatement(t)]))}isStandAloneIdentifier(t){let e=t.node,i=t.parentPath?.node;if(this.t.isMemberExpression(i)&&i.property===e||this.isAttrFromFunction(t,e.name))return!1;for(;t.parentPath;){if(this.t.isVariableDeclarator(t.parentPath.node)||this.t.isObjectProperty(t.parentPath.node)&&t.parentPath.node.key===t.node&&!t.parentPath.node.computed)return!1;t=t.parentPath}return!0}getIdentifiers(t){if(this.t.isIdentifier(t))return[t.name];let e=new Set;return this.traverse(this.valueWrapper(t),{Identifier:i=>{this.isStandAloneIdentifier(i)&&e.add(i.node.name)}}),[...e]}isAttrFromFunction(t,e){let i=t.parentPath,s=r=>this.t.isIdentifier(r)?r.name===e:this.t.isAssignmentPattern(r)?s(r.left):this.t.isArrayPattern(r)?r.elements.filter(Boolean).map(n=>s(n)).includes(!0):this.t.isObjectPattern(r)?r.properties.filter(n=>this.t.isObjectProperty(n)&&this.t.isIdentifier(n.key)).map(n=>n.key.name).includes(e):this.t.isRestElement(r)?s(r.argument):!1;for(;i;){let r=i.node;if(this.t.isArrowFunctionExpression(r)||this.t.isFunctionDeclaration(r)){for(let n of r.params)if(s(n))return!0}i=i.parentPath}return!1}isAssignmentExpressionLeft(t){let e=t.parentPath;for(;e&&!this.t.isStatement(e.node);){if(this.t.isAssignmentExpression(e.node)){if(e.node.left===t.node)return!0;let i=e.get("left");if(t.isDescendant(i))return!0}else if(this.t.isUpdateExpression(e.node))return!0;e=e.parentPath}return!1}isAssignmentFunction(t){let e=t.parentPath;for(;e&&this.t.isMemberExpression(e.node);)e=e.parentPath;return e?this.t.isCallExpression(e.node)&&this.t.isMemberExpression(e.node.callee)&&this.t.isIdentifier(e.node.callee.property)&&this.reactivityFuncNames.includes(e.node.callee.property.name):!1}isMemberInEscapeFunction(t){let e=!1,i=t.parentPath;for(;i;){let s=i.node;if(this.t.isCallExpression(s)&&this.t.isIdentifier(s.callee)&&this.escapeNamings.includes(s.callee.name)){e=!0;break}i=i.parentPath}return e}isMemberInManualFunction(t){let e=!1,i=t.parentPath;for(;i;){let s=i.node,r=i.parentPath?.node,n=this.t.isCallExpression(r)&&this.t.isIdentifier(r.callee)&&r.callee.name==="manual",o=this.t.isCallExpression(r)&&r.arguments[0]===s;if(n&&o){e=!0;break}i=i.parentPath}return e}uid(){return Math.random().toString(36).slice(2)}},z=A;Mt(z,"customHTMLProps",["didUpdate","willMount","didMount","willUnmount","didUnmount","element","innerHTML","props","attrs","dataset","forwardProps"]);function M(t,e){let i=new Set;return[t.map(s=>{let r=new z(e),n=r.parse(s);return r.usedProperties.forEach(i.add.bind(i)),n}),i]}var It=Object.defineProperty,Ct=(t,e,i)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,I=(t,e,i)=>(Ct(t,typeof e!="symbol"?e+"":e,i),i),N={template:"$t",node:"$node"},g=class{viewParticle;config;t;traverse;className;importMap;snippetPropMap;elementAttributeMap;alterAttributeMap;viewGenerator;constructor(t,e){this.viewParticle=t,this.config=e,this.t=e.babelApi.types,this.traverse=e.babelApi.traverse,this.className=e.className,this.importMap=e.importMap,this.snippetPropMap=e.snippetPropMap,this.viewGenerator=new C(e),this.elementAttributeMap=e.attributeMap?Object.entries(e.attributeMap).reduce((i,[s,r])=>(r.forEach(n=>{i[n]||(i[n]=[]),i[n].push(s)}),i),{}):{},this.alterAttributeMap=e.alterAttributeMap}initStatements=[];addInitStatement(...t){this.initStatements.push(...t.filter(Boolean))}classProperties=[];addStaticClassProperty(t,e){this.classProperties.push(this.t.classProperty(this.t.identifier(t),e,void 0,void 0,void 0,!0))}updateStatements={};addUpdateStatements(t,e){if(!t||t.length===0)return;let i=g.calcDependencyNum(t);this.updateStatements[i]||(this.updateStatements[i]=[]),e&&this.updateStatements[i].push(e)}addUpdateStatementsWithoutDep(t){this.updateStatements[0]||(this.updateStatements[0]=[]),this.updateStatements[0].push(t)}generate(){let t=this.run();return[this.initStatements,this.updateStatements,this.classProperties,t]}generateChildren(t,e=!0,i=!1){this.viewGenerator.nodeIdx=i?-1:this.nodeIdx,this.viewGenerator.templateIdx=this.templateIdx;let[s,r,n,o]=this.viewGenerator.generateChildren(t);return i||(this.nodeIdx=this.viewGenerator.nodeIdx),this.templateIdx=this.viewGenerator.templateIdx,this.classProperties.push(...n),e&&this.mergeStatements(r),[s,o,r,this.viewGenerator.nodeIdx]}mergeStatements(t){Object.entries(t).forEach(([e,i])=>{this.updateStatements[Number(e)]||(this.updateStatements[Number(e)]=[]),this.updateStatements[Number(e)].push(...i)})}generateChild(t,e=!0,i=!1){this.viewGenerator.nodeIdx=i?-1:this.nodeIdx,this.viewGenerator.templateIdx=this.templateIdx;let[s,r,n,o]=this.viewGenerator.generateChild(t);return i||(this.nodeIdx=this.viewGenerator.nodeIdx),this.templateIdx=this.viewGenerator.templateIdx,this.classProperties.push(...n),e&&this.mergeStatements(r),[s,o,r,this.viewGenerator.nodeIdx]}geneUpdateFunc(t){return this.t.variableDeclaration("const",[this.t.variableDeclarator(this.t.identifier("$update"),this.t.arrowFunctionExpression([this.t.identifier("$changed")],this.geneUpdateBody(t)))])}get updateParams(){return[this.t.identifier("$changed")]}geneUpdateBody(t){return this.t.blockStatement([...Object.entries(t).filter(([e])=>e!=="0").map(([e,i])=>this.t.ifStatement(this.t.binaryExpression("&",this.t.identifier("$changed"),this.t.numericLiteral(Number(e))),this.t.blockStatement(i))),...t[0]??[]])}declareNodes(t){return t===-1?[]:[this.t.variableDeclaration("let",Array.from({length:t+1},(e,i)=>this.t.variableDeclarator(this.t.identifier(`${N.node}${i}`))))]}generateReturnStatement(t){return this.t.returnStatement(this.t.arrayExpression(t.map(e=>this.t.identifier(e))))}run(){return""}nodeIdx=-1;generateNodeName(t){return`${N.node}${t??++this.nodeIdx}`}templateIdx=-1;generateTemplateName(){return`${N.template}${++this.templateIdx}`}static calcDependencyNum(t){return!t||t.length===0?0:(t=[...new Set(t)],t.reduce((e,i)=>e+(1<{i.forEach(s=>{Array.isArray(s)?t.push(...s):t.push(s)})}]}},Y=class extends g{addOnUpdate(t,e){return this.t.expressionStatement(this.t.logicalExpression("&&",this.t.identifier(t),this.t.callExpression(e,[this.t.identifier(t),...this.updateParams.slice(1)])))}addLifecycle(t,e,i){return e==="willMount"?this.addWillMount(t,i):this.addOtherLifecycle(t,i,e)}addWillMount(t,e){return this.t.expressionStatement(this.t.callExpression(e,[this.t.identifier(t)]))}addOtherLifecycle(t,e,i){return this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier("View"),this.t.identifier(`add${i[0].toUpperCase()}${i.slice(1)}`)),[this.t.identifier(t),e]))}};I(Y,"lifecycle",["willMount","didMount","willUnmount","didUnmount"]);var O=class extends Y{alterPropViews(t){return t&&Object.fromEntries(Object.entries(t).map(([e,i])=>[e,this.alterPropView(i)]))}declarePropView(t){let[e,i,s,r]=this.generateChildren(t,!1,!0);Object.keys(s).length>0&&e.unshift(this.t.expressionStatement(this.t.callExpression(this.t.identifier("$addUpdate"),[this.t.arrowFunctionExpression(this.updateParams,this.geneUpdateBody(s))]))),e.unshift(...this.declareNodes(r)),e.push(this.generateReturnStatement(i));let n=this.generateNodeName(),o=this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(n),this.t.newExpression(this.t.identifier(this.importMap.PropView),[this.t.arrowFunctionExpression([this.t.identifier("$addUpdate")],this.t.blockStatement(e))])));this.addInitStatement(o);let a=this.t.identifier(n);return this.addUpdateStatementsWithoutDep(this.optionalExpression(n,this.t.callExpression(this.t.memberExpression(a,this.t.identifier("update")),this.updateParams))),n}alterPropView(t){if(!t)return t;let{value:e,viewPropMap:i}=t;if(!i)return{...t,value:e};let s=e;return this.traverse(this.valueWrapper(e),{StringLiteral:r=>{let n=r.node.value,o=i[n];if(!o)return;let a=this.t.identifier(this.declarePropView(o));e===r.node&&(s=a),r.replaceWith(a),r.skip()}}),{...t,value:s}}static reverseDependencyIndexArr(t){let e=Object.keys(t).map(Number).reduce((s,r)=>s|r,0),i=[];for(let s=0;s{if(n!=="forwardProps"&&n!=="didUpdate"){if(r.push(...a),j.lifecycle.includes(n)){this.addInitStatement(this.addLifecycle(s,n,o));return}if(n==="ref"){this.addInitStatement(this.initElement(s,o));return}if(n==="elements"){this.addInitStatement(this.initElement(s,o,!0));return}if(n==="_$content"){this.addUpdateStatements(a,this.setCompContent(s,o,h));return}if(n==="props"){this.addUpdateStatements(a,this.setCompProps(s,o,h));return}this.addUpdateStatements(a,this.setCompProp(s,n,o,h))}}),t.didUpdate&&this.addUpdateStatements(r,this.addOnUpdate(s,t.didUpdate.value)),s}generateCompProps(t){return Object.keys(t).length===0?this.t.nullLiteral():this.t.arrayExpression(Object.entries(t).map(([e,{value:i,dependenciesNode:s}])=>this.t.arrayExpression([this.t.stringLiteral(e),i,s])))}declareCompNode(t,e,i,s){let r="forwardProps"in i,n=Object.fromEntries(Object.entries(i).filter(([a])=>!["ref","elements","forwardProps","_$content","didUpdate","props",...j.lifecycle].includes(a))),o=i._$content;return[this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(e,[]))),this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("_$init")),[this.generateCompProps(n),o?this.t.arrayExpression([o.value,o.dependenciesNode]):this.t.nullLiteral(),s.length>0?this.t.identifier(this.declarePropView(s)):this.t.nullLiteral(),r?this.t.identifier("this"):this.t.nullLiteral()]))]}setCompContent(t,e,i){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("_$setContent")),[this.t.arrowFunctionExpression([],e),i]))}setCompProp(t,e,i,s){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("_$setProp")),[this.t.stringLiteral(e),this.t.arrowFunctionExpression([],i),s]))}setCompProps(t,e,i){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("_$setProps")),[this.t.arrowFunctionExpression([],e),i]))}},tt=E("ViewGenerator",{1:"Element prop in HTML should be a function or an identifier",2:"Unrecognized HTML common prop",3:"Do prop only accepts function or arrow function"},{},{1:"ExpressionNode only supports prop as element and lifecycle, receiving $0"}),y=class extends Z{addHTMLProp(t,e,i,s,r,n,o){return r?(this.addUpdateStatements(n,this.setDynamicHTMLProp(t,e,i,s,o,!0)),this.setDynamicHTMLProp(t,e,i,s,o,!1)):this.setStaticHTMLProp(t,e,i,s)}insertNode(t,e,i){return this.t.expressionStatement(this.t.callExpression(this.t.identifier(this.importMap.insertNode),[this.t.identifier(t),this.t.identifier(e),this.t.numericLiteral(i)]))}setPropWithCheck(t,e,i){return i?this.optionalExpression(t,e):this.t.expressionStatement(e)}setHTMLStyle(t,e,i){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setStyle),[this.t.identifier(t),e]),i)}setHTMLDataset(t,e,i){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setDataset),[this.t.identifier(t),e]),i)}setHTMLProp(t,e,i){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier(t),this.t.identifier(e)),i))}setHTMLAttr(t,e,i){return this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("setAttribute")),[this.t.stringLiteral(e),i]))}setHTMLEvent(t,e,i){return this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("addEventListener")),[this.t.stringLiteral(e),i]))}setEvent(t,e,i,s){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setEvent),[this.t.identifier(t),this.t.stringLiteral(e),i]),s)}delegateEvent(t,e,i,s){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.delegateEvent),[this.t.identifier(t),this.t.stringLiteral(e),i]),s)}setCachedProp(t,e,i,s,r){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setHTMLProp),[this.t.identifier(t),this.t.stringLiteral(e),this.t.arrowFunctionExpression([],i),s]),r)}setCachedAttr(t,e,i,s,r){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setHTMLAttr),[this.t.identifier(t),this.t.stringLiteral(e),this.t.arrowFunctionExpression([],i),s]),r)}setHTMLPropObject(t,e,i){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setHTMLProps),[this.t.identifier(t),e]),i)}setHTMLAttrObject(t,e,i){return this.setPropWithCheck(t,this.t.callExpression(this.t.identifier(this.importMap.setHTMLAttrs),[this.t.identifier(t),e]),i)}addCommonHTMLProp(t,e,i,s){return y.lifecycle.includes(e)?s?null:this.addLifecycle(t,e,i):e==="ref"?s?null:this.initElement(t,i):e==="style"?this.setHTMLStyle(t,i,s):e==="dataset"?this.setHTMLDataset(t,i,s):e==="props"?this.setHTMLPropObject(t,i,s):e==="attrs"?this.setHTMLAttrObject(t,i,s):e==="forwardProps"?this.forwardProps(t):tt.throw2()}setStaticHTMLProp(t,e,i,s){if(y.commonHTMLPropKeys.includes(i))return this.addCommonHTMLProp(t,i,s,!1);if(i.startsWith("on")){let r=i.slice(2).toLowerCase();return y.DelegatedEvents.has(r)?this.delegateEvent(t,r,s,!1):this.setHTMLEvent(t,r,s)}return this.isInternalAttribute(e,i)?(i==="class"?i="className":i==="for"&&(i="htmlFor"),this.setHTMLProp(t,i,s)):this.setHTMLAttr(t,i,s)}setDynamicHTMLProp(t,e,i,s,r,n){if(y.commonHTMLPropKeys.includes(i))return this.addCommonHTMLProp(t,i,s,n);if(i.startsWith("on")){let o=i.slice(2).toLowerCase();return y.DelegatedEvents.has(o)?this.delegateEvent(t,o,s,n):this.setEvent(t,o,s,n)}return this.alterAttributeMap[i]&&(i=this.alterAttributeMap[i]),this.isInternalAttribute(e,i)?this.setCachedProp(t,i,s,r,n):this.setCachedAttr(t,i,s,r,n)}isInternalAttribute(t,e){return this.elementAttributeMap["*"]?.includes(e)||this.elementAttributeMap[t]?.includes(e)}},P=y;I(P,"DelegatedEvents",new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]));I(P,"commonHTMLPropKeys",["style","dataset","props","ref","attrs","forwardProps",...y.lifecycle]);var Lt=class extends P{run(){let{tag:t,props:e,children:i}=this.viewParticle,s=this.generateNodeName();this.addInitStatement(this.declareHTMLNode(s,t));let r=this.t.isStringLiteral(t)?t.value:"ANY",n=[];Object.entries(e).forEach(([h,{value:p,dependencyIndexArr:l,dependenciesNode:d,dynamic:c}])=>{h!=="didUpdate"&&(n.push(...l??[]),this.addInitStatement(this.addHTMLProp(s,r,h,p,c,l,d)))}),e.didUpdate&&this.addUpdateStatements(n,this.addOnUpdate(s,e.didUpdate.value));let o=[],a=!1;return i.forEach((h,p)=>{let[l,d]=this.generateChild(h);o.push(d),this.addInitStatement(...l),h.type==="html"?this.addInitStatement(this.appendChild(s,d)):(a=!0,this.addInitStatement(this.insertNode(s,d,p)))}),a&&this.addInitStatement(this.setHTMLNodes(s,o)),s}declareHTMLNode(t,e){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.callExpression(this.t.identifier(this.importMap.createElement),[e])))}setHTMLNodes(t,e){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier(t),this.t.identifier("_$nodes")),this.t.arrayExpression(e.map(i=>this.t.identifier(i)))))}appendChild(t,e){return this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("appendChild")),[this.t.identifier(e)]))}},F=class extends P{run(){let{template:t,mutableParticles:e,props:i}=this.viewParticle,s=this.generateNodeName(),r=this.addTemplate(t);this.addInitStatement(this.declareTemplateNode(s,r));let n=[];i.forEach(({path:p})=>{n.push(p)}),e.forEach(({path:p})=>{n.push(p.slice(0,-1))});let[o,a]=this.insertElements(n,s);this.addInitStatement(...o);let h={};return i.forEach(({tag:p,path:l,key:d,value:c,dependencyIndexArr:m,dependenciesNode:u,dynamic:f})=>{let x=a[l.join(".")];if(h[x]||(h[x]={deps:[]}),d==="didUpdate"){h[x].value=c;return}h[x].deps.push(...m),this.addInitStatement(this.addHTMLProp(x,p,d,c,f,m,u))}),Object.entries(h).forEach(([p,{deps:l,value:d}])=>{d&&this.addUpdateStatements(l,this.addOnUpdate(p,d))}),e.forEach(p=>{let l=p.path,d=a[l.slice(0,-1).join(".")],[c,m]=this.generateChild(p);this.addInitStatement(...c),this.addInitStatement(this.insertNode(d,m,l[l.length-1]))}),s}addTemplate(t){let e=this.generateTemplateName(),[i,s,,r]=this.generateChild(t,!1,!0);return this.addStaticClassProperty(e,this.t.callExpression(this.t.arrowFunctionExpression([],this.t.blockStatement([...this.declareNodes(r),...i,this.t.returnStatement(this.t.identifier(s))])),[])),e}declareTemplateNode(t,e){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.callExpression(this.t.memberExpression(this.t.memberExpression(this.t.identifier(this.className),this.t.identifier(e)),this.t.identifier("cloneNode")),[this.t.booleanLiteral(!0)])))}insertElement(t,e,i){let s=this.generateNodeName();if(e.length===0)return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(s),Array.from({length:i}).reduce(p=>this.t.memberExpression(p,this.t.identifier("nextSibling")),this.t.identifier(t))));let r=p=>this.t.memberExpression(p,this.t.identifier("firstChild")),n=p=>this.t.memberExpression(r(p),this.t.identifier("nextSibling")),o=p=>this.t.memberExpression(n(p),this.t.identifier("nextSibling")),a=(p,l)=>this.t.memberExpression(this.t.memberExpression(p,this.t.identifier("childNodes")),this.t.numericLiteral(l),!0),h=p=>this.t.memberExpression(p,this.t.identifier("nextSibling"));return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(s),e.reduce((p,l,d)=>{if(d===0&&i>0)for(let c=0;c{let h=F.findBestNodeAndPath(r,a,e),[,p,l]=h,d=h[0];(p.length!==0||l!==0)&&(s(this.insertElement(d,p,l)),d=this.generateNodeName(this.nodeIdx),r[d]=a)});let o=Object.fromEntries(Object.entries(r).map(([a,h])=>[h.join("."),a]));return[i,o]}static pathWithCommonPrefix(t){let e=[...t];t.forEach(r=>{t.forEach(n=>{if(r!==n){for(let o=0;or.length!==n.length?r.length-n.length:r[0]-n[0]);return[...new Set(i.map(r=>r.join(".")))].map(r=>r.split(".").filter(Boolean).map(Number))}static findBestNodeAndPath(t,e,i){let s=0,r,n;return Object.entries(t).forEach(([o,a])=>{let h=0,p=a.length;for(let l=0;l
0&&l<=3&&(n=[o,h,l])}h===a.length&&h>s&&(r=o,s=h)}),r?[r,e.slice(s),0]:n?[n[0],e.slice(n[1]+1),n[2]]:[i,e,0]}},Tt=class extends g{run(){let{item:t,array:e,key:i,children:s}=this.viewParticle,r=this.generateNodeName();return this.addInitStatement(this.declareForNode(r,e.value,t,s,g.calcDependencyNum(e.dependencyIndexArr),i)),this.addUpdateStatements(e.dependencyIndexArr,this.updateForNode(r,e.value,t,i)),this.addUpdateStatementsWithoutDep(this.updateForNodeItem(r)),r}declareForNode(t,e,i,s,r,n){let[o,a,h,p]=this.generateChildren(s,!1,!0);return o.unshift(...this.declareNodes(p),this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$updateArr"),this.t.identifier("$idx"),!0),this.t.arrowFunctionExpression([...this.updateParams,this.t.identifier("$item")],this.t.blockStatement([this.t.expressionStatement(this.t.assignmentExpression("=",i,this.t.identifier("$item"))),...this.geneUpdateBody(h).body]))))),o.push(this.generateReturnStatement(a)),this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.ForNode),[e,this.t.numericLiteral(r),this.getForKeyStatement(e,i,n),this.t.arrowFunctionExpression([i,this.t.identifier("$updateArr"),this.t.identifier("$idx")],this.t.blockStatement(o))])))}getForKeyStatement(t,e,i){return this.t.isNullLiteral(i)?i:this.t.callExpression(this.t.memberExpression(t,this.t.identifier("map")),[this.t.arrowFunctionExpression([e],i)])}updateForNode(t,e,i,s){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("updateArray")),[e,...this.updateParams.slice(1),this.getForKeyStatement(e,i,s)]))}updateForNodeItem(t){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("update")),this.updateParams))}},U=class extends g{geneCondIdx(t){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("cond")),this.t.numericLiteral(t)))}geneCondCheck(t){return this.t.ifStatement(this.t.binaryExpression("===",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("cond")),this.t.numericLiteral(t)),this.t.blockStatement([this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("didntChange")),this.t.booleanLiteral(!0))),this.t.returnStatement(this.t.arrayExpression([]))]))}updateCondNodeCond(t){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("updateCond")),[...this.updateParams.slice(1)]))}updateCondNode(t){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("update")),this.updateParams))}declareCondNode(t,e,i){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.CondNode),[this.t.numericLiteral(U.calcDependencyNum(i)),this.t.arrowFunctionExpression([this.t.identifier("$thisCond")],e)])))}geneCondReturnStatement(t,e){return this.t.returnStatement(this.t.conditionalExpression(this.t.binaryExpression("===",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("cond")),this.t.numericLiteral(e)),this.t.arrayExpression(t.map(i=>this.t.identifier(i))),this.t.callExpression(this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("updateCond")),this.updateParams.slice(1))))}},kt=class extends U{run(){let{branches:t}=this.viewParticle,e=t.flatMap(({condition:s})=>s.dependencyIndexArr??[]),i=this.generateNodeName();return this.addInitStatement(this.declareIfNode(i,t,e)),this.addUpdateStatements(e,this.updateCondNodeCond(i)),this.addUpdateStatementsWithoutDep(this.updateCondNode(i)),i}geneIfStatement(t,e,i){return this.t.ifStatement(t,this.t.blockStatement(e),i)}declareIfNode(t,e,i){this.t.isBooleanLiteral(e[e.length-1].condition.value,{value:!0})||e.push({condition:{value:this.t.booleanLiteral(!0),dependencyIndexArr:[],dependenciesNode:this.t.arrayExpression([]),dynamic:!1},children:[]});let s=e.reverse().reduce((r,{condition:n,children:o},a)=>{let h=e.length-a-1,[p,l,d,c]=this.generateChildren(o,!1,!0),m=this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("updateFunc")),this.t.arrowFunctionExpression(this.updateParams,this.geneUpdateBody(d))));return p.unshift(...this.declareNodes(c),m),p.unshift(this.geneCondCheck(h),this.geneCondIdx(h)),p.push(this.geneCondReturnStatement(l,h)),a===0?this.t.blockStatement(p):this.geneIfStatement(n.value,p,r)},void 0);return this.declareCondNode(t,this.t.blockStatement([s]),i)}},Dt=class extends O{run(){let{props:t}=this.viewParticle;t=this.alterPropViews(t);let{children:e}=this.viewParticle,i=this.generateNodeName();return this.addInitStatement(this.declareEnvNode(i,t)),this.addInitStatement(this.geneEnvChildren(i,e)),Object.entries(t).forEach(([s,{dependencyIndexArr:r,value:n,dependenciesNode:o}])=>{r&&this.addUpdateStatements(r,this.updateEnvNode(i,s,n,o))}),i}generateEnvs(t){return[this.t.objectExpression(Object.entries(t).map(([e,{value:i}])=>this.t.objectProperty(this.t.identifier(e),i))),this.t.objectExpression(Object.entries(t).map(([e,{dependenciesNode:i}])=>i&&this.t.objectProperty(this.t.identifier(e),i)).filter(Boolean))]}declareEnvNode(t,e){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.EnvNode),this.generateEnvs(e))))}geneEnvChildren(t,e){let[i,s]=this.generateChildren(e);return this.addInitStatement(...i),this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("initNodes")),[this.t.arrayExpression(s.map(r=>this.t.identifier(r)))]))}updateEnvNode(t,e,i,s){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("updateEnv")),[this.t.stringLiteral(e),this.t.arrowFunctionExpression([],i),s]))}},At=class extends g{run(){let{content:t}=this.viewParticle,e=this.generateNodeName();return this.addInitStatement(this.declareTextNode(e,t.value,t.dependenciesNode)),t.dynamic&&this.addUpdateStatements(t.dependencyIndexArr,this.updateTextNode(e,t.value,t.dependenciesNode)),e}declareTextNode(t,e,i){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.callExpression(this.t.identifier(this.importMap.createTextNode),[e,i])))}updateTextNode(t,e,i){return this.t.expressionStatement(this.t.logicalExpression("&&",this.t.identifier(t),this.t.callExpression(this.t.identifier(this.importMap.updateText),[this.t.identifier(t),this.t.arrowFunctionExpression([],e),i])))}},et=class extends Q{run(){let{content:t,props:e}=this.viewParticle;t=this.alterPropView(t),e=this.alterPropViews(e);let i=this.generateNodeName();return this.addInitStatement(this.declareExpNode(i,t.value,t.dependenciesNode)),t.dynamic&&this.addUpdateStatements(t.dependencyIndexArr,this.updateExpNode(i,t.value,t.dependenciesNode)),e&&Object.entries(e).forEach(([s,{value:r}])=>{if(et.lifecycle.includes(s))return this.addInitStatement(this.addLifecycle(i,s,r));if(s==="ref")return this.addInitStatement(this.initElement(i,r));if(s==="elements")return this.addInitStatement(this.initElement(i,r,!0));if(s==="didUpdate")return this.addUpdateStatements(t.dependencyIndexArr,this.addOnUpdate(i,r));tt.warn1(s)}),i}declareExpNode(t,e,i){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.ExpNode),[e,i??this.t.nullLiteral()])))}updateExpNode(t,e,i){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("update")),[this.t.arrowFunctionExpression([],e),i??this.t.nullLiteral()]))}},it=class extends O{run(){let{props:t}=this.viewParticle;t=this.alterPropViews(t);let{tag:e}=this.viewParticle,i=this.generateNodeName(),s=this.snippetPropMap[e]??[],r=Array.from({length:s.length},()=>this.t.nullLiteral()),n=[];return Object.entries(t).forEach(([o,{value:a,dependencyIndexArr:h,dependenciesNode:p}])=>{if(o==="didUpdate")return;if(it.lifecycle.includes(o)){this.addInitStatement(this.addLifecycle(i,o,a));return}if(!h||h.length===0)return;n.push(...h);let l=s.indexOf(o);p&&(r[l]=p);let d=1<this.t.objectProperty(this.t.identifier(e),i.value)))}declareSnippetNode(t,e,i,s){return[this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.SnippetNode),[this.t.arrayExpression(s)]))),this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier(e)),[this.genePropNode(i),this.t.identifier(t)]))]}updateProp(t,e,i,s,r){return this.optionalExpression(t,this.t.optionalCallExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("updateProp")),[this.t.numericLiteral(e),...this.updateParams.slice(1),this.t.arrowFunctionExpression([],this.t.objectExpression([this.t.objectProperty(this.t.identifier(i),s)])),r],!0))}updateSnippet(t){return this.optionalExpression(t,this.t.optionalCallExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("update")),this.updateParams,!0))}},jt=class extends U{run(){let{branches:t,discriminant:e}=this.viewParticle,i=t.flatMap(({case:r})=>r.dependencyIndexArr);i.push(...e.dependencyIndexArr);let s=this.generateNodeName();return this.addInitStatement(this.declareSwitchNode(s,e.value,t,i)),this.addUpdateStatements(i,this.updateCondNodeCond(s)),this.addUpdateStatementsWithoutDep(this.updateCondNode(s)),s}declareSwitchNode(t,e,i,s){let r=i.map(({case:a,break:h,children:p},l)=>{if(!h)for(let d=l+1;da===null)===-1&&r.push({case:{value:this.t.booleanLiteral(!0),dependencyIndexArr:[],dependenciesNode:this.t.arrayExpression([]),dynamic:!1},break:!0,children:[]});let o=r.map(({case:a,children:h},p)=>{let[l,d,c,m]=this.generateChildren(h,!1,!0),u=this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$thisCond"),this.t.identifier("updateFunc")),this.t.arrowFunctionExpression(this.updateParams,this.geneUpdateBody(c))));return l.unshift(...this.declareNodes(m),u),l.unshift(this.geneCondCheck(p),this.geneCondIdx(p)),l.push(this.geneCondReturnStatement(d,p)),this.t.switchCase(a?a.value:null,[this.t.blockStatement(l)])});return this.declareCondNode(t,this.t.blockStatement([this.t.switchStatement(e,o)]),s)}},Ft=class extends g{run(){let{children:t,catchChildren:e,exception:i}=this.viewParticle,s=this.generateNodeName();return this.addInitStatement(this.declareTryNode(s,t,e,i)),this.addUpdateStatementsWithoutDep(this.declareUpdate(s)),s}declareTryNodeUpdate(t,e=!0){let[i,s,r,n]=this.generateChildren(t,!1,!0),o=this.t.arrowFunctionExpression([this.t.identifier("$changed")],this.geneUpdateBody(r));return i.unshift(...this.declareNodes(n),this.t.expressionStatement(this.t.callExpression(this.t.identifier("$setUpdate"),e?[this.t.callExpression(this.t.identifier("$catchable"),[o])]:[o]))),i.push(this.t.returnStatement(this.t.arrayExpression(s.map(a=>this.t.identifier(a))))),i}declareTryNode(t,e,i,s){let r=s?[s]:[];return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.identifier(t),this.t.newExpression(this.t.identifier(this.importMap.TryNode),[this.t.arrowFunctionExpression([this.t.identifier("$setUpdate"),this.t.identifier("$catchable")],this.t.blockStatement(this.declareTryNodeUpdate(e,!0))),this.t.arrowFunctionExpression([this.t.identifier("$setUpdate"),...r],this.t.blockStatement(this.declareTryNodeUpdate(i,!1)))])))}declareUpdate(t){return this.optionalExpression(t,this.t.callExpression(this.t.memberExpression(this.t.identifier(t),this.t.identifier("update")),this.updateParams))}},st=class{config;t;constructor(t){this.config=t,this.t=t.babelApi.types,this.templateIdx=t.templateIdx}generateChildren(t){let e=[],i=[],s={},r=[];return t.forEach(n=>{let[o,a,h,p]=this.generateChild(n);e.push(...o),Object.entries(a).forEach(([l,d])=>{s[Number(l)]||(s[Number(l)]=[]),s[Number(l)].push(...d)}),i.push(...h),r.push(p)}),[e,s,i,r]}nodeIdx=-1;templateIdx=-1;generateChild(t){let{type:e}=t,i=st.generatorMap[e];if(!i)throw new Error(`Unknown view particle type: ${e}`);let s=new i(t,this.config);s.nodeIdx=this.nodeIdx,s.templateIdx=this.templateIdx;let r=s.generate();return this.nodeIdx=s.nodeIdx,this.templateIdx=s.templateIdx,r}declareNodes(){return this.nodeIdx===-1?[]:[this.t.variableDeclaration("let",Array.from({length:this.nodeIdx+1},(t,e)=>this.t.variableDeclarator(this.t.identifier(`${N.node}${e}`))))]}get updateParams(){return[this.t.identifier("$changed")]}},C=st;I(C,"generatorMap",{comp:j,html:Lt,template:F,for:Tt,if:kt,switch:jt,env:Dt,text:At,exp:et,snippet:it,try:Ft});var Ot=class extends C{generate(t){let e=[],i=[],s={},r=[];return t.forEach(o=>{let[a,h,p,l]=this.generateChild(o);i.push(...a),Object.entries(h).forEach(([d,c])=>{s[Number(d)]||(s[Number(d)]=[]),s[Number(d)].push(...c)}),e.push(...p),r.push(l)}),[this.t.blockStatement([...this.declareNodes(),...this.geneUpdate(s),...i,this.geneReturn(r)]),e,this.templateIdx]}geneUpdate(t){return Object.keys(t).length===0?[]:[this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$update"),!1),this.t.arrowFunctionExpression(this.updateParams,this.t.blockStatement([...Object.entries(t).filter(([e])=>e!=="0").map(([e,i])=>this.t.ifStatement(this.t.binaryExpression("&",this.t.identifier("$changed"),this.t.numericLiteral(Number(e))),this.t.blockStatement(i))),...t[0]??[]]))))]}geneReturn(t){return this.t.returnStatement(this.t.arrayExpression(t.map(e=>this.t.identifier(e))))}},Ut=class extends C{generate(t,e,i){let s=[],r=[],n={},o={},a=[],h=this.templateIdx;t.forEach(c=>{let[m,u,f,x]=this.generateChild(c);r.push(...m),Object.entries(u).forEach(([T,ct])=>{n[Number(T)]||(n[Number(T)]=[]),n[Number(T)].push(...ct)}),s.push(...f),a.push(x)}),this.templateIdx=h,this.nodeIdx=-1,e.forEach(c=>{let[,m]=this.generateChild(c);Object.entries(m).forEach(([u,f])=>{o[Number(u)]||(o[Number(u)]=[]),o[Number(u)].push(...f)})});let p=Object.keys(n).length>0,l=Object.keys(o).filter(c=>c!=="0").length>0;return[this.t.blockStatement([...this.declareNodes(),...p?[this.geneUpdateFunc("update",n)]:[],...l?[this.geneUpdateFunc("updateProp",o,i)]:[],...r,this.geneAddNodes(a)]),s,this.templateIdx]}geneAddNodes(t){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$snippetNode"),this.t.identifier("_$nodes")),this.t.arrayExpression(t.map(e=>this.t.identifier(e)))))}geneUpdateFunc(t,e,i){return this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.identifier("$snippetNode"),this.t.identifier(t)),this.geneUpdateBody(e,i)))}geneUpdateBody(t,e){let i=[],s=this.updateParams;e&&(s.push(this.t.identifier("$snippetPropsFunc"),this.t.identifier("$depsArr")),i.push(this.t.ifStatement(this.t.callExpression(this.t.memberExpression(this.t.identifier("$snippetNode"),this.t.identifier("cached")),[this.t.identifier("$depsArr"),this.t.identifier("$changed")]),this.t.blockStatement([this.t.returnStatement()]))),i.push(this.t.variableDeclaration("const",[this.t.variableDeclarator(this.t.identifier("$snippetProps"),this.t.callExpression(this.t.identifier("$snippetPropsFunc"),[]))])),e.properties.filter(n=>this.t.isObjectProperty(n)).forEach((n,o)=>{let a=1<n!=="0").map(([n,o])=>this.t.ifStatement(this.t.binaryExpression("&",this.t.identifier("$changed"),this.t.numericLiteral(Number(n))),this.t.blockStatement(o))),...r]))}};function rt(t,e){return new Ot(e).generate(t)}function nt(t,e,i,s){return new Ut(s).generate(t,e,i)}function $t(t,e){let i=t.node.id.name,s=t.node.id.name+"Temp",r=e.genClassComponent(s);t.replaceWith(r),t.scope.rename(s,i)}var Vt=class{constructor(t,e){this.babelApi=t,this.t=t.types}functionDeclarationVisitor(t){var e,i;if(((e=t.node.id)==null?void 0:e.name[0])!==((i=t.node.id)==null?void 0:i.name[0].toUpperCase()))return;let s=t.node.body.body.find(h=>this.t.isReturnStatement(h));if(!s||!(this.t.isJSXElement(s.argument)||this.t.isJSXFragment(s.argument)))return;let r=new Bt(this.babelApi,t),o=t.node.params[0];r.transformProps(o);let a=t.node.body.body;a.forEach((h,p)=>{if(this.t.isVariableDeclaration(h)){r.transformStateDeclaration(h);return}if(this.t.isFunctionDeclaration(h)){r.transformMethods(h);return}if(r.shouldTransformWatch(h)){r.transformWatch(h);return}if(this.t.isReturnStatement(h)){if(p!==a.length-1)throw new Error("Early return is not supported yet.");r.transformRenderMethod(h);return}}),$t(t,r)}},Bt=class{constructor(t,e){this.properties=[],this.babelApi=t,this.t=t.types,this.functionScope=e.scope}valueWrapper(t){return this.t.file(this.t.program([this.t.isStatement(t)?t:this.t.expressionStatement(t)]))}addProperty(t,e){this.properties.push(t),e&&(this.functionScope.rename(e,`this.${e}`),this.functionScope.path.traverse({Identifier:i=>{i.node.name===`this.${e}`&&i.replaceWith(this.t.memberExpression(this.t.thisExpression(),this.t.identifier(e)))}}))}genClassComponent(t){return this.t.classDeclaration(this.t.identifier(t),this.t.identifier("View"),this.t.classBody(this.properties),[])}transformStateDeclaration(t){t.declarations.forEach(e=>{let i=e.id;if(this.t.isObjectPattern(i))return this.transformPropsDestructuring(i);if(!this.t.isArrayPattern(i)){if(this.t.isIdentifier(i)){let s=this.t.cloneNode(i);this.addProperty(this.t.classProperty(s,e.init),i.name)}}})}transformRenderMethod(t){let e=this.t.classMethod("method",this.t.identifier("Body"),[],this.t.blockStatement([t]),!1,!1);this.addProperty(e,"Body")}transformLifeCycle(){}transformComputed(){}transformMethods(t){var e;let i=(e=t.id)==null?void 0:e.name;if(!i)return;let s=this.t.classMethod("method",this.t.identifier(i),t.params,t.body,t.generator,t.async);this.addProperty(s,i)}transformProps(t){if(t){if(this.isObjDestructuring(t)){this.transformPropsDestructuring(t);return}if(!this.t.isIdentifier(t))throw new Error("Unsupported props type, please use object destructuring or identifier.")}}transformWatch(t){let e=this.functionScope.generateUidIdentifier("watch"),i=this.t.classMethod("method",e,[],this.t.blockStatement([t]),!1,!1);i.decorators=[this.t.decorator(this.t.identifier("Watch"))],this.addProperty(i)}isObjDestructuring(t){return this.t.isObjectPattern(t)}transformPropsDestructuring(t){let e=[];return t.properties.forEach(i=>{if(this.t.isObjectProperty(i)){let s=i.key;if(this.t.isIdentifier(s)){if(this.t.isAssignmentPattern(i.value)){let r=i.value.right;this.addProp(s,r),e.push(s);return}else if(this.t.isIdentifier(i.value)){this.addProp(s,void 0,i.value.name==="children"),e.push(s);return}else if(this.t.isObjectPattern(i.value)){this.transformPropsDestructuring(i.value);return}return}if(this.t.isAssignmentPattern(i.value)){let r=i.value.right,n=i.value.left;this.t.isIdentifier(n)&&(this.addProp(n,r),e.push(n));return}throw new Error("Unsupported props destructuring, please use simple object destructuring.")}}),e}addProp(t,e,i=!1){let s=this.t.cloneNode(t);this.addProperty(this.t.classProperty(s,e??void 0,void 0,[this.t.decorator(this.t.identifier(i?"Children":"Prop"))],void 0,!1),t.name)}shouldTransformWatch(t){return!!(this.t.isExpressionStatement(t)&&(this.t.isCallExpression(t.expression)||this.t.isAssignmentExpression(t.expression)||this.t.isUpdateExpression(t.expression))||this.t.isForStatement(t)||this.t.isWhileStatement(t)||this.t.isIfStatement(t)||this.t.isSwitchStatement(t)||this.t.isTryStatement(t))}};function Wt(t,e){let i=new Vt(t,e);return{name:"zouyu-2",visitor:{FunctionDeclaration(s){i.functionDeclarationVisitor(s)}}}}var at=Wt;var _t=Object.defineProperty,Ht=(t,e,i)=>e in t?_t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Gt=(t,e,i)=>(Ht(t,typeof e!="symbol"?e+"":e,i),i),Rt=process.env.NODE_ENV==="development",ht={class:"className",for:"htmlFor"},S=["push","pop","shift","unshift","splice","sort","reverse","add","delete","clear","set","delete","clear"],B=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","acronym","applet","basefont","bgsound","big","blink","center","dir","font","frame","frameset","isindex","keygen","listing","marquee","menuitem","multicol","nextid","nobr","noembed","noframes","param","plaintext","rb","rtc","spacer","strike","tt","xmp","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tspan","use","view"],Jt=["Static","Prop","Env","Content","Children"],$="@inula/next",L=Object.fromEntries(["createElement","setStyle","setDataset","setEvent","delegateEvent","setHTMLProp","setHTMLAttr","setHTMLProps","setHTMLAttrs","createTextNode","updateText","insertNode","ForNode","CondNode","ExpNode","EnvNode","TryNode","SnippetNode","PropView","render"].map(t=>[t,`$$${t}`])),Xt=["Static","Children","Content","Prop","Env","Watch","ForwardProps","Main","App","Mount","_","env","Snippet",...B.filter(t=>t!=="use")],qt={textContent:["*"],innerHTML:["*"],accept:["form","input"],acceptCharset:["form"],accesskey:["*"],action:["form"],align:["caption","col","colgroup","hr","iframe","img","table","tbody","td","tfoot","th","thead","tr"],allow:["iframe"],alt:["area","img","input"],async:["script"],autocapitalize:["*"],autocomplete:["form","input","select","textarea"],autofocus:["button","input","select","textarea"],autoplay:["audio","video"],background:["body","table","td","th"],bgColor:["body","col","colgroup","marquee","table","tbody","tfoot","td","th","tr"],border:["img","object","table"],buffered:["audio","video"],capture:["input"],charset:["meta"],checked:["input"],cite:["blockquote","del","ins","q"],className:["*"],color:["font","hr"],cols:["textarea"],colSpan:["td","th"],content:["meta"],contentEditable:["*"],contextmenu:["*"],controls:["audio","video"],coords:["area"],crossOrigin:["audio","img","link","script","video"],csp:["iframe"],data:["object"],dateTime:["del","ins","time"],decoding:["img"],default:["track"],defer:["script"],dir:["*"],dirname:["input","textarea"],disabled:["button","fieldset","input","optgroup","option","select","textarea"],download:["a","area"],draggable:["*"],enctype:["form"],enterKeyHint:["textarea","contenteditable"],htmlFor:["label","output"],form:["button","fieldset","input","label","meter","object","output","progress","select","textarea"],formAction:["input","button"],formEnctype:["button","input"],formMethod:["button","input"],formNoValidate:["button","input"],formTarget:["button","input"],headers:["td","th"],height:["canvas","embed","iframe","img","input","object","video"],hidden:["*"],high:["meter"],href:["a","area","base","link"],hreflang:["a","link"],httpEquiv:["meta"],id:["*"],integrity:["link","script"],intrinsicSize:["img"],inputMode:["textarea","contenteditable"],ismap:["img"],itemProp:["*"],kind:["track"],label:["optgroup","option","track"],lang:["*"],language:["script"],loading:["img","iframe"],list:["input"],loop:["audio","marquee","video"],low:["meter"],manifest:["html"],max:["input","meter","progress"],maxLength:["input","textarea"],minLength:["input","textarea"],media:["a","area","link","source","style"],method:["form"],min:["input","meter"],multiple:["input","select"],muted:["audio","video"],name:["button","form","fieldset","iframe","input","object","output","select","textarea","map","meta","param"],noValidate:["form"],open:["details","dialog"],optimum:["meter"],pattern:["input"],ping:["a","area"],placeholder:["input","textarea"],playsInline:["video"],poster:["video"],preload:["audio","video"],readonly:["input","textarea"],referrerPolicy:["a","area","iframe","img","link","script"],rel:["a","area","link"],required:["input","select","textarea"],reversed:["ol"],role:["*"],rows:["textarea"],rowSpan:["td","th"],sandbox:["iframe"],scope:["th"],scoped:["style"],selected:["option"],shape:["a","area"],size:["input","select"],sizes:["link","img","source"],slot:["*"],span:["col","colgroup"],spellcheck:["*"],src:["audio","embed","iframe","img","input","script","source","track","video"],srcdoc:["iframe"],srclang:["track"],srcset:["img","source"],start:["ol"],step:["input"],style:["*"],summary:["table"],tabIndex:["*"],target:["a","area","base","form"],title:["*"],translate:["*"],type:["button","input","embed","object","ol","script","source","style","menu","link"],usemap:["img","input","object"],value:["button","data","input","li","meter","option","progress","param","text"],width:["canvas","embed","iframe","img","input","object","video"],wrap:["textarea"],ariaAutocomplete:["*"],ariaChecked:["*"],ariaDisabled:["*"],ariaErrorMessage:["*"],ariaExpanded:["*"],ariaHasPopup:["*"],ariaHidden:["*"],ariaInvalid:["*"],ariaLabel:["*"],ariaLevel:["*"],ariaModal:["*"],ariaMultiline:["*"],ariaMultiSelectable:["*"],ariaOrientation:["*"],ariaPlaceholder:["*"],ariaPressed:["*"],ariaReadonly:["*"],ariaRequired:["*"],ariaSelected:["*"],ariaSort:["*"],ariaValuemax:["*"],ariaValuemin:["*"],ariaValueNow:["*"],ariaValueText:["*"],ariaBusy:["*"],ariaLive:["*"],ariaRelevant:["*"],ariaAtomic:["*"],ariaDropEffect:["*"],ariaGrabbed:["*"],ariaActiveDescendant:["*"],ariaColCount:["*"],ariaColIndex:["*"],ariaColSpan:["*"],ariaControls:["*"],ariaDescribedBy:["*"],ariaDescription:["*"],ariaDetails:["*"],ariaFlowTo:["*"],ariaLabelledBy:["*"],ariaOwns:["*"],ariaPosInset:["*"],ariaRowCount:["*"],ariaRowIndex:["*"],ariaRowSpan:["*"],ariaSetSize:["*"]},W=class{dlightPackageName=$;babelApi;t;traverse;enableDevTools;includes;excludes;htmlTags;attributeMap;isJsx=!1;constructor(t,e,i,s,r,n,o){this.babelApi=t,this.t=e,this.traverse=t.traverse,this.includes=i,this.excludes=s,this.enableDevTools=Rt&&r,this.htmlTags=typeof n=="function"?n(B):n.includes("*")?[...new Set([...B,...n])].filter(a=>a!=="*"):n,this.attributeMap=o}classDeclarationNode;classBodyNode;propertiesContainer={};dependencyMap={};enter=!0;dLightModel=!1;enterClassNode=!1;className;programNode;allImports=[];didAlterImports=!1;clearNode(){this.classDeclarationNode=void 0,this.classBodyNode=void 0,this.propertiesContainer={},this.dependencyMap={},this.enter=!0,this.enterClassNode=!1,this.dLightModel=!1,this.className=void 0}get availableProperties(){return Object.entries(this.propertiesContainer).filter(([t,{isWatcher:e,isStatic:i,isChildren:s}])=>t!=="_$compName"&&!e&&!i&&!s).map(([t])=>t)}initNode(t){let e=t.node;if(this.classDeclarationNode=e,this.classBodyNode=e.body,this.propertiesContainer={},e.id?.name||(e.id=this.t.identifier(`Anonymous_${W.uid()}`)),this.className=e.id?.name,this.handleClassCustomDecorators(),this.enableDevTools&&this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$compName"),this.t.stringLiteral(this.className))),!this.didAlterImports){let i=this.allImports.filter(s=>s.source.value===$);this.dlightPackageName!==$&&i.forEach(s=>{s.source.value=this.dlightPackageName}),i.forEach(s=>{s.specifiers=s.specifiers.filter(r=>!(this.t.isImportSpecifier(r)&&this.t.isIdentifier(r.imported)&&Xt.includes(r.imported.name)))}),this.programNode.body.unshift(this.t.importDeclaration(Object.entries(L).map(([s,r])=>this.t.importSpecifier(this.t.identifier(r),this.t.identifier(s))),this.t.stringLiteral(this.dlightPackageName))),this.didAlterImports=!0}}programEnterVisitor(t,e){this.enter=this.fileAllowed(e),this.enter&&((e&&e.endsWith(".jsx")||e&&e.endsWith(".tsx"))&&(this.isJsx=!0),this.allImports=t.node.body.filter(i=>this.t.isImportDeclaration(i)),this.programNode=t.node)}programExitVisitor(){this.enter&&(this.didAlterImports=!1,this.allImports=[],this.programNode=void 0)}classEnter(t){this.enter&&(this.enterClassNode=this.isDLightClass(t),this.enterClassNode&&(this.initNode(t),this.resolveMounting(t)))}classExit(){this.enter&&this.enterClassNode&&(this.transformDLightClass(),this.clearNode(),this.enterClassNode=!1)}classMethodVisitor(t){if(!this.enterClassNode||!this.t.isIdentifier(t.node.key))return;let e=t.node.key.name;if(e==="Body"||this.findDecoratorByName(t.node.decorators,"Snippet"))return;let s=t.node,r=this.findDecoratorByName(s.decorators,"Watch");if(this.t.isIdentifier(s.key,{name:"constructor"})||(this.autoBindMethods(s),!r))return;let n=[],o;if(this.t.isIdentifier(r))[n,o]=this.getDependencies(s);else{let a=r.arguments.filter(p=>this.t.isStringLiteral(p)).map(p=>p.value),h=this.t.classMethod("method",s.key,[],this.t.blockStatement([this.t.expressionStatement(this.t.arrayExpression(a.map(p=>this.t.memberExpression(this.t.thisExpression(),this.t.identifier(p)))))]));[n,o]=this.getDependencies(h)}this.propertiesContainer[e]={node:s,deps:n,depsNode:o,isWatcher:!0},s.decorators=this.removeDecorators(s.decorators,["Watch"])}classPropertyVisitor(t){if(!this.enterClassNode)return;let e=t.node;if(!this.t.isIdentifier(e.key))return;let i=e.key.name;if(i==="Body")return;let s=e.decorators;if(this.findDecoratorByName(s,"Snippet"))return;let n=this.parseModel(t),o=!!this.findDecoratorByName(s,"Prop"),a=!!this.findDecoratorByName(s,"Env"),h=!!this.findDecoratorByName(e.decorators,"Children"),[p,l]=h?[[]]:this.getDependencies(e);this.propertiesContainer[i]={node:e,deps:p,depsNode:l,isStatic:!!this.findDecoratorByName(s,"Static"),isContent:!!this.findDecoratorByName(s,"Content"),isChildren:h,isPropOrEnv:o?"Prop":a?"Env":void 0,isModel:n},e.decorators=this.removeDecorators(s,Jt)}resolveWatcherDecorator(t,e){if(!this.t.isIdentifier(t.key))return;let i=t.key.name,s=this.classBodyNode.body.indexOf(t),r=this.t.classProperty(this.t.identifier(`$w$${i}`));this.classBodyNode.body.splice(s,0,r),t.body.body.unshift(this.t.ifStatement(this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$cache")),[this.t.stringLiteral(i),e]),this.t.blockStatement([this.t.returnStatement()])))}resolveChildrenDecorator(t){if(!this.classBodyNode||!this.t.isIdentifier(t.key))return;let e=t.key.name,i=this.classBodyNode.body.indexOf(t),s=this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$children")),r=this.t.classMethod("get",this.t.identifier(e),[],this.t.blockStatement([this.t.returnStatement(s)]));this.classBodyNode.body.splice(i,1,r)}resolveContentDecorator(t){if(!this.classBodyNode||!this.t.isIdentifier(t.key)||this.classBodyNode.body.some(r=>this.t.isClassProperty(r)&&r.key.name==="_$contentKey"))return;let e=t.key.name,i=this.classBodyNode.body.indexOf(t),s=this.t.classProperty(this.t.identifier("_$contentKey"),this.t.stringLiteral(e));this.classBodyNode.body.splice(i,0,s)}resolvePropDecorator(t,e){if(!this.classBodyNode||!this.t.isIdentifier(t.key))return;let i=t.key.name,s=this.classBodyNode.body.indexOf(t),r=e.toLowerCase()==="prop"?"p":"e",n=this.t.classProperty(this.t.identifier(`$${r}$${i}`));this.classBodyNode.body.splice(s,0,n)}resolveStateDecorator(t,e,i){if(!this.classBodyNode||!this.t.isIdentifier(t.key))return;let s=t.key.name,r=this.classBodyNode.body.indexOf(t),n=this.dLightModel?[]:[this.t.classProperty(this.t.identifier(`$$${s}`),this.t.numericLiteral(1<this.t.stringLiteral(a))))]:[];this.classBodyNode.body.splice(r+1,0,...n,...o)}handleClassCustomDecorators(){if(!this.classBodyNode)return;let t=this.classDeclarationNode?.decorators;if(!t)return;this.findDecoratorByName(t,"ForwardProps")&&(this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$forwardProps")),this.t.classProperty(this.t.identifier("_$forwardPropsSet"),this.t.newExpression(this.t.identifier("Set"),[])),this.t.classProperty(this.t.identifier("_$forwardPropsId"),this.t.arrayExpression([]))),this.classDeclarationNode.decorators=this.removeDecorators(t,["ForwardProps"]))}transformDLightClass(){let t=this.handleView();this.addAutoUpdate(this.dLightModel?this.availableProperties:t);let e=Object.entries(this.propertiesContainer).reverse(),i=this.dependencyMapReversed();for(let[s,{node:r,deps:n,isStatic:o,isChildren:a,isPropOrEnv:h,isWatcher:p,isContent:l,isModel:d,depsNode:c}]of e){if(a){this.resolveChildrenDecorator(r);continue}n.length>0&&(t.push(...n),p?this.resolveWatcherDecorator(r,c):d||this.handleDerivedProperty(r,c)),h&&this.resolvePropDecorator(r,h),l&&(this.resolvePropDecorator(r,"Prop"),this.resolveContentDecorator(r)),!o&&t.includes(s)&&this.resolveStateDecorator(r,this.availableProperties.indexOf(s),i[s])}}addAutoUpdate(t){if(!this.classBodyNode)return;this.classBodyNode.body.filter(i=>!((this.t.isClassProperty(i)||this.t.isClassMethod(i))&&["constructor","_$compName"].includes(i.key.name)||this.t.isClassMethod(i,{static:!0})||this.t.isClassProperty(i,{static:!0}))).forEach(i=>{let s=this.t.isClassProperty(i)?i.value:this.t.isClassMethod(i)?i.body:null;s&&this.addUpdateDerived(s,t)})}addUpdateDerived(t,e){let i=(s,r)=>this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$ud")),[s,this.t.stringLiteral(r)]);this.traverse(this.valueWrapper(t),{MemberExpression:s=>{if(!this.t.isThisExpression(s.node.object)||!this.t.isIdentifier(s.node.property))return;let r=s.node.property.name;if(!e.includes(r))return;let n=this.isAssignmentExpressionLeft(s);n&&(n.replaceWith(i(n.node,r)),n.skip())},CallExpression:s=>{if(!this.t.isMemberExpression(s.node.callee))return;let r=s.node.callee.property;if(!this.t.isIdentifier(r)||!S.includes(r.name))return;let n=s.get("callee").get("object");for(;this.t.isMemberExpression(n.node);)n=n.get("object");if(!this.t.isThisExpression(n?.node))return;let o=n.parentPath.node.property.name;s.replaceWith(i(s.node,o)),s.skip()}})}handleView(){if(!this.classBodyNode)return[];let t=new Set,e,i=[];for(let a of this.classBodyNode.body){if(!this.t.isClassProperty(a)&&!this.t.isClassMethod(a)||!this.t.isIdentifier(a.key))continue;let h=this.findDecoratorByName(a.decorators,"Snippet"),p=a.key.name==="Body";if(!(!h&&!p)){if(this.t.isClassProperty(a)){let l=a.value;for(;this.t.isTSAsExpression(l);)l=l.expression;if(!this.t.isArrowFunctionExpression(l))continue;a.value=l;let d=this.arrowFunctionPropertyToMethod(a);if(!d)continue;a=d}h?(a.decorators=null,i.push(a)):e=a}}let s=i.map(a=>a.key.name),r=Object.fromEntries(i.map(a=>{let h=a.params[0];if(!h||!this.t.isObjectPattern(h))return["-",null];let p=Object.fromEntries(h.properties.map(l=>{if(!this.t.isObjectProperty(l))return["-",null];let d=l.key.name,c=this.getIdentifiers(this.t.assignmentExpression("=",this.t.objectPattern([this.t.objectProperty(this.t.numericLiteral(0),l.value)]),this.t.numericLiteral(0))).filter(m=>m!==d);return[d,c]}).filter(([l,d])=>d));return[a.key.name,p]}).filter(([a,h])=>h)),n=-1;if(e){let a;[a,n]=this.alterMainView(e,s,r),a.forEach(t.add.bind(t))}i.forEach(a=>{let h;[h,n]=this.alterSnippet(a,s,r,n),h.forEach(t.add.bind(t))});let o=[];return this.availableProperties.forEach(a=>{t.has(a)&&o.push(a)}),o}alterMainView(t,e,i){let s=[];if(this.isJsx){let p=t.body.body.find(l=>this.t.isReturnStatement(l));(this.t.isJSXElement(p.argument)||this.t.isJSXFragment(p.argument))&&(s=K(p.argument,{babelApi:this.babelApi,htmlTags:this.htmlTags,parseTemplate:!1}))}else s=D(t.body,{babelApi:this.babelApi,snippetNames:e,htmlTags:this.htmlTags});let[r,n]=M(s,{babelApi:this.babelApi,availableProperties:this.availableProperties,dependencyMap:this.dependencyMap,reactivityFuncNames:S}),[o,a,h]=rt(r,{babelApi:this.babelApi,className:this.className,importMap:L,snippetPropMap:Object.fromEntries(Object.entries(i).map(([p,l])=>[p,Object.keys(l)])),templateIdx:-1,attributeMap:this.attributeMap,alterAttributeMap:ht});return t.body=o,this.classBodyNode?.body.push(...a),[n,h]}alterSnippet(t,e,i,s){t.params.length===0?t.params.push(this.t.identifier("_$"),this.t.identifier("$snippetNode")):t.params.length===1?t.params.push(this.t.identifier("$snippetNode")):(t.params[1]=this.t.identifier("$snippetNode"),t.params.length=2);let r=D(t.body,{babelApi:this.babelApi,snippetNames:e,htmlTags:this.htmlTags}),n=i[t.key.name]??[],o={};Object.entries(n).forEach(([u,f])=>{f.forEach(x=>{o[x]=[u]})});let[a,h]=M(r,{babelApi:this.babelApi,availableProperties:this.availableProperties,availableIdentifiers:Object.keys(n),dependencyMap:this.dependencyMap,dependencyParseType:"property",reactivityFuncNames:S}),[p]=M(r,{babelApi:this.babelApi,availableProperties:Object.keys(n),dependencyMap:this.dependencyMap,dependencyParseType:"identifier",identifierDepMap:o,reactivityFuncNames:S}),l=Object.fromEntries(Object.entries(i).map(([u,f])=>[u,Object.keys(f)])),[d,c,m]=nt(a,p,t.params[0],{babelApi:this.babelApi,className:this.className,importMap:L,snippetPropMap:l,templateIdx:s,attributeMap:this.attributeMap,alterAttributeMap:ht});return t.body=d,this.classBodyNode?.body.push(...c),[h,m]}fileAllowed(t){return this.includes.includes("*")?!0:!(!t||this.excludes.some(e=>ot(t,e))||!this.includes.some(e=>ot(t,e)))}isDLightView(t){let e=t.node;return(e.decorators??[]).find(r=>this.t.isIdentifier(r.expression,{name:"View"}))&&(e.superClass=this.t.identifier("View"),e.decorators=e.decorators?.filter(r=>!this.t.isIdentifier(r.expression,{name:"View"}))),this.t.isIdentifier(e.superClass,{name:"View"})}isDLightModel(t){let e=t.node;return(e.decorators??[]).find(r=>this.t.isIdentifier(r.expression,{name:"Model"}))&&(e.superClass=this.t.identifier("Model"),e.decorators=e.decorators?.filter(r=>!this.t.isIdentifier(r.expression,{name:"Model"}))),e.body.body.unshift(this.t.classProperty(this.t.identifier("_$model"))),e.body.body=e.body.body.filter(r=>!((this.t.isClassProperty(r)||this.t.isClassMethod(r,{kind:"method"}))&&(this.findDecoratorByName(r.decorators,"Snippet")||this.t.isIdentifier(r.key)&&r.key.name==="Body"))),this.dLightModel=!0,this.t.isIdentifier(e.superClass,{name:"Model"})}isDLightClass(t){return this.isDLightView(t)||this.isDLightModel(t)}parseModel(t){if(!this.allImports.some(c=>c.source.value===this.dlightPackageName&&c.specifiers.some(m=>{if(this.t.isImportSpecifier(m)&&this.t.isIdentifier(m.imported,{name:"use"}))return!0})))return;let i=t.node,s=i.key;if(!this.t.isIdentifier(s))return;let r=i.value;if(!this.t.isCallExpression(r)||!this.t.isIdentifier(r.callee,{name:"use"}))return;let n=r.arguments,o=n[1],a=n[2],h=this.t.nullLiteral();if(o){let c=[],m=[];if(this.t.isObjectExpression(o))o.properties.forEach(u=>{if(this.t.isSpreadElement(u)){let[,f]=this.getDependenciesFromNode(u.argument);c.push([u.argument,f??this.t.nullLiteral()])}else if(this.t.isObjectProperty(u)){let[,f]=this.getDependenciesFromNode(u.value);m.push([!u.computed&&this.t.isIdentifier(u.key)?this.t.stringLiteral(u.key.name):u.key,u.value,f??this.t.nullLiteral()])}else m.push([!u.computed&&this.t.isIdentifier(u.key)?this.t.stringLiteral(u.key.name):u.key,this.t.arrowFunctionExpression([],u.body),this.t.nullLiteral()])});else{let[,u]=this.getDependenciesFromNode(o);c.push([o,u??this.t.nullLiteral()])}h=this.t.objectExpression([this.t.objectProperty(this.t.identifier("m"),this.t.arrayExpression(c.map(u=>this.t.arrayExpression(u)))),this.t.objectProperty(this.t.identifier("s"),this.t.arrayExpression(m.map(u=>this.t.arrayExpression(u))))])}let p=this.t.nullLiteral();if(a){let[,c]=this.getDependenciesFromNode(a);p=this.t.arrayExpression([a,c??this.t.nullLiteral()])}n[1]=this.t.arrowFunctionExpression([],h),n[2]=this.t.arrowFunctionExpression([],p),n[3]=this.t.stringLiteral(s.name),r.callee=this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$injectModel")),i.value=this.t.arrowFunctionExpression([],r);let l=this.classBodyNode.body.indexOf(i),d=this.t.classProperty(this.t.identifier(`$md$${s.name}`));return this.classBodyNode.body.splice(l,0,d),!0}removeDecorators(t,e){return t?t.filter(i=>!(this.t.isIdentifier(i.expression)&&e.includes(i.expression.name)||this.t.isCallExpression(i.expression)&&this.t.isIdentifier(i.expression.callee)&&e.includes(i.expression.callee.name))):[]}findDecoratorByName(t,e){if(t)return t.find(i=>this.t.isIdentifier(i.expression,{name:e})||this.t.isCallExpression(i.expression)&&this.t.isIdentifier(i.expression.callee,{name:e}))?.expression}geneDependencyNode(t){let e=t;for(;e?.parentPath;){let s=e.parentPath;if(!(this.t.isMemberExpression(s.node,{computed:!1})||this.t.isOptionalMemberExpression(s.node)))break;e=s}let i=this.t.cloneNode(e.node);return this.traverse(this.valueWrapper(i),{MemberExpression:s=>{this.t.isThisExpression(s.node.object)||(s.node.optional=!0,s.node.type="OptionalMemberExpression")}}),i}addConstructor(){let t=this.classBodyNode.body.find(e=>this.t.isClassMethod(e,{kind:"constructor"}));return t||(t=this.t.classMethod("constructor",this.t.identifier("constructor"),[],this.t.blockStatement([this.t.expressionStatement(this.t.callExpression(this.t.super(),[]))])),this.classBodyNode.body.unshift(t),t)}autoBindMethods(t){this.addConstructor().body.body.push(this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.thisExpression(),t.key),this.t.callExpression(this.t.memberExpression(this.t.memberExpression(this.t.thisExpression(),t.key),this.t.identifier("bind")),[this.t.thisExpression()]))))}handleDerivedProperty(t,e){if(!this.t.isIdentifier(t.key))return;let i=t.key.name,s=t.value,r=this.classBodyNode.body.indexOf(t),n=this.t.classMethod("get",this.t.identifier(`$f$${i}`),[],this.t.blockStatement([this.t.ifStatement(this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$cache")),[this.t.stringLiteral(i),e]),this.t.blockStatement([this.t.returnStatement(this.t.memberExpression(this.t.thisExpression(),this.t.identifier(i)))])),this.t.returnStatement(s)]));this.classBodyNode.body.splice(r+1,0,n),t.value=null}getDependenciesFromNode(t,e=!1){let i=new Set,s=new Set,r={};this.traverse(this.valueWrapper(t),{MemberExpression:a=>{if(!this.t.isIdentifier(a.node.property)||!this.t.isThisExpression(a.node.object))return;let h=a.node.property.name;this.isAssignmentExpressionLeft(a)||this.isAssignmentFunction(a)?s.add(h):this.availableProperties.includes(h)&&!this.isMemberInEscapeFunction(a,this.classDeclarationNode)&&!this.isMemberInManualFunction(a,this.classDeclarationNode)&&(i.add(h),e&&this.dependencyMap[h]?.forEach(i.add.bind(i)),r[h]||(r[h]=[]),r[h].push(this.geneDependencyNode(a)))}}),s.forEach(a=>{i.delete(a),delete r[a]});let n=Object.values(r).flat();n=n.filter((a,h)=>n.findIndex(l=>this.t.isNodesEquivalent(l,a))===h);let o=[...i];if(e&&i.size>0){let a=t.body.body[0].key.name;this.dependencyMap[a]=o}return[o,this.t.arrayExpression(n)]}getDependencies(t){if(!this.t.isIdentifier(t.key))return[[],void 0];let e=this.t.classDeclaration(null,null,this.t.classBody([t]));return this.getDependenciesFromNode(e,!0)}dependencyMapReversed(){let t={};return Object.entries(this.dependencyMap).forEach(([e,i])=>{i.forEach(s=>{t[s]||(t[s]=new Set),t[s].add(e)})}),t}resolveMounting(t){let e=t.node;if(!this.t.isIdentifier(e.id))return;let i=e.decorators??[],s=h=>{let p=i.find(l=>this.t.isIdentifier(l.expression,{name:h}));return p&&i.splice(i.findIndex(l=>l===p),1),p},r=s("Main")?"main":s("App")?"app":null,n;if(r)n=this.t.stringLiteral(r);else{let h=i.find(p=>this.t.isCallExpression(p.expression)&&this.t.isIdentifier(p.expression.callee,{name:"Mount"})&&p.expression.arguments.length===1);if(!h)return;i.splice(i.findIndex(p=>p===h),1),n=h.expression.arguments[0]}let o=t.parentPath.node;if(!this.t.isBlockStatement(o)&&!this.t.isProgram(o))return;let a=o.body.indexOf(e);o.body.splice(a+1,0,this.t.expressionStatement(this.t.callExpression(this.t.identifier(L.render),[n,e.id])))}arrowFunctionPropertyToMethod(t){if(!this.t.isArrowFunctionExpression(t.value))return;let e=t.value;if(!this.t.isBlockStatement(e.body))return;let i=this.classBodyNode.body.indexOf(t),s=this.t.classMethod("method",t.key,e.params,e.body);return this.classBodyNode.body.splice(i,1,s),s}isMemberExpressionProperty(t,e){return this.t.isMemberExpression(t)&&!t.computed&&t.property===e}isObjectKey(t,e){return this.t.isObjectProperty(t)&&t.key===e}valueWithArrowFunc(t){t.value||(t.value=this.t.identifier("undefined")),t.value=this.t.arrowFunctionExpression([],t.value)}getAllTopLevelReturnBlock(t){let e=[],i=!1;return this.traverse(this.valueWrapper(t),{Function:s=>{i||(i=!0,s.skip())},ReturnStatement:s=>{if(i)return;let r=s.parentPath.node;if(this.t.isBlockStatement(r))e.push(r);else{let n=this.t.blockStatement([s.node]);s.replaceWith(n),e.push(n)}s.skip()},exit:s=>{this.t.isFunction(s.node)&&(i=!1)}}),e}valueWrapper(t){return this.t.file(this.t.program([this.t.isStatement(t)?t:this.t.expressionStatement(t)]))}isAttrFromFunction(t,e){let i=t.parentPath,s=r=>this.t.isIdentifier(r)?r.name===e:this.t.isAssignmentPattern(r)?s(r.left):this.t.isArrayPattern(r)?r.elements.filter(Boolean).map(n=>s(n)).includes(!0):this.t.isObjectPattern(r)?r.properties.filter(n=>this.t.isObjectProperty(n)&&this.t.isIdentifier(n.key)).map(n=>n.key.name).includes(e):this.t.isRestElement(r)?s(r.argument):!1;for(;i;){let r=i.node;if(this.t.isArrowFunctionExpression(r)||this.t.isFunctionDeclaration(r)){for(let n of r.params)if(s(n))return!0}i=i.parentPath}return!1}isStandAloneIdentifier(t){let e=t.node,i=t.parentPath?.node;if(this.t.isMemberExpression(i)&&i.property===e||this.isAttrFromFunction(t,e.name))return!1;for(;t.parentPath;){if(this.t.isVariableDeclarator(t.parentPath.node)||this.t.isObjectProperty(t.parentPath.node)&&t.parentPath.node.key===t.node&&!t.parentPath.node.computed)return!1;t=t.parentPath}return!0}getIdentifiers(t){if(this.t.isIdentifier(t))return[t.name];let e=new Set;return this.traverse(this.valueWrapper(t),{Identifier:i=>{this.isStandAloneIdentifier(i)&&e.add(i.node.name)}}),[...e]}isAssignmentExpressionLeft(t){let e=t.parentPath;for(;e&&!this.t.isStatement(e.node);){if(this.t.isAssignmentExpression(e.node)){if(e.node.left===t.node)return e;let i=e.get("left");if(t.isDescendant(i))return e}else if(this.t.isUpdateExpression(e.node))return e;e=e.parentPath}return null}isAssignmentFunction(t){let e=t.parentPath;for(;e&&this.t.isMemberExpression(e.node);)e=e.parentPath;return e?this.t.isCallExpression(e.node)&&this.t.isMemberExpression(e.node.callee)&&this.t.isIdentifier(e.node.callee.property)&&S.includes(e.node.callee.property.name):!1}isMemberInEscapeFunction(t,e){let i=!1,s=t.parentPath;for(;s&&s.node!==e;){let r=s.node;if(this.t.isCallExpression(r)&&this.t.isIdentifier(r.callee)&&W.escapeNamings.includes(r.callee.name)){i=!0;break}s=s.parentPath}return i}isMemberInManualFunction(t,e){let i=!1,s=t.parentPath;for(;s&&s.node!==e;){let r=s.node,n=s.parentPath?.node,o=this.t.isFunctionExpression(r)||this.t.isArrowFunctionExpression(r),a=this.t.isCallExpression(n)&&this.t.isIdentifier(n.callee)&&n.callee.name==="manual";if(o&&a){i=!0;break}s=s.parentPath}return i}static uid(t=4){return Math.random().toString(32).slice(2,t+2)}},pt=W;Gt(pt,"escapeNamings",["escape","$"]);var Kt=pt;function zt(t,e){let{types:i}=t,{files:s="**/*.{js,ts,jsx,tsx}",excludeFiles:r="**/{dist,node_modules,lib}/*",enableDevTools:n=!1,htmlTags:o=p=>p,attributeMap:a=qt}=e,h=new Kt(t,i,Array.isArray(s)?s:[s],Array.isArray(r)?r:[r],n,o,a);return{visitor:{Program:{enter(p,{filename:l}){return h.programEnterVisitor(p,l)},exit:h.programExitVisitor.bind(h)},ClassDeclaration:{enter:h.classEnter.bind(h),exit:h.classExit.bind(h)},ClassMethod:h.classMethodVisitor.bind(h),ClassProperty:h.classPropertyVisitor.bind(h)}}}function lt(t,e){return{plugins:[["@babel/plugin-syntax-jsx"],["@babel/plugin-syntax-typescript",{isTSX:!0}],[V.default.default??V.default,{legacy:!0}],at,[zt,e]]}}import{minimatch as dt}from"minimatch";function Ke(t={}){let{files:e="**/*.{js,jsx,ts,tsx}",excludeFiles:i="**/{dist,node_modules,lib}/*.{js,ts}"}=t,s=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:[i];return{name:"dlight",enforce:"pre",transform(n,o){let a=!1;for(let h of s)if(dt(o,h)){a=!0;break}for(let h of r)if(dt(o,h)){a=!1;break}if(a)return Yt(n,{babelrc:!1,configFile:!1,presets:[[lt,t]],sourceMaps:!0,filename:o})}}}export{Ke as default};
-//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/packages/transpiler/vite-plugin-inula-next/dist/index.js.map b/packages/transpiler/vite-plugin-inula-next/dist/index.js.map
deleted file mode 100644
index 82981e7c303df7f50fc517df03f8624b579574c4..0000000000000000000000000000000000000000
--- a/packages/transpiler/vite-plugin-inula-next/dist/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["../../../../node_modules/.pnpm/@babel+helper-plugin-utils@7.24.0/node_modules/@babel/helper-plugin-utils/src/index.ts","../../../../node_modules/.pnpm/@babel+plugin-syntax-decorators@7.24.1_@babel+core@7.23.9/node_modules/@babel/plugin-syntax-decorators/src/index.ts","../src/index.ts","../../babel-preset-inula-next/src/index.ts","../../babel-preset-inula-next/src/pluginProvider.ts","../../babel-preset-inula-next/src/const.ts","../../babel-preset-inula-next/src/plugin.ts","../../error-handler/src/index.ts","../../view-parser/src/error.ts","../../view-parser/src/parser.ts","../../view-parser/src/index.ts","../../jsx-parser/src/parser.ts","../../jsx-parser/src/index.ts","../../reactivity-parser/src/error.ts","../../reactivity-parser/src/parser.ts","../../reactivity-parser/src/index.ts","../../view-generator/src/HelperGenerators/BaseGenerator.ts","../../view-generator/src/HelperGenerators/LifecycleGenerator.ts","../../view-generator/src/HelperGenerators/PropViewGenerator.ts","../../view-generator/src/HelperGenerators/ElementGenerator.ts","../../view-generator/src/HelperGenerators/ForwardPropGenerator.ts","../../view-generator/src/NodeGenerators/CompGenerator.ts","../../view-generator/src/error.ts","../../view-generator/src/HelperGenerators/HTMLPropGenerator.ts","../../view-generator/src/NodeGenerators/HTMLGenerator.ts","../../view-generator/src/NodeGenerators/TemplateGenerator.ts","../../view-generator/src/NodeGenerators/ForGenerator.ts","../../view-generator/src/HelperGenerators/CondGenerator.ts","../../view-generator/src/NodeGenerators/IfGenerator.ts","../../view-generator/src/NodeGenerators/EnvGenerator.ts","../../view-generator/src/NodeGenerators/TextGenerator.ts","../../view-generator/src/NodeGenerators/ExpGenerator.ts","../../view-generator/src/NodeGenerators/SnippetGenerator.ts","../../view-generator/src/NodeGenerators/SwitchGenerator.ts","../../view-generator/src/NodeGenerators/TryGenerator.ts","../../view-generator/src/ViewGenerator.ts","../../view-generator/src/MainViewGenerator.ts","../../view-generator/src/SnippetGenerator.ts","../../view-generator/src/index.ts","../../class-transformer/src/pluginProvider.ts","../../class-transformer/src/plugin.ts","../../class-transformer/src/index.ts"],"sourcesContent":["import type {\n PluginAPI,\n PluginObject,\n PluginPass,\n PresetAPI,\n PresetObject,\n} from \"@babel/core\";\n\ntype APIPolyfillFactory = (\n api: PluginAPI,\n) => PluginAPI[T];\n\ntype APIPolyfills = {\n assertVersion: APIPolyfillFactory<\"assertVersion\">;\n};\n\nconst apiPolyfills: APIPolyfills = {\n // Not supported by Babel 7 and early versions of Babel 7 beta.\n // It's important that this is polyfilled for older Babel versions\n // since it's needed to report the version mismatch.\n assertVersion: (api: PluginAPI) => (range: number | string) => {\n throwVersionError(range, api.version);\n },\n};\nif (!process.env.BABEL_8_BREAKING) {\n Object.assign(apiPolyfills, {\n // This is supported starting from Babel 7.13\n targets: () => () => {\n return {};\n },\n // This is supported starting from Babel 7.13\n assumption: () => () => {\n return undefined;\n },\n });\n}\n\nexport function declare(\n builder: (\n api: PluginAPI,\n options: Option,\n dirname: string,\n ) => PluginObject,\n): (\n api: PluginAPI,\n options: Option,\n dirname: string,\n) => PluginObject {\n return (api, options: Option, dirname: string) => {\n let clonedApi: PluginAPI;\n\n for (const name of Object.keys(\n apiPolyfills,\n ) as (keyof typeof apiPolyfills)[]) {\n if (api[name]) continue;\n\n clonedApi ??= copyApiObject(api);\n clonedApi[name] = apiPolyfills[name](clonedApi);\n }\n\n // @ts-expect-error options || {} may not be assigned to Options\n return builder(clonedApi ?? api, options || {}, dirname);\n };\n}\n\nexport const declarePreset = declare as