2022-08-18 19:47:49 +08:00

3 lines
25 KiB
JavaScript

var Oe=Object.defineProperty;var Me=(t,n,e)=>n in t?Oe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var $=(t,n,e)=>(Me(t,typeof n!="symbol"?n+"":n,e),e);function Ge(){import("data:text/javascript,")}const be=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function e(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=e(i);fetch(i.href,o)}};be();const Se="modulepreload",Ce=function(t){return"/static/vue3/runtime/playground/"+t},re={},se=function(n,e,r){return!e||e.length===0?n():Promise.all(e.map(i=>{if(i=Ce(i),i in re)return;re[i]=!0;const o=i.endsWith(".css"),s=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${s}`))return;const a=document.createElement("link");if(a.rel=o?"stylesheet":Se,o||(a.as="script",a.crossOrigin=""),a.href=i,document.head.appendChild(a),o)return new Promise((l,v)=>{a.addEventListener("load",l),a.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>n())};var ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},G={exports:{}},F=typeof Reflect=="object"?Reflect:null,oe=F&&typeof F.apply=="function"?F.apply:function(n,e,r){return Function.prototype.apply.call(n,e,r)},X;F&&typeof F.ownKeys=="function"?X=F.ownKeys:Object.getOwnPropertySymbols?X=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:X=function(n){return Object.getOwnPropertyNames(n)};function xe(t){console&&console.warn&&console.warn(t)}var le=Number.isNaN||function(n){return n!==n};function w(){w.init.call(this)}G.exports=w;G.exports.once=Ie;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var ue=10;function ee(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return ue},set:function(t){if(typeof t!="number"||t<0||le(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ue=t}});w.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};w.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||le(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function de(t){return t._maxListeners===void 0?w.defaultMaxListeners:t._maxListeners}w.prototype.getMaxListeners=function(){return de(this)};w.prototype.emit=function(n){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=n==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[n];if(l===void 0)return!1;if(typeof l=="function")oe(l,this,e);else for(var v=l.length,b=ve(l,v),r=0;r<v;++r)oe(b[r],this,e);return!0};function he(t,n,e,r){var i,o,s;if(ee(e),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",n,e.listener?e.listener:e),o=t._events),s=o[n]),s===void 0)s=o[n]=e,++t._eventsCount;else if(typeof s=="function"?s=o[n]=r?[e,s]:[s,e]:r?s.unshift(e):s.push(e),i=de(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=n,a.count=s.length,xe(a)}return t}w.prototype.addListener=function(n,e){return he(this,n,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(n,e){return he(this,n,e,!0)};function De(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function pe(t,n,e){var r={fired:!1,wrapFn:void 0,target:t,type:n,listener:e},i=De.bind(r);return i.listener=e,r.wrapFn=i,i}w.prototype.once=function(n,e){return ee(e),this.on(n,pe(this,n,e)),this};w.prototype.prependOnceListener=function(n,e){return ee(e),this.prependListener(n,pe(this,n,e)),this};w.prototype.removeListener=function(n,e){var r,i,o,s,a;if(ee(e),i=this._events,i===void 0)return this;if(r=i[n],r===void 0)return this;if(r===e||r.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,r.listener||e));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===e||r[s].listener===e){a=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():Te(r,o),r.length===1&&(i[n]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",n,a||e)}return this};w.prototype.off=w.prototype.removeListener;w.prototype.removeAllListeners=function(n){var e,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[n]),this;if(arguments.length===0){var o=Object.keys(r),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=r[n],typeof e=="function")this.removeListener(n,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(n,e[i]);return this};function me(t,n,e){var r=t._events;if(r===void 0)return[];var i=r[n];return i===void 0?[]:typeof i=="function"?e?[i.listener||i]:[i]:e?Ae(i):ve(i,i.length)}w.prototype.listeners=function(n){return me(this,n,!0)};w.prototype.rawListeners=function(n){return me(this,n,!1)};w.listenerCount=function(t,n){return typeof t.listenerCount=="function"?t.listenerCount(n):ge.call(t,n)};w.prototype.listenerCount=ge;function ge(t){var n=this._events;if(n!==void 0){var e=n[t];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?X(this._events):[]};function ve(t,n){for(var e=new Array(n),r=0;r<n;++r)e[r]=t[r];return e}function Te(t,n){for(;n+1<t.length;n++)t[n]=t[n+1];t.pop()}function Ae(t){for(var n=new Array(t.length),e=0;e<n.length;++e)n[e]=t[e].listener||t[e];return n}function Ie(t,n){return new Promise(function(e,r){function i(s){t.removeListener(n,o),r(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),e([].slice.call(arguments))}$e(t,n,o,{once:!0}),n!=="error"&&Ne(t,i,{once:!0})})}function Ne(t,n,e){typeof t.on=="function"&&$e(t,"error",n,e)}function $e(t,n,e,r){if(typeof t.on=="function")r.once?t.once(n,e):t.on(n,e);else if(typeof t.addEventListener=="function")t.addEventListener(n,function i(o){r.once&&t.removeEventListener(n,i),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class je{constructor(n=globalThis.navigator.userAgent,e={}){$(this,"isIos",!1);$(this,"isIphone",!1);$(this,"isIpad",!1);$(this,"isAndroid",!1);$(this,"isAndroidPad",!1);$(this,"isMac",!1);$(this,"isWin",!1);$(this,"isMqq",!1);$(this,"isWechat",!1);$(this,"isWeb",!1);this.isIphone=n.indexOf("iPhone")>=0,this.isIpad=/(iPad).*OS\s([\d_]+)/.test(n),this.isIos=this.isIphone||this.isIpad,this.isAndroid=n.indexOf("Android")>=0,this.isAndroidPad=this.isAndroid&&n.indexOf("Mobile")<0,this.isMac=n.indexOf("Macintosh")>=0,this.isWin=n.indexOf("Windows")>=0,this.isMqq=/QQ\/([\d.]+)/.test(n),this.isWechat=n.indexOf("MicroMessenger")>=0&&n.indexOf("wxwork")<0,this.isWeb=!this.isIos&&!this.isAndroid&&!/(WebOS|BlackBerry)/.test(n),Object.entries(e).forEach(([r,i])=>{this[r]=i})}}const ne="magic:common:events:",ye="magic:common:actions:",K={SHOW:"show",HIDE:"hide",SCROLL_TO_VIEW:"scrollIntoView",SCROLL_TO_TOP:"scrollToTop"},Pe=[{label:"\u70B9\u51FB",value:`${ne}click`}],we=(t,n)=>{const e=`${t}:${n}`;return t.startsWith(ne)?e:`${ne}${e}`},We=t=>t.startsWith(ye),Ee=(t,n)=>{var r;if(!t)return!1;if(!t.id)return Ee(t.parentElement,n);const e=(r=n.page)==null?void 0:r.getNode(t.id);return e||!1},ae=(t,n,e)=>{const r=Ee(e.target,t);if(r){const{instance:i,data:o}=r;t.emit(we(n,o.id),i)}},He=t=>{window.document.body.addEventListener("click",n=>{ae(t,"click",n)}),window.document.body.addEventListener("click",n=>{ae(t,"click:capture",n)},!0)},Re=(t,n)=>{const{instance:e}=n;switch(t.replace(ye,"")){case K.SHOW:e.show();break;case K.HIDE:e.hide();break;case K.SCROLL_TO_VIEW:e.$el.scrollIntoView({behavior:"smooth"});break;case K.SCROLL_TO_TOP:window.scrollTo({top:0,behavior:"smooth"});break}};class ke{constructor(){$(this,"data",{})}set(n,e){this.data[n]=e}get(n){return this.data[n]}}class fe extends G.exports.EventEmitter{constructor(e){super();$(this,"data");$(this,"style");$(this,"events");$(this,"instance");$(this,"page");$(this,"parent");$(this,"app");$(this,"store",new ke);this.page=e.page,this.parent=e.parent,this.app=e.app;const{events:r}=e.config;this.data=e.config,this.events=r,this.listenLifeSafe(),this.once("destroy",()=>{this.instance=null,typeof this.data.destroy=="function"&&this.data.destroy(this),this.listenLifeSafe()})}listenLifeSafe(){this.once("created",e=>{this.instance=e,typeof this.data.created=="function"&&this.data.created(this)}),this.once("mounted",e=>{this.instance=e;const r=this.app.eventQueueMap[e.config.id]||[];for(let i=r.shift();i;i=r.shift())this.app.eventHandler(i.eventConfig,i.fromCpt,i.args);typeof this.data.mounted=="function"&&this.data.mounted(this)})}}class Ve extends fe{constructor(e){super(e);$(this,"nodes",new Map);this.setNode(e.config.id,this),this.initNode(e.config,this)}initNode(e,r){var o;const i=new fe({config:e,parent:r,page:this,app:this.app});this.setNode(e.id,i),(o=e.items)==null||o.forEach(s=>{this.initNode(s,i)})}getNode(e){return this.nodes.get(e)}setNode(e,r){this.nodes.set(e,r)}deleteNode(e){this.nodes.delete(e)}}const Ue=t=>{if(typeof t!="string")return t;const n={};return t.split(";").forEach(e=>{if(!e)return;const r=e.split(":");let i=r.shift(),o=r.join(":");!i||(i=i.replace(/^\s*/,"").replace(/\s*$/,""),o=o.replace(/^\s*/,"").replace(/\s*$/,""),i=i.split("-").map((s,a)=>a>0?`${s[0].toUpperCase()}${s.substr(1)}`:s).join(""),n[i]=o)}),n},Ye=t=>t&&!/^url/.test(t)&&!/^linear-gradient/.test(t)?`url(${t})`:t,Fe=t=>/^(-?\d+)(\.\d+)?$/.test(t);class Be extends G.exports.EventEmitter{constructor(e){super();$(this,"env");$(this,"pages",new Map);$(this,"page");$(this,"platform","mobile");$(this,"jsEngine","browser");$(this,"designWidth",375);$(this,"components",new Map);$(this,"eventQueueMap",{});if(this.env=new je(e.ua),e.platform&&(this.platform=e.platform),e.jsEngine&&(this.jsEngine=e.jsEngine),e.designWidth&&(this.designWidth=e.designWidth),this.platform==="mobile"||this.platform==="editor"){const r=()=>{let{width:i}=document.documentElement.getBoundingClientRect();i=Math.min(800,i);const o=i/(this.designWidth/100);document.documentElement.style.fontSize=`${o}px`};r(),document.body.style.fontSize="14px",globalThis.addEventListener("resize",r)}e.transformStyle&&(this.transformStyle=e.transformStyle),e.config&&this.setConfig(e.config,e.curPage),He(this)}transformStyle(e){if(!e)return{};let r={};const i={};typeof e=="string"?r=Ue(e):r={...e};const o=["zIndex","opacity","fontWeight"];return Object.entries(r).forEach(([s,a])=>{s==="backgroundImage"?a&&(i[s]=Ye(a)):s==="transform"&&typeof a!="string"?i[s]=Object.entries(a).map(([l,v])=>{let b=0;return l==="scale"&&(b=1),l==="rotate"&&Fe(v)&&(v=`${v}deg`),`${l}(${v||b})`}).join(" "):!o.includes(s)&&a&&/^[-]?[0-9]*[.]?[0-9]*$/.test(a)?i[s]=`${a/100}rem`:i[s]=a}),i}setConfig(e,r){var i,o,s;this.pages=new Map,(i=e.items)==null||i.forEach(a=>{this.pages.set(a.id,new Ve({config:a,app:this}))}),this.setPage(r||((s=(o=this.page)==null?void 0:o.data)==null?void 0:s.id))}setPage(e){let r;e&&(r=this.pages.get(e)),r||(r=this.pages.get(this.pages.keys().next().value)),this.page=r,this.platform!=="magic"&&this.bindEvents()}registerComponent(e,r){this.components.set(e,r)}unregisterComponent(e){this.components.delete(e)}resolveComponent(e){return this.components.get(e)}bindEvents(){var e;if(!!this.page){this.removeAllListeners();for(const[,r]of this.page.nodes)(e=r.events)==null||e.forEach(i=>this.bindEvent(i,`${r.data.id}`))}}bindEvent(e,r){let{name:i}=e;Pe.findIndex(o=>o.value===i)>-1&&(i=we(i,r)),this.on(i,(o,...s)=>{this.eventHandler(e,o,s)})}eventHandler(e,r,i){if(!this.page)throw new Error("\u5F53\u524D\u6CA1\u6709\u9875\u9762");const{method:o,to:s}=e,a=this.page.getNode(s);if(!a)throw`ID\u4E3A${s}\u7684\u7EC4\u4EF6\u4E0D\u5B58\u5728`;if(We(o))return Re(o,a);a.instance?typeof a.instance[o]=="function"&&a.instance[o](r,...i):this.addEventToMap({eventConfig:e,fromCpt:r,args:i})}destroy(){this.removeAllListeners(),this.pages.clear()}addEventToMap(e){this.eventQueueMap[e.eventConfig.to]?this.eventQueueMap[e.eventConfig.to].push(e):this.eventQueueMap[e.eventConfig.to]=[e]}}var _e={exports:{}};(function(t,n){(function(e,r){t.exports=r()})(ce,function(){var e=1e3,r=6e4,i=36e5,o="millisecond",s="second",a="minute",l="hour",v="day",b="week",M="month",P="quarter",T="year",I="date",d="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,R=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,k={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},D=function(g,c,u){var h=String(g);return!h||h.length>=c?g:""+Array(c+1-h.length).join(u)+g},q={s:D,z:function(g){var c=-g.utcOffset(),u=Math.abs(c),h=Math.floor(u/60),f=u%60;return(c<=0?"+":"-")+D(h,2,"0")+":"+D(f,2,"0")},m:function g(c,u){if(c.date()<u.date())return-g(u,c);var h=12*(u.year()-c.year())+(u.month()-c.month()),f=c.clone().add(h,M),m=u-f<0,p=c.clone().add(h+(m?-1:1),M);return+(-(h+(u-f)/(m?f-p:p-f))||0)},a:function(g){return g<0?Math.ceil(g)||0:Math.floor(g)},p:function(g){return{M,y:T,w:b,d:v,D:I,h:l,m:a,s,ms:o,Q:P}[g]||String(g||"").toLowerCase().replace(/s$/,"")},u:function(g){return g===void 0}},N="en",A={};A[N]=k;var V=function(g){return g instanceof Z},U=function g(c,u,h){var f;if(!c)return N;if(typeof c=="string"){var m=c.toLowerCase();A[m]&&(f=m),u&&(A[m]=u,f=m);var p=c.split("-");if(!f&&p.length>1)return g(p[0])}else{var y=c.name;A[y]=c,f=y}return!h&&f&&(N=f),f||!h&&N},_=function(g,c){if(V(g))return g.clone();var u=typeof c=="object"?c:{};return u.date=g,u.args=arguments,new Z(u)},E=q;E.l=U,E.i=V,E.w=function(g,c){return _(g,{locale:c.$L,utc:c.$u,x:c.$x,$offset:c.$offset})};var Z=function(){function g(u){this.$L=U(u.locale,null,!0),this.parse(u)}var c=g.prototype;return c.parse=function(u){this.$d=function(h){var f=h.date,m=h.utc;if(f===null)return new Date(NaN);if(E.u(f))return new Date;if(f instanceof Date)return new Date(f);if(typeof f=="string"&&!/Z$/i.test(f)){var p=f.match(x);if(p){var y=p[2]-1||0,O=(p[7]||"0").substring(0,3);return m?new Date(Date.UTC(p[1],y,p[3]||1,p[4]||0,p[5]||0,p[6]||0,O)):new Date(p[1],y,p[3]||1,p[4]||0,p[5]||0,p[6]||0,O)}}return new Date(f)}(u),this.$x=u.x||{},this.init()},c.init=function(){var u=this.$d;this.$y=u.getFullYear(),this.$M=u.getMonth(),this.$D=u.getDate(),this.$W=u.getDay(),this.$H=u.getHours(),this.$m=u.getMinutes(),this.$s=u.getSeconds(),this.$ms=u.getMilliseconds()},c.$utils=function(){return E},c.isValid=function(){return this.$d.toString()!==d},c.isSame=function(u,h){var f=_(u);return this.startOf(h)<=f&&f<=this.endOf(h)},c.isAfter=function(u,h){return _(u)<this.startOf(h)},c.isBefore=function(u,h){return this.endOf(h)<_(u)},c.$g=function(u,h,f){return E.u(u)?this[h]:this.set(f,u)},c.unix=function(){return Math.floor(this.valueOf()/1e3)},c.valueOf=function(){return this.$d.getTime()},c.startOf=function(u,h){var f=this,m=!!E.u(h)||h,p=E.p(u),y=function(Y,C){var H=E.w(f.$u?Date.UTC(f.$y,C,Y):new Date(f.$y,C,Y),f);return m?H:H.endOf(v)},O=function(Y,C){return E.w(f.toDate()[Y].apply(f.toDate("s"),(m?[0,0,0,0]:[23,59,59,999]).slice(C)),f)},L=this.$W,S=this.$M,W=this.$D,j="set"+(this.$u?"UTC":"");switch(p){case T:return m?y(1,0):y(31,11);case M:return m?y(1,S):y(0,S+1);case b:var B=this.$locale().weekStart||0,z=(L<B?L+7:L)-B;return y(m?W-z:W+(6-z),S);case v:case I:return O(j+"Hours",0);case l:return O(j+"Minutes",1);case a:return O(j+"Seconds",2);case s:return O(j+"Milliseconds",3);default:return this.clone()}},c.endOf=function(u){return this.startOf(u,!1)},c.$set=function(u,h){var f,m=E.p(u),p="set"+(this.$u?"UTC":""),y=(f={},f[v]=p+"Date",f[I]=p+"Date",f[M]=p+"Month",f[T]=p+"FullYear",f[l]=p+"Hours",f[a]=p+"Minutes",f[s]=p+"Seconds",f[o]=p+"Milliseconds",f)[m],O=m===v?this.$D+(h-this.$W):h;if(m===M||m===T){var L=this.clone().set(I,1);L.$d[y](O),L.init(),this.$d=L.set(I,Math.min(this.$D,L.daysInMonth())).$d}else y&&this.$d[y](O);return this.init(),this},c.set=function(u,h){return this.clone().$set(u,h)},c.get=function(u){return this[E.p(u)]()},c.add=function(u,h){var f,m=this;u=Number(u);var p=E.p(h),y=function(S){var W=_(m);return E.w(W.date(W.date()+Math.round(S*u)),m)};if(p===M)return this.set(M,this.$M+u);if(p===T)return this.set(T,this.$y+u);if(p===v)return y(1);if(p===b)return y(7);var O=(f={},f[a]=r,f[l]=i,f[s]=e,f)[p]||1,L=this.$d.getTime()+u*O;return E.w(L,this)},c.subtract=function(u,h){return this.add(-1*u,h)},c.format=function(u){var h=this,f=this.$locale();if(!this.isValid())return f.invalidDate||d;var m=u||"YYYY-MM-DDTHH:mm:ssZ",p=E.z(this),y=this.$H,O=this.$m,L=this.$M,S=f.weekdays,W=f.months,j=function(C,H,te,J){return C&&(C[H]||C(h,m))||te[H].slice(0,J)},B=function(C){return E.s(y%12||12,C,"0")},z=f.meridiem||function(C,H,te){var J=C<12?"AM":"PM";return te?J.toLowerCase():J},Y={YY:String(this.$y).slice(-2),YYYY:this.$y,M:L+1,MM:E.s(L+1,2,"0"),MMM:j(f.monthsShort,L,W,3),MMMM:j(W,L),D:this.$D,DD:E.s(this.$D,2,"0"),d:String(this.$W),dd:j(f.weekdaysMin,this.$W,S,2),ddd:j(f.weekdaysShort,this.$W,S,3),dddd:S[this.$W],H:String(y),HH:E.s(y,2,"0"),h:B(1),hh:B(2),a:z(y,O,!0),A:z(y,O,!1),m:String(O),mm:E.s(O,2,"0"),s:String(this.$s),ss:E.s(this.$s,2,"0"),SSS:E.s(this.$ms,3,"0"),Z:p};return m.replace(R,function(C,H){return H||Y[C]||p.replace(":","")})},c.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},c.diff=function(u,h,f){var m,p=E.p(h),y=_(u),O=(y.utcOffset()-this.utcOffset())*r,L=this-y,S=E.m(this,y);return S=(m={},m[T]=S/12,m[M]=S,m[P]=S/3,m[b]=(L-O)/6048e5,m[v]=(L-O)/864e5,m[l]=L/i,m[a]=L/r,m[s]=L/e,m)[p]||L,f?S:E.a(S)},c.daysInMonth=function(){return this.endOf(M).$D},c.$locale=function(){return A[this.$L]},c.locale=function(u,h){if(!u)return this.$L;var f=this.clone(),m=U(u,h,!0);return m&&(f.$L=m),f},c.clone=function(){return E.w(this.$d,this)},c.toDate=function(){return new Date(this.valueOf())},c.toJSON=function(){return this.isValid()?this.toISOString():null},c.toISOString=function(){return this.$d.toISOString()},c.toString=function(){return this.$d.toUTCString()},g}(),ie=Z.prototype;return _.prototype=ie,[["$ms",o],["$s",s],["$m",a],["$H",l],["$W",v],["$M",M],["$y",T],["$D",I]].forEach(function(g){ie[g[1]]=function(c){return this.$g(c,g[0],g[1])}}),_.extend=function(g,c){return g.$i||(g(c,Z,_),g.$i=!0),_},_.locale=U,_.isDayjs=V,_.unix=function(g){return _(1e3*g)},_.en=A[N],_.Ls=A,_.p={},_})})(_e);const ze=_e.exports;var Le={exports:{}};(function(t,n){(function(e,r){t.exports=r()})(ce,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,s,a){var l=s.prototype;a.utc=function(d){var x={date:d,utc:!0,args:arguments};return new s(x)},l.utc=function(d){var x=a(this.toDate(),{locale:this.$L,utc:!0});return d?x.add(this.utcOffset(),e):x},l.local=function(){return a(this.toDate(),{locale:this.$L,utc:!1})};var v=l.parse;l.parse=function(d){d.utc&&(this.$u=!0),this.$utils().u(d.$offset)||(this.$offset=d.$offset),v.call(this,d)};var b=l.init;l.init=function(){if(this.$u){var d=this.$d;this.$y=d.getUTCFullYear(),this.$M=d.getUTCMonth(),this.$D=d.getUTCDate(),this.$W=d.getUTCDay(),this.$H=d.getUTCHours(),this.$m=d.getUTCMinutes(),this.$s=d.getUTCSeconds(),this.$ms=d.getUTCMilliseconds()}else b.call(this)};var M=l.utcOffset;l.utcOffset=function(d,x){var R=this.$utils().u;if(R(d))return this.$u?0:R(this.$offset)?M.call(this):this.$offset;if(typeof d=="string"&&(d=function(N){N===void 0&&(N="");var A=N.match(r);if(!A)return null;var V=(""+A[0]).match(i)||["-",0,0],U=V[0],_=60*+V[1]+ +V[2];return _===0?0:U==="+"?_:-_}(d),d===null))return this;var k=Math.abs(d)<=16?60*d:d,D=this;if(x)return D.$offset=k,D.$u=d===0,D;if(d!==0){var q=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(D=this.local().add(k+q,e)).$offset=k,D.$x.$localOffset=q}else D=this.utc();return D};var P=l.format;l.format=function(d){var x=d||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return P.call(this,x)},l.valueOf=function(){var d=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*d},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var T=l.toDate;l.toDate=function(d){return d==="s"&&this.$offset?a(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():T.call(this)};var I=l.diff;l.diff=function(d,x,R){if(d&&this.$u===d.$u)return I.call(this,d,x,R);var k=this.local(),D=a(d).local();return I.call(k,D,x,R)}}})})(Le);const Qe=Le.exports;ze.extend(Qe);const et=(t="")=>t.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Q=(t,n=[])=>{const e=[],r=function(i,o){if(!Array.isArray(o))return null;for(let s=0,a=o.length;s<a;s++){const l=o[s];if(e.push(l),`${l.id}`==`${i}`)return l;if(l.items){const v=r(i,l.items);if(v)return v}e.pop()}return null};return r(t,n),e},qe=Vue.defineComponent({setup(){var o;const t=Vue.ref(),n=Vue.ref(),e=Vue.ref(),r=Vue.computed(()=>{var s,a,l,v;return((a=(s=t.value)==null?void 0:s.items)==null?void 0:a.find(b=>b.id===n.value))||((v=(l=t.value)==null?void 0:l.items)==null?void 0:v[0])}),i=new Be({config:t.value,platform:"editor"});return Vue.provide("app",i),Vue.watch(r,async()=>{await Vue.nextTick();const s=document.querySelector(".magic-ui-page");s&&window.magic.onPageElUpdate(s)}),(o=window.magic)==null||o.onRuntimeReady({getApp(){return i},updateRootConfig(s){console.log("update config",s),t.value=s,i==null||i.setConfig(s,n.value)},updatePageId(s){console.log("update page id",s),n.value=s,i==null||i.setPage(s)},select(s){console.log("select config",s),e.value=s;const a=document.getElementById(`${s}`);return a||Vue.nextTick().then(()=>document.getElementById(`${s}`))},add({config:s,parentId:a}){var v;if(console.log("add config",s),!t.value)throw new Error("error");if(!e.value)throw new Error("error");const l=Q(a,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u7236\u8282\u70B9");(v=l.items)==null||v.push(s)},update({config:s,parentId:a}){var M;if(console.log("update config",s),!t.value)throw new Error("error");const l=Q(s.id,[t.value]).pop(),v=Q(a,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9");if(!v)throw new Error("\u672A\u627E\u5230\u7236\u8282\u70B9");const b=(M=v.items)==null?void 0:M.findIndex(P=>P.id===l.id);v.items.splice(b,1,Vue.reactive(s))},remove({id:s,parentId:a}){var M;if(!t.value)throw new Error("error");const l=Q(s,[t.value]).pop();if(!l)throw new Error("\u672A\u627E\u5230\u76EE\u6807\u5143\u7D20");const v=Q(a,[t.value]).pop();if(!v)throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");const b=(M=v.items)==null?void 0:M.findIndex(P=>P.id===l.id);v.items.splice(b,1)}}),{pageConfig:r}}}),Ze=(t,n)=>{const e=t.__vccOpts||t;for(const[r,i]of n)e[r]=i;return e};function Je(t,n,e,r,i,o){const s=Vue.resolveComponent("magic-ui-page");return t.pageConfig?(Vue.openBlock(),Vue.createBlock(s,{key:0,config:t.pageConfig},null,8,["config"])):Vue.createCommentVNode("v-if",!0)}const Ke=Ze(qe,[["render",Je],["__file","/data/magic/tmagic-editor/runtime/vue3/playground/App.vue"]]);Promise.all([se(()=>import("./comp-entry.13d1f45f.js"),[]),se(()=>import("./plugin-entry.b765d2c2.js"),[])]).then(([t,n])=>{const e=Vue.createApp(Ke);Object.values(t.default).forEach(r=>{e.component(r.name,r)}),Object.values(n.default).forEach(r=>{e.use(r)}),e.mount("#app")});export{Ze as _,Ge as __vite_legacy_guard,et as t};
//# sourceMappingURL=index.6f272ec3.js.map