UNPKG

balm-ui

Version:

A modular and customizable UI library based on Material Design and Vue 3

1 lines 37.7 kB
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define("vTooltip",[],e):"object"===typeof exports?exports.vTooltip=e():t.vTooltip=e()}("undefined"!==typeof self?self:this,(function(){return function(){"use strict";var t={d:function(e,i){for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e={};t.d(e,{default:function(){return It}});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},i(t,e)};function o(t,e){if("function"!==typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var n=function(){return n=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)};Object.create;function r(t){var e="function"===typeof Symbol&&Symbol.iterator,i=e&&t[e],o=0;if(i)return i.call(t);if(t&&"number"===typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var i="function"===typeof Symbol&&t[Symbol.iterator];if(!i)return t;var o,n,r=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)a.push(o.value)}catch(s){n={error:s}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}return a}function s(t,e,i){if(i||2===arguments.length)for(var o,n=0,r=e.length;n<r;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))}Object.create;"function"===typeof SuppressedError&&SuppressedError;var l,h=function(){function t(t){void 0===t&&(t={}),this.adapter=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}(),c=function(){function t(t,e){for(var i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];this.root=t,this.initialize.apply(this,s([],a(i))),this.foundation=void 0===e?this.getDefaultFoundation():e,this.foundation.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new h({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation.destroy()},t.prototype.listen=function(t,e,i){this.root.addEventListener(t,e,i)},t.prototype.unlisten=function(t,e,i){this.root.removeEventListener(t,e,i)},t.prototype.emit=function(t,e,i){var o;void 0===i&&(i=!1),"function"===typeof CustomEvent?o=new CustomEvent(t,{bubbles:i,detail:e}):(o=document.createEvent("CustomEvent")).initCustomEvent(t,i,!1,e),this.root.dispatchEvent(o)},t}();!function(t){t.RICH="mdc-tooltip--rich",t.SHOWN="mdc-tooltip--shown",t.SHOWING="mdc-tooltip--showing",t.SHOWING_TRANSITION="mdc-tooltip--showing-transition",t.HIDE="mdc-tooltip--hide",t.HIDE_TRANSITION="mdc-tooltip--hide-transition",t.MULTILINE_TOOLTIP="mdc-tooltip--multiline",t.SURFACE="mdc-tooltip__surface",t.SURFACE_ANIMATION="mdc-tooltip__surface-animation",t.TOOLTIP_CARET_TOP="mdc-tooltip__caret-surface-top",t.TOOLTIP_CARET_BOTTOM="mdc-tooltip__caret-surface-bottom"}(l||(l={}));var d,u,p,f=4,T=8,E=8,m=600,y=500,g=24,v=200,A=24,O=.8,w="aria-expanded",S="aria-haspopup",D="data-mdc-tooltip-persistent",C="data-mdc-tooltip-has-caret",x="MDCTooltip:hidden";!function(t){t[t.DETECTED=0]="DETECTED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END"}(d||(d={})),function(t){t[t.DETECTED=0]="DETECTED",t[t.ABOVE=1]="ABOVE",t[t.BELOW=2]="BELOW"}(u||(u={})),function(t){t[t.BOUNDED=0]="BOUNDED",t[t.UNBOUNDED=1]="UNBOUNDED"}(p||(p={}));var _,R,P,H="left",I="right",b="center",N="top",L="bottom";!function(t){t[t.DETECTED=0]="DETECTED",t[t.ABOVE_START=1]="ABOVE_START",t[t.ABOVE_CENTER=2]="ABOVE_CENTER",t[t.ABOVE_END=3]="ABOVE_END",t[t.TOP_SIDE_START=4]="TOP_SIDE_START",t[t.CENTER_SIDE_START=5]="CENTER_SIDE_START",t[t.BOTTOM_SIDE_START=6]="BOTTOM_SIDE_START",t[t.TOP_SIDE_END=7]="TOP_SIDE_END",t[t.CENTER_SIDE_END=8]="CENTER_SIDE_END",t[t.BOTTOM_SIDE_END=9]="BOTTOM_SIDE_END",t[t.BELOW_START=10]="BELOW_START",t[t.BELOW_CENTER=11]="BELOW_CENTER",t[t.BELOW_END=12]="BELOW_END"}(_||(_={})),function(t){t[t.ABOVE=1]="ABOVE",t[t.BELOW=2]="BELOW",t[t.SIDE_TOP=3]="SIDE_TOP",t[t.SIDE_CENTER=4]="SIDE_CENTER",t[t.SIDE_BOTTOM=5]="SIDE_BOTTOM"}(R||(R={})),function(t){t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t[t.SIDE_START=4]="SIDE_START",t[t.SIDE_END=5]="SIDE_END"}(P||(P={}));var B=function(){function t(){this.rafIDs=new Map}return t.prototype.request=function(t,e){var i=this;this.cancel(t);var o=requestAnimationFrame((function(o){i.rafIDs.delete(t),e(o)}));this.rafIDs.set(t,o)},t.prototype.cancel=function(t){var e=this.rafIDs.get(t);e&&(cancelAnimationFrame(e),this.rafIDs.delete(t))},t.prototype.cancelAll=function(){var t=this;this.rafIDs.forEach((function(e,i){t.cancel(i)}))},t.prototype.getQueue=function(){var t=[];return this.rafIDs.forEach((function(e,i){t.push(i)})),t},t}(),M={animation:{prefixed:"-webkit-animation",standard:"animation"},transform:{prefixed:"-webkit-transform",standard:"transform"},transition:{prefixed:"-webkit-transition",standard:"transition"}};function W(t){return Boolean(t.document)&&"function"===typeof t.document.createElement}function V(t,e){if(W(t)&&e in M){var i=t.document.createElement("div"),o=M[e],n=o.standard,r=o.prefixed;return n in i.style?n:r}return e}var k="Unknown",F="Backspace",z="Enter",j="Spacebar",U="PageUp",q="PageDown",G="End",Y="Home",K="ArrowLeft",X="ArrowUp",$="ArrowRight",Q="ArrowDown",J="Delete",Z="Escape",tt="Tab",et=new Set;et.add(F),et.add(z),et.add(j),et.add(U),et.add(q),et.add(G),et.add(Y),et.add(K),et.add(X),et.add($),et.add(Q),et.add(J),et.add(Z),et.add(tt);var it=8,ot=13,nt=32,rt=33,at=34,st=35,lt=36,ht=37,ct=38,dt=39,ut=40,pt=46,ft=27,Tt=9,Et=new Map;Et.set(it,F),Et.set(ot,z),Et.set(nt,j),Et.set(rt,U),Et.set(at,q),Et.set(st,G),Et.set(lt,Y),Et.set(ht,K),Et.set(ct,X),Et.set(dt,$),Et.set(ut,Q),Et.set(pt,J),Et.set(ft,Z),Et.set(Tt,tt);var mt=new Set;function yt(t){var e=t.key;if(et.has(e))return e;var i=Et.get(t.keyCode);return i||k}mt.add(U),mt.add(q),mt.add(G),mt.add(Y),mt.add(K),mt.add(X),mt.add($),mt.add(Q);var gt,vt=l.RICH,At=l.SHOWN,Ot=l.SHOWING,wt=l.SHOWING_TRANSITION,St=l.HIDE,Dt=l.HIDE_TRANSITION,Ct=l.MULTILINE_TOOLTIP;!function(t){t.POLL_ANCHOR="poll_anchor"}(gt||(gt={}));var xt="undefined"!==typeof window,_t=function(t){function e(i){var o=t.call(this,n(n({},e.defaultAdapter),i))||this;return o.tooltipShown=!1,o.anchorGap=f,o.xTooltipPos=d.DETECTED,o.yTooltipPos=u.DETECTED,o.tooltipPositionWithCaret=_.DETECTED,o.minViewportTooltipThreshold=E,o.hideDelayMs=m,o.showDelayMs=y,o.anchorRect=null,o.parentRect=null,o.frameId=null,o.hideTimeout=null,o.showTimeout=null,o.addAncestorScrollEventListeners=new Array,o.removeAncestorScrollEventListeners=new Array,o.animFrame=new B,o.anchorBlurHandler=function(t){o.handleAnchorBlur(t)},o.documentClickHandler=function(t){o.handleDocumentClick(t)},o.documentKeydownHandler=function(t){o.handleKeydown(t)},o.tooltipMouseEnterHandler=function(){o.handleTooltipMouseEnter()},o.tooltipMouseLeaveHandler=function(){o.handleTooltipMouseLeave()},o.richTooltipFocusOutHandler=function(t){o.handleRichTooltipFocusOut(t)},o.windowScrollHandler=function(){o.handleWindowScrollEvent()},o.windowResizeHandler=function(){o.handleWindowChangeEvent()},o}return o(e,t),Object.defineProperty(e,"defaultAdapter",{get:function(){return{getAttribute:function(){return null},setAttribute:function(){},removeAttribute:function(){},addClass:function(){},hasClass:function(){return!1},removeClass:function(){},getComputedStyleProperty:function(){return""},setStyleProperty:function(){},setSurfaceAnimationStyleProperty:function(){},getViewportWidth:function(){return 0},getViewportHeight:function(){return 0},getTooltipSize:function(){return{width:0,height:0}},getAnchorBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},getParentBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},getAnchorAttribute:function(){return null},setAnchorAttribute:function(){return null},isRTL:function(){return!1},anchorContainsElement:function(){return!1},tooltipContainsElement:function(){return!1},focusAnchorElement:function(){},registerEventHandler:function(){},deregisterEventHandler:function(){},registerAnchorEventHandler:function(){},deregisterAnchorEventHandler:function(){},registerDocumentEventHandler:function(){},deregisterDocumentEventHandler:function(){},registerWindowEventHandler:function(){},deregisterWindowEventHandler:function(){},notifyHidden:function(){},getTooltipCaretBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},setTooltipCaretStyle:function(){},clearTooltipCaretStyles:function(){},getActiveElement:function(){return null}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.richTooltip=this.adapter.hasClass(vt),this.persistentTooltip="true"===this.adapter.getAttribute(D),this.interactiveTooltip=!!this.adapter.getAnchorAttribute(w)&&"dialog"===this.adapter.getAnchorAttribute(S),this.hasCaret=this.richTooltip&&"true"===this.adapter.getAttribute(C)},e.prototype.isShown=function(){return this.tooltipShown},e.prototype.isRich=function(){return this.richTooltip},e.prototype.isPersistent=function(){return this.persistentTooltip},e.prototype.handleAnchorMouseEnter=function(){var t=this;this.tooltipShown?this.show():(this.clearHideTimeout(),this.showTimeout=setTimeout((function(){t.show()}),this.showDelayMs))},e.prototype.handleAnchorTouchstart=function(){var t=this;this.showTimeout=setTimeout((function(){t.show()}),this.showDelayMs),this.adapter.registerWindowEventHandler("contextmenu",this.preventContextMenuOnLongTouch)},e.prototype.preventContextMenuOnLongTouch=function(t){t.preventDefault()},e.prototype.handleAnchorTouchend=function(){this.clearShowTimeout(),this.isShown()||this.adapter.deregisterWindowEventHandler("contextmenu",this.preventContextMenuOnLongTouch)},e.prototype.handleAnchorFocus=function(t){var e=this,i=t.relatedTarget;i instanceof HTMLElement&&this.adapter.tooltipContainsElement(i)||(this.showTimeout=setTimeout((function(){e.show()}),this.showDelayMs))},e.prototype.handleAnchorMouseLeave=function(){var t=this;this.clearShowTimeout(),this.hideTimeout=setTimeout((function(){t.hide()}),this.hideDelayMs)},e.prototype.handleAnchorClick=function(){this.tooltipShown?this.hide():this.show()},e.prototype.handleDocumentClick=function(t){var e=t.target instanceof HTMLElement&&(this.adapter.anchorContainsElement(t.target)||this.adapter.tooltipContainsElement(t.target));this.richTooltip&&this.persistentTooltip&&e||this.hide()},e.prototype.handleKeydown=function(t){if(yt(t)===Z){var e=this.adapter.getActiveElement();e instanceof HTMLElement&&this.adapter.tooltipContainsElement(e)&&this.adapter.focusAnchorElement(),this.hide()}},e.prototype.handleAnchorBlur=function(t){if(this.richTooltip){if(t.relatedTarget instanceof HTMLElement&&this.adapter.tooltipContainsElement(t.relatedTarget))return;if(null===t.relatedTarget&&this.interactiveTooltip)return}this.hide()},e.prototype.handleTooltipMouseEnter=function(){this.show()},e.prototype.handleTooltipMouseLeave=function(){var t=this;this.clearShowTimeout(),this.hideTimeout=setTimeout((function(){t.hide()}),this.hideDelayMs)},e.prototype.handleRichTooltipFocusOut=function(t){t.relatedTarget instanceof HTMLElement&&(this.adapter.anchorContainsElement(t.relatedTarget)||this.adapter.tooltipContainsElement(t.relatedTarget))||null===t.relatedTarget&&this.interactiveTooltip||this.hide()},e.prototype.handleWindowScrollEvent=function(){this.persistentTooltip?this.handleWindowChangeEvent():this.hide()},e.prototype.handleWindowChangeEvent=function(){var t=this;this.animFrame.request(gt.POLL_ANCHOR,(function(){t.repositionTooltipOnAnchorMove()}))},e.prototype.show=function(){var t,e,i=this;if(this.clearHideTimeout(),this.clearShowTimeout(),!this.tooltipShown){this.tooltipShown=!0,this.adapter.removeAttribute("aria-hidden"),this.richTooltip&&(this.interactiveTooltip&&this.adapter.setAnchorAttribute("aria-expanded","true"),this.adapter.registerEventHandler("focusout",this.richTooltipFocusOutHandler)),this.persistentTooltip||(this.adapter.registerEventHandler("mouseenter",this.tooltipMouseEnterHandler),this.adapter.registerEventHandler("mouseleave",this.tooltipMouseLeaveHandler)),this.adapter.removeClass(St),this.adapter.addClass(Ot),this.isTooltipMultiline()&&!this.richTooltip&&this.adapter.addClass(Ct),this.anchorRect=this.adapter.getAnchorBoundingRect(),this.parentRect=this.adapter.getParentBoundingRect(),this.richTooltip?this.positionRichTooltip():this.positionPlainTooltip(),this.adapter.registerAnchorEventHandler("blur",this.anchorBlurHandler),this.adapter.registerDocumentEventHandler("click",this.documentClickHandler),this.adapter.registerDocumentEventHandler("keydown",this.documentKeydownHandler),this.adapter.registerWindowEventHandler("scroll",this.windowScrollHandler),this.adapter.registerWindowEventHandler("resize",this.windowResizeHandler);try{for(var o=r(this.addAncestorScrollEventListeners),n=o.next();!n.done;n=o.next()){(0,n.value)()}}catch(a){t={error:a}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}this.frameId=requestAnimationFrame((function(){i.clearAllAnimationClasses(),i.adapter.addClass(At),i.adapter.addClass(wt)}))}},e.prototype.hide=function(){var t,e;if(this.clearHideTimeout(),this.clearShowTimeout(),this.tooltipShown){this.frameId&&cancelAnimationFrame(this.frameId),this.tooltipShown=!1,this.adapter.setAttribute("aria-hidden","true"),this.adapter.deregisterEventHandler("focusout",this.richTooltipFocusOutHandler),this.richTooltip&&this.interactiveTooltip&&this.adapter.setAnchorAttribute("aria-expanded","false"),this.persistentTooltip||(this.adapter.deregisterEventHandler("mouseenter",this.tooltipMouseEnterHandler),this.adapter.deregisterEventHandler("mouseleave",this.tooltipMouseLeaveHandler)),this.clearAllAnimationClasses(),this.adapter.addClass(St),this.adapter.addClass(Dt),this.adapter.removeClass(At),this.adapter.deregisterAnchorEventHandler("blur",this.anchorBlurHandler),this.adapter.deregisterDocumentEventHandler("click",this.documentClickHandler),this.adapter.deregisterDocumentEventHandler("keydown",this.documentKeydownHandler),this.adapter.deregisterWindowEventHandler("scroll",this.windowScrollHandler),this.adapter.deregisterWindowEventHandler("resize",this.windowResizeHandler),this.adapter.deregisterWindowEventHandler("contextmenu",this.preventContextMenuOnLongTouch);try{for(var i=r(this.removeAncestorScrollEventListeners),o=i.next();!o.done;o=i.next()){(0,o.value)()}}catch(n){t={error:n}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}}},e.prototype.handleTransitionEnd=function(){var t=this.adapter.hasClass(St);this.adapter.removeClass(Ot),this.adapter.removeClass(wt),this.adapter.removeClass(St),this.adapter.removeClass(Dt),t&&null===this.showTimeout&&this.adapter.notifyHidden()},e.prototype.clearAllAnimationClasses=function(){this.adapter.removeClass(wt),this.adapter.removeClass(Dt)},e.prototype.setTooltipPosition=function(t){var e=t.xPos,i=t.yPos,o=t.withCaretPos;this.hasCaret&&o?this.tooltipPositionWithCaret=o:(e&&(this.xTooltipPos=e),i&&(this.yTooltipPos=i))},e.prototype.setAnchorBoundaryType=function(t){t===p.UNBOUNDED?this.anchorGap=T:this.anchorGap=f},e.prototype.setShowDelay=function(t){this.showDelayMs=t},e.prototype.setHideDelay=function(t){this.hideDelayMs=t},e.prototype.isTooltipMultiline=function(){var t=this.adapter.getTooltipSize();return t.height>g&&t.width>=v},e.prototype.positionPlainTooltip=function(){var t=this.calculateTooltipStyles(this.anchorRect),e=t.top,i=t.yTransformOrigin,o=t.left,n=t.xTransformOrigin,r=xt?V(window,"transform"):"transform";this.adapter.setSurfaceAnimationStyleProperty(r+"-origin",n+" "+i),this.adapter.setStyleProperty("top",e+"px"),this.adapter.setStyleProperty("left",o+"px")},e.prototype.positionRichTooltip=function(){var t,e,i,o,n=this.adapter.getComputedStyleProperty("width");this.adapter.setStyleProperty("width",n);var r=this.hasCaret?this.calculateTooltipWithCaretStyles(this.anchorRect):this.calculateTooltipStyles(this.anchorRect),a=r.top,s=r.yTransformOrigin,l=r.left,h=r.xTransformOrigin,c=xt?V(window,"transform"):"transform";this.adapter.setSurfaceAnimationStyleProperty(c+"-origin",h+" "+s);var d=l-(null!==(e=null===(t=this.parentRect)||void 0===t?void 0:t.left)&&void 0!==e?e:0),u=a-(null!==(o=null===(i=this.parentRect)||void 0===i?void 0:i.top)&&void 0!==o?o:0);this.adapter.setStyleProperty("top",u+"px"),this.adapter.setStyleProperty("left",d+"px")},e.prototype.calculateTooltipStyles=function(t){if(!t)return{top:0,left:0};var e=this.adapter.getTooltipSize(),i=this.calculateYTooltipDistance(t,e.height),o=this.calculateXTooltipDistance(t,e.width);return{top:i.distance,yTransformOrigin:i.yTransformOrigin,left:o.distance,xTransformOrigin:o.xTransformOrigin}},e.prototype.calculateXTooltipDistance=function(t,e){var i,o,n,r,a,s=!this.adapter.isRTL();this.richTooltip?(i=s?t.left-e:t.right,o=s?t.right:t.left-e,r=s?I:H,a=s?H:I):(i=s?t.left:t.right-e,o=s?t.right-e:t.left,n=t.left+(t.width-e)/2,r=s?H:I,a=s?I:H);var l=this.richTooltip?this.determineValidPositionOptions(i,o):this.determineValidPositionOptions(n,i,o);if(this.xTooltipPos===d.START&&l.has(i))return{distance:i,xTransformOrigin:r};if(this.xTooltipPos===d.END&&l.has(o))return{distance:o,xTransformOrigin:a};if(this.xTooltipPos===d.CENTER&&l.has(n))return{distance:n,xTransformOrigin:b};var h=(this.richTooltip?[{distance:o,xTransformOrigin:a},{distance:i,xTransformOrigin:r}]:[{distance:n,xTransformOrigin:b},{distance:i,xTransformOrigin:r},{distance:o,xTransformOrigin:a}]).find((function(t){var e=t.distance;return l.has(e)}));return h||(t.left<0?{distance:this.minViewportTooltipThreshold,xTransformOrigin:H}:{distance:this.adapter.getViewportWidth()-(e+this.minViewportTooltipThreshold),xTransformOrigin:I})},e.prototype.determineValidPositionOptions=function(){for(var t,e,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var n=new Set,a=new Set;try{for(var s=r(i),l=s.next();!l.done;l=s.next()){var h=l.value;this.positionHonorsViewportThreshold(h)?n.add(h):this.positionDoesntCollideWithViewport(h)&&a.add(h)}}catch(c){t={error:c}}finally{try{l&&!l.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n.size?n:a},e.prototype.positionHonorsViewportThreshold=function(t){var e=this.adapter.getViewportWidth();return t+this.adapter.getTooltipSize().width<=e-this.minViewportTooltipThreshold&&t>=this.minViewportTooltipThreshold},e.prototype.positionDoesntCollideWithViewport=function(t){var e=this.adapter.getViewportWidth();return t+this.adapter.getTooltipSize().width<=e&&t>=0},e.prototype.calculateYTooltipDistance=function(t,e){var i=t.bottom+this.anchorGap,o=t.top-(this.anchorGap+e),n=this.determineValidYPositionOptions(o,i);return this.yTooltipPos===u.ABOVE&&n.has(o)?{distance:o,yTransformOrigin:L}:this.yTooltipPos===u.BELOW&&n.has(i)||n.has(i)?{distance:i,yTransformOrigin:N}:n.has(o)?{distance:o,yTransformOrigin:L}:{distance:i,yTransformOrigin:N}},e.prototype.determineValidYPositionOptions=function(t,e){var i=new Set,o=new Set;return this.yPositionHonorsViewportThreshold(t)?i.add(t):this.yPositionDoesntCollideWithViewport(t)&&o.add(t),this.yPositionHonorsViewportThreshold(e)?i.add(e):this.yPositionDoesntCollideWithViewport(e)&&o.add(e),i.size?i:o},e.prototype.yPositionHonorsViewportThreshold=function(t){var e=this.adapter.getViewportHeight();return t+this.adapter.getTooltipSize().height+this.minViewportTooltipThreshold<=e&&t>=this.minViewportTooltipThreshold},e.prototype.yPositionDoesntCollideWithViewport=function(t){var e=this.adapter.getViewportHeight();return t+this.adapter.getTooltipSize().height<=e&&t>=0},e.prototype.calculateTooltipWithCaretStyles=function(t){this.adapter.clearTooltipCaretStyles();var e=this.adapter.getTooltipCaretBoundingRect();if(!t||!e)return{position:_.DETECTED,top:0,left:0};var i=e.width/O,o=e.height/O/2,n=this.adapter.getTooltipSize(),r=this.calculateYWithCaretDistanceOptions(t,n.height,{caretWidth:i,caretHeight:o}),a=this.calculateXWithCaretDistanceOptions(t,n.width,{caretWidth:i,caretHeight:o}),s=this.validateTooltipWithCaretDistances(r,a);s.size<1&&(s=this.generateBackupPositionOption(t,n,{caretWidth:i,caretHeight:o}));var l=this.determineTooltipWithCaretDistance(s),h=l.position,c=l.xDistance,d=l.yDistance,u=this.setCaretPositionStyles(h,{caretWidth:i,caretHeight:o});return{yTransformOrigin:u.yTransformOrigin,xTransformOrigin:u.xTransformOrigin,top:d,left:c}},e.prototype.calculateXWithCaretDistanceOptions=function(t,e,i){var o=i.caretWidth,n=i.caretHeight,r=!this.adapter.isRTL(),a=t.left+t.width/2,s=t.left-(e+this.anchorGap+n),l=t.right+this.anchorGap+n,h=r?s:l,c=r?l:s,d=a-(A+o/2),u=a-(e-A-o/2),p=r?d:u,f=r?u:d,T=a-e/2;return new Map([[P.START,p],[P.CENTER,T],[P.END,f],[P.SIDE_END,c],[P.SIDE_START,h]])},e.prototype.calculateYWithCaretDistanceOptions=function(t,e,i){var o=i.caretWidth,n=i.caretHeight,r=t.top+t.height/2,a=t.bottom+this.anchorGap+n,s=t.top-(this.anchorGap+e+n),l=r-(A+o/2),h=r-e/2,c=r-(e-A-o/2);return new Map([[R.ABOVE,s],[R.BELOW,a],[R.SIDE_TOP,l],[R.SIDE_CENTER,h],[R.SIDE_BOTTOM,c]])},e.prototype.repositionTooltipOnAnchorMove=function(){var t=this.adapter.getAnchorBoundingRect();t&&this.anchorRect&&(t.top===this.anchorRect.top&&t.left===this.anchorRect.left&&t.height===this.anchorRect.height&&t.width===this.anchorRect.width||(this.anchorRect=t,this.parentRect=this.adapter.getParentBoundingRect(),this.richTooltip?this.positionRichTooltip():this.positionPlainTooltip()))},e.prototype.validateTooltipWithCaretDistances=function(t,e){var i,o,n,a,s,l,h=new Map,c=new Map,d=new Map([[R.ABOVE,[P.START,P.CENTER,P.END]],[R.BELOW,[P.START,P.CENTER,P.END]],[R.SIDE_TOP,[P.SIDE_START,P.SIDE_END]],[R.SIDE_CENTER,[P.SIDE_START,P.SIDE_END]],[R.SIDE_BOTTOM,[P.SIDE_START,P.SIDE_END]]]);try{for(var u=r(d.keys()),p=u.next();!p.done;p=u.next()){var f=p.value,T=t.get(f);if(this.yPositionHonorsViewportThreshold(T))try{for(var E=(n=void 0,r(d.get(f))),m=E.next();!m.done;m=E.next()){var y=m.value,g=e.get(y);if(this.positionHonorsViewportThreshold(g)){var v=this.caretPositionOptionsMapping(y,f);h.set(v,{xDistance:g,yDistance:T})}}}catch(w){n={error:w}}finally{try{m&&!m.done&&(a=E.return)&&a.call(E)}finally{if(n)throw n.error}}if(this.yPositionDoesntCollideWithViewport(T))try{for(var A=(s=void 0,r(d.get(f))),O=A.next();!O.done;O=A.next()){y=O.value,g=e.get(y);if(this.positionDoesntCollideWithViewport(g)){v=this.caretPositionOptionsMapping(y,f);c.set(v,{xDistance:g,yDistance:T})}}}catch(S){s={error:S}}finally{try{O&&!O.done&&(l=A.return)&&l.call(A)}finally{if(s)throw s.error}}}}catch(D){i={error:D}}finally{try{p&&!p.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}return h.size?h:c},e.prototype.generateBackupPositionOption=function(t,e,i){var o,n,r,a,s=!this.adapter.isRTL();t.left<0?(o=this.minViewportTooltipThreshold+i.caretHeight,n=s?P.END:P.START):(o=this.adapter.getViewportWidth()-(e.width+this.minViewportTooltipThreshold+i.caretHeight),n=s?P.START:P.END);t.top<0?(r=this.minViewportTooltipThreshold+i.caretHeight,a=R.BELOW):(r=this.adapter.getViewportHeight()-(e.height+this.minViewportTooltipThreshold+i.caretHeight),a=R.ABOVE);var l=this.caretPositionOptionsMapping(n,a);return new Map([[l,{xDistance:o,yDistance:r}]])},e.prototype.determineTooltipWithCaretDistance=function(t){if(t.has(this.tooltipPositionWithCaret)){var e=t.get(this.tooltipPositionWithCaret);return{position:this.tooltipPositionWithCaret,xDistance:e.xDistance,yDistance:e.yDistance}}var i=[_.ABOVE_START,_.ABOVE_CENTER,_.ABOVE_END,_.TOP_SIDE_START,_.CENTER_SIDE_START,_.BOTTOM_SIDE_START,_.TOP_SIDE_END,_.CENTER_SIDE_END,_.BOTTOM_SIDE_END,_.BELOW_START,_.BELOW_CENTER,_.BELOW_END].find((function(e){return t.has(e)})),o=t.get(i);return{position:i,xDistance:o.xDistance,yDistance:o.yDistance}},e.prototype.caretPositionOptionsMapping=function(t,e){switch(e){case R.ABOVE:if(t===P.START)return _.ABOVE_START;if(t===P.CENTER)return _.ABOVE_CENTER;if(t===P.END)return _.ABOVE_END;break;case R.BELOW:if(t===P.START)return _.BELOW_START;if(t===P.CENTER)return _.BELOW_CENTER;if(t===P.END)return _.BELOW_END;break;case R.SIDE_TOP:if(t===P.SIDE_START)return _.TOP_SIDE_START;if(t===P.SIDE_END)return _.TOP_SIDE_END;break;case R.SIDE_CENTER:if(t===P.SIDE_START)return _.CENTER_SIDE_START;if(t===P.SIDE_END)return _.CENTER_SIDE_END;break;case R.SIDE_BOTTOM:if(t===P.SIDE_START)return _.BOTTOM_SIDE_START;if(t===P.SIDE_END)return _.BOTTOM_SIDE_END}throw new Error("MDCTooltipFoundation: Invalid caret position of "+t+", "+e)},e.prototype.setCaretPositionStyles=function(t,e){var i,o,n=this.calculateCaretPositionOnTooltip(t,e);if(!n)return{yTransformOrigin:0,xTransformOrigin:0};this.adapter.clearTooltipCaretStyles(),this.adapter.setTooltipCaretStyle(n.yAlignment,n.yAxisPx),this.adapter.setTooltipCaretStyle(n.xAlignment,n.xAxisPx);var a=n.skew*(Math.PI/180),s=Math.cos(a);this.adapter.setTooltipCaretStyle("transform","rotate("+n.rotation+"deg) skewY("+n.skew+"deg) scaleX("+s+")"),this.adapter.setTooltipCaretStyle("transform-origin",n.xAlignment+" "+n.yAlignment);try{for(var l=r(n.caretCorners),h=l.next();!h.done;h=l.next()){var c=h.value;this.adapter.setTooltipCaretStyle(c,"0")}}catch(d){i={error:d}}finally{try{h&&!h.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}return{yTransformOrigin:n.yTransformOrigin,xTransformOrigin:n.xTransformOrigin}},e.prototype.calculateCaretPositionOnTooltip=function(t,e){var i=!this.adapter.isRTL(),o=this.adapter.getComputedStyleProperty("width"),n=this.adapter.getComputedStyleProperty("height");if(o&&n&&e){var r="calc(("+o+" - "+e.caretWidth+"px) / 2)",a="calc(("+n+" - "+e.caretWidth+"px) / 2)",s="0",l=A+"px",h="calc("+o+" - "+l+")",c="calc("+n+" - "+l+")",d=35,u=Math.abs(55),p=["border-bottom-right-radius","border-top-left-radius"],f=["border-bottom-left-radius","border-top-right-radius"],T=20;switch(t){case _.BELOW_CENTER:return{yAlignment:N,xAlignment:H,yAxisPx:s,xAxisPx:r,rotation:-35,skew:-20,xTransformOrigin:r,yTransformOrigin:s,caretCorners:p};case _.BELOW_END:return{yAlignment:N,xAlignment:i?I:H,yAxisPx:s,xAxisPx:l,rotation:i?d:-35,skew:i?T:-20,xTransformOrigin:i?h:l,yTransformOrigin:s,caretCorners:i?f:p};case _.BELOW_START:return{yAlignment:N,xAlignment:i?H:I,yAxisPx:s,xAxisPx:l,rotation:i?-35:d,skew:i?-20:T,xTransformOrigin:i?l:h,yTransformOrigin:s,caretCorners:i?p:f};case _.TOP_SIDE_END:return{yAlignment:N,xAlignment:i?H:I,yAxisPx:l,xAxisPx:s,rotation:i?u:-1*u,skew:i?-20:T,xTransformOrigin:i?s:o,yTransformOrigin:l,caretCorners:i?p:f};case _.CENTER_SIDE_END:return{yAlignment:N,xAlignment:i?H:I,yAxisPx:a,xAxisPx:s,rotation:i?u:-1*u,skew:i?-20:T,xTransformOrigin:i?s:o,yTransformOrigin:a,caretCorners:i?p:f};case _.BOTTOM_SIDE_END:return{yAlignment:L,xAlignment:i?H:I,yAxisPx:l,xAxisPx:s,rotation:i?-1*u:u,skew:i?T:-20,xTransformOrigin:i?s:o,yTransformOrigin:c,caretCorners:i?f:p};case _.TOP_SIDE_START:return{yAlignment:N,xAlignment:i?I:H,yAxisPx:l,xAxisPx:s,rotation:i?-1*u:u,skew:i?T:-20,xTransformOrigin:i?o:s,yTransformOrigin:l,caretCorners:i?f:p};case _.CENTER_SIDE_START:return{yAlignment:N,xAlignment:i?I:H,yAxisPx:a,xAxisPx:s,rotation:i?-1*u:u,skew:i?T:-20,xTransformOrigin:i?o:s,yTransformOrigin:a,caretCorners:i?f:p};case _.BOTTOM_SIDE_START:return{yAlignment:L,xAlignment:i?I:H,yAxisPx:l,xAxisPx:s,rotation:i?u:-1*u,skew:i?-20:T,xTransformOrigin:i?o:s,yTransformOrigin:c,caretCorners:i?p:f};case _.ABOVE_CENTER:return{yAlignment:L,xAlignment:H,yAxisPx:s,xAxisPx:r,rotation:d,skew:T,xTransformOrigin:r,yTransformOrigin:n,caretCorners:f};case _.ABOVE_END:return{yAlignment:L,xAlignment:i?I:H,yAxisPx:s,xAxisPx:l,rotation:i?-35:d,skew:i?-20:T,xTransformOrigin:i?h:l,yTransformOrigin:n,caretCorners:i?p:f};default:case _.ABOVE_START:return{yAlignment:L,xAlignment:i?H:I,yAxisPx:s,xAxisPx:l,rotation:i?d:-35,skew:i?T:-20,xTransformOrigin:i?l:h,yTransformOrigin:n,caretCorners:i?f:p}}}},e.prototype.clearShowTimeout=function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null)},e.prototype.clearHideTimeout=function(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)},e.prototype.attachScrollHandler=function(t){var e=this;this.addAncestorScrollEventListeners.push((function(){t("scroll",e.windowScrollHandler)}))},e.prototype.removeScrollHandler=function(t){var e=this;this.removeAncestorScrollEventListeners.push((function(){t("scroll",e.windowScrollHandler)}))},e.prototype.destroy=function(){var t,e;this.frameId&&(cancelAnimationFrame(this.frameId),this.frameId=null),this.clearHideTimeout(),this.clearShowTimeout(),this.adapter.removeClass(At),this.adapter.removeClass(wt),this.adapter.removeClass(Ot),this.adapter.removeClass(St),this.adapter.removeClass(Dt),this.richTooltip&&this.adapter.deregisterEventHandler("focusout",this.richTooltipFocusOutHandler),this.persistentTooltip||(this.adapter.deregisterEventHandler("mouseenter",this.tooltipMouseEnterHandler),this.adapter.deregisterEventHandler("mouseleave",this.tooltipMouseLeaveHandler)),this.adapter.deregisterAnchorEventHandler("blur",this.anchorBlurHandler),this.adapter.deregisterDocumentEventHandler("click",this.documentClickHandler),this.adapter.deregisterDocumentEventHandler("keydown",this.documentKeydownHandler),this.adapter.deregisterWindowEventHandler("scroll",this.windowScrollHandler),this.adapter.deregisterWindowEventHandler("resize",this.windowResizeHandler);try{for(var i=r(this.removeAncestorScrollEventListeners),o=i.next();!o.done;o=i.next()){(0,o.value)()}}catch(n){t={error:n}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}this.animFrame.cancelAll()},e}(h),Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialize=function(){var t=this.root.getAttribute("id");if(!t)throw new Error("MDCTooltip: Tooltip component must have an id.");var e=document.querySelector('[data-tooltip-id="'+t+'"]')||document.querySelector('[aria-describedby="'+t+'"]');if(!e)throw new Error("MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id].");this.anchorElem=e},e.prototype.initialSyncWithDOM=function(){var t=this;this.isTooltipRich=this.foundation.isRich(),this.isTooltipPersistent=this.foundation.isPersistent(),this.handleMouseEnter=function(){t.foundation.handleAnchorMouseEnter()},this.handleFocus=function(e){t.foundation.handleAnchorFocus(e)},this.handleMouseLeave=function(){t.foundation.handleAnchorMouseLeave()},this.handleTransitionEnd=function(){t.foundation.handleTransitionEnd()},this.handleClick=function(){t.foundation.handleAnchorClick()},this.handleTouchstart=function(){t.foundation.handleAnchorTouchstart()},this.handleTouchend=function(){t.foundation.handleAnchorTouchend()},this.isTooltipRich&&this.isTooltipPersistent?this.anchorElem.addEventListener("click",this.handleClick):(this.anchorElem.addEventListener("mouseenter",this.handleMouseEnter),this.anchorElem.addEventListener("focus",this.handleFocus),this.anchorElem.addEventListener("mouseleave",this.handleMouseLeave),this.anchorElem.addEventListener("touchstart",this.handleTouchstart),this.anchorElem.addEventListener("touchend",this.handleTouchend)),this.listen("transitionend",this.handleTransitionEnd)},e.prototype.destroy=function(){this.anchorElem&&(this.isTooltipRich&&this.isTooltipPersistent?this.anchorElem.removeEventListener("click",this.handleClick):(this.anchorElem.removeEventListener("mouseenter",this.handleMouseEnter),this.anchorElem.removeEventListener("focus",this.handleFocus),this.anchorElem.removeEventListener("mouseleave",this.handleMouseLeave),this.anchorElem.removeEventListener("touchstart",this.handleTouchstart),this.anchorElem.removeEventListener("touchend",this.handleTouchend))),this.unlisten("transitionend",this.handleTransitionEnd),t.prototype.destroy.call(this)},e.prototype.setTooltipPosition=function(t){this.foundation.setTooltipPosition(t)},e.prototype.setAnchorBoundaryType=function(t){this.foundation.setAnchorBoundaryType(t)},e.prototype.setShowDelay=function(t){this.foundation.setShowDelay(t)},e.prototype.setHideDelay=function(t){this.foundation.setHideDelay(t)},e.prototype.hide=function(){this.foundation.hide()},e.prototype.isShown=function(){return this.foundation.isShown()},e.prototype.attachScrollHandler=function(t){this.foundation.attachScrollHandler(t)},e.prototype.removeScrollHandler=function(t){this.foundation.removeScrollHandler(t)},e.prototype.getDefaultFoundation=function(){var t=this;return new _t({getAttribute:function(e){return t.root.getAttribute(e)},setAttribute:function(e,i){t.root.setAttribute(e,i)},removeAttribute:function(e){t.root.removeAttribute(e)},addClass:function(e){t.root.classList.add(e)},hasClass:function(e){return t.root.classList.contains(e)},removeClass:function(e){t.root.classList.remove(e)},getComputedStyleProperty:function(e){return window.getComputedStyle(t.root).getPropertyValue(e)},setStyleProperty:function(e,i){t.root.style.setProperty(e,i)},setSurfaceAnimationStyleProperty:function(e,i){var o=t.root.querySelector("."+l.SURFACE_ANIMATION);null===o||void 0===o||o.style.setProperty(e,i)},getViewportWidth:function(){return window.innerWidth},getViewportHeight:function(){return window.innerHeight},getTooltipSize:function(){return{width:t.root.offsetWidth,height:t.root.offsetHeight}},getAnchorBoundingRect:function(){return t.anchorElem?t.anchorElem.getBoundingClientRect():null},getParentBoundingRect:function(){var e,i;return null!==(i=null===(e=t.root.parentElement)||void 0===e?void 0:e.getBoundingClientRect())&&void 0!==i?i:null},getAnchorAttribute:function(e){return t.anchorElem?t.anchorElem.getAttribute(e):null},setAnchorAttribute:function(e,i){var o;null===(o=t.anchorElem)||void 0===o||o.setAttribute(e,i)},isRTL:function(){return"rtl"===getComputedStyle(t.root).direction},anchorContainsElement:function(e){var i;return!!(null===(i=t.anchorElem)||void 0===i?void 0:i.contains(e))},tooltipContainsElement:function(e){return t.root.contains(e)},focusAnchorElement:function(){var e;null===(e=t.anchorElem)||void 0===e||e.focus()},registerEventHandler:function(e,i){t.root instanceof HTMLElement&&t.root.addEventListener(e,i)},deregisterEventHandler:function(e,i){t.root instanceof HTMLElement&&t.root.removeEventListener(e,i)},registerAnchorEventHandler:function(e,i){var o;null===(o=t.anchorElem)||void 0===o||o.addEventListener(e,i)},deregisterAnchorEventHandler:function(e,i){var o;null===(o=t.anchorElem)||void 0===o||o.removeEventListener(e,i)},registerDocumentEventHandler:function(t,e){document.body.addEventListener(t,e)},deregisterDocumentEventHandler:function(t,e){document.body.removeEventListener(t,e)},registerWindowEventHandler:function(t,e){window.addEventListener(t,e)},deregisterWindowEventHandler:function(t,e){window.removeEventListener(t,e)},notifyHidden:function(){t.emit(x,{})},getTooltipCaretBoundingRect:function(){var e=t.root.querySelector("."+l.TOOLTIP_CARET_TOP);return e?e.getBoundingClientRect():null},setTooltipCaretStyle:function(e,i){var o=t.root.querySelector("."+l.TOOLTIP_CARET_TOP),n=t.root.querySelector("."+l.TOOLTIP_CARET_BOTTOM);o&&n&&(o.style.setProperty(e,i),n.style.setProperty(e,i))},clearTooltipCaretStyles:function(){var e=t.root.querySelector("."+l.TOOLTIP_CARET_TOP),i=t.root.querySelector("."+l.TOOLTIP_CARET_BOTTOM);e&&i&&(e.removeAttribute("style"),i.removeAttribute("style"))},getActiveElement:function(){return document.activeElement}})},e}(c);let Pt={globalAnchor:{el:null,id:"mdc-tooltip-anchor",className:"mdc-tooltip-wrapper--rich"},attrs:{ariaId:"aria-describedby"}};const Ht=()=>{Pt.globalAnchor.el||(document.body.appendChild((()=>{const t=document.createElement("div");return t.id=Pt.globalAnchor.id,t.className=Pt.globalAnchor.className,t})()),Pt.globalAnchor.el=document.getElementById(Pt.globalAnchor.id))};var It={name:"tooltip",mounted(t,e){((t,e)=>{let{value:i}=e;Ht();const o=t.getAttribute(Pt.attrs.ariaId);if(o){let t=((t,e)=>`<div id="${t}" class="mdc-tooltip" role="tooltip" aria-hidden="true">\n <div class="mdc-tooltip__surface mdc-tooltip__surface-animation">${e}</div>\n </div>`)(o,i),e=document.createRange().createContextualFragment(t);Pt.globalAnchor.el.appendChild(e),new Rt(document.getElementById(o))}else console.warn("[v-tooltip]",`The '${Pt.attrs.ariaId}' attribute is required for plain tooltip`)})(t,e)},beforeUnmount(t){(t=>{const e=t.getAttribute(Pt.attrs.ariaId),i=document.getElementById(e);Pt.globalAnchor.el.removeChild(i)})(t)}};return e=e.default}()}));