Source code

Revision control

Copy as Markdown

Other Tools

var app=function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function c(t){return"function"==typeof t}function r(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t,e){t.appendChild(e)}function i(t,e,n){t.insertBefore(e,n||null)}function u(t){t.parentNode&&t.parentNode.removeChild(t)}function s(t){return document.createElement(t)}function a(t){return document.createTextNode(t)}function d(){return a(" ")}function f(){return a("")}function p(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function m(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function h(t,e){e=""+e,t.data!==e&&(t.data=e)}function $(t,e,n){t.classList[n?"add":"remove"](e)}let g;function x(t){g=t}function y(){if(!g)throw new Error("Function called outside component initialization");return g}function v(){const t=y();return(e,n,{cancelable:o=!1}={})=>{const c=t.$$.callbacks[e];if(c){const r=function(t,e,{bubbles:n=!1,cancelable:o=!1}={}){const c=document.createEvent("CustomEvent");return c.initCustomEvent(t,n,o,e),c}(e,n,{cancelable:o});return c.slice().forEach((e=>{e.call(t,r)})),!r.defaultPrevented}return!0}}const b=[],k=[];let w=[];const _=[],C=Promise.resolve();let E=!1;function A(){E||(E=!0,C.then(S))}function F(t){w.push(t)}const I=new Set;let M=0;function S(){if(0!==M)return;const t=g;do{try{for(;M<b.length;){const t=b[M];M++,x(t),N(t.$$)}}catch(t){throw b.length=0,M=0,t}for(x(null),b.length=0,M=0;k.length;)k.pop()();for(let t=0;t<w.length;t+=1){const e=w[t];I.has(e)||(I.add(e),e())}w.length=0}while(b.length);for(;_.length;)_.pop()();E=!1,I.clear(),x(t)}function N(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(F)}}const L=new Set;let O;function j(){O={r:0,c:[],p:O}}function q(){O.r||o(O.c),O=O.p}function P(t,e){t&&t.i&&(L.delete(t),t.i(e))}function T(t,e,n,o){if(t&&t.o){if(L.has(t))return;L.add(t),O.c.push((()=>{L.delete(t),o&&(n&&t.d(1),o())})),t.o(e)}else o&&o()}function z(t,e){T(t,1,1,(()=>{e.delete(t.key)}))}function B(t){t&&t.c()}function W(t,n,r,l){const{fragment:i,after_update:u}=t.$$;i&&i.m(n,r),l||F((()=>{const n=t.$$.on_mount.map(e).filter(c);t.$$.on_destroy?t.$$.on_destroy.push(...n):o(n),t.$$.on_mount=[]})),u.forEach(F)}function D(t,e){const n=t.$$;null!==n.fragment&&(!function(t){const e=[],n=[];w.forEach((o=>-1===t.indexOf(o)?e.push(o):n.push(o))),n.forEach((t=>t())),w=e}(n.after_update),o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function G(e,c,r,l,i,s,a,d=[-1]){const f=g;x(e);const p=e.$$={fragment:null,ctx:[],props:s,update:t,not_equal:i,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(c.context||(f?f.$$.context:[])),callbacks:n(),dirty:d,skip_bound:!1,root:c.target||f.$$.root};a&&a(p.root);let m=!1;if(p.ctx=r?r(e,c.props||{},((t,n,...o)=>{const c=o.length?o[0]:n;return p.ctx&&i(p.ctx[t],p.ctx[t]=c)&&(!p.skip_bound&&p.bound[t]&&p.bound[t](c),m&&function(t,e){-1===t.$$.dirty[0]&&(b.push(t),A(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(e,t)),n})):[],p.update(),m=!0,o(p.before_update),p.fragment=!!l&&l(p.ctx),c.target){if(c.hydrate){const t=function(t){return Array.from(t.childNodes)}(c.target);p.fragment&&p.fragment.l(t),t.forEach(u)}else p.fragment&&p.fragment.c();c.intro&&P(e.$$.fragment),W(e,c.target,c.anchor,c.customElement),S()}x(f)}class H{$destroy(){D(this,1),this.$destroy=t}$on(e,n){if(!c(n))return t;const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(n),()=>{const t=o.indexOf(n);-1!==t&&o.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function J(e){let n,o,c,r,a,f;return{c(){n=s("header"),o=s("h1"),o.textContent="todos",c=d(),r=s("input"),m(r,"class","new-todo"),m(r,"placeholder","What needs to be done?"),r.autofocus=!0,m(n,"class","header")},m(t,u){i(t,n,u),l(n,o),l(n,c),l(n,r),r.focus(),a||(f=p(r,"keydown",e[0]),a=!0)},p:t,i:t,o:t,d(t){t&&u(n),a=!1,f()}}}function K(t){const e=v();return[function(t){"Enter"===t.key&&(e("addItem",{text:t.target.value}),t.target.value="")}]}class Q extends H{constructor(t){super(),G(this,t,K,J,r,{})}}function R(e){let n,o,c;return{c(){n=s("button"),n.textContent="Clear completed",m(n,"class","clear-completed")},m(t,r){i(t,n,r),o||(c=p(n,"click",e[3]),o=!0)},p:t,d(t){t&&u(n),o=!1,c()}}}function U(e){let n,o,c,r,f,p,g,x,y,v,b,k,w,_,C,E,A,F,I=1===e[0]?"item":"items",M=e[2]&&R(e);return{c(){n=s("footer"),o=s("span"),c=s("strong"),r=a(e[0]),f=d(),p=a(I),g=a(" left"),x=d(),y=s("ul"),v=s("li"),b=s("a"),b.textContent="All",k=d(),w=s("li"),_=s("a"),_.textContent="Active",C=d(),E=s("li"),A=s("a"),A.textContent="Completed",F=d(),M&&M.c(),m(o,"class","todo-count"),m(b,"href","#/"),$(b,"selected","all"===e[1]),m(_,"href","#/active"),$(_,"selected","active"===e[1]),m(A,"href","#/completed"),$(A,"selected","completed"===e[1]),m(y,"class","filters"),m(n,"class","footer")},m(t,e){i(t,n,e),l(n,o),l(o,c),l(c,r),l(o,f),l(o,p),l(o,g),l(n,x),l(n,y),l(y,v),l(v,b),l(y,k),l(y,w),l(w,_),l(y,C),l(y,E),l(E,A),l(n,F),M&&M.m(n,null)},p(t,[e]){1&e&&h(r,t[0]),1&e&&I!==(I=1===t[0]?"item":"items")&&h(p,I),2&e&&$(b,"selected","all"===t[1]),2&e&&$(_,"selected","active"===t[1]),2&e&&$(A,"selected","completed"===t[1]),t[2]?M?M.p(t,e):(M=R(t),M.c(),M.m(n,null)):M&&(M.d(1),M=null)},i:t,o:t,d(t){t&&u(n),M&&M.d()}}}function V(t,e,n){let{numActive:o}=e,{currentFilter:c}=e,{numCompleted:r}=e;const l=v();return t.$$set=t=>{"numActive"in t&&n(0,o=t.numActive),"currentFilter"in t&&n(1,c=t.currentFilter),"numCompleted"in t&&n(2,r=t.numCompleted)},[o,c,r,function(t){l("removeCompletedItems")}]}class X extends H{constructor(t){super(),G(this,t,V,U,r,{numActive:0,currentFilter:1,numCompleted:2})}}function Y(e){let n,r,a,f,h,$,g;return{c(){n=s("div"),r=s("input"),f=d(),h=s("label"),h.textContent="Edit Todo Input",r.value=a=e[0].description,m(r,"id","edit-todo-input"),m(r,"class","edit"),m(h,"class","visually-hidden"),m(h,"for","edit-todo-input"),m(n,"class","input-container")},m(o,u){var s;i(o,n,u),l(n,r),l(n,f),l(n,h),$||(g=[p(r,"keydown",e[5]),p(r,"blur",e[6]),(s=e[7].call(null,r),s&&c(s.destroy)?s.destroy:t)],$=!0)},p(t,e){1&e&&a!==(a=t[0].description)&&r.value!==a&&(r.value=a)},d(t){t&&u(n),$=!1,o(g)}}}function Z(e){let n,c,r,f,g,x,y,v,b,k,w,_,C,E=e[0].description+"",A=e[2]&&Y(e);return{c(){n=s("li"),c=s("div"),r=s("input"),g=d(),x=s("label"),y=a(E),v=d(),b=s("button"),k=d(),A&&A.c(),m(r,"class","toggle"),m(r,"type","checkbox"),r.checked=f=e[0].completed,m(b,"class","destroy"),m(c,"class","view"),m(n,"data-priority",w=4-e[1]%5),$(n,"completed",e[0].completed),$(n,"editing",e[2])},m(t,o){i(t,n,o),l(n,c),l(c,r),l(c,g),l(c,x),l(x,y),l(c,v),l(c,b),l(n,k),A&&A.m(n,null),_||(C=[p(r,"change",e[8]),p(x,"dblclick",e[4]),p(b,"click",e[3])],_=!0)},p(t,[e]){1&e&&f!==(f=t[0].completed)&&(r.checked=f),1&e&&E!==(E=t[0].description+"")&&h(y,E),t[2]?A?A.p(t,e):(A=Y(t),A.c(),A.m(n,null)):A&&(A.d(1),A=null),2&e&&w!==(w=4-t[1]%5)&&m(n,"data-priority",w),1&e&&$(n,"completed",t[0].completed),4&e&&$(n,"editing",t[2])},i:t,o:t,d(t){t&&u(n),A&&A.d(),_=!1,o(C)}}}function tt(t,e,n){let{item:o}=e,{index:c}=e;const r=v();let l=!1;function i(){r("removeItem")}return t.$$set=t=>{"item"in t&&n(0,o=t.item),"index"in t&&n(1,c=t.index)},[o,c,l,i,function(){n(2,l=!0)},function(t){"Enter"===t.key?t.target.blur():"Escape"===t.key&&n(2,l=!1)},function(t){if(!l)return;const{value:e}=t.target;e.length?n(0,o.description=e,o):i(),n(2,l=!1)},async function(t){await(A(),C),t.focus()},t=>n(0,o.completed=t.target.checked,o)]}class et extends H{constructor(t){super(),G(this,t,tt,Z,r,{item:0,index:1})}}function nt(t,e,n){const o=t.slice();return o[11]=e[n],o[12]=e,o[13]=n,o}function ot(t){let e,n,c,r,a,f,h,$,g,x,y,v,b,k=[],w=new Map,_=t[4];const C=t=>t[11].id;for(let e=0;e<_.length;e+=1){let n=nt(t,_,e),o=C(n);w.set(o,k[e]=ct(o,n))}return x=new X({props:{numActive:t[3],currentFilter:t[0],numCompleted:t[2]}}),x.$on("removeCompletedItems",t[8]),{c(){e=s("main"),n=s("div"),c=s("input"),a=d(),f=s("label"),f.textContent="Mark all as complete",h=d(),$=s("ul");for(let t=0;t<k.length;t+=1)k[t].c();g=d(),B(x.$$.fragment),m(c,"id","toggle-all"),m(c,"class","toggle-all"),m(c,"type","checkbox"),c.checked=r=t[2]===t[1].length,m(f,"for","toggle-all"),m(n,"class","toggle-all-container"),m($,"class","todo-list show-priority"),m(e,"class","main")},m(o,r){i(o,e,r),l(e,n),l(n,c),l(n,a),l(n,f),l(e,h),l(e,$);for(let t=0;t<k.length;t+=1)k[t]&&k[t].m($,null);l(e,g),W(x,e,null),y=!0,v||(b=p(c,"change",t[7]),v=!0)},p(t,e){(!y||6&e&&r!==(r=t[2]===t[1].length))&&(c.checked=r),80&e&&(_=t[4],j(),k=function(t,e,n,c,r,l,i,u,s,a,d,f){let p=t.length,m=l.length,h=p;const $={};for(;h--;)$[t[h].key]=h;const g=[],x=new Map,y=new Map,v=[];for(h=m;h--;){const t=f(r,l,h),o=n(t);let u=i.get(o);u?c&&v.push((()=>u.p(t,e))):(u=a(o,t),u.c()),x.set(o,g[h]=u),o in $&&y.set(o,Math.abs(h-$[o]))}const b=new Set,k=new Set;function w(t){P(t,1),t.m(u,d),i.set(t.key,t),d=t.first,m--}for(;p&&m;){const e=g[m-1],n=t[p-1],o=e.key,c=n.key;e===n?(d=e.first,p--,m--):x.has(c)?!i.has(o)||b.has(o)?w(e):k.has(c)?p--:y.get(o)>y.get(c)?(k.add(o),w(e)):(b.add(c),p--):(s(n,i),p--)}for(;p--;){const e=t[p];x.has(e.key)||s(e,i)}for(;m;)w(g[m-1]);return o(v),g}(k,e,C,1,t,_,w,$,z,ct,null,nt),q());const n={};8&e&&(n.numActive=t[3]),1&e&&(n.currentFilter=t[0]),4&e&&(n.numCompleted=t[2]),x.$set(n)},i(t){if(!y){for(let t=0;t<_.length;t+=1)P(k[t]);P(x.$$.fragment,t),y=!0}},o(t){for(let t=0;t<k.length;t+=1)T(k[t]);T(x.$$.fragment,t),y=!1},d(t){t&&u(e);for(let t=0;t<k.length;t+=1)k[t].d();D(x),v=!1,b()}}}function ct(t,e){let n,o,c,r;function l(t){e[9](t,e[11],e[12],e[13])}let s={index:e[13]};return void 0!==e[11]&&(s.item=e[11]),o=new et({props:s}),k.push((()=>function(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}(o,"item",l))),o.$on("removeItem",(function(){return e[10](e[13])})),{key:t,first:null,c(){n=f(),B(o.$$.fragment),this.first=n},m(t,e){i(t,n,e),W(o,t,e),r=!0},p(t,n){e=t;const r={};var l;16&n&&(r.index=e[13]),!c&&16&n&&(c=!0,r.item=e[11],l=()=>c=!1,_.push(l)),o.$set(r)},i(t){r||(P(o.$$.fragment,t),r=!0)},o(t){T(o.$$.fragment,t),r=!1},d(t){t&&u(n),D(o,t)}}}function rt(t){let e,n,o,c;e=new Q({}),e.$on("addItem",t[5]);let r=t[1].length>0&&ot(t);return{c(){B(e.$$.fragment),n=d(),r&&r.c(),o=f()},m(t,l){W(e,t,l),i(t,n,l),r&&r.m(t,l),i(t,o,l),c=!0},p(t,[e]){t[1].length>0?r?(r.p(t,e),2&e&&P(r,1)):(r=ot(t),r.c(),P(r,1),r.m(o.parentNode,o)):r&&(j(),T(r,1,1,(()=>{r=null})),q())},i(t){c||(P(e.$$.fragment,t),P(r),c=!0)},o(t){T(e.$$.fragment,t),T(r),c=!1},d(t){D(e,t),t&&u(n),r&&r.d(t),t&&u(o)}}}function lt(t,e,n){let o,c,r,l="all",i=[];function u(t){i.splice(t,1),n(1,i)}var s;s=()=>{(function(t){let e="all";function n(){switch(window.location.hash){case"#/active":e="active";break;case"#/completed":e="completed";break;default:e="all"}t(e)}return{init:function(){window.addEventListener("hashchange",n)}}})((t=>n(0,l=t))).init()},y().$$.on_mount.push(s);return t.$$.update=()=>{3&t.$$.dirty&&n(4,o="all"===l?i:"completed"===l?i.filter((t=>t.completed)):i.filter((t=>!t.completed))),2&t.$$.dirty&&n(3,c=i.filter((t=>!t.completed)).length),2&t.$$.dirty&&n(2,r=i.filter((t=>t.completed)).length)},[l,i,r,c,o,function(t){i.push({id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),description:t.detail.text,completed:!1}),n(1,i)},u,function(t){const e=t.target.checked;n(1,i=i.map((t=>({...t,completed:e}))))},function(){n(1,i=i.filter((t=>!t.completed)))},function(t,e,c,r){c[r]=t,n(4,o),n(0,l),n(1,i)},t=>u(t)]}return new class extends H{constructor(t){super(),G(this,t,lt,rt,r,{})}}({target:document.querySelector(".todoapp")})}();
//# sourceMappingURL=app.js.map