@minix-iot/ui
Version:
基于Vue的移动端轻量级UI组件库
7 lines • 22.2 kB
JavaScript
/*!
* @minix-iot/ui v0.2.4 - cell.js, 2709badeb34a699cd765, Wed Nov 24 2021 14:21:12 GMT+0800 (中国标准时间)
* (c) 2017-2020 JDC
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("cell",["vue"],e):"object"==typeof exports?exports.cell=e(require("vue")):t.cell=e(t.Vue)}("undefined"!=typeof self?self:this,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="./",n(n.s=110)}({0:function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},1:function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0},10:function(t,e,n){var r=n(7);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0},11:function(t,e,n){var r=n(19),o=n(20),i=n(10),a=n(21);t.exports=function(t,e){return r(t)||o(t,e)||i(t,e)||a()},t.exports.default=t.exports,t.exports.__esModule=!0},110:function(t,e,n){"use strict";n.r(e);var r,o=n(5),i=n(1),a=n.n(i),s=n(17),l=n(31),u=n(32),c=n(3).a.Create("cell"),f={name:c.name,components:(r={Icon:s.a},a()(r,l.a.name,l.a),a()(r,"Tag",u.a),r),props:{value:{type:Boolean,default:!1},theme:{type:String,default:""},icon:{type:String,default:""},iconShape:{type:String,default:"square"},iconColor:{type:String,default:""},iconSize:{type:String,default:""},iconDot:{type:Boolean,default:!1},size:{type:String,default:"small"},title:{type:String|Number,required:!0},subtitle:{type:String,default:""},tags:{type:Array,default:function(){return[]}},desc:{type:String,default:""},stamp:{type:String,default:""},type:{type:String,default:"normal"},card:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},model:{prop:"value",event:"change"},data:function(){return{active:!1,bodyHeaderStyle:"",collapse:!1}},computed:{valueInner:{get:function(){return this.value},set:function(t){this.$emit("change",t)}},cls:function(){return c.derive({disabled:this.disabled,collapse:this.collapse})},headerCls:function(){return c.derive("header",[this.size,{active:this.active}])},headerLeftCls:function(){return c.derive("header-left",{pdr:this.icon||this.$slots.left||this.isRadio})},iconCls:function(){return c.derive("icon")},headerRightWrapperCls:function(){return c.derive("header-right-wrapper")},headerRightCls:function(){return c.derive("header-right",{stamp:this.stamp})},prefixCls:function(){return c.derive("header-right-prefix")},middleCls:function(){return c.derive("header-right-middle",{prefix:this.desc||this.$slots.desc})},suffixCls:function(){return c.derive("header-right-suffix")},spliterCls:function(){return c.derive("spliter",{card:this.card})},titleCls:function(){return c.derive("title",{mgb:this.subtitle||this.$slots.subtitle})},titleTextCls:function(){return c.derive("title-text")},titleTagCls:function(){return c.derive("title-tag")},subtitleCls:function(){return c.derive("subtitle")},descCls:function(){return c.derive("desc",[{more:!this.icon}])},stampCls:function(){return c.derive("stamp",{small:"large"===this.size})},linkCls:function(){return c.derive("arrow")},collapseCls:function(){return c.derive("collapse",{collapse:this.collapse})},bodyCls:function(){return c.derive("body")},isSmall:function(){return"small"===this.size},isSwitch:function(){return"switch"===this.type},isLink:function(){return"link"===this.type},isCollapse:function(){return"collapse"===this.type},iconSizeDict:function(){return{small:20,middle:28,large:32,super:48}},iconSizePixel:function(){var t=this.iconSize?this.iconSize:this.size;return"small"===this.size?this.iconSizeDict.small:this.iconSizeDict[t]},isIconRound:function(){return"square"!==this.iconShape},switchTheme:function(){return this.theme||"brand"},transitionName:function(){return c.derive("slide")}},methods:{onClick:function(){this.$emit("click")},onTouchStart:function(){this.disabled||(this.active=!0)},onTouchEnd:function(){this.disabled||(this.active=!1)},onArrowClick:function(){if(console.log("click"),"link"!==this.type&&(this.collapse=!this.collapse,!this.bodyHeaderStyle)){var t=this.$refs.hLeft.clientWidth;this.bodyHeaderStyle="width: ".concat(t,"px")}}},render:function(){var t=this,e=arguments[0],n=function(){return t.$slots.left?t.$slots.left:t.icon&&e(s.a,{class:t.iconCls,attrs:{theme:t.theme,name:t.icon,dot:t.iconDot,color:t.iconColor,size:t.iconSizePixel,round:t.isIconRound}})},r=function(){return e("div",{class:t.prefixCls},[e("div",{class:t.titleCls},[o()]),e("div",{class:t.subtitleCls},[a()])])},o=function(){return t.$slots.title?t.$slots.title:[e("div",{class:t.titleTextCls},[t.title]),i()]},i=function(){return t.tags.map((function(t){return e(u.a,{attrs:{theme:"gray"}},[t])}))},a=function(){return t.$slots.subtitle?t.$slots.subtitle:!t.isSmall&&t.subtitle},l=function(){return e("div",{class:t.middleCls},[t.$slots.desc||e("div",{class:t.descCls},[t.desc])])},c=function(){return e("div",{class:t.suffixCls},[t.$slots.suffix||t.stamp&&e("div",{class:t.stampCls},[t.stamp])||t.isSwitch&&e("mx-switch",{attrs:{theme:t.switchTheme},model:{value:t.valueInner,callback:function(e){t.valueInner=e}}})||t.isLink&&e(s.a,{attrs:{name:"arrow-right",size:10}})||t.isCollapse&&e("div",{class:t.collapseCls,on:{click:t.onArrowClick}},[e(s.a,{attrs:{name:"arrow-right",size:10}})])])},f=function(){return e("div",{class:t.headerCls,on:{click:t.onClick,touchstart:t.onTouchStart,touchend:t.onTouchEnd,touchcancel:t.onTouchEnd}},[e("div",{class:t.headerLeftCls,ref:"hLeft"},[n()]),e("div",{class:t.headerRightWrapperCls},[e("div",{class:t.headerRightCls},[r(),l(),c()]),e("div",{class:t.spliterCls})])])},d=function(){return e("Transition",{attrs:{name:t.transitionName}},[t.collapse&&e("div",{class:t.bodyCls},[t.$slots.body||[e("div",{style:t.bodyHeaderStyle},[t.$slots["body-header"]]),e("div",[t.$slots["body-content"]])]])])};return e("div",{class:this.cls},[f(),d()])}};n(50);o.a.WithInstall(f);e.default=f},12:function(t,e,n){var r=n(7);t.exports=function(t){if(Array.isArray(t))return r(t)},t.exports.default=t.exports,t.exports.__esModule=!0},13:function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0},14:function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},15:function(t,e,n){"use strict";var r=n(11),o=n.n(r),i=n(3),a=n(9),s=i.a.Create("badge");e.a={name:s.name,props:{tag:{type:String,default:"div"},theme:{type:String,default:"red"},dot:{type:Boolean,default:!1},max:{type:Number},content:{type:Number|String},color:{type:String},offset:{type:Array},small:{type:Boolean,default:!1}},computed:{cls:function(){return s.derive([this.theme,{dot:this.dot,fixed:!!this.$slots.default,small:this.small}])},wrapperCls:function(){return s.derive("wrapper")},style:function(){var t={};if(this.color){t.backgroundColor=this.color;var e=a.a.FromHex(this.color);t.color=e.isDark?a.a.WHITE:a.a.BLACK}if(this.offset){var n=o()(this.offset,2),r=n[0],i=n[1];this.$slots.default?(t.top="".concat(i,"px"),t.right="".concat(-r,"px")):(t.marginLeft="".concat(r,"px"),t.marginTop="".concat(i,"px"))}return t},hasContent:function(){return this.$slots.content||!!this.content}},render:function(){var t=this,e=arguments[0],n=function(){if(!t.dot){if(t.$slots.content)return t.$slots.content;var e=t.$props,n=e.max,r=e.content;return n&&!Number.isNaN(Number(r))&&r>n?"".concat(n,"+"):t.content}},r=function(){if(t.hasContent||t.dot)return e("div",{class:t.cls,style:t.style},[n()])};if(this.$slots.default){var o=this.tag;return e(o,{class:this.wrapperCls},[this.$slots.default,r()])}return r()}}},17:function(t,e,n){"use strict";var r=n(3),o=n(15),i=r.a.Create("icon");e.a={name:i.name,components:{Badge:o.a},props:{tag:{type:String,default:"i"},dot:{type:Boolean,default:!1},badge:{type:String|Number},name:{type:String,required:!0},size:{type:Number|String},color:{type:String},round:{type:Boolean,default:!1},classPrefix:{type:String,default:"mx-icon"},theme:{type:String},offset:{type:Array}},computed:{imgCls:function(){return i.derive("img")},isImgIcon:function(){return this.name.includes("/")},style:function(){var t={};return this.color&&(t[this.isImgIcon?"backgroundColor":"color"]=this.color),this.size&&(t.fontSize="".concat(this.size,"px")),this.round&&(t.borderRadius="50%"),t}},methods:{onClick:function(t){this.$emit("click",t)}},render:function(){var t=this,e=arguments[0],n=this.$props,r=n.tag,i=n.dot,a=n.badge,s=n.name,l=n.classPrefix,u=function(){return e(r,{class:[l,t.isImgIcon?"":"".concat(l,"-").concat(s),t.isImgIcon&&"mx-icon--img",t.theme&&"mx-icon--".concat(t.theme)],style:t.style,on:{click:t.onClick}},[t.isImgIcon&&e("img",{class:t.imgCls,attrs:{src:s}})])};return i||a?e(o.a,{attrs:{dot:i,content:a,offset:this.offset,small:!0}},[u()]):u()}}},18:function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(0),o=n.n(r),i=n(2),a=n.n(i),s=function(){function t(){o()(this,t)}return a()(t,null,[{key:"IsWindow",value:function(t){return t===window}},{key:"IsElement",value:function(t){return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE}},{key:"IsHidden",value:function(t){if(t)return!1;var e=widnow.getComputedStyle(t),n="none"===e.getPropertyValue("display"),r=null===t.offsetParent&&"fixed"!==e.getPropertyValue("position");return n||r}},{key:"GetScrollTop",value:function(t){return Math.max("scrollTop"in t?t.scrollTop:t.scrollY,0)}},{key:"GetBoundingClientRect",value:function(t){return null!=t&&t.getBoundingClientRect?t.getBoundingClientRect():this.IsWindow(t)?new DOMRect(0,0,t.innerWidth,t.innerHeight):new DOMRect(0,0,0,0)}},{key:"GetScrollParent",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,n=t;n&&n!==e&&this.IsElement(n);){var r=window.getComputedStyle(n).getPropertyValue("overflow-y");if(/scroll|auto/i.test(r)&&n.scrollHeight>n.offsetHeight)return n;n=n.parentNode}return e}},{key:"stopPropagation",value:function(t){null==t||t.stopPropagation()}},{key:"PreventDefault",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];("boolean"!=typeof(null==t?void 0:t.cancelable)||null!=t&&t.cancelable)&&t.preventDefault(),e&&t.stopPropagation()}},{key:"AddEventListener",value:function(t,e,n,r){t&&t instanceof EventTarget&&t.addEventListener(e,n,r)}},{key:"RemoveEventListener",value:function(t,e,n){t&&t instanceof EventTarget&&t.removeEventListener(e,n)}}]),t}()},19:function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.default=t.exports,t.exports.__esModule=!0},2:function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t},t.exports.default=t.exports,t.exports.__esModule=!0},20:function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}},t.exports.default=t.exports,t.exports.__esModule=!0},21:function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},3:function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(0),o=n.n(r),i=n(2),a=n.n(i),s=n(1),l=n.n(s),u=function(){function t(e){o()(this,t),this._name=e}return a()(t,[{key:"name",get:function(){return"".concat(t.ROOT,"-").concat(this._name)}},{key:"derive",value:function(t,e){return t&&"string"!=typeof t&&(e=t,t=""),t=t?this.sub(t):this.name,"".concat(t).concat(this.mod(t,e))}},{key:"sub",value:function(t){var e=Array.isArray(t)?t:[t];return e.reduce((function(t,e){return"".concat(t,"-").concat(e)}),e.length?this.name:"")}},{key:"mod",value:function(t,e){var n=this;return e?"string"==typeof e?" ".concat(t,"--").concat(e):Array.isArray(e)?e.reduce((function(e,r){return e+n.mod(t,r)}),""):Object.keys(e).reduce((function(r,o){return r+(e[o]?n.mod(t,o):"")}),""):""}}],[{key:"Create",value:function(e){return new t(e)}}]),t}();l()(u,"ROOT","mx")},31:function(t,e,n){"use strict";var r=n(18),o=n(3).a.Create("switch");e.a={name:o.name,props:{theme:{type:String,default:"brand"},value:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},color:{type:String,default:""}},model:{prop:"value",event:"change"},computed:{cls:function(){return o.derive([this.theme,{disabled:this.disabled,active:this.value}])},style:function(){var t={};return this.value&&this.color&&(t.backgroundColor=this.color,t.borderColor=this.color),t},circleCls:function(){return o.derive("circle",{active:this.value})}},methods:{toggle:function(t){r.a.StopPropogation(t),this.disabled||this.$emit("change",!this.value)}},render:function(){var t=this,e=arguments[0];return e("div",{class:this.cls,style:this.style,on:{click:function(e){return e.stopPropagation(),t.toggle(e)}}},[e("div",{class:this.circleCls})])}}},32:function(t,e,n){"use strict";var r=n(3),o=n(9),i=r.a.Create("tag");e.a={name:i.name,props:{theme:{type:String,default:"brand"},size:{type:String,default:"middle"},round:{type:Boolean,default:!0},plain:{type:Boolean,default:!1},mark:{type:Boolean,default:!1},color:{type:String},textColor:{type:String}},computed:{cls:function(){return i.derive([this.theme,this.size,{round:this.round,plain:this.plain,mark:this.mark}])},style:function(){var t={};if(this.color)if(this.plain)t.borderColor=this.color,t.color=this.color;else{var e=o.a.FromHex(this.color);t.backgroundColor=this.color,t.color=e.isDark?o.a.WHITE:o.a.BLACK}return this.textColor&&(t.color=this.textColor),t}},render:function(){var t=arguments[0];return t("span",{class:this.cls,style:this.style},[this.$slots.default])}}},4:function(t,e,n){var r=n(12),o=n(13),i=n(10),a=n(14);t.exports=function(t){return r(t)||o(t)||i(t)||a()},t.exports.default=t.exports,t.exports.__esModule=!0},5:function(t,e,n){"use strict";n.d(e,"a",(function(){return y}));var r=n(4),o=n.n(r),i=n(6),a=n.n(i),s=n(0),l=n.n(s),u=n(2),c=n.n(u),f=n(8),d=n.n(f);function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var y=function(){function t(){l()(this,t)}return c()(t,null,[{key:"WithInstall",value:function(t,e){if("object"!==a()(t)&&!t.name)throw new Error("could not install,because it is not a vue component!");t.install=function(n){n.component(t.name,t),e&&(n.prototype["$".concat(t.name.replace("mx-",""))]=e)}}},{key:"SortChildren",value:function(t,e){var n=e.$vnode.componentOptions;if(n&&n.children&&n.children.length){var r=this.FlattenVNode(n.children);return t.sort((function(t,e){return r.indexOf(t.$vnode)-r.indexOf(e.$vnode)})),t}}},{key:"FlattenVNode",value:function(t){return this.TraverseVNode(t)}},{key:"TraverseVNode",value:function(t){var e,n=[],r=p(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;n.push(i),i.componentInstance&&n.push.apply(n,o()(this.TraverseVNode(i.componentInstance.$children.map((function(t){return t.$vnode}))))),i.children&&n.push.apply(n,o()(this.TraverseVNode(i.children)))}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"InvokeComponent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=function(){var e=t((function(){r.$destroy(),document.body.removeChild(r.$el),n=n.filter((function(t){return t!==r}))})),r=new d.a(e),o=document.createElement("div");return document.body.appendChild(o),r.$mount(o),r},o=function(){return n.length&&!e||n.push(r()),n[n.length-1]};return function(t){o().open(t)}}}]),t}()},50:function(t,e,n){},6:function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=n=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),n(e)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},7:function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.default=t.exports,t.exports.__esModule=!0},8:function(e,n){e.exports=t},9:function(t,e,n){"use strict";n.d(e,"a",(function(){return p}));var r=n(11),o=n.n(r),i=n(0),a=n.n(i),s=n(2),l=n.n(s),u=n(1),c=n.n(u);function f(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var p=function(){function t(e,n){a()(this,t),this._channels=e,this._alpha=n}return l()(t,[{key:"r",get:function(){return this._channels[0]}},{key:"g",get:function(){return this._channels[1]}},{key:"b",get:function(){return this._channels[2]}},{key:"a",get:function(){return this._alpha}},{key:"luminosity",get:function(){var t,e=[],n=f(this._channels.entries());try{for(n.s();!(t=n.n()).done;){var r=o()(t.value,2),i=r[0],a=r[1]/255;e[i]=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)}}catch(t){n.e(t)}finally{n.f()}return.2126*e[0]+.7152*e[1]+.0722*e[2]}},{key:"isDark",get:function(){return this.luminosity<.5}},{key:"isLight",get:function(){return!this.isDark}},{key:"isNone",get:function(){return!this._channels||!this._channels.length}},{key:"toString",value:function(){return this.isNone?"":Number.isNaN(this._alpha)?"rgb(".concat(this._channels.map((function(t){return Math.round(t)})).join(","),")"):"rgba(".concat([this._channels,this._alpha].map((function(t){return Math.round(t)})).join(","),")")}}],[{key:"FromHex",value:function(e){if(!e.startsWith("#"))return new t(null,NaN);var n=e.length>5?function(e){for(var n=e.match(t.REG_HEX),r=[0,0,0],o=n[1],i=0;i<3;i++)r[i]=parseInt(o.slice(2*i,2*i+2),16);return{channels:r,alpha:n[2]?parseFloat(n[2],16)/255:NaN}}(e):function(e){for(var n=e.match(t.REG_HEX_ABBR)[1],r=[0,0,0],o=0;o<3;o++)r[o]=parseInt(n[o]+n[o],16);return{channels:r,alpha:n[4]?parseFloat(n[4],16)/255:NaN}}(e);return new t(n.channels,n.alpha)}},{key:"Mix",value:function(e,n,r){var o=void 0===r?.5:r,i=2*o-1,a=(e.a||1)-(n.a||1),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,l=1-s;return new t([s*e.r+l*n.r,s*e.g+l*n.g,s*e.b+l*n.b],e.a*o+n.a*(1-o))}},{key:"Shift",value:function(e,n){return n>0?t.Shade(e,n):t.Tint(e,-n)}},{key:"Tint",value:function(e,n){return t.Mix(t.WHITE,e,n)}},{key:"Shade",value:function(e,n){return t.Mix(t.BLACK,e,n)}}]),t}();c()(p,"WHITE",new p([255,255,255],1)),c()(p,"BLACK",new p([0,0,0],1)),c()(p,"REG_HEX",/^#([a-f0-9]{6})([a-f0-9]{2})?$/i),c()(p,"REG_HEX_ABBR",/^#([a-f0-9]{3,4})$/i)}})}));
//# sourceMappingURL=cell.js.map