tmagic-editor/playground/runtime/vue3/page/assets/plugin-vueexport-helper-CYignUIG.js
2025-03-31 12:39:00 +00:00

3 lines
32 KiB
JavaScript

var Ce=Object.defineProperty;var St=t=>{throw TypeError(t)};var Ee=(t,r,e)=>r in t?Ce(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var p=(t,r,e)=>Ee(t,typeof r!="symbol"?r+"":r,e),Dt=(t,r,e)=>r.has(t)||St("Cannot "+e);var b=(t,r,e)=>(Dt(t,r,"read from private field"),e?e.call(t):r.get(t)),T=(t,r,e)=>r.has(t)?St("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e),_=(t,r,e,n)=>(Dt(t,r,"write to private field"),n?n.call(t,e):r.set(t,e),e);import{E as Vt,e as Ie,s as xe,c as Pe}from"./index-kuiGTNrJ.js";var te=typeof global=="object"&&global&&global.Object===Object&&global,Me=typeof self=="object"&&self&&self.Object===Object&&self,S=te||Me||Function("return this")(),O=S.Symbol,ee=Object.prototype,Fe=ee.hasOwnProperty,Le=ee.toString,B=O?O.toStringTag:void 0;function Ne(t){var r=Fe.call(t,B),e=t[B];try{t[B]=void 0;var n=!0}catch(s){}var a=Le.call(t);return n&&(r?t[B]=e:delete t[B]),a}var Re=Object.prototype,Ue=Re.toString;function Be(t){return Ue.call(t)}var ke="[object Null]",qe="[object Undefined]",$t=O?O.toStringTag:void 0;function X(t){return t==null?t===void 0?qe:ke:$t&&$t in Object(t)?Ne(t):Be(t)}function R(t){return t!=null&&typeof t=="object"}var nt=Array.isArray;function at(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}function re(t){return t}var He="[object AsyncFunction]",ze="[object Function]",Ge="[object GeneratorFunction]",Ke="[object Proxy]";function ne(t){if(!at(t))return!1;var r=X(t);return r==ze||r==Ge||r==He||r==Ke}var ct=S["__core-js_shared__"],At=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function We(t){return!!At&&At in t}var Ye=Function.prototype,Je=Ye.toString;function I(t){if(t!=null){try{return Je.call(t)}catch(r){}try{return t+""}catch(r){}}return""}var Xe=/[\\^$.*+?()[\]{}|]/g,Ze=/^\[object .+?Constructor\]$/,Qe=Function.prototype,Ve=Object.prototype,tr=Qe.toString,er=Ve.hasOwnProperty,rr=RegExp("^"+tr.call(er).replace(Xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){if(!at(t)||We(t))return!1;var r=ne(t)?rr:Ze;return r.test(I(t))}function ar(t,r){return t==null?void 0:t[r]}function x(t,r){var e=ar(t,r);return nr(e)?e:void 0}var ht=x(S,"WeakMap"),wt=Object.create,sr=function(){function t(){}return function(r){if(!at(r))return{};if(wt)return wt(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function ir(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}function or(){}var cr=800,ur=16,fr=Date.now;function hr(t){var r=0,e=0;return function(){var n=fr(),a=ur-(n-e);if(e=n,a>0){if(++r>=cr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}function dr(t){return function(){return t}}var Q=function(){try{var t=x(Object,"defineProperty");return t({},"",{}),t}catch(r){}}(),lr=Q?function(t,r){return Q(t,"toString",{configurable:!0,enumerable:!1,value:dr(r),writable:!0})}:re,pr=hr(lr);function gr(t,r){for(var e=-1,n=t==null?0:t.length;++e<n&&r(t[e],e,t)!==!1;);return t}function yr(t,r,e,n){for(var a=t.length,s=e+-1;++s<a;)if(r(t[s],s,t))return s;return-1}function br(t){return t!==t}function mr(t,r,e){for(var n=e-1,a=t.length;++n<a;)if(t[n]===r)return n;return-1}function Tr(t,r,e){return r===r?mr(t,r,e):yr(t,br,e)}function _r(t,r){var e=t==null?0:t.length;return!!e&&Tr(t,r,0)>-1}var jr=9007199254740991,Sr=/^(?:0|[1-9]\d*)$/;function Dr(t,r){var e=typeof t;return r=r==null?jr:r,!!r&&(e=="number"||e!="symbol"&&Sr.test(t))&&t>-1&&t%1==0&&t<r}function $r(t,r,e){r=="__proto__"&&Q?Q(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function ae(t,r){return t===r||t!==t&&r!==r}var Ar=Object.prototype,wr=Ar.hasOwnProperty;function Or(t,r,e){var n=t[r];(!(wr.call(t,r)&&ae(n,e))||e===void 0&&!(r in t))&&$r(t,r,e)}var Ot=Math.max;function vr(t,r,e){return r=Ot(r===void 0?t.length-1:r,0),function(){for(var n=arguments,a=-1,s=Ot(n.length-r,0),i=Array(s);++a<s;)i[a]=n[r+a];a=-1;for(var c=Array(r+1);++a<r;)c[a]=n[a];return c[r]=e(i),ir(t,this,c)}}function Cr(t,r){return pr(vr(t,r,re),t+"")}var Er=9007199254740991;function se(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Er}function ie(t){return t!=null&&se(t.length)&&!ne(t)}var Ir=Object.prototype;function oe(t){var r=t&&t.constructor,e=typeof r=="function"&&r.prototype||Ir;return t===e}function xr(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}var Pr="[object Arguments]";function vt(t){return R(t)&&X(t)==Pr}var ce=Object.prototype,Mr=ce.hasOwnProperty,Fr=ce.propertyIsEnumerable,ue=vt(function(){return arguments}())?vt:function(t){return R(t)&&Mr.call(t,"callee")&&!Fr.call(t,"callee")};function Lr(){return!1}var fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=fe&&typeof module=="object"&&module&&!module.nodeType&&module,Nr=Ct&&Ct.exports===fe,Et=Nr?S.Buffer:void 0,Rr=Et?Et.isBuffer:void 0,he=Rr||Lr,Ur="[object Arguments]",Br="[object Array]",kr="[object Boolean]",qr="[object Date]",Hr="[object Error]",zr="[object Function]",Gr="[object Map]",Kr="[object Number]",Wr="[object Object]",Yr="[object RegExp]",Jr="[object Set]",Xr="[object String]",Zr="[object WeakMap]",Qr="[object ArrayBuffer]",Vr="[object DataView]",tn="[object Float32Array]",en="[object Float64Array]",rn="[object Int8Array]",nn="[object Int16Array]",an="[object Int32Array]",sn="[object Uint8Array]",on="[object Uint8ClampedArray]",cn="[object Uint16Array]",un="[object Uint32Array]",g={};g[tn]=g[en]=g[rn]=g[nn]=g[an]=g[sn]=g[on]=g[cn]=g[un]=!0;g[Ur]=g[Br]=g[Qr]=g[kr]=g[Vr]=g[qr]=g[Hr]=g[zr]=g[Gr]=g[Kr]=g[Wr]=g[Yr]=g[Jr]=g[Xr]=g[Zr]=!1;function fn(t){return R(t)&&se(t.length)&&!!g[X(t)]}function bt(t){return function(r){return t(r)}}var de=typeof exports=="object"&&exports&&!exports.nodeType&&exports,k=de&&typeof module=="object"&&module&&!module.nodeType&&module,hn=k&&k.exports===de,ut=hn&&te.process,N=function(){try{var t=k&&k.require&&k.require("util").types;return t||ut&&ut.binding&&ut.binding("util")}catch(r){}}(),It=N&&N.isTypedArray,dn=It?bt(It):fn,ln=Object.prototype,pn=ln.hasOwnProperty;function gn(t,r){var e=nt(t),n=!e&&ue(t),a=!e&&!n&&he(t),s=!e&&!n&&!a&&dn(t),i=e||n||a||s,c=i?xr(t.length,String):[],o=c.length;for(var f in t)pn.call(t,f)&&!(i&&(f=="length"||a&&(f=="offset"||f=="parent")||s&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Dr(f,o)))&&c.push(f);return c}function le(t,r){return function(e){return t(r(e))}}var yn=le(Object.keys,Object),bn=Object.prototype,mn=bn.hasOwnProperty;function Tn(t){if(!oe(t))return yn(t);var r=[];for(var e in Object(t))mn.call(t,e)&&e!="constructor"&&r.push(e);return r}function _n(t){return ie(t)?gn(t):Tn(t)}var q=x(Object,"create");function jn(){this.__data__=q?q(null):{},this.size=0}function Sn(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}var Dn="__lodash_hash_undefined__",$n=Object.prototype,An=$n.hasOwnProperty;function wn(t){var r=this.__data__;if(q){var e=r[t];return e===Dn?void 0:e}return An.call(r,t)?r[t]:void 0}var On=Object.prototype,vn=On.hasOwnProperty;function Cn(t){var r=this.__data__;return q?r[t]!==void 0:vn.call(r,t)}var En="__lodash_hash_undefined__";function In(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=q&&r===void 0?En:r,this}function C(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}C.prototype.clear=jn;C.prototype.delete=Sn;C.prototype.get=wn;C.prototype.has=Cn;C.prototype.set=In;function xn(){this.__data__=[],this.size=0}function st(t,r){for(var e=t.length;e--;)if(ae(t[e][0],r))return e;return-1}var Pn=Array.prototype,Mn=Pn.splice;function Fn(t){var r=this.__data__,e=st(r,t);if(e<0)return!1;var n=r.length-1;return e==n?r.pop():Mn.call(r,e,1),--this.size,!0}function Ln(t){var r=this.__data__,e=st(r,t);return e<0?void 0:r[e][1]}function Nn(t){return st(this.__data__,t)>-1}function Rn(t,r){var e=this.__data__,n=st(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this}function A(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}A.prototype.clear=xn;A.prototype.delete=Fn;A.prototype.get=Ln;A.prototype.has=Nn;A.prototype.set=Rn;var H=x(S,"Map");function Un(){this.size=0,this.__data__={hash:new C,map:new(H||A),string:new C}}function Bn(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}function it(t,r){var e=t.__data__;return Bn(r)?e[typeof r=="string"?"string":"hash"]:e.map}function kn(t){var r=it(this,t).delete(t);return this.size-=r?1:0,r}function qn(t){return it(this,t).get(t)}function Hn(t){return it(this,t).has(t)}function zn(t,r){var e=it(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this}function P(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}P.prototype.clear=Un;P.prototype.delete=kn;P.prototype.get=qn;P.prototype.has=Hn;P.prototype.set=zn;function pe(t,r){for(var e=-1,n=r.length,a=t.length;++e<n;)t[a+e]=r[e];return t}var xt=O?O.isConcatSpreadable:void 0;function Gn(t){return nt(t)||ue(t)||!!(xt&&t&&t[xt])}function Kn(t,r,e,n,a){var s=-1,i=t.length;for(e||(e=Gn),a||(a=[]);++s<i;){var c=t[s];e(c)&&pe(a,c)}return a}var Wn=le(Object.getPrototypeOf,Object);function Yn(){this.__data__=new A,this.size=0}function Jn(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e}function Xn(t){return this.__data__.get(t)}function Zn(t){return this.__data__.has(t)}var Qn=200;function Vn(t,r){var e=this.__data__;if(e instanceof A){var n=e.__data__;if(!H||n.length<Qn-1)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new P(n)}return e.set(t,r),this.size=e.size,this}function U(t){var r=this.__data__=new A(t);this.size=r.size}U.prototype.clear=Yn;U.prototype.delete=Jn;U.prototype.get=Xn;U.prototype.has=Zn;U.prototype.set=Vn;var ge=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pt=ge&&typeof module=="object"&&module&&!module.nodeType&&module,ta=Pt&&Pt.exports===ge,Mt=ta?S.Buffer:void 0;Mt&&Mt.allocUnsafe;function ea(t,r){return t.slice()}function ra(t,r){for(var e=-1,n=t==null?0:t.length,a=0,s=[];++e<n;){var i=t[e];r(i,e,t)&&(s[a++]=i)}return s}function na(){return[]}var aa=Object.prototype,sa=aa.propertyIsEnumerable,Ft=Object.getOwnPropertySymbols,ia=Ft?function(t){return t==null?[]:(t=Object(t),ra(Ft(t),function(r){return sa.call(t,r)}))}:na;function oa(t,r,e){var n=r(t);return nt(t)?n:pe(n,e(t))}function ca(t){return oa(t,_n,ia)}var dt=x(S,"DataView"),lt=x(S,"Promise"),F=x(S,"Set"),Lt="[object Map]",ua="[object Object]",Nt="[object Promise]",Rt="[object Set]",Ut="[object WeakMap]",Bt="[object DataView]",fa=I(dt),ha=I(H),da=I(lt),la=I(F),pa=I(ht),$=X;(dt&&$(new dt(new ArrayBuffer(1)))!=Bt||H&&$(new H)!=Lt||lt&&$(lt.resolve())!=Nt||F&&$(new F)!=Rt||ht&&$(new ht)!=Ut)&&($=function(t){var r=X(t),e=r==ua?t.constructor:void 0,n=e?I(e):"";if(n)switch(n){case fa:return Bt;case ha:return Lt;case da:return Nt;case la:return Rt;case pa:return Ut}return r});var ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t){var r=t.length,e=new t.constructor(r);return r&&typeof t[0]=="string"&&ya.call(t,"index")&&(e.index=t.index,e.input=t.input),e}var kt=S.Uint8Array;function mt(t){var r=new t.constructor(t.byteLength);return new kt(r).set(new kt(t)),r}function ma(t,r){var e=mt(t.buffer);return new t.constructor(e,t.byteOffset,t.byteLength)}var Ta=/\w*$/;function _a(t){var r=new t.constructor(t.source,Ta.exec(t));return r.lastIndex=t.lastIndex,r}var qt=O?O.prototype:void 0,Ht=qt?qt.valueOf:void 0;function ja(t){return Ht?Object(Ht.call(t)):{}}function Sa(t,r){var e=mt(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}var Da="[object Boolean]",$a="[object Date]",Aa="[object Map]",wa="[object Number]",Oa="[object RegExp]",va="[object Set]",Ca="[object String]",Ea="[object Symbol]",Ia="[object ArrayBuffer]",xa="[object DataView]",Pa="[object Float32Array]",Ma="[object Float64Array]",Fa="[object Int8Array]",La="[object Int16Array]",Na="[object Int32Array]",Ra="[object Uint8Array]",Ua="[object Uint8ClampedArray]",Ba="[object Uint16Array]",ka="[object Uint32Array]";function qa(t,r,e){var n=t.constructor;switch(r){case Ia:return mt(t);case Da:case $a:return new n(+t);case xa:return ma(t);case Pa:case Ma:case Fa:case La:case Na:case Ra:case Ua:case Ba:case ka:return Sa(t);case Aa:return new n;case wa:case Ca:return new n(t);case Oa:return _a(t);case va:return new n;case Ea:return ja(t)}}function Ha(t){return typeof t.constructor=="function"&&!oe(t)?sr(Wn(t)):{}}var za="[object Map]";function Ga(t){return R(t)&&$(t)==za}var zt=N&&N.isMap,Ka=zt?bt(zt):Ga,Wa="[object Set]";function Ya(t){return R(t)&&$(t)==Wa}var Gt=N&&N.isSet,Ja=Gt?bt(Gt):Ya,ye="[object Arguments]",Xa="[object Array]",Za="[object Boolean]",Qa="[object Date]",Va="[object Error]",be="[object Function]",ts="[object GeneratorFunction]",es="[object Map]",rs="[object Number]",me="[object Object]",ns="[object RegExp]",as="[object Set]",ss="[object String]",is="[object Symbol]",os="[object WeakMap]",cs="[object ArrayBuffer]",us="[object DataView]",fs="[object Float32Array]",hs="[object Float64Array]",ds="[object Int8Array]",ls="[object Int16Array]",ps="[object Int32Array]",gs="[object Uint8Array]",ys="[object Uint8ClampedArray]",bs="[object Uint16Array]",ms="[object Uint32Array]",l={};l[ye]=l[Xa]=l[cs]=l[us]=l[Za]=l[Qa]=l[fs]=l[hs]=l[ds]=l[ls]=l[ps]=l[es]=l[rs]=l[me]=l[ns]=l[as]=l[ss]=l[is]=l[gs]=l[ys]=l[bs]=l[ms]=!0;l[Va]=l[be]=l[os]=!1;function Z(t,r,e,n,a,s){var i;if(i!==void 0)return i;if(!at(t))return t;var c=nt(t);if(c)i=ba(t);else{var o=$(t),f=o==be||o==ts;if(he(t))return ea(t);if(o==me||o==ye||f&&!a)i=f?{}:Ha(t);else{if(!l[o])return a?t:{};i=qa(t,o)}}s||(s=new U);var u=s.get(t);if(u)return u;s.set(t,i),Ja(t)?t.forEach(function(d){i.add(Z(d,r,e,d,t,s))}):Ka(t)&&t.forEach(function(d,m){i.set(m,Z(d,r,e,m,t,s))});var h=ca,y=c?void 0:h(t);return gr(y||t,function(d,m){y&&(m=d,d=t[m]),Or(i,m,Z(d,r,e,m,t,s))}),i}var Ts=1,_s=4;function ot(t){return Z(t,Ts|_s)}var js="__lodash_hash_undefined__";function Ss(t){return this.__data__.set(t,js),this}function Ds(t){return this.__data__.has(t)}function V(t){var r=-1,e=t==null?0:t.length;for(this.__data__=new P;++r<e;)this.add(t[r])}V.prototype.add=V.prototype.push=Ss;V.prototype.has=Ds;function $s(t,r){return t.has(r)}function Te(t){var r=-1,e=Array(t.size);return t.forEach(function(n){e[++r]=n}),e}function As(t){return R(t)&&ie(t)}var ws=1/0,Os=F&&1/Te(new F([,-0]))[1]==ws?function(t){return new F(t)}:or,vs=200;function Cs(t,r,e){var n=-1,a=_r,s=t.length,i=!0,c=[],o=c;if(s>=vs){var f=Os(t);if(f)return Te(f);i=!1,a=$s,o=new V}else o=c;t:for(;++n<s;){var u=t[n],h=u;if(u=u!==0?u:0,i&&h===h){for(var y=o.length;y--;)if(o[y]===h)continue t;c.push(u)}else a(o,h,e)||(o!==c&&o.push(h),c.push(u))}return c}Cr(function(t){return Cs(Kn(t,1,As))});class Es{}class _e extends Es{constructor(e){super();p(this,"data",{});p(this,"event",new Ie.EventEmitter);this.data=e}update(e,n){n?yt(n,e,this.data):this.data=e;const a={updateData:e,path:n!=null?n:""};n&&this.event.emit(n,a),this.event.emit("",a)}on(e,n){this.event.on(e,n)}off(e,n){this.event.off(e,n)}getData(e){return e?E(e,this.data):this.data}destroy(){}}var et,G,K,j,v,W;class je extends Vt{constructor(e){var s,i,c,o,f;super();p(this,"isInit",!1);p(this,"app");p(this,"mockData");T(this,et,"base");T(this,G);T(this,K);T(this,j);T(this,v,[]);T(this,W,[]);_(this,G,e.schema.id),_(this,K,e.schema),this.app=e.app,this.setFields(e.schema.fields),this.setMethods(e.schema.methods||[]);let n=e.initialData;const a=e.ObservedDataClass||_e;if(this.app.platform==="editor")this.mockData=((i=(s=e.schema.mocks)==null?void 0:s.find(u=>u.useInEditor))==null?void 0:i.data)||this.getDefaultData(),n=ot(this.mockData);else if(typeof e.useMock=="boolean"&&e.useMock)this.mockData=(o=(c=e.schema.mocks)==null?void 0:c.find(u=>u.enable))==null?void 0:o.data,n=this.mockData||this.getDefaultData();else if(!e.initialData)n=this.getDefaultData();else{_(this,j,new a((f=e.initialData)!=null?f:{})),this.isInit=!0;return}_(this,j,new a(n!=null?n:{}))}get id(){return b(this,G)}get type(){return b(this,et)}get schema(){return b(this,K)}get fields(){return b(this,v)}get methods(){return b(this,W)}setFields(e){_(this,v,e)}setMethods(e){_(this,W,e)}get data(){return b(this,j).getData("")}setData(e,n){b(this,j).update(e,n);const a={updateData:e,path:n};this.emit("change",a)}setValue(e,n){return this.setData(n,e)}onDataChange(e,n){b(this,j).on(e,n)}offDataChange(e,n){b(this,j).off(e,n)}getDefaultData(){return we(b(this,v))}async init(){this.isInit=!0}destroy(){_(this,v,[]),this.removeAllListeners(),b(this,j).destroy()}}et=new WeakMap,G=new WeakMap,K=new WeakMap,j=new WeakMap,v=new WeakMap,W=new WeakMap;const Kt=t=>Object.entries(t).reduce((r,[e,n])=>{let a=n;return typeof n=="object"&&(a=JSON.stringify(n)),typeof n<"u"?"".concat(r).concat(r?"&":"").concat(globalThis.encodeURIComponent(e),"=").concat(globalThis.encodeURIComponent("".concat(a))):r},""),Is=async t=>{var u;const{url:r,method:e="GET",headers:n={},params:a={},data:s={},...i}=t,c=Kt(a);let o=JSON.stringify(s);return(u=n["Content-Type"])!=null&&u.includes("application/x-www-form-urlencoded")&&(o=Kt(s)),(await globalThis.fetch(c?"".concat(r,"?").concat(c):r,{method:e,headers:n,body:e==="GET"?void 0:o,...i})).json()};var L,Y,J,rt;class xs extends je{constructor(e){const{options:n}=e.schema;super(e);p(this,"isLoading",!1);p(this,"error");p(this,"httpOptions");T(this,L);T(this,Y,[]);T(this,J,[]);T(this,rt,"http");this.httpOptions=n,typeof e.request=="function"?_(this,L,e.request):typeof globalThis.fetch=="function"&&_(this,L,Is),this.methods.forEach(a=>{typeof a.content=="function"&&(a.timing==="beforeRequest"&&b(this,Y).push(a.content),a.timing==="afterRequest"&&b(this,J).push(a.content))})}get type(){return b(this,rt)}async init(){this.schema.autoFetch&&await this.request(),super.init()}async request(e={}){var f,u;this.isLoading=!0;const{url:n,params:a,data:s,headers:i,...c}=this.httpOptions;let o={url:typeof n=="function"?n({app:this.app,dataSource:this}):n,params:typeof a=="function"?a({app:this.app,dataSource:this}):a,data:typeof s=="function"?s({app:this.app,dataSource:this}):s,headers:typeof i=="function"?i({app:this.app,dataSource:this}):i,...c,...e};try{for(const h of b(this,Y))await h({options:o,params:{},dataSource:this,app:this.app});if(typeof this.schema.beforeRequest=="function"&&(o=await this.schema.beforeRequest(o,{app:this.app,dataSource:this})),this.mockData)this.setData(this.mockData);else{let h=await((f=b(this,L))==null?void 0:f.call(this,o));for(const y of b(this,J))await y({res:h,options:o,params:{},dataSource:this,app:this.app});if(typeof this.schema.afterResponse=="function"&&(h=await this.schema.afterResponse(h,{app:this.app,dataSource:this,options:o})),(u=this.schema.responseOptions)!=null&&u.dataPath){const y=E(this.schema.responseOptions.dataPath,h);this.setData(y)}else this.setData(h)}this.error=void 0}catch(h){this.error={msg:h.message},this.emit("error",h)}this.isLoading=!1}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}}L=new WeakMap,Y=new WeakMap,J=new WeakMap,rt=new WeakMap;const ft=new Map,Ps=(t,r,e)=>{let n;if(e){const o=[];r.forEach(f=>{ve(f,u=>{o.push(u.id)})}),n="".concat(t.id,":").concat(o.join(":"))}else n="".concat(t.id,":").concat(r.map(o=>o.id).join(":"));if(ft.has(n))return ft.get(n);const a=new zs;a.addTarget(new Zt({id:t.id,type:"data-source",isTarget:(o,f)=>"".concat(o).includes($e)?!1:qs(t,o,f,!0)})),a.addTarget(new Zt({id:t.id,type:"cond",isTarget:(o,f)=>Hs(t,o,f,!0)})),a.collect(r,{},!0);const{deps:s}=a.getTarget(t.id,"data-source"),{deps:i}=a.getTarget(t.id,"cond"),c={deps:s,condDeps:i};return ft.set(n,c),c},Ms=(t,r)=>{let e=!0;for(const{op:n,value:a,range:s,field:i}of t){const[c,...o]=i,f=r[c];if(!f||!o.length)break;try{const u=E(o.join("."),f);if(!Ns(n,u,a,s)){e=!1;break}}catch(u){console.warn(u)}}return e},pt=(t,r)=>{if(!t[M]||!Array.isArray(t[M])||!t[M].length)return!0;for(const{cond:e}of t[M])if(e&&Ms(e,r))return!0;return!1},Wt=(t,r,e=[],n={})=>{const a={...n,[r]:{}};let s=ot(n[r]),i=a[r];return e.forEach((c,o)=>{if(Object.assign(i,s),o===e.length-1){i[c]=t;return}Array.isArray(s[c])&&(s[c]={},i[c]={}),s=s[c],i=i[c]}),a},Fs=(t,r)=>{const[e,...n]=t,a=e.indexOf(tt);if(a>-1){const s=e.substring(a+tt.length),i=r[s];if(!i)return t;try{return E(n.join("."),i)}catch(c){return t}}return t},Yt=(t,r)=>t.replaceAll(Oe,(e,n)=>{try{return E(n,r)}catch(a){return e}}),Jt=(t,r)=>typeof t=="string"?Yt(t,r):t!=null&&t.isBindDataSource&&t.dataSourceId?r[t.dataSourceId]:t!=null&&t.isBindDataSourceField&&t.dataSourceId&&typeof t.template=="string"?Yt(t.template,r[t.dataSourceId]):Array.isArray(t)&&typeof t[0]=="string"?Fs(t,r):t,Se=({compile:t,dsId:r,item:e,deps:n,condDeps:a,inEditor:s,ctxData:i})=>{var u,h;const{items:c,...o}=e,f=ot(o);return(u=a[o.id])!=null&&u.keys.length&&!s&&(f.condResult=pt(o,i)),Array.isArray(c)&&c.length?f.items=c.map(y=>Se({compile:t,dsId:r,item:y,deps:n,condDeps:a,inEditor:s,ctxData:i})):c&&(f.items=c),(h=n[f.id])!=null&&h.keys.length?Ae(t,f,{[r]:n},r):f},D=class D extends Vt{constructor({app:e,useMock:n,initialData:a}){var i,c;super();p(this,"app");p(this,"dataSourceMap",new Map);p(this,"data",{});p(this,"useMock",!1);this.app=e,this.useMock=n,a&&(this.data=a),(c=(i=e.dsl)==null?void 0:i.dataSources)==null||c.forEach(o=>{this.addDataSource(o)});const s=Array.from(this.dataSourceMap);typeof Promise.allSettled=="function"?Promise.allSettled(s.map(([,o])=>this.init(o))).then(o=>{const f={},u={};o.forEach((h,y)=>{const d=s[y][0];h.status==="fulfilled"?this.data[d]?f[d]=this.data[d]:delete f[d]:h.status==="rejected"&&(delete f[d],u[d]=h.reason)}),this.emit("init",f,u)}):Promise.all(s.map(([,o])=>this.init(o))).then(()=>{this.emit("init",this.data)}).catch(()=>{this.emit("init",this.data)})}static register(e,n){D.dataSourceClassMap.set(e,n)}static getDataSourceClass(e){return D.dataSourceClassMap.get(e)}static registerObservedData(e){D.ObservedDataClass=e}async init(e){var n;if(!e.isInit&&!(this.app.jsEngine&&((n=e.schema.disabledInitInJsEngine)!=null&&n.includes(this.app.jsEngine)))){for(const a of e.methods){if(typeof a.content!="function")return;a.timing==="beforeInit"&&await a.content({params:{},dataSource:e,app:this.app})}await e.init();for(const a of e.methods){if(typeof a.content!="function")return;a.timing==="afterInit"&&await a.content({params:{},dataSource:e,app:this.app})}}}get(e){return this.dataSourceMap.get(e)}async addDataSource(e){if(!e)return;const n=D.dataSourceClassMap.get(e.type)||je,a=new n({app:this.app,schema:e,request:this.app.request,useMock:this.useMock,initialData:this.data[e.id],ObservedDataClass:D.ObservedDataClass});this.dataSourceMap.set(e.id,a),this.data[a.id]=a.data,a.on("change",s=>{this.setData(a,s)})}setData(e,n){this.data[e.id]=e.data,this.emit("change",e.id,n)}removeDataSource(e){var n;(n=this.get(e))==null||n.destroy(),delete this.data[e],this.dataSourceMap.delete(e)}updateSchema(e){e.forEach(n=>{if(!this.get(n.id))return;this.removeDataSource(n.id),this.addDataSource(n);const s=this.get(n.id);s&&this.init(s)})}compiledNode({items:e,...n},a,s=!1){var c;const i=ot(n);return e&&(i.items=Array.isArray(e)&&s?e.map(o=>this.compiledNode(o,a,s)):e),n.condResult===!1||n.visible===!1?i:Ae(o=>Jt(o,this.data),i,((c=this.app.dsl)==null?void 0:c.dataSourceDeps)||{},a)}compliedConds(e){return pt(e,this.data)}compliedIteratorItemConds(e,n,a=[]){const[s,...i]=a,c=this.get(s);if(!c)return!0;const o=Wt(e,c.id,i,this.data);return pt(n,o)}compliedIteratorItems(e,n,a=[]){const[s,...i]=a,c=this.get(s);if(!c)return n;const o=this.app.platform==="editor",f=Wt(e,c.id,i,this.data),{deps:u={},condDeps:h={}}=Ps(c.schema,n,o);return!Object.keys(u).length&&!Object.keys(h).length?n:n.map(y=>Se({compile:d=>Jt(d,f),dsId:c.id,item:y,deps:u,condDeps:h,inEditor:o,ctxData:f}))}destroy(){this.removeAllListeners(),this.data={},this.dataSourceMap.forEach(e=>{e.destroy()}),this.dataSourceMap.clear()}onDataChange(e,n,a){var s;return(s=this.get(e))==null?void 0:s.onDataChange(n,a)}offDataChange(e,n,a){var s;return(s=this.get(e))==null?void 0:s.offDataChange(n,a)}};p(D,"dataSourceClassMap",new Map),p(D,"ObservedDataClass",_e);let gt=D;gt.register("http",xs);const M="displayConds",De=(t="")=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),z=t=>Object.prototype.toString.call(t)==="[object Object]",Tt=t=>"".concat(t).replaceAll(/\[(\d+)\]/g,".$1").split("."),E=(t="",r={})=>(Array.isArray(t)?t:Tt(t)).reduce((n,a)=>{if(z(n)||Array.isArray(n)&&/^\d*$/.test("".concat(a)))return n[a];throw new Error("".concat(r,"中不存在").concat(t))},r),yt=(t,r,e={})=>xe(e,t,r),Ls=(t={},r)=>Array.from(Object.values(t).reduce((e,n)=>{var a;return(((a=n[r])==null?void 0:a.keys)||[]).forEach(s=>e.add(s)),e},new Set)),$e="__tmagic__",Xt="__tmagic__dslNode",Ae=(t,r,e={},n)=>{let a=[];if(!n)a=Ls(e,r.id);else{const s=e[n];a=(s==null?void 0:s[r.id].keys)||[]}return a.forEach(s=>{const i=Tt(s),c=i.map((u,h)=>h<i.length-1?u:"".concat($e).concat(u));let o=E(c,r);if(typeof o>"u")try{const u=E(s,r);yt(c.join("."),u,r),o=u}catch(u){console.warn(u);return}let f;try{f=t(o)}catch(u){console.error(u),f=""}yt(s,f,r)}),r},Ns=(t,r,e,n=[])=>{var a,s;switch(typeof r=="string"&&typeof e>"u"&&(e=""),t){case"is":return r===e;case"not":return r!==e;case"=":return r===e;case"!=":return r!==e;case">":return r>e;case">=":return r>=e;case"<":return r<e;case"<=":return r<=e;case"between":return n.length>1&&r>=n[0]&&r<=n[1];case"not_between":return n.length<2||r<n[0]||r>n[1];case"include":return(a=r==null?void 0:r.includes)==null?void 0:a.call(r,e);case"not_include":return typeof r>"u"||!((s=r.includes)!=null&&s.call(r,e))}return!1},we=t=>{const r={},e={string:void 0,object:{},array:[],boolean:void 0,number:void 0,null:null,any:void 0};return t.forEach(n=>{if(typeof n.defaultValue<"u"){if(n.type==="array"&&!Array.isArray(n.defaultValue)){r[n.name]=e.array;return}if(n.type==="object"&&!z(n.defaultValue)){if(typeof n.defaultValue=="string"){try{r[n.name]=JSON.parse(n.defaultValue)}catch(a){r[n.name]=e.object}return}r[n.name]=e.object;return}r[n.name]=Pe(n.defaultValue);return}if(n.type==="object"){r[n.name]=n.fields?we(n.fields):e.object;return}if(n.type){r[n.name]=e[n.type];return}r[n.name]=void 0}),r},tt="ds-field::",Oe=/\$\{([\s\S]+?)\}/g,Rs=t=>typeof t[Xt]>"u"||t[Xt]===!0,ve=(t,r,e=[],n=!1)=>{n||r(t,e),Array.isArray(t.items)&&t.items.length&&(e.push(t),t.items.forEach(a=>{ve(a,r,[...e],n)})),n&&r(t,e)};var w=(t=>(t.DEFAULT="default",t.CODE_BLOCK="code-block",t.DATA_SOURCE="data-source",t.DATA_SOURCE_METHOD="data-source-method",t.DATA_SOURCE_COND="data-source-cond",t))(w||{});class Zt{constructor(r){p(this,"isTarget");p(this,"id");p(this,"name");p(this,"type",w.DEFAULT);p(this,"deps",{});p(this,"isCollectByDefault");var e;this.isTarget=r.isTarget,this.id=r.id,this.name=r.name,this.isCollectByDefault=(e=r.isCollectByDefault)!=null?e:!0,r.type&&(this.type=r.type),r.initialDeps&&(this.deps=r.initialDeps)}updateDep({id:r,name:e,key:n,data:a}){const s=this.deps[r]||{name:e,keys:[]};s.name=e,s.data=a,this.deps[r]=s,s.keys.indexOf(n)===-1&&s.keys.push(n)}removeDep(r,e){if(typeof r>"u"){Object.keys(this.deps).forEach(a=>{delete this.deps[a]});return}const n=this.deps[r];if(n)if(e){const a=n.keys.indexOf(e);n.keys.splice(a,1),n.keys.length===0&&delete this.deps[r]}else delete this.deps[r]}hasDep(r,e){const n=this.deps[r];return!!(n!=null&&n.keys.find(a=>a===e))}destroy(){this.deps={}}}const _t=(t,r)=>{let e=r;return t.some((n,a)=>{const s=e.find(({name:i})=>i===n);return e=(s==null?void 0:s.fields)||[],s&&s.type==="array"&&/^(?!\d+$).*$/.test("".concat(t[a+1]))&&a<t.length-1})},Us=(t,r,e=!1)=>{const n=t.match(Oe)||[];if(n.length<=0)return!1;const a=[],s=[];return n.forEach(i=>{const c=i.substring(2,i.length-1),o=Tt(c),f=o.shift();!f||f!==r.id||(_t(o,r.fields)?a.push(i):s.push(i))}),e?a.length>0:s.length>0},Bs=(t,r)=>(t==null?void 0:t.isBindDataSourceField)&&t.dataSourceId&&t.dataSourceId===r&&typeof t.template=="string",ks=(t,r)=>{if(!Array.isArray(t)||typeof t[0]!="string")return!1;const[e]=t,n=e.indexOf(tt);return n===-1?!1:e.substring(n+tt.length)===r},qs=(t,r,e,n=!1)=>{if(!e||!["string","object"].includes(typeof e)||"".concat(r).startsWith(M))return!1;if(typeof e=="string")return Us(e,t,n);if(z(e)&&(e!=null&&e.isBindDataSource)&&e.dataSourceId&&e.dataSourceId===t.id||Bs(e,t.id))return!0;if(ks(e,t.id)){const[,...a]=e,s=_t(a,t.fields);return n?s:!s}return!1},Hs=(t,r,e,n=!1)=>{var i;if(!Array.isArray(e)||!t)return!1;const[a,...s]=e;if(a!==t.id||!"".concat(r).startsWith(M))return!1;if((i=t.fields)!=null&&i.find(c=>c.name===s[0])){const c=_t(s,t.fields);return n?c:!c}return!1},Qt=(t,r,e)=>{for(const n of Object.values(t))for(const a of Object.values(n))e&&a.type!==e||r(a)};class zs{constructor(r){p(this,"targetsList",{});p(this,"childrenProp","items");p(this,"idProp","id");p(this,"nameProp","name");r!=null&&r.initialTargets&&(this.targetsList=r.initialTargets),r!=null&&r.childrenProp&&(this.childrenProp=r.childrenProp)}getTargetsList(){return this.targetsList}getTargets(r=w.DEFAULT){return this.targetsList[r]||{}}addTarget(r){const e=this.getTargets(r.type)||{};this.targetsList[r.type]=e,e[r.id]=r}getTarget(r,e=w.DEFAULT){return this.getTargets(e)[r]}hasTarget(r,e=w.DEFAULT){return!!this.getTarget(r,e)}hasSpecifiedTypeTarget(r=w.DEFAULT){return Object.keys(this.getTargets(r)).length>0}removeTarget(r,e=w.DEFAULT){const n=this.getTargets(e);n[r]&&(n[r].destroy(),delete n[r])}removeTargets(r=w.DEFAULT){const e=this.targetsList[r];if(e){for(const n of Object.values(e))n.destroy();delete this.targetsList[r]}}clearTargets(){for(const r of Object.keys(this.targetsList))delete this.targetsList[r]}collect(r,e={},n=!1,a){this.collectByCallback(r,a,({node:s,target:i})=>{this.removeTargetDep(i,s),this.collectItem(s,i,e,n)})}collectByCallback(r,e,n){Qt(this.targetsList,a=>{if(!(!e&&!a.isCollectByDefault))for(const s of r)n({node:s,target:a})},e)}clear(r,e){let{targetsList:n}=this;e&&(n={[e]:this.getTargets(e)});const a=[];Qt(n,s=>{if(r)for(const i of r)s.removeDep(i[this.idProp]),Array.isArray(i[this.childrenProp])&&i[this.childrenProp].length&&!a.includes(i[this.idProp])&&(a.push(i[this.idProp]),this.clear(i[this.childrenProp]));else s.removeDep()})}clearByType(r,e){this.clear(e,r)}collectItem(r,e,n={},a=!1){const s=(i,c="")=>{const o=(f,u)=>{const h=f===this.childrenProp,y=c?"".concat(c,".").concat(f):f;if(e.isTarget(y,u))e.updateDep({id:r[this.idProp],name:"".concat(r[this.nameProp]||r[this.idProp]),data:n,key:y});else if(!h&&Array.isArray(u))for(let d=0,m=u.length;d<m;d++){const jt=u[d];z(jt)&&s(jt,"".concat(y,"[").concat(d,"]"))}else z(u)&&s(u,y);if(h&&a&&Array.isArray(u))for(const d of u)this.collectItem(d,e,n,a)};for(const[f,u]of Object.entries(i))typeof u>"u"||u===""||f==="id"||f==="name"||o(f,u)};s(r)}removeTargetDep(r,e,n){if(r.removeDep(e[this.idProp],n),typeof n>"u"&&Array.isArray(e[this.childrenProp])&&e[this.childrenProp].length)for(const a of e[this.childrenProp])this.removeTargetDep(r,a,n)}}const Gs=(t,r=VueDemi.inject("app"))=>Rs(t.config)&&t.config.id?r==null?void 0:r.getNode(t.config.id,t.iteratorContainerId,t.iteratorIndex):void 0,Ks=(t,r={})=>{if(!t)return;const e={config:t.data,...r};t.emit("created",e),VueDemi.onMounted(()=>{t.emit("mounted",e)}),VueDemi.onBeforeUnmount(()=>{t.emit("destroy",e)})},Js=({methods:t={},config:r,iteratorContainerId:e,iteratorIndex:n})=>{const a=VueDemi.inject("app"),s=Gs({config:r,iteratorContainerId:e,iteratorIndex:n},a);return s&&Ks(s,t),{app:a,node:s}},Xs=t=>{const r=VueDemi.inject("app"),e=VueDemi.ref("default"),n=new Map,a=new Map,s=new Map,i=o=>{e.value=o},c=(o,{style:f,className:u,...h})=>{f&&n.set(o,f),u&&a.set(o,u),s.set(o,VueDemi.shallowReactive(h))};return VueDemi.watchEffect(()=>{c("default",{style:t.config.style,className:t.config.className})}),VueDemi.onScopeDispose(()=>{s.clear()}),{status:VueDemi.computed(()=>e.value),style:VueDemi.computed(()=>{const o=e.value||"default",f=n.get("default")||{},u=n.get(o);let h=(r==null?void 0:r.transformStyle(f))||{};return o!=="default"&&u&&(h=Object.keys(u).reduce((y,d)=>{const m=u[d];return m===null||typeof m>"u"||isNaN(m)||m===""?{...y,[d]:u[d]}:{...y}},h)),t.config.displayHidden&&(h.display="none"),typeof t.config.condResult<"u"&&t.config.displayRenderModel==="mount"&&t.config.condResult===!1&&(h.display="none"),h}),className:VueDemi.computed(()=>{var h;const o=e.value||"default",f=(h=a.get(o))!=null?h:"",u=[];return t.config.type&&u.push("magic-ui-".concat(De(t.config.type))),t.config.layout&&u.push("magic-layout-".concat(t.config.layout)),f&&u.push(f),u.join(" ")}),setStatus:i,registerStatus:c}};function Zs(t=""){let r,e,n;return typeof t=="string"?r=t:{componentType:r,app:e}=t,(!r||r==="")&&(r="container"),e||(e=VueDemi.inject("app")),n=e==null?void 0:e.resolveComponent(r),!n&&!r.startsWith("magic-ui-")&&(r="magic-ui-".concat(De(r)),n=e==null?void 0:e.resolveComponent(r)),n!=null?n:r}const Qs=(t,r)=>{const e=t.__vccOpts||t;for(const[n,a]of r)e[n]=a;return e};export{Qs as _,Xs as a,Gs as b,Js as c,Ks as r,Zs as u};
//# sourceMappingURL=plugin-vueexport-helper-CYignUIG.js.map