p-91b670e6.js 17 KB

123456
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import{c as t,a as n}from"./p-96bf42e5.js";import{d as e}from"./p-622f8ecb.js";function o(t){return t.split("-")[0]}function r(t){return t.split("-")[1]}function i(t){return["top","bottom"].includes(o(t))?"x":"y"}function a(t){return"y"===t?"height":"width"}function l(t,n,e){let{reference:l,floating:s}=t;const c=l.x+l.width/2-s.width/2,u=l.y+l.height/2-s.height/2,f=i(n),d=a(f),m=l[d]/2-s[d]/2,p="x"===f;let y;switch(o(n)){case"top":y={x:c,y:l.y-s.height};break;case"bottom":y={x:c,y:l.y+l.height};break;case"right":y={x:l.x+l.width,y:u};break;case"left":y={x:l.x-s.width,y:u};break;default:y={x:l.x,y:l.y}}switch(r(n)){case"start":y[f]-=m*(e&&p?-1:1);break;case"end":y[f]+=m*(e&&p?-1:1)}return y}function s(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function c(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function u(t,n){var e;void 0===n&&(n={});const{x:o,y:r,platform:i,rects:a,elements:l,strategy:u}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:m="floating",altBoundary:p=!1,padding:y=0}=n,g=s(y),x=l[p?"floating"===m?"reference":"floating":m],v=c(await i.getClippingRect({element:null==(e=await(null==i.isElement?void 0:i.isElement(x)))||e?x:x.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:d,strategy:u})),w=c(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===m?{...a.floating,x:o,y:r}:a.reference,offsetParent:await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),strategy:u}):a[m]);return{top:v.top-w.top+g.top,bottom:w.bottom-v.bottom+g.bottom,left:v.left-w.left+g.left,right:w.right-v.right+g.right}}const f=Math.min,d=Math.max;function m(t,n,e){return d(t,f(n,e))}const p={left:"right",right:"left",bottom:"top",top:"bottom"};function y(t){return t.replace(/left|right|bottom|top/g,(t=>p[t]))}function g(t,n,e){void 0===e&&(e=!1);const o=r(t),l=i(t),s=a(l);let c="x"===l?o===(e?"end":"start")?"right":"left":"start"===o?"bottom":"top";return n.reference[s]>n.floating[s]&&(c=y(c)),{main:c,cross:y(c)}}const x={start:"end",end:"start"};function v(t){return t.replace(/start|end/g,(t=>x[t]))}const w=["top","right","bottom","left"],h=w.reduce(((t,n)=>t.concat(n,n+"-start",n+"-end")),[]),b=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var e;const{placement:r,middlewareData:i,rects:a,initialPlacement:l,platform:s,elements:c}=n,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",flipAlignment:x=!0,...w}=t,h=o(r),b=[l,...m||(h!==l&&x?function(t){const n=y(t);return[v(t),n,v(n)]}(l):[y(l)])],A=await u(n,w),P=[];let R=(null==(e=i.flip)?void 0:e.overflows)||[];if(f&&P.push(A[h]),d){const{main:t,cross:n}=g(r,a,await(null==s.isRTL?void 0:s.isRTL(c.floating)));P.push(A[t],A[n])}if(R=[...R,{placement:r,overflows:P}],!P.every((t=>t<=0))){var k,D;const t=(null!=(k=null==(D=i.flip)?void 0:D.index)?k:0)+1,n=b[t];if(n)return{data:{index:t,overflows:R},reset:{placement:n}};let e="bottom";switch(p){case"bestFit":{var E;const t=null==(E=R.map((t=>[t,t.overflows.filter((t=>t>0)).reduce(((t,n)=>t+n),0)])).sort(((t,n)=>t[1]-n[1]))[0])?void 0:E[0].placement;t&&(e=t);break}case"initialPlacement":e=l}if(r!==e)return{reset:{placement:e}}}return{}}}};function A(t,n){return{top:t.top-n.height,right:t.right-n.width,bottom:t.bottom-n.height,left:t.left-n.width}}function P(t){return w.some((n=>t[n]>=0))}const R=function(t){let{strategy:n="referenceHidden",...e}=void 0===t?{}:t;return{name:"hide",async fn(t){const{rects:o}=t;switch(n){case"referenceHidden":{const n=A(await u(t,{...e,elementContext:"reference"}),o.reference);return{data:{referenceHiddenOffsets:n,referenceHidden:P(n)}}}case"escaped":{const n=A(await u(t,{...e,altBoundary:!0}),o.floating);return{data:{escapedOffsets:n,escaped:P(n)}}}default:return{}}}}};function k(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function D(t){if(null==t)return window;if(!k(t)){const n=t.ownerDocument;return n&&n.defaultView||window}return t}function E(t){return D(t).getComputedStyle(t)}function F(t){return k(t)?"":t?(t.nodeName||"").toLowerCase():""}function M(){const t=navigator.userAgentData;return null!=t&&t.brands?t.brands.map((t=>t.brand+"/"+t.version)).join(" "):navigator.userAgent}function O(t){return t instanceof D(t).HTMLElement}function $(t){return t instanceof D(t).Element}function T(t){return"undefined"!=typeof ShadowRoot&&(t instanceof D(t).ShadowRoot||t instanceof ShadowRoot)}function S(t){const{overflow:n,overflowX:e,overflowY:o,display:r}=E(t);return/auto|scroll|overlay|hidden/.test(n+o+e)&&!["inline","contents"].includes(r)}function j(t){return["table","td","th"].includes(F(t))}function C(t){const n=/firefox/i.test(M()),e=E(t);return"none"!==e.transform||"none"!==e.perspective||n&&"filter"===e.willChange||n&&!!e.filter&&"none"!==e.filter||["transform","perspective"].some((t=>e.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const n=e.contain;return null!=n&&n.includes(t)}))}function z(){return!/^((?!chrome|android).)*safari/i.test(M())}function B(t){return["html","body","#document"].includes(F(t))}const L=Math.min,H=Math.max,I=Math.round;function W(t,n,e){var o,r,i,a;void 0===n&&(n=!1),void 0===e&&(e=!1);const l=t.getBoundingClientRect();let s=1,c=1;n&&O(t)&&(s=t.offsetWidth>0&&I(l.width)/t.offsetWidth||1,c=t.offsetHeight>0&&I(l.height)/t.offsetHeight||1);const u=$(t)?D(t):window,f=!z()&&e,d=(l.left+(f&&null!=(o=null==(r=u.visualViewport)?void 0:r.offsetLeft)?o:0))/s,m=(l.top+(f&&null!=(i=null==(a=u.visualViewport)?void 0:a.offsetTop)?i:0))/c,p=l.width/s,y=l.height/c;return{width:p,height:y,top:m,right:d+p,bottom:m+y,left:d,x:d,y:m}}function q(t){return(n=t,(n instanceof D(n).Node?t.ownerDocument:t.document)||window.document).documentElement;var n}function N(t){return $(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function U(t){return W(q(t)).left+N(t).scrollLeft}function V(t,n,e){const o=O(n),r=q(n),i=W(t,o&&function(t){const n=W(t);return I(n.width)!==t.offsetWidth||I(n.height)!==t.offsetHeight}(n),"fixed"===e);let a={scrollLeft:0,scrollTop:0};const l={x:0,y:0};if(o||!o&&"fixed"!==e)if(("body"!==F(n)||S(r))&&(a=N(n)),O(n)){const t=W(n,!0);l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}else r&&(l.x=U(r));return{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function X(t){return"html"===F(t)?t:t.assignedSlot||t.parentNode||(T(t)?t.host:null)||q(t)}function Y(t){return O(t)&&"fixed"!==E(t).position?t.offsetParent:null}function G(t){const n=D(t);let e=Y(t);for(;e&&j(e)&&"static"===E(e).position;)e=Y(e);return e&&("html"===F(e)||"body"===F(e)&&"static"===E(e).position&&!C(e))?n:e||function(t){let n=X(t);for(T(n)&&(n=n.host);O(n)&&!B(n);){if(C(n))return n;{const t=n.parentNode;n=T(t)?t.host:t}}return null}(t)||n}function J(t){if(O(t))return{width:t.offsetWidth,height:t.offsetHeight};const n=W(t);return{width:n.width,height:n.height}}function K(t){const n=X(t);return B(n)?t.ownerDocument.body:O(n)&&S(n)?n:K(n)}function Q(t,n){var e;void 0===n&&(n=[]);const o=K(t),r=o===(null==(e=t.ownerDocument)?void 0:e.body),i=D(o),a=r?[i].concat(i.visualViewport||[],S(o)?o:[]):o,l=n.concat(a);return r?l:l.concat(Q(a))}function Z(t,n,e){return"viewport"===n?c(function(t,n){const e=D(t),o=q(t),r=e.visualViewport;let i=o.clientWidth,a=o.clientHeight,l=0,s=0;if(r){i=r.width,a=r.height;const t=z();(t||!t&&"fixed"===n)&&(l=r.offsetLeft,s=r.offsetTop)}return{width:i,height:a,x:l,y:s}}(t,e)):$(n)?function(t,n){const e=W(t,!1,"fixed"===n),o=e.top+t.clientTop,r=e.left+t.clientLeft;return{top:o,left:r,x:r,y:o,right:r+t.clientWidth,bottom:o+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}(n,e):c(function(t){var n;const e=q(t),o=N(t),r=null==(n=t.ownerDocument)?void 0:n.body,i=H(e.scrollWidth,e.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=H(e.scrollHeight,e.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let l=-o.scrollLeft+U(t);const s=-o.scrollTop;return"rtl"===E(r||e).direction&&(l+=H(e.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:l,y:s}}(q(t)))}function _(t){const n=Q(t),e=function(t,n){let e=t;for(;e&&!B(e)&&!n.includes(e)&&(!$(e)||!["absolute","fixed"].includes(E(e).position));){const t=X(e);e=T(t)?t.host:t}return e}(t,n);let o=null;if(e&&O(e)){const t=G(e);S(e)?o=e:O(t)&&(o=t)}return $(o)?n.filter((t=>o&&$(t)&&function(t,n){const e=null==n.getRootNode?void 0:n.getRootNode();if(t.contains(n))return!0;if(e&&T(e)){let e=n;do{if(e&&t===e)return!0;e=e.parentNode||e.host}while(e)}return!1}(t,o)&&"body"!==F(t))):[]}const tt={getClippingRect:function(t){let{element:n,boundary:e,rootBoundary:o,strategy:r}=t;const i=[..."clippingAncestors"===e?_(n):[].concat(e),o],a=i.reduce(((t,e)=>{const o=Z(n,e,r);return t.top=H(o.top,t.top),t.right=L(o.right,t.right),t.bottom=L(o.bottom,t.bottom),t.left=H(o.left,t.left),t}),Z(n,i[0],r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:n,offsetParent:e,strategy:o}=t;const r=O(e),i=q(e);if(e===i)return n;let a={scrollLeft:0,scrollTop:0};const l={x:0,y:0};if((r||!r&&"fixed"!==o)&&(("body"!==F(e)||S(i))&&(a=N(e)),O(e))){const t=W(e,!0);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}return{...n,x:n.x-a.scrollLeft+l.x,y:n.y-a.scrollTop+l.y}},isElement:$,getDimensions:J,getOffsetParent:G,getDocumentElement:q,getElementRects:t=>{let{reference:n,floating:e,strategy:o}=t;return{reference:V(n,G(e),o),floating:{...J(e),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===E(t).direction};const nt={floatingUINonChromiumPositioningFix:!0,...globalThis.calciteComponentsConfig},et=async function(){if(nt.floatingUINonChromiumPositioningFix&&/firefox|safari/i.test(function(){const t=navigator.userAgentData;return(null==t?void 0:t.brands)?t.brands.map((t=>`${t.brand}/${t.version}`)).join(" "):navigator.userAgent}())){const{getClippingRect:t,getElementRects:n,getOffsetParent:e}=await import("./p-02206586.js");tt.getClippingRect=t,tt.getOffsetParent=e,tt.getElementRects=n}}(),ot=["top","bottom","right","left","top-start","top-end","bottom-start","bottom-end","right-start","right-end","left-start","left-end"],rt="bottom-start",it={animation:"calcite-floating-ui-anim",animationActive:"calcite-floating-ui-anim--active"};function at({placement:t,disableFlip:n,flipPlacements:e,offsetDistance:l,offsetSkidding:c,arrowEl:f,type:d}){const p=[(void 0===y&&(y={}),{name:"shift",options:y,async fn(t){const{x:n,y:e,placement:r}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:s={fn:t=>{let{x:n,y:e}=t;return{x:n,y:e}}},...c}=y,f={x:n,y:e},d=await u(t,c),p=i(o(r)),g="x"===p?"y":"x";let x=f[p],v=f[g];a&&(x=m(x+d["y"===p?"top":"left"],x,x-d["y"===p?"bottom":"right"])),l&&(v=m(v+d["y"===g?"top":"left"],v,v-d["y"===g?"bottom":"right"]));const w=s.fn({...t,[p]:x,[g]:v});return{...w,data:{x:w.x-n,y:w.y-e}}}}),R()];var y,x;if("menu"===d)return[...p,b({fallbackPlacements:e||["top-start","top","top-end","bottom-start","bottom","bottom-end"]})];if("popover"===d||"tooltip"===d){const d=[...p,(x={mainAxis:"number"==typeof l?l:0,crossAxis:"number"==typeof c?c:0},void 0===x&&(x=0),{name:"offset",options:x,async fn(t){const{x:n,y:e}=t,a=await async function(t,n){const{placement:e,platform:a,elements:l}=t,s=await(null==a.isRTL?void 0:a.isRTL(l.floating)),c=o(e),u=r(e),f="x"===i(e),d=["left","top"].includes(c)?-1:1,m=s&&f?-1:1,p="function"==typeof n?n(t):n;let{mainAxis:y,crossAxis:g,alignmentAxis:x}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return u&&"number"==typeof x&&(g="end"===u?-1*x:x),f?{x:g*m,y:y*d}:{x:y*d,y:g*m}}(t,x);return{x:n+a.x,y:e+a.y,data:a}}})];return"auto"===t||"auto-start"===t||"auto-end"===t?d.push(function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(n){var e,i,a,l,s;const{x:c,y:f,rects:d,middlewareData:m,placement:p,platform:y,elements:x}=n,{alignment:w=null,allowedPlacements:b=h,autoAlignment:A=!0,...P}=t,R=function(t,n,e){return(t?[...e.filter((n=>r(n)===t)),...e.filter((n=>r(n)!==t))]:e.filter((t=>o(t)===t))).filter((e=>!t||r(e)===t||!!n&&v(e)!==e))}(w,A,b),k=await u(n,P),D=null!=(e=null==(i=m.autoPlacement)?void 0:i.index)?e:0,E=R[D];if(null==E)return{};const{main:F,cross:M}=g(E,d,await(null==y.isRTL?void 0:y.isRTL(x.floating)));if(p!==E)return{x:c,y:f,reset:{placement:R[0]}};const O=[k[o(E)],k[F],k[M]],$=[...null!=(a=null==(l=m.autoPlacement)?void 0:l.overflows)?a:[],{placement:E,overflows:O}],T=R[D+1];if(T)return{data:{index:D+1,overflows:$},reset:{placement:T}};const S=$.slice().sort(((t,n)=>t.overflows[0]-n.overflows[0])),j=null==(s=S.find((t=>{let{overflows:n}=t;return n.every((t=>t<=0))})))?void 0:s.placement,C=null!=j?j:S[0].placement;return C!==p?{data:{index:D+1,overflows:$},reset:{placement:C}}:{}}}}({alignment:"auto-start"===t?"start":"auto-end"===t?"end":null})):n||d.push(b(e?{fallbackPlacements:e}:{})),f&&d.push((t=>({name:"arrow",options:t,async fn(n){const{element:e,padding:o=0}=null!=t?t:{},{x:l,y:c,placement:u,rects:f,platform:d}=n;if(null==e)return{};const p=s(o),y={x:l,y:c},g=i(u),x=r(u),v=a(g),w=await d.getDimensions(e),h="y"===g?"top":"left",b="y"===g?"bottom":"right",A=f.reference[v]+f.reference[g]-y[g]-f.floating[v],P=y[g]-f.reference[g],R=await(null==d.getOffsetParent?void 0:d.getOffsetParent(e));let k=R?"y"===g?R.clientHeight||0:R.clientWidth||0:0;0===k&&(k=f.floating[v]);const D=p[h],E=k-w[v]-p[b],F=k/2-w[v]/2+(A/2-P/2),M=m(D,F,E);return{[g]:y[g]-(("start"===x?p[h]:p[b])>0&&F!==M&&f.reference[v]<=f.floating[v]?F<D?D-F:E-F:0),data:{[g]:M,centerOffset:F-M}}}}))({element:f})),d}return[]}function lt(t,n){const e=t.filter((t=>ot.includes(t)));return e.length!==t.length&&console.warn(`${n.tagName}: Invalid value found in: flipPlacements. Try any of these: ${ot.map((t=>`"${t}"`)).join(", ").trim()}`,{el:n}),e}function st(t,e){const o=["left","right"];return"rtl"===n(t)&&o.reverse(),e.replace(/-leading/gi,"-start").replace(/-trailing/gi,"-end").replace(/leading/gi,o[0]).replace(/trailing/gi,o[1])}async function ct(t,n,e=!1){if(t.open)return e?ut(n):ft(n)}const ut=e(ft,100,{leading:!0,maxWait:100});async function ft({referenceEl:t,floatingEl:n,overlayPositioning:e="absolute",placement:o,disableFlip:r,flipPlacements:i,offsetDistance:a,offsetSkidding:s,includeArrow:c=!1,arrowEl:u,type:f}){var d;if(!t||!n||c&&!u)return null;await et;const{x:m,y:p,placement:y,strategy:g,middlewareData:x}=await(v=t,w=n,h={strategy:e,placement:"auto"===o||"auto-start"===o||"auto-end"===o?void 0:st(n,o),middleware:at({placement:o,disableFlip:r,flipPlacements:i,offsetDistance:a,offsetSkidding:s,arrowEl:u,type:f})},(async(t,n,e)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:a}=e,s=await(null==a.isRTL?void 0:a.isRTL(n));let c=await a.getElementRects({reference:t,floating:n,strategy:r}),{x:u,y:f}=l(c,o,s),d=o,m={},p=0;for(let e=0;e<i.length;e++){const{name:y,fn:g}=i[e],{x,y:v,data:w,reset:h}=await g({x:u,y:f,initialPlacement:o,placement:d,strategy:r,middlewareData:m,rects:c,platform:a,elements:{reference:t,floating:n}});u=null!=x?x:u,f=null!=v?v:f,m={...m,[y]:{...m[y],...w}},h&&p<=50&&(p++,"object"==typeof h&&(h.placement&&(d=h.placement),h.rects&&(c=!0===h.rects?await a.getElementRects({reference:t,floating:n,strategy:r}):h.rects),({x:u,y:f}=l(c,d,s))),e=-1)}return{x:u,y:f,placement:d,strategy:r,middlewareData:m}})(v,w,{platform:tt,...h}));var v,w,h;if(null==x?void 0:x.arrow){const{x:t,y:n}=x.arrow;Object.assign(u.style,{left:null!=t?`${t}px`:"",top:null!=n?`${n}px`:""})}const b=(null===(d=null==x?void 0:x.hide)||void 0===d?void 0:d.referenceHidden)?"hidden":null,A=b?"none":null;n.setAttribute("data-placement",y);const P=`translate(${Math.round(m)}px,${Math.round(p)}px)`;Object.assign(n.style,{visibility:b,pointerEvents:A,position:g,top:"0",left:"0",transform:P})}const dt=new WeakMap;function mt(t,n,e){if(!e||!n)return;pt(t,n,e);const o=t.overlayPositioning;e.style.position=o,"absolute"===o&&wt(e),dt.set(t,function(t,n,e,o){void 0===o&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:a=!0,animationFrame:l=!1}=o,s=r&&!l,c=s||i?[...$(t)?Q(t):[],...Q(n)]:[];c.forEach((t=>{s&&t.addEventListener("scroll",e,{passive:!0}),i&&t.addEventListener("resize",e)}));let u,f=null;if(a){let o=!0;f=new ResizeObserver((()=>{o||e(),o=!1})),$(t)&&!l&&f.observe(t),f.observe(n)}let d=l?W(t):null;return l&&function n(){const o=W(t);!d||o.x===d.x&&o.y===d.y&&o.width===d.width&&o.height===d.height||e(),d=o,u=requestAnimationFrame(n)}(),e(),()=>{var t;c.forEach((t=>{s&&t.removeEventListener("scroll",e),i&&t.removeEventListener("resize",e)})),null==(t=f)||t.disconnect(),f=null,l&&cancelAnimationFrame(u)}}(n,e,(()=>t.reposition())))}function pt(t,n,e){if(!e||!n)return;xt(e).removeEventListener("transitionend",vt);const o=dt.get(t);o&&o(),dt.delete(t)}const yt=Math.ceil(Math.hypot(4,4));function gt(t){t&&"absolute"===t.style.position&&xt(t).addEventListener("transitionend",vt)}function xt(t){return t.shadowRoot||t}function vt(n){const e=n.target;if("opacity"===n.propertyName&&e.classList.contains(it.animation)){const n=function(n){return t(n,"[data-placement]")}(e);wt(n),xt(n).removeEventListener("transitionend",vt)}}function wt(t){t.style.transform="",t.style.top="-99999px",t.style.left="-99999px"}export{it as F,pt as a,yt as b,mt as c,rt as d,c as e,lt as f,ct as r,gt as u}