Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- code compiled through rollup 
repo @github

https://github.com/borntofrappe/svelte-tutorial/tree/master/Infinity%20Maze
-->
              
            
!

CSS

              
                * {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
body {
    /*   use in the background one of the patterns elaborated through the algorithm */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: hsl(0, 0%, 95%);
    background: url('data:image/svg+xml;utf8,<svg opacity="0.05" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 650 650"><defs><path id="a" d="M0 0h80"/><path id="c" d="M80 0v80"/><path id="d" d="M0 80h80"/><path id="b" d="M0 0v80"/></defs><g stroke="hsl(0, 0%, 80%)" stroke-width="10" stroke-linejoin="square" stroke-linecap="square" fill="none"><g transform="translate(5 5)"><use href="%23a"/><use href="%23b"/></g><g transform="translate(85 5)"><use href="%23a"/><use href="%23c"/><use href="%23d"/></g><g transform="translate(165 5)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><use href="%23a" transform="translate(245 5)"/><g transform="translate(325 5)"><use href="%23a"/><use href="%23c"/></g><g transform="translate(405 5)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><g transform="translate(485 5)"><use href="%23a"/><use href="%23c"/></g><g transform="translate(565 5)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(5 85)"><use href="%23d"/><use href="%23b"/></g><g transform="translate(85 85)"><use href="%23a"/><use href="%23d"/></g><use href="%23a" transform="translate(165 85)"/><g transform="translate(245 85)"><use href="%23c"/><use href="%23d"/></g><use href="%23b" transform="translate(325 85)"/><g transform="translate(405 85)"><use href="%23a"/><use href="%23d"/></g><use href="%23d" transform="translate(485 85)"/><g transform="translate(565 85)"><use href="%23c"/><use href="%23d"/></g><g transform="translate(5 165)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(85 165)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><use href="%23c" transform="translate(165 165)"/><g transform="translate(245 165)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(325 165)"><use href="%23c"/><use href="%23d"/><use href="%23b"/></g><g transform="translate(405 165)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><g transform="translate(485 165)"><use href="%23a"/><use href="%23d"/></g><g transform="translate(565 165)"><use href="%23a"/><use href="%23c"/></g><g transform="translate(5 245)"><use href="%23d"/><use href="%23b"/></g><use href="%23a" transform="translate(85 245)"/><use href="%23c" transform="translate(165 245)"/><g transform="translate(245 245)"><use href="%23c"/><use href="%23b"/></g><g transform="translate(325 245)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(405 245)"><use href="%23a"/><use href="%23b"/></g><g transform="translate(485 245)"><use href="%23a"/><use href="%23c"/><use href="%23d"/></g><g transform="translate(565 245)"><use href="%23c"/><use href="%23b"/></g><g transform="translate(5 325)"><use href="%23a"/><use href="%23b"/></g><use href="%23c" transform="translate(85 325)"/><g transform="translate(165 325)"><use href="%23c"/><use href="%23d"/><use href="%23b"/></g><use href="%23b" transform="translate(245 325)"/><use href="%23d" transform="translate(325 325)"/><use href="%23c" transform="translate(405 325)"/><g transform="translate(485 325)"><use href="%23a"/><use href="%23b"/></g><g transform="translate(565 325)"><use href="%23c"/><use href="%23d"/></g><g transform="translate(5 405)"><use href="%23c"/><use href="%23d"/><use href="%23b"/></g><g transform="translate(85 405)"><use href="%23c"/><use href="%23b"/></g><g transform="translate(165 405)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><use href="%23c" transform="translate(245 405)"/><g transform="translate(325 405)"><use href="%23a"/><use href="%23d"/><use href="%23b"/></g><use href="%23d" transform="translate(405 405)"/><use href="%23d" transform="translate(485 405)"/><g transform="translate(565 405)"><use href="%23a"/><use href="%23c"/></g><g transform="translate(5 485)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(85 485)"><use href="%23d"/><use href="%23b"/></g><use href="%23a" transform="translate(165 485)"/><use href="%23c" transform="translate(245 485)"/><g transform="translate(325 485)"><use href="%23a"/><use href="%23b"/></g><g transform="translate(405 485)"><use href="%23a"/><use href="%23c"/><use href="%23d"/></g><g transform="translate(485 485)"><use href="%23a"/><use href="%23c"/><use href="%23b"/></g><g transform="translate(565 485)"><use href="%23c"/><use href="%23b"/></g><g transform="translate(5 565)"><use href="%23d"/><use href="%23b"/></g><g transform="translate(85 565)"><use href="%23a"/><use href="%23d"/></g><g transform="translate(165 565)"><use href="%23c"/><use href="%23d"/></g><g transform="translate(245 565)"><use href="%23c"/><use href="%23d"/><use href="%23b"/></g><g transform="translate(325 565)"><use href="%23d"/><use href="%23b"/></g><g transform="translate(405 565)"><use href="%23a"/><use href="%23d"/></g><use href="%23d" transform="translate(485 565)"/><g transform="translate(565 565)"><use href="%23c"/><use href="%23d"/></g></g></svg>'),
        hsl(0, 0%, 5%);
    background-size: 75px;
    background-position: 50% 50%;
    font-weight: 600;
}
/* remove the default border and background
the size is picked up by the nested svg, or in case of grid-supported browser by the grid cell
*/
button {
    border: none;
    background: none;
    color: inherit;
    outline-color: hsl(0, 0%, 95%);
}

/* the background might actually be temporary */
#maze {
    max-width: 500px;
    width: 75vw;
    height: auto;
    display: block;
}

/* by default position the buttons around the .game container
the size of the container is dictated by the nested svg (the only element with a non-absolute position)
*/
.game {
    position: relative;
}
button {
    position: absolute;
    transition: color 0.2s ease-in-out;
}
button:disabled {
    cursor: not-allowed;
    color: hsl(0, 0%, 35%);
}
#play {
    color: hsl(0, 0%, 100%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.15);
}
#north {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -100%);
}
#west {
    top: 50%;
    left: 0%;
    transform: translate(-100%, -50%);
}
#east {
    top: 50%;
    right: 0%;
    transform: translate(100%, -50%);
}
#south {
    bottom: 0%;
    left: 50%;
    transform: translate(-50%, 100%);
}

/* for grid-supporting browsers position the buttons in a 3x3 grid

    .       north       .
    west    maze        east
    .       south       .

    ! be sure to reset the values included only for the default layout (for the position of the .game container and the nested buttons
*/

@supports (display: grid) {
    .game {
        display: grid;
        grid-template-columns: auto [maze-start] max-content [maze-end] auto;
        grid-template-rows: auto [maze-start] max-content [maze-end] auto;
        position: initial;
    }
    #maze {
        grid-area: maze;
    }
    button {
        position: initial;
    }
    #play {
        grid-area: maze;
        top: initial;
        left: initial;
        transform: initial;
    }
    #north {
        grid-column: maze;
        top: initial;
        left: initial;
        transform: initial;
    }
    #west {
        grid-column-end: maze-start;
        top: initial;
        left: initial;
        transform: initial;
    }
    #east {
        grid-column-start: maze-end;
        top: initial;
        right: initial;
        transform: initial;
    }
    #south {
        grid-column: maze;
        bottom: initial;
        left: initial;
        transform: initial;
    }
}

              
            
!

JS

              
                var app=function(){"use strict";function t(){}const e=t=>t;function n(t,e){for(const n in e)t[n]=e[n];return t}function r(t){return t()}function i(){return Object.create(null)}function o(t){t.forEach(r)}function a(t){return"function"==typeof t}function s(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t,e,n){t.$$.on_destroy.push(function(t,e){const n=t.subscribe(e);return n.unsubscribe?()=>n.unsubscribe():n}(e,n))}const c="undefined"!=typeof window;let u=c?()=>window.performance.now():()=>Date.now(),d=c?t=>requestAnimationFrame(t):t;const f=new Set;let h,g=!1;function $(){f.forEach(t=>{t[0](u())||(f.delete(t),t[1]())}),(g=f.size>0)&&d($)}function m(t){let e;return g||(g=!0,d($)),{promise:new Promise(n=>{f.add(e=[t,n])}),abort(){f.delete(e)}}}function p(t,e){t.appendChild(e)}function y(t,e,n){t.insertBefore(e,n||null)}function w(t){t.parentNode.removeChild(t)}function v(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function b(t){return document.createElement(t)}function _(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function k(t){return document.createTextNode(t)}function x(){return k(" ")}function P(){return k("")}function R(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function E(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function X(t,e){const n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n}let Y,C=0,M={};function j(t,e,n,r,i,o,a,s=0){const l=16.666/r;let c="{\n";for(let t=0;t<=1;t+=l){const r=e+(n-e)*o(t);c+=100*t+`%{${a(r,1-r)}}\n`}const u=c+`100% {${a(n,1-n)}}\n}`,d=`__svelte_${function(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}(u)}_${s}`;if(!M[d]){if(!h){const t=b("style");document.head.appendChild(t),h=t.sheet}M[d]=!0,h.insertRule(`@keyframes ${d} ${u}`,h.cssRules.length)}const f=t.style.animation||"";return t.style.animation=`${f?`${f}, `:""}${d} ${r}ms linear ${i}ms 1 both`,C+=1,d}function A(t,e){t.style.animation=(t.style.animation||"").split(", ").filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf("__svelte")).join(", "),e&&!--C&&d(()=>{if(C)return;let t=h.cssRules.length;for(;t--;)h.deleteRule(t);M={}})}function O(t){Y=t}const z=[],S=[],q=[],T=[],N=Promise.resolve();let B,H=!1;function W(t){q.push(t)}function D(){const t=new Set;do{for(;z.length;){const t=z.shift();O(t),V(t.$$)}for(;S.length;)S.pop()();for(let e=0;e<q.length;e+=1){const n=q[e];t.has(n)||(n(),t.add(n))}q.length=0}while(z.length);for(;T.length;)T.pop()();H=!1}function V(t){t.fragment&&(t.update(t.dirty),o(t.before_update),t.fragment.p(t.dirty,t.ctx),t.dirty=null,t.after_update.forEach(W))}function G(){return B||(B=Promise.resolve()).then(()=>{B=null}),B}function L(t,e,n){t.dispatchEvent(X(`${e?"intro":"outro"}${n}`))}const F=new Set;let I;function J(t,e){t&&t.i&&(F.delete(t),t.i(e))}function K(t,e,n,r){if(t&&t.o){if(F.has(t))return;F.add(t),I.c.push(()=>{F.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}const Q={duration:0};function U(n,r,i){let o,s,l=r(n,i),c=!1,d=0;function f(){o&&A(n,o)}function h(){const{delay:r=0,duration:i=300,easing:a=e,tick:h=t,css:g}=l||Q;g&&(o=j(n,0,1,i,r,a,g,d++)),h(0,1);const $=u()+r,p=$+i;s&&s.abort(),c=!0,W(()=>L(n,!0,"start")),s=m(t=>{if(c){if(t>=p)return h(1,0),L(n,!0,"end"),f(),c=!1;if(t>=$){const e=a((t-$)/i);h(e,1-e)}}return c})}let g=!1;return{start(){g||(A(n),a(l)?(l=l(),G().then(h)):h())},invalidate(){g=!1},end(){c&&(f(),c=!1)}}}function Z(n,r,i){let s,l=r(n,i),c=!0;const d=I;function f(){const{delay:r=0,duration:i=300,easing:a=e,tick:f=t,css:h}=l||Q;h&&(s=j(n,1,0,i,r,a,h));const g=u()+r,$=g+i;W(()=>L(n,!1,"start")),m(t=>{if(c){if(t>=$)return f(0,1),L(n,!1,"end"),--d.r||o(d.c),!1;if(t>=g){const e=a((t-g)/i);f(1-e,e)}}return c})}return d.r+=1,a(l)?G().then(()=>{l=l(),f()}):f(),{end(t){t&&l.tick&&l.tick(1,0),c&&(s&&A(n,s),c=!1)}}}function tt(t,e,n){const{fragment:i,on_mount:s,on_destroy:l,after_update:c}=t.$$;i.m(e,n),W(()=>{const e=s.map(r).filter(a);l?l.push(...e):o(e),t.$$.on_mount=[]}),c.forEach(W)}function et(t,e){t.$$.fragment&&(o(t.$$.on_destroy),t.$$.fragment.d(e),t.$$.on_destroy=t.$$.fragment=null,t.$$.ctx={})}function nt(t,e){t.$$.dirty||(z.push(t),H||(H=!0,N.then(D)),t.$$.dirty=i()),t.$$.dirty[e]=!0}function rt(e,n,r,a,s,l){const c=Y;O(e);const u=n.props||{},d=e.$$={fragment:null,ctx:null,props:l,update:t,not_equal:s,bound:i(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(c?c.$$.context:[]),callbacks:i(),dirty:null};let f=!1;var h;d.ctx=r?r(e,u,(t,n,r=n)=>(d.ctx&&s(d.ctx[t],d.ctx[t]=r)&&(d.bound[t]&&d.bound[t](r),f&&nt(e,t)),n)):u,d.update(),f=!0,o(d.before_update),d.fragment=a(d.ctx),n.target&&(n.hydrate?d.fragment.l((h=n.target,Array.from(h.childNodes))):d.fragment.c(),n.intro&&J(e.$$.fragment),tt(e,n.target,n.anchor),D()),O(c)}class it{$destroy(){et(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}function ot(e){var n,r,i,o,a,s,l;return{c(){n=_("svg"),r=_("g"),i=_("g"),o=_("g"),a=_("g"),E(s=_("path"),"d","M 0 86 100 86 100 68 87.5 68 87.5 50 75 50 75 32 62.5 32 62.5 14 37.5 14 37.5 32 25 32 25 50 12.5 50 12.5 68 0 68 0 86"),E(a,"fill","currentColor"),E(a,"stroke","currentColor"),E(o,"transform","translate(-50 -50)"),E(i,"transform",l="rotate("+e.rotation+")"),E(r,"transform","translate(50 50)"),E(n,"aria-hidden","true"),E(n,"viewBox","0 0 100 100"),E(n,"width","50"),E(n,"height","50")},m(t,e){y(t,n,e),p(n,r),p(r,i),p(i,o),p(o,a),p(a,s)},p(t,e){t.rotation&&l!==(l="rotate("+e.rotation+")")&&E(i,"transform",l)},i:t,o:t,d(t){t&&w(n)}}}function at(t,e,n){let{rotation:r=0}=e;return t.$set=(t=>{"rotation"in t&&n("rotation",r=t.rotation)}),{rotation:r}}class st extends it{constructor(t){super(),rt(this,t,at,ot,s,["rotation"])}}function lt(t){const e=t-1;return e*e*e+1}function ct(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}function ut(t){return-.5*(Math.cos(Math.PI*t)-1)}function dt(t,{delay:e=0,duration:n=400,easing:r=lt,x:i=0,y:o=0,opacity:a=0}){const s=getComputedStyle(t),l=+s.opacity,c="none"===s.transform?"":s.transform,u=l*(1-a);return{delay:e,duration:n,easing:r,css:(t,e)=>`\n\t\t\ttransform: ${c} translate(${(1-t)*i}px, ${(1-t)*o}px);\n\t\t\topacity: ${l-u*e}`}}function ft(t){var e,n,r,i,a,s,l,c,u,d,f,h,g,$,m,p,v,_,k,P,X,Y=new st({}),C=new st({props:{rotation:270}}),M=new st({props:{rotation:90}}),j=new st({props:{rotation:180}});return{c(){e=b("button"),Y.$$.fragment.c(),a=x(),s=b("button"),C.$$.fragment.c(),d=x(),f=b("button"),M.$$.fragment.c(),m=x(),p=b("button"),j.$$.fragment.c(),e.disabled=n=t.gates.north,E(e,"id","north"),E(e,"aria-label","Move the square up"),s.disabled=l=t.gates.west,E(s,"id","west"),E(s,"aria-label","Move the square left"),f.disabled=h=t.gates.east,E(f,"id","east"),E(f,"aria-label","Move the square right"),p.disabled=v=t.gates.south,E(p,"id","south"),E(p,"aria-label","Move the square down"),X=[R(e,"click",t.click_handler_1),R(s,"click",t.click_handler_2),R(f,"click",t.click_handler_3),R(p,"click",t.click_handler_4)]},m(t,n){y(t,e,n),tt(Y,e,null),y(t,a,n),y(t,s,n),tt(C,s,null),y(t,d,n),y(t,f,n),tt(M,f,null),y(t,m,n),y(t,p,n),tt(j,p,null),P=!0},p(t,r){P&&!t.gates||n===(n=r.gates.north)||(e.disabled=n),P&&!t.gates||l===(l=r.gates.west)||(s.disabled=l),P&&!t.gates||h===(h=r.gates.east)||(f.disabled=h),P&&!t.gates||v===(v=r.gates.south)||(p.disabled=v)},i(t){P||(J(Y.$$.fragment,t),W(()=>{i&&i.end(1),r||(r=U(e,dt,{delay:150})),r.start()}),J(C.$$.fragment,t),W(()=>{u&&u.end(1),c||(c=U(s,dt,{delay:150})),c.start()}),J(M.$$.fragment,t),W(()=>{$&&$.end(1),g||(g=U(f,dt,{delay:150})),g.start()}),J(j.$$.fragment,t),W(()=>{k&&k.end(1),_||(_=U(p,dt,{delay:150})),_.start()}),P=!0)},o(t){K(Y.$$.fragment,t),r&&r.invalidate(),i=Z(e,dt,{duration:200}),K(C.$$.fragment,t),c&&c.invalidate(),u=Z(s,dt,{duration:200}),K(M.$$.fragment,t),g&&g.invalidate(),$=Z(f,dt,{duration:200}),K(j.$$.fragment,t),_&&_.invalidate(),k=Z(p,dt,{duration:200}),P=!1},d(t){t&&w(e),et(Y),t&&(i&&i.end(),w(a),w(s)),et(C),t&&(u&&u.end(),w(d),w(f)),et(M),t&&($&&$.end(),w(m),w(p)),et(j),t&&k&&k.end(),o(X)}}}function ht(e){var n,r,i,o,a=new st({props:{rotation:90}});return{c(){n=b("button"),a.$$.fragment.c(),E(n,"id","play"),E(n,"aria-label","Play the infinite maze"),o=R(n,"click",e.click_handler)},m(t,e){y(t,n,e),tt(a,n,null),i=!0},p:t,i(t){i||(J(a.$$.fragment,t),r&&r.end(1),i=!0)},o(t){K(a.$$.fragment,t),r=Z(n,$t,{}),i=!1},d(t){t&&w(n),et(a),t&&r&&r.end(),o()}}}function gt(t){var e,n,r,i,a=[ht,ft],s=[];function l(t,e){return e.isPlaying?e.isReady?1:-1:0}return~(e=l(0,t))&&(n=s[e]=a[e](t)),{c(){n&&n.c(),r=P()},m(t,n){~e&&s[e].m(t,n),y(t,r,n),i=!0},p(t,i){var c=e;(e=l(0,i))===c?~e&&s[e].p(t,i):(n&&(I={r:0,c:[],p:I},K(s[c],1,1,()=>{s[c]=null}),I.r||o(I.c),I=I.p),~e?((n=s[e])||(n=s[e]=a[e](i)).c(),J(n,1),n.m(r.parentNode,r)):n=null)},i(t){i||(J(n),i=!0)},o(t){K(n),i=!1},d(t){~e&&s[e].d(t),t&&w(r)}}}function $t(t,{duration:e=250}){return{duration:e,css:t=>{return`transform: scale(${ut(t)});`}}}function mt(t,e,n){const r=function(){const t=Y;return(e,n)=>{const r=t.$$.callbacks[e];if(r){const i=X(e,n);r.slice().forEach(e=>{e.call(t,i)})}}}();function i(t){r("control",t)}let{isPlaying:o,isReady:a,gates:s={north:!1,east:!1,south:!1,west:!1}}=e;return t.$set=(t=>{"isPlaying"in t&&n("isPlaying",o=t.isPlaying),"isReady"in t&&n("isReady",a=t.isReady),"gates"in t&&n("gates",s=t.gates)}),{handleDispatch:i,isPlaying:o,isReady:a,gates:s,click_handler:()=>i("play"),click_handler_1:()=>i("north"),click_handler_2:()=>i("west"),click_handler_3:()=>i("east"),click_handler_4:()=>i("south")}}class pt extends it{constructor(t){super(),rt(this,t,mt,gt,s,["isPlaying","isReady","gates"])}}function yt(e){var n,r,i;return{c(){n=_("svg"),E(r=_("rect"),"fill",e.fill),E(r,"x","0"),E(r,"y","0"),E(r,"width",e.width),E(r,"height",e.height),E(n,"aria-hidden","true"),E(n,"viewBox",i="0 0 "+e.width+" "+e.height),E(n,"width",e.width),E(n,"height",e.height)},m(t,e){y(t,n,e),p(n,r)},p(t,e){t.fill&&E(r,"fill",e.fill),t.width&&E(r,"width",e.width),t.height&&E(r,"height",e.height),(t.width||t.height)&&i!==(i="0 0 "+e.width+" "+e.height)&&E(n,"viewBox",i),t.width&&E(n,"width",e.width),t.height&&E(n,"height",e.height)},i:t,o:t,d(t){t&&w(n)}}}function wt(t,e,n){let{width:r,height:i,fill:o}=e;return t.$set=(t=>{"width"in t&&n("width",r=t.width),"height"in t&&n("height",i=t.height),"fill"in t&&n("fill",o=t.fill)}),{width:r,height:i,fill:o}}class vt extends it{constructor(t){super(),rt(this,t,wt,yt,s,["width","height","fill"])}}function bt(t){return Math.floor(Math.random()*t)}function _t(t,e,n=[-1,-1]){const[r,i]=n,o=bt(t),a=bt(e);return o===r&&a===i?_t(t,e,n):[o,a]}const kt=(t,e)=>new Promise(n=>{const r=[["north","south"],["east","west"]],i=Array(e).fill().map((e,n)=>Array(t).fill().map((t,e)=>({column:e,row:n,gates:{north:!0,east:!0,south:!0,west:!0},isVisited:!1}))).reduce((t,e)=>[...t,...e],[]);!function o(a,s){const l=i.find(({column:t,row:e})=>t===a&&e===s);l.isVisited=!0;const c=[{gate:"north",coordinates:[a,s-1]},{gate:"east",coordinates:[a+1,s]},{gate:"south",coordinates:[a,s+1]},{gate:"west",coordinates:[a-1,s]}].filter(({coordinates:n})=>{const[r,i]=n;return r>=0&&r<=t-1&&i>=0&&i<=e-1}),u=(d=c)[bt(d.length)];var d;const{gate:f}=u,[h,g]=u.coordinates,$=i.find(({column:t,row:e})=>t===h&&e===g);if(!$.isVisited){l.gates[f]=!1;const t=r.find(t=>t.includes(f)).find(t=>t!==f);$.gates[t]=!1}i.every(({isVisited:t})=>t)?n(i):o(h,g)}(bt(t),bt(e))}),xt=[];function Pt(t){return"[object Date]"===Object.prototype.toString.call(t)}function Rt(t,e){if(t===e||t!=t)return()=>t;const n=typeof t;if(n!==typeof e||Array.isArray(t)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(t)){const n=e.map((e,n)=>Rt(t[n],e));return t=>n.map(e=>e(t))}if("object"===n){if(!t||!e)throw new Error("Object cannot be null");if(Pt(t)&&Pt(e)){t=t.getTime();const n=(e=e.getTime())-t;return e=>new Date(t+e*n)}const n=Object.keys(e),r={};return n.forEach(n=>{r[n]=Rt(t[n],e[n])}),t=>{const e={};return n.forEach(n=>{e[n]=r[n](t)}),e}}if("number"===n){const n=e-t;return e=>t+e*n}throw new Error(`Cannot interpolate ${n} values`)}function Et(r,i={}){const o=function(e,n=t){let r;const i=[];function o(t){if(s(e,t)&&(e=t,r)){const t=!xt.length;for(let t=0;t<i.length;t+=1){const n=i[t];n[1](),xt.push(n,e)}if(t){for(let t=0;t<xt.length;t+=2)xt[t][0](xt[t+1]);xt.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=t){const l=[a,s];return i.push(l),1===i.length&&(r=n(o)||t),a(e),()=>{const t=i.indexOf(l);-1!==t&&i.splice(t,1),0===i.length&&(r(),r=null)}}}}(r);let a,l=r;function c(t,s){l=t;let c=a,d=!1,{delay:f=0,duration:h=400,easing:g=e,interpolate:$=Rt}=n(n({},i),s);const p=u()+f;let y;return(a=m(e=>{if(e<p)return!0;d||(y=$(r,t),"function"==typeof h&&(h=h(r,t)),d=!0),c&&(c.abort(),c=null);const n=e-p;return n>h?(o.set(r=t),!1):(o.set(r=y(g(n/h))),!0)})).promise}return{set:c,update:(t,e)=>c(t(l,r),e),subscribe:o.subscribe}}function Xt(t,e,n){const r=Object.create(t);return r.href=e[n][0],r.isGated=e[n][1],r}function Yt(t,e,n){const r=Object.create(t);return r.column=e[n].column,r.row=e[n].row,r.gates=e[n].gates,r}function Ct(t){var e,n;let r=t.maze,i=[];for(let e=0;e<r.length;e+=1)i[e]=At(Yt(t,r,e));return{c(){e=_("rect");for(let t=0;t<i.length;t+=1)i[t].c();n=P(),E(e,"x","0"),E(e,"y","0"),E(e,"width",t.width),E(e,"height",t.height),E(e,"fill","hsl(0, 0%, 5%)")},m(t,r){y(t,e,r);for(let e=0;e<i.length;e+=1)i[e].m(t,r);y(t,n,r)},p(t,e){if(t.maze||t.h||t.v){let o;for(r=e.maze,o=0;o<r.length;o+=1){const a=Yt(e,r,o);i[o]?i[o].p(t,a):(i[o]=At(a),i[o].c(),i[o].m(n.parentNode,n))}for(;o<i.length;o+=1)i[o].d(1);i.length=r.length}},d(t){t&&w(e),v(i,t),t&&w(n)}}}function Mt(t){var e,n;return{c(){E(e=_("use"),"href",n="#"+t.href)},m(t,n){y(t,e,n)},p(t,r){t.maze&&n!==(n="#"+r.href)&&E(e,"href",n)},d(t){t&&w(e)}}}function jt(t){var e,n=t.isGated&&Mt(t);return{c(){n&&n.c(),e=P()},m(t,r){n&&n.m(t,r),y(t,e,r)},p(t,r){r.isGated?n?n.p(t,r):((n=Mt(r)).c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null)},d(t){n&&n.d(t),t&&w(e)}}}function At(t){var e,n;let r=Object.entries(t.gates),i=[];for(let e=0;e<r.length;e+=1)i[e]=jt(Xt(t,r,e));return{c(){e=_("g");for(let t=0;t<i.length;t+=1)i[t].c();E(e,"transform",n="translate("+t.column*zt+" "+t.row*St+")")},m(t,n){y(t,e,n);for(let t=0;t<i.length;t+=1)i[t].m(e,null)},p(t,o){if(t.maze){let n;for(r=Object.entries(o.gates),n=0;n<r.length;n+=1){const a=Xt(o,r,n);i[n]?i[n].p(t,a):(i[n]=jt(a),i[n].c(),i[n].m(e,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=r.length}t.maze&&n!==(n="translate("+o.column*zt+" "+o.row*St+")")&&E(e,"transform",n)},d(t){t&&w(e),v(i,t)}}}function Ot(t){var e,n,r,i,o,a,s,l,c,u,d,f,h,g,$,m,v,k,P=t.isSetup&&Ct(t),X=new vt({props:{fill:"hsl(0, 0%, 25%)",width:zt-qt,height:St-qt}}),Y=new vt({props:{fill:"hsl(340, 70%, 50%)",width:zt-qt,height:St-qt}}),C=new pt({props:{gates:t.cell?t.cell.gates:"",isPlaying:t.isPlaying,isReady:t.isReady}});return C.$on("control",t.handleControl),{c(){e=b("div"),n=_("svg"),r=_("defs"),i=_("path"),o=_("path"),a=_("path"),s=_("path"),l=_("g"),c=_("g"),P&&P.c(),u=_("g"),d=_("g"),X.$$.fragment.c(),h=_("g"),Y.$$.fragment.c(),m=x(),C.$$.fragment.c(),E(i,"id","north"),E(i,"d","M 0 0 h "+zt),E(o,"id","east"),E(o,"d","M "+zt+" 0 v "+St),E(a,"id","south"),E(a,"d","M 0 "+St+" h "+zt),E(s,"id","west"),E(s,"d","M 0 0 v "+St),E(c,"transform","translate("+qt/2+" "+qt/2+")"),E(l,"stroke","currentColor"),E(l,"stroke-width",qt),E(l,"stroke-linejoin","square"),E(l,"stroke-linecap","square"),E(l,"fill","none"),E(d,"id","goal"),E(d,"transform",f="translate("+t.gX*zt+" "+t.gY*St+")"),E(h,"id","player"),E(h,"transform",g="translate("+t.$pX*zt+" "+t.$pY*St+")"),E(u,"transform","translate("+qt+" "+qt+")"),E(n,"id","maze"),E(n,"viewBox",$=t.$vX+" "+t.$vY+" "+t.$vWidth+" "+t.$vHeight),E(n,"width",t.width),E(n,"height",t.height),E(e,"class","game"),k=R(window,"keydown",t.keydown_handler)},m(t,f){y(t,e,f),p(e,n),p(n,r),p(r,i),p(r,o),p(r,a),p(r,s),p(n,l),p(l,c),P&&P.m(c,null),p(n,u),p(u,d),tt(X,d,null),p(u,h),tt(Y,h,null),p(e,m),tt(C,e,null),v=!0},p(t,e){e.isSetup?P?P.p(t,e):((P=Ct(e)).c(),P.m(c,null)):P&&(P.d(1),P=null),v&&!t.gX&&!t.gY||f===(f="translate("+e.gX*zt+" "+e.gY*St+")")||E(d,"transform",f),v&&!t.$pX&&!t.$pY||g===(g="translate("+e.$pX*zt+" "+e.$pY*St+")")||E(h,"transform",g),(!v||t.$vX||t.$vY||t.$vWidth||t.$vHeight)&&$!==($=e.$vX+" "+e.$vY+" "+e.$vWidth+" "+e.$vHeight)&&E(n,"viewBox",$);var r={};t.cell&&(r.gates=e.cell?e.cell.gates:""),t.isPlaying&&(r.isPlaying=e.isPlaying),t.isReady&&(r.isReady=e.isReady),C.$set(r)},i(t){v||(J(X.$$.fragment,t),J(Y.$$.fragment,t),J(C.$$.fragment,t),v=!0)},o(t){K(X.$$.fragment,t),K(Y.$$.fragment,t),K(C.$$.fragment,t),v=!1},d(t){t&&w(e),P&&P.d(),et(X),et(Y),et(C),k()}}}const zt=100,St=100,qt=10,Tt=5,Nt=5;function Bt(t,e,n){let r,i,o,a,s,c,u=!1,d=!1,f=!1;const h=Tt*zt,g=Nt*St;let $,m=[];const p=Tt/2-.5,y=Nt/2-.5;let w=p,v=y,b=Et(p);l(t,b,t=>{n("$pX",r=t)});let _=Et(y);l(t,_,t=>{n("$pY",i=t)});let k=Et(0);l(t,k,t=>{n("$vX",o=t)});let x=Et(0);l(t,x,t=>{n("$vY",a=t)});let P=Et(h+qt);l(t,P,t=>{n("$vWidth",s=t)});let R=Et(g+qt);function E(){n("gX",[w,v]=_t(Tt,Nt),w,n("gY",v));let[t,e]=_t(Tt,Nt,[w,v]);n("cell",$=m.find(({column:n,row:r})=>n===t&&r===e)),b.set(t,{duration:0}),_.set(e,{duration:0}),k.set(t*zt+qt,{duration:0}),x.set(e*St+qt,{duration:0});let r=setTimeout(()=>{!function(){const t={easing:ct,duration:450};n("isReady",d=!0),k.set(0,t),x.set(0,t),P.set(h+qt,t),R.set(g+qt,t)}(),clearTimeout(r)},1e3)}function X(){n("isPlaying",u=!0),n("isReady",d=!1);const t={easing:ct,duration:500};k.set(r*zt+qt,t),x.set(i*St+qt,t),P.set(zt-qt,t),R.set(St-qt,t);let e=setTimeout(()=>{kt(Tt,Nt).then(t=>{n("maze",m=t),n("isSetup",f=!0),E(),clearTimeout(e)})},1e3)}l(t,R,t=>{n("$vHeight",c=t)});const Y={north:{y:-1},south:{y:1},west:{x:-1},east:{x:1}},C=[[38,"north"],[39,"east"],[40,"south"],[37,"west"]];let M=!1;function j(t){if(d&&!M&&!$.gates[t]){const e={duration:150,easing:ut},{x:o=0,y:a=0}=Y[t],s=r+o,l=i+a;n("cell",$=m.find(({column:t,row:e})=>t===s&&e===l)),b.set(s,e),_.set(l,e),M=!0;setTimeout(()=>{s===w&&l===v&&X(),M=!1},e.duration+50)}}return{isPlaying:u,isReady:d,isSetup:f,width:h,height:g,cell:$,maze:m,gX:w,gY:v,pX:b,pY:_,vX:k,vY:x,vWidth:P,vHeight:R,keyCodes:C,moveSquare:j,handleControl:function(t){const e=t.detail;switch(e){case"play":X();break;case"north":case"west":case"east":case"south":j(e)}},$pX:r,$pY:i,$vX:o,$vY:a,$vWidth:s,$vHeight:c,keydown_handler:({keyCode:t})=>{const e=C.find(([e])=>e===t);e&&j(e[1])}}}return new class extends it{constructor(t){super(),rt(this,t,Bt,Ot,s,[])}}({target:document.body})}();
              
            
!
999px

Console