PageSourceSearch

https://mathstodon.xyz/packs/scroll_container-DTFJ2dtn.js

js mathstodon.xyz collected 2026-09-24 08:40:00 UTC 12,360 bytes, 2 lines download raw bytes

1import{o as e,t}from"./rolldown-runtime-C0FnF6B9.js";import{t as n}from"./react-C21x__mS.js";import{t as r}from"./jsx-runtime-BdxMnOeJ.js";import{c as i,s as a}from"./react-router-BkmJBoOP.js";import{r as o}from"./icon_button-DfNtv8BJ.js";var s=e(n()),c=(e,t)=>!(t.state?.mastodonModalKey&&t.state.mastodonModalKey!==e?.state?.mastodonModalKey),l=!!(typeof window<`u`&&window.document&&window.document.createElement),u=new Date().getTime();function d(e){var t=new Date().getTime(),n=Math.max(0,16-(t-u)),r=setTimeout(e,n);return u=t,r}var f=[``,`webkit`,`moz`,`o`,`ms`],p=`clearTimeout`,m=d,h=function(e,t){return e+(e?t[0].toUpperCase()+t.substr(1):t)+`AnimationFrame`};l&&f.some(function(e){var t=h(e,`request`);return t in window&&(p=h(e,`cancel`),m=function(e){return window[t](e)}),!!m});var g=function(e){typeof window[p]==`function`&&window[p](e)},_=m;function v(e){return`nodeType`in e&&e.nodeType===document.DOCUMENT_NODE}function y(e){return`window`in e&&e.window===e?e:v(e)&&e.defaultView||!1}function b(e){var t=e===`pageXOffset`?`scrollLeft`:`scrollTop`;function n(n,r){var i=y(n);if(r===void 0)return i?i[e]:n[t];i?i.scrollTo(i[e],r):n[t]=r}return n}var x=b(`pageXOffset`),S=b(`pageYOffset`),C=t(((e,t)=>{t.exports=function(e,t,n,r,i,a,o,s){if(!e){var c;if(t===void 0)c=Error(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var l=[n,r,i,a,o,s],u=0;c=Error(t.replace(/%s/g,function(){return l[u++]})),c.name=`Invariant Violation`}throw c.framesToPop=1,c}}})),w=t(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):n.lifecycle=r()})(e,function(){var e=void 0;try{new EventTarget,e=!1}catch{e=!1}var t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n=function(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},a=function(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return!t||typeof t!=`object`&&typeof t!=`function`?e:t},o=function(){function e(){n(this,e),this._registry={}}return r(e,[{key:`addEventListener`,value:function(e,t){this._getRegistry(e).push(t)}},{key:`removeEventListener`,value:function(e,t){var n=this._getRegistry(e),r=n.indexOf(t);r>-1&&n.splice(r,1)}},{key:`dispatchEvent`,value:function(e){return e.target=this,Object.freeze(e),this._getRegistry(e.type).forEach(function(t){return t(e)}),!0}},{key:`_getRegistry`,value:function(e){return this._registry[e]=this._registry[e]||[]}}]),e}(),s=e?EventTarget:o,c=e?Event:function e(t){n(this,e),this.type=t},l=function(e){function t(e,r){n(this,t);var i=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return i.newState=r.newState,i.oldState=r.oldState,i.originalEvent=r.originalEvent,i}return i(t,c),t}(),u=`active`,d=`passive`,f=`hidden`,p=`frozen`,m=`terminated`,h=(typeof safari>`u`?`undefined`:t(safari))===`object`&&safari.pushNotification,g=[`focus`,`blur`,`visibilitychange`,`freeze`,`resume`,`pageshow`,`onpageshow`in self?`pagehide`:`unload`],_=function(e){return e.preventDefault(),e.returnValue=`Are you sure?`},v=[[u,d,f,m],[u,d,f,p],[f,d,u],[p,f],[p,u],[p,d]].map(function(e){return e.reduce(function(e,t,n){return e[t]=n,e},{})}),y=function(){return document.visibilityState===f?f:document.hasFocus()?u:d};return new(function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._state=y(),e._unsavedChanges=[],e._handleEvents=e._handleEvents.bind(e),g.forEach(function(t){return addEventListener(t,e._handleEvents,!0)}),h&&addEventListener(`beforeunload`,function(t){e._safariBeforeUnloadTimeout=setTimeout(function(){t.defaultPrevented||t.returnValue.length>0||e._dispatchChangesIfNeeded(t,f)},0)}),e}return i(t,s),r(t,[{key:`addUnsavedChanges`,value:function(e){!this._unsavedChanges.indexOf(e)>-1&&(this._unsavedChanges.length===0&&addEventListener(`beforeunload`,_),this._unsavedChanges.push(e))}},{key:`removeUnsavedChanges`,value:function(e){var t=this._unsavedChanges.indexOf(e);t>-1&&(this._unsavedChanges.splice(t,1),this._unsavedChanges.length===0&&removeEventListener(`beforeunload`,_))}},{key:`_dispatchChangesIfNeeded`,value:function(e,t){if(t!==this._state)for(var n=function(e,t){for(var n,r=0;n=v[r];++r){var i=n[e],a=n[t];if(i>=0&&a>=0&&a>i)return Object.keys(n).slice(i,a+1)}return[]}(this._state,t),r=0;r<n.length-1;++r){var i=n[r],a=n[r+1];this._state=a,this.dispatchEvent(new l(`statechange`,{oldState:i,newState:a,originalEvent:e}))}}},{key:`_handleEvents`,value:function(e){switch(h&&clearTimeout(this._safariBeforeUnloadTimeout),e.type){case`pageshow`:case`resume`:this._dispatchChangesIfNeeded(e,y());break;case`focus`:this._dispatchChangesIfNeeded(e,u);break;case`blur`:this._state===u&&this._dispatchChangesIfNeeded(e,y());break;case`pagehide`:case`unload`:this._dispatchChangesIfNeeded(e,e.persisted?p:m);break;case`visibilitychange`:this._state!==p&&this._state!==m&&this._dispatchChangesIfNeeded(e,y());break;case`freeze`:this._dispatchChangesIfNeeded(e,p)}}},{key:`state`,get:function(){return this._state}},{key:`pageWasDiscarded`,get:function(){return document.wasDiscarded||!1}}]),t}())})})),T=e(C()),E=e(w());function D(){return/iPad|iPhone|iPod/.test(window.navigator.platform)&&/^((?!CriOS).)*Safari/.test(window.navigator.userAgent)}var O=2,k=function(){function e(e){var t=this,n=e.addNavigationListener,r=e.stateStorage,i=e.getCurrentLocation,a=e.shouldUpdateScroll;this._setScrollRestoration=function(){if(!t._oldScrollRestoration&&`scrollRestoration`in window.history&&!D()){t._oldScrollRestoration=window.history.scrollRestoration;try{window.history.scrollRestoration=`manual`}catch{t._oldScrollRestoration=null}}},this._restoreScrollRestoration=function(){if(t._oldScrollRestoration){try{window.history.scrollRestoration=t._oldScrollRestoration}catch{}t._oldScrollRestoration=null}},this._onWindowScroll=function(){if(!t._ignoreScrollEvents&&(t._saveWindowPositionHandle||=_(t._saveWindowPosition),t._windowScrollTarget)){var e=t._windowScrollTarget,n=e[0],r=e[1],i=x(window),a=S(window);i===n&&a===r&&(t._windowScrollTarget=null,t._cancelCheckWindowScroll())}},this._saveWindowPosition=function(){t._saveWindowPositionHandle=null,t._savePosition(null,window)},this._checkWindowScrollPosition=function(){return t._checkWindowScrollHandle=null,t._windowScrollTarget?(t.scrollToTarget(window,t._windowScrollTarget),++t._numWindowScrollAttempts,t._numWindowScrollAttempts>=O?(t._windowScrollTarget=null,Promise.resolve()):new Promise(function(e){t._checkWindowScrollHandle=_(function(){return e(t._checkWindowScrollPosition())})})):Promise.resolve()},this._stateStorage=r,this._getCurrentLocation=i,this._shouldUpdateScroll=a,this._oldScrollRestoration=null,this._setScrollRestoration(),this._saveWindowPositionHandle=null,this._checkWindowScrollHandle=null,this._windowScrollTarget=null,this._numWindowScrollAttempts=0,this._ignoreScrollEvents=!1,this._scrollElements={},window.addEventListener(`scroll`,this._onWindowScroll);var o=function(e){g(t._saveWindowPositionHandle),t._saveWindowPositionHandle=null,e&&!t._ignoreScrollEvents&&t._saveWindowPosition(),Object.keys(t._scrollElements).forEac
1h(function(e){var n=t._scrollElements[e];g(n.savePositionHandle),n.savePositionHandle=null,t._ignoreScrollEvents||t._saveElementPosition(e)})};this._removeNavigationListener=n(function(e){var t=e.action;o(t!==`POP`)}),E.default.addEventListener(`statechange`,function(e){var n=e.newState;n===`terminated`||n===`frozen`||n===`discarded`?(o(!0),t._restoreScrollRestoration()):t._setScrollRestoration()})}var t=e.prototype;return t.registerElement=function(e,t,n,r){var i=this;this._scrollElements[e]&&(0,T.default)(!1);var a=function(){i._saveElementPosition(e)},o={element:t,shouldUpdateScroll:n,savePositionHandle:null,onScroll:function(){!o.savePositionHandle&&!i._ignoreScrollEvents&&(o.savePositionHandle=_(a))}};!o.savePositionHandle&&!this._ignoreScrollEvents&&(o.savePositionHandle=_(a)),this._scrollElements[e]=o,t.addEventListener(`scroll`,o.onScroll),this._updateElementScroll(e,null,r)},t.unregisterElement=function(e){!this._scrollElements[e]&&(0,T.default)(!1);var t=this._scrollElements[e],n=t.element,r=t.onScroll,i=t.savePositionHandle;n.removeEventListener(`scroll`,r),g(i),delete this._scrollElements[e]},t.updateScroll=function(e,t){var n=this;this._updateWindowScroll(e,t).then(function(){n._saveWindowPositionHandle||=_(n._saveWindowPosition)}),Object.keys(this._scrollElements).forEach(function(r){n._updateElementScroll(r,e,t)})},t.stop=function(){this._restoreScrollRestoration(),window.removeEventListener(`scroll`,this._onWindowScroll),this._cancelCheckWindowScroll(),this._removeNavigationListener()},t.startIgnoringScrollEvents=function(){this._ignoreScrollEvents=!0},t.stopIgnoringScrollEvents=function(){this._ignoreScrollEvents=!1},t._cancelCheckWindowScroll=function(){g(this._checkWindowScrollHandle),this._checkWindowScrollHandle=null},t._saveElementPosition=function(e){var t=this._scrollElements[e];t.savePositionHandle=null,this._savePosition(e,t.element)},t._savePosition=function(e,t){this._stateStorage.save(this._getCurrentLocation(),e,[x(t),S(t)])},t._updateWindowScroll=function(e,t){return this._cancelCheckWindowScroll(),this._windowScrollTarget=this._getScrollTarget(null,this._shouldUpdateScroll,e,t),this._numWindowScrollAttempts=0,this._checkWindowScrollPosition()},t._updateElementScroll=function(e,t,n){var r=this._scrollElements[e],i=r.element,a=r.shouldUpdateScroll,o=this._getScrollTarget(e,a,t,n);o&&this.scrollToTarget(i,o)},t._getDefaultScrollTarget=function(e){var t=e.hash;return t&&t!==`#`?t.charAt(0)===`#`?t.slice(1):t:[0,0]},t._getScrollTarget=function(e,t,n,r){var i=!t||t.call(this,n,r);if(!i||Array.isArray(i)||typeof i==`string`)return i;var a=this._getCurrentLocation();return this._getSavedScrollTarget(e,a)||this._getDefaultScrollTarget(a)},t._getSavedScrollTarget=function(e,t){return t.action===`PUSH`?null:this._stateStorage.read(t,e)},t.scrollToTarget=function(e,t){if(typeof t==`string`){var n=document.getElementById(t)||document.getElementsByName(t)[0];if(n){n.scrollIntoView();return}t=[0,0]}var r=t,i=r[0],a=r[1];x(e,i),S(e,a)},e}(),A=`@@scroll|`,j=class{read(e,t){let n=this.getStateKey(e,t);try{let e=sessionStorage.getItem(n);return e?JSON.parse(e):null}catch{return null}}save(e,t,n){let r=this.getStateKey(e,t),i=JSON.stringify(n);try{sessionStorage.setItem(r,i)}catch{}}getStateKey(e,t){let n=`${A}${e.key}`;return t==null?n:`${n}|${t}`}},M=r(),N=s.createContext(null),P=({children:e,shouldUpdateScroll:t=c})=>{let n=i(),r=a(),l=(0,s.useRef)(n);(0,s.useEffect)(()=>{l.current=n},[n]);let[u]=(0,s.useState)(()=>new k({addNavigationListener:r.listen.bind(r),stateStorage:new j,getCurrentLocation:()=>l.current,shouldUpdateScroll:(e,n)=>t.call(u,e,n)})),d=o(n)??null;(0,s.useEffect)(()=>{u.updateScroll(d,n)},[n,d,u]),(0,s.useEffect)(()=>()=>{u.stop()},[u]);let f=(0,s.useMemo)(()=>({registerElement:(e,t,r)=>{u.registerElement(e,t,r,n)},unregisterElement:e=>{u.unregisterElement(e)},scrollBehavior:u}),[n,u]);return(0,M.jsx)(N.Provider,{value:f,children:s.Children.only(e)})},F=({children:e,scrollKey:t,childRef:n,shouldUpdateScroll:r=c})=>{let i=(0,s.useContext)(N),a=(0,s.useRef)(null);return(0,s.useImperativeHandle)(n,()=>a.current??void 0,[]),(0,s.useEffect)(()=>
1{if(!(!i||!a.current))return i.registerElement(t,a.current,(e,t)=>r.call(i.scrollBehavior,e,t)),()=>{i.unregisterElement(t)}},[]),s.Children.only((0,s.isValidElement)(e)?s.cloneElement(e,{ref:a}):e)};export{P as n,F as t};
2//# sourceMappingURL=scroll_container-DTFJ2dtn.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.