!function(){function t(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}System.register([],(function(e,n){"use strict";return{execute:function(){const i=function(t,e,n){return t()};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,s={exports:{}},o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var u=Number.isNaN||function(t){return t!=t};function c(){c.init.call(this)}s.exports=c,s.exports.once=function(t,e){return new Promise((function(n,i){function r(n){t.removeListener(e,s),i(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}$(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&$(t,"error",e,n)}(t,r,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var f=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?c.defaultMaxListeners:t._maxListeners}function d(t,e,n,i){var r,s,o,a;if(h(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=l(t))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function v(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=p.bind(i);return r.listener=n,i.wrapFn=r,r}function g(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var u=r[t];if(void 0===u)return!1;if("function"==typeof u)a(u,this,e);else{var c=u.length,f=y(u,c);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},c.prototype.listeners=function(t){return g(this,t,!0)},c.prototype.rawListeners=function(t){return g(this,t,!1)},c.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},c.prototype.listenerCount=m,c.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};class w{constructor(e=globalThis.navigator.userAgent,n={}){t(this,"isIos",!1),t(this,"isIphone",!1),t(this,"isIpad",!1),t(this,"isAndroid",!1),t(this,"isAndroidPad",!1),t(this,"isMac",!1),t(this,"isWin",!1),t(this,"isMqq",!1),t(this,"isWechat",!1),t(this,"isWeb",!1),this.isIphone=e.indexOf("iPhone")>=0,this.isIpad=/(iPad).*OS\s([\d_]+)/.test(e),this.isIos=this.isIphone||this.isIpad,this.isAndroid=e.indexOf("Android")>=0,this.isAndroidPad=this.isAndroid&&e.indexOf("Mobile")<0,this.isMac=e.indexOf("Macintosh")>=0,this.isWin=e.indexOf("Windows")>=0,this.isMqq=/QQ\/([\d.]+)/.test(e),this.isWechat=e.indexOf("MicroMessenger")>=0&&e.indexOf("wxwork")<0,this.isWeb=!this.isIos&&!this.isAndroid&&!/(WebOS|BlackBerry)/.test(e),Object.entries(n).forEach((([t,e])=>{this[t]=e}))}}const M="magic:common:events:",b="magic:common:actions:",O="show",L="hide",E="scrollIntoView",S="scrollToTop",_=[{label:"点击",value:"magic:common:events:click"}],x=(t,e)=>{const n=`${t}:${e}`;return t.startsWith(M)?n:`magic:common:events:${n}`},C=(t,e)=>{var n;if(!t)return!1;if(!t.id)return C(t.parentElement,e);const i=null===(n=e.page)||void 0===n?void 0:n.getNode(t.id);return i||!1},D=(t,e,n)=>{const i=C(n.target,t);if(i){const{instance:n,data:r}=i;t.emit(x(e,r.id),n)}};class T{constructor(){t(this,"data",{})}set(t,e){this.data[t]=e}get(t){return this.data[t]}}class I extends s.exports.EventEmitter{constructor(e){super(),t(this,"data",void 0),t(this,"style",void 0),t(this,"events",void 0),t(this,"instance",void 0),t(this,"page",void 0),t(this,"parent",void 0),t(this,"app",void 0),t(this,"store",new T),this.page=e.page,this.parent=e.parent,this.app=e.app;const{events:n}=e.config;this.data=e.config,this.events=n,this.listenLifeSafe(),this.once("destroy",(()=>{this.instance=null,"function"==typeof this.data.destroy&&this.data.destroy(this),this.listenLifeSafe()}))}listenLifeSafe(){this.once("created",(t=>{this.instance=t,"function"==typeof this.data.created&&this.data.created(this)})),this.once("mounted",(t=>{this.instance=t;const e=this.app.eventQueueMap[t.config.id]||[];for(let n=e.shift();n;n=e.shift())this.app.eventHandler(n.eventConfig,n.fromCpt,n.args);"function"==typeof this.data.mounted&&this.data.mounted(this)}))}}class j extends I{constructor(e){super(e),t(this,"nodes",new Map),this.setNode(e.config.id,this),this.initNode(e.config,this)}initNode(t,e){var n;const i=new I({config:t,parent:e,page:this,app:this.app});this.setNode(t.id,i),null===(n=t.items)||void 0===n||n.forEach((t=>{this.initNode(t,i)}))}getNode(t){return this.nodes.get(t)}setNode(t,e){this.nodes.set(t,e)}deleteNode(t){this.nodes.delete(t)}}class A extends s.exports.EventEmitter{constructor(e){if(super(),t(this,"env",void 0),t(this,"pages",new Map),t(this,"page",void 0),t(this,"platform","mobile"),t(this,"jsEngine","browser"),t(this,"designWidth",375),t(this,"components",new Map),t(this,"eventQueueMap",{}),this.env=new w(e.ua),e.platform&&(this.platform=e.platform),e.jsEngine&&(this.jsEngine=e.jsEngine),e.designWidth&&(this.designWidth=e.designWidth),"mobile"===this.platform||"editor"===this.platform){const t=()=>{let{width:t}=document.documentElement.getBoundingClientRect();t=Math.min(800,t);const e=t/(this.designWidth/100);document.documentElement.style.fontSize=`${e}px`};t(),document.body.style.fontSize="14px",globalThis.addEventListener("resize",t)}var n;e.transformStyle&&(this.transformStyle=e.transformStyle),e.config&&this.setConfig(e.config,e.curPage),n=this,window.document.body.addEventListener("click",(t=>{D(n,"click",t)})),window.document.body.addEventListener("click",(t=>{D(n,"click:capture",t)}),!0)}transformStyle(t){if(!t)return{};let e={};const n={};e="string"==typeof t?(t=>{if("string"!=typeof t)return t;const e={};return t.split(";").forEach((t=>{if(!t)return;const n=t.split(":");let i=n.shift(),r=n.join(":");i&&(i=i.replace(/^\s*/,"").replace(/\s*$/,""),r=r.replace(/^\s*/,"").replace(/\s*$/,""),i=i.split("-").map(((t,e)=>e>0?`${t[0].toUpperCase()}${t.substr(1)}`:t)).join(""),e[i]=r)})),e})(t):{...t};const i=["zIndex","opacity","fontWeight"];return Object.entries(e).forEach((([t,e])=>{"backgroundImage"===t?e&&(n[t]=(t=>!t||/^url/.test(t)||/^linear-gradient/.test(t)?t:`url(${t})`)(e)):"transform"===t&&"string"!=typeof e?n[t]=Object.entries(e).map((([t,e])=>{let n=0;return"scale"===t&&(n=1),"rotate"===t&&(t=>/^(-?\d+)(\.\d+)?$/.test(t))(e)&&(e=`${e}deg`),`${t}(${e||n})`})).join(" "):!i.includes(t)&&e&&/^[-]?[0-9]*[.]?[0-9]*$/.test(e)?n[t]=e/100+"rem":n[t]=e})),n}setConfig(t,e){var n,i,r;this.pages=new Map,null===(n=t.items)||void 0===n||n.forEach((t=>{this.pages.set(t.id,new j({config:t,app:this}))})),this.setPage(e||(null===(i=this.page)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.id))}setPage(t){let e;t&&(e=this.pages.get(t)),e||(e=this.pages.get(this.pages.keys().next().value)),this.page=e,"magic"!==this.platform&&this.bindEvents()}registerComponent(t,e){this.components.set(t,e)}unregisterComponent(t){this.components.delete(t)}resolveComponent(t){return this.components.get(t)}bindEvents(){if(this.page){this.removeAllListeners();for(const[,e]of this.page.nodes){var t;null===(t=e.events)||void 0===t||t.forEach((t=>this.bindEvent(t,`${e.data.id}`)))}}}bindEvent(t,e){let{name:n}=t;_.findIndex((t=>t.value===n))>-1&&(n=x(n,e)),this.on(n,((e,...n)=>{this.eventHandler(t,e,n)}))}eventHandler(t,e,n){if(!this.page)throw new Error("当前没有页面");const{method:i,to:r}=t,s=this.page.getNode(r);if(!s)throw`ID为${r}的组件不存在`;if((t=>t.startsWith(b))(i))return((t,e)=>{const{instance:n}=e;switch(t.replace(b,"")){case O:n.show();break;case L:n.hide();break;case E:n.$el.scrollIntoView({behavior:"smooth"});break;case S:window.scrollTo({top:0,behavior:"smooth"})}})(i,s);s.instance?"function"==typeof s.instance[i]&&s.instance[i](e,...n):this.addEventToMap({eventConfig:t,fromCpt:e,args:n})}destroy(){this.removeAllListeners(),this.pages.clear()}addEventToMap(t){this.eventQueueMap[t.eventConfig.to]?this.eventQueueMap[t.eventConfig.to].push(t):this.eventQueueMap[t.eventConfig.to]=[t]}}var W={exports:{}};!function(t,e){t.exports=function(){var t=1e3,e=6e4,n=36e5,i="millisecond",r="second",s="minute",o="hour",a="day",u="week",c="month",f="quarter",h="year",l="date",d="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|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,g={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("_")},m=function(t,e,n){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(n)+t},y={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),i=Math.floor(n/60),r=n%60;return(e<=0?"+":"-")+m(i,2,"0")+":"+m(r,2,"0")},m:function t(e,n){if(e.date()1)return t(o[0])}else{var a=e.name;w[a]=e,r=a}return!i&&r&&($=r),r||!i&&$},O=function(t,e){if(M(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new E(n)},L=y;L.l=b,L.i=M,L.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var E=function(){function g(t){this.$L=b(t.locale,null,!0),this.parse(t)}var m=g.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(L.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match(p);if(i){var r=i[2]-1||0,s=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)):new Date(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return L},m.isValid=function(){return!(this.$d.toString()===d)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)t.replace(/\B([A-Z])/g,"-$1").toLowerCase()));const H=(t,e=[])=>{const n=[],i=function(t,e){if(!Array.isArray(e))return null;for(let r=0,s=e.length;r{var t,i,r,s;return(null===(t=e.value)||void 0===t||null===(i=t.items)||void 0===i?void 0:i.find((t=>t.id===n.value)))||(null===(r=e.value)||void 0===r||null===(s=r.items)||void 0===s?void 0:s[0])})),s=new A({config:e.value,platform:"editor"});return Vue.provide("app",s),Vue.watch(r,(async()=>{await Vue.nextTick();const t=document.querySelector(".magic-ui-page");t&&window.magic.onPageElUpdate(t)})),null===(t=window.magic)||void 0===t||t.onRuntimeReady({getApp:()=>s,updateRootConfig(t){console.log("update config",t),e.value=t,null==s||s.setConfig(t,n.value)},updatePageId(t){console.log("update page id",t),n.value=t,null==s||s.setPage(t)},select(t){console.log("select config",t),i.value=t;const e=document.getElementById(`${t}`);return e||Vue.nextTick().then((()=>document.getElementById(`${t}`)))},add({config:t,parentId:n}){var r;if(console.log("add config",t),!e.value)throw new Error("error");if(!i.value)throw new Error("error");const s=H(n,[e.value]).pop();if(!s)throw new Error("未找到父节点");null===(r=s.items)||void 0===r||r.push(t)},update({config:t,parentId:n}){var i;if(console.log("update config",t),!e.value)throw new Error("error");const r=H(t.id,[e.value]).pop(),s=H(n,[e.value]).pop();if(!r)throw new Error("未找到目标节点");if(!s)throw new Error("未找到父节点");const o=null===(i=s.items)||void 0===i?void 0:i.findIndex((t=>t.id===r.id));s.items.splice(o,1,Vue.reactive(t))},remove({id:t,parentId:n}){var i;if(!e.value)throw new Error("error");const r=H(t,[e.value]).pop();if(!r)throw new Error("未找到目标元素");const s=H(n,[e.value]).pop();if(!s)throw new Error("未找到父元素");const o=null===(i=s.items)||void 0===i?void 0:i.findIndex((t=>t.id===r.id));s.items.splice(o,1)}}),{pageConfig:r}}});const V=e("_",((t,e)=>{const n=t.__vccOpts||t;for(const[i,r]of e)n[i]=r;return n}))(P,[["render",function(t,e,n,i,r,s){const o=Vue.resolveComponent("magic-ui-page");return t.pageConfig?(Vue.openBlock(),Vue.createBlock(o,{key:0,config:t.pageConfig},null,8,["config"])):Vue.createCommentVNode("v-if",!0)}],["__file","/data/magic/tmagic-editor/runtime/vue3/playground/App.vue"]]);Promise.all([i((()=>n.import("./comp-entry-legacy.e6d0a969.js"))),i((()=>n.import("./plugin-entry-legacy.7d9da6d6.js")))]).then((([t,e])=>{const n=Vue.createApp(V);Object.values(t.default).forEach((t=>{n.component(t.name,t)})),Object.values(e.default).forEach((t=>{n.use(t)})),n.mount("#app")}))}}}))}(); //# sourceMappingURL=index-legacy.97f27bc4.js.map