@ssgoi/core 7.1.0-beta.2 → 7.1.0-beta.3

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/README.md CHANGED
@@ -49,6 +49,9 @@ Rule forms:
49
49
  - `from`/`to`: precise pair. Reverse matching is enabled by default.
50
50
  - `ordered`: array order decides forward and backward.
51
51
  - `priority`: higher values win before path specificity.
52
+ - Web Back reverses the effect recorded for the exact visited entry pair;
53
+ Forward replays it. Fresh push/replace rematch these rules. Unrecorded returns
54
+ also rematch. See [history behavior](https://ssgoi.dev/llms/route-rules.txt).
52
55
  - Scroll is automatic: `on` and `from`/`to` restore the forward `from` side
53
56
  and reset `to`; `ordered` restores both. Use
54
57
  `preserveScroll: { from: boolean, to: boolean }` for an exact override.
package/dist/internal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var _t=Object.defineProperty;var Nt=(n,e,t)=>e in n?_t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var U=(n,e,t)=>Nt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("./resolve-transition-rule-BL12rDDu.cjs"),ot=require("./multi-animation-B5hEmEgN.cjs");class Rt extends ot.Animation{constructor(){super(...arguments);U(this,"child",null);U(this,"_state","idle");U(this,"_settled",!1);U(this,"listeners",new Set)}attach(t){const i=this.child;if(this.child=t,this._settled=!1,i){const c=i.getPose();i.complete(),t.matchInto(c)}t.playbackRate=this.playbackRate;const a=t.onComplete;t.onComplete=()=>{a==null||a(),this.child===t&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const s=t.onUpdate;t.onUpdate=c=>{var u;s==null||s(c),(u=this.onUpdate)==null||u.call(this,c),this.notify()},this._state==="paused"?t.pause():this._state==="reversing"?t.reverse():(this._state="playing",t.play()),this.notify()}play(){var t;this._state="playing",this._settled=!1,(t=this.child)==null||t.play(),this.notify()}reverse(){var t;this._state="reversing",this._settled=!1,(t=this.child)==null||t.reverse(),this.notify()}pause(){var t;this._state="paused",(t=this.child)==null||t.pause(),this.notify()}complete(){var t;(t=this.child)==null||t.complete(),this.notify()}get isAnimating(){var t;return((t=this.child)==null?void 0:t.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var t;return((t=this.child)==null?void 0:t.isReversing)??this._state==="reversing"}get progress(){var t;return((t=this.child)==null?void 0:t.progress)??0}findTimeForProgress(t){var i;return((i=this.child)==null?void 0:i.findTimeForProgress(t))??null}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.child&&(this.child.playbackRate=t),this.notify()}getPose(){var t;return((t=this.child)==null?void 0:t.getPose())??[]}getTimeline(){var t;return((t=this.child)==null?void 0:t.getTimeline())??[]}matchInto(t){var i;(i=this.child)==null||i.matchInto(t)}get activeChild(){return this.child}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(const t of this.listeners)t()}}const It=(n,e)=>{var t;n.style.position="absolute",n.style.width="100%",n.style.top=`${-1*(((t=e==null?void 0:e.scrollOffset)==null?void 0:t.y)??0)}px`,n.style.left="0"},vt=new Set(["auto","scroll","overlay"]),Ft=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e);if(vt.has(t.overflowY)||vt.has(t.overflowX))return e;e=e.parentElement}return document.documentElement},Bt=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e).position;if(t==="relative"||t==="absolute"||t==="fixed"||t==="sticky")return e;e=e.parentElement}return document.body};function Wt(n){const e=Object.keys(n);return Promise.all(e.map(t=>n[t])).then(t=>{const i={};return e.forEach((a,s)=>{i[a]=t[s]}),i})}const Xt=768,qt=10,zt=10;function Gt(n={}){const{resolvePath:e=p=>p}=n;let t=null,i=!1,a=!1;const s=()=>{const p=(t==null?void 0:t.clientWidth)??0,m=p>0?p:typeof window<"u"?window.innerWidth:0;return m>0&&m<Xt},c=()=>(a||(i=s(),a=!0),i),u=p=>`path:${e(p)}`;let h=null;const f=new Map;let y=null,b=!1,E=0,w=0,_=0;const q=()=>{t&&y&&!b&&f.set(u(y),{x:t.scrollLeft,y:t.scrollTop})},$=(p,m,A)=>{if(!t)return;const C=++w,L=u(p),R=m&&f.has(L)?f.get(L):{x:0,y:0};let x=0;const N=()=>{if(!t||A!==E||C!==w)return;m||f.set(L,R),t.scrollTo({top:R.y,left:R.x}),!(Math.abs(t.scrollTop-R.y)<1&&Math.abs(t.scrollLeft-R.x)<1)&&x<qt&&(x++,requestAnimationFrame(N))};requestAnimationFrame(N)};return{initializeContext:(p,m,A)=>{b=!0;const C=y===m?E:++E;h=p,t||(t=Ft(p),i=s(),a=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{i=s()}).observe(t),(t===document.documentElement?window:t).addEventListener("scroll",q,{passive:!0})),y=m;const L=u(m),R=f.get(L),x=F=>{C===E&&(_=C,F&&R&&f.set(L,R),$(m,F,C))};A!==void 0?x(A):requestAnimationFrame(()=>{_!==C&&C===E&&x(!1)});let N=0;const V=()=>{C===E&&(N++,N>=zt?b=!1:requestAnimationFrame(V))};return requestAnimationFrame(V),x},calculateScrollOffset:(p,m,A=!1)=>{const C=p?u(p):null,L=C&&f.has(C)?f.get(C):{x:0,y:0},R=m&&A?u(m):null,x=R&&f.has(R)?f.get(R):{x:0,y:0};return{x:-x.x+L.x,y:-x.y+L.y}},evictScrollPosition:p=>{f.delete(u(p))},getScrollContainer:()=>t,getPositionedParentElement:()=>h?Bt(h):document.body,getScrollPosition:(p,m=!0)=>{if(!m)return{x:0,y:0};const A=p?u(p):null;return A&&f.has(A)?f.get(A):{x:0,y:0}},getIsMobile:c}}const bt=30,wt=8,Et=1.2,St=30,Vt=600;function Kt(){let n=null,e=!1,t=!1,i=null,a=null,s=!1;const c=(g,S)=>{for(let k=0;k<g.length;k++){const M=g.item(k);if(M&&M.identifier===S)return M}return null},u=()=>{i!==null&&(clearTimeout(i),i=null)},h=()=>{a!==null&&(clearTimeout(a),a=null)},f=()=>{e=!0,t=!0,u(),h(),i=setTimeout(()=>{e=!1,t=!1,i=null},Vt)},y=g=>{if(g.touches.length!==1){n=null;return}const S=g.touches.item(0);if(!S){n=null;return}const k=window.innerWidth,M=S.clientX<=bt,I=S.clientX>=k-bt;if(!M&&!I){n=null;return}n={identifier:S.identifier,startX:S.clientX,startY:S.clientY,fromLeftEdge:M,moved:!1}},b=g=>{if(!n)return;if(g.touches.length!==1){n=null;return}const S=c(g.touches,n.identifier);if(!S){n=null;return}const k=S.clientX-n.startX,M=S.clientY-n.startY,I=Math.abs(k),p=Math.abs(M);if(p>wt&&p>I*Et){n=null;return}const m=n.fromLeftEdge?k>0:k<0;I>wt&&I>p*Et&&m&&(n.moved=!0)},E=g=>{if(!n)return;const S=c(g.changedTouches,n.identifier);if(!S){n=null;return}const k=S.clientX-n.startX,M=n.fromLeftEdge?k>0:k<0;if(n.moved&&M&&Math.abs(k)>=St){f(),n=null;return}n.moved&&Math.abs(k)>=St&&f(),n=null},w=()=>{n&&(n.moved&&f(),n=null)};return{initialize:()=>{if(typeof window>"u"||s)return;s=!0;const g={passive:!0,capture:!0};window.addEventListener("touchstart",y,g),window.addEventListener("touchmove",b,g),window.addEventListener("touchend",E,g),window.addEventListener("touchcancel",w,g)},destroy:()=>{if(typeof window>"u"||!s)return;s=!1;const g={capture:!0};window.removeEventListener("touchstart",y,g),window.removeEventListener("touchmove",b,g),window.removeEventListener("touchend",E,g),window.removeEventListener("touchcancel",w,g),u(),h(),n=null,e=!1,t=!1},isSwipeBack:()=>{const g=e||t;return g&&u(),g},onPageEnter:()=>{e=!1,u(),h(),a=setTimeout(()=>{t=!1,a=null},0)}}}function Ut(){let n=null,e=null,t=null;const i=()=>{t!==null&&clearTimeout(t),t=null},a=w=>{n=w,e=w,i(),t=setTimeout(()=>{e===w&&(e=null,n===w&&(n=null),t=null)},1e3)},s=()=>{if(e!==null){e=null,i();return}n="backward"};let c=null,u=null,h=null,f=null,y=null,b=null,E=null;return typeof window<"u"&&(window.addEventListener("popstate",s,!0),c=window.history,u=c.back,h=c.forward,f=c.go,y=()=>(a("backward"),u==null?void 0:u.call(c)),b=()=>(a("forward"),h==null?void 0:h.call(c)),E=(w=0)=>(w<0?a("backward"):w>0&&a("forward"),f==null?void 0:f.call(c,w)),c.back=y,c.forward=b,c.go=E),{resolve(w,_){const q=n??"forward";return n=null,q},dispose(){i(),typeof window<"u"&&window.removeEventListener("popstate",s,!0),c&&(c.back===y&&u&&(c.back=u),c.forward===b&&h&&(c.forward=h),c.go===E&&f&&(c.go=f))}}}function Yt(n={}){let e=null,t=null;function i(){var s,c;e&&((s=e.out)==null||s.resolve(null),(c=e.in)==null||c.resolve(null),e=null)}function a(){if(e!=null&&e.out&&e.in){if(e.out.path===e.in.path){i();return}const s={from:e.out.path,to:e.in.path,out:e.out.payload,in:e.in.payload};t=s,e.out.resolve(s),e.in.resolve(s),e=null}}return{arrive(s,c,u){return new Promise(h=>{var E,w;const f=t===null?null:c==="out"?{path:t.from,payload:t.out}:{path:t.to,payload:t.in};if((f==null?void 0:f.path)===s){h(null);return}c==="out"&&((E=e==null?void 0:e.in)==null?void 0:E.path)===s&&!e.out&&(e.in.resolve(null),e.in=void 0);const y=e==null?void 0:e[c];y&&y.path!==s&&i(),e||(e={});const b=e[c];if(b){if(((w=n.keepCurrent)==null?void 0:w.call(n,{type:c,path:s,current:b.payload,next:u}))??!1){h(null);return}b.resolve(null)}e[c]={path:s,payload:u,resolve:h},a()})},cancel(s){(e!=null&&e.out&&s(e.out.payload)||e!=null&&e.in&&s(e.in.payload))&&i(),(t&&s(t.out)||t&&s(t.in))&&(t=null)}}}const $t={},G=new Map;let Q=null,Tt=!1;function Ct(n,e,t){n instanceof HTMLElement&&G.has(n)&&!n.isConnected&&t.set(n,{entry:G.get(n),anchor:e});for(const i of Array.from(n.childNodes))Ct(i,e,t)}function jt(n){const e=new Set(Array.from(n.values(),({entry:t})=>t));for(const[t,{entry:i,anchor:a}]of n){G.delete(t);let s=i.parent,c=!1;for(;s;){if(s.group===i.group&&e.has(s)){c=!0;break}s=s.parent}queueMicrotask(()=>i.callback(a,{emit:!c}))}}function Zt(){if(Tt||typeof document>"u")return;Tt=!0,Q=new MutationObserver(e=>{const t=new Map;for(const i of e){const a={parent:i.target,nextSibling:i.nextSibling};for(const s of Array.from(i.removedNodes))Ct(s,a,t)}jt(t)});const n=()=>{Q==null||Q.observe(document.body,{childList:!0,subtree:!0})};document.body?n():document.addEventListener("DOMContentLoaded",n,{once:!0})}function Jt(n,e,t=$t){Zt();let i=n.parentElement,a=null;for(;i;){const s=G.get(i);if((s==null?void 0:s.group)===t){a=s;break}i=i.parentElement}return G.set(n,{element:n,callback:e,group:t,parent:a}),()=>{G.delete(n)}}const ut=new WeakMap;let tt=null;const et="none !important";function Y(n){const e=n.style.getPropertyValue("display");return n.style.getPropertyPriority("display")?`${e} !important`:e}function Qt(){return tt||(tt=new MutationObserver(n=>{for(const e of n){const t=e.target,i=ut.get(t);if(!i)continue;const a=Y(t);a!==i.accounted&&(i.accounted=a,a===et?(i.reactHidden=!0,i.onHide()):a!=="none"&&i.reactHidden&&(i.reactHidden=!1,i.onShow()))}}),tt)}function te(n,e){const t=Y(n),i={accounted:t,reactHidden:t===et,onHide:e.onHide,onShow:e.onShow};return ut.set(n,i),Qt().observe(n,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return Y(n)===et},setDisplay(a,s=!1){a===null?n.style.removeProperty("display"):n.style.setProperty("display",a,s?"important":""),i.accounted=Y(n)},sync(){i.accounted=Y(n),i.reactHidden=i.accounted===et},stop(){ut.delete(n)}}}function ee(n,e={}){const{transitions:t=[],middleware:i=(o,r)=>({from:o,to:r})}=n,a=e.host??new Rt,s={},c=Yt({keepCurrent:({current:o,next:r})=>o.element.contains(r.element)}),u=Ut(),h=typeof t=="function"?t:()=>t,f=Kt();f.initialize();const y=new Map,b=o=>{let r=y.get(o);return r===void 0&&(r=i(o,o).from,y.set(o,r)),r},{initializeContext:E,calculateScrollOffset:w,evictScrollPosition:_,getScrollContainer:q,getPositionedParentElement:$,getScrollPosition:j,getIsMobile:g}=Gt({resolvePath:b}),S=new Map,k=()=>{const o=g();let r=S.get(o);return r||(r=h({isMobile:o}),S.set(o,r)),r},M=new WeakMap,I=o=>{M.set(o,{parent:o.parentNode,nextSibling:o.nextSibling})},p=o=>{const r=M.get(o);return r||{parent:o.parentNode,nextSibling:o.nextSibling}},m=new WeakMap,A=new WeakMap;let C=0;const L=o=>{const r=typeof getComputedStyle<"u"?getComputedStyle(o).display:"";return r&&r!=="none"?r:"block"},R=(o,r)=>{r.visibleDisplay=o.style.getPropertyValue("display"),r.computedDisplay=L(o)},x=(o,r)=>{if(A.get(o)!==r)return;A.delete(o);const l=m.get(o);l&&(l.savedCss!==null&&(o.style.cssText=l.savedCss,l.savedCss=null),l.intent==="hidden"?l.vis.setDisplay("none",!0):l.visibleDisplay?(l.vis.setDisplay(l.visibleDisplay,!1),R(o,l)):(l.vis.setDisplay(null),R(o,l)))},N=(o,r)=>{if(o.mode!=="hidden")return;const l=Array.from(new Set([o.element,r==null?void 0:r.element].filter(Boolean))),P=++C;for(const d of l)A.set(d,P);a.complete();for(const d of l)x(d,P)},V=(o,r,l,P,d,v,T)=>{const H=d.element,O=v.element,B=(d.mode??"unmount")==="hidden",{parent:W,nextSibling:z}=d.parent?{parent:d.parent,nextSibling:d.nextSibling}:p(H),Z=w(l,P,T.to),rt={direction:r,scrollOffset:Z,from:{scroll:j(l)},to:{scroll:j(P,T.to)},get scrollingElement(){return q()||document.documentElement},get positionedParent(){return $()}};let D;if(B){D=H,D.style.top=`${-1*((Z==null?void 0:Z.y)??0)}px`;const X=m.get(O);X&&X.savedCss===null&&(X.savedCss=O.style.cssText)}else D=H,It(D,rt);T.from||_(l);const J=B?++C:0;B&&(A.set(O,J),A.set(H,J));const mt=Promise.resolve(D),yt=Promise.resolve(O),gt=[],Lt={from:mt,to:yt,context:rt,createElement:((X,st="div")=>{const K=document.createElement(st);return K.setAttribute("data-ssgoi-id",X),gt.push(K),K})},Dt=Promise.resolve(o.prepare?o.prepare(Lt):{});Wt({from:mt,to:yt,extras:Dt}).then(({from:X,to:st,extras:K})=>{!B&&W&&(z&&W.contains(z)?W.insertBefore(D,z):W.appendChild(D));const lt=o.animation({from:X,to:st,context:rt,...K}),ct=lt.onComplete;lt.onComplete=()=>{ct==null||ct(),B?(x(H,J),x(O,J)):D.parentNode&&D.parentNode.removeChild(D);for(const at of gt)at.parentNode&&at.parentNode.removeChild(at)},a.attach(lt)})},F=(o,r,l)=>{const P=f.isSwipeBack();c.arrive(o,r,l).then(d=>{var it,B,W,z;if(r==="in"&&f.onPageEnter(),!d){r==="out"&&N(l);return}if(r!=="in")return;const{from:v,to:T}=i(d.from,d.to),H=u.resolve(v,T),O=Ht.resolveTransitionRule(v,T,k(),H);if(!O){(B=(it=d.in).applyScrollPolicy)==null||B.call(it,!1),_(d.from),N(d.out,d.in);return}if((z=(W=d.in).applyScrollPolicy)==null||z.call(W,O.preserveScroll.to),P){O.preserveScroll.from||_(d.from),N(d.out,d.in);return}V(O.transition,O.direction,d.from,d.to,d.out,d.in,O.preserveScroll)})},dt=(o,r)=>{const l=m.get(o);if(!l)return;const P=l.intent==="hidden";if(l.intent="hidden",l.savedCss===null&&(l.savedCss=o.style.cssText),l.vis.setDisplay(l.computedDisplay||"block",!0),o.style.position="absolute",o.style.width="100%",o.style.left="0",P)return;const d=p(o),v={element:o,parent:d.parent,nextSibling:d.nextSibling,mode:"hidden"},T=l.pendingOutPath??l.currentPath??r;l.pendingOutPath=null,F(T,"out",v)},Ot=(o,r)=>{const l=m.get(o);if(!l||l.intent==="visible")return;l.intent="visible",l.currentPath=o.getAttribute("data-ssgoi-transition")??l.currentPath??r,l.pendingOutPath=null,l.pathRevision++,R(o,l),l.savedCss!==null&&(o.style.cssText=l.savedCss,l.visibleDisplay?l.vis.setDisplay(l.visibleDisplay,!1):l.vis.setDisplay(null));const P=l.currentPath,d=E(o,P),v={element:o,parent:o.parentElement,nextSibling:o.nextElementSibling,applyScrollPolicy:d};F(P,"in",v)},xt=(o,r,l,P=!0)=>{const d=m.get(o),v=(d==null?void 0:d.pendingOutPath)??(d==null?void 0:d.currentPath)??r;if(d&&(d.vis.stop(),m.delete(o),A.delete(o),d.intent==="hidden")){c.cancel(O=>O.element===o);return}if(!P)return;const T=l??p(o),H={element:o,parent:T.parent,nextSibling:T.nextSibling,mode:"unmount"};F(v,"out",H)},ft=new WeakSet,ht=(o,r,{enter:l=!0}={})=>{if(ft.has(r)){const v=m.get(r);if(v&&v.currentPath!==o){v.intent==="visible"&&v.pendingOutPath===null&&(v.pendingOutPath=v.currentPath),v.currentPath=o;const T=++v.pathRevision;queueMicrotask(()=>{v.pathRevision===T&&(v.pendingOutPath=null)})}return}ft.add(r),I(r);const P=te(r,{onHide:()=>dt(r,o),onShow:()=>Ot(r,o)}),d={vis:P,savedCss:null,intent:P.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:o,pendingOutPath:null,pathRevision:0};if(m.set(r,d),!P.isHidden&&(R(r,d),l)){const v=E(r,o),T={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling,applyScrollPolicy:v};F(o,"in",T)}Jt(r,(v,T)=>xt(r,o,v,(T==null?void 0:T.emit)??!0),s)},pt=new Map;return{register:ht,refFor:o=>{let r=pt.get(o);return r||(r=l=>{l&&ht(o,l)},pt.set(o,r)),r}}}const Mt="data-ssgoi-root",ne=`[${Mt}]`,nt="data-ssgoi-transition",Pt=`[${nt}]`,oe="[data-ssgoi-clone]";function ie(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function re(n){return n.nodeType===Node.ELEMENT_NODE}function se(n){return n instanceof HTMLElement}function kt(n){let e=0,t=n.parentElement;for(;t;)e++,t=t.parentElement;return e}function At(n,e,t=n){const i=Array.from(n).sort((a,s)=>kt(a)-kt(s));for(const a of i){const s=a.getAttribute(nt);if(s===null)continue;let c=a.parentElement,u=!1;for(;c;){if(t.has(c)){u=!0;break}c=c.parentElement}e.register(s,a,{enter:!u})}}function le(n,e){if(!ie())return()=>{};n.setAttribute(Mt,"");const t=u=>u.closest(ne)===n,i=u=>!se(u)||!t(u)||u.closest(oe)||u.getAttribute(nt)===null?null:u,a=(u,h)=>{if(re(u)){if(u.matches(Pt)){const f=i(u);f&&h.add(f)}for(const f of u.querySelectorAll(Pt)){const y=i(f);y&&h.add(y)}}},s=new MutationObserver(u=>{const h=new Set,f=new Set;for(const y of u){if(y.type==="attributes"){const b=i(y.target);b&&h.add(b);continue}for(const b of y.addedNodes)a(b,f)}for(const y of f)h.add(y);At(h,e,f)});s.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[nt]});const c=new Set;return a(n,c),At(c,e),()=>s.disconnect()}exports.Animation=ot.Animation;exports.MultiAnimation=ot.MultiAnimation;exports.WebAnimation=ot.WebAnimation;exports.HostAnimation=Rt;exports.createSggoiTransitionContext=ee;exports.observeSsgoiTransitions=le;
1
+ "use strict";var Fe=Object.defineProperty;var ze=(n,t,e)=>t in n?Fe(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Y=(n,t,e)=>ze(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("./resolve-transition-rule-BL12rDDu.cjs"),oe=require("./multi-animation-B5hEmEgN.cjs");class Le extends oe.Animation{constructor(){super(...arguments);Y(this,"child",null);Y(this,"_state","idle");Y(this,"_settled",!1);Y(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const d=o.getPose();o.complete(),e.matchInto(d)}e.playbackRate=this.playbackRate;const a=e.onComplete;e.onComplete=()=>{a==null||a(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const r=e.onUpdate;e.onUpdate=d=>{var s;r==null||r(d),(s=this.onUpdate)==null||s.call(this,d),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var o;return((o=this.child)==null?void 0:o.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var o;(o=this.child)==null||o.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const Xe=(n,t)=>{var e;n.style.position="absolute",n.style.width="100%",n.style.top=`${-1*(((e=t==null?void 0:t.scrollOffset)==null?void 0:e.y)??0)}px`,n.style.left="0"},Ee=new Set(["auto","scroll","overlay"]),qe=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if(Ee.has(e.overflowY)||Ee.has(e.overflowX))return t;t=t.parentElement}return document.documentElement},$e=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const e=window.getComputedStyle(t).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return t;t=t.parentElement}return document.body};function Ge(n){const t=Object.keys(n);return Promise.all(t.map(e=>n[e])).then(e=>{const o={};return t.forEach((a,r)=>{o[a]=e[r]}),o})}const Ke=768,Ue=10,Ve=10;function Ye(n={}){const{resolvePath:t=m=>m}=n;let e=null,o=!1,a=!1;const r=()=>{const m=(e==null?void 0:e.clientWidth)??0,g=m>0?m:typeof window<"u"?window.innerWidth:0;return g>0&&g<Ke},d=()=>(a||(o=r(),a=!0),o),s=m=>`path:${t(m)}`;let p=null;const u=new Map;let y=null,h=!1,S=0,v=0,E=0;const N=()=>{e&&y&&!h&&u.set(s(y),{x:e.scrollLeft,y:e.scrollTop})},_=(m,g,R)=>{if(!e)return;const M=++v,D=s(m),A=g&&u.has(D)?u.get(D):{x:0,y:0};let L=0;const W=()=>{if(!e||R!==S||M!==v)return;g||u.set(D,A),e.scrollTo({top:A.y,left:A.x}),!(Math.abs(e.scrollTop-A.y)<1&&Math.abs(e.scrollLeft-A.x)<1)&&L<Ue&&(L++,requestAnimationFrame(W))};requestAnimationFrame(W)};return{initializeContext:(m,g,R)=>{h=!0;const M=y===g?S:++S;p=m,e||(e=qe(m),o=r(),a=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{o=r()}).observe(e),(e===document.documentElement?window:e).addEventListener("scroll",N,{passive:!0})),y=g;const D=s(g),A=u.get(D),L=F=>{M===S&&(E=M,F&&A&&u.set(D,A),_(g,F,M))};R!==void 0?L(R):requestAnimationFrame(()=>{E!==M&&M===S&&L(!1)});let W=0;const K=()=>{M===S&&(W++,W>=Ve?h=!1:requestAnimationFrame(K))};return requestAnimationFrame(K),L},calculateScrollOffset:(m,g,R=!1)=>{const M=m?s(m):null,D=M&&u.has(M)?u.get(M):{x:0,y:0},A=g&&R?s(g):null,L=A&&u.has(A)?u.get(A):{x:0,y:0};return{x:-L.x+D.x,y:-L.y+D.y}},evictScrollPosition:m=>{u.delete(s(m))},getScrollContainer:()=>e,getPositionedParentElement:()=>p?$e(p):document.body,getScrollPosition:(m,g=!0)=>{if(!g)return{x:0,y:0};const R=m?s(m):null;return R&&u.has(R)?u.get(R):{x:0,y:0}},getIsMobile:d}}const Se=30,Pe=8,Te=1.2,ke=30,je=600;function Ze(){let n=null,t=!1,e=!1,o=null,a=null,r=!1;const d=(b,P)=>{for(let x=0;x<b.length;x++){const O=b.item(x);if(O&&O.identifier===P)return O}return null},s=()=>{o!==null&&(clearTimeout(o),o=null)},p=()=>{a!==null&&(clearTimeout(a),a=null)},u=()=>{t=!0,e=!0,s(),p(),o=setTimeout(()=>{t=!1,e=!1,o=null},je)},y=b=>{if(b.touches.length!==1){n=null;return}const P=b.touches.item(0);if(!P){n=null;return}const x=window.innerWidth,O=P.clientX<=Se,B=P.clientX>=x-Se;if(!O&&!B){n=null;return}n={identifier:P.identifier,startX:P.clientX,startY:P.clientY,fromLeftEdge:O,moved:!1}},h=b=>{if(!n)return;if(b.touches.length!==1){n=null;return}const P=d(b.touches,n.identifier);if(!P){n=null;return}const x=P.clientX-n.startX,O=P.clientY-n.startY,B=Math.abs(x),m=Math.abs(O);if(m>Pe&&m>B*Te){n=null;return}const g=n.fromLeftEdge?x>0:x<0;B>Pe&&B>m*Te&&g&&(n.moved=!0)},S=b=>{if(!n)return;const P=d(b.changedTouches,n.identifier);if(!P){n=null;return}const x=P.clientX-n.startX,O=n.fromLeftEdge?x>0:x<0;if(n.moved&&O&&Math.abs(x)>=ke){u(),n=null;return}n.moved&&Math.abs(x)>=ke&&u(),n=null},v=()=>{n&&(n.moved&&u(),n=null)};return{initialize:()=>{if(typeof window>"u"||r)return;r=!0;const b={passive:!0,capture:!0};window.addEventListener("touchstart",y,b),window.addEventListener("touchmove",h,b),window.addEventListener("touchend",S,b),window.addEventListener("touchcancel",v,b)},destroy:()=>{if(typeof window>"u"||!r)return;r=!1;const b={capture:!0};window.removeEventListener("touchstart",y,b),window.removeEventListener("touchmove",h,b),window.removeEventListener("touchend",S,b),window.removeEventListener("touchcancel",v,b),s(),p(),n=null,t=!1,e=!1},isSwipeBack:()=>{const b=t||e;return b&&s(),b},onPageEnter:()=>{t=!1,s(),p(),a=setTimeout(()=>{e=!1,a=null},0)}}}const xe="__ssgoi_entry_v1",ue=new WeakMap,_e={read:()=>null,previous:()=>null,dispose(){}};function Je(){var r;if(typeof window>"u")return _e;const n=window.navigation;if((r=n==null?void 0:n.currentEntry)!=null&&r.key&&n.currentEntry.index>=0)return{read:()=>Re(n.currentEntry),previous:()=>{var s;const d=(s=n.currentEntry)==null?void 0:s.index;return Re(n.entries().find(p=>p.index===(d??0)-1))},dispose(){}};const t=window;let e=ue.get(t);e||(e=Qe(t),ue.set(t,e)),e.users++;const o=e;let a=!1;return{read:o.read,previous:o.previous,dispose(){a||(a=!0,--o.users===0&&(o.dispose(),ue.delete(t)))}}}function Re(n){return n&&typeof n.key=="string"&&typeof n.url=="string"&&Number.isSafeInteger(n.index)&&n.index>=0?{key:n.key,index:n.index,url:n.url}:null}function de(n){return n!==null&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype}function Qe(n){const t=n.history,e=t.pushState,o=t.replaceState,a=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let r=0,d=!0,s=null;const p=()=>{const v=t.state,E=de(v)?v[xe]:null;return!de(E)||typeof E.key!="string"||!E.key.startsWith(a)||!Number.isSafeInteger(E.index)?null:{key:E.key,index:E.index,url:n.location.href}},u=(v,E)=>v!==null&&!de(v)?v:{...v,[xe]:E},y=v=>({key:`${a}${++r}`,index:v});try{o.call(t,u(t.state,y(0)),"")}catch{return{..._e,users:0}}const h=function(v,E,N){if(!d)return e.call(this,v,E,N);const _=p(),$=y(((_==null?void 0:_.index)??0)+1);e.call(this,u(v,$),E,N),s=_},S=function(v,E,N){if(!d)return o.call(this,v,E,N);const _=p();o.call(this,u(v,_??y(0)),E,N)};return t.pushState=h,t.replaceState=S,{users:0,read:p,previous:()=>s,dispose(){d=!1,t.pushState===h&&(t.pushState=e),t.replaceState===S&&(t.replaceState=o)}}}function et(){let n=null,t=null;const e=new Set,o=r=>{r&&e.add(r.key),e.size>200&&e.delete(e.values().next().value)},a=()=>{n||(n=Je(),t=n.read(),o(t))};return{connect:a,resolve(r,d){a();const s=n.read();let p=t,u="unknown";if(p&&s&&(s.key===p.key||s.index===p.index?u="replace":s.index<p.index?u="back":u=e.has(s.key)?"forward":"push"),u==="push"){const y=n.previous();y&&y.index===s.index-1&&fe.normalizePath(new URL(y.url).pathname)===fe.normalizePath(r)&&(p=y)}return t=s,o(p),o(s),{kind:u,direction:u==="back"?"backward":"forward",from:p,to:s}},dispose(){n==null||n.dispose(),n=null,t=null,e.clear()}}}function tt(){const n=et(),t=new Map;return{connect:n.connect,resolve(e,o,a){var u,y;const r=n.resolve(e,o),d=(u=r.from)==null?void 0:u.key,s=(y=r.to)==null?void 0:y.key;if(r.kind==="back"&&d&&s){const h=t.get(d);if((h==null?void 0:h.source)===s&&h.from===o&&h.to===e)return h.rule?{...h.rule,direction:h.rule.direction==="forward"?"backward":"forward",preserveScroll:{from:h.rule.preserveScroll.to,to:h.rule.preserveScroll.from}}:null}if(r.kind==="forward"&&d&&s){const h=t.get(s);if((h==null?void 0:h.source)===d&&h.from===e&&h.to===o)return h.rule}const p=a(r.direction);if(s&&r.kind==="replace"&&t.delete(s),s&&d&&r.kind==="push"){for(const[h,S]of t)S.index>=r.to.index&&t.delete(h);t.set(s,{source:d,index:r.to.index,from:e,to:o,rule:p?{...p,preserveScroll:{...p.preserveScroll}}:null}),t.size>100&&t.delete(t.keys().next().value)}return p},dispose(){n.dispose(),t.clear()}}}function nt(n={}){let t=null,e=null;function o(){var r,d;t&&((r=t.out)==null||r.resolve(null),(d=t.in)==null||d.resolve(null),t=null)}function a(){if(t!=null&&t.out&&t.in){if(t.out.path===t.in.path){o();return}const r={from:t.out.path,to:t.in.path,out:t.out.payload,in:t.in.payload};e=r,t.out.resolve(r),t.in.resolve(r),t=null}}return{arrive(r,d,s){return new Promise(p=>{var S,v;const u=e===null?null:d==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((u==null?void 0:u.path)===r){p(null);return}d==="out"&&((S=t==null?void 0:t.in)==null?void 0:S.path)===r&&!t.out&&(t.in.resolve(null),t.in=void 0);const y=t==null?void 0:t[d];y&&y.path!==r&&o(),t||(t={});const h=t[d];if(h){if(((v=n.keepCurrent)==null?void 0:v.call(n,{type:d,path:r,current:h.payload,next:s}))??!1){p(null);return}h.resolve(null)}t[d]={path:r,payload:s,resolve:p},a()})},cancel(r){(t!=null&&t.out&&r(t.out.payload)||t!=null&&t.in&&r(t.in.payload))&&o(),(e&&r(e.out)||e&&r(e.in))&&(e=null)}}}const ot={},G=new Map;let Q=null,Ae=!1;function De(n,t,e){n instanceof HTMLElement&&G.has(n)&&!n.isConnected&&e.set(n,{entry:G.get(n),anchor:t});for(const o of Array.from(n.childNodes))De(o,t,e)}function it(n){const t=new Set(Array.from(n.values(),({entry:e})=>e));for(const[e,{entry:o,anchor:a}]of n){G.delete(e);let r=o.parent,d=!1;for(;r;){if(r.group===o.group&&t.has(r)){d=!0;break}r=r.parent}queueMicrotask(()=>o.callback(a,{emit:!d}))}}function rt(){if(Ae||typeof document>"u")return;Ae=!0,Q=new MutationObserver(t=>{const e=new Map;for(const o of t){const a={parent:o.target,nextSibling:o.nextSibling};for(const r of Array.from(o.removedNodes))De(r,a,e)}it(e)});const n=()=>{Q==null||Q.observe(document.body,{childList:!0,subtree:!0})};document.body?n():document.addEventListener("DOMContentLoaded",n,{once:!0})}function st(n,t,e=ot){rt();let o=n.parentElement,a=null;for(;o;){const r=G.get(o);if((r==null?void 0:r.group)===e){a=r;break}o=o.parentElement}return G.set(n,{element:n,callback:t,group:e,parent:a}),()=>{G.delete(n)}}const pe=new WeakMap;let ee=null;const te="none !important";function j(n){const t=n.style.getPropertyValue("display");return n.style.getPropertyPriority("display")?`${t} !important`:t}function lt(){return ee||(ee=new MutationObserver(n=>{for(const t of n){const e=t.target,o=pe.get(e);if(!o)continue;const a=j(e);a!==o.accounted&&(o.accounted=a,a===te?(o.reactHidden=!0,o.onHide()):a!=="none"&&o.reactHidden&&(o.reactHidden=!1,o.onShow()))}}),ee)}function ct(n,t){const e=j(n),o={accounted:e,reactHidden:e===te,onHide:t.onHide,onShow:t.onShow};return pe.set(n,o),lt().observe(n,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return j(n)===te},setDisplay(a,r=!1){a===null?n.style.removeProperty("display"):n.style.setProperty("display",a,r?"important":""),o.accounted=j(n)},sync(){o.accounted=j(n),o.reactHidden=o.accounted===te},stop(){pe.delete(n)}}}function at(n,t={}){const{transitions:e=[],middleware:o=(i,l)=>({from:i,to:l})}=n,a=t.host??new Le,r={},d=nt({keepCurrent:({current:i,next:l})=>i.element.contains(l.element)}),s=tt(),p=typeof e=="function"?e:()=>e,u=Ze();u.initialize();const y=new Map,h=i=>{let l=y.get(i);return l===void 0&&(l=o(i,i).from,y.set(i,l)),l},{initializeContext:S,calculateScrollOffset:v,evictScrollPosition:E,getScrollContainer:N,getPositionedParentElement:_,getScrollPosition:$,getIsMobile:b}=Ye({resolvePath:h}),P=new Map,x=()=>{const i=b();let l=P.get(i);return l||(l=p({isMobile:i}),P.set(i,l)),l},O=new WeakMap,B=i=>{O.set(i,{parent:i.parentNode,nextSibling:i.nextSibling})},m=i=>{const l=O.get(i);return l||{parent:i.parentNode,nextSibling:i.nextSibling}},g=new WeakMap,R=new WeakMap;let M=0;const D=i=>{const l=typeof getComputedStyle<"u"?getComputedStyle(i).display:"";return l&&l!=="none"?l:"block"},A=(i,l)=>{l.visibleDisplay=i.style.getPropertyValue("display"),l.computedDisplay=D(i)},L=(i,l)=>{if(R.get(i)!==l)return;R.delete(i);const c=g.get(i);c&&(c.savedCss!==null&&(i.style.cssText=c.savedCss,c.savedCss=null),c.intent==="hidden"?c.vis.setDisplay("none",!0):c.visibleDisplay?(c.vis.setDisplay(c.visibleDisplay,!1),A(i,c)):(c.vis.setDisplay(null),A(i,c)))},W=(i,l)=>{if(i.mode!=="hidden")return;const c=Array.from(new Set([i.element,l==null?void 0:l.element].filter(Boolean))),T=++M;for(const f of c)R.set(f,T);a.complete();for(const f of c)L(f,T)},K=(i,l,c,T,f,w,k)=>{const C=f.element,H=w.element,z=(f.mode??"unmount")==="hidden",{parent:X,nextSibling:U}=f.parent?{parent:f.parent,nextSibling:f.nextSibling}:m(C),Z=v(c,T,k.to),re={direction:l,scrollOffset:Z,from:{scroll:$(c)},to:{scroll:$(T,k.to)},get scrollingElement(){return N()||document.documentElement},get positionedParent(){return _()}};let I;if(z){I=C,I.style.top=`${-1*((Z==null?void 0:Z.y)??0)}px`;const q=g.get(H);q&&q.savedCss===null&&(q.savedCss=H.style.cssText)}else I=C,Xe(I,re);k.from||E(c);const J=z?++M:0;z&&(R.set(H,J),R.set(C,J));const ve=Promise.resolve(I),be=Promise.resolve(H),we=[],We={from:ve,to:be,context:re,createElement:((q,se="div")=>{const V=document.createElement(se);return V.setAttribute("data-ssgoi-id",q),we.push(V),V})},Be=Promise.resolve(i.prepare?i.prepare(We):{});Ge({from:ve,to:be,extras:Be}).then(({from:q,to:se,extras:V})=>{!z&&X&&(U&&X.contains(U)?X.insertBefore(I,U):X.appendChild(I));const le=i.animation({from:q,to:se,context:re,...V}),ce=le.onComplete;le.onComplete=()=>{ce==null||ce(),z?(L(C,J),L(H,J)):I.parentNode&&I.parentNode.removeChild(I);for(const ae of we)ae.parentNode&&ae.parentNode.removeChild(ae)},a.attach(le)})},F=(i,l,c)=>{const T=u.isSwipeBack();d.arrive(i,l,c).then(f=>{var H,ie,z,X;if(l==="in"&&u.onPageEnter(),!f){l==="out"&&W(c);return}if(l!=="in")return;const{from:w,to:k}=o(f.from,f.to),C=s.resolve(f.from,f.to,U=>fe.resolveTransitionRule(w,k,x(),U));if(!C){(ie=(H=f.in).applyScrollPolicy)==null||ie.call(H,!1),E(f.from),W(f.out,f.in);return}if((X=(z=f.in).applyScrollPolicy)==null||X.call(z,C.preserveScroll.to),T){C.preserveScroll.from||E(f.from),W(f.out,f.in);return}K(C.transition,C.direction,f.from,f.to,f.out,f.in,C.preserveScroll)})},he=(i,l)=>{const c=g.get(i);if(!c)return;const T=c.intent==="hidden";if(c.intent="hidden",c.savedCss===null&&(c.savedCss=i.style.cssText),c.vis.setDisplay(c.computedDisplay||"block",!0),i.style.position="absolute",i.style.width="100%",i.style.left="0",T)return;const f=m(i),w={element:i,parent:f.parent,nextSibling:f.nextSibling,mode:"hidden"},k=c.pendingOutPath??c.currentPath??l;c.pendingOutPath=null,F(k,"out",w)},He=(i,l)=>{const c=g.get(i);if(!c||c.intent==="visible")return;c.intent="visible",c.currentPath=i.getAttribute("data-ssgoi-transition")??c.currentPath??l,c.pendingOutPath=null,c.pathRevision++,A(i,c),c.savedCss!==null&&(i.style.cssText=c.savedCss,c.visibleDisplay?c.vis.setDisplay(c.visibleDisplay,!1):c.vis.setDisplay(null));const T=c.currentPath,f=S(i,T),w={element:i,parent:i.parentElement,nextSibling:i.nextElementSibling,applyScrollPolicy:f};F(T,"in",w)},Ie=(i,l,c,T=!0)=>{const f=g.get(i),w=(f==null?void 0:f.pendingOutPath)??(f==null?void 0:f.currentPath)??l;if(f&&(f.vis.stop(),g.delete(i),R.delete(i),f.intent==="hidden")){d.cancel(H=>H.element===i);return}if(!T)return;const k=c??m(i),C={element:i,parent:k.parent,nextSibling:k.nextSibling,mode:"unmount"};F(w,"out",C)},ye=new WeakSet,me=(i,l,{enter:c=!0}={})=>{if(s.connect(),ye.has(l)){const w=g.get(l);if(w&&w.currentPath!==i){w.intent==="visible"&&w.pendingOutPath===null&&(w.pendingOutPath=w.currentPath),w.currentPath=i;const k=++w.pathRevision;queueMicrotask(()=>{w.pathRevision===k&&(w.pendingOutPath=null)})}return}ye.add(l),B(l);const T=ct(l,{onHide:()=>he(l,i),onShow:()=>He(l,i)}),f={vis:T,savedCss:null,intent:T.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:i,pendingOutPath:null,pathRevision:0};if(g.set(l,f),!T.isHidden&&(A(l,f),c)){const w=S(l,i),k={element:l,parent:l.parentElement,nextSibling:l.nextElementSibling,applyScrollPolicy:w};F(i,"in",k)}st(l,(w,k)=>Ie(l,i,w,(k==null?void 0:k.emit)??!0),r)},ge=new Map;return{register:me,refFor:i=>{let l=ge.get(i);return l||(l=c=>{c&&me(i,c)},ge.set(i,l)),l},disconnect:s.dispose}}const Ne="data-ssgoi-root",ut=`[${Ne}]`,ne="data-ssgoi-transition",Me=`[${ne}]`,dt="[data-ssgoi-clone]";function ft(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function pt(n){return n.nodeType===Node.ELEMENT_NODE}function ht(n){return n instanceof HTMLElement}function Oe(n){let t=0,e=n.parentElement;for(;e;)t++,e=e.parentElement;return t}function Ce(n,t,e=n){const o=Array.from(n).sort((a,r)=>Oe(a)-Oe(r));for(const a of o){const r=a.getAttribute(ne);if(r===null)continue;let d=a.parentElement,s=!1;for(;d;){if(e.has(d)){s=!0;break}d=d.parentElement}t.register(r,a,{enter:!s})}}function yt(n,t){if(!ft())return()=>{};n.setAttribute(Ne,"");const e=s=>s.closest(ut)===n,o=s=>!ht(s)||!e(s)||s.closest(dt)||s.getAttribute(ne)===null?null:s,a=(s,p)=>{if(pt(s)){if(s.matches(Me)){const u=o(s);u&&p.add(u)}for(const u of s.querySelectorAll(Me)){const y=o(u);y&&p.add(y)}}},r=new MutationObserver(s=>{const p=new Set,u=new Set;for(const y of s){if(y.type==="attributes"){const h=o(y.target);h&&p.add(h);continue}for(const h of y.addedNodes)a(h,u)}for(const y of u)p.add(y);Ce(p,t,u)});r.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ne]});const d=new Set;return a(n,d),Ce(d,t),()=>{var s;r.disconnect(),(s=t.disconnect)==null||s.call(t)}}exports.Animation=oe.Animation;exports.MultiAnimation=oe.MultiAnimation;exports.WebAnimation=oe.WebAnimation;exports.HostAnimation=Le;exports.createSggoiTransitionContext=at;exports.observeSsgoiTransitions=yt;