ray-template/docs/assets/chunks/index.CRUCD9CF.js

2 lines
4.1 KiB
JavaScript

import{q as S,v as E,P as z,a8 as k,a9 as A,ag as F,G as h,h as R,ah as x,k as L}from"./framework.BNdm2jZV.js";function M(e,n){return k()?(A(e,n),!0):!1}const P=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const $=e=>e!=null,j=Object.prototype.toString,G=e=>j.call(e)==="[object Object]";function y(e){return Array.isArray(e)?e:[e]}function I(e){return F()}function C(e,n=!0,c){I()?E(e,c):n?e():z(e)}function q(e,n,c){return S(e,n,{...c,immediate:!0})}const W=P?window:void 0;function m(e){var n;const c=x(e);return(n=c==null?void 0:c.$el)!==null&&n!==void 0?n:c}function B(...e){const n=(s,i,o,r)=>(s.addEventListener(i,o,r),()=>s.removeEventListener(i,o,r)),c=R(()=>{const s=y(x(e[0])).filter(i=>i!=null);return s.every(i=>typeof i!="string")?s:void 0});return q(()=>{var s,i;return[(s=(i=c.value)===null||i===void 0?void 0:i.map(o=>m(o)))!==null&&s!==void 0?s:[W].filter(o=>o!=null),y(x(c.value?e[1]:e[0])),y(L(c.value?e[2]:e[1])),x(c.value?e[3]:e[2])]},([s,i,o,r],l,v)=>{if(!(s!=null&&s.length)||!(i!=null&&i.length)||!(o!=null&&o.length))return;const p=G(r)?{...r}:r,d=s.flatMap(t=>i.flatMap(u=>o.map(a=>n(t,u,a,p))));v(()=>{d.forEach(t=>t())})},{flush:"post"})}function D(){const e=h(!1),n=F();return n&&E(()=>{e.value=!0},n),e}function N(e){const n=D();return R(()=>(n.value,!!e()))}function H(e,n,c={}){const{window:s=W,...i}=c;let o;const r=N(()=>s&&"MutationObserver"in s),l=()=>{o&&(o.disconnect(),o=void 0)},v=R(()=>{const u=x(e),a=y(u).map(m).filter($);return new Set(a)}),p=S(v,u=>{l(),r.value&&u.size&&(o=new MutationObserver(n),u.forEach(a=>o.observe(a,i)))},{immediate:!0,flush:"post"}),d=()=>o==null?void 0:o.takeRecords(),t=()=>{p(),l()};return M(t),{isSupported:r,stop:t,takeRecords:d}}function T(e,n,c={}){const{window:s=W,...i}=c;let o;const r=N(()=>s&&"ResizeObserver"in s),l=()=>{o&&(o.disconnect(),o=void 0)},v=R(()=>{const t=x(e);return Array.isArray(t)?t.map(u=>m(u)):[m(t)]}),p=S(v,t=>{if(l(),r.value&&s){o=new ResizeObserver(n);for(const u of t)u instanceof Element&&o.observe(u,i)}},{immediate:!0,flush:"post"}),d=()=>{l(),p()};return M(d),{isSupported:r,stop:d}}function X(e,n={}){const{reset:c=!0,windowResize:s=!0,windowScroll:i=!0,immediate:o=!0,updateTiming:r="sync"}=n,l=h(0),v=h(0),p=h(0),d=h(0),t=h(0),u=h(0),a=h(0),f=h(0);function g(){const O=m(e);if(!O){c&&(l.value=0,v.value=0,p.value=0,d.value=0,t.value=0,u.value=0,a.value=0,f.value=0);return}const w=O.getBoundingClientRect();l.value=w.height,v.value=w.bottom,p.value=w.left,d.value=w.right,t.value=w.top,u.value=w.width,a.value=w.x,f.value=w.y}function b(){r==="sync"?g():r==="next-frame"&&requestAnimationFrame(()=>g())}return T(e,b),S(()=>m(e),O=>!O&&b()),H(e,b,{attributeFilter:["style","class"]}),i&&B("scroll",b,{capture:!0,passive:!0}),s&&B("resize",b,{passive:!0}),C(()=>{o&&b()}),{height:l,bottom:v,left:p,right:d,top:t,width:u,x:a,y:f,update:b}}function Y(e,n={width:0,height:0},c={}){const{window:s=W,box:i="content-box"}=c,o=R(()=>{var t;return(t=m(e))===null||t===void 0||(t=t.namespaceURI)===null||t===void 0?void 0:t.includes("svg")}),r=h(n.width),l=h(n.height),{stop:v}=T(e,([t])=>{const u=i==="border-box"?t.borderBoxSize:i==="content-box"?t.contentBoxSize:t.devicePixelContentBoxSize;if(s&&o.value){const a=m(e);if(a){const f=a.getBoundingClientRect();r.value=f.width,l.value=f.height}}else if(u){const a=y(u);r.value=a.reduce((f,{inlineSize:g})=>f+g,0),l.value=a.reduce((f,{blockSize:g})=>f+g,0)}else r.value=t.contentRect.width,l.value=t.contentRect.height},c);C(()=>{const t=m(e);if(t&&"offsetWidth"in t)if(i==="content-box"&&s){const u=s.getComputedStyle(t),a=Number.parseFloat(u.paddingLeft)+Number.parseFloat(u.paddingRight),f=Number.parseFloat(u.paddingTop)+Number.parseFloat(u.paddingBottom),g=Number.parseFloat(u.borderLeftWidth)+Number.parseFloat(u.borderRightWidth),b=Number.parseFloat(u.borderTopWidth)+Number.parseFloat(u.borderBottomWidth);r.value=t.offsetWidth-a-g,l.value=t.offsetHeight-f-b}else r.value=t.offsetWidth,l.value=t.offsetHeight;else t&&(r.value=n.width,l.value=n.height)});const p=S(()=>m(e),t=>{r.value=t?n.width:0,l.value=t?n.height:0});function d(){v(),p()}return{width:r,height:l,stop:d}}export{X as a,T as b,Y as c,B as u};