@chamn/render 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ function $$_run_$$() {
17
17
  return $$_f_$$.apply($$_f_$$, $$$__args__$$$);
18
18
  }
19
19
  return $$_run_$$();
20
- `,new Function(a)(...o,e,r)}catch(i){console.log(a),console.warn(i)}},rr=(t,e)=>{const r={};return e.forEach((n,o)=>{r[n]=t[o]}),r},nr=(t=[])=>{const e={};return t.forEach(({property:r,value:n})=>{let o=r.replace("-webkit","Webkit");o=o.replace("-ms","ms"),o=o.replace("-moz","Moz"),o=o.replace("-o","O");let a=o.split("-");a.length>=2&&(a=a.map((i,s)=>s!==0?Zh(i):i)),e[a.join("")]=n}),e},Sm=t=>{let e="";return Object.keys(t||{}).forEach(r=>{e+=`${r}:${t[r]};`}),e},jm=(t,e)=>{const r={};return t.forEach(n=>{if(n.globalName){const o=e[n.globalName];o&&(r[n.globalName]=o,o.__esModule&&(r[n.globalName]=o.__esModule))}}),r},Om=(t,e=1)=>{let r=0,n=t,o={},a={};for(;r<e;)Object.keys(n).forEach(i=>{o={...o,...n[i]}}),a=o,n=o,o={},r+=1;return a},ra=(t,e)=>{const r=[];return e.forEach(n=>{const a=n.exec(t);a!=null&&a.length&&r.push(a[1])}),r},na=(t,e)=>{const r={};return e.forEach(n=>{t[n.name]&&(r[n.name]=t[n.name])}),r},Cm=(t,e)=>na(t,e),wm=(t,e)=>na(t,e),le=t=>{var r;return((r=t.value.css)==null?void 0:r.class)||`c_${t.id}`},oa=(t,e)=>{const r=t.split(".");let n,o=e;return r.forEach(a=>{n=o==null?void 0:o[a],o=n}),n||(()=>`Component [${t}] not found`)},ue="DYNAMIC",Em=["$$context","$$nodeModel"],Dn=t=>{let e;const r=new Set,n=(c,u)=>{const l=typeof c=="function"?c(e):c;if(!Object.is(l,e)){const p=e;e=u??typeof l!="object"?l:Object.assign({},e,l),r.forEach(f=>f(e,p))}},o=()=>e,s={setState:n,getState:o,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,s),s},$m=t=>t?Dn(t):Dn;class Nm{constructor(){y(this,"storeMap",new Map)}addStore(e,r){const n=$m(r);return this.storeMap.set(e,n),n.name=e,n}setStore(e,r){this.storeMap.set(e,r)}removeStore(e){this.storeMap.delete(e)}getStore(e){return this.storeMap.get(e)}getState(e){var r;return(r=this.storeMap.get(e))==null?void 0:r.getState()}getStateObj(e){return{state:this.getState(e),updateState:r=>{this.setState(e,r)}}}setState(e,r){var n;return(n=this.storeMap.get(e))==null?void 0:n.setState(r)}connect(e,r){const n=this.storeMap.get(e);return n?n.subscribe(r):(console.warn("store not exits"),()=>{})}getStateSnapshot(){const e={};return this.storeMap.forEach((r,n)=>{e[n]=this.getStateObj(n)}),e}destroy(){this.storeMap=new Map}}class Tm{constructor(){y(this,"varSpace",new Map)}get(e){return this.varSpace.get(e)}add(e,r){this.varSpace.set(e,r)}remove(e){this.varSpace.delete(e)}destroy(){this.varSpace.clear()}getStateSnapshot(){const e={};return this.varSpace.forEach((r,n)=>{e[n]=r}),e}}class aa{constructor(){y(this,"renderMode","normal");y(this,"components",{});y(this,"storeManager",new Nm);y(this,"variableManager",new Tm);y(this,"runtimeComponentCache",new Map);y(this,"onGetRef");y(this,"onGetComponent");y(this,"onComponentMount");y(this,"onComponentDestroy");y(this,"processNodeConfigHook")}getComponent(e){var o;const r=e.value.componentName;let n=oa(r,this.components);return Zo(n)||(n=ta(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}getContext(e={},r){let n=e;return r&&(n={...e},n.__proto__=r||null),n}pageRender(e,{components:r,onGetRef:n,$$context:o={},onGetComponent:a,onComponentMount:i,onComponentDestroy:s,renderMode:c,processNodeConfigHook:u}){this.renderMode=c,this.components=r,this.onGetRef=n,this.onGetComponent=a,this.onComponentMount=i,this.onComponentDestroy=s,this.processNodeConfigHook=u;const l=e.value.componentsTree,p=this.getComponent(l),f=this.convertModelToComponent(p,e.value.componentsTree),d={},h=l.props;return Object.keys(h).forEach(g=>{d[g]=h[g].value}),d.$$context=o,this.render(f,d)}transformProps(e={},{$$context:r}){const n=e,o=i=>{if(Array.isArray(i))return i.map(s=>o(s));if(De(i))return o(i.value);if(Vf(i)){const s=i.value,c=s.value;if(!c)return console.warn("slot value is null, this maybe cause some error, pls check it",e),()=>{};const u=l=>{const p=`${l.id}-${ue}`;if(this.runtimeComponentCache.get(l.id))return{key:p,component:this.runtimeComponentCache.get(l.id)};const f=this.getComponent(l),d=this.convertModelToComponent(f,l),h=s.params||[];return{component:(...j)=>{const O=rr(j,h),T=this.getContext({params:O},r);return this.render(d,{$$context:T,key:p})},key:p}};if(Array.isArray(c)){const l=c==null?void 0:c.map(p=>u(p));return(...p)=>l.map(f=>{if(Xo(f.component)){const h=f.component;return S.createElement(h,{$$context:r,key:f.key})}else{const h=f.component;return h==null?void 0:h(...p)}})}else return u(c).component}else{if(ct(i))return lt(i.value,r||{});if(Uf(i))return ea(i.value,r,this.storeManager);if($t(i)){let s=i;De(i)&&(s=i.value);const c=s,u={};return Object.keys(s).forEach(l=>{u[l]=o(c[l])}),u}else return i}},a={};return Object.keys(n).forEach(i=>{const s=n[i];a[i]=o(s)}),a}collectSpecialProps(e={},r){const n=[],o=(a,i)=>{let s=i;De(i)&&(s=i.value),r(s)?n.push({keyPath:a,val:s}):Et(s)?s.forEach((c,u)=>{o([...a,String(u)],c)}):$t(s)&&Object.keys(s).forEach(c=>{o([...a,c],s[c])})};return o(["$root"],e),n}convertModelToComponent(e,r){const n=this;class o extends S.Component{constructor(s){super(s);y(this,"_CONDITION",!0);y(this,"_DESIGN_BOX",!1);y(this,"_NODE_MODEL",r);y(this,"_NODE_ID",r.id);y(this,"UNIQUE_ID",`${r.id}_${Z()}`);y(this,"targetComponentRef");y(this,"listenerHandle",[]);y(this,"storeState");y(this,"storeListenDisposeList",[]);y(this,"domHeader");y(this,"mediaStyleDomMap",{});y(this,"variableSpace");y(this,"nodeName");y(this,"updateState",s=>{this.storeState.setState(s),this.forceUpdate()});y(this,"getStyleDomById",s=>{const c=this.mediaStyleDomMap;let u=c[s];return u||(u=document.createElement("style"),c[s]=u),u.id=s,u});y(this,"addMediaCSS",()=>{var u;let s=this.domHeader;if(s||(s=(u=document.getElementsByTagName("head"))==null?void 0:u[0],this.domHeader=s),!this.domHeader)return;const c=this._NODE_MODEL.value.css;c&&c.value.forEach(l=>{var d;const p=`${this.UNIQUE_ID}_${l.state}`;let f=le(this._NODE_MODEL);if(l.state!=="normal"&&(f=`${f}:${l.state}`),l.text){const h=this.getStyleDomById(p);h.innerText=`.${f} { ${l.text} }`,s==null||s.appendChild(h)}(d=l.media)!=null&&d.length&&l.media.forEach(h=>{const g=`${p}_${h.type}_${h.value}`,b=this.getStyleDomById(g);b.media=`screen and (${h.type}:${h.value}px)`,b.innerHTML=`.${f} { ${h.text} }`,s==null||s.appendChild(b)})})});y(this,"removeMediaCSS",()=>{const s=this.mediaStyleDomMap;Object.keys(s).forEach(c=>{var u;(u=this.domHeader)==null||u.removeChild(s[c])}),this.mediaStyleDomMap={}});y(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(s=>s()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=S.createRef(),this.state=r.value.state||{};const c=r.value.nodeName||r.id;this.nodeName=c;const u=n.storeManager.getStore(c);u?(this.storeState=u,u.setState({...r.value.state||{}})):this.storeState=n.storeManager.addStore(c,()=>({...r.value.state||{}})),this.storeState.subscribe(p=>{this.setState({...p})}),this.connectStore();const l=n.variableManager.get(c);l?this.variableSpace=l:(this.variableSpace={staticVar:{},methods:{}},n.variableManager.add(c,this.variableSpace))}connectStore(){const s=n.collectSpecialProps(r.props,f=>!!ct(f)),c=n.collectSpecialProps({css:r.value.css,class:r.value.classNames},f=>!!ct(f));let u=[];[...s,...c].map(f=>{const d=f.val,h=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],g=ra(d.value,h);u=[...u,...g]}).filter(Boolean);const l=Array.from(new Set(u)),p=[];l.length&&l.forEach(f=>{n.storeManager.getStore(f)||(n.storeManager.addStore(f,()=>({})),console.warn(n.storeManager,f,"not exits"));const h=n.storeManager.connect(f,()=>{this.forceUpdate()});p.push(h)}),this.storeListenDisposeList=p}componentDidMount(){var c;this.addMediaCSS(),n.onGetRef&&n.onGetRef(this.targetComponentRef,r,this),(c=n.onComponentMount)==null||c.call(n,this,r);const s=()=>{n.storeManager.setStore(r.value.nodeName||r.id,this.storeState),this.storeState.setState({...this.state,...r.value.state||{}}),this.rebuildNode()};r.onChange(s)}componentWillUnmount(){var s;this.storeListenDisposeList.forEach(c=>c()),this.removeMediaCSS(),(s=n.onComponentDestroy)==null||s.call(n,this,r)}render(){var ae;const{$$context:s,...c}=this.props,u=r.value.nodeName||r.id,l={key:r.id,...r.props,...c},p={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n.storeManager,getState:()=>n.storeManager.getStateObj(u),getStateObj:()=>n.storeManager.getStateObj(u),getStateObjById:D=>n.storeManager.getStateObj(D),stateManager:n.storeManager.getStateSnapshot(),getMethods:()=>n.variableManager.get(u).methods,getMethodsById:D=>n.variableManager.get(D).methods,getStaticVar:()=>n.variableManager.get(u).staticVar,getStaticVarById:D=>n.variableManager.get(D).staticVar};r.value.componentName===At.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState);const f=n.getContext(p,s),g=n.transformProps({methods:r.value.methods},{$$context:f}).methods.reduce((D,G)=>(D[G.name]=G.define,D),{});f.methods=g,this.variableSpace.methods=Object.assign(this.variableSpace.methods,g);const b=r.value.loop;let j=[];if(b&&b.open){this.targetComponentRef.current=[];let D=b.data||[];if(ct(b.data)){const G=b.data;D=lt(G.value,f||{})}return j=D.map((...G)=>{var Lr;const Bt=G[1],bt=[b.forName||"item",b.forIndex||"index"],$e=rr(G,bt);let Ne="loopData";b.name&&(Ne=`${Ne}${b.name}`);const Ft=n.getContext({[Ne]:$e},f),q=n.transformProps(l,{$$context:Ft}),ha=((Lr=r.value.classNames)==null?void 0:Lr.map(H=>{var ie;const Ut=H.name;return(ct(H.status)?lt(String(((ie=H.status)==null?void 0:ie.value)||""),Ft):!1)?Ut:""}))||[];let Te=`${q.className??""} ${ha.join(" ")}`.trim();r.value.css&&(Te=`${le(r)} ${Te}`.trim()),q.className=Te;const ma=n.transformProps({style:r.value.style},{$$context:Ft});r.value.style&&(q.style=nr(ma.style||[]));const{children:se}=q;let xe=[];if(se!==void 0)delete q.children,xe=Array.isArray(se)?se:[se];else{const H=[];r.value.children.forEach((Br,ie)=>{const va=n.buildComponent(Br,{$$context:Ft,idx:ie});H.push(va)}),xe=H}if(q.key=`${q.key}-${Bt}`,ct(b.key)){const H=b.key,Ut=lt(H.value,Ft||{});q.key+=`-${Ut}`}return q.ref=H=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[Bt]=H},n.render(e,q,...xe)}),j}const O=n.transformProps(l,{$$context:f}),{children:T}=O;let A=[];if(T!==void 0)delete O.children,A=Array.isArray(T)?T:[T];else{const D=[];r.value.children.forEach((Bt,bt)=>{const $e=n.buildComponent(Bt,{$$context:f,idx:bt});D.push($e)}),A=D}O.ref=this.targetComponentRef;const I=((ae=r.value.classNames)==null?void 0:ae.map(D=>{var bt;const G=D.name;return(ct(D.status)?lt(((bt=D.status)==null?void 0:bt.value)||"",f):!1)?G:""}))||[];let k=`${O.className??""} ${I.join(" ")}`.trim();r.value.css&&(k=`${le(r)} ${k}`.trim()),O.className=k;const Lt=n.transformProps({style:r.value.style},{$$context:f});r.value.style&&(O.style=nr(Lt.style||[]));let w=r.value.condition??!0;typeof w!="boolean"&&(w=lt(w.value,f||{}));let ot={condition:w,props:O};n.processNodeConfigHook&&(ot=n.processNodeConfigHook(ot,r));const it=n.render(e,ot.props,...A);return this._CONDITION=ot.condition,ot.condition?it:S.createElement("div",{style:{display:"none"}},it)}}return y(o,"__CP_TYPE__",ue),o.displayName=`${r.value.componentName}Dynamic`,o}buildComponent(e,{$$context:r={}}){const n=this.runtimeComponentCache;return typeof e=="string"?this.render(e):kf(e)?(({currentNode:a})=>{const i=a.value.id;let s=null;if(n.get(i)){const l=n.get(i);s=l==null?void 0:l.component}else{const l=this.getComponent(a);s=this.convertModelToComponent(l,a),!n.get(i)&&this.renderMode!=="design"&&n.set(i,{component:s})}const c=`${i}-${ue}`,u={$$context:r,$$nodeModel:e,key:c};return this.render(s,u)})({currentNode:e}):void 0}render(e,r={},...n){return typeof e=="string"||typeof e=="number"?String(e):(Em.forEach(a=>{a in r&&e.__CP_TYPE__!==ue&&delete r[a]}),S.createElement(e,r,...n))}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const xm=Ln(new aa),Mm=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","math","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rbc","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"];var Am=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pm(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var sa={exports:{}},Ee={};/**
20
+ `,new Function(a)(...o,e,r)}catch(i){console.log(a),console.warn(i)}},rr=(t,e)=>{const r={};return e.forEach((n,o)=>{r[n]=t[o]}),r},nr=(t=[])=>{const e={};return t.forEach(({property:r,value:n})=>{let o=r.replace("-webkit","Webkit");o=o.replace("-ms","ms"),o=o.replace("-moz","Moz"),o=o.replace("-o","O");let a=o.split("-");a.length>=2&&(a=a.map((i,s)=>s!==0?Zh(i):i)),e[a.join("")]=n}),e},Sm=t=>{let e="";return Object.keys(t||{}).forEach(r=>{e+=`${r}:${t[r]};`}),e},jm=(t,e)=>{const r={};return t.forEach(n=>{if(n.globalName){const o=e[n.globalName];o&&(r[n.globalName]=o,o.__esModule&&(r[n.globalName]=o.default))}}),r},Om=(t,e=1)=>{let r=0,n=t,o={},a={};for(;r<e;)Object.keys(n).forEach(i=>{o={...o,...n[i]}}),a=o,n=o,o={},r+=1;return a},ra=(t,e)=>{const r=[];return e.forEach(n=>{const a=n.exec(t);a!=null&&a.length&&r.push(a[1])}),r},na=(t,e)=>{const r={};return e.forEach(n=>{t[n.name]&&(r[n.name]=t[n.name])}),r},Cm=(t,e)=>na(t,e),wm=(t,e)=>na(t,e),le=t=>{var r;return((r=t.value.css)==null?void 0:r.class)||`c_${t.id}`},oa=(t,e)=>{const r=t.split(".");let n,o=e;return r.forEach(a=>{n=o==null?void 0:o[a],o=n}),n||(()=>`Component [${t}] not found`)},ue="DYNAMIC",Em=["$$context","$$nodeModel"],Dn=t=>{let e;const r=new Set,n=(c,u)=>{const l=typeof c=="function"?c(e):c;if(!Object.is(l,e)){const p=e;e=u??typeof l!="object"?l:Object.assign({},e,l),r.forEach(f=>f(e,p))}},o=()=>e,s={setState:n,getState:o,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,s),s},$m=t=>t?Dn(t):Dn;class Nm{constructor(){y(this,"storeMap",new Map)}addStore(e,r){const n=$m(r);return this.storeMap.set(e,n),n.name=e,n}setStore(e,r){this.storeMap.set(e,r)}removeStore(e){this.storeMap.delete(e)}getStore(e){return this.storeMap.get(e)}getState(e){var r;return(r=this.storeMap.get(e))==null?void 0:r.getState()}getStateObj(e){return{state:this.getState(e),updateState:r=>{this.setState(e,r)}}}setState(e,r){var n;return(n=this.storeMap.get(e))==null?void 0:n.setState(r)}connect(e,r){const n=this.storeMap.get(e);return n?n.subscribe(r):(console.warn("store not exits"),()=>{})}getStateSnapshot(){const e={};return this.storeMap.forEach((r,n)=>{e[n]=this.getStateObj(n)}),e}destroy(){this.storeMap=new Map}}class Tm{constructor(){y(this,"varSpace",new Map)}get(e){return this.varSpace.get(e)}add(e,r){this.varSpace.set(e,r)}remove(e){this.varSpace.delete(e)}destroy(){this.varSpace.clear()}getStateSnapshot(){const e={};return this.varSpace.forEach((r,n)=>{e[n]=r}),e}}class aa{constructor(){y(this,"renderMode","normal");y(this,"components",{});y(this,"storeManager",new Nm);y(this,"variableManager",new Tm);y(this,"runtimeComponentCache",new Map);y(this,"onGetRef");y(this,"onGetComponent");y(this,"onComponentMount");y(this,"onComponentDestroy");y(this,"processNodeConfigHook")}getComponent(e){var o;const r=e.value.componentName;let n=oa(r,this.components);return Zo(n)||(n=ta(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}getContext(e={},r){let n=e;return r&&(n={...e},n.__proto__=r||null),n}pageRender(e,{components:r,onGetRef:n,$$context:o={},onGetComponent:a,onComponentMount:i,onComponentDestroy:s,renderMode:c,processNodeConfigHook:u}){this.renderMode=c,this.components=r,this.onGetRef=n,this.onGetComponent=a,this.onComponentMount=i,this.onComponentDestroy=s,this.processNodeConfigHook=u;const l=e.value.componentsTree,p=this.getComponent(l),f=this.convertModelToComponent(p,e.value.componentsTree),d={},h=l.props;return Object.keys(h).forEach(g=>{d[g]=h[g].value}),d.$$context=o,this.render(f,d)}transformProps(e={},{$$context:r}){const n=e,o=i=>{if(Array.isArray(i))return i.map(s=>o(s));if(De(i))return o(i.value);if(Vf(i)){const s=i.value,c=s.value;if(!c)return console.warn("slot value is null, this maybe cause some error, pls check it",e),()=>{};const u=l=>{const p=`${l.id}-${ue}`;if(this.runtimeComponentCache.get(l.id))return{key:p,component:this.runtimeComponentCache.get(l.id)};const f=this.getComponent(l),d=this.convertModelToComponent(f,l),h=s.params||[];return{component:(...j)=>{const O=rr(j,h),T=this.getContext({params:O},r);return this.render(d,{$$context:T,key:p})},key:p}};if(Array.isArray(c)){const l=c==null?void 0:c.map(p=>u(p));return(...p)=>l.map(f=>{if(Xo(f.component)){const h=f.component;return S.createElement(h,{$$context:r,key:f.key})}else{const h=f.component;return h==null?void 0:h(...p)}})}else return u(c).component}else{if(ct(i))return lt(i.value,r||{});if(Uf(i))return ea(i.value,r,this.storeManager);if($t(i)){let s=i;De(i)&&(s=i.value);const c=s,u={};return Object.keys(s).forEach(l=>{u[l]=o(c[l])}),u}else return i}},a={};return Object.keys(n).forEach(i=>{const s=n[i];a[i]=o(s)}),a}collectSpecialProps(e={},r){const n=[],o=(a,i)=>{let s=i;De(i)&&(s=i.value),r(s)?n.push({keyPath:a,val:s}):Et(s)?s.forEach((c,u)=>{o([...a,String(u)],c)}):$t(s)&&Object.keys(s).forEach(c=>{o([...a,c],s[c])})};return o(["$root"],e),n}convertModelToComponent(e,r){const n=this;class o extends S.Component{constructor(s){super(s);y(this,"_CONDITION",!0);y(this,"_DESIGN_BOX",!1);y(this,"_NODE_MODEL",r);y(this,"_NODE_ID",r.id);y(this,"UNIQUE_ID",`${r.id}_${Z()}`);y(this,"targetComponentRef");y(this,"listenerHandle",[]);y(this,"storeState");y(this,"storeListenDisposeList",[]);y(this,"domHeader");y(this,"mediaStyleDomMap",{});y(this,"variableSpace");y(this,"nodeName");y(this,"updateState",s=>{this.storeState.setState(s),this.forceUpdate()});y(this,"getStyleDomById",s=>{const c=this.mediaStyleDomMap;let u=c[s];return u||(u=document.createElement("style"),c[s]=u),u.id=s,u});y(this,"addMediaCSS",()=>{var u;let s=this.domHeader;if(s||(s=(u=document.getElementsByTagName("head"))==null?void 0:u[0],this.domHeader=s),!this.domHeader)return;const c=this._NODE_MODEL.value.css;c&&c.value.forEach(l=>{var d;const p=`${this.UNIQUE_ID}_${l.state}`;let f=le(this._NODE_MODEL);if(l.state!=="normal"&&(f=`${f}:${l.state}`),l.text){const h=this.getStyleDomById(p);h.innerText=`.${f} { ${l.text} }`,s==null||s.appendChild(h)}(d=l.media)!=null&&d.length&&l.media.forEach(h=>{const g=`${p}_${h.type}_${h.value}`,b=this.getStyleDomById(g);b.media=`screen and (${h.type}:${h.value}px)`,b.innerHTML=`.${f} { ${h.text} }`,s==null||s.appendChild(b)})})});y(this,"removeMediaCSS",()=>{const s=this.mediaStyleDomMap;Object.keys(s).forEach(c=>{var u;(u=this.domHeader)==null||u.removeChild(s[c])}),this.mediaStyleDomMap={}});y(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(s=>s()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=S.createRef(),this.state=r.value.state||{};const c=r.value.nodeName||r.id;this.nodeName=c;const u=n.storeManager.getStore(c);u?(this.storeState=u,u.setState({...r.value.state||{}})):this.storeState=n.storeManager.addStore(c,()=>({...r.value.state||{}})),this.storeState.subscribe(p=>{this.setState({...p})}),this.connectStore();const l=n.variableManager.get(c);l?this.variableSpace=l:(this.variableSpace={staticVar:{},methods:{}},n.variableManager.add(c,this.variableSpace))}connectStore(){const s=n.collectSpecialProps(r.props,f=>!!ct(f)),c=n.collectSpecialProps({css:r.value.css,class:r.value.classNames},f=>!!ct(f));let u=[];[...s,...c].map(f=>{const d=f.val,h=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],g=ra(d.value,h);u=[...u,...g]}).filter(Boolean);const l=Array.from(new Set(u)),p=[];l.length&&l.forEach(f=>{n.storeManager.getStore(f)||(n.storeManager.addStore(f,()=>({})),console.warn(n.storeManager,f,"not exits"));const h=n.storeManager.connect(f,()=>{this.forceUpdate()});p.push(h)}),this.storeListenDisposeList=p}componentDidMount(){var c;this.addMediaCSS(),n.onGetRef&&n.onGetRef(this.targetComponentRef,r,this),(c=n.onComponentMount)==null||c.call(n,this,r);const s=()=>{n.storeManager.setStore(r.value.nodeName||r.id,this.storeState),this.storeState.setState({...this.state,...r.value.state||{}}),this.rebuildNode()};r.onChange(s)}componentWillUnmount(){var s;this.storeListenDisposeList.forEach(c=>c()),this.removeMediaCSS(),(s=n.onComponentDestroy)==null||s.call(n,this,r)}render(){var ae;const{$$context:s,...c}=this.props,u=r.value.nodeName||r.id,l={key:r.id,...r.props,...c},p={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n.storeManager,getState:()=>n.storeManager.getStateObj(u),getStateObj:()=>n.storeManager.getStateObj(u),getStateObjById:D=>n.storeManager.getStateObj(D),stateManager:n.storeManager.getStateSnapshot(),getMethods:()=>n.variableManager.get(u).methods,getMethodsById:D=>n.variableManager.get(D).methods,getStaticVar:()=>n.variableManager.get(u).staticVar,getStaticVarById:D=>n.variableManager.get(D).staticVar};r.value.componentName===At.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState);const f=n.getContext(p,s),g=n.transformProps({methods:r.value.methods},{$$context:f}).methods.reduce((D,G)=>(D[G.name]=G.define,D),{});f.methods=g,this.variableSpace.methods=Object.assign(this.variableSpace.methods,g);const b=r.value.loop;let j=[];if(b&&b.open){this.targetComponentRef.current=[];let D=b.data||[];if(ct(b.data)){const G=b.data;D=lt(G.value,f||{})}return j=D.map((...G)=>{var Lr;const Bt=G[1],bt=[b.forName||"item",b.forIndex||"index"],$e=rr(G,bt);let Ne="loopData";b.name&&(Ne=`${Ne}${b.name}`);const Ft=n.getContext({[Ne]:$e},f),q=n.transformProps(l,{$$context:Ft}),ha=((Lr=r.value.classNames)==null?void 0:Lr.map(H=>{var ie;const Ut=H.name;return(ct(H.status)?lt(String(((ie=H.status)==null?void 0:ie.value)||""),Ft):!1)?Ut:""}))||[];let Te=`${q.className??""} ${ha.join(" ")}`.trim();r.value.css&&(Te=`${le(r)} ${Te}`.trim()),q.className=Te;const ma=n.transformProps({style:r.value.style},{$$context:Ft});r.value.style&&(q.style=nr(ma.style||[]));const{children:se}=q;let xe=[];if(se!==void 0)delete q.children,xe=Array.isArray(se)?se:[se];else{const H=[];r.value.children.forEach((Br,ie)=>{const va=n.buildComponent(Br,{$$context:Ft,idx:ie});H.push(va)}),xe=H}if(q.key=`${q.key}-${Bt}`,ct(b.key)){const H=b.key,Ut=lt(H.value,Ft||{});q.key+=`-${Ut}`}return q.ref=H=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[Bt]=H},n.render(e,q,...xe)}),j}const O=n.transformProps(l,{$$context:f}),{children:T}=O;let A=[];if(T!==void 0)delete O.children,A=Array.isArray(T)?T:[T];else{const D=[];r.value.children.forEach((Bt,bt)=>{const $e=n.buildComponent(Bt,{$$context:f,idx:bt});D.push($e)}),A=D}O.ref=this.targetComponentRef;const I=((ae=r.value.classNames)==null?void 0:ae.map(D=>{var bt;const G=D.name;return(ct(D.status)?lt(((bt=D.status)==null?void 0:bt.value)||"",f):!1)?G:""}))||[];let k=`${O.className??""} ${I.join(" ")}`.trim();r.value.css&&(k=`${le(r)} ${k}`.trim()),O.className=k;const Lt=n.transformProps({style:r.value.style},{$$context:f});r.value.style&&(O.style=nr(Lt.style||[]));let w=r.value.condition??!0;typeof w!="boolean"&&(w=lt(w.value,f||{}));let ot={condition:w,props:O};n.processNodeConfigHook&&(ot=n.processNodeConfigHook(ot,r));const it=n.render(e,ot.props,...A);return this._CONDITION=ot.condition,ot.condition?it:S.createElement("div",{style:{display:"none"}},it)}}return y(o,"__CP_TYPE__",ue),o.displayName=`${r.value.componentName}Dynamic`,o}buildComponent(e,{$$context:r={}}){const n=this.runtimeComponentCache;return typeof e=="string"?this.render(e):kf(e)?(({currentNode:a})=>{const i=a.value.id;let s=null;if(n.get(i)){const l=n.get(i);s=l==null?void 0:l.component}else{const l=this.getComponent(a);s=this.convertModelToComponent(l,a),!n.get(i)&&this.renderMode!=="design"&&n.set(i,{component:s})}const c=`${i}-${ue}`,u={$$context:r,$$nodeModel:e,key:c};return this.render(s,u)})({currentNode:e}):void 0}render(e,r={},...n){return typeof e=="string"||typeof e=="number"?String(e):(Em.forEach(a=>{a in r&&e.__CP_TYPE__!==ue&&delete r[a]}),S.createElement(e,r,...n))}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const xm=Ln(new aa),Mm=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","math","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rbc","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"];var Am=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pm(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var sa={exports:{}},Ee={};/**
21
21
  * @license React
22
22
  * react-jsx-runtime.production.min.js
23
23
  *