import{p as B,aZ as z,aQ as D,a_ as F,br as Q,r as R,c as d,o as w,h,a6 as W,av as N,aS as P,Y as K,L as S,g as E}from"./index-BT5eY4j5.js";const G=B({name:"QRating",props:{...z,...D,modelValue:{type:Number,required:!0},max:{type:[String,Number],default:5},icon:[String,Array],iconHalf:[String,Array],iconSelected:[String,Array],iconAriaLabel:[String,Array],color:[String,Array],colorHalf:[String,Array],colorSelected:[String,Array],noReset:Boolean,noDimming:Boolean,readonly:Boolean,disable:Boolean},emits:["update:modelValue"],setup(e,{slots:f,emit:m}){const{proxy:{$q:r}}=E(),v=F(e),$=Q(e),k=P($),l=R(0);let s={};const g=d(()=>e.readonly!==!0&&e.disable!==!0),x=d(()=>`q-rating row inline items-center q-rating--${g.value===!0?"":"non-"}editable`+(e.noDimming===!0?" q-rating--no-dimming":"")+(e.disable===!0?" disabled":"")+(e.color!==void 0&&Array.isArray(e.color)===!1?` text-${e.color}`:"")),C=d(()=>{const t=Array.isArray(e.icon)===!0?e.icon.length:0,n=Array.isArray(e.iconSelected)===!0?e.iconSelected.length:0,o=Array.isArray(e.iconHalf)===!0?e.iconHalf.length:0,i=Array.isArray(e.color)===!0?e.color.length:0,u=Array.isArray(e.colorSelected)===!0?e.colorSelected.length:0,a=Array.isArray(e.colorHalf)===!0?e.colorHalf.length:0;return{iconLen:t,icon:t>0?e.icon[t-1]:e.icon,selIconLen:n,selIcon:n>0?e.iconSelected[n-1]:e.iconSelected,halfIconLen:o,halfIcon:o>0?e.iconHalf[n-1]:e.iconHalf,colorLen:i,color:i>0?e.color[i-1]:e.color,selColorLen:u,selColor:u>0?e.colorSelected[u-1]:e.colorSelected,halfColorLen:a,halfColor:a>0?e.colorHalf[a-1]:e.colorHalf}}),V=d(()=>{if(typeof e.iconAriaLabel=="string"){const t=e.iconAriaLabel.length!==0?`${e.iconAriaLabel} `:"";return n=>`${t}${n}`}if(Array.isArray(e.iconAriaLabel)===!0){const t=e.iconAriaLabel.length;if(t>0)return n=>e.iconAriaLabel[Math.min(n,t)-1]}return(t,n)=>`${n} ${t}`}),_=d(()=>{const t=[],n=C.value,o=Math.ceil(e.modelValue),i=g.value===!0?0:null,u=e.iconHalf===void 0||o===e.modelValue?-1:o;for(let a=1;a<=e.max;a++){const c=l.value===0&&e.modelValue>=a||l.value>0&&l.value>=a,y=u===a&&l.value<a,A=l.value>0&&(y===!0?o:e.modelValue)>=a&&l.value<a,H=y===!0?a<=n.halfColorLen?e.colorHalf[a-1]:n.halfColor:n.selColor!==void 0&&c===!0?a<=n.selColorLen?e.colorSelected[a-1]:n.selColor:a<=n.colorLen?e.color[a-1]:n.color,j=(y===!0?a<=n.halfIconLen?e.iconHalf[a-1]:n.halfIcon:n.selIcon!==void 0&&(c===!0||A===!0)?a<=n.selIconLen?e.iconSelected[a-1]:n.selIcon:a<=n.iconLen?e.icon[a-1]:n.icon)||r.iconSet.rating.icon;t.push({name:(y===!0?a<=n.halfIconLen?e.iconHalf[a-1]:n.halfIcon:n.selIcon!==void 0&&(c===!0||A===!0)?a<=n.selIconLen?e.iconSelected[a-1]:n.selIcon:a<=n.iconLen?e.icon[a-1]:n.icon)||r.iconSet.rating.icon,attrs:{tabindex:i,role:"radio","aria-checked":e.modelValue===a?"true":"false","aria-label":V.value(a,j)},iconClass:"q-rating__icon"+(c===!0||y===!0?" q-rating__icon--active":"")+(A===!0?" q-rating__icon--exselected":"")+(l.value===a?" q-rating__icon--hovered":"")+(H!==void 0?` text-${H}`:"")})}return t}),q=d(()=>{const t={role:"radiogroup"};return e.disable===!0&&(t["aria-disabled"]="true"),e.readonly===!0&&(t["aria-readonly"]="true"),t});function b(t){if(g.value===!0){const n=K(parseInt(t,10),1,parseInt(e.max,10)),o=e.noReset!==!0&&e.modelValue===n?0:n;o!==e.modelValue&&m("update:modelValue",o),l.value=0}}function L(t){g.value===!0&&(l.value=t)}function M(t,n){switch(t.keyCode){case 13:case 32:return b(n),S(t);case 37:case 40:return s[`rt${n-1}`]&&s[`rt${n-1}`].focus(),S(t);case 39:case 38:return s[`rt${n+1}`]&&s[`rt${n+1}`].focus(),S(t)}}function I(){l.value=0}return w(()=>{s={}}),()=>{const t=[];return _.value.forEach(({iconClass:n,name:o,attrs:i},u)=>{const a=u+1;t.push(h("div",{key:a,ref:c=>{s[`rt${a}`]=c},class:"q-rating__icon-container flex flex-center",...i,onClick(){b(a)},onMouseover(){L(a)},onMouseout:I,onFocus(){L(a)},onBlur:I,onKeyup(c){M(c,a)}},W(f[`tip-${a}`],[h(N,{class:n,name:o})])))}),e.name!==void 0&&e.disable!==!0&&k(t,"push"),h("div",{class:x.value,style:v.value,...q.value},t)}}}),U=["nedelja","ponedeljak","utorak","sreda","četvrtak","petak","subota"];function Y(e){return U[e]}function J(e,f){const m=Y(typeof f=="number"?f:f.getDay()),r=e.find(v=>v.dan===m);return!r||r.pocetak==="zatvoreno"||r.kraj==="zatvoreno"?null:`${r.pocetak} - ${r.kraj}`}export{G as Q,Y as a,J as g};
