@jiess/plus
Version:
基于Jiess核心库的强化与拓展,为Jiess应用的完整形态
1 lines • 76.5 kB
JavaScript
const e="JIESS_CONSTRUCTOR",t="isJiess",s="THIS_IS_JIESS",i="JIESS_INIT_VALUE",n="_isJiessRef",r="_isJiessComputed",a="JiessForceUpdate",o="_initialParent",l=[e,"_isVue","_uid","_Ctor","__v_isRef","__v_isReactive","$$typeof","_store",{field:"install",type:"function"}],c=["is","component","$exclude"],u=(e,t,s=!0)=>{if(Object.is(e,t))return!0;const i=Object.prototype.toString.call(e);if(i!==Object.prototype.toString.call(t))return!1;if("[object Date]"===i)return e.getTime()===t.getTime();if("[object Promise]"===i)return!1;if("function"==typeof e)return String(e)===String(t);if(e&&"object"==typeof e){const i=Object.keys(e),n=Object.keys(t);if(i.length===n.length){let i=e,n=t;if(s){const s=[],r=[];if(i=g(e,(e=>(s.push(e),s.length))),n=g(t,(e=>(r.push(e),r.length))),s.length!==r.length)return!1;if(!s.every(((e,t)=>Object.is(e,r[t]))))return!1}return function(e,t){const s=Object.keys(e),i=Object.keys(t);for(let n of s){if(!i.includes(n))return!1;if(!u(e[n],t[n],!1))return!1}return!0}(i,n)}}return!1};function h(e){return e.slice(0,1).toUpperCase()+e.slice(1)}function d(e){return e.slice(0,1).toLowerCase()+e.slice(1)}const p=(...e)=>{},f=(e=p,t=0)=>{let s=setTimeout((()=>{null!==s&&clearTimeout(s),e()}),t)},m=function(e,t,s=!0){if("exp"===t&&(t="RegExp"),Array.isArray(t))return t.some((t=>m(e,t)));if(s&&!m(t,"string",!1))throw new Error(`${t} Error:须提供字符串`);return t=h(t),Object.prototype.toString.call(e)===`[object ${t}]`};function y(e,t){for(let s in t){let i=t[s];Array.isArray(i)?(e[s]=[],y(e[s],i)):m(i,"object")?(e[s]={},y(e[s],i)):e[s]=i}}const g=(e,t,s=new WeakSet)=>{if(m(e,["array","object"])){if(s.has(e))return t?.(e,"loop");if(s.add(e),Array.isArray(e))return e.map((e=>g(e,t,s)));if(N(e))return t?.(e,"filter")||e;{const i={};for(const n in e)if(c.includes(n))i[n]=e[n];else if(Reflect.has(e,n)){const r=e[n];i[n]=g(r,t,s)}return i}}return e},b=(e,t)=>!(!t||""!==e)||[null,void 0,NaN].some((t=>Object.is(t,e))),x=(e,t)=>!b(e,t),v=function(e=6){e=parseInt(e.toString(),10),e=isNaN(e)?6:e;for(var t="";e--;)t+="0123456789abcdefghijklmnopqrstubwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ"[Math.round(61*Math.random())];return t},$=function(e,t){let s=new Date(e),i={"M+":s.getMonth()+1,"d+":s.getDate(),"h+":s.getHours(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};const n=(/(y+)/.exec(t)||[])[1];n&&(t=t.replace(n,s.getFullYear()+""));for(let e in i){const s=i[e]+"",n=(new RegExp("("+e+")").exec(t)||[])[1];n&&(t=t.replace(n,`00${s}`.slice(-n.length)))}return t},w=e=>{let t=0,s={},i=(e,n)=>{if(Array.isArray(n))return n.map((t=>i(e,t)));if("function"==typeof n){let i=`__${t++}__`;return s[i]=n.toString(),s[i].startsWith(e)&&(s[i]=s[i].replace(e,"function")),i}if(m(n,"object")){if(n&&"object"==typeof n&&!Array.isArray(n)){const{$model:e,$done:i,...r}=n;if("template"===e){let e=`__${t++}__`;return s[e]=i(r),e}return r}return n}return n},n=JSON.stringify(e,((e,t)=>e?i(e,t):t),2);for(let e in s)n=n.replace(new RegExp(`"${e}"`),s[e]);return n},k=function(e){let t=new RegExp("(^| )"+e+"=([^;]*)(;|$)"),s=document.cookie.match(t);return s?decodeURIComponent(s[2]):null},P=function(e,t,s=30){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3),t=encodeURIComponent(t),document.cookie=`${e}=${t};expires=${i.toUTCString()};path=/`},C=(e=!1)=>{let t;return function(s,i=100){x(t,!0)?clearTimeout(t):e&&s(),t=setTimeout(s,i)}},j=C(),S=()=>{let e=0;return function(t,s=100){let i=(new Date).getTime();i-e>s&&t(),e=i}},_=S(),E=()=>{let e=!0;return function(t,s=100){e&&(e=!1,setTimeout((()=>{e=!0,t()}),s))}},T=E(),A=()=>{let e=0;return function(t,s=100){let i=(new Date).getTime();i-e>s&&(e=i,t())}},R=A(),D={initVal:e=>["string","number"].includes(typeof e)?e.toString():"",stringify(e){let t=[];for(let s in e){const i=e[s];Array.isArray(i)?i.forEach((e=>t.push(`${s}=${this.initVal(e)}`))):t.push(`${s}=${this.initVal(i)}`)}return t.join("&")},parse(e){const t={};return e.split("&").forEach((e=>{const[s,...i]=e.split("="),n=i.join("=");s in t?(Array.isArray(t[s])||(t[s]=[t[s]]),t[s].push(n)):t[s]=n})),t}},V=function(e,...t){return(s,i=[],n)=>{if("function"==typeof s){let r=null;return r=e?s.call(e,...t,...i):s(...t,...i),void 0===r?n:r}return void 0===n?s:n}},O=(e,t)=>{throw new Error(`${e} Error:${t}`)},B=(t,s,i=e)=>!!m(t,"object")&&Object.is(t[i],s),N=e=>l.some((t=>{if("string"==typeof t)return Reflect.has(e,t);{const{field:s,type:i}=t;if(Reflect.has(e,s))return m(e[s],i)}}));function I(e,t,s=p,i="数据类型"){if(m(e,t))return s();O(i,`须提供 ${t} 类型`)}function F(e={},t="toString"){if("function"==typeof e[t]){if("string"==typeof t){const s=new RegExp(t,"g");return(e[t]+"").replace(s,"")}return e[t]+""}}const J=(()=>{const e=F();return(t,s)=>F(t,s)===e})(),M=(e,t)=>Array.isArray(e)?[...e]:m(e,"object")?{...e}:t?void O("shallowCopy","须提供对象或数组"):e,z=(e,t,s={})=>{if(e.has(t)){const i=s;s=e.get(t),"function"==typeof i&&i(s)}return s};function q(e){return B(e,"JsRender")}function L(e,t){q(e)?t(e):Array.isArray(e)&&e.forEach((e=>{q(e)&&t(e)}))}function U(e){L(e,(e=>{e.destory()}))}const G=new WeakMap;function K(e){return!(!e||"object"!=typeof e||!e[s])}const H=e=>!!m(e,"object")&&Reflect.has(e,"$proxy"),W=e=>{const{$proxy:t,field:s,done:i}=e;return i?i(t):s?t[s]:t},X=e=>{if(H(e)){const{$proxy:t,field:s="value"}=e;return t[s]}return e},Y=(e,t)=>Array.isArray(e)?function(e){let t=null;return e.filter((e=>{if(!q(e))return!0;{const s=e,{_resConfig:i,_resData:n}=s;if(void 0!==i.$show){const e=n.style={...n.style};if(G.has(s)||G.set(s,e.display),i.$show){if("none"===e.display){const t=G.get(s);t?e.display=t:delete e.display}}else e.display="none"}let{$if:r=!0,$elseIf:a}=i;if(r=X(r),a=X(a),!x(a,!0))return i.hasOwnProperty("$if")?(t=!!r,r):(t=null,r);if("boolean"==typeof t){const e=a&&!t;return e&&(t=!0),e}O("$elseIf","须配合$if")}}))}(e).map(Y):q(e)?e.getNative(t):x(e)?e:void 0;class Z{static uid=1;constructor(t,s={}){this[e]=t,this.J_uid=Z.uid++,"function"==typeof s&&(s=s(this)),Object.assign(this,s),this.bindCxt()}bindCxt(){for(const e of Reflect.ownKeys(this.__proto__))"constructor"!==e&&"string"==typeof e&&("function"==typeof this[e]&&(this[e]=this[e].bind(this)),this.freezeField(e))}resetField(e,t){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{value:t})}freezeField(e){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{writable:!1,enumerable:!0,configurable:!0})}}const Q=class extends Z{watcher;fn;flush;constructor(e,t,s="async"){super("Composite"),this.watcher=e,this.fn=t,this.flush=s,this.effecting="doned",this.debounce1=C()}initComputed(e,t){this.computer=!0,this.target=e,this.proxy=t}init(e,t,s,i){return this.watcher.effecter.addCurrent(this),this.done(e,t,s,i),this.watcher.effecter.removeCurrent(),this.value}done(e,t,s,i){return this.effecting="start",this.value=this.fn(e,t,s,i),this.effecting="computed",this.computer&&(this.proxy.value=this.value),this.effecting="doned",this.value}check(e){this.computer?"start"===this.effecting?O("Computed","计算中禁止赋值"):"function"==typeof e&&e((e=>{this.target.value=e,this.watcher.effecter.trigger(this.target,"value",e,this.proxy)})):"function"==typeof e&&e()}trigger(e,t,s,i){this.check(((n=p)=>{"sync"===this.flush?n(this.init(e,t,s,i)):this.debounce1((()=>n(this.init())),0)}))}},ee=[Symbol.iterator,"constructor","__proto__","prototype",NaN,null,void 0,1/0],te=class extends Z{watcher;current;execStack=[];mapStore;constructor(e){super("Effecter"),this.watcher=e,this.mapStore=new WeakMap}addCurrent(e){this.current&&this.execStack.push(this.current),this.current=e}removeCurrent(){this.current=this.execStack.pop()}collect(e,t){if("start"!==this.current?.effecting)return;if(ee.includes(t))return;if(J(e,t))return;const s=z(this.mapStore,e),i=t;s[i]=s[i]||new Set,s[i].add(this.current),this.mapStore.set(e,s)}trigger(e,t,s,i){if(ee.includes(t))return;if(J(e,t))return;this.current?.check();const n=z(this.mapStore,e);n.hasOwnProperty(t)&&n[t].forEach((n=>n.trigger(e,t,s,i))),this.watcher.update(i,t,s)}},se=(e,t)=>void 0===e?t:e;class ie extends Z{proxy;field;config;reuse=!1;constructor(e,t,s={}){super("Observe"),this.proxy=e,this.field=t,this.config=s,this.cbs=new Set,this.debounce1=C();const{hasKey:i,defaultValue:n,observe:r,...a}=s;this.observe(r),this.other=a,this.value=i?e[t]:M(e);const o=this.value=se(this.value,n);this.getValue(((e,t)=>{this.result=e,t&&this.dispatch(e,{value:o,...a})}))}getValue(e){const{value:t,config:s,result:i}=this,{defaultValue:n,done:r}=s;"function"==typeof r?m(r,"AsyncFunction")?(r(t,this).then((t=>e(t,!0))),e(se(i,n))):e(r(t,this)):e(t)}observe(e){return"function"==typeof e&&this.cbs.add(e),this}resolve(e){const t=this.value,s={value:e,oldValue:t,...this.other};let{isSync:i,hasKey:n,sameState:r=!1}=this.config;if(n){try{r=u(t,e)}catch(e){console.error(e)}if(r)return;this.value=e,this.oldValue=t,this.getValue((e=>this.dispatch(e,s)))}else{const t=()=>{this.value=M(e),this.getValue((e=>this.dispatch(e,s)))};i?t():this.debounce1((()=>t()),0)}}dispatch(e,t){t.oldResult=this.result,t.result=this.result=e,this.cbs.forEach((s=>s(e,t.oldResult,t)))}}const ne=class extends Z{watcher;constructor(e){super("Observer"),this.watcher=e}create(t,i){return N(t)&&"Target"!==t[e]?t:I(t,["array","object"],(()=>{const e=new Proxy(t,{get:(e,t,n)=>t===s||("_initialTarget"===t?e:t===o?i:t===Symbol.toStringTag?Array.isArray(e)?"Array":"Object":(this.watcher.effecter.collect(e,t),B(e,!0,r)&&"value"===t?e.getValue():Reflect.get(e,t,n))),set:(e,t,s,n)=>(t===o&&(i=s),!!Object.is(e[t],s)||(this.trigger(e,t,s,n),Reflect.set(e,t,s,n))),deleteProperty:(t,s)=>(s in t&&this.trigger(t,s,void 0,e),Reflect.deleteProperty(t,s))});for(const s in t)c.includes(s)||m(t[s],["array","object"])&&(t[s]=this.create(t[s],e));return e}),"创建响应式数据")}trigger(e,t,s,i){const{effecter:n}=this.watcher;B(e,!0,r)?e.setValue(s,t):n.trigger(e,t,s,i)}},re=class extends Z{_setter;_composite;constructor(){super("Target"),this[s]=!0,this.value=i,this[r]=!0}initSetter(e){this._setter=e}initComposite(e){this._composite=e}getValue(){return this.value===i&&(this.value=this._composite?.init()),this.value}setValue(e,t){"value"!==t?O("Computed","仅允许对value赋值"):"function"==typeof this._setter?this._setter(e):"computed"===this._composite?.effecting||O("Computed","须提供setter")}},ae=new WeakMap,oe=new WeakMap;class le extends Z{static instance;effecter;observer;constructor(){return super("Watcher"),this.observer=new ne(this),this.effecter=new te(this),le.instance?le.instance:le.instance=this}createProxy(e){let t=!1;const s=g(e,((e,s)=>{"loop"===s&&(t=!0)}));return t?this.observer?.create(s):this.observer?.create(e)}createComputed(e,t){const s=new re,i=this.createProxy(s);if(m(e,"object")){const{get:t,set:i}=e;"function"==typeof t&&(e=t),"function"==typeof i&&s.initSetter(i)}const n=new Q(this,e,t);return s.initComposite(n),n.initComputed(s,i),i}watchEffect(e,t){new Q(this,e,t).init()}observe(e={$proxy:{}}){const{$proxy:t,field:i,warn:a=!0,...o}=e,l=Reflect.has(t,r)||Reflect.has(t,n)?"value":i,c=o.hasKey=m(l,["number","string"]);if(t[s]){const e=new ie(t,l,o);if(c){const s=z(ae,t,[]),i=l;s[i]=s[i]||[],s[i].push(e),ae.set(t,s)}else{const s=z(oe,t,[]);oe.set(t,s),s.push(e)}return e}if(!a)return W(e);if("function"==typeof a){const e=o.done,s=a(t,l);return e?e(s):s}console.warn("$proxy:需要定义为响应式对象")}bind(e,t,s,{cb:i}){if(!m(s,["number","string"])){const n=s,r=this.createProxy(n);return r[o]=e,"function"==typeof i?i(r):t&&(e[t]=r),r}e[t]=s}update(e,t,s){z(ae,e,(e=>{const i=e[t];Array.isArray(i)&&i.forEach((e=>e.resolve(s)))})),this.resolveParent(e)}resolveParent(e){z(oe,e,(t=>{Array.isArray(t)&&t.forEach((t=>t.resolve(e)))}));const t=e[o];t?.[s]&&this.resolveParent(t)}}let ce=1,ue="jiess";const he=class extends Z{ctx;expose={};isDestory=!1;constructor(e,t){super("JsRender"),this.ctx=e,this._buildNode(t)}_buildNode({config:e,data:s}){s.is=Ve(s.is),this[t]=B(s.is,!0,t),this._resData=this._initParam(s),this._resConfig=this._initParam(e);const{$ref:i}=this._resConfig;"function"==typeof i?this.ctx.nextTick((()=>{f((()=>i(this.expose,this)))})):m(i,"object")&&i[n]&&(i.value=this.expose)}_initParam(e){const t={};for(const s in e){const i=e[s];m(i,["object","array"])?this._analyObserve(t,i,s):t[s]=i}return t}_analyObserve(e,s,i){const n=this.ctx._slotRender;if("$if"!==i&&"$elseIf"!==i&&this[t])e[i]=s;else if(H(s))if(K(s.$proxy)){const t=(s=this.ctx._observe(s)).result;e[i]="children"===i?n.initNodes(t):t,s.observe(((t,s)=>{this.isDestory||("children"===i?(U(s),e[i]=n.initNodes(t)):e[i]=t,this.ctx.forceUpdate())}))}else e[i]=W(s);else e[i]="children"===i?n.initNodes(s):s}_initKey(e,t){return m(e,"object")&&b(e.key)&&(e.key=x(t)?`${ue}_${t}`:"auto_"+ce++),e}_injectKey({J_uid:e}){let{key:t}=this._resData;if(t){if("string"==typeof t){if(t.startsWith("_static_"))return;if(Number(t.split("_")[1])===e)return}}else t=this.J_uid;this._resData.key=`${ue}_${e}_${t}`}getNative(e){const{ctx:s,_resData:i}=this,{component:n,_slotRender:r}=s,{is:a,key:o,children:l,...c}=i;if(B(a,!0,t)){if(!this._vnode){const{jiessEnv:t}=n,{slot:s,...i}=c,r=this._initKey({is:a,key:o,slot:s},e);this._vnode=t.createVNode(r,(()=>(this.component=new $e(a,t),{NativeComponent:this.component.start(i,l,this),component:this.component})))}return this._vnode}return r.toRender(this,e)}destory(){this.isDestory||(this.isDestory=!0,this[t]?this.component&&U(this.ctx._nodes):U(this._resData.children))}},de=[];class pe extends Z{contextParam;static instance;$env="";$render;$moTag="div";JiessComponent;constructor(e={},t){super("Jiess"),this.contextParam=t,Object.assign(this,e),pe.instance=this}static addCtx(e){de.push(e)}static removeCtx(e){de.splice(de.indexOf(e),1)}static useCtx(){return de[de.length-1]}useInjects(e){if(this.contextParam){const{$page:t,...s}=this.contextParam;return"function"==typeof t&&(s.$page=t.call(e,this)),s}}}const fe=pe,me=class extends Z{ctx;constructor(e,t){super("Attrs"),this.ctx=e,this.config={},this.data={},this.init(this.initAttrs(t))}initAttrs({...e}={}){const t=e.class||e.className,{env:s}=this.ctx.component.jiessEnv;return delete e.class,delete e.className,t&&(e["vue3"===s?"class":"className"]=t),e}init(e){const{env:t}=this.ctx.component.jiessEnv,{children:s,...i}=function(e,t){const{$mergeAttrs:s,...i}=t;return Object.assign(i,s?.[e])}(t,e);var n,r,a;return n=["$if","$ref","$elseIf","$name","$show","$slots","$render","$observe","$slotData","$mergeAttrs"],r=i,a=this.config,n.forEach((e=>{r.hasOwnProperty(e)&&(a[e]=r[e],delete r[e])})),x(s)&&(i.children=s),this.data=i,this}},ye=new WeakMap,ge=class extends Z{ctx;attrs;constructor(e,t){if(super("Done"),this.ctx=e,this.attrs=t,ye.has(t))return ye.get(t);ye.set(t,this)}beginSetup(e){const{ctx:t}=this,s={},{setup:i,props:r,name:a}=e,o=new me(t,this.attrs);s.$param=o.data,s.$props=function(e,t,s=""){if(t){let i="",r={};return s&&(i=`${s} 组件 `),I(t,"function",(()=>{let s=t();I(s,"object",(()=>{for(let t in s){const a=s[t];let o,l=!1,c=null,u=!1,h=!1;if("string"==typeof a)c=a;else if("object"==typeof a){const e=a;c=e.type,o=e.default,h=!!e.isRef,l=!!e.required,u=!!e.isResponsive}l&&!e.hasOwnProperty(t)&&O(`${i}${t}`,"必须");const d=e=>{if(void 0!==e)return"string"!=typeof c||m(e,c)||O(`${i}${t}`,`须提供 ${c} 类型`),e},p=e=>e&&"object"==typeof e&&e[n],f=e.hasOwnProperty(t)?e[t]:o;u&&!K(f)&&O(`${i}${t}`,"须提供 Jiess 响应式数据"),p(f)?(d(f.value),r[t]=f):void 0!==f&&h?O(`${i}${t}`,"须提供 JiessRef 响应式数据"):r[t]=d(f)}}),`${i}Props 返回`)}),`${i}Props 定义`),r}return{...e}}(o.data,r,a),t.expose(s),I(i,["function","asyncFunction"],(()=>{fe.addCtx(t),i.call(t,s.$props,s.$param),fe.removeCtx(t)}),"setup函数")}buildRender(e=this.attrs){return this.jsRender&&!this.jsRender.isDestory||(this.jsRender=new he(this.ctx,new me(this.ctx,e))),this.jsRender}},be=class extends Z{ctx;children;constructor(e,t){super("SlotRender"),this.ctx=e,this.children=t}initNodes(e){return b(e)?e:[e].flat(1/0).filter((e=>x(e))).map((e=>{if("function"==typeof e)return e;if("object"!=typeof e)return e+"";if(!("$slot"in e))return q(e)?e:new ge(this.ctx,e).buildRender();{const{$slot:t="default",...s}=e,{slots:i,baseCnf:n}=this.initSlots(t,s);if(x(i))return this.initNodes(i);if(m(s,"object"))return this.initNodes(n)}}))}initSlots(e="default",{$slotData:t,...s}={}){const{$slots:i}=this.ctx.PJR?._resConfig||{};if(i&&"object"==typeof i){let n=i[e];return m(n,"function")&&(n=n.call(this.ctx,t)),"default"===e&&x(this.children)&&(n=x(n)?n:this.children),{baseCnf:s,slots:n}}return{baseCnf:s,slots:this.children}}toRender(e,t){const{$moTag:s,$env:i}=this.ctx.jiess,{is:n=s,children:r,...a}=e._resData;e._initKey(a,t);const o=this.getSlots(a,r,e);return"JiessFragment"===n?"vue3"===i?o.default.call(this):o:this.$h(n,a,o,e)}$h(e,t,s,i){const{jiessEnv:n}=this.ctx.component;return n.createElement(e,t,s,i)}getSlots(e,t,s){const{ctx:i}=this,{env:n}=i.component.jiessEnv,r=e=>{const t=this.initNodes(e);return L(t,(e=>e._injectKey(s))),Y(t)};let{$slots:a}=s._resConfig||{};if("react"!==n){e.scopedSlots=e.scopedSlots||{};const s=e.scopedSlots;a={...a};let o={};for(let e in a){let t=a[e];"vue2"===n?"function"==typeof t?s[e]=e=>r(t.call(i,e)):o[e]=r(t):o[e]=e=>r(m(t,"function")?t.call(i,e):t)}return o.hasOwnProperty("default")||("vue2"===n?s.hasOwnProperty("default")||x(t)&&(o.default=r(t)):x(t)&&(o.default=()=>r(t))),"vue2"===n?Object.values(o).flat(1/0):o}if(x(t)){let e=r(t);return e.length>1?e:e[0]}}};function xe(e,t=1/0,s){const{_provideData:i,PJR:n}=s?.ctx||{},r=i;return m(r,"object")&&r.hasOwnProperty(e)?r[e]:n&&t>0?xe(e,--t,n):null}const ve=class extends Z{component;PJR;$obs={};_provideData={};_slotRender;_nodes=[];_lifts={beforeRender:[],beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[]};constructor(e,t,s,i){const{IS:n,jiessEnv:r}=e;super("Context",(e=>r.jiess.useInjects(e))),this.component=e,this.PJR=i,this.jiess=r.jiess,this._slotRender=new be(this,s),new ge(this,t).beginSetup(n)}forceUpdate(){this.component.frame?.forceUpdate()}onBeforeRender(e){this._lifts.beforeRender.push({fn:e,once:!1})}onBeforeMount(e){this._lifts.beforeMount.push({fn:e,once:!1})}onMounted(e){this._lifts.mounted.push({fn:e,once:!1})}onBeforeUpdate(e,t=!1){this._lifts.beforeUpdate.push({fn:e,once:t})}onUpdated(e,t=!1){this._lifts.updated.push({fn:e,once:t})}onBeforeUnmount(e){this._lifts.beforeUnmount.push({fn:e,once:!1})}nextTick(e){switch(this.jiess.$env){case"vue3":this.jiess.nextTick(e);break;case"vue2":this.component.frame?.$nextTick(e);break;default:b(e)}}add(...e){return this._nodes=[...this._nodes,...this._slotRender.initNodes(e)],this}native(...e){return Y(this._slotRender.initNodes(e))}provide(e={}){Object.assign(this._provideData,e)}inject(e,t){return xe(e,t,this.PJR)}expose(e){this.PJR&&Object.assign(this.PJR.expose,e)}_buildVNodeTree(){let e=Y(this._nodes);return this._lifts.beforeRender.forEach((t=>{"function"==typeof t.fn&&(e=t.fn(e)||e,t.once&&delete t.fn)})),e}_observe({key:e,...t}){const{$proxy:s,field:i="value"}=t;let n=null;if(e&&"string"==typeof e){this.$obs[e]=this.$obs[e]||new WeakMap;const r=this.$obs[e].get(s)||{};Reflect.has(r,i)&&(t={defaultValue:r[i].result,...t}),n=r[i]=(new le).observe(t),this.$obs[e].set(s,r)}else n=(new le).observe(t);return n}},$e=class extends Z{IS;jiessEnv;cpn;ctx;frame;frameProps={};constructor(e,s){super("Component"),this.IS=e,this.jiessEnv=s,this[t]=!0}start(e={},t,s){return this.cpn=this.cpn||this.component(e,t,s)}component(e,t,s){return this.jiessEnv.component(this,(()=>{const i={...e};return this.ctx=new ve(this,i,t,s),e=>{this.ctx._lifts[e].forEach((e=>{"function"==typeof e.fn&&(e.fn(),e.once&&delete e.fn)}))}}))}},we=new WeakMap,ke=new WeakMap,Pe={},Ce=B;function je(e,t,s){const i={};t&&("object"==typeof t?Object.assign(i,t):i.field=t);const n=(new le).observe({$proxy:e,...i});B(n,"Observe")&&n.observe(s)}const Se=(e,t="async")=>I(e,"function",(()=>(new le).watchEffect(e,t))),_e=e=>K(e);let Ee=1;function Te(e){return Ae({value:e,[n]:!0,__uid:Ee++})}function Ae(e){return I(e,["Object","Array"],(()=>{let t=null;return we.has(e)?t=we.get(e):(t=(new le).createProxy(e),we.set(e,t)),t}))}function Re(e,t="async"){return I(e,["Object","Function"],(()=>{let s=null;return ke.has(e)?s=ke.get(e):(s=(new le).createComputed(e,t),ke.set(e,s)),s}))}function De(e,t){I(e,"string"),Pe[e]=t}function Ve(e){return Pe[e]||e}function Oe(e,t,s,i={}){return(new le).bind(e,t,s,i)}function Be(e,s,i){const n=new fe((e=>{const t={...e},s=t.default;return delete t.default,Object.assign(t,s)})(s),i);return new e(n,(({is:e,setup:s,jiessEnv:i})=>{if(B(e,!0,t));else{if("function"!=typeof s)throw new Error("须提供(组件is)或(setup函数)");e={isJiess:!0,name:"JiessComponent",setup:s}}return new $e(e,i)})),n}const Ne=/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,Ie=/^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$/,Fe={ruleData:{card:e=>({exp:[Ne,Ie],msg:"身份证号校验不通过"})}},Je={rowKey:"id",fieldPage:"page",fieldPageSize:"limit",fieldTotal:"total",fieldDatas:"list",defaultPage:1,defaultPageSize:10,defaultTotal:0,defaultDatas:[],boxParam:void 0,initLayout:void 0},Me=void 0,ze=void 0,qe={model:"divider"},Le={_ruleConfig:Fe,_SuperTable:Je,_ProPager:Me,_ProTable:ze,_FilterLayout:qe,_SwitchEnv:{envs:{local:{label:"本地环境",protocol:"http:",hostname:"127.0.0.1",port:"9007",pathname:"api"},development:{label:"研发环境",protocol:"http:",hostname:"121.37.217.25",port:"9007",pathname:"api"},test:{label:"测试环境",protocol:"http:",hostname:"121.37.195.250",port:"9007",pathname:"api"},preview:{label:"预览环境",protocol:"http:",hostname:"121.37.195.250",port:"9007",pathname:"api"},production:{label:"生产环境",protocol:"http:",hostname:"121.37.217.25",port:"9007",pathname:"api"}}}},Ue=/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,Ge=/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;class Ke{area;config;rules=[];ruleData;constructor(e,t={}){this.area=e,this.config=t,this.ruleData=this.getRuleData()}buildByFn(e,t){return{trigger:["blur","submit"],validator:async(s,i,n)=>{const r=await e(i,t);return this.area.hook.hookBuildRule(r,n)}}}getRuleData(){const{config:e}=this,t={},{ruleData:s}=Fe;if(s)for(let e in s){const i=s[e];t[e]=e=>"function"==typeof i?this.buildByFn(i,e):i}return{required:t=>({required:!0,message:`${t} 必填`,...e}),range:(t,s,i)=>({min:s,max:i,message:`${t} 长度控制在${s}到${i}`,...e}),requireArr:e=>this.buildByFn((t=>{if(!Array.isArray(t)||!t?.length)return`${e} 需要非空数组`}),e),email:e=>this.buildByFn((t=>{if(!Ue.test(t))return`${e} 邮箱格式有误`}),e),phone:e=>this.buildByFn((t=>{if(!Ge.test(t))return`${e} 手机格式有误`}),e),...t}}init(e,t=""){if(Array.isArray(e))return e.map((e=>"string"==typeof e?this.ruleData[e](t):Array.isArray(e)?this.ruleData.range(t,...e):"function"==typeof e?this.buildByFn(e,t):e))}}const He=class{area;config={};staticValues={};initialValues={};fieldsSet=new Set;fieldsMap=new Map;values={};constructor(e){this.area=e,this.area=e}init({initialValues:e,staticValues:t,...s}={initialValues:{},staticValues:{}}){this.config=s,this.area.nameManger=this,this.staticValues={...t},this.initialValues={...e},this.values=this.area.hook.hookInitValues(this)}getBaseValues(){return{...this.staticValues,...this.initialValues}}getInputValue(e){const t=e,s=this.getBaseValues();if(Reflect.has(s,t))return s[t]}input(e,{defaultValue:t}={}){const{fieldsMap:s,fieldsSet:i,area:n}=this;if(!e)return;if("object"==typeof e){if(s.has(e))return s.get(e)}else if(i.has(e))return e;let r,a;const o=this.getBaseValues();if(Array.isArray(e))r=e.join("__"),a=e.every((e=>Reflect.has(o,e)))?e.map((e=>this.getInputValue(e))):[],s.set(e,r);else if("object"==typeof e){const{config:t}=e;if(!t)throw new Error("name为配置对象时,需定义config属性");a=[];const i=e=>{const t=[];return(e=Array.isArray(e)?e:[e]).forEach((e=>{const{inputField:s,inputDone:i}=e;let n=this.getInputValue(s);"function"==typeof i&&(n=i(n,o)),t.push(s),a.push(n)})),t.join("__")};r=i(t),Array.isArray(t)||(a=a[0]),s.set(e,r)}else i.add(r=e),a=this.getInputValue(e);const{ctx:l,hook:c}=n,u=void 0===a?t:a;return c.hookNameMangerInput(this.values,r,u,l),r}async output({...e}=this.values){for(let[t,s]of this.fieldsMap){const i=e[s];if(delete e[s],Array.isArray(t))Array.isArray(i)&&t.forEach(((t,s)=>e[t]=i[s]));else{if(!t.config)throw new Error("name为配置对象时,需定义config属性");const s=async(t,s)=>{const{inputField:n,outputField:r,outputDone:a}=t;let o=i;Array.isArray(i)&&(o="number"==typeof s?i[s]:i),"function"==typeof a&&(o=await a(o,e)),e[r||n]=o};Array.isArray(t.config)?await Promise.all(t.config.map(s)):await s(t.config)}}return e}},We=e=>e&&"object"==typeof e,Xe=(t,s,i=e)=>We(t)&&t[i]===s,Ye=(e,t)=>{if(H(e)){const{$proxy:s,done:i,field:n,...r}=e,a=s[n||"value"];return t&&je(s,{done:i,field:n,...r},t),"function"==typeof i?i(a):a}return e};function Ze(e,t,s=[]){for(const i of e){const e=[...s,i.value];if(i.value===t)return e;if(Array.isArray(i.children)){const s=Ze(i.children,t,e);if(s)return s}}}const Qe=(e,t,s="label")=>{const i=[];if(!Array.isArray(t)){const i=Ze(e,t);return i&&Qe(e,i,s)}return t.forEach((t=>{const n=e.find((e=>e.value===t));n&&(i.push(n[s]),e=n.children)})),i};function et(e,t,s){let i=null;return m(e,"AsyncFunction")?e().then(t):m(e,"Function")?e((e=>{i=t(e)??e})):H(e)&&(i=Ye(e,t)),"function"==typeof s?s(i??e):i??e}const tt=e=>{if(We(e)){const t=e;if(t._isJiessRef||t._isJiessComputed)return t.value}return e};function st(e,t){const s=e.indexOf(t),i=e.substring(0,s),n=e.slice(s+t.length);return s>-1?this.native({is:"b",children:[i,{is:"span",children:t,style:{color:"#FF6666"}},n]}):e}function it(e,t,s){return e?.map((e=>{let i=!1,{children:n,...r}=e;if(Array.isArray(n)&&n.length){let e=it.call(this,n,t,s).filter(Boolean);if(e.length&&(i=!0,r.children=e),r[s].includes(t)&&(i=!0,r[s+"_text"]=r[s],r[s]=st.call(this,r[s],t)),!i)return}else r[s].includes(t)&&(i=!0,r[s+"_text"]=r[s],r[s]=st.call(this,r[s],t));return i&&r}))}function nt(e,t,s=1,i){const n={display:"-webkit-box",WebkitBoxOrient:"vertical",overflow:"hidden",WebkitLineClamp:s,textOverflow:"ellipsis",wordBreak:"break-all"};let r="onMouseenter";return"react"===this.jiess.$env&&(r="onMouseEnter"),{style:1===s?{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}:n,children:t,[r]:({target:t})=>{if(1===s){const{scrollWidth:s,clientWidth:i}=t;e.disabled=s<=i}else{const{scrollHeight:s,clientHeight:i}=t;e.disabled=s<=i}},...i}}const rt=class{area;constructor(e){this.area=e}getFieldValue(e){return this.area.formOper?.getFieldValue(e)}getFieldsValue(){return this.area.formOper?.getFieldsValue()}setFieldValue(e,t){this.area.formOper?.setFieldValue(e,t)}setFieldsValue(e){this.area.formOper?.setFieldsValue(e)}validateField(e){return this.area.formOper?.validateField(e)}validateFields(){return this.area.formOper?.validateFields()}resetFields(){this.area.formOper?.resetFields()}scrollToField(){this.area.formOper?.scrollToField()}value(e=!0){return new Promise((async(t,s)=>{const{nameManger:i,formOper:n}=this.area;let r={};if("boolean"==typeof e)try{r=e?await(n?.validateFields()):await(n?.getFieldsValue())}catch(e){return void(e&&console.warn("【获取表单数据】",e))}else e&&"object"==typeof e?r=e:s("须提供数据对象才可解析");t(await i.output(r))}))}},at=class{func;otherAttrs={};constructor(e){this.func=e}_buildLevel(e,t,s=0){const{$if:i,$show:n,$elseIf:r,...a}=e;if(t[s]){const{is:o,isEnd:l,fieldHas:c,fieldInject:u,fieldParam:h,fieldPicks:d,useOtherAttrs:p,...f}=t[s];if(l)return this.func(e,f);const m=(()=>{if(c){const e=a[c.field];return delete a[c.field],"boolean"==typeof e?e:c.default}return!0})(),y=(()=>{if(h){const e=a[h.field]||h.default;return delete a[h.field],{...e}}})();d?.forEach((e=>{e&&a.hasOwnProperty(e)&&(y[e]=a[e],delete a[e])}));const g=s+1;let b={$if:i,$show:n,$elseIf:r};if(t[g]||(this.otherAttrs=a),m){b={is:o,...b,...y};const e=this._buildLevel(a,t,g);return b.children?b.children=[b.children,e]:b.children=e,"function"==typeof u&&(b=u(this,b,a)||b),"function"==typeof p&&p(b,this.otherAttrs),b}return this._buildLevel({...b,...a},t,g)}return this.func(e)}},ot=class extends at{hook;ctx;exec;[e]="AreaBuilder";formOper={};other={};nameManger;collect=[];param={};constructor(e,t,s){super((()=>this.collect.flat(1/0).map((e=>Xe(e,"ItemBuilder")?e.useArea(this):e)))),this.hook=e,this.ctx=t,this.nameManger=new He(this),this.exec=V(t),this.nameManger.init(s)}init(){const{spaceParam:e,ruleConfig:t={},hasRule:s=!0,gutter:i=8,span:n=8,...r}=this.nameManger.config;return r.spaceParam={span:n,gutter:i,...e},this.param=Object.assign({rule:new Ke(this,t),childsProxy:Ae({}),hasRule:s},r),this.hook.hookNameManger(this),this}reload(e){this.nameManger.init(e),this.init(),this.ctx._nodes.length=0;const t=this.done();return this.ctx.forceUpdate(),t}render({is:e,...t}){return this.hook.itemBuilder({is:e},t)}add(...e){return this.collect.push(...e),this}done(e=!0){const{ctx:t,param:s}=this,i=this.hook.levelsArea(),n=new rt(this),r=this._buildLevel({...s},i);return e?(t.add(r),n):{node:r,action:n}}},lt=["Select","SelectGroup","CheckboxGroup","RadioGroup","RadioButtonGroup"],ct=class{itemBuilder;[e]="PreviewManger";className=[];constructor(e){this.itemBuilder=e}initClassName(e){this.className=e?[e].flat(1/0):[]}buildByName(e,t){let{className:s}=this;return t&&(s=[...s,t]),e.className=s,e}buildNode({name:e,children:t,className:s,$mode:i,$slots:n,$brother:r,$preview:a,...o}){const{hook:l,param:c,area:u,cpts:h={}}=this.itemBuilder,{mark:d,proxyChildren:p,optionBuilder:f,valueBuilder:y}=c;if(!u)return[];const{childsProxy:g}=u.param,b=(e,t)=>{const s=e.find((e=>e.value===t));return"antd"===l.uiName?s?s.children:"":s?s.label:""};if(this.initClassName(s),e&&p&&(g._initialTarget[e]=t,t={$proxy:g,field:e}),h.is?.isJiess&&(h.$area=u),"preview"===u?.param.mode)if(this.className.push("jiess-item_preview"),"edit"===i)o=this.buildByName({children:t,...h,...o},"jiess-item");else if(e){o.name=e;const s=l.hookProxyValue(u,o),i=e=>{const t=this.buildByName({is:l.$c.$TipText,text:e});return m(a,"object")&&Object.assign(t,a),t};if("function"==typeof a)o=a(s,t);else if("function"==typeof y)o=i(y.call(this,o,s));else if(lt.includes(d)){const e=Ae({textValue:""}),n=(t,s)=>{"function"==typeof f&&(s=f.call(this,s)),Array.isArray(t)?e.textValue=t.map((e=>b(s,e))).filter(Boolean).join():e.textValue=b(s,t)};let r=Ye(s,(e=>n(r=e,a))),a=Ye(t,(e=>n(r,a=e)));n(r,a),o=i({$proxy:e,field:"textValue"})}else o=i(s)}else o=this.buildByName({children:t,...o});else o=this.buildByName({children:t,...h,...o},"jiess-item");return n&&(o.$slots=n),r?[o,r]:o}};let ut=1;const ht=class extends at{hook;info;J_uid=ut++;ctx;[e]="ItemBuilder";cpts={};setValue;param={};area;itemParam={};previewManger;constructor(e,t=[],s){super((e=>this.previewManger.buildNode(e))),this.hook=e,this.info=s,this.previewManger=new ct(this),Array.isArray(t)?(this.cpts=t[0],this.param=t[1]||{}):(this.cpts=t,this.param={})}call(e,t,s={}){const i=this;return this.ctx=e,{$itemBuilder:this,is:e.jiess.JiessComponent,setup(){const{name:e="value",...n}=s,{hook:r,previewManger:a}=i;e&&(i.info.$name=e,n.initialValues=n.initialValues||{},n.initialValues[e]=t,i.setValue=t=>{o.nameManger.values[e]=t});const o=i.area=this.area(n),l=r.hookItemCall(i);this.add(a.buildNode(l))}}}useArea(e){this.area=e,this.ctx=e.ctx;const t=this.hook.hookItemCall(this),s=this.hook.levelsItem();return this._buildLevel(t,s)}},dt=class{hook;config;method;area;param;constructor(e,t){this.hook=e,this.config=t}initOptions(e){const{area:t,param:s}=this;return function(e,t){return et(e,t,(e=>Array.isArray(e)?e:[]))}(e,(e=>{let i=null;i="selectGroup"===this.method?this.getGroups(e):this.getOptions(e),t?.param?.childsProxy&&s?.name&&(t.param.childsProxy[s.name]=i)}),this.hook)}fieldsOption({...e}){const{text:t="text",value:s="value",disabled:i="disabled"}=this.fields;if(t in e){const s=e[t];delete e[t],e.text=s}if(s in e){const t=e[s];delete e[s],e.value=t}if(i in e){const t=e[i];delete e[i],e.disabled=t}return e}fieldsGroup({...e}){const{text:t="text",children:s="children"}=this.fields;if(t in e){const s=e[t];delete e[t],e.text=s}if(s in e){const t=e[s];delete e[s],e.children=t}return e}getOptions(e,t="no-group_"){return e=this.initOptions(e),this.area&&Array.isArray(e)?e.map(((e,s)=>{const i=this.fieldsOption(e);let{text:n,render:r,...a}=i;return n=this.area?.exec(r,[i],n),this.config.hookOption?.(n,{key:t+s,attrs:a,opt:i})})):[]}getGroups(e){return this.initOptions(e).map(((e,t)=>{const s=t+"_group_",i=this.fieldsGroup(e),{text:n,children:r,...a}=i;return{key:s,label:n,is:this.config.Group,children:this.getOptions(r,s),...a}}))}initParam(e,t,s){const{children:i,$options:n,$fields:r,...a}=t;this.config.hookParam?.(e,t,a),this.hook=e.hook,this.area=e.area,this.fields=r||{},this.param=a;const o=i||n;return a.children="group"===s?this.getGroups(o):this.getOptions(o),a}radio(e,t){return this.method="radio",this.initParam(e,t)}radioButton(e,t){return this.method="radioButton",this.initParam(e,t)}checkbox(e,t){return this.method="checkbox",this.initParam(e,t)}checkboxButton(e,t){return this.method="checkboxButton",this.initParam(e,t)}select(e,t){return this.method="select",this.initParam(e,t)}selectGroup(e,t){return this.method="selectGroup",this.initParam(e,t,"group")}};const pt=class{midder;debounces;queue;listenerCache;doneCache;constructor(e){this.midder=e,this.debounces={},this.queue={},this.listenerCache={},this.doneCache={}}clean(e,t){if("string"==typeof e)if(t){const s=this.listenerCache[e];Array.isArray(s)&&s.splice(s.findIndex((e=>e.tag===t)),1)}else delete this.listenerCache[e];else this.listenerCache={}}addListener(e){const{tag:t,name:s}=e;this.debounces[s]=this.debounces[s]||C();const i=this.listenerCache[s]=this.listenerCache[s]||[];if("string"==typeof t){const s=i.findIndex((e=>e.tag===t));s>-1?i.splice(s,1,e):i.push(e)}else i.push(e)}addDones(e){const{midder:t,doneCache:s}=this,{name:i}=e;t.isDebounce&&this.debounces[i]?(s[i]||(s[i]=()=>{this.debounces[i]((()=>{delete s[i],this.done(e)}))}),s[i]()):this.done(e)}async done(e){let{name:t,defaultValue:s}=e,{queue:i,midder:n,listenerCache:r}=this,{$results:a}=n,o=null;if(Array.isArray(r[t]))try{for(let s of r[t])await s.done(e)}catch(e){o=e||"执行异常"}else a[t]=n.result=s;if(Array.isArray(i[t]))for(let e of i[t])o?e.reject(o):e.resolve(a[t]);delete i[t]}},ft=class{midder;tag;fn;name="useDefaultKey";constructor(e){this.midder=e}init(...e){const{model:t}=this.midder;let s;return"multiple"===t||"no-store"===t?(this.name=e[0],s=e[1]):s=e[0],m(s,"object")&&"function"==typeof s.listener?("string"==typeof s.tag&&(this.tag=s.tag),this.fn=s.listener):"function"==typeof s?this.fn=s:O("Midder","未提供监听器"),this}async done(e){let{fn:t,name:s,midder:i}=this;try{let{defaultValue:n,args:r}=e,a=await(t?.call(i,n,...r));return void 0===a&&(a=n),i.$results[s]=i.result=a,e.defaultValue=a}catch(e){return Promise.reject(e)}}},mt=class{midder;tag;name="useDefaultKey";defaultValue;args;constructor(e){this.midder=e,this.args=[]}init(...e){const{model:t}=this.midder;let s;return"multiple"===t||"no-store"===t?(this.name=e[0],s=e[1],this.args=e.slice(2)):(s=e[0],this.args=e.slice(1)),m(s,"object")&&s.hasOwnProperty("defaultValue")?("string"==typeof s.tag&&(this.tag=s.tag),this.defaultValue=s.defaultValue):this.defaultValue=s,this}start(){const{tag:e,name:t,midder:s}=this,{queue:i}=s.$listenerStore;return new Promise(((s,n)=>{const r=i[t]=i[t]||[];if("string"==typeof e){const t=r.find((t=>t.tag===e));t?(t.resolve=s,t.reject=n):r.push({resolve:s,reject:n,tag:e})}else r.push({resolve:s,reject:n})}))}},yt={},gt=new WeakMap,bt=class extends Z{reference;model;isDebounce;$jiess;$watchEffects;result;$results;$listenerStore;constructor(e,t,s,i=!0){if(super("JiessMidder"),this.reference=t,this.model=s,this.isDebounce=i,this.$jiess=e,this.$watchEffects={},this.result=null,this.$results={},this.$listenerStore=new pt(this),"no-store"!==s){if(m(t,["symbol","string","number"])){return yt[t]||(yt[t]=this)}return gt.get(t)||(gt.set(t,this),this)}}watchEffect(e,t,s={}){this.$watchEffects[t]||(this.$watchEffects[t]=!0,this.$jiess.$watchEffect(e,s))}clean(e,t){this.$listenerStore.clean(e,t)}addListener(...e){const t=new ft(this).init(...e);this.$listenerStore.addListener(t)}dispatch(...e){const t=new mt(this).init(...e),s=t.start();return this.$listenerStore.addDones(t),s}};async function xt({api:e,midder:t,requestData:s}){let i=null;const{customRequest:n,customReload:r}=t.table;if(i="function"==typeof n?await n(e,s,t):await e(s),"function"==typeof r){const e=await r(i,s,t);e&&(i=e)}return i}async function vt(e,t){const{pager:s,proxy:i,filter:n,table:r,JiessTableConfig:a}=t,{fieldPage:o,fieldPageSize:l,fieldTotal:c,fieldDatas:u,defaultTotal:h}=a;try{const{page:a,pageSize:d,...p}=s.values,f={...n.values,...r.values,...p};f[o]=a,f[l]=d;for(const e in f){const t=f[e];"string"==typeof t&&(f[e]=t.trim())}const m=await xt({api:e,requestData:f,midder:t});return i.datas=m?.[u],i.total=Number(m?.[c]||h),f}catch(e){console.error("列表数据异常:",e)}}async function $t(e,t){const{filter:s,table:i,proxy:n}=t;try{const r={...s.values,...i.values};return n.datas=await xt({api:e,requestData:r,midder:t}),r}catch(e){console.error("列表数据异常:",e)}}const wt={add:"新增",edit:"编辑"};function kt(e){return(t,s,{type:i,title:n,param:r,...a}={})=>{const{record:o={},...l}=a;return new Promise((a=>{const c=i;i&&!e[c]&&(e[c]={}),this.$tan({title:n||wt[c],children:{is:t,type:i,midder:e,record:o,...l},onOk:async t=>{let{action:n,actions:r,httpParam:o}=e[c];n&&(r=[n]);let l={};r&&(l=await Promise.all(r.map((e=>e.value()))).then((e=>e.reduce(((e,t)=>Object.assign(t,e)),{}))));const u=`${i}TanHttpBefore`;l=await e.dispatch(u,{tag:u,defaultValue:l}),l=Object.assign(l,o),await s(l,t),e.table.reload(),a(),t()},...r})}))}}const Pt=class{$m;$c;ui;jiess;uiName="未初始化";levelsArea=p;levelsItem=p;constructor(e,t){this.$m=e,this.$c=t}hookBuildRule(e,t){}hookFormParam(e,t){}hookItemCall(e){}hookFormItem(e,t){}hookInitValues(e){}hookProxyValue(e,t){}areaBuilder(e,t){return new ot(this,e,t).init()}itemBuilder(e,t={}){return new ht(this,e,t)}initValue(e){const{defaultValue:t,...s}=e.param;return"defaultValue"in e.param&&(s.defaultValue="function"==typeof t?t(e.info):t),s}initFormItem(e,t,...s){const i={};if(t){const s={key:t};s[e]=t,Object.assign(i,s)}return Object.assign(i,...s)}hookNameManger(e){}hookNameMangerInput(e,t,s,i){e[t]=s}},Ct=class extends Pt{stack="vue";hookInitParam(e,{valueName:t,eventName:s},i){const{values:n}=e.nameManger,{onEvent:r,name:a,...o}=i,l=o[s];return o[t]={$proxy:n,field:a},o[s]=t=>{const s=n[a]=e.exec(r,[t],t);e.exec(l,[s])},o.name=a,o}},jt=class extends Ct{stackVersion="3"};var St;!function(e){e.React="react",e.Vue2="vue2",e.Vue3="vue3"}(St||(St={}));const _t="vue3";class Et{jiess;env=_t;constructor(e,t){this.jiess=e,this.initRender(),this.env=e.$env=_t,e.JiessComponent=e=>{const{is:s,setup:i,children:n,...r}=e,a={is:s,setup:i,jiessEnv:this};return this.createElement(t(a).start(r,n))}}initRender(){const{$render:e}=this.jiess;"function"==typeof e&&(this.jiess.h=(...t)=>e.call(this,...t))}createElement(e,t,s){const{useDirectives:i,...n}=t||{},{withDirectives:r,h:a}=this.jiess;return"function"==typeof i?r(a(e,n,s),i()):a(e,n,s)}createVNode({key:e},t){const{NativeComponent:s}=t(this);return this.createElement(s,{key:e})}component(e,t){let s=p;return{inheritAttrs:!0,data:()=>({[a]:!1}),created(){e.frame=this,e.frameProps=this.$props,s=t()},beforeMount(){s("beforeMount")},mounted(){s("mounted")},beforeUpdate(){s("beforeUpdate")},updated(){s("updated")},beforeUnmount(){s("beforeUnmount")},render(){return this[a],e.ctx._buildVNodeTree()},methods:{forceUpdate(){this[a]=!this[a]}}}}}function Tt(){return[{is:this.ui.ElForm,fieldHas:{field:"hasForm",default:!0},fieldParam:{field:"formParam",default:{}},fieldInject:(e,t)=>this.hookFormParam(e,t),fieldPicks:["size","labelWidth","disabled","class"]},{is:this.ui.ElCard,fieldHas:{field:"hasCard",default:!0},fieldParam:{field:"cardParam",default:{}},fieldPicks:["children","shadow","header","className"],useOtherAttrs:(e,{rule:t,hasRule:s,childsProxy:i,...n})=>{Object.assign(e,n)}},{is:this.$c.$Space,fieldHas:{field:"hasSpace",default:!0},fieldParam:{field:"spaceParam",default:{}},fieldPicks:["span","gutter"]}]}function At(){return[{is:this.$c.$SpaceItem,fieldHas:{field:"$hasSpaceItem",default:!0},fieldParam:{field:"$spaceItemParam",default:{}},fieldPicks:["$span"]},{is:this.ui.ElFormItem,fieldHas:{field:"$hasFormItem",default:!0},fieldParam:{field:"$formItemParam",default:{}},fieldPicks:["$label","$rules"],fieldInject:(e,{$label:t,$rules:s,...i},{name:n})=>{if(!e.area)return[];i.label=t,i=this.hookFormItem(n,i);const{rule:r,hasRule:a=!0}=e.area.param;return a?i.rules=r?.init(s,t):i.style={marginBottom:0},i}}]}const Rt=class{area;$el;ctx;values;constructor(e){this.area=e;const{ctx:t,nameManger:s}=e;this.values=s.values,this.ctx=t}setNode(e){this.$el=e}checkName(e,t){if("string"!=typeof e)throw new Error("参数 name 须定义为字符串");if(Reflect.has(this.values,e))return t&&t()}getFieldValue(e){return this.checkName(e,(()=>this.values[e]))}getFieldsValue(){return{...this.values}}setFieldsValue(e,t=!0){for(let s in this.values)(t||Reflect.has(e,s))&&(this.values[s]=e[s])}setFieldValue(e,t){this.checkName(e,(()=>this.values[e]=t))}validateField(e){return this.checkName(e,(()=>new Promise(((t,s)=>{this.$el?.validateField(e,(i=>{i?t(this.values[e]):s()}))}))))}validateFields(){return new Promise(((e,t)=>{this.$el?.validate((s=>{if(!s)return t(),!1;e(this.getFieldsValue())}))}))}resetFields(){return this.$el?.resetFields()}scrollToField(){return this.$el?.scrollToField()}clearValidate(){return this.$el?.clearValidate()}},Dt=class extends jt{levelsArea=Tt;levelsItem=At;uiName="element";constructor(e,t){super(e,t)}hookNameManger({nameManger:e}){e.values=this.$m.reactive(e.values)}hookBuildRule(e,t){t(e||void 0)}hookFormParam(e,t){return e.formOper=new Rt(e),{ref:t=>e.formOper.setNode(t),model:e.nameManger.values,labelWidth:"88px",...t}}hookInitValues(e){return Ae({...e.staticValues})}hookItemCall(e){const t=this.initValue(e),{groupConfig:s,valueName:i="modelValue",eventName:n="onUpdate:modelValue"}=t,r="defaultValue"in t?t.defaultValue:null;let{$name:a,...o}=e.info;if(a){const t={defaultValue:r,valueName:i,eventName:n};o.name=e.area?.nameManger.input(a,t),o=this.hookInitParam(e.area,t,o)}if(s){const{method:t,groupManger:i}=s;return i[t](e,o)}return o}hookFormItem(e,...t){return this.initFormItem("prop",e,...t)}hookProxyValue(e,t){return t.modelValue}hookDialog(e,t,s){let i;const{okText:n="确定",cancelText:r="取消",hasButtons:a=!0,leftFooter:o,buttons:l,onOk:c=e,onCancel:u=e,showOk:h=!0,showCancal:d=!0,...p}=s,f=Te(!0);return{show:f,beforeClose:e,is:this.ui.ElDialog,modelValue:{$proxy:f},buttonPromise:new Promise((e=>i=e)),$slots:{footer(){if(o||a)return{is:es,left:o,right:a?{is:rs,buttons:()=>l||(()=>{const s=[];return h&&s.push({text:n,type:"primary",onClick:async()=>{await c.call(t,e),i()}}),d&&s.push({text:r,onClick:async()=>{await u.call(t,e),i()}}),s})()}:void 0}}},...p}}};class Vt extends Dt{static instance;jiess={};ui={};globalConfig={};constructor({ui:e,globalConfig:t,...s}){if(Vt.instance)return Vt.instance;super(s,{$identify:m,$clone:g,$watch:je,$computed:Re,$reactive:Ae,$watchEffect:Se,$Space:ss,$SpaceItem:is,$TipText:Yt}),this.ui=e,this.globalConfig={...Le,...t},Vt.instance=this}start(e){const t=this.ui.ElMessage;"function"==typeof e&&(e=e(this.ui,this.$m,this)),this.jiess=Be(Et,this.$m,{$msg:(e,s="success")=>t({message:e,type:s}),area:Qt,...e});const s=new bt(this.jiess,"GlobalMidder","no-store");return this.jiess.contextParam.$midder=s,this.jiess}}const Ot=Vt,Bt={};class Nt{tag;keys;fn;wait;cache;startTime;constructor(e,t,s=p,i=300){this.tag=e,this.keys=t,this.fn=s,this.wait=i,this.cache={},this.startTime=0,Bt[e]=this}add(e,t){this.checkKey(e,t,(s=>{this.cache[s]=[e,t],this.startTime=Date.now(),this.fn(!0)}))}remove(e,t){this.checkKey(e,t,(e=>{delete this.cache[e];let t=Date.now()-this.startTime;if(!Object.keys(this.cache).length){let e=this.wait-t;e>0?f((()=>this.fn(!1)),e):this.fn(!1)}}))}checkKey(e,t,s){const i=Nt.getKey(e,t);this.keys.includes(i)&&s(i)}static getKey(e,t){return`${e}__${t.toLocaleUpperCase()}`}static request(e,t){Object.values(Bt).forEach((s=>s.add(e,t)))}static response(e,t){Object.values(Bt).forEach((s=>s.remove(e,t)))}}const It=Nt,Ft={isJiess:!0,name:"Custom",setup({midder:e,hook:t}){const{columns:s=[]}=e.proxy,i=Te([...s]);this.add({draggable:!0,is:t.ui.ElTree,"node-key":"key","show-checkbox":!0,data:{$proxy:i},"default-checked-keys":s.filter((e=>!e.hidden)).map((e=>e.key)),onNodeDrop(t,s,n,r){f((()=>e.proxy.columns=[...i.value]),0)},onCheck(t,{checkedKeys:i}){e.proxy.columns=s.map((e=>(e.hidden=!i.includes(e.key),e)))},allowDrop:(e,t,s)=>"inner"!==s,allowDrag:e=>"操作"!==e.label})}},Jt={isJiess:!0,name:"FilterLayout",setup({hook:e,filter:t,boxStyle:s,isCollapse:i,buttons:n=[],$ActionButtons:r,showButtons:a=!0,collapseItemParam:o={},collapseParam:l={},size:c="default",...u}){const{model:h="divider"}=qe,d=["filter-layout",h];i||d.push("no-expand");const p=e=>{e?.addEventListener("click",(e=>e.stopPropagation())),e?.addEventListener("keydown",(e=>{e.stopPropagation(),"Enter"===e.key&&t.onSearch()}))};this.add({class:d.join(" "),style:s,children:[i?{is:e.ui.ElCollapse,children:{is:e.ui.ElCollapseItem,...o,$slots:{title:{ref:p,style:{width:"100%"},children:{$slot:"default"}}},children:{ref:p,style:{width:"100%"},children:{$slot:"expand"}}},...l}:{style:{flex:1},children:{$slot:"default"},...l},{$if:a,style:{margin:"0 36px 0 18px"},children:{is:r,buttons:()=>{const[e,s,...i]=n;return[{text:"搜索",onClick:t.onSearch,type:"primary",...e},{text:"重置",onClick:t.onReset,...s},...i]},...u}}]})}},Mt="36px",zt={right:"30px",bottom:"30vh",color:"white",zIndex:1e4,width:Mt,height:Mt,fontSize:"24px",position:"fixed",borderRadius:"50%",backgroundColor:"#FF6666",boxShadow:"1px 1px 6px #6666",justifyContent:"center",alignItems:"center",cursor:"pointer",display:"flex"},qt={},Lt=class{req;key;headers;cache;waitTime=0;constructor(e,t){this.req=e;const{waitTime:s=0}=t,{url:i,method:n}=e;this.body=e.body,this.waitTime=s,this.headers=e.headers,this.key=It.getKey(i,n),this.cache=qt[this.key]||[],qt[this.key]=this.cache}add(e){this.cache.push(e)}remove(e){this.cache.splice(this.cache.indexOf(e),1)}start(){return new Promise(((e,t)=>{const{headers:s,body:i}=this;if(!qt[this.key].some((n=>{if(n.body===i&&JSON.stringify(n.headers)===JSON.stringify(s)){switch(n.status){case 1e3:n.cbs.push({resolve:e,reject:t});break;case 2e3:e(n.value);break;case 3e3:t(n.value)}return!0}}))){const n={cbs:[{resolve:e,reject:t}],key:this.key,status:1e3,value:{},headers:s,body:i};this.add(n),this.req.request().then((e=>{n.value=e,n.status=2e3,n.cbs.forEach((({resolve:t})=>t(e)))})).catch((e=>{n.value=e,n.status=3e3,n.cbs.forEach((({reject:t})=>t(e)))})).finally((()=>{this.waitTime>0?f((()=>this.remove(n)),this.waitTime):this.remove(n)}))}}))}},Ut=class{param;config;url;method;headers;body;httpFetch;constructor(e,t={}){this.param=e,this.config=t;const{method:s="GET"}=e;this.method=s.toLocaleUpperCase(),this.url=this.initFullUrl(),this.headers=this.initHeaders(),this.body=this.initBody()}initFullUrl(){if(this.param.query){const e=this.param.url,t=D.stringify(this.param.query);if(t)return e.includes("?")?`${e}&${t}`:`${e}?${t}`}return this.param.url}initHeaders(){const{headers:e}=this.param,t={};if(e)for(const s in e)t[s.toLocaleLowerCase()]=e[s];return t}initBody(){let e=null;const{body:t,type:s="json"}=this.param,i=e=>{"content-type"in this.headers||(this.headers["content-type"]=e)};return"json"===s?(t&&(e=JSON.stringify(t)),i("application/json")):"form"===s?(t&&(e=D.stringify(t)),i("application/x-www-form-urlencoded")):"text"===s?i("text/plain"):"html"===s?i("text/html"):"string"==typeof s?(this.param.useCache=!1,i(s)):this.param.useCache=!1,!e&&t&&(e=t),e}async initResult(){const{httpBefore:e}=this.config,{method:t,headers:s,body:i}=this,n={method:t,headers:s,body:i};return"function"==typeof e?await e(n):n}async initXHR(e){const{onInitXHR:t}=this.config,{method:s,headers:i}=this,n=new XMLHttpRequest;n.open(s,this.url);for(let e in i)n.setRequestHeader(e,i[e]);return"function"==typeof t?await t(n,e):n}async send(){const{body:e,headers:t}=this,{useCache:s=!0,httpCacheParam:i}=this.param;if(s){const s={headers:t,body:e,...i};return new Lt(this,s).start()}return this.request()}async request(){const{config:e,param:t,url:s}=this,{responseType:i,useFetch:n=!0}=t,r=await this.initResult();return"function"==typeof e.customFetch?e.customFetch(s,r,t).then((e=>({config:t,...e}))):n&&"function"==typeof fetch?await fetch(s,r).then((async e=>{const s=i||"text";if(s in e&&"function"==typeof e[s]){const i=await e[s]();return{config:t,response:e,responseText:i}}return{config:t,response:e}})).catch((e=>Promise.reject({config:t,error:e}))):new Promise((async(e,s)=>{const n=await this.initXHR(r);n.send(this.body),i?(n.responseType=i,n.onload=()=>{const{status:s,response:i}=n;200===s&&e({responseText:i,config:t,xhr:n})}):n.onreadystatechange=()=>{if(4===n.readyState){const i={responseText:n.responseText,config:t,xhr:n};200===n.status?e(i):s(i)}}}))}},Gt=class{config;method;requestData={url:"",mainURL:"",method:""};interceptors={};constructor(e,t,s){this.config=e,this.method=s,this.initRequestData(t,s)}initRequestData(e,t){const{baseURL:s="",headers:i={},...n}=this.config,{httpCacheParam:r,useFetch:a,useCache:o}=n;this.requestData={url:s+e,useFetch:a,useCache:o,method:t,headers:i,httpCacheParam:r,mainURL:e}}addHeaderData(e={}){return Object.assign(this.requestData.headers,e),this}addRequestData(e={}){return Object.assign(this.requestData,e),this}addInterceptors(e){return this.interceptors=e,this}async toRequest(){try{const e=await this.turnIntercept("request",this.requestData),t=new Ut(e,this.config),s=await Promise.race([this.timeout(),t.send()]);return await this.turnIntercept("responseSuccess",s)}catch(e){return console.warn("toRequest捕获异常【@jiess/http】:",e),await this.turnIntercept("responseError",e)}}timeout()