PageSourceSearch

https://sendou.ink/assets/Popover-CXmBGy-L.js

js sendou.ink collected 2026-10-03 23:29:45 UTC 9,597 bytes, 1 lines download raw bytes

1import{it as e,tt as t}from"./components-95HoEAGN.js";import{t as n}from"./react-dom-BbicZnIQ.js";import{t as r}from"./jsx-runtime-ADKGLI3c.js";import{t as i}from"./compiler-runtime-COTCmOQp.js";import{t as a}from"./clsx-DB0hHKMi.js";import{t as o}from"./useHydrated-8nknCoOh.js";import{t as s}from"./scroll-lock-DP1bDCJP.js";var c=e(n(),1),l=i(),u=e(t(),1),d=typeof window<`u`?u.useLayoutEffect:u.useEffect,f={triggerContainer:`_triggerContainer_11uod_3`,content:`_content_11uod_7`},p=150;function m(){let e=document.documentElement,t=e.clientWidth,n=e.clientHeight,r=window.visualViewport;if(!r)return{top:0,left:0,right:t,bottom:n,width:t,height:n};let i=r.offsetTop,a=r.offsetLeft,o=Math.min(t,a+r.width),s=Math.min(n,i+r.height);return{top:i,left:a,right:o,bottom:s,width:o-a,height:s-i}}function h(){let e=window.visualViewport;return e?window.innerHeight-e.height>p:!1}var g={top:`bottom`,bottom:`top`,left:`right`,right:`left`},_={start:`0%`,center:`50%`,end:`100%`};function v({anchor:e,floating:t,bounds:n,placement:r,gap:i,padding:a,rtl:o}){let{side:s,align:c}=C(r),l=T(e,n,i,a),u=g[s],d=w(s)?t.height:t.width,f=y(n,r,a),p=d<=l[s]||l[s]>=l[u]?s:u;return{side:p,align:c,availableWidth:Math.max(0,w(p)?f:l[p]),availableHeight:Math.max(0,w(p)?l[p]:f),transformOrigin:ee(p,c,o)}}function y(e,t,n){let r=b(t)?e.right-e.left:e.bottom-e.top;return Math.max(0,r-2*n)}function b(e){return w(C(e).side)}function x({anchor:e,floating:t,bounds:n,side:r,align:i,gap:a,padding:o,rtl:s,viewport:c}){if(w(r)){let l=O(E(e.left,e.width,t.width,D(i,s)),n.left+o,n.right-o-t.width);return r===`bottom`?{top:e.top+e.height+a,right:null,bottom:null,left:l}:{top:null,right:null,bottom:c.height-(e.top-a),left:l}}let l=O(E(e.top,e.height,t.height,i),n.top+o,n.bottom-o-t.height);return r===`right`?{top:l,right:null,bottom:null,left:e.left+e.width+a}:{top:l,right:c.width-(e.left-a),bottom:null,left:null}}function S(e,t){let{top:n,right:r,bottom:i,left:a}=e;return{top:n===null?null:n+t.y,right:r===null?null:r-t.x,bottom:i===null?null:i-t.y,left:a===null?null:a+t.x}}function C(e){let[t,n=`center`]=e.split(` `);return{side:t,align:n}}function w(e){return e===`top`||e===`bottom`}function T(e,t,n,r){let i=n+r;return{top:e.top-t.top-i,bottom:t.bottom-(e.top+e.height)-i,left:e.left-t.left-i,right:t.right-(e.left+e.width)-i}}function E(e,t,n,r){return r===`start`?e:r===`end`?e+t-n:e+t/2-n/2}function D(e,t){return!t||e===`center`?e:e===`start`?`end`:`start`}function O(e,t,n){return Math.max(t,Math.min(e,n))}function ee(e,t,n){if(w(e)){let r=_[D(t,n)];return e===`bottom`?`${r} 0%`:`${r} 100%`}let r=_[t];return e===`right`?`0% ${r}`:`100% ${r}`}var te=`--floating-gap`,ne=`--floating-viewport-padding`,k=`--popover-boundary-top`,A=`--popover-boundary-bottom`,j=`--floating-available-width`,M=`--floating-available-height`,N=`--floating-anchor-width`,P=`--floating-anchor-height`,F=`--floating-transform-origin`,I=[j,M,N,P,F],L=[`top`,`right`,`bottom`,`left`],R=`10000000px`;function z({isOpen:e,floatingRef:t,getAnchor:n,placement:r=`bottom`}){let i=u.useRef(n);i.current=n,d(()=>{let n=t.current;if(!e||!n)return;let a=null,o=null,s=null,c=null,l=null,u=()=>{let e=i.current();if(!e||!n.matches(`:popover-open`))return;c===null&&(c=U(e),n.style.position=c?`fixed`:`absolute`);let t=getComputedStyle(n),l=K(t,te),u=K(t,ne),d=t.direction===`rtl`,f=V(n),p=e.getBoundingClientRect(),m=H(e,p,t,c);if(n.style.visibility=m?`hidden`:``,m)return;n.style.setProperty(N,q(p.width)),n.style.setProperty(P,q(p.height)),(a===null||!W(f,o))&&(o=f,a=B(n,f,r,u),s=null);let h=v({anchor:p,floating:a,bounds:f,placement:r,gap:l,padding:u,rtl:d});G(h,s)||(s=h,n.style.setProperty(j,q(Math.floor(h.availableWidth))),n.style.setProperty(M,q(Math.floor(h.availableHeight))),n.style.setProperty(F,h.transformOrigin),n.dataset.side=h.side,n.dataset.align=h.align);let g=document.documentElement,_=x({anchor:p,floating:n.getBoundingClientRect(),bounds:f,side:h.side,align:h.align,gap:l,padding:u,rtl:d,viewport:{width:g.clientWidth,height:g.clientHeight}}),y=c?_:S(_,{x:window.scrollX,y:window.scrollY});for(let e of L){let t=y[e];n.style.setProperty(e,t===null?`auto`:q(re(t)))}};u();let d=()=>{l===null&&(l=requestAnimationFrame(()=>{l=null,u()}))},f=e=>{e.target instanceof Node&&n.contains(e.target)||u()},p=new ResizeObserver(d);p.observe(n);let m=i.current();return m&&p.observe(m),n.addEventListener(`toggle`,u),window.addEventListener(`scroll`,f,{capture:!0,passive:!0}
1),window.addEventListener(`resize`,d),window.visualViewport?.addEventListener(`resize`,d),window.visualViewport?.addEventListener(`scroll`,d),()=>{p.disconnect(),n.removeEventListener(`toggle`,u),window.removeEventListener(`scroll`,f,{capture:!0}),window.removeEventListener(`resize`,d),window.visualViewport?.removeEventListener(`resize`,d),window.visualViewport?.removeEventListener(`scroll`,d),l!==null&&cancelAnimationFrame(l);for(let e of[`position`,`visibility`,...L,...I])n.style.removeProperty(e);delete n.dataset.side,delete n.dataset.align}},[e,t,r])}function B(e,t,n,r){let i=b(n);e.style.setProperty(i?j:M,q(y(t,n,r))),e.style.setProperty(i?M:j,R);let{width:a,height:o}=e.getBoundingClientRect();return{width:a,height:o}}function V(e){let t=getComputedStyle(e),n=m(),r=document.documentElement.clientHeight;return{top:Math.max(n.top,K(t,k)),right:n.right,bottom:Math.min(n.bottom,r-K(t,A)),left:n.left}}function H(e,t,n,r){let i=document.documentElement,a=r?0:K(n,k),o=i.clientWidth,s=i.clientHeight-(r?0:K(n,A)),c=0,l=e.parentElement;for(;l!==null&&l!==document.body;){if(getComputedStyle(l).overflow!==`visible`){let e=l.getBoundingClientRect();a=Math.max(a,e.top),o=Math.min(o,e.right),s=Math.min(s,e.bottom),c=Math.max(c,e.left)}l=l.parentElement}return t.bottom<=a||t.top>=s||t.right<=c||t.left>=o}function U(e){let t=e;for(;t!==null&&t!==document.body;){let e=getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0;t=t.parentElement}return!1}function W(e,t){return t!==null&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}function G(e,t){return t!==null&&e.side===t.side&&e.align===t.align&&Math.floor(e.availableWidth)===Math.floor(t.availableWidth)&&Math.floor(e.availableHeight)===Math.floor(t.availableHeight)&&e.transformOrigin===t.transformOrigin}function K(e,t){return Number.parseFloat(e.getPropertyValue(t))||0}function re(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}function q(e){return`${e}px`}var ie=`--floating-viewport-padding`;function J(e,t){let n=u.useRef(t);n.current=t,u.useEffect(()=>{let t=window.visualViewport;if(!e||!t)return;let r=()=>{if(!h())return;let e=n.current();e&&ae(e)};return t.addEventListener(`resize`,r),()=>t.removeEventListener(`resize`,r)},[e])}function ae(e){if(e.scrollIntoView({block:`nearest`,inline:`nearest`}),s())return;let t=Number.parseFloat(getComputedStyle(e).getPropertyValue(ie))||0,n=V(e),r=e.getBoundingClientRect(),i=r.bottom-(n.bottom-t),a=n.top+t-r.top;i>0?window.scrollBy({top:i}):a>0&&window.scrollBy({top:-a})}var Y=r();function X(e){return e.target===e.currentTarget}function Z(e){return o()?{popoverTarget:e,form:``}:{}}function Q({popoverRef:e,open:t,onOpen:n}){let r=u.useRef(!1),i=u.useRef(n);return i.current=n,d(()=>{let n=e.current;t&&n&&!n.matches(`:popover-open`)&&(r.current=!0,n.showPopover(),r.current=!1)},[t,e]),e=>{X(e)&&e.newState===`open`&&!r.current&&(e.preventDefault(),requestAnimationFrame(()=>(0,c.flushSync)(()=>i.current())))}}function $(e,t){let n=e.relatedTarget;return n instanceof Node&&!t.some(e=>e?.contains(n))}function oe({children:e,trigger:t,popoverClassName:n,placement:r,onOpenChange:i,isOpen:o,eager:s}){let c=`${u.useId()}-popover`,l=Z(c),[d]=u.useState(o!==void 0),[p,m]=u.useState(!1),h=d?!!o:p,g=u.useRef(null),_=u.useRef(null),v=e=>{d||m(e),i?.(e)},y=u.useRef(v);y.current=v;let b=u.useRef(!1);u.useEffect(()=>{let e=g.current;if(!e)return;let t=e.matches(`:popover-open`),n=!b.current;if(b.current=!0,t!==h){if(n&&t){y.current(!0);return}h||e.hidePopover()}},[h]);let x=Q({popoverRef:g,open:h,onOpen:()=>v(!0)});J(h,()=>_.current?.firstElementChild??null),z({isOpen:h,floatingRef:g,getAnchor:()=>_.current?.firstElementChild??null,placement:r});let S=e=>{if(!X(e))return;let t=e.newState===`open`;t!==h&&v(t),t&&g.current?.focus()},C=e=>{h&&$(e,[_.current,g.current])&&g.current?.hidePopover()};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{ref:_,className:f.triggerContainer,onBlur:C,children:u.cloneElement(t,{...l,"aria-haspopup":`dialog`})}),(0,Y.jsx)(`div`,{ref:g,id:c,popover:`auto`,className:a(f.content,n),role:`dialog`,tabIndex:-1,onBeforeToggle:x,onToggle:S,onBlur:C,children:h||s?e:null})]})}function se(e){let t=(0,l.c)(17),{children:n,isOpen:r,onOpenChange:i,triggerRef:a,"aria-label":o}=e,s=u.useRef(null),c,p;t[0]===r?(c=t[1],p=t[2]):(c=()=>{let e=s.current;e&&(r?e.matches(`:popover-open`)||e.showPopover():e.matches(`:popover-open`)&&e.hidePopover())},p=[r],t[0]=r,t[1]=c,t[2]=p),d(c,p);let m;t[3]===a?m=t[4]:(m=()=>a.current,t[3]=a,t[4]=m),J(r,m);let h;t[5]===a?h=t[6]:(h=()=>a.current,t[5]=a,t[6]=h);let g;t[7]!==r||t[8]!==h?(g={isOpen:r,floatingRef:s,getAnchor:h},t[7]=r,t[8]=h,t[9]=g):g=t[9],z(g);let _;t[10]!==r||t[11]!==i?(_=e=>{if(!X(e))return;let t=e.newState===`open`;t!==r&&i(t),t&&s.current?.focus()},t[10]=r,t[11]=i,t[12]=_):_=t[12];let v=_,y=r?n:null,b;return t[13]!==o||t[14]!==v||t[15]!==y?(b=(0,Y.jsx)(`div`,{ref:s,popover:`auto`,className:f.content,role:`dialog`,tabIndex:-1,"aria-label":o,onToggle:v,children:y}),t[13]=o,t[14]=v,t[15]=y,t[16]=b):b=t[16],b}export{Z as a,z as c,X as i,d as l,oe as n,Q as o,$ as r,J as s,se as t};

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.