UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

2 lines (1 loc) 35.2 kB
import{dL as he,a3 as U,bJ as ve,bG as oe,bm as m,d8 as ae,cV as D,bK as il,d6 as ge,dn as sl,a5 as W,H as s,U as E,n as L,dM as rl,bt as de,dN as dl,dO as Ye,dP as cl,dQ as Re,dR as Se,dS as Te,dT as ke,cL as Je,b as f,i as te,ac as ml,ad as vl,dU as De,dH as hl,cM as pe,bo as G,cO as fl,cA as Vl,cy as bl,a8 as yl,cB as kl,a2 as xe,cq as ze,cn as Qe,cw as gl,dV as wl,cr as we,cT as Cl,q as Ce,v as Sl,dW as pl,cx as xl,a4 as Ie,dl as Pl,dr as Fe,dX as _l,am as Ze,R as re,dg as Rl,du as Tl,dY as Il,cu as Ll,dZ as Nl,d_ as Oe,d$ as $e,e0 as Be,e1 as Ml,d7 as Bl,e2 as El,l as Le,e3 as Dl,r as Ae,e4 as zl,bI as Fl,e5 as Ol,cE as Al,cG as Hl,_ as Ul,c as q,z as g,k as Y,e as M,h as J,t as H,w as x,aq as He,bl as Ue,D as me,K as Ke,aa as Kl,F as jl,G as Gl,J as ql,g as Wl,by as Xl,ae as Yl,aU as je,aV as Ge,x as qe}from"./index-B8xHYEBg.js";import{c as Jl}from"./colors-DoZdCu1D.js";const Ql=U({color:{type:Object},disabled:Boolean,dotSize:{type:[Number,String],default:10},height:{type:[Number,String],default:150},width:{type:[Number,String],default:300},...de()},"VColorPickerCanvas"),Zl=he({name:"VColorPickerCanvas",props:Ql(),emits:{"update:color":e=>!0,"update:position":e=>!0},setup(e,l){let{emit:t}=l;const u=ve(!1),o=oe(),a=ve(parseFloat(e.width)),n=ve(parseFloat(e.height)),i=oe({x:0,y:0}),d=m({get:()=>i.value,set(c){if(!o.value)return;const{x:h,y:b}=c;i.value=c,t("update:color",{h:e.color?.h??0,s:ae(h,0,a.value)/a.value,v:1-ae(b,0,n.value)/n.value,a:e.color?.a??1})}}),w=m(()=>{const{x:c,y:h}=d.value,b=parseInt(e.dotSize,10)/2;return{width:D(e.dotSize),height:D(e.dotSize),transform:`translate(${D(c-b)}, ${D(h-b)})`}}),{resizeRef:v}=il(c=>{if(!v.el?.offsetParent)return;const{width:h,height:b}=c[0].contentRect;a.value=h,n.value=b});function C(c,h,b){const{left:P,top:F,width:B,height:O}=b;d.value={x:ae(c-P,0,B),y:ae(h-F,0,O)}}function y(c){c.type==="mousedown"&&c.preventDefault(),!e.disabled&&(S(c),window.addEventListener("mousemove",S),window.addEventListener("mouseup",p),window.addEventListener("touchmove",S),window.addEventListener("touchend",p))}function S(c){if(e.disabled||!o.value)return;u.value=!0;const h=rl(c);C(h.clientX,h.clientY,o.value.getBoundingClientRect())}function p(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",p),window.removeEventListener("touchmove",S),window.removeEventListener("touchend",p)}function z(){if(!o.value)return;const c=o.value,h=c.getContext("2d");if(!h)return;const b=h.createLinearGradient(0,0,c.width,0);b.addColorStop(0,"hsla(0, 0%, 100%, 1)"),b.addColorStop(1,`hsla(${e.color?.h??0}, 100%, 50%, 1)`),h.fillStyle=b,h.fillRect(0,0,c.width,c.height);const P=h.createLinearGradient(0,0,0,c.height);P.addColorStop(0,"hsla(0, 0%, 0%, 0)"),P.addColorStop(1,"hsla(0, 0%, 0%, 1)"),h.fillStyle=P,h.fillRect(0,0,c.width,c.height)}return ge(()=>e.color?.h,z,{immediate:!0}),ge(()=>[a.value,n.value],(c,h)=>{z(),i.value={x:d.value.x*c[0]/h[0],y:d.value.y*c[1]/h[1]}},{flush:"post"}),ge(()=>e.color,()=>{if(u.value){u.value=!1;return}i.value=e.color?{x:e.color.s*a.value,y:(1-e.color.v)*n.value}:{x:0,y:0}},{deep:!0,immediate:!0}),sl(()=>z()),W(()=>s("div",{ref:v,class:L(["v-color-picker-canvas",e.class]),style:E(e.style),onMousedown:y,onTouchstartPassive:y},[s("canvas",{ref:o,width:a.value,height:n.value},null),e.color&&s("div",{class:L(["v-color-picker-canvas__dot",{"v-color-picker-canvas__dot--disabled":e.disabled}]),style:E(w.value)},null)])),{}}});function $l(e,l){if(l){const{a:t,...u}=e;return u}return e}function et(e,l){if(l==null||typeof l=="string"){const t=e.a!==1;if(l?.startsWith("rgb(")){const{r:o,g:a,b:n,a:i}=Te(e);return`rgb(${o} ${a} ${n}`+(t?` / ${i})`:")")}else if(l?.startsWith("hsl(")){const{h:o,s:a,l:n,a:i}=Re(e);return`hsl(${o} ${Math.round(a*100)} ${Math.round(n*100)}`+(t?` / ${i})`:")")}const u=Ye(e);return e.a===1?u.slice(0,7):u}if(typeof l=="object"){let t;return ke(l,["r","g","b"])?t=Te(e):ke(l,["h","s","l"])?t=Re(e):ke(l,["h","s","v"])&&(t=e),$l(t,!ke(l,["a"])&&e.a===1)}return e}const se={h:0,s:0,v:0,a:1},Ne={inputProps:{type:"number",min:0},inputs:[{label:"R",max:255,step:1,getValue:e=>Math.round(e.r),getColor:(e,l)=>({...e,r:Number(l)}),localeKey:"redInput"},{label:"G",max:255,step:1,getValue:e=>Math.round(e.g),getColor:(e,l)=>({...e,g:Number(l)}),localeKey:"greenInput"},{label:"B",max:255,step:1,getValue:e=>Math.round(e.b),getColor:(e,l)=>({...e,b:Number(l)}),localeKey:"blueInput"},{label:"A",max:1,step:.01,getValue:e=>{let{a:l}=e;return l!=null?Math.round(l*100)/100:1},getColor:(e,l)=>({...e,a:Number(l)}),localeKey:"alphaInput"}],to:Te,from:Se},lt={...Ne,inputs:Ne.inputs?.slice(0,3)},Me={inputProps:{type:"number",min:0},inputs:[{label:"H",max:360,step:1,getValue:e=>Math.round(e.h),getColor:(e,l)=>({...e,h:Number(l)}),localeKey:"hueInput"},{label:"S",max:1,step:.01,getValue:e=>Math.round(e.s*100)/100,getColor:(e,l)=>({...e,s:Number(l)}),localeKey:"saturationInput"},{label:"L",max:1,step:.01,getValue:e=>Math.round(e.l*100)/100,getColor:(e,l)=>({...e,l:Number(l)}),localeKey:"lightnessInput"},{label:"A",max:1,step:.01,getValue:e=>{let{a:l}=e;return l!=null?Math.round(l*100)/100:1},getColor:(e,l)=>({...e,a:Number(l)}),localeKey:"alphaInput"}],to:Re,from:cl},tt={...Me,inputs:Me.inputs.slice(0,3)},el={inputProps:{type:"text"},inputs:[{label:"HEXA",getValue:e=>e,getColor:(e,l)=>l,localeKey:"hexaInput"}],to:Ye,from:dl},at={...el,inputs:[{label:"HEX",getValue:e=>e.slice(0,7),getColor:(e,l)=>l,localeKey:"hexInput"}]},ne={rgb:lt,rgba:Ne,hsl:tt,hsla:Me,hex:at,hexa:el},nt=e=>{let{label:l,...t}=e;return s("div",{class:"v-color-picker-edit__input"},[s("input",ml(vl(t)),null),s("span",null,[l])])},ot=U({color:Object,disabled:Boolean,mode:{type:String,default:"rgba",validator:e=>Object.keys(ne).includes(e)},modes:{type:Array,default:()=>Object.keys(ne),validator:e=>Array.isArray(e)&&e.every(l=>Object.keys(ne).includes(l))},...de()},"VColorPickerEdit"),ut=he({name:"VColorPickerEdit",props:ot(),emits:{"update:color":e=>!0,"update:mode":e=>!0},setup(e,l){let{emit:t}=l;const{t:u}=Je(),o=m(()=>e.modes.map(n=>({...ne[n],name:n}))),a=m(()=>{const n=o.value.find(d=>d.name===e.mode);if(!n)return[];const i=e.color?n.to(e.color):null;return n.inputs?.map(d=>{let{getValue:w,getColor:v,localeKey:C,...y}=d;return{...n.inputProps,...y,ariaLabel:u(`$vuetify.colorPicker.ariaLabel.${C}`),disabled:e.disabled,value:i&&w(i),onChange:S=>{const p=S.target;p&&t("update:color",n.from(v(i??n.to(se),p.value)))}}})});return W(()=>s("div",{class:L(["v-color-picker-edit",e.class]),style:E(e.style)},[a.value?.map(n=>f(nt,n,null)),o.value.length>1&&f(te,{icon:"$unfold",size:"x-small",variant:"plain","aria-label":u("$vuetify.colorPicker.ariaLabel.changeFormat"),onClick:()=>{const n=o.value.findIndex(i=>i.name===e.mode);t("update:mode",o.value[(n+1)%o.value.length].name)}},null)])),{}}}),Ee=Symbol.for("vuetify:v-slider");function it(e,l,t){const u=t==="vertical",o=l.getBoundingClientRect(),a="touches"in e?e.touches[0]:e;return u?a.clientY-(o.top+o.height/2):a.clientX-(o.left+o.width/2)}function st(e,l){return"touches"in e&&e.touches.length?e.touches[0][l]:"changedTouches"in e&&e.changedTouches.length?e.changedTouches[0][l]:e[l]}const rt=U({disabled:{type:Boolean,default:null},error:Boolean,readonly:{type:Boolean,default:null},max:{type:[Number,String],default:100},min:{type:[Number,String],default:0},step:{type:[Number,String],default:0},thumbColor:String,thumbLabel:{type:[Boolean,String],default:void 0,validator:e=>typeof e=="boolean"||e==="always"},thumbSize:{type:[Number,String],default:20},showTicks:{type:[Boolean,String],default:!1,validator:e=>typeof e=="boolean"||e==="always"},ticks:{type:[Array,Object]},tickSize:{type:[Number,String],default:2},color:String,trackColor:String,trackFillColor:String,trackSize:{type:[Number,String],default:4},direction:{type:String,default:"horizontal",validator:e=>["vertical","horizontal"].includes(e)},reverse:Boolean,noKeyboard:Boolean,...bl(),...Vl({elevation:2}),ripple:{type:Boolean,default:!0}},"Slider"),dt=e=>{const l=m(()=>parseFloat(e.min)),t=m(()=>parseFloat(e.max)),u=m(()=>Number(e.step)>0?parseFloat(e.step):0),o=m(()=>Math.max(De(u.value),De(l.value)));function a(n){if(n=parseFloat(n),u.value<=0)return n;const i=ae(n,l.value,t.value),d=l.value%u.value;let w=Math.round((i-d)/u.value)*u.value+d;return i>w&&w+u.value>t.value&&(w=t.value),parseFloat(Math.min(w,t.value).toFixed(o.value))}return{min:l,max:t,step:u,decimals:o,roundValue:a}},ct=e=>{let{props:l,steps:t,onSliderStart:u,onSliderMove:o,onSliderEnd:a,getActiveThumb:n}=e;const i=hl(l),{isRtl:d}=pe(),w=G(()=>l.reverse),v=m(()=>l.direction==="vertical"),C=m(()=>v.value!==w.value),{min:y,max:S,step:p,decimals:z,roundValue:c}=t,h=m(()=>parseInt(l.thumbSize,10)),b=m(()=>parseInt(l.tickSize,10)),P=m(()=>parseInt(l.trackSize,10)),F=m(()=>(S.value-y.value)/p.value),B=m(()=>l.error||i.isDisabled.value?void 0:l.thumbColor??l.color),O=m(()=>l.error||i.isDisabled.value?void 0:l.thumbColor),Q=m(()=>l.error||i.isDisabled.value?void 0:l.trackColor??l.color),X=m(()=>l.error||i.isDisabled.value?void 0:l.trackFillColor??l.color),_=ve(!1),R=ve(0),N=oe(),k=oe();function A(r){const V=N.value?.$el;if(!V)return;const le=l.direction==="vertical",be=le?"top":"left",ye=le?"height":"width",al=le?"clientY":"clientX",{[be]:nl,[ye]:ol}=V.getBoundingClientRect(),ul=st(r,al);let _e=ae((ul-nl-R.value)/ol)||0;return(le?C.value:C.value!==d.value)&&(_e=1-_e),c(y.value+_e*(S.value-y.value))}const K=r=>{const V=A(r);V!=null&&a({value:V}),_.value=!1,R.value=0},ce=r=>{const V=A(r);k.value=n(r),k.value&&(_.value=!0,k.value.contains(r.target)?R.value=it(r,k.value,l.direction):(R.value=0,V!=null&&o({value:V})),V!=null&&u({value:V}),yl(()=>k.value?.focus()))},Z={passive:!0,capture:!0};function j(r){const V=A(r);V!=null&&o({value:V})}function $(r){r.stopPropagation(),r.preventDefault(),K(r),window.removeEventListener("mousemove",j,Z),window.removeEventListener("mouseup",$)}function ue(r){K(r),window.removeEventListener("touchmove",j,Z),r.target?.removeEventListener("touchend",ue)}function ee(r){ce(r),window.addEventListener("touchmove",j,Z),r.target?.addEventListener("touchend",ue,{passive:!1})}function Pe(r){r.button===0&&(r.preventDefault(),ce(r),window.addEventListener("mousemove",j,Z),window.addEventListener("mouseup",$,{passive:!1}))}const ie=r=>{const V=(r-y.value)/(S.value-y.value)*100;return ae(isNaN(V)?0:V,0,100)},fe=G(()=>l.showTicks),Ve=m(()=>fe.value?l.ticks?Array.isArray(l.ticks)?l.ticks.map(r=>({value:r,position:ie(r),label:r.toString()})):Object.keys(l.ticks).map(r=>({value:parseFloat(r),position:ie(parseFloat(r)),label:l.ticks[r]})):F.value!==1/0?fl(F.value+1).map(r=>{const V=y.value+r*p.value;return{value:V,position:ie(V)}}):[]:[]),I=m(()=>Ve.value.some(r=>{let{label:V}=r;return!!V})),T={activeThumbRef:k,color:G(()=>l.color),decimals:z,disabled:i.isDisabled,direction:G(()=>l.direction),elevation:G(()=>l.elevation),hasLabels:I,isReversed:w,indexFromEnd:C,min:y,max:S,mousePressed:_,noKeyboard:G(()=>l.noKeyboard),numTicks:F,onSliderMousedown:Pe,onSliderTouchstart:ee,parsedTicks:Ve,parseMouseMove:A,position:ie,readonly:i.isReadonly,rounded:G(()=>l.rounded),roundValue:c,showTicks:fe,startOffset:R,step:p,thumbSize:h,thumbColor:B,thumbLabelColor:O,thumbLabel:G(()=>l.thumbLabel),ticks:G(()=>l.ticks),tickSize:b,trackColor:Q,trackContainerRef:N,trackFillColor:X,trackSize:P,vertical:v};return kl(Ee,T),T},mt=U({focused:Boolean,max:{type:Number,required:!0},min:{type:Number,required:!0},modelValue:{type:Number,required:!0},position:{type:Number,required:!0},ripple:{type:[Boolean,Object],default:!0},name:String,noKeyboard:Boolean,...de()},"VSliderThumb"),vt=xe()({name:"VSliderThumb",directives:{vRipple:ze},props:mt(),emits:{"update:modelValue":e=>!0},setup(e,l){let{slots:t,emit:u}=l;const o=Qe(Ee),{isRtl:a,rtlClasses:n}=pe();if(!o)throw new Error("[Vuetify] v-slider-thumb must be used inside v-slider or v-range-slider");const{min:i,max:d,thumbColor:w,thumbLabelColor:v,step:C,disabled:y,thumbSize:S,thumbLabel:p,direction:z,isReversed:c,vertical:h,readonly:b,elevation:P,mousePressed:F,decimals:B,indexFromEnd:O}=o,Q=m(()=>y.value?void 0:P.value),{elevationClasses:X}=gl(Q),{textColorClasses:_,textColorStyles:R}=wl(w),{backgroundColorClasses:N,backgroundColorStyles:k}=we(v),{pageup:A,pagedown:K,end:ce,home:Z,left:j,right:$,down:ue,up:ee}=Cl,Pe=[A,K,ce,Z,j,$,ue,ee],ie=m(()=>C.value?[1,2,3]:[1,5,10]);function fe(I,T){if(e.noKeyboard||y.value||!Pe.includes(I.key))return;I.preventDefault();const r=C.value||.1,V=(d.value-i.value)/r;if([j,$,ue,ee].includes(I.key)){const be=(h.value?[a.value?j:$,c.value?ue:ee]:O.value!==a.value?[j,ee]:[$,ee]).includes(I.key)?1:-1,ye=I.shiftKey?2:I.ctrlKey?1:0;be===-1&&T===d.value&&!ye&&!Number.isInteger(V)?T=T-V%1*r:T=T+be*r*ie.value[ye]}else if(I.key===Z)T=i.value;else if(I.key===ce)T=d.value;else{const le=I.key===K?1:-1;T=T-le*r*(V>100?V/10:10)}return Math.max(e.min,Math.min(e.max,T))}function Ve(I){const T=fe(I,e.modelValue);T!=null&&u("update:modelValue",T)}return W(()=>{const I=D(O.value?100-e.position:e.position,"%");return s("div",{class:L(["v-slider-thumb",{"v-slider-thumb--focused":e.focused,"v-slider-thumb--pressed":e.focused&&F.value},e.class,n.value]),style:E([{"--v-slider-thumb-position":I,"--v-slider-thumb-size":D(S.value)},e.style]),role:"slider",tabindex:y.value?-1:0,"aria-label":e.name,"aria-valuemin":i.value,"aria-valuemax":d.value,"aria-valuenow":e.modelValue,"aria-readonly":!!b.value,"aria-orientation":z.value,onKeydown:b.value?void 0:Ve},[s("div",{class:L(["v-slider-thumb__surface",_.value,X.value]),style:E(R.value)},null),Ce(s("div",{class:L(["v-slider-thumb__ripple",_.value]),style:E(R.value)},null),[[ze,e.ripple,null,{circle:!0,center:!0}]]),f(pl,{origin:"bottom center"},{default:()=>[Ce(s("div",{class:"v-slider-thumb__label-container"},[s("div",{class:L(["v-slider-thumb__label",N.value]),style:E(k.value)},[s("div",null,[t["thumb-label"]?.({modelValue:e.modelValue})??e.modelValue.toFixed(C.value?B.value:1)]),s("div",{class:"v-slider-thumb__label-wedge"},null)])]),[[Sl,p.value&&e.focused||p.value==="always"]])]})])}),{}}}),ht=U({start:{type:Number,required:!0},stop:{type:Number,required:!0},...de()},"VSliderTrack"),ft=xe()({name:"VSliderTrack",props:ht(),emits:{},setup(e,l){let{slots:t}=l;const u=Qe(Ee);if(!u)throw new Error("[Vuetify] v-slider-track must be inside v-slider or v-range-slider");const{color:o,parsedTicks:a,rounded:n,showTicks:i,tickSize:d,trackColor:w,trackFillColor:v,trackSize:C,vertical:y,min:S,max:p,indexFromEnd:z}=u,{roundedClasses:c}=xl(n),{backgroundColorClasses:h,backgroundColorStyles:b}=we(v),{backgroundColorClasses:P,backgroundColorStyles:F}=we(w),B=m(()=>`inset-${y.value?"block":"inline"}-${z.value?"end":"start"}`),O=m(()=>y.value?"height":"width"),Q=m(()=>({[B.value]:"0%",[O.value]:"100%"})),X=m(()=>e.stop-e.start),_=m(()=>({[B.value]:D(e.start,"%"),[O.value]:D(X.value,"%")})),R=m(()=>i.value?(y.value?a.value.slice().reverse():a.value).map((k,A)=>{const K=k.value!==S.value&&k.value!==p.value?D(k.position,"%"):void 0;return s("div",{key:k.value,class:L(["v-slider-track__tick",{"v-slider-track__tick--filled":k.position>=e.start&&k.position<=e.stop,"v-slider-track__tick--first":k.value===S.value,"v-slider-track__tick--last":k.value===p.value}]),style:{[B.value]:K}},[(k.label||t["tick-label"])&&s("div",{class:"v-slider-track__tick-label"},[t["tick-label"]?.({tick:k,index:A})??k.label])])}):[]);return W(()=>s("div",{class:L(["v-slider-track",c.value,e.class]),style:E([{"--v-slider-track-size":D(C.value),"--v-slider-tick-size":D(d.value)},e.style])},[s("div",{class:L(["v-slider-track__background",P.value,{"v-slider-track__background--opacity":!!o.value||!v.value}]),style:{...Q.value,...F.value}},null),s("div",{class:L(["v-slider-track__fill",h.value]),style:{..._.value,...b.value}},null),i.value&&s("div",{class:L(["v-slider-track__ticks",{"v-slider-track__ticks--always-show":i.value==="always"}])},[R.value])])),{}}}),Vt=U({...Il(),...rt(),...Tl(),modelValue:{type:[Number,String],default:0}},"VSlider"),We=xe()({name:"VSlider",props:Vt(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,start:e=>!0,end:e=>!0},setup(e,l){let{slots:t,emit:u}=l;const o=oe(),a=oe(),{rtlClasses:n}=pe(),i=dt(e),d=Ie(e,"modelValue",void 0,_=>i.roundValue(_??i.min.value)),{min:w,max:v,mousePressed:C,roundValue:y,onSliderMousedown:S,onSliderTouchstart:p,trackContainerRef:z,position:c,hasLabels:h,disabled:b,readonly:P,noKeyboard:F}=ct({props:e,steps:i,onSliderStart:()=>{!b.value&&!P.value&&u("start",d.value)},onSliderEnd:_=>{let{value:R}=_;const N=y(R);!b.value&&!P.value&&(d.value=N),u("end",N)},onSliderMove:_=>{let{value:R}=_;!b.value&&!P.value&&(d.value=y(R))},getActiveThumb:()=>o.value?.$el}),{isFocused:B,focus:O,blur:Q}=Pl(e),X=m(()=>c(d.value));return W(()=>{const _=Fe.filterProps(e),R=!!(e.label||t.label||t.prepend);return f(Fe,re({ref:a,class:["v-slider",{"v-slider--has-labels":!!t["tick-label"]||h.value,"v-slider--focused":B.value,"v-slider--pressed":C.value,"v-slider--disabled":b.value},n.value,e.class],style:e.style},_,{focused:B.value}),{...t,prepend:R?N=>s(Ze,null,[t.label?.(N)??(e.label?f(_l,{id:N.id.value,class:"v-slider__label",text:e.label},null):void 0),t.prepend?.(N)]):void 0,default:N=>{let{id:k,messagesId:A}=N;return s("div",{class:"v-slider__container",onMousedown:P.value?void 0:S,onTouchstartPassive:P.value?void 0:p},[s("input",{id:k.value,name:e.name||k.value,disabled:b.value,readonly:P.value,tabindex:"-1",value:d.value},null),f(ft,{ref:z,start:0,stop:X.value},{"tick-label":t["tick-label"]}),f(vt,{ref:o,"aria-describedby":A.value,focused:B.value,noKeyboard:F.value,min:w.value,max:v.value,modelValue:d.value,"onUpdate:modelValue":K=>d.value=K,position:X.value,elevation:e.elevation,onFocus:O,onBlur:Q,ripple:e.ripple,name:e.name},{"thumb-label":t["thumb-label"]})])}})}),Rl({focus:()=>o.value?.$el.focus()},a)}}),ll=U({color:{type:Object},disabled:Boolean,hideAlpha:Boolean,hideEyeDropper:Boolean,eyeDropperIcon:{type:Ll,default:"$eyeDropper"},...de()},"VColorPickerPreview"),bt=he({name:"VColorPickerPreview",props:ll(),emits:{"update:color":e=>!0},setup(e,l){let{emit:t}=l;const{t:u}=Je(),o=new AbortController;Nl(()=>o.abort());async function a(){if(!Oe||e.disabled)return;const n=new window.EyeDropper;try{const i=await n.open({signal:o.signal}),d=Se(Be(i.sRGBHex));t("update:color",{...e.color??se,...d})}catch{}}return W(()=>s("div",{class:L(["v-color-picker-preview",{"v-color-picker-preview--hide-alpha":e.hideAlpha},e.class]),style:E(e.style)},[Oe&&!e.hideEyeDropper&&s("div",{class:"v-color-picker-preview__eye-dropper",key:"eyeDropper"},[f(te,{"aria-label":u("$vuetify.colorPicker.ariaLabel.eyedropper"),density:"comfortable",disabled:e.disabled,icon:e.eyeDropperIcon,variant:"plain",onClick:a},null)]),s("div",{class:"v-color-picker-preview__dot"},[s("div",{style:{background:$e(e.color??se)}},null)]),s("div",{class:"v-color-picker-preview__sliders"},[f(We,{class:"v-color-picker-preview__track v-color-picker-preview__hue",name:u("$vuetify.colorPicker.ariaLabel.hueSlider"),modelValue:e.color?.h,"onUpdate:modelValue":n=>t("update:color",{...e.color??se,h:n}),step:1,min:0,max:360,disabled:e.disabled,thumbSize:14,trackSize:8,trackFillColor:"white",hideDetails:!0},null),!e.hideAlpha&&f(We,{class:"v-color-picker-preview__track v-color-picker-preview__alpha",name:u("$vuetify.colorPicker.ariaLabel.alphaSlider"),modelValue:e.color?.a??1,"onUpdate:modelValue":n=>t("update:color",{...e.color??se,a:n}),step:.01,min:0,max:1,disabled:e.disabled,thumbSize:14,trackSize:8,trackFillColor:"white",hideDetails:!0},null)])])),{}}}),yt=U({swatches:{type:Array,default:()=>kt(Jl)},disabled:Boolean,color:Object,maxHeight:[Number,String],...de()},"VColorPickerSwatches");function kt(e){return Object.keys(e).map(l=>{const t=e[l];return t.base?[t.base,t.darken4,t.darken3,t.darken2,t.darken1,t.lighten1,t.lighten2,t.lighten3,t.lighten4,t.lighten5]:[t.black,t.white,t.transparent]})}const gt=he({name:"VColorPickerSwatches",props:yt(),emits:{"update:color":e=>!0},setup(e,l){let{emit:t}=l;return W(()=>s("div",{class:L(["v-color-picker-swatches",e.class]),style:E([{maxHeight:D(e.maxHeight)},e.style])},[s("div",null,[e.swatches.map(u=>s("div",{class:"v-color-picker-swatches__swatch"},[u.map(o=>{const a=Be(o),n=Se(a),i=Ml(a);return s("div",{class:"v-color-picker-swatches__color",onClick:()=>n&&t("update:color",n)},[s("div",{style:{background:i}},[e.color&&Bl(e.color,n)?f(Le,{size:"x-small",icon:"$success",color:El(o,"#FFFFFF")>2?"white":"black"},null):void 0])])})]))])])),{}}}),wt=Dl("v-picker-title"),tl=U({bgColor:String,divided:Boolean,landscape:Boolean,title:String,hideHeader:Boolean,hideTitle:Boolean,...zl()},"VPicker"),Xe=xe()({name:"VPicker",props:tl(),setup(e,l){let{slots:t}=l;const{backgroundColorClasses:u,backgroundColorStyles:o}=we(()=>e.color);return W(()=>{const a=Ae.filterProps(e),n=!e.hideTitle&&!!(e.title||t.title);return f(Ae,re(a,{color:e.bgColor,class:["v-picker",{"v-picker--divided":e.divided,"v-picker--landscape":e.landscape,"v-picker--with-actions":!!t.actions},e.class],style:e.style}),{default:()=>[!e.hideHeader&&s("div",{key:"header",class:L([u.value]),style:E([o.value])},[n&&f(wt,{key:"picker-title"},{default:()=>[t.title?.()??e.title]}),t.header&&s("div",{class:"v-picker__header"},[t.header()])]),s("div",{class:"v-picker__body"},[t.default?.()]),t.actions&&f(Fl,{defaults:{VBtn:{slim:!0,variant:"text"}}},{default:()=>[s("div",{class:"v-picker__actions"},[t.actions()])]})]})}),{}}}),Ct=U({canvasHeight:{type:[String,Number],default:150},disabled:Boolean,dotSize:{type:[Number,String],default:10},hideCanvas:Boolean,hideSliders:Boolean,hideInputs:Boolean,mode:{type:String,default:"rgba",validator:e=>Object.keys(ne).includes(e)},modes:{type:Array,default:()=>Object.keys(ne),validator:e=>Array.isArray(e)&&e.every(l=>Object.keys(ne).includes(l))},showSwatches:Boolean,swatches:Array,swatchesMaxHeight:{type:[Number,String],default:150},modelValue:{type:[Object,String]},...tl({hideHeader:!0}),...Hl(ll(),["hideEyeDropper","eyeDropperIcon"])},"VColorPicker"),St=he({name:"VColorPicker",props:Ct(),emits:{"update:modelValue":e=>!0,"update:mode":e=>!0},setup(e,l){let{slots:t}=l;const u=Ie(e,"mode"),o=oe(null),a=Ie(e,"modelValue",void 0,v=>{if(v==null||v==="")return null;let C;try{C=Se(Be(v))}catch{return null}return C},v=>v?et(v,e.modelValue):null),n=m(()=>a.value?{...a.value,h:o.value??a.value.h}:null),{rtlClasses:i}=pe();let d=!0;ge(a,v=>{if(!d){d=!0;return}v&&(o.value=v.h)},{immediate:!0});const w=v=>{d=!1,o.value=v.h,a.value=v};return Ol(()=>{e.modes.includes(u.value)||(u.value=e.modes[0])}),Al({VSlider:{color:void 0,trackColor:void 0,trackFillColor:void 0}}),W(()=>{const v=Xe.filterProps(e);return f(Xe,re(v,{class:["v-color-picker",i.value,e.class],style:[{"--v-color-picker-color-hsv":$e({...n.value??se,a:1})},e.style]}),{...t,default:()=>s(Ze,null,[!e.hideCanvas&&f(Zl,{key:"canvas",color:n.value,"onUpdate:color":w,disabled:e.disabled,dotSize:e.dotSize,width:e.width,height:e.canvasHeight},null),(!e.hideSliders||!e.hideInputs)&&s("div",{key:"controls",class:"v-color-picker__controls"},[!e.hideSliders&&f(bt,{key:"preview",color:n.value,"onUpdate:color":w,hideAlpha:!u.value.endsWith("a"),disabled:e.disabled,hideEyeDropper:e.hideEyeDropper,eyeDropperIcon:e.eyeDropperIcon},null),!e.hideInputs&&f(ut,{key:"edit",modes:e.modes,mode:u.value,"onUpdate:mode":C=>u.value=C,color:n.value,"onUpdate:color":w,disabled:e.disabled},null)]),e.showSwatches&&f(gt,{key:"swatches",color:n.value,"onUpdate:color":w,maxHeight:e.swatchesMaxHeight,swatches:e.swatches,disabled:e.disabled},null)])})}),{}}}),pt={props:{modelValue:{type:Object},disable_send:{type:Boolean},node:{type:Object}},data(){return{durations:["seconds","minutes"],showMenu:!1,error:null}},computed:{trueLabel(){return this.modelValue.type==="boolean"&&this.modelValue.states?.length>0?this.modelValue.states.find(e=>e.value===!0)?.text:null},isDefault(){return this.modelValue.default!==void 0&&this.modelValue.default===this.modelValue.newValue},numberOutOfRange(){const e=this.modelValue.min??-1/0,l=this.modelValue.max??1/0;return this.modelValue.type==="number"&&(this.modelValue.newValue<e||this.modelValue.newValue>l)},falseLabel(){return this.modelValue.type==="boolean"&&this.modelValue.states?.length>0?this.modelValue.states.find(e=>e.value===!1)?.text:null},selectedItem(){const e=this.modelValue.type==="number"?Number(this.modelValue.newValue):this.modelValue.newValue;return this.modelValue.states?this.modelValue.states.find(l=>l.value===e):null},canIdleNotification(){return!this.modelValue||this.disable_send?!1:this.modelValue.commandClassName==="Notification"&&this.modelValue.states?.find(e=>e.value===0)},canResetConfiguration(){return!this.modelValue||this.disable_send?!1:this.modelValue.writeable&&this.modelValue.commandClass===112&&this.modelValue.commandClassVersion>3},items(){return this.selectedItem?this.modelValue.states:[{value:this.modelValue.newValue,text:"Custom"},...this.modelValue.states]},label(){return"["+this.modelValue.id+"] "+this.modelValue.label},help(){return`${this.modelValue.description?`${this.modelValue.description} `:""}${this.modelValue.default!==void 0&&!this.modelValue.list?`(Default: ${this.modelValue.default}${this.modelValue.max!==void 0?`, max: ${this.modelValue.max}`:""}${this.modelValue.min!==void 0?`, min: ${this.modelValue.min}`:""})`:""}`},color:{get:function(){return"#"+(this.modelValue.newValue||"ffffff").toUpperCase()},set:function(e){this.modelValue.newValue=e?e.substr(1,7):null}},parsedValue:{get:function(){return typeof this.modelValue.newValue=="object"?JSON.stringify(this.modelValue.newValue):this.modelValue.states&&this.modelValue.newValue!==void 0?this.itemText(this.selectedItem||this.modelValue.newValue):this.modelValue===null?"(unknown)":this.modelValue===void 0?"(missing)":this.modelValue.newValue},set:function(e){try{this.modelValue.type==="any"?this.modelValue.newValue=JSON.parse(e):typeof e=="string"&&this.modelValue.type==="number"&&(this.modelValue.newValue=Number(e)),this.error=null}catch{this.error="Value not valid"}}},pickerStyle(){return this.modelValue.type!=="color"?null:{backgroundColor:this.color,cursor:"pointer",border:"1px solid "+(this.$vuetify.theme.current.dark?"white":"black"),height:"30px",width:"30px",borderRadius:this.showMenu?"50%":"4px",transition:"border-radius 200ms ease-in-out"}}},methods:{async resetConfig(){(await je.getInstance(Ge.APP).apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"reset",[this.modelValue.property]])).success&&qe().showSnackbar("Configuration reset","success")},async idleNotification(){(await je.getInstance(Ge.APP).apiRequest("manuallyIdleNotificationValue",[this.modelValue],{infoSnack:!1,errorSnack:!0})).success&&qe().showSnackbar("Notification manually idled","success")},itemText(e){if(typeof e=="object"){const l=e.text!==void 0?` ${e.text}`:"";return`[${e.value}]${l}${this.modelValue.default===e.value?" (Default)":""}`}else return e},updateValue(e,l){l!==void 0&&(e.newValue=l),e.type==="boolean"&&e.states?.length===1&&(l=e.states[0].value,e.newValue=l),this.$emit("updateValue",e,l)}}},xt={class:"valueid-slot"},Pt={class:"valueid-label text-subtitle-2"},_t={key:0},Rt={class:"readonly mt-5"},Tt={key:0,class:"text-caption mt-1 help"},It={key:1,class:"d-flex align-center"},Lt={key:3,style:{display:"flex"}},Nt={key:7},Mt={key:0},Bt={key:0},Et={key:0,class:"text-caption mt-2 help"},Dt={class:"help"};function zt(e,l,t,u,o,a){return g(),q("div",xt,[s("div",Pt,[Y(H(a.label)+" ",1),a.canResetConfiguration?(g(),M(te,{key:0,class:"ml-2 mb-1",onClick:a.resetConfig,size:"x-small",variant:"outlined",color:"error"},{default:x(()=>[...l[20]||(l[20]=[Y("Reset",-1)])]),_:1},8,["onClick"])):J("",!0),a.isDefault?Ce((g(),M(Ue,{key:1,class:"ml-2 mb-1",size:"x-small",variant:"outlined",color:"primary"},{default:x(()=>[...l[21]||(l[21]=[Y("Default",-1)])]),_:1})),[[He,"This value is set to its default","bottom"]]):J("",!0)]),t.modelValue.writeable?(g(),q("div",It,[!t.modelValue.list&&(t.modelValue.type==="string"||t.modelValue.type==="buffer")?(g(),M(me,{key:0,"append-icon":t.disable_send?null:"send",suffix:t.modelValue.unit,"persistent-hint":"",hint:a.help,modelValue:t.modelValue.newValue,"onUpdate:modelValue":l[0]||(l[0]=n=>t.modelValue.newValue=n),"onClick:append":l[1]||(l[1]=n=>a.updateValue(t.modelValue))},null,8,["append-icon","suffix","hint","modelValue"])):!t.modelValue.list&&t.modelValue.type==="number"?(g(),M(me,{key:1,type:"number","append-icon":!t.disable_send&&!a.numberOutOfRange?"send":null,suffix:t.modelValue.unit,min:t.modelValue.min!=t.modelValue.max?t.modelValue.min:null,step:t.modelValue.step||1,"persistent-hint":"",max:t.modelValue.min!=t.modelValue.max?t.modelValue.max:null,hint:a.help,error:a.numberOutOfRange,"error-messages":a.numberOutOfRange?`Value must be between ${t.modelValue.min} and ${t.modelValue.max}`:"",modelValue:t.modelValue.newValue,"onUpdate:modelValue":l[2]||(l[2]=n=>t.modelValue.newValue=n),modelModifiers:{number:!0},"onClick:append":l[3]||(l[3]=n=>!a.numberOutOfRange&&a.updateValue(t.modelValue))},null,8,["append-icon","suffix","min","step","max","hint","error","error-messages","modelValue"])):!t.modelValue.list&&t.modelValue.type==="any"?(g(),M(me,{key:2,"append-icon":t.disable_send?null:"send",suffix:t.modelValue.unit,"persistent-hint":"",error:!!o.error,"error-messages":o.error,hint:a.help,modelValue:a.parsedValue,"onUpdate:modelValue":l[4]||(l[4]=n=>a.parsedValue=n),"onClick:append":l[5]||(l[5]=n=>a.updateValue(t.modelValue))},null,8,["append-icon","suffix","error","error-messages","hint","modelValue"])):t.modelValue.type==="duration"?(g(),q("div",Lt,[f(me,{type:t.modelValue.type==="number"?"number":"text",min:t.modelValue.min!=t.modelValue.max?t.modelValue.min:null,step:t.modelValue.step||1,"persistent-hint":"",readonly:t.disable_send,max:t.modelValue.min!=t.modelValue.max?t.modelValue.max:null,hint:a.help,modelValue:t.modelValue.newValue.value,"onUpdate:modelValue":l[6]||(l[6]=n=>t.modelValue.newValue.value=n),modelModifiers:{number:!0}},null,8,["type","min","step","readonly","max","hint","modelValue"]),f(Ke,{style:{"margin-left":"10px","min-width":"105px",width:"135px"},items:o.durations,modelValue:t.modelValue.newValue.unit,"onUpdate:modelValue":l[7]||(l[7]=n=>t.modelValue.newValue.unit=n),readonly:t.disable_send,"persistent-hint":"","append-icon":t.disable_send?null:"send","onClick:append":l[8]||(l[8]=n=>a.updateValue(t.modelValue))},null,8,["items","modelValue","readonly","append-icon"])])):t.modelValue.type==="color"?(g(),M(me,{key:4,style:{"max-width":"250px","margin-top":"10px"},flat:"",variant:"solo",modelValue:a.color,"onUpdate:modelValue":l[11]||(l[11]=n=>a.color=n),"persistent-hint":"","append-icon":t.disable_send?null:"send",hint:a.help,"onClick:append":l[12]||(l[12]=n=>a.updateValue(t.modelValue))},{append:x(()=>[f(Kl,{modelValue:o.showMenu,"onUpdate:modelValue":l[10]||(l[10]=n=>o.showMenu=n),location:"top",offset:[16,105],"close-on-content-click":!1},{activator:x(({props:n})=>[s("div",re({class:"ml-2",style:a.pickerStyle},n),null,16)]),default:x(()=>[f(jl,null,{default:x(()=>[f(Gl,{class:"pa-0"},{default:x(()=>[o.showMenu?(g(),M(St,{key:0,modelValue:a.color,"onUpdate:modelValue":l[9]||(l[9]=n=>a.color=n)},null,8,["modelValue"])):J("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["modelValue","append-icon","hint"])):t.modelValue.list&&!t.modelValue.allowManualEntry&&t.modelValue.type!=="boolean"?(g(),M(Ke,{key:5,items:a.items,style:E({"max-width":e.$vuetify.display.smAndDown?"280px":e.$vuetify.display.sm?"400px":"auto"}),hint:a.help,"persistent-hint":"","return-object":!1,"item-title":a.itemText,"item-value":"value",suffix:t.modelValue.unit,"append-icon":t.disable_send?null:"send",modelValue:t.modelValue.newValue,"onUpdate:modelValue":l[13]||(l[13]=n=>t.modelValue.newValue=n),"onClick:append":l[14]||(l[14]=n=>a.updateValue(t.modelValue))},{selection:x(({item:n})=>[s("span",null,H(a.itemText(a.selectedItem||n)),1)]),_:1},8,["items","style","hint","item-title","suffix","append-icon","modelValue"])):t.modelValue.list&&t.modelValue.allowManualEntry&&t.modelValue.type!=="boolean"?(g(),M(ql,{key:6,items:a.items,style:E({"max-width":e.$vuetify.display.smAndDown?"280px":e.$vuetify.display.sm?"400px":"auto"}),hint:a.help,"persistent-hint":"",chips:"",suffix:t.modelValue.unit,"item-title":a.itemText,"item-value":"value",type:t.modelValue.type==="number"?"number":"text","return-object":!1,"append-icon":t.disable_send?null:"send",modelValue:t.modelValue.newValue,"onUpdate:modelValue":l[15]||(l[15]=n=>t.modelValue.newValue=n),ref:"myCombo","onClick:append":l[16]||(l[16]=n=>a.updateValue(t.modelValue))},{chip:x(({attrs:n,item:i,selected:d})=>[f(Ue,re(n,{"model-value":d}),{default:x(()=>[s("span",null,H(a.itemText(a.selectedItem||i)),1)]),_:2},1040,["model-value"])]),_:1},8,["items","style","hint","suffix","item-title","type","append-icon","modelValue"])):t.modelValue.type==="boolean"&&(t.modelValue.writeable&&t.modelValue.readable||t.modelValue.states&&t.modelValue.states.length===2)?(g(),q("div",Nt,[f(Wl,{class:"my-2",rounded:"xl"},{default:x(()=>[f(te,{variant:t.modelValue.newValue===!0?"flat":"outlined",modelValue:!0,color:"success",onClick:l[17]||(l[17]=n=>a.updateValue(t.modelValue,!0))},{default:x(()=>[a.trueLabel?(g(),q("span",Mt,H(a.trueLabel),1)):(g(),M(Le,{key:1,size:"large",color:t.modelValue.newValue===!0&&!t.modelValue.list?"white":"success",style:{rotate:"90deg"}},{default:x(()=>[...l[23]||(l[23]=[Y(" horizontal_rule ",-1)])]),_:1},8,["color"]))]),_:1},8,["variant"]),f(te,{variant:t.modelValue.newValue===!1?"flat":"outlined",modelValue:!1,color:"error",onClick:l[18]||(l[18]=n=>a.updateValue(t.modelValue,!1))},{default:x(()=>[a.falseLabel?(g(),q("span",Bt,H(a.falseLabel),1)):(g(),M(Le,{key:1,size:"large",color:t.modelValue.newValue===!1&&!t.modelValue.list?"white":"error"},{default:x(()=>[...l[24]||(l[24]=[Y("radio_button_unchecked",-1)])]),_:1},8,["color"]))]),_:1},8,["variant"])]),_:1}),a.help?(g(),q("div",Et,H(a.help),1)):J("",!0)])):t.modelValue.type==="boolean"&&!t.modelValue.readable?(g(),M(Xl,{key:8,location:"right"},{activator:x(({props:n})=>[f(te,re({"max-width":"100%",size:"small",variant:"flat"},n,{color:"primary",onClick:l[19]||(l[19]=i=>a.updateValue(t.modelValue)),class:"mb-2 mt-2"}),{default:x(()=>[Y(H(a.trueLabel||a.falseLabel||t.modelValue.label),1)]),_:1},16)]),default:x(()=>[s("span",Dt,H("["+t.modelValue.id+"] "+a.help),1)]),_:1})):J("",!0),t.modelValue.toUpdate?Ce((g(),M(Yl,{key:9,indeterminate:"",class:"ml-2",size:"20",color:t.node?.status==="Asleep"?"warning":"primary"},null,8,["color"])),[[He,t.node?.status==="Asleep"?"Wake up your device in order to send commands":"Set value in progress...","bottom"]]):J("",!0)])):(g(),q("div",_t,[s("div",Rt,[Y(H(a.parsedValue+(t.modelValue.unit?" "+t.modelValue.unit:""))+" ",1),a.canIdleNotification?(g(),M(te,{key:0,onClick:a.idleNotification,size:"small",color:"primary"},{default:x(()=>[...l[22]||(l[22]=[Y("Idle",-1)])]),_:1},8,["onClick"])):J("",!0)]),a.help?(g(),q("div",Tt,H(a.help),1)):J("",!0)]))])}const At=Ul(pt,[["render",zt],["__scopeId","data-v-b2f71486"]]);export{At as default};