-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock-face.js
More file actions
1 lines (1 loc) · 5.87 KB
/
clock-face.js
File metadata and controls
1 lines (1 loc) · 5.87 KB
1
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerpolicy&&(o.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?o.credentials="include":r.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function h(){}function j(e,t){for(const n in t)e[n]=t[n];return e}function C(e){return e()}function z(){return Object.create(null)}function _(e){e.forEach(C)}function $(e){return typeof e=="function"}function B(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function I(e){return Object.keys(e).length===0}function H(e){const t={};for(const n in e)n[0]!=="$"&&(t[n]=e[n]);return t}function p(e,t){e.appendChild(t)}function S(e,t,n){e.insertBefore(t,n||null)}function L(e){e.parentNode.removeChild(e)}function d(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function i(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function R(e){return Array.from(e.childNodes)}function U(e){const t={};for(const n of e)t[n.name]=n.value;return t}let x;function g(e){x=e}const m=[],T=[],b=[],D=[],q=Promise.resolve();let v=!1;function F(){v||(v=!0,q.then(O))}function E(e){b.push(e)}const w=new Set;let k=0;function O(){const e=x;do{for(;k<m.length;){const t=m[k];k++,g(t),K(t.$$)}for(g(null),m.length=0,k=0;T.length;)T.pop()();for(let t=0;t<b.length;t+=1){const n=b[t];w.has(n)||(w.add(n),n())}b.length=0}while(m.length);for(;D.length;)D.pop()();v=!1,w.clear(),g(e)}function K(e){if(e.fragment!==null){e.update(),_(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(E)}}const V=new Set;function Z(e,t){e&&e.i&&(V.delete(e),e.i(t))}function G(e,t,n,s){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),s||E(()=>{const a=e.$$.on_mount.map(C).filter($);e.$$.on_destroy?e.$$.on_destroy.push(...a):_(a),e.$$.on_mount=[]}),o.forEach(E)}function J(e,t){const n=e.$$;n.fragment!==null&&(_(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Q(e,t){e.$$.dirty[0]===-1&&(m.push(e),F(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function W(e,t,n,s,r,o,a,f=[-1]){const l=x;g(e);const c=e.$$={fragment:null,ctx:[],props:o,update:h,not_equal:r,bound:z(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:z(),dirty:f,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let y=!1;if(c.ctx=n?n(e,t.props||{},(u,A,...M)=>{const N=M.length?M[0]:A;return c.ctx&&r(c.ctx[u],c.ctx[u]=N)&&(!c.skip_bound&&c.bound[u]&&c.bound[u](N),y&&Q(e,u)),A}):[],c.update(),y=!0,_(c.before_update),c.fragment=s?s(c.ctx):!1,t.target){if(t.hydrate){const u=R(t.target);c.fragment&&c.fragment.l(u),u.forEach(L)}else c.fragment&&c.fragment.c();t.intro&&Z(e.$$.fragment),G(e,t.target,t.anchor,t.customElement),O()}g(l)}let P;typeof HTMLElement=="function"&&(P=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:e}=this.$$;this.$$.on_disconnect=e.map(C).filter($);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(e,t,n){this[e]=n}disconnectedCallback(){_(this.$$.on_disconnect)}$destroy(){J(this,1),this.$destroy=h}$on(e,t){if(!$(t))return h;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!I(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});function X(e){let t,n,s;return{c(){t=d("g"),n=d("line"),i(n,"class","seconds-hand"),i(n,"y1","4"),i(n,"y2","-40"),i(t,"transform",s="rotate("+6*e[0]+")")},m(r,o){S(r,t,o),p(t,n)},p(r,o){o&1&&s!==(s="rotate("+6*r[0]+")")&&i(t,"transform",s)},d(r){r&&L(t)}}}function Y(e){let t,n,s,r,o,a,f=e[3]&&X(e);return{c(){t=d("svg"),n=d("circle"),f&&f.c(),s=d("line"),o=d("line"),this.c=h,i(n,"class","clock-face"),i(n,"r","48"),i(s,"class","hours-hand"),i(s,"y1","4"),i(s,"y2","-24"),i(s,"transform",r="rotate("+(30*e[2]+e[1]/2)+")"),i(o,"class","minutes-hand"),i(o,"y1","4"),i(o,"y2","-40"),i(o,"transform",a="rotate("+(6*e[1]+e[0]/10)+")"),i(t,"class","clock"),i(t,"viewBox","-50 -50 100 100")},m(l,c){S(l,t,c),p(t,n),f&&f.m(t,null),p(t,s),p(t,o)},p(l,[c]){l[3]&&f.p(l,c),c&6&&r!==(r="rotate("+(30*l[2]+l[1]/2)+")")&&i(s,"transform",r),c&3&&a!==(a="rotate("+(6*l[1]+l[0]/10)+")")&&i(o,"transform",a)},i:h,o:h,d(l){l&&L(t),f&&f.d()}}}function ee(e,t,n){let s,r,o,a=t["time-zone"]||t.timezone||"America/Toronto",f=t["second-hand"]||!0;const l=()=>new Date(new Date().toUTCString()).toLocaleString("en-US",{timeZone:a});let c=new Date(l());return setInterval(()=>{n(4,c=new Date(l()))},1e3),e.$$set=y=>{n(8,t=j(j({},t),H(y)))},e.$$.update=()=>{e.$$.dirty&16&&n(2,s=c.getHours()),e.$$.dirty&16&&n(1,r=c.getMinutes()),e.$$.dirty&16&&n(0,o=c.getSeconds())},t=H(t),[o,r,s,f,c]}class te extends P{constructor(t){super(),this.shadowRoot.innerHTML="<style>svg.clock{width:var(--clock-size, 100%);height:var(--clock-size, 100%)}.clock-face{fill:var(--clock-face-fill, none);stroke:var(--clock-face-stroke, currentColor)}.clock-face,.hours-hand,.minutes-hand,.seconds-hand{stroke-width:var(--clock-stroke-width, 1.5)}.hours-hand,.minutes-hand{stroke:var(--clock-hand-stroke, currentColor)}.seconds-hand{stroke:var(--clock-seconds-color, orange)}</style>",W(this,{target:this.shadowRoot,props:U(this.attributes),customElement:!0},ee,Y,B,{},null),t&&(t.target&&S(t.target,this,t.anchor),t.props&&(this.$set(t.props),O()))}}customElements.define("clock-face",te);