var Pe=Object.defineProperty;var Q=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var X=(e,t,n)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||(t={}))Ae.call(t,n)&&X(e,n,t[n]);if(Q)for(var n of Q(t))je.call(t,n)&&X(e,n,t[n]);return e};const Ie=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 n(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=n(i);fetch(i.href,o)}};Ie();var Te=function(e){return Object.prototype.toString.call(e)};function G(e){return typeof e=="function"&&/native code/.test(e.toString())}var We=typeof Symbol!="undefined"&&G(Symbol)&&typeof Reflect!="undefined"&&G(Reflect.ownKeys),L=function(e){return e};function p(e,t,n){var r=n.get,i=n.set;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:r||L,set:i||L})}function oe(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}function O(e,t){return Object.hasOwnProperty.call(e,t)}function M(e){return Array.isArray(e)}function fe(e){return e!==null&&typeof e=="object"}function y(e){return Te(e)==="[object Object]"}function _(e){return typeof e=="function"}var B=void 0;try{var w=require("vue");w&&J(w)?B=w:w&&"default"in w&&J(w.default)&&(B=w.default)}catch{}var V=null,T=null,ue="__composition_api_installed__";function J(e){return e&&_(e)&&e.name==="Vue"}function ke(e){return O(e,ue)}function ae(){return V}function Fe(){var e=V||B;return e}function De(e){V=e,Object.defineProperty(e,ue,{configurable:!0,writable:!0,value:!0})}function Y(e){T=e}function Ke(){return T}function Be(){return T?H(T):null}var F=new WeakMap;function H(e){if(F.has(e))return F.get(e);var t={proxy:e,update:e.$forceUpdate,uid:e._uid,emit:e.$emit.bind(e),parent:null,root:null},n=["data","props","attrs","refs","vnode","slots"];return n.forEach(function(r){p(t,r,{get:function(){return e["$"+r]}})}),p(t,"isMounted",{get:function(){return e._isMounted}}),p(t,"isUnmounted",{get:function(){return e._isDestroyed}}),p(t,"isDeactivated",{get:function(){return e._inactive}}),p(t,"emitted",{get:function(){return e._events}}),F.set(e,t),e.$parent&&(t.parent=H(e.$parent)),e.$root&&(t.root=H(e.$root)),t}function He(e,t){t===void 0&&(t={});var n=e.config.silent;e.config.silent=!0;var r=new e(t);return e.config.silent=n,r}function ze(e){var t=ae();return t&&e instanceof t}function Ue(e,t){return function(){for(var n=[],r=0;r=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var R="composition-api.refKey",Z=new WeakMap,Qe=new WeakMap,le=function(){function e(t){var n=t.get,r=t.set;p(this,"value",{get:n,set:r})}return e}();function de(e,t){var n=new le(e),r=Object.seal(n);return Qe.set(r,!0),r}function ee(e){var t;if(g(e))return e;var n=pe((t={},t[R]=e,t));return de({get:function(){return n[R]},set:function(r){return n[R]=r}})}function g(e){return e instanceof le}function Xe(e){if(!y(e))return e;var t={};for(var n in e)t[n]=qe(e,n);return t}function qe(e,t){var n=e[t];return g(n)?n:de({get:function(){return e[t]},set:function(r){return e[t]=r}})}function S(e){var t;return Boolean(e&&O(e,"__ob__")&&typeof e.__ob__=="object"&&((t=e.__ob__)===null||t===void 0?void 0:t.__raw__))}function $(e){var t;return Boolean(e&&O(e,"__ob__")&&typeof e.__ob__=="object"&&!(!((t=e.__ob__)===null||t===void 0)&&t.__raw__))}function z(e){if(!(!y(e)||S(e)||M(e)||g(e)||ze(e)||Z.has(e))){Z.set(e,!0);for(var t=Object.keys(e),n=0;n0&&(s=n[0]),s instanceof Error)throw s;var f=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw f.context=s,f}var u=o[t];if(u===void 0)return!1;if(typeof u=="function")ne(u,this,n);else for(var h=u.length,l=xe(u,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,st(f)}return e}a.prototype.addListener=function(t,n){return we(this,t,n,!1)};a.prototype.on=a.prototype.addListener;a.prototype.prependListener=function(t,n){return we(this,t,n,!0)};function ot(){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 Oe(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=ot.bind(r);return i.listener=n,r.wrapFn=i,i}a.prototype.once=function(t,n){return k(n),this.on(t,Oe(this,t,n)),this};a.prototype.prependOnceListener=function(t,n){return k(n),this.prependListener(t,Oe(this,t,n)),this};a.prototype.removeListener=function(t,n){var r,i,o,s,f;if(k(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){f=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():ft(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,f||n)}return this};a.prototype.off=a.prototype.removeListener;a.prototype.removeAllListeners=function(t){var n,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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var o=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(t,n[i]);return this};function Le(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?ut(i):xe(i,i.length)}a.prototype.listeners=function(t){return Le(this,t,!0)};a.prototype.rawListeners=function(t){return Le(this,t,!1)};a.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Ee.call(e,t)};a.prototype.listenerCount=Ee;function Ee(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?I(this._events):[]};function xe(e,t){for(var n=new Array(t),r=0;r=0,this.isIpad=/(iPad).*OS\s([\d_]+)/.test(t),this.isIos=this.isIphone||this.isIpad,this.isAndroid=t.indexOf("Android")>=0,this.isAnroidPad=this.isAndroid&&t.indexOf("Mobile")<0,this.isMac=t.indexOf("Macintosh")>=0,this.isWin=t.indexOf("Windows")>=0,this.isMqq=/QQ\/([\d.]+)/.test(t),this.isWechat=t.indexOf("MicroMessenger")>=0&&t.indexOf("wxwork")<0,this.isWeb=!this.isIos&&!this.isAndroid&&!/(WebOS|BlackBerry)/.test(t),Object.entries(n).forEach(([r,i])=>{this[r]=i})}}const U="magic:common:events:",Ce="magic:common:actions:",j={SHOW:"show",HIDE:"hide",SCROLL_TO_VIEW:"scrollIntoView",SCROLL_TO_TOP:"scrollToTop"},dt=[{label:"\u70B9\u51FB",value:`${U}click`}],$e=(e,t)=>{const n=`${e}:${t}`;return e.startsWith(U)?n:`${U}${n}`},ht=e=>e.startsWith(Ce),Re=(e,t)=>{var r;if(!e)return!1;if(!e.id)return Re(e.parentElement,t);const n=(r=t.page)==null?void 0:r.getNode(e.id);return n||!1},ie=(e,t,n)=>{const r=Re(n.target,e);if(r){const{instance:i,data:o}=r;e.emit($e(t,o.id),i)}},vt=e=>{window.document.body.addEventListener("click",t=>{ie(e,"click",t)}),window.document.body.addEventListener("click",t=>{ie(e,"click:capture",t)},!0)},pt=(e,t)=>{const{instance:n}=t;switch(e.replace(Ce,"")){case j.SHOW:n.show();break;case j.HIDE:n.hide();break;case j.SCROLL_TO_VIEW:n.$el.scrollIntoView({behavior:"smooth"});break;case j.SCROLL_TO_TOP:window.scrollTo({top:0,behavior:"smooth"});break}};class se extends W.exports.EventEmitter{constructor(t){super();const{events:n}=t;this.data=t,this.events=n,this.listenLifeSafe(),this.once("destroy",()=>{this.instance=null,typeof this.data.destroy=="function"&&this.data.destroy(this),this.listenLifeSafe()})}listenLifeSafe(){this.once("created",t=>{this.instance=t,typeof this.data.created=="function"&&this.data.created(this)}),this.once("mounted",t=>{this.instance=t,typeof this.data.mounted=="function"&&this.data.mounted(this)})}}class gt extends se{constructor(t){super(t.config),this.nodes=new Map,this.setNode(t.config.id,this),this.initNode(t.config)}initNode(t){var n;this.setNode(t.id,new se(t)),(n=t.items)==null||n.forEach(r=>{this.initNode(r)})}getNode(t){return this.nodes.get(t)}setNode(t,n){this.nodes.set(t,n)}deleteNode(t){this.nodes.delete(t)}}const mt=e=>{if(typeof e!="string")return e;const t={};return e.split(";").forEach(n=>{if(!n)return;const r=n.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,f)=>f>0?`${s[0].toUpperCase()}${s.substr(1)}`:s).join(""),t[i]=o)}),t},yt=e=>e&&!/^url/.test(e)&&!/^linear-gradient/.test(e)?`url(${e})`:e;class Lt extends W.exports.EventEmitter{constructor(t){if(super(),this.pages=new Map,this.platform="mobile",this.jsEngine="browser",this.components=new Map,this.env=new lt(t.ua),t.platform&&(this.platform=t.platform),t.jsEngine&&(this.jsEngine=t.jsEngine),this.platform==="mobile"||this.platform==="editor"){const n=()=>{let{width:r}=document.documentElement.getBoundingClientRect();r=Math.min(800,r);const i=r/3.75;document.documentElement.style.fontSize=`${i}px`};n(),document.body.style.fontSize="14px",globalThis.addEventListener("resize",n)}t.transformStyle&&(this.transformStyle=t.transformStyle),t.config&&this.setConfig(t.config,t.curPage),vt(this)}transformStyle(t){if(!t)return{};let n={};const r={};typeof t=="string"?n=mt(t):n=q({},t);const i=["zIndex","opacity","fontWeight"];return Object.entries(n).forEach(([o,s])=>{o==="backgroundImage"?s&&(r[o]=yt(s)):!i.includes(o)&&s&&/^[-]?[0-9]*[.]?[0-9]*$/.test(s)?r[o]=`${s/100}rem`:r[o]=s}),r}setConfig(t,n){var r,i,o;this.pages=new Map,(r=t.items)==null||r.forEach(s=>{this.pages.set(s.id,new gt({config:s}))}),this.setPage(n||((o=(i=this.page)==null?void 0:i.data)==null?void 0:o.id))}setPage(t){let n;t&&(n=this.pages.get(t)),n||(n=this.pages.get(this.pages.keys().next().value)),this.page=n,this.platform!=="magic"&&this.bindEvents()}registerComponent(t,n){this.components.set(t,n)}unregisterComponent(t){this.components.delete(t)}resolveComponent(t){return this.components.get(t)}bindEvents(){var t;if(!!this.page){this.removeAllListeners();for(const[,n]of this.page.nodes)(t=n.events)==null||t.forEach(r=>{let{name:i}=r;dt.findIndex(o=>o.value===i)>-1&&(i=$e(i,`${n.data.id}`)),this.on(i,(o,...s)=>{var h;if(!this.page)throw new Error("\u5F53\u524D\u6CA1\u6709\u9875\u9762");const f=this.page.getNode(r.to);if(!f)throw`ID\u4E3A${r.to}\u7684\u7EC4\u4EF6\u4E0D\u5B58\u5728`;const{method:u}=r;if(ht(u))return pt(u,f);typeof((h=f.instance)==null?void 0:h[u])=="function"&&f.instance[u](o,...s)})})}}destroy(){this.removeAllListeners(),this.pages.clear()}}export{Lt as A,Ot as C,wt as d,bt as i,pe as r};