=0)return t[`${i}_${n}`]}return r&&n?n[i]:void 0}(e,n.hourly,n.daily,!1!==d.daily_forecast_fallback);if(!c)return N``;const u=!1!==d.show_conditions,_=!1!==d.show_temp,m=!0===d.show_uv_index&&void 0!==c.uv_index&&c.uv_index>=(null!=(s=d.uv_index_threshold)?s:0),h="row"===r,p=h||u,f=h&&u?function(e,t,n,r){var a;if(!e||!t||!n)return;const i=Ka(e,r);if(i){const e=Qa(i,n);if(e)return e}const o=null==(a=e.states)?void 0:a[t];if(!o||"function"!=typeof e.formatEntityState)return;const s=e.formatEntityState(o,n);return s?(s!==n||oi.has(n)||(oi.add(n),st(`Weather condition "${n}" came back untranslated from ${t}; Home Assistant returned the raw token, so the row will show it as-is`)),s):void 0}(a,null==(l=t.weather)?void 0:l.entity,c.condition,t.language):void 0;return N`
${p?N``:F}${_?N`${c.temperature}°`:F}${m?N`UV${c.uv_index}`:F}${f?N`${f}`:F}
`}function fi(e,t,n,r={}){const{weatherForecasts:a,weatherPlacement:i="title",progressPlacement:o="inline",countdownPlacement:s="trailing",hass:l}=r,{eventTime:d,allDayBadge:c,titlePill:u,eventLocation:_,locationIcon:m,eventDescription:h,shouldShowTime:p,countdownStr:f,progressPercentage:g,entityLabel:y,mergedLabels:v}=n,w=null!==g&&t.show_progress_bar,b=w&&"inline"===o,M=w&&"row"===o?N`
`:F,k="title"===i?a:void 0,D="row"===i&&hi(t)?pi(e,t,a,"row",l):F,Y="text"===s&&null!==f,$=Y?null:f,x=d?N`${d}`:F,S=c?N`${c.label}`:F,L=Y?N`${x}${f}`:x;return N`
${function(e,t,n,r,a,i){var o,s,l;const d=!!e._isEmptyDay,c=d&&!e._isCustomEmptyText,u=d?"var(--calendar-card-empty-day-color)":(null==(o=e._matchedConfig)?void 0:o.color)||t.event_color,_=null==(s=e._matchedConfig)?void 0:s.label_icon_color,m=null==(l=e._matchedConfig)?void 0:l.label_type,h=c?`✓ ${e.summary}`:e.summary,p=a?`allday-title-pill allday-pill-${a.mode}`+(a.inheritsText?" allday-source-text":""):"",f=a?`--calendar-card-event-accent: ${a.accent};`+(a.inheritsText?` --badge-source: ${u};`:""):"",g=a?N`
${h}`:h,y=i?i.map((e=>mi(e.value,e.iconColor,e.type))):n?mi(n,_,m):F;return N`
`}(e,t,y,k,u,v)}
${M}
${p?N`
${S}${L}
${$?N`
${$}
`:b?N`
`:F}
`:f?N`
`:b?N`
`:F}
${D}
${_?N`
${_}
`:""}
${h?N`
${h}
`:""}
`}function gi(e,t,n="absolute"){if(!e.today_indicator||!t)return F;const r=e.today_indicator,a=void 0===(i=r)||!1===i?"none":!0===i?"dot":"string"==typeof i?"dot"===i||"pulse"===i||"glow"===i?i:""===i.trim()?"dot":Te(i)?"mdi":i.startsWith("/")||/^https?:\/\//i.test(i)||/\.(apng|avif|bmp|gif|ico|jpe?g|png|svg|webp)(?:[?#]|$)/i.test(i)?"image":"emoji":"none";var i;if("none"===a)return F;const o="inline"===n?{}:function(e){const t={position:"absolute",transform:"translate(-50%, -50%)"},n=e.trim().split(/\s+/);return n.length>=1&&(t.left=n[0]),n.length>=2?t.top=n[1]:t.top="50%",t}(e.today_indicator_position);return N`
${function(e,t,n){let r="";switch(e){case"dot":case"pulse":case"glow":r="mdi:circle";break;case"mdi":r="string"==typeof t?t:"mdi:circle";break;case"image":return"string"==typeof t?N`

`:F;case"emoji":return"string"==typeof t?N`
${t}
`:F;default:return F}if(r)return N`
`;return F}(a,r,o)}
`}function yi(e){return"home-assistant"===e}const vi=new Set(["primary","accent","red","pink","purple","deep-purple","indigo","blue","light-blue","cyan","teal","green","light-green","lime","yellow","amber","orange","deep-orange","brown","light-grey","grey","dark-grey","blue-grey","black","white","primary-text","secondary-text","disabled"]);let wi,bi,Mi=new Map,ki=!1,Di=0,Yi=!1;const $i=new Set;function xi(){for(const e of $i)e()}function Si(e){const t=function(e,t){if("function"==typeof e.callWS)return e.callWS(t);const n=e.connection;return n&&"function"==typeof n.sendMessagePromise?n.sendMessagePromise(t):void 0}(e,{type:"config/entity_registry/list"});if(t)return t.then((e=>{Mi=function(e){var t,n;const r=new Map;for(const i of null!=e?e:[]){const e=null==i?void 0:i.entity_id;if("string"!=typeof e||!e.startsWith("calendar."))continue;const o=null==(n=null==(t=i.options)?void 0:t.calendar)?void 0:n.color;"string"==typeof o&&""!==o&&r.set(e,(a=o,vi.has(a)?`var(--${a}-color)`:a))}var a;return r}(e),ki=!0,st(`Loaded ${Mi.size} calendar colors from the entity registry`)})).catch((e=>{st("Could not read calendar colors from the entity registry",e)}));Yi||(Yi=!0,st("This instance exposes no WebSocket command API, so Home Assistant calendar colors are unavailable; configured colors are used instead"))}function Li(e,t){if(!e)return;if($i.add(t),function(e){const t=e.connection;if(bi||!t||"function"!=typeof t.subscribeEvents)return;bi=()=>{};const n=++Di;t.subscribeEvents((()=>{const t=Si(e);t&&t.then(xi)}),"entity_registry_updated").then((e=>{n===Di?bi=e:e()})).catch((()=>{n===Di&&(bi=void 0)}))}(e),ki||wi)return;const n=Si(e);n&&(wi=n.then((()=>{wi=void 0,xi()})))}function Ti(e){$i.delete(e),0===$i.size&&(Di++,bi&&(bi(),bi=void 0),ki=!1)}const ji=/(?:^|\s)year[:=](\d{4})(?!\w)/i,Hi=new RegExp(ji.source,"gi");function zi(e){return e.replace(Hi,"").replace(/[^\S\n]{2,}/g," ").replace(/[^\S\n]+\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim()}function Ei(e,t){return e.trim().length>0?`${e} (${t})`:`(${t})`}const Oi={sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},Ai="start_of_week";function Ci(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Pi(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function Ii(e,t){const n=(t-e.getDay()+7)%7;return Pi(e,n)}function Ni(e,t){const n=(e.getDay()-t+7)%7;return Pi(e,-n)}function Wi(e){const t=[];let n="";for(const r of e)"+"===r||"-"===r?(t.push(n),n=r):n+=r;return t.push(n),t}function Fi(e,t,n){const r=String(e).replace(/\s+/g,"").toLowerCase();if(""===r)return{kind:"nomatch"};const a=Wi(r),i=a[0],o=a.slice(1);let s;if("today"===i)s=Ci(n);else if(i===Ai)s=function(e,t){return Ni(e,(t%7+7)%7)}(n,t);else if(i in Oi)s=Ii(Ci(n),Oi[i]);else{if(""!==i)return{kind:"nomatch"};s=Ci(n)}if(o.length>8)return{kind:"error",message:"too many operators (maximum 8)"};for(const e of o){const t="-"===e[0]?-1:1,n=e.slice(1);if(""===n)return{kind:"error",message:`dangling "${e[0]}" with no value`};if(n in Oi){const e=Oi[n];s=t>0?Ii(s,e):Ni(s,e);continue}const r=n.match(/^(\d+)w$/);if(r){s=Pi(s,t*parseInt(r[1],10)*7);continue}const a=n.match(/^(\d+)$/);if(!a)return{kind:"error",message:`unrecognized operand "${n}"`};s=Pi(s,t*parseInt(a[1],10))}return{kind:"ok",date:s}}const Ui=new Map;function Ri(e){return void 0===e||""===e?void 0:e}function Ji(e,t,n){var r,a;if(null===t||t.field!==n||""===e)return{text:e,replacedWholeField:!1};if(void 0===t.pattern)return{text:null!=(r=t.replacement)?r:"",replacedWholeField:!0};const i=function(e){var t;if(Ui.has(e))return null!=(t=Ui.get(e))?t:null;let n=null;try{n=new RegExp(e,"gi")}catch(t){at(`Ignoring "replace_pattern": ${JSON.stringify(e)} is not a valid regular expression. Event text is shown unchanged.`)}return Ui.set(e,n),n}(t.pattern);return null===i?{text:e,replacedWholeField:!1}:{text:e.replace(i,null!=(a=t.replacement)?a:""),replacedWholeField:!1}}var Vi=Object.defineProperty,Bi=Object.defineProperties,Ki=Object.getOwnPropertyDescriptors,qi=Object.getOwnPropertySymbols,Gi=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable,Qi=(e,t,n)=>t in e?Vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xi=(e,t)=>{for(var n in t||(t={}))Gi.call(t,n)&&Qi(e,n,t[n]);if(qi)for(var n of qi(t))Zi.call(t,n)&&Qi(e,n,t[n]);return e},eo=(e,t)=>Bi(e,Ki(t));const to=new Map;async function no(e,t,n,r=!1){const a=Na(t.first_day_of_week,e.locale),i=function(e,t,n,r,a){const i=t.map((e=>"string"==typeof e?e:e.entity)).sort().join("_");let o="";if(r)try{o=r.includes("T")?r.split("T")[0]:r}catch(e){o=r}const s=o?`_${o}`:"",l=function(e){const t=String(e).replace(/\s+/g,"").toLowerCase();return""!==t&&Wi(t)[0]===Ai}(o)&&void 0!==a?`_fdw${a}`:"";return`${me}${e}_${i}_${n}${s}${l}${de}`}(n,t.entities,t.days_to_show,t.start_date,a),o=function(){if(window.performance&&window.performance.navigation)return 1===window.performance.navigation.type;if(window.performance&&window.performance.getEntriesByType){const e=window.performance.getEntriesByType("navigation");if(e.length>0&&"type"in e[0])return"reload"===e[0].type}return!1}();if(!r){const e=function(e,t,n=!1){const r=So(e,t,n);if(r)return[...r.events];return null}(i,t,o);if(e)return ot(`Using ${e.length} events from cache`),{events:ro(e,t,a),failedEntities:[]}}let s=to.get(i);s?ot("Joining an in-flight request for the same calendars and window"):(s=async function(e,t,n,r){try{ot("Fetching events from API");const a=t.entities.map((e=>"string"==typeof e?{entity:e,color:"var(--primary-text-color)"}:e)),i=$o(t.days_to_show,t.start_date,r),{events:o,failedEntities:s}=await async function(e,t,n){const r=[],a=[],i=new Set;for(const o of t)if(!i.has(o.entity))try{const t=`calendars/${o.entity}?start=${n.start.toISOString()}&end=${n.end.toISOString()}`;ot(`Fetching calendar events with path: ${t}`);const s=await e.callApi("GET",t);if(!s||!Array.isArray(s)){at(`Invalid response for ${o.entity}`),a.push(o.entity);continue}const l=s.map((e=>eo(Xi({},e),{_entityId:o.entity})));r.push(...l),i.add(o.entity)}catch(t){rt(`Failed to fetch events for ${o.entity}:`,t),a.push(o.entity);try{ot("Available hass API methods:",Object.keys(e).filter((t=>"function"==typeof e[t])))}catch(e){}}return{events:r,failedEntities:a}}(e,a,i);if(o.length>0)xo(n,o);else if(s.length>0)at(`No events returned and ${s.length} calendar(s) failed to load; not caching empty result`);else{const e=1e3*_e;ot(`No events returned; caching empty result briefly (${_e}s)`),xo(n,o,e)}return{events:o,failedEntities:s}}finally{to.delete(n)}}(e,t,i,a),to.set(i,s));const{events:l,failedEntities:d}=await s;return{events:ro(l,t,a),failedEntities:d}}function ro(e,t,n){const r=function(e,t){const n=[],r=ao(e),a=e.length-r.length;a>0&&at(`Ignoring ${a} calendar event(s) missing a start or end; the calendar integration returned an incomplete payload`);return t.entities.forEach((e=>{const a="string"==typeof e?e:e.entity,i=r.filter((e=>e._entityId===a));if(0===i.length)return;const o=function(e,t,n){if("string"==typeof t)return go(e,fo(void 0,n));let r=go(e,fo(t,n));const a=t.filter_field;if(t.allowlist)try{const e=new RegExp(t.allowlist,"i");r=r.filter((t=>{const n=yo(t,a);return Boolean(n&&e.test(n))}))}catch(e){at(`Invalid allowlist pattern: ${t.allowlist}`,e)}if(t.blocklist)try{const e=new RegExp(t.blocklist,"i");r=r.filter((t=>{const n=yo(t,a);return!(n&&e.test(n))}))}catch(e){at(`Invalid blocklist pattern: ${t.blocklist}`,e)}return r}(i,e,t),s=o.map((n=>{const r=eo(Xi({},n),{_matchedConfig:"object"==typeof e?e:void 0});return r._entityLabel=bo(a,t,r),r}));n.push(...s)})),st(`Processed ${n.length} events after filtering`),n}(e,t),a=Lo(t,n),i=new Date(a);return i.setDate(i.getDate()+t.days_to_show),r.filter((e=>{if(!e.start)return!1;let t;if(e.start.dateTime)t=new Date(e.start.dateTime);else{if(!e.start.date)return!1;t=ja(e.start.date)}return tBoolean(e.start)&&Boolean(e.end)))}function io(e,t,n){return e>=n?e:t.toDateString()===n.toDateString()||t>n?n:e}const oo=/^(\d{1,2}):([0-5]\d)(?::([0-5]\d))?$/,so=new Set;function lo(e,t){const n=function(e){if("string"!=typeof e)return null;const t=oo.exec(e.trim());if(!t)return null;const n=Number(t[1]);return n>23?null:{hours:n,minutes:Number(t[2]),seconds:t[3]?Number(t[3]):0}}(t);if(!n){if("string"==typeof t&&""!==t.trim()){const e=t.trim();so.has(e)||(so.add(e),at(`Invalid allday_expires_at value "${e}" — expected a time such as 10:00`))}const n=new Date(e);return n.setDate(n.getDate()+1),n.setHours(0,0,0,0),n}const r=new Date(e);return r.setHours(n.hours,n.minutes,n.seconds,0),r}function co(e,t,n,r,a="list",i){const o=Xt(t,a),s=function(e,t,n){if(!n||e.length<2)return e;const r=new Set,a=new Set,i=new Map;for(const n of t.entities){const t="string"==typeof n?n:n.entity;for(const n of e){if(n._entityId!==t)continue;const e=vo(n),o=i.get(e);o?o.some((e=>e.entityId===t))||o.push({entityId:t,config:n._matchedConfig}):i.set(e,[{entityId:t,config:n._matchedConfig}]),r.has(e)||(r.add(e),a.add(n))}}const o=[];for(const t of e){const e=vo(t);if(!a.has(t)&&r.has(e))continue;const n=i.get(e);o.push(n&&n.length>1?eo(Xi({},t),{_mergedFrom:n}):t)}return o}(ao(e),o,o.filter_duplicates),l=o.show_empty_days,d=!n&&Zt(a),c=function(e,t,n=!1){const r=[];for(const a of e){if(!mo(a,t,n)){r.push(a);continue}if(!_o(a)){r.push(a);continue}const e=po(a);r.push(...e)}return r}(s,o,"column"===a);const u=Lo(o,Na(o.first_day_of_week,i)),_=new Date(u),m=new Date(_);m.setHours(23,59,59,999);const h=new Date(_);h.setDate(h.getDate()+o.days_to_show);const p=new Date,f=c.filter((e=>{if(!(null==e?void 0:e.start)||!(null==e?void 0:e.end))return!1;const t=!e.start.dateTime;let n,r;if(t){if(n=e.start.date?ja(e.start.date):null,r=e.end.date?ja(e.end.date):null,r){const e=new Date(r);e.setDate(e.getDate()-1),r=e}}else n=e.start.dateTime?new Date(e.start.dateTime):null,r=e.end.dateTime?new Date(e.end.dateTime):null;if(!n||!r)return!1;if(e._isMultiDaySegment&&n>=h)return!1;if(!(n>=_&&n<=m||n>m||r>=_))return!1;if(!o.show_past_events){if(!t&&r=lo(r,n))return!1}const a=function(e){const t=null==e?void 0:e.days_of_week;return"weekdays"===t||"weekends"===t?t:void 0}(e._matchedConfig);return!a||(i=io(n,r,_),s=a,za(i)===("weekends"===s));var i,s})),g={};f.length>0&&f.forEach((e=>{var t,n;let a,i;if(!e.start.dateTime){if(a=e.start.date?ja(e.start.date):null,i=e.end.date?ja(e.end.date):null,i){const e=new Date(i);e.setDate(e.getDate()-1),i=e}}else a=e.start.dateTime?new Date(e.start.dateTime):null,i=e.end.dateTime?new Date(e.end.dateTime):null;if(!a||!i)return;const s=io(a,i,_),l=Ha(s),d=Gn(r);g[l]||(g[l]={weekday:d.daysOfWeek[s.getDay()],day:s.getDate(),month:d.months[s.getMonth()],timestamp:s.getTime(),events:[]});const c=null!=(t=Do(e._entityId,"show_description",o,e))?t:o.show_description,u=e.description||"",m=function(e){return e.length>0&&/year/i.test(e)}(u),h=c||m?function(e){if(!e)return"";const t=e.replace(La,""),n=document.createElement("textarea");return n.innerHTML=t,n.value.trim()}(u):"",p=m?function(e){const t=ji.exec(e);return t?Number(t[1]):null}(h):null,f=null===p?null:function(e,t){const n=e-t;return n>=1?n:null}(a.getFullYear(),p),y=e.summary||"",v=function(e,t,n){const r=Ri(t),a=Ri(n);return void 0===r&&void 0===a?null:{field:"location"===e||"description"===e?e:"title",pattern:r,replacement:a}}(Do(e._entityId,"replace_field",o,e),Do(e._entityId,"replace_pattern",o,e),Do(e._entityId,"replace_with",o,e)),w=Ji(y,v,"title"),b=w.replacedWholeField||""!==y.trim()&&""===w.text.trim();g[l].events.push({summary:null===f||b?w.text:Ei(w.text,f),location:(null!=(n=Do(e._entityId,"show_location",o,e))?n:o.show_location)?Ji($a(e.location||"",o.remove_location_country),v,"location").text:"",description:c?Ji(null===p?h:zi(h),v,"description").text:"",start:e.start,end:e.end,_entityId:e._entityId,_entityLabel:bo(e._entityId,o,e),_matchedConfig:e._matchedConfig,_mergedFrom:e._mergedFrom,_isEmptyDay:e._isEmptyDay,_isCustomEmptyText:e._isCustomEmptyText,_isMultiDaySegment:e._isMultiDaySegment,_splitFromTimedEvent:e._splitFromTimedEvent})}));const y=Na(o.first_day_of_week,i);Object.values(g).forEach((e=>{const t=new Date(e.timestamp);e.weekNumber=To(t,o,y),e.monthNumber=t.getMonth()})),Object.values(g).forEach((e=>{e.events.sort(((e,t)=>{const n=!e.start.dateTime,r=!t.start.dateTime;if(n&&!r)return-1;if(!n&&r)return 1;let a,i;if(a=n&&e.start.date?ja(e.start.date).getTime():e.start.dateTime?new Date(e.start.dateTime).getTime():0,i=r&&t.start.date?ja(t.start.date).getTime():t.start.dateTime?new Date(t.start.dateTime).getTime():0,n&&r&&a===i){const n=uo(e._entityId,o),r=uo(t._entityId,o);return n!==r?n-r:(e.summary||"").localeCompare(t.summary||"",void 0,{sensitivity:"base"})}return a-i}))}));const v=d?Math.min(o.compact_days_to_show||o.days_to_show,o.days_to_show):o.days_to_show;let w=Object.values(g).sort(((e,t)=>e.timestamp-t.timestamp)).slice(0,v||3);if(d){const e=new Map;for(const t of w){const n=[];for(const r of t.events){if(r._isEmptyDay){n.push(r);continue}const t=r._entityId,a=r._matchedConfig;let i=-1;a?i=o.entities.findIndex((e=>"object"==typeof e&&e===a)):t&&(i=o.entities.findIndex((e=>"string"==typeof e&&e===t)));const s=-1!==i?`${t}__${i}`:t||"",l=null==a?void 0:a.compact_events_to_show;if("number"!=typeof l||!Number.isFinite(l)){n.push(r);continue}const d=e.get(s)||0;de.events.length>0&&!(1===e.events.length&&e.events[0]._isEmptyDay)))),d){const e=o.compact_events_to_show;if("number"==typeof e&&Number.isFinite(e)){let t=[],n=0;if(o.compact_events_complete_days){const r=new Set;for(const t of w)if((1!==t.events.length||!t.events[0]._isEmptyDay)&&n0){const a=Math.min(t.events.length,e-n);a>0&&(r.add(Ha(new Date(t.timestamp))),n+=a)}t=w.filter((e=>{const t=Ha(new Date(e.timestamp));return r.has(t)}))}else{t=[];for(const r of w){if(n>=e&&(1!==r.events.length||!r.events[0]._isEmptyDay))break;if(1===r.events.length&&r.events[0]._isEmptyDay){t.push(r);continue}const a=e-n;if(a>0&&r.events.length>0){const e=eo(Xi({},r),{events:r.events.slice(0,a)});t.push(e),n+=e.events.length}}}w=t}}if(l||0===w.length){const e=Gn(r),t=o.empty_day_text,a=Boolean(t),i=t||e.noEvents,s=new Date(u);let c;if(n)c=new Date(u),c.setDate(c.getDate()+v-1);else if(0===w.length)l?(c=new Date(u),c.setDate(c.getDate()+v-1)):c=new Date(u);else if(d&&o.compact_events_to_show)if(w.length>0){const e=Math.max(...w.map((e=>e.timestamp)));c=new Date(e)}else c=new Date(u);else c=new Date(u),c.setDate(c.getDate()+v-1);const _=new Set(w.map((e=>Ha(new Date(e.timestamp))))),m=[...w],h=Ea(s,c);for(let t=0;t<=h;t++){const n=new Date(s);n.setDate(s.getDate()+t);const r=Ha(n);if(!_.has(r)){const t=To(n,o,y),s={weekday:e.daysOfWeek[n.getDay()],day:n.getDate(),month:e.months[n.getMonth()],timestamp:n.getTime(),events:[{summary:i,start:{date:r},end:{date:r},_entityId:"_empty_day_",_isEmptyDay:!0,_isCustomEmptyText:a,location:""}],weekNumber:t,monthNumber:n.getMonth()};m.push(s)}}m.sort(((e,t)=>e.timestamp-t.timestamp)),w=m}return w.slice(0,v)}function uo(e,t){if(!e)return Number.MAX_SAFE_INTEGER;const n=t.entities.findIndex((t=>"string"==typeof t?t===e:t.entity===e));return-1!==n?n:Number.MAX_SAFE_INTEGER}function _o(e){if(!e.start||!e.end)return!1;if(e.start.date&&e.end.date){const t=new Date(e.start.date),n=new Date(e.end.date);return n.setDate(n.getDate()-1),t.toDateString()!==n.toDateString()}if(e.start.dateTime&&e.end.dateTime){const t=new Date(e.start.dateTime),n=new Date(e.end.dateTime);return t.toDateString()!==n.toDateString()}return!1}function mo(e,t,n=!1){return!n&&e._entityId&&e._matchedConfig&&void 0!==e._matchedConfig.split_multiday_events?e._matchedConfig.split_multiday_events:t.split_multiday_events}function ho(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function po(e){const t=[];if(e.start.date&&e.end.date){const n=ja(e.start.date),r=ja(e.end.date);r.setDate(r.getDate()-1);for(let a=new Date(n);a<=r;a.setDate(a.getDate()+1)){const n=ho(a),r=new Date(a);r.setDate(r.getDate()+1);const i=ho(r),o=eo(Xi({},e),{start:{date:n},end:{date:i},_isMultiDaySegment:!0});t.push(o)}}else if(e.start.dateTime&&e.end.dateTime){const n=new Date(e.start.dateTime),r=new Date(e.end.dateTime),a=new Date(n);a.setHours(23,59,59,999);if(new Date(a.getTime()+1)!e.start.dateTime===n))}function yo(e,t){return"location"===t?e.location:"description"===t?e.description:e.summary}function vo(e){const t=e.summary||"",n=e.location||"";let r="";if(e.start.dateTime){r=`${new Date(e.start.dateTime).getTime()}|${e.end.dateTime?new Date(e.end.dateTime).getTime():0}`}else r=`${e.start.date||""}|${e.end.date||""}`;return`${t}|${r}|${n}`}function wo(e,t,n,r,a){if(!e)return"var(--calendar-card-line-color-vertical)";let i;i=r&&r._matchedConfig?r._matchedConfig:t.entities.find((t=>"string"==typeof t&&t===e||"object"==typeof t&&t.entity===e));const o=function(e,t,n,r){const a=null==r?void 0:r.get(e),i="string"==typeof n||null==n?void 0:n.accent_color;if(yi(i)){if(a)return a}else if(i)return i;if(yi(t.accent_color))return null!=a?a:vt.accent_color;return t.accent_color}(e,t,i,a);return void 0===n||0===n||isNaN(n)?o:Le(o,n)}function bo(e,t,n){if(!e)return;if(n&&n._matchedConfig)return n._matchedConfig.label;const r=t.entities.find((t=>"string"==typeof t&&t===e||"object"==typeof t&&t.entity===e));return r&&"string"!=typeof r?r.label:void 0}function Mo(e,t,n,r){const a=bo(e,t,n),i=Ye(a),o=xe(a);if(!i&&!o)return a;const s=Do(e,"label_type",t,n);return je(s)&&s!==(i?"icon":"image")?a:o?function(e,t){var n,r,a;if(!e)return;const i=null==(a=null==(r=null==(n=null==t?void 0:t.states)?void 0:n[e])?void 0:r.attributes)?void 0:a.entity_picture;return"string"==typeof i&&""!==i?i:void 0}(a,r):function(e,t){var n,r,a;if(!e)return;const i=null==(a=null==(r=null==(n=null==t?void 0:t.states)?void 0:n[e])?void 0:r.attributes)?void 0:a.icon;return"string"==typeof i&&""!==i?i:void 0}(e,r)}function ko(e,t,n){const r=e._mergedFrom;if(!r||r.length<2)return;const a=[],i=new Set;for(const o of r){const r=eo(Xi({},e),{_entityId:o.entityId,_matchedConfig:o.config}),s=Mo(o.entityId,t,r,n);s&&(i.has(s)||(i.add(s),a.push({value:s,iconColor:Do(o.entityId,"label_icon_color",t,r),type:Do(o.entityId,"label_type",t,r)})))}return a.length>1?a:void 0}function Do(e,t,n,r){if(!e)return;if(r&&r._matchedConfig)return r._matchedConfig[t];const a=n.entities.find((t=>"string"==typeof t&&t===e||"object"==typeof t&&t.entity===e));return a&&"string"!=typeof a?a[t]:void 0}function Yo(e){if(!e||e._isEmptyDay)return!1;const t=new Date;if(!e.start.dateTime)return!1;const n=e.start.dateTime?new Date(e.start.dateTime):null,r=e.end.dateTime?new Date(e.end.dateTime):null;return!(!n||!r)&&(t>=n&&t{const e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},i=null==t?"":String(t);if(""!==i.trim())try{const e=i.trim(),t=Fi(e,n,new Date);if("ok"===t.kind)r=t.date,isNaN(r.getTime())?(at(`start_date "${e}" resolved outside the supported date range. Falling back to today.`),r=a()):ot(`Resolved start_date "${e}" to ${Ha(r)}`);else if("error"===t.kind)at(`Invalid start_date "${e}": ${t.message}. Falling back to today.`),r=a();else if(e.includes("T"))r=new Date(e),isNaN(r.getTime())&&(at(`Invalid ISO date: ${e}, falling back to today`),r=a());else{const[t,n,i]=e.split("-").map(Number);t&&n&&i&&n>=1&&n<=12&&i>=1&&i<=31?(r=new Date(t,n-1,i),r.getFullYear()===t&&r.getMonth()===n-1&&r.getDate()===i||(at(`Impossible date: ${e}, falling back to today`),r=a())):(at(`Malformed date: ${e}, falling back to today`),r=a())}}catch(e){at(`Error parsing date: ${i}, falling back to today`,e),r=a()}else r=a();r.setHours(0,0,0,0);const o=new Date(r),s=parseInt(e.toString())||3;return o.setDate(r.getDate()+s),o.setHours(23,59,59,999),{start:r,end:o}}function xo(e,t,n){try{ot(`Caching ${t.length} events`);const r={events:t,timestamp:Date.now()};return"number"==typeof n&&n>0&&(r.ttlMs=n),localStorage.setItem(e,JSON.stringify(r)),null!==So(e)}catch(e){return rt("Failed to cache calendar events:",e),!1}}function So(e,t,n=!1){try{const r=localStorage.getItem(e);if(!r)return null;const a=JSON.parse(r);if(!function(e){if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=e;return!("number"!=typeof t.timestamp||!Number.isFinite(t.timestamp))&&!!Array.isArray(t.events)&&t.events.every((e=>"object"==typeof e&&null!==e&&!Array.isArray(e)))}(a))return localStorage.removeItem(e),at(`Malformed cache entry removed for ${e}`),null;const i=a,o=Date.now();let s;s="number"==typeof i.ttlMs&&i.ttlMs>0?i.ttlMs:n&&(null==t?void 0:t.refresh_on_navigate)?1e3*ue:function(e){return 60*((null==e?void 0:e.refresh_interval)||ce)*1e3}(t);return o-i.timestampt}else{const t=e.end.dateTime?new Date(e.end.dateTime):null;l=null!==t&&o>t}}const d=Mi,c=e._mergedFrom&&e._mergedFrom.length>1?t.duplicate_accent_color:void 0,u=c||wo(e._entityId,t,void 0,e,d),_=t.event_background_opacity>0?t.event_background_opacity:0,m=_>0?c?Le(c,_):wo(e._entityId,t,_,e,d):"",h=null!=(a=Do(e._entityId,"show_time",t,e))?a:t.show_time,p=!e.start.dateTime,f=function(e){if(e.start.dateTime)return!1;const t=ja(e.start.date||""),n=ja(e.end.date||"");return n.setDate(n.getDate()-1),t.toDateString()!==n.toDateString()}(e),g=h&&!(p&&!f&&!t.show_single_allday_time)&&!(f&&!t.show_multiday_allday_time)&&!i;let y=null;!t.show_countdown||p&&!t.show_countdown_allday||i||l||(y=function(e,t="en"){if(e._isEmptyDay||!e.start)return null;const n=new Date,r=e.start.dateTime?new Date(e.start.dateTime):e.start.date?ja(e.start.date):null;if(!r||r<=n)return null;const a=Ea(n,r);if(1===a)return Ma(1,"day",t);if(a>1){const e=new Date(n.getFullYear(),n.getMonth(),n.getDate());return ka(new Date(r.getFullYear(),r.getMonth(),r.getDate()),t,e)}const i=Math.round((r.getTime()-n.getTime())/36e5);return i>=2?Ma(i,"hour",t):ka(r,t,n)}(e,n));const v=Yo(e)&&t.show_progress_bar?function(e){if(!Yo(e))return null;const t=new Date,n=new Date(e.start.dateTime),r=new Date(e.end.dateTime).getTime()-n.getTime(),a=t.getTime()-n.getTime();return Math.min(100,Math.max(0,Math.floor(a/r*100)))}(e):null,w=function(e,t,n,r){const a=!e.start.dateTime;let i,o;a?(i=ja(e.start.date||""),o=ja(e.end.date||"")):(i=new Date(e.start.dateTime||""),o=new Date(e.end.dateTime||""));const s=Gn(n);if(a){const e=new Date(o);return e.setDate(e.getDate()-1),i.toDateString()!==e.toDateString()?{allDayLabel:s.allDay,text:Ra(e,n,s)}:{allDayLabel:s.allDay,text:""}}const l=!("system"!==t.time_24h||!(null==r?void 0:r.locale)),d=!0===t.time_24h;return i.toDateString()!==o.toDateString()?{text:Ua(i,o,n,s,l,d,t.time_two_digit_hours,r)}:{text:Fa(i,o,t.show_end_time,l,d,t.time_two_digit_hours,r)}}(e,t,n,r),b=function(e){if("string"==typeof e){const t=e.toLowerCase().trim();return Ie.includes(t)?t:null}return null}(t.allday_badge),M=function(e){if("string"==typeof e){const t=e.toLowerCase().trim();if(Ne.includes(t))return t}return"subtle"}(t.allday_badge_style),k=void 0!==w.allDayLabel,D=function(e){if("string"!=typeof e)return{source:Fe};const t=e.trim();if(""===t)return{source:Fe};const n=t.toLowerCase();return We.includes(n)?{source:n}:{source:"custom",color:t}}(t.allday_badge_color),Y="custom"===D.source?D.color:u,$="text"===D.source,x="time"===b&&k?{label:w.allDayLabel,lang:n,accent:Y,mode:M,inheritsText:$}:void 0,S="title"===b&&k&&!i?{accent:Y,mode:M,inheritsText:$}:void 0,L=x?w.text:function({allDayLabel:e,text:t}){return Ta(void 0===e?t:t?`${e}, ${t}`:e)}(w),T=p&&!e._splitFromTimedEvent,j=T&&!t.show_location_allday?"":e.location||"",H=T&&!t.show_description_allday?"":e.description||"";return{isEmptyDay:i,isPastEvent:l,entityAccentColor:u,entityAccentBackgroundColor:m,contentParts:{eventTime:L,allDayBadge:x,titlePill:S,eventLocation:j,locationIcon:Sa(j,Do(e._entityId,"location_icon",t,e)),eventDescription:H,entityLabel:Mo(e._entityId,t,e,r),mergedLabels:ko(e,t,r),shouldShowTime:g,countdownStr:y,progressPercentage:v}}}var Ho=Object.defineProperty,zo=Object.getOwnPropertySymbols,Eo=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Ao=(e,t,n)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function Co(e,t){return e.isNewMonth&&!Bt(t.month_separator_width)?{kind:"month",width:t.month_separator_width,color:t.month_separator_color}:e.isNewWeek&&!Bt(t.week_separator_width)?{kind:"week",width:t.week_separator_width,color:t.week_separator_color}:Bt(t.day_separator_width)?null:{kind:"day",width:t.day_separator_width,color:t.day_separator_color}}function Po(e,t,n,r,a,i){const o=new Date(e.timestamp),{isToday:s,isTomorrow:l}=di(e.timestamp),d=za(o),c=li(o,t,a),u=Vt(t,"day_header_separator_width"),_=Vt(t,"day_header_separator_color"),m=Bt(u)?F:N``,h=gi(t,s,"inline"),p=h!==F;return N`
${m}
${Dn(e.events,((e,t)=>`${e._entityId}-${e.summary}-${t}`),((r,o)=>function(e,t,n,r,a,i,o){const s=jo(e,r,a,o),l=0===n,d=n===t.events.length-1,c={event:!0,"event-first":l,"event-middle":!l&&!d,"event-last":d,"past-event":s.isPastEvent};return N`
${fi(e,r,s.contentParts,{weatherForecasts:i,weatherPlacement:"row",progressPlacement:"row",countdownPlacement:"text",hass:o})}
`}(r,e,o,t,n,a,i)))}
`}function Io(e,t,n){return N`
{for(var n in t||(t={}))Eo.call(t,n)&&Ao(e,n,t[n]);if(zo)for(var n of zo(t))Oo.call(t,n)&&Ao(e,n,t[n]);return e})({gridColumn:String(n+1),gridRow:"1"},t?{}:{visibility:"hidden"}))}
>
${null!=e?e:""}
`}function No(e,t,n,r,a){const i=Vt(t,"day_header_gap"),o=tn(t.day_spacing),s=function(e){return e.map(((t,n)=>{const r=n>0?e[n-1]:void 0;return{isNewWeek:!r||t.weekNumber!==r.weekNumber,isNewMonth:Boolean(r&&t.monthNumber!==r.monthNumber)}}))}(e),l=function(e,t,n){const r=t.map(((e,t)=>e.isNewWeek&&!(0===t&&!n.show_current_week_number)));return null!==n.show_week_numbers&&r.some(Boolean)?e.map(((e,t)=>Io(e.weekNumber,r[t],t))):e.map((()=>F))}(e,s,t),d=s.map(((e,n)=>({separator:Co(e,t),index:n}))).filter((({separator:e,index:t})=>null!==e&&t>0)).map((({separator:e,index:t})=>function(e,t,n){return N`
`}(e,t,o)));return N`
${l}
${e.map(((e,i)=>Po(e,t,n,i,r,a)))}
${d}
`}function Wo(e,t){const n=Gn(t);return"loading"===e?N`
`:N`
`}function Fo(e,t,n,r="day"){if("day"===r)return{borderTopWidth:e,borderTopColor:t,borderTopStyle:"solid",marginTop:"0px",marginBottom:n.day_spacing};let a=be.WEEK;"month"===r&&(a=be.MONTH);const i=Kt(n.day_spacing,a);return{borderTopWidth:e,borderTopColor:t,borderTopStyle:"solid",marginTop:i,marginBottom:i}}function Uo(e,t,n,r,a=!1,i="day"){if(Bt(e)||a)return F;const o=Fo(e,t,r,i);return N``}function Ro(e){return Uo(e.month_separator_width,e.month_separator_color,"month-separator",e,!1,"month")}function Jo(e,t=!1){return Uo(e.week_separator_width,e.week_separator_color,"week-separator",e,t,"week")}function Vo(e,t,n,r,a,i,o){const{isToday:s,isTomorrow:l}=di(e.timestamp),d=za(new Date(e.timestamp));let c=F;const u=(null==a?void 0:a.isNewMonth)||!1,_=(null==a?void 0:a.isNewWeek)||!1,m=u&&!Bt(t.month_separator_width),h=_&&(null!==t.show_week_numbers||!Bt(t.week_separator_width)),p=t.day_separator_width,f=t.day_separator_color;if(r&&!Bt(p)&&!m&&!h){const e=Fo(p,f,t,"day");c=N``}return N`
${c}
${Dn(e.events,((e,t)=>`${e._entityId}-${e.summary}-${t}`),((r,a)=>function(e,t,n,r,a,i,o,s){const l=jo(e,r,a,s),d=new Date(t.timestamp),c=za(d),u=0===n,_=n===t.events.length-1,m={event:!0,"event-first":u,"event-middle":!u&&!_,"event-last":_,"past-event":l.isPastEvent};return N`
${0===n?N`
|
${function(e,t,n,r,a){return ci(e,t,n,r,li(e,t,a))}(d,r,a,i,o)}
${gi(r,i)}
|
`:""}
${fi(e,r,l.contentParts,{weatherForecasts:o})}
|
`}(r,e,a,t,n,s,i,o)))}
`}function Bo(e,t,n,r,a){return N`
${e.map(((i,o)=>{var s;const l=o>0?e[o-1]:void 0,d=null!=(s=i.weekNumber)?s:null;let c=!1;if(l){c=i.weekNumber!==l.weekNumber}else c=!0;const u=l&&i.monthNumber!==l.monthNumber,_=0===o,m={isNewWeek:c,isNewMonth:Boolean(u)};let h=F;return!u||Bt(t.month_separator_width)||c&&null!==t.show_week_numbers?c&&(h=_&&null!==t.show_week_numbers&&!t.show_current_week_number?u?Ro(t):Jo(t,_):null!==t.show_week_numbers?function(e,t,n,r=!1){if(null===e)return F;const a=t?be.MONTH:be.WEEK,i={marginTop:r?"0px":Kt(n.day_spacing,a/2-1),marginBottom:Kt(n.day_spacing,a/2)},o={};return r?o["--separator-display"]="none":t&&!Bt(n.month_separator_width)?(o["--separator-border-width"]=n.month_separator_width,o["--separator-border-color"]=n.month_separator_color,o["--separator-display"]="block"):Bt(n.week_separator_width)?o["--separator-display"]="none":(o["--separator-border-width"]=n.week_separator_width,o["--separator-border-color"]=n.week_separator_color,o["--separator-display"]="block"),N`
`}(d,Boolean(u),t,_):Jo(t,_)):h=Ro(t),N`
${h}
${Vo(i,t,n,l,m,r,a)}
`}))}
`}const Ko=((e,...t)=>{const r=1===e.length?e[0]:t.reduce(((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[r+1]),e[0]);return new a(r,e,n)})`
:host {
display: block;
height: 100%;
}
ha-card {
display: flex;
flex-direction: column;
height: 100%;
position: relative;
overflow: hidden;
box-sizing: border-box;
padding: calc(var(--calendar-card-spacing-additional) + 16px) 16px
calc(var(--calendar-card-spacing-additional) + 16px) 8px;
background: var(--calendar-card-background-color, var(--card-background-color));
cursor: pointer;
}
ha-card:focus {
outline: none;
}
ha-card:focus-visible {
outline: 2px solid var(--calendar-card-line-color-vertical);
}
.header-container,
.content-container {
width: 100%;
}
.content-container {
max-height: var(--calendar-card-max-height, none);
height: var(--calendar-card-height, auto);
overflow-x: hidden;
overflow-y: auto;
padding-bottom: 1px;
hyphens: auto;
scrollbar-width: none;
-ms-overflow-style: none;
}
.content-container:hover {
scrollbar-width: thin;
scrollbar-color: var(--secondary-text-color) transparent;
-ms-overflow-style: auto;
}
.card-header-placeholder {
height: 0;
}
.card-header {
float: left;
margin: 0 0 16px 8px;
padding: 0;
color: var(--calendar-card-color-title, var(--primary-text-color));
font-size: var(--calendar-card-font-size-title, var(--ha-card-header-font-size, 24px));
font-weight: var(--ha-font-weight-normal, 400);
letter-spacing: -0.012em;
line-height: 1.33;
}
.week-row-table {
height: calc(var(--calendar-card-week-number-font-size) * 1.5);
width: 100%;
table-layout: fixed;
padding-left: 8px;
border-spacing: 0;
border: none !important;
}
.week-number-cell,
.separator-cell {
height: 100%;
}
.week-number-cell {
width: var(--calendar-card-date-column-width);
position: relative;
text-align: center;
vertical-align: middle;
padding-right: 12px;
}
.week-number {
width: calc(var(--calendar-card-week-number-font-size) * 2.5);
height: calc(var(--calendar-card-week-number-font-size) * 1.5);
display: inline-flex;
align-items: center;
justify-content: center;
font-size: var(--calendar-card-week-number-font-size);
font-weight: 500;
color: var(--calendar-card-week-number-color);
background-color: var(--calendar-card-week-number-bg-color);
border-radius: 999px;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
@supports (-webkit-touch-callout: none) {
.week-number {
padding-top: calc(var(--calendar-card-week-number-font-size) * 0.1);
}
}
.separator-cell {
vertical-align: middle;
}
.separator-line {
width: 100%;
height: var(--separator-border-width, 0);
background-color: var(--separator-border-color, transparent);
display: var(--separator-display, none);
}
.separator {
width: 100%;
margin-left: 8px;
}
.week-separator {
width: 100%;
margin-left: 8px;
border-top-style: solid;
}
.month-separator {
width: 100%;
margin-left: 8px;
border-top-style: solid;
}
table {
width: 100%;
table-layout: fixed;
border-spacing: 0;
border-collapse: separate;
margin-bottom: var(--calendar-card-day-spacing);
}
.day-table {
border: none !important;
}
table:last-of-type {
margin-bottom: 0;
border-bottom: 0;
}
.date-column {
width: var(--calendar-card-date-column-width);
min-width: var(--calendar-card-date-column-width);
max-width: var(--calendar-card-date-column-width);
vertical-align: var(--calendar-card-date-column-vertical-alignment);
text-align: center;
position: relative;
padding-left: 8px;
padding-right: 12px;
}
.today-indicator-container:not(.inline) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
}
.weekday {
font-size: var(--calendar-card-font-size-weekday);
line-height: var(--calendar-card-font-size-weekday);
color: var(--calendar-card-color-weekday);
}
.day {
font-size: var(--calendar-card-font-size-day);
line-height: var(--calendar-card-font-size-day);
font-weight: 500;
color: var(--calendar-card-color-day);
}
.month {
font-size: var(--calendar-card-font-size-month);
line-height: var(--calendar-card-font-size-month);
text-transform: uppercase;
color: var(--calendar-card-color-month);
}
.today-indicator-container {
color: var(--calendar-card-today-indicator-color);
pointer-events: none;
z-index: 1;
}
.today-indicator-container.inline {
display: flex;
align-items: center;
justify-content: flex-start;
}
ha-icon.today-indicator {
--mdc-icon-size: var(--calendar-card-today-indicator-size);
}
img.today-indicator.image {
width: var(--calendar-card-today-indicator-size);
height: auto;
max-height: var(--calendar-card-today-indicator-size);
object-fit: contain;
}
span.today-indicator.emoji {
font-size: var(--calendar-card-today-indicator-size);
line-height: 1;
}
ha-icon.today-indicator.pulse {
animation: pulse-animation 2s infinite ease-in-out;
}
ha-icon.today-indicator.glow {
filter: drop-shadow(
0 0 calc(var(--calendar-card-today-indicator-size) * 0.5)
var(--calendar-card-today-indicator-color)
);
}
@keyframes pulse-animation {
0% {
transform: scale(0.95);
opacity: 0.7;
}
50% {
transform: scale(1.1);
opacity: 1;
}
100% {
transform: scale(0.95);
opacity: 0.7;
}
}
.date-column .weather,
.column-date-content .weather {
font-size: var(--calendar-card-weather-date-font-size, 12px);
color: var(--calendar-card-weather-date-color, var(--primary-text-color));
}
.date-column .weather {
display: flex;
align-items: center;
justify-content: center;
}
.weather ha-icon {
margin-right: 1px;
}
.date-column .weather ha-icon,
.column-date-content .weather ha-icon {
--mdc-icon-size: var(--calendar-card-weather-date-icon-size, 14px);
}
.weather-temp-high,
.weather-temp-low {
line-height: 1;
vertical-align: middle;
}
.weather-temp-high {
font-weight: 500;
}
.weather-temp-low {
opacity: 0.8;
}
.weather .weather-uv-index {
line-height: 1;
vertical-align: middle;
font-weight: 500;
margin-left: 2px;
}
.event-weather .weather-uv-index {
font-weight: 500;
margin-left: 2px;
}
.event {
padding: var(--calendar-card-event-spacing) 0 var(--calendar-card-event-spacing) 12px;
border-radius: 0;
}
.event-first.event-last {
border-start-start-radius: 0;
border-start-end-radius: var(--calendar-card-event-border-radius);
border-end-end-radius: var(--calendar-card-event-border-radius);
border-end-start-radius: 0;
}
.event-first {
border-start-end-radius: var(--calendar-card-event-border-radius);
border-start-start-radius: 0;
}
.event-last {
border-end-end-radius: var(--calendar-card-event-border-radius);
border-end-start-radius: 0;
}
.past-event .event-content {
opacity: 0.6;
}
.event-content {
display: flex;
flex-direction: column;
}
.summary-row {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.summary {
flex: 1;
margin-right: 12px;
overflow: hidden;
overflow-wrap: break-word;
font-size: var(--calendar-card-font-size-event);
line-height: 1.2;
padding-block: 0.2em;
}
.event-title {
font-size: var(--calendar-card-font-size-event);
font-weight: 500;
line-height: 1.2;
color: var(--calendar-card-color-event);
padding-bottom: 2px;
text-indent: 0;
display: var(--calendar-card-title-display);
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-title-max-lines);
overflow: hidden;
}
.summary:has(> .label-icon),
.summary:has(> .label-image) {
text-indent: calc(-1 * (var(--calendar-card-font-size-event) + 4px));
padding-inline-start: calc(var(--calendar-card-font-size-event) + 4px);
}
.summary:has(> .label-emoji) {
text-indent: calc(-1 * (var(--calendar-card-font-size-event) * 1.25 + 4px));
padding-inline-start: calc(var(--calendar-card-font-size-event) * 1.25 + 4px);
}
.calendar-label {
display: inline;
margin-right: 4px;
}
.label-icon {
--mdc-icon-size: var(--calendar-card-font-size-event);
vertical-align: middle;
margin-right: 4px;
}
.label-image {
height: var(--calendar-card-font-size-event);
width: auto;
vertical-align: middle;
margin-right: 4px;
}
.event-weather {
display: flex;
align-items: center;
font-weight: 500;
margin-left: 8px;
margin-right: 12px;
}
.event-weather ha-icon {
margin-right: 2px;
--mdc-icon-size: var(--calendar-card-weather-event-icon-size, 14px);
color: var(--calendar-card-weather-event-color, var(--secondary-text-color));
}
.event-weather .event-weather-text {
color: var(--calendar-card-weather-event-color, var(--secondary-text-color));
font-size: var(--calendar-card-weather-event-font-size, 12px);
}
.time-location {
display: flex;
flex-direction: column;
margin-top: 0;
}
.time,
.location,
.description {
display: flex;
align-items: var(--calendar-card-event-icon-vertical-alignment);
line-height: 1.2;
margin-top: 2px;
margin-right: 12px;
}
.time span,
.location span,
.description span {
display: inline-block;
vertical-align: middle;
overflow-wrap: break-word;
}
.time {
font-size: var(--calendar-card-font-size-time);
color: var(--calendar-card-color-time);
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
flex-wrap: wrap;
row-gap: 2px;
column-gap: 8px;
}
.time-actual {
display: flex;
align-items: var(--calendar-card-event-icon-vertical-alignment);
}
.time .time-actual:has(.allday-badge) {
align-items: center;
min-width: 0;
}
.time .time-actual .time-text {
min-width: 0;
flex: 1 1 auto;
}
.time .time-actual .time-text > span {
display: var(--calendar-card-time-display);
vertical-align: baseline;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-time-max-lines);
overflow: hidden;
}
.time .time-actual .time-text > .time-countdown {
display: inline;
-webkit-line-clamp: none;
overflow: visible;
margin-inline-start: 4px;
margin-inline-end: 0;
white-space: normal;
}
.time .time-actual .time-text > .time-countdown::before {
content: '\\2060·\\200B';
margin-inline-end: 4px;
}
.time .time-actual .allday-badge + .time-text > .time-countdown {
margin-inline-start: 0;
}
.time-countdown {
text-align: right;
color: var(--calendar-card-color-time);
font-size: var(--calendar-card-font-size-time);
margin-inline-start: auto;
margin-inline-end: 12px;
white-space: nowrap;
}
.location {
font-size: var(--calendar-card-font-size-location);
color: var(--calendar-card-color-location);
}
.description {
font-size: var(--calendar-card-font-size-description);
color: var(--calendar-card-color-description);
}
.allday-badge,
.allday-title-pill {
--badge-ink: color-mix(
in srgb,
var(--calendar-card-event-accent) 30%,
var(--primary-text-color)
);
--badge-wash: color-mix(
in srgb,
var(--calendar-card-event-accent) 10%,
var(--calendar-card-background-color, var(--card-background-color))
);
--badge-solid: var(--calendar-card-event-accent);
display: inline-block;
box-sizing: border-box;
max-width: 100%;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
border-radius: 999px;
}
.allday-pill-tinted {
color: var(--badge-ink);
background-color: var(--badge-wash);
box-shadow: inset 0 0 0 1px var(--badge-solid);
}
.allday-badge {
font-size: 0.85em;
font-weight: 500;
letter-spacing: 0.04em;
text-transform: uppercase;
line-height: 1.05;
padding-block: 0.193em 0.127em;
padding-inline: 0.5em;
margin-inline-end: 5px;
}
.allday-title-pill {
font-size: 0.95em;
line-height: 1.16;
padding-block: 0.21em;
padding-inline: 0.55em;
font-weight: 400;
vertical-align: middle;
margin-block: -0.17em;
}
@supports (text-box-trim: trim-both) and (text-box-edge: cap alphabetic) {
.allday-badge {
text-box-trim: trim-both;
text-box-edge: cap alphabetic;
padding-block: 0.3295em;
}
}
.allday-pill-subtle {
color: var(--badge-ink);
background-color: var(--badge-wash);
box-shadow: none;
}
.allday-pill-outline {
color: var(--badge-solid);
background-color: transparent;
box-shadow: inset 0 0 0 1px currentColor;
}
.allday-pill-filled {
color: var(--calendar-card-background-color, var(--card-background-color));
background-color: color-mix(
in srgb,
var(--badge-solid) 85%,
var(--calendar-card-background-color, var(--card-background-color))
);
box-shadow: none;
}
@supports (color: color-mix(in oklch, red, blue)) {
.allday-badge,
.allday-title-pill {
--badge-ink: color-mix(
in oklch,
var(--calendar-card-event-accent) 45%,
var(--primary-text-color)
);
--badge-wash: color-mix(
in oklch,
var(--calendar-card-event-accent) 14%,
var(--calendar-card-background-color, var(--card-background-color))
);
}
}
@supports (color: oklch(from red l c h)) {
.allday-badge,
.allday-title-pill {
--badge-ink: oklch(
from color-mix(in oklch, var(--calendar-card-event-accent) 45%, var(--primary-text-color)) l
calc(c * 2.2) h
);
--badge-wash: oklch(
from
color-mix(
in oklch,
var(--calendar-card-event-accent) 14%,
var(--calendar-card-background-color, var(--card-background-color))
)
l calc(c * 1.8) h
);
}
}
@supports (color: oklch(from red l c h)) {
.allday-pill-filled {
color: oklch(from var(--badge-solid) clamp(0, calc((l - 0.55) * -1000), 1) 0 h);
background-color: var(--badge-solid);
}
}
.allday-badge.allday-source-text,
.allday-title-pill.allday-source-text {
--badge-ink: var(--badge-source);
--badge-wash: color-mix(in srgb, var(--badge-source) 14%, transparent);
--badge-solid: var(--badge-source);
}
.time-location .event-weather {
display: flex;
flex-wrap: nowrap;
row-gap: 2px;
align-items: var(--calendar-card-event-icon-vertical-alignment);
font-size: var(--calendar-card-weather-event-font-size, 12px);
line-height: 1.2;
font-weight: normal;
margin-top: 2px;
margin-inline-start: 0;
margin-inline-end: 12px;
padding-inline-start: calc(var(--calendar-card-weather-event-icon-size, 14px) + 4px);
}
.time-location .event-weather ha-icon {
margin-inline-end: 4px;
margin-inline-start: calc(-1 * (var(--calendar-card-weather-event-icon-size, 14px) + 4px));
color: var(--calendar-card-weather-event-color, var(--secondary-text-color));
}
.time-location .event-weather .event-weather-text {
min-width: 0;
flex: 1 1 auto;
color: var(--calendar-card-weather-event-color, var(--secondary-text-color));
overflow-wrap: break-word;
}
.time-location .event-weather .weather-condition {
display: var(--calendar-card-weather-event-condition-display);
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-weather-event-max-lines);
overflow: hidden;
hyphens: manual;
}
.time-location .event-weather .event-weather-text > span + span::before {
content: '\\2060·\\200B';
margin-inline-start: 4px;
margin-inline-end: 4px;
}
.time-location .event-weather .weather-uv-index {
margin-inline-start: 0;
font-weight: normal;
}
.description span {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-description-max-lines);
overflow: hidden;
}
.time .time-actual > span:not(.time-text):not(.allday-badge) {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-time-max-lines);
overflow: hidden;
}
.location span {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--calendar-card-location-max-lines);
overflow: hidden;
}
.progress-bar {
width: var(--calendar-card-progress-bar-width, 60px);
height: var(--calendar-card-progress-bar-height);
background-color: color-mix(in srgb, var(--calendar-card-progress-bar-color) 20%, transparent);
border-radius: 999px;
overflow: hidden;
margin-inline-start: auto;
margin-inline-end: 12px;
}
.progress-bar-row {
width: var(--calendar-card-progress-bar-width, 80%);
margin-inline-start: 0;
margin-top: 2px;
}
.progress-bar-filled {
height: 100%;
background-color: var(--calendar-card-progress-bar-color);
border-radius: 999px 0 0 999px;
}
ha-icon {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
position: relative;
vertical-align: top;
top: 0;
margin-right: 4px;
}
.time ha-icon {
--mdc-icon-size: var(--calendar-card-icon-size-time, 14px);
}
.location ha-icon {
--mdc-icon-size: var(--calendar-card-icon-size-location, 14px);
}
.description ha-icon {
--mdc-icon-size: var(--calendar-card-icon-size-description, 14px);
}
.loading,
.error {
text-align: center;
padding: 16px;
}
.error {
color: var(--error-color);
}
.loading-indicator {
position: absolute;
top: calc(var(--ha-card-border-radius, 12px) * 0.5 + 2px);
right: calc(var(--ha-card-border-radius, 12px) * 0.5 + 2px);
width: 16px;
height: 16px;
display: inline-flex;
align-items: center;
justify-content: center;
z-index: 5;
pointer-events: none;
}
.loading-indicator .spinner {
box-sizing: border-box;
width: 14px;
height: 14px;
border: 2px solid color-mix(in srgb, var(--primary-text-color) 25%, transparent);
border-top-color: var(--primary-text-color);
border-radius: 50%;
animation: ccp-spin 0.8s linear infinite;
}
@keyframes ccp-spin {
to {
transform: rotate(360deg);
}
}
.calendar-card-pro.column-view {
padding-inline: 16px;
}
.calendar-card-pro.column-view .card-header {
margin-inline-start: 0;
}
.column-grid {
display: grid;
grid-template-rows: auto auto;
align-items: start;
width: 100%;
}
.day-column {
display: flex;
flex-direction: column;
min-width: 0;
}
.column-day-header {
position: relative;
padding-bottom: var(--calendar-card-column-header-gap, 8px);
}
.column-date-content {
display: grid;
grid-template-columns: auto auto 1fr;
grid-template-areas:
'weekday weekday .'
'day month weather';
align-items: baseline;
column-gap: 6px;
row-gap: 2px;
position: relative;
z-index: 2;
min-width: 0;
}
.column-date-content .weekday {
grid-area: weekday;
}
.column-date-content .day {
grid-area: day;
}
.column-date-content .month {
grid-area: month;
}
.column-date-content .today-indicator-container.inline {
grid-area: weekday;
justify-self: start;
align-self: center;
z-index: 3;
}
.column-date-content.with-today-indicator .weekday {
padding-inline-start: calc(var(--calendar-card-today-indicator-size, 6px) + 4px);
}
.column-date-content .weather {
grid-area: weather;
justify-self: start;
align-self: baseline;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.column-header-separator {
margin-bottom: var(--calendar-card-column-header-gap, 8px);
}
.column-grid > .column-week-number {
justify-self: start;
margin-bottom: 2px;
}
.column-events {
display: flex;
flex-direction: column;
min-width: 0;
}
.column-events .time-countdown,
.column-events .progress-bar {
margin-inline-end: 0;
}
.column-events .time {
justify-content: flex-start;
box-sizing: border-box;
column-gap: 4px;
padding-inline-start: calc(var(--calendar-card-icon-size-time, 14px) + 4px);
}
.column-events .time-actual {
margin-inline-start: calc(-1 * (var(--calendar-card-icon-size-time, 14px) + 4px));
}
.column-events .time-countdown {
margin-inline-start: 0;
text-align: start;
white-space: normal;
}
.column-events .time-countdown::before {
content: '·';
margin-inline-end: 4px;
}
.column-separator {
align-self: stretch;
justify-self: start;
pointer-events: none;
}
`;var qo=Object.defineProperty,Go=Object.getOwnPropertySymbols,Zo=Object.prototype.hasOwnProperty,Qo=Object.prototype.propertyIsEnumerable,Xo=(e,t,n)=>t in e?qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;let es=!0;function ts(e){return"string"==typeof e&&(e.includes("{{")||e.includes("{%"))}async function ns(e,t,n){const r=null==e?void 0:e.connection;if(!r||!t)return;const a=e=>{if(e&&"error"in e)return"WARNING"===e.level?void st("Template warning",{template:t,error:e.error}):(rt("Template render error",{template:t,error:e.error}),void n.onError(e.error));var r;e&&"result"in e&&n.onResult(null==(r=e.result)?"":"string"==typeof r?r:String(r))},i=e=>r.subscribeMessage(a,((e,t)=>{for(var n in t||(t={}))Zo.call(t,n)&&Xo(e,n,t[n]);if(Go)for(var n of Go(t))Qo.call(t,n)&&Xo(e,n,t[n]);return e})({type:"render_template",template:t},e?{report_errors:!0}:{}));try{return await i(es)}catch(e){if(es&&function(e){return"invalid_format"===(null==e?void 0:e.code)}(e)){es=!1,at("Home Assistant rejected the render_template `report_errors` option; falling back to basic template rendering (requires 2023.9+ for error reporting)");try{return await i(!1)}catch(e){return void rt("Failed to subscribe to template",{template:t,error:e})}}const r=null==e?void 0:e.message;return rt("Failed to subscribe to template",{template:t,error:e}),void n.onError(null!=r?r:String(e))}}class rs{constructor(e){this.callbacks=e,this._hasConnected=!1,this._version=0}update(e,t){const n=ts(t)?t:void 0,r=null==e?void 0:e.connection,a=!this._hasConnected&&Boolean(r);r&&(this._hasConnected=!0),n===this._template&&r===this._connection||(this._template=n,this._connection=r,this._version++,this._clearPending(),this._teardown(),n&&e&&(a?this._subscribe(e,n,this._version):this._debounceId=setTimeout((()=>{this._debounceId=void 0,this._subscribe(e,n,this._version)}),300)))}destroy(){this._version++,this._template=void 0,this._connection=void 0,this._hasConnected=!1,this._clearPending(),this._teardown()}async _subscribe(e,t,n){const r=await ns(e,t,{onResult:e=>{n===this._version&&this.callbacks.onResult(e)},onError:e=>{n===this._version&&this.callbacks.onError(e)}});r&&(n===this._version?this._unsubscribe=r:r())}_clearPending(){this._debounceId&&(clearTimeout(this._debounceId),this._debounceId=void 0)}_teardown(){if(this._unsubscribe){try{this._unsubscribe()}catch(e){at("Failed to unsubscribe from template",e)}this._unsubscribe=void 0}}}var as=Object.defineProperty,is=Object.defineProperties,os=Object.getOwnPropertyDescriptor,ss=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,ds=Object.prototype.hasOwnProperty,cs=Object.prototype.propertyIsEnumerable,us=(e,t,n)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_s=(e,t)=>{for(var n in t||(t={}))ds.call(t,n)&&us(e,n,t[n]);if(ls)for(var n of ls(t))cs.call(t,n)&&us(e,n,t[n]);return e},ms=(e,t)=>is(e,ss(t)),hs=(e,t,n,r)=>{for(var a,i=r>1?void 0:r?os(t,n):t,o=e.length-1;o>=0;o--)(a=e[o])&&(i=(r?a(t,n,i):a(i))||i);return r&&i&&as(t,n,i),i};function ps(e,t){const n=e,r=null==n?void 0:n.CalendarCardProEditor;if("function"!=typeof r)throw new Error("Calendar Card Pro: the editor file was found but is not the card’s editor. This usually means another file of the same name is installed alongside it — put the card’s files in a folder of their own, or reinstall through HACS, which does that for you. The card itself is unaffected.");const a=null==n?void 0:n.EDITOR_VERSION;a!==de&&at(`Editor file is v${null!=a?a:"unknown"} but the card is v${de}. Both files come from the same release, so one of them is stale — hard-refresh the browser, and if that does not help, reinstall so the card and editor files are replaced together.`),customElements.get(t)||customElements.define(t,r)}let fs=class extends ae{constructor(){super(),this.config=_s({},vt),this.events=[],this.isInitialLoad=!0,this.isLoading=!1,this.isExpanded=!1,this.weatherForecasts={daily:{},hourly:{}},this.preview=!1,this.editMode=!1,this.connectedWhileHidden=!0,this._instanceId=ze(),this._eventsInstanceId="",this._eventRequestGeneration=0,this._language="",this._lastUpdateTime=0,this._weatherUnsubscribers=[],this._weatherSetupVersion=0,this._weatherSetupPending=!1,this._hasFetchError=!1,this._activePointerId=null,this._holdTriggered=!1,this._holdTimer=null,this._holdIndicator=null,this._measuredWidthPx=null,this._effectiveView="list",this._columnCount=0,this._resizeObserver=null,this._widthSettleTimerId=null,this._handleVisibilityChange=()=>{if("visible"===document.visibilityState){Date.now()-this._lastUpdateTime>ve&&(st("Visibility changed to visible, updating events"),this.updateEvents())}},this._onEntityColorsChanged=()=>{this.requestUpdate()},this._instanceId=ze(),nt(de)}static async getConfigElement(){if(!customElements.get("calendar-card-pro-editor"))try{ps(await import(function(e){const t=new URL("./editor.js",e);return t.search=new URL(e).search,t.href}(import.meta.url)),"calendar-card-pro-editor")}catch(e){const t=e instanceof Error?e.message:String(e);throw rt(e,"loading the editor file"),new Error(`Calendar Card Pro: the editor could not be loaded because one of the card’s files is missing. Reinstalling the card in HACS restores it. The card itself is unaffected. (${t})`)}return document.createElement("calendar-card-pro-editor")}getGridOptions(){return{columns:"full",rows:"auto"}}get safeHass(){return this.hass||null}get effectiveLanguage(){return!this._language&&this.hass&&(this._language=qn(this.config.language,this.hass.locale)),this._language||"en"}get groupedEvents(){var e;return co(this.events,this.effectiveConfig,this.isExpanded,this.effectiveLanguage,this.effectiveView,null==(e=this.hass)?void 0:e.locale)}get requestedView(){return this.config.view}get effectiveView(){return this.preview||this.editMode?this.requestedView:this._effectiveView}get effectiveConfig(){const e=this.effectiveView,t=this._effectiveConfigCache;if(t&&t.config===this.config&&t.view===e)return t.resolved;const n=Xt(this.config,e);return this._effectiveConfigCache={config:this.config,view:e,resolved:n},n}get effectiveTitle(){var e;return ts(this.config.title)?null!=(e=this.renderedTitle)?e:"":this.config.title}get isTitlePending(){return ts(this.config.title)&&void 0===this.renderedTitle}get visibleEventCount(){var e,t;const n=this.effectiveLanguage,r=this.effectiveView,a=Na(this.config.first_day_of_week,null==(e=this.hass)?void 0:e.locale),i=this._visibleCountCache;if(i&&i.events===this.events&&i.config===this.config&&i.view===r&&i.language===n&&i.firstWeekday===a)return i.count;const o=this.events.length?co(this.events,this.effectiveConfig,!0,n,r,null==(t=this.hass)?void 0:t.locale).reduce(((e,t)=>e+t.events.filter((e=>!e._isEmptyDay)).length),0):0;return this._visibleCountCache={events:this.events,config:this.config,view:r,language:n,firstWeekday:a,count:o},o}static get styles(){return Ko}connectedCallback(){super.connectedCallback(),st("Component connected"),this.startRefreshTimer(),this.updateEvents(),this._scheduleWeatherSetup(),this._updateTitleSubscription(),document.addEventListener("visibilitychange",this._handleVisibilityChange),this._syncEntityColors(),this._startWidthObserver()}disconnectedCallback(){var e;super.disconnectedCallback(),this._stopWidthObserver(),this._weatherSetupVersion++,this._weatherSetupPending=!1,this._cleanupWeatherSubscriptions(),null==(e=this._titleSubscription)||e.destroy(),this._titleSubscription=void 0,this._refreshTimerId&&clearTimeout(this._refreshTimerId),this._initialLoadRetryId&&(clearTimeout(this._initialLoadRetryId),this._initialLoadRetryId=void 0),this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._holdIndicator&&(cn(this._holdIndicator),this._holdIndicator=null),document.removeEventListener("visibilitychange",this._handleVisibilityChange),Ti(this._onEntityColorsChanged),st("Component disconnected")}_startWidthObserver(){this._resizeObserver||"undefined"==typeof ResizeObserver||(this._resizeObserver=new ResizeObserver((e=>{var t,n;const r=null==(n=null==(t=e[0])?void 0:t.contentRect)?void 0:n.width;"number"==typeof r&&r>0&&this._scheduleWidthMeasurement(r)})),this._resizeObserver.observe(this))}_scheduleWidthMeasurement(e){null!==this._widthSettleTimerId&&clearTimeout(this._widthSettleTimerId),this._widthSettleTimerId=window.setTimeout((()=>{this._widthSettleTimerId=null,this._handleWidthMeasured(e)}),we)}_stopWidthObserver(){var e;null==(e=this._resizeObserver)||e.disconnect(),this._resizeObserver=null,null!==this._widthSettleTimerId&&(clearTimeout(this._widthSettleTimerId),this._widthSettleTimerId=null)}_handleWidthMeasured(e){const t=(n=this.requestedView,r=this.config,a=this._measuredWidthPx,i=e,o={view:this._effectiveView,columns:this._columnCount},ln(n,r,i,null===a?null:o));var n,r,a,i,o;this._measuredWidthPx=e,t.view===this._effectiveView&&t.columns===this._columnCount||(st(`Layout changed from ${this._effectiveView}/${this._columnCount} to ${t.view}/${t.columns} at ${Math.round(e)}px`),this._effectiveView=t.view,this._columnCount=t.columns,this.requestUpdate())}updated(e){var t,n,r,a,i,o,s,l,d,c,u;e.has("hass")&&this.hass&&!e.get("hass")&&this.updateEvents(!0),(e.has("hass")&&(null==(t=this.hass)?void 0:t.locale)||e.has("config")&&(null==(n=e.get("config"))?void 0:n.language)!==this.config.language)&&(this._language=qn(this.config.language,null==(r=this.hass)?void 0:r.locale));const _=e.has("hass")&&this.hass&&!e.get("hass"),m=e.get("config"),h=e.has("config")&&(null==(i=null==(a=this.config)?void 0:a.weather)?void 0:i.entity)!==(null==(o=null==m?void 0:m.weather)?void 0:o.entity),p=h||e.has("config")&&(null==(l=null==(s=this.config)?void 0:s.weather)?void 0:l.position)!==(null==(d=null==m?void 0:m.weather)?void 0:d.position);h&&(this.weatherForecasts={daily:{},hourly:{}}),(_||p)&&this._scheduleWeatherSetup(),(null==(u=null==(c=this.config)?void 0:c.weather)?void 0:u.entity)&&ei(this.hass,this.config.language,(()=>this.requestUpdate())),this._syncEntityColors(),(e.has("hass")||e.has("config"))&&this._updateTitleSubscription(),this._applyVisibility()}_updateTitleSubscription(){if(!ts(this.config.title))return this._titleSubscription&&(this._titleSubscription.destroy(),this._titleSubscription=void 0),void(this.renderedTitle=void 0);this._titleSubscription||(this._titleSubscription=new rs({onResult:e=>{this.renderedTitle=e},onError:()=>{void 0===this.renderedTitle&&(this.renderedTitle="")}})),this._titleSubscription.update(this.hass,this.config.title)}_applyVisibility(){const e=!(this.isInitialLoad||this.safeHass&&0!==this.config.entities.length),t=!(!0!==this.config.hide_when_empty||this.preview||this.editMode||e||this._hasFetchError||0!==this.visibleEventCount);this.hidden!==t&&(st(`hide_when_empty: ${t?"hiding":"revealing"} card`),this.hidden=t,this.style.display=t?"none":"",this.dispatchEvent(new CustomEvent("card-visibility-changed",{detail:{value:!t},bubbles:!0,composed:!0})))}getCustomStyles(){return function(e){var t,n,r,a,i,o,s,l,d,c,u,_,m,h,p,f,g,y,v,w;const b={"--calendar-card-background-color":e.background_color,"--calendar-card-font-size-weekday":e.weekday_font_size,"--calendar-card-font-size-day":e.day_font_size,"--calendar-card-font-size-month":e.month_font_size,"--calendar-card-font-size-event":e.event_font_size,"--calendar-card-font-size-time":e.time_font_size,"--calendar-card-font-size-location":e.location_font_size,"--calendar-card-font-size-description":e.description_font_size,"--calendar-card-color-weekday":e.weekday_color,"--calendar-card-color-day":e.day_color,"--calendar-card-color-month":e.month_color,"--calendar-card-color-event":e.event_color,"--calendar-card-color-time":e.time_color,"--calendar-card-color-location":e.location_color,"--calendar-card-color-description":e.description_color,"--calendar-card-line-color-vertical":e.accent_color,"--calendar-card-line-width-vertical":e.vertical_line_width,"--calendar-card-day-spacing":e.day_spacing,"--calendar-card-event-spacing":e.event_spacing,"--calendar-card-spacing-additional":e.additional_card_spacing,"--calendar-card-height":e.height||"auto","--calendar-card-max-height":e.max_height,"--calendar-card-progress-bar-color":e.progress_bar_color,"--calendar-card-progress-bar-height":e.progress_bar_height,"--calendar-card-icon-size-time":e.time_icon_size||"14px","--calendar-card-icon-size-location":e.location_icon_size||"14px","--calendar-card-icon-size-description":e.description_icon_size||"14px","--calendar-card-description-max-lines":e.description_max_lines>0?String(e.description_max_lines):"none","--calendar-card-title-max-lines":e.title_max_lines>0?String(e.title_max_lines):"none","--calendar-card-time-max-lines":e.time_max_lines>0?String(e.time_max_lines):"none","--calendar-card-location-max-lines":e.location_max_lines>0?String(e.location_max_lines):"none","--calendar-card-title-display":e.title_max_lines>0?"-webkit-box":"inline","--calendar-card-time-display":e.time_max_lines>0?"-webkit-box":"inline","--calendar-card-date-column-width":Kt(e.day_font_size,1.75),"--calendar-card-date-column-vertical-alignment":e.date_vertical_alignment,"--calendar-card-event-icon-vertical-alignment":"top"===e.event_icon_vertical_alignment?"flex-start":"bottom"===e.event_icon_vertical_alignment?"flex-end":"center","--calendar-card-event-border-radius":"calc(var(--ha-card-border-radius, 10px) / 2)","--ha-ripple-hover-opacity":"0.04","--ha-ripple-hover-color":e.accent_color,"--ha-ripple-pressed-opacity":"0.12","--ha-ripple-pressed-color":e.accent_color,"--calendar-card-today-indicator-color":e.today_indicator_color,"--calendar-card-today-indicator-size":e.today_indicator_size,"--calendar-card-week-number-font-size":e.week_number_font_size,"--calendar-card-week-number-color":e.week_number_color,"--calendar-card-week-number-bg-color":e.week_number_background_color,"--calendar-card-empty-day-color":e.empty_day_color===vt.empty_day_color?"color-mix(in srgb, var(--primary-text-color) 60%, transparent)":e.empty_day_color,"--calendar-card-weather-date-icon-size":(null==(n=null==(t=e.weather)?void 0:t.date)?void 0:n.icon_size)||"14px","--calendar-card-weather-date-font-size":(null==(a=null==(r=e.weather)?void 0:r.date)?void 0:a.font_size)||"12px","--calendar-card-weather-date-color":(null==(o=null==(i=e.weather)?void 0:i.date)?void 0:o.color)||"var(--primary-text-color)","--calendar-card-weather-event-icon-size":(null==(l=null==(s=e.weather)?void 0:s.event)?void 0:l.icon_size)||"14px","--calendar-card-weather-event-font-size":(null==(c=null==(d=e.weather)?void 0:d.event)?void 0:c.font_size)||"12px","--calendar-card-weather-event-max-lines":(null!=(m=null==(_=null==(u=e.weather)?void 0:u.event)?void 0:_.max_lines)?m:0)>0?String(null==(p=null==(h=e.weather)?void 0:h.event)?void 0:p.max_lines):"none","--calendar-card-weather-event-condition-display":(null!=(y=null==(g=null==(f=e.weather)?void 0:f.event)?void 0:g.max_lines)?y:0)>0?"-webkit-box":"inline"};return e.progress_bar_width&&(b["--calendar-card-progress-bar-width"]=e.progress_bar_width),e.title_font_size&&(b["--calendar-card-font-size-title"]=e.title_font_size),e.title_color&&(b["--calendar-card-color-title"]=e.title_color),(null==(w=null==(v=e.weather)?void 0:v.event)?void 0:w.color)&&(b["--calendar-card-weather-event-color"]=e.weather.event.color),b}(this.effectiveConfig)}_syncEntityColors(){var e,t;this.isConnected&&(yi((e=this.config).accent_color)||(null!=(t=e.entities)?t:[]).some((e=>"object"==typeof e&&null!==e&&yi(e.accent_color)))?Li(this.hass,this._onEntityColorsChanged):Ti(this._onEntityColorsChanged))}startRefreshTimer(){this._refreshTimerId&&clearTimeout(this._refreshTimerId);const e=this.config.refresh_interval||ce,t=60*e*1e3;this._refreshTimerId=window.setTimeout((()=>{this.updateEvents(),this.startRefreshTimer()}),t),st(`Scheduled next refresh in ${e} minutes`)}_scheduleWeatherSetup(){this._weatherSetupPending||(this._weatherSetupPending=!0,queueMicrotask((()=>{this._weatherSetupPending=!1,this.isConnected&&this._setupWeatherSubscriptions()})))}async _setupWeatherSubscriptions(){var e,t;const n=++this._weatherSetupVersion;if(this._cleanupWeatherSubscriptions(),!(null==(t=null==(e=this.config)?void 0:e.weather)?void 0:t.entity)||!this.hass)return;const r=function(e){if(!e||!e.entity)return[];const t=ni(e);return"none"===t?[]:"date"===t?["daily"]:["daily","hourly"]}(this.config.weather);for(const e of r){if(this._weatherSetupVersion!==n)return;const t=await si(this.hass,this.config,e,(t=>{this.weatherForecasts=ms(_s({},this.weatherForecasts),{[e]:t}),this.requestUpdate()}));if(this._weatherSetupVersion!==n)return void(t&&t());t&&this._weatherUnsubscribers.push(t)}}_cleanupWeatherSubscriptions(){const e=this._weatherUnsubscribers.length;e>0&&st(`Unsubscribing ${e} weather forecast subscription(s)`),this._weatherUnsubscribers.forEach((e=>{try{"function"==typeof e&&e()}catch(e){at("Failed to unsubscribe weather forecast",e)}})),this._weatherUnsubscribers=[]}_handlePointerDown(e){this._activePointerId=e.pointerId,this._holdTriggered=!1,this.config.hold_action&&"none"!==this.config.hold_action.action&&(this._holdTimer&&clearTimeout(this._holdTimer),this._holdTimer=window.setTimeout((()=>{this._activePointerId===e.pointerId&&(this._holdTriggered=!0,this._holdIndicator=function(e,t){const n=document.createElement("div");n.style.position="absolute",n.style.pointerEvents="none",n.style.borderRadius="50%",n.style.backgroundColor=t.accent_color,n.style.opacity=`${Me}`,n.style.transform="translate(-50%, -50%) scale(0)",n.style.transition=`transform ${ge}ms ease-out`,n.style.left=e.pageX+"px",n.style.top=e.pageY+"px";const r="touch"===e.pointerType?ke.TOUCH_SIZE:ke.POINTER_SIZE;return n.style.width=`${r}px`,n.style.height=`${r}px`,document.body.appendChild(n),setTimeout((()=>{n.style.transform="translate(-50%, -50%) scale(1)"}),10),st("Created hold indicator"),n}(e,this.config))}),fe))}_handlePointerUp(e){e.pointerId===this._activePointerId&&(this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._holdTriggered&&this.config.hold_action?(st("Executing hold action"),dn(this,this.config,"hold",(()=>this.toggleExpanded()))):!this._holdTriggered&&this.config.tap_action&&(st("Executing tap action"),dn(this,this.config,"tap",(()=>this.toggleExpanded()))),this._activePointerId=null,this._holdTriggered=!1,this._holdIndicator&&(cn(this._holdIndicator),this._holdIndicator=null))}_handlePointerCancel(){this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._activePointerId=null,this._holdTriggered=!1,this._holdIndicator&&(cn(this._holdIndicator),this._holdIndicator=null)}_handleKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),dn(this,this.config,"tap",(()=>this.toggleExpanded())))}setConfig(e){const t=this.config;for(const t of function(e){const t=e,n=[];for(const[e,r]of Object.entries(bt))e in t&&n.push(`"${e}" was removed in v3.0.0 and is being ignored — use "${r}"`);const r=t.entities;return Array.isArray(r)&&r.forEach(((e,t)=>{if("object"!=typeof e||null===e)return;const r=e;for(const[e,a]of Object.entries(Mt))e in r&&n.push(`"${e}" on entities[${t}] was removed in v3.0.0 and is being ignored — use "${a}"`)})),n}(e))it(t);const n=kt(vt,e);var r;this.config=n,this.config.entities=(r=this.config.entities,Array.isArray(r)?r.map((e=>"string"==typeof e?{entity:e,color:void 0,accent_color:void 0,label_icon_color:void 0}:e&&"object"==typeof e&&e.entity?{entity:e.entity,label:e.label,label_type:je(e.label_type)?e.label_type:void 0,color:e.color||void 0,accent_color:e.accent_color||void 0,label_icon_color:e.label_icon_color||void 0,show_time:e.show_time,show_location:e.show_location,location_icon:e.location_icon||void 0,show_description:e.show_description,compact_events_to_show:wt(e.compact_events_to_show,0),blocklist:e.blocklist,allowlist:e.allowlist,filter_field:e.filter_field,replace_field:e.replace_field,replace_pattern:e.replace_pattern,replace_with:e.replace_with,split_multiday_events:e.split_multiday_events,event_type:e.event_type,days_of_week:e.days_of_week,allday_expires_at:e.allday_expires_at}:null)).filter(Boolean):[]),function(e){var t,n,r;e.days_to_show=null!=(t=wt(e.days_to_show,1))?t:vt.days_to_show,e.refresh_interval=null!=(n=wt(e.refresh_interval,1))?n:vt.refresh_interval,e.event_background_opacity=null!=(r=wt(e.event_background_opacity,0))?r:vt.event_background_opacity,e.compact_days_to_show=wt(e.compact_days_to_show,1),e.compact_events_to_show=wt(e.compact_events_to_show,0)}(this.config),xt(this.config),function(e){const t=e.view;"list"!==t&&"column"!==t&&(at(`Ignoring "view: ${JSON.stringify(t)}": not a recognized view. Expected "list" or "column". Falling back to "list".`),e.view="list")}(this.config),en(this.config);const a=ln(this.config.view,this.config,this._measuredWidthPx,null===this._measuredWidthPx?null:{view:this._effectiveView,columns:this._columnCount});this._effectiveView=a.view,this._columnCount=a.columns,this._instanceId=Ee(this.config.entities,this.config.days_to_show,this.config.start_date,this.config.first_day_of_week);const i=function(e,t){if(!e||0===Object.keys(e).length)return!0;const n=(e.entities||[]).map((e=>"string"==typeof e?e:e.entity)).sort().join(","),r=(t.entities||[]).map((e=>"string"==typeof e?e:e.entity)).sort().join(","),a=(null==e?void 0:e.refresh_interval)!==(null==t?void 0:t.refresh_interval),i=n!==r||e.days_to_show!==t.days_to_show||e.start_date!==t.start_date||e.first_day_of_week!==t.first_day_of_week;return(i||a)&&st("Configuration change requires data refresh"),i||a}(t,this.config);var o,s;i?(st("Configuration changed, refreshing data"),this.updateEvents(!0)):(o=t,s=this.config,o&&0!==Object.keys(o).length&&(Tt(o.entities)!==Tt(s.entities)||jt.some((e=>o[e]!==s[e])))&&(st("Per-calendar configuration changed, reprocessing cached data"),this.updateEvents(!1))),this.startRefreshTimer()}async updateEvents(e=!1){st(`Updating events (force=${e})`);const t=++this._eventRequestGeneration,n=()=>t!==this._eventRequestGeneration;if(this.safeHass&&this._initialLoadRetryId&&(clearTimeout(this._initialLoadRetryId),this._initialLoadRetryId=void 0),!this.safeHass||!this.config.entities.length)return this.isLoading=!1,void(this.safeHass?this.isInitialLoad=!1:(this._initialLoadRetryId&&clearTimeout(this._initialLoadRetryId),this._initialLoadRetryId=window.setTimeout((()=>{this.updateEvents(!0)}),1500)));try{this.isLoading=!0,await this.updateComplete;const{events:t,failedEntities:r}=await no(this.safeHass,this.config,this._instanceId,e);if(n())return void st("Discarding a superseded event response");if(this._hasFetchError=r.length>0,this._hasFetchError&&at(`Could not load calendar(s): ${r.join(", ")}`),this.isLoading=!1,this.isInitialLoad=!1,await this.updateComplete,n())return void st("Discarding a superseded event response");const a=this._eventsInstanceId===this._instanceId;this._hasFetchError&&0===t.length&&this.events.length>0&&a?at("Refresh failed and returned nothing — keeping previously loaded events"):(this.events=[...t],this._eventsInstanceId=this._instanceId),this._hasFetchError||(this._lastUpdateTime=Date.now(),ot("Event update completed successfully"))}catch(e){if(n())return void st("Ignoring a failure from a superseded event request");rt("Failed to update events:",e),this._hasFetchError=!0,this.isLoading=!1,this.isInitialLoad=!1}}hasCompactModeLimits(){var e;if(!Zt(this.effectiveView))return!1;const t=e=>"number"==typeof e&&Number.isFinite(e);return!(!t(this.config.compact_events_to_show)&&!t(this.config.compact_days_to_show))||(null!=(e=this.config.entities)?e:[]).some((e=>"object"==typeof e&&null!==e&&t(e.compact_events_to_show)))}toggleExpanded(){this.hasCompactModeLimits()&&(this.isExpanded=!this.isExpanded)}handleAction(e){const t=e===this.config.hold_action?"hold":"tap";dn(this,this.config,t,(()=>this.toggleExpanded()))}render(){const e=this.getCustomStyles(),t={keyDown:e=>this._handleKeyDown(e),pointerDown:e=>this._handlePointerDown(e),pointerUp:e=>this._handlePointerUp(e),pointerCancel:()=>this._handlePointerCancel(),pointerLeave:()=>this._handlePointerCancel()};let n;const r=e=>"column"===this.effectiveView?No(this._columnCount>0&&this._columnCount""!==e)).join(" ");return N`
${a?N`
`:F}
${n}
`}(e,this.effectiveTitle,n,t,this.isLoading,this.isTitlePending,this.effectiveView)}};fs.getStubConfig=Et,hs([le({attribute:!1})],fs.prototype,"hass",2),hs([le({attribute:!1})],fs.prototype,"config",2),hs([le({attribute:!1})],fs.prototype,"events",2),hs([le({attribute:!1})],fs.prototype,"isInitialLoad",2),hs([le({attribute:!1})],fs.prototype,"isLoading",2),hs([le({attribute:!1})],fs.prototype,"isExpanded",2),hs([le({attribute:!1})],fs.prototype,"weatherForecasts",2),hs([le({attribute:!1})],fs.prototype,"renderedTitle",2),hs([le({type:Boolean})],fs.prototype,"preview",2),hs([le({type:Boolean})],fs.prototype,"editMode",2),fs=hs([(e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)})("calendar-card-pro")],fs);const gs=customElements.get("calendar-card-pro");gs&&(gs.getStubConfig=Et),window.customCards=window.customCards||[],window.customCards.push({type:"calendar-card-pro",name:"Calendar Card Pro",preview:!0,description:"A calendar card that supports multiple calendars with individual styling.",documentationURL:"https://github.com/alexpfau/calendar-card-pro",getEntitySuggestion:function(e,t){if("string"!=typeof t||"calendar"!==t.split(".")[0])return null;if(!e||"object"!=typeof e)return null;const n=e.states;return n&&"object"==typeof n&&n[t]?[{config:yt(gt({},zt([t])),{grid_options:gt({},Ht)})},{label:"Columns",config:yt(gt({},zt([t])),{view:"column",grid_options:gt({},Ht)})}]:null}});export{ps as adoptEditorComponent};