balm-ui
Version:
A modular and customizable UI library based on Material Design and Vue 3
1 lines • 31.1 kB
JavaScript
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define("UiSwitch",["vue"],e):"object"===typeof exports?exports.UiSwitch=e(require("vue")):t.UiSwitch=e(t.Vue)}("undefined"!==typeof self?self:this,(function(t){return function(){"use strict";var e={744:function(t){var e=function(t){return function(t){return!!t&&"object"===typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===n}(t)}(t)};var n="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(t,e){return!1!==e.clone&&e.isMergeableObject(t)?c((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function i(t,e,n){return t.concat(e).map((function(t){return r(t,n)}))}function a(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return Object.propertyIsEnumerable.call(t,e)})):[]}(t))}function o(t,e){try{return e in t}catch(n){return!1}}function s(t,e,n){var i={};return n.isMergeableObject(t)&&a(t).forEach((function(e){i[e]=r(t[e],n)})),a(e).forEach((function(a){(function(t,e){return o(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,a)||(o(t,a)&&n.isMergeableObject(e[a])?i[a]=function(t,e){if(!e.customMerge)return c;var n=e.customMerge(t);return"function"===typeof n?n:c}(a,n)(t[a],e[a],n):i[a]=r(e[a],n))})),i}function c(t,n,a){(a=a||{}).arrayMerge=a.arrayMerge||i,a.isMergeableObject=a.isMergeableObject||e,a.cloneUnlessOtherwiseSpecified=r;var o=Array.isArray(n);return o===Array.isArray(t)?o?a.arrayMerge(t,n,a):s(t,n,a):r(n,a)}c.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,n){return c(t,n,e)}),{})};var u=c;t.exports=u},154:function(e){e.exports=t}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var a=n[t]={exports:{}};return e[t](a,a.exports,r),a.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var i={};r.d(i,{default:function(){return K}});var a=r(744),o=r.n(a);const s=/(?:^\[object\s(.*?)\]$)/;var c=t=>Object.prototype.toString.call(t).replace(s,"$1").toLowerCase();const u=t=>{let{componentProps:e,propName:n,props:r}=t,i=r[n];if("object"===c(i)){const t=e[n].default;e[n].default=()=>o()(t,i)}else Array.isArray(i)?e[n].default=()=>i:e[n].default=i},d=t=>{let{componentMixins:e,propName:n,props:r}=t;if(e.length){let t=e.length;for(;t--;)if(e[t].props&&void 0!==e[t].props[n]){u({componentProps:e[t].props,propName:n,props:r});break}}};var l=(t,e)=>{for(const n of Object.keys(e))t.props?void 0===t.props[n]?d({componentMixins:t.mixins,propName:n,props:e}):u({componentProps:t.props,propName:n,props:e}):d({componentMixins:t.mixins,propName:n,props:e})};var p=t=>{const e={install(e){l(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),e.component(t.name,t)}};return e},f=r(154),h=function(t,e){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},h(t,e)};function v(t,e){if("function"!==typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var y=function(){return y=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},y.apply(this,arguments)};Object.create;function m(t){var e="function"===typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"===typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(t,e){var n="function"===typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,a=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(s){i={error:s}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}function g(t,e,n){if(n||2===arguments.length)for(var r,i=0,a=e.length;i<a;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}Object.create;"function"===typeof SuppressedError&&SuppressedError;var C=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}(),E=function(){function t(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];this.root=t,this.initialize.apply(this,g([],b(n))),this.foundation=void 0===e?this.getDefaultFoundation():e,this.foundation.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new C({}))},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,n){this.root.addEventListener(t,e,n)},t.prototype.unlisten=function(t,e,n){this.root.removeEventListener(t,e,n)},t.prototype.emit=function(t,e,n){var r;void 0===n&&(n=!1),"function"===typeof CustomEvent?r=new CustomEvent(t,{bubbles:n,detail:e}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,n,!1,e),this.root.dispatchEvent(r)},t}();function A(t){return void 0===t&&(t=window),!!function(t){void 0===t&&(t=window);var e=!1;try{var n={get passive(){return e=!0,!1}},r=function(){};t.document.addEventListener("test",r,n),t.document.removeEventListener("test",r,n)}catch(i){e=!1}return e}(t)&&{passive:!0}}function S(t,e){return(t.matches||t.webkitMatchesSelector||t.msMatchesSelector).call(t,e)}var w,O={BG_FOCUSED:"mdc-ripple-upgraded--background-focused",FG_ACTIVATION:"mdc-ripple-upgraded--foreground-activation",FG_DEACTIVATION:"mdc-ripple-upgraded--foreground-deactivation",ROOT:"mdc-ripple-upgraded",UNBOUNDED:"mdc-ripple-upgraded--unbounded"},T={VAR_FG_SCALE:"--mdc-ripple-fg-scale",VAR_FG_SIZE:"--mdc-ripple-fg-size",VAR_FG_TRANSLATE_END:"--mdc-ripple-fg-translate-end",VAR_FG_TRANSLATE_START:"--mdc-ripple-fg-translate-start",VAR_LEFT:"--mdc-ripple-left",VAR_TOP:"--mdc-ripple-top"},D={DEACTIVATION_TIMEOUT_MS:225,FG_DEACTIVATION_MS:150,INITIAL_ORIGIN_SCALE:.6,PADDING:10,TAP_DELAY_MS:300};var _,I,R=["touchstart","pointerdown","mousedown","keydown"],P=["touchend","pointerup","mouseup","contextmenu"],L=[],H=function(t){function e(n){var r=t.call(this,y(y({},e.defaultAdapter),n))||this;return r.activationAnimationHasEnded=!1,r.activationTimer=0,r.fgDeactivationRemovalTimer=0,r.fgScale="0",r.frame={width:0,height:0},r.initialSize=0,r.layoutFrame=0,r.maxRadius=0,r.unboundedCoords={left:0,top:0},r.activationState=r.defaultActivationState(),r.activationTimerCallback=function(){r.activationAnimationHasEnded=!0,r.runDeactivationUXLogicIfReady()},r.activateHandler=function(t){r.activateImpl(t)},r.deactivateHandler=function(){r.deactivateImpl()},r.focusHandler=function(){r.handleFocus()},r.blurHandler=function(){r.handleBlur()},r.resizeHandler=function(){r.layout()},r}return v(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return O},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return T},enumerable:!1,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return D},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},browserSupportsCssVars:function(){return!0},computeBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},containsEventTarget:function(){return!0},deregisterDocumentInteractionHandler:function(){},deregisterInteractionHandler:function(){},deregisterResizeHandler:function(){},getWindowPageOffset:function(){return{x:0,y:0}},isSurfaceActive:function(){return!0},isSurfaceDisabled:function(){return!0},isUnbounded:function(){return!0},registerDocumentInteractionHandler:function(){},registerInteractionHandler:function(){},registerResizeHandler:function(){},removeClass:function(){},updateCssVariable:function(){}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){var t=this,n=this.supportsPressRipple();if(this.registerRootHandlers(n),n){var r=e.cssClasses,i=r.ROOT,a=r.UNBOUNDED;requestAnimationFrame((function(){t.adapter.addClass(i),t.adapter.isUnbounded()&&(t.adapter.addClass(a),t.layoutInternal())}))}},e.prototype.destroy=function(){var t=this;if(this.supportsPressRipple()){this.activationTimer&&(clearTimeout(this.activationTimer),this.activationTimer=0,this.adapter.removeClass(e.cssClasses.FG_ACTIVATION)),this.fgDeactivationRemovalTimer&&(clearTimeout(this.fgDeactivationRemovalTimer),this.fgDeactivationRemovalTimer=0,this.adapter.removeClass(e.cssClasses.FG_DEACTIVATION));var n=e.cssClasses,r=n.ROOT,i=n.UNBOUNDED;requestAnimationFrame((function(){t.adapter.removeClass(r),t.adapter.removeClass(i),t.removeCssVars()}))}this.deregisterRootHandlers(),this.deregisterDeactivationHandlers()},e.prototype.activate=function(t){this.activateImpl(t)},e.prototype.deactivate=function(){this.deactivateImpl()},e.prototype.layout=function(){var t=this;this.layoutFrame&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame((function(){t.layoutInternal(),t.layoutFrame=0}))},e.prototype.setUnbounded=function(t){var n=e.cssClasses.UNBOUNDED;t?this.adapter.addClass(n):this.adapter.removeClass(n)},e.prototype.handleFocus=function(){var t=this;requestAnimationFrame((function(){return t.adapter.addClass(e.cssClasses.BG_FOCUSED)}))},e.prototype.handleBlur=function(){var t=this;requestAnimationFrame((function(){return t.adapter.removeClass(e.cssClasses.BG_FOCUSED)}))},e.prototype.supportsPressRipple=function(){return this.adapter.browserSupportsCssVars()},e.prototype.defaultActivationState=function(){return{activationEvent:void 0,hasDeactivationUXRun:!1,isActivated:!1,isProgrammatic:!1,wasActivatedByPointer:!1,wasElementMadeActive:!1}},e.prototype.registerRootHandlers=function(t){var e,n;if(t){try{for(var r=m(R),i=r.next();!i.done;i=r.next()){var a=i.value;this.adapter.registerInteractionHandler(a,this.activateHandler)}}catch(o){e={error:o}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.adapter.isUnbounded()&&this.adapter.registerResizeHandler(this.resizeHandler)}this.adapter.registerInteractionHandler("focus",this.focusHandler),this.adapter.registerInteractionHandler("blur",this.blurHandler)},e.prototype.registerDeactivationHandlers=function(t){var e,n;if("keydown"===t.type)this.adapter.registerInteractionHandler("keyup",this.deactivateHandler);else try{for(var r=m(P),i=r.next();!i.done;i=r.next()){var a=i.value;this.adapter.registerDocumentInteractionHandler(a,this.deactivateHandler)}}catch(o){e={error:o}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},e.prototype.deregisterRootHandlers=function(){var t,e;try{for(var n=m(R),r=n.next();!r.done;r=n.next()){var i=r.value;this.adapter.deregisterInteractionHandler(i,this.activateHandler)}}catch(a){t={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this.adapter.deregisterInteractionHandler("focus",this.focusHandler),this.adapter.deregisterInteractionHandler("blur",this.blurHandler),this.adapter.isUnbounded()&&this.adapter.deregisterResizeHandler(this.resizeHandler)},e.prototype.deregisterDeactivationHandlers=function(){var t,e;this.adapter.deregisterInteractionHandler("keyup",this.deactivateHandler);try{for(var n=m(P),r=n.next();!r.done;r=n.next()){var i=r.value;this.adapter.deregisterDocumentInteractionHandler(i,this.deactivateHandler)}}catch(a){t={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},e.prototype.removeCssVars=function(){var t=this,n=e.strings;Object.keys(n).forEach((function(e){0===e.indexOf("VAR_")&&t.adapter.updateCssVariable(n[e],null)}))},e.prototype.activateImpl=function(t){var e=this;if(!this.adapter.isSurfaceDisabled()){var n=this.activationState;if(!n.isActivated){var r=this.previousActivationEvent;if(!(r&&void 0!==t&&r.type!==t.type))n.isActivated=!0,n.isProgrammatic=void 0===t,n.activationEvent=t,n.wasActivatedByPointer=!n.isProgrammatic&&(void 0!==t&&("mousedown"===t.type||"touchstart"===t.type||"pointerdown"===t.type)),void 0!==t&&L.length>0&&L.some((function(t){return e.adapter.containsEventTarget(t)}))?this.resetActivationState():(void 0!==t&&(L.push(t.target),this.registerDeactivationHandlers(t)),n.wasElementMadeActive=this.checkElementMadeActive(t),n.wasElementMadeActive&&this.animateActivation(),requestAnimationFrame((function(){L=[],n.wasElementMadeActive||void 0===t||" "!==t.key&&32!==t.keyCode||(n.wasElementMadeActive=e.checkElementMadeActive(t),n.wasElementMadeActive&&e.animateActivation()),n.wasElementMadeActive||(e.activationState=e.defaultActivationState())})))}}},e.prototype.checkElementMadeActive=function(t){return void 0===t||"keydown"!==t.type||this.adapter.isSurfaceActive()},e.prototype.animateActivation=function(){var t=this,n=e.strings,r=n.VAR_FG_TRANSLATE_START,i=n.VAR_FG_TRANSLATE_END,a=e.cssClasses,o=a.FG_DEACTIVATION,s=a.FG_ACTIVATION,c=e.numbers.DEACTIVATION_TIMEOUT_MS;this.layoutInternal();var u="",d="";if(!this.adapter.isUnbounded()){var l=this.getFgTranslationCoordinates(),p=l.startPoint,f=l.endPoint;u=p.x+"px, "+p.y+"px",d=f.x+"px, "+f.y+"px"}this.adapter.updateCssVariable(r,u),this.adapter.updateCssVariable(i,d),clearTimeout(this.activationTimer),clearTimeout(this.fgDeactivationRemovalTimer),this.rmBoundedActivationClasses(),this.adapter.removeClass(o),this.adapter.computeBoundingRect(),this.adapter.addClass(s),this.activationTimer=setTimeout((function(){t.activationTimerCallback()}),c)},e.prototype.getFgTranslationCoordinates=function(){var t,e=this.activationState,n=e.activationEvent;return{startPoint:t={x:(t=e.wasActivatedByPointer?function(t,e,n){if(!t)return{x:0,y:0};var r,i,a=e.x,o=e.y,s=a+n.left,c=o+n.top;if("touchstart"===t.type){var u=t;r=u.changedTouches[0].pageX-s,i=u.changedTouches[0].pageY-c}else{var d=t;r=d.pageX-s,i=d.pageY-c}return{x:r,y:i}}(n,this.adapter.getWindowPageOffset(),this.adapter.computeBoundingRect()):{x:this.frame.width/2,y:this.frame.height/2}).x-this.initialSize/2,y:t.y-this.initialSize/2},endPoint:{x:this.frame.width/2-this.initialSize/2,y:this.frame.height/2-this.initialSize/2}}},e.prototype.runDeactivationUXLogicIfReady=function(){var t=this,n=e.cssClasses.FG_DEACTIVATION,r=this.activationState,i=r.hasDeactivationUXRun,a=r.isActivated;(i||!a)&&this.activationAnimationHasEnded&&(this.rmBoundedActivationClasses(),this.adapter.addClass(n),this.fgDeactivationRemovalTimer=setTimeout((function(){t.adapter.removeClass(n)}),D.FG_DEACTIVATION_MS))},e.prototype.rmBoundedActivationClasses=function(){var t=e.cssClasses.FG_ACTIVATION;this.adapter.removeClass(t),this.activationAnimationHasEnded=!1,this.adapter.computeBoundingRect()},e.prototype.resetActivationState=function(){var t=this;this.previousActivationEvent=this.activationState.activationEvent,this.activationState=this.defaultActivationState(),setTimeout((function(){return t.previousActivationEvent=void 0}),e.numbers.TAP_DELAY_MS)},e.prototype.deactivateImpl=function(){var t=this,e=this.activationState;if(e.isActivated){var n=y({},e);e.isProgrammatic?(requestAnimationFrame((function(){t.animateDeactivation(n)})),this.resetActivationState()):(this.deregisterDeactivationHandlers(),requestAnimationFrame((function(){t.activationState.hasDeactivationUXRun=!0,t.animateDeactivation(n),t.resetActivationState()})))}},e.prototype.animateDeactivation=function(t){var e=t.wasActivatedByPointer,n=t.wasElementMadeActive;(e||n)&&this.runDeactivationUXLogicIfReady()},e.prototype.layoutInternal=function(){var t=this;this.frame=this.adapter.computeBoundingRect();var n=Math.max(this.frame.height,this.frame.width);this.maxRadius=this.adapter.isUnbounded()?n:Math.sqrt(Math.pow(t.frame.width,2)+Math.pow(t.frame.height,2))+e.numbers.PADDING;var r=Math.floor(n*e.numbers.INITIAL_ORIGIN_SCALE);this.adapter.isUnbounded()&&r%2!==0?this.initialSize=r-1:this.initialSize=r,this.fgScale=""+this.maxRadius/this.initialSize,this.updateLayoutCssVars()},e.prototype.updateLayoutCssVars=function(){var t=e.strings,n=t.VAR_FG_SIZE,r=t.VAR_LEFT,i=t.VAR_TOP,a=t.VAR_FG_SCALE;this.adapter.updateCssVariable(n,this.initialSize+"px"),this.adapter.updateCssVariable(a,this.fgScale),this.adapter.isUnbounded()&&(this.unboundedCoords={left:Math.round(this.frame.width/2-this.initialSize/2),top:Math.round(this.frame.height/2-this.initialSize/2)},this.adapter.updateCssVariable(r,this.unboundedCoords.left+"px"),this.adapter.updateCssVariable(i,this.unboundedCoords.top+"px"))},e}(C),N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.disabled=!1,e}return v(e,t),e.attachTo=function(t,n){void 0===n&&(n={isUnbounded:void 0});var r=new e(t);return void 0!==n.isUnbounded&&(r.unbounded=n.isUnbounded),r},e.createAdapter=function(t){return{addClass:function(e){return t.root.classList.add(e)},browserSupportsCssVars:function(){return function(t,e){void 0===e&&(e=!1);var n,r=t.CSS;if("boolean"===typeof w&&!e)return w;if(!r||"function"!==typeof r.supports)return!1;var i=r.supports("--css-vars","yes"),a=r.supports("(--css-vars: yes)")&&r.supports("color","#00000000");return n=i||a,e||(w=n),n}(window)},computeBoundingRect:function(){return t.root.getBoundingClientRect()},containsEventTarget:function(e){return t.root.contains(e)},deregisterDocumentInteractionHandler:function(t,e){return document.documentElement.removeEventListener(t,e,A())},deregisterInteractionHandler:function(e,n){return t.root.removeEventListener(e,n,A())},deregisterResizeHandler:function(t){return window.removeEventListener("resize",t)},getWindowPageOffset:function(){return{x:window.pageXOffset,y:window.pageYOffset}},isSurfaceActive:function(){return S(t.root,":active")},isSurfaceDisabled:function(){return Boolean(t.disabled)},isUnbounded:function(){return Boolean(t.unbounded)},registerDocumentInteractionHandler:function(t,e){return document.documentElement.addEventListener(t,e,A())},registerInteractionHandler:function(e,n){return t.root.addEventListener(e,n,A())},registerResizeHandler:function(t){return window.addEventListener("resize",t)},removeClass:function(e){return t.root.classList.remove(e)},updateCssVariable:function(e,n){return t.root.style.setProperty(e,n)}}},Object.defineProperty(e.prototype,"unbounded",{get:function(){return Boolean(this.isUnbounded)},set:function(t){this.isUnbounded=Boolean(t),this.setUnbounded()},enumerable:!1,configurable:!0}),e.prototype.activate=function(){this.foundation.activate()},e.prototype.deactivate=function(){this.foundation.deactivate()},e.prototype.layout=function(){this.foundation.layout()},e.prototype.getDefaultFoundation=function(){return new H(e.createAdapter(this))},e.prototype.initialSyncWithDOM=function(){var t=this.root;this.isUnbounded="mdcRippleIsUnbounded"in t.dataset},e.prototype.setUnbounded=function(){this.foundation.setUnbounded(Boolean(this.isUnbounded))},e}(E),V={CHECKED:"mdc-switch--checked",DISABLED:"mdc-switch--disabled"},x={ARIA_CHECKED_ATTR:"aria-checked",NATIVE_CONTROL_SELECTOR:".mdc-switch__native-control",RIPPLE_SURFACE_SELECTOR:".mdc-switch__thumb-underlay"},k=function(t){function e(n){return t.call(this,y(y({},e.defaultAdapter),n))||this}return v(e,t),Object.defineProperty(e,"strings",{get:function(){return x},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssClasses",{get:function(){return V},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},setNativeControlChecked:function(){},setNativeControlDisabled:function(){},setNativeControlAttr:function(){}}},enumerable:!1,configurable:!0}),e.prototype.setChecked=function(t){this.adapter.setNativeControlChecked(t),this.updateAriaChecked(t),this.updateCheckedStyling(t)},e.prototype.setDisabled=function(t){this.adapter.setNativeControlDisabled(t),t?this.adapter.addClass(V.DISABLED):this.adapter.removeClass(V.DISABLED)},e.prototype.handleChange=function(t){var e=t.target;this.updateAriaChecked(e.checked),this.updateCheckedStyling(e.checked)},e.prototype.updateCheckedStyling=function(t){t?this.adapter.addClass(V.CHECKED):this.adapter.removeClass(V.CHECKED)},e.prototype.updateAriaChecked=function(t){this.adapter.setNativeControlAttr(x.ARIA_CHECKED_ATTR,""+!!t)},e}(C);!function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.rippleSurface=e.createRipple(),e}v(e,t),e.attachTo=function(t){return new e(t)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.rippleSurface.destroy(),this.nativeControl.removeEventListener("change",this.changeHandler)},e.prototype.initialSyncWithDOM=function(){var t=this;this.changeHandler=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];(e=t.foundation).handleChange.apply(e,g([],b(n)))},this.nativeControl.addEventListener("change",this.changeHandler),this.checked=this.checked},e.prototype.getDefaultFoundation=function(){var t=this;return new k({addClass:function(e){return t.root.classList.add(e)},removeClass:function(e){return t.root.classList.remove(e)},setNativeControlChecked:function(e){return t.nativeControl.checked=e},setNativeControlDisabled:function(e){return t.nativeControl.disabled=e},setNativeControlAttr:function(e,n){t.nativeControl.setAttribute(e,n)}})},Object.defineProperty(e.prototype,"ripple",{get:function(){return this.rippleSurface},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checked",{get:function(){return this.nativeControl.checked},set:function(t){this.foundation.setChecked(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this.nativeControl.disabled},set:function(t){this.foundation.setDisabled(t)},enumerable:!1,configurable:!0}),e.prototype.createRipple=function(){var t=this,e=k.strings.RIPPLE_SURFACE_SELECTOR,n=this.root.querySelector(e),r=y(y({},N.createAdapter(this)),{addClass:function(t){return n.classList.add(t)},computeBoundingRect:function(){return n.getBoundingClientRect()},deregisterInteractionHandler:function(e,n){t.nativeControl.removeEventListener(e,n,A())},isSurfaceActive:function(){return S(t.nativeControl,":active")},isUnbounded:function(){return!0},registerInteractionHandler:function(e,n){t.nativeControl.addEventListener(e,n,A())},removeClass:function(t){n.classList.remove(t)},updateCssVariable:function(t,e){n.style.setProperty(t,e)}});return new N(this.root,new H(r))},Object.defineProperty(e.prototype,"nativeControl",{get:function(){var t=k.strings.NATIVE_CONTROL_SELECTOR;return this.root.querySelector(t)},enumerable:!1,configurable:!0})}(E);function j(t,e,n){var r=function(t,e){var n=new Map;M.has(t)||M.set(t,{isEnabled:!0,getObservers:function(t){var e=n.get(t)||[];return n.has(t)||n.set(t,e),e},installedProperties:new Set});var r=M.get(t);if(r.installedProperties.has(e))return r;var i=function(t,e){var n,r=t;for(;r&&!(n=Object.getOwnPropertyDescriptor(r,e));)r=Object.getPrototypeOf(r);return n}(t,e)||{configurable:!0,enumerable:!0,value:t[e],writable:!0},a=y({},i),o=i.get,s=i.set;if("value"in i){delete a.value,delete a.writable;var c=i.value;o=function(){return c},i.writable&&(s=function(t){c=t})}o&&(a.get=function(){return o.call(this)});s&&(a.set=function(t){var n,i,a=o?o.call(this):t;if(s.call(this,t),r.isEnabled&&(!o||t!==a))try{for(var c=m(r.getObservers(e)),u=c.next();!u.done;u=c.next()){(0,u.value)(t,a)}}catch(d){n={error:d}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}});return r.installedProperties.add(e),Object.defineProperty(t,e,a),r}(t,e),i=r.getObservers(e);return i.push(n),function(){i.splice(i.indexOf(n),1)}}!function(t){t.PROCESSING="mdc-switch--processing",t.SELECTED="mdc-switch--selected",t.UNSELECTED="mdc-switch--unselected"}(_||(_={})),function(t){t.RIPPLE=".mdc-switch__ripple"}(I||(I={}));var M=new WeakMap;function F(t,e){var n=M.get(t);n&&(n.isEnabled=e)}var U=function(t){function e(e){var n=t.call(this,e)||this;return n.handleClick=n.handleClick.bind(n),n}return v(e,t),e.prototype.init=function(){this.observe(this.adapter.state,{disabled:this.stopProcessingIfDisabled,processing:this.stopProcessingIfDisabled})},e.prototype.handleClick=function(){this.adapter.state.disabled||(this.adapter.state.selected=!this.adapter.state.selected)},e.prototype.stopProcessingIfDisabled=function(){this.adapter.state.disabled&&(this.adapter.state.processing=!1)},e}(function(t){function e(e){var n=t.call(this,e)||this;return n.unobserves=new Set,n}return v(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.unobserve()},e.prototype.observe=function(t,e){var n,r,i=this,a=[];try{for(var o=m(Object.keys(e)),s=o.next();!s.done;s=o.next()){var c=s.value,u=e[c].bind(this);a.push(this.observeProperty(t,c,u))}}catch(l){n={error:l}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}var d=function(){var t,e;try{for(var n=m(a),r=n.next();!r.done;r=n.next()){(0,r.value)()}}catch(o){t={error:o}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}i.unobserves.delete(d)};return this.unobserves.add(d),d},e.prototype.observeProperty=function(t,e,n){return j(t,e,n)},e.prototype.setObserversEnabled=function(t,e){F(t,e)},e.prototype.unobserve=function(){var t,e;try{for(var n=m(g([],b(this.unobserves))),r=n.next();!r.done;r=n.next()){(0,r.value)()}}catch(i){t={error:i}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},e}(C)),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e.prototype.init=function(){t.prototype.init.call(this),this.observe(this.adapter.state,{disabled:this.onDisabledChange,processing:this.onProcessingChange,selected:this.onSelectedChange})},e.prototype.initFromDOM=function(){this.setObserversEnabled(this.adapter.state,!1),this.adapter.state.selected=this.adapter.hasClass(_.SELECTED),this.onSelectedChange(),this.adapter.state.disabled=this.adapter.isDisabled(),this.adapter.state.processing=this.adapter.hasClass(_.PROCESSING),this.setObserversEnabled(this.adapter.state,!0),this.stopProcessingIfDisabled()},e.prototype.onDisabledChange=function(){this.adapter.setDisabled(this.adapter.state.disabled)},e.prototype.onProcessingChange=function(){this.toggleClass(this.adapter.state.processing,_.PROCESSING)},e.prototype.onSelectedChange=function(){this.adapter.setAriaChecked(String(this.adapter.state.selected)),this.toggleClass(this.adapter.state.selected,_.SELECTED),this.toggleClass(!this.adapter.state.selected,_.UNSELECTED)},e.prototype.toggleClass=function(t,e){t?this.adapter.addClass(e):this.adapter.removeClass(e)},e}(U),G=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.root=e,r}return v(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialize=function(){this.ripple=new N(this.root,this.createRippleFoundation())},e.prototype.initialSyncWithDOM=function(){var t=this.root.querySelector(I.RIPPLE);if(!t)throw new Error("Switch "+I.RIPPLE+" element is required.");this.rippleElement=t,this.root.addEventListener("click",this.foundation.handleClick),this.foundation.initFromDOM()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.ripple.destroy(),this.root.removeEventListener("click",this.foundation.handleClick)},e.prototype.getDefaultFoundation=function(){return new B(this.createAdapter())},e.prototype.createAdapter=function(){var t=this;return{addClass:function(e){t.root.classList.add(e)},hasClass:function(e){return t.root.classList.contains(e)},isDisabled:function(){return t.root.disabled},removeClass:function(e){t.root.classList.remove(e)},setAriaChecked:function(e){return t.root.setAttribute("aria-checked",e)},setDisabled:function(e){t.root.disabled=e},state:this}},e.prototype.createRippleFoundation=function(){return new H(this.createRippleAdapter())},e.prototype.createRippleAdapter=function(){var t=this;return y(y({},N.createAdapter(this)),{computeBoundingRect:function(){return t.rippleElement.getBoundingClientRect()},isUnbounded:function(){return!0}})},e}(E);const z=["aria-checked","disabled"],q=[(0,f.createStaticVNode)('<div class="mdc-switch__track"></div><div class="mdc-switch__handle-track"><div class="mdc-switch__handle"><div class="mdc-switch__shadow"><div class="mdc-elevation-overlay"></div></div><div class="mdc-switch__ripple"></div><div class="mdc-switch__icons"><svg class="mdc-switch__icon mdc-switch__icon--on" viewBox="0 0 24 24"><path d="M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z"></path></svg><svg class="mdc-switch__icon mdc-switch__icon--off" viewBox="0 0 24 24"><path d="M20 13H4v-2h16v2z"></path></svg></div></div></div>',2)],W={EVENTS:{CHANGE:"update:modelValue",SELECTED:"selected"}},X={name:"UiSwitch",customOptions:{UI_SWITCH:W}};var $=Object.assign(X,{props:{modelValue:{type:Boolean,default:!1},trueValue:{type:[Boolean,Number,String],default:!0},falseValue:{type:[Boolean,Number,String],default:!1},disabled:{type:Boolean,default:!1}},emits:[W.EVENTS.CHANGE,W.EVENTS.SELECTED],setup(t,e){let{emit:n}=e;const r=t,i=n,a=(0,f.ref)(null),o=(0,f.reactive)({$switch:null,selectedValue:r.modelValue}),{selectedValue:s}=(0,f.toRefs)(o),c=(0,f.computed)((()=>({"mdc-switch":!0,"mdc-switch--unselected":!o.selectedValue,"mdc-switch--selected":o.selectedValue})));function u(){o.$switch=new G(a.value),d(),o.$switch.selected=o.selectedValue}function d(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.modelValue;o.selectedValue=t}function l(){const t=!o.selectedValue;i(W.EVENTS.CHANGE,t),i(W.EVENTS.SELECTED,t?r.trueValue:r.falseValue)}return(0,f.onMounted)((()=>{u(),(0,f.watch)((()=>r.modelValue),(t=>d(t))),(0,f.watch)((()=>r.disabled),(t=>{o.$switch&&(o.$switch.disabled=t)}))})),(0,f.onUpdated)((()=>u())),(e,n)=>((0,f.openBlock)(),(0,f.createElementBlock)("button",{ref_key:"switchRef",ref:a,class:(0,f.normalizeClass)(c.value),type:"button",role:"switch","aria-checked":(0,f.unref)(s),disabled:t.disabled,onClick:l},q,10,z))}});var K=p($);return i=i.default}()}));