@ssgoi/core 7.1.3-beta.3 → 7.1.3-beta.5

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/dist/internal.cjs CHANGED
@@ -1 +1 @@
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-hDUcfD7W.cjs"),Xe=require("./provider-D9Q2URox.cjs");class _e 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 p=o.getPose();o.complete(),e.matchInto(p)}e.playbackRate=this.playbackRate;const c=e.onComplete;e.onComplete=()=>{c==null||c(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const i=e.onUpdate;e.onUpdate=p=>{var s;i==null||i(p),(s=this.onUpdate)==null||s.call(this,p),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 qe=(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"},Se=new Set(["auto","scroll","overlay"]),$e=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if(Se.has(e.overflowY)||Se.has(e.overflowX))return t;t=t.parentElement}return document.documentElement},Ge=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 Ke(n){const t=Object.keys(n);return Promise.all(t.map(e=>n[e])).then(e=>{const o={};return t.forEach((c,i)=>{o[c]=e[i]}),o})}const Ue=768,Ve=10,Ye=10;function je(n={}){const{resolvePath:t=b=>b}=n;let e=null,o=!1,c=!1;const i=()=>{const b=(e==null?void 0:e.clientWidth)??0,w=b>0?b:typeof window<"u"?window.innerWidth:0;return w>0&&w<Ue},p=()=>(c||(o=i(),c=!0),o),s=b=>`path:${t(b)}`;let y=null;const u=new Map;let m=null,h=!1,P=0,O=0,L=0;const z=()=>{e&&m&&!h&&u.set(s(m),{x:e.scrollLeft,y:e.scrollTop})},X=(b,w,x)=>{if(!e)return;const M=++O,N=s(b),R=w&&u.has(N)?u.get(N):{x:0,y:0};let _=0;const W=()=>{if(!e||x!==P||M!==O)return;w||u.set(N,R),e.scrollTo({top:R.y,left:R.x}),!(Math.abs(e.scrollTop-R.y)<1&&Math.abs(e.scrollLeft-R.x)<1)&&_<Ve&&(_++,requestAnimationFrame(W))};requestAnimationFrame(W)};return{initializeContext:(b,w,x)=>{h=!0;const M=m===w?P:++P;y=b,e||(e=$e(b),o=i(),c=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{o=i()}).observe(e),(e===document.documentElement?window:e).addEventListener("scroll",z,{passive:!0})),m=w;const N=s(w),R=u.get(N),_=B=>{M===P&&(L=M,B&&R&&u.set(N,R),X(w,B,M))};x!==void 0?_(x):requestAnimationFrame(()=>{L!==M&&M===P&&_(!1)});let W=0;const K=()=>{M===P&&(W++,W>=Ye?h=!1:requestAnimationFrame(K))};return requestAnimationFrame(K),_},calculateScrollOffset:(b,w,x=!1)=>{const M=b?s(b):null,N=M&&u.has(M)?u.get(M):{x:0,y:0},R=w&&x?s(w):null,_=R&&u.has(R)?u.get(R):{x:0,y:0};return{x:-_.x+N.x,y:-_.y+N.y}},evictScrollPosition:b=>{u.delete(s(b))},getScrollContainer:()=>e,getPositionedParentElement:()=>y?Ge(y):document.body,getScrollPosition:(b,w=!0)=>{if(!w)return{x:0,y:0};const x=b?s(b):null;return x&&u.has(x)?u.get(x):{x:0,y:0}},getIsMobile:p}}const Ee=30,Pe=8,Te=1.2,ke=30,Ze=600;function Je(){let n=null,t=!1,e=!1,o=null,c=null,i=!1;const p=(f,g)=>{for(let S=0;S<f.length;S++){const A=f.item(S);if(A&&A.identifier===g)return A}return null},s=()=>{o!==null&&(clearTimeout(o),o=null)},y=()=>{c!==null&&(clearTimeout(c),c=null)},u=()=>{t=!0,e=!0,s(),y(),o=setTimeout(()=>{t=!1,e=!1,o=null},Ze)},m=f=>{if(f.touches.length!==1){n=null;return}const g=f.touches.item(0);if(!g){n=null;return}const S=window.innerWidth,A=g.clientX<=Ee,D=g.clientX>=S-Ee;if(!A&&!D){n=null;return}n={identifier:g.identifier,startX:g.clientX,startY:g.clientY,fromLeftEdge:A,moved:!1}},h=f=>{if(!n)return;if(f.touches.length!==1){n=null;return}const g=p(f.touches,n.identifier);if(!g){n=null;return}const S=g.clientX-n.startX,A=g.clientY-n.startY,D=Math.abs(S),b=Math.abs(A);if(b>Pe&&b>D*Te){n=null;return}const w=n.fromLeftEdge?S>0:S<0;D>Pe&&D>b*Te&&w&&(n.moved=!0)},P=f=>{if(!n)return;const g=p(f.changedTouches,n.identifier);if(!g){n=null;return}const S=g.clientX-n.startX,A=n.fromLeftEdge?S>0:S<0;if(n.moved&&A&&Math.abs(S)>=ke){u(),n=null;return}n.moved&&Math.abs(S)>=ke&&u(),n=null},O=()=>{n&&(n.moved&&u(),n=null)};return{initialize:()=>{if(typeof window>"u"||i)return;i=!0;const f={passive:!0,capture:!0};window.addEventListener("touchstart",m,f),window.addEventListener("touchmove",h,f),window.addEventListener("touchend",P,f),window.addEventListener("touchcancel",O,f)},destroy:()=>{if(typeof window>"u"||!i)return;i=!1;const f={capture:!0};window.removeEventListener("touchstart",m,f),window.removeEventListener("touchmove",h,f),window.removeEventListener("touchend",P,f),window.removeEventListener("touchcancel",O,f),s(),y(),n=null,t=!1,e=!1},isSwipeBack:()=>{const f=t||e;return f&&s(),f},onPageEnter:()=>{t=!1,s(),y(),c=setTimeout(()=>{e=!1,c=null},0)}}}const xe="__ssgoi_entry_v1",ue=new WeakMap,Le={read:()=>null,previous:()=>null,dispose(){}};function Qe(){if(typeof window>"u")return Le;const n=window.navigation,t=window;let e=ue.get(t);e||(e=et(t,n),ue.set(t,e)),e.users++;const o=e;let c=!1;return{read:o.read,previous:o.previous,dispose(){c||(c=!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 et(n,t){var X;const e=n.history,o=e.pushState,c=e.replaceState,i=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let p=0,s=!0,y=null,u=null;const m=()=>{const v=Re(t==null?void 0:t.currentEntry);return(v==null?void 0:v.url)===n.location.href?v:null},h=()=>{const v=e.state,f=de(v)?v[xe]:null;return!de(f)||typeof f.key!="string"||!f.key.startsWith(i)||!Number.isSafeInteger(f.index)?m():{key:f.key,index:f.index,url:n.location.href}},P=(v,f)=>v!==null&&!de(v)?v:{...v,[xe]:f},O=v=>({key:`${i}${++p}`,index:v});try{c.call(e,P(e.state,O(((X=m())==null?void 0:X.index)??0)),"")}catch{return{...Le,read:m,users:0}}const L=function(v,f,g){var D;if(!s)return o.call(this,v,f,g);const S=h(),A=O(((S==null?void 0:S.index)??0)+1);o.call(this,P(v,A),f,g),y=S,u=((D=h())==null?void 0:D.key)??null},z=function(v,f,g){if(!s)return c.call(this,v,f,g);const S=h();c.call(this,P(v,S??O(0)),f,g)};return e.pushState=L,e.replaceState=z,{users:0,read:h,previous:()=>{var f;if(((f=h())==null?void 0:f.key)===u)return y;const v=m();return v?Re(t==null?void 0:t.entries().find(g=>g.index===v.index-1)):null},dispose(){s=!1,e.pushState===L&&(e.pushState=o),e.replaceState===z&&(e.replaceState=c)}}}function tt(){let n=null,t=null;const e=new Set,o=i=>{i&&e.add(i.key),e.size>200&&e.delete(e.values().next().value)},c=()=>{n||(n=Qe(),t=n.read(),o(t))};return{connect:c,resolve(i,p){c();const s=n.read();let y=t,u="unknown";if(y&&s&&(s.key===y.key||s.index===y.index?u="replace":s.index<y.index?u="back":u=e.has(s.key)?"forward":"push"),u==="push"){const m=n.previous();m&&m.index===s.index-1&&fe.normalizePath(new URL(m.url).pathname)===fe.normalizePath(i)&&(y=m)}return t=s,o(y),o(s),{kind:u,direction:u==="back"?"backward":"forward",from:y,to:s}},dispose(){n==null||n.dispose(),n=null,t=null,e.clear()}}}function nt(){const n=tt(),t=new Map;return{connect:n.connect,resolve(e,o,c){var u,m;const i=n.resolve(e,o),p=(u=i.from)==null?void 0:u.key,s=(m=i.to)==null?void 0:m.key;if(i.kind==="back"&&p&&s){const h=t.get(p);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(i.kind==="forward"&&p&&s){const h=t.get(s);if((h==null?void 0:h.source)===p&&h.from===e&&h.to===o)return h.rule}const y=c(i.direction);if(s&&i.kind==="replace"&&t.delete(s),s&&p&&i.kind==="push"){for(const[h,P]of t)P.index>=i.to.index&&t.delete(h);t.set(s,{source:p,index:i.to.index,from:e,to:o,rule:y?{...y,preserveScroll:{...y.preserveScroll}}:null}),t.size>100&&t.delete(t.keys().next().value)}return y},dispose(){n.dispose(),t.clear()}}}function ot(n={}){let t=null,e=null;function o(){var i,p;t&&((i=t.out)==null||i.resolve(null),(p=t.in)==null||p.resolve(null),t=null)}function c(){if(t!=null&&t.out&&t.in){if(t.out.path===t.in.path){o();return}const i={from:t.out.path,to:t.in.path,out:t.out.payload,in:t.in.payload};e=i,t.out.resolve(i),t.in.resolve(i),t=null}}return{arrive(i,p,s){return new Promise(y=>{var P,O;const u=e===null?null:p==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((u==null?void 0:u.path)===i){y(null);return}p==="out"&&((P=t==null?void 0:t.in)==null?void 0:P.path)===i&&!t.out&&(t.in.resolve(null),t.in=void 0);const m=t==null?void 0:t[p];m&&m.path!==i&&o(),t||(t={});const h=t[p];if(h){if(((O=n.keepCurrent)==null?void 0:O.call(n,{type:p,path:i,current:h.payload,next:s}))??!1){y(null);return}h.resolve(null)}t[p]={path:i,payload:s,resolve:y},c()})},cancel(i){(t!=null&&t.out&&i(t.out.payload)||t!=null&&t.in&&i(t.in.payload))&&o(),(e&&i(e.out)||e&&i(e.in))&&(e=null)}}}const rt={},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:c}]of n){G.delete(e);let i=o.parent,p=!1;for(;i;){if(i.group===o.group&&t.has(i)){p=!0;break}i=i.parent}queueMicrotask(()=>o.callback(c,{emit:!p}))}}function st(){if(Ae||typeof document>"u")return;Ae=!0,Q=new MutationObserver(t=>{const e=new Map;for(const o of t){const c={parent:o.target,nextSibling:o.nextSibling};for(const i of Array.from(o.removedNodes))De(i,c,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 lt(n,t,e=rt){st();let o=n.parentElement,c=null;for(;o;){const i=G.get(o);if((i==null?void 0:i.group)===e){c=i;break}o=o.parentElement}return G.set(n,{element:n,callback:t,group:e,parent:c}),()=>{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 ct(){return ee||(ee=new MutationObserver(n=>{for(const t of n){const e=t.target,o=pe.get(e);if(!o)continue;const c=j(e);c!==o.accounted&&(o.accounted=c,c===te?(o.reactHidden=!0,o.onHide()):c!=="none"&&o.reactHidden&&(o.reactHidden=!1,o.onShow()))}}),ee)}function at(n,t){const e=j(n),o={accounted:e,reactHidden:e===te,onHide:t.onHide,onShow:t.onShow};return pe.set(n,o),ct().observe(n,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return j(n)===te},setDisplay(c,i=!1){c===null?n.style.removeProperty("display"):n.style.setProperty("display",c,i?"important":""),o.accounted=j(n)},sync(){o.accounted=j(n),o.reactHidden=o.accounted===te},stop(){pe.delete(n)}}}function ut(n,t={}){const{transitions:e=[],middleware:o=(r,l)=>({from:r,to:l})}=n,c=t.host??new _e,i={},p=ot({keepCurrent:({current:r,next:l})=>r.element.contains(l.element)}),s=nt(),y=typeof e=="function"?e:()=>e,u=Je();u.initialize();const m=new Map,h=r=>{let l=m.get(r);return l===void 0&&(l=o(r,r).from,m.set(r,l)),l},{initializeContext:P,calculateScrollOffset:O,evictScrollPosition:L,getScrollContainer:z,getPositionedParentElement:X,getScrollPosition:v,getIsMobile:f}=je({resolvePath:h}),g=new Map,S=()=>{const r=f();let l=g.get(r);return l||(l=y({isMobile:r}),g.set(r,l)),l},A=new WeakMap,D=r=>{A.set(r,{parent:r.parentNode,nextSibling:r.nextSibling})},b=r=>{const l=A.get(r);return l||{parent:r.parentNode,nextSibling:r.nextSibling}},w=new WeakMap,x=new WeakMap;let M=0;const N=r=>{const l=typeof getComputedStyle<"u"?getComputedStyle(r).display:"";return l&&l!=="none"?l:"block"},R=(r,l)=>{l.visibleDisplay=r.style.getPropertyValue("display"),l.computedDisplay=N(r)},_=(r,l)=>{if(x.get(r)!==l)return;x.delete(r);const a=w.get(r);a&&(a.savedCss!==null&&(r.style.cssText=a.savedCss,a.savedCss=null),a.intent==="hidden"?a.vis.setDisplay("none",!0):a.visibleDisplay?(a.vis.setDisplay(a.visibleDisplay,!1),R(r,a)):(a.vis.setDisplay(null),R(r,a)))},W=(r,l)=>{if(r.mode!=="hidden")return;const a=Array.from(new Set([r.element,l==null?void 0:l.element].filter(Boolean))),T=++M;for(const d of a)x.set(d,T);c.complete();for(const d of a)_(d,T)},K=(r,l,a,T,d,E,k)=>{const C=d.element,H=E.element,F=(d.mode??"unmount")==="hidden",{parent:q,nextSibling:U}=d.parent?{parent:d.parent,nextSibling:d.nextSibling}:b(C),Z=O(a,T,k.to),ie={direction:l,scrollOffset:Z,from:{scroll:v(a)},to:{scroll:v(T,k.to)},get scrollingElement(){return z()||document.documentElement},get positionedParent(){return X()}};let I;if(F){I=C,I.style.top=`${-1*((Z==null?void 0:Z.y)??0)}px`;const $=w.get(H);$&&$.savedCss===null&&($.savedCss=H.style.cssText)}else I=C,qe(I,ie);k.from||L(a);const J=F?++M:0;F&&(x.set(H,J),x.set(C,J));const ge=Promise.resolve(I),be=Promise.resolve(H),we=[],We={from:ge,to:be,context:ie,createElement:(($,se="div")=>{const V=document.createElement(se);return V.setAttribute("data-ssgoi-id",$),we.push(V),V})},Be=Promise.resolve(r.prepare?r.prepare(We):{});Ke({from:ge,to:be,extras:Be}).then(({from:$,to:se,extras:V})=>{!F&&q&&(U&&q.contains(U)?q.insertBefore(I,U):q.appendChild(I));const le=r.animation({from:$,to:se,context:ie,...V}),ce=le.onComplete;le.onComplete=()=>{ce==null||ce(),F?(_(C,J),_(H,J)):I.parentNode&&I.parentNode.removeChild(I);for(const ae of we)ae.parentNode&&ae.parentNode.removeChild(ae)},c.attach(le)})},B=(r,l,a)=>{const T=u.isSwipeBack();p.arrive(r,l,a).then(d=>{var H,re,F,q;if(l==="in"&&u.onPageEnter(),!d){l==="out"&&W(a);return}if(l!=="in")return;const{from:E,to:k}=o(d.from,d.to),C=s.resolve(d.from,d.to,U=>fe.resolveTransitionRule(E,k,S(),U));if(!C){(re=(H=d.in).applyScrollPolicy)==null||re.call(H,!1),L(d.from),W(d.out,d.in);return}if((q=(F=d.in).applyScrollPolicy)==null||q.call(F,C.preserveScroll.to),T){C.preserveScroll.from||L(d.from),W(d.out,d.in);return}K(C.transition,C.direction,d.from,d.to,d.out,d.in,C.preserveScroll)})},he=(r,l)=>{const a=w.get(r);if(!a)return;const T=a.intent==="hidden";if(a.intent="hidden",a.savedCss===null&&(a.savedCss=r.style.cssText),a.vis.setDisplay(a.computedDisplay||"block",!0),r.style.position="absolute",r.style.width="100%",r.style.left="0",T)return;const d=b(r),E={element:r,parent:d.parent,nextSibling:d.nextSibling,mode:"hidden"},k=a.pendingOutPath??a.currentPath??l;a.pendingOutPath=null,B(k,"out",E)},He=(r,l)=>{const a=w.get(r);if(!a||a.intent==="visible")return;a.intent="visible",a.currentPath=r.getAttribute("data-ssgoi-transition")??a.currentPath??l,a.pendingOutPath=null,a.pathRevision++,R(r,a),a.savedCss!==null&&(r.style.cssText=a.savedCss,a.visibleDisplay?a.vis.setDisplay(a.visibleDisplay,!1):a.vis.setDisplay(null));const T=a.currentPath,d=P(r,T),E={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling,applyScrollPolicy:d};B(T,"in",E)},Ie=(r,l,a,T=!0)=>{const d=w.get(r),E=(d==null?void 0:d.pendingOutPath)??(d==null?void 0:d.currentPath)??l;if(d&&(d.vis.stop(),w.delete(r),x.delete(r),d.intent==="hidden")){p.cancel(H=>H.element===r);return}if(!T)return;const k=a??b(r),C={element:r,parent:k.parent,nextSibling:k.nextSibling,mode:"unmount"};B(E,"out",C)},ye=new WeakSet,me=(r,l,{enter:a=!0}={})=>{if(s.connect(),ye.has(l)){const E=w.get(l);if(E&&E.currentPath!==r){E.intent==="visible"&&E.pendingOutPath===null&&(E.pendingOutPath=E.currentPath),E.currentPath=r;const k=++E.pathRevision;queueMicrotask(()=>{E.pathRevision===k&&(E.pendingOutPath=null)})}return}ye.add(l),D(l);const T=at(l,{onHide:()=>he(l,r),onShow:()=>He(l,r)}),d={vis:T,savedCss:null,intent:T.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:r,pendingOutPath:null,pathRevision:0};if(w.set(l,d),!T.isHidden&&(R(l,d),a)){const E=P(l,r),k={element:l,parent:l.parentElement,nextSibling:l.nextElementSibling,applyScrollPolicy:E};B(r,"in",k)}lt(l,(E,k)=>Ie(l,r,E,(k==null?void 0:k.emit)??!0),i)},ve=new Map;return{register:me,refFor:r=>{let l=ve.get(r);return l||(l=a=>{a&&me(r,a)},ve.set(r,l)),l},disconnect:s.dispose}}const Ne="data-ssgoi-root",dt=`[${Ne}]`,ne="data-ssgoi-transition",Me=`[${ne}]`,ft="[data-ssgoi-clone]";function pt(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function ht(n){return n.nodeType===Node.ELEMENT_NODE}function yt(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((c,i)=>Oe(c)-Oe(i));for(const c of o){const i=c.getAttribute(ne);if(i===null)continue;let p=c.parentElement,s=!1;for(;p;){if(e.has(p)){s=!0;break}p=p.parentElement}t.register(i,c,{enter:!s})}}function mt(n,t){if(!pt())return()=>{};n.setAttribute(Ne,"");const e=s=>s.closest(dt)===n,o=s=>!yt(s)||!e(s)||s.closest(ft)||s.getAttribute(ne)===null?null:s,c=(s,y)=>{if(ht(s)){if(s.matches(Me)){const u=o(s);u&&y.add(u)}for(const u of s.querySelectorAll(Me)){const m=o(u);m&&y.add(m)}}},i=new MutationObserver(s=>{const y=new Set,u=new Set;for(const m of s){if(m.type==="attributes"){const h=o(m.target);h&&y.add(h);continue}for(const h of m.addedNodes)c(h,u)}for(const m of u)y.add(m);Ce(y,t,u)});i.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ne]});const p=new Set;return c(n,p),Ce(p,t),()=>{var s;i.disconnect(),(s=t.disconnect)==null||s.call(t)}}exports.Animation=oe.Animation;exports.MultiAnimation=oe.MultiAnimation;exports.WebAnimation=oe.WebAnimation;exports.simulate=Xe.simulate;exports.HostAnimation=_e;exports.createSggoiTransitionContext=ut;exports.observeSsgoiTransitions=mt;
1
+ "use strict";var Qe=Object.defineProperty;var et=(t,n,e)=>n in t?Qe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var J=(t,n,e)=>et(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Te=require("./resolve-transition-rule-BL12rDDu.cjs"),de=require("./multi-animation-hDUcfD7W.cjs"),tt=require("./provider-D9Q2URox.cjs");class Ue extends de.Animation{constructor(){super(...arguments);J(this,"child",null);J(this,"_state","idle");J(this,"_settled",!1);J(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const u=o.getPose();o.complete(),e.matchInto(u)}e.playbackRate=this.playbackRate;const c=e.onComplete;e.onComplete=()=>{c==null||c(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const s=e.onUpdate;e.onUpdate=u=>{var i;s==null||s(u),(i=this.onUpdate)==null||i.call(this,u),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 nt=(t,n)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=n==null?void 0:n.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},Le=new Set(["auto","scroll","overlay"]),ot=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(Le.has(e.overflowY)||Le.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},rt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return n;n=n.parentElement}return document.body};function st(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const o={};return n.forEach((c,s)=>{o[c]=e[s]}),o})}const be=new WeakMap;function it(t){let n=be.get(t);if(!n){const o=t.ownerDocument,s=t===o.documentElement||t===o.scrollingElement?o:t,u=f=>{f.type==="wheel"&&f.ctrlKey||f.type==="touchmove"&&f.touches.length>1||f.cancelable&&f.preventDefault()},i={passive:!1,capture:!0};s.addEventListener("wheel",u,i),s.addEventListener("touchmove",u,i);const y=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," "]),h=f=>{var g,R;const d=f;if(!(d.defaultPrevented||d.altKey||!y.has(d.key))){for(const I of d.composedPath()){const x=I;if(x.isContentEditable||(g=x.matches)!=null&&g.call(x,"input, textarea, select, [role=slider], [role=spinbutton], [role=listbox], [role=menu], [role=tablist]")||d.key===" "&&((R=x.matches)!=null&&R.call(x,"button, [role=button]")))return}d.cancelable&&d.preventDefault()}};s.addEventListener("keydown",h,{capture:!0}),n={owners:0,restore(){s.removeEventListener("wheel",u,{capture:!0}),s.removeEventListener("touchmove",u,{capture:!0}),s.removeEventListener("keydown",h,{capture:!0})}},be.set(t,n)}n.owners++;let e=!1;return()=>{e||(e=!0,--n.owners===0&&(be.delete(t),n.restore()))}}const lt=768,ct=10,at=10;function ut(t={}){const{resolvePath:n=m=>m}=t;let e=null,o=null;const c=new Set,s=m=>{const S=m&&e?it(e):()=>{},M=()=>{c.delete(M)&&S()};return c.add(M),M};let u=!1,i=!1;const y=()=>{const m=(e==null?void 0:e.clientWidth)??0,S=m>0?m:typeof window<"u"?window.innerWidth:0;return S>0&&S<lt},h=()=>(i||(u=y(),i=!0),u),f=m=>`path:${n(m)}`;let d=null;const g=new Map;let R=null,I=!1,x=0,B=0,w=0;const p=()=>{e&&R&&!I&&!c.size&&g.set(f(R),{x:e.scrollLeft,y:e.scrollTop})},b=(m,S,M)=>{if(!e)return;const D=++B,H=f(m),C=S&&g.has(H)?g.get(H):{x:0,y:0};let N=0;const K=()=>{if(!e||M!==x||D!==B)return;S||g.set(H,C),e.scrollTo({top:C.y,left:C.x,behavior:"instant"}),!(Math.abs(e.scrollTop-C.y)<1&&Math.abs(e.scrollLeft-C.x)<1)&&N<ct&&(N++,requestAnimationFrame(K))};requestAnimationFrame(K)};return{beginTransition:s,disconnect(){++x,++B;for(const m of c)m();e&&(e===document.documentElement?window:e).removeEventListener("scroll",p),o==null||o.disconnect(),o=null,e=null,d=null,R=null,i=!1},initializeContext:(m,S,M)=>{I=!0;const D=R===S?x:++x;d=m,e||(e=ot(m),u=y(),i=!0,typeof ResizeObserver<"u"&&(o=new ResizeObserver(()=>{u=y()}),o.observe(e)),(e===document.documentElement?window:e).addEventListener("scroll",p,{passive:!0})),R=S;const H=f(S),C=g.get(H),N=U=>{D===x&&(w=D,U&&C&&g.set(H,C),b(S,U,D))};M!==void 0?N(M):requestAnimationFrame(()=>{w!==D&&D===x&&N(!1)});let K=0;const A=()=>{D===x&&(K++,K>=at?I=!1:requestAnimationFrame(A))};return requestAnimationFrame(A),N},calculateScrollOffset:(m,S,M=!1)=>{const D=m?f(m):null,H=D&&g.has(D)?g.get(D):{x:0,y:0},C=S&&M?f(S):null,N=C&&g.has(C)?g.get(C):{x:0,y:0};return{x:-N.x+H.x,y:-N.y+H.y}},evictScrollPosition:m=>{g.delete(f(m))},getScrollContainer:()=>e,getPositionedParentElement:()=>d?rt(d):document.body,getScrollPosition:(m,S=!0)=>{if(!S)return{x:0,y:0};const M=m?f(m):null;return M&&g.has(M)?g.get(M):{x:0,y:0}},getIsMobile:h}}const _e=30,De=8,He=1.2,Ne=30,dt=600;function ft(){let t=null,n=!1,e=!1,o=null,c=null,s=!1;const u=(p,b)=>{for(let T=0;T<p.length;T++){const O=p.item(T);if(O&&O.identifier===b)return O}return null},i=()=>{o!==null&&(clearTimeout(o),o=null)},y=()=>{c!==null&&(clearTimeout(c),c=null)},h=()=>{n=!0,e=!0,i(),y(),o=setTimeout(()=>{n=!1,e=!1,o=null},dt)},f=p=>{if(p.touches.length!==1){t=null;return}const b=p.touches.item(0);if(!b){t=null;return}const T=window.innerWidth,O=b.clientX<=_e,F=b.clientX>=T-_e;if(!O&&!F){t=null;return}t={identifier:b.identifier,startX:b.clientX,startY:b.clientY,fromLeftEdge:O,moved:!1}},d=p=>{if(!t)return;if(p.touches.length!==1){t=null;return}const b=u(p.touches,t.identifier);if(!b){t=null;return}const T=b.clientX-t.startX,O=b.clientY-t.startY,F=Math.abs(T),q=Math.abs(O);if(q>De&&q>F*He){t=null;return}const ee=t.fromLeftEdge?T>0:T<0;F>De&&F>q*He&&ee&&(t.moved=!0)},g=p=>{if(!t)return;const b=u(p.changedTouches,t.identifier);if(!b){t=null;return}const T=b.clientX-t.startX,O=t.fromLeftEdge?T>0:T<0;if(t.moved&&O&&Math.abs(T)>=Ne){h(),t=null;return}t.moved&&Math.abs(T)>=Ne&&h(),t=null},R=()=>{t&&(t.moved&&h(),t=null)};return{initialize:()=>{if(typeof window>"u"||s)return;s=!0;const p={passive:!0,capture:!0};window.addEventListener("touchstart",f,p),window.addEventListener("touchmove",d,p),window.addEventListener("touchend",g,p),window.addEventListener("touchcancel",R,p)},destroy:()=>{if(typeof window>"u"||!s)return;s=!1;const p={capture:!0};window.removeEventListener("touchstart",f,p),window.removeEventListener("touchmove",d,p),window.removeEventListener("touchend",g,p),window.removeEventListener("touchcancel",R,p),i(),y(),t=null,n=!1,e=!1},isSwipeBack:()=>{const p=n||e;return p&&i(),p},onPageEnter:()=>{n=!1,i(),y(),c=setTimeout(()=>{e=!1,c=null},0)}}}const Ie="__ssgoi_entry_v1",Ee=new WeakMap,Xe={read:()=>null,previous:()=>null,dispose(){}};function pt(){if(typeof window>"u")return Xe;const t=window.navigation,n=window;let e=Ee.get(n);e||(e=ht(n,t),Ee.set(n,e)),e.users++;const o=e;let c=!1;return{read:o.read,previous:o.previous,dispose(){c||(c=!0,--o.users===0&&(o.dispose(),Ee.delete(n)))}}}function We(t){return t&&typeof t.key=="string"&&typeof t.url=="string"&&Number.isSafeInteger(t.index)&&t.index>=0?{key:t.key,index:t.index,url:t.url}:null}function Se(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype}function ht(t,n){var B;const e=t.history,o=e.pushState,c=e.replaceState,s=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let u=0,i=!0,y=null,h=null;const f=()=>{const w=We(n==null?void 0:n.currentEntry);return(w==null?void 0:w.url)===t.location.href?w:null},d=()=>{const w=e.state,p=Se(w)?w[Ie]:null;return!Se(p)||typeof p.key!="string"||!p.key.startsWith(s)||!Number.isSafeInteger(p.index)?f():{key:p.key,index:p.index,url:t.location.href}},g=(w,p)=>w!==null&&!Se(w)?w:{...w,[Ie]:p},R=w=>({key:`${s}${++u}`,index:w});try{c.call(e,g(e.state,R(((B=f())==null?void 0:B.index)??0)),"")}catch{return{...Xe,read:f,users:0}}const I=function(w,p,b){var F;if(!i)return o.call(this,w,p,b);const T=d(),O=R(((T==null?void 0:T.index)??0)+1);o.call(this,g(w,O),p,b),y=T,h=((F=d())==null?void 0:F.key)??null},x=function(w,p,b){if(!i)return c.call(this,w,p,b);const T=d();c.call(this,g(w,T??R(0)),p,b)};return e.pushState=I,e.replaceState=x,{users:0,read:d,previous:()=>{var p;if(((p=d())==null?void 0:p.key)===h)return y;const w=f();return w?We(n==null?void 0:n.entries().find(b=>b.index===w.index-1)):null},dispose(){i=!1,e.pushState===I&&(e.pushState=o),e.replaceState===x&&(e.replaceState=c)}}}function yt(){let t=null,n=null;const e=new Set,o=s=>{s&&e.add(s.key),e.size>200&&e.delete(e.values().next().value)},c=()=>{t||(t=pt(),n=t.read(),o(n))};return{connect:c,resolve(s,u){c();const i=t.read();let y=n,h="unknown";if(y&&i&&(i.key===y.key||i.index===y.index?h="replace":i.index<y.index?h="back":h=e.has(i.key)?"forward":"push"),h==="push"){const f=t.previous();f&&f.index===i.index-1&&Te.normalizePath(new URL(f.url).pathname)===Te.normalizePath(s)&&(y=f)}return n=i,o(y),o(i),{kind:h,direction:h==="back"?"backward":"forward",from:y,to:i}},dispose(){t==null||t.dispose(),t=null,n=null,e.clear()}}}function mt(){const t=yt(),n=new Map;return{connect:t.connect,resolve(e,o,c){var h,f;const s=t.resolve(e,o),u=(h=s.from)==null?void 0:h.key,i=(f=s.to)==null?void 0:f.key;if(s.kind==="back"&&u&&i){const d=n.get(u);if((d==null?void 0:d.source)===i&&d.from===o&&d.to===e)return d.rule?{...d.rule,direction:d.rule.direction==="forward"?"backward":"forward",preserveScroll:{from:d.rule.preserveScroll.to,to:d.rule.preserveScroll.from}}:null}if(s.kind==="forward"&&u&&i){const d=n.get(i);if((d==null?void 0:d.source)===u&&d.from===e&&d.to===o)return d.rule}const y=c(s.direction);if(i&&s.kind==="replace"&&n.delete(i),i&&u&&s.kind==="push"){for(const[d,g]of n)g.index>=s.to.index&&n.delete(d);n.set(i,{source:u,index:s.to.index,from:e,to:o,rule:y?{...y,preserveScroll:{...y.preserveScroll}}:null}),n.size>100&&n.delete(n.keys().next().value)}return y},dispose(){t.dispose(),n.clear()}}}function vt(t={}){let n=null,e=null;function o(){var s,u;n&&((s=n.out)==null||s.resolve(null),(u=n.in)==null||u.resolve(null),n=null)}function c(){if(n!=null&&n.out&&n.in){if(n.out.path===n.in.path){o();return}const s={from:n.out.path,to:n.in.path,out:n.out.payload,in:n.in.payload};e=s,n.out.resolve(s),n.in.resolve(s),n=null}}return{arrive(s,u,i){return new Promise(y=>{var g,R;const h=e===null?null:u==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((h==null?void 0:h.path)===s){y(null);return}u==="out"&&((g=n==null?void 0:n.in)==null?void 0:g.path)===s&&!n.out&&(n.in.resolve(null),n.in=void 0);const f=n==null?void 0:n[u];f&&f.path!==s&&o(),n||(n={});const d=n[u];if(d){if(((R=t.keepCurrent)==null?void 0:R.call(t,{type:u,path:s,current:d.payload,next:i}))??!1){y(null);return}d.resolve(null)}n[u]={path:s,payload:i,resolve:y},c()})},cancel(s){(n!=null&&n.out&&s(n.out.payload)||n!=null&&n.in&&s(n.in.payload))&&o(),(e&&s(e.out)||e&&s(e.in))&&(e=null)}}}const gt={},j=new Map;let le=null,Be=!1;function qe(t,n,e){t instanceof HTMLElement&&j.has(t)&&!t.isConnected&&e.set(t,{entry:j.get(t),anchor:n});for(const o of Array.from(t.childNodes))qe(o,n,e)}function wt(t){const n=new Set(Array.from(t.values(),({entry:e})=>e));for(const[e,{entry:o,anchor:c}]of t){j.delete(e);let s=o.parent,u=!1;for(;s;){if(s.group===o.group&&n.has(s)){u=!0;break}s=s.parent}queueMicrotask(()=>o.callback(c,{emit:!u}))}}function bt(){if(Be||typeof document>"u")return;Be=!0,le=new MutationObserver(n=>{const e=new Map;for(const o of n){const c={parent:o.target,nextSibling:o.nextSibling};for(const s of Array.from(o.removedNodes))qe(s,c,e)}wt(e)});const t=()=>{le==null||le.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function Et(t,n,e=gt){bt();let o=t.parentElement,c=null;for(;o;){const s=j.get(o);if((s==null?void 0:s.group)===e){c=s;break}o=o.parentElement}return j.set(t,{element:t,callback:n,group:e,parent:c}),()=>{j.delete(t)}}const ke=new WeakMap;let ce=null;const ae="none !important";function Q(t){const n=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${n} !important`:n}function St(){return ce||(ce=new MutationObserver(t=>{for(const n of t){const e=n.target,o=ke.get(e);if(!o)continue;const c=Q(e);c!==o.accounted&&(o.accounted=c,c===ae?(o.reactHidden=!0,o.onHide()):c!=="none"&&o.reactHidden&&(o.reactHidden=!1,o.onShow()))}}),ce)}function Tt(t,n){const e=Q(t),o={accounted:e,reactHidden:e===ae,onHide:n.onHide,onShow:n.onShow};return ke.set(t,o),St().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return Q(t)===ae},setDisplay(c,s=!1){c===null?t.style.removeProperty("display"):t.style.setProperty("display",c,s?"important":""),o.accounted=Q(t)},sync(){o.accounted=Q(t),o.reactHidden=o.accounted===ae},stop(){ke.delete(t)}}}const kt=5e3;function Pt(t,n={}){const{transitions:e=[],middleware:o=(r,l)=>({from:r,to:l})}=t,c=n.host??new Ue,s={},u=vt({keepCurrent:({current:r,next:l})=>r.element.contains(l.element)}),i=mt(),y=typeof e=="function"?e:()=>e,h=ft();h.initialize();const f=new Map,d=r=>{let l=f.get(r);return l===void 0&&(l=o(r,r).from,f.set(r,l)),l},{initializeContext:g,beginTransition:R,disconnect:I,calculateScrollOffset:x,evictScrollPosition:B,getScrollContainer:w,getPositionedParentElement:p,getScrollPosition:b,getIsMobile:T}=ut({resolvePath:d}),O=new Map,F=()=>{const r=T();let l=O.get(r);return l||(l=y({isMobile:r}),O.set(r,l)),l},q=new WeakMap,ee=r=>{q.set(r,{parent:r.parentNode,nextSibling:r.nextSibling})},te=r=>{const l=q.get(r);return l||{parent:r.parentNode,nextSibling:r.nextSibling}},m=new WeakMap,S=new WeakMap;let M=0;const D=r=>{const l=typeof getComputedStyle<"u"?getComputedStyle(r).display:"";return l&&l!=="none"?l:"block"},H=(r,l)=>{l.visibleDisplay=r.style.getPropertyValue("display"),l.computedDisplay=D(r)},C=(r,l)=>{if(S.get(r)!==l)return;S.delete(r);const a=m.get(r);a&&(a.savedCss!==null&&(r.style.cssText=a.savedCss,a.savedCss=null),a.intent==="hidden"?a.vis.setDisplay("none",!0):a.visibleDisplay?(a.vis.setDisplay(a.visibleDisplay,!1),H(r,a)):(a.vis.setDisplay(null),H(r,a)))},N=(r,l)=>{if(r.mode!=="hidden")return;const a=Array.from(new Set([r.element,l==null?void 0:l.element].filter(Boolean))),L=++M;for(const v of a)S.set(v,L);c.complete();for(const v of a)C(v,L)},K=new Set;let A,U=0,ne=!1;const $e=(r,l,a,L,v,E,W)=>{const k=v.element,P=E.element,X=(v.mode??"unmount")==="hidden",{parent:G,nextSibling:V}=v.parent?{parent:v.parent,nextSibling:v.nextSibling}:te(k),Y=x(a,L,W.to),he={direction:l,scrollOffset:Y,from:{scroll:b(a)},to:{scroll:b(L,W.to)},get scrollingElement(){return w()||document.documentElement},get positionedParent(){return p()}};let z;if(X){z=k,z.style.top=`${-1*((Y==null?void 0:Y.y)??0)}px`;const _=m.get(P);_&&_.savedCss===null&&(_.savedCss=P.style.cssText)}else z=k,nt(z,he);W.from||B(a);const ie=X?++M:0;X&&(S.set(P,ie),S.set(k,ie));const Re=Promise.resolve(z),Ae=Promise.resolve(P),Me=[],Ze={from:Re,to:Ae,context:he,createElement:((_,ve="div")=>{const Z=document.createElement(ve);return Z.setAttribute("data-ssgoi-id",_),Me.push(Z),Z})},Je=R(t.scrollLock!==!1);let ye=!1;const $=()=>{if(!ye){ye=!0,clearTimeout(Oe),K.delete($),A===$&&(A=void 0);try{X?(C(k,ie),C(P,ie)):z.parentNode&&z.parentNode.removeChild(z);for(const _ of Me)_.parentNode&&_.parentNode.removeChild(_)}finally{Je()}}};K.add($),A==null||A(),A=$;const me=_=>{$(),console.error("[SSGOI] Page transition failed",_)},Oe=setTimeout(()=>{me(new Error("Page transition preparation timed out"))},kt);let Ce;try{Ce=Promise.resolve(r.prepare?r.prepare(Ze):{})}catch(_){me(_);return}st({from:Re,to:Ae,extras:Ce}).then(({from:_,to:ve,extras:Z})=>{if(ye)return;clearTimeout(Oe),A===$&&(A=void 0),!X&&G&&(V&&G.contains(V)?G.insertBefore(z,V):G.appendChild(z));const ge=r.animation({from:_,to:ve,context:he,...Z}),we=ge.onComplete;ge.onComplete=()=>{try{we==null||we()}finally{$()}},c.attach(ge)}).catch(me)},oe=(r,l,a)=>{if(ne)return;const L=U,v=h.isSwipeBack();u.arrive(r,l,a).then(E=>{var pe,X,G,V;if(ne||L!==U)return;if(l==="in"&&h.onPageEnter(),!E){l==="out"&&N(a);return}if(l!=="in")return;const{from:W,to:k}=o(E.from,E.to),P=i.resolve(E.from,E.to,Y=>Te.resolveTransitionRule(W,k,F(),Y));if(!P){(X=(pe=E.in).applyScrollPolicy)==null||X.call(pe,!1),B(E.from),N(E.out,E.in),A==null||A(),c.complete();return}if((V=(G=E.in).applyScrollPolicy)==null||V.call(G,P.preserveScroll.to),v){P.preserveScroll.from||B(E.from),N(E.out,E.in),A==null||A(),c.complete();return}$e(P.transition,P.direction,E.from,E.to,E.out,E.in,P.preserveScroll)})},Ve=(r,l)=>{const a=m.get(r);if(!a)return;const L=a.intent==="hidden";if(a.intent="hidden",a.savedCss===null&&(a.savedCss=r.style.cssText),a.vis.setDisplay(a.computedDisplay||"block",!0),r.style.position="absolute",r.style.width="100%",r.style.left="0",L)return;const v=te(r),E={element:r,parent:v.parent,nextSibling:v.nextSibling,mode:"hidden"},W=a.pendingOutPath??a.currentPath??l;a.pendingOutPath=null,oe(W,"out",E)},Ye=(r,l)=>{const a=m.get(r);if(!a||a.intent==="visible")return;a.intent="visible",a.currentPath=r.getAttribute("data-ssgoi-transition")??a.currentPath??l,a.pendingOutPath=null,a.pathRevision++,H(r,a),a.savedCss!==null&&(r.style.cssText=a.savedCss,a.visibleDisplay?a.vis.setDisplay(a.visibleDisplay,!1):a.vis.setDisplay(null));const L=a.currentPath,v=g(r,L),E={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling,applyScrollPolicy:v};oe(L,"in",E)},je=(r,l,a,L=!0)=>{const v=m.get(r);se.delete(r);const E=(v==null?void 0:v.pendingOutPath)??(v==null?void 0:v.currentPath)??l;if(v&&(v.vis.stop(),re.delete(v.vis),m.delete(r),S.delete(r),v.intent==="hidden")){u.cancel(P=>P.element===r);return}if(!L)return;const W=a??te(r),k={element:r,parent:W.parent,nextSibling:W.nextSibling,mode:"unmount"};oe(E,"out",k)};let fe=new WeakSet;const re=new Set,se=new Map,Pe=(r,l,{enter:a=!0}={})=>{if(ne=!1,i.connect(),h.initialize(),fe.has(l)){const k=m.get(l);if(k&&k.currentPath!==r){k.intent==="visible"&&k.pendingOutPath===null&&(k.pendingOutPath=k.currentPath),k.currentPath=r;const P=++k.pathRevision;queueMicrotask(()=>{k.pathRevision===P&&(k.pendingOutPath=null)})}return}fe.add(l);const L=U;ee(l);const v=Tt(l,{onHide:()=>Ve(l,r),onShow:()=>Ye(l,r)});re.add(v);const E={vis:v,savedCss:null,intent:v.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:r,pendingOutPath:null,pathRevision:0};if(m.set(l,E),!v.isHidden&&(H(l,E),a)){const k=g(l,r),P={element:l,parent:l.parentElement,nextSibling:l.nextElementSibling,applyScrollPolicy:k};oe(r,"in",P)}const W=Et(l,(k,P)=>{L===U&&je(l,r,k,(P==null?void 0:P.emit)??!0)},s);se.set(l,W)},xe=new Map;return{register:Pe,refFor:r=>{let l=xe.get(r);return l||(l=a=>{a&&Pe(r,a)},xe.set(r,l)),l},disconnect(){ne=!0,U++,u.cancel(()=>!0);try{c.complete()}finally{for(const r of K)r();for(const r of re)r.stop();re.clear();for(const r of se.values())r();se.clear(),fe=new WeakSet,I(),h.destroy(),i.dispose()}}}}const Ge="data-ssgoi-root",xt=`[${Ge}]`,ue="data-ssgoi-transition",Fe=`[${ue}]`,Rt="[data-ssgoi-clone]";function At(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Mt(t){return t.nodeType===Node.ELEMENT_NODE}function Ot(t){return t instanceof HTMLElement}function ze(t){let n=0,e=t.parentElement;for(;e;)n++,e=e.parentElement;return n}function Ke(t,n,e=t){const o=Array.from(t).sort((c,s)=>ze(c)-ze(s));for(const c of o){const s=c.getAttribute(ue);if(s===null)continue;let u=c.parentElement,i=!1;for(;u;){if(e.has(u)){i=!0;break}u=u.parentElement}n.register(s,c,{enter:!i})}}function Ct(t,n){if(!At())return()=>{};t.setAttribute(Ge,"");const e=i=>i.closest(xt)===t,o=i=>!Ot(i)||!e(i)||i.closest(Rt)||i.getAttribute(ue)===null?null:i,c=(i,y)=>{if(Mt(i)){if(i.matches(Fe)){const h=o(i);h&&y.add(h)}for(const h of i.querySelectorAll(Fe)){const f=o(h);f&&y.add(f)}}},s=new MutationObserver(i=>{const y=new Set,h=new Set;for(const f of i){if(f.type==="attributes"){const d=o(f.target);d&&y.add(d);continue}for(const d of f.addedNodes)c(d,h)}for(const f of h)y.add(f);Ke(y,n,h)});s.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ue]});const u=new Set;return c(t,u),Ke(u,n),()=>{var i;s.disconnect(),(i=n.disconnect)==null||i.call(n)}}exports.Animation=de.Animation;exports.MultiAnimation=de.MultiAnimation;exports.WebAnimation=de.WebAnimation;exports.simulate=tt.simulate;exports.HostAnimation=Ue;exports.createSggoiTransitionContext=Pt;exports.observeSsgoiTransitions=Ct;