import{d as me,u as Le,o as v,P as N,g as A,i as C,e as w,q as D,t as k,C as ke,h as i,z,F as P,a9 as rn,k as p,_ as he,B as an,aD as sn,aE as un,aF as dn,aG as cn,aH as _e,aI as pn,aJ as fn,aK as vn,aL as gn,aM as mn,aN as hn,aO as lt,aP as bn,aQ as yn,aR as Ke,aS as wn,ak as Cn,x as yt,f as E,aT as _n,p as Be,y as ge,a0 as rt,ap as kn,aU as On,S as Ln,ay as Oe,X as Ze,A as Sn,G as ce,E as pe,aV as it,D as at,a as Mn,am as Fn,w as ee,O as st,aW as En,N as Dn,b as Tn,c as xn,ad as Rn,a1 as Nn,J as An,r as U,a2 as Vn,L as We,aX as fe}from"./index-D92x6h1h.js";import{A as Ye,a as Qe,i as $n,c as He,L as zn,s as Pn,D as In,b as Un,d as Gn,e as Kn,h as Bn,f as Wn,g as Hn}from"./DataGrid-CbtTsx8d.js";import{D as jn}from"./DrillDownCell-BHLEJdwp.js";import{S as ut}from"./SearchInput-DBHWpJgW.js";import{u as wt,a as qn}from"./EpgEventDrawer-B9_gYZmG.js";import{C as Zn}from"./circle-CPRK1bie.js";import{S as Yn,_ as ve}from"./CollapsibleSection.vue_vue_type_style_index_0_lang-Cq2AVc9p.js";import{u as Qn,L as Jn,b as dt}from"./useEpgViewState-B4w344gx.js";import{f as ct,a as pt}from"./localDay-CoEbUe3O.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";/* empty css                                                                      */import"./ActionMenu-B3aKIJFu.js";import"./circle-dot-BCp4dfsV.js";import"./useResizableDrawerWidth-BORt6i7d.js";import"./sliders-horizontal-Am8f4Xsv.js";import"./dvrEntries-CyzR5N-9.js";const Xn={key:0},eo=["title"],to=["title"],no={class:"only-multiselect__row"},oo=["src"],lo={class:"only-multiselect__label"},ro=["onClick"],io=me({__name:"OnlyMultiSelect",props:{modelValue:{},options:{},placeholder:{default:""},ariaLabel:{},filter:{type:Boolean,default:!1},showToggleAll:{type:Boolean,default:!0},appendTo:{},onlyLabel:{}},emits:["update:modelValue","only"],setup(o,{emit:t}){const e=t,{t:r}=Le(),f=p(()=>o.onlyLabel??r("Only")),g=p(()=>{const m=new Map;for(const y of o.options)m.set(y.value,y.label);return m});function S(m){return m.map(y=>g.value.get(y)??String(y)).join(", ")}function L(m){return m.length===0?"":g.value.get(m[0])??String(m[0])}function M(m){if(o.options.length<2||m.length!==o.options.length)return!1;const y=new Set(m);for(const _ of o.options)if(!y.has(_.value))return!1;return!0}return(m,y)=>(v(),N(i(rn),{"model-value":o.modelValue,options:o.options,"option-value":"value","option-label":"label",placeholder:o.placeholder,"aria-label":o.ariaLabel,filter:o.filter,"show-toggle-all":o.showToggleAll,"append-to":o.appendTo,"onUpdate:modelValue":y[1]||(y[1]=_=>e("update:modelValue",_))},{value:A(_=>[!_.value||_.value.length===0?(v(),w("span",Xn,k(_.placeholder),1)):M(_.value)?(v(),w("span",{key:1,title:S(_.value)},k(i(r)("All")),9,eo)):(v(),w("span",{key:2,title:S(_.value)},[z(k(L(_.value)),1),_.value.length>1?(v(),w(P,{key:0},[z(" , +"+k(_.value.length-1)+" "+k(i(r)("more")),1)],64)):D("",!0)],8,to))]),option:A(_=>[C("span",no,[_.option.icon?(v(),w("img",{key:0,src:_.option.icon,class:"only-multiselect__icon",alt:""},null,8,oo)):D("",!0),C("span",lo,k(_.option.label),1),C("button",{type:"button",class:"only-multiselect__only",onClick:ke(q=>e("only",_.option.value),["stop"]),onMousedown:y[0]||(y[0]=ke(()=>{},["prevent","stop"]))},k(f.value),41,ro)])]),_:1},8,["model-value","options","placeholder","aria-label","filter","show-toggle-all","append-to"]))}}),Ct=he(io,[["__scopeId","data-v-9a0d33d5"]]);var ao=`
    .p-popover {
        margin-block-start: dt('popover.gutter');
        background: dt('popover.background');
        color: dt('popover.color');
        border: 1px solid dt('popover.border.color');
        border-radius: dt('popover.border.radius');
        box-shadow: dt('popover.shadow');
        will-change: transform;
    }

    .p-popover-content {
        padding: dt('popover.content.padding');
    }

    .p-popover-flipped {
        margin-block-start: calc(dt('popover.gutter') * -1);
        margin-block-end: dt('popover.gutter');
    }

    .p-popover:after,
    .p-popover:before {
        bottom: 100%;
        left: calc(dt('popover.arrow.offset') + dt('popover.arrow.left'));
        content: ' ';
        height: 0;
        width: 0;
        position: absolute;
        pointer-events: none;
    }

    .p-popover:after {
        border-width: calc(dt('popover.gutter') - 2px);
        margin-left: calc(-1 * (dt('popover.gutter') - 2px));
        border-style: solid;
        border-color: transparent;
        border-bottom-color: dt('popover.background');
    }

    .p-popover:before {
        border-width: dt('popover.gutter');
        margin-left: calc(-1 * dt('popover.gutter'));
        border-style: solid;
        border-color: transparent;
        border-bottom-color: dt('popover.border.color');
    }

    .p-popover-flipped:after,
    .p-popover-flipped:before {
        bottom: auto;
        top: 100%;
    }

    .p-popover.p-popover-flipped:after {
        border-bottom-color: transparent;
        border-top-color: dt('popover.background');
    }

    .p-popover.p-popover-flipped:before {
        border-bottom-color: transparent;
        border-top-color: dt('popover.border.color');
    }
`,so={root:"p-popover p-component",content:"p-popover-content"},uo=an.extend({name:"popover",style:ao,classes:so}),co={name:"BasePopover",extends:cn,props:{dismissable:{type:Boolean,default:!0},appendTo:{type:[String,Object],default:"body"},baseZIndex:{type:Number,default:0},autoZIndex:{type:Boolean,default:!0},breakpoints:{type:Object,default:null},closeOnEscape:{type:Boolean,default:!0}},style:uo,provide:function(){return{$pcPopover:this,$parentInstance:this}}},_t={name:"Popover",extends:co,inheritAttrs:!1,emits:["show","hide"],data:function(){return{visible:!1}},watch:{dismissable:{immediate:!0,handler:function(t){t?this.bindOutsideClickListener():this.unbindOutsideClickListener()}}},selfClick:!1,target:null,eventTarget:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,styleElement:null,overlayEventListener:null,documentKeydownListener:null,contentResizeObserver:null,beforeUnmount:function(){this.dismissable&&this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.destroyStyle(),this.unbindResizeListener(),this.unbindContentResizeListener(),this.target=null,this.container&&this.autoZIndex&&Ke.clear(this.container),this.overlayEventListener&&(_e.off("overlay-click",this.overlayEventListener),this.overlayEventListener=null),this.container=null},mounted:function(){this.breakpoints&&this.createStyle()},methods:{toggle:function(t,e){this.visible?this.hide():this.show(t,e)},show:function(t,e){this.visible=!0,this.eventTarget=t.currentTarget,this.target=e||t.currentTarget},hide:function(){this.visible=!1},onContentClick:function(){this.selfClick=!0},onEnter:function(t){var e=this;wn(t,{position:"absolute",top:"0"}),this.alignOverlay(),this.dismissable&&this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.autoZIndex&&Ke.set("overlay",t,this.baseZIndex||this.$primevue.config.zIndex.overlay),this.overlayEventListener=function(r){e.container.contains(r.target)&&(e.selfClick=!0)},this.bindContentResizeListener(),this.focus(),_e.on("overlay-click",this.overlayEventListener),this.$emit("show"),this.closeOnEscape&&this.bindDocumentKeyDownListener()},onLeave:function(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.unbindDocumentKeyDownListener(),this.unbindContentResizeListener(),_e.off("overlay-click",this.overlayEventListener),this.overlayEventListener=null,this.$emit("hide")},onAfterLeave:function(t){this.autoZIndex&&Ke.clear(t)},alignOverlay:function(){hn(this.container,this.target,!1);var t=lt(this.container),e=lt(this.target),r=0;t.left<e.left&&(r=e.left-t.left),this.container.style.setProperty(bn("popover.arrow.left").name,"".concat(r,"px")),t.top<e.top&&(this.container.setAttribute("data-p-popover-flipped","true"),!this.isUnstyled&&yn(this.container,"p-popover-flipped"))},onContentKeydown:function(t){t.code==="Escape"&&this.closeOnEscape&&(this.hide(),mn(this.target))},onButtonKeydown:function(t){switch(t.code){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":t.preventDefault()}},focus:function(){var t=this.container.querySelector("[autofocus]");t&&t.focus()},onKeyDown:function(t){t.code==="Escape"&&this.closeOnEscape&&(this.visible=!1)},bindDocumentKeyDownListener:function(){this.documentKeydownListener||(this.documentKeydownListener=this.onKeyDown.bind(this),window.document.addEventListener("keydown",this.documentKeydownListener))},unbindDocumentKeyDownListener:function(){this.documentKeydownListener&&(window.document.removeEventListener("keydown",this.documentKeydownListener),this.documentKeydownListener=null)},bindOutsideClickListener:function(){var t=this;!this.outsideClickListener&&gn()&&(this.outsideClickListener=function(e){t.visible&&!t.selfClick&&!t.isTargetClicked(e)&&(t.visible=!1),t.selfClick=!1},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener:function(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null,this.selfClick=!1)},bindScrollListener:function(){var t=this;this.scrollHandler||(this.scrollHandler=new vn(this.target,function(){t.visible&&(t.visible=!1)})),this.scrollHandler.bindScrollListener()},unbindScrollListener:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener:function(){var t=this;this.resizeListener||(this.resizeListener=function(){t.visible&&!fn()&&(t.visible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindContentResizeListener:function(){var t=this;this.contentResizeObserver||(this.contentResizeObserver=new ResizeObserver(function(){t.visible&&t.alignOverlay()}),this.contentResizeObserver.observe(this.container))},unbindContentResizeListener:function(){this.contentResizeObserver&&(this.contentResizeObserver.disconnect(),this.contentResizeObserver=null)},isTargetClicked:function(t){return this.eventTarget&&(this.eventTarget===t.target||this.eventTarget.contains(t.target))},containerRef:function(t){this.container=t},createStyle:function(){if(!this.styleElement&&!this.isUnstyled){var t;this.styleElement=document.createElement("style"),this.styleElement.type="text/css",pn(this.styleElement,"nonce",(t=this.$primevue)===null||t===void 0||(t=t.config)===null||t===void 0||(t=t.csp)===null||t===void 0?void 0:t.nonce),document.head.appendChild(this.styleElement);var e="";for(var r in this.breakpoints)e+=`
                        @media screen and (max-width: `.concat(r,`) {
                            .p-popover[`).concat(this.$attrSelector,`] {
                                width: `).concat(this.breakpoints[r],` !important;
                            }
                        }
                    `);this.styleElement.innerHTML=e}},destroyStyle:function(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},onOverlayClick:function(t){_e.emit("overlay-click",{originalEvent:t,target:this.target})}},directives:{focustrap:dn,ripple:un},components:{Portal:sn}},po=["aria-modal"];function fo(o,t,e,r,f,g){var S=Cn("Portal"),L=yt("focustrap");return v(),N(S,{appendTo:o.appendTo},{default:A(function(){return[E(_n,Be({name:"p-anchored-overlay",onEnter:g.onEnter,onLeave:g.onLeave,onAfterLeave:g.onAfterLeave},o.ptm("transition")),{default:A(function(){return[f.visible?ge((v(),w("div",Be({key:0,ref:g.containerRef,role:"dialog","aria-modal":f.visible,onClick:t[3]||(t[3]=function(){return g.onOverlayClick&&g.onOverlayClick.apply(g,arguments)}),class:o.cx("root")},o.ptmi("root")),[o.$slots.container?rt(o.$slots,"container",{key:0,closeCallback:g.hide,keydownCallback:function(m){return g.onButtonKeydown(m)}}):(v(),w("div",Be({key:1,class:o.cx("content"),onClick:t[0]||(t[0]=function(){return g.onContentClick&&g.onContentClick.apply(g,arguments)}),onMousedown:t[1]||(t[1]=function(){return g.onContentClick&&g.onContentClick.apply(g,arguments)}),onKeydown:t[2]||(t[2]=function(){return g.onContentKeydown&&g.onContentKeydown.apply(g,arguments)})},o.ptm("content")),[rt(o.$slots,"default")],16))],16,po)),[[L]]):D("",!0)]}),_:3},16,["onEnter","onLeave","onAfterLeave"])]}),_:3},8,["appendTo"])}_t.render=fo;const vo=["title","aria-label"],go=me({__name:"DvrStateCell",props:{value:{}},setup(o){const t=o,{t:e}=Le(),r=p(()=>{const g=typeof t.value=="string"?t.value:"";return g==="recordingError"?"recordingError":g.startsWith("recording")?"recording":g.startsWith("scheduled")?"scheduled":null}),f=p(()=>{switch(r.value){case"recording":return e("Recording");case"recordingError":return e("Recording (errors)");case"scheduled":return e("Scheduled for recording");default:return""}});return(g,S)=>r.value?(v(),w("span",{key:0,class:"dvr-state-cell",title:f.value,role:"img","aria-label":f.value},[r.value==="recording"?(v(),N(i(Zn),{key:0,size:10,fill:"currentColor",class:"dvr-state-cell__recording","aria-hidden":"true"})):r.value==="recordingError"?(v(),N(i(kn),{key:1,size:14,class:"dvr-state-cell__error","aria-hidden":"true"})):(v(),N(i(On),{key:2,size:14,class:"dvr-state-cell__scheduled","aria-hidden":"true"}))],8,vo)):D("",!0)}}),mo=he(go,[["__scopeId","data-v-914f982c"]]);function kt(){const o=wt();return o.ensure(),p(()=>{const t=[];for(const[e,r]of o.labels.entries())e&15||t.push({value:e,label:r});return t})}const ho={class:"epg-table-options"},bo={key:0,class:"epg-table-options__subheading"},yo={class:"epg-table-options__filter-row"},wo={class:"epg-table-options__filter-label epg-table-options__filter-label--global"},Co={class:"epg-table-options__filter-row"},_o={class:"epg-table-options__filter-label epg-table-options__filter-label--global"},ko={key:1,class:"epg-table-options__filter-row"},Oo={class:"epg-table-options__filter-label epg-table-options__filter-label--global"},Lo={class:"epg-table-options__filter-row"},So={class:"epg-table-options__filter-label epg-table-options__filter-label--global"},Mo={class:"epg-table-options__duration-range"},Fo=["placeholder","aria-label","value"],Eo=["placeholder","aria-label","value"],Do={class:"epg-table-options__duration-unit"},To=["aria-label"],xo={class:"epg-table-options__filter-row"},Ro={for:"epg-table-options-new-only",class:"epg-table-options__filter-label epg-table-options__filter-label--global"},No={class:"epg-table-options__subheading"},Ao={class:"epg-table-options__filter-label"},Vo=["title"],$o=["aria-label","onClick"],zo=["aria-checked","onClick"],Po={class:"settings-popover__radio","aria-hidden":"true"},Io={class:"grid-settings__sort-label"},Uo={key:0,class:"grid-settings__sort-dir","aria-hidden":"true"},Go={key:0,class:"settings-popover__note"},Ko=["aria-checked"],Bo={class:"settings-popover__radio","aria-hidden":"true"},Wo=["aria-checked","onClick"],Ho={class:"settings-popover__radio","aria-hidden":"true"},jo={class:"grid-settings__sort-label"},qo={key:0,class:"grid-settings__sort-dir","aria-hidden":"true"},Zo={key:0,class:"settings-popover__note"},Yo=["aria-checked","onClick"],Qo={class:"settings-popover__radio","aria-hidden":"true"},Jo=["checked","disabled"],Xo={class:"settings-popover__note"},el=["checked","onChange"],tl=me({__name:"EpgTableOptions",props:{options:{},defaults:{},toggleableColumns:{},groupableFields:{},sortableFields:{},sortField:{},sortOrder:{},perColumnFilters:{},perColumnLabels:{},tags:{}},emits:["update:options","update:sort-field","update:sort-order","clear-per-column"],setup(o,{emit:t}){const{t:e}=Le(),r=o,f=t,g=[{value:"bar",label:e("Bar")},{value:"pie",label:e("Pie")},{value:"off",label:e("Off")}],S=[{value:"all",label:e("All")},{value:"now",label:e("Now")},{value:"today",label:e("Today")},{value:"tomorrow",label:e("Tomorrow")}];function L(c){f("update:options",{...r.options,timeWindow:c})}const M=kt();function m(c){f("update:options",{...r.options,genre:c})}function y(c){f("update:options",{...r.options,newOnly:c})}function _(c){const s=c.trim()===""?null:Math.max(0,Math.floor(Number(c)));s!==null&&!Number.isFinite(s)||f("update:options",{...r.options,durationMinMinutes:s})}function q(c){const s=c.trim()===""?null:Math.max(0,Math.floor(Number(c)));s!==null&&!Number.isFinite(s)||f("update:options",{...r.options,durationMaxMinutes:s})}const H=p(()=>r.options.durationMinMinutes!==null||r.options.durationMaxMinutes!==null);function Z(){f("update:options",{...r.options,durationMinMinutes:null,durationMaxMinutes:null})}function te(c){f("update:options",{...r.options,tagFilter:c})}const Se=p(()=>[{value:null,label:e("Any")},...(r.tags??[]).map(c=>({value:c.uuid,label:c.name??c.uuid}))]);function Me(c){te({tag:c})}const Fe=p(()=>$n(r.options.tagFilter)),be=Ln();function I(c){f("update:options",{...r.options,progressDisplay:c})}function K(c){f("update:options",{...r.options,progressColoured:c})}function Y(c){const s=r.options.columnVisibility[c.field];return s!==void 0?s:!(c.hiddenByDefault??!1)}function Ee(c,s){f("update:options",{...r.options,columnVisibility:{...r.options.columnVisibility,[c]:s}})}const ne=p(()=>r.options.progressDisplay===r.defaults.progressDisplay&&r.options.progressColoured===r.defaults.progressColoured),ye=p(()=>g.find(s=>s.value===r.options.progressDisplay)?.label??""),O=p(()=>Object.keys(r.options.columnVisibility).length===0),De=p(()=>{const c=r.toggleableColumns.length,s=r.toggleableColumns.filter(u=>Y(u)).length;return e("{0} of {1}",s,c)}),Te=p(()=>(r.sortableFields?.length??0)>0&&r.options.groupField===null),oe=p(()=>r.sortField==="start"&&r.sortOrder===1),xe=p(()=>{if(!r.sortField)return e("Off");const s=(r.sortableFields??[]).find(R=>R.field===r.sortField)?.label??r.sortField,u=r.sortOrder===-1?"↓":"↑";return`${s} ${u}`});function Re(c){if(r.sortField===c){f("update:sort-order",r.sortOrder===-1?1:-1);return}f("update:sort-field",c),f("update:sort-order",1)}const we=p(()=>(r.groupableFields?.length??0)>0),Q=p(()=>!r.options.groupField),Ne=p(()=>{if(!r.options.groupField)return e("Off");const s=(r.groupableFields??[]).find(R=>R.field===r.options.groupField)?.label??r.options.groupField,u=r.options.groupOrder==="DESC"?"↓":"↑";return`${s} ${u}`});function le(c){if(c===null){f("update:options",{...r.options,groupField:null});return}if(r.options.groupField===c){f("update:options",{...r.options,groupOrder:r.options.groupOrder==="DESC"?"ASC":"DESC"});return}f("update:options",{...r.options,groupField:c})}const J=p(()=>{const c=r.perColumnFilters??{},s=r.perColumnLabels??{};return Object.entries(c).filter(([,u])=>typeof u=="string"&&u.length>0).map(([u,R])=>({field:u,label:s[u]??u,value:R}))}),re=p(()=>J.value.length>0),B=p(()=>{const c=r.options,s=r.defaults;let u=0;return c.timeWindow!==s.timeWindow&&u++,c.genre.length>0&&u++,c.newOnly&&u++,c.durationMinMinutes!==null&&u++,c.durationMaxMinutes!==null&&u++,Fe.value&&u++,u}),ie=p(()=>B.value===0&&!re.value),Ae=p(()=>S.find(s=>s.value===r.options.timeWindow)?.label??r.options.timeWindow),Ve=p(()=>{if(ie.value)return e("None");const c=J.value.length,s=[];r.options.timeWindow!==r.defaults.timeWindow&&s.push(Ae.value);const u=B.value-(r.options.timeWindow===r.defaults.timeWindow?0:1);return u>0&&s.push(e("{0} global",u)),c>0&&s.push(e("{0} columns",c)),s.join(" · ")}),$e=p(()=>ne.value&&O.value&&Q.value&&oe.value&&ie.value);function G(){f("update:options",{...r.options,tagFilter:{tag:r.defaults.tagFilter.tag},progressDisplay:r.defaults.progressDisplay,progressColoured:r.defaults.progressColoured,columnVisibility:{...r.defaults.columnVisibility},groupField:null,groupOrder:r.defaults.groupOrder,timeWindow:r.defaults.timeWindow,genre:r.defaults.genre,newOnly:r.defaults.newOnly,durationMinMinutes:r.defaults.durationMinMinutes,durationMaxMinutes:r.defaults.durationMaxMinutes}),f("update:sort-field","start"),f("update:sort-order",1)}return(c,s)=>(v(),w("div",ho,[E(Yn,{"defaults-active":$e.value,onReset:G},{default:A(()=>[E(ve,{id:"filters",title:i(e)("Filters"),"is-default":ie.value,summary:Ve.value},{default:A(()=>[re.value?(v(),w("p",bo,k(i(e)("Global")),1)):D("",!0),C("div",yo,[C("span",wo,k(i(e)("Time")),1),E(i(Oe),{"model-value":o.options.timeWindow,options:S,"option-value":"value","option-label":"label","aria-label":i(e)("Time window"),class:"epg-table-options__filter-select","onUpdate:modelValue":s[0]||(s[0]=u=>L(u))},null,8,["model-value","aria-label"])]),C("div",Co,[C("span",_o,k(i(e)("Content type")),1),E(Ct,{"model-value":o.options.genre,options:i(M),placeholder:i(e)("Any"),"aria-label":i(e)("Content type"),filter:!0,class:"epg-table-options__filter-select","onUpdate:modelValue":s[1]||(s[1]=u=>m(u)),onOnly:s[2]||(s[2]=u=>m([u]))},null,8,["model-value","options","placeholder","aria-label"])]),(o.tags?.length??0)>0?(v(),w("div",ko,[C("span",Oo,k(i(e)("Tag")),1),E(i(Oe),{"model-value":o.options.tagFilter.tag,options:Se.value,"option-label":"label","option-value":"value",placeholder:i(e)("Any"),"aria-label":i(e)("Channel tag"),class:"epg-table-options__filter-select","onUpdate:modelValue":s[3]||(s[3]=u=>Me(u))},null,8,["model-value","options","placeholder","aria-label"])])):D("",!0),C("div",Lo,[C("span",So,k(i(e)("Duration")),1),C("div",Mo,[C("input",{type:"number",min:"0",inputmode:"numeric",placeholder:i(e)("min"),"aria-label":i(e)("Minimum duration in minutes"),class:"epg-table-options__duration-input",value:o.options.durationMinMinutes??"",onChange:s[4]||(s[4]=u=>_(u.target.value))},null,40,Fo),s[9]||(s[9]=C("span",{class:"epg-table-options__duration-sep","aria-hidden":"true"},"–",-1)),C("input",{type:"number",min:"0",inputmode:"numeric",placeholder:i(e)("max"),"aria-label":i(e)("Maximum duration in minutes"),class:"epg-table-options__duration-input",value:o.options.durationMaxMinutes??"",onChange:s[5]||(s[5]=u=>q(u.target.value))},null,40,Eo),C("span",Do,k(i(e)("min")),1),H.value?(v(),w("button",{key:0,type:"button",class:"epg-table-options__filter-clear","aria-label":i(e)("Clear duration range"),onClick:Z},[E(i(Ze),{size:14,"stroke-width":2})],8,To)):D("",!0)])]),C("div",xo,[C("label",Ro,k(i(e)("New only")),1),E(i(Sn),{"input-id":"epg-table-options-new-only","model-value":o.options.newOnly,binary:"","aria-label":i(e)("New only"),"onUpdate:modelValue":s[6]||(s[6]=u=>y(u))},null,8,["model-value","aria-label"])]),re.value?(v(),w(P,{key:2},[C("p",No,k(i(e)("Per column")),1),(v(!0),w(P,null,ce(J.value,u=>(v(),w("div",{key:u.field,class:"epg-table-options__filter-row"},[C("span",Ao,k(u.label),1),C("span",{class:"epg-table-options__filter-value",title:u.value},k(u.value),9,Vo),C("button",{type:"button",class:"epg-table-options__filter-clear","aria-label":i(e)("Clear {0} filter",u.label),onClick:R=>f("clear-per-column",u.field)},[E(i(Ze),{size:14,"stroke-width":2})],8,$o)]))),128))],64)):D("",!0)]),_:1},8,["title","is-default","summary"]),Te.value?(v(),N(ve,{key:0,id:"sort",title:i(e)("Sort by"),"is-default":oe.value,summary:xe.value},{default:A(()=>[(v(!0),w(P,null,ce(o.sortableFields,u=>(v(),w("button",{key:u.field,type:"button",class:pe(["settings-popover__option grid-settings__sort-row",{"settings-popover__option--active":o.sortField===u.field}]),role:"menuitemradio","aria-checked":o.sortField===u.field,onClick:R=>Re(u.field)},[C("span",Po,k(o.sortField===u.field?"●":"○"),1),C("span",Io,k(u.label),1),o.sortField===u.field?(v(),w("span",Uo,[o.sortOrder===-1?(v(),N(i(Ye),{key:0,size:14,"stroke-width":2})):(v(),N(i(Qe),{key:1,size:14,"stroke-width":2}))])):D("",!0)],10,zo))),128)),o.sortField?(v(),w("p",Go,k(i(e)("Click the active row to flip direction.")),1)):D("",!0)]),_:1},8,["title","is-default","summary"])):D("",!0),we.value?(v(),N(ve,{key:1,id:"group",title:i(e)("Group by"),"is-default":Q.value,summary:Ne.value},{default:A(()=>[C("button",{type:"button",class:pe(["settings-popover__option",{"settings-popover__option--active":!o.options.groupField}]),role:"menuitemradio","aria-checked":!o.options.groupField,onClick:s[7]||(s[7]=u=>le(null))},[C("span",Bo,k(o.options.groupField?"○":"●"),1),z(" "+k(i(e)("Off")),1)],10,Ko),(v(!0),w(P,null,ce(o.groupableFields,u=>(v(),w("button",{key:u.field,type:"button",class:pe(["settings-popover__option grid-settings__sort-row",{"settings-popover__option--active":o.options.groupField===u.field}]),role:"menuitemradio","aria-checked":o.options.groupField===u.field,onClick:R=>le(u.field)},[C("span",Ho,k(o.options.groupField===u.field?"●":"○"),1),C("span",jo,k(u.label),1),o.options.groupField===u.field?(v(),w("span",qo,[o.options.groupOrder==="DESC"?(v(),N(i(Ye),{key:0,size:14,"stroke-width":2})):(v(),N(i(Qe),{key:1,size:14,"stroke-width":2}))])):D("",!0)],10,Wo))),128)),o.options.groupField?(v(),w("p",Zo,k(i(e)("Click the active row to flip cluster direction.")),1)):D("",!0)]),_:1},8,["title","is-default","summary"])):D("",!0),i(be)?D("",!0):(v(),N(ve,{key:2,id:"progress",title:i(e)("Progress display"),"is-default":ne.value,summary:ye.value},{default:A(()=>[(v(),w(P,null,ce(g,u=>C("button",{key:u.value,type:"button",class:pe(["settings-popover__option",{"settings-popover__option--active":o.options.progressDisplay===u.value}]),role:"menuitemradio","aria-checked":o.options.progressDisplay===u.value,onClick:R=>I(u.value)},[C("span",Qo,k(o.options.progressDisplay===u.value?"●":"○"),1),z(" "+k(u.label),1)],10,Yo)),64)),C("label",{class:pe(["settings-popover__option",{"settings-popover__option--disabled":o.options.progressDisplay==="off"}])},[C("input",{type:"checkbox",class:"settings-popover__checkbox",checked:o.options.progressColoured,disabled:o.options.progressDisplay==="off",onChange:s[8]||(s[8]=u=>K(u.target.checked))},null,40,Jo),z(" "+k(i(e)("Colour by elapsed time")),1)],2),C("p",Xo,k(i(e)("Off → single brand colour. On → green → amber → red as the event progresses.")),1)]),_:1},8,["title","is-default","summary"])),i(be)?D("",!0):(v(),N(ve,{key:3,id:"columns",title:i(e)("Columns"),"is-default":O.value,summary:De.value},{default:A(()=>[(v(!0),w(P,null,ce(o.toggleableColumns,u=>(v(),w("label",{key:u.field,class:"settings-popover__option"},[C("input",{type:"checkbox",class:"settings-popover__checkbox",checked:Y(u),onChange:R=>Ee(u.field,R.target.checked)},null,40,el),z(" "+k(u.label??u.field),1)]))),128))]),_:1},8,["title","is-default","summary"]))]),_:1},8,["defaults-active"])]))}}),nl=he(tl,[["__scopeId","data-v-0ea7832e"]]),ol={key:0,class:"progress-cell progress-cell--pie"},ll=["title"],rl={key:1,class:"progress-cell"},il=me({__name:"ProgressCell",props:{row:{}},setup(o){const t=o,e=it("epg-now",{value:Math.floor(Date.now()/1e3)}),f=it("epg-progress-options",{value:{display:"bar",coloured:!1}}),g=p(()=>{const m=t.row.start,y=t.row.stop;if(typeof m!="number"||typeof y!="number")return null;const _=y-m;return _<=0||e.value<m||e.value>=y?null:Math.max(0,Math.min(100,(e.value-m)/_*100))});function S(m,y){return y?m<33?"var(--tvh-success)":m<66?"var(--tvh-warning)":"var(--tvh-error)":"var(--tvh-accent, #3b82f6)"}const L=p(()=>g.value===null?"":S(g.value,f.value.coloured)),M=p(()=>{if(g.value===null)return"";const m=g.value*3.6;return`conic-gradient(${L.value} 0deg ${m}deg, var(--tvh-border) ${m}deg 360deg)`});return(m,y)=>g.value!==null?(v(),w(P,{key:0},[i(f).display==="pie"?(v(),w("div",ol,[C("div",{class:"progress-cell__pie",style:at({background:M.value}),title:`${Math.round(g.value)}% elapsed`},null,12,ll)])):(v(),w("div",rl,[C("div",{class:"progress-cell__bar",style:at({width:g.value+"%",background:L.value})},null,4)]))],64)):D("",!0)}}),al=he(il,[["__scopeId","data-v-7139d67d"]]);function sl(o,t,e){return o==null&&t==null?0:o==null?-e:t==null?e:typeof o=="number"&&typeof t=="number"?(o-t)*e:String(o).localeCompare(String(t))*e}function ul(o,t,e,r){return t?t==="start"&&e===1?{rows:o,mutated:!1}:{rows:[...o].sort((g,S)=>{const L=g[t],M=S[t];return r?r(L,M)*e:sl(L,M,e)}),mutated:!0}:{rows:o,mutated:!1}}function ft(o){const t=String(o),e=t.indexOf("."),r=Number(e<0?t:t.slice(0,e)),f=e<0?0:Number(t.slice(e+1));return[Number.isFinite(r)?r:Number.POSITIVE_INFINITY,Number.isFinite(f)?f:0]}function dl(o,t){if(o==null&&t==null)return 0;if(o==null)return-1;if(t==null)return 1;const[e,r]=ft(o),[f,g]=ft(t);return e!==f?e-f:r-g}function cl(){return{entries:new Map,generation:0}}function pl(o,t){const e=o.entries.get(t);if(e?.loading)return null;const r=e?{...e,loading:!0,error:null}:{loadedCount:0,totalCount:0,loading:!0,error:null},f=new Map(o.entries);return f.set(t,r),{state:{entries:f,generation:o.generation},generation:o.generation}}function fl(o,t,e,r,f){if(e!==o.generation)return o;const g=o.entries.get(t);if(!g)return o;const S={loadedCount:g.loadedCount+r,totalCount:f,loading:!1,error:null},L=new Map(o.entries);return L.set(t,S),{entries:L,generation:o.generation}}function vt(o,t,e,r){if(e!==o.generation)return o;const f=o.entries.get(t);if(!f)return o;const g=new Map(o.entries);return g.set(t,{...f,loading:!1,error:r}),{entries:g,generation:o.generation}}function gt(o){return{entries:new Map,generation:o.generation+1}}function vl(o,t){return o.entries.get(t)?.loading===!0}function je(o,t){const e=o.entries.get(t);return e!==void 0&&!e.loading}function qe(o,t){const e=o.entries.get(t);return e!==void 0&&!e.loading&&e.totalCount===0}function gl(o,t){const e=o.entries.get(t);return e!==void 0&&!e.loading&&e.loadedCount<e.totalCount}function ml(o,t){const e=o.entries.get(t);return e===void 0?!1:e.loadedCount>0||!e.loading}function mt(o,t){return o.entries.get(t)?.loadedCount??0}function hl(o,t,e,r,f,g){const S=o.filter(M=>{const m=He(M,r);return m===null?!1:ml(e,m)});S.sort((M,m)=>{const y=He(M,r)??"",_=He(m,r)??"";return y<_?-1:y>_?1:0});const L=[];for(const[M,m]of e.entries)if(!m.loading&&!(m.loadedCount>=m.totalCount))if(r==="channelName")L.push(f.channel(M,-3e5-L.length));else{const y=M.split("-").map(Number);if(y.length!==3||y.some(te=>!Number.isFinite(te)))continue;const[_,q,H]=y,Z=Math.floor(new Date(_,q-1,H).getTime()/1e3);L.push(f.date(M,Z,-4e5-L.length))}return[...S,...t,...L]}function bl(o){let t=null,e=!1;const r=new Map,f=new Map;function g(m){for(const y of m){if(!y.isIntersecting)continue;const _=r.get(y.target);_!==void 0&&o(_)}}function S(m){e||t===null&&(t=new IntersectionObserver(g,{root:m,rootMargin:"1000px 0px",threshold:0}))}function L(m,y){if(e)return;t===null&&S(null);const _=f.get(m);_&&_!==y&&(t?.unobserve(_),r.delete(_),f.delete(m)),y!==null&&(r.has(y)||(r.set(y,m),f.set(m,y),t?.observe(y)))}function M(){if(e=!0,t===null){r.clear(),f.clear();return}t.disconnect(),t=null,r.clear(),f.clear()}return{ensureObserver:S,bind:L,destroy:M}}const yl={class:"table-view"},wl={key:0,class:"epg-table-grid__loading-chip"},Cl={key:0,class:"data-grid__group-suffix"},_l=["aria-label"],kl=["aria-label"],Ol={class:"epg-table-grid__empty"},Ll=["value","placeholder","aria-label","onInput","onKeydown"],Sl=["aria-label"],Ml={class:"epg-table-grid__search-popover-body"},Fl=["aria-label","disabled"],El=["aria-label","aria-pressed"],ht=1440*60,bt=100,Dl=!1,Tl=5,xl=me({__name:"TableView",setup(o){const{t}=Le(),e=Qn({tableLazyPaging:!0,getInitialLoadParams:()=>G()});e.saveLastView("table");const r=Mn(),f=(n,l)=>l.channelName??"",g=wt();g.ensure();const S=n=>!Array.isArray(n)||n.length===0?"":n.map(l=>typeof l=="number"?g.labels.get(l)??`0x${l.toString(16)}`:String(l)).join(", "),L=kt();function M(n){e.setViewOptions({...e.viewOptions.value,genre:[...n].sort((l,d)=>l-d)})}const m=(n,l)=>{const d=l;if(typeof d.start!="number"||typeof d.stop!="number")return"";const a=d.stop-d.start;if(a<=0)return"";const h=Math.floor(a/3600),b=Math.floor(a%3600/60);return h===0?`${b}m`:b===0?`${h}h`:`${h}h ${b}m`},y=n=>typeof n!="number"||n===0?"":String(n),{now:_}=Fn();fe("epg-now",_);const q=p(()=>({display:e.viewOptions.value.progressDisplay,coloured:e.viewOptions.value.progressColoured}));fe("epg-progress-options",q);const H=[{field:"dvrState",label:t("Recording"),hideHeaderLabel:!0,sortable:!1,minVisible:"desktop",width:44,cellComponent:mo},{field:"channelName",label:t("Channel"),sortable:!0,filterType:"string",minVisible:"phone",width:180,format:f,cellComponent:jn,targetUuidField:"channelUuid",targetAccessKey:"admin"},{field:"channelNumber",label:"#",sortable:!0,sortComparator:dl,minVisible:"desktop",width:60},{field:"progress",label:t("Progress"),sortable:!1,minVisible:"desktop",width:50,cellComponent:al},{field:"title",label:t("Title"),sortable:!0,filterType:"string",minVisible:"phone",phoneRole:"primary",width:260,cellComponent:zn},{field:"episodeOnscreen",label:t("Episode"),sortable:!0,minVisible:"desktop",hiddenByDefault:!0,width:180},{field:"genre",label:t("Content type"),sortable:!1,filterType:"genre",minVisible:"desktop",width:140,format:S},{field:"start",label:t("Start"),sortable:!0,minVisible:"phone",width:170,format:ct},{field:"stop",label:t("End"),sortable:!0,minVisible:"phone",phoneOrder:4,width:170,format:ct},{field:"duration",label:t("Duration"),sortable:!1,minVisible:"phone",phoneOrder:3,width:100,format:m},{field:"starRating",label:t("Stars"),sortable:!0,minVisible:"desktop",hiddenByDefault:!0,width:80,format:y},{field:"ratingLabel",label:t("Rating"),sortable:!0,minVisible:"desktop",hiddenByDefault:!0,width:100},{field:"ageRating",label:t("Age"),sortable:!0,minVisible:"desktop",hiddenByDefault:!0,width:70,format:y}],Z=p(()=>e.viewOptions.value.progressDisplay==="off"?H.filter(n=>n.field!=="progress"):H),te=new Set(["title","channelName"]),Se=new Set(["dvrState","channelNumber","start","stop","duration","genre","episodeOnscreen","starRating","ratingLabel","ageRating"]);function Me(n){if(te.has(n.field))return!0;const l=e.viewOptions.value.columnVisibility[n.field];return l!==void 0?l:!(n.hiddenByDefault??!1)}const Fe=p(()=>Z.value.filter(Me)),be=p(()=>Z.value.filter(n=>Se.has(n.field))),I=U("start"),K=U(1),Y=[{field:"channelName",label:t("Channel")},{field:"start",label:t("Date"),groupKey:n=>pt(n.start)}],Ee=[{field:"start",label:t("Start")},{field:"channelName",label:t("Channel")},{field:"title",label:t("Title")},{field:"duration",label:t("Duration")}];function ne(n){e.viewOptions.value.groupField===null&&(I.value=typeof n.sortField=="string"?n.sortField:null,K.value=n.sortOrder===-1?-1:1,c())}function ye(n,l){e.viewOptions.value.groupField===null&&(l===null?I.value=null:(I.value=n,K.value=l==="asc"?1:-1),c())}const O=U(cl()),De={channel:(n,l)=>({__loadMore:!0,eventId:l,channelName:n}),date:(n,l,d)=>({__loadMore:!0,eventId:d,start:l})},Te=p(()=>{for(const n of O.value.entries.values())if(n.loading)return!0;return!1}),oe=p(()=>{for(const[n,l]of O.value.entries)if(l.loading)return n;return""}),xe=p(()=>{const n=new Map;if(V.value!==null)return n;for(const[l,d]of O.value.entries)n.set(l,d.totalCount);return n});function Re(n){return n.__loadMore===!0}ee(()=>e.viewOptions.value.groupField,()=>{O.value=gt(O.value)});const we=p(()=>{const n=e.viewOptions.value.groupField;if(n===null)return[];if(n==="channelName"){const l=s.value.perColumn.channelName;let d=()=>!0;if(typeof l=="string"&&l.length>0)try{const a=new RegExp(l,"i");d=h=>a.test(h)}catch{}return e.filteredChannels.value.filter(a=>{const h=a.name??"";return!h||je(O.value,h)&&!qe(O.value,h)?!1:d(h)}).map(a=>({__stub:!0,__empty:qe(O.value,a.name??""),eventId:-1e5-(a.number??0),channelName:a.name,channelUuid:a.uuid,channelNumber:a.number}))}if(n==="start"){const l=[],d=e.trackStart.value,a=e.trackEnd.value,h=86400;for(let b=d;b<a;b+=h){const T=pt(b),F=qe(O.value,T);je(O.value,T)&&!F||l.push({__stub:!0,__empty:F,eventId:-2e5-Math.floor(b/h),start:b})}return l}return[]});async function Q(n,l){const d=e.viewOptions.value.groupField;if(d!=="channelName"&&d!=="start")return;const a=pl(O.value,n);if(a===null)return;O.value=a.state;const h=a.generation;try{const{filter:b,params:T}=G(),F=Kn(d,n,b);if(!F.ok){O.value=vt(O.value,n,h,new Error(F.error));return}const $=await We("epg/events/grid",{start:l,limit:bt,sort:"start",dir:"ASC",...T,filter:JSON.stringify(F.filter)}),x=$.entries??[];e.events.value=dt(e.events.value,x);const Ge=x.length<bt,nn=mt(O.value,n)+x.length,on=$.totalCount??x.length,ln=Ge?nn:on;O.value=fl(O.value,n,h,x.length,ln)}catch(b){const T=b instanceof Error?b:new Error(String(b));O.value=vt(O.value,n,h,T),Pe.error(`${t("Failed to load events for {0}",n)}: ${T.message}`)}}async function Ne(n){if(!gl(O.value,n))return;const l=mt(O.value,n);await Q(n,l)}const le=bl(n=>{Ne(n).catch(()=>{})});fe("cluster-paging-bind",le.bind);const J=p(()=>{const n=e.viewOptions.value.groupField;return n==="channelName"||n==="start"?n:null});fe("cluster-paging-group-field",J);const re=p(()=>e.viewOptions.value.tooltipMode);fe("epg-tooltip-mode",re),st(()=>{le.destroy()});const B=U(new Set);function ie(n){if(typeof n!="string")return;const l=new Set(B.value);l.add(n),B.value=l,!je(O.value,n)&&!vl(O.value,n)&&Q(n,0).catch(()=>{})}function Ae(n){if(typeof n!="string")return;const l=new Set(B.value);l.delete(n),B.value=l}function Ve(){if(e.events.value=[],O.value=gt(O.value),e.viewOptions.value.groupField===null)return;const{filter:l,params:d}=G();e.refreshMatchedCount(l,d);for(const a of B.value)Q(a,0).catch(()=>{})}function $e(){const n=new Date;return n.setHours(24,0,0,0),Math.floor(n.getTime()/1e3)}function G(){const n=e.viewOptions.value;return Un({perColumn:s.value.perColumn,timeWindow:n.timeWindow,genre:n.genre,newOnly:n.newOnly,durationMinMinutes:n.durationMinMinutes,durationMaxMinutes:n.durationMaxMinutes,tagFilter:n.tagFilter,now:Math.floor(Date.now()/1e3),endOfToday:$e()})}function c(){if(e.viewOptions.value.groupField!==null||V.value!==null)return;const{filter:n,params:l}=G();e.loadPage({offset:0,limit:100,sort:I.value??"start",dir:K.value===-1?"DESC":"ASC",filter:n,extraParams:l,append:!1})}const s=U({perColumn:{}}),u=En();function R(n,l){const d=n==="channelName"?"title":"channelName",a={...s.value.perColumn,[n]:l};delete a[d],s.value={...s.value,perColumn:a},e.viewOptions.value.tagFilter.tag!==null&&e.setViewOptions({...e.viewOptions.value,tagFilter:{tag:null}})}ee(()=>u.query.channelName,n=>{typeof n!="string"||n.length===0||R("channelName",n)}),ee(()=>u.query.title,n=>{typeof n!="string"||n.length===0||R("title",n)}),Dn(()=>{const n=u.query.channelName;typeof n=="string"&&n.length>0&&R("channelName",n);const l=u.query.title;typeof l=="string"&&l.length>0&&R("title",l)});const Ot=p(()=>({channelName:{value:s.value.perColumn.channelName??null,matchMode:"contains"},title:{value:s.value.perColumn.title??null,matchMode:"contains"},episodeOnscreen:{value:s.value.perColumn.episodeOnscreen??null,matchMode:"contains"},genre:{value:e.viewOptions.value.genre.length?e.viewOptions.value.genre:null,matchMode:"in"}}));function Lt(n){const l={};for(const[F,$]of Object.entries(n.filters)){if(!$||typeof $!="object")continue;const x=$.value;typeof x=="string"&&x&&(F==="channelName"||F==="title"||F==="episodeOnscreen")&&(l[F]=x)}s.value={...s.value,perColumn:l};const a=n.filters.genre?.value,b=[...Array.isArray(a)?a:[]].sort((F,$)=>F-$),T=[...e.viewOptions.value.genre].sort((F,$)=>F-$);b.join(",")!==T.join(",")&&M(b)}const St=p(()=>({title:t("Title"),channelName:t("Channel"),episodeOnscreen:t("Episode")}));function Mt(n){if(!(n in s.value.perColumn))return;const l={...s.value.perColumn};delete l[n],s.value={...s.value,perColumn:l}}function Ft(){const n=s.value.perColumn.title??"",l=Wn({hasTitle:n.length>0,isGrouped:e.viewOptions.value.groupField!==null,queryResultsActive:V.value!==null});switch(l.clearQueryResults&&(V.value=null,ae.value=null,X.value=!1),l.action){case"fire-title-query":Et(n).catch(()=>{});return;case"invalidate-grouped":Ve();return;case"refetch-flat":c();return}}if(ee(()=>e.viewOptions.value.groupField,(n,l)=>{if(B.value=new Set,n!==null&&l===null){const{filter:d,params:a}=G();e.refreshMatchedCount(d,a)}else n===null&&l!==null&&c()}),e.viewOptions.value.groupField!==null){const{filter:n,params:l}=G();e.refreshMatchedCount(n,l)}const V=U(null),X=U(!1),ae=U(null);let se=0;const W=p({get:()=>e.viewOptions.value.titleSearchMode,set:n=>e.setViewOptions({...e.viewOptions.value,titleSearchMode:n})}),Je=p(()=>[{value:"title",label:t("Title only")},{value:"fulltext",label:t("Full text")},{value:"mergetext",label:t("Merged text")}]);async function Et(n){if(!n){V.value=null,ae.value=null,X.value=!1;return}se+=1;const l=se;X.value=!0,ae.value=null;try{const d=G(),a=Hn(d,n,W.value),h=await We("epg/events/grid",a);if(l!==se)return;const b=h.entries??[];V.value=b,e.events.value=dt(e.events.value,b)}catch(d){if(l!==se)return;ae.value=d instanceof Error?d:new Error(String(d)),V.value=[]}finally{l===se&&(X.value=!1)}}ee(()=>[s.value.perColumn.title,s.value.perColumn.channelName,W.value,e.viewOptions.value.timeWindow,e.viewOptions.value.genre,e.viewOptions.value.newOnly,e.viewOptions.value.durationMinMinutes,e.viewOptions.value.durationMaxMinutes,e.viewOptions.value.tagFilter.tag],()=>{Ft()});const Xe=U(null);function Dt(n){Xe.value?.toggle(n)}const j=U("");let ue;function et(){ue!==void 0&&globalThis.clearTimeout(ue),ue=globalThis.setTimeout(()=>{const n=j.value.trim(),l={...s.value.perColumn};n?l.title=n:delete l.title,s.value={...s.value,perColumn:l}},300)}ee(()=>s.value.perColumn.title,(n="")=>{n!==j.value&&(j.value=n)}),st(()=>{ue!==void 0&&globalThis.clearTimeout(ue)});const Tt=p(()=>I.value??void 0);function xt(n,l,d){if(!d||l)return n;const a=J.value;return a===null?[...n,...we.value]:hl(n,we.value,O.value,a,De)}function Rt(n,l,d){const a=n;if(a.__loadMore||a.__stub&&l!=="channelName")return!0;const h=n[l];return typeof h=="string"&&h.toLowerCase().includes(d)}function Nt(n,l,d){let a=n,h=!1;for(const[b,T]of Object.entries(l)){if(!T||d&&b==="title")continue;const F=T.toLowerCase();a=a.filter($=>Rt($,b,F)),h=!0}return{rows:a,mutated:h}}const de=p(()=>{const n=V.value!==null,l=e.viewOptions.value.groupField!==null,d=n?V.value:e.events.value,a=xt(d,n,l),h=Nt(a,s.value.perColumn,n),b=H.find(F=>F.field===I.value)?.sortComparator,T=ul(h.rows,I.value,K.value,b);return!h.mutated&&!T.mutated?a:T.rows});function At(){const n=e.trackStart.value,l=e.trackEnd.value;for(let d=n;d<l;d+=ht)if(!e.loadedDays.value.has(d)&&!e.loadingDays.value.has(d))return d;return null}const Vt=p(()=>{const n=e.trackStart.value,l=e.trackEnd.value;for(let d=n;d<l;d+=ht)if(!e.loadedDays.value.has(d)&&!e.loadingDays.value.has(d))return!1;return!0}),$t=Math.floor(100/2);function zt(n){if(V.value!==null||de.value.length===0)return;if(e.viewOptions.value.groupField===null){if(e.loadingMorePage.value||!e.hasMorePages.value)return;const d=e.events.value.length-$t;if(n.last<d)return;const{filter:a,params:h}=G();e.loadPage({offset:e.events.value.length,limit:100,sort:I.value??"start",dir:K.value===-1?"DESC":"ASC",filter:a,extraParams:h,append:!0});return}if(e.loadingDays.value.size>0||n.last<de.value.length-Tl||Vt.value)return;const l=At();l!==null&&e.ensureDaysLoaded([l])}const Pt=p(()=>de.value.length>0?{itemSize:36,lazy:!1,onScrollIndexChange:zt}:void 0),It=p(()=>e.selectedEvent.value);function Ut(n){if(n.__stub)return;const l=n.eventId;typeof l=="number"&&e.toggleDrawer({eventId:l})}function Gt(){e.closeDrawer()}const Kt=p(()=>Object.keys(s.value.perColumn).length>0),Bt=p(()=>e.loading.value||X.value),Wt=p(()=>ae.value??e.error.value),Ht=p(()=>de.value),ze=p(()=>V.value!==null?V.value.length:e.eventsTotalCount.value),jt=p(()=>de.value.filter(n=>!n.__stub).length),qt=p(()=>V.value===null?ze.value:jt.value),tt=p(()=>{const n=e.viewOptions.value.groupField;return n===null?null:Y.find(l=>l.field===n)??null}),nt=Vn();function Zt(){nt.toggle("epg").catch(()=>{})}const Yt=Tn(),Pe=xn(),Ce=U(!1),ot=p(()=>!!r.data?.dvr);function Qt(){const n=e.viewOptions.value;return{title:s.value.perColumn.title??"",channelName:s.value.perColumn.channelName??"",mode:W.value,newOnly:n.newOnly,genre:n.genre,durationMinMinutes:n.durationMinMinutes,durationMaxMinutes:n.durationMaxMinutes,tagUuid:n.tagFilter.tag,commentSuffix:t("Created from EPG query")}}const Ie=p(()=>Bn(Qt())),Ue=p(()=>e.viewOptions.value.genre.length>=2);function Jt(n){return n==="fulltext"?t("full text"):n==="mergetext"?t("merged text"):""}function Xt(n,l){return n!==null&&l!==null?t("{0} – {1} min",n,l):n!==null?t("≥ {0} min",n):l!==null?t("≤ {0} min",l):t("Don't care")}function en(n){const l=t("Don't care"),d=Jt(n.mode),a=n.title&&d?` (${d})`:"";let h=l;n.tagName&&(h=n.tagName);let b=l;return n.genreLabel?b=n.genreLabel:n.genreMultiActive&&(b=t("Active filter can't be saved (multi-genre rules not supported by server)")),t("This will create an automatic rule that continuously scans the EPG for programs to record that match this query:")+`

${t("Title")}: ${n.title||l}${a}
${t("Channel")}: ${n.channelName||l}
${t("Content type")}: ${b}
${t("Duration")}: ${Xt(n.durationMinMinutes,n.durationMaxMinutes)}
${t("New only")}: ${n.newOnly?t("Yes"):t("No")}
${t("Channel tag")}: ${h}

`+t("Currently this will match (and record) {0} events.",n.matchCount)+" "+t("Are you sure?")}async function tn(){if(Ce.value||!ot.value||!Ie.value||Ue.value)return;const n=s.value.perColumn.title??"",l=s.value.perColumn.channelName??"",d=W.value,a=e.viewOptions.value,h=a.genre.length===1?g.labels.get(a.genre[0])??`0x${a.genre[0].toString(16)}`:null,b=a.tagFilter.tag,T=b===null?null:e.tags.value.find(x=>x.uuid===b)?.name??b,F=en({title:n,channelName:l,mode:d,newOnly:a.newOnly,genreLabel:h,durationMinMinutes:a.durationMinMinutes,durationMaxMinutes:a.durationMaxMinutes,tagName:T,genreMultiActive:a.genre.length>=2,matchCount:ze.value});if(await Yt.ask(F,{acceptLabel:t("Create"),rejectLabel:t("Cancel")})){Ce.value=!0;try{const x=Gn({title:n,channelName:l,mode:d,newOnly:a.newOnly,genre:a.genre,durationMinMinutes:a.durationMinMinutes,durationMaxMinutes:a.durationMaxMinutes,tagUuid:a.tagFilter.tag,commentSuffix:t("Created from EPG query")});await We("dvr/autorec/create",{conf:JSON.stringify(x)}),Pe.success(t("AutoRec rule created"))}catch(x){const Ge=x instanceof Error?x.message:String(x);Pe.error(`${t("Failed to create AutoRec rule")}: ${Ge}`)}finally{Ce.value=!1}}}return(n,l)=>{const d=yt("tooltip");return v(),w("section",yl,[E(In,{"bem-prefix":"epg-table",entries:Ht.value,total:ze.value,loading:Bt.value,error:Wt.value,columns:Fe.value,"key-field":"eventId",selectable:!1,"virtual-scroller-options":Pt.value,"sort-field":Tt.value,"sort-order":K.value,filters:Ot.value,"filter-display":"menu",lazy:!0,"column-actions":{sort:!0,filter:!0},"group-field":i(e).viewOptions.value.groupField,"group-order":i(e).viewOptions.value.groupOrder,"groupable-fields":Y,"sort-locked-by-group":!0,"cluster-totals":xe.value,"is-load-more-row":Re,"enable-grouped-virtual-scroll":Dl,class:"epg-table-grid table-view__grid",onSort:ne,onSetSort:ye,onFilter:Lt,onRowClick:Ut,"onUpdate:groupField":l[8]||(l[8]=a=>i(e).setViewOptions({...i(e).viewOptions.value,groupField:a})),"onUpdate:groupOrder":l[9]||(l[9]=a=>i(e).setViewOptions({...i(e).viewOptions.value,groupOrder:a})),onRowgroupExpand:ie,onRowgroupCollapse:Ae},{listSummary:A(()=>[Te.value?(v(),w("span",wl,k(oe.value?i(t)("Loading {0}…",oe.value):i(t)("Loading…")),1)):(v(),w(P,{key:1},[z(k(i(Pn)({entries:qt.value,total:void 0,selected:0,allVisibleSelected:!1})),1),tt.value?(v(),w("span",Cl,[z(k(i(t)(", grouped by {0}",tt.value.label)),1),C("button",{type:"button",class:"data-grid__group-arrow","aria-label":i(e).viewOptions.value.groupOrder==="DESC"?i(t)("Switch to ascending cluster order"):i(t)("Switch to descending cluster order"),onClick:l[0]||(l[0]=ke(a=>i(e).setViewOptions({...i(e).viewOptions.value,groupOrder:i(e).viewOptions.value.groupOrder==="DESC"?"ASC":"DESC"}),["stop"]))},[i(e).viewOptions.value.groupOrder==="DESC"?(v(),N(i(Ye),{key:0,size:14,"stroke-width":2})):(v(),N(i(Qe),{key:1,size:14,"stroke-width":2}))],8,_l),C("button",{type:"button",class:"data-grid__group-clear","aria-label":i(t)("Ungroup"),onClick:l[1]||(l[1]=ke(a=>i(e).setViewOptions({...i(e).viewOptions.value,groupField:null}),["stop"]))},[E(i(Ze),{size:12,"stroke-width":2})],8,kl)])):D("",!0)],64))]),empty:A(()=>[C("p",Ol,[X.value?(v(),w(P,{key:0},[z(" Searching the EPG… ")],64)):Kt.value?(v(),w(P,{key:1},[z(" No events match the current filter. ")],64)):i(e).loading.value?(v(),w(P,{key:2},[z(" Loading events… ")],64)):(v(),w(P,{key:3},[z(" No EPG events available. Make sure your network's EPG grabbers are configured and have run at least once. ")],64))])]),columnFilter:A(({col:a,filterProps:h})=>[a.filterType==="string"?(v(),w("input",{key:0,type:"text",class:"epg-table-grid__col-filter-input",value:h.filterModel.value??"",placeholder:i(t)("Filter {0}",a.label??a.field),"aria-label":i(t)("Filter {0}",a.label??a.field),onInput:b=>h.filterModel.value=b.target.value,onKeydown:An(b=>h.filterCallback(),["enter"])},null,40,Ll)):a.filterType==="genre"?(v(),N(Ct,{key:1,class:"epg-table-grid__col-filter-genre","model-value":h.filterModel.value??[],options:i(L),placeholder:i(t)("Any"),"aria-label":i(t)("Content type"),filter:!0,"append-to":"self","onUpdate:modelValue":b=>{h.filterModel.value=b.length?b:null},onOnly:b=>{h.filterModel.value=[b]}},null,8,["model-value","options","placeholder","aria-label","onUpdate:modelValue","onOnly"])):D("",!0)]),toolbarActions:A(()=>[E(Jn)]),toolbarRight:A(()=>[E(ut,{modelValue:j.value,"onUpdate:modelValue":[l[2]||(l[2]=a=>j.value=a),et],class:"epg-table-grid__search epg-table-grid__search--inline",placeholder:i(t)("Search {0}",i(t)("Title"))},null,8,["modelValue","placeholder"]),ge(E(i(Oe),{modelValue:W.value,"onUpdate:modelValue":l[3]||(l[3]=a=>W.value=a),options:Je.value,"option-value":"value","option-label":"label","aria-label":i(t)("Title search scope"),class:"epg-table-grid__title-scope epg-table-grid__title-scope--inline"},null,8,["modelValue","options","aria-label"]),[[d,i(t)("Choose where to look when searching by title"),void 0,{bottom:!0}]]),ge((v(),w("button",{type:"button",class:"epg-table-grid__search-toggle","aria-label":i(t)("Search"),onClick:Dt},[E(i(Rn),{size:16,"stroke-width":2})],8,Sl)),[[d,i(t)("Search"),void 0,{bottom:!0}]]),E(i(_t),{ref_key:"searchPopoverRef",ref:Xe},{default:A(()=>[C("div",Ml,[E(ut,{modelValue:j.value,"onUpdate:modelValue":[l[4]||(l[4]=a=>j.value=a),et],placeholder:i(t)("Search {0}",i(t)("Title"))},null,8,["modelValue","placeholder"]),E(i(Oe),{modelValue:W.value,"onUpdate:modelValue":l[5]||(l[5]=a=>W.value=a),options:Je.value,"option-value":"value","option-label":"label","aria-label":i(t)("Title search scope")},null,8,["modelValue","options","aria-label"])])]),_:1},512),ot.value?ge((v(),w("button",{key:0,type:"button",class:"epg-table-grid__autorec","aria-label":i(t)("Create AutoRec"),disabled:Ce.value||!Ie.value||Ue.value,onClick:tn},[z(k(i(t)("Create AutoRec")),1)],8,Fl)),[[d,Ue.value?i(t)("Pick a single genre and a single tag to create an AutoRec rule — multi-select filters can’t be saved as a rule."):Ie.value?i(t)("Create an automatic recording rule to record all future programs that match the current query."):i(t)("Set at least one filter (title, channel, genre, duration, tag, or “New only”) to create an AutoRec rule."),void 0,{bottom:!0}]]):D("",!0),E(nl,{options:i(e).viewOptions.value,defaults:i(e).currentDefaults.value,"toggleable-columns":be.value,"groupable-fields":Y,"sortable-fields":Ee,"sort-field":I.value,"sort-order":K.value,"per-column-filters":s.value.perColumn,"per-column-labels":St.value,tags:i(e).tags.value,"onUpdate:options":i(e).setViewOptions,"onUpdate:sortField":l[6]||(l[6]=a=>ye(a??"start","asc")),"onUpdate:sortOrder":l[7]||(l[7]=a=>ne({sortField:I.value,sortOrder:a})),onClearPerColumn:Mt},null,8,["options","defaults","toggleable-columns","sort-field","sort-order","per-column-filters","per-column-labels","tags","onUpdate:options"]),ge((v(),w("button",{type:"button",class:"epg-table-grid__help","aria-label":i(t)("Help"),"aria-pressed":i(nt).isOpen.value,onClick:Zt},[E(i(Nn),{size:16,"stroke-width":2})],8,El)),[[d,i(t)("Help"),void 0,{bottom:!0}]])]),_:1},8,["entries","total","loading","error","columns","virtual-scroller-options","sort-field","sort-order","filters","group-field","group-order","cluster-totals"]),E(qn,{event:It.value,onClose:Gt},null,8,["event"])])}}}),Yl=he(xl,[["__scopeId","data-v-5f1ac23b"]]);export{Yl as default};
