@fox-js/fox 3.1.1-25 → 3.1.1-26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.Fox={},m.Vue))})(this,function(m,v){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});var me=typeof window<"u",j=function(){return window},Ve=function(){return window.document};function We(e,t,r,s=!1){e.addEventListener?e.addEventListener(t,r,s):e.attachEvent?e.attachEvent(`on${t}`,r):e[`on${t}`]=r}function gt(e,t,r){e.removeEventListener?e.removeEventListener(t,r):e.detachEvent?e.detachEvent(`on${t}`,r):e[`on${t}`]=null}var Je=(e,t,r)=>{t=t??{bubbles:!1,cancelable:!1,detail:void 0};const s=document.createEvent("Events");let i=!0,n=!0;for(let o in t)o==="bubbles"?i=!!t[o]:o==="cancelable"?n=!!t[o]:s[o]=t[o];s.initEvent(e,i,n),(r??document).dispatchEvent(s)},bt=Array.isArray,ds=e=>ze(e)==="[object Map]",ms=e=>ze(e)==="[object Set]",vs=e=>e instanceof Date,S=e=>typeof e=="function",ps=e=>typeof e=="string",gs=e=>typeof e=="symbol",ir=e=>e!==null&&typeof e=="object",bs=e=>ir(e)&&S(e.then)&&S(e.catch),ve=e=>e==null,ws=Object.prototype.toString,ze=e=>ws.call(e),nr=e=>ze(e)==="[object Object]",Rs=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol";function Ge(e){return e.__esModule||Rs&&e[Symbol.toStringTag]==="Module"}var Ss=typeof Promise<"u"&&Promise.toString().indexOf("[native code]")!==-1;function q(...e){let t=e[0]!==void 0&&e[0]!==null?e[0]:{},r=1,s=e.length,i=!1;for(typeof t=="boolean"&&(i=t,t=e[r]??{},r++),typeof t!="object"&&(t={});r<s;r++)if(e[r]!==null&&e[r]!==void 0){let n=e[r];for(let o in n){let u=t[o],l=n[o];if(u!==l)if(i===!0&&l&&typeof l=="object"){let a;Array.isArray(l)?a=u&&Array.isArray(u)?u:[]:a=u&&typeof u=="object"?u:{},t[o]=q(i,a,l)}else l!==void 0&&(t[o]=l)}}return t}function or(e,t,r=!1){if(typeof t!="object")return{};typeof e!="object"&&(e={});for(let s of Reflect.ownKeys(t)){let i=e[s],n=t[s];if(i!==n)if(typeof n=="object"){if(!Array.isArray(n)&&!nr(n))continue;i=or(i,n,r),e[s]=i}else{if(typeof n=="function")continue;e[s]=n}}return e}var Fe=class rr{static seed=new Date().getTime();static get(){let t=++rr.seed;return t>=Number.MAX_VALUE&&(rr.seed=0),t}},wt=Ss?Promise.resolve():null;function Ce(e,...t){wt!==null?t&&t.length>0?wt.then(()=>{e(t)}):wt.then(e):t&&t.length>0?setTimeout(()=>{e(t)}):setTimeout(e)}function Rt(e){return e==null?!1:typeof e=="boolean"?e:typeof e=="string"?e.toLocaleLowerCase()==="true":!!e}function xs(e){return typeof e=="number"?e:Number(e)}var Ps={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Object]":"object"};function St(e){let t=Object.prototype.toString.call(e);return e==null?String(e):Ps[t]||"object"}function xt(e,t){if(e==t)return!0;if(e===void 0||t===void 0)return!1;let r=St(e);if(r!==St(t))return!1;if(r==="object"){let s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(let n=0;n<s.length;n++){let o=s[n],u=e[o],l=t[o];if(!xt(u,l))return!1}return!0}else if(r==="array"){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){let i=e[s],n=t[s];if(!xt(i,n))return!1}return!0}return!1}var lr=e=>{const t={};for(let r of Reflect.ownKeys(e)){let s=e[r];s&&!Array.isArray(s)&&typeof s=="object"&&(s=lr(s)),typeof r=="symbol"?t[String(r)]=s:t[r]=s}return t},Es=/^Symbol\((.*)\)$/,ar=e=>{const t={};for(let r of Reflect.ownKeys(e)){let s=e[r];s&&!Array.isArray(s)&&typeof s=="object"&&(s=ar(s));const i=Es.exec(r);if(i&&i[1]){const n=Symbol.for(i[1]);t[n]=s}else t[r]=s}return t};function ur(e,t){let r=null;return function(...s){r&&clearTimeout(r),r=setTimeout(()=>{r=null,Reflect.apply(e,null,[...s])},t)}}var fr=Symbol("idKey"),oe=Symbol("valueKey"),x=Symbol("childrenKey"),V=Symbol("growKey"),cr=class{[V]=!0;[fr];[oe]=(0,v.ref)();[x]=new Map;constructor(e){this[fr]=e}},Fs=class{get(e,t){if(t=="value")return e[oe].value;if(t==="grow")return e[V];let r=e[x].get(t);if(r)return _e(r);if(e[V])return r=Et(t),r[V]=e[V],e[x].set(t,r),_e(r)}set(e,t,r){return t=="value"?(e[oe].value=r,!0):t==="grow"?(e[V]=Rt(r),!0):r==null?(e[x].delete(t),!0):(console.error(`[Fox]illegal property:${t}`),!1)}deleteProperty(e,t){return t==="value"||t=="grow"?(console.error(`[Fox]can not delete property:${String(t)}`),!1):(e[x].delete(t),!0)}},Pt="__proxy__";function Et(e){const t=new cr(e);return Reflect.set(t,Pt,new Proxy(t,new Fs)),t}function _e(e){return Reflect.get(e,Pt)}var Cs=class{name="";persistPolicy="memory";storage;initFlag=!1;state={};constructor(e={},t){if(e.persistPolicy&&e.persistPolicy!=="memory"&&ve(e.name))throw new Error("name can not be empty, where persistPolicy is not memory.");this.name=e.name??"",this.persistPolicy=e.persistPolicy??"memory",this.storage=e.storage,t&&typeof t=="object"&&Object.assign(this.state,t)}init(e){this.restore(e),this.initFlag=!0}getStorage(){if(!this.persistPolicy||this.persistPolicy==="memory")return null;let e=null;if(this.persistPolicy==="custom")e=this.storage;else if(me){const t=j();e=this.persistPolicy==="session"?t.sessionStorage:t.localStorage}return e}saveState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null||!this.state)return;const t=`_bus_${this.name}`,r=JSON.stringify(this.state??{});e.setItem(t,r)}removeState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null||!this.state)return;const t=`_bus_${this.name}`;e.removeItem(t)}restore(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null)return;const r=`_bus_${this.name}`,s=t.getItem(r);if(s){const i=JSON.parse(s);Object.assign(this.state,i),Reflect.ownKeys(this.state).forEach(n=>{if(typeof n!="string")return;const o=this.state[n],u=n.split(/\//g);u.push(o),Reflect.apply(e.put,e,u)})}}put(e){if(this.initFlag&&this.persistPolicy!=="memory")try{const t=e.length,r=e.slice(0,t-1).join("/"),s=e[t-1];this.state[r]=s,this.saveState()}catch(t){console.error(t)}}remove(e){if(this.initFlag&&this.persistPolicy!=="memory")try{const t=e.length,r=e.slice(0,t-1).join("/"),s={};Reflect.ownKeys(this.state).forEach(i=>{typeof i=="string"&&(i===r||i.startsWith(r)||(s[i]=this.state[i]))}),this.state=s,this.saveState()}catch(t){console.error(t)}}clear(){if(this.initFlag)try{this.state={},this.removeState()}catch(e){console.error(e)}}},hr=class extends cr{_persistHandler;constructor(e={},t){super("__root__"),this._persistHandler=new Cs(e,t),this._persistHandler.init(this)}put(...e){let t=e.length;if(t<2)return console.error("[Fox]参数至少包括一个(key, value)"),!1;let r=this;for(let s=0;s<t-1;s++){let i=e[s],n;r[x].has(i)?n=r[x].get(i):(n=Et(i),r[x].set(i,n)),r=n}return r[oe].value=e[t-1],this._persistHandler.put(e),!0}get(...e){let t=e.length;if(t===0)return;let r=this;for(let s=0;s<t;s++){let i=e[s];if(r[x].has(i))r=r[x].get(i);else return}return r[oe].value}remove(...e){let t=e.length;if(t==0)return!1;let r=this;for(let i=0;i<t-1;i++){const n=e[i];if(r[x].has(n))r=r[x].get(n);else return!1}const s=e[t-1];return r[x].has(s)?(r[x].delete(s),this._persistHandler.remove(e),!0):!1}contains(...e){const t=e.length;if(t==0)return!1;let r=this;for(let i=0;i<t-1;i++){let n=e[i];if(r[x].has(n))r=r[x].get(n);else return!1}const s=e[t-1];return r[x].has(s)}clear(){this[x].clear(),this._persistHandler.clear()}},_s=["put","get","contains","remove","clear","_persistHandler"];function yr(e){return _s.includes(e)}var As=class{get(e,t){if(t=="value")return e[oe].value;if(t==="grow")return e[V];if(t===x)return e[x];if(typeof t=="string"&&yr(t))return e[t];const r=String(t);let s=e[x].get(r);if(s)return _e(s);if(e[V])return s=Et(r),s[V]=e[V],e[x].set(r,s),_e(s)}set(e,t,r){return t=="value"?(e[oe].value=r,!0):t==="grow"?(e[V]=Rt(r),!0):yr(t)?!1:r==null?(e[x].delete(t),!0):(console.error(`[Fox]illegal property:${t}`),!1)}deleteProperty(e,t){return t==="value"||t=="grow"?(console.error(`[Fox]can not delete property:${String(t)}`),!1):(e[x].delete(t),!0)}};function js(e,t){const r=new hr(e,t),s=new As,i=new Proxy(r,s);return Reflect.set(r,Pt,i),r}var Ft=new Proxy(hr,{construct(e,t){const r=t[0]??{},s=t[1];return _e(js(r,s))}}),Ct=e=>!e||typeof e!="object"?!0:Reflect.ownKeys(e).length===0,dr=class{name="";persistPolicy="memory";storage;constructor(e={}){if(e.persistPolicy&&e.persistPolicy!=="memory"&&ve(e.name))throw new Error("name can not be empty, where persistPolicy is not memory.");this.name=e.name??"",this.persistPolicy=e.persistPolicy??"memory",this.storage=e.storage}getStorage(){if(!this.persistPolicy||this.persistPolicy==="memory")return null;let e=null;if(this.persistPolicy==="custom")e=this.storage;else if(me){const t=j();e=this.persistPolicy==="session"?t.sessionStorage:t.localStorage}return e}saveState(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null||Ct(e))return;const r=`_state_${this.name}`,s=JSON.stringify(e??{});t.setItem(r,s)}removeState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null)return;const t=`_state_${this.name}`;e.removeItem(t)}restore(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null)return;const r=`_state_${this.name}`,s=t.getItem(r);if(s){const i=JSON.parse(s);Object.assign(e,i)}}};function mr(e,t,r){const s=new dr(r);s.restore(t);const i=u=>{const l=(0,v.toRaw)(u),a={};for(let f in l){const c=l[f];ve(c)||(a[f]=c)}Ct(a)?s.removeState():s.saveState(a)};let n=null;r&&r.debounce===!1?n=i:n=ur(i,r&&r.debounceDelay?r.debounceDelay:250);const o=e?(0,v.shallowReactive)(t):(0,v.reactive)(t);return(0,v.effectScope)(!0).run(()=>{(0,v.watch)(o,u=>{const l=(0,v.toRaw)(u);n(l)})}),o}function qs(e,t){return mr(!1,e,t)}function Ks(e,t){return mr(!0,e,t)}function $s(e,t){const r=new dr(t);r.restore(e);const s=n=>{const o=(0,v.toRaw)(n),u={};for(let l in o){const a=o[l];ve(a)||(u[l]=a)}Ct(u)?r.removeState():r.saveState(u)};let i=null;return t&&t.debounce===!1?i=s:i=ur(s,t&&t.debounceDelay?t.debounceDelay:250),new Proxy(e,{get(n,o){return n[o]},set(n,o,u){return n[o]=u,i(n),!0}})}function Ls(e,t){return $s(e,t)}var le=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e})({}),C=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e})(C||{}),Ts={type:le.Static,value:""},Ms=/[a-zA-Z0-9_]/;function ks(e){if(!e)return[[]];if(e==="/")return[[Ts]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(y){throw new Error(`ERR (${r})/"${a}": ${y}`)}let r=C.Static,s=r;const i=[];let n;function o(){n&&i.push(n),n=[]}let u=0,l,a="",f="";function c(){a&&(r===C.Static?n.push({type:le.Static,value:a}):r===C.Param||r===C.ParamRegExp||r===C.ParamRegExpEnd?(n.length>1&&(l==="*"||l==="+")&&t(`A repeatable param (${a}) must be alone in its segment. eg: '/:ids+.`),n.push({type:le.Param,value:a,regexp:f,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):t("Invalid state to consume buffer"),a="")}function h(){a+=l}for(;u<e.length;){if(l=e[u++],l==="\\"&&r!==C.ParamRegExp){s=r,r=C.EscapeNext;continue}switch(r){case C.Static:l==="/"?(a&&c(),o()):l===":"?(c(),r=C.Param):h();break;case C.EscapeNext:h(),r=s;break;case C.Param:l==="("?r=C.ParamRegExp:Ms.test(l)?h():(c(),r=C.Static,l!=="*"&&l!=="?"&&l!=="+"&&u--);break;case C.ParamRegExp:l===")"?f[f.length-1]=="\\"?f=f.slice(0,-1)+l:r=C.ParamRegExpEnd:f+=l;break;case C.ParamRegExpEnd:c(),r=C.Static,l!=="*"&&l!=="?"&&l!=="+"&&u--,f="";break;default:t("Unknown state");break}}return r===C.ParamRegExp&&t(`Unfinished custom RegExp for param "${a}"`),c(),o(),i}var vr="[^/]+?",Is={sensitive:!1,strict:!1,start:!0,end:!0},W=(function(e){return e[e._multiplier=10]="_multiplier",e[e.Root=90]="Root",e[e.Segment=40]="Segment",e[e.SubSegment=30]="SubSegment",e[e.Static=40]="Static",e[e.Dynamic=20]="Dynamic",e[e.BonusCustomRegExp=10]="BonusCustomRegExp",e[e.BonusWildcard=-50]="BonusWildcard",e[e.BonusRepeatable=-20]="BonusRepeatable",e[e.BonusOptional=-8]="BonusOptional",e[e.BonusStrict=.7000000000000001]="BonusStrict",e[e.BonusCaseSensitive=.25]="BonusCaseSensitive",e})(W||{}),Os=/[.+*?^${}()[\]/\\]/g;function Bs(e,t){const r=q(!0,{},Is,t),s=[];let i=r.start?"^":"";const n=[];for(const a of e){const f=a.length?[]:[W.Root];r.strict&&!a.length&&(i+="/");for(let c=0;c<a.length;c++){const h=a[c];let y=W.Segment+(r.sensitive?W.BonusCaseSensitive:0);if(h.type===le.Static)c||(i+="/"),i+=h.value.replace(Os,"\\$&"),y+=W.Static;else if(h.type===le.Param){const{value:d,repeatable:p,optional:R,regexp:w}=h;n.push({name:d,repeatable:p,optional:R});const g=w||vr;if(g!==vr){y+=W.BonusCustomRegExp;try{new RegExp(`(${g})`)}catch(I){throw new Error(`Invalid custom RegExp for param "${d}" (${g}): `+I.message)}}let T=p?`((?:${g})(?:/(?:${g}))*)`:`(${g})`;c||(T=R&&a.length<2?`(?:/${T})`:"/"+T),R&&(T+="?"),i+=T,y+=W.Dynamic,R&&(y+=W.BonusOptional),p&&(y+=W.BonusRepeatable),g===".*"&&(y+=W.BonusWildcard)}f.push(y)}s.push(f)}if(r.strict&&r.end){const a=s.length-1;s[a][s[a].length-1]+=W.BonusStrict}r.strict||(i+="/?"),r.end?i+="$":r.strict&&!i.endsWith("/")&&(i+="(?:/|$)");const o=new RegExp(i,r.sensitive?"":"i");function u(a){const f=a.match(o),c={};if(!f)return null;for(let h=1;h<f.length;h++){const y=f[h]||"",d=n[h-1];c[d.name]=y&&d.repeatable?y.split("/"):y}return c}function l(a){let f="",c=!1;for(const h of e){(!c||!f.endsWith("/"))&&(f+="/"),c=!1;for(const y of h)if(y.type===le.Static)f+=y.value;else if(y.type===le.Param){const{value:d,repeatable:p,optional:R}=y,w=d in a?a[d]:"";if(bt(w)&&!p)throw new Error(`Provided param "${d}" is an array but it is not repeatable (* or + modifiers)`);const g=bt(w)?w.join("/"):w;if(!g)if(R)h.length<2&&(f.endsWith("/")?f=f.slice(0,-1):c=!0);else throw new Error(`Missing required param "${d}"`);f+=g}}return f||"/"}return{re:o,score:s,keys:n,parse:u,stringify:l}}function Ds(e,t){const r=Bs(ks(e),t);return function(s){const i=r.parse(s);return i?{path:s,params:i}:null}}var pr="default",gr=Symbol("sync"),M=Symbol("normalizeRoute");function br(e){let t=!1;return function(...r){if(!t)return t=!0,Reflect.apply(e,{},r)}}function Hs(e){let t=e.src;return new Promise((r,s)=>{const i=br(u=>{Ge(u)&&(u=u.default),e.component=u,console.debug("success load async module"),r()}),n=br(u=>{`${u}`,console.debug("reject load async module"),s(u)});let o;try{o=t(i,n)}catch(u){n(u)}if(o)if(typeof o.then=="function")o.then(i,n);else{const u=o.component;u&&typeof u.then=="function"&&u.then(i,n)}})}var Ns=class{name;level;rootName;rootIndex=0;constructor(e,t,r,s){this.name=e,this.level=t,this.rootName=r,this.rootIndex=s}},Xe=class ys{to;routeModel;from;data={};constructor(t,r){this.to=t,this.from=r}static from(t){const r=new ys(t.to,t.from),s=t.data??{};return q(!0,r.data,s),r}static clear(t){for(let r in t)t[r]=void 0}},P=class sr{path;get fullPath(){const t=this.path??`${this.name}`;return`${this.root??"default"}!${t}`}alias;name;root;params;query;traceless;template;matched;meta;success;error;destroy;opsType;updateType;historyUpdatePolicy;viewTagAttrs;index;active;slot;static clone(t,r){let s=new sr;return or(s,t,r),s}static isSame(t,r){return!t||!r?!1:t===r?!0:t.root!==r.root||t.index!==r.index?!1:t.path&&r.path&&t.path===r.path?!0:!!(t.name&&r.name&&t.name===r.name)}static isSamePathForRoute(t,r){return!t||!r?!1:t===r||t.path&&r.path&&t.path===r.path?!0:!!(t.name&&r.name&&t.name===r.name)}static from(t){let r=new sr;if(t==null)return r;let s=r;for(let n in t)s[n]=t[n];const i=Object.getOwnPropertySymbols(t);if(Array.isArray(i)&&i.length>0)for(let n of i)s[n]=t[n];return r}},Us=class{id;name;props;src;component;constructor(e,t,r){this.id=Fe.get(),this.name=e,this.src=t,typeof t!="function"&&(this.component=t),this.props=r}get isResolved(){return this.component!==void 0}resolve(){return Hs(this)}},wr=class{models=[]},_t=class{path;match;redirect;name;meta;matchedRoutes;layers=[]},_=(function(e){return e[e.Push=0]="Push",e[e.Replace=1]="Replace",e[e.Put=2]="Put",e[e.Append=3]="Append",e[e.Open=4]="Open",e})({}),At=(function(e){return e[e.Part=0]="Part",e[e.All=1]="All",e})({}),J=Symbol("rootKey"),z=Symbol("rootNodeKey"),ae=Symbol("parentNodeKey"),Qe=Symbol("nameKey"),re=class{model;route;active=!0;index=0;constructor(e,t,r=0,s=!0){this.route=e,this.model=t,this.index=r,this.active=s}},Ae=class{_slots;get slots(){return this._slots==null&&(this._slots=(0,v.shallowRef)([])),this._slots}get empty(){return this._slots==null||this._slots.value.length==0}[Qe];[J];[z]=null;[ae]=null;get name(){return this[Qe]}constructor(e,t,r){this[Qe]=e,this[J]=t,r&&(this[z]=r)}},D=class{view;index;level;constructor(e,t,r){this.view=e,this.index=t,this.level=r}static include(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.view===t.view&&(t.index==-1||s.index===t.index)&&s.level===t.level)return!0}return!1}},jt=class{views=[]},Vs=class{layers=[]},Ws=class{time;route},Js=class{forbidTime=300;submitRecorder=new Ws;isSameRoute(e,t){return e==null||t==null?!1:e.name===t.name&&e.path===t.path&&e.root===t.root}acquire(e){let t=new Date().getTime();if(this.isSameRoute(e,this.submitRecorder.route)&&this.submitRecorder.time&&t-this.submitRecorder.time<=this.forbidTime){this.submitRecorder.time=t;return}return this.submitRecorder.route=e,this.submitRecorder.time=t,t}release(e){this.submitRecorder.time===e&&(this.submitRecorder.route=void 0)}},F=(function(e){return e.Busy="Busy",e.Free="Free",e.Reject="Reject",e.Exception="Exception",e.Finished="Finished",e})(F||{}),H=Symbol("chainKey"),k=Symbol("cursorKey"),qt=Symbol("$persistentModeKey"),A=Symbol("statusKey"),Z=Symbol("argsKey"),Ze=Symbol("exArgsKey"),pe=Symbol("successFnsKey"),je=Symbol("errorFnsKey"),ue=Symbol("sessionKey"),Y=Symbol("_go"),qe=class{[H]=[];[k]=0;[qt]=!1;[A]=F.Free;[Z]=[];[Ze]=[];[pe]=[];[je]=[];[ue];get session(){return this[ue]}constructor(e,t=!1){this[ue]=e,this[qt]=t}[Y](e,...t){let r=this[A];if(this[A]=F.Busy,this[k]+=e,this[k]<0&&(this[k]=0),this[Z]=t,r===F.Exception||r===F.Reject){let n=[{session:this[ue]},...this[Ze]];for(;this[je].length>0;)try{let o=this[je].shift();typeof o=="function"&&Ce(()=>{Reflect.apply(o,{},n)})}catch(o){console.error(o.message,o)}return this[A]=r,this[H]=[],this[k]=0,this}else if(r===F.Finished||this[k]>=this[H].length){let n=[{session:this[ue]},...this[Z]];for(;this[pe].length>0;){let o=this[pe].shift();typeof o=="function"&&Ce(()=>{Reflect.apply(o,{},n)})}return this[A]=F.Free,this}if(this[k]>=this[H].length)return this[A]=F.Free,this;let s=this[H][this[k]];this[qt]||(this[H].splice(0,this[k]+1),this[k]=-1);let i=this[k]+1;try{let n=!1,o={go:(u,...l)=>{n||(n=!0,Reflect.apply(this[Y],this,[u,...l]))},resolve:(...u)=>{n||(n=!0,Reflect.apply(this[Y],this,[1,...u]))},reject:(...u)=>{n||(n=!0,Reflect.apply(this.reject,this,[...u]))},insert:u=>{n||(this[H].splice(i,0,u),i++)},session:this[ue]};Ce(()=>{Reflect.apply(s,{},[o,...this[Z]])})}catch(n){this.throw(n)}return this}go(e,...t){return Reflect.apply(this[Y],this,[e,...t])}finish(...e){return this[A]=F.Finished,this[Z]=e,Reflect.apply(this[Y],this,[0])}reject(...e){return this[A]=F.Reject,this[Ze]=e,Reflect.apply(this[Y],this,[0])}throw(...e){return this[A]=F.Exception,this[Ze]=e,Reflect.apply(this[Y],this,[0])}reset(...e){this[A]=F.Busy,this[Z]=e,this[H]=[],this[k]=0;let t=[{session:this[ue]},...this[Z]];for(;this[pe].length>0;){let r=this[pe].shift();Ce(()=>{Reflect.apply(r,this,t)})}return this[A]=F.Free,this}post(e){return this[A]===F.Reject||this[A]===F.Exception?this:(Array.isArray(e)?this[H]=[...this[H],...e]:this[H].push(e),this[A]===F.Busy?this:(Reflect.apply(this[Y],this,[0,...this[Z]]),this))}wait(e,t){return e&&typeof e=="function"&&this[pe].push(e),t&&typeof t=="function"&&this[je].push(t),this[A]===F.Busy?this:(Reflect.apply(this[Y],this,[0,...this[Z]]),this)}exception(e){return e&&typeof e=="function"&&this[je].push(e),this[A]===F.Busy?this:Reflect.apply(this[Y],this,[0,...this[Z]])}isFinish(){return this[A]==F.Reject||this[A]==F.Free&&this[k]>=this[H].length}},ge=Symbol("_notifyChange"),Rr=class{currentRoute;routes;constructor(e,t){this.currentRoute=e,this.routes=t}},fe=Symbol("historyChangeConsumerKey"),Sr=Symbol("_navigateFirstRoute"),Ye=Symbol("_getRouteMark"),Kt=Symbol("_getUrlSearch"),$t=Symbol("_generateLocation"),et=Symbol("_setRouteMarkRecorder"),Ke=Symbol("beforeRestoreFiltersKey"),xr=Symbol("_beforeRestore"),Pr="Symbol(_fox_restore_point)";function $e(e,...t){return typeof e=="function"?Reflect.apply(e,null,[...t]):e}function Er(e){if(!Array.isArray(e))return!1;if(e.length===0)return!0;const t=e[0];return!!(Reflect.has(t,"path")&&Reflect.has(t,"root"))}var Fr=class{base;storage;mode;query;firstNavigate=!0;historyMonitor;traceless=!1;changeHandler;historyChange;[fe]=!1;[Ke]=new Array;backTimeout=320;constructor(e="hash",t="",r="",s=!0,i=!0,n=!1,o,u){this.mode=e,this.base=t,this.query=r,this.firstNavigate=s,this.historyMonitor=i,this.traceless=n,this.storage=o??j().sessionStorage,this.backTimeout=u??320}init(e=!0){const t=j();return typeof this.historyChange!="function"&&(this.historyChange=()=>{if(typeof this[fe]=="function"){const r=this[fe]();if(this[fe]=!1,r)return}else if(this[fe]===!0){this[fe]=!1;return}if($e(this.historyMonitor)){const r=t.history.state;this[ge](r);try{let s=[];if(typeof r=="string"?s=JSON.parse(r):s=r,Array.isArray(s)&&s.length>0){const i=this[Ye]()??"/";this[et](i,s)}}catch{}}}),We(t,"popstate",this.historyChange),this.firstNavigate&&e&&this[Sr](),Promise.resolve()}destroy(){this.historyChange&&gt(j(),"popstate",this.historyChange)}[xr](e,t,r,s){for(let i of this[Ke])try{const n=Reflect.apply(i,{},[e,t,r,s]);if(n===!1)return n}catch(n){console.error(n.message,n)}return!0}beforeRestoreEach(e){this[Ke].push(e)}removeBeforeRestoreEach(e){const t=this[Ke].indexOf(e);return t!==-1?(this[Ke].splice(t,1),!0):!1}[Sr](){const e=this[Ye]()??"/",t=this.storage.getItem(Pr);if(t)try{const n=JSON.parse(t);if(n.mark===e&&Array.isArray(n.routes)&&n.routes.length>0){const o=n.routes.filter((u,l)=>(u.params=u.params?ar(u.params):{},this[xr](u,l,e,n.routes)));if(o.length>0){const u=this[Kt](),l=o.length-1;o[l].query=u||o[l].query,this[ge](o);return}}}catch{}const r=e.indexOf("!");let s;r!=-1?s=e.substring(r+1):s=e;const i=new P;i.path=s,i.query=this[Kt](),this[ge]([i])}[et](e,t){try{t.forEach(s=>{s.params=s.params?lr(s.params):{}});const r=JSON.stringify({mark:e,routes:t});this.storage.setItem(Pr,r)}catch(r){console.error(r.message,r)}}setRestorePoint(e){const t=this[Ye]()??"/";this[et](t,e)}[ge](e){typeof this.changeHandler=="function"&&this.changeHandler(e)}[Ye](){const e=j();if(this.mode==="path"){let t=e.location.pathname;return this.base&&t.indexOf(this.base)===0&&(t=t.substring(this.base.length)),t}else{const t=e.location.hash,r=t.indexOf("#");if(r!=-1)return t.substring(r+1)}return null}[Kt](){let e=j().location.search;return e.length>0&&e.indexOf("?")===0&&(e=e.substring(1)),e}listen(e){this.changeHandler=e}go(e,t=!1){const r=j();this[fe]=t,r.history.go(e)}goBack(e,t){const r=j(),s=r.history.state;if(Er(s)&&s.length>0){let i=!1;for(let a=s.length-1;a>=0;a--){const f=P.from(s[a]);if(!(f.historyUpdatePolicy==="traceless"||$e(this.traceless,f))&&P.isSame(f,e)){i=!0;break}}if(!i){t();return}const n=this.backTimeout;let o=null;const u=()=>{r.history.go(-1),o=setTimeout(u,n)},l=()=>{clearTimeout(o);const a=j().history.state;if(Er(a)&&a.length>0){let f=a.length;const c=a[f-1],h=P.from(c);if(P.isSame(h,e))return t(),!0;if(f>0){let y=!1;for(let d=f-1;d>=0;d--){const p=P.from(a[d]);if(!(p.traceless===!0||$e(this.traceless,p))&&P.isSame(p,e)){y=!0;break}}return y?(setTimeout(()=>{o=setTimeout(u,n),this.go(-1,l)},0),!0):(t(),!0)}}return t(),!0};o=setTimeout(u,n),this.go(-1,l)}else t()}setRouteMark(e){const t=e.currentRoute.fullPath;this[et](t,e.routes)}push(e){const t=this[$t](e.currentRoute);e.currentRoute.historyUpdatePolicy!=="traceless"&&!$e(this.traceless,e.currentRoute)&&j().history.pushState(e.routes,"",t),this.setRouteMark(e)}replace(e){const t=this[$t](e.currentRoute);(e.currentRoute.historyUpdatePolicy!=="traceless"||!$e(this.traceless,e.currentRoute))&&j().history.replaceState(e.routes,"",t),this.setRouteMark(e)}[$t](e){const t=j();let r="";if(e.query){let o="";if(typeof e.query=="object")for(let u of Reflect.ownKeys(e.query)){let l=encodeURIComponent(e.query[u]),a=`${encodeURIComponent(String(u))}=${l}`;o.length>0&&(o+="&"),o+=a}else o=e.query;this.query?(r=o.length>0?`${this.query}&${o}`:this.query,r.length>0&&r.charAt(0)!=="?"&&(r=`?${r}`)):o.length>0&&(r=`?${o}`)}const s=t.location;let i=e.alias??e.fullPath;i.startsWith("default")&&(i=i.substring(pr.length+1));let n;return r?this.mode=="path"?i.indexOf("/")===0?n=`${this.base}${i}${r}`:n=`${this.base}/${i}${r}`:n=`${s.pathname}${r}#${i}`:this.mode=="path"?i.indexOf("/")===0?n=`${this.base}${i}`:n=`${this.base}/${i}`:n=`${s.pathname}#${i}`,`${s.origin}${n}`}};function zs(e=!0,t=null,r="",s=!0,i=!1,n){return t!==null&&(t=j().location.pathname),t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),new Fr("path",t??"",r,e,s,i,n)}function Cr(e=!0,t="",r=!0,s=!1,i){return new Fr("hash","",t,e,r,s,i)}var Gs=class{maxSize=50;cursor=-1;queue=[];changeHandler;base;historyMonitor=!1;traceless=!1;constructor(e,t=50){this.base=e,this.maxSize=t}init(e=!0){return Promise.resolve()}destroy(){this.queue=[]}beforeRestoreEach(e){}removeBeforeRestoreEach(e){return!1}listen(e){this.changeHandler=e}[ge](e){typeof this.changeHandler=="function"&&this.changeHandler(e)}go(e,t=!1){if(this.queue.length==0||this.cursor<=0)return;let r=this.cursor+e;if(r<0?r=0:r>this.queue.length-1&&(r=this.queue.length-1),r!=this.cursor){this.cursor=r;let s=!1;if(typeof t=="function"?s=t():s=t,!s){const i=this.queue[r];this[ge](i.routes)}}}goBack(e,t){if(this.queue.length==0||this.cursor<=0)return;let r=0;if(e===null)r=this.cursor+1;else for(let s=this.cursor;s>=0;s--){const i=this.queue[s];if(P.isSame(i.currentRoute,e))break;r++}if(r===0){t();return}this.go(-r,()=>(t(),!0))}setRouteMark(e){}push(e){this.queue.length>=this.maxSize&&this.queue.splice(0,1),this.queue.push(e),this.cursor=this.queue.length-1}replace(e){let t=this.queue.length-this.cursor;this.queue.splice(this.cursor,t),this.queue[this.cursor]=e}setRestorePoint(e){}};function _r(e="",t=50){return new Gs(e,t)}function Bi(e){}var tt=Symbol("_constructRouteModel"),rt=Symbol("_findRouteModel"),Lt=Symbol("_findRootView"),Xs=Symbol("_getFirstView"),ce=Symbol("_removeView"),Ar=Symbol("_buildPage"),jr=Symbol("_resolveComponent"),qr=Symbol("_update"),se=Symbol("_merge"),Tt=Symbol("_handleHistoryChange"),he=Symbol("_handleRouteUpdated"),st=Symbol("routeUpdatedCallback"),Mt=Symbol("currentRoute"),b=Symbol("currentRoutes"),it=Symbol("routeSessionCacheKey"),Kr=Symbol("_addRouteRecorder"),Le=Symbol("_removeRouteRecorder"),nt=Symbol("_cloneRouteRecorder"),$=Symbol("_handleError"),ot=Symbol("errorCallback"),N=Symbol("registerKey"),lt=Symbol("notFoundKey"),kt=Symbol("notFoundPathKey"),G=Symbol("forestKey"),E=Symbol("historyKey"),Te=Symbol("beforeFiltersKey"),Me=Symbol("afterFiltersKey"),ke=Symbol("destroyFiltersKey"),It=Symbol("propsFilterKey"),be=Symbol("mainDispatcherKey"),Ot=Symbol("initKey"),ye=Symbol("readyKey"),Bt=Symbol("readyHandlersKey"),at=Symbol("_markReady"),$r=Symbol("_createNextFn"),Dt=Symbol("_start"),Ht=Symbol("_before"),Nt=Symbol("_after"),Lr=Symbol("_destroy"),Ut=Symbol("_load"),Ie=Symbol("_unload"),Oe=Symbol("routerGuardKey");function Qs(e){return e.layers.length==0||e.layers[0].views.length==0}var Tr=class{[N]=new Array;[lt];[kt]="*";[ye]=!1;[Bt]=[];[G]=new Vs;[E];[b]=new Array;[Mt]=(0,v.shallowRef)(null);[it]=new WeakMap;[ot]=null;[st]=null;[Te]=new Array;[Me]=new Array;[ke]=new Array;[It]=null;[be]=new qe;[Oe]=new Js;[Ot]=!1;get currentRoute(){return(0,v.readonly)(this[Mt])}options;constructor(e){this.options=e??{},this.options.notFoundPath&&this.setNotFoundPath(this.options.notFoundPath);let t=this.options.routes||[];this.addRoutes(t),this.options.notFound&&this.setNotFoundRoute(this.options.notFound),e.history?this[E]=e.history:this[E]=me?Cr():_r(),this[E]?.listen(async r=>{let s=!0;try{if(typeof r=="string"){const i=this[M](r);i&&await this[Tt]([i])}else await this[Tt](r)}catch(i){console.error(i.message,i),s=!1}this[ye]===!1&&this[at](s)})}[$](e="error",t){if(t&&typeof t.error=="function")try{t.error(e)}catch{}if(typeof this[ot]=="function")try{this[ot](e,t)}catch{}console.error(e)}init(){this[Ot]!==!0&&(this[E]?.init(!this[ye]),this[Ot]=!0)}isReady(){return this[ye]?Promise.resolve():new Promise((e,t)=>{this[Bt].push([e,t])})}[at](e){this[ye]=!0,this[Bt].forEach(([t,r])=>{try{e?t():r()}catch(s){console.error(s.message,s)}})}[Tt](e){try{if(!e){let n=[...this[b]].reverse();return this[Ie](n),me&&j().location.reload(),Promise.resolve()}let t=null,r=[],s=[],i=0;for(;i<e.length&&i<this[b].length&&P.isSame(e[i],this[b][i]);i++)e[i].active===!0&&e[i].active!==this[b][i].active&&(t=e[i]);if(i<e.length&&(r=e.slice(i)),i<this[b].length&&(s=this[b].slice(i).reverse()),s.length===0&&r.length===0){if(t!==null)return this.restore([t])}else if(s.length>0){if(this[Ie](s)){if(r.length>0)return this.restore(r);if(t!==null)return this.restore([t])}}else return this.restore(r)}catch(t){this[$](t)}return Promise.resolve()}[he](e=null){if(this[Mt].value=e,typeof this[st]=="function")try{this[st](e)}catch{}}[Kr](e,t){if(e.opsType===_.Open){let r=!1;const s=this[b].length-1;for(let i=s;i>=0;i--){const n=this[b][i];if(e.root==n.root){if(e.path===n.path){this[b].splice(i,1,e),r=!0;continue}e.active&&(n.active=!1)}}r||this[b].push(e)}else this[b].push(e);this[it].set(e,t),this[he](e)}[nt](){let e=[];for(let t of this[b]){let r=P.clone(t,!0);e.push(r)}return e}[Le](e){if(!this[b]){this[he](null);return}let t=-1;for(let r=0;r<this[b].length;r++)if(P.isSame(this[b][r],e)){t=r;break}if(t!=-1){const r=this[b][t];this[b].splice(t,1);const s=this[it].get(r);if(this[it].delete(r),this[Lr](r,s),r.opsType===_.Append){const i=this[b].length-1;this[he](this[b][i]??null)}else this[he](null)}else this[he](null)}set historyMonitor(e){this[E]&&(this[E].historyMonitor=e)}get historyMonitor(){return this[E]?this[E].historyMonitor:!1}set traceless(e){this[E]&&(this[E].traceless=e)}get traceless(){return this[E]?this[E].traceless:!1}set propsFilter(e){this[It]=e}get propsFilter(){return this[It]}setRestorePoint(){const e=this[nt]();this[E]?.setRestorePoint(e)}onRouteUpdated(e){this[st]=e}onError(e){this[ot]=e}beforeEach(e){this[Te].push(e)}removeBeforeEach(e){const t=this[Te].indexOf(e);return t!==-1?(this[Te].splice(t,1),!0):!1}afterEach(e){this[Me].push(e)}removeAfterEach(e){const t=this[Me].indexOf(e);return t!==-1?(this[Me].splice(t,1),!0):!1}destroyEach(e){this[ke].push(e)}removeDestroyEach(e){const t=this[ke].indexOf(e);return t!==-1?(this[ke].splice(t,1),!0):!1}beforeRestoreEach(e){this[E]?.beforeRestoreEach(e)}removeBeforeRestoreEach(e){return this[E]?.removeBeforeRestoreEach(e)??!1}addRoutes(e){for(let t of e)this.addRoute(t)}addRoute(e,t=-1){if(e.path===this[kt]){this.setNotFoundRoute(e);return}const r=this[tt](e);if(t==-1)this[N]=[...this[N],...r];else for(let s=r.length-1;s>=0;s--)this[N].splice(t,0,r[s])}removeRoute(e){const t=this[M](e);if(t===null)return console.warn("[Fox]route格式错误",e),!1;for(let r=0;r<this[N].length;r++){const s=this[N][r];if(t?.path&&s.path===t.path)return this[N].splice(r,1),!0;if(t?.name&&s.name===t.name)return this[N].splice(r,1),!0}return!1}hasRoute(e){const t=this[M](e);return t===null?(console.warn("[Fox]route格式错误",e),!1):this[N].findIndex(r=>{if(t?.path&&r.path===t.path||t?.name&&r.name===t.name)return!0})!==-1}setNotFoundPath(e){this[kt]=e}setNotFoundRoute(e){this[lt]=this[tt](e)[0]}getRoutes(){return[...this[N]]}[tt](e){let t=e.path??"";t.length>0&&t.charAt(0)!=="/"&&(t=`/${t}`);let r=e.components??(e.component&&{"":e.component});if(!r){const u=new _t;return u.path=t,u.redirect=e.redirect,[u]}const s=new P;s.path=t,s.name=e.name,s.meta=e.meta;let i=[];for(let u in r){const l=r[u];u.length===0&&(u=pr);const a=new Us(u,l,e.props);i.push(a)}let n=!1,o=[];if(e.children)for(let u of e.children){const l=this[tt](u);for(let a of l){let f=new _t;f.name=a.name,a.path&&a.path.length>0?t!=="/"?f.path=`${t}${a.path}`:f.path=a.path:(n=!0,f.path=t);let c=new wr;c.models=[...i],f.layers=[c,...a.layers],f.matchedRoutes=[s,...a.matchedRoutes??[]],o.push(f)}}if(!n){const u=new wr;u.models=i;const l=new _t;l.name=e.name,l.path=t,l.matchedRoutes=[s],l.layers=[u],o.splice(0,0,l)}return o}[rt](e){const t=e.route;try{for(let r of this[N]){const s=t.path?t.template??t.path:null,i=t.name?t.template??t.name:null;if(s&&r.path){let n=r.match;n||(n=r.match=Ds(r.path));const o=n(s);if(!o)continue;if(r.redirect){const u=new P;q(!0,u,t),u.path=r.redirect;const l={route:u,find:void 0};return this[rt](l)?(e.route=l.route,e.find=l.find,t.template&&e.find&&(e.find={...e.find},e.find.path=t.path),!0):!1}if(t.params=t.params??{},q(!0,t.params,o.params),t.query){const u=t.query;if(typeof u=="string"){const l={},a=u.split("&");for(let f of a){const c=f.split("=");if(c.length!==2)continue;const h=decodeURIComponent(c[0].trim());l[h]=decodeURIComponent(c[1].trim())}q(!0,t.params,l)}else typeof u=="object"&&q(!0,t.params,u)}return e.find=r,t.template&&e.find&&(e.find={...e.find},e.find.path=t.path),!0}else if(i===r.name)return e.find=r,t.template&&e.find&&(e.find={...e.find},e.find.name=t.name),!0}}catch(r){console.error(r.message,r),typeof t.error=="function"&&t.error(r.message)}return!1}[M](e){let t=null;if(Array.isArray(e))if(t=new P,typeof e[0]=="object")t=P.from(e[0]);else for(let r=0;r<e.length;r++)r===0?e[r].charAt(0)==="/"?t.path=e[r]:t.name=e[r]:r===1?t.params=e[r]:r===2?t.root=e[r]:r===3&&q(!1,t,e[r]);else typeof e=="object"?t=P.from(e):typeof e=="string"&&(t=new P,e.charAt(0)=="/"?t.path=e:t.name=e);if(t){if(t.path){let r=t.path.indexOf("?");r!==-1&&r<t.path.length-1&&(t.query=t.path.substring(r+1),t.path=t.path.substring(0,r))}t.root=t.root??"default",t.opsType=t.opsType??this.options.defaultOperationType??_.Push,t.traceless&&!t.historyUpdatePolicy&&(t.historyUpdatePolicy="traceless")}return t}push(...e){const t=this[M](e);return t?(t.opsType=_.Push,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[$]("resolve route fail",t),this)}put(...e){const t=this[M](e);return t?(t.opsType=_.Put,t.historyUpdatePolicy=t.historyUpdatePolicy??"traceless",this.to(t)):(this[$]("resolve route fail",t),this)}replace(...e){const t=this[M](e);return t?(t.opsType=_.Replace,t.historyUpdatePolicy=t.historyUpdatePolicy??"replace",this.to(t)):(this[$]("resolve route fail",t),this)}append(...e){const t=this[M](e);return t?(t.opsType=_.Append,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[$]("resolve route fail",t),this)}remove(e,t){return new Promise(r=>{this[be].post(s=>{try{if(this[b].length===0){s.resolve(),r(!1);return}let i=-1,n=null,o=[];if(e){if(n=e.root??"default",e.all)for(let l=this[b].length-1;l>0;l--){const a=this[b][l];if(a.opsType===_.Append){const f=a.root??"default";if(n&&n!==f)continue;o.splice(0,0,a),i=l-1}}else if(e.until)for(let l=this[b].length-1;l>0;l--){let a=this[b][l];if(a.opsType===_.Append&&a.root===n){if(e.until.charAt(0)==="/"&&e.until===a.path){i=l;break}else if(e.until===a.name){i=l;break}o.splice(0,0,a)}}else if(e.to)for(let l=this[b].length-1;l>0;l--){const a=this[b][l];if(a.opsType===_.Append){const f=a.root??"default";if(n&&n!==f)continue;if(o.splice(0,0,a),e.to.charAt(0)==="/"&&e.to===a.path){i=l-1;break}else if(e.to===a.name){i=l-1;break}}}}else for(let l=this[b].length-1;l>0;l--){let a=this[b][l];if(a.opsType===_.Append){o.push(a),i=l-1;break}}if(i===-1||o.length===0){const l="[Fox]can not find route";console.warn(l),s.resolve(l),r(!1);return}let u=null;if(i!==-1&&(u=this[b][i]),this[Ie](o)){if(t===!1)return s.resolve(),r(!0),!0;const l=()=>(s.resolve(),r(!0),!0),a=this[b].length;if(u&&P.isSame(u,this[b][a-1])){this[E]?.goBack(u,l);return}l()}}catch(i){this[$](i),s.resolve(),r(!1)}})})}open(...e){const t=this[M](e);return t?(t.opsType=_.Open,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[$]("resolve route fail",t),this)}close(e){return this[be].post(t=>{try{let r=this[M](e);if(!r){t.reject("resolve route fail");return}let s=[];for(let i=0;i<this[b].length;i++){let n=this[b][i];if(n.root===r.root){if(!r.path&&!r.name){s.push(n);continue}if(r.path&&r.path===n.path){s.push(n);break}else if(r.name&&r.name===n.name){s.push(n);break}}}if(s.length===0){t.resolve();return}this[Ie](s),t.resolve()}catch(r){this[$](r),t.resolve()}}),this}to(...e){const t=this[M](e);if(!t)return this[$]("resolve route fail",t),this;const r=this[Oe].acquire(t);return r==null?(this[$]("route forbid",t),this):(this[be].post(s=>{try{let i=this[Dt](t);this[Ht](i),this[Ut](i),this[Nt](i),i.wait((n,o)=>{const u=n.session.to;if(n.session.updateResult&&n.session.updateResult.status==="success")try{const l=new Rr(P.clone(u,!0),this[nt]());u.historyUpdatePolicy==="replace"?this[E]?.replace(l):u.historyUpdatePolicy==="traceless"?this[E]?.setRouteMark(l):this[E]?.push(l)}catch(l){console.error(l.message,l)}if(Xe.clear(n.session),this[Oe].release(r),typeof t.success=="function")try{Reflect.apply(t.success,{},[])}catch(l){console.error(l.message,l)}this[ye]===!1&&this[at](!0),i=null,s.resolve()},(n,o)=>{this[Oe].release(r),o!==null&&this[$](o,t),this[ye]===!1&&this[at](!1),Xe.clear(n.session),i=null,s.resolve()})}catch(i){this[Oe].release(r),this[$](i,t),s.resolve()}}),this)}back(e=1){this[E]?.go(-e,!1)}[$r](e){return(t,r)=>{if(typeof t=="boolean")e.session.redirect=!1,t?e.resolve():e.reject(r??null);else if(t){const s=this[M](t);if(s){const i=e.session.to;s.success=i.success,s.error=i.error,e.session.to=s,e.session.redirect=!0,e.session.routeModel=null,e.resolve()}else e.session.redirect=!1,e.reject("route resolve fail")}else e.session.redirect=!1,e.resolve()}}[Dt](e){const t=new Xe(e,this[b].length>0?this[b][this[b].length-1]:void 0),r={route:e,find:null};if(this[rt](r),r.find){t.routeModel=r.find,e.matched=r.find.matchedRoutes??[];const s={};if(Array.isArray(r.find?.matchedRoutes))for(let i=0;i<r.find.matchedRoutes.length;i++){const n=r.find.matchedRoutes[i];n.meta&&typeof n.meta=="object"&&Object.assign(s,n.meta)}e.meta&&typeof e.meta=="object"&&Object.assign(s,e.meta),e.meta=s}return new qe(t)}[Ht](e){for(let t of this[Te])e.post(r=>{const s=this[$r](r);Reflect.apply(t,{},[r.session.to,r.session.from,s,r.session])})}[Nt](e){e.post(t=>{for(let r of this[Me])try{Reflect.apply(r,{},[t.session.to,t.session.from,t.session])}catch(s){console.error(s.message,s)}t.resolve()})}[Lr](e,t){for(let r of this[ke])try{Reflect.apply(r,{},[e,t])}catch(s){console.error(s.message,s)}typeof e.destroy=="function"&&Reflect.apply(e.destroy,e,[])}[Ut](e){e.post(t=>{const r=t.session.to;let s=t.session.routeModel;if(s==null){let n={route:r,find:null};if(this[rt](n))s=n.find,t.session.routeModel=s;else if(this[lt])s=this[lt];else{t.reject(`not find route model, path:${r.path??r.name}`);return}}const i=Xe.from(t.session);this[Ar](r,s,i).then(n=>{this[G],t.session.updateResult=n??{status:"success",message:""},t.resolve()},n=>{t.reject(n)})})}[Ie](e){if(e.length==0)return!0;let t=this[G],r=[];for(let s of e){let i=this[Lt](t,s);i!=null&&r.push({...i,route:s})}if(r.length==0)return this[$]("can not find view index"),!1;for(let s of r.reverse())this[ce](t,{x:s.x,y:s.y},[s.route.index??0],!0);return!0}[Lt](e,t){const r=t.root??"default";let s;for(let i=0;i<e.layers.length;i++){const n=e.layers[i];for(let o=n.views.length-1;o>=0;o--){const u=n.views[o];if(u[J]&&u[Qe]===r)return s={x:o,y:i},s}}return null}[Xs](e){return e.layers.length>0&&e.layers[0].views.length>0?e.layers[0].views[0]:null}[ce](e,t,r=null,s=!0){if(t.y>=e.layers.length||t.x>=e.layers[t.y].views.length)return;let i=e.layers[t.y].views[t.x],n=!1,o=[],u=!1,l=[...i.slots.value];for(let f=l.length-1;f>=0;f--){let c=l[f];(!r||r.indexOf(c.index)!=-1)&&(c.route&&i[J]&&(this[Le](c.route),c.active===!0&&c.route.opsType==_.Append&&(u=!0)),o.push(new D(i,c.index,t.y)),l.splice(f,1))}if(l.length==0)s?i.slots.value=l:e.layers[t.y].views.splice(t.x,1);else{if(u){let f=l[l.length-1];f.active=!0,f.route&&(f.route.active=f.active)}i.slots.value=l}e.layers[t.y].views.length==0&&(n=!0);let a=t.y+1;for(;a<e.layers.length;a++){let f=e.layers[a].views,c=[];for(let h=f.length-1;(n||o.length>0)&&h>=0;h--){let y=f[h];if(y[ae]&&(n||D.include(o,y[ae]))){let d=y.slots.value;for(let p=d.length-1;p>=0;p--){let R=d[p];R.route&&y[J]&&this[Le](R.route),c.push(new D(y,R.index,a)),d.splice(p,1)}e.layers[a].views.splice(h,1)}}o=c,e.layers[a].views.length==0&&(n=!0)}}restore(e){if(!e||this[N].length==0){let t=this[G];if(t.layers.length>0){let r=t.layers[0].views;r.length>0&&(r[0].slots.value=[])}return this[b]=[],this[he](null),Promise.resolve()}else return new Promise((t,r)=>{let s=null,i=!1;for(let n=0;n<e.length;n++){const o=e[n];this[be].post(u=>{const l=this[Dt](o);this[Ht](l),this[Ut](l),this[Nt](l),l.wait((a,f)=>{s=a.session.to,i=a.session.redirect,u.resolve()},(a,f)=>{s=null,f!==null&&this[$](f),u.resolve()})})}this[be].post(n=>{if(s&&i===!0){const o=new Rr(P.clone(s,!0),this[nt]());this[E]?.replace(o)}n.resolve(),t()})})}async[Ar](e,t,r){const s=e.updateType??At.Part;await this[jr](t);const i=this[qr](t,e,r,s);if(i.status==="error")throw Error(i.message);return i}[jr](e){let t=[];for(let r=0;r<e.layers.length;r++){let s=e.layers[r];for(let i=0;i<s.models.length;i++){let n=s.models[i];n.isResolved||t.push(n.resolve())}}return t.length>0?Promise.all(t):Promise.resolve()}[qr](e,t,r,s){if(e.layers[0].models.length!==1)return{status:"error",message:"illegal route structure(multi root node)"};const i=e.layers[0].models[0];let n=this[G],o=Qs(n),u=t.root??"default",l;!o&&s==At.Part&&(l=this[Lt](n,t));let a,f=0;if(l==null||l==null)if(o||s===At.All)n.layers.length==0&&(n.layers[0]=new jt),n.layers[0].views.length==0?(a=new Ae(t.root??"default",!0,null),n.layers[0].views=[a]):a=n.layers[0].views[0],l={x:0,y:0};else{let c=t.slot;if(!c)return{status:"error",message:"can not rebuild view(because not route slot)"};let h=c.level;if(h>n.layers.length)return{status:"error",message:"can not insert view(override level)"};let y;if(c.rootName){let d=n.layers[h-1];for(let p of d.views){if(p[J]&&p.name===c.rootName){y=new D(p,c.rootIndex??0,h-1);break}if(p[z]&&p[z].view.name===c.rootName&&p[z].index===c.rootIndex){y=p[z];break}}}if(!y)return{status:"error",message:"can not insert view(not find root node ref)"};a=new Ae(u,!0,y),n.layers[h].views.push(a),l={x:n.layers[h].views.length-1,y:h}}else a=n.layers[l.y].views[l.x];if(f=l.y,a[J]=!0,t.opsType===_.Append){t.index=t.index??Fe.get(),t.active=!0;let c=a.slots.value;if(c.length>0){let R=c[c.length-1];R.active=!1,R.route&&(R.route.active=R.active)}let h=new re(t,i,t.index,!0);a.slots.value=[...c,h];let y=f+1,d=1,p=new D(a,t.index,f);this[se](n,y,e,d,p)}else if(t.opsType===_.Open){let c=a.slots.value;const h=t.active??!0;let y=!1;for(let d of c){if(d.route!==null&&P.isSamePathForRoute(d.route,t)){if(d.active===h)return t.index=d.index,t.active=h,d.route=t,{status:"noChange",message:""};d.active=h,y=!0,t.index=d.index,t.active=h,d.route=t}else h&&(d.active=!1);d.route&&(d.route.active=d.active)}if(!y){t.index=t.index??Fe.get(),t.active=h;let d=new re(t,i,t.index,h);c.push(d);let p=f+1,R=1,w=new D(a,t.index,f);this[se](n,p,e,R,w)}a.slots.value=[...c]}else{let c=a.slots.value;if(c.length==0){t.index=t.index??Fe.get(),t.active=!0,a.slots.value=[new re(t,i,t.index)];let h=f+1,y=1,d=new D(a,t.index,f);this[se](n,h,e,y,d)}else{let h=c[0];if(h.model!==i){this[ce](n,l,null,!0),t.index=t.index??Fe.get(),t.active=!0,a.slots.value=[new re(t,i,t.index)];let y=f+1,d=1,p=new D(a,t.index,f);this[se](n,y,e,d,p)}else{h.route!==null&&this[Le](h.route);let y=!1;const d=t.active??!0;h.active!==d&&(h.active=d,y=!0),t.active=d,t.index=h.index,h.route=t;let p=[];for(let I=1;I<c.length;I++)p.push(c[I].index);p.length>0?this[ce](n,l,p,!0):y&&(a.slots.value=[...c]);let R=[new D(a,t.index,f)],w=f+1,g=1,T=new D(a,t.index,f);for(;R.length>0&&w<n.layers.length&&g<e.layers.length;w++,g++){let I=[];for(let O=0;O<n.layers[w].views.length;O++){let L=n.layers[w].views[O];L[ae]&&D.include(R,L[ae])&&I.unshift(O)}let Ne=[];for(let O of I){let L=n.layers[w].views[O],de=e.layers[g].models,te;for(let B=0;B<de.length;B++)if(L.name===de[B].name){te=de[B];break}if(!te)this[ce](n,{x:O,y:w},null,!1);else{let B=L.slots.value;if(B.length==0){let ee=0;L.slots.value=[new re(null,te,ee)];let X=w+1,Q=g+1;this[se](n,X,e,Q,T)}else{let ee=B[0];if(ee.model!==te){this[ce](n,{x:O,y:w},null,!0),L.slots.value=[new re(null,te,0)];let X=w+1,Q=g+1;this[se](n,X,e,Q,T)}else{L[J]&&ee.route!==null&&this[Le](ee.route);let X=[];for(let Q=1;Q<B.length;Q++)X.push(B[Q].index);X.length>0&&this[ce](n,{x:O,y:w},X,!0),Ne.push(new D(L,ee.index,w))}}L[J]=!1}}R=Ne}this[se](n,w,e,g,T)}}}if(a&&a[z]){let c=a[z];c&&(t.slot=new Ns(u,f,c?.view.name,c?.index??0))}return r.to=void 0,r.routeModel=void 0,this[Kr](t,r),{status:"success",message:""}}[se](e,t,r,s,i){let n=s,o=t;for(;o<e.layers.length&&n<r.layers.length;o++,n++){let u=e.layers[o].views;for(let l of r.layers[n].models){let a=new Ae(l.name,!1,i),f=new re(null,l);a.slots.value=[f],u.push(a)}}for(;n<r.layers.length;n++){let u=new jt;u.views=[];for(let l of r.layers[n].models){let a=new Ae(l.name,!1,i),f=new re(null,l);a.slots.value=[f],u.views.push(a)}e.layers.push(u)}}[gr](e,t,r,s,i,n){if(t<0||t>this[G].layers.length)return null;if(t<this[G].layers.length){let a=this[G].layers[t],f=null;for(let c of a.views){let h=!1;if(r!==null?(h=c.name===e&&c[z]?.view===r,h&&s!==-1&&(h=c[z]?.index===s)):h=c.name===e,!!h){i!==null&&(c[ae]={view:i,index:n,level:t-1}),f=c;break}}if(f!==null)return f}let o=null,u=null;i!==null&&(i[J]?o={view:i,index:n,level:t-1}:o=i[z],u={view:i,index:n,level:t-1});let l=new Ae(e,!0,o);if(l[ae]=u,t==this[G].layers.length){let a=new jt;a.views=[l],this[G].layers.push(a)}else this[G].layers[t].views.push(l);return l}},ut=Symbol("rk"),Vt=Symbol("vd"),Mr=Symbol("rv"),Wt=Symbol("rvi"),kr=Symbol("pv"),Jt=Symbol("pvi"),Be=Symbol("registerKey"),Ir=Symbol("lc"),Zs=class{[Be]=new Map;constructor(){}set(e,t){this[Be].set(e,t)}get(e){return this[Be].get(e)}has(e){return this[Be].has(e)}delete(e){return this[Be].delete(e)}},ie=new WeakMap,De=[];function ft(e,t=!1){let r=e?ie.get(e)??null:null;return t&&!r&&(r=new Zs,e&&ie.set(e,r),(0,v.onScopeDispose)(()=>{e&&ie.delete(e)}),(0,v.provide)(Ir,r)),r}function He(e){let t=e?ie.get(e)??null:null;return!t&&(0,v.hasInjectionContext)()&&(t=(0,v.inject)(Ir,null)),!t&&De.length>0&&(t=De[De.length-1]),t}async function Or(e,t){De.push(e);try{return await t()}finally{De.pop()}}function Ys(e){const t=(0,v.getCurrentScope)();if(!t)return!1;const r=He();if(!r)return!1;if(ie.set(t,r),Array.isArray(e))for(let s=0;s<e.length;s++)ie.set(e[s],r);return(0,v.onScopeDispose)(()=>{if(ie.delete(t),Array.isArray(e))for(let s=0;s<e.length;s++)ie.delete(e[s])}),!0}function zt(e,t){return He(e)?.get(t)??null}function ei(e,t,r,s){He(e)?.set(t,r)}function ti(e,t,r){He(e)?.delete(t)}var ct=Symbol("hooksKey");function ri(e){let t=e.get(ct);t||(t=[],e.set(ct,t))}function Br(e,t){const r=e.get(ct);r!=null&&Or(e,async()=>{for(let s=r.length-1;s>=0;s--){let i=r[s];if(i.type===t)try{await Reflect.apply(i.hook,null,[])}catch(n){console.error(n.message,n)}}})}var ht=(function(e){return e.INACTIVATED="ia",e.ACTIVATED="a",e})({}),si=class{type;hook;constructor(e,t){this.hook=t,this.type=e}};function ii(e,t,r){const s=new si(t,r);return e.push(s),!0}function ni(e,t,r){let s=-1;for(let i=0;i<e.length;i++){const n=e[i];if(n.type===t&&n.hook===r){s=i;break}}return s!=-1?(e.splice(s,1),!0):!1}function Dr(e){return t=>{const r=zt(null,ct);if(r==null){console.warn("[Fox]hooks context not found");return}(0,v.onScopeDispose)(()=>{ni(r,e,t)}),ii(r,e,t)}}var oi=function(e){(0,v.onActivated)(e),Dr(ht.ACTIVATED)(e)},li=function(e){(0,v.onDeactivated)(e),Dr(ht.INACTIVATED)(e)},Hr=Symbol("routeKey");function Nr(e,t){e.set(Hr,t)}function Ur(e){const t=zt(e??null,Hr);return typeof t=="function"?t():t}var Vr="FoxBeforeEnter",Wr="FoxEnter",Jr="FoxLeave",zr="FoxLeave",yt="FoxLeaveEnd";function Gr(e,t=!1){let r=null;return t?r=e.showFromClass??e.enterFromClass:r=e.enterFromClass,r||(r=e.transitionName,r?t?`${r}-show-from`:`${r}-enter-from`:null)}function Xr(e,t=!1){let r=null;return t?r=e.showActiveClass??e.enterActiveClass:r=e.enterActiveClass,r||(r=e.transitionName,r?t?`${r}-show-active`:`${r}-enter-active`:null)}function ai(e,t=!1){let r=null;return t?r=e.showToClass??e.enterToClass:r=e.enterToClass,r||(r=e.transitionName,r?t?`${r}-show-to`:`${r}-enter-to`:null)}function Qr(e,t=!1){let r=null;return t?r=e.hideFromClass??e.leaveFromClass:r=e.leaveFromClass,r||(r=e.transitionName,r?t?`${r}-hide-from`:`${r}-leave-from`:null)}function Zr(e,t=!1){let r=null;return t?r=e.hideActiveClass??e.leaveActiveClass:r=e.leaveActiveClass,r||(r=e.transitionName,r?t?`${r}-hide-active`:`${r}-leave-active`:null)}function ui(e,t=!1){let r=null;return t?r=e.hideToClass??e.leaveToClass:r=e.leaveToClass,r||(r=e.transitionName,r?t?`${r}-hide-to`:`${r}-leave-to`:null)}function fi(e,t=!1){let r=null;return t?r=e.beforeShow??e.beforeEnter:r=e.beforeEnter,r}function ci(e,t=!1){let r=null;return t?r=e.show??e.enter:r=e.enter,r}function hi(e,t=!1){let r=null;return t?r=e.afterShow??e.afterEnter:r=e.afterEnter,r}function yi(e,t=!1){let r=null;return t?r=e.showCancelled??e.enterCancelled:r=e.enterCancelled,r}function di(e,t=!1){let r=null;return t?r=e.beforeHide??e.beforeLeave:r=e.beforeLeave,r}function mi(e,t=!1){let r=null;return t?r=e.hide??e.leave:r=e.leave,r}function vi(e,t=!1){let r=null;return t?r=e.afterHide??e.afterLeave:r=e.afterLeave,r}function pi(e,t=!1){let r=null;return t?r=e.hideCancelled??e.leaveCancelled:r=e.leaveCancelled,r}function Gt(e){let t,r=e.transitionDuration;return typeof r=="object"?t={enter:r.enter??-1,leave:r.leave??-1,show:r.show??-1,hide:r.hide??-1}:(typeof r=="string"&&(r=r.length==0?-1:Number(r)),t={enter:r,leave:r,show:r,hide:r}),t}function we(e,t){e.classList.contains(t)||e.classList.add(t)}function Re(e,t){e.classList.remove(t)}var gi=me&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout;function dt(e){gi(e)}function K(e,t){S(e)&&Reflect.apply(e,null,t)}function Yr(e,t,r=-1,s,i,n){let o=[];const u=()=>{for(let l of o)gt(e,l.type,l.listener);o=[]};if(S(i)){if(s!==void 0&&s>=0){setTimeout(()=>{Reflect.apply(i,null,[e,t,r])},s);return}const l=["animationend","transitionend",yt],a=f=>{(f.target||f.srcElement)===f.currentTarget&&(u(),Reflect.apply(i,null,[e,t,r]))};l.forEach(f=>{We(e,f,a),o.push({type:f,listener:a})})}if(S(n)){const l="animationcancel",a=f=>{(f.target||f.srcElement)===f.currentTarget&&(u(),Reflect.apply(n,null,[e,t,r]))};We(e,l,a),o.push({type:l,listener:a})}}function mt(e){return!me||e===null?!1:e.opsType===_.Append||e.opsType===_.Open}function es(e,t,r={},s,i=-1){if(e||mt(s)){const n=Gr(r,e);n&&we(t,n);const o=Xr(r,e);o&&we(t,o),K(fi(r,e),[t,e,s,i])}}function ts(e,t,r={},s,i,n,o){if(!mt(i)&&!e){S(o)&&o(o,[t]);return}const u=Gr(r,e),l=Xr(r,e),a=ai(r,e),f=ci(r,e),c=hi(r,e),h=yi(r,e);if(!u&&!l&&!a&&!f){S(o)&&o(o,[t]);return}dt(()=>{Yr(t,i,n,s,()=>{l&&Re(t,l),a&&Re(t,a),S(c)&&K(c,[t,e,i,n]),S(o)&&o(o,[t])},()=>{S(h)&&K(h,[t,e,i,n])}),u&&Re(t,u),a&&we(t,a),S(f)&&K(f,[t,e,i,n])})}function rs(e,t,r={},s,i=-1){if(e||mt(s)){const n=Qr(r,e);n&&we(t,n);const o=Zr(r,e);o&&we(t,o),K(di(r,e),[t,e,s,i])}}function ss(e,t,r={},s,i,n,o,u){if(!mt(n)&&!e){S(u)&&K(u,[t]),!e&&S(i)&&i();return}const l=Qr(r,e),a=Zr(r,e),f=ui(r,e),c=mi(r,e),h=vi(r,e),y=pi(r,e);if(!l&&!a&&!f&&!c){S(u)&&K(u,[t]),!e&&S(i)&&i();return}dt(()=>{Yr(t,n,o,s,()=>{try{a&&Re(t,a),f&&Re(t,f),S(h)&&K(h,[t,e,n,o]),S(u)&&K(u,[t])}finally{!e&&S(i)&&i()}},()=>{try{S(y)&&K(y,[t,e,n,o]),S(u)&&K(u,[t])}finally{!e&&S(i)&&i()}}),l&&Re(t,l),f&&we(t,f),S(c)&&K(c,[t,e,n,o])})}function Xt(e,t={},r,s=-1){const i=t.mode??"default",n=Gt(t);return{mode:i,persisted:!1,beforeEnter:o=>{es(!1,o,t,r,s)},enter:o=>{ts(!1,o,t,n.enter,r,s)},leave:(o,u)=>{rs(!1,o,t,r,s),ss(!1,o,t,n.leave,u,r,s,()=>{e.transition=null})},clone:o=>Xt(e,t,r,s)}}function is(e){return e.el}function bi(e,t={},r,s,i,n){if(i===!0){const o=is(e);if(o==null)return;const u=Gt(t);es(!0,o,t,r,s),ts(!0,o,t,u.show,r,s,l=>{S(n)&&K(n,[l])})}else S(n)&&K(n,[])}function wi(e,t={},r,s,i,n){if(i===!0){const o=is(e);if(o==null)return;const u=Gt(t);rs(!0,o,t,r,s),ss(!0,o,t,u.hide,null,r,s,l=>{S(n)&&K(n,[l])})}else S(n)&&K(n,[])}function Ri(e){dt(()=>{for(let t=0;t<e.length;t++)Reflect.apply(e[t],null,[])})}function ns(e,t={},r,s=-1){return{mode:t.mode??"default",persisted:!1,beforeEnter:i=>{Je(Vr,{},i)},enter:i=>{Je(Wr,{},i)},leave:(i,n)=>{Je(Jr,{},i),dt(()=>{const o=u=>{(u.target||u.srcElement)===u.currentTarget&&(gt(i,yt,o),n&&Reflect.apply(n,null,[]),e.transition=null)};We(i,yt,o),Je(zr,{},i)})},clone:i=>ns(e,t,r,s)}}function ne(e,t,r){return typeof e=="function"?Reflect.apply(e,{},[t,r]):e}function Qt(e,t){if(!e)return null;const r=e(t);return r.length===1?r[0]:r}function Se(e,t){return typeof t=="function"?t(e):e}var Si=class{node;state;constructor(e,t){this.node=e,this.state=t}},vt=(0,v.defineComponent)({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,required:!1,default:"default"},modelSlot:{type:[Object],required:!1},multi:{type:Boolean,required:!1,default:!1},tag:{type:[String,Object,Function],required:!1,default:"div"},viewTag:{type:[String,Object,Function],required:!1,default:"div"},viewTagProps:{type:[Object,Function],required:!1,default(){return{}}},viewClass:{type:[String,Function],required:!1},viewActiveClass:{type:[String,Function],required:!1},viewInactiveClass:{type:[String,Function],required:!1},transition:{type:[Boolean,String,Function],required:!1,default:!1},transitionName:{type:String,required:!1},transitionDuration:{type:[String,Number,Object],required:!1},enterFromClass:{type:String,required:!1},enterActiveClass:{type:String,required:!1},enterToClass:{type:String,required:!1},leaveFromClass:{type:String,required:!1},leaveActiveClass:{type:String,required:!1},leaveToClass:{type:String,required:!1},showFromClass:{type:String,required:!1},showActiveClass:{type:String,required:!1},showToClass:{type:String,required:!1},hideFromClass:{type:String,required:!1},hideActiveClass:{type:String,required:!1},hideToClass:{type:String,required:!1},beforeEnter:{type:Function,required:!1},enter:{type:Function,required:!1},afterEnter:{type:Function,required:!1},enterCancelled:{type:Function,required:!1},beforeLeave:{type:Function,required:!1},leave:{type:Function,required:!1},afterLeave:{type:Function,required:!1},leaveCancelled:{type:Function,required:!1},beforeShow:{type:Function,required:!1},show:{type:Function,required:!1},afterShow:{type:Function,required:!1},showCancelled:{type:Function,required:!1},beforeHide:{type:Function,required:!1},hide:{type:Function,required:!1},afterHide:{type:Function,required:!1},hideCancelled:{type:Function,required:!1}},setup(e,t){const r=(0,v.getCurrentScope)(),s=e.multi===!0,i=(0,v.inject)(ut,null),n=(0,v.inject)(Vt,0),o=(0,v.inject)(Mr,null),u=(0,v.inject)(Wt,-1);let l=null,a=e.modelSlot??null;if(a){if((0,v.provide)(Vt,n+1),(0,v.provide)(Wt,a.index),(0,v.provide)(Jt,a.index),!a.route){console.warn("[Fox]child view render error, route not exist");return}const c=ft(a,!0);c&&(ri(c),Nr(c,()=>a?.route??null))}else{if(i==null){console.error("[Fox]router is not been injected");return}const c=e.name,h=(0,v.inject)(kr,null),y=(0,v.inject)(Jt,0);if(l=i[gr](c,n,o,u,h,y),l===null)return;(0,v.provide)(kr,l);const d=l[J]===!0;if(d&&(0,v.provide)(Mr,l),!s&&((0,v.provide)(Wt,-1),(0,v.provide)(Vt,n+1),(0,v.provide)(Jt,-1),d&&r)){const p=ft(r,!0);p&&Nr(p,()=>{const R=l?.slots.value??[];return R.length>0?R[0].route:null})}}const f={value:new Map};return(0,v.onScopeDispose)(()=>{if(f.value&&f.value.clear(),a){const c=a;c.route=null,c.model=null,c.instance=null,a=null}}),()=>{if(s){const c=new Map,h=[],y=l?.slots.value,d=[];for(let w=0;w<y.length;w++){const g=y[w],T=`${e.name}_${g.index}`,I=ne(e.transition,g.route,w)??!0,Ne={modelSlot:g};let O;t.slots.default?O=(0,v.h)(vt,Ne,{default:t.slots.default}):O=(0,v.h)(vt,Ne);const L={},de=ne(e.viewClass,g.route,w);typeof de=="string"&&de.length>0&&(L[de]=!0);const te=ne(e.viewActiveClass,g.route,w),B=ne(e.viewInactiveClass,g.route,w),ee=f.value.get(T);if(typeof te=="string"&&te.length>0&&(L[te]=g.active),typeof B=="string"&&B.length>0&&(L[B]=!g.active),ee&&g.active!==ee.state){const hs=ee.node;g.active?d.unshift(()=>{const tr=()=>{const Ue=ft(g);Ue!=null&&Br(Ue,ht.ACTIVATED)};bi(hs,e,g.route,w,I,tr)}):d.push(()=>{const tr=()=>{const Ue=ft(g);Ue!=null&&Br(Ue,ht.INACTIVATED)};wi(hs,e,g.route,w,I,tr)})}const X={class:L,key:T},Q=ne(e.viewTagProps,g.route,w);Q!==null&&typeof Q=="object"&&q(!0,X,Se(Q,i?.propsFilter)),g.route?.viewTagAttrs&&typeof g.route?.viewTagAttrs=="object"&&q(!0,X,Se(g.route.viewTagAttrs,i?.propsFilter));const Ee=(0,v.h)(ne(e.viewTag,g.route,w),X,{default:()=>[O]});c.set(T,new Si(Ee,g.active)),f.value.delete(T),I===!0?Ee.transition=Xt(Ee,e,g.route,w):I==="custom"&&(Ee.transition=ns(Ee,e,g.route,w)),h.push(Ee)}f.value=c,Ri(d);const p=ne(e.tag,null,-1),R={};return Object.assign(R,t.attrs),(0,v.h)(p,R,{default:()=>h})}else if(a!=null){const c=a.model,h={};c.props&&(typeof c.props=="object"?q(!1,h,Se(c.props,i?.propsFilter)):c.props===!0&&typeof a.route?.params=="object"&&q(!1,h,Se(a.route.params,i?.propsFilter)));const y=(0,v.h)(c.component,h);return Qt(t.slots.default,{Component:y,route:a.route})??y}else{const c=l?.slots.value??[];if(c.length>0){const h=c[0],y=h.route,d=h.model,p={};d.props&&(typeof d.props=="object"?q(!1,p,Se(d.props,i?.propsFilter)):d.props===!0&&typeof y?.params=="object"&&q(!1,p,Se(y.params,i?.propsFilter)));const R=(0,v.h)(d.component,p);return(ne(e.transition,y,-1)??!0)&&(R.transition=Xt(R,e,y,-1)),Qt(t.slots.default,{Component:R,route:y})??R}else return Qt(t.slots.fallback,{})}}}});function xi(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!=null&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Pi(e,t){return e==null||t==null?!1:!!(e.path&&t.path&&t.path.startsWith(e.path)||e.name&&e.name==t.name)}function xe(e,t){return typeof e=="function"?Reflect.apply(e,{},[t]):e}var os=(0,v.defineComponent)({name:"RouterLink",inheritAttrs:!1,props:{tag:{type:[String,Object,Function],required:!1,default:"a"},to:{type:[String,Object,Function],required:!0},root:{type:String},activeClass:{type:[String,Function],required:!1,default:"fox-router-link-active"},exact:{type:[String,Boolean,Function],required:!1},exactActiveClass:{type:[String,Function],required:!1,default:"fox-router-link-exact-active"},event:{type:[String,Function],required:!1,default:"onClick"}},setup(e,t){const r=(0,v.inject)(ut,null);return()=>{let s=xe(e.to,null),i=xe(e.tag,s);if(i==null){console.warn("[Fox]can not resolve link tag");return}let n=null,o=null;r!==null&&(n=r[M](s),e.root&&(n.root=e.root),o=r.currentRoute.value);let u={},l=xe(e.activeClass,n);if(typeof l=="string"&&l.length>0&&(u[l]=Pi(n,o)),xe(e.exact,n)===!0){let c=xe(e.exactActiveClass,n);typeof c=="string"&&c.length>0&&(u[c]=P.isSamePathForRoute(n,o))}let a={class:u};(i==="a"||i==="A")&&(a.href=n?.path??n?.name??"#"),q(!0,a,t.attrs);const f=xe(e.event,n);if(typeof f=="string"){const c=h=>{if(r==null){console.warn("[Fox]router is not been injected");return}if(n==null){console.warn("[Fox]route is not been resolved");return}xi(h)&&r.to(n)};a[f]=c}return(0,v.h)(i,a,t.slots)}}}),pt=(function(e){return e[e.limitless=0]="limitless",e[e.once=1]="once",e})(pt||{}),Pe=Symbol("registerKey"),Ei=class{policy;callback;constructor(e,t){this.callback=e,this.policy=t}},Zt=class{[Pe]=new Map;constructor(){}on(e,t,r=!1){let s=this[Pe].get(e);s||(s=new Array,this[Pe].set(e,s));let i=new Ei(t,r===!0?pt.once:pt.limitless);return s.push(i),this}off(e,t){if(!t)return this[Pe].delete(e),this;let r=this[Pe].get(e);if(r){for(let s=0;s<r.length;s++)if(r[s].callback===t){r.splice(s,1);break}}return this}bind(e,t,r=!1){return this.on(e,t,r)}unbind(e,t){return this.off(e,t)}once(e,t){return this.on(e,t,!0)}all(...e){let t=e.length;if(t<1)return this;let r=e[t-1];if(typeof r!="function")return console.error("[Fox]callback can not be empty"),this;let s=t-1,i=new Array(s),n=[].splice.call(e,0,s);for(let o=0;o<n.length;o++)this.once(n[o],u=>{i[o]=u,s-=1,s==0&&Reflect.apply(r,{},i)});return this}emit(e,...t){let r=this[Pe].get(e);if(!r)return this;for(let s=0;s<r.length;){let i=r[s];if(i.policy==pt.once?r.splice(s,1):s++,typeof i.callback=="function")try{Ce(()=>{Reflect.apply(i.callback,{},t)})}catch(n){console.error(n.message,n)}}return this}trigger(e,...t){return Reflect.apply(this.emit,this,[e,...t])}},Fi="FoxRouterView",Ci="FoxRouterLink",U=(function(e){return e[e.Loading=0]="Loading",e[e.Loaded=1]="Loaded",e[e.Defining=2]="Defining",e[e.Defined=3]="Defined",e})({});function _i(e){return e==U.Loaded||e===U.Defined}var ls=(function(e){return e[e.normal=0]="normal",e[e.factory=1]="factory",e})({}),Ai=class{register=new Map;regExpRegisters=[];constructor(){}get(e){let t=this.register.get(e)??null;return t||(t=this.regExpRegisters.find(r=>r.pattern?.test(e))?.module??null),t}has(e){return!!this.get(e)}set(e,t){if(typeof e=="string")this.register.set(e,t);else if(e instanceof RegExp){const r=this.regExpRegisters.find(s=>(s.pattern?.source??"")===(e?.source??""));r?r.module=t:this.regExpRegisters.push({pattern:e,module:t})}}remove(e){if(typeof e=="string"){const t=this.register.get(e);return this.register.delete(e),t??null}else if(e instanceof RegExp){const t=this.regExpRegisters.findIndex(r=>(r.pattern?.source??"")===(e?.source??""));if(t!==-1){const r=this.regExpRegisters[t].module??null;return this.regExpRegisters.splice(t,1),r}}return null}clear(){this.register.clear(),this.regExpRegisters=[]}},Yt=["require","exports","module"];async function ji(e){return await new Function("url","return import(url)")(e)}var as=class{moduleManager=new Ai;_alias={};set alias(e){this._alias=e}get alias(){return this._alias}_resourceParser;set resourceParser(e){this._resourceParser=e}get resourceParser(){return this._resourceParser}_timeout;set timeout(e){this._timeout=e}get timeout(){return this._timeout}_query;set query(e){this._query=e}get query(){return this._query}get head(){return Ve().head}_cssMountPoint=null;set cssMountPoint(e){this._cssMountPoint=e}get cssMountPoint(){return this._cssMountPoint}_jsMountPoint=null;set jsMountPoint(e){this._jsMountPoint=e}get jsMountPoint(){return this._jsMountPoint}setModule(e,t){const r={id:typeof e=="string"?e:e?.source,src:"",status:U.Loaded};typeof t=="function"?(r.exports=t,r.type=ls.factory):r.exports=t,this.moduleManager.set(e,r)}removeModule(e){this.moduleManager.remove(e)}getModuleExports(e){const t=this.moduleManager.get(e);return t&&_i(t.status)?t.type===ls.factory&&typeof t.exports=="function"?t.exports():t.exports:null}exposeRequire(e="__foxRequire",t,r){const s=t??j();return s&&typeof s=="object"?(s[e]=i=>{const n=this.getModuleExports(i);return r&&!n&&console.error(`[Fox] module:${i}, not found!`),n},!0):!1}resloveResource(e){if(typeof e=="string"){if(Yt.includes(e))return e;if(e=this.alias?.[e]??e,typeof this.resourceParser=="function"){const r=this.resloveResource(e);if(!r)return r}const t=this.getResourcePathSuffix(e);if(t==="mjs")return{path:e,type:"js",format:"es"};if(t==="js")return{path:e,type:"js",format:"umd"};if(t==="css")return{path:e,type:"css"}}return e}ensure(...e){return new Promise((t,r)=>{if(e.length<=0){r("args is empty");return}const s=[];let i=e.length-1,n=null;typeof e[i]=="function"&&(n=e[i],i--);for(let l=0;l<=i;l++)if(Array.isArray(e[l])){const a=e[l];for(let f=0;f<a.length;f++){const c=this.resloveResource(a[f]);s.push(c)}}else if(typeof e[l]=="string"){const a=this.resloveResource(e[l]);s.push(a)}const o=new qi(s.length,(l,a)=>{if(o.isOK())try{typeof n=="function"&&Reflect.apply(n,{},a),t(a)}catch(f){console.error(f),r(f)}else try{console.error(l),typeof n=="function"&&Reflect.apply(n,{},[]),r(l)}catch(f){console.error(f),r(f)}}),u=new qe;for(let l=0;l<s.length;l++){const a=new Ki(l,s[l],o);this.mount(u,a)}return this})}remove(...e){return new Promise((t,r)=>{if(e.length<=0){r("args is empty");return}const s=[];let i=e.length-1,n=null;typeof e[i]=="function"&&(n=e[i],i--);for(let o=0;o<=i;o++)if(Array.isArray(e[o])){const u=e[o];for(let l=0;l<u.length;l++){const a=this.resloveResource(u[l]);s.push(a)}}else if(typeof e[o]=="string"){const u=this.resloveResource(e[o]);s.push(u)}for(let o=0;o<s.length;o++)try{this.unmount(s[o])}catch(u){console.error(u)}typeof n=="function"&&Reflect.apply(n,{},[!0]),t(!0)})}mount(e,t){if(!t.resource){e.post(s=>{t.progress.work(!1,t.index,null),s.resolve()});return}if(typeof t.resource=="string"){if(Yt.includes(t.resource)){e.post(i=>{t.progress.work(!0,t.index,t.resource),i.resolve()});return}const s=this.getModuleExports(t.resource);if(s){e.post(i=>{t.progress.work(!0,t.index,s),i.resolve()});return}}const r=t.resource;if(r.type==="js")if(r.format==="es")this.mountCJS(e,t);else{const s=this.jsMountPoint??this.head;this.mountJS(e,t,s)}else{const s=this.cssMountPoint??this.head;this.mountCSS(e,t,s)}}mountCSS(e,t,r){e.post(s=>{const i=t.resource,n=this.getModuleExports(i.path);if(n){t.progress.work(!0,t.index,n),s.resolve();return}const o=Ve(),u=o.createElement("link"),l="onload"in u;l&&(u.onload=()=>{u.onload=null,u.onerror=null,t.progress.work(!0,t.index,i.path),s.resolve()},u.onerror=()=>{try{r.removeChild(u)}catch(c){console.error(c)}u.onload=null,u.onerror=null,t.progress.work(!1,t.index,null),s.reject()});const a=this.constructResourceUri(i.path),f=o.getElementById(i.path);f&&f.parentNode&&f.parentNode.removeChild(f),u.rel="stylesheet",u.type="text/css",u.id=i.path,u.href=a,r.appendChild(u),l||(t.progress.work(!0,t.index,i.path),s.resolve())})}mountJS(e,t,r){e.post(s=>{const i=t.resource,n=this.getModuleExports(i.path);if(n){t.progress.work(!0,t.index,n),s.resolve();return}const o={id:i.path,src:i.path,status:U.Loading};this.moduleManager.set(i.path,o);const u=Ve().createElement("script");if("onload"in u)u.onload=()=>{u.onload=null,u.onerror=null,o.status===U.Loading&&(o.status=U.Loaded,t.progress.work(!0,t.index,i.path)),s.resolve()},u.onerror=()=>{try{r.removeChild(u)}catch(h){console.error(h)}u.onload=null,u.onerror=null,this.moduleManager.remove(i.path),t.progress.work(!1,t.index,null),s.resolve()};else{const h=u;h.onreadystatechange=()=>{/loaded|complete/.test(h.readyState)&&(h.onreadystatechange=null,o.status==U.Loading&&(o.status=U.Loaded,t.progress.work(!0,t.index,i.path)),s.resolve())}}const l=this.constructResourceUri(i.path);u.defer=!0,u.src=l;const a=j(),f=this.createRequireLoad();a.__require=a.__require??a.require,a.require=f;const c=this.createDefine(o,f,t);a.__define=a.__define??a.define,a.define=c,typeof t.progress.finalCallback!="function"&&(t.progress.finalCallback=function(){a.require=a.__require,a.__require=void 0,a.define=a.__define,a.__define=void 0}),r.appendChild(u)})}mountCJS(e,t){e.post(async r=>{const s=t.resource,i=this.getModuleExports(s.path);if(i){t.progress.work(!0,t.index,i),r.resolve();return}try{let n=await ji(s.path);if(Ge(n)&&(n=n.default??n),ve(n)){t.progress.work(!1,t.index,n),r.resolve();return}const o={id:s.path,src:s.path,status:U.Loaded,exports:n};this.moduleManager.set(s.path,o),t.progress.work(!0,t.index,n),r.resolve()}catch(n){console.error(n),t.progress.work(!1,t.index,null),r.resolve()}})}unmount(e){let t="",r="";typeof e=="string"?(this.moduleManager.remove(e),r=this.getResourcePathSuffix(e),t=e):(this.moduleManager.remove(e.path),r=e.type==="css"?"css":e.format??"",t=e.path);const s=Ve();if(r==="umd"){let i=s.getElementById(t);i||(i=s.querySelector(`script[src="${t}"]`)),i&&i.remove()}else if(r==="css"){let i=s.getElementById(t);if(!i){const n=this.constructResourceUri(t);i=s.querySelector(`link[href="${n}"]`)}i&&i.remove()}}trimEmptyElement(e){const t=[];for(let r=0;r<e.length;r++){let s=e[r];s!=null&&(s=s.trim(),s.length!==0&&t.push(s))}return t}createDefine(e,t,r){const s=this,i=function(...n){e.status=U.Defining;let o,u,l,a=n.length;if(a===1?(l=n[0],o=void 0):a===2?(l=n[1],Array.isArray(n[0])?(u=s.trimEmptyElement(n[0]),o=void 0):u=void 0):(o=n[0],u=s.trimEmptyElement(n[1]),l=n[2]),o&&(e.id=o,typeof s._alias=="object"&&(s._alias[o]=e.src)),u&&u.length>0)s.ensure(u,(...f)=>{try{const c=f.map(h=>h==="exports"?((!e.exports||typeof e.exports!="object")&&(e.exports={}),e.exports):h==="module"?e:h==="require"?t:h);if(typeof l=="function"){const h=Reflect.apply(l,e,c);h&&typeof h=="object"&&(e.exports=h)}else e.exports=l;e.status=U.Defined,r.progress.work(!0,r.index,e.exports)}catch(c){console.error(c),r.progress.work(!1,r.index,[])}});else{if(typeof l=="function"){const f=Reflect.apply(l,e,[]);f&&typeof f=="object"&&(e.exports=e.exports??{},Object.assign(e.exports,f))}else e.exports=l;e.status=U.Defined,r.progress.work(!0,r.index,e.exports)}};return i.amd=!0,i}createRequireLoad(){return e=>(e=this._alias?.[e]??e,this.getModuleExports(e))}constructResourceUri(e){try{if(Yt.includes(e)||!this.query)return e;const t=this.createSearch(this.query);return e.indexOf("?")==-1?e+=`?${t}`:t.length>0&&(e+=`&${t}`),e}catch(t){throw console.error(`[Fox]resolve path[${e}] fail`,t),t}}createSearch(e){let t="";if(e&&typeof e=="object"){for(let r in e){let s=`${e[r]}`;t+=`${encodeURIComponent(r)}=${encodeURIComponent(s)}&`}t.length>0&&(t=t.substring(0,t.length-1))}return t}getResourcePathSuffix(e){let t=e.lastIndexOf("?");t==-1&&(t=e.length);let r=e.lastIndexOf(".",t);return r==-1?"":e.substring(r+1,t)}},qi=class{finalCallback;callback;values;status;size;lastIndex;constructor(e,t){this.size=e,this.callback=t,this.status=!0,this.values=[],this.lastIndex=-1}work(e,t,r){if(this.status=e,this.status===!0&&(this.lastIndex!==t&&this.size--,this.lastIndex=t,this.values[t]=r),this.size===0||this.status===!1)try{Reflect.apply(this.callback,this,[this.status,this.values])}catch(s){console.error(s.message,s)}finally{typeof this.finalCallback=="function"&&(Reflect.apply(this.finalCallback,null,[]),this.finalCallback=null)}}isOK(){return this.status}},Ki=class{index;resource;progress;constructor(e,t,r){this.index=e,this.resource=t,this.progress=r}},us=Symbol("fk"),fs=Symbol("fbk"),cs=Symbol("fepk");function $i(e={}){const t=new Tr(e),r=new Ft,s=new Zt,i=new as,n={get router(){return t},get bus(){return r},get Bus(){return Ft},get EventProxy(){return Zt},get eventproxy(){return s},get EventChain(){return qe},get Require(){return as},get require(){return i},get isESModule(){return Ge},install(o,u={}){o.provide(ut,t),o.provide(us,n),o.provide(fs,r),o.provide(cs,s),u.install!==!1&&(o.component(Fi,vt),o.component(Ci,os)),u.optionsApi!==!1&&(Reflect.defineProperty(o.config.globalProperties,"$fox",{get(){return n}}),Reflect.defineProperty(o.config.globalProperties,"$router",{get(){return t}}),Reflect.defineProperty(o.config.globalProperties,"$bus",{get(){return r}}),Reflect.defineProperty(o.config.globalProperties,"$bus",{get(){return r}}),Reflect.defineProperty(o.config.globalProperties,"$eventProxy",{get(){return s}}),o.config.globalProperties.$fox_on=function(l,a,f=!1){s.on(l,a,f)},o.config.globalProperties.$fox_off=function(l,a){s.off(l,a)},o.config.globalProperties.$fox_once=function(l,a){s.once(l,a)},o.config.globalProperties.$fox_all=function(...l){let a=s;Reflect.apply(a.all,a,l)},o.config.globalProperties.$fox_trigger=function(l,...a){let f=s;Reflect.apply(f.trigger,f,[l,...a])},o.config.globalProperties.$fox_emit=function(l,...a){let f=s;Reflect.apply(f.trigger,f,[l,...a])},o.mixin({setup(){return{$route:Ur()}}})),t.init()}};return n}function er(){return(0,v.inject)(ut,null)}function Li(e){return Ur(e)}function Ti(){return(0,v.inject)(us,null)}function Mi(){return(0,v.inject)(fs,null)}function ki(){return(0,v.inject)(cs,null)}function Ii(e){const t=er();if(!t){console.error("[Fox]router is not exist.");return}const r=(s,i,n)=>{try{Reflect.apply(e,{},[s,i])}catch(o){console.error(o)}n()};t?.beforeEach(r),(0,v.onScopeDispose)(()=>{t?.removeBeforeEach(r)})}function Oi(e){const t=er();if(!t){console.error("[Fox]router is not exist.");return}const r=(s,i,n)=>{try{Reflect.apply(e,{},[s,i])}catch(o){console.error(o)}n()};t?.afterEach(r),(0,v.onScopeDispose)(()=>{t?.removeAfterEach(r)})}m.Bus=Ft,m.EventChain=qe,m.EventProxy=Zt,m.FoxBeforeEnter=Vr,m.FoxBeforeLeave=Jr,m.FoxEnter=Wr,m.FoxLeave=zr,m.FoxLeaveEnd=yt,m.OperationType=_,m.Route=P,m.Router=Tr,m.RouterLink=os,m.RouterView=vt,m.bindLifecycleContextToCurrentScope=Ys,m.createFox=$i,m.createMemoryHistory=_r,m.createWebHashHistory=Cr,m.createWebHistory=zs,m.deleteContextValue=ti,m.extend=q,m.injectContextValue=zt,m.injectLifecycleContext=He,m.isArray=bt,m.isDate=vs,m.isESModule=Ge,m.isEqual=xt,m.isFunction=S,m.isMap=ds,m.isNil=ve,m.isObject=ir,m.isPlainObject=nr,m.isPromise=bs,m.isSet=ms,m.isString=ps,m.isSymbol=gs,m.onAfterRouteUpdate=Oi,m.onBeforeRouteUpdate=Ii,m.onFoxActivated=oi,m.onFoxInactivated=li,m.provideContextValue=ei,m.rawState=Ls,m.reactiveState=qs,m.shallowReactiveState=Ks,m.toBoolean=Rt,m.toNumber=xs,m.toTypeString=ze,m.typeOf=St,m.useBus=Mi,m.useEventProxy=ki,m.useFox=Ti,m.useRoute=Li,m.useRouter=er,m.withLifecycleContext=Or});
1
+ (function(p,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(p=typeof globalThis<"u"?globalThis:p||self,d(p.Fox={},p.Vue))})(this,function(p,d){Object.defineProperty(p,Symbol.toStringTag,{value:"Module"});var me=typeof window<"u",j=function(){return window},We=function(){return window.document};function Je(e,t,r,s=!1){e.addEventListener?e.addEventListener(t,r,s):e.attachEvent?e.attachEvent(`on${t}`,r):e[`on${t}`]=r}function gt(e,t,r){e.removeEventListener?e.removeEventListener(t,r):e.detachEvent?e.detachEvent(`on${t}`,r):e[`on${t}`]=null}var ze=(e,t,r)=>{t=t??{bubbles:!1,cancelable:!1,detail:void 0};const s=document.createEvent("Events");let i=!0,n=!0;for(let o in t)o==="bubbles"?i=!!t[o]:o==="cancelable"?n=!!t[o]:s[o]=t[o];s.initEvent(e,i,n),(r??document).dispatchEvent(s)},bt=Array.isArray,ds=e=>Ge(e)==="[object Map]",ms=e=>Ge(e)==="[object Set]",ps=e=>e instanceof Date,S=e=>typeof e=="function",vs=e=>typeof e=="string",gs=e=>typeof e=="symbol",ar=e=>e!==null&&typeof e=="object",bs=e=>ar(e)&&S(e.then)&&S(e.catch),pe=e=>e==null,ws=Object.prototype.toString,Ge=e=>ws.call(e),ur=e=>Ge(e)==="[object Object]",Rs=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol";function Xe(e){return e.__esModule||Rs&&e[Symbol.toStringTag]==="Module"}var Ss=typeof Promise<"u"&&Promise.toString().indexOf("[native code]")!==-1;function q(...e){let t=e[0]!==void 0&&e[0]!==null?e[0]:{},r=1,s=e.length,i=!1;for(typeof t=="boolean"&&(i=t,t=e[r]??{},r++),typeof t!="object"&&(t={});r<s;r++)if(e[r]!==null&&e[r]!==void 0){let n=e[r];for(let o in n){let u=t[o],l=n[o];if(u!==l)if(i===!0&&l&&typeof l=="object"){let a;Array.isArray(l)?a=u&&Array.isArray(u)?u:[]:a=u&&typeof u=="object"?u:{},t[o]=q(i,a,l)}else l!==void 0&&(t[o]=l)}}return t}function fr(e,t,r=!1){if(typeof t!="object")return{};typeof e!="object"&&(e={});for(let s of Reflect.ownKeys(t)){let i=e[s],n=t[s];if(i!==n)if(typeof n=="object"){if(!Array.isArray(n)&&!ur(n))continue;i=fr(i,n,r),e[s]=i}else{if(typeof n=="function")continue;e[s]=n}}return e}var Ce=class or{static seed=new Date().getTime();static get(){let t=++or.seed;return t>=Number.MAX_VALUE&&(or.seed=0),t}},wt=Ss?Promise.resolve():null;function Fe(e,...t){wt!==null?t&&t.length>0?wt.then(()=>{e(t)}):wt.then(e):t&&t.length>0?setTimeout(()=>{e(t)}):setTimeout(e)}function Rt(e){return e==null?!1:typeof e=="boolean"?e:typeof e=="string"?e.toLocaleLowerCase()==="true":!!e}function xs(e){return typeof e=="number"?e:Number(e)}var Es={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Object]":"object"};function St(e){let t=Object.prototype.toString.call(e);return e==null?String(e):Es[t]||"object"}function xt(e,t){if(e==t)return!0;if(e===void 0||t===void 0)return!1;let r=St(e);if(r!==St(t))return!1;if(r==="object"){let s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(let n=0;n<s.length;n++){let o=s[n],u=e[o],l=t[o];if(!xt(u,l))return!1}return!0}else if(r==="array"){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){let i=e[s],n=t[s];if(!xt(i,n))return!1}return!0}return!1}var cr=e=>{const t={};for(let r of Reflect.ownKeys(e)){let s=e[r];s&&!Array.isArray(s)&&typeof s=="object"&&(s=cr(s)),typeof r=="symbol"?t[String(r)]=s:t[r]=s}return t},Ps=/^Symbol\((.*)\)$/,hr=e=>{const t={};for(let r of Reflect.ownKeys(e)){let s=e[r];s&&!Array.isArray(s)&&typeof s=="object"&&(s=hr(s));const i=Ps.exec(r);if(i&&i[1]){const n=Symbol.for(i[1]);t[n]=s}else t[r]=s}return t};function yr(e,t){let r=null;return function(...s){r&&clearTimeout(r),r=setTimeout(()=>{r=null,Reflect.apply(e,null,[...s])},t)}}var dr=Symbol("idKey"),oe=Symbol("valueKey"),x=Symbol("childrenKey"),V=Symbol("growKey"),mr=class{[V]=!0;[dr];[oe]=(0,d.ref)();[x]=new Map;constructor(e){this[dr]=e}},Cs=class{get(e,t){if(t=="value")return e[oe].value;if(t==="grow")return e[V];let r=e[x].get(t);if(r)return _e(r);if(e[V])return r=Pt(t),r[V]=e[V],e[x].set(t,r),_e(r)}set(e,t,r){return t=="value"?(e[oe].value=r,!0):t==="grow"?(e[V]=Rt(r),!0):r==null?(e[x].delete(t),!0):(console.error(`[Fox]illegal property:${t}`),!1)}deleteProperty(e,t){return t==="value"||t=="grow"?(console.error(`[Fox]can not delete property:${String(t)}`),!1):(e[x].delete(t),!0)}},Et="__proxy__";function Pt(e){const t=new mr(e);return Reflect.set(t,Et,new Proxy(t,new Cs)),t}function _e(e){return Reflect.get(e,Et)}var Fs=class{name="";persistPolicy="memory";storage;initFlag=!1;state={};constructor(e={},t){if(e.persistPolicy&&e.persistPolicy!=="memory"&&pe(e.name))throw new Error("name can not be empty, where persistPolicy is not memory.");this.name=e.name??"",this.persistPolicy=e.persistPolicy??"memory",this.storage=e.storage,t&&typeof t=="object"&&Object.assign(this.state,t)}init(e){this.restore(e),this.initFlag=!0}getStorage(){if(!this.persistPolicy||this.persistPolicy==="memory")return null;let e=null;if(this.persistPolicy==="custom")e=this.storage;else if(me){const t=j();e=this.persistPolicy==="session"?t.sessionStorage:t.localStorage}return e}saveState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null||!this.state)return;const t=`_bus_${this.name}`,r=JSON.stringify(this.state??{});e.setItem(t,r)}removeState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null||!this.state)return;const t=`_bus_${this.name}`;e.removeItem(t)}restore(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null)return;const r=`_bus_${this.name}`,s=t.getItem(r);if(s){const i=JSON.parse(s);Object.assign(this.state,i),Reflect.ownKeys(this.state).forEach(n=>{if(typeof n!="string")return;const o=this.state[n],u=n.split(/\//g);u.push(o),Reflect.apply(e.put,e,u)})}}put(e){if(this.initFlag&&this.persistPolicy!=="memory")try{const t=e.length,r=e.slice(0,t-1).join("/"),s=e[t-1];this.state[r]=s,this.saveState()}catch(t){console.error(t)}}remove(e){if(this.initFlag&&this.persistPolicy!=="memory")try{const t=e.length,r=e.slice(0,t-1).join("/"),s={};Reflect.ownKeys(this.state).forEach(i=>{typeof i=="string"&&(i===r||i.startsWith(r)||(s[i]=this.state[i]))}),this.state=s,this.saveState()}catch(t){console.error(t)}}clear(){if(this.initFlag)try{this.state={},this.removeState()}catch(e){console.error(e)}}},pr=class extends mr{_persistHandler;constructor(e={},t){super("__root__"),this._persistHandler=new Fs(e,t),this._persistHandler.init(this)}put(...e){let t=e.length;if(t<2)return console.error("[Fox]参数至少包括一个(key, value)"),!1;let r=this;for(let s=0;s<t-1;s++){let i=e[s],n;r[x].has(i)?n=r[x].get(i):(n=Pt(i),r[x].set(i,n)),r=n}return r[oe].value=e[t-1],this._persistHandler.put(e),!0}get(...e){let t=e.length;if(t===0)return;let r=this;for(let s=0;s<t;s++){let i=e[s];if(r[x].has(i))r=r[x].get(i);else return}return r[oe].value}remove(...e){let t=e.length;if(t==0)return!1;let r=this;for(let i=0;i<t-1;i++){const n=e[i];if(r[x].has(n))r=r[x].get(n);else return!1}const s=e[t-1];return r[x].has(s)?(r[x].delete(s),this._persistHandler.remove(e),!0):!1}contains(...e){const t=e.length;if(t==0)return!1;let r=this;for(let i=0;i<t-1;i++){let n=e[i];if(r[x].has(n))r=r[x].get(n);else return!1}const s=e[t-1];return r[x].has(s)}clear(){this[x].clear(),this._persistHandler.clear()}},_s=["put","get","contains","remove","clear","_persistHandler"];function vr(e){return _s.includes(e)}var As=class{get(e,t){if(t=="value")return e[oe].value;if(t==="grow")return e[V];if(t===x)return e[x];if(typeof t=="string"&&vr(t))return e[t];const r=String(t);let s=e[x].get(r);if(s)return _e(s);if(e[V])return s=Pt(r),s[V]=e[V],e[x].set(r,s),_e(s)}set(e,t,r){return t=="value"?(e[oe].value=r,!0):t==="grow"?(e[V]=Rt(r),!0):vr(t)?!1:r==null?(e[x].delete(t),!0):(console.error(`[Fox]illegal property:${t}`),!1)}deleteProperty(e,t){return t==="value"||t=="grow"?(console.error(`[Fox]can not delete property:${String(t)}`),!1):(e[x].delete(t),!0)}};function js(e,t){const r=new pr(e,t),s=new As,i=new Proxy(r,s);return Reflect.set(r,Et,i),r}var Ct=new Proxy(pr,{construct(e,t){const r=t[0]??{},s=t[1];return _e(js(r,s))}}),Ft=e=>!e||typeof e!="object"?!0:Reflect.ownKeys(e).length===0,gr=class{name="";persistPolicy="memory";storage;constructor(e={}){if(e.persistPolicy&&e.persistPolicy!=="memory"&&pe(e.name))throw new Error("name can not be empty, where persistPolicy is not memory.");this.name=e.name??"",this.persistPolicy=e.persistPolicy??"memory",this.storage=e.storage}getStorage(){if(!this.persistPolicy||this.persistPolicy==="memory")return null;let e=null;if(this.persistPolicy==="custom")e=this.storage;else if(me){const t=j();e=this.persistPolicy==="session"?t.sessionStorage:t.localStorage}return e}saveState(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null||Ft(e))return;const r=`_state_${this.name}`,s=JSON.stringify(e??{});t.setItem(r,s)}removeState(){if(!this.persistPolicy||this.persistPolicy==="memory")return;let e=this.getStorage();if(e===null)return;const t=`_state_${this.name}`;e.removeItem(t)}restore(e){if(!this.persistPolicy||this.persistPolicy==="memory")return;let t=this.getStorage();if(t===null)return;const r=`_state_${this.name}`,s=t.getItem(r);if(s){const i=JSON.parse(s);Object.assign(e,i)}}};function br(e,t,r){const s=new gr(r);s.restore(t);const i=u=>{const l=(0,d.toRaw)(u),a={};for(let f in l){const c=l[f];pe(c)||(a[f]=c)}Ft(a)?s.removeState():s.saveState(a)};let n=null;r&&r.debounce===!1?n=i:n=yr(i,r&&r.debounceDelay?r.debounceDelay:250);const o=e?(0,d.shallowReactive)(t):(0,d.reactive)(t);return(0,d.effectScope)(!0).run(()=>{(0,d.watch)(o,u=>{const l=(0,d.toRaw)(u);n(l)})}),o}function qs(e,t){return br(!1,e,t)}function $s(e,t){return br(!0,e,t)}function Ks(e,t){const r=new gr(t);r.restore(e);const s=n=>{const o=(0,d.toRaw)(n),u={};for(let l in o){const a=o[l];pe(a)||(u[l]=a)}Ft(u)?r.removeState():r.saveState(u)};let i=null;return t&&t.debounce===!1?i=s:i=yr(s,t&&t.debounceDelay?t.debounceDelay:250),new Proxy(e,{get(n,o){return n[o]},set(n,o,u){return n[o]=u,i(n),!0}})}function Ls(e,t){return Ks(e,t)}var le=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e})({}),F=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e})(F||{}),Ts={type:le.Static,value:""},Ms=/[a-zA-Z0-9_]/;function ks(e){if(!e)return[[]];if(e==="/")return[[Ts]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(y){throw new Error(`ERR (${r})/"${a}": ${y}`)}let r=F.Static,s=r;const i=[];let n;function o(){n&&i.push(n),n=[]}let u=0,l,a="",f="";function c(){a&&(r===F.Static?n.push({type:le.Static,value:a}):r===F.Param||r===F.ParamRegExp||r===F.ParamRegExpEnd?(n.length>1&&(l==="*"||l==="+")&&t(`A repeatable param (${a}) must be alone in its segment. eg: '/:ids+.`),n.push({type:le.Param,value:a,regexp:f,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):t("Invalid state to consume buffer"),a="")}function h(){a+=l}for(;u<e.length;){if(l=e[u++],l==="\\"&&r!==F.ParamRegExp){s=r,r=F.EscapeNext;continue}switch(r){case F.Static:l==="/"?(a&&c(),o()):l===":"?(c(),r=F.Param):h();break;case F.EscapeNext:h(),r=s;break;case F.Param:l==="("?r=F.ParamRegExp:Ms.test(l)?h():(c(),r=F.Static,l!=="*"&&l!=="?"&&l!=="+"&&u--);break;case F.ParamRegExp:l===")"?f[f.length-1]=="\\"?f=f.slice(0,-1)+l:r=F.ParamRegExpEnd:f+=l;break;case F.ParamRegExpEnd:c(),r=F.Static,l!=="*"&&l!=="?"&&l!=="+"&&u--,f="";break;default:t("Unknown state");break}}return r===F.ParamRegExp&&t(`Unfinished custom RegExp for param "${a}"`),c(),o(),i}var wr="[^/]+?",Is={sensitive:!1,strict:!1,start:!0,end:!0},W=(function(e){return e[e._multiplier=10]="_multiplier",e[e.Root=9*e._multiplier]="Root",e[e.Segment=4*e._multiplier]="Segment",e[e.SubSegment=3*e._multiplier]="SubSegment",e[e.Static=4*e._multiplier]="Static",e[e.Dynamic=2*e._multiplier]="Dynamic",e[e.BonusCustomRegExp=1*e._multiplier]="BonusCustomRegExp",e[e.BonusWildcard=-4*e._multiplier-e.BonusCustomRegExp]="BonusWildcard",e[e.BonusRepeatable=-2*e._multiplier]="BonusRepeatable",e[e.BonusOptional=-.8*e._multiplier]="BonusOptional",e[e.BonusStrict=.07*e._multiplier]="BonusStrict",e[e.BonusCaseSensitive=.025*e._multiplier]="BonusCaseSensitive",e})(W||{}),Bs=/[.+*?^${}()[\]/\\]/g;function Os(e,t){const r=q(!0,{},Is,t),s=[];let i=r.start?"^":"";const n=[];for(const a of e){const f=a.length?[]:[W.Root];r.strict&&!a.length&&(i+="/");for(let c=0;c<a.length;c++){const h=a[c];let y=W.Segment+(r.sensitive?W.BonusCaseSensitive:0);if(h.type===le.Static)c||(i+="/"),i+=h.value.replace(Bs,"\\$&"),y+=W.Static;else if(h.type===le.Param){const{value:m,repeatable:v,optional:R,regexp:w}=h;n.push({name:m,repeatable:v,optional:R});const g=w||wr;if(g!==wr){y+=W.BonusCustomRegExp;try{new RegExp(`(${g})`)}catch(I){throw new Error(`Invalid custom RegExp for param "${m}" (${g}): `+I.message)}}let T=v?`((?:${g})(?:/(?:${g}))*)`:`(${g})`;c||(T=R&&a.length<2?`(?:/${T})`:"/"+T),R&&(T+="?"),i+=T,y+=W.Dynamic,R&&(y+=W.BonusOptional),v&&(y+=W.BonusRepeatable),g===".*"&&(y+=W.BonusWildcard)}f.push(y)}s.push(f)}if(r.strict&&r.end){const a=s.length-1;s[a][s[a].length-1]+=W.BonusStrict}r.strict||(i+="/?"),r.end?i+="$":r.strict&&!i.endsWith("/")&&(i+="(?:/|$)");const o=new RegExp(i,r.sensitive?"":"i");function u(a){const f=a.match(o),c={};if(!f)return null;for(let h=1;h<f.length;h++){const y=f[h]||"",m=n[h-1];c[m.name]=y&&m.repeatable?y.split("/"):y}return c}function l(a){let f="",c=!1;for(const h of e){(!c||!f.endsWith("/"))&&(f+="/"),c=!1;for(const y of h)if(y.type===le.Static)f+=y.value;else if(y.type===le.Param){const{value:m,repeatable:v,optional:R}=y,w=m in a?a[m]:"";if(bt(w)&&!v)throw new Error(`Provided param "${m}" is an array but it is not repeatable (* or + modifiers)`);const g=bt(w)?w.join("/"):w;if(!g)if(R)h.length<2&&(f.endsWith("/")?f=f.slice(0,-1):c=!0);else throw new Error(`Missing required param "${m}"`);f+=g}}return f||"/"}return{re:o,score:s,keys:n,parse:u,stringify:l}}function Ds(e,t){const r=Os(ks(e),t);return function(s){const i=r.parse(s);return i?{path:s,params:i}:null}}var Rr="default",Sr=Symbol("sync"),M=Symbol("normalizeRoute");function xr(e){let t=!1;return function(...r){if(!t)return t=!0,Reflect.apply(e,{},r)}}function Hs(e){let t=e.src;return new Promise((r,s)=>{const i=xr(u=>{Xe(u)&&(u=u.default),e.component=u,console.debug("success load async module"),r()}),n=xr(u=>{`${u}`,console.debug("reject load async module"),s(u)});let o;try{o=t(i,n)}catch(u){n(u)}if(o)if(typeof o.then=="function")o.then(i,n);else{const u=o.component;u&&typeof u.then=="function"&&u.then(i,n)}})}var Ns=class{name;level;rootName;rootIndex=0;constructor(e,t,r,s){this.name=e,this.level=t,this.rootName=r,this.rootIndex=s}},Qe=class ys{to;routeModel;from;data={};constructor(t,r){this.to=t,this.from=r}static from(t){const r=new ys(t.to,t.from),s=t.data??{};return q(!0,r.data,s),r}static clear(t){for(let r in t)t[r]=void 0}},E=class lr{path;get fullPath(){const t=this.path??`${this.name}`;return`${this.root??"default"}!${t}`}alias;name;root;params;query;traceless;template;matched;meta;success;error;destroy;opsType;updateType;historyUpdatePolicy;viewTagAttrs;index;active;slot;static clone(t,r){let s=new lr;return fr(s,t,r),s}static isSame(t,r){return!t||!r?!1:t===r?!0:t.root!==r.root||t.index!==r.index?!1:t.path&&r.path&&t.path===r.path?!0:!!(t.name&&r.name&&t.name===r.name)}static isSamePathForRoute(t,r){return!t||!r?!1:t===r||t.path&&r.path&&t.path===r.path?!0:!!(t.name&&r.name&&t.name===r.name)}static from(t){let r=new lr;if(t==null)return r;let s=r;for(let n in t)s[n]=t[n];const i=Object.getOwnPropertySymbols(t);if(Array.isArray(i)&&i.length>0)for(let n of i)s[n]=t[n];return r}},Us=class{id;name;props;src;component;constructor(e,t,r){this.id=Ce.get(),this.name=e,this.src=t,typeof t!="function"&&(this.component=t),this.props=r}get isResolved(){return this.component!==void 0}resolve(){return Hs(this)}},Er=class{models=[]},_t=class{path;match;redirect;name;meta;matchedRoutes;layers=[]},_=(function(e){return e[e.Push=0]="Push",e[e.Replace=1]="Replace",e[e.Put=2]="Put",e[e.Append=3]="Append",e[e.Open=4]="Open",e})({}),At=(function(e){return e[e.Part=0]="Part",e[e.All=1]="All",e})({}),J=Symbol("rootKey"),z=Symbol("rootNodeKey"),ae=Symbol("parentNodeKey"),Ze=Symbol("nameKey"),re=class{model;route;active=!0;index=0;constructor(e,t,r=0,s=!0){this.route=e,this.model=t,this.index=r,this.active=s}},Ae=class{_slots;get slots(){return this._slots==null&&(this._slots=(0,d.shallowRef)([])),this._slots}get empty(){return this._slots==null||this._slots.value.length==0}[Ze];[J];[z]=null;[ae]=null;get name(){return this[Ze]}constructor(e,t,r){this[Ze]=e,this[J]=t,r&&(this[z]=r)}},D=class{view;index;level;constructor(e,t,r){this.view=e,this.index=t,this.level=r}static include(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.view===t.view&&(t.index==-1||s.index===t.index)&&s.level===t.level)return!0}return!1}},jt=class{views=[]},Vs=class{layers=[]},Ws=class{time;route},Js=class{forbidTime=300;submitRecorder=new Ws;isSameRoute(e,t){return e==null||t==null?!1:e.name===t.name&&e.path===t.path&&e.root===t.root}acquire(e){let t=new Date().getTime();if(this.isSameRoute(e,this.submitRecorder.route)&&this.submitRecorder.time&&t-this.submitRecorder.time<=this.forbidTime){this.submitRecorder.time=t;return}return this.submitRecorder.route=e,this.submitRecorder.time=t,t}release(e){this.submitRecorder.time===e&&(this.submitRecorder.route=void 0)}},C=(function(e){return e.Busy="Busy",e.Free="Free",e.Reject="Reject",e.Exception="Exception",e.Finished="Finished",e})(C||{}),H=Symbol("chainKey"),k=Symbol("cursorKey"),qt=Symbol("$persistentModeKey"),A=Symbol("statusKey"),Z=Symbol("argsKey"),Ye=Symbol("exArgsKey"),ve=Symbol("successFnsKey"),je=Symbol("errorFnsKey"),ue=Symbol("sessionKey"),Y=Symbol("_go"),qe=class{[H]=[];[k]=0;[qt]=!1;[A]=C.Free;[Z]=[];[Ye]=[];[ve]=[];[je]=[];[ue];get session(){return this[ue]}constructor(e,t=!1){this[ue]=e,this[qt]=t}[Y](e,...t){let r=this[A];if(this[A]=C.Busy,this[k]+=e,this[k]<0&&(this[k]=0),this[Z]=t,r===C.Exception||r===C.Reject){let n=[{session:this[ue]},...this[Ye]];for(;this[je].length>0;)try{let o=this[je].shift();typeof o=="function"&&Fe(()=>{Reflect.apply(o,{},n)})}catch(o){console.error(o.message,o)}return this[A]=r,this[H]=[],this[k]=0,this}else if(r===C.Finished||this[k]>=this[H].length){let n=[{session:this[ue]},...this[Z]];for(;this[ve].length>0;){let o=this[ve].shift();typeof o=="function"&&Fe(()=>{Reflect.apply(o,{},n)})}return this[A]=C.Free,this}if(this[k]>=this[H].length)return this[A]=C.Free,this;let s=this[H][this[k]];this[qt]||(this[H].splice(0,this[k]+1),this[k]=-1);let i=this[k]+1;try{let n=!1,o={go:(u,...l)=>{n||(n=!0,Reflect.apply(this[Y],this,[u,...l]))},resolve:(...u)=>{n||(n=!0,Reflect.apply(this[Y],this,[1,...u]))},reject:(...u)=>{n||(n=!0,Reflect.apply(this.reject,this,[...u]))},insert:u=>{n||(this[H].splice(i,0,u),i++)},session:this[ue]};Fe(()=>{Reflect.apply(s,{},[o,...this[Z]])})}catch(n){this.throw(n)}return this}go(e,...t){return Reflect.apply(this[Y],this,[e,...t])}finish(...e){return this[A]=C.Finished,this[Z]=e,Reflect.apply(this[Y],this,[0])}reject(...e){return this[A]=C.Reject,this[Ye]=e,Reflect.apply(this[Y],this,[0])}throw(...e){return this[A]=C.Exception,this[Ye]=e,Reflect.apply(this[Y],this,[0])}reset(...e){this[A]=C.Busy,this[Z]=e,this[H]=[],this[k]=0;let t=[{session:this[ue]},...this[Z]];for(;this[ve].length>0;){let r=this[ve].shift();Fe(()=>{Reflect.apply(r,this,t)})}return this[A]=C.Free,this}post(e){return this[A]===C.Reject||this[A]===C.Exception?this:(Array.isArray(e)?this[H]=[...this[H],...e]:this[H].push(e),this[A]===C.Busy?this:(Reflect.apply(this[Y],this,[0,...this[Z]]),this))}wait(e,t){return e&&typeof e=="function"&&this[ve].push(e),t&&typeof t=="function"&&this[je].push(t),this[A]===C.Busy?this:(Reflect.apply(this[Y],this,[0,...this[Z]]),this)}exception(e){return e&&typeof e=="function"&&this[je].push(e),this[A]===C.Busy?this:Reflect.apply(this[Y],this,[0,...this[Z]])}isFinish(){return this[A]==C.Reject||this[A]==C.Free&&this[k]>=this[H].length}},ge=Symbol("_notifyChange"),Pr=class{currentRoute;routes;constructor(e,t){this.currentRoute=e,this.routes=t}},fe=Symbol("historyChangeConsumerKey"),Cr=Symbol("_navigateFirstRoute"),et=Symbol("_getRouteMark"),$t=Symbol("_getUrlSearch"),Kt=Symbol("_generateLocation"),tt=Symbol("_setRouteMarkRecorder"),$e=Symbol("beforeRestoreFiltersKey"),Fr=Symbol("_beforeRestore"),_r="Symbol(_fox_restore_point)";function Ke(e,...t){return typeof e=="function"?Reflect.apply(e,null,[...t]):e}function Ar(e){if(!Array.isArray(e))return!1;if(e.length===0)return!0;const t=e[0];return!!(Reflect.has(t,"path")&&Reflect.has(t,"root"))}var jr=class{base;storage;mode;query;firstNavigate=!0;historyMonitor;traceless=!1;changeHandler;historyChange;[fe]=!1;[$e]=new Array;backTimeout=320;constructor(e="hash",t="",r="",s=!0,i=!0,n=!1,o,u){this.mode=e,this.base=t,this.query=r,this.firstNavigate=s,this.historyMonitor=i,this.traceless=n,this.storage=o??j().sessionStorage,this.backTimeout=u??320}init(e=!0){const t=j();return typeof this.historyChange!="function"&&(this.historyChange=()=>{if(typeof this[fe]=="function"){const r=this[fe]();if(this[fe]=!1,r)return}else if(this[fe]===!0){this[fe]=!1;return}if(Ke(this.historyMonitor)){const r=t.history.state;this[ge](r);try{let s=[];if(typeof r=="string"?s=JSON.parse(r):s=r,Array.isArray(s)&&s.length>0){const i=this[et]()??"/";this[tt](i,s)}}catch{}}}),Je(t,"popstate",this.historyChange),this.firstNavigate&&e&&this[Cr](),Promise.resolve()}destroy(){this.historyChange&&gt(j(),"popstate",this.historyChange)}[Fr](e,t,r,s){for(let i of this[$e])try{const n=Reflect.apply(i,{},[e,t,r,s]);if(n===!1)return n}catch(n){console.error(n.message,n)}return!0}beforeRestoreEach(e){this[$e].push(e)}removeBeforeRestoreEach(e){const t=this[$e].indexOf(e);return t!==-1?(this[$e].splice(t,1),!0):!1}[Cr](){const e=this[et]()??"/",t=this.storage.getItem(_r);if(t)try{const n=JSON.parse(t);if(n.mark===e&&Array.isArray(n.routes)&&n.routes.length>0){const o=n.routes.filter((u,l)=>(u.params=u.params?hr(u.params):{},this[Fr](u,l,e,n.routes)));if(o.length>0){const u=this[$t](),l=o.length-1;o[l].query=u||o[l].query,this[ge](o);return}}}catch{}const r=e.indexOf("!");let s;r!=-1?s=e.substring(r+1):s=e;const i=new E;i.path=s,i.query=this[$t](),this[ge]([i])}[tt](e,t){try{t.forEach(s=>{s.params=s.params?cr(s.params):{}});const r=JSON.stringify({mark:e,routes:t});this.storage.setItem(_r,r)}catch(r){console.error(r.message,r)}}setRestorePoint(e){const t=this[et]()??"/";this[tt](t,e)}[ge](e){typeof this.changeHandler=="function"&&this.changeHandler(e)}[et](){const e=j();if(this.mode==="path"){let t=e.location.pathname;return this.base&&t.indexOf(this.base)===0&&(t=t.substring(this.base.length)),t}else{const t=e.location.hash,r=t.indexOf("#");if(r!=-1)return t.substring(r+1)}return null}[$t](){let e=j().location.search;return e.length>0&&e.indexOf("?")===0&&(e=e.substring(1)),e}listen(e){this.changeHandler=e}go(e,t=!1){const r=j();this[fe]=t,r.history.go(e)}goBack(e,t){const r=j(),s=r.history.state;if(Ar(s)&&s.length>0){let i=!1;for(let a=s.length-1;a>=0;a--){const f=E.from(s[a]);if(!(f.historyUpdatePolicy==="traceless"||Ke(this.traceless,f))&&E.isSame(f,e)){i=!0;break}}if(!i){t();return}const n=this.backTimeout;let o=null;const u=()=>{r.history.go(-1),o=setTimeout(u,n)},l=()=>{clearTimeout(o);const a=j().history.state;if(Ar(a)&&a.length>0){let f=a.length;const c=a[f-1],h=E.from(c);if(E.isSame(h,e))return t(),!0;if(f>0){let y=!1;for(let m=f-1;m>=0;m--){const v=E.from(a[m]);if(!(v.traceless===!0||Ke(this.traceless,v))&&E.isSame(v,e)){y=!0;break}}return y?(setTimeout(()=>{o=setTimeout(u,n),this.go(-1,l)},0),!0):(t(),!0)}}return t(),!0};o=setTimeout(u,n),this.go(-1,l)}else t()}setRouteMark(e){const t=e.currentRoute.fullPath;this[tt](t,e.routes)}push(e){const t=this[Kt](e.currentRoute);e.currentRoute.historyUpdatePolicy!=="traceless"&&!Ke(this.traceless,e.currentRoute)&&j().history.pushState(e.routes,"",t),this.setRouteMark(e)}replace(e){const t=this[Kt](e.currentRoute);(e.currentRoute.historyUpdatePolicy!=="traceless"||!Ke(this.traceless,e.currentRoute))&&j().history.replaceState(e.routes,"",t),this.setRouteMark(e)}[Kt](e){const t=j();let r="";if(e.query){let o="";if(typeof e.query=="object")for(let u of Reflect.ownKeys(e.query)){let l=encodeURIComponent(e.query[u]),a=`${encodeURIComponent(String(u))}=${l}`;o.length>0&&(o+="&"),o+=a}else o=e.query;this.query?(r=o.length>0?`${this.query}&${o}`:this.query,r.length>0&&r.charAt(0)!=="?"&&(r=`?${r}`)):o.length>0&&(r=`?${o}`)}const s=t.location;let i=e.alias??e.fullPath;i.startsWith("default")&&(i=i.substring(Rr.length+1));let n;return r?this.mode=="path"?i.indexOf("/")===0?n=`${this.base}${i}${r}`:n=`${this.base}/${i}${r}`:n=`${s.pathname}${r}#${i}`:this.mode=="path"?i.indexOf("/")===0?n=`${this.base}${i}`:n=`${this.base}/${i}`:n=`${s.pathname}#${i}`,`${s.origin}${n}`}};function zs(e=!0,t=null,r="",s=!0,i=!1,n){return t!==null&&(t=j().location.pathname),t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),new jr("path",t??"",r,e,s,i,n)}function qr(e=!0,t="",r=!0,s=!1,i){return new jr("hash","",t,e,r,s,i)}var Gs=class{maxSize=50;cursor=-1;queue=[];changeHandler;base;historyMonitor=!1;traceless=!1;constructor(e,t=50){this.base=e,this.maxSize=t}init(e=!0){return Promise.resolve()}destroy(){this.queue=[]}beforeRestoreEach(e){}removeBeforeRestoreEach(e){return!1}listen(e){this.changeHandler=e}[ge](e){typeof this.changeHandler=="function"&&this.changeHandler(e)}go(e,t=!1){if(this.queue.length==0||this.cursor<=0)return;let r=this.cursor+e;if(r<0?r=0:r>this.queue.length-1&&(r=this.queue.length-1),r!=this.cursor){this.cursor=r;let s=!1;if(typeof t=="function"?s=t():s=t,!s){const i=this.queue[r];this[ge](i.routes)}}}goBack(e,t){if(this.queue.length==0||this.cursor<=0)return;let r=0;if(e===null)r=this.cursor+1;else for(let s=this.cursor;s>=0;s--){const i=this.queue[s];if(E.isSame(i.currentRoute,e))break;r++}if(r===0){t();return}this.go(-r,()=>(t(),!0))}setRouteMark(e){}push(e){this.queue.length>=this.maxSize&&this.queue.splice(0,1),this.queue.push(e),this.cursor=this.queue.length-1}replace(e){let t=this.queue.length-this.cursor;this.queue.splice(this.cursor,t),this.queue[this.cursor]=e}setRestorePoint(e){}};function $r(e="",t=50){return new Gs(e,t)}function Oi(e){}var rt=Symbol("_constructRouteModel"),st=Symbol("_findRouteModel"),Lt=Symbol("_findRootView"),Xs=Symbol("_getFirstView"),ce=Symbol("_removeView"),Kr=Symbol("_buildPage"),Lr=Symbol("_resolveComponent"),Tr=Symbol("_update"),se=Symbol("_merge"),Tt=Symbol("_handleHistoryChange"),he=Symbol("_handleRouteUpdated"),it=Symbol("routeUpdatedCallback"),Mt=Symbol("currentRoute"),b=Symbol("currentRoutes"),nt=Symbol("routeSessionCacheKey"),Mr=Symbol("_addRouteRecorder"),Le=Symbol("_removeRouteRecorder"),ot=Symbol("_cloneRouteRecorder"),K=Symbol("_handleError"),lt=Symbol("errorCallback"),N=Symbol("registerKey"),at=Symbol("notFoundKey"),kt=Symbol("notFoundPathKey"),G=Symbol("forestKey"),P=Symbol("historyKey"),Te=Symbol("beforeFiltersKey"),Me=Symbol("afterFiltersKey"),ke=Symbol("destroyFiltersKey"),It=Symbol("propsFilterKey"),be=Symbol("mainDispatcherKey"),Bt=Symbol("initKey"),ye=Symbol("readyKey"),Ot=Symbol("readyHandlersKey"),ut=Symbol("_markReady"),kr=Symbol("_createNextFn"),Dt=Symbol("_start"),Ht=Symbol("_before"),Nt=Symbol("_after"),Ir=Symbol("_destroy"),Ut=Symbol("_load"),Ie=Symbol("_unload"),Be=Symbol("routerGuardKey");function Qs(e){return e.layers.length==0||e.layers[0].views.length==0}var Br=class{[N]=new Array;[at];[kt]="*";[ye]=!1;[Ot]=[];[G]=new Vs;[P];[b]=new Array;[Mt]=(0,d.shallowRef)(null);[nt]=new WeakMap;[lt]=null;[it]=null;[Te]=new Array;[Me]=new Array;[ke]=new Array;[It]=null;[be]=new qe;[Be]=new Js;[Bt]=!1;get currentRoute(){return(0,d.readonly)(this[Mt])}options;constructor(e){this.options=e??{},this.options.notFoundPath&&this.setNotFoundPath(this.options.notFoundPath);let t=this.options.routes||[];this.addRoutes(t),this.options.notFound&&this.setNotFoundRoute(this.options.notFound),e.history?this[P]=e.history:this[P]=me?qr():$r(),this[P]?.listen(async r=>{let s=!0;try{if(typeof r=="string"){const i=this[M](r);i&&await this[Tt]([i])}else await this[Tt](r)}catch(i){console.error(i.message,i),s=!1}this[ye]===!1&&this[ut](s)})}[K](e="error",t){if(t&&typeof t.error=="function")try{t.error(e)}catch{}if(typeof this[lt]=="function")try{this[lt](e,t)}catch{}console.error(e)}init(){this[Bt]!==!0&&(this[P]?.init(!this[ye]),this[Bt]=!0)}isReady(){return this[ye]?Promise.resolve():new Promise((e,t)=>{this[Ot].push([e,t])})}[ut](e){this[ye]=!0,this[Ot].forEach(([t,r])=>{try{e?t():r()}catch(s){console.error(s.message,s)}})}[Tt](e){try{if(!e){let n=[...this[b]].reverse();return this[Ie](n),me&&j().location.reload(),Promise.resolve()}let t=null,r=[],s=[],i=0;for(;i<e.length&&i<this[b].length&&E.isSame(e[i],this[b][i]);i++)e[i].active===!0&&e[i].active!==this[b][i].active&&(t=e[i]);if(i<e.length&&(r=e.slice(i)),i<this[b].length&&(s=this[b].slice(i).reverse()),s.length===0&&r.length===0){if(t!==null)return this.restore([t])}else if(s.length>0){if(this[Ie](s)){if(r.length>0)return this.restore(r);if(t!==null)return this.restore([t])}}else return this.restore(r)}catch(t){this[K](t)}return Promise.resolve()}[he](e=null){if(this[Mt].value=e,typeof this[it]=="function")try{this[it](e)}catch{}}[Mr](e,t){if(e.opsType===_.Open){let r=!1;const s=this[b].length-1;for(let i=s;i>=0;i--){const n=this[b][i];if(e.root==n.root){if(e.path===n.path){this[b].splice(i,1,e),r=!0;continue}e.active&&(n.active=!1)}}r||this[b].push(e)}else this[b].push(e);this[nt].set(e,t),this[he](e)}[ot](){let e=[];for(let t of this[b]){let r=E.clone(t,!0);e.push(r)}return e}[Le](e){if(!this[b]){this[he](null);return}let t=-1;for(let r=0;r<this[b].length;r++)if(E.isSame(this[b][r],e)){t=r;break}if(t!=-1){const r=this[b][t];this[b].splice(t,1);const s=this[nt].get(r);if(this[nt].delete(r),this[Ir](r,s),r.opsType===_.Append){const i=this[b].length-1;this[he](this[b][i]??null)}else this[he](null)}else this[he](null)}set historyMonitor(e){this[P]&&(this[P].historyMonitor=e)}get historyMonitor(){return this[P]?this[P].historyMonitor:!1}set traceless(e){this[P]&&(this[P].traceless=e)}get traceless(){return this[P]?this[P].traceless:!1}set propsFilter(e){this[It]=e}get propsFilter(){return this[It]}setRestorePoint(){const e=this[ot]();this[P]?.setRestorePoint(e)}onRouteUpdated(e){this[it]=e}onError(e){this[lt]=e}beforeEach(e){this[Te].push(e)}removeBeforeEach(e){const t=this[Te].indexOf(e);return t!==-1?(this[Te].splice(t,1),!0):!1}afterEach(e){this[Me].push(e)}removeAfterEach(e){const t=this[Me].indexOf(e);return t!==-1?(this[Me].splice(t,1),!0):!1}destroyEach(e){this[ke].push(e)}removeDestroyEach(e){const t=this[ke].indexOf(e);return t!==-1?(this[ke].splice(t,1),!0):!1}beforeRestoreEach(e){this[P]?.beforeRestoreEach(e)}removeBeforeRestoreEach(e){return this[P]?.removeBeforeRestoreEach(e)??!1}addRoutes(e){for(let t of e)this.addRoute(t)}addRoute(e,t=-1){if(e.path===this[kt]){this.setNotFoundRoute(e);return}const r=this[rt](e);if(t==-1)this[N]=[...this[N],...r];else for(let s=r.length-1;s>=0;s--)this[N].splice(t,0,r[s])}removeRoute(e){const t=this[M](e);if(t===null)return console.warn("[Fox]route格式错误",e),!1;for(let r=0;r<this[N].length;r++){const s=this[N][r];if(t?.path&&s.path===t.path)return this[N].splice(r,1),!0;if(t?.name&&s.name===t.name)return this[N].splice(r,1),!0}return!1}hasRoute(e){const t=this[M](e);return t===null?(console.warn("[Fox]route格式错误",e),!1):this[N].findIndex(r=>{if(t?.path&&r.path===t.path||t?.name&&r.name===t.name)return!0})!==-1}setNotFoundPath(e){this[kt]=e}setNotFoundRoute(e){const t=this[rt](e);this[at]=t[0]}getRoutes(){return[...this[N]]}[rt](e){let t=e.path??"";t.length>0&&t.charAt(0)!=="/"&&(t=`/${t}`);let r=e.components??(e.component&&{"":e.component});if(!r){const u=new _t;return u.path=t,u.redirect=e.redirect,[u]}const s=new E;s.path=t,s.name=e.name,s.meta=e.meta;let i=[];for(let u in r){const l=r[u];u.length===0&&(u=Rr);const a=new Us(u,l,e.props);i.push(a)}let n=!1,o=[];if(e.children)for(let u of e.children){const l=this[rt](u);for(let a of l){let f=new _t;f.name=a.name,a.path&&a.path.length>0?t!=="/"?f.path=`${t}${a.path}`:f.path=a.path:(n=!0,f.path=t);let c=new Er;c.models=[...i],f.layers=[c,...a.layers],f.matchedRoutes=[s,...a.matchedRoutes??[]],o.push(f)}}if(!n){const u=new Er;u.models=i;const l=new _t;l.name=e.name,l.path=t,l.matchedRoutes=[s],l.layers=[u],o.splice(0,0,l)}return o}[st](e){const t=e.route;try{for(let r of this[N]){const s=t.path?t.template??t.path:null,i=t.name?t.template??t.name:null;if(s&&r.path){let n=r.match;n||(n=r.match=Ds(r.path));const o=n(s);if(!o)continue;if(r.redirect){const u=new E;q(!0,u,t),u.path=r.redirect;const l={route:u,find:void 0};return this[st](l)?(e.route=l.route,e.find=l.find,t.template&&e.find&&(e.find={...e.find},e.find.path=t.path),!0):!1}if(t.params=t.params??{},q(!0,t.params,o.params),t.query){const u=t.query;if(typeof u=="string"){const l={},a=u.split("&");for(let f of a){const c=f.split("=");if(c.length!==2)continue;const h=decodeURIComponent(c[0].trim());l[h]=decodeURIComponent(c[1].trim())}q(!0,t.params,l)}else typeof u=="object"&&q(!0,t.params,u)}return e.find=r,t.template&&e.find&&(e.find={...e.find},e.find.path=t.path),!0}else if(i===r.name)return e.find=r,t.template&&e.find&&(e.find={...e.find},e.find.name=t.name),!0}}catch(r){console.error(r.message,r),typeof t.error=="function"&&t.error(r.message)}return!1}[M](e){let t=null;if(Array.isArray(e))if(t=new E,typeof e[0]=="object")t=E.from(e[0]);else for(let r=0;r<e.length;r++)r===0?e[r].charAt(0)==="/"?t.path=e[r]:t.name=e[r]:r===1?t.params=e[r]:r===2?t.root=e[r]:r===3&&q(!1,t,e[r]);else typeof e=="object"?t=E.from(e):typeof e=="string"&&(t=new E,e.charAt(0)=="/"?t.path=e:t.name=e);if(t){if(t.path){let r=t.path.indexOf("?");r!==-1&&r<t.path.length-1&&(t.query=t.path.substring(r+1),t.path=t.path.substring(0,r))}t.root=t.root??"default",t.opsType=t.opsType??this.options.defaultOperationType??_.Push,t.traceless&&!t.historyUpdatePolicy&&(t.historyUpdatePolicy="traceless")}return t}push(...e){const t=this[M](e);return t?(t.opsType=_.Push,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[K]("resolve route fail",t),this)}put(...e){const t=this[M](e);return t?(t.opsType=_.Put,t.historyUpdatePolicy=t.historyUpdatePolicy??"traceless",this.to(t)):(this[K]("resolve route fail",t),this)}replace(...e){const t=this[M](e);return t?(t.opsType=_.Replace,t.historyUpdatePolicy=t.historyUpdatePolicy??"replace",this.to(t)):(this[K]("resolve route fail",t),this)}append(...e){const t=this[M](e);return t?(t.opsType=_.Append,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[K]("resolve route fail",t),this)}remove(e,t){return new Promise(r=>{this[be].post(s=>{try{if(this[b].length===0){s.resolve(),r(!1);return}let i=-1,n=null,o=[];if(e){if(n=e.root??"default",e.all)for(let l=this[b].length-1;l>0;l--){const a=this[b][l];if(a.opsType===_.Append){const f=a.root??"default";if(n&&n!==f)continue;o.splice(0,0,a),i=l-1}}else if(e.until)for(let l=this[b].length-1;l>0;l--){let a=this[b][l];if(a.opsType===_.Append&&a.root===n){if(e.until.charAt(0)==="/"&&e.until===a.path){i=l;break}else if(e.until===a.name){i=l;break}o.splice(0,0,a)}}else if(e.to)for(let l=this[b].length-1;l>0;l--){const a=this[b][l];if(a.opsType===_.Append){const f=a.root??"default";if(n&&n!==f)continue;if(o.splice(0,0,a),e.to.charAt(0)==="/"&&e.to===a.path){i=l-1;break}else if(e.to===a.name){i=l-1;break}}}}else for(let l=this[b].length-1;l>0;l--){let a=this[b][l];if(a.opsType===_.Append){o.push(a),i=l-1;break}}if(i===-1||o.length===0){const l="[Fox]can not find route";console.warn(l),s.resolve(l),r(!1);return}let u=null;if(i!==-1&&(u=this[b][i]),this[Ie](o)){if(t===!1)return s.resolve(),r(!0),!0;const l=()=>(s.resolve(),r(!0),!0),a=this[b].length;if(u&&E.isSame(u,this[b][a-1])){this[P]?.goBack(u,l);return}l()}}catch(i){this[K](i),s.resolve(),r(!1)}})})}open(...e){const t=this[M](e);return t?(t.opsType=_.Open,t.historyUpdatePolicy=t.historyUpdatePolicy??"push",this.to(t)):(this[K]("resolve route fail",t),this)}close(e){return this[be].post(t=>{try{let r=this[M](e);if(!r){t.reject("resolve route fail");return}let s=[];for(let i=0;i<this[b].length;i++){let n=this[b][i];if(n.root===r.root){if(!r.path&&!r.name){s.push(n);continue}if(r.path&&r.path===n.path){s.push(n);break}else if(r.name&&r.name===n.name){s.push(n);break}}}if(s.length===0){t.resolve();return}this[Ie](s),t.resolve()}catch(r){this[K](r),t.resolve()}}),this}to(...e){const t=this[M](e);if(!t)return this[K]("resolve route fail",t),this;const r=this[Be].acquire(t);return r==null?(this[K]("route forbid",t),this):(this[be].post(s=>{try{let i=this[Dt](t);this[Ht](i),this[Ut](i),this[Nt](i),i.wait((n,o)=>{const u=n.session.to;if(n.session.updateResult&&n.session.updateResult.status==="success")try{const l=new Pr(E.clone(u,!0),this[ot]());u.historyUpdatePolicy==="replace"?this[P]?.replace(l):u.historyUpdatePolicy==="traceless"?this[P]?.setRouteMark(l):this[P]?.push(l)}catch(l){console.error(l.message,l)}if(Qe.clear(n.session),this[Be].release(r),typeof t.success=="function")try{Reflect.apply(t.success,{},[])}catch(l){console.error(l.message,l)}this[ye]===!1&&this[ut](!0),i=null,s.resolve()},(n,o)=>{this[Be].release(r),o!==null&&this[K](o,t),this[ye]===!1&&this[ut](!1),Qe.clear(n.session),i=null,s.resolve()})}catch(i){this[Be].release(r),this[K](i,t),s.resolve()}}),this)}back(e=1){this[P]?.go(-e,!1)}[kr](e){return(t,r)=>{if(typeof t=="boolean")e.session.redirect=!1,t?e.resolve():e.reject(r??null);else if(t){const s=this[M](t);if(s){const i=e.session.to;s.success=i.success,s.error=i.error,e.session.to=s,e.session.redirect=!0,e.session.routeModel=null,e.resolve()}else e.session.redirect=!1,e.reject("route resolve fail")}else e.session.redirect=!1,e.resolve()}}[Dt](e){const t=new Qe(e,this[b].length>0?this[b][this[b].length-1]:void 0),r={route:e,find:null};if(this[st](r),r.find){t.routeModel=r.find,e.matched=r.find.matchedRoutes??[];const s={};if(Array.isArray(r.find?.matchedRoutes))for(let i=0;i<r.find.matchedRoutes.length;i++){const n=r.find.matchedRoutes[i];n.meta&&typeof n.meta=="object"&&Object.assign(s,n.meta)}e.meta&&typeof e.meta=="object"&&Object.assign(s,e.meta),e.meta=s}return new qe(t)}[Ht](e){for(let t of this[Te])e.post(r=>{const s=this[kr](r);Reflect.apply(t,{},[r.session.to,r.session.from,s,r.session])})}[Nt](e){e.post(t=>{for(let r of this[Me])try{Reflect.apply(r,{},[t.session.to,t.session.from,t.session])}catch(s){console.error(s.message,s)}t.resolve()})}[Ir](e,t){for(let r of this[ke])try{Reflect.apply(r,{},[e,t])}catch(s){console.error(s.message,s)}typeof e.destroy=="function"&&Reflect.apply(e.destroy,e,[])}[Ut](e){e.post(t=>{const r=t.session.to;let s=t.session.routeModel;if(s==null){let n={route:r,find:null};if(this[st](n))s=n.find,t.session.routeModel=s;else if(this[at])s=this[at];else{t.reject(`not find route model, path:${r.path??r.name}`);return}}const i=Qe.from(t.session);this[Kr](r,s,i).then(n=>{this[G],t.session.updateResult=n??{status:"success",message:""},t.resolve()},n=>{t.reject(n)})})}[Ie](e){if(e.length==0)return!0;let t=this[G],r=[];for(let s of e){let i=this[Lt](t,s);i!=null&&r.push({...i,route:s})}if(r.length==0)return this[K]("can not find view index"),!1;for(let s of r.reverse())this[ce](t,{x:s.x,y:s.y},[s.route.index??0],!0);return!0}[Lt](e,t){const r=t.root??"default";let s;for(let i=0;i<e.layers.length;i++){const n=e.layers[i];for(let o=n.views.length-1;o>=0;o--){const u=n.views[o];if(u[J]&&u[Ze]===r)return s={x:o,y:i},s}}return null}[Xs](e){return e.layers.length>0&&e.layers[0].views.length>0?e.layers[0].views[0]:null}[ce](e,t,r=null,s=!0){if(t.y>=e.layers.length||t.x>=e.layers[t.y].views.length)return;let i=e.layers[t.y].views[t.x],n=!1,o=[],u=!1,l=[...i.slots.value];for(let f=l.length-1;f>=0;f--){let c=l[f];(!r||r.indexOf(c.index)!=-1)&&(c.route&&i[J]&&(this[Le](c.route),c.active===!0&&c.route.opsType==_.Append&&(u=!0)),o.push(new D(i,c.index,t.y)),l.splice(f,1))}if(l.length==0)s?i.slots.value=l:e.layers[t.y].views.splice(t.x,1);else{if(u){let f=l[l.length-1];f.active=!0,f.route&&(f.route.active=f.active)}i.slots.value=l}e.layers[t.y].views.length==0&&(n=!0);let a=t.y+1;for(;a<e.layers.length;a++){let f=e.layers[a].views,c=[];for(let h=f.length-1;(n||o.length>0)&&h>=0;h--){let y=f[h];if(y[ae]&&(n||D.include(o,y[ae]))){let m=y.slots.value;for(let v=m.length-1;v>=0;v--){let R=m[v];R.route&&y[J]&&this[Le](R.route),c.push(new D(y,R.index,a)),m.splice(v,1)}e.layers[a].views.splice(h,1)}}o=c,e.layers[a].views.length==0&&(n=!0)}}restore(e){if(!e||this[N].length==0){let t=this[G];if(t.layers.length>0){let r=t.layers[0].views;r.length>0&&(r[0].slots.value=[])}return this[b]=[],this[he](null),Promise.resolve()}else return new Promise((t,r)=>{let s=null,i=!1;for(let n=0;n<e.length;n++){const o=e[n];this[be].post(u=>{const l=this[Dt](o);this[Ht](l),this[Ut](l),this[Nt](l),l.wait((a,f)=>{s=a.session.to,i=a.session.redirect,u.resolve()},(a,f)=>{s=null,f!==null&&this[K](f),u.resolve()})})}this[be].post(n=>{if(s&&i===!0){const o=new Pr(E.clone(s,!0),this[ot]());this[P]?.replace(o)}n.resolve(),t()})})}async[Kr](e,t,r){const s=e.updateType??At.Part;await this[Lr](t);const i=this[Tr](t,e,r,s);if(i.status==="error")throw Error(i.message);return i}[Lr](e){let t=[];for(let r=0;r<e.layers.length;r++){let s=e.layers[r];for(let i=0;i<s.models.length;i++){let n=s.models[i];n.isResolved||t.push(n.resolve())}}return t.length>0?Promise.all(t):Promise.resolve()}[Tr](e,t,r,s){if(e.layers[0].models.length!==1)return{status:"error",message:"illegal route structure(multi root node)"};const i=e.layers[0].models[0];let n=this[G],o=Qs(n),u=t.root??"default",l;!o&&s==At.Part&&(l=this[Lt](n,t));let a,f=0;if(l==null||l==null)if(o||s===At.All)n.layers.length==0&&(n.layers[0]=new jt),n.layers[0].views.length==0?(a=new Ae(t.root??"default",!0,null),n.layers[0].views=[a]):a=n.layers[0].views[0],l={x:0,y:0};else{let c=t.slot;if(!c)return{status:"error",message:"can not rebuild view(because not route slot)"};let h=c.level;if(h>n.layers.length)return{status:"error",message:"can not insert view(override level)"};let y;if(c.rootName){let m=n.layers[h-1];for(let v of m.views){if(v[J]&&v.name===c.rootName){y=new D(v,c.rootIndex??0,h-1);break}if(v[z]&&v[z].view.name===c.rootName&&v[z].index===c.rootIndex){y=v[z];break}}}if(!y)return{status:"error",message:"can not insert view(not find root node ref)"};a=new Ae(u,!0,y),n.layers[h].views.push(a),l={x:n.layers[h].views.length-1,y:h}}else a=n.layers[l.y].views[l.x];if(f=l.y,a[J]=!0,t.opsType===_.Append){t.index=t.index??Ce.get(),t.active=!0;let c=a.slots.value;if(c.length>0){let R=c[c.length-1];R.active=!1,R.route&&(R.route.active=R.active)}let h=new re(t,i,t.index,!0);a.slots.value=[...c,h];let y=f+1,m=1,v=new D(a,t.index,f);this[se](n,y,e,m,v)}else if(t.opsType===_.Open){let c=a.slots.value;const h=t.active??!0;let y=!1;for(let m of c){if(m.route!==null&&E.isSamePathForRoute(m.route,t)){if(m.active===h)return t.index=m.index,t.active=h,m.route=t,{status:"noChange",message:""};m.active=h,y=!0,t.index=m.index,t.active=h,m.route=t}else h&&(m.active=!1);m.route&&(m.route.active=m.active)}if(!y){t.index=t.index??Ce.get(),t.active=h;let m=new re(t,i,t.index,h);c.push(m);let v=f+1,R=1,w=new D(a,t.index,f);this[se](n,v,e,R,w)}a.slots.value=[...c]}else{let c=a.slots.value;if(c.length==0){t.index=t.index??Ce.get(),t.active=!0,a.slots.value=[new re(t,i,t.index)];let h=f+1,y=1,m=new D(a,t.index,f);this[se](n,h,e,y,m)}else{let h=c[0];if(h.model!==i){this[ce](n,l,null,!0),t.index=t.index??Ce.get(),t.active=!0,a.slots.value=[new re(t,i,t.index)];let y=f+1,m=1,v=new D(a,t.index,f);this[se](n,y,e,m,v)}else{h.route!==null&&this[Le](h.route);let y=!1;const m=t.active??!0;h.active!==m&&(h.active=m,y=!0),t.active=m,t.index=h.index,h.route=t;let v=[];for(let I=1;I<c.length;I++)v.push(c[I].index);v.length>0?this[ce](n,l,v,!0):y&&(a.slots.value=[...c]);let R=[new D(a,t.index,f)],w=f+1,g=1,T=new D(a,t.index,f);for(;R.length>0&&w<n.layers.length&&g<e.layers.length;w++,g++){let I=[];for(let B=0;B<n.layers[w].views.length;B++){let L=n.layers[w].views[B];L[ae]&&D.include(R,L[ae])&&I.unshift(B)}let Ue=[];for(let B of I){let L=n.layers[w].views[B],de=e.layers[g].models,te;for(let O=0;O<de.length;O++)if(L.name===de[O].name){te=de[O];break}if(!te)this[ce](n,{x:B,y:w},null,!1);else{let O=L.slots.value;if(O.length==0){let ee=0;L.slots.value=[new re(null,te,ee)];let X=w+1,Q=g+1;this[se](n,X,e,Q,T)}else{let ee=O[0];if(ee.model!==te){this[ce](n,{x:B,y:w},null,!0),L.slots.value=[new re(null,te,0)];let X=w+1,Q=g+1;this[se](n,X,e,Q,T)}else{L[J]&&ee.route!==null&&this[Le](ee.route);let X=[];for(let Q=1;Q<O.length;Q++)X.push(O[Q].index);X.length>0&&this[ce](n,{x:B,y:w},X,!0),Ue.push(new D(L,ee.index,w))}}L[J]=!1}}R=Ue}this[se](n,w,e,g,T)}}}if(a&&a[z]){let c=a[z];c&&(t.slot=new Ns(u,f,c?.view.name,c?.index??0))}return r.to=void 0,r.routeModel=void 0,this[Mr](t,r),{status:"success",message:""}}[se](e,t,r,s,i){let n=s,o=t;for(;o<e.layers.length&&n<r.layers.length;o++,n++){let u=e.layers[o].views;for(let l of r.layers[n].models){let a=new Ae(l.name,!1,i),f=new re(null,l);a.slots.value=[f],u.push(a)}}for(;n<r.layers.length;n++){let u=new jt;u.views=[];for(let l of r.layers[n].models){let a=new Ae(l.name,!1,i),f=new re(null,l);a.slots.value=[f],u.views.push(a)}e.layers.push(u)}}[Sr](e,t,r,s,i,n){if(t<0||t>this[G].layers.length)return null;if(t<this[G].layers.length){let a=this[G].layers[t],f=null;for(let c of a.views){let h=!1;if(r!==null?(h=c.name===e&&c[z]?.view===r,h&&s!==-1&&(h=c[z]?.index===s)):h=c.name===e,!!h){i!==null&&(c[ae]={view:i,index:n,level:t-1}),f=c;break}}if(f!==null)return f}let o=null,u=null;i!==null&&(i[J]?o={view:i,index:n,level:t-1}:o=i[z],u={view:i,index:n,level:t-1});let l=new Ae(e,!0,o);if(l[ae]=u,t==this[G].layers.length){let a=new jt;a.views=[l],this[G].layers.push(a)}else this[G].layers[t].views.push(l);return l}},Oe=Symbol("rk"),Vt=Symbol("vd"),Or=Symbol("rv"),Wt=Symbol("rvi"),Dr=Symbol("pv"),Jt=Symbol("pvi"),De=Symbol("registerKey"),Hr=Symbol("lc"),Zs=class{[De]=new Map;constructor(){}set(e,t){this[De].set(e,t)}get(e){return this[De].get(e)}has(e){return this[De].has(e)}delete(e){return this[De].delete(e)}},ie=new WeakMap,He=[];function ft(e,t=!1){let r=e?ie.get(e)??null:null;return t&&!r&&(r=new Zs,e&&ie.set(e,r),(0,d.onScopeDispose)(()=>{e&&ie.delete(e)}),(0,d.provide)(Hr,r)),r}function Ne(e){let t=e?ie.get(e)??null:null;return!t&&(0,d.hasInjectionContext)()&&(t=(0,d.inject)(Hr,null)),!t&&He.length>0&&(t=He[He.length-1]),t}async function Nr(e,t){He.push(e);try{return await t()}finally{He.pop()}}function Ys(e){const t=(0,d.getCurrentScope)();if(!t)return!1;const r=Ne();if(!r)return!1;if(ie.set(t,r),Array.isArray(e))for(let s=0;s<e.length;s++)ie.set(e[s],r);return(0,d.onScopeDispose)(()=>{if(ie.delete(t),Array.isArray(e))for(let s=0;s<e.length;s++)ie.delete(e[s])}),!0}function zt(e,t){return Ne(e)?.get(t)??null}function ei(e,t,r){Ne(e)?.set(t,r)}function ti(e,t,r){Ne(e)?.delete(t)}var ct=Symbol("hooksKey");function ri(e){let t=e.get(ct);t||(t=[],e.set(ct,t))}function Ur(e,t){const r=e.get(ct);r!=null&&Nr(e,async()=>{for(let s=r.length-1;s>=0;s--){let i=r[s];if(i.type===t)try{await Reflect.apply(i.hook,null,[])}catch(n){console.error(n.message,n)}}})}var ht=(function(e){return e.INACTIVATED="ia",e.ACTIVATED="a",e})({}),si=class{type;hook;constructor(e,t){this.hook=t,this.type=e}};function ii(e,t,r){const s=new si(t,r);return e.push(s),!0}function ni(e,t,r){let s=-1;for(let i=0;i<e.length;i++){const n=e[i];if(n.type===t&&n.hook===r){s=i;break}}return s!=-1?(e.splice(s,1),!0):!1}function Vr(e){return t=>{const r=zt(null,ct);if(r==null){console.warn("[Fox]hooks context not found");return}(0,d.onScopeDispose)(()=>{ni(r,e,t)}),ii(r,e,t)}}var oi=function(e){(0,d.onActivated)(e),Vr(ht.ACTIVATED)(e)},li=function(e){(0,d.onDeactivated)(e),Vr(ht.INACTIVATED)(e)},Wr=Symbol("routeKey");function Jr(e,t){e.set(Wr,t)}function Gt(e){const t=zt(e??null,Wr);return typeof t=="function"?t():t}var zr="FoxBeforeEnter",Gr="FoxEnter",Xr="FoxLeave",Qr="FoxLeave",yt="FoxLeaveEnd";function Zr(e,t=!1){let r=null;return t?r=e.showFromClass??e.enterFromClass:r=e.enterFromClass,r||(r=e.transitionName,r?t?`${r}-show-from`:`${r}-enter-from`:null)}function Yr(e,t=!1){let r=null;return t?r=e.showActiveClass??e.enterActiveClass:r=e.enterActiveClass,r||(r=e.transitionName,r?t?`${r}-show-active`:`${r}-enter-active`:null)}function ai(e,t=!1){let r=null;return t?r=e.showToClass??e.enterToClass:r=e.enterToClass,r||(r=e.transitionName,r?t?`${r}-show-to`:`${r}-enter-to`:null)}function es(e,t=!1){let r=null;return t?r=e.hideFromClass??e.leaveFromClass:r=e.leaveFromClass,r||(r=e.transitionName,r?t?`${r}-hide-from`:`${r}-leave-from`:null)}function ts(e,t=!1){let r=null;return t?r=e.hideActiveClass??e.leaveActiveClass:r=e.leaveActiveClass,r||(r=e.transitionName,r?t?`${r}-hide-active`:`${r}-leave-active`:null)}function ui(e,t=!1){let r=null;return t?r=e.hideToClass??e.leaveToClass:r=e.leaveToClass,r||(r=e.transitionName,r?t?`${r}-hide-to`:`${r}-leave-to`:null)}function fi(e,t=!1){let r=null;return t?r=e.beforeShow??e.beforeEnter:r=e.beforeEnter,r}function ci(e,t=!1){let r=null;return t?r=e.show??e.enter:r=e.enter,r}function hi(e,t=!1){let r=null;return t?r=e.afterShow??e.afterEnter:r=e.afterEnter,r}function yi(e,t=!1){let r=null;return t?r=e.showCancelled??e.enterCancelled:r=e.enterCancelled,r}function di(e,t=!1){let r=null;return t?r=e.beforeHide??e.beforeLeave:r=e.beforeLeave,r}function mi(e,t=!1){let r=null;return t?r=e.hide??e.leave:r=e.leave,r}function pi(e,t=!1){let r=null;return t?r=e.afterHide??e.afterLeave:r=e.afterLeave,r}function vi(e,t=!1){let r=null;return t?r=e.hideCancelled??e.leaveCancelled:r=e.leaveCancelled,r}function Xt(e){let t,r=e.transitionDuration;return typeof r=="object"?t={enter:r.enter??-1,leave:r.leave??-1,show:r.show??-1,hide:r.hide??-1}:(typeof r=="string"&&(r=r.length==0?-1:Number(r)),t={enter:r,leave:r,show:r,hide:r}),t}function we(e,t){e.classList.contains(t)||e.classList.add(t)}function Re(e,t){e.classList.remove(t)}var gi=me&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout;function dt(e){gi(e)}function $(e,t){S(e)&&Reflect.apply(e,null,t)}function rs(e,t,r=-1,s,i,n){let o=[];const u=()=>{for(let l of o)gt(e,l.type,l.listener);o=[]};if(S(i)){if(s!==void 0&&s>=0){setTimeout(()=>{Reflect.apply(i,null,[e,t,r])},s);return}const l=["animationend","transitionend",yt],a=f=>{(f.target||f.srcElement)===f.currentTarget&&(u(),Reflect.apply(i,null,[e,t,r]))};l.forEach(f=>{Je(e,f,a),o.push({type:f,listener:a})})}if(S(n)){const l="animationcancel",a=f=>{(f.target||f.srcElement)===f.currentTarget&&(u(),Reflect.apply(n,null,[e,t,r]))};Je(e,l,a),o.push({type:l,listener:a})}}function mt(e){return!me||e===null?!1:e.opsType===_.Append||e.opsType===_.Open}function ss(e,t,r={},s,i=-1){if(e||mt(s)){const n=Zr(r,e);n&&we(t,n);const o=Yr(r,e);o&&we(t,o),$(fi(r,e),[t,e,s,i])}}function is(e,t,r={},s,i,n,o){if(!mt(i)&&!e){S(o)&&o(o,[t]);return}const u=Zr(r,e),l=Yr(r,e),a=ai(r,e),f=ci(r,e),c=hi(r,e),h=yi(r,e);if(!u&&!l&&!a&&!f){S(o)&&o(o,[t]);return}dt(()=>{rs(t,i,n,s,()=>{l&&Re(t,l),a&&Re(t,a),S(c)&&$(c,[t,e,i,n]),S(o)&&o(o,[t])},()=>{S(h)&&$(h,[t,e,i,n])}),u&&Re(t,u),a&&we(t,a),S(f)&&$(f,[t,e,i,n])})}function ns(e,t,r={},s,i=-1){if(e||mt(s)){const n=es(r,e);n&&we(t,n);const o=ts(r,e);o&&we(t,o),$(di(r,e),[t,e,s,i])}}function os(e,t,r={},s,i,n,o,u){if(!mt(n)&&!e){S(u)&&$(u,[t]),!e&&S(i)&&i();return}const l=es(r,e),a=ts(r,e),f=ui(r,e),c=mi(r,e),h=pi(r,e),y=vi(r,e);if(!l&&!a&&!f&&!c){S(u)&&$(u,[t]),!e&&S(i)&&i();return}dt(()=>{rs(t,n,o,s,()=>{try{a&&Re(t,a),f&&Re(t,f),S(h)&&$(h,[t,e,n,o]),S(u)&&$(u,[t])}finally{!e&&S(i)&&i()}},()=>{try{S(y)&&$(y,[t,e,n,o]),S(u)&&$(u,[t])}finally{!e&&S(i)&&i()}}),l&&Re(t,l),f&&we(t,f),S(c)&&$(c,[t,e,n,o])})}function Qt(e,t={},r,s=-1){const i=t.mode??"default",n=Xt(t);return{mode:i,persisted:!1,beforeEnter:o=>{ss(!1,o,t,r,s)},enter:o=>{is(!1,o,t,n.enter,r,s)},leave:(o,u)=>{ns(!1,o,t,r,s),os(!1,o,t,n.leave,u,r,s,()=>{e.transition=null})},clone:o=>Qt(e,t,r,s)}}function ls(e){return e.el}function bi(e,t={},r,s,i,n){if(i===!0){const o=ls(e);if(o==null)return;const u=Xt(t);ss(!0,o,t,r,s),is(!0,o,t,u.show,r,s,l=>{S(n)&&$(n,[l])})}else S(n)&&$(n,[])}function wi(e,t={},r,s,i,n){if(i===!0){const o=ls(e);if(o==null)return;const u=Xt(t);ns(!0,o,t,r,s),os(!0,o,t,u.hide,null,r,s,l=>{S(n)&&$(n,[l])})}else S(n)&&$(n,[])}function Ri(e){dt(()=>{for(let t=0;t<e.length;t++)Reflect.apply(e[t],null,[])})}function as(e,t={},r,s=-1){return{mode:t.mode??"default",persisted:!1,beforeEnter:i=>{ze(zr,{},i)},enter:i=>{ze(Gr,{},i)},leave:(i,n)=>{ze(Xr,{},i),dt(()=>{const o=u=>{(u.target||u.srcElement)===u.currentTarget&&(gt(i,yt,o),n&&Reflect.apply(n,null,[]),e.transition=null)};Je(i,yt,o),ze(Qr,{},i)})},clone:i=>as(e,t,r,s)}}function ne(e,t,r){return typeof e=="function"?Reflect.apply(e,{},[t,r]):e}function Zt(e,t){if(!e)return null;const r=e(t);return r.length===1?r[0]:r}function Se(e,t){return typeof t=="function"?t(e):e}var Si=class{node;state;constructor(e,t){this.node=e,this.state=t}},pt=(0,d.defineComponent)({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,required:!1,default:"default"},modelSlot:{type:[Object],required:!1},multi:{type:Boolean,required:!1,default:!1},tag:{type:[String,Object,Function],required:!1,default:"div"},viewTag:{type:[String,Object,Function],required:!1,default:"div"},viewTagProps:{type:[Object,Function],required:!1,default(){return{}}},viewClass:{type:[String,Function],required:!1},viewActiveClass:{type:[String,Function],required:!1},viewInactiveClass:{type:[String,Function],required:!1},transition:{type:[Boolean,String,Function],required:!1,default:!1},transitionName:{type:String,required:!1},transitionDuration:{type:[String,Number,Object],required:!1},enterFromClass:{type:String,required:!1},enterActiveClass:{type:String,required:!1},enterToClass:{type:String,required:!1},leaveFromClass:{type:String,required:!1},leaveActiveClass:{type:String,required:!1},leaveToClass:{type:String,required:!1},showFromClass:{type:String,required:!1},showActiveClass:{type:String,required:!1},showToClass:{type:String,required:!1},hideFromClass:{type:String,required:!1},hideActiveClass:{type:String,required:!1},hideToClass:{type:String,required:!1},beforeEnter:{type:Function,required:!1},enter:{type:Function,required:!1},afterEnter:{type:Function,required:!1},enterCancelled:{type:Function,required:!1},beforeLeave:{type:Function,required:!1},leave:{type:Function,required:!1},afterLeave:{type:Function,required:!1},leaveCancelled:{type:Function,required:!1},beforeShow:{type:Function,required:!1},show:{type:Function,required:!1},afterShow:{type:Function,required:!1},showCancelled:{type:Function,required:!1},beforeHide:{type:Function,required:!1},hide:{type:Function,required:!1},afterHide:{type:Function,required:!1},hideCancelled:{type:Function,required:!1}},setup(e,t){const r=(0,d.getCurrentScope)(),s=e.multi===!0,i=(0,d.inject)(Oe,null),n=(0,d.inject)(Vt,0),o=(0,d.inject)(Or,null),u=(0,d.inject)(Wt,-1);let l=null,a=e.modelSlot??null;if(a){if((0,d.provide)(Vt,n+1),(0,d.provide)(Wt,a.index),(0,d.provide)(Jt,a.index),!a.route){console.warn("[Fox]child view render error, route not exist");return}const c=ft(a,!0);c&&(ri(c),Jr(c,()=>a?.route??null))}else{if(i==null){console.error("[Fox]router is not been injected");return}const c=e.name,h=(0,d.inject)(Dr,null),y=(0,d.inject)(Jt,0);if(l=i[Sr](c,n,o,u,h,y),l===null)return;(0,d.provide)(Dr,l);const m=l[J]===!0;if(m&&(0,d.provide)(Or,l),!s&&((0,d.provide)(Wt,-1),(0,d.provide)(Vt,n+1),(0,d.provide)(Jt,-1),m&&r)){const v=ft(r,!0);v&&Jr(v,()=>{const R=l?.slots.value??[];return R.length>0?R[0].route:null})}}const f={value:new Map};return(0,d.onScopeDispose)(()=>{if(f.value&&f.value.clear(),a){const c=a;c.route=null,c.model=null,c.instance=null,a=null}}),()=>{if(s){const c=new Map,h=[],y=l?.slots.value,m=[];for(let w=0;w<y.length;w++){const g=y[w],T=`${e.name}_${g.index}`,I=ne(e.transition,g.route,w)??!0,Ue={modelSlot:g};let B;t.slots.default?B=(0,d.h)(pt,Ue,{default:t.slots.default}):B=(0,d.h)(pt,Ue);const L={},de=ne(e.viewClass,g.route,w);typeof de=="string"&&de.length>0&&(L[de]=!0);const te=ne(e.viewActiveClass,g.route,w),O=ne(e.viewInactiveClass,g.route,w),ee=f.value.get(T);if(typeof te=="string"&&te.length>0&&(L[te]=g.active),typeof O=="string"&&O.length>0&&(L[O]=!g.active),ee&&g.active!==ee.state){const hs=ee.node;g.active?m.unshift(()=>{const nr=()=>{const Ve=ft(g);Ve!=null&&Ur(Ve,ht.ACTIVATED)};bi(hs,e,g.route,w,I,nr)}):m.push(()=>{const nr=()=>{const Ve=ft(g);Ve!=null&&Ur(Ve,ht.INACTIVATED)};wi(hs,e,g.route,w,I,nr)})}const X={class:L,key:T},Q=ne(e.viewTagProps,g.route,w);Q!==null&&typeof Q=="object"&&q(!0,X,Se(Q,i?.propsFilter)),g.route?.viewTagAttrs&&typeof g.route?.viewTagAttrs=="object"&&q(!0,X,Se(g.route.viewTagAttrs,i?.propsFilter));const Pe=(0,d.h)(ne(e.viewTag,g.route,w),X,{default:()=>[B]});c.set(T,new Si(Pe,g.active)),f.value.delete(T),I===!0?Pe.transition=Qt(Pe,e,g.route,w):I==="custom"&&(Pe.transition=as(Pe,e,g.route,w)),h.push(Pe)}f.value=c,Ri(m);const v=ne(e.tag,null,-1),R={};return Object.assign(R,t.attrs),(0,d.h)(v,R,{default:()=>h})}else if(a!=null){const c=a.model,h={};c.props&&(typeof c.props=="object"?q(!1,h,Se(c.props,i?.propsFilter)):c.props===!0&&typeof a.route?.params=="object"&&q(!1,h,Se(a.route.params,i?.propsFilter)));const y=(0,d.h)(c.component,h);return Zt(t.slots.default,{Component:y,route:a.route})??y}else{const c=l?.slots.value??[];if(c.length>0){const h=c[0],y=h.route,m=h.model,v={};m.props&&(typeof m.props=="object"?q(!1,v,Se(m.props,i?.propsFilter)):m.props===!0&&typeof y?.params=="object"&&q(!1,v,Se(y.params,i?.propsFilter)));const R=(0,d.h)(m.component,v);return(ne(e.transition,y,-1)??!0)&&(R.transition=Qt(R,e,y,-1)),Zt(t.slots.default,{Component:R,route:y})??R}else return Zt(t.slots.fallback,{})}}}});function xi(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!=null&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Ei(e,t){return e==null||t==null?!1:!!(e.path&&t.path&&t.path.startsWith(e.path)||e.name&&e.name==t.name)}function xe(e,t){return typeof e=="function"?Reflect.apply(e,{},[t]):e}var us=(0,d.defineComponent)({name:"RouterLink",inheritAttrs:!1,props:{tag:{type:[String,Object,Function],required:!1,default:"a"},to:{type:[String,Object,Function],required:!0},root:{type:String},activeClass:{type:[String,Function],required:!1,default:"fox-router-link-active"},exact:{type:[String,Boolean,Function],required:!1},exactActiveClass:{type:[String,Function],required:!1,default:"fox-router-link-exact-active"},event:{type:[String,Function],required:!1,default:"onClick"}},setup(e,t){const r=(0,d.inject)(Oe,null);return()=>{let s=xe(e.to,null),i=xe(e.tag,s);if(i==null){console.warn("[Fox]can not resolve link tag");return}let n=null,o=null;r!==null&&(n=r[M](s),e.root&&(n.root=e.root),o=r.currentRoute.value);let u={},l=xe(e.activeClass,n);if(typeof l=="string"&&l.length>0&&(u[l]=Ei(n,o)),xe(e.exact,n)===!0){let c=xe(e.exactActiveClass,n);typeof c=="string"&&c.length>0&&(u[c]=E.isSamePathForRoute(n,o))}let a={class:u};(i==="a"||i==="A")&&(a.href=n?.path??n?.name??"#"),q(!0,a,t.attrs);const f=xe(e.event,n);if(typeof f=="string"){const c=h=>{if(r==null){console.warn("[Fox]router is not been injected");return}if(n==null){console.warn("[Fox]route is not been resolved");return}xi(h)&&r.to(n)};a[f]=c}return(0,d.h)(i,a,t.slots)}}}),vt=(function(e){return e[e.limitless=0]="limitless",e[e.once=1]="once",e})(vt||{}),Ee=Symbol("registerKey"),Pi=class{policy;callback;constructor(e,t){this.callback=e,this.policy=t}},Yt=class{[Ee]=new Map;constructor(){}on(e,t,r=!1){let s=this[Ee].get(e);s||(s=new Array,this[Ee].set(e,s));let i=new Pi(t,r===!0?vt.once:vt.limitless);return s.push(i),this}off(e,t){if(!t)return this[Ee].delete(e),this;let r=this[Ee].get(e);if(r){for(let s=0;s<r.length;s++)if(r[s].callback===t){r.splice(s,1);break}}return this}bind(e,t,r=!1){return this.on(e,t,r)}unbind(e,t){return this.off(e,t)}once(e,t){return this.on(e,t,!0)}all(...e){let t=e.length;if(t<1)return this;let r=e[t-1];if(typeof r!="function")return console.error("[Fox]callback can not be empty"),this;let s=t-1,i=new Array(s),n=[].splice.call(e,0,s);for(let o=0;o<n.length;o++)this.once(n[o],u=>{i[o]=u,s-=1,s==0&&Reflect.apply(r,{},i)});return this}emit(e,...t){let r=this[Ee].get(e);if(!r)return this;for(let s=0;s<r.length;){let i=r[s];if(i.policy==vt.once?r.splice(s,1):s++,typeof i.callback=="function")try{Fe(()=>{Reflect.apply(i.callback,{},t)})}catch(n){console.error(n.message,n)}}return this}trigger(e,...t){return Reflect.apply(this.emit,this,[e,...t])}},Ci="FoxRouterView",Fi="FoxRouterLink",U=(function(e){return e[e.Loading=0]="Loading",e[e.Loaded=1]="Loaded",e[e.Defining=2]="Defining",e[e.Defined=3]="Defined",e})({});function _i(e){return e==U.Loaded||e===U.Defined}var fs=(function(e){return e[e.normal=0]="normal",e[e.factory=1]="factory",e})({}),Ai=class{register=new Map;regExpRegisters=[];constructor(){}get(e){let t=this.register.get(e)??null;return t||(t=this.regExpRegisters.find(r=>r.pattern?.test(e))?.module??null),t}has(e){return!!this.get(e)}set(e,t){if(typeof e=="string")this.register.set(e,t);else if(e instanceof RegExp){const r=this.regExpRegisters.find(s=>(s.pattern?.source??"")===(e?.source??""));r?r.module=t:this.regExpRegisters.push({pattern:e,module:t})}}remove(e){if(typeof e=="string"){const t=this.register.get(e);return this.register.delete(e),t??null}else if(e instanceof RegExp){const t=this.regExpRegisters.findIndex(r=>(r.pattern?.source??"")===(e?.source??""));if(t!==-1){const r=this.regExpRegisters[t].module??null;return this.regExpRegisters.splice(t,1),r}}return null}clear(){this.register.clear(),this.regExpRegisters=[]}},er=["require","exports","module"];async function ji(e){return await new Function("url","return import(url)")(e)}var cs=class{moduleManager=new Ai;_alias={};set alias(e){this._alias=e}get alias(){return this._alias}_resourceParser;set resourceParser(e){this._resourceParser=e}get resourceParser(){return this._resourceParser}_timeout;set timeout(e){this._timeout=e}get timeout(){return this._timeout}_query;set query(e){this._query=e}get query(){return this._query}get head(){return We().head}_cssMountPoint=null;set cssMountPoint(e){this._cssMountPoint=e}get cssMountPoint(){return this._cssMountPoint}_jsMountPoint=null;set jsMountPoint(e){this._jsMountPoint=e}get jsMountPoint(){return this._jsMountPoint}setModule(e,t){const r={id:typeof e=="string"?e:e?.source,src:"",status:U.Loaded};typeof t=="function"?(r.exports=t,r.type=fs.factory):r.exports=t,this.moduleManager.set(e,r)}removeModule(e){this.moduleManager.remove(e)}getModuleExports(e){const t=this.moduleManager.get(e);return t&&_i(t.status)?t.type===fs.factory&&typeof t.exports=="function"?t.exports():t.exports:null}exposeRequire(e="__foxRequire",t,r){const s=t??j();return s&&typeof s=="object"?(s[e]=i=>{const n=this.getModuleExports(i);return r&&!n&&console.error(`[Fox] module:${i}, not found!`),n},!0):!1}resloveResource(e){if(typeof e=="string"){if(er.includes(e))return e;if(e=this.alias?.[e]??e,typeof this.resourceParser=="function"){const r=this.resloveResource(e);if(!r)return r}const t=this.getResourcePathSuffix(e);if(t==="mjs")return{path:e,type:"js",format:"es"};if(t==="js")return{path:e,type:"js",format:"umd"};if(t==="css")return{path:e,type:"css"}}return e}ensure(...e){return new Promise((t,r)=>{if(e.length<=0){r("args is empty");return}const s=[];let i=e.length-1,n=null;typeof e[i]=="function"&&(n=e[i],i--);for(let l=0;l<=i;l++)if(Array.isArray(e[l])){const a=e[l];for(let f=0;f<a.length;f++){const c=this.resloveResource(a[f]);s.push(c)}}else if(typeof e[l]=="string"){const a=this.resloveResource(e[l]);s.push(a)}const o=new qi(s.length,(l,a)=>{if(o.isOK())try{typeof n=="function"&&Reflect.apply(n,{},a),t(a)}catch(f){console.error(f),r(f)}else try{console.error(l),typeof n=="function"&&Reflect.apply(n,{},[]),r(l)}catch(f){console.error(f),r(f)}}),u=new qe;for(let l=0;l<s.length;l++){const a=new $i(l,s[l],o);this.mount(u,a)}return this})}remove(...e){return new Promise((t,r)=>{if(e.length<=0){r("args is empty");return}const s=[];let i=e.length-1,n=null;typeof e[i]=="function"&&(n=e[i],i--);for(let o=0;o<=i;o++)if(Array.isArray(e[o])){const u=e[o];for(let l=0;l<u.length;l++){const a=this.resloveResource(u[l]);s.push(a)}}else if(typeof e[o]=="string"){const u=this.resloveResource(e[o]);s.push(u)}for(let o=0;o<s.length;o++)try{this.unmount(s[o])}catch(u){console.error(u)}typeof n=="function"&&Reflect.apply(n,{},[!0]),t(!0)})}mount(e,t){if(!t.resource){e.post(s=>{t.progress.work(!1,t.index,null),s.resolve()});return}if(typeof t.resource=="string"){if(er.includes(t.resource)){e.post(i=>{t.progress.work(!0,t.index,t.resource),i.resolve()});return}const s=this.getModuleExports(t.resource);if(s){e.post(i=>{t.progress.work(!0,t.index,s),i.resolve()});return}}const r=t.resource;if(r.type==="js")if(r.format==="es")this.mountCJS(e,t);else{const s=this.jsMountPoint??this.head;this.mountJS(e,t,s)}else{const s=this.cssMountPoint??this.head;this.mountCSS(e,t,s)}}mountCSS(e,t,r){e.post(s=>{const i=t.resource,n=this.getModuleExports(i.path);if(n){t.progress.work(!0,t.index,n),s.resolve();return}const o=We(),u=o.createElement("link"),l="onload"in u;l&&(u.onload=()=>{u.onload=null,u.onerror=null,t.progress.work(!0,t.index,i.path),s.resolve()},u.onerror=()=>{try{r.removeChild(u)}catch(c){console.error(c)}u.onload=null,u.onerror=null,t.progress.work(!1,t.index,null),s.reject()});const a=this.constructResourceUri(i.path),f=o.getElementById(i.path);f&&f.parentNode&&f.parentNode.removeChild(f),u.rel="stylesheet",u.type="text/css",u.id=i.path,u.href=a,r.appendChild(u),l||(t.progress.work(!0,t.index,i.path),s.resolve())})}mountJS(e,t,r){e.post(s=>{const i=t.resource,n=this.getModuleExports(i.path);if(n){t.progress.work(!0,t.index,n),s.resolve();return}const o={id:i.path,src:i.path,status:U.Loading};this.moduleManager.set(i.path,o);const u=We().createElement("script");if("onload"in u)u.onload=()=>{u.onload=null,u.onerror=null,o.status===U.Loading&&(o.status=U.Loaded,t.progress.work(!0,t.index,i.path)),s.resolve()},u.onerror=()=>{try{r.removeChild(u)}catch(h){console.error(h)}u.onload=null,u.onerror=null,this.moduleManager.remove(i.path),t.progress.work(!1,t.index,null),s.resolve()};else{const h=u;h.onreadystatechange=()=>{/loaded|complete/.test(h.readyState)&&(h.onreadystatechange=null,o.status==U.Loading&&(o.status=U.Loaded,t.progress.work(!0,t.index,i.path)),s.resolve())}}const l=this.constructResourceUri(i.path);u.defer=!0,u.src=l;const a=j(),f=this.createRequireLoad();a.__require=a.__require??a.require,a.require=f;const c=this.createDefine(o,f,t);a.__define=a.__define??a.define,a.define=c,typeof t.progress.finalCallback!="function"&&(t.progress.finalCallback=function(){a.require=a.__require,a.__require=void 0,a.define=a.__define,a.__define=void 0}),r.appendChild(u)})}mountCJS(e,t){e.post(async r=>{const s=t.resource,i=this.getModuleExports(s.path);if(i){t.progress.work(!0,t.index,i),r.resolve();return}try{let n=await ji(s.path);if(Xe(n)&&(n=n.default??n),pe(n)){t.progress.work(!1,t.index,n),r.resolve();return}const o={id:s.path,src:s.path,status:U.Loaded,exports:n};this.moduleManager.set(s.path,o),t.progress.work(!0,t.index,n),r.resolve()}catch(n){console.error(n),t.progress.work(!1,t.index,null),r.resolve()}})}unmount(e){let t="",r="";typeof e=="string"?(this.moduleManager.remove(e),r=this.getResourcePathSuffix(e),t=e):(this.moduleManager.remove(e.path),r=e.type==="css"?"css":e.format??"",t=e.path);const s=We();if(r==="umd"){let i=s.getElementById(t);i||(i=s.querySelector(`script[src="${t}"]`)),i&&i.remove()}else if(r==="css"){let i=s.getElementById(t);if(!i){const n=this.constructResourceUri(t);i=s.querySelector(`link[href="${n}"]`)}i&&i.remove()}}trimEmptyElement(e){const t=[];for(let r=0;r<e.length;r++){let s=e[r];s!=null&&(s=s.trim(),s.length!==0&&t.push(s))}return t}createDefine(e,t,r){const s=this,i=function(...n){e.status=U.Defining;let o,u,l,a=n.length;if(a===1?(l=n[0],o=void 0):a===2?(l=n[1],Array.isArray(n[0])?(u=s.trimEmptyElement(n[0]),o=void 0):u=void 0):(o=n[0],u=s.trimEmptyElement(n[1]),l=n[2]),o&&(e.id=o,typeof s._alias=="object"&&(s._alias[o]=e.src)),u&&u.length>0)s.ensure(u,(...f)=>{try{const c=f.map(h=>h==="exports"?((!e.exports||typeof e.exports!="object")&&(e.exports={}),e.exports):h==="module"?e:h==="require"?t:h);if(typeof l=="function"){const h=Reflect.apply(l,e,c);h&&typeof h=="object"&&(e.exports=h)}else e.exports=l;e.status=U.Defined,r.progress.work(!0,r.index,e.exports)}catch(c){console.error(c),r.progress.work(!1,r.index,[])}});else{if(typeof l=="function"){const f=Reflect.apply(l,e,[]);f&&typeof f=="object"&&(e.exports=e.exports??{},Object.assign(e.exports,f))}else e.exports=l;e.status=U.Defined,r.progress.work(!0,r.index,e.exports)}};return i.amd=!0,i}createRequireLoad(){return e=>(e=this._alias?.[e]??e,this.getModuleExports(e))}constructResourceUri(e){try{if(er.includes(e)||!this.query)return e;const t=this.createSearch(this.query);return e.indexOf("?")==-1?e+=`?${t}`:t.length>0&&(e+=`&${t}`),e}catch(t){throw console.error(`[Fox]resolve path[${e}] fail`,t),t}}createSearch(e){let t="";if(e&&typeof e=="object"){for(let r in e){let s=`${e[r]}`;t+=`${encodeURIComponent(r)}=${encodeURIComponent(s)}&`}t.length>0&&(t=t.substring(0,t.length-1))}return t}getResourcePathSuffix(e){let t=e.lastIndexOf("?");t==-1&&(t=e.length);let r=e.lastIndexOf(".",t);return r==-1?"":e.substring(r+1,t)}},qi=class{finalCallback;callback;values;status;size;lastIndex;constructor(e,t){this.size=e,this.callback=t,this.status=!0,this.values=[],this.lastIndex=-1}work(e,t,r){if(this.status=e,this.status===!0&&(this.lastIndex!==t&&this.size--,this.lastIndex=t,this.values[t]=r),this.size===0||this.status===!1)try{Reflect.apply(this.callback,this,[this.status,this.values])}catch(s){console.error(s.message,s)}finally{typeof this.finalCallback=="function"&&(Reflect.apply(this.finalCallback,null,[]),this.finalCallback=null)}}isOK(){return this.status}},$i=class{index;resource;progress;constructor(e,t,r){this.index=e,this.resource=t,this.progress=r}},tr=Symbol("fk"),rr=Symbol("fbk"),sr=Symbol("fepk");function Ki(e={}){const t=new Br(e),r=new Ct,s=new Yt,i=new cs,n={get router(){return t},get bus(){return r},get Bus(){return Ct},get EventProxy(){return Yt},get eventproxy(){return s},get EventChain(){return qe},get Require(){return cs},get require(){return i},get isESModule(){return Xe},install(o,u={}){o.provide(Oe,t),o.provide(tr,n),o.provide(rr,r),o.provide(sr,s),u.install!==!1&&(o.component(Ci,pt),o.component(Fi,us)),u.optionsApi!==!1&&(Reflect.defineProperty(o.config.globalProperties,"$fox",{get(){return n}}),Reflect.defineProperty(o.config.globalProperties,"$router",{get(){return t}}),Reflect.defineProperty(o.config.globalProperties,"$bus",{get(){return r}}),Reflect.defineProperty(o.config.globalProperties,"$bus",{get(){return r}}),Reflect.defineProperty(o.config.globalProperties,"$eventProxy",{get(){return s}}),o.config.globalProperties.$fox_on=function(l,a,f=!1){s.on(l,a,f)},o.config.globalProperties.$fox_off=function(l,a){s.off(l,a)},o.config.globalProperties.$fox_once=function(l,a){s.once(l,a)},o.config.globalProperties.$fox_all=function(...l){let a=s;Reflect.apply(a.all,a,l)},o.config.globalProperties.$fox_trigger=function(l,...a){let f=s;Reflect.apply(f.trigger,f,[l,...a])},o.config.globalProperties.$fox_emit=function(l,...a){let f=s;Reflect.apply(f.trigger,f,[l,...a])},o.mixin({setup(){return{$route:Gt()}}})),t.init()}};return n}function ir(e){return(0,d.hasInjectionContext)()?(0,d.inject)(Oe,null):e?e.$?.appContext?.provides?.[Oe]??null:null}function Li(e){let t=Gt(e);if(!t&&e&&!(0,d.hasInjectionContext)()){let r=e;for(r=r.$parent;r&&(t=Gt(r),!t);)r=r.$parent}return t}function Ti(e){return(0,d.hasInjectionContext)()?(0,d.inject)(tr,null):e?e.$?.appContext?.provides?.[tr]??null:null}function Mi(e){return(0,d.hasInjectionContext)()?(0,d.inject)(rr,null):e?e.$?.appContext?.provides?.[rr]??null:null}function ki(e){return(0,d.hasInjectionContext)()?(0,d.inject)(sr,null):e?e.$?.appContext?.provides?.[sr]??null:null}function Ii(e){const t=ir();if(!t){console.error("[Fox]router is not exist.");return}const r=(s,i,n)=>{try{Reflect.apply(e,{},[s,i])}catch(o){console.error(o)}n()};t?.beforeEach(r),(0,d.onScopeDispose)(()=>{t?.removeBeforeEach(r)})}function Bi(e){const t=ir();if(!t){console.error("[Fox]router is not exist.");return}const r=(s,i,n)=>{try{Reflect.apply(e,{},[s,i])}catch(o){console.error(o)}n()};t?.afterEach(r),(0,d.onScopeDispose)(()=>{t?.removeAfterEach(r)})}p.Bus=Ct,p.EventChain=qe,p.EventProxy=Yt,p.FoxBeforeEnter=zr,p.FoxBeforeLeave=Xr,p.FoxEnter=Gr,p.FoxLeave=Qr,p.FoxLeaveEnd=yt,p.OperationType=_,p.Route=E,p.Router=Br,p.RouterLink=us,p.RouterView=pt,p.bindLifecycleContextToCurrentScope=Ys,p.createFox=Ki,p.createMemoryHistory=$r,p.createWebHashHistory=qr,p.createWebHistory=zs,p.deleteContextValue=ti,p.extend=q,p.injectContextValue=zt,p.injectLifecycleContext=Ne,p.isArray=bt,p.isDate=ps,p.isESModule=Xe,p.isEqual=xt,p.isFunction=S,p.isMap=ds,p.isNil=pe,p.isObject=ar,p.isPlainObject=ur,p.isPromise=bs,p.isSet=ms,p.isString=vs,p.isSymbol=gs,p.onAfterRouteUpdate=Bi,p.onBeforeRouteUpdate=Ii,p.onFoxActivated=oi,p.onFoxInactivated=li,p.provideContextValue=ei,p.rawState=Ls,p.reactiveState=qs,p.shallowReactiveState=$s,p.toBoolean=Rt,p.toNumber=xs,p.toTypeString=Ge,p.typeOf=St,p.useBus=Mi,p.useEventProxy=ki,p.useFox=Ti,p.useRoute=Li,p.useRouter=ir,p.withLifecycleContext=Nr});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fox-js/fox",
3
3
  "type": "module",
4
- "version": "3.1.1-25",
4
+ "version": "3.1.1-26",
5
5
  "description": "Fox Router and commons Utils",
6
6
  "author": "jiangcheng",
7
7
  "keywords": [