diff --git a/about/index.html b/about/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/about/index.html
+++ b/about/index.html
@@ -1 +1 @@
-
NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/asm/index.html b/asm/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/asm/index.html
+++ b/asm/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/asset-manifest.json b/asset-manifest.json
index 48b7c417b..62786cca7 100644
--- a/asset-manifest.json
+++ b/asset-manifest.json
@@ -1,8 +1,8 @@
{
"files": {
"main.css": "/web-ide/static/css/main.9d762a7f.css",
- "main.js": "/web-ide/static/js/main.66e9b6eb.js",
- "static/js/288.1852c135.chunk.js": "/web-ide/static/js/288.1852c135.chunk.js",
+ "main.js": "/web-ide/static/js/main.9984f23c.js",
+ "static/js/288.3bdeec9c.chunk.js": "/web-ide/static/js/288.3bdeec9c.chunk.js",
"static/js/297.2c45dab0.chunk.js": "/web-ide/static/js/297.2c45dab0.chunk.js",
"static/js/269.1e46835e.chunk.js": "/web-ide/static/js/269.1e46835e.chunk.js",
"static/js/608.6d63ee31.chunk.js": "/web-ide/static/js/608.6d63ee31.chunk.js",
@@ -17,7 +17,7 @@
"static/css/34.2a1f584b.chunk.css": "/web-ide/static/css/34.2a1f584b.chunk.css",
"static/js/34.9f280457.chunk.js": "/web-ide/static/js/34.9f280457.chunk.js",
"static/css/598.4a56c158.chunk.css": "/web-ide/static/css/598.4a56c158.chunk.css",
- "static/js/598.beb31f34.chunk.js": "/web-ide/static/js/598.beb31f34.chunk.js",
+ "static/js/598.183c6bb5.chunk.js": "/web-ide/static/js/598.183c6bb5.chunk.js",
"static/css/408.4548b55f.chunk.css": "/web-ide/static/css/408.4548b55f.chunk.css",
"static/js/408.e6e0ca78.chunk.js": "/web-ide/static/js/408.e6e0ca78.chunk.js",
"static/js/614.12dbb7c0.chunk.js": "/web-ide/static/js/614.12dbb7c0.chunk.js",
@@ -33,6 +33,6 @@
},
"entrypoints": [
"static/css/main.9d762a7f.css",
- "static/js/main.66e9b6eb.js"
+ "static/js/main.9984f23c.js"
]
}
\ No newline at end of file
diff --git a/bitmap/index.html b/bitmap/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/bitmap/index.html
+++ b/bitmap/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/chip/index.html b/chip/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/chip/index.html
+++ b/chip/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/compiler/index.html b/compiler/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/compiler/index.html
+++ b/compiler/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/cpu/index.html b/cpu/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/cpu/index.html
+++ b/cpu/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/guide/index.html b/guide/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/guide/index.html
+++ b/guide/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/index.html b/index.html
index 90dacf8c5..8b1f6a528 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-NAND2Tetris
\ No newline at end of file
+NAND2Tetris
\ No newline at end of file
diff --git a/service-worker.js b/service-worker.js
index 5033752a9..df07da91c 100644
--- a/service-worker.js
+++ b/service-worker.js
@@ -1 +1 @@
-(()=>{"use strict";var e={42:()=>{try{self["workbox:core:6.5.4"]&&_()}catch(e){}},940:()=>{try{self["workbox:expiration:6.5.4"]&&_()}catch(e){}},881:()=>{try{self["workbox:precaching:6.5.4"]&&_()}catch(e){}},661:()=>{try{self["workbox:routing:6.5.4"]&&_()}catch(e){}},772:()=>{try{self["workbox:strategies:6.5.4"]&&_()}catch(e){}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{s(42);const e=(e,...t)=>{let s=e;return t.length>0&&(s+=` :: ${JSON.stringify(t)}`),s};class t extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}const n=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!==typeof registration?registration.scope:""},a=e=>[r.prefix,e,r.suffix].filter((e=>e&&e.length>0)).join("-"),i=e=>e||a(r.precache),o=e=>e||a(r.runtime);function c(e,t){const s=new URL(e);for(const n of t)s.searchParams.delete(n);return s.href}let h;function l(e){e.then((()=>{}))}class u{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}const d=e=>new URL(String(e),location.href).href.replace(new RegExp(`^${location.origin}`),"");function p(e){return new Promise((t=>setTimeout(t,e)))}function f(e,t){const s=t();return e.waitUntil(s),s}async function g(e,s){let n=null;if(e.url){n=new URL(e.url).origin}if(n!==self.location.origin)throw new t("cross-origin-copy-response",{origin:n});const r=e.clone(),a={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},i=s?s(a):a,o=function(){if(void 0===h){const t=new Response("");if("body"in t)try{new Response(t.body),h=!0}catch(e){h=!1}h=!1}return h}()?r.body:await r.blob();return new Response(o,i)}const m=(e,t)=>t.some((t=>e instanceof t));let w,y;const _=new WeakMap,v=new WeakMap,b=new WeakMap,R=new WeakMap,x=new WeakMap;let C={get(e,t,s){if(e instanceof IDBTransaction){if("done"===t)return v.get(e);if("objectStoreNames"===t)return e.objectStoreNames||b.get(e);if("store"===t)return s.objectStoreNames[1]?void 0:s.objectStore(s.objectStoreNames[0])}return q(e[t])},set:(e,t,s)=>(e[t]=s,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function L(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(y||(y=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(U(this),t),q(_.get(this))}:function(...t){return q(e.apply(U(this),t))}:function(t,...s){const n=e.call(U(this),t,...s);return b.set(n,t.sort?t.sort():[t]),q(n)}}function E(e){return"function"===typeof e?L(e):(e instanceof IDBTransaction&&function(e){if(v.has(e))return;const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",a),e.removeEventListener("abort",a)},r=()=>{t(),n()},a=()=>{s(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",r),e.addEventListener("error",a),e.addEventListener("abort",a)}));v.set(e,t)}(e),m(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,C):e)}function q(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("success",r),e.removeEventListener("error",a)},r=()=>{t(q(e.result)),n()},a=()=>{s(e.error),n()};e.addEventListener("success",r),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&_.set(t,e)})).catch((()=>{})),x.set(t,e),t}(e);if(R.has(e))return R.get(e);const t=E(e);return t!==e&&(R.set(e,t),x.set(t,e)),t}const U=e=>x.get(e);const D=["get","getKey","getAll","getAllKeys","count"],k=["put","add","delete","clear"],T=new Map;function N(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!==typeof t)return;if(T.get(t))return T.get(t);const s=t.replace(/FromIndex$/,""),n=t!==s,r=k.includes(s);if(!(s in(n?IDBIndex:IDBObjectStore).prototype)||!r&&!D.includes(s))return;const a=async function(e,...t){const a=this.transaction(e,r?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[s](...t),r&&a.done]))[0]};return T.set(t,a),a}C=(e=>({...e,get:(t,s,n)=>N(t,s)||e.get(t,s,n),has:(t,s)=>!!N(t,s)||e.has(t,s)}))(C);s(940);const I="cache-entries",K=e=>{const t=new URL(e,location.href);return t.hash="",t.href};class M{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(I,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&function(e,{blocked:t}={}){const s=indexedDB.deleteDatabase(e);t&&s.addEventListener("blocked",(e=>t(e.oldVersion,e))),q(s).then((()=>{}))}(this._cacheName)}async setTimestamp(e,t){const s={url:e=K(e),timestamp:t,cacheName:this._cacheName,id:this._getId(e)},n=(await this.getDb()).transaction(I,"readwrite",{durability:"relaxed"});await n.store.put(s),await n.done}async getTimestamp(e){const t=await this.getDb(),s=await t.get(I,this._getId(e));return null===s||void 0===s?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let n=await s.transaction(I).store.index("timestamp").openCursor(null,"prev");const r=[];let a=0;for(;n;){const s=n.value;s.cacheName===this._cacheName&&(e&&s.timestamp=t?r.push(n.value):a++),n=await n.continue()}const i=[];for(const o of r)await s.delete(I,o.id),i.push(o.url);return i}_getId(e){return this._cacheName+"|"+K(e)}async getDb(){return this._db||(this._db=await function(e,t,{blocked:s,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(e,t),o=q(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(q(i.result),e.oldVersion,e.newVersion,q(i.transaction),e)})),s&&i.addEventListener("blocked",(e=>s(e.oldVersion,e.newVersion,e))),o.then((e=>{a&&e.addEventListener("close",(()=>a())),r&&e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("workbox-expiration",1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class P{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new M(e)}async expireEntries(){if(this._isRunning)return void(this._rerunRequested=!0);this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-1e3*this._maxAgeSeconds:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const n of t)await s.delete(n,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,l(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-1e3*this._maxAgeSeconds;return void 0===t||t{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if("install"===e.type&&t&&t.originalRequest&&t.originalRequest instanceof Request){const e=t.originalRequest.url;s?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return s}}}class A{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{const s=(null===t||void 0===t?void 0:t.cacheKey)||this._precacheController.getCacheKeyForURL(e.url);return s?new Request(s,{headers:e.headers}):e},this._precacheController=e}}s(772);function j(e){return"string"===typeof e?new Request(e):e}class B{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new u,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:s}=this;let n=j(e);if("navigate"===n.mode&&s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const e of this.iterateCallbacks("requestWillFetch"))n=await e({request:n.clone(),event:s})}catch(i){if(i instanceof Error)throw new t("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const a=n.clone();try{let e;e=await fetch(n,"navigate"===n.mode?void 0:this._strategy.fetchOptions);for(const t of this.iterateCallbacks("fetchDidSucceed"))e=await t({event:s,request:a,response:e});return e}catch(o){throw r&&await this.runCallbacks("fetchDidFail",{error:o,event:s,originalRequest:r.clone(),request:a.clone()}),o}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=j(e);let s;const{cacheName:n,matchOptions:r}=this._strategy,a=await this.getCacheKey(t,"read"),i=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(a,i);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:n,matchOptions:r,cachedResponse:s,request:a,event:this.event})||void 0;return s}async cachePut(e,s){const r=j(e);await p(0);const a=await this.getCacheKey(r,"write");if(!s)throw new t("cache-put-with-no-response",{url:d(a.url)});const i=await this._ensureResponseSafeToCache(s);if(!i)return!1;const{cacheName:o,matchOptions:h}=this._strategy,l=await self.caches.open(o),u=this.hasCallback("cacheDidUpdate"),f=u?await async function(e,t,s,n){const r=c(t.url,s);if(t.url===r)return e.match(t,n);const a=Object.assign(Object.assign({},n),{ignoreSearch:!0}),i=await e.keys(t,a);for(const o of i)if(r===c(o.url,s))return e.match(o,n)}(l,a.clone(),["__WB_REVISION__"],h):null;try{await l.put(a,u?i.clone():i)}catch(g){if(g instanceof Error)throw"QuotaExceededError"===g.name&&await async function(){for(const e of n)await e()}(),g}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:o,oldResponse:f,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let n=e;for(const e of this.iterateCallbacks("cacheKeyWillBeUsed"))n=j(await e({mode:t,request:n,event:this.event,params:this.params}));this._cacheKeys[s]=n}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if("function"===typeof t[e]){const s=this._pluginStateMap.get(t),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return t[e](r)};yield n}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const n of this.iterateCallbacks("cacheWillUpdate"))if(t=await n({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&200!==t.status&&(t=void 0),t}}class W{constructor(e={}){this.cacheName=o(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s="string"===typeof e.request?new Request(e.request):e.request,n="params"in e?e.params:void 0,r=new B(this,{event:t,request:s,params:n}),a=this._getResponse(r,s,t);return[a,this._awaitComplete(a,r,s,t)]}async _getResponse(e,s,n){let r;await e.runCallbacks("handlerWillStart",{event:n,request:s});try{if(r=await this._handle(s,e),!r||"error"===r.type)throw new t("no-response",{url:s.url})}catch(a){if(a instanceof Error)for(const t of e.iterateCallbacks("handlerDidError"))if(r=await t({error:a,event:n,request:s}),r)break;if(!r)throw a}for(const t of e.iterateCallbacks("handlerWillRespond"))r=await t({event:n,request:s,response:r});return r}async _awaitComplete(e,t,s,n){let r,a;try{r=await e}catch(a){}try{await t.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await t.doneWaiting()}catch(i){i instanceof Error&&(a=i)}if(await t.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:a}),t.destroy(),a)throw a}}class F extends W{constructor(e={}){e.cacheName=i(e.cacheName),super(e),this._fallbackToNetwork=!1!==e.fallbackToNetwork,this.plugins.push(F.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&"install"===t.event.type?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,s){let n;const r=s.params||{};if(!this._fallbackToNetwork)throw new t("missing-precache-entry",{cacheName:this.cacheName,url:e.url});{0;const t=r.integrity,a=e.integrity,i=!a||a===t;if(n=await s.fetch(new Request(e,{integrity:"no-cors"!==e.mode?a||t:void 0})),t&&i&&"no-cors"!==e.mode){this._useDefaultCacheabilityPluginIfNeeded();await s.cachePut(e,n.clone());0}}return n}async _handleInstall(e,s){this._useDefaultCacheabilityPluginIfNeeded();const n=await s.fetch(e);if(!await s.cachePut(e,n.clone()))throw new t("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,n]of this.plugins.entries())n!==F.copyRedirectedCacheableResponsesPlugin&&(n===F.defaultPrecacheCacheabilityPlugin&&(e=s),n.cacheWillUpdate&&t++);0===t?this.plugins.push(F.defaultPrecacheCacheabilityPlugin):t>1&&null!==e&&this.plugins.splice(e,1)}}F.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:e})=>!e||e.status>=400?null:e},F.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:e})=>e.redirected?await g(e):e};class H{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new F({cacheName:i(e),plugins:[...t,new A({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const s=[];for(const n of e){"string"===typeof n?s.push(n):n&&void 0===n.revision&&s.push(n.url);const{cacheKey:e,url:r}=S(n),a="string"!==typeof n&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==e)throw new t("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:e});if("string"!==typeof n&&n.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==n.integrity)throw new t("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(e,n.integrity)}if(this._urlsToCacheKeys.set(r,e),this._urlsToCacheModes.set(r,a),s.length>0){const e=`Workbox is precaching URLs without revision info: ${s.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return f(e,(async()=>{const t=new O;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const t=this._cacheKeysToIntegrities.get(a),s=this._urlsToCacheModes.get(r),n=new Request(r,{integrity:t,cache:s,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:n,event:e}))}const{updatedURLs:s,notUpdatedURLs:n}=t;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(e){return f(e,(async()=>{const e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),s=new Set(this._urlsToCacheKeys.values()),n=[];for(const r of t)s.has(r.url)||(await e.delete(r),n.push(r.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(e){const s=this.getCacheKeyForURL(e);if(!s)throw new t("non-precached-url",{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:s},t.params),this.strategy.handle(t))}}let V;const $=()=>(V||(V=new H),V);s(661);const G=e=>e&&"object"===typeof e?e:{handle:e};class Q{constructor(e,t,s="GET"){this.handler=G(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=G(e)}}class J extends Q{constructor(e,t,s){super((({url:t})=>{const s=e.exec(t.href);if(s&&(t.origin===location.origin||0===s.index))return s.slice(1)}),t,s)}}class Y{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&"CACHE_URLS"===e.data.type){const{payload:t}=e.data;0;const s=Promise.all(t.urlsToCache.map((t=>{"string"===typeof t&&(t=[t]);const s=new Request(...t);return this.handleRequest({request:s,event:e})})));e.waitUntil(s),e.ports&&e.ports[0]&&s.then((()=>e.ports[0].postMessage(!0)))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return void 0;const n=s.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:n,url:s});let i=a&&a.handler;const o=e.method;if(!i&&this._defaultHandlerMap.has(o)&&(i=this._defaultHandlerMap.get(o)),!i)return void 0;let c;try{c=i.handle({url:s,request:e,event:t,params:r})}catch(l){c=Promise.reject(l)}const h=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||h)&&(c=c.catch((async n=>{if(h){0;try{return await h.handle({url:s,request:e,event:t,params:r})}catch(a){a instanceof Error&&(n=a)}}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw n}))),c}findMatchingRoute({url:e,sameOrigin:t,request:s,event:n}){const r=this._routes.get(s.method)||[];for(const a of r){let r;const i=a.match({url:e,sameOrigin:t,request:s,event:n});if(i)return r=i,(Array.isArray(r)&&0===r.length||i.constructor===Object&&0===Object.keys(i).length||"boolean"===typeof i)&&(r=void 0),{route:a,params:r}}return{}}setDefaultHandler(e,t="GET"){this._defaultHandlerMap.set(t,G(e))}setCatchHandler(e){this._catchHandler=G(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t("unregister-route-but-not-found-with-method",{method:e.method});const s=this._routes.get(e.method).indexOf(e);if(!(s>-1))throw new t("unregister-route-route-not-registered");this._routes.get(e.method).splice(s,1)}}let X;const z=()=>(X||(X=new Y,X.addFetchListener(),X.addCacheListener()),X);function Z(e,s,n){let r;if("string"===typeof e){const t=new URL(e,location.href);0;r=new Q((({url:e})=>e.href===t.href),s,n)}else if(e instanceof RegExp)r=new J(e,s,n);else if("function"===typeof e)r=new Q(e,s,n);else{if(!(e instanceof Q))throw new t("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});r=e}return z().registerRoute(r),r}class ee extends Q{constructor(e,t){super((({request:s})=>{const n=e.getURLsToCacheKeys();for(const r of function*(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const a=new URL(e,location.href);a.hash="",yield a.href;const i=function(e,t=[]){for(const s of[...e.searchParams.keys()])t.some((e=>e.test(s)))&&e.searchParams.delete(s);return e}(a,t);if(yield i.href,s&&i.pathname.endsWith("/")){const e=new URL(i.href);e.pathname+=s,yield e.href}if(n){const e=new URL(i.href);e.pathname+=".html",yield e.href}if(r){const e=r({url:a});for(const t of e)yield t.href}}(s.url,t)){const t=n.get(r);if(t){return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}}}),e.strategy)}}const te={cacheWillUpdate:async({response:e})=>200===e.status||0===e.status?e:null};var se;self.addEventListener("activate",(()=>self.clients.claim())),function(e){$().precache(e)}([...[{'revision':'fc5d086f4544223951f0b53b33b961ab','url':'/web-ide/index.html'},{'revision':null,'url':'/web-ide/static/css/34.2a1f584b.chunk.css'},{'revision':null,'url':'/web-ide/static/css/408.4548b55f.chunk.css'},{'revision':null,'url':'/web-ide/static/css/519.829f2cf9.chunk.css'},{'revision':null,'url':'/web-ide/static/css/535.a8c1f171.chunk.css'},{'revision':null,'url':'/web-ide/static/css/598.4a56c158.chunk.css'},{'revision':null,'url':'/web-ide/static/css/744.3fc532fa.chunk.css'},{'revision':null,'url':'/web-ide/static/css/787.968be482.chunk.css'},{'revision':null,'url':'/web-ide/static/css/main.9d762a7f.css'},{'revision':null,'url':'/web-ide/static/js/269.1e46835e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/288.1852c135.chunk.js'},{'revision':null,'url':'/web-ide/static/js/297.2c45dab0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/323.14a08baf.chunk.js'},{'revision':null,'url':'/web-ide/static/js/34.9f280457.chunk.js'},{'revision':null,'url':'/web-ide/static/js/408.e6e0ca78.chunk.js'},{'revision':null,'url':'/web-ide/static/js/519.0a360ef5.chunk.js'},{'revision':null,'url':'/web-ide/static/js/535.74ad7816.chunk.js'},{'revision':null,'url':'/web-ide/static/js/537.c02a5bfa.chunk.js'},{'revision':null,'url':'/web-ide/static/js/578.b9f22ec3.chunk.js'},{'revision':null,'url':'/web-ide/static/js/598.beb31f34.chunk.js'},{'revision':null,'url':'/web-ide/static/js/608.6d63ee31.chunk.js'},{'revision':null,'url':'/web-ide/static/js/614.12dbb7c0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/656.c1a30912.chunk.js'},{'revision':null,'url':'/web-ide/static/js/744.e7730500.chunk.js'},{'revision':null,'url':'/web-ide/static/js/787.781c176c.chunk.js'},{'revision':null,'url':'/web-ide/static/js/828.e00c10f6.chunk.js'},{'revision':null,'url':'/web-ide/static/js/965.0e3f3e65.chunk.js'},{'revision':null,'url':'/web-ide/static/js/983.681012c4.chunk.js'},{'revision':null,'url':'/web-ide/static/js/main.66e9b6eb.js'}],{url:"/web-ide/root.css",revision:null},{url:"/web-ide/pico.min.css",revision:null},{url:"/web-ide/poppins_400.ttf",revision:null},{url:"/web-ide/poppins_700.ttf",revision:null},{url:"/web-ide/jet_brains_mono.ttf",revision:null},{url:"/web-ide/manifest.json",revision:null},{url:"/web-ide/favicon.svg",revision:null},{url:"/web-ide/logo_192.png",revision:null},{url:"/web-ide/logo_512.png",revision:null},{url:"https://fonts.gstatic.com/s/materialsymbolsoutlined/v179/kJEhBvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oFsLjBuVY.woff2",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/loader.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.css",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.nls.js",revision:null},{url:"user_guide/chip.pdf",revision:null},{url:"user_guide/cpu.pdf",revision:null},{url:"user_guide/asm.pdf",revision:null},{url:"user_guide/vm.pdf",revision:null},{url:"user_guide/compiler.pdf",revision:null},{url:"/web-ide/bitmap_editor.html",revision:null}]),function(e){const t=$();Z(new ee(t,e))}(se);const ne=new RegExp("/[^/?]+\\.[^/]+$");var re;Z((({request:e,url:t})=>"navigate"===e.mode&&(!t.pathname.startsWith("/_")&&!t.pathname.match(ne))),(re="/web-ide/index.html",$().createHandlerBoundToURL(re))),Z((({url:e})=>e.origin===self.location.origin&&e.pathname.endsWith(".png")),new class extends W{constructor(e={}){super(e),this.plugins.some((e=>"cacheWillUpdate"in e))||this.plugins.unshift(te)}async _handle(e,s){const n=s.fetchAndCachePut(e).catch((()=>{}));s.waitUntil(n);let r,a=await s.cacheMatch(e);if(a)0;else{0;try{a=await n}catch(i){i instanceof Error&&(r=i)}}if(!a)throw new t("no-response",{url:e.url,error:r});return a}}({cacheName:"images",plugins:[new class{constructor(e={}){this.cachedResponseWillBeUsed=async({event:e,request:t,cacheName:s,cachedResponse:n})=>{if(!n)return null;const r=this._isResponseDateFresh(n),a=this._getCacheExpiration(s);l(a.expireEntries());const i=a.updateTimestamp(t.url);if(e)try{e.waitUntil(i)}catch(o){0}return r?n:null},this.cacheDidUpdate=async({cacheName:e,request:t})=>{const s=this._getCacheExpiration(e);await s.updateTimestamp(t.url),await s.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&function(e){n.add(e)}((()=>this.deleteCacheAndMetadata()))}_getCacheExpiration(e){if(e===o())throw new t("expire-custom-caches-only");let s=this._cacheExpirations.get(e);return s||(s=new P(e,this._config),this._cacheExpirations.set(e,s)),s}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(null===t)return!0;return t>=Date.now()-1e3*this._maxAgeSeconds}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),s=new Date(t).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}({maxEntries:50})]})),self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}))})()})();
\ No newline at end of file
+(()=>{"use strict";var e={42:()=>{try{self["workbox:core:6.5.4"]&&_()}catch(e){}},940:()=>{try{self["workbox:expiration:6.5.4"]&&_()}catch(e){}},881:()=>{try{self["workbox:precaching:6.5.4"]&&_()}catch(e){}},661:()=>{try{self["workbox:routing:6.5.4"]&&_()}catch(e){}},772:()=>{try{self["workbox:strategies:6.5.4"]&&_()}catch(e){}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{s(42);const e=(e,...t)=>{let s=e;return t.length>0&&(s+=` :: ${JSON.stringify(t)}`),s};class t extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}const n=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!==typeof registration?registration.scope:""},a=e=>[r.prefix,e,r.suffix].filter((e=>e&&e.length>0)).join("-"),i=e=>e||a(r.precache),o=e=>e||a(r.runtime);function c(e,t){const s=new URL(e);for(const n of t)s.searchParams.delete(n);return s.href}let h;function l(e){e.then((()=>{}))}class u{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}const d=e=>new URL(String(e),location.href).href.replace(new RegExp(`^${location.origin}`),"");function p(e){return new Promise((t=>setTimeout(t,e)))}function f(e,t){const s=t();return e.waitUntil(s),s}async function g(e,s){let n=null;if(e.url){n=new URL(e.url).origin}if(n!==self.location.origin)throw new t("cross-origin-copy-response",{origin:n});const r=e.clone(),a={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},i=s?s(a):a,o=function(){if(void 0===h){const t=new Response("");if("body"in t)try{new Response(t.body),h=!0}catch(e){h=!1}h=!1}return h}()?r.body:await r.blob();return new Response(o,i)}const m=(e,t)=>t.some((t=>e instanceof t));let w,y;const _=new WeakMap,v=new WeakMap,b=new WeakMap,R=new WeakMap,x=new WeakMap;let C={get(e,t,s){if(e instanceof IDBTransaction){if("done"===t)return v.get(e);if("objectStoreNames"===t)return e.objectStoreNames||b.get(e);if("store"===t)return s.objectStoreNames[1]?void 0:s.objectStore(s.objectStoreNames[0])}return q(e[t])},set:(e,t,s)=>(e[t]=s,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function L(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(y||(y=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(U(this),t),q(_.get(this))}:function(...t){return q(e.apply(U(this),t))}:function(t,...s){const n=e.call(U(this),t,...s);return b.set(n,t.sort?t.sort():[t]),q(n)}}function E(e){return"function"===typeof e?L(e):(e instanceof IDBTransaction&&function(e){if(v.has(e))return;const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",a),e.removeEventListener("abort",a)},r=()=>{t(),n()},a=()=>{s(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",r),e.addEventListener("error",a),e.addEventListener("abort",a)}));v.set(e,t)}(e),m(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,C):e)}function q(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("success",r),e.removeEventListener("error",a)},r=()=>{t(q(e.result)),n()},a=()=>{s(e.error),n()};e.addEventListener("success",r),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&_.set(t,e)})).catch((()=>{})),x.set(t,e),t}(e);if(R.has(e))return R.get(e);const t=E(e);return t!==e&&(R.set(e,t),x.set(t,e)),t}const U=e=>x.get(e);const D=["get","getKey","getAll","getAllKeys","count"],k=["put","add","delete","clear"],T=new Map;function N(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!==typeof t)return;if(T.get(t))return T.get(t);const s=t.replace(/FromIndex$/,""),n=t!==s,r=k.includes(s);if(!(s in(n?IDBIndex:IDBObjectStore).prototype)||!r&&!D.includes(s))return;const a=async function(e,...t){const a=this.transaction(e,r?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[s](...t),r&&a.done]))[0]};return T.set(t,a),a}C=(e=>({...e,get:(t,s,n)=>N(t,s)||e.get(t,s,n),has:(t,s)=>!!N(t,s)||e.has(t,s)}))(C);s(940);const I="cache-entries",K=e=>{const t=new URL(e,location.href);return t.hash="",t.href};class M{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(I,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&function(e,{blocked:t}={}){const s=indexedDB.deleteDatabase(e);t&&s.addEventListener("blocked",(e=>t(e.oldVersion,e))),q(s).then((()=>{}))}(this._cacheName)}async setTimestamp(e,t){const s={url:e=K(e),timestamp:t,cacheName:this._cacheName,id:this._getId(e)},n=(await this.getDb()).transaction(I,"readwrite",{durability:"relaxed"});await n.store.put(s),await n.done}async getTimestamp(e){const t=await this.getDb(),s=await t.get(I,this._getId(e));return null===s||void 0===s?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let n=await s.transaction(I).store.index("timestamp").openCursor(null,"prev");const r=[];let a=0;for(;n;){const s=n.value;s.cacheName===this._cacheName&&(e&&s.timestamp=t?r.push(n.value):a++),n=await n.continue()}const i=[];for(const o of r)await s.delete(I,o.id),i.push(o.url);return i}_getId(e){return this._cacheName+"|"+K(e)}async getDb(){return this._db||(this._db=await function(e,t,{blocked:s,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(e,t),o=q(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(q(i.result),e.oldVersion,e.newVersion,q(i.transaction),e)})),s&&i.addEventListener("blocked",(e=>s(e.oldVersion,e.newVersion,e))),o.then((e=>{a&&e.addEventListener("close",(()=>a())),r&&e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("workbox-expiration",1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class P{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new M(e)}async expireEntries(){if(this._isRunning)return void(this._rerunRequested=!0);this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-1e3*this._maxAgeSeconds:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const n of t)await s.delete(n,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,l(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-1e3*this._maxAgeSeconds;return void 0===t||t{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if("install"===e.type&&t&&t.originalRequest&&t.originalRequest instanceof Request){const e=t.originalRequest.url;s?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return s}}}class A{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{const s=(null===t||void 0===t?void 0:t.cacheKey)||this._precacheController.getCacheKeyForURL(e.url);return s?new Request(s,{headers:e.headers}):e},this._precacheController=e}}s(772);function j(e){return"string"===typeof e?new Request(e):e}class B{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new u,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:s}=this;let n=j(e);if("navigate"===n.mode&&s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const e of this.iterateCallbacks("requestWillFetch"))n=await e({request:n.clone(),event:s})}catch(i){if(i instanceof Error)throw new t("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const a=n.clone();try{let e;e=await fetch(n,"navigate"===n.mode?void 0:this._strategy.fetchOptions);for(const t of this.iterateCallbacks("fetchDidSucceed"))e=await t({event:s,request:a,response:e});return e}catch(o){throw r&&await this.runCallbacks("fetchDidFail",{error:o,event:s,originalRequest:r.clone(),request:a.clone()}),o}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=j(e);let s;const{cacheName:n,matchOptions:r}=this._strategy,a=await this.getCacheKey(t,"read"),i=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(a,i);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:n,matchOptions:r,cachedResponse:s,request:a,event:this.event})||void 0;return s}async cachePut(e,s){const r=j(e);await p(0);const a=await this.getCacheKey(r,"write");if(!s)throw new t("cache-put-with-no-response",{url:d(a.url)});const i=await this._ensureResponseSafeToCache(s);if(!i)return!1;const{cacheName:o,matchOptions:h}=this._strategy,l=await self.caches.open(o),u=this.hasCallback("cacheDidUpdate"),f=u?await async function(e,t,s,n){const r=c(t.url,s);if(t.url===r)return e.match(t,n);const a=Object.assign(Object.assign({},n),{ignoreSearch:!0}),i=await e.keys(t,a);for(const o of i)if(r===c(o.url,s))return e.match(o,n)}(l,a.clone(),["__WB_REVISION__"],h):null;try{await l.put(a,u?i.clone():i)}catch(g){if(g instanceof Error)throw"QuotaExceededError"===g.name&&await async function(){for(const e of n)await e()}(),g}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:o,oldResponse:f,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let n=e;for(const e of this.iterateCallbacks("cacheKeyWillBeUsed"))n=j(await e({mode:t,request:n,event:this.event,params:this.params}));this._cacheKeys[s]=n}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if("function"===typeof t[e]){const s=this._pluginStateMap.get(t),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return t[e](r)};yield n}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const n of this.iterateCallbacks("cacheWillUpdate"))if(t=await n({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&200!==t.status&&(t=void 0),t}}class W{constructor(e={}){this.cacheName=o(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s="string"===typeof e.request?new Request(e.request):e.request,n="params"in e?e.params:void 0,r=new B(this,{event:t,request:s,params:n}),a=this._getResponse(r,s,t);return[a,this._awaitComplete(a,r,s,t)]}async _getResponse(e,s,n){let r;await e.runCallbacks("handlerWillStart",{event:n,request:s});try{if(r=await this._handle(s,e),!r||"error"===r.type)throw new t("no-response",{url:s.url})}catch(a){if(a instanceof Error)for(const t of e.iterateCallbacks("handlerDidError"))if(r=await t({error:a,event:n,request:s}),r)break;if(!r)throw a}for(const t of e.iterateCallbacks("handlerWillRespond"))r=await t({event:n,request:s,response:r});return r}async _awaitComplete(e,t,s,n){let r,a;try{r=await e}catch(a){}try{await t.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await t.doneWaiting()}catch(i){i instanceof Error&&(a=i)}if(await t.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:a}),t.destroy(),a)throw a}}class F extends W{constructor(e={}){e.cacheName=i(e.cacheName),super(e),this._fallbackToNetwork=!1!==e.fallbackToNetwork,this.plugins.push(F.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&"install"===t.event.type?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,s){let n;const r=s.params||{};if(!this._fallbackToNetwork)throw new t("missing-precache-entry",{cacheName:this.cacheName,url:e.url});{0;const t=r.integrity,a=e.integrity,i=!a||a===t;if(n=await s.fetch(new Request(e,{integrity:"no-cors"!==e.mode?a||t:void 0})),t&&i&&"no-cors"!==e.mode){this._useDefaultCacheabilityPluginIfNeeded();await s.cachePut(e,n.clone());0}}return n}async _handleInstall(e,s){this._useDefaultCacheabilityPluginIfNeeded();const n=await s.fetch(e);if(!await s.cachePut(e,n.clone()))throw new t("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,n]of this.plugins.entries())n!==F.copyRedirectedCacheableResponsesPlugin&&(n===F.defaultPrecacheCacheabilityPlugin&&(e=s),n.cacheWillUpdate&&t++);0===t?this.plugins.push(F.defaultPrecacheCacheabilityPlugin):t>1&&null!==e&&this.plugins.splice(e,1)}}F.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:e})=>!e||e.status>=400?null:e},F.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:e})=>e.redirected?await g(e):e};class H{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new F({cacheName:i(e),plugins:[...t,new A({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const s=[];for(const n of e){"string"===typeof n?s.push(n):n&&void 0===n.revision&&s.push(n.url);const{cacheKey:e,url:r}=S(n),a="string"!==typeof n&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==e)throw new t("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:e});if("string"!==typeof n&&n.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==n.integrity)throw new t("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(e,n.integrity)}if(this._urlsToCacheKeys.set(r,e),this._urlsToCacheModes.set(r,a),s.length>0){const e=`Workbox is precaching URLs without revision info: ${s.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return f(e,(async()=>{const t=new O;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const t=this._cacheKeysToIntegrities.get(a),s=this._urlsToCacheModes.get(r),n=new Request(r,{integrity:t,cache:s,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:n,event:e}))}const{updatedURLs:s,notUpdatedURLs:n}=t;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(e){return f(e,(async()=>{const e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),s=new Set(this._urlsToCacheKeys.values()),n=[];for(const r of t)s.has(r.url)||(await e.delete(r),n.push(r.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(e){const s=this.getCacheKeyForURL(e);if(!s)throw new t("non-precached-url",{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:s},t.params),this.strategy.handle(t))}}let V;const $=()=>(V||(V=new H),V);s(661);const G=e=>e&&"object"===typeof e?e:{handle:e};class Q{constructor(e,t,s="GET"){this.handler=G(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=G(e)}}class J extends Q{constructor(e,t,s){super((({url:t})=>{const s=e.exec(t.href);if(s&&(t.origin===location.origin||0===s.index))return s.slice(1)}),t,s)}}class Y{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&"CACHE_URLS"===e.data.type){const{payload:t}=e.data;0;const s=Promise.all(t.urlsToCache.map((t=>{"string"===typeof t&&(t=[t]);const s=new Request(...t);return this.handleRequest({request:s,event:e})})));e.waitUntil(s),e.ports&&e.ports[0]&&s.then((()=>e.ports[0].postMessage(!0)))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return void 0;const n=s.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:n,url:s});let i=a&&a.handler;const o=e.method;if(!i&&this._defaultHandlerMap.has(o)&&(i=this._defaultHandlerMap.get(o)),!i)return void 0;let c;try{c=i.handle({url:s,request:e,event:t,params:r})}catch(l){c=Promise.reject(l)}const h=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||h)&&(c=c.catch((async n=>{if(h){0;try{return await h.handle({url:s,request:e,event:t,params:r})}catch(a){a instanceof Error&&(n=a)}}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw n}))),c}findMatchingRoute({url:e,sameOrigin:t,request:s,event:n}){const r=this._routes.get(s.method)||[];for(const a of r){let r;const i=a.match({url:e,sameOrigin:t,request:s,event:n});if(i)return r=i,(Array.isArray(r)&&0===r.length||i.constructor===Object&&0===Object.keys(i).length||"boolean"===typeof i)&&(r=void 0),{route:a,params:r}}return{}}setDefaultHandler(e,t="GET"){this._defaultHandlerMap.set(t,G(e))}setCatchHandler(e){this._catchHandler=G(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t("unregister-route-but-not-found-with-method",{method:e.method});const s=this._routes.get(e.method).indexOf(e);if(!(s>-1))throw new t("unregister-route-route-not-registered");this._routes.get(e.method).splice(s,1)}}let X;const z=()=>(X||(X=new Y,X.addFetchListener(),X.addCacheListener()),X);function Z(e,s,n){let r;if("string"===typeof e){const t=new URL(e,location.href);0;r=new Q((({url:e})=>e.href===t.href),s,n)}else if(e instanceof RegExp)r=new J(e,s,n);else if("function"===typeof e)r=new Q(e,s,n);else{if(!(e instanceof Q))throw new t("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});r=e}return z().registerRoute(r),r}class ee extends Q{constructor(e,t){super((({request:s})=>{const n=e.getURLsToCacheKeys();for(const r of function*(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const a=new URL(e,location.href);a.hash="",yield a.href;const i=function(e,t=[]){for(const s of[...e.searchParams.keys()])t.some((e=>e.test(s)))&&e.searchParams.delete(s);return e}(a,t);if(yield i.href,s&&i.pathname.endsWith("/")){const e=new URL(i.href);e.pathname+=s,yield e.href}if(n){const e=new URL(i.href);e.pathname+=".html",yield e.href}if(r){const e=r({url:a});for(const t of e)yield t.href}}(s.url,t)){const t=n.get(r);if(t){return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}}}),e.strategy)}}const te={cacheWillUpdate:async({response:e})=>200===e.status||0===e.status?e:null};var se;self.addEventListener("activate",(()=>self.clients.claim())),function(e){$().precache(e)}([...[{'revision':'48fc0974ec91e7ad74ec5ccb48d37e3e','url':'/web-ide/index.html'},{'revision':null,'url':'/web-ide/static/css/34.2a1f584b.chunk.css'},{'revision':null,'url':'/web-ide/static/css/408.4548b55f.chunk.css'},{'revision':null,'url':'/web-ide/static/css/519.829f2cf9.chunk.css'},{'revision':null,'url':'/web-ide/static/css/535.a8c1f171.chunk.css'},{'revision':null,'url':'/web-ide/static/css/598.4a56c158.chunk.css'},{'revision':null,'url':'/web-ide/static/css/744.3fc532fa.chunk.css'},{'revision':null,'url':'/web-ide/static/css/787.968be482.chunk.css'},{'revision':null,'url':'/web-ide/static/css/main.9d762a7f.css'},{'revision':null,'url':'/web-ide/static/js/269.1e46835e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/288.3bdeec9c.chunk.js'},{'revision':null,'url':'/web-ide/static/js/297.2c45dab0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/323.14a08baf.chunk.js'},{'revision':null,'url':'/web-ide/static/js/34.9f280457.chunk.js'},{'revision':null,'url':'/web-ide/static/js/408.e6e0ca78.chunk.js'},{'revision':null,'url':'/web-ide/static/js/519.0a360ef5.chunk.js'},{'revision':null,'url':'/web-ide/static/js/535.74ad7816.chunk.js'},{'revision':null,'url':'/web-ide/static/js/537.c02a5bfa.chunk.js'},{'revision':null,'url':'/web-ide/static/js/578.b9f22ec3.chunk.js'},{'revision':null,'url':'/web-ide/static/js/598.183c6bb5.chunk.js'},{'revision':null,'url':'/web-ide/static/js/608.6d63ee31.chunk.js'},{'revision':null,'url':'/web-ide/static/js/614.12dbb7c0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/656.c1a30912.chunk.js'},{'revision':null,'url':'/web-ide/static/js/744.e7730500.chunk.js'},{'revision':null,'url':'/web-ide/static/js/787.781c176c.chunk.js'},{'revision':null,'url':'/web-ide/static/js/828.e00c10f6.chunk.js'},{'revision':null,'url':'/web-ide/static/js/965.0e3f3e65.chunk.js'},{'revision':null,'url':'/web-ide/static/js/983.681012c4.chunk.js'},{'revision':null,'url':'/web-ide/static/js/main.9984f23c.js'}],{url:"/web-ide/root.css",revision:null},{url:"/web-ide/pico.min.css",revision:null},{url:"/web-ide/poppins_400.ttf",revision:null},{url:"/web-ide/poppins_700.ttf",revision:null},{url:"/web-ide/jet_brains_mono.ttf",revision:null},{url:"/web-ide/manifest.json",revision:null},{url:"/web-ide/favicon.svg",revision:null},{url:"/web-ide/logo_192.png",revision:null},{url:"/web-ide/logo_512.png",revision:null},{url:"https://fonts.gstatic.com/s/materialsymbolsoutlined/v179/kJEhBvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oFsLjBuVY.woff2",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/loader.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.css",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.nls.js",revision:null},{url:"user_guide/chip.pdf",revision:null},{url:"user_guide/cpu.pdf",revision:null},{url:"user_guide/asm.pdf",revision:null},{url:"user_guide/vm.pdf",revision:null},{url:"user_guide/compiler.pdf",revision:null},{url:"/web-ide/bitmap_editor.html",revision:null}]),function(e){const t=$();Z(new ee(t,e))}(se);const ne=new RegExp("/[^/?]+\\.[^/]+$");var re;Z((({request:e,url:t})=>"navigate"===e.mode&&(!t.pathname.startsWith("/_")&&!t.pathname.match(ne))),(re="/web-ide/index.html",$().createHandlerBoundToURL(re))),Z((({url:e})=>e.origin===self.location.origin&&e.pathname.endsWith(".png")),new class extends W{constructor(e={}){super(e),this.plugins.some((e=>"cacheWillUpdate"in e))||this.plugins.unshift(te)}async _handle(e,s){const n=s.fetchAndCachePut(e).catch((()=>{}));s.waitUntil(n);let r,a=await s.cacheMatch(e);if(a)0;else{0;try{a=await n}catch(i){i instanceof Error&&(r=i)}}if(!a)throw new t("no-response",{url:e.url,error:r});return a}}({cacheName:"images",plugins:[new class{constructor(e={}){this.cachedResponseWillBeUsed=async({event:e,request:t,cacheName:s,cachedResponse:n})=>{if(!n)return null;const r=this._isResponseDateFresh(n),a=this._getCacheExpiration(s);l(a.expireEntries());const i=a.updateTimestamp(t.url);if(e)try{e.waitUntil(i)}catch(o){0}return r?n:null},this.cacheDidUpdate=async({cacheName:e,request:t})=>{const s=this._getCacheExpiration(e);await s.updateTimestamp(t.url),await s.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&function(e){n.add(e)}((()=>this.deleteCacheAndMetadata()))}_getCacheExpiration(e){if(e===o())throw new t("expire-custom-caches-only");let s=this._cacheExpirations.get(e);return s||(s=new P(e,this._config),this._cacheExpirations.set(e,s)),s}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(null===t)return!0;return t>=Date.now()-1e3*this._maxAgeSeconds}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),s=new Date(t).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}({maxEntries:50})]})),self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}))})()})();
\ No newline at end of file
diff --git a/static/js/288.1852c135.chunk.js b/static/js/288.3bdeec9c.chunk.js
similarity index 76%
rename from static/js/288.1852c135.chunk.js
rename to static/js/288.3bdeec9c.chunk.js
index 3feb81686..83ac0adfe 100644
--- a/static/js/288.1852c135.chunk.js
+++ b/static/js/288.3bdeec9c.chunk.js
@@ -1 +1 @@
-"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[288],{3288:(n,t,e)=>{e.r(t),e.d(t,{Assignments:()=>_,ChipProjects:()=>K,VmProjects:()=>X,resetFiles:()=>J,resetTests:()=>G});var s={};e.r(s),e.d(s,{BUILTIN_CHIPS:()=>k,CHIPS:()=>l,resetFiles:()=>h,resetTests:()=>B});var o={};e.r(o),e.d(o,{BUILTIN_CHIPS:()=>v,CHIPS:()=>m,resetFiles:()=>f,resetTests:()=>M});var u={};e.r(u),e.d(u,{BUILTIN_CHIPS:()=>A,CHIPS:()=>R,resetFiles:()=>b,resetTests:()=>T});var a={};e.r(a),e.d(a,{TESTS:()=>g,resetFiles:()=>w,resetTests:()=>S});var d={};e.r(d),e.d(d,{BUILTIN_CHIPS:()=>I,CHIPS:()=>P,resetFiles:()=>F,resetTests:()=>N});var i={};e.r(i),e.d(i,{VMS:()=>E,resetFiles:()=>z,resetTests:()=>O});var p={};e.r(p),e.d(p,{VMS:()=>j,resetFiles:()=>L,resetTests:()=>U});var r=e(4544);async function c(n,t,e){for(const[s,o]of Object.entries(t))"string"===typeof o?s.endsWith(`${e}`)&&await n.writeFile(s,o):(n.cd(s),await c(n,o,e),n.cd(".."))}const l={Nand:{"Nand.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Nand.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Nand.cmp":"| a | b |out|\n| 0 | 0 | 1 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |"},Not:{"Not.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not.hdl\n/**\n * Not gate:\n * if (in) out = 0, else out = 1\n */\nCHIP Not {\n IN in;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Not.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not.tst\n\noutput-list in out;\n\nset in 0,\neval,\noutput;\n\nset in 1,\neval,\noutput;',"Not.cmp":"|in |out|\n| 0 | 1 |\n| 1 | 0 |"},And:{"And.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And.hdl\n/**\n * And gate:\n * if (a and b) out = 1, else out = 0 \n */\nCHIP And {\n IN a, b;\n OUT out;\n \n PARTS:\n //// Replace this comment with your code.\n}',"And.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"And.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 0 |\n| 1 | 0 | 0 |\n| 1 | 1 | 1 |"},Or:{"Or.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or.hdl\n/**\n * Or gate:\n * if (a or b) out = 1, else out = 0 \n */\nCHIP Or {\n IN a, b;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Or.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 1 |"},Xor:{"Xor.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Xor.hdl\n/**\n * Exclusive-or gate:\n * if ((a and Not(b)) or (Not(a) and b)) out = 1, else out = 0\n */\nCHIP Xor {\n IN a, b;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Xor.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Xor.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Xor.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |"},Mux:{"Mux.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux.hdl\n/** \n * Multiplexor:\n * if (sel = 0) out = a, else out = b\n */\nCHIP Mux {\n IN a, b, sel;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux.tst\n\noutput-list a b sel out;\n\nset a 0,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 0,\nset b 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 1,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 1,\nset b 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"Mux.cmp":"| a | b |sel|out|\n| 0 | 0 | 0 | 0 |\n| 0 | 0 | 1 | 0 |\n| 0 | 1 | 0 | 0 |\n| 0 | 1 | 1 | 1 |\n| 1 | 0 | 0 | 1 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |\n| 1 | 1 | 1 | 1 |"},DMux:{"DMux.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux.hdl\n/**\n * Demultiplexor:\n * [a, b] = [in, 0] if sel = 0\n * [0, in] if sel = 1\n */\nCHIP DMux {\n IN in, sel;\n OUT a, b;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux.tst\n\noutput-list in sel a b;\n\nset in 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset in 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"DMux.cmp":"|in |sel| a | b |\n| 0 | 0 | 0 | 0 |\n| 0 | 1 | 0 | 0 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |"},Not16:{"Not16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/01/Not16.hdl\n/**\n * 16-bit Not gate:\n * for i = 0, ..., 15:\n * out[i] = Not(a[i])\n */\nCHIP Not16 {\n IN in[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Not16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not16.tst\n\noutput-list in%B1.16.1 out%B1.16.1;\n\nset in %B0000000000000000,\neval,\noutput;\n\nset in %B1111111111111111,\neval,\noutput;\n\nset in %B1010101010101010,\neval,\noutput;\n\nset in %B0011110011000011,\neval,\noutput;\n\nset in %B0001001000110100,\neval,\noutput;',"Not16.cmp":"| in | out |\n| 0000000000000000 | 1111111111111111 |\n| 1111111111111111 | 0000000000000000 |\n| 1010101010101010 | 0101010101010101 |\n| 0011110011000011 | 1100001100111100 |\n| 0001001000110100 | 1110110111001011 |"},And16:{"And16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And16.hdl\n/**\n * 16-bit And gate:\n * for i = 0, ..., 15:\n * out[i] = a[i] And b[i] \n */\nCHIP And16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"And16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"And16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0000000000000000 |\n| 1111111111111111 | 1111111111111111 | 1111111111111111 |\n| 1010101010101010 | 0101010101010101 | 0000000000000000 |\n| 0011110011000011 | 0000111111110000 | 0000110011000000 |\n| 0001001000110100 | 1001100001110110 | 0001000000110100 |"},Or16:{"Or16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or16.hdl\n/**\n * 16-bit Or gate:\n * for i = 0, ..., 15:\n * out[i] = a[i] Or b[i] \n */\nCHIP Or16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"Or16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1111111111111111 |\n| 1111111111111111 | 1111111111111111 | 1111111111111111 |\n| 1010101010101010 | 0101010101010101 | 1111111111111111 |\n| 0011110011000011 | 0000111111110000 | 0011111111110011 |\n| 0001001000110100 | 1001100001110110 | 1001101001110110 |"},Mux16:{"Mux16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux16.hdl\n/**\n * 16-bit multiplexor: \n * for i = 0, ..., 15:\n * if (sel = 0) out[i] = a[i], else out[i] = b[i]\n */\nCHIP Mux16 {\n IN a[16], b[16], sel;\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 sel out%B1.16.1;\n\nset a 0,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B0001001000110100,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B1001100001110110,\nset b %B0000000000000000,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"Mux16.cmp":"| a | b |sel| out |\n| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 |\n| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 |\n| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 |\n| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 |\n| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 |\n| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 |\n| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 |"},Mux4Way16:{"Mux4Way16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux4Way16.hdl\n/**\n * 4-way 16-bit multiplexor:\n * out = a if sel = 00\n * b if sel = 01\n * c if sel = 10\n * d if sel = 11\n */\nCHIP Mux4Way16 {\n IN a[16], b[16], c[16], d[16], sel[2];\n OUT out[16];\n \n PARTS:\n //// Replace this comment with your code.\n}',"Mux4Way16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux4Way16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 sel%B2.2.2 out%B1.16.1;\n\nset a 0,\nset b 0,\nset c 0,\nset d 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\nset c %B1010101010101010,\nset d %B0101010101010101,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;',"Mux4Way16.cmp":"| a | b | c | d | sel | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 ||"},Mux8Way16:{"Mux8Way16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux8Way16.hdl\n/**\n * 8-way 16-bit multiplexor:\n * out = a if sel = 000\n * b if sel = 001\n * c if sel = 010\n * d if sel = 011\n * e if sel = 100\n * f if sel = 101\n * g if sel = 110\n * h if sel = 111\n */\nCHIP Mux8Way16 {\n IN a[16], b[16], c[16], d[16],\n e[16], f[16], g[16], h[16],\n sel[3];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux8Way16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux8Way16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 e%B1.16.1 f%B1.16.1 g%B1.16.1 h%B1.16.1 sel%B2.3.2 out%B1.16.1;\n\nset a 0,\nset b 0,\nset c 0,\nset d 0,\nset e 0,\nset f 0,\nset g 0,\nset h 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset sel 4,\neval,\noutput;\n\nset sel 5,\neval,\noutput;\n\nset sel 6,\neval,\noutput;\n\nset sel 7,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B0010001101000101,\nset c %B0011010001010110,\nset d %B0100010101100111,\nset e %B0101011001111000,\nset f %B0110011110001001,\nset g %B0111100010011010,\nset h %B1000100110101011,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset sel 4,\neval,\noutput;\n\nset sel 5,\neval,\noutput;\n\nset sel 6,\neval,\noutput;\n\nset sel 7,\neval,\noutput;',"Mux8Way16.cmp":"| a | b | c | d | e | f | g | h | sel | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 |"},DMux4Way:{"DMux4Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux4Way.hdl\n/**\n * 4-way demultiplexor:\n * [a, b, c, d] = [in, 0, 0, 0] if sel = 00\n * [0, in, 0, 0] if sel = 01\n * [0, 0, in, 0] if sel = 10\n * [0, 0, 0, in] if sel = 11\n */\nCHIP DMux4Way {\n IN in, sel[2];\n OUT a, b, c, d;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux4Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux4Way.tst\n\noutput-list in sel%B2.2.2 a b c d;\n\nset in 0,\nset sel %B00,\neval,\noutput;\n\nset sel %B01,\neval,\noutput;\n\nset sel %B10,\neval,\noutput;\n\nset sel %B11,\neval,\noutput;\n\nset in 1,\nset sel %B00,\neval,\noutput;\n\nset sel %B01,\neval,\noutput;\n\nset sel %B10,\neval,\noutput;\n\nset sel %B11,\neval,\noutput;',"DMux4Way.cmp":"|in | sel | a | b | c | d |\n| 0 | 00 | 0 | 0 | 0 | 0 |\n| 0 | 01 | 0 | 0 | 0 | 0 |\n| 0 | 10 | 0 | 0 | 0 | 0 |\n| 0 | 11 | 0 | 0 | 0 | 0 |\n| 1 | 00 | 1 | 0 | 0 | 0 |\n| 1 | 01 | 0 | 1 | 0 | 0 |\n| 1 | 10 | 0 | 0 | 1 | 0 |\n| 1 | 11 | 0 | 0 | 0 | 1 |"},DMux8Way:{"DMux8Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux8Way.hdl\n/**\n * 8-way demultiplexor:\n * [a, b, c, d, e, f, g, h] = [in, 0, 0, 0, 0, 0, 0, 0] if sel = 000\n * [0, in, 0, 0, 0, 0, 0, 0] if sel = 001\n * [0, 0, in, 0, 0, 0, 0, 0] if sel = 010\n * [0, 0, 0, in, 0, 0, 0, 0] if sel = 011\n * [0, 0, 0, 0, in, 0, 0, 0] if sel = 100\n * [0, 0, 0, 0, 0, in, 0, 0] if sel = 101\n * [0, 0, 0, 0, 0, 0, in, 0] if sel = 110\n * [0, 0, 0, 0, 0, 0, 0, in] if sel = 111\n */\nCHIP DMux8Way {\n IN in, sel[3];\n OUT a, b, c, d, e, f, g, h;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux8Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux8Way.tst\n\noutput-list in sel%B2.3.2 a b c d e f g h;\n\nset in 0,\nset sel %B000,\neval,\noutput;\n\nset sel %B001,\neval,\noutput;\n\nset sel %B010,\neval,\noutput;\n\nset sel %B011,\neval,\noutput;\n\nset sel %B100,\neval,\noutput;\n\nset sel %B101,\neval,\noutput;\n\nset sel %B110,\neval,\noutput;\n\nset sel %B111,\neval,\noutput;\n\nset in 1,\nset sel %B000,\neval,\noutput;\n\nset sel %B001,\neval,\noutput;\n\nset sel %B010,\neval,\noutput;\n\nset sel %B011,\neval,\noutput;\n\nset sel %B100,\neval,\noutput;\n\nset sel %B101,\neval,\noutput;\n\nset sel %B110,\neval,\noutput;\n\nset sel %B111,\neval,\noutput;',"DMux8Way.cmp":"|in | sel | a | b | c | d | e | f | g | h |\n| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |\n| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |\n| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |\n| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |\n| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |"},Or8Way:{"Or8Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or8Way.hdl\n/**\n * 8-way Or gate: \n * out = in[0] Or in[1] Or ... Or in[7]\n */\nCHIP Or8Way {\n IN in[8];\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or8Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or8Way.tst\n\noutput-list in%B2.8.2 out;\n\nset in %B00000000,\neval,\noutput;\n\nset in %B11111111,\neval,\noutput;\n\nset in %B00010000,\neval,\noutput;\n\nset in %B00000001,\neval,\noutput;\n\nset in %B00100110,\neval,\noutput;',"Or8Way.cmp":"| in |out|\n| 00000000 | 0 |\n| 11111111 | 1 |\n| 00010000 | 1 |\n| 00000001 | 1 |\n| 00100110 | 1 |"}},k={Nand:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Nand.hdl\n/**\n * Nand gate:\n * if (a and b) out = 0, else out = 1 \n */\nCHIP Nand {\n IN a, b;\n OUT out;\n \n PARTS:\n BUILTIN Nand;\n}'};async function h(n){await n.pushd("/projects/01"),await(0,r.cL)(n,l),await n.popd()}async function B(n){await n.pushd("/projects/01"),await c(n,l,".tst"),await c(n,l,".cmp"),await n.popd()}const m={HalfAdder:{"HalfAdder.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/HalfAdder.hdl\n/**\n * Computes the sum of two bits.\n */\nCHIP HalfAdder {\n IN a, b; // 1-bit inputs\n OUT sum, // Right bit of a + b \n carry; // Left bit of a + b\n\n PARTS:\n //// Replace this comment with your code.\n}',"HalfAdder.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/HalfAdder.tst\n\noutput-list a b sum carry;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"HalfAdder.cmp":"| a | b |sum|car|\n| 0 | 0 | 0 | 0 |\n| 0 | 1 | 1 | 0 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |"},FullAdder:{"FullAdder.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/FullAdder.hdl\n/**\n * Computes the sum of three bits.\n */\nCHIP FullAdder {\n IN a, b, c; // 1-bit inputs\n OUT sum, // Right bit of a + b + c\n carry; // Left bit of a + b + c\n\n PARTS:\n //// Replace this comment with your code.\n}',"FullAdder.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/FullAdder.tst\n\noutput-list a b c sum carry%B2.1.2;\n\nset a 0,\nset b 0,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset b 1,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset a 1,\nset b 0,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset b 1,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;',"FullAdder.cmp":"| a | b | c |sum|carry|\n| 0 | 0 | 0 | 0 | 0 |\n| 0 | 0 | 1 | 1 | 0 |\n| 0 | 1 | 0 | 1 | 0 |\n| 0 | 1 | 1 | 0 | 1 |\n| 1 | 0 | 0 | 1 | 0 |\n| 1 | 0 | 1 | 0 | 1 |\n| 1 | 1 | 0 | 0 | 1 |\n| 1 | 1 | 1 | 1 | 1 |"},Add16:{"Add16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Add16.hdl\n/**\n * 16-bit adder: Adds two 16-bit two\'s complement values.\n * The most significant carry bit is ignored.\n */\nCHIP Add16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Add16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Add16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"Add16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1111111111111111 |\n| 1111111111111111 | 1111111111111111 | 1111111111111110 |\n| 1010101010101010 | 0101010101010101 | 1111111111111111 |\n| 0011110011000011 | 0000111111110000 | 0100110010110011 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 |"},Inc16:{"Inc16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Inc16.hdl\n/**\n * 16-bit incrementer:\n * out = in + 1\n */\nCHIP Inc16 {\n IN in[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Inc16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Inc16.tst\n\noutput-list in%B1.16.1 out%B1.16.1;\n\nset in %B0000000000000000, // in = 0\neval,\noutput;\n\nset in %B1111111111111111, // in = -1\neval,\noutput;\n\nset in %B0000000000000101, // in = 5\neval,\noutput;\n\nset in %B1111111111111011, // in = -5\neval,\noutput;',"Inc16.cmp":"| in | out |\n| 0000000000000000 | 0000000000000001 |\n| 1111111111111111 | 0000000000000000 |\n| 0000000000000101 | 0000000000000110 |\n| 1111111111111011 | 1111111111111100 |\n"},ALU:{"ALU.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU.hdl\n/**\n * ALU (Arithmetic Logic Unit):\n * Computes out = one of the following functions:\n * 0, 1, -1,\n * x, y, !x, !y, -x, -y,\n * x + 1, y + 1, x - 1, y - 1,\n * x + y, x - y, y - x,\n * x & y, x | y\n * on the 16-bit inputs x, y,\n * according to the input bits zx, nx, zy, ny, f, no.\n * In addition, computes the two output bits:\n * if (out == 0) zr = 1, else zr = 0\n * if (out < 0) ng = 1, else ng = 0\n */\n// Implementation: Manipulates the x and y inputs\n// and operates on the resulting values, as follows:\n// if (zx == 1) sets x = 0 // 16-bit constant\n// if (nx == 1) sets x = !x // bitwise not\n// if (zy == 1) sets y = 0 // 16-bit constant\n// if (ny == 1) sets y = !y // bitwise not\n// if (f == 1) sets out = x + y // integer 2\'s complement addition\n// if (f == 0) sets out = x & y // bitwise and\n// if (no == 1) sets out = !out // bitwise not\n\nCHIP ALU {\n IN \n x[16], y[16], // 16-bit inputs \n zx, // zero the x input?\n nx, // negate the x input?\n zy, // zero the y input?\n ny, // negate the y input?\n f, // compute (out = x + y) or (out = x & y)?\n no; // negate the out output?\n OUT \n out[16], // 16-bit output\n zr, // if (out == 0) equals 1, else 0\n ng; // if (out < 0) equals 1, else 0\n\n PARTS:\n //// Replace this comment with your code.\n}',"ALU.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU.tst\n\noutput-list x%B1.16.1 y%B1.16.1 zx nx zy ny f no out zr ng;\n\nset x %B0000000000000000, // x = 0\nset y %B1111111111111111; // y = -1\n\n// Compute 0\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute 1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute !x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute !y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute -x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x + 1\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y + 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x - 1\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute y - 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x + y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x - y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y - x\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x & y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute x | y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset x %B000000000010001, // x = 17\nset y %B000000000000011; // y = 3\n\n// Compute 0\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute 1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute !x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute !y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute -x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x + 1\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y + 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x - 1\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute y - 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x + y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x - y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y - x\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x & y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute x | y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;',"ALU.cmp":"| x | y |zx |nx |zy |ny | f |no | out |zr |ng |\n| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000010001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000011 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111101110 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 1 | 1111111111111100 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 1 | 1111111111101111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 1 | 1111111111111101 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000010010 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000100 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000010000 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000010 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000010100 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000001110 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111110010 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000010011 | 0 | 0 |","ALU-basic.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU-basic.tst\n\n// Tests the basic version of the ALU chip.\n// DOES NOT replace the final test provided by ALU.tst.\n// Specifically: Tests the ALU logic that computes the 'out' output;\n// The 'zr' and 'ng' output bits are ignored.\n\noutput-list x%B1.16.1 y%B1.16.1 zx nx zy ny f no out%B1.16.1;\n\nset x %B0000000000000000,\nset y %B1111111111111111,\n\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset x %B101101110100000,\nset y %B001111011010010,\n\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;","ALU-basic.cmp":"| x | y |zx |nx |zy |ny | f |no | out |\n| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 |\n| 0101101110100000 | 0001111011010010 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 0 | 0101101110100000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 0 | 0001111011010010 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 1 | 1010010001011111 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 1 | 1110000100101101 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 1 | 1010010001100000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 1 | 1110000100101110 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 1 | 1 | 1 | 1 | 0101101110100001 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 1 | 1 | 1 | 0001111011010011 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 0 | 0101101110011111 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 0 | 0001111011010001 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 1 | 0 | 0111101001110010 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 0 | 1 | 1 | 0011110011001110 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 1 | 1 | 1 | 1100001100110010 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 0 | 0 | 0001101010000000 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 1 | 0 | 1 | 0101111111110010 |"}},v={};async function f(n){await n.pushd("/projects/02"),await(0,r.cL)(n,m),await n.popd()}async function M(n){await n.pushd("/projects/02"),await c(n,m,".tst"),await c(n,m,".cmp"),await n.popd()}const y='// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM16K.hdl\n/**\n * Memory of 16K 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM16K {\n IN in[16], load, address[14];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',R={Bit:{"Bit.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Bit.hdl\n/**\n * 1-bit register:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value:\n * if (load(t)) out(t+1) = in(t), else out(t+1) = out(t)\n */\nCHIP Bit {\n IN in, load;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Bit.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Bit.tst\n\noutput-list time%S1.4.1 in load%B1.1.2 out;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;',"Bit.cmp":"| time |in |load|out|\n| 0+ | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 |\n| 2 | 0 | 1 | 0 |\n| 2+ | 1 | 0 | 0 |\n| 3 | 1 | 0 | 0 |\n| 3+ | 1 | 1 | 0 |\n| 4 | 1 | 1 | 1 |\n| 4+ | 0 | 0 | 1 |\n| 5 | 0 | 0 | 1 |\n| 5+ | 1 | 0 | 1 |\n| 6 | 1 | 0 | 1 |\n| 6+ | 0 | 1 | 1 |\n| 7 | 0 | 1 | 0 |\n| 7+ | 1 | 1 | 0 |\n| 8 | 1 | 1 | 1 |\n| 8+ | 0 | 0 | 1 |\n| 9 | 0 | 0 | 1 |\n| 9+ | 0 | 0 | 1 |\n| 10 | 0 | 0 | 1 |\n| 10+ | 0 | 0 | 1 |\n| 11 | 0 | 0 | 1 |\n| 11+ | 0 | 0 | 1 |\n| 12 | 0 | 0 | 1 |\n| 12+ | 0 | 0 | 1 |\n| 13 | 0 | 0 | 1 |\n| 13+ | 0 | 0 | 1 |\n| 14 | 0 | 0 | 1 |\n| 14+ | 0 | 0 | 1 |\n| 15 | 0 | 0 | 1 |\n| 15+ | 0 | 0 | 1 |\n| 16 | 0 | 0 | 1 |\n| 16+ | 0 | 0 | 1 |\n| 17 | 0 | 0 | 1 |\n| 17+ | 0 | 0 | 1 |\n| 18 | 0 | 0 | 1 |\n| 18+ | 0 | 0 | 1 |\n| 19 | 0 | 0 | 1 |\n| 19+ | 0 | 0 | 1 |\n| 20 | 0 | 0 | 1 |\n| 20+ | 0 | 0 | 1 |\n| 21 | 0 | 0 | 1 |\n| 21+ | 0 | 0 | 1 |\n| 22 | 0 | 0 | 1 |\n| 22+ | 0 | 0 | 1 |\n| 23 | 0 | 0 | 1 |\n| 23+ | 0 | 0 | 1 |\n| 24 | 0 | 0 | 1 |\n| 24+ | 0 | 0 | 1 |\n| 25 | 0 | 0 | 1 |\n| 25+ | 0 | 0 | 1 |\n| 26 | 0 | 0 | 1 |\n| 26+ | 0 | 0 | 1 |\n| 27 | 0 | 0 | 1 |\n| 27+ | 0 | 0 | 1 |\n| 28 | 0 | 0 | 1 |\n| 28+ | 0 | 0 | 1 |\n| 29 | 0 | 0 | 1 |\n| 29+ | 0 | 0 | 1 |\n| 30 | 0 | 0 | 1 |\n| 30+ | 0 | 0 | 1 |\n| 31 | 0 | 0 | 1 |\n| 31+ | 0 | 0 | 1 |\n| 32 | 0 | 0 | 1 |\n| 32+ | 0 | 0 | 1 |\n| 33 | 0 | 0 | 1 |\n| 33+ | 0 | 0 | 1 |\n| 34 | 0 | 0 | 1 |\n| 34+ | 0 | 0 | 1 |\n| 35 | 0 | 0 | 1 |\n| 35+ | 0 | 0 | 1 |\n| 36 | 0 | 0 | 1 |\n| 36+ | 0 | 0 | 1 |\n| 37 | 0 | 0 | 1 |\n| 37+ | 0 | 0 | 1 |\n| 38 | 0 | 0 | 1 |\n| 38+ | 0 | 0 | 1 |\n| 39 | 0 | 0 | 1 |\n| 39+ | 0 | 0 | 1 |\n| 40 | 0 | 0 | 1 |\n| 40+ | 0 | 0 | 1 |\n| 41 | 0 | 0 | 1 |\n| 41+ | 0 | 0 | 1 |\n| 42 | 0 | 0 | 1 |\n| 42+ | 0 | 0 | 1 |\n| 43 | 0 | 0 | 1 |\n| 43+ | 0 | 0 | 1 |\n| 44 | 0 | 0 | 1 |\n| 44+ | 0 | 0 | 1 |\n| 45 | 0 | 0 | 1 |\n| 45+ | 0 | 0 | 1 |\n| 46 | 0 | 0 | 1 |\n| 46+ | 0 | 0 | 1 |\n| 47 | 0 | 0 | 1 |\n| 47+ | 0 | 0 | 1 |\n| 48 | 0 | 0 | 1 |\n| 48+ | 0 | 0 | 1 |\n| 49 | 0 | 0 | 1 |\n| 49+ | 0 | 0 | 1 |\n| 50 | 0 | 0 | 1 |\n| 50+ | 0 | 0 | 1 |\n| 51 | 0 | 0 | 1 |\n| 51+ | 0 | 0 | 1 |\n| 52 | 0 | 0 | 1 |\n| 52+ | 0 | 0 | 1 |\n| 53 | 0 | 0 | 1 |\n| 53+ | 0 | 0 | 1 |\n| 54 | 0 | 0 | 1 |\n| 54+ | 0 | 0 | 1 |\n| 55 | 0 | 0 | 1 |\n| 55+ | 0 | 0 | 1 |\n| 56 | 0 | 0 | 1 |\n| 56+ | 0 | 0 | 1 |\n| 57 | 0 | 0 | 1 |\n| 57+ | 0 | 1 | 1 |\n| 58 | 0 | 1 | 0 |\n| 58+ | 1 | 0 | 0 |\n| 59 | 1 | 0 | 0 |\n| 59+ | 1 | 0 | 0 |\n| 60 | 1 | 0 | 0 |\n| 60+ | 1 | 0 | 0 |\n| 61 | 1 | 0 | 0 |\n| 61+ | 1 | 0 | 0 |\n| 62 | 1 | 0 | 0 |\n| 62+ | 1 | 0 | 0 |\n| 63 | 1 | 0 | 0 |\n| 63+ | 1 | 0 | 0 |\n| 64 | 1 | 0 | 0 |\n| 64+ | 1 | 0 | 0 |\n| 65 | 1 | 0 | 0 |\n| 65+ | 1 | 0 | 0 |\n| 66 | 1 | 0 | 0 |\n| 66+ | 1 | 0 | 0 |\n| 67 | 1 | 0 | 0 |\n| 67+ | 1 | 0 | 0 |\n| 68 | 1 | 0 | 0 |\n| 68+ | 1 | 0 | 0 |\n| 69 | 1 | 0 | 0 |\n| 69+ | 1 | 0 | 0 |\n| 70 | 1 | 0 | 0 |\n| 70+ | 1 | 0 | 0 |\n| 71 | 1 | 0 | 0 |\n| 71+ | 1 | 0 | 0 |\n| 72 | 1 | 0 | 0 |\n| 72+ | 1 | 0 | 0 |\n| 73 | 1 | 0 | 0 |\n| 73+ | 1 | 0 | 0 |\n| 74 | 1 | 0 | 0 |\n| 74+ | 1 | 0 | 0 |\n| 75 | 1 | 0 | 0 |\n| 75+ | 1 | 0 | 0 |\n| 76 | 1 | 0 | 0 |\n| 76+ | 1 | 0 | 0 |\n| 77 | 1 | 0 | 0 |\n| 77+ | 1 | 0 | 0 |\n| 78 | 1 | 0 | 0 |\n| 78+ | 1 | 0 | 0 |\n| 79 | 1 | 0 | 0 |\n| 79+ | 1 | 0 | 0 |\n| 80 | 1 | 0 | 0 |\n| 80+ | 1 | 0 | 0 |\n| 81 | 1 | 0 | 0 |\n| 81+ | 1 | 0 | 0 |\n| 82 | 1 | 0 | 0 |\n| 82+ | 1 | 0 | 0 |\n| 83 | 1 | 0 | 0 |\n| 83+ | 1 | 0 | 0 |\n| 84 | 1 | 0 | 0 |\n| 84+ | 1 | 0 | 0 |\n| 85 | 1 | 0 | 0 |\n| 85+ | 1 | 0 | 0 |\n| 86 | 1 | 0 | 0 |\n| 86+ | 1 | 0 | 0 |\n| 87 | 1 | 0 | 0 |\n| 87+ | 1 | 0 | 0 |\n| 88 | 1 | 0 | 0 |\n| 88+ | 1 | 0 | 0 |\n| 89 | 1 | 0 | 0 |\n| 89+ | 1 | 0 | 0 |\n| 90 | 1 | 0 | 0 |\n| 90+ | 1 | 0 | 0 |\n| 91 | 1 | 0 | 0 |\n| 91+ | 1 | 0 | 0 |\n| 92 | 1 | 0 | 0 |\n| 92+ | 1 | 0 | 0 |\n| 93 | 1 | 0 | 0 |\n| 93+ | 1 | 0 | 0 |\n| 94 | 1 | 0 | 0 |\n| 94+ | 1 | 0 | 0 |\n| 95 | 1 | 0 | 0 |\n| 95+ | 1 | 0 | 0 |\n| 96 | 1 | 0 | 0 |\n| 96+ | 1 | 0 | 0 |\n| 97 | 1 | 0 | 0 |\n| 97+ | 1 | 0 | 0 |\n| 98 | 1 | 0 | 0 |\n| 98+ | 1 | 0 | 0 |\n| 99 | 1 | 0 | 0 |\n| 99+ | 1 | 0 | 0 |\n| 100 | 1 | 0 | 0 |\n| 100+ | 1 | 0 | 0 |\n| 101 | 1 | 0 | 0 |\n| 101+ | 1 | 0 | 0 |\n| 102 | 1 | 0 | 0 |\n| 102+ | 1 | 0 | 0 |\n| 103 | 1 | 0 | 0 |\n| 103+ | 1 | 0 | 0 |\n| 104 | 1 | 0 | 0 |\n| 104+ | 1 | 0 | 0 |\n| 105 | 1 | 0 | 0 |\n| 105+ | 1 | 0 | 0 |\n| 106 | 1 | 0 | 0 |\n| 106+ | 1 | 0 | 0 |\n| 107 | 1 | 0 | 0 |"},Register:{"Register.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Register.hdl\n/**\n * 16-bit register:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value:\n * if (load(t)) out(t+1) = int(t), else out(t+1) = out(t)\n */\nCHIP Register {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Register.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Register.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 out%D1.6.1;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 11111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 12345,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000001,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000010,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000100,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000001000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000010000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000100000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000001000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000010000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000100000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000001000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000010000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000100000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0001000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0010000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0100000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1000000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111110,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111101,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111011,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111110111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111101111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111011111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111110111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111101111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111011111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111110111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111101111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111011111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1110111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1101111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1011111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0111111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;',"Register.cmp":"|time | in |load| out |\n| 0+ | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 |\n| 2 | 0 | 1 | 0 |\n| 2+ | -32123 | 0 | 0 |\n| 3 | -32123 | 0 | 0 |\n| 3+ | 11111 | 0 | 0 |\n| 4 | 11111 | 0 | 0 |\n| 4+ | -32123 | 1 | 0 |\n| 5 | -32123 | 1 | -32123 |\n| 5+ | -32123 | 1 | -32123 |\n| 6 | -32123 | 1 | -32123 |\n| 6+ | -32123 | 0 | -32123 |\n| 7 | -32123 | 0 | -32123 |\n| 7+ | 12345 | 1 | -32123 |\n| 8 | 12345 | 1 | 12345 |\n| 8+ | 0 | 0 | 12345 |\n| 9 | 0 | 0 | 12345 |\n| 9+ | 0 | 1 | 12345 |\n| 10 | 0 | 1 | 0 |\n| 10+ | 1 | 0 | 0 |\n| 11 | 1 | 0 | 0 |\n| 11+ | 1 | 1 | 0 |\n| 12 | 1 | 1 | 1 |\n| 12+ | 2 | 0 | 1 |\n| 13 | 2 | 0 | 1 |\n| 13+ | 2 | 1 | 1 |\n| 14 | 2 | 1 | 2 |\n| 14+ | 4 | 0 | 2 |\n| 15 | 4 | 0 | 2 |\n| 15+ | 4 | 1 | 2 |\n| 16 | 4 | 1 | 4 |\n| 16+ | 8 | 0 | 4 |\n| 17 | 8 | 0 | 4 |\n| 17+ | 8 | 1 | 4 |\n| 18 | 8 | 1 | 8 |\n| 18+ | 16 | 0 | 8 |\n| 19 | 16 | 0 | 8 |\n| 19+ | 16 | 1 | 8 |\n| 20 | 16 | 1 | 16 |\n| 20+ | 32 | 0 | 16 |\n| 21 | 32 | 0 | 16 |\n| 21+ | 32 | 1 | 16 |\n| 22 | 32 | 1 | 32 |\n| 22+ | 64 | 0 | 32 |\n| 23 | 64 | 0 | 32 |\n| 23+ | 64 | 1 | 32 |\n| 24 | 64 | 1 | 64 |\n| 24+ | 128 | 0 | 64 |\n| 25 | 128 | 0 | 64 |\n| 25+ | 128 | 1 | 64 |\n| 26 | 128 | 1 | 128 |\n| 26+ | 256 | 0 | 128 |\n| 27 | 256 | 0 | 128 |\n| 27+ | 256 | 1 | 128 |\n| 28 | 256 | 1 | 256 |\n| 28+ | 512 | 0 | 256 |\n| 29 | 512 | 0 | 256 |\n| 29+ | 512 | 1 | 256 |\n| 30 | 512 | 1 | 512 |\n| 30+ | 1024 | 0 | 512 |\n| 31 | 1024 | 0 | 512 |\n| 31+ | 1024 | 1 | 512 |\n| 32 | 1024 | 1 | 1024 |\n| 32+ | 2048 | 0 | 1024 |\n| 33 | 2048 | 0 | 1024 |\n| 33+ | 2048 | 1 | 1024 |\n| 34 | 2048 | 1 | 2048 |\n| 34+ | 4096 | 0 | 2048 |\n| 35 | 4096 | 0 | 2048 |\n| 35+ | 4096 | 1 | 2048 |\n| 36 | 4096 | 1 | 4096 |\n| 36+ | 8192 | 0 | 4096 |\n| 37 | 8192 | 0 | 4096 |\n| 37+ | 8192 | 1 | 4096 |\n| 38 | 8192 | 1 | 8192 |\n| 38+ | 16384 | 0 | 8192 |\n| 39 | 16384 | 0 | 8192 |\n| 39+ | 16384 | 1 | 8192 |\n| 40 | 16384 | 1 | 16384 |\n| 40+ | -32768 | 0 | 16384 |\n| 41 | -32768 | 0 | 16384 |\n| 41+ | -32768 | 1 | 16384 |\n| 42 | -32768 | 1 | -32768 |\n| 42+ | -2 | 0 | -32768 |\n| 43 | -2 | 0 | -32768 |\n| 43+ | -2 | 1 | -32768 |\n| 44 | -2 | 1 | -2 |\n| 44+ | -3 | 0 | -2 |\n| 45 | -3 | 0 | -2 |\n| 45+ | -3 | 1 | -2 |\n| 46 | -3 | 1 | -3 |\n| 46+ | -5 | 0 | -3 |\n| 47 | -5 | 0 | -3 |\n| 47+ | -5 | 1 | -3 |\n| 48 | -5 | 1 | -5 |\n| 48+ | -9 | 0 | -5 |\n| 49 | -9 | 0 | -5 |\n| 49+ | -9 | 1 | -5 |\n| 50 | -9 | 1 | -9 |\n| 50+ | -17 | 0 | -9 |\n| 51 | -17 | 0 | -9 |\n| 51+ | -17 | 1 | -9 |\n| 52 | -17 | 1 | -17 |\n| 52+ | -33 | 0 | -17 |\n| 53 | -33 | 0 | -17 |\n| 53+ | -33 | 1 | -17 |\n| 54 | -33 | 1 | -33 |\n| 54+ | -65 | 0 | -33 |\n| 55 | -65 | 0 | -33 |\n| 55+ | -65 | 1 | -33 |\n| 56 | -65 | 1 | -65 |\n| 56+ | -129 | 0 | -65 |\n| 57 | -129 | 0 | -65 |\n| 57+ | -129 | 1 | -65 |\n| 58 | -129 | 1 | -129 |\n| 58+ | -257 | 0 | -129 |\n| 59 | -257 | 0 | -129 |\n| 59+ | -257 | 1 | -129 |\n| 60 | -257 | 1 | -257 |\n| 60+ | -513 | 0 | -257 |\n| 61 | -513 | 0 | -257 |\n| 61+ | -513 | 1 | -257 |\n| 62 | -513 | 1 | -513 |\n| 62+ | -1025 | 0 | -513 |\n| 63 | -1025 | 0 | -513 |\n| 63+ | -1025 | 1 | -513 |\n| 64 | -1025 | 1 | -1025 |\n| 64+ | -2049 | 0 | -1025 |\n| 65 | -2049 | 0 | -1025 |\n| 65+ | -2049 | 1 | -1025 |\n| 66 | -2049 | 1 | -2049 |\n| 66+ | -4097 | 0 | -2049 |\n| 67 | -4097 | 0 | -2049 |\n| 67+ | -4097 | 1 | -2049 |\n| 68 | -4097 | 1 | -4097 |\n| 68+ | -8193 | 0 | -4097 |\n| 69 | -8193 | 0 | -4097 |\n| 69+ | -8193 | 1 | -4097 |\n| 70 | -8193 | 1 | -8193 |\n| 70+ | -16385 | 0 | -8193 |\n| 71 | -16385 | 0 | -8193 |\n| 71+ | -16385 | 1 | -8193 |\n| 72 | -16385 | 1 | -16385 |\n| 72+ | 32767 | 0 | -16385 |\n| 73 | 32767 | 0 | -16385 |\n| 73+ | 32767 | 1 | -16385 |\n| 74 | 32767 | 1 | 32767 |"},PC:{"PC.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/PC.hdl\n/**\n * A 16-bit counter.\n * if reset(t): out(t+1) = 0\n * else if load(t): out(t+1) = in(t)\n * else if inc(t): out(t+1) = out(t) + 1\n * else out(t+1) = out(t)\n */\nCHIP PC {\n IN in[16], reset, load, inc;\n OUT out[16];\n \n PARTS:\n //// Replace this comment with your code.\n}',"PC.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/03/a/PC.tst\n\noutput-list time%S1.3.1 in%D1.6.1 reset%B2.1.2 load%B2.1.2 inc%B2.1.2 out%D1.6.1;\n\nset in 0,\nset reset 0,\nset load 0,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\ntick,\noutput;\n\ntock,\noutput;\n\nset in 12345,\nset load 1,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 0,\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset reset 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 0,\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 22222,\nset reset 1,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;',"PC.cmp":"|time | in |reset|load | inc | out |\n| 0+ | 0 | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 0 | 0 | 1 | 0 |\n| 2 | 0 | 0 | 0 | 1 | 1 |\n| 2+ | -32123 | 0 | 0 | 1 | 1 |\n| 3 | -32123 | 0 | 0 | 1 | 2 |\n| 3+ | -32123 | 0 | 1 | 1 | 2 |\n| 4 | -32123 | 0 | 1 | 1 | -32123 |\n| 4+ | -32123 | 0 | 0 | 1 | -32123 |\n| 5 | -32123 | 0 | 0 | 1 | -32122 |\n| 5+ | -32123 | 0 | 0 | 1 | -32122 |\n| 6 | -32123 | 0 | 0 | 1 | -32121 |\n| 6+ | 12345 | 0 | 1 | 0 | -32121 |\n| 7 | 12345 | 0 | 1 | 0 | 12345 |\n| 7+ | 12345 | 1 | 1 | 0 | 12345 |\n| 8 | 12345 | 1 | 1 | 0 | 0 |\n| 8+ | 12345 | 0 | 1 | 1 | 0 |\n| 9 | 12345 | 0 | 1 | 1 | 12345 |\n| 9+ | 12345 | 1 | 1 | 1 | 12345 |\n| 10 | 12345 | 1 | 1 | 1 | 0 |\n| 10+ | 12345 | 0 | 0 | 1 | 0 |\n| 11 | 12345 | 0 | 0 | 1 | 1 |\n| 11+ | 12345 | 1 | 0 | 1 | 1 |\n| 12 | 12345 | 1 | 0 | 1 | 0 |\n| 12+ | 0 | 0 | 1 | 1 | 0 |\n| 13 | 0 | 0 | 1 | 1 | 0 |\n| 13+ | 0 | 0 | 0 | 1 | 0 |\n| 14 | 0 | 0 | 0 | 1 | 1 |\n| 14+ | 22222 | 1 | 0 | 0 | 1 |\n| 15 | 22222 | 1 | 0 | 0 | 0 |"},RAM8:{"RAM8.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM8.hdl\n/**\n * Memory of eight 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM8 {\n IN in[16], load, address[3];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM8.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM8.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D3.1.3 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 11111,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 3333,\nset address 3,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 1,\neval,\noutput;\n\nset in 7777,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 7,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 3,\neval,\noutput;\n\nset address 7,\neval,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\ntick,\noutput,\ntock,\noutput;\nset address 2,\ntick,\noutput,\ntock,\noutput;\nset address 3,\ntick,\noutput,\ntock,\noutput;\nset address 4,\ntick,\noutput,\ntock,\noutput;\nset address 5,\ntick,\noutput,\ntock,\noutput;\nset address 6,\ntick,\noutput,\ntock,\noutput;\nset address 7,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 0,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 0,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 1,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 1,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 2,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 2,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 3,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 3,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 4,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 4,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 5,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 5,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 6,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 6,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 7,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 7,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n',"RAM8.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 11111 | 0 | 0 | 0 |\n| 3 | 11111 | 0 | 0 | 0 |\n| 3+ | 11111 | 1 | 1 | 0 |\n| 4 | 11111 | 1 | 1 | 11111 |\n| 4+ | 11111 | 0 | 0 | 0 |\n| 5 | 11111 | 0 | 0 | 0 |\n| 5+ | 3333 | 0 | 3 | 0 |\n| 6 | 3333 | 0 | 3 | 0 |\n| 6+ | 3333 | 1 | 3 | 0 |\n| 7 | 3333 | 1 | 3 | 3333 |\n| 7+ | 3333 | 0 | 3 | 3333 |\n| 8 | 3333 | 0 | 3 | 3333 |\n| 8 | 3333 | 0 | 1 | 11111 |\n| 8+ | 7777 | 0 | 1 | 11111 |\n| 9 | 7777 | 0 | 1 | 11111 |\n| 9+ | 7777 | 1 | 7 | 0 |\n| 10 | 7777 | 1 | 7 | 7777 |\n| 10+ | 7777 | 0 | 7 | 7777 |\n| 11 | 7777 | 0 | 7 | 7777 |\n| 11 | 7777 | 0 | 3 | 3333 |\n| 11 | 7777 | 0 | 7 | 7777 |\n| 11+ | 7777 | 0 | 0 | 0 |\n| 12 | 7777 | 0 | 0 | 0 |\n| 12 | 7777 | 0 | 1 | 11111 |\n| 12 | 7777 | 0 | 2 | 0 |\n| 12 | 7777 | 0 | 3 | 3333 |\n| 12 | 7777 | 0 | 4 | 0 |\n| 12 | 7777 | 0 | 5 | 0 |\n| 12 | 7777 | 0 | 6 | 0 |\n| 12 | 7777 | 0 | 7 | 7777 |\n| 12+ | 21845 | 1 | 0 | 0 |\n| 13 | 21845 | 1 | 0 | 21845 |\n| 13+ | 21845 | 1 | 1 | 11111 |\n| 14 | 21845 | 1 | 1 | 21845 |\n| 14+ | 21845 | 1 | 2 | 0 |\n| 15 | 21845 | 1 | 2 | 21845 |\n| 15+ | 21845 | 1 | 3 | 3333 |\n| 16 | 21845 | 1 | 3 | 21845 |\n| 16+ | 21845 | 1 | 4 | 0 |\n| 17 | 21845 | 1 | 4 | 21845 |\n| 17+ | 21845 | 1 | 5 | 0 |\n| 18 | 21845 | 1 | 5 | 21845 |\n| 18+ | 21845 | 1 | 6 | 0 |\n| 19 | 21845 | 1 | 6 | 21845 |\n| 19+ | 21845 | 1 | 7 | 7777 |\n| 20 | 21845 | 1 | 7 | 21845 |\n| 20+ | 21845 | 0 | 0 | 21845 |\n| 21 | 21845 | 0 | 0 | 21845 |\n| 21 | 21845 | 0 | 1 | 21845 |\n| 21 | 21845 | 0 | 2 | 21845 |\n| 21 | 21845 | 0 | 3 | 21845 |\n| 21 | 21845 | 0 | 4 | 21845 |\n| 21 | 21845 | 0 | 5 | 21845 |\n| 21 | 21845 | 0 | 6 | 21845 |\n| 21 | 21845 | 0 | 7 | 21845 |\n| 21+ | -21846 | 1 | 0 | 21845 |\n| 22 | -21846 | 1 | 0 | -21846 |\n| 22+ | -21846 | 0 | 0 | -21846 |\n| 23 | -21846 | 0 | 0 | -21846 |\n| 23 | -21846 | 0 | 1 | 21845 |\n| 23 | -21846 | 0 | 2 | 21845 |\n| 23 | -21846 | 0 | 3 | 21845 |\n| 23 | -21846 | 0 | 4 | 21845 |\n| 23 | -21846 | 0 | 5 | 21845 |\n| 23 | -21846 | 0 | 6 | 21845 |\n| 23 | -21846 | 0 | 7 | 21845 |\n| 23+ | 21845 | 1 | 0 | -21846 |\n| 24 | 21845 | 1 | 0 | 21845 |\n| 24+ | -21846 | 1 | 1 | 21845 |\n| 25 | -21846 | 1 | 1 | -21846 |\n| 25+ | -21846 | 0 | 0 | 21845 |\n| 26 | -21846 | 0 | 0 | 21845 |\n| 26 | -21846 | 0 | 1 | -21846 |\n| 26 | -21846 | 0 | 2 | 21845 |\n| 26 | -21846 | 0 | 3 | 21845 |\n| 26 | -21846 | 0 | 4 | 21845 |\n| 26 | -21846 | 0 | 5 | 21845 |\n| 26 | -21846 | 0 | 6 | 21845 |\n| 26 | -21846 | 0 | 7 | 21845 |\n| 26+ | 21845 | 1 | 1 | -21846 |\n| 27 | 21845 | 1 | 1 | 21845 |\n| 27+ | -21846 | 1 | 2 | 21845 |\n| 28 | -21846 | 1 | 2 | -21846 |\n| 28+ | -21846 | 0 | 0 | 21845 |\n| 29 | -21846 | 0 | 0 | 21845 |\n| 29 | -21846 | 0 | 1 | 21845 |\n| 29 | -21846 | 0 | 2 | -21846 |\n| 29 | -21846 | 0 | 3 | 21845 |\n| 29 | -21846 | 0 | 4 | 21845 |\n| 29 | -21846 | 0 | 5 | 21845 |\n| 29 | -21846 | 0 | 6 | 21845 |\n| 29 | -21846 | 0 | 7 | 21845 |\n| 29+ | 21845 | 1 | 2 | -21846 |\n| 30 | 21845 | 1 | 2 | 21845 |\n| 30+ | -21846 | 1 | 3 | 21845 |\n| 31 | -21846 | 1 | 3 | -21846 |\n| 31+ | -21846 | 0 | 0 | 21845 |\n| 32 | -21846 | 0 | 0 | 21845 |\n| 32 | -21846 | 0 | 1 | 21845 |\n| 32 | -21846 | 0 | 2 | 21845 |\n| 32 | -21846 | 0 | 3 | -21846 |\n| 32 | -21846 | 0 | 4 | 21845 |\n| 32 | -21846 | 0 | 5 | 21845 |\n| 32 | -21846 | 0 | 6 | 21845 |\n| 32 | -21846 | 0 | 7 | 21845 |\n| 32+ | 21845 | 1 | 3 | -21846 |\n| 33 | 21845 | 1 | 3 | 21845 |\n| 33+ | -21846 | 1 | 4 | 21845 |\n| 34 | -21846 | 1 | 4 | -21846 |\n| 34+ | -21846 | 0 | 0 | 21845 |\n| 35 | -21846 | 0 | 0 | 21845 |\n| 35 | -21846 | 0 | 1 | 21845 |\n| 35 | -21846 | 0 | 2 | 21845 |\n| 35 | -21846 | 0 | 3 | 21845 |\n| 35 | -21846 | 0 | 4 | -21846 |\n| 35 | -21846 | 0 | 5 | 21845 |\n| 35 | -21846 | 0 | 6 | 21845 |\n| 35 | -21846 | 0 | 7 | 21845 |\n| 35+ | 21845 | 1 | 4 | -21846 |\n| 36 | 21845 | 1 | 4 | 21845 |\n| 36+ | -21846 | 1 | 5 | 21845 |\n| 37 | -21846 | 1 | 5 | -21846 |\n| 37+ | -21846 | 0 | 0 | 21845 |\n| 38 | -21846 | 0 | 0 | 21845 |\n| 38 | -21846 | 0 | 1 | 21845 |\n| 38 | -21846 | 0 | 2 | 21845 |\n| 38 | -21846 | 0 | 3 | 21845 |\n| 38 | -21846 | 0 | 4 | 21845 |\n| 38 | -21846 | 0 | 5 | -21846 |\n| 38 | -21846 | 0 | 6 | 21845 |\n| 38 | -21846 | 0 | 7 | 21845 |\n| 38+ | 21845 | 1 | 5 | -21846 |\n| 39 | 21845 | 1 | 5 | 21845 |\n| 39+ | -21846 | 1 | 6 | 21845 |\n| 40 | -21846 | 1 | 6 | -21846 |\n| 40+ | -21846 | 0 | 0 | 21845 |\n| 41 | -21846 | 0 | 0 | 21845 |\n| 41 | -21846 | 0 | 1 | 21845 |\n| 41 | -21846 | 0 | 2 | 21845 |\n| 41 | -21846 | 0 | 3 | 21845 |\n| 41 | -21846 | 0 | 4 | 21845 |\n| 41 | -21846 | 0 | 5 | 21845 |\n| 41 | -21846 | 0 | 6 | -21846 |\n| 41 | -21846 | 0 | 7 | 21845 |\n| 41+ | 21845 | 1 | 6 | -21846 |\n| 42 | 21845 | 1 | 6 | 21845 |\n| 42+ | -21846 | 1 | 7 | 21845 |\n| 43 | -21846 | 1 | 7 | -21846 |\n| 43+ | -21846 | 0 | 0 | 21845 |\n| 44 | -21846 | 0 | 0 | 21845 |\n| 44 | -21846 | 0 | 1 | 21845 |\n| 44 | -21846 | 0 | 2 | 21845 |\n| 44 | -21846 | 0 | 3 | 21845 |\n| 44 | -21846 | 0 | 4 | 21845 |\n| 44 | -21846 | 0 | 5 | 21845 |\n| 44 | -21846 | 0 | 6 | 21845 |\n| 44 | -21846 | 0 | 7 | -21846 |\n| 44+ | 21845 | 1 | 7 | -21846 |\n| 45 | 21845 | 1 | 7 | 21845 |\n| 45+ | 21845 | 0 | 0 | 21845 |\n| 46 | 21845 | 0 | 0 | 21845 |\n| 46 | 21845 | 0 | 1 | 21845 |\n| 46 | 21845 | 0 | 2 | 21845 |\n| 46 | 21845 | 0 | 3 | 21845 |\n| 46 | 21845 | 0 | 4 | 21845 |\n| 46 | 21845 | 0 | 5 | 21845 |\n| 46 | 21845 | 0 | 6 | 21845 |\n| 46 | 21845 | 0 | 7 | 21845 |"},RAM64:{"RAM64.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM64.hdl\n/**\n * Memory of sixty four 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM64 {\n IN in[16], load, address[6];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM64.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM64.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.3.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 1313,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 13,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 4747,\nset address 47,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 13,\neval,\noutput;\n\nset in 6363,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 63,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 47,\neval,\noutput;\n\nset address 63,\neval,\noutput;\n\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\ntick,\noutput,\ntock,\noutput;\nset address %B101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101011,\ntick,\noutput,\ntock,\noutput;\nset address %B101100,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\ntick,\noutput,\ntock,\noutput;\nset address %B101110,\ntick,\noutput,\ntock,\noutput;\nset address %B101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B000101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B000101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B001101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B011101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B100101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B110101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B111101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;',"RAM64.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 1313 | 0 | 0 | 0 |\n| 3 | 1313 | 0 | 0 | 0 |\n| 3+ | 1313 | 1 | 13 | 0 |\n| 4 | 1313 | 1 | 13 | 1313 |\n| 4+ | 1313 | 0 | 0 | 0 |\n| 5 | 1313 | 0 | 0 | 0 |\n| 5+ | 4747 | 0 | 47 | 0 |\n| 6 | 4747 | 0 | 47 | 0 |\n| 6+ | 4747 | 1 | 47 | 0 |\n| 7 | 4747 | 1 | 47 | 4747 |\n| 7+ | 4747 | 0 | 47 | 4747 |\n| 8 | 4747 | 0 | 47 | 4747 |\n| 8 | 4747 | 0 | 13 | 1313 |\n| 8+ | 6363 | 0 | 13 | 1313 |\n| 9 | 6363 | 0 | 13 | 1313 |\n| 9+ | 6363 | 1 | 63 | 0 |\n| 10 | 6363 | 1 | 63 | 6363 |\n| 10+ | 6363 | 0 | 63 | 6363 |\n| 11 | 6363 | 0 | 63 | 6363 |\n| 11 | 6363 | 0 | 47 | 4747 |\n| 11 | 6363 | 0 | 63 | 6363 |\n| 11+ | 6363 | 0 | 40 | 0 |\n| 12 | 6363 | 0 | 40 | 0 |\n| 12 | 6363 | 0 | 41 | 0 |\n| 12 | 6363 | 0 | 42 | 0 |\n| 12 | 6363 | 0 | 43 | 0 |\n| 12 | 6363 | 0 | 44 | 0 |\n| 12 | 6363 | 0 | 45 | 0 |\n| 12 | 6363 | 0 | 46 | 0 |\n| 12 | 6363 | 0 | 47 | 4747 |\n| 12+ | 21845 | 1 | 40 | 0 |\n| 13 | 21845 | 1 | 40 | 21845 |\n| 13+ | 21845 | 1 | 41 | 0 |\n| 14 | 21845 | 1 | 41 | 21845 |\n| 14+ | 21845 | 1 | 42 | 0 |\n| 15 | 21845 | 1 | 42 | 21845 |\n| 15+ | 21845 | 1 | 43 | 0 |\n| 16 | 21845 | 1 | 43 | 21845 |\n| 16+ | 21845 | 1 | 44 | 0 |\n| 17 | 21845 | 1 | 44 | 21845 |\n| 17+ | 21845 | 1 | 45 | 0 |\n| 18 | 21845 | 1 | 45 | 21845 |\n| 18+ | 21845 | 1 | 46 | 0 |\n| 19 | 21845 | 1 | 46 | 21845 |\n| 19+ | 21845 | 1 | 47 | 4747 |\n| 20 | 21845 | 1 | 47 | 21845 |\n| 20+ | 21845 | 0 | 40 | 21845 |\n| 21 | 21845 | 0 | 40 | 21845 |\n| 21 | 21845 | 0 | 41 | 21845 |\n| 21 | 21845 | 0 | 42 | 21845 |\n| 21 | 21845 | 0 | 43 | 21845 |\n| 21 | 21845 | 0 | 44 | 21845 |\n| 21 | 21845 | 0 | 45 | 21845 |\n| 21 | 21845 | 0 | 46 | 21845 |\n| 21 | 21845 | 0 | 47 | 21845 |\n| 21+ | -21846 | 1 | 40 | 21845 |\n| 22 | -21846 | 1 | 40 | -21846 |\n| 22+ | -21846 | 0 | 40 | -21846 |\n| 23 | -21846 | 0 | 40 | -21846 |\n| 23 | -21846 | 0 | 41 | 21845 |\n| 23 | -21846 | 0 | 42 | 21845 |\n| 23 | -21846 | 0 | 43 | 21845 |\n| 23 | -21846 | 0 | 44 | 21845 |\n| 23 | -21846 | 0 | 45 | 21845 |\n| 23 | -21846 | 0 | 46 | 21845 |\n| 23 | -21846 | 0 | 47 | 21845 |\n| 23+ | 21845 | 1 | 40 | -21846 |\n| 24 | 21845 | 1 | 40 | 21845 |\n| 24+ | -21846 | 1 | 41 | 21845 |\n| 25 | -21846 | 1 | 41 | -21846 |\n| 25+ | -21846 | 0 | 40 | 21845 |\n| 26 | -21846 | 0 | 40 | 21845 |\n| 26 | -21846 | 0 | 41 | -21846 |\n| 26 | -21846 | 0 | 42 | 21845 |\n| 26 | -21846 | 0 | 43 | 21845 |\n| 26 | -21846 | 0 | 44 | 21845 |\n| 26 | -21846 | 0 | 45 | 21845 |\n| 26 | -21846 | 0 | 46 | 21845 |\n| 26 | -21846 | 0 | 47 | 21845 |\n| 26+ | 21845 | 1 | 41 | -21846 |\n| 27 | 21845 | 1 | 41 | 21845 |\n| 27+ | -21846 | 1 | 42 | 21845 |\n| 28 | -21846 | 1 | 42 | -21846 |\n| 28+ | -21846 | 0 | 40 | 21845 |\n| 29 | -21846 | 0 | 40 | 21845 |\n| 29 | -21846 | 0 | 41 | 21845 |\n| 29 | -21846 | 0 | 42 | -21846 |\n| 29 | -21846 | 0 | 43 | 21845 |\n| 29 | -21846 | 0 | 44 | 21845 |\n| 29 | -21846 | 0 | 45 | 21845 |\n| 29 | -21846 | 0 | 46 | 21845 |\n| 29 | -21846 | 0 | 47 | 21845 |\n| 29+ | 21845 | 1 | 42 | -21846 |\n| 30 | 21845 | 1 | 42 | 21845 |\n| 30+ | -21846 | 1 | 43 | 21845 |\n| 31 | -21846 | 1 | 43 | -21846 |\n| 31+ | -21846 | 0 | 40 | 21845 |\n| 32 | -21846 | 0 | 40 | 21845 |\n| 32 | -21846 | 0 | 41 | 21845 |\n| 32 | -21846 | 0 | 42 | 21845 |\n| 32 | -21846 | 0 | 43 | -21846 |\n| 32 | -21846 | 0 | 44 | 21845 |\n| 32 | -21846 | 0 | 45 | 21845 |\n| 32 | -21846 | 0 | 46 | 21845 |\n| 32 | -21846 | 0 | 47 | 21845 |\n| 32+ | 21845 | 1 | 43 | -21846 |\n| 33 | 21845 | 1 | 43 | 21845 |\n| 33+ | -21846 | 1 | 44 | 21845 |\n| 34 | -21846 | 1 | 44 | -21846 |\n| 34+ | -21846 | 0 | 40 | 21845 |\n| 35 | -21846 | 0 | 40 | 21845 |\n| 35 | -21846 | 0 | 41 | 21845 |\n| 35 | -21846 | 0 | 42 | 21845 |\n| 35 | -21846 | 0 | 43 | 21845 |\n| 35 | -21846 | 0 | 44 | -21846 |\n| 35 | -21846 | 0 | 45 | 21845 |\n| 35 | -21846 | 0 | 46 | 21845 |\n| 35 | -21846 | 0 | 47 | 21845 |\n| 35+ | 21845 | 1 | 44 | -21846 |\n| 36 | 21845 | 1 | 44 | 21845 |\n| 36+ | -21846 | 1 | 45 | 21845 |\n| 37 | -21846 | 1 | 45 | -21846 |\n| 37+ | -21846 | 0 | 40 | 21845 |\n| 38 | -21846 | 0 | 40 | 21845 |\n| 38 | -21846 | 0 | 41 | 21845 |\n| 38 | -21846 | 0 | 42 | 21845 |\n| 38 | -21846 | 0 | 43 | 21845 |\n| 38 | -21846 | 0 | 44 | 21845 |\n| 38 | -21846 | 0 | 45 | -21846 |\n| 38 | -21846 | 0 | 46 | 21845 |\n| 38 | -21846 | 0 | 47 | 21845 |\n| 38+ | 21845 | 1 | 45 | -21846 |\n| 39 | 21845 | 1 | 45 | 21845 |\n| 39+ | -21846 | 1 | 46 | 21845 |\n| 40 | -21846 | 1 | 46 | -21846 |\n| 40+ | -21846 | 0 | 40 | 21845 |\n| 41 | -21846 | 0 | 40 | 21845 |\n| 41 | -21846 | 0 | 41 | 21845 |\n| 41 | -21846 | 0 | 42 | 21845 |\n| 41 | -21846 | 0 | 43 | 21845 |\n| 41 | -21846 | 0 | 44 | 21845 |\n| 41 | -21846 | 0 | 45 | 21845 |\n| 41 | -21846 | 0 | 46 | -21846 |\n| 41 | -21846 | 0 | 47 | 21845 |\n| 41+ | 21845 | 1 | 46 | -21846 |\n| 42 | 21845 | 1 | 46 | 21845 |\n| 42+ | -21846 | 1 | 47 | 21845 |\n| 43 | -21846 | 1 | 47 | -21846 |\n| 43+ | -21846 | 0 | 40 | 21845 |\n| 44 | -21846 | 0 | 40 | 21845 |\n| 44 | -21846 | 0 | 41 | 21845 |\n| 44 | -21846 | 0 | 42 | 21845 |\n| 44 | -21846 | 0 | 43 | 21845 |\n| 44 | -21846 | 0 | 44 | 21845 |\n| 44 | -21846 | 0 | 45 | 21845 |\n| 44 | -21846 | 0 | 46 | 21845 |\n| 44 | -21846 | 0 | 47 | -21846 |\n| 44+ | 21845 | 1 | 47 | -21846 |\n| 45 | 21845 | 1 | 47 | 21845 |\n| 45+ | 21845 | 0 | 40 | 21845 |\n| 46 | 21845 | 0 | 40 | 21845 |\n| 46 | 21845 | 0 | 41 | 21845 |\n| 46 | 21845 | 0 | 42 | 21845 |\n| 46 | 21845 | 0 | 43 | 21845 |\n| 46 | 21845 | 0 | 44 | 21845 |\n| 46 | 21845 | 0 | 45 | 21845 |\n| 46 | 21845 | 0 | 46 | 21845 |\n| 46 | 21845 | 0 | 47 | 21845 |\n| 46+ | 21845 | 0 | 5 | 0 |\n| 47 | 21845 | 0 | 5 | 0 |\n| 47 | 21845 | 0 | 13 | 1313 |\n| 47 | 21845 | 0 | 21 | 0 |\n| 47 | 21845 | 0 | 29 | 0 |\n| 47 | 21845 | 0 | 37 | 0 |\n| 47 | 21845 | 0 | 45 | 21845 |\n| 47 | 21845 | 0 | 53 | 0 |\n| 47 | 21845 | 0 | 61 | 0 |\n| 47+ | 21845 | 1 | 5 | 0 |\n| 48 | 21845 | 1 | 5 | 21845 |\n| 48+ | 21845 | 1 | 13 | 1313 |\n| 49 | 21845 | 1 | 13 | 21845 |\n| 49+ | 21845 | 1 | 21 | 0 |\n| 50 | 21845 | 1 | 21 | 21845 |\n| 50+ | 21845 | 1 | 29 | 0 |\n| 51 | 21845 | 1 | 29 | 21845 |\n| 51+ | 21845 | 1 | 37 | 0 |\n| 52 | 21845 | 1 | 37 | 21845 |\n| 52+ | 21845 | 1 | 45 | 21845 |\n| 53 | 21845 | 1 | 45 | 21845 |\n| 53+ | 21845 | 1 | 53 | 0 |\n| 54 | 21845 | 1 | 53 | 21845 |\n| 54+ | 21845 | 1 | 61 | 0 |\n| 55 | 21845 | 1 | 61 | 21845 |\n| 55+ | 21845 | 0 | 5 | 21845 |\n| 56 | 21845 | 0 | 5 | 21845 |\n| 56 | 21845 | 0 | 13 | 21845 |\n| 56 | 21845 | 0 | 21 | 21845 |\n| 56 | 21845 | 0 | 29 | 21845 |\n| 56 | 21845 | 0 | 37 | 21845 |\n| 56 | 21845 | 0 | 45 | 21845 |\n| 56 | 21845 | 0 | 53 | 21845 |\n| 56 | 21845 | 0 | 61 | 21845 |\n| 56+ | -21846 | 1 | 5 | 21845 |\n| 57 | -21846 | 1 | 5 | -21846 |\n| 57+ | -21846 | 0 | 5 | -21846 |\n| 58 | -21846 | 0 | 5 | -21846 |\n| 58 | -21846 | 0 | 13 | 21845 |\n| 58 | -21846 | 0 | 21 | 21845 |\n| 58 | -21846 | 0 | 29 | 21845 |\n| 58 | -21846 | 0 | 37 | 21845 |\n| 58 | -21846 | 0 | 45 | 21845 |\n| 58 | -21846 | 0 | 53 | 21845 |\n| 58 | -21846 | 0 | 61 | 21845 |\n| 58+ | 21845 | 1 | 5 | -21846 |\n| 59 | 21845 | 1 | 5 | 21845 |\n| 59+ | -21846 | 1 | 13 | 21845 |\n| 60 | -21846 | 1 | 13 | -21846 |\n| 60+ | -21846 | 0 | 5 | 21845 |\n| 61 | -21846 | 0 | 5 | 21845 |\n| 61 | -21846 | 0 | 13 | -21846 |\n| 61 | -21846 | 0 | 21 | 21845 |\n| 61 | -21846 | 0 | 29 | 21845 |\n| 61 | -21846 | 0 | 37 | 21845 |\n| 61 | -21846 | 0 | 45 | 21845 |\n| 61 | -21846 | 0 | 53 | 21845 |\n| 61 | -21846 | 0 | 61 | 21845 |\n| 61+ | 21845 | 1 | 13 | -21846 |\n| 62 | 21845 | 1 | 13 | 21845 |\n| 62+ | -21846 | 1 | 21 | 21845 |\n| 63 | -21846 | 1 | 21 | -21846 |\n| 63+ | -21846 | 0 | 5 | 21845 |\n| 64 | -21846 | 0 | 5 | 21845 |\n| 64 | -21846 | 0 | 13 | 21845 |\n| 64 | -21846 | 0 | 21 | -21846 |\n| 64 | -21846 | 0 | 29 | 21845 |\n| 64 | -21846 | 0 | 37 | 21845 |\n| 64 | -21846 | 0 | 45 | 21845 |\n| 64 | -21846 | 0 | 53 | 21845 |\n| 64 | -21846 | 0 | 61 | 21845 |\n| 64+ | 21845 | 1 | 21 | -21846 |\n| 65 | 21845 | 1 | 21 | 21845 |\n| 65+ | -21846 | 1 | 29 | 21845 |\n| 66 | -21846 | 1 | 29 | -21846 |\n| 66+ | -21846 | 0 | 5 | 21845 |\n| 67 | -21846 | 0 | 5 | 21845 |\n| 67 | -21846 | 0 | 13 | 21845 |\n| 67 | -21846 | 0 | 21 | 21845 |\n| 67 | -21846 | 0 | 29 | -21846 |\n| 67 | -21846 | 0 | 37 | 21845 |\n| 67 | -21846 | 0 | 45 | 21845 |\n| 67 | -21846 | 0 | 53 | 21845 |\n| 67 | -21846 | 0 | 61 | 21845 |\n| 67+ | 21845 | 1 | 29 | -21846 |\n| 68 | 21845 | 1 | 29 | 21845 |\n| 68+ | -21846 | 1 | 37 | 21845 |\n| 69 | -21846 | 1 | 37 | -21846 |\n| 69+ | -21846 | 0 | 5 | 21845 |\n| 70 | -21846 | 0 | 5 | 21845 |\n| 70 | -21846 | 0 | 13 | 21845 |\n| 70 | -21846 | 0 | 21 | 21845 |\n| 70 | -21846 | 0 | 29 | 21845 |\n| 70 | -21846 | 0 | 37 | -21846 |\n| 70 | -21846 | 0 | 45 | 21845 |\n| 70 | -21846 | 0 | 53 | 21845 |\n| 70 | -21846 | 0 | 61 | 21845 |\n| 70+ | 21845 | 1 | 37 | -21846 |\n| 71 | 21845 | 1 | 37 | 21845 |\n| 71+ | -21846 | 1 | 45 | 21845 |\n| 72 | -21846 | 1 | 45 | -21846 |\n| 72+ | -21846 | 0 | 5 | 21845 |\n| 73 | -21846 | 0 | 5 | 21845 |\n| 73 | -21846 | 0 | 13 | 21845 |\n| 73 | -21846 | 0 | 21 | 21845 |\n| 73 | -21846 | 0 | 29 | 21845 |\n| 73 | -21846 | 0 | 37 | 21845 |\n| 73 | -21846 | 0 | 45 | -21846 |\n| 73 | -21846 | 0 | 53 | 21845 |\n| 73 | -21846 | 0 | 61 | 21845 |\n| 73+ | 21845 | 1 | 45 | -21846 |\n| 74 | 21845 | 1 | 45 | 21845 |\n| 74+ | -21846 | 1 | 53 | 21845 |\n| 75 | -21846 | 1 | 53 | -21846 |\n| 75+ | -21846 | 0 | 5 | 21845 |\n| 76 | -21846 | 0 | 5 | 21845 |\n| 76 | -21846 | 0 | 13 | 21845 |\n| 76 | -21846 | 0 | 21 | 21845 |\n| 76 | -21846 | 0 | 29 | 21845 |\n| 76 | -21846 | 0 | 37 | 21845 |\n| 76 | -21846 | 0 | 45 | 21845 |\n| 76 | -21846 | 0 | 53 | -21846 |\n| 76 | -21846 | 0 | 61 | 21845 |\n| 76+ | 21845 | 1 | 53 | -21846 |\n| 77 | 21845 | 1 | 53 | 21845 |\n| 77+ | -21846 | 1 | 61 | 21845 |\n| 78 | -21846 | 1 | 61 | -21846 |\n| 78+ | -21846 | 0 | 5 | 21845 |\n| 79 | -21846 | 0 | 5 | 21845 |\n| 79 | -21846 | 0 | 13 | 21845 |\n| 79 | -21846 | 0 | 21 | 21845 |\n| 79 | -21846 | 0 | 29 | 21845 |\n| 79 | -21846 | 0 | 37 | 21845 |\n| 79 | -21846 | 0 | 45 | 21845 |\n| 79 | -21846 | 0 | 53 | 21845 |\n| 79 | -21846 | 0 | 61 | -21846 |\n| 79+ | 21845 | 1 | 61 | -21846 |\n| 80 | 21845 | 1 | 61 | 21845 |\n| 80+ | 21845 | 0 | 5 | 21845 |\n| 81 | 21845 | 0 | 5 | 21845 |\n| 81 | 21845 | 0 | 13 | 21845 |\n| 81 | 21845 | 0 | 21 | 21845 |\n| 81 | 21845 | 0 | 29 | 21845 |\n| 81 | 21845 | 0 | 37 | 21845 |\n| 81 | 21845 | 0 | 45 | 21845 |\n| 81 | 21845 | 0 | 53 | 21845 |\n| 81 | 21845 | 0 | 61 | 21845 |"},RAM512:{"RAM512.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM512.hdl\n/**\n * Memory of 512 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM512 {\n IN in[16], load, address[9];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM512.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM512.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.3.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 13099,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 130,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 4729,\nset address 472,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 130,\neval,\noutput;\n\nset in 5119,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 511,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 472,\neval,\noutput;\n\nset address 511,\neval,\noutput;\n\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B000101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B000101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B001101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B011101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B100101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B101101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B110101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B111101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n',"RAM512.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 13099 | 0 | 0 | 0 |\n| 3 | 13099 | 0 | 0 | 0 |\n| 3+ | 13099 | 1 | 130 | 0 |\n| 4 | 13099 | 1 | 130 | 13099 |\n| 4+ | 13099 | 0 | 0 | 0 |\n| 5 | 13099 | 0 | 0 | 0 |\n| 5+ | 4729 | 0 | 472 | 0 |\n| 6 | 4729 | 0 | 472 | 0 |\n| 6+ | 4729 | 1 | 472 | 0 |\n| 7 | 4729 | 1 | 472 | 4729 |\n| 7+ | 4729 | 0 | 472 | 4729 |\n| 8 | 4729 | 0 | 472 | 4729 |\n| 8 | 4729 | 0 | 130 | 13099 |\n| 8+ | 5119 | 0 | 130 | 13099 |\n| 9 | 5119 | 0 | 130 | 13099 |\n| 9+ | 5119 | 1 | 511 | 0 |\n| 10 | 5119 | 1 | 511 | 5119 |\n| 10+ | 5119 | 0 | 511 | 5119 |\n| 11 | 5119 | 0 | 511 | 5119 |\n| 11 | 5119 | 0 | 472 | 4729 |\n| 11 | 5119 | 0 | 511 | 5119 |\n| 11+ | 5119 | 0 | 168 | 0 |\n| 12 | 5119 | 0 | 168 | 0 |\n| 12 | 5119 | 0 | 169 | 0 |\n| 12 | 5119 | 0 | 170 | 0 |\n| 12 | 5119 | 0 | 171 | 0 |\n| 12 | 5119 | 0 | 172 | 0 |\n| 12 | 5119 | 0 | 173 | 0 |\n| 12 | 5119 | 0 | 174 | 0 |\n| 12 | 5119 | 0 | 175 | 0 |\n| 12+ | 21845 | 1 | 168 | 0 |\n| 13 | 21845 | 1 | 168 | 21845 |\n| 13+ | 21845 | 1 | 169 | 0 |\n| 14 | 21845 | 1 | 169 | 21845 |\n| 14+ | 21845 | 1 | 170 | 0 |\n| 15 | 21845 | 1 | 170 | 21845 |\n| 15+ | 21845 | 1 | 171 | 0 |\n| 16 | 21845 | 1 | 171 | 21845 |\n| 16+ | 21845 | 1 | 172 | 0 |\n| 17 | 21845 | 1 | 172 | 21845 |\n| 17+ | 21845 | 1 | 173 | 0 |\n| 18 | 21845 | 1 | 173 | 21845 |\n| 18+ | 21845 | 1 | 174 | 0 |\n| 19 | 21845 | 1 | 174 | 21845 |\n| 19+ | 21845 | 1 | 175 | 0 |\n| 20 | 21845 | 1 | 175 | 21845 |\n| 20+ | 21845 | 0 | 168 | 21845 |\n| 21 | 21845 | 0 | 168 | 21845 |\n| 21 | 21845 | 0 | 169 | 21845 |\n| 21 | 21845 | 0 | 170 | 21845 |\n| 21 | 21845 | 0 | 171 | 21845 |\n| 21 | 21845 | 0 | 172 | 21845 |\n| 21 | 21845 | 0 | 173 | 21845 |\n| 21 | 21845 | 0 | 174 | 21845 |\n| 21 | 21845 | 0 | 175 | 21845 |\n| 21+ | -21846 | 1 | 168 | 21845 |\n| 22 | -21846 | 1 | 168 | -21846 |\n| 22+ | -21846 | 0 | 168 | -21846 |\n| 23 | -21846 | 0 | 168 | -21846 |\n| 23 | -21846 | 0 | 169 | 21845 |\n| 23 | -21846 | 0 | 170 | 21845 |\n| 23 | -21846 | 0 | 171 | 21845 |\n| 23 | -21846 | 0 | 172 | 21845 |\n| 23 | -21846 | 0 | 173 | 21845 |\n| 23 | -21846 | 0 | 174 | 21845 |\n| 23 | -21846 | 0 | 175 | 21845 |\n| 23+ | 21845 | 1 | 168 | -21846 |\n| 24 | 21845 | 1 | 168 | 21845 |\n| 24+ | -21846 | 1 | 169 | 21845 |\n| 25 | -21846 | 1 | 169 | -21846 |\n| 25+ | -21846 | 0 | 168 | 21845 |\n| 26 | -21846 | 0 | 168 | 21845 |\n| 26 | -21846 | 0 | 169 | -21846 |\n| 26 | -21846 | 0 | 170 | 21845 |\n| 26 | -21846 | 0 | 171 | 21845 |\n| 26 | -21846 | 0 | 172 | 21845 |\n| 26 | -21846 | 0 | 173 | 21845 |\n| 26 | -21846 | 0 | 174 | 21845 |\n| 26 | -21846 | 0 | 175 | 21845 |\n| 26+ | 21845 | 1 | 169 | -21846 |\n| 27 | 21845 | 1 | 169 | 21845 |\n| 27+ | -21846 | 1 | 170 | 21845 |\n| 28 | -21846 | 1 | 170 | -21846 |\n| 28+ | -21846 | 0 | 168 | 21845 |\n| 29 | -21846 | 0 | 168 | 21845 |\n| 29 | -21846 | 0 | 169 | 21845 |\n| 29 | -21846 | 0 | 170 | -21846 |\n| 29 | -21846 | 0 | 171 | 21845 |\n| 29 | -21846 | 0 | 172 | 21845 |\n| 29 | -21846 | 0 | 173 | 21845 |\n| 29 | -21846 | 0 | 174 | 21845 |\n| 29 | -21846 | 0 | 175 | 21845 |\n| 29+ | 21845 | 1 | 170 | -21846 |\n| 30 | 21845 | 1 | 170 | 21845 |\n| 30+ | -21846 | 1 | 171 | 21845 |\n| 31 | -21846 | 1 | 171 | -21846 |\n| 31+ | -21846 | 0 | 168 | 21845 |\n| 32 | -21846 | 0 | 168 | 21845 |\n| 32 | -21846 | 0 | 169 | 21845 |\n| 32 | -21846 | 0 | 170 | 21845 |\n| 32 | -21846 | 0 | 171 | -21846 |\n| 32 | -21846 | 0 | 172 | 21845 |\n| 32 | -21846 | 0 | 173 | 21845 |\n| 32 | -21846 | 0 | 174 | 21845 |\n| 32 | -21846 | 0 | 175 | 21845 |\n| 32+ | 21845 | 1 | 171 | -21846 |\n| 33 | 21845 | 1 | 171 | 21845 |\n| 33+ | -21846 | 1 | 172 | 21845 |\n| 34 | -21846 | 1 | 172 | -21846 |\n| 34+ | -21846 | 0 | 168 | 21845 |\n| 35 | -21846 | 0 | 168 | 21845 |\n| 35 | -21846 | 0 | 169 | 21845 |\n| 35 | -21846 | 0 | 170 | 21845 |\n| 35 | -21846 | 0 | 171 | 21845 |\n| 35 | -21846 | 0 | 172 | -21846 |\n| 35 | -21846 | 0 | 173 | 21845 |\n| 35 | -21846 | 0 | 174 | 21845 |\n| 35 | -21846 | 0 | 175 | 21845 |\n| 35+ | 21845 | 1 | 172 | -21846 |\n| 36 | 21845 | 1 | 172 | 21845 |\n| 36+ | -21846 | 1 | 173 | 21845 |\n| 37 | -21846 | 1 | 173 | -21846 |\n| 37+ | -21846 | 0 | 168 | 21845 |\n| 38 | -21846 | 0 | 168 | 21845 |\n| 38 | -21846 | 0 | 169 | 21845 |\n| 38 | -21846 | 0 | 170 | 21845 |\n| 38 | -21846 | 0 | 171 | 21845 |\n| 38 | -21846 | 0 | 172 | 21845 |\n| 38 | -21846 | 0 | 173 | -21846 |\n| 38 | -21846 | 0 | 174 | 21845 |\n| 38 | -21846 | 0 | 175 | 21845 |\n| 38+ | 21845 | 1 | 173 | -21846 |\n| 39 | 21845 | 1 | 173 | 21845 |\n| 39+ | -21846 | 1 | 174 | 21845 |\n| 40 | -21846 | 1 | 174 | -21846 |\n| 40+ | -21846 | 0 | 168 | 21845 |\n| 41 | -21846 | 0 | 168 | 21845 |\n| 41 | -21846 | 0 | 169 | 21845 |\n| 41 | -21846 | 0 | 170 | 21845 |\n| 41 | -21846 | 0 | 171 | 21845 |\n| 41 | -21846 | 0 | 172 | 21845 |\n| 41 | -21846 | 0 | 173 | 21845 |\n| 41 | -21846 | 0 | 174 | -21846 |\n| 41 | -21846 | 0 | 175 | 21845 |\n| 41+ | 21845 | 1 | 174 | -21846 |\n| 42 | 21845 | 1 | 174 | 21845 |\n| 42+ | -21846 | 1 | 175 | 21845 |\n| 43 | -21846 | 1 | 175 | -21846 |\n| 43+ | -21846 | 0 | 168 | 21845 |\n| 44 | -21846 | 0 | 168 | 21845 |\n| 44 | -21846 | 0 | 169 | 21845 |\n| 44 | -21846 | 0 | 170 | 21845 |\n| 44 | -21846 | 0 | 171 | 21845 |\n| 44 | -21846 | 0 | 172 | 21845 |\n| 44 | -21846 | 0 | 173 | 21845 |\n| 44 | -21846 | 0 | 174 | 21845 |\n| 44 | -21846 | 0 | 175 | -21846 |\n| 44+ | 21845 | 1 | 175 | -21846 |\n| 45 | 21845 | 1 | 175 | 21845 |\n| 45+ | 21845 | 0 | 168 | 21845 |\n| 46 | 21845 | 0 | 168 | 21845 |\n| 46 | 21845 | 0 | 169 | 21845 |\n| 46 | 21845 | 0 | 170 | 21845 |\n| 46 | 21845 | 0 | 171 | 21845 |\n| 46 | 21845 | 0 | 172 | 21845 |\n| 46 | 21845 | 0 | 173 | 21845 |\n| 46 | 21845 | 0 | 174 | 21845 |\n| 46 | 21845 | 0 | 175 | 21845 |\n| 46+ | 21845 | 0 | 42 | 0 |\n| 47 | 21845 | 0 | 42 | 0 |\n| 47 | 21845 | 0 | 106 | 0 |\n| 47 | 21845 | 0 | 170 | 21845 |\n| 47 | 21845 | 0 | 234 | 0 |\n| 47 | 21845 | 0 | 298 | 0 |\n| 47 | 21845 | 0 | 362 | 0 |\n| 47 | 21845 | 0 | 426 | 0 |\n| 47 | 21845 | 0 | 490 | 0 |\n| 47+ | 21845 | 1 | 42 | 0 |\n| 48 | 21845 | 1 | 42 | 21845 |\n| 48+ | 21845 | 1 | 106 | 0 |\n| 49 | 21845 | 1 | 106 | 21845 |\n| 49+ | 21845 | 1 | 170 | 21845 |\n| 50 | 21845 | 1 | 170 | 21845 |\n| 50+ | 21845 | 1 | 234 | 0 |\n| 51 | 21845 | 1 | 234 | 21845 |\n| 51+ | 21845 | 1 | 298 | 0 |\n| 52 | 21845 | 1 | 298 | 21845 |\n| 52+ | 21845 | 1 | 362 | 0 |\n| 53 | 21845 | 1 | 362 | 21845 |\n| 53+ | 21845 | 1 | 426 | 0 |\n| 54 | 21845 | 1 | 426 | 21845 |\n| 54+ | 21845 | 1 | 490 | 0 |\n| 55 | 21845 | 1 | 490 | 21845 |\n| 55+ | 21845 | 0 | 42 | 21845 |\n| 56 | 21845 | 0 | 42 | 21845 |\n| 56 | 21845 | 0 | 106 | 21845 |\n| 56 | 21845 | 0 | 170 | 21845 |\n| 56 | 21845 | 0 | 234 | 21845 |\n| 56 | 21845 | 0 | 298 | 21845 |\n| 56 | 21845 | 0 | 362 | 21845 |\n| 56 | 21845 | 0 | 426 | 21845 |\n| 56 | 21845 | 0 | 490 | 21845 |\n| 56+ | -21846 | 1 | 42 | 21845 |\n| 57 | -21846 | 1 | 42 | -21846 |\n| 57+ | -21846 | 0 | 42 | -21846 |\n| 58 | -21846 | 0 | 42 | -21846 |\n| 58 | -21846 | 0 | 106 | 21845 |\n| 58 | -21846 | 0 | 170 | 21845 |\n| 58 | -21846 | 0 | 234 | 21845 |\n| 58 | -21846 | 0 | 298 | 21845 |\n| 58 | -21846 | 0 | 362 | 21845 |\n| 58 | -21846 | 0 | 426 | 21845 |\n| 58 | -21846 | 0 | 490 | 21845 |\n| 58+ | 21845 | 1 | 42 | -21846 |\n| 59 | 21845 | 1 | 42 | 21845 |\n| 59+ | -21846 | 1 | 106 | 21845 |\n| 60 | -21846 | 1 | 106 | -21846 |\n| 60+ | -21846 | 0 | 42 | 21845 |\n| 61 | -21846 | 0 | 42 | 21845 |\n| 61 | -21846 | 0 | 106 | -21846 |\n| 61 | -21846 | 0 | 170 | 21845 |\n| 61 | -21846 | 0 | 234 | 21845 |\n| 61 | -21846 | 0 | 298 | 21845 |\n| 61 | -21846 | 0 | 362 | 21845 |\n| 61 | -21846 | 0 | 426 | 21845 |\n| 61 | -21846 | 0 | 490 | 21845 |\n| 61+ | 21845 | 1 | 106 | -21846 |\n| 62 | 21845 | 1 | 106 | 21845 |\n| 62+ | -21846 | 1 | 170 | 21845 |\n| 63 | -21846 | 1 | 170 | -21846 |\n| 63+ | -21846 | 0 | 42 | 21845 |\n| 64 | -21846 | 0 | 42 | 21845 |\n| 64 | -21846 | 0 | 106 | 21845 |\n| 64 | -21846 | 0 | 170 | -21846 |\n| 64 | -21846 | 0 | 234 | 21845 |\n| 64 | -21846 | 0 | 298 | 21845 |\n| 64 | -21846 | 0 | 362 | 21845 |\n| 64 | -21846 | 0 | 426 | 21845 |\n| 64 | -21846 | 0 | 490 | 21845 |\n| 64+ | 21845 | 1 | 170 | -21846 |\n| 65 | 21845 | 1 | 170 | 21845 |\n| 65+ | -21846 | 1 | 234 | 21845 |\n| 66 | -21846 | 1 | 234 | -21846 |\n| 66+ | -21846 | 0 | 42 | 21845 |\n| 67 | -21846 | 0 | 42 | 21845 |\n| 67 | -21846 | 0 | 106 | 21845 |\n| 67 | -21846 | 0 | 170 | 21845 |\n| 67 | -21846 | 0 | 234 | -21846 |\n| 67 | -21846 | 0 | 298 | 21845 |\n| 67 | -21846 | 0 | 362 | 21845 |\n| 67 | -21846 | 0 | 426 | 21845 |\n| 67 | -21846 | 0 | 490 | 21845 |\n| 67+ | 21845 | 1 | 234 | -21846 |\n| 68 | 21845 | 1 | 234 | 21845 |\n| 68+ | -21846 | 1 | 298 | 21845 |\n| 69 | -21846 | 1 | 298 | -21846 |\n| 69+ | -21846 | 0 | 42 | 21845 |\n| 70 | -21846 | 0 | 42 | 21845 |\n| 70 | -21846 | 0 | 106 | 21845 |\n| 70 | -21846 | 0 | 170 | 21845 |\n| 70 | -21846 | 0 | 234 | 21845 |\n| 70 | -21846 | 0 | 298 | -21846 |\n| 70 | -21846 | 0 | 362 | 21845 |\n| 70 | -21846 | 0 | 426 | 21845 |\n| 70 | -21846 | 0 | 490 | 21845 |\n| 70+ | 21845 | 1 | 298 | -21846 |\n| 71 | 21845 | 1 | 298 | 21845 |\n| 71+ | -21846 | 1 | 362 | 21845 |\n| 72 | -21846 | 1 | 362 | -21846 |\n| 72+ | -21846 | 0 | 42 | 21845 |\n| 73 | -21846 | 0 | 42 | 21845 |\n| 73 | -21846 | 0 | 106 | 21845 |\n| 73 | -21846 | 0 | 170 | 21845 |\n| 73 | -21846 | 0 | 234 | 21845 |\n| 73 | -21846 | 0 | 298 | 21845 |\n| 73 | -21846 | 0 | 362 | -21846 |\n| 73 | -21846 | 0 | 426 | 21845 |\n| 73 | -21846 | 0 | 490 | 21845 |\n| 73+ | 21845 | 1 | 362 | -21846 |\n| 74 | 21845 | 1 | 362 | 21845 |\n| 74+ | -21846 | 1 | 426 | 21845 |\n| 75 | -21846 | 1 | 426 | -21846 |\n| 75+ | -21846 | 0 | 42 | 21845 |\n| 76 | -21846 | 0 | 42 | 21845 |\n| 76 | -21846 | 0 | 106 | 21845 |\n| 76 | -21846 | 0 | 170 | 21845 |\n| 76 | -21846 | 0 | 234 | 21845 |\n| 76 | -21846 | 0 | 298 | 21845 |\n| 76 | -21846 | 0 | 362 | 21845 |\n| 76 | -21846 | 0 | 426 | -21846 |\n| 76 | -21846 | 0 | 490 | 21845 |\n| 76+ | 21845 | 1 | 426 | -21846 |\n| 77 | 21845 | 1 | 426 | 21845 |\n| 77+ | -21846 | 1 | 490 | 21845 |\n| 78 | -21846 | 1 | 490 | -21846 |\n| 78+ | -21846 | 0 | 42 | 21845 |\n| 79 | -21846 | 0 | 42 | 21845 |\n| 79 | -21846 | 0 | 106 | 21845 |\n| 79 | -21846 | 0 | 170 | 21845 |\n| 79 | -21846 | 0 | 234 | 21845 |\n| 79 | -21846 | 0 | 298 | 21845 |\n| 79 | -21846 | 0 | 362 | 21845 |\n| 79 | -21846 | 0 | 426 | 21845 |\n| 79 | -21846 | 0 | 490 | -21846 |\n| 79+ | 21845 | 1 | 490 | -21846 |\n| 80 | 21845 | 1 | 490 | 21845 |\n| 80+ | 21845 | 0 | 42 | 21845 |\n| 81 | 21845 | 0 | 42 | 21845 |\n| 81 | 21845 | 0 | 106 | 21845 |\n| 81 | 21845 | 0 | 170 | 21845 |\n| 81 | 21845 | 0 | 234 | 21845 |\n| 81 | 21845 | 0 | 298 | 21845 |\n| 81 | 21845 | 0 | 362 | 21845 |\n| 81 | 21845 | 0 | 426 | 21845 |\n| 81 | 21845 | 0 | 490 | 21845 |"},RAM4K:{"RAM4K.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM4K.hdl\n/**\n * Memory of 4K 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM4K {\n IN in[16], load, address[12];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM4K.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM4K.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.4.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 1111,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 1111,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 3513,\nset address 3513,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 1111,\neval,\noutput;\n\nset in 4095,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 4095,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 3513,\neval,\noutput;\n\nset address 4095,\neval,\noutput;\n\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B000101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B000101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B001101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B011101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B100101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B101101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B111101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;',"RAM4K.cmp":"|time | in |load|address | out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 1111 | 0 | 0 | 0 |\n| 3 | 1111 | 0 | 0 | 0 |\n| 3+ | 1111 | 1 | 1111 | 0 |\n| 4 | 1111 | 1 | 1111 | 1111 |\n| 4+ | 1111 | 0 | 0 | 0 |\n| 5 | 1111 | 0 | 0 | 0 |\n| 5+ | 3513 | 0 | 3513 | 0 |\n| 6 | 3513 | 0 | 3513 | 0 |\n| 6+ | 3513 | 1 | 3513 | 0 |\n| 7 | 3513 | 1 | 3513 | 3513 |\n| 7+ | 3513 | 0 | 3513 | 3513 |\n| 8 | 3513 | 0 | 3513 | 3513 |\n| 8 | 3513 | 0 | 1111 | 1111 |\n| 8+ | 4095 | 0 | 1111 | 1111 |\n| 9 | 4095 | 0 | 1111 | 1111 |\n| 9+ | 4095 | 1 | 4095 | 0 |\n| 10 | 4095 | 1 | 4095 | 4095 |\n| 10+ | 4095 | 0 | 4095 | 4095 |\n| 11 | 4095 | 0 | 4095 | 4095 |\n| 11 | 4095 | 0 | 3513 | 3513 |\n| 11 | 4095 | 0 | 4095 | 4095 |\n| 11+ | 4095 | 0 | 2728 | 0 |\n| 12 | 4095 | 0 | 2728 | 0 |\n| 12 | 4095 | 0 | 2729 | 0 |\n| 12 | 4095 | 0 | 2730 | 0 |\n| 12 | 4095 | 0 | 2731 | 0 |\n| 12 | 4095 | 0 | 2732 | 0 |\n| 12 | 4095 | 0 | 2733 | 0 |\n| 12 | 4095 | 0 | 2734 | 0 |\n| 12 | 4095 | 0 | 2735 | 0 |\n| 12+ | 21845 | 1 | 2728 | 0 |\n| 13 | 21845 | 1 | 2728 | 21845 |\n| 13+ | 21845 | 1 | 2729 | 0 |\n| 14 | 21845 | 1 | 2729 | 21845 |\n| 14+ | 21845 | 1 | 2730 | 0 |\n| 15 | 21845 | 1 | 2730 | 21845 |\n| 15+ | 21845 | 1 | 2731 | 0 |\n| 16 | 21845 | 1 | 2731 | 21845 |\n| 16+ | 21845 | 1 | 2732 | 0 |\n| 17 | 21845 | 1 | 2732 | 21845 |\n| 17+ | 21845 | 1 | 2733 | 0 |\n| 18 | 21845 | 1 | 2733 | 21845 |\n| 18+ | 21845 | 1 | 2734 | 0 |\n| 19 | 21845 | 1 | 2734 | 21845 |\n| 19+ | 21845 | 1 | 2735 | 0 |\n| 20 | 21845 | 1 | 2735 | 21845 |\n| 20+ | 21845 | 0 | 2728 | 21845 |\n| 21 | 21845 | 0 | 2728 | 21845 |\n| 21 | 21845 | 0 | 2729 | 21845 |\n| 21 | 21845 | 0 | 2730 | 21845 |\n| 21 | 21845 | 0 | 2731 | 21845 |\n| 21 | 21845 | 0 | 2732 | 21845 |\n| 21 | 21845 | 0 | 2733 | 21845 |\n| 21 | 21845 | 0 | 2734 | 21845 |\n| 21 | 21845 | 0 | 2735 | 21845 |\n| 21+ | -21846 | 1 | 2728 | 21845 |\n| 22 | -21846 | 1 | 2728 | -21846 |\n| 22+ | -21846 | 0 | 2728 | -21846 |\n| 23 | -21846 | 0 | 2728 | -21846 |\n| 23 | -21846 | 0 | 2729 | 21845 |\n| 23 | -21846 | 0 | 2730 | 21845 |\n| 23 | -21846 | 0 | 2731 | 21845 |\n| 23 | -21846 | 0 | 2732 | 21845 |\n| 23 | -21846 | 0 | 2733 | 21845 |\n| 23 | -21846 | 0 | 2734 | 21845 |\n| 23 | -21846 | 0 | 2735 | 21845 |\n| 23+ | 21845 | 1 | 2728 | -21846 |\n| 24 | 21845 | 1 | 2728 | 21845 |\n| 24+ | -21846 | 1 | 2729 | 21845 |\n| 25 | -21846 | 1 | 2729 | -21846 |\n| 25+ | -21846 | 0 | 2728 | 21845 |\n| 26 | -21846 | 0 | 2728 | 21845 |\n| 26 | -21846 | 0 | 2729 | -21846 |\n| 26 | -21846 | 0 | 2730 | 21845 |\n| 26 | -21846 | 0 | 2731 | 21845 |\n| 26 | -21846 | 0 | 2732 | 21845 |\n| 26 | -21846 | 0 | 2733 | 21845 |\n| 26 | -21846 | 0 | 2734 | 21845 |\n| 26 | -21846 | 0 | 2735 | 21845 |\n| 26+ | 21845 | 1 | 2729 | -21846 |\n| 27 | 21845 | 1 | 2729 | 21845 |\n| 27+ | -21846 | 1 | 2730 | 21845 |\n| 28 | -21846 | 1 | 2730 | -21846 |\n| 28+ | -21846 | 0 | 2728 | 21845 |\n| 29 | -21846 | 0 | 2728 | 21845 |\n| 29 | -21846 | 0 | 2729 | 21845 |\n| 29 | -21846 | 0 | 2730 | -21846 |\n| 29 | -21846 | 0 | 2731 | 21845 |\n| 29 | -21846 | 0 | 2732 | 21845 |\n| 29 | -21846 | 0 | 2733 | 21845 |\n| 29 | -21846 | 0 | 2734 | 21845 |\n| 29 | -21846 | 0 | 2735 | 21845 |\n| 29+ | 21845 | 1 | 2730 | -21846 |\n| 30 | 21845 | 1 | 2730 | 21845 |\n| 30+ | -21846 | 1 | 2731 | 21845 |\n| 31 | -21846 | 1 | 2731 | -21846 |\n| 31+ | -21846 | 0 | 2728 | 21845 |\n| 32 | -21846 | 0 | 2728 | 21845 |\n| 32 | -21846 | 0 | 2729 | 21845 |\n| 32 | -21846 | 0 | 2730 | 21845 |\n| 32 | -21846 | 0 | 2731 | -21846 |\n| 32 | -21846 | 0 | 2732 | 21845 |\n| 32 | -21846 | 0 | 2733 | 21845 |\n| 32 | -21846 | 0 | 2734 | 21845 |\n| 32 | -21846 | 0 | 2735 | 21845 |\n| 32+ | 21845 | 1 | 2731 | -21846 |\n| 33 | 21845 | 1 | 2731 | 21845 |\n| 33+ | -21846 | 1 | 2732 | 21845 |\n| 34 | -21846 | 1 | 2732 | -21846 |\n| 34+ | -21846 | 0 | 2728 | 21845 |\n| 35 | -21846 | 0 | 2728 | 21845 |\n| 35 | -21846 | 0 | 2729 | 21845 |\n| 35 | -21846 | 0 | 2730 | 21845 |\n| 35 | -21846 | 0 | 2731 | 21845 |\n| 35 | -21846 | 0 | 2732 | -21846 |\n| 35 | -21846 | 0 | 2733 | 21845 |\n| 35 | -21846 | 0 | 2734 | 21845 |\n| 35 | -21846 | 0 | 2735 | 21845 |\n| 35+ | 21845 | 1 | 2732 | -21846 |\n| 36 | 21845 | 1 | 2732 | 21845 |\n| 36+ | -21846 | 1 | 2733 | 21845 |\n| 37 | -21846 | 1 | 2733 | -21846 |\n| 37+ | -21846 | 0 | 2728 | 21845 |\n| 38 | -21846 | 0 | 2728 | 21845 |\n| 38 | -21846 | 0 | 2729 | 21845 |\n| 38 | -21846 | 0 | 2730 | 21845 |\n| 38 | -21846 | 0 | 2731 | 21845 |\n| 38 | -21846 | 0 | 2732 | 21845 |\n| 38 | -21846 | 0 | 2733 | -21846 |\n| 38 | -21846 | 0 | 2734 | 21845 |\n| 38 | -21846 | 0 | 2735 | 21845 |\n| 38+ | 21845 | 1 | 2733 | -21846 |\n| 39 | 21845 | 1 | 2733 | 21845 |\n| 39+ | -21846 | 1 | 2734 | 21845 |\n| 40 | -21846 | 1 | 2734 | -21846 |\n| 40+ | -21846 | 0 | 2728 | 21845 |\n| 41 | -21846 | 0 | 2728 | 21845 |\n| 41 | -21846 | 0 | 2729 | 21845 |\n| 41 | -21846 | 0 | 2730 | 21845 |\n| 41 | -21846 | 0 | 2731 | 21845 |\n| 41 | -21846 | 0 | 2732 | 21845 |\n| 41 | -21846 | 0 | 2733 | 21845 |\n| 41 | -21846 | 0 | 2734 | -21846 |\n| 41 | -21846 | 0 | 2735 | 21845 |\n| 41+ | 21845 | 1 | 2734 | -21846 |\n| 42 | 21845 | 1 | 2734 | 21845 |\n| 42+ | -21846 | 1 | 2735 | 21845 |\n| 43 | -21846 | 1 | 2735 | -21846 |\n| 43+ | -21846 | 0 | 2728 | 21845 |\n| 44 | -21846 | 0 | 2728 | 21845 |\n| 44 | -21846 | 0 | 2729 | 21845 |\n| 44 | -21846 | 0 | 2730 | 21845 |\n| 44 | -21846 | 0 | 2731 | 21845 |\n| 44 | -21846 | 0 | 2732 | 21845 |\n| 44 | -21846 | 0 | 2733 | 21845 |\n| 44 | -21846 | 0 | 2734 | 21845 |\n| 44 | -21846 | 0 | 2735 | -21846 |\n| 44+ | 21845 | 1 | 2735 | -21846 |\n| 45 | 21845 | 1 | 2735 | 21845 |\n| 45+ | 21845 | 0 | 2728 | 21845 |\n| 46 | 21845 | 0 | 2728 | 21845 |\n| 46 | 21845 | 0 | 2729 | 21845 |\n| 46 | 21845 | 0 | 2730 | 21845 |\n| 46 | 21845 | 0 | 2731 | 21845 |\n| 46 | 21845 | 0 | 2732 | 21845 |\n| 46 | 21845 | 0 | 2733 | 21845 |\n| 46 | 21845 | 0 | 2734 | 21845 |\n| 46 | 21845 | 0 | 2735 | 21845 |\n| 46+ | 21845 | 0 | 341 | 0 |\n| 47 | 21845 | 0 | 341 | 0 |\n| 47 | 21845 | 0 | 853 | 0 |\n| 47 | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 1877 | 0 |\n| 47 | 21845 | 0 | 2389 | 0 |\n| 47 | 21845 | 0 | 2901 | 0 |\n| 47 | 21845 | 0 | 3413 | 0 |\n| 47 | 21845 | 0 | 3925 | 0 |\n| 47+ | 21845 | 1 | 341 | 0 |\n| 48 | 21845 | 1 | 341 | 21845 |\n| 48+ | 21845 | 1 | 853 | 0 |\n| 49 | 21845 | 1 | 853 | 21845 |\n| 49+ | 21845 | 1 | 1365 | 0 |\n| 50 | 21845 | 1 | 1365 | 21845 |\n| 50+ | 21845 | 1 | 1877 | 0 |\n| 51 | 21845 | 1 | 1877 | 21845 |\n| 51+ | 21845 | 1 | 2389 | 0 |\n| 52 | 21845 | 1 | 2389 | 21845 |\n| 52+ | 21845 | 1 | 2901 | 0 |\n| 53 | 21845 | 1 | 2901 | 21845 |\n| 53+ | 21845 | 1 | 3413 | 0 |\n| 54 | 21845 | 1 | 3413 | 21845 |\n| 54+ | 21845 | 1 | 3925 | 0 |\n| 55 | 21845 | 1 | 3925 | 21845 |\n| 55+ | 21845 | 0 | 341 | 21845 |\n| 56 | 21845 | 0 | 341 | 21845 |\n| 56 | 21845 | 0 | 853 | 21845 |\n| 56 | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 1877 | 21845 |\n| 56 | 21845 | 0 | 2389 | 21845 |\n| 56 | 21845 | 0 | 2901 | 21845 |\n| 56 | 21845 | 0 | 3413 | 21845 |\n| 56 | 21845 | 0 | 3925 | 21845 |\n| 56+ | -21846 | 1 | 341 | 21845 |\n| 57 | -21846 | 1 | 341 | -21846 |\n| 57+ | -21846 | 0 | 341 | -21846 |\n| 58 | -21846 | 0 | 341 | -21846 |\n| 58 | -21846 | 0 | 853 | 21845 |\n| 58 | -21846 | 0 | 1365 | 21845 |\n| 58 | -21846 | 0 | 1877 | 21845 |\n| 58 | -21846 | 0 | 2389 | 21845 |\n| 58 | -21846 | 0 | 2901 | 21845 |\n| 58 | -21846 | 0 | 3413 | 21845 |\n| 58 | -21846 | 0 | 3925 | 21845 |\n| 58+ | 21845 | 1 | 341 | -21846 |\n| 59 | 21845 | 1 | 341 | 21845 |\n| 59+ | -21846 | 1 | 853 | 21845 |\n| 60 | -21846 | 1 | 853 | -21846 |\n| 60+ | -21846 | 0 | 341 | 21845 |\n| 61 | -21846 | 0 | 341 | 21845 |\n| 61 | -21846 | 0 | 853 | -21846 |\n| 61 | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 1877 | 21845 |\n| 61 | -21846 | 0 | 2389 | 21845 |\n| 61 | -21846 | 0 | 2901 | 21845 |\n| 61 | -21846 | 0 | 3413 | 21845 |\n| 61 | -21846 | 0 | 3925 | 21845 |\n| 61+ | 21845 | 1 | 853 | -21846 |\n| 62 | 21845 | 1 | 853 | 21845 |\n| 62+ | -21846 | 1 | 1365 | 21845 |\n| 63 | -21846 | 1 | 1365 | -21846 |\n| 63+ | -21846 | 0 | 341 | 21845 |\n| 64 | -21846 | 0 | 341 | 21845 |\n| 64 | -21846 | 0 | 853 | 21845 |\n| 64 | -21846 | 0 | 1365 | -21846 |\n| 64 | -21846 | 0 | 1877 | 21845 |\n| 64 | -21846 | 0 | 2389 | 21845 |\n| 64 | -21846 | 0 | 2901 | 21845 |\n| 64 | -21846 | 0 | 3413 | 21845 |\n| 64 | -21846 | 0 | 3925 | 21845 |\n| 64+ | 21845 | 1 | 1365 | -21846 |\n| 65 | 21845 | 1 | 1365 | 21845 |\n| 65+ | -21846 | 1 | 1877 | 21845 |\n| 66 | -21846 | 1 | 1877 | -21846 |\n| 66+ | -21846 | 0 | 341 | 21845 |\n| 67 | -21846 | 0 | 341 | 21845 |\n| 67 | -21846 | 0 | 853 | 21845 |\n| 67 | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 1877 | -21846 |\n| 67 | -21846 | 0 | 2389 | 21845 |\n| 67 | -21846 | 0 | 2901 | 21845 |\n| 67 | -21846 | 0 | 3413 | 21845 |\n| 67 | -21846 | 0 | 3925 | 21845 |\n| 67+ | 21845 | 1 | 1877 | -21846 |\n| 68 | 21845 | 1 | 1877 | 21845 |\n| 68+ | -21846 | 1 | 2389 | 21845 |\n| 69 | -21846 | 1 | 2389 | -21846 |\n| 69+ | -21846 | 0 | 341 | 21845 |\n| 70 | -21846 | 0 | 341 | 21845 |\n| 70 | -21846 | 0 | 853 | 21845 |\n| 70 | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 1877 | 21845 |\n| 70 | -21846 | 0 | 2389 | -21846 |\n| 70 | -21846 | 0 | 2901 | 21845 |\n| 70 | -21846 | 0 | 3413 | 21845 |\n| 70 | -21846 | 0 | 3925 | 21845 |\n| 70+ | 21845 | 1 | 2389 | -21846 |\n| 71 | 21845 | 1 | 2389 | 21845 |\n| 71+ | -21846 | 1 | 2901 | 21845 |\n| 72 | -21846 | 1 | 2901 | -21846 |\n| 72+ | -21846 | 0 | 341 | 21845 |\n| 73 | -21846 | 0 | 341 | 21845 |\n| 73 | -21846 | 0 | 853 | 21845 |\n| 73 | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 1877 | 21845 |\n| 73 | -21846 | 0 | 2389 | 21845 |\n| 73 | -21846 | 0 | 2901 | -21846 |\n| 73 | -21846 | 0 | 3413 | 21845 |\n| 73 | -21846 | 0 | 3925 | 21845 |\n| 73+ | 21845 | 1 | 2901 | -21846 |\n| 74 | 21845 | 1 | 2901 | 21845 |\n| 74+ | -21846 | 1 | 3413 | 21845 |\n| 75 | -21846 | 1 | 3413 | -21846 |\n| 75+ | -21846 | 0 | 341 | 21845 |\n| 76 | -21846 | 0 | 341 | 21845 |\n| 76 | -21846 | 0 | 853 | 21845 |\n| 76 | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 1877 | 21845 |\n| 76 | -21846 | 0 | 2389 | 21845 |\n| 76 | -21846 | 0 | 2901 | 21845 |\n| 76 | -21846 | 0 | 3413 | -21846 |\n| 76 | -21846 | 0 | 3925 | 21845 |\n| 76+ | 21845 | 1 | 3413 | -21846 |\n| 77 | 21845 | 1 | 3413 | 21845 |\n| 77+ | -21846 | 1 | 3925 | 21845 |\n| 78 | -21846 | 1 | 3925 | -21846 |\n| 78+ | -21846 | 0 | 341 | 21845 |\n| 79 | -21846 | 0 | 341 | 21845 |\n| 79 | -21846 | 0 | 853 | 21845 |\n| 79 | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 1877 | 21845 |\n| 79 | -21846 | 0 | 2389 | 21845 |\n| 79 | -21846 | 0 | 2901 | 21845 |\n| 79 | -21846 | 0 | 3413 | 21845 |\n| 79 | -21846 | 0 | 3925 | -21846 |\n| 79+ | 21845 | 1 | 3925 | -21846 |\n| 80 | 21845 | 1 | 3925 | 21845 |\n| 80+ | 21845 | 0 | 341 | 21845 |\n| 81 | 21845 | 0 | 341 | 21845 |\n| 81 | 21845 | 0 | 853 | 21845 |\n| 81 | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 1877 | 21845 |\n| 81 | 21845 | 0 | 2389 | 21845 |\n| 81 | 21845 | 0 | 2901 | 21845 |\n| 81 | 21845 | 0 | 3413 | 21845 |\n| 81 | 21845 | 0 | 3925 | 21845 |"},RAM16K:{"RAM16K.hdl":y,"RAM16K.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM16K.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.5.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 4321,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 4321,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 12345,\nset address 12345,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 4321,\neval,\noutput;\n\nset in 16383,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 16383,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 12345,\neval,\noutput;\n\nset address 16383,\neval,\noutput;\n\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11110101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B00110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B01010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B01110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B10010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B10110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B11010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B11110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;',"RAM16K.cmp":"|time | in |load| address | out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 4321 | 0 | 0 | 0 |\n| 3 | 4321 | 0 | 0 | 0 |\n| 3+ | 4321 | 1 | 4321 | 0 |\n| 4 | 4321 | 1 | 4321 | 4321 |\n| 4+ | 4321 | 0 | 0 | 0 |\n| 5 | 4321 | 0 | 0 | 0 |\n| 5+ | 12345 | 0 | 12345 | 0 |\n| 6 | 12345 | 0 | 12345 | 0 |\n| 6+ | 12345 | 1 | 12345 | 0 |\n| 7 | 12345 | 1 | 12345 | 12345 |\n| 7+ | 12345 | 0 | 12345 | 12345 |\n| 8 | 12345 | 0 | 12345 | 12345 |\n| 8 | 12345 | 0 | 4321 | 4321 |\n| 8+ | 16383 | 0 | 4321 | 4321 |\n| 9 | 16383 | 0 | 4321 | 4321 |\n| 9+ | 16383 | 1 | 16383 | 0 |\n| 10 | 16383 | 1 | 16383 | 16383 |\n| 10+ | 16383 | 0 | 16383 | 16383 |\n| 11 | 16383 | 0 | 16383 | 16383 |\n| 11 | 16383 | 0 | 12345 | 12345 |\n| 11 | 16383 | 0 | 16383 | 16383 |\n| 11+ | 16383 | 0 | 10920 | 0 |\n| 12 | 16383 | 0 | 10920 | 0 |\n| 12 | 16383 | 0 | 10921 | 0 |\n| 12 | 16383 | 0 | 10922 | 0 |\n| 12 | 16383 | 0 | 10923 | 0 |\n| 12 | 16383 | 0 | 10924 | 0 |\n| 12 | 16383 | 0 | 10925 | 0 |\n| 12 | 16383 | 0 | 10926 | 0 |\n| 12 | 16383 | 0 | 10927 | 0 |\n| 12+ | 21845 | 1 | 10920 | 0 |\n| 13 | 21845 | 1 | 10920 | 21845 |\n| 13+ | 21845 | 1 | 10921 | 0 |\n| 14 | 21845 | 1 | 10921 | 21845 |\n| 14+ | 21845 | 1 | 10922 | 0 |\n| 15 | 21845 | 1 | 10922 | 21845 |\n| 15+ | 21845 | 1 | 10923 | 0 |\n| 16 | 21845 | 1 | 10923 | 21845 |\n| 16+ | 21845 | 1 | 10924 | 0 |\n| 17 | 21845 | 1 | 10924 | 21845 |\n| 17+ | 21845 | 1 | 10925 | 0 |\n| 18 | 21845 | 1 | 10925 | 21845 |\n| 18+ | 21845 | 1 | 10926 | 0 |\n| 19 | 21845 | 1 | 10926 | 21845 |\n| 19+ | 21845 | 1 | 10927 | 0 |\n| 20 | 21845 | 1 | 10927 | 21845 |\n| 20+ | 21845 | 0 | 10920 | 21845 |\n| 21 | 21845 | 0 | 10920 | 21845 |\n| 21 | 21845 | 0 | 10921 | 21845 |\n| 21 | 21845 | 0 | 10922 | 21845 |\n| 21 | 21845 | 0 | 10923 | 21845 |\n| 21 | 21845 | 0 | 10924 | 21845 |\n| 21 | 21845 | 0 | 10925 | 21845 |\n| 21 | 21845 | 0 | 10926 | 21845 |\n| 21 | 21845 | 0 | 10927 | 21845 |\n| 21+ | -21846 | 1 | 10920 | 21845 |\n| 22 | -21846 | 1 | 10920 | -21846 |\n| 22+ | -21846 | 0 | 10920 | -21846 |\n| 23 | -21846 | 0 | 10920 | -21846 |\n| 23 | -21846 | 0 | 10921 | 21845 |\n| 23 | -21846 | 0 | 10922 | 21845 |\n| 23 | -21846 | 0 | 10923 | 21845 |\n| 23 | -21846 | 0 | 10924 | 21845 |\n| 23 | -21846 | 0 | 10925 | 21845 |\n| 23 | -21846 | 0 | 10926 | 21845 |\n| 23 | -21846 | 0 | 10927 | 21845 |\n| 23+ | 21845 | 1 | 10920 | -21846 |\n| 24 | 21845 | 1 | 10920 | 21845 |\n| 24+ | -21846 | 1 | 10921 | 21845 |\n| 25 | -21846 | 1 | 10921 | -21846 |\n| 25+ | -21846 | 0 | 10920 | 21845 |\n| 26 | -21846 | 0 | 10920 | 21845 |\n| 26 | -21846 | 0 | 10921 | -21846 |\n| 26 | -21846 | 0 | 10922 | 21845 |\n| 26 | -21846 | 0 | 10923 | 21845 |\n| 26 | -21846 | 0 | 10924 | 21845 |\n| 26 | -21846 | 0 | 10925 | 21845 |\n| 26 | -21846 | 0 | 10926 | 21845 |\n| 26 | -21846 | 0 | 10927 | 21845 |\n| 26+ | 21845 | 1 | 10921 | -21846 |\n| 27 | 21845 | 1 | 10921 | 21845 |\n| 27+ | -21846 | 1 | 10922 | 21845 |\n| 28 | -21846 | 1 | 10922 | -21846 |\n| 28+ | -21846 | 0 | 10920 | 21845 |\n| 29 | -21846 | 0 | 10920 | 21845 |\n| 29 | -21846 | 0 | 10921 | 21845 |\n| 29 | -21846 | 0 | 10922 | -21846 |\n| 29 | -21846 | 0 | 10923 | 21845 |\n| 29 | -21846 | 0 | 10924 | 21845 |\n| 29 | -21846 | 0 | 10925 | 21845 |\n| 29 | -21846 | 0 | 10926 | 21845 |\n| 29 | -21846 | 0 | 10927 | 21845 |\n| 29+ | 21845 | 1 | 10922 | -21846 |\n| 30 | 21845 | 1 | 10922 | 21845 |\n| 30+ | -21846 | 1 | 10923 | 21845 |\n| 31 | -21846 | 1 | 10923 | -21846 |\n| 31+ | -21846 | 0 | 10920 | 21845 |\n| 32 | -21846 | 0 | 10920 | 21845 |\n| 32 | -21846 | 0 | 10921 | 21845 |\n| 32 | -21846 | 0 | 10922 | 21845 |\n| 32 | -21846 | 0 | 10923 | -21846 |\n| 32 | -21846 | 0 | 10924 | 21845 |\n| 32 | -21846 | 0 | 10925 | 21845 |\n| 32 | -21846 | 0 | 10926 | 21845 |\n| 32 | -21846 | 0 | 10927 | 21845 |\n| 32+ | 21845 | 1 | 10923 | -21846 |\n| 33 | 21845 | 1 | 10923 | 21845 |\n| 33+ | -21846 | 1 | 10924 | 21845 |\n| 34 | -21846 | 1 | 10924 | -21846 |\n| 34+ | -21846 | 0 | 10920 | 21845 |\n| 35 | -21846 | 0 | 10920 | 21845 |\n| 35 | -21846 | 0 | 10921 | 21845 |\n| 35 | -21846 | 0 | 10922 | 21845 |\n| 35 | -21846 | 0 | 10923 | 21845 |\n| 35 | -21846 | 0 | 10924 | -21846 |\n| 35 | -21846 | 0 | 10925 | 21845 |\n| 35 | -21846 | 0 | 10926 | 21845 |\n| 35 | -21846 | 0 | 10927 | 21845 |\n| 35+ | 21845 | 1 | 10924 | -21846 |\n| 36 | 21845 | 1 | 10924 | 21845 |\n| 36+ | -21846 | 1 | 10925 | 21845 |\n| 37 | -21846 | 1 | 10925 | -21846 |\n| 37+ | -21846 | 0 | 10920 | 21845 |\n| 38 | -21846 | 0 | 10920 | 21845 |\n| 38 | -21846 | 0 | 10921 | 21845 |\n| 38 | -21846 | 0 | 10922 | 21845 |\n| 38 | -21846 | 0 | 10923 | 21845 |\n| 38 | -21846 | 0 | 10924 | 21845 |\n| 38 | -21846 | 0 | 10925 | -21846 |\n| 38 | -21846 | 0 | 10926 | 21845 |\n| 38 | -21846 | 0 | 10927 | 21845 |\n| 38+ | 21845 | 1 | 10925 | -21846 |\n| 39 | 21845 | 1 | 10925 | 21845 |\n| 39+ | -21846 | 1 | 10926 | 21845 |\n| 40 | -21846 | 1 | 10926 | -21846 |\n| 40+ | -21846 | 0 | 10920 | 21845 |\n| 41 | -21846 | 0 | 10920 | 21845 |\n| 41 | -21846 | 0 | 10921 | 21845 |\n| 41 | -21846 | 0 | 10922 | 21845 |\n| 41 | -21846 | 0 | 10923 | 21845 |\n| 41 | -21846 | 0 | 10924 | 21845 |\n| 41 | -21846 | 0 | 10925 | 21845 |\n| 41 | -21846 | 0 | 10926 | -21846 |\n| 41 | -21846 | 0 | 10927 | 21845 |\n| 41+ | 21845 | 1 | 10926 | -21846 |\n| 42 | 21845 | 1 | 10926 | 21845 |\n| 42+ | -21846 | 1 | 10927 | 21845 |\n| 43 | -21846 | 1 | 10927 | -21846 |\n| 43+ | -21846 | 0 | 10920 | 21845 |\n| 44 | -21846 | 0 | 10920 | 21845 |\n| 44 | -21846 | 0 | 10921 | 21845 |\n| 44 | -21846 | 0 | 10922 | 21845 |\n| 44 | -21846 | 0 | 10923 | 21845 |\n| 44 | -21846 | 0 | 10924 | 21845 |\n| 44 | -21846 | 0 | 10925 | 21845 |\n| 44 | -21846 | 0 | 10926 | 21845 |\n| 44 | -21846 | 0 | 10927 | -21846 |\n| 44+ | 21845 | 1 | 10927 | -21846 |\n| 45 | 21845 | 1 | 10927 | 21845 |\n| 45+ | 21845 | 0 | 10920 | 21845 |\n| 46 | 21845 | 0 | 10920 | 21845 |\n| 46 | 21845 | 0 | 10921 | 21845 |\n| 46 | 21845 | 0 | 10922 | 21845 |\n| 46 | 21845 | 0 | 10923 | 21845 |\n| 46 | 21845 | 0 | 10924 | 21845 |\n| 46 | 21845 | 0 | 10925 | 21845 |\n| 46 | 21845 | 0 | 10926 | 21845 |\n| 46 | 21845 | 0 | 10927 | 21845 |\n| 46+ | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 3413 | 0 |\n| 47 | 21845 | 0 | 5461 | 0 |\n| 47 | 21845 | 0 | 7509 | 0 |\n| 47 | 21845 | 0 | 9557 | 0 |\n| 47 | 21845 | 0 | 11605 | 0 |\n| 47 | 21845 | 0 | 13653 | 0 |\n| 47 | 21845 | 0 | 15701 | 0 |\n| 47+ | 21845 | 1 | 1365 | 0 |\n| 48 | 21845 | 1 | 1365 | 21845 |\n| 48+ | 21845 | 1 | 3413 | 0 |\n| 49 | 21845 | 1 | 3413 | 21845 |\n| 49+ | 21845 | 1 | 5461 | 0 |\n| 50 | 21845 | 1 | 5461 | 21845 |\n| 50+ | 21845 | 1 | 7509 | 0 |\n| 51 | 21845 | 1 | 7509 | 21845 |\n| 51+ | 21845 | 1 | 9557 | 0 |\n| 52 | 21845 | 1 | 9557 | 21845 |\n| 52+ | 21845 | 1 | 11605 | 0 |\n| 53 | 21845 | 1 | 11605 | 21845 |\n| 53+ | 21845 | 1 | 13653 | 0 |\n| 54 | 21845 | 1 | 13653 | 21845 |\n| 54+ | 21845 | 1 | 15701 | 0 |\n| 55 | 21845 | 1 | 15701 | 21845 |\n| 55+ | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 3413 | 21845 |\n| 56 | 21845 | 0 | 5461 | 21845 |\n| 56 | 21845 | 0 | 7509 | 21845 |\n| 56 | 21845 | 0 | 9557 | 21845 |\n| 56 | 21845 | 0 | 11605 | 21845 |\n| 56 | 21845 | 0 | 13653 | 21845 |\n| 56 | 21845 | 0 | 15701 | 21845 |\n| 56+ | -21846 | 1 | 1365 | 21845 |\n| 57 | -21846 | 1 | 1365 | -21846 |\n| 57+ | -21846 | 0 | 1365 | -21846 |\n| 58 | -21846 | 0 | 1365 | -21846 |\n| 58 | -21846 | 0 | 3413 | 21845 |\n| 58 | -21846 | 0 | 5461 | 21845 |\n| 58 | -21846 | 0 | 7509 | 21845 |\n| 58 | -21846 | 0 | 9557 | 21845 |\n| 58 | -21846 | 0 | 11605 | 21845 |\n| 58 | -21846 | 0 | 13653 | 21845 |\n| 58 | -21846 | 0 | 15701 | 21845 |\n| 58+ | 21845 | 1 | 1365 | -21846 |\n| 59 | 21845 | 1 | 1365 | 21845 |\n| 59+ | -21846 | 1 | 3413 | 21845 |\n| 60 | -21846 | 1 | 3413 | -21846 |\n| 60+ | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 3413 | -21846 |\n| 61 | -21846 | 0 | 5461 | 21845 |\n| 61 | -21846 | 0 | 7509 | 21845 |\n| 61 | -21846 | 0 | 9557 | 21845 |\n| 61 | -21846 | 0 | 11605 | 21845 |\n| 61 | -21846 | 0 | 13653 | 21845 |\n| 61 | -21846 | 0 | 15701 | 21845 |\n| 61+ | 21845 | 1 | 3413 | -21846 |\n| 62 | 21845 | 1 | 3413 | 21845 |\n| 62+ | -21846 | 1 | 5461 | 21845 |\n| 63 | -21846 | 1 | 5461 | -21846 |\n| 63+ | -21846 | 0 | 1365 | 21845 |\n| 64 | -21846 | 0 | 1365 | 21845 |\n| 64 | -21846 | 0 | 3413 | 21845 |\n| 64 | -21846 | 0 | 5461 | -21846 |\n| 64 | -21846 | 0 | 7509 | 21845 |\n| 64 | -21846 | 0 | 9557 | 21845 |\n| 64 | -21846 | 0 | 11605 | 21845 |\n| 64 | -21846 | 0 | 13653 | 21845 |\n| 64 | -21846 | 0 | 15701 | 21845 |\n| 64+ | 21845 | 1 | 5461 | -21846 |\n| 65 | 21845 | 1 | 5461 | 21845 |\n| 65+ | -21846 | 1 | 7509 | 21845 |\n| 66 | -21846 | 1 | 7509 | -21846 |\n| 66+ | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 3413 | 21845 |\n| 67 | -21846 | 0 | 5461 | 21845 |\n| 67 | -21846 | 0 | 7509 | -21846 |\n| 67 | -21846 | 0 | 9557 | 21845 |\n| 67 | -21846 | 0 | 11605 | 21845 |\n| 67 | -21846 | 0 | 13653 | 21845 |\n| 67 | -21846 | 0 | 15701 | 21845 |\n| 67+ | 21845 | 1 | 7509 | -21846 |\n| 68 | 21845 | 1 | 7509 | 21845 |\n| 68+ | -21846 | 1 | 9557 | 21845 |\n| 69 | -21846 | 1 | 9557 | -21846 |\n| 69+ | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 3413 | 21845 |\n| 70 | -21846 | 0 | 5461 | 21845 |\n| 70 | -21846 | 0 | 7509 | 21845 |\n| 70 | -21846 | 0 | 9557 | -21846 |\n| 70 | -21846 | 0 | 11605 | 21845 |\n| 70 | -21846 | 0 | 13653 | 21845 |\n| 70 | -21846 | 0 | 15701 | 21845 |\n| 70+ | 21845 | 1 | 9557 | -21846 |\n| 71 | 21845 | 1 | 9557 | 21845 |\n| 71+ | -21846 | 1 | 11605 | 21845 |\n| 72 | -21846 | 1 | 11605 | -21846 |\n| 72+ | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 3413 | 21845 |\n| 73 | -21846 | 0 | 5461 | 21845 |\n| 73 | -21846 | 0 | 7509 | 21845 |\n| 73 | -21846 | 0 | 9557 | 21845 |\n| 73 | -21846 | 0 | 11605 | -21846 |\n| 73 | -21846 | 0 | 13653 | 21845 |\n| 73 | -21846 | 0 | 15701 | 21845 |\n| 73+ | 21845 | 1 | 11605 | -21846 |\n| 74 | 21845 | 1 | 11605 | 21845 |\n| 74+ | -21846 | 1 | 13653 | 21845 |\n| 75 | -21846 | 1 | 13653 | -21846 |\n| 75+ | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 3413 | 21845 |\n| 76 | -21846 | 0 | 5461 | 21845 |\n| 76 | -21846 | 0 | 7509 | 21845 |\n| 76 | -21846 | 0 | 9557 | 21845 |\n| 76 | -21846 | 0 | 11605 | 21845 |\n| 76 | -21846 | 0 | 13653 | -21846 |\n| 76 | -21846 | 0 | 15701 | 21845 |\n| 76+ | 21845 | 1 | 13653 | -21846 |\n| 77 | 21845 | 1 | 13653 | 21845 |\n| 77+ | -21846 | 1 | 15701 | 21845 |\n| 78 | -21846 | 1 | 15701 | -21846 |\n| 78+ | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 3413 | 21845 |\n| 79 | -21846 | 0 | 5461 | 21845 |\n| 79 | -21846 | 0 | 7509 | 21845 |\n| 79 | -21846 | 0 | 9557 | 21845 |\n| 79 | -21846 | 0 | 11605 | 21845 |\n| 79 | -21846 | 0 | 13653 | 21845 |\n| 79 | -21846 | 0 | 15701 | -21846 |\n| 79+ | 21845 | 1 | 15701 | -21846 |\n| 80 | 21845 | 1 | 15701 | 21845 |\n| 80+ | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 3413 | 21845 |\n| 81 | 21845 | 0 | 5461 | 21845 |\n| 81 | 21845 | 0 | 7509 | 21845 |\n| 81 | 21845 | 0 | 9557 | 21845 |\n| 81 | 21845 | 0 | 11605 | 21845 |\n| 81 | 21845 | 0 | 13653 | 21845 |\n| 81 | 21845 | 0 | 15701 | 21845 |"}},A={DFF:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/03/DFF.hdl\n/**\n * Data Flip-flop:\n * maintains its current value:\n * out(t+1) = in(t)\n */\nCHIP DFF {\n IN in;\n OUT out;\n\n PARTS:\n BUILTIN DFF;\n CLOCKED in;\n}'};async function b(n){await n.pushd("/projects/03"),await(0,r.cL)(n,R),await n.popd()}async function T(n){await n.pushd("/projects/03"),await c(n,R,".tst"),await c(n,R,".cmp"),await n.popd()}const g={Mult:{"Mult.asm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/Mult.asm\n\n// Multiplies R0 and R1 and stores the result in R2.\n// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)\n// The algorithm is based on repetitive addition.\n\n//// Replace this comment with your code.',"Mult.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/mult/Mult.tst\n\n// Tests the Mult program, designed to compute R2 = R0 * R1.\n// Tests the program by having it multiply several sets of\n// R0 and R1 values.\n\noutput-list RAM[0]%D2.6.2 RAM[1]%D2.6.2 RAM[2]%D2.6.2;\n\nset RAM[0] 0, // Sets R0 and R1 to some input values\nset RAM[1] 0,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 20 {\n ticktock;\n}\nset RAM[0] 0, // Restores R0 and R1 in case the program changed them\nset RAM[1] 0,\noutput;\n\nset PC 0,\nset RAM[0] 1, // Sets R0 and R1 to some input values\nset RAM[1] 0,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 50 {\n ticktock;\n}\nset RAM[0] 1, // Restores R0 and R1 in case the program changed them\nset RAM[1] 0,\noutput;\n\nset PC 0,\nset RAM[0] 0, // Sets R0 and R1 to some input values\nset RAM[1] 2,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 80 {\n ticktock;\n}\nset RAM[0] 0, // Restores R0 and R1 in case the program changed them\nset RAM[1] 2,\noutput;\n\nset PC 0,\nset RAM[0] 3, // Sets R0 and R1 to some input values\nset RAM[1] 1,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 120 {\n ticktock;\n}\nset RAM[0] 3, // Restores R0 and R1 in case the program changed them\nset RAM[1] 1,\noutput;\n\nset PC 0,\nset RAM[0] 2, // Sets R0 and R1 to some input values\nset RAM[1] 4,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 150 {\n ticktock;\n}\nset RAM[0] 2, // Restores R0 and R1 in case the program changed them\nset RAM[1] 4,\noutput;\n\nset PC 0,\nset RAM[0] 6, // Sets R0 and R1 to some input values\nset RAM[1] 7,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 210 {\n ticktock;\n}\nset RAM[0] 6, // Restores R0 and R1 in case the program changed them\nset RAM[1] 7,\noutput;',"Mult.cmp":"| RAM[0] | RAM[1] | RAM[2] |\n| 0 | 0 | 0 |\n| 1 | 0 | 0 |\n| 0 | 2 | 0 |\n| 3 | 1 | 3 |\n| 2 | 4 | 8 |\n| 6 | 7 | 42 |"},Fill:{"Fill.asm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/Fill.asm\n\n// Runs an infinite loop that listens to the keyboard input. \n// When a key is pressed (any key), the program blackens the screen,\n// i.e. writes "black" in every pixel. When no key is pressed, \n// the screen should be cleared.\n\n//// Replace this comment with your code.',"Fill.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/fill/Fill.tst\n\n// Tests the Fill.hack program in the CPU emulator.\n\necho "Select the highest speed and \'enable keyboard\'. Then press any key for some time, and inspect the screen.";\n\nrepeat {\n ticktock;\n}',"FillAutomatic.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/fill/FillAutomatic\n\n// This script can be used to test the Fill program automatically, \n// rather than interactively. Specifically, the script sets the keyboard\n// memory map (RAM[24576]) to 0, 1, and then again to 0. This simulates the \n// acts of leaving the keyboard untouched, pressing some key, and then releasing\n// the key. After each one of these simulated events, the script outputs the values\n// of some selected registers from the screen memory map (RAM[16384]-RAM[24576]).\n// This is done in order to test that these registers are set to 000...0 or 111....1, \n// as mandated by how the Fill program should react to the keyboard events.\n\noutput-list RAM[16384]%D2.6.2 RAM[17648]%D2.6.2 RAM[18349]%D2.6.2 RAM[19444]%D2.6.2 RAM[20771]%D2.6.2 RAM[21031]%D2.6.2 RAM[22596]%D2.6.2 RAM[23754]%D2.6.2 RAM[24575]%D2.6.2;\n\nset RAM[24576] 0, // the keyboard is untouched\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is white\n\nset RAM[24576] 1, // a keyboard key is pressed\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is black\n\nset RAM[24576] 0, // the keyboard is untouched\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is white',"FillAutomatic.cmp":"|RAM[16384]|RAM[17648]|RAM[18349]|RAM[19444]|RAM[20771]|RAM[21031]|RAM[22596]|RAM[23754]|RAM[24575]|\n| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 |\n| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |"}};async function w(n){await n.pushd("/projects/04"),await(0,r.cL)(n,g),await n.popd()}async function S(n){await n.pushd("/projects/04"),await c(n,g,".tst"),await c(n,g,".cmp"),await n.popd()}const C="\n0000000000000010\n1110110000010000\n0000000000000011\n1110000010010000\n0000000000000000\n1110001100001000\n",x="0000000000000000\n1111110000010000\n0000000000000001\n1111010011010000\n0000000000001010\n1110001100000001\n0000000000000001\n1111110000010000\n0000000000001100\n1110101010000111\n0000000000000000\n1111110000010000\n0000000000000010\n1110001100001000\n0000000000001110\n1110101010000111",D="\n0000000000000000\n1111110000010000\n0000000000010111\n1110001100000110\n0000000000010000\n1110001100001000\n0100000000000000\n1110110000010000\n0000000000010001\n1110001100001000\n0000000000010001\n1111110000100000\n1110111010001000\n0000000000010001\n1111110000010000\n0000000000100000\n1110000010010000\n0000000000010001\n1110001100001000\n0000000000010000\n1111110010011000\n0000000000001010\n1110001100000001\n0000000000010111\n1110101010000111",P={Memory:{"Memory.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/Memory.hdl\n/**\n * The complete address space of the Hack computer\'s memory,\n * including RAM and memory-mapped I/O. \n * The chip facilitates read and write operations, as follows:\n * Read: out(t) = Memory[address(t)](t)\n * Write: if load(t-1) then Memory[address(t-1)](t) = in(t-1)\n * In words: the chip always outputs the value stored at the memory \n * location specified by address. If load=1, the in value is loaded \n * into the memory location specified by address. This value becomes \n * available through the out output from the next time step onward.\n * Address space rules:\n * Only the upper 16K+8K+1 words of the Memory chip are used. \n * Access to address>0x6000 is invalid and reads 0. Access to any address\n * in the range 0x4000-0x5FFF results in accessing the screen memory \n * map. Access to address 0x6000 results in accessing the keyboard \n * memory map. The behavior in these addresses is described in the Screen\n * and Keyboard chip specifications given in the lectures and the book.\n */\nCHIP Memory {\n IN in[16], load, address[15];\n OUT out[16];\n\n PARTS:\n\t//// Replace this comment with your code.\n}',"Memory.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Memory.tst\n\n// Tests the Memory chip by inputting values to selected addresses, \n// verifying that these addresses were indeed written to, and verifying \n// that other addresses were not accessed by mistake. In particular, we \n// focus on probing the registers in addresses 'lower RAM', 'upper RAM',\n// and 'Screen', which correspond to 0, %X2000, and %X4000 in Hexadecimal \n// (0, 8192 (8K), and 16385 (16K+1) in decimal).\n\noutput-list in%D1.6.1 load%B2.1.2 address%B1.15.1 out%D1.6.1;\n\necho \"Before you run this script, select the 'Screen' option from the 'View' menu\";\n\n// We've noticed a common design mistake in several students' Memory.hdl files.\n// This error leads to zeros being written in the offset of inactive memory segments\n// instead of the intended location. To identify this issue, the test should check not\n// only for incorrect writes into the wrong segment but also for any unexpected changes.\n// To prepare for this, we've initialized the memory with a specific number in the areas\n// where these erroneous writes might happen.\n\n//// Sets RAM[2000], RAM[4000] = 12345 (for the following overwrite test)\nset in 12345, set load 1, set address %X2000, tick, output; tock, output;\nset address %X4000, tick, output; tock, output;\n\nset in -1,\t\t\t\t// Sets RAM[0] = -1\nset load 1,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 9999,\t\t\t// RAM[0] holds value\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address %X2000,\t\t// Did not also write to upper RAM or Screen\neval,\noutput;\nset address %X4000,\neval,\noutput;\n\n//// Sets RAM[0], RAM[4000] = 12345 (for following overwrite test)\nset in 12345, set load 1, set address %X0000, tick, output; tock, output;\nset address %X4000, tick, output; tock, output;\n\nset in 2222,\t\t\t// Sets RAM[2000] = 2222\nset load 1,\nset address %X2000,\ntick,\noutput;\ntock,\noutput;\n\nset in 9999,\t\t\t// RAM[2000] holds value\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 0,\t\t\t// Did not also write to lower RAM or Screen\neval,\noutput;\nset address %X4000,\neval,\noutput;\n\nset load 0,\t\t\t\t// Low order address bits connected\nset address %X0001, eval, output;\nset address %X0002, eval, output;\nset address %X0004, eval, output;\nset address %X0008, eval, output;\nset address %X0010, eval, output;\nset address %X0020, eval, output;\nset address %X0040, eval, output;\nset address %X0080, eval, output;\nset address %X0100, eval, output;\nset address %X0200, eval, output;\nset address %X0400, eval, output;\nset address %X0800, eval, output;\nset address %X1000, eval, output;\nset address %X2000, eval, output;\n\nset address %X1234,\t\t// RAM[1234] = 1234\nset in 1234,\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %X2234,\t\t// Did not also write to upper RAM or Screen \neval, output;\nset address %X6234,\neval, output;\n\nset address %X2345,\t\t// RAM[2345] = 2345\nset in 2345,\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %X0345,\t\t// Did not also write to lower RAM or Screen \neval, output;\nset address %X4345,\neval, output;\n\n//// Clears the overwrite detection value from the screen\nset in 0, set load 1, set address %X4000, tick, output; tock, output;\n\n// Keyboard test\n\nset address 24576,\necho \"Click the Keyboard icon and hold down the 'K' key (uppercase) until you see the next message...\",\n// It's important to keep holding the key down since if the system is busy,\n// the memory will zero itself before being outputted.\n\nwhile out <> 75 {\n tick, tock; // tick, tock prevents hang if sync. parts used in KB path.\n}\n\nclear-echo,\noutput;\n\n// Screen test\n\n//// Sets RAM[0FCF], RAM[2FCF] = 12345 (for following overwrite test)\nset in 12345, set load 1, set address %X0FCF, tick, output; tock, output;\nset address %X2FCF, tick, output; tock, output;\n\nset load 1,\nset in -1,\nset address %X4FCF,\ntick,\ntock,\noutput,\n\nset address %X504F,\ntick,\ntock,\noutput;\n\nset address %X0FCF,\t\t// Did not also write to lower or upper RAM\neval,\noutput;\nset address %X2FCF,\neval,\noutput;\n\nset load 0,\t\t\t\t// Low order address bits connected\nset address %X4FCE, eval, output;\nset address %X4FCD, eval, output;\nset address %X4FCB, eval, output;\nset address %X4FC7, eval, output;\nset address %X4FDF, eval, output;\nset address %X4FEF, eval, output;\nset address %X4F8F, eval, output;\nset address %X4F4F, eval, output;\nset address %X4ECF, eval, output;\nset address %X4DCF, eval, output;\nset address %X4BCF, eval, output;\nset address %X47CF, eval, output;\nset address %X5FCF, eval, output;\n\nset load 0,\nset address 24576,\necho \"Two horizontal lines should be in the middle of the screen. Hold down 'Y' (uppercase) until you see the next message ...\",\n// It's important to keep holding the key down since if the system is busy,\n// the memory will zero itself before being outputted.\n\nwhile out <> 89 {\n tick, tock; // tick, tock prevents hang if sync. parts used in KB path.\n}\n\nclear-echo,\noutput;","Memory.cmp":"| in |load | address | out |\n| 12345 | 1 | 010000000000000 | 0 |\n| 12345 | 1 | 010000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 0 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| -1 | 1 | 000000000000000 | 0 |\n| -1 | 1 | 000000000000000 | -1 |\n| 9999 | 0 | 000000000000000 | -1 |\n| 9999 | 0 | 000000000000000 | -1 |\n| 9999 | 0 | 010000000000000 | 12345 |\n| 9999 | 0 | 100000000000000 | 12345 |\n| 12345 | 1 | 000000000000000 | -1 |\n| 12345 | 1 | 000000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| 2222 | 1 | 010000000000000 | 12345 |\n| 2222 | 1 | 010000000000000 | 2222 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 9999 | 0 | 000000000000000 | 12345 |\n| 9999 | 0 | 100000000000000 | 12345 |\n| 9999 | 0 | 000000000000001 | 0 |\n| 9999 | 0 | 000000000000010 | 0 |\n| 9999 | 0 | 000000000000100 | 0 |\n| 9999 | 0 | 000000000001000 | 0 |\n| 9999 | 0 | 000000000010000 | 0 |\n| 9999 | 0 | 000000000100000 | 0 |\n| 9999 | 0 | 000000001000000 | 0 |\n| 9999 | 0 | 000000010000000 | 0 |\n| 9999 | 0 | 000000100000000 | 0 |\n| 9999 | 0 | 000001000000000 | 0 |\n| 9999 | 0 | 000010000000000 | 0 |\n| 9999 | 0 | 000100000000000 | 0 |\n| 9999 | 0 | 001000000000000 | 0 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 1234 | 1 | 001001000110100 | 0 |\n| 1234 | 1 | 001001000110100 | 1234 |\n| 1234 | 0 | 010001000110100 | 0 |\n| 1234 | 0 | 110001000110100 | 0 |\n| 2345 | 1 | 010001101000101 | 0 |\n| 2345 | 1 | 010001101000101 | 2345 |\n| 2345 | 0 | 000001101000101 | 0 |\n| 2345 | 0 | 100001101000101 | 0 |\n| 0 | 1 | 100000000000000 | 12345 |\n| 0 | 1 | 100000000000000 | 0 |\n| 0 | 1 | 110000000000000 | 75 |\n| 12345 | 1 | 000111111001111 | 0 |\n| 12345 | 1 | 000111111001111 | 12345 |\n| 12345 | 1 | 010111111001111 | 0 |\n| 12345 | 1 | 010111111001111 | 12345 |\n| -1 | 1 | 100111111001111 | -1 |\n| -1 | 1 | 101000001001111 | -1 |\n| -1 | 1 | 000111111001111 | 12345 |\n| -1 | 1 | 010111111001111 | 12345 |\n| -1 | 0 | 100111111001110 | 0 |\n| -1 | 0 | 100111111001101 | 0 |\n| -1 | 0 | 100111111001011 | 0 |\n| -1 | 0 | 100111111000111 | 0 |\n| -1 | 0 | 100111111011111 | 0 |\n| -1 | 0 | 100111111101111 | 0 |\n| -1 | 0 | 100111110001111 | 0 |\n| -1 | 0 | 100111101001111 | 0 |\n| -1 | 0 | 100111011001111 | 0 |\n| -1 | 0 | 100110111001111 | 0 |\n| -1 | 0 | 100101111001111 | 0 |\n| -1 | 0 | 100011111001111 | 0 |\n| -1 | 0 | 101111111001111 | 0 |\n| -1 | 0 | 110000000000000 | 89 |"},CPU:{"CPU.hdl":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU.hdl\n/**\n * The Hack Central Processing unit (CPU).\n * Parses the binary code in the instruction input and executes it according to the\n * Hack machine language specification. In the case of a C-instruction, computes the\n * function specified by the instruction. If the instruction specifies to read a memory\n * value, the inM input is expected to contain this value. If the instruction specifies\n * to write a value to the memory, sets the outM output to this value, sets the addressM\n * output to the target address, and asserts the writeM output (when writeM = 0, any\n * value may appear in outM).\n * If the reset input is 0, computes the address of the next instruction and sets the\n * pc output to that value. If the reset input is 1, sets pc to 0.\n * Note: The outM and writeM outputs are combinational: they are affected by the\n * instruction's execution during the current cycle. The addressM and pc outputs are\n * clocked: although they are affected by the instruction's execution, they commit to\n * their new values only in the next cycle.\n */\nCHIP CPU {\n\n IN inM[16], // M value input (M = contents of RAM[A])\n instruction[16], // Instruction for execution\n reset; // Signals whether to re-start the current\n // program (reset==1) or continue executing\n // the current program (reset==0).\n\n OUT outM[16], // M value output\n writeM, // Write to M? \n addressM[15], // Address in data memory (of M)\n pc[15]; // address of next instruction\n\n PARTS:\n\t//// Replace this comment with your code.\n}","CPU.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU.tst\n\n// Tests the CPU by setting the instruction input to various binary values that\n// code Hack instructions, and outputting the values of the registers that are\n// supposed to be affected by the instructions.\n\n// Tracks the time, the CPU inputs (inM, instruction, reset bit), the CPU\n// outputs (outM, writeM bit, address, pc), and the value of the D-register.\noutput-list time%S1.3.1 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.2 addressM%D1.5.1 pc%D0.5.0 DRegister[]%D1.7.1;\n\nset instruction %B0011000000111001, // @12345\ntick, output, tock, output;\n\nset instruction %B1110110000010000, // D=A\ntick, output, tock, output;\n\nset instruction %B0101101110100000, // @23456\ntick, output, tock, output;\n\nset instruction %B1110000111110000, // AD=A-D\ntick, output, tock, output;\n\nset instruction %B0000001111101011, // @1003\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000001111101100, // @1004\ntick, output, tock, output;\n\nset instruction %B1110001110011000, // MD=D-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1111010011110000, // AD=D-M\nset inM 11111,\ntick, output, tock, output;\n\nset instruction %B0000000000001110, // @14\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;jlt\ntick, output, tock, output;\n\nset instruction %B0000001111100111, // @999\ntick, output, tock, output;\n\nset instruction %B1111110111100000, // A=M+1\ntick, output, tock, output;\n\nset instruction %B1110001100101000, // AM=D\ntick, output, tock, output;\n\nset instruction %B0000000000010101, // @21\ntick, output, tock, output;\n\nset instruction %B1110011111000010, // D+1;jeq\ntick, output, tock, output;\n\nset instruction %B0000000000000010, // @2\ntick, output, tock, output;\n\nset instruction %B1110000010111000, // AMD=D+A\ntick, output, tock, output;\n\nset instruction %B1111110111001000, // M=M+1\ntick, output, tock, output;\n\nset instruction %B1111110010101000, // AM=M-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110111010010000, // D=-1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110101010010000, // D=0\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110111111010000, // D=1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset reset 1;\ntick, output, tock, output;\n\nset instruction %B0111111111111111, // @32767\nset reset 0;\ntick, output, tock, output;',"CPU.cmp":"|time | inM | instruction |reset| outM |writeM|address| pc |DRegister|\n| 0+ | 0|0011000000111001| 0 |*******| 0 | 0 | 0| 0 |\n| 1 | 0|0011000000111001| 0 |*******| 0 | 12345 | 1| 0 |\n| 1+ | 0|1110110000010000| 0 |*******| 0 | 12345 | 1| 12345 |\n| 2 | 0|1110110000010000| 0 |*******| 0 | 12345 | 2| 12345 |\n| 2+ | 0|0101101110100000| 0 |*******| 0 | 12345 | 2| 12345 |\n| 3 | 0|0101101110100000| 0 |*******| 0 | 23456 | 3| 12345 |\n| 3+ | 0|1110000111110000| 0 |*******| 0 | 23456 | 3| 11111 |\n| 4 | 0|1110000111110000| 0 |*******| 0 | 11111 | 4| 11111 |\n| 4+ | 0|0000001111101011| 0 |*******| 0 | 11111 | 4| 11111 |\n| 5 | 0|0000001111101011| 0 |*******| 0 | 1003 | 5| 11111 |\n| 5+ | 0|1110001100001000| 0 | 11111| 1 | 1003 | 5| 11111 |\n| 6 | 0|1110001100001000| 0 | 11111| 1 | 1003 | 6| 11111 |\n| 6+ | 0|0000001111101100| 0 |*******| 0 | 1003 | 6| 11111 |\n| 7 | 0|0000001111101100| 0 |*******| 0 | 1004 | 7| 11111 |\n| 7+ | 0|1110001110011000| 0 | 11110| 1 | 1004 | 7| 11110 |\n| 8 | 0|1110001110011000| 0 | 11109| 1 | 1004 | 8| 11110 |\n| 8+ | 0|0000001111101000| 0 |*******| 0 | 1004 | 8| 11110 |\n| 9 | 0|0000001111101000| 0 |*******| 0 | 1000 | 9| 11110 |\n| 9+ | 11111|1111010011110000| 0 |*******| 0 | 1000 | 9| -1 |\n| 10 | 11111|1111010011110000| 0 |*******| 0 | 32767 | 10| -1 |\n| 10+ | 11111|0000000000001110| 0 |*******| 0 | 32767 | 10| -1 |\n| 11 | 11111|0000000000001110| 0 |*******| 0 | 14 | 11| -1 |\n| 11+ | 11111|1110001100000100| 0 |*******| 0 | 14 | 11| -1 |\n| 12 | 11111|1110001100000100| 0 |*******| 0 | 14 | 14| -1 |\n| 12+ | 11111|0000001111100111| 0 |*******| 0 | 14 | 14| -1 |\n| 13 | 11111|0000001111100111| 0 |*******| 0 | 999 | 15| -1 |\n| 13+ | 11111|1111110111100000| 0 |*******| 0 | 999 | 15| -1 |\n| 14 | 11111|1111110111100000| 0 |*******| 0 | 11112 | 16| -1 |\n| 14+ | 11111|1110001100101000| 0 | -1| 1 | 11112 | 16| -1 |\n| 15 | 11111|1110001100101000| 0 | -1| 1 | 32767 | 17| -1 |\n| 15+ | 11111|0000000000010101| 0 |*******| 0 | 32767 | 17| -1 |\n| 16 | 11111|0000000000010101| 0 |*******| 0 | 21 | 18| -1 |\n| 16+ | 11111|1110011111000010| 0 |*******| 0 | 21 | 18| -1 |\n| 17 | 11111|1110011111000010| 0 |*******| 0 | 21 | 21| -1 |\n| 17+ | 11111|0000000000000010| 0 |*******| 0 | 21 | 21| -1 |\n| 18 | 11111|0000000000000010| 0 |*******| 0 | 2 | 22| -1 |\n| 18+ | 11111|1110000010111000| 0 | 1| 1 | 2 | 22| 1 |\n| 19 | 11111|1110000010111000| 0 | 2| 1 | 1 | 23| 1 |\n| 19+ | 11111|1111110111001000| 0 | 11112| 1 | 1 | 23| 1 |\n| 20 | 11111|1111110111001000| 0 | 11112| 1 | 1 | 24| 1 |\n| 20+ | 11111|1111110010101000| 0 | 11110| 1 | 1 | 24| 1 |\n| 21 | 11111|1111110010101000| 0 | 11110| 1 | 11110 | 25| 1 |\n| 21+ | 11111|0000001111101000| 0 |*******| 0 | 11110 | 25| 1 |\n| 22 | 11111|0000001111101000| 0 |*******| 0 | 1000 | 26| 1 |\n| 22+ | 11111|1110111010010000| 0 |*******| 0 | 1000 | 26| -1 |\n| 23 | 11111|1110111010010000| 0 |*******| 0 | 1000 | 27| -1 |\n| 23+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 27| -1 |\n| 24 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 28| -1 |\n| 24+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 28| -1 |\n| 25 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 29| -1 |\n| 25+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 29| -1 |\n| 26 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 30| -1 |\n| 26+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 30| -1 |\n| 27 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000| -1 |\n| 27+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000| -1 |\n| 28 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000| -1 |\n| 28+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000| -1 |\n| 29 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000| -1 |\n| 29+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000| -1 |\n| 30 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000| -1 |\n| 30+ | 11111|1110101010010000| 0 |*******| 0 | 1000 | 1000| 0 |\n| 31 | 11111|1110101010010000| 0 |*******| 0 | 1000 | 1001| 0 |\n| 31+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1001| 0 |\n| 32 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1002| 0 |\n| 32+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1002| 0 |\n| 33 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1000| 0 |\n| 33+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000| 0 |\n| 34 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000| 0 |\n| 34+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000| 0 |\n| 35 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1001| 0 |\n| 35+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1001| 0 |\n| 36 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1002| 0 |\n| 36+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1002| 0 |\n| 37 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000| 0 |\n| 37+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000| 0 |\n| 38 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000| 0 |\n| 38+ | 11111|1110111111010000| 0 |*******| 0 | 1000 | 1000| 1 |\n| 39 | 11111|1110111111010000| 0 |*******| 0 | 1000 | 1001| 1 |\n| 39+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1001| 1 |\n| 40 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1000| 1 |\n| 40+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1000| 1 |\n| 41 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1001| 1 |\n| 41+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1001| 1 |\n| 42 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000| 1 |\n| 42+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000| 1 |\n| 43 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1001| 1 |\n| 43+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1001| 1 |\n| 44 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000| 1 |\n| 44+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000| 1 |\n| 45 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1001| 1 |\n| 45+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1001| 1 |\n| 46 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000| 1 |\n| 46+ | 11111|1110001100000111| 1 |*******| 0 | 1000 | 1000| 1 |\n| 47 | 11111|1110001100000111| 1 |*******| 0 | 1000 | 0| 1 |\n| 47+ | 11111|0111111111111111| 0 |*******| 0 | 1000 | 0| 1 |\n| 48 | 11111|0111111111111111| 0 |*******| 0 | 32767 | 1| 1 |","CPU-external.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU-external.tst\n\n// Tests the CPU by setting the instruction input to various binary values that\n// code Hack instructions, and outputting the values of the registers that are\n// supposed to be affected by the instructions.\n\n// Tracks the time, the CPU inputs (inM, instruction, reset bit), and the CPU\n// outputs (outM, writeM bit, address, pc).\noutput-list time%S1.3.1 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.2 addressM%D1.5.1 pc%D0.5.0;\n\nset instruction %B0011000000111001, // @12345\ntick, output, tock, output;\n\nset instruction %B1110110000010000, // D=A\ntick, output, tock, output;\n\nset instruction %B0101101110100000, // @23456\ntick, output, tock, output;\n\nset instruction %B1110000111110000, // AD=A-D\ntick, output, tock, output;\n\nset instruction %B0000001111101011, // @1003\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000001111101100, // @1004\ntick, output, tock, output;\n\nset instruction %B1110001110011000, // MD=D-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1111010011110000, // AD=D-M\nset inM 11111,\ntick, output, tock, output;\n\nset instruction %B0000000000001110, // @14\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;jlt\ntick, output, tock, output;\n\nset instruction %B0000001111100111, // @999\ntick, output, tock, output;\n\nset instruction %B1111110111100000, // A=M+1\ntick, output, tock, output;\n\nset instruction %B1110001100101000, // AM=D\ntick, output, tock, output;\n\nset instruction %B0000000000010101, // @21\ntick, output, tock, output;\n\nset instruction %B1110011111000010, // D+1;jeq\ntick, output, tock, output;\n\nset instruction %B0000000000000010, // @2\ntick, output, tock, output;\n\nset instruction %B1110000010111000, // AMD=D+A\ntick, output, tock, output;\n\nset instruction %B1111110111001000, // M=M+1\ntick, output, tock, output;\n\nset instruction %B1111110010101000, // AM=M-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110111010010000, // D=-1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110101010010000, // D=0\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110111111010000, // D=1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset reset 1;\ntick, output, tock, output;\n\nset instruction %B0111111111111111, // @32767\nset reset 0;\ntick, output, tock, output;',"CPU-external.cmp":"|time | inM | instruction |reset| outM |writeM|address| pc |\n| 0+ | 0|0011000000111001| 0 |*******| 0 | 0 | 0|\n| 1 | 0|0011000000111001| 0 |*******| 0 | 12345 | 1|\n| 1+ | 0|1110110000010000| 0 |*******| 0 | 12345 | 1|\n| 2 | 0|1110110000010000| 0 |*******| 0 | 12345 | 2|\n| 2+ | 0|0101101110100000| 0 |*******| 0 | 12345 | 2|\n| 3 | 0|0101101110100000| 0 |*******| 0 | 23456 | 3|\n| 3+ | 0|1110000111110000| 0 |*******| 0 | 23456 | 3|\n| 4 | 0|1110000111110000| 0 |*******| 0 | 11111 | 4|\n| 4+ | 0|0000001111101011| 0 |*******| 0 | 11111 | 4|\n| 5 | 0|0000001111101011| 0 |*******| 0 | 1003 | 5|\n| 5+ | 0|1110001100001000| 0 | 11111| 1 | 1003 | 5|\n| 6 | 0|1110001100001000| 0 | 11111| 1 | 1003 | 6|\n| 6+ | 0|0000001111101100| 0 |*******| 0 | 1003 | 6|\n| 7 | 0|0000001111101100| 0 |*******| 0 | 1004 | 7|\n| 7+ | 0|1110001110011000| 0 | 11110| 1 | 1004 | 7|\n| 8 | 0|1110001110011000| 0 | 11109| 1 | 1004 | 8|\n| 8+ | 0|0000001111101000| 0 |*******| 0 | 1004 | 8|\n| 9 | 0|0000001111101000| 0 |*******| 0 | 1000 | 9|\n| 9+ | 11111|1111010011110000| 0 |*******| 0 | 1000 | 9|\n| 10 | 11111|1111010011110000| 0 |*******| 0 | 32767 | 10|\n| 10+ | 11111|0000000000001110| 0 |*******| 0 | 32767 | 10|\n| 11 | 11111|0000000000001110| 0 |*******| 0 | 14 | 11|\n| 11+ | 11111|1110001100000100| 0 |*******| 0 | 14 | 11|\n| 12 | 11111|1110001100000100| 0 |*******| 0 | 14 | 14|\n| 12+ | 11111|0000001111100111| 0 |*******| 0 | 14 | 14|\n| 13 | 11111|0000001111100111| 0 |*******| 0 | 999 | 15|\n| 13+ | 11111|1111110111100000| 0 |*******| 0 | 999 | 15|\n| 14 | 11111|1111110111100000| 0 |*******| 0 | 11112 | 16|\n| 14+ | 11111|1110001100101000| 0 | -1| 1 | 11112 | 16|\n| 15 | 11111|1110001100101000| 0 | -1| 1 | 32767 | 17|\n| 15+ | 11111|0000000000010101| 0 |*******| 0 | 32767 | 17|\n| 16 | 11111|0000000000010101| 0 |*******| 0 | 21 | 18|\n| 16+ | 11111|1110011111000010| 0 |*******| 0 | 21 | 18|\n| 17 | 11111|1110011111000010| 0 |*******| 0 | 21 | 21|\n| 17+ | 11111|0000000000000010| 0 |*******| 0 | 21 | 21|\n| 18 | 11111|0000000000000010| 0 |*******| 0 | 2 | 22|\n| 18+ | 11111|1110000010111000| 0 | 1| 1 | 2 | 22|\n| 19 | 11111|1110000010111000| 0 | 2| 1 | 1 | 23|\n| 19+ | 11111|1111110111001000| 0 | 11112| 1 | 1 | 23|\n| 20 | 11111|1111110111001000| 0 | 11112| 1 | 1 | 24|\n| 20+ | 11111|1111110010101000| 0 | 11110| 1 | 1 | 24|\n| 21 | 11111|1111110010101000| 0 | 11110| 1 | 11110 | 25|\n| 21+ | 11111|0000001111101000| 0 |*******| 0 | 11110 | 25|\n| 22 | 11111|0000001111101000| 0 |*******| 0 | 1000 | 26|\n| 22+ | 11111|1110111010010000| 0 |*******| 0 | 1000 | 26|\n| 23 | 11111|1110111010010000| 0 |*******| 0 | 1000 | 27|\n| 23+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 27|\n| 24 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 28|\n| 24+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 28|\n| 25 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 29|\n| 25+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 29|\n| 26 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 30|\n| 26+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 30|\n| 27 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000|\n| 27+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000|\n| 28 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000|\n| 28+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000|\n| 29 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000|\n| 29+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000|\n| 30 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000|\n| 30+ | 11111|1110101010010000| 0 |*******| 0 | 1000 | 1000|\n| 31 | 11111|1110101010010000| 0 |*******| 0 | 1000 | 1001|\n| 31+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1001|\n| 32 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1002|\n| 32+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1002|\n| 33 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1000|\n| 33+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000|\n| 34 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000|\n| 34+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000|\n| 35 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1001|\n| 35+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1001|\n| 36 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1002|\n| 36+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1002|\n| 37 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000|\n| 37+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000|\n| 38 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000|\n| 38+ | 11111|1110111111010000| 0 |*******| 0 | 1000 | 1000|\n| 39 | 11111|1110111111010000| 0 |*******| 0 | 1000 | 1001|\n| 39+ | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1001|\n| 40 | 11111|1110001100000001| 0 |*******| 0 | 1000 | 1000|\n| 40+ | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1000|\n| 41 | 11111|1110001100000010| 0 |*******| 0 | 1000 | 1001|\n| 41+ | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1001|\n| 42 | 11111|1110001100000011| 0 |*******| 0 | 1000 | 1000|\n| 42+ | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1000|\n| 43 | 11111|1110001100000100| 0 |*******| 0 | 1000 | 1001|\n| 43+ | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1001|\n| 44 | 11111|1110001100000101| 0 |*******| 0 | 1000 | 1000|\n| 44+ | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1000|\n| 45 | 11111|1110001100000110| 0 |*******| 0 | 1000 | 1001|\n| 45+ | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1001|\n| 46 | 11111|1110001100000111| 0 |*******| 0 | 1000 | 1000|\n| 46+ | 11111|1110001100000111| 1 |*******| 0 | 1000 | 1000|\n| 47 | 11111|1110001100000111| 1 |*******| 0 | 1000 | 0|\n| 47+ | 11111|0111111111111111| 0 |*******| 0 | 1000 | 0|\n| 48 | 11111|0111111111111111| 0 |*******| 0 | 32767 | 1|"},Computer:{"Computer.hdl":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/Computer.hdl\n/**\n * The Hack computer, consisting of CPU, ROM and RAM.\n * When reset = 0, the program stored in the ROM executes.\n * When reset = 1, the program's execution restarts. \n * Thus, to start running the currently loaded program,\n * set reset to 1, and then set it to 0. \n * From this point onwards, the user is at the mercy of the software.\n * Depending on the program's code, and whether the code is correct,\n * the screen may show some output, the user may be expected to enter\n * some input using the keyboard, or the program may do some procerssing. \n */\nCHIP Computer {\n\n IN reset;\n\n PARTS:\n //// Replace this comment with your code.\n}","ComputerAdd.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerAdd.tst\n\n// Tests the Computer chip by having it execute the program Add.hack.\n// The program adds up the constants 2 and 3 and writes the result in RAM[0]. \n\n// Tracks the values of the time, reset bit, A-register, D-register,\n// program counter, R0, R1, and R2.\noutput-list time%S1.3.1 reset%B2.1.2 ARegister[0]%D1.7.1 DRegister[0]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Add.hack into the computer\'s instruction memory \nROM32K load Add.hack,\noutput;\n\n// First run (at the beginning PC=0)\nrepeat 6 {\n tick, tock, output;\n}\n\n// Resets the PC\nset reset 1,\nset RAM16K[0] 0,\ntick, tock, output;\n\n// Second run, to check that the PC was reset correctly.\nset reset 0,\n\nrepeat 6 {\n tick, tock, output;\n}',"ComputerAdd.cmp":"|time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0 | 0| 0 | 0 | 0 |\n| 1 | 0 | 2 | 0 | 1| 0 | 0 | 0 |\n| 2 | 0 | 2 | 2 | 2| 0 | 0 | 0 |\n| 3 | 0 | 3 | 2 | 3| 0 | 0 | 0 |\n| 4 | 0 | 3 | 5 | 4| 0 | 0 | 0 |\n| 5 | 0 | 0 | 5 | 5| 0 | 0 | 0 |\n| 6 | 0 | 0 | 5 | 6| 5 | 0 | 0 |\n| 7 | 1 | 0 | 5 | 0| 0 | 0 | 0 |\n| 8 | 0 | 2 | 5 | 1| 0 | 0 | 0 |\n| 9 | 0 | 2 | 2 | 2| 0 | 0 | 0 |\n| 10 | 0 | 3 | 2 | 3| 0 | 0 | 0 |\n| 11 | 0 | 3 | 5 | 4| 0 | 0 | 0 |\n| 12 | 0 | 0 | 5 | 5| 0 | 0 | 0 |\n| 13 | 0 | 0 | 5 | 6| 5 | 0 | 0 |","ComputerMax.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerMax.tst\n\n// Tests the Computer chip by having it execute the program Max.hack.\n// The program computes maximum(R0, R1) and writes the result in RAM[2].\n\n// Tracks the values of the time, reset bit, A-register, D-register,\n// program counter, R0, R1, and R2.\noutput-list time%S1.3.1 reset%B2.1.2 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Add.hack into the computer\'s instruction memory \nROM32K load Max.hack,\n\n// first run: computes max(3,5)\nset RAM16K[0] 3,\nset RAM16K[1] 5,\noutput;\n\nrepeat 14 {\n tick, tock, output;\n}\n\n// resets the PC\nset reset 1,\ntick, tock, output;\n\n// second run: computes max(23456,12345)\nset reset 0,\nset RAM16K[0] 23456,\nset RAM16K[1] 12345,\noutput;\n\n// The run on these inputs requires less cycles (different branching)\nrepeat 10 {\n tick, tock, output;\n}\n',"ComputerMax.cmp":"|time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0 | 0| 3 | 5 | 0 |\n| 1 | 0 | 0 | 0 | 1| 3 | 5 | 0 |\n| 2 | 0 | 0 | 3 | 2| 3 | 5 | 0 |\n| 3 | 0 | 1 | 3 | 3| 3 | 5 | 0 |\n| 4 | 0 | 1 | -2 | 4| 3 | 5 | 0 |\n| 5 | 0 | 10 | -2 | 5| 3 | 5 | 0 |\n| 6 | 0 | 10 | -2 | 6| 3 | 5 | 0 |\n| 7 | 0 | 1 | -2 | 7| 3 | 5 | 0 |\n| 8 | 0 | 1 | 5 | 8| 3 | 5 | 0 |\n| 9 | 0 | 12 | 5 | 9| 3 | 5 | 0 |\n| 10 | 0 | 12 | 5 | 12| 3 | 5 | 0 |\n| 11 | 0 | 2 | 5 | 13| 3 | 5 | 0 |\n| 12 | 0 | 2 | 5 | 14| 3 | 5 | 5 |\n| 13 | 0 | 14 | 5 | 15| 3 | 5 | 5 |\n| 14 | 0 | 14 | 5 | 14| 3 | 5 | 5 |\n| 15 | 1 | 14 | 5 | 0| 3 | 5 | 5 |\n| 15 | 0 | 14 | 5 | 0| 23456 | 12345 | 5 |\n| 16 | 0 | 0 | 5 | 1| 23456 | 12345 | 5 |\n| 17 | 0 | 0 | 23456 | 2| 23456 | 12345 | 5 |\n| 18 | 0 | 1 | 23456 | 3| 23456 | 12345 | 5 |\n| 19 | 0 | 1 | 11111 | 4| 23456 | 12345 | 5 |\n| 20 | 0 | 10 | 11111 | 5| 23456 | 12345 | 5 |\n| 21 | 0 | 10 | 11111 | 10| 23456 | 12345 | 5 |\n| 22 | 0 | 0 | 11111 | 11| 23456 | 12345 | 5 |\n| 23 | 0 | 0 | 23456 | 12| 23456 | 12345 | 5 |\n| 24 | 0 | 2 | 23456 | 13| 23456 | 12345 | 5 |\n| 25 | 0 | 2 | 23456 | 14| 23456 | 12345 | 23456 |","ComputerRect.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerRect.tst\n\n// Tests the Computer chip by having it execute the program Rect.hack.\n// The program draws a rectangle of width 16 pixels and length RAM[0]\n// at the top left corner of the screen.\n\n// Tracks the values of the time, A-register, D-register, program counter, R0, R1, and R2.\noutput-list time%S1.3.1 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Rect.hack into the computer's instruction memory \nROM32K load Rect.hack,\n\necho \"Before you run this script, select the 'Screen' option from the 'View' menu\";\n\necho \"A small rectangle should be drawn at the top left of the screen (the 'Screen' option of the 'View' menu should be selected.)\";\n\n// Draws a rectangle consisting of 4 rows (each 16 pixels wide)\nset RAM16K[0] 4,\noutput;\n\nrepeat 63 {\n tick, tock, output;\n}","ComputerRect.cmp":"|time |ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0| 4 | 0 | 0 |\n| 1 | 0 | 0 | 1| 4 | 0 | 0 |\n| 2 | 0 | 4 | 2| 4 | 0 | 0 |\n| 3 | 23 | 4 | 3| 4 | 0 | 0 |\n| 4 | 23 | 4 | 4| 4 | 0 | 0 |\n| 5 | 16 | 4 | 5| 4 | 0 | 0 |\n| 6 | 16 | 4 | 6| 4 | 0 | 0 |\n| 7 | 16384 | 4 | 7| 4 | 0 | 0 |\n| 8 | 16384 | 16384 | 8| 4 | 0 | 0 |\n| 9 | 17 | 16384 | 9| 4 | 0 | 0 |\n| 10 | 17 | 16384 | 10| 4 | 0 | 0 |\n| 11 | 17 | 16384 | 11| 4 | 0 | 0 |\n| 12 | 16384 | 16384 | 12| 4 | 0 | 0 |\n| 13 | 16384 | 16384 | 13| 4 | 0 | 0 |\n| 14 | 17 | 16384 | 14| 4 | 0 | 0 |\n| 15 | 17 | 16384 | 15| 4 | 0 | 0 |\n| 16 | 32 | 16384 | 16| 4 | 0 | 0 |\n| 17 | 32 | 16416 | 17| 4 | 0 | 0 |\n| 18 | 17 | 16416 | 18| 4 | 0 | 0 |\n| 19 | 17 | 16416 | 19| 4 | 0 | 0 |\n| 20 | 16 | 16416 | 20| 4 | 0 | 0 |\n| 21 | 16 | 3 | 21| 4 | 0 | 0 |\n| 22 | 10 | 3 | 22| 4 | 0 | 0 |\n| 23 | 10 | 3 | 10| 4 | 0 | 0 |\n| 24 | 17 | 3 | 11| 4 | 0 | 0 |\n| 25 | 16416 | 3 | 12| 4 | 0 | 0 |\n| 26 | 16416 | 3 | 13| 4 | 0 | 0 |\n| 27 | 17 | 3 | 14| 4 | 0 | 0 |\n| 28 | 17 | 16416 | 15| 4 | 0 | 0 |\n| 29 | 32 | 16416 | 16| 4 | 0 | 0 |\n| 30 | 32 | 16448 | 17| 4 | 0 | 0 |\n| 31 | 17 | 16448 | 18| 4 | 0 | 0 |\n| 32 | 17 | 16448 | 19| 4 | 0 | 0 |\n| 33 | 16 | 16448 | 20| 4 | 0 | 0 |\n| 34 | 16 | 2 | 21| 4 | 0 | 0 |\n| 35 | 10 | 2 | 22| 4 | 0 | 0 |\n| 36 | 10 | 2 | 10| 4 | 0 | 0 |\n| 37 | 17 | 2 | 11| 4 | 0 | 0 |\n| 38 | 16448 | 2 | 12| 4 | 0 | 0 |\n| 39 | 16448 | 2 | 13| 4 | 0 | 0 |\n| 40 | 17 | 2 | 14| 4 | 0 | 0 |\n| 41 | 17 | 16448 | 15| 4 | 0 | 0 |\n| 42 | 32 | 16448 | 16| 4 | 0 | 0 |\n| 43 | 32 | 16480 | 17| 4 | 0 | 0 |\n| 44 | 17 | 16480 | 18| 4 | 0 | 0 |\n| 45 | 17 | 16480 | 19| 4 | 0 | 0 |\n| 46 | 16 | 16480 | 20| 4 | 0 | 0 |\n| 47 | 16 | 1 | 21| 4 | 0 | 0 |\n| 48 | 10 | 1 | 22| 4 | 0 | 0 |\n| 49 | 10 | 1 | 10| 4 | 0 | 0 |\n| 50 | 17 | 1 | 11| 4 | 0 | 0 |\n| 51 | 16480 | 1 | 12| 4 | 0 | 0 |\n| 52 | 16480 | 1 | 13| 4 | 0 | 0 |\n| 53 | 17 | 1 | 14| 4 | 0 | 0 |\n| 54 | 17 | 16480 | 15| 4 | 0 | 0 |\n| 55 | 32 | 16480 | 16| 4 | 0 | 0 |\n| 56 | 32 | 16512 | 17| 4 | 0 | 0 |\n| 57 | 17 | 16512 | 18| 4 | 0 | 0 |\n| 58 | 17 | 16512 | 19| 4 | 0 | 0 |\n| 59 | 16 | 16512 | 20| 4 | 0 | 0 |\n| 60 | 16 | 0 | 21| 4 | 0 | 0 |\n| 61 | 10 | 0 | 22| 4 | 0 | 0 |\n| 62 | 10 | 0 | 23| 4 | 0 | 0 |\n| 63 | 23 | 0 | 24| 4 | 0 | 0 |"}},I={Screen:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Screen.hdl\n/**\n * The Screen (memory map).\n * Same functionality as a 16-bit 8K RAM:\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n *\n * This built-in implementation has the side effect of continuously \n * refreshing a visual 256 by 512 black-and-white screen, simulated \n * by the simulator. Each row in the visual screen is represented \n * by 32 consecutive 16-bit words, starting at the top left corner \n * of the visual screen. Thus the pixel at row r from the top and \n * column c from the left (0<=r<256, 0<=c<512) reflects the c%16 \n * bit (counting from LSB to MSB) of the word found in Screen[r*32+c/16]. \n */\nCHIP Screen {\n IN in[16], // what to write\n load, // write-enable bit\n address[13]; // where to read/write\n OUT out[16]; // Screen value at the given address\n\n PARTS:\n BUILTIN Screen;\n CLOCKED in, load;\n}',Keyboard:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Keyboard.hdl\n/**\n * The keyboard (memory map).\n * Outputs the character code of the currently pressed key,\n * or 0 if no key is pressed.\n *\n * This built-in implementation has a visualization side effect.\n */\nCHIP Keyboard {\n OUT out[16];\n\n PARTS:\n BUILTIN Keyboard;\n}',DRegister:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/DRegister.hdl\n/**\n * A 16-bit register named DRegister with the same functionality\n * of the Register chip:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value.\n * out(t+1) = (load(t), in(t), out(t))\n *\n * This built-in implementation has a visualization side effect.\n */\nCHIP DRegister {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n BUILTIN DRegister;\n CLOCKED in, load;\n}',ARegister:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/ARegister.hdl\n/**\n * A 16-bit register named ARegister with the same functionality\n * of the Register chip:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value.\n * out(t+1) = (load(t), in(t), out(t))\n *\n * This built-in implementation has a visualization side effect.\n */\n CHIP ARegister {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n BUILTIN ARegister;\n CLOCKED in, load;\n}',ROM32K:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/ROM32K.hdl\n/**\n * Read-Only memory (ROM) of 32K registers, each 16-bit wide.\n * Facilitates data read, as follows:\n * out(t) = ROM32K[address(t)](t)\n * In words: the chip outputs the value stored at the \n * memory location specified by address.\n *\n * Can be used as the instruction memory of the Hack computer.\n * To that end, the built-in chip implementation supports the handling \n * of the "ROM32K load Xxx" script command, where Xxx is the name of a\n * text file containing a program written in the binary Hack machine language.\n * When the simulator encounters such a command in a test script,\n * the file\'s contents is loaded into the simulated ROM32K chip.\n */\n CHIP ROM32K {\n IN address[15];\n OUT out[16];\n\n PARTS:\n BUILTIN ROM32K;\n}',RAM16K:y.replace("//// Replace this comment with your code.","BUILTIN RAM16K;")};async function F(n){await n.pushd("/projects/05"),await(0,r.cL)(n,P),await n.popd(),await n.pushd("/samples"),await n.writeFile("Add.hack",C),await n.writeFile("Max.hack",x),await n.writeFile("Rect.hack",D),await n.popd()}async function N(n){await n.pushd("/projects/05"),await c(n,P,".tst"),await c(n,P,".cmp"),await n.popd()}const E={SimpleAdd:{"SimpleAdd.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAdd.vm\n\n// Pushes and adds two constants.\n\npush constant 7\npush constant 8\nadd\n',"SimpleAddVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAddVME.tst\n\n// Tests and illustrates SimpleAdd.vm on the VM simulator.\n\nload SimpleAdd.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 3 { // SimpleAdd.vm has 3 VM commands\n vmstep;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;\noutput;',"SimpleAdd.cmp":"| RAM[0] | RAM[256] |\n| 257 | 15 |\n","SimpleAdd.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAdd.tst\n\n// Tests SimpleAdd.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer \n\nrepeat 60 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;\noutput;\n'},StackTest:{"StackTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTest.vm\n\n// Executes a sequence of arithmetic and logical operations on the stack. \n\npush constant 17\npush constant 17\neq\npush constant 17\npush constant 16\neq\npush constant 16\npush constant 17\neq\npush constant 892\npush constant 891\nlt\npush constant 891\npush constant 892\nlt\npush constant 891\npush constant 891\nlt\npush constant 32767\npush constant 32766\ngt\npush constant 32766\npush constant 32767\ngt\npush constant 32766\npush constant 32766\ngt\npush constant 57\npush constant 31\npush constant 53\nadd\npush constant 112\nsub\nneg\nand\npush constant 82\nor\nnot\n',"StackTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTestVME.tst\n\n// Tests and illustrates StackTest.vm on the VM simulator.\n\nload StackTest.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 38 { // StackTest.vm has 38 VM commands\n vmstep;\n}\n\n// Outputs the stack pointer (RAM[0]) and the stack contents: RAM[256]-RAM[265]\noutput-list RAM[0]%D2.6.2 \n RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;\noutput;\noutput-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;\noutput;\n',"StackTest.cmp":"| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] |\n| 266 | -1 | 0 | 0 | 0 | -1 |\n| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] |\n| 0 | -1 | 0 | 0 | -91 |\n","StackTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTest.tst\n\n// Tests StackTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 1000 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the stack pointer and the stack contents: RAM[256]-RAM[265]\noutput-list RAM[0]%D2.6.2 \n RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;\noutput;\noutput-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;\noutput;\n'},BasicTest:{"BasicTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTest.vm\n\n// Executes pop and push commands.\n\npush constant 10\npop local 0\npush constant 21\npush constant 22\npop argument 2\npop argument 1\npush constant 36\npop this 6\npush constant 42\npush constant 45\npop that 5\npop that 2\npush constant 510\npop temp 6\npush local 0\npush that 5\nadd\npush argument 1\nsub\npush this 6\npush this 6\nadd\nsub\npush temp 6\nadd\n',"BasicTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTestVME.tst\n\n// Tests and illustrates BasicTest.vm on the VM simulator.\n// Starts by setting the stack pointer and the base addresses\n// of relevant memory segments to selected RAM addresses.\n\nload BasicTest.vm,\n\nset sp 256, // stack pointer\nset local 300, // base address of the local segment\nset argument 400, // base address of the argument segment\nset this 3000, // base address of the this segment\nset that 3010, // base address of the that segment\n\nrepeat 25 { // BasicTest.vm has 25 VM commands\n vmstep;\n}\n\n// Outputs the value at the stack\'s base and some values from the tested memory segments\noutput-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 \n RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1\n RAM[3015]%D1.6.1 RAM[11]%D1.6.1;\noutput;\n',"BasicTest.cmp":"|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] |\n| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 |","BasicTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTest.tst\n\n// Tests BasicTest.asm on the CPU emulator.\n\nset RAM[0] 256, // stack pointer\nset RAM[1] 300, // base address of the local segment\nset RAM[2] 400, // base address of the argument segment\nset RAM[3] 3000, // base address of the this segment\nset RAM[4] 3010, // base address of the that segment\n\nrepeat 600 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base and some values from the tested memory segments\noutput-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 \n RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1\n RAM[3015]%D1.6.1 RAM[11]%D1.6.1;\noutput;\n'},PointerTest:{"PointerTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTest.vm\n\n// Executes pop and push commands using the \n// pointer, this, and that segments.\n\npush constant 3030\npop pointer 0\npush constant 3040\npop pointer 1\npush constant 32\npop this 2\npush constant 46\npop that 6\npush pointer 0\npush pointer 1\nadd\npush this 2\nsub\npush that 6\nadd\n',"PointerTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTestVME.tst\n\n// Tests and illustrates PointerTest.vm on the VM simulator.\n\nload PointerTest.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 15 { // PointerTest.vm has 15 VM commands\n vmstep;\n}\n\n// Outputs the stack base, THIS, THAT, and\n// some values from the the this and that segments\noutput-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1\n RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;\noutput;\n',"PointerTest.cmp":"|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|\n | 6084 | 3030 | 3040 | 32 | 46 |","PointerTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTest.tst\n\n// Tests PointerTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 450 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base, THIS, THAT, and\n// some values from the the this and that segments\noutput-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 \n RAM[4]%D1.6.1 RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;\noutput;\n'},StaticTest:{"StaticTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTest.vm\n\n// Executes pop and push commands using the static segment.\n\npush constant 111\npush constant 333\npush constant 888\npop static 8\npop static 3\npop static 1\npush static 3\npush static 1\nsub\npush static 8\nadd\n',"StaticTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTestVME.tst\n\n// Tests and illustrates StaticTest.vm on the VM simulator.\n\nload StaticTest.vm,\n\nset sp 256, // initializes the stack pointer\n\nrepeat 11 { // StaticTest.vm has 11 VM commands\n vmstep;\n}\n\n// Outputs the value at the stack\'s base \noutput-list RAM[256]%D1.6.1;\noutput;\n',"StaticTest.cmp":"|RAM[256]|\n| 1110 |","StaticTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTest.tst\n\n// Tests StaticTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 200 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base \noutput-list RAM[256]%D1.6.1;\noutput;\n'}};async function z(n){await n.pushd("/projects/07"),await(0,r.cL)(n,E),await n.popd()}async function O(n){await n.pushd("/projects/07"),await c(n,E,".tst"),await c(n,E,"VME.tst"),await c(n,E,".cmp"),await n.popd()}const j={BasicLoop:{"BasicLoop.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoop.vm\n\n// Computes the sum 1 + 2 + ... + n and pushes the result onto\n// the stack. The value n is given in argument[0], which must be \n// initialized by the caller of this code.\n\n\tpush constant 0 \n\tpop local 0 // sum = 0\nlabel LOOP\n\tpush argument 0 \n\tpush local 0\n\tadd\n\tpop local 0\t // sum = sum + n\n\tpush argument 0\n\tpush constant 1\n\tsub\n\tpop argument 0 // n--\n\tpush argument 0\n\tif-goto LOOP // if n > 0, goto LOOP\n\tpush local 0 // else, pushes sum to the stack\'s top\n',"BasicLoopVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoopVME.tst\n\n// Tests and illustrates BasicLoop.vm on the VM emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0].\n\nload BasicLoop.vm,\n\nset sp 256,\nset local 300,\nset argument 400,\nset argument[0] 3,\n\nrepeat 33 {\n \tvmstep;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D1.6.1 RAM[256]%D1.6.1;\noutput;\n',"BasicLoop.cmp":"| RAM[0] |RAM[256]|\n| 257 | 6 |\n","BasicLoop.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoop.tst\n\n// Tests BasicLoop.asm on the CPU emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0].\n\nset RAM[0] 256, // SP\nset RAM[1] 300, // LCL\nset RAM[2] 400, // ARG\nset RAM[400] 3, // argument 0\n\nrepeat 600 {\n\tticktock;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D1.6.1 RAM[256]%D1.6.1;\noutput;\n'},FibonacciSeries:{"FibonacciSeries.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeries.vm\n\n// Puts the first n elements of the Fibonacci series in the memory,\n// starting at address addr. n and addr are given in argument[0] and\n// argument[1], which must be initialized by the caller of this code.\n\n\tpush argument 1 // sets THAT, the base address of the\n\tpop pointer 1 // that segment, to argument[1]\n\tpush constant 0 // sets the series\' first and second\n\tpop that 0 // elements to 0 and 1, respectively \n\tpush constant 1 \n\tpop that 1 \n\tpush argument 0 // sets n, the number of remaining elements\n\tpush constant 2 // to be computed, to argument[0] minus 2,\n\tsub // since 2 elements were already computed.\n\tpop argument 0 \n\nlabel LOOP\n\tpush argument 0\n\tif-goto COMPUTE_ELEMENT // if n > 0, goto COMPUTE_ELEMENT\n\tgoto END // otherwise, goto END\n\nlabel COMPUTE_ELEMENT\n // that[2] = that[0] + that[1]\n\tpush that 0\n\tpush that 1\n\tadd\n\tpop that 2\n\t// THAT += 1 (updates the base address of that)\n\tpush pointer 1\n\tpush constant 1\n\tadd\n\tpop pointer 1 \n\t// updates n-- and loops \n\tpush argument 0\n\tpush constant 1\n\tsub\n\tpop argument 0 \n\tgoto LOOP\n\nlabel END\n',"FibonacciSeriesVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst\n\n// Tests and illustrates FibonacciSeries.vm on the VM emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0] to n and argument [1] to the base address\n// of the generated series.\n\nload FibonacciSeries.vm,\n\nset sp 256,\nset local 300,\nset argument 400,\nset argument[0] 6,\nset argument[1] 3000,\n\nrepeat 73 {\n\tvmstep;\n}\n\n// Outputs the series of values generated and written by the code.\noutput-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 \n RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2;\noutput;\n',"FibonacciSeries.cmp":"|RAM[3000]|RAM[3001]|RAM[3002]|RAM[3003]|RAM[3004]|RAM[3005]|\n| 0 | 1 | 1 | 2 | 3 | 5 |\n","FibonacciSeries.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeries.tst\n\n// Tests FibonacciSeries.asm on the CPU emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0] and argument [1].\n\nset RAM[0] 256, // SP\nset RAM[1] 300, // LCL\nset RAM[2] 400, // ARG\nset RAM[400] 6, // argument[0], n\nset RAM[401] 3000, // argument[1], base address of the generated series\n\nrepeat 1100 {\n\tticktock;\n}\n\n// Outputs the series of values generated and written by the code.\noutput-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 \n RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2;\noutput;\n'},SimpleFunction:{"SimpleFunction.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunction.vm\n\n// Performs a simple calculation and returns the result.\n// argument[0] and argument[1] must be set by the caller.\n\nfunction SimpleFunction.test 2\n\tpush local 0\n\tpush local 1\n\tadd\n\tnot\n\tpush argument 0\n\tadd\n\tpush argument 1\n\tsub\n\treturn\n',"SimpleFunctionVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst\n\n// Tests and illustrates SimpleFunction.vm in the VM emulator. \n// Before executing the code, initializes the stack pointer\n// and the base addresses of some of the memory segments, \n// and sets some values in the argument segment.\n\nload SimpleFunction.vm,\n\nset sp 317,\nset local 317,\nset argument 310,\nset this 3000,\nset that 4000,\nset argument[0] 1234,\nset argument[1] 37,\nset argument[2] 9,\nset argument[3] 305,\nset argument[4] 300,\nset argument[5] 3010,\nset argument[6] 4010,\n\nrepeat 10 {\n\tvmstep;\n}\n\n// Outputs SP, LCL, ARG, THIS, THAT, and the return value.\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 \n RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1;\noutput;\n',"SimpleFunction.cmp":"| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] |RAM[310]|\n| 311 | 305 | 300 | 3010 | 4010 | 1196 |\n","SimpleFunction.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunction.tst\n\n// Tests SimpleFunction.asm in the CPU emulator.\n// In particular, tests how the assembly implementation of the 'function'\n// VM command initializes local variables, and how the assembly implementation\n// of the 'return' VM command handles the return value, SP, LCL, ARG, THIS, and THAT. \n// Before executing the code, initializes the stack pointer and the pointers of some\n// of the memory segments, and sets some values in the argument segment.\n\nset RAM[0] 317, // SP\nset RAM[1] 317, // LCL\nset RAM[2] 310, // ARG\nset RAM[3] 3000, // THIS\nset RAM[4] 4000, // THAT\nset RAM[310] 1234, \nset RAM[311] 37, \nset RAM[312] 1000, \nset RAM[313] 305,\nset RAM[314] 300,\nset RAM[315] 3010,\nset RAM[316] 4010, \n\nrepeat 300 {\n\tticktock;\n}\n\n// Outputs SP, LCL, ARG, THIS, THAT, and the return value.\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 \n RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1;\noutput;\n"},NestedCall:{"Sys.vm":"// Sys.vm. Tested by the NestedCall test script.\n// Consists of three functions: Sys.init, Sys.main, and Sys.add12.\n\n// Calls Sys.main() and stores a return value in temp 1.\n// Does not return (enters infinite loop).\n// The VM implementation starts running the Sys.init function, by default.\nfunction Sys.init 0\n\tpush constant 4000\t// tests that THIS and THAT are handled correctly\n\tpop pointer 0\n\tpush constant 5000\n\tpop pointer 1\n\tcall Sys.main 0\n\tpop temp 1\n\tlabel LOOP\n\tgoto LOOP\n\n// Sets locals 1, 2 and 3 to some values. Leaves locals 0 and 4 unchanged, \n// to test that the 'function' VM command initliazes them to 0 (the test \n// script sets them to -1 before this code starts running).\n// Calls Sys.add12(123) and stores the return value (should be 135) in temp 0.\n// Returns local 0 + local 1 + local 2 + local 3 + local 4 (should be 456), to \n// confirm that locals were not mangled by the function call.\nfunction Sys.main 5\n\tpush constant 4001\n\tpop pointer 0\n\tpush constant 5001\n\tpop pointer 1\n\tpush constant 200\n\tpop local 1\n\tpush constant 40\n\tpop local 2\n\tpush constant 6\n\tpop local 3\n\tpush constant 123\n\tcall Sys.add12 1\n\tpop temp 0\n\tpush local 0\n\tpush local 1\n\tpush local 2\n\tpush local 3\n\tpush local 4\n\tadd\n\tadd\n\tadd\n\tadd\n\treturn\n\n// Returns (argument 0) + 12.\nfunction Sys.add12 0\n\tpush constant 4002\n\tpop pointer 0\n\tpush constant 5002\n\tpop pointer 1\n\tpush argument 0\n\tpush constant 12\n\tadd\n\treturn\n","NestedCallVME.tst":"// Tests and illustrates how the VM implementation handles function-call-and-return,\n// by executing the functions in Sys.vm in the VM emulator.\n// In particular, loads and runs the functions in Sys.vm.\n\nload Sys.vm,\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1;\n\nset RAM[0] 261,\nset RAM[1] 261,\nset RAM[2] 256,\nset RAM[3] -3,\nset RAM[4] -4,\nset RAM[5] -1, // test results\nset RAM[6] -1,\nset RAM[256] 1234, // fake stack frame from call Sys.init\nset RAM[257] -1,\nset RAM[258] -2,\nset RAM[259] -3,\nset RAM[260] -4,\n\nset RAM[261] -1, // Initialize stack to check for local segment\nset RAM[262] -1, // being cleared to zero.\nset RAM[263] -1,\nset RAM[264] -1,\nset RAM[265] -1,\nset RAM[266] -1,\nset RAM[267] -1,\nset RAM[268] -1,\nset RAM[269] -1,\nset RAM[270] -1,\nset RAM[271] -1,\nset RAM[272] -1,\nset RAM[273] -1,\nset RAM[274] -1,\nset RAM[275] -1,\nset RAM[276] -1,\nset RAM[277] -1,\nset RAM[278] -1,\nset RAM[279] -1,\nset RAM[280] -1,\nset RAM[281] -1,\nset RAM[282] -1,\nset RAM[283] -1,\nset RAM[284] -1,\nset RAM[285] -1,\nset RAM[286] -1,\nset RAM[287] -1,\nset RAM[288] -1,\nset RAM[289] -1,\nset RAM[290] -1,\nset RAM[291] -1,\nset RAM[292] -1,\nset RAM[293] -1,\nset RAM[294] -1,\nset RAM[295] -1,\nset RAM[296] -1,\nset RAM[297] -1,\nset RAM[298] -1,\nset RAM[299] -1,\n\nset sp 261,\nset local 261,\nset argument 256,\nset this 3000,\nset that 4000;\n\nrepeat 50 {\n\tvmstep;\n}\noutput;\n","NestedCall.cmp":"| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] |\n| 261 | 261 | 256 | 4000 | 5000 | 135 | 246 |\n","NestedCall.tst":"// Tests how the VM implementation handles function-call-and-return,\n// by executing the functions in Sys.vm.\n// In particular, loads and runs NestedCall.asm, which results when \n// the VM translator is applied to the NestedCall folder, which \n// includes only one VM file: Sys.vm.\n\nset RAM[0] 261,\nset RAM[1] 261,\nset RAM[2] 256,\nset RAM[3] -3,\nset RAM[4] -4,\nset RAM[5] -1, // test results\nset RAM[6] -1,\nset RAM[256] 1234, // fake stack frame from call Sys.init\nset RAM[257] -1,\nset RAM[258] -2,\nset RAM[259] -3,\nset RAM[260] -4,\n\nset RAM[261] -1, // Initializes the stack, to check that the local segment\nset RAM[262] -1, // is initialized to zeros by the 'function' VM command.\nset RAM[263] -1,\nset RAM[264] -1,\nset RAM[265] -1,\nset RAM[266] -1,\nset RAM[267] -1,\nset RAM[268] -1,\nset RAM[269] -1,\nset RAM[270] -1,\nset RAM[271] -1,\nset RAM[272] -1,\nset RAM[273] -1,\nset RAM[274] -1,\nset RAM[275] -1,\nset RAM[276] -1,\nset RAM[277] -1,\nset RAM[278] -1,\nset RAM[279] -1,\nset RAM[280] -1,\nset RAM[281] -1,\nset RAM[282] -1,\nset RAM[283] -1,\nset RAM[284] -1,\nset RAM[285] -1,\nset RAM[286] -1,\nset RAM[287] -1,\nset RAM[288] -1,\nset RAM[289] -1,\nset RAM[290] -1,\nset RAM[291] -1,\nset RAM[292] -1,\nset RAM[293] -1,\nset RAM[294] -1,\nset RAM[295] -1,\nset RAM[296] -1,\nset RAM[297] -1,\nset RAM[298] -1,\nset RAM[299] -1,\n\nrepeat 4000 {\n\tticktock;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1;\noutput;\n"},FibonacciElement:{"Sys.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/Sys.vm\n\n// Containts one function: Sys.init.\n\n// Pushes a constant n onto the stack, and calls the Main.fibonacii\n// function, which computes the n\'th element of the Fibonacci series.\n// Note that by convention, the Sys.init function is called "automatically" \n// by the bootstrap code generated by the VM translator.\nfunction Sys.init 0\n // Computes fibonacci(4)\n\tpush constant 4\n\t// Calls the function, informing that one argument was pushed onto the stack\n\tcall Main.fibonacci 1\nlabel END \n\tgoto END // loops infinitely',"Main.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/Main.vm\n\n// Contains one function: Main.fibonacci.\n\n// Computes the n\'th element of the Fibonacci series, recursively.\n// n is given in argument[0]. Called by the Sys.init function \n// (part of the Sys.vm file), which sets argument[0] to an input\n// value and then calls Main.fibonacci.\nfunction Main.fibonacci 0\n\tpush argument 0\n\tpush constant 2\n\tlt \n\tif-goto N_LT_2 \n\tgoto N_GE_2\nlabel N_LT_2 // if n < 2 returns n\n\tpush argument 0 \n\treturn\nlabel N_GE_2 // if n >= 2 returns fib(n - 2) + fib(n - 1)\n\tpush argument 0\n\tpush constant 2\n\tsub\n\tcall Main.fibonacci 1 // computes fib(n - 2)\n\tpush argument 0\n\tpush constant 1\n\tsub\n\tcall Main.fibonacci 1 // computes fib(n - 1)\n\tadd // returns fib(n - 1) + fib(n - 2)\n\treturn\n',"FibonacciElementVME.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/FibonacciElementVME.tst\n\n// Tests and illustrates the given Fibonacci element program on the VM emulator.\n\nload,\n\nset sp 261,\n\nrepeat 110 {\n vmstep;\n}\n\n// Outputs the stack pointer and the value at the stack's base.\n// That's where the implementation should put the return value. \noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;\noutput;\n","FibonacciElement.cmp":"| RAM[0] |RAM[261]|\n| 262 | 3 |\n","FibonacciElement.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/FibonacciElement.tst\n\n// Tests FibonacciElement.asm on the CPU emulator. \n// FibonacciElement.asm results from translating Main.vm and Sys.vm into\n// a single assembly program, stored in the file FibonacciElement.asm.\n\nrepeat 6000 {\n\tticktock;\n}\n\n// Outputs the stack pointer and the value at the stack's base.\n// That's where the implementation should put the return value.\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;\noutput;\n"},StaticsTest:{"Class1.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Class1.vm\n\n// Stores two supplied arguments in static[0] and static[1].\nfunction Class1.set 0\n\tpush argument 0\n\tpop static 0\n\tpush argument 1\n\tpop static 1\n\tpush constant 0\n\treturn\n\n// Returns static[0] - static[1].\nfunction Class1.get 0\n\tpush static 0\n\tpush static 1\n\tsub\n\treturn',"Class2.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Class2.vm\n\n// Stores two supplied arguments in static[0] and static[1].\nfunction Class2.set 0\n\tpush argument 0\n\tpop static 0\n\tpush argument 1\n\tpop static 1\n\tpush constant 0\n\treturn\n\n// Returns static[0] - static[1].\nfunction Class2.get 0\n\tpush static 0\n\tpush static 1\n\tsub\n\treturn',"Sys.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Sys.vm\n\n// Tests that different functions, stored in two different \n// class files, manipulate the static segment correctly. \n\nfunction Sys.init 0\n\tpush constant 6\n\tpush constant 8\n\tcall Class1.set 2\n\tpop temp 0 // dumps the return value\n\tpush constant 23\n\tpush constant 15\n\tcall Class2.set 2\n\tpop temp 0 // dumps the return value\n\tcall Class1.get 0\n\tcall Class2.get 0\nlabel END\n\tgoto END',"StaticsTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/StaticsTestVME.tst\n\n// Tests and illustrates the statics test on the VM emulator.\n\nload,\n\nset sp 261,\n\nrepeat 36 {\n\tvmstep;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1;\noutput;\n',"StaticsTest.cmp":"| RAM[0] |RAM[261]|RAM[262]|\n| 263 | -2 | 8 |\n","StaticsTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/StaticsTest.tst\n\n// Tests StaticTest.asm in the CPU emulator.\n// This assembly file results from translating the staticsTest folder.\n\nset RAM[0] 256,\n\nrepeat 2500 {\n\tticktock;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1;\noutput;\n'}};async function L(n){await n.pushd("/projects/08"),await(0,r.cL)(n,j),await n.popd()}async function U(n){await n.pushd("/projects/08"),await c(n,j,".tst"),await c(n,j,"VME.tst"),await c(n,j,".cmp"),await n.popd()}var H=e(9828);const K={"01":s,"02":o,"03":u,"05":d},X={"07":i,"08":p},V={1:s,2:o,3:u,4:a,5:d,6:H,7:i,8:p};let W=!1;const J=async(n,t)=>{if(!W){W=!0,t??=[1,2,3,4,6,5,7,8];for(const e of t)Object.keys(V).includes(e.toString())&&await V[e].resetFiles(n);W=!1}},G=async(n,t)=>{if(!W){W=!0,t??=[1,2,3,4,5,7,8];for(const e of t)Object.keys(V).includes(e.toString())&&await V[e].resetTests(n);W=!1}},_={...l,...m,...R,...P,...E,...j}}}]);
\ No newline at end of file
+"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[288],{3288:(n,t,e)=>{e.r(t),e.d(t,{Assignments:()=>_,ChipProjects:()=>K,VmProjects:()=>X,resetFiles:()=>J,resetTests:()=>G});var s={};e.r(s),e.d(s,{BUILTIN_CHIPS:()=>k,CHIPS:()=>l,resetFiles:()=>h,resetTests:()=>B});var o={};e.r(o),e.d(o,{BUILTIN_CHIPS:()=>v,CHIPS:()=>m,resetFiles:()=>f,resetTests:()=>M});var u={};e.r(u),e.d(u,{BUILTIN_CHIPS:()=>A,CHIPS:()=>R,resetFiles:()=>T,resetTests:()=>b});var a={};e.r(a),e.d(a,{TESTS:()=>g,resetFiles:()=>w,resetTests:()=>S});var d={};e.r(d),e.d(d,{BUILTIN_CHIPS:()=>I,CHIPS:()=>P,resetFiles:()=>F,resetTests:()=>N});var i={};e.r(i),e.d(i,{VMS:()=>E,resetFiles:()=>z,resetTests:()=>O});var p={};e.r(p),e.d(p,{VMS:()=>j,resetFiles:()=>L,resetTests:()=>U});var r=e(4544);async function c(n,t,e){for(const[s,o]of Object.entries(t))"string"===typeof o?s.endsWith(`${e}`)&&await n.writeFile(s,o):(n.cd(s),await c(n,o,e),n.cd(".."))}const l={Nand:{"Nand.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Nand.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Nand.cmp":"| a | b |out|\n| 0 | 0 | 1 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |"},Not:{"Not.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not.hdl\n/**\n * Not gate:\n * if (in) out = 0, else out = 1\n */\nCHIP Not {\n IN in;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Not.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not.tst\n\noutput-list in out;\n\nset in 0,\neval,\noutput;\n\nset in 1,\neval,\noutput;',"Not.cmp":"|in |out|\n| 0 | 1 |\n| 1 | 0 |"},And:{"And.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And.hdl\n/**\n * And gate:\n * if (a and b) out = 1, else out = 0 \n */\nCHIP And {\n IN a, b;\n OUT out;\n \n PARTS:\n //// Replace this comment with your code.\n}',"And.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"And.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 0 |\n| 1 | 0 | 0 |\n| 1 | 1 | 1 |"},Or:{"Or.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or.hdl\n/**\n * Or gate:\n * if (a or b) out = 1, else out = 0 \n */\nCHIP Or {\n IN a, b;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Or.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 1 |"},Xor:{"Xor.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Xor.hdl\n/**\n * Exclusive-or gate:\n * if ((a and Not(b)) or (Not(a) and b)) out = 1, else out = 0\n */\nCHIP Xor {\n IN a, b;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Xor.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Xor.tst\n\noutput-list a b out;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"Xor.cmp":"| a | b |out|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |"},Mux:{"Mux.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux.hdl\n/** \n * Multiplexor:\n * if (sel = 0) out = a, else out = b\n */\nCHIP Mux {\n IN a, b, sel;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux.tst\n\noutput-list a b sel out;\n\nset a 0,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 0,\nset b 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 1,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a 1,\nset b 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"Mux.cmp":"| a | b |sel|out|\n| 0 | 0 | 0 | 0 |\n| 0 | 0 | 1 | 0 |\n| 0 | 1 | 0 | 0 |\n| 0 | 1 | 1 | 1 |\n| 1 | 0 | 0 | 1 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |\n| 1 | 1 | 1 | 1 |"},DMux:{"DMux.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux.hdl\n/**\n * Demultiplexor:\n * [a, b] = [in, 0] if sel = 0\n * [0, in] if sel = 1\n */\nCHIP DMux {\n IN in, sel;\n OUT a, b;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux.tst\n\noutput-list in sel a b;\n\nset in 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset in 1,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"DMux.cmp":"|in |sel| a | b |\n| 0 | 0 | 0 | 0 |\n| 0 | 1 | 0 | 0 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |"},Not16:{"Not16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/01/Not16.hdl\n/**\n * 16-bit Not gate:\n * for i = 0, ..., 15:\n * out[i] = Not(a[i])\n */\nCHIP Not16 {\n IN in[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Not16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Not16.tst\n\noutput-list in%B1.16.1 out%B1.16.1;\n\nset in %B0000000000000000,\neval,\noutput;\n\nset in %B1111111111111111,\neval,\noutput;\n\nset in %B1010101010101010,\neval,\noutput;\n\nset in %B0011110011000011,\neval,\noutput;\n\nset in %B0001001000110100,\neval,\noutput;',"Not16.cmp":"| in | out |\n| 0000000000000000 | 1111111111111111 |\n| 1111111111111111 | 0000000000000000 |\n| 1010101010101010 | 0101010101010101 |\n| 0011110011000011 | 1100001100111100 |\n| 0001001000110100 | 1110110111001011 |"},And16:{"And16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And16.hdl\n/**\n * 16-bit And gate:\n * for i = 0, ..., 15:\n * out[i] = a[i] And b[i] \n */\nCHIP And16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"And16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/And16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"And16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0000000000000000 |\n| 1111111111111111 | 1111111111111111 | 1111111111111111 |\n| 1010101010101010 | 0101010101010101 | 0000000000000000 |\n| 0011110011000011 | 0000111111110000 | 0000110011000000 |\n| 0001001000110100 | 1001100001110110 | 0001000000110100 |"},Or16:{"Or16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or16.hdl\n/**\n * 16-bit Or gate:\n * for i = 0, ..., 15:\n * out[i] = a[i] Or b[i] \n */\nCHIP Or16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"Or16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1111111111111111 |\n| 1111111111111111 | 1111111111111111 | 1111111111111111 |\n| 1010101010101010 | 0101010101010101 | 1111111111111111 |\n| 0011110011000011 | 0000111111110000 | 0011111111110011 |\n| 0001001000110100 | 1001100001110110 | 1001101001110110 |"},Mux16:{"Mux16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux16.hdl\n/**\n * 16-bit multiplexor: \n * for i = 0, ..., 15:\n * if (sel = 0) out[i] = a[i], else out[i] = b[i]\n */\nCHIP Mux16 {\n IN a[16], b[16], sel;\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 sel out%B1.16.1;\n\nset a 0,\nset b 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B0001001000110100,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B1001100001110110,\nset b %B0000000000000000,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;',"Mux16.cmp":"| a | b |sel| out |\n| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 |\n| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 |\n| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 |\n| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 |\n| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 |\n| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 |\n| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 |"},Mux4Way16:{"Mux4Way16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux4Way16.hdl\n/**\n * 4-way 16-bit multiplexor:\n * out = a if sel = 00\n * b if sel = 01\n * c if sel = 10\n * d if sel = 11\n */\nCHIP Mux4Way16 {\n IN a[16], b[16], c[16], d[16], sel[2];\n OUT out[16];\n \n PARTS:\n //// Replace this comment with your code.\n}',"Mux4Way16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux4Way16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 sel%B2.2.2 out%B1.16.1;\n\nset a 0,\nset b 0,\nset c 0,\nset d 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\nset c %B1010101010101010,\nset d %B0101010101010101,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;',"Mux4Way16.cmp":"| a | b | c | d | sel | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 ||"},Mux8Way16:{"Mux8Way16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux8Way16.hdl\n/**\n * 8-way 16-bit multiplexor:\n * out = a if sel = 000\n * b if sel = 001\n * c if sel = 010\n * d if sel = 011\n * e if sel = 100\n * f if sel = 101\n * g if sel = 110\n * h if sel = 111\n */\nCHIP Mux8Way16 {\n IN a[16], b[16], c[16], d[16],\n e[16], f[16], g[16], h[16],\n sel[3];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Mux8Way16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Mux8Way16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 e%B1.16.1 f%B1.16.1 g%B1.16.1 h%B1.16.1 sel%B2.3.2 out%B1.16.1;\n\nset a 0,\nset b 0,\nset c 0,\nset d 0,\nset e 0,\nset f 0,\nset g 0,\nset h 0,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset sel 4,\neval,\noutput;\n\nset sel 5,\neval,\noutput;\n\nset sel 6,\neval,\noutput;\n\nset sel 7,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B0010001101000101,\nset c %B0011010001010110,\nset d %B0100010101100111,\nset e %B0101011001111000,\nset f %B0110011110001001,\nset g %B0111100010011010,\nset h %B1000100110101011,\nset sel 0,\neval,\noutput;\n\nset sel 1,\neval,\noutput;\n\nset sel 2,\neval,\noutput;\n\nset sel 3,\neval,\noutput;\n\nset sel 4,\neval,\noutput;\n\nset sel 5,\neval,\noutput;\n\nset sel 6,\neval,\noutput;\n\nset sel 7,\neval,\noutput;',"Mux8Way16.cmp":"| a | b | c | d | e | f | g | h | sel | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 |\n| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 |"},DMux4Way:{"DMux4Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux4Way.hdl\n/**\n * 4-way demultiplexor:\n * [a, b, c, d] = [in, 0, 0, 0] if sel = 00\n * [0, in, 0, 0] if sel = 01\n * [0, 0, in, 0] if sel = 10\n * [0, 0, 0, in] if sel = 11\n */\nCHIP DMux4Way {\n IN in, sel[2];\n OUT a, b, c, d;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux4Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux4Way.tst\n\noutput-list in sel%B2.2.2 a b c d;\n\nset in 0,\nset sel %B00,\neval,\noutput;\n\nset sel %B01,\neval,\noutput;\n\nset sel %B10,\neval,\noutput;\n\nset sel %B11,\neval,\noutput;\n\nset in 1,\nset sel %B00,\neval,\noutput;\n\nset sel %B01,\neval,\noutput;\n\nset sel %B10,\neval,\noutput;\n\nset sel %B11,\neval,\noutput;',"DMux4Way.cmp":"|in | sel | a | b | c | d |\n| 0 | 00 | 0 | 0 | 0 | 0 |\n| 0 | 01 | 0 | 0 | 0 | 0 |\n| 0 | 10 | 0 | 0 | 0 | 0 |\n| 0 | 11 | 0 | 0 | 0 | 0 |\n| 1 | 00 | 1 | 0 | 0 | 0 |\n| 1 | 01 | 0 | 1 | 0 | 0 |\n| 1 | 10 | 0 | 0 | 1 | 0 |\n| 1 | 11 | 0 | 0 | 0 | 1 |"},DMux8Way:{"DMux8Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux8Way.hdl\n/**\n * 8-way demultiplexor:\n * [a, b, c, d, e, f, g, h] = [in, 0, 0, 0, 0, 0, 0, 0] if sel = 000\n * [0, in, 0, 0, 0, 0, 0, 0] if sel = 001\n * [0, 0, in, 0, 0, 0, 0, 0] if sel = 010\n * [0, 0, 0, in, 0, 0, 0, 0] if sel = 011\n * [0, 0, 0, 0, in, 0, 0, 0] if sel = 100\n * [0, 0, 0, 0, 0, in, 0, 0] if sel = 101\n * [0, 0, 0, 0, 0, 0, in, 0] if sel = 110\n * [0, 0, 0, 0, 0, 0, 0, in] if sel = 111\n */\nCHIP DMux8Way {\n IN in, sel[3];\n OUT a, b, c, d, e, f, g, h;\n\n PARTS:\n //// Replace this comment with your code.\n}',"DMux8Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/DMux8Way.tst\n\noutput-list in sel%B2.3.2 a b c d e f g h;\n\nset in 0,\nset sel %B000,\neval,\noutput;\n\nset sel %B001,\neval,\noutput;\n\nset sel %B010,\neval,\noutput;\n\nset sel %B011,\neval,\noutput;\n\nset sel %B100,\neval,\noutput;\n\nset sel %B101,\neval,\noutput;\n\nset sel %B110,\neval,\noutput;\n\nset sel %B111,\neval,\noutput;\n\nset in 1,\nset sel %B000,\neval,\noutput;\n\nset sel %B001,\neval,\noutput;\n\nset sel %B010,\neval,\noutput;\n\nset sel %B011,\neval,\noutput;\n\nset sel %B100,\neval,\noutput;\n\nset sel %B101,\neval,\noutput;\n\nset sel %B110,\neval,\noutput;\n\nset sel %B111,\neval,\noutput;',"DMux8Way.cmp":"|in | sel | a | b | c | d | e | f | g | h |\n| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |\n| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |\n| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |\n| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |\n| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |"},Or8Way:{"Or8Way.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or8Way.hdl\n/**\n * 8-way Or gate: \n * out = in[0] Or in[1] Or ... Or in[7]\n */\nCHIP Or8Way {\n IN in[8];\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Or8Way.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Or8Way.tst\n\noutput-list in%B2.8.2 out;\n\nset in %B00000000,\neval,\noutput;\n\nset in %B11111111,\neval,\noutput;\n\nset in %B00010000,\neval,\noutput;\n\nset in %B00000001,\neval,\noutput;\n\nset in %B00100110,\neval,\noutput;',"Or8Way.cmp":"| in |out|\n| 00000000 | 0 |\n| 11111111 | 1 |\n| 00010000 | 1 |\n| 00000001 | 1 |\n| 00100110 | 1 |"}},k={Nand:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/1/Nand.hdl\n/**\n * Nand gate:\n * if (a and b) out = 0, else out = 1 \n */\nCHIP Nand {\n IN a, b;\n OUT out;\n \n PARTS:\n BUILTIN Nand;\n}'};async function h(n){await n.pushd("/projects/01"),await(0,r.cL)(n,l),await n.popd()}async function B(n){await n.pushd("/projects/01"),await c(n,l,".tst"),await c(n,l,".cmp"),await n.popd()}const m={HalfAdder:{"HalfAdder.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/HalfAdder.hdl\n/**\n * Computes the sum of two bits.\n */\nCHIP HalfAdder {\n IN a, b; // 1-bit inputs\n OUT sum, // Right bit of a + b \n carry; // Left bit of a + b\n\n PARTS:\n //// Replace this comment with your code.\n}',"HalfAdder.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/HalfAdder.tst\n\noutput-list a b sum carry;\n\nset a 0,\nset b 0,\neval,\noutput;\n\nset a 0,\nset b 1,\neval,\noutput;\n\nset a 1,\nset b 0,\neval,\noutput;\n\nset a 1,\nset b 1,\neval,\noutput;',"HalfAdder.cmp":"| a | b |sum|car|\n| 0 | 0 | 0 | 0 |\n| 0 | 1 | 1 | 0 |\n| 1 | 0 | 1 | 0 |\n| 1 | 1 | 0 | 1 |"},FullAdder:{"FullAdder.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/FullAdder.hdl\n/**\n * Computes the sum of three bits.\n */\nCHIP FullAdder {\n IN a, b, c; // 1-bit inputs\n OUT sum, // Right bit of a + b + c\n carry; // Left bit of a + b + c\n\n PARTS:\n //// Replace this comment with your code.\n}',"FullAdder.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/FullAdder.tst\n\noutput-list a b c sum carry%B2.1.2;\n\nset a 0,\nset b 0,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset b 1,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset a 1,\nset b 0,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;\n\nset b 1,\nset c 0,\neval,\noutput;\n\nset c 1,\neval,\noutput;',"FullAdder.cmp":"| a | b | c |sum|carry|\n| 0 | 0 | 0 | 0 | 0 |\n| 0 | 0 | 1 | 1 | 0 |\n| 0 | 1 | 0 | 1 | 0 |\n| 0 | 1 | 1 | 0 | 1 |\n| 1 | 0 | 0 | 1 | 0 |\n| 1 | 0 | 1 | 0 | 1 |\n| 1 | 1 | 0 | 0 | 1 |\n| 1 | 1 | 1 | 1 | 1 |"},Add16:{"Add16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Add16.hdl\n/**\n * 16-bit adder: Adds two 16-bit two\'s complement values.\n * The most significant carry bit is ignored.\n */\nCHIP Add16 {\n IN a[16], b[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Add16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Add16.tst\n\noutput-list a%B1.16.1 b%B1.16.1 out%B1.16.1;\n\nset a %B0000000000000000,\nset b %B0000000000000000,\neval,\noutput;\n\nset a %B0000000000000000,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1111111111111111,\nset b %B1111111111111111,\neval,\noutput;\n\nset a %B1010101010101010,\nset b %B0101010101010101,\neval,\noutput;\n\nset a %B0011110011000011,\nset b %B0000111111110000,\neval,\noutput;\n\nset a %B0001001000110100,\nset b %B1001100001110110,\neval,\noutput;',"Add16.cmp":"| a | b | out |\n| 0000000000000000 | 0000000000000000 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1111111111111111 |\n| 1111111111111111 | 1111111111111111 | 1111111111111110 |\n| 1010101010101010 | 0101010101010101 | 1111111111111111 |\n| 0011110011000011 | 0000111111110000 | 0100110010110011 |\n| 0001001000110100 | 1001100001110110 | 1010101010101010 |"},Inc16:{"Inc16.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Inc16.hdl\n/**\n * 16-bit incrementer:\n * out = in + 1\n */\nCHIP Inc16 {\n IN in[16];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Inc16.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/Inc16.tst\n\noutput-list in%B1.16.1 out%B1.16.1;\n\nset in %B0000000000000000, // in = 0\neval,\noutput;\n\nset in %B1111111111111111, // in = -1\neval,\noutput;\n\nset in %B0000000000000101, // in = 5\neval,\noutput;\n\nset in %B1111111111111011, // in = -5\neval,\noutput;',"Inc16.cmp":"| in | out |\n| 0000000000000000 | 0000000000000001 |\n| 1111111111111111 | 0000000000000000 |\n| 0000000000000101 | 0000000000000110 |\n| 1111111111111011 | 1111111111111100 |\n"},ALU:{"ALU.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU.hdl\n/**\n * ALU (Arithmetic Logic Unit):\n * Computes out = one of the following functions:\n * 0, 1, -1,\n * x, y, !x, !y, -x, -y,\n * x + 1, y + 1, x - 1, y - 1,\n * x + y, x - y, y - x,\n * x & y, x | y\n * on the 16-bit inputs x, y,\n * according to the input bits zx, nx, zy, ny, f, no.\n * In addition, computes the two output bits:\n * if (out == 0) zr = 1, else zr = 0\n * if (out < 0) ng = 1, else ng = 0\n */\n// Implementation: Manipulates the x and y inputs\n// and operates on the resulting values, as follows:\n// if (zx == 1) sets x = 0 // 16-bit constant\n// if (nx == 1) sets x = !x // bitwise not\n// if (zy == 1) sets y = 0 // 16-bit constant\n// if (ny == 1) sets y = !y // bitwise not\n// if (f == 1) sets out = x + y // integer 2\'s complement addition\n// if (f == 0) sets out = x & y // bitwise and\n// if (no == 1) sets out = !out // bitwise not\n\nCHIP ALU {\n IN \n x[16], y[16], // 16-bit inputs \n zx, // zero the x input?\n nx, // negate the x input?\n zy, // zero the y input?\n ny, // negate the y input?\n f, // compute (out = x + y) or (out = x & y)?\n no; // negate the out output?\n OUT \n out[16], // 16-bit output\n zr, // if (out == 0) equals 1, else 0\n ng; // if (out < 0) equals 1, else 0\n\n PARTS:\n //// Replace this comment with your code.\n}',"ALU.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU.tst\n\noutput-list x%B1.16.1 y%B1.16.1 zx nx zy ny f no out zr ng;\n\nset x %B0000000000000000, // x = 0\nset y %B1111111111111111; // y = -1\n\n// Compute 0\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute 1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute !x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute !y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute -x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x + 1\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y + 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x - 1\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute y - 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x + y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x - y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y - x\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x & y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute x | y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset x %B000000000010001, // x = 17\nset y %B000000000000011; // y = 3\n\n// Compute 0\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute 1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -1\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute !x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute !y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\n// Compute -x\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute -y\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x + 1\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y + 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x - 1\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute y - 1\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x + y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\n// Compute x - y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute y - x\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\n// Compute x & y\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\n// Compute x | y\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;',"ALU.cmp":"| x | y |zx |nx |zy |ny | f |no | out |zr |ng |\n| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000010001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000011 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111101110 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 1 | 1111111111111100 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 1 | 1111111111101111 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 1 | 1111111111111101 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000010010 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000100 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000010000 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000010 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000010100 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000001110 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111110010 | 0 | 1 |\n| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000001 | 0 | 0 |\n| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000010011 | 0 | 0 |","ALU-basic.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/2/ALU-basic.tst\n\n// Tests the basic version of the ALU chip.\n// DOES NOT replace the final test provided by ALU.tst.\n// Specifically: Tests the ALU logic that computes the 'out' output;\n// The 'zr' and 'ng' output bits are ignored.\n\noutput-list x%B1.16.1 y%B1.16.1 zx nx zy ny f no out%B1.16.1;\n\nset x %B0000000000000000,\nset y %B1111111111111111,\n\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset x %B101101110100000,\nset y %B001111011010010,\n\nset zx 1,\nset nx 0,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 1,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 0,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 1,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 1,\nset ny 1,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 1,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 1,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 0,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 1,\nset f 1,\nset no 1,\neval,\noutput;\n\nset zx 0,\nset nx 0,\nset zy 0,\nset ny 0,\nset f 0,\nset no 0,\neval,\noutput;\n\nset zx 0,\nset nx 1,\nset zy 0,\nset ny 1,\nset f 0,\nset no 1,\neval,\noutput;","ALU-basic.cmp":"| x | y |zx |nx |zy |ny | f |no | out |\n| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 |\n| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 |\n| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 |\n| 0101101110100000 | 0001111011010010 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 0 | 0101101110100000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 0 | 0001111011010010 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 1 | 1010010001011111 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 1 | 1110000100101101 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 1 | 1010010001100000 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 1 | 1110000100101110 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 1 | 1 | 1 | 1 | 0101101110100001 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 1 | 1 | 1 | 0001111011010011 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 0 | 0101101110011111 |\n| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 0 | 0001111011010001 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 1 | 0 | 0111101001110010 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 0 | 1 | 1 | 0011110011001110 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 1 | 1 | 1 | 1100001100110010 |\n| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 0 | 0 | 0001101010000000 |\n| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 1 | 0 | 1 | 0101111111110010 |"}},v={};async function f(n){await n.pushd("/projects/02"),await(0,r.cL)(n,m),await n.popd()}async function M(n){await n.pushd("/projects/02"),await c(n,m,".tst"),await c(n,m,".cmp"),await n.popd()}const y='// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM16K.hdl\n/**\n * Memory of 16K 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM16K {\n IN in[16], load, address[14];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',R={Bit:{"Bit.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Bit.hdl\n/**\n * 1-bit register:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value:\n * if (load(t)) out(t+1) = in(t), else out(t+1) = out(t)\n */\nCHIP Bit {\n IN in, load;\n OUT out;\n\n PARTS:\n //// Replace this comment with your code.\n}',"Bit.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Bit.tst\n\noutput-list time%S1.4.1 in load%B1.1.2 out;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 1,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;',"Bit.cmp":"| time |in |load|out|\n| 0+ | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 |\n| 2 | 0 | 1 | 0 |\n| 2+ | 1 | 0 | 0 |\n| 3 | 1 | 0 | 0 |\n| 3+ | 1 | 1 | 0 |\n| 4 | 1 | 1 | 1 |\n| 4+ | 0 | 0 | 1 |\n| 5 | 0 | 0 | 1 |\n| 5+ | 1 | 0 | 1 |\n| 6 | 1 | 0 | 1 |\n| 6+ | 0 | 1 | 1 |\n| 7 | 0 | 1 | 0 |\n| 7+ | 1 | 1 | 0 |\n| 8 | 1 | 1 | 1 |\n| 8+ | 0 | 0 | 1 |\n| 9 | 0 | 0 | 1 |\n| 9+ | 0 | 0 | 1 |\n| 10 | 0 | 0 | 1 |\n| 10+ | 0 | 0 | 1 |\n| 11 | 0 | 0 | 1 |\n| 11+ | 0 | 0 | 1 |\n| 12 | 0 | 0 | 1 |\n| 12+ | 0 | 0 | 1 |\n| 13 | 0 | 0 | 1 |\n| 13+ | 0 | 0 | 1 |\n| 14 | 0 | 0 | 1 |\n| 14+ | 0 | 0 | 1 |\n| 15 | 0 | 0 | 1 |\n| 15+ | 0 | 0 | 1 |\n| 16 | 0 | 0 | 1 |\n| 16+ | 0 | 0 | 1 |\n| 17 | 0 | 0 | 1 |\n| 17+ | 0 | 0 | 1 |\n| 18 | 0 | 0 | 1 |\n| 18+ | 0 | 0 | 1 |\n| 19 | 0 | 0 | 1 |\n| 19+ | 0 | 0 | 1 |\n| 20 | 0 | 0 | 1 |\n| 20+ | 0 | 0 | 1 |\n| 21 | 0 | 0 | 1 |\n| 21+ | 0 | 0 | 1 |\n| 22 | 0 | 0 | 1 |\n| 22+ | 0 | 0 | 1 |\n| 23 | 0 | 0 | 1 |\n| 23+ | 0 | 0 | 1 |\n| 24 | 0 | 0 | 1 |\n| 24+ | 0 | 0 | 1 |\n| 25 | 0 | 0 | 1 |\n| 25+ | 0 | 0 | 1 |\n| 26 | 0 | 0 | 1 |\n| 26+ | 0 | 0 | 1 |\n| 27 | 0 | 0 | 1 |\n| 27+ | 0 | 0 | 1 |\n| 28 | 0 | 0 | 1 |\n| 28+ | 0 | 0 | 1 |\n| 29 | 0 | 0 | 1 |\n| 29+ | 0 | 0 | 1 |\n| 30 | 0 | 0 | 1 |\n| 30+ | 0 | 0 | 1 |\n| 31 | 0 | 0 | 1 |\n| 31+ | 0 | 0 | 1 |\n| 32 | 0 | 0 | 1 |\n| 32+ | 0 | 0 | 1 |\n| 33 | 0 | 0 | 1 |\n| 33+ | 0 | 0 | 1 |\n| 34 | 0 | 0 | 1 |\n| 34+ | 0 | 0 | 1 |\n| 35 | 0 | 0 | 1 |\n| 35+ | 0 | 0 | 1 |\n| 36 | 0 | 0 | 1 |\n| 36+ | 0 | 0 | 1 |\n| 37 | 0 | 0 | 1 |\n| 37+ | 0 | 0 | 1 |\n| 38 | 0 | 0 | 1 |\n| 38+ | 0 | 0 | 1 |\n| 39 | 0 | 0 | 1 |\n| 39+ | 0 | 0 | 1 |\n| 40 | 0 | 0 | 1 |\n| 40+ | 0 | 0 | 1 |\n| 41 | 0 | 0 | 1 |\n| 41+ | 0 | 0 | 1 |\n| 42 | 0 | 0 | 1 |\n| 42+ | 0 | 0 | 1 |\n| 43 | 0 | 0 | 1 |\n| 43+ | 0 | 0 | 1 |\n| 44 | 0 | 0 | 1 |\n| 44+ | 0 | 0 | 1 |\n| 45 | 0 | 0 | 1 |\n| 45+ | 0 | 0 | 1 |\n| 46 | 0 | 0 | 1 |\n| 46+ | 0 | 0 | 1 |\n| 47 | 0 | 0 | 1 |\n| 47+ | 0 | 0 | 1 |\n| 48 | 0 | 0 | 1 |\n| 48+ | 0 | 0 | 1 |\n| 49 | 0 | 0 | 1 |\n| 49+ | 0 | 0 | 1 |\n| 50 | 0 | 0 | 1 |\n| 50+ | 0 | 0 | 1 |\n| 51 | 0 | 0 | 1 |\n| 51+ | 0 | 0 | 1 |\n| 52 | 0 | 0 | 1 |\n| 52+ | 0 | 0 | 1 |\n| 53 | 0 | 0 | 1 |\n| 53+ | 0 | 0 | 1 |\n| 54 | 0 | 0 | 1 |\n| 54+ | 0 | 0 | 1 |\n| 55 | 0 | 0 | 1 |\n| 55+ | 0 | 0 | 1 |\n| 56 | 0 | 0 | 1 |\n| 56+ | 0 | 0 | 1 |\n| 57 | 0 | 0 | 1 |\n| 57+ | 0 | 1 | 1 |\n| 58 | 0 | 1 | 0 |\n| 58+ | 1 | 0 | 0 |\n| 59 | 1 | 0 | 0 |\n| 59+ | 1 | 0 | 0 |\n| 60 | 1 | 0 | 0 |\n| 60+ | 1 | 0 | 0 |\n| 61 | 1 | 0 | 0 |\n| 61+ | 1 | 0 | 0 |\n| 62 | 1 | 0 | 0 |\n| 62+ | 1 | 0 | 0 |\n| 63 | 1 | 0 | 0 |\n| 63+ | 1 | 0 | 0 |\n| 64 | 1 | 0 | 0 |\n| 64+ | 1 | 0 | 0 |\n| 65 | 1 | 0 | 0 |\n| 65+ | 1 | 0 | 0 |\n| 66 | 1 | 0 | 0 |\n| 66+ | 1 | 0 | 0 |\n| 67 | 1 | 0 | 0 |\n| 67+ | 1 | 0 | 0 |\n| 68 | 1 | 0 | 0 |\n| 68+ | 1 | 0 | 0 |\n| 69 | 1 | 0 | 0 |\n| 69+ | 1 | 0 | 0 |\n| 70 | 1 | 0 | 0 |\n| 70+ | 1 | 0 | 0 |\n| 71 | 1 | 0 | 0 |\n| 71+ | 1 | 0 | 0 |\n| 72 | 1 | 0 | 0 |\n| 72+ | 1 | 0 | 0 |\n| 73 | 1 | 0 | 0 |\n| 73+ | 1 | 0 | 0 |\n| 74 | 1 | 0 | 0 |\n| 74+ | 1 | 0 | 0 |\n| 75 | 1 | 0 | 0 |\n| 75+ | 1 | 0 | 0 |\n| 76 | 1 | 0 | 0 |\n| 76+ | 1 | 0 | 0 |\n| 77 | 1 | 0 | 0 |\n| 77+ | 1 | 0 | 0 |\n| 78 | 1 | 0 | 0 |\n| 78+ | 1 | 0 | 0 |\n| 79 | 1 | 0 | 0 |\n| 79+ | 1 | 0 | 0 |\n| 80 | 1 | 0 | 0 |\n| 80+ | 1 | 0 | 0 |\n| 81 | 1 | 0 | 0 |\n| 81+ | 1 | 0 | 0 |\n| 82 | 1 | 0 | 0 |\n| 82+ | 1 | 0 | 0 |\n| 83 | 1 | 0 | 0 |\n| 83+ | 1 | 0 | 0 |\n| 84 | 1 | 0 | 0 |\n| 84+ | 1 | 0 | 0 |\n| 85 | 1 | 0 | 0 |\n| 85+ | 1 | 0 | 0 |\n| 86 | 1 | 0 | 0 |\n| 86+ | 1 | 0 | 0 |\n| 87 | 1 | 0 | 0 |\n| 87+ | 1 | 0 | 0 |\n| 88 | 1 | 0 | 0 |\n| 88+ | 1 | 0 | 0 |\n| 89 | 1 | 0 | 0 |\n| 89+ | 1 | 0 | 0 |\n| 90 | 1 | 0 | 0 |\n| 90+ | 1 | 0 | 0 |\n| 91 | 1 | 0 | 0 |\n| 91+ | 1 | 0 | 0 |\n| 92 | 1 | 0 | 0 |\n| 92+ | 1 | 0 | 0 |\n| 93 | 1 | 0 | 0 |\n| 93+ | 1 | 0 | 0 |\n| 94 | 1 | 0 | 0 |\n| 94+ | 1 | 0 | 0 |\n| 95 | 1 | 0 | 0 |\n| 95+ | 1 | 0 | 0 |\n| 96 | 1 | 0 | 0 |\n| 96+ | 1 | 0 | 0 |\n| 97 | 1 | 0 | 0 |\n| 97+ | 1 | 0 | 0 |\n| 98 | 1 | 0 | 0 |\n| 98+ | 1 | 0 | 0 |\n| 99 | 1 | 0 | 0 |\n| 99+ | 1 | 0 | 0 |\n| 100 | 1 | 0 | 0 |\n| 100+ | 1 | 0 | 0 |\n| 101 | 1 | 0 | 0 |\n| 101+ | 1 | 0 | 0 |\n| 102 | 1 | 0 | 0 |\n| 102+ | 1 | 0 | 0 |\n| 103 | 1 | 0 | 0 |\n| 103+ | 1 | 0 | 0 |\n| 104 | 1 | 0 | 0 |\n| 104+ | 1 | 0 | 0 |\n| 105 | 1 | 0 | 0 |\n| 105+ | 1 | 0 | 0 |\n| 106 | 1 | 0 | 0 |\n| 106+ | 1 | 0 | 0 |\n| 107 | 1 | 0 | 0 |"},Register:{"Register.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Register.hdl\n/**\n * 16-bit register:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value:\n * if (load(t)) out(t+1) = int(t), else out(t+1) = out(t)\n */\nCHIP Register {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"Register.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/Register.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 out%D1.6.1;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 11111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 12345,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000001,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000010,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000000100,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000001000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000010000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000000100000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000001000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000010000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000000100000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000001000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000010000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0000100000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0001000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0010000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0100000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1000000000000000,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111110,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111101,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111111011,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111110111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111101111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111111011111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111110111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111101111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111111011111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111110111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111101111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1111011111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1110111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1101111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B1011111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in %B0111111111111111,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;',"Register.cmp":"|time | in |load| out |\n| 0+ | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 |\n| 2 | 0 | 1 | 0 |\n| 2+ | -32123 | 0 | 0 |\n| 3 | -32123 | 0 | 0 |\n| 3+ | 11111 | 0 | 0 |\n| 4 | 11111 | 0 | 0 |\n| 4+ | -32123 | 1 | 0 |\n| 5 | -32123 | 1 | -32123 |\n| 5+ | -32123 | 1 | -32123 |\n| 6 | -32123 | 1 | -32123 |\n| 6+ | -32123 | 0 | -32123 |\n| 7 | -32123 | 0 | -32123 |\n| 7+ | 12345 | 1 | -32123 |\n| 8 | 12345 | 1 | 12345 |\n| 8+ | 0 | 0 | 12345 |\n| 9 | 0 | 0 | 12345 |\n| 9+ | 0 | 1 | 12345 |\n| 10 | 0 | 1 | 0 |\n| 10+ | 1 | 0 | 0 |\n| 11 | 1 | 0 | 0 |\n| 11+ | 1 | 1 | 0 |\n| 12 | 1 | 1 | 1 |\n| 12+ | 2 | 0 | 1 |\n| 13 | 2 | 0 | 1 |\n| 13+ | 2 | 1 | 1 |\n| 14 | 2 | 1 | 2 |\n| 14+ | 4 | 0 | 2 |\n| 15 | 4 | 0 | 2 |\n| 15+ | 4 | 1 | 2 |\n| 16 | 4 | 1 | 4 |\n| 16+ | 8 | 0 | 4 |\n| 17 | 8 | 0 | 4 |\n| 17+ | 8 | 1 | 4 |\n| 18 | 8 | 1 | 8 |\n| 18+ | 16 | 0 | 8 |\n| 19 | 16 | 0 | 8 |\n| 19+ | 16 | 1 | 8 |\n| 20 | 16 | 1 | 16 |\n| 20+ | 32 | 0 | 16 |\n| 21 | 32 | 0 | 16 |\n| 21+ | 32 | 1 | 16 |\n| 22 | 32 | 1 | 32 |\n| 22+ | 64 | 0 | 32 |\n| 23 | 64 | 0 | 32 |\n| 23+ | 64 | 1 | 32 |\n| 24 | 64 | 1 | 64 |\n| 24+ | 128 | 0 | 64 |\n| 25 | 128 | 0 | 64 |\n| 25+ | 128 | 1 | 64 |\n| 26 | 128 | 1 | 128 |\n| 26+ | 256 | 0 | 128 |\n| 27 | 256 | 0 | 128 |\n| 27+ | 256 | 1 | 128 |\n| 28 | 256 | 1 | 256 |\n| 28+ | 512 | 0 | 256 |\n| 29 | 512 | 0 | 256 |\n| 29+ | 512 | 1 | 256 |\n| 30 | 512 | 1 | 512 |\n| 30+ | 1024 | 0 | 512 |\n| 31 | 1024 | 0 | 512 |\n| 31+ | 1024 | 1 | 512 |\n| 32 | 1024 | 1 | 1024 |\n| 32+ | 2048 | 0 | 1024 |\n| 33 | 2048 | 0 | 1024 |\n| 33+ | 2048 | 1 | 1024 |\n| 34 | 2048 | 1 | 2048 |\n| 34+ | 4096 | 0 | 2048 |\n| 35 | 4096 | 0 | 2048 |\n| 35+ | 4096 | 1 | 2048 |\n| 36 | 4096 | 1 | 4096 |\n| 36+ | 8192 | 0 | 4096 |\n| 37 | 8192 | 0 | 4096 |\n| 37+ | 8192 | 1 | 4096 |\n| 38 | 8192 | 1 | 8192 |\n| 38+ | 16384 | 0 | 8192 |\n| 39 | 16384 | 0 | 8192 |\n| 39+ | 16384 | 1 | 8192 |\n| 40 | 16384 | 1 | 16384 |\n| 40+ | -32768 | 0 | 16384 |\n| 41 | -32768 | 0 | 16384 |\n| 41+ | -32768 | 1 | 16384 |\n| 42 | -32768 | 1 | -32768 |\n| 42+ | -2 | 0 | -32768 |\n| 43 | -2 | 0 | -32768 |\n| 43+ | -2 | 1 | -32768 |\n| 44 | -2 | 1 | -2 |\n| 44+ | -3 | 0 | -2 |\n| 45 | -3 | 0 | -2 |\n| 45+ | -3 | 1 | -2 |\n| 46 | -3 | 1 | -3 |\n| 46+ | -5 | 0 | -3 |\n| 47 | -5 | 0 | -3 |\n| 47+ | -5 | 1 | -3 |\n| 48 | -5 | 1 | -5 |\n| 48+ | -9 | 0 | -5 |\n| 49 | -9 | 0 | -5 |\n| 49+ | -9 | 1 | -5 |\n| 50 | -9 | 1 | -9 |\n| 50+ | -17 | 0 | -9 |\n| 51 | -17 | 0 | -9 |\n| 51+ | -17 | 1 | -9 |\n| 52 | -17 | 1 | -17 |\n| 52+ | -33 | 0 | -17 |\n| 53 | -33 | 0 | -17 |\n| 53+ | -33 | 1 | -17 |\n| 54 | -33 | 1 | -33 |\n| 54+ | -65 | 0 | -33 |\n| 55 | -65 | 0 | -33 |\n| 55+ | -65 | 1 | -33 |\n| 56 | -65 | 1 | -65 |\n| 56+ | -129 | 0 | -65 |\n| 57 | -129 | 0 | -65 |\n| 57+ | -129 | 1 | -65 |\n| 58 | -129 | 1 | -129 |\n| 58+ | -257 | 0 | -129 |\n| 59 | -257 | 0 | -129 |\n| 59+ | -257 | 1 | -129 |\n| 60 | -257 | 1 | -257 |\n| 60+ | -513 | 0 | -257 |\n| 61 | -513 | 0 | -257 |\n| 61+ | -513 | 1 | -257 |\n| 62 | -513 | 1 | -513 |\n| 62+ | -1025 | 0 | -513 |\n| 63 | -1025 | 0 | -513 |\n| 63+ | -1025 | 1 | -513 |\n| 64 | -1025 | 1 | -1025 |\n| 64+ | -2049 | 0 | -1025 |\n| 65 | -2049 | 0 | -1025 |\n| 65+ | -2049 | 1 | -1025 |\n| 66 | -2049 | 1 | -2049 |\n| 66+ | -4097 | 0 | -2049 |\n| 67 | -4097 | 0 | -2049 |\n| 67+ | -4097 | 1 | -2049 |\n| 68 | -4097 | 1 | -4097 |\n| 68+ | -8193 | 0 | -4097 |\n| 69 | -8193 | 0 | -4097 |\n| 69+ | -8193 | 1 | -4097 |\n| 70 | -8193 | 1 | -8193 |\n| 70+ | -16385 | 0 | -8193 |\n| 71 | -16385 | 0 | -8193 |\n| 71+ | -16385 | 1 | -8193 |\n| 72 | -16385 | 1 | -16385 |\n| 72+ | 32767 | 0 | -16385 |\n| 73 | 32767 | 0 | -16385 |\n| 73+ | 32767 | 1 | -16385 |\n| 74 | 32767 | 1 | 32767 |"},PC:{"PC.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/PC.hdl\n/**\n * A 16-bit counter.\n * if reset(t): out(t+1) = 0\n * else if load(t): out(t+1) = in(t)\n * else if inc(t): out(t+1) = out(t) + 1\n * else out(t+1) = out(t)\n */\nCHIP PC {\n IN in[16], reset, load, inc;\n OUT out[16];\n \n PARTS:\n //// Replace this comment with your code.\n}',"PC.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/03/a/PC.tst\n\noutput-list time%S1.3.1 in%D1.6.1 reset%B2.1.2 load%B2.1.2 inc%B2.1.2 out%D1.6.1;\n\nset in 0,\nset reset 0,\nset load 0,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in -32123,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\ntick,\noutput;\n\ntock,\noutput;\n\nset in 12345,\nset load 1,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 0,\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 0,\nset load 0,\ntick,\noutput;\n\ntock,\noutput;\n\nset reset 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 0,\nset reset 0,\nset load 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset load 0,\nset inc 1,\ntick,\noutput;\n\ntock,\noutput;\n\nset in 22222,\nset reset 1,\nset inc 0,\ntick,\noutput;\n\ntock,\noutput;',"PC.cmp":"|time | in |reset|load | inc | out |\n| 0+ | 0 | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 0 | 0 | 1 | 0 |\n| 2 | 0 | 0 | 0 | 1 | 1 |\n| 2+ | -32123 | 0 | 0 | 1 | 1 |\n| 3 | -32123 | 0 | 0 | 1 | 2 |\n| 3+ | -32123 | 0 | 1 | 1 | 2 |\n| 4 | -32123 | 0 | 1 | 1 | -32123 |\n| 4+ | -32123 | 0 | 0 | 1 | -32123 |\n| 5 | -32123 | 0 | 0 | 1 | -32122 |\n| 5+ | -32123 | 0 | 0 | 1 | -32122 |\n| 6 | -32123 | 0 | 0 | 1 | -32121 |\n| 6+ | 12345 | 0 | 1 | 0 | -32121 |\n| 7 | 12345 | 0 | 1 | 0 | 12345 |\n| 7+ | 12345 | 1 | 1 | 0 | 12345 |\n| 8 | 12345 | 1 | 1 | 0 | 0 |\n| 8+ | 12345 | 0 | 1 | 1 | 0 |\n| 9 | 12345 | 0 | 1 | 1 | 12345 |\n| 9+ | 12345 | 1 | 1 | 1 | 12345 |\n| 10 | 12345 | 1 | 1 | 1 | 0 |\n| 10+ | 12345 | 0 | 0 | 1 | 0 |\n| 11 | 12345 | 0 | 0 | 1 | 1 |\n| 11+ | 12345 | 1 | 0 | 1 | 1 |\n| 12 | 12345 | 1 | 0 | 1 | 0 |\n| 12+ | 0 | 0 | 1 | 1 | 0 |\n| 13 | 0 | 0 | 1 | 1 | 0 |\n| 13+ | 0 | 0 | 0 | 1 | 0 |\n| 14 | 0 | 0 | 0 | 1 | 1 |\n| 14+ | 22222 | 1 | 0 | 0 | 1 |\n| 15 | 22222 | 1 | 0 | 0 | 0 |"},RAM8:{"RAM8.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM8.hdl\n/**\n * Memory of eight 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM8 {\n IN in[16], load, address[3];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM8.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM8.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D3.1.3 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 11111,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 3333,\nset address 3,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 1,\neval,\noutput;\n\nset in 7777,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 7,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 3,\neval,\noutput;\n\nset address 7,\neval,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\ntick,\noutput,\ntock,\noutput;\nset address 2,\ntick,\noutput,\ntock,\noutput;\nset address 3,\ntick,\noutput,\ntock,\noutput;\nset address 4,\ntick,\noutput,\ntock,\noutput;\nset address 5,\ntick,\noutput,\ntock,\noutput;\nset address 6,\ntick,\noutput,\ntock,\noutput;\nset address 7,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 0,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 0,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 1,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 1,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 2,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 2,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 3,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 3,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 4,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 4,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 5,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 5,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 6,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 6,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address 7,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n\nset load 1,\nset address 7,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\nset address 1,\neval,\noutput;\nset address 2,\neval,\noutput;\nset address 3,\neval,\noutput;\nset address 4,\neval,\noutput;\nset address 5,\neval,\noutput;\nset address 6,\neval,\noutput;\nset address 7,\neval,\noutput;\n',"RAM8.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 11111 | 0 | 0 | 0 |\n| 3 | 11111 | 0 | 0 | 0 |\n| 3+ | 11111 | 1 | 1 | 0 |\n| 4 | 11111 | 1 | 1 | 11111 |\n| 4+ | 11111 | 0 | 0 | 0 |\n| 5 | 11111 | 0 | 0 | 0 |\n| 5+ | 3333 | 0 | 3 | 0 |\n| 6 | 3333 | 0 | 3 | 0 |\n| 6+ | 3333 | 1 | 3 | 0 |\n| 7 | 3333 | 1 | 3 | 3333 |\n| 7+ | 3333 | 0 | 3 | 3333 |\n| 8 | 3333 | 0 | 3 | 3333 |\n| 8 | 3333 | 0 | 1 | 11111 |\n| 8+ | 7777 | 0 | 1 | 11111 |\n| 9 | 7777 | 0 | 1 | 11111 |\n| 9+ | 7777 | 1 | 7 | 0 |\n| 10 | 7777 | 1 | 7 | 7777 |\n| 10+ | 7777 | 0 | 7 | 7777 |\n| 11 | 7777 | 0 | 7 | 7777 |\n| 11 | 7777 | 0 | 3 | 3333 |\n| 11 | 7777 | 0 | 7 | 7777 |\n| 11+ | 7777 | 0 | 0 | 0 |\n| 12 | 7777 | 0 | 0 | 0 |\n| 12 | 7777 | 0 | 1 | 11111 |\n| 12 | 7777 | 0 | 2 | 0 |\n| 12 | 7777 | 0 | 3 | 3333 |\n| 12 | 7777 | 0 | 4 | 0 |\n| 12 | 7777 | 0 | 5 | 0 |\n| 12 | 7777 | 0 | 6 | 0 |\n| 12 | 7777 | 0 | 7 | 7777 |\n| 12+ | 21845 | 1 | 0 | 0 |\n| 13 | 21845 | 1 | 0 | 21845 |\n| 13+ | 21845 | 1 | 1 | 11111 |\n| 14 | 21845 | 1 | 1 | 21845 |\n| 14+ | 21845 | 1 | 2 | 0 |\n| 15 | 21845 | 1 | 2 | 21845 |\n| 15+ | 21845 | 1 | 3 | 3333 |\n| 16 | 21845 | 1 | 3 | 21845 |\n| 16+ | 21845 | 1 | 4 | 0 |\n| 17 | 21845 | 1 | 4 | 21845 |\n| 17+ | 21845 | 1 | 5 | 0 |\n| 18 | 21845 | 1 | 5 | 21845 |\n| 18+ | 21845 | 1 | 6 | 0 |\n| 19 | 21845 | 1 | 6 | 21845 |\n| 19+ | 21845 | 1 | 7 | 7777 |\n| 20 | 21845 | 1 | 7 | 21845 |\n| 20+ | 21845 | 0 | 0 | 21845 |\n| 21 | 21845 | 0 | 0 | 21845 |\n| 21 | 21845 | 0 | 1 | 21845 |\n| 21 | 21845 | 0 | 2 | 21845 |\n| 21 | 21845 | 0 | 3 | 21845 |\n| 21 | 21845 | 0 | 4 | 21845 |\n| 21 | 21845 | 0 | 5 | 21845 |\n| 21 | 21845 | 0 | 6 | 21845 |\n| 21 | 21845 | 0 | 7 | 21845 |\n| 21+ | -21846 | 1 | 0 | 21845 |\n| 22 | -21846 | 1 | 0 | -21846 |\n| 22+ | -21846 | 0 | 0 | -21846 |\n| 23 | -21846 | 0 | 0 | -21846 |\n| 23 | -21846 | 0 | 1 | 21845 |\n| 23 | -21846 | 0 | 2 | 21845 |\n| 23 | -21846 | 0 | 3 | 21845 |\n| 23 | -21846 | 0 | 4 | 21845 |\n| 23 | -21846 | 0 | 5 | 21845 |\n| 23 | -21846 | 0 | 6 | 21845 |\n| 23 | -21846 | 0 | 7 | 21845 |\n| 23+ | 21845 | 1 | 0 | -21846 |\n| 24 | 21845 | 1 | 0 | 21845 |\n| 24+ | -21846 | 1 | 1 | 21845 |\n| 25 | -21846 | 1 | 1 | -21846 |\n| 25+ | -21846 | 0 | 0 | 21845 |\n| 26 | -21846 | 0 | 0 | 21845 |\n| 26 | -21846 | 0 | 1 | -21846 |\n| 26 | -21846 | 0 | 2 | 21845 |\n| 26 | -21846 | 0 | 3 | 21845 |\n| 26 | -21846 | 0 | 4 | 21845 |\n| 26 | -21846 | 0 | 5 | 21845 |\n| 26 | -21846 | 0 | 6 | 21845 |\n| 26 | -21846 | 0 | 7 | 21845 |\n| 26+ | 21845 | 1 | 1 | -21846 |\n| 27 | 21845 | 1 | 1 | 21845 |\n| 27+ | -21846 | 1 | 2 | 21845 |\n| 28 | -21846 | 1 | 2 | -21846 |\n| 28+ | -21846 | 0 | 0 | 21845 |\n| 29 | -21846 | 0 | 0 | 21845 |\n| 29 | -21846 | 0 | 1 | 21845 |\n| 29 | -21846 | 0 | 2 | -21846 |\n| 29 | -21846 | 0 | 3 | 21845 |\n| 29 | -21846 | 0 | 4 | 21845 |\n| 29 | -21846 | 0 | 5 | 21845 |\n| 29 | -21846 | 0 | 6 | 21845 |\n| 29 | -21846 | 0 | 7 | 21845 |\n| 29+ | 21845 | 1 | 2 | -21846 |\n| 30 | 21845 | 1 | 2 | 21845 |\n| 30+ | -21846 | 1 | 3 | 21845 |\n| 31 | -21846 | 1 | 3 | -21846 |\n| 31+ | -21846 | 0 | 0 | 21845 |\n| 32 | -21846 | 0 | 0 | 21845 |\n| 32 | -21846 | 0 | 1 | 21845 |\n| 32 | -21846 | 0 | 2 | 21845 |\n| 32 | -21846 | 0 | 3 | -21846 |\n| 32 | -21846 | 0 | 4 | 21845 |\n| 32 | -21846 | 0 | 5 | 21845 |\n| 32 | -21846 | 0 | 6 | 21845 |\n| 32 | -21846 | 0 | 7 | 21845 |\n| 32+ | 21845 | 1 | 3 | -21846 |\n| 33 | 21845 | 1 | 3 | 21845 |\n| 33+ | -21846 | 1 | 4 | 21845 |\n| 34 | -21846 | 1 | 4 | -21846 |\n| 34+ | -21846 | 0 | 0 | 21845 |\n| 35 | -21846 | 0 | 0 | 21845 |\n| 35 | -21846 | 0 | 1 | 21845 |\n| 35 | -21846 | 0 | 2 | 21845 |\n| 35 | -21846 | 0 | 3 | 21845 |\n| 35 | -21846 | 0 | 4 | -21846 |\n| 35 | -21846 | 0 | 5 | 21845 |\n| 35 | -21846 | 0 | 6 | 21845 |\n| 35 | -21846 | 0 | 7 | 21845 |\n| 35+ | 21845 | 1 | 4 | -21846 |\n| 36 | 21845 | 1 | 4 | 21845 |\n| 36+ | -21846 | 1 | 5 | 21845 |\n| 37 | -21846 | 1 | 5 | -21846 |\n| 37+ | -21846 | 0 | 0 | 21845 |\n| 38 | -21846 | 0 | 0 | 21845 |\n| 38 | -21846 | 0 | 1 | 21845 |\n| 38 | -21846 | 0 | 2 | 21845 |\n| 38 | -21846 | 0 | 3 | 21845 |\n| 38 | -21846 | 0 | 4 | 21845 |\n| 38 | -21846 | 0 | 5 | -21846 |\n| 38 | -21846 | 0 | 6 | 21845 |\n| 38 | -21846 | 0 | 7 | 21845 |\n| 38+ | 21845 | 1 | 5 | -21846 |\n| 39 | 21845 | 1 | 5 | 21845 |\n| 39+ | -21846 | 1 | 6 | 21845 |\n| 40 | -21846 | 1 | 6 | -21846 |\n| 40+ | -21846 | 0 | 0 | 21845 |\n| 41 | -21846 | 0 | 0 | 21845 |\n| 41 | -21846 | 0 | 1 | 21845 |\n| 41 | -21846 | 0 | 2 | 21845 |\n| 41 | -21846 | 0 | 3 | 21845 |\n| 41 | -21846 | 0 | 4 | 21845 |\n| 41 | -21846 | 0 | 5 | 21845 |\n| 41 | -21846 | 0 | 6 | -21846 |\n| 41 | -21846 | 0 | 7 | 21845 |\n| 41+ | 21845 | 1 | 6 | -21846 |\n| 42 | 21845 | 1 | 6 | 21845 |\n| 42+ | -21846 | 1 | 7 | 21845 |\n| 43 | -21846 | 1 | 7 | -21846 |\n| 43+ | -21846 | 0 | 0 | 21845 |\n| 44 | -21846 | 0 | 0 | 21845 |\n| 44 | -21846 | 0 | 1 | 21845 |\n| 44 | -21846 | 0 | 2 | 21845 |\n| 44 | -21846 | 0 | 3 | 21845 |\n| 44 | -21846 | 0 | 4 | 21845 |\n| 44 | -21846 | 0 | 5 | 21845 |\n| 44 | -21846 | 0 | 6 | 21845 |\n| 44 | -21846 | 0 | 7 | -21846 |\n| 44+ | 21845 | 1 | 7 | -21846 |\n| 45 | 21845 | 1 | 7 | 21845 |\n| 45+ | 21845 | 0 | 0 | 21845 |\n| 46 | 21845 | 0 | 0 | 21845 |\n| 46 | 21845 | 0 | 1 | 21845 |\n| 46 | 21845 | 0 | 2 | 21845 |\n| 46 | 21845 | 0 | 3 | 21845 |\n| 46 | 21845 | 0 | 4 | 21845 |\n| 46 | 21845 | 0 | 5 | 21845 |\n| 46 | 21845 | 0 | 6 | 21845 |\n| 46 | 21845 | 0 | 7 | 21845 |"},RAM64:{"RAM64.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM64.hdl\n/**\n * Memory of sixty four 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM64 {\n IN in[16], load, address[6];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM64.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/a/RAM64.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.3.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 1313,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 13,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 4747,\nset address 47,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 13,\neval,\noutput;\n\nset in 6363,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 63,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 47,\neval,\noutput;\n\nset address 63,\neval,\noutput;\n\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\ntick,\noutput,\ntock,\noutput;\nset address %B101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101011,\ntick,\noutput,\ntock,\noutput;\nset address %B101100,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\ntick,\noutput,\ntock,\noutput;\nset address %B101110,\ntick,\noutput,\ntock,\noutput;\nset address %B101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\nset load 1,\nset address %B101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101001,\neval,\noutput;\nset address %B101010,\neval,\noutput;\nset address %B101011,\neval,\noutput;\nset address %B101100,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B101110,\neval,\noutput;\nset address %B101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B000101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B000101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B001101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B011101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B100101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B110101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;\n\nset load 1,\nset address %B111101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101,\neval,\noutput;\nset address %B010101,\neval,\noutput;\nset address %B011101,\neval,\noutput;\nset address %B100101,\neval,\noutput;\nset address %B101101,\neval,\noutput;\nset address %B110101,\neval,\noutput;\nset address %B111101,\neval,\noutput;',"RAM64.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 1313 | 0 | 0 | 0 |\n| 3 | 1313 | 0 | 0 | 0 |\n| 3+ | 1313 | 1 | 13 | 0 |\n| 4 | 1313 | 1 | 13 | 1313 |\n| 4+ | 1313 | 0 | 0 | 0 |\n| 5 | 1313 | 0 | 0 | 0 |\n| 5+ | 4747 | 0 | 47 | 0 |\n| 6 | 4747 | 0 | 47 | 0 |\n| 6+ | 4747 | 1 | 47 | 0 |\n| 7 | 4747 | 1 | 47 | 4747 |\n| 7+ | 4747 | 0 | 47 | 4747 |\n| 8 | 4747 | 0 | 47 | 4747 |\n| 8 | 4747 | 0 | 13 | 1313 |\n| 8+ | 6363 | 0 | 13 | 1313 |\n| 9 | 6363 | 0 | 13 | 1313 |\n| 9+ | 6363 | 1 | 63 | 0 |\n| 10 | 6363 | 1 | 63 | 6363 |\n| 10+ | 6363 | 0 | 63 | 6363 |\n| 11 | 6363 | 0 | 63 | 6363 |\n| 11 | 6363 | 0 | 47 | 4747 |\n| 11 | 6363 | 0 | 63 | 6363 |\n| 11+ | 6363 | 0 | 40 | 0 |\n| 12 | 6363 | 0 | 40 | 0 |\n| 12 | 6363 | 0 | 41 | 0 |\n| 12 | 6363 | 0 | 42 | 0 |\n| 12 | 6363 | 0 | 43 | 0 |\n| 12 | 6363 | 0 | 44 | 0 |\n| 12 | 6363 | 0 | 45 | 0 |\n| 12 | 6363 | 0 | 46 | 0 |\n| 12 | 6363 | 0 | 47 | 4747 |\n| 12+ | 21845 | 1 | 40 | 0 |\n| 13 | 21845 | 1 | 40 | 21845 |\n| 13+ | 21845 | 1 | 41 | 0 |\n| 14 | 21845 | 1 | 41 | 21845 |\n| 14+ | 21845 | 1 | 42 | 0 |\n| 15 | 21845 | 1 | 42 | 21845 |\n| 15+ | 21845 | 1 | 43 | 0 |\n| 16 | 21845 | 1 | 43 | 21845 |\n| 16+ | 21845 | 1 | 44 | 0 |\n| 17 | 21845 | 1 | 44 | 21845 |\n| 17+ | 21845 | 1 | 45 | 0 |\n| 18 | 21845 | 1 | 45 | 21845 |\n| 18+ | 21845 | 1 | 46 | 0 |\n| 19 | 21845 | 1 | 46 | 21845 |\n| 19+ | 21845 | 1 | 47 | 4747 |\n| 20 | 21845 | 1 | 47 | 21845 |\n| 20+ | 21845 | 0 | 40 | 21845 |\n| 21 | 21845 | 0 | 40 | 21845 |\n| 21 | 21845 | 0 | 41 | 21845 |\n| 21 | 21845 | 0 | 42 | 21845 |\n| 21 | 21845 | 0 | 43 | 21845 |\n| 21 | 21845 | 0 | 44 | 21845 |\n| 21 | 21845 | 0 | 45 | 21845 |\n| 21 | 21845 | 0 | 46 | 21845 |\n| 21 | 21845 | 0 | 47 | 21845 |\n| 21+ | -21846 | 1 | 40 | 21845 |\n| 22 | -21846 | 1 | 40 | -21846 |\n| 22+ | -21846 | 0 | 40 | -21846 |\n| 23 | -21846 | 0 | 40 | -21846 |\n| 23 | -21846 | 0 | 41 | 21845 |\n| 23 | -21846 | 0 | 42 | 21845 |\n| 23 | -21846 | 0 | 43 | 21845 |\n| 23 | -21846 | 0 | 44 | 21845 |\n| 23 | -21846 | 0 | 45 | 21845 |\n| 23 | -21846 | 0 | 46 | 21845 |\n| 23 | -21846 | 0 | 47 | 21845 |\n| 23+ | 21845 | 1 | 40 | -21846 |\n| 24 | 21845 | 1 | 40 | 21845 |\n| 24+ | -21846 | 1 | 41 | 21845 |\n| 25 | -21846 | 1 | 41 | -21846 |\n| 25+ | -21846 | 0 | 40 | 21845 |\n| 26 | -21846 | 0 | 40 | 21845 |\n| 26 | -21846 | 0 | 41 | -21846 |\n| 26 | -21846 | 0 | 42 | 21845 |\n| 26 | -21846 | 0 | 43 | 21845 |\n| 26 | -21846 | 0 | 44 | 21845 |\n| 26 | -21846 | 0 | 45 | 21845 |\n| 26 | -21846 | 0 | 46 | 21845 |\n| 26 | -21846 | 0 | 47 | 21845 |\n| 26+ | 21845 | 1 | 41 | -21846 |\n| 27 | 21845 | 1 | 41 | 21845 |\n| 27+ | -21846 | 1 | 42 | 21845 |\n| 28 | -21846 | 1 | 42 | -21846 |\n| 28+ | -21846 | 0 | 40 | 21845 |\n| 29 | -21846 | 0 | 40 | 21845 |\n| 29 | -21846 | 0 | 41 | 21845 |\n| 29 | -21846 | 0 | 42 | -21846 |\n| 29 | -21846 | 0 | 43 | 21845 |\n| 29 | -21846 | 0 | 44 | 21845 |\n| 29 | -21846 | 0 | 45 | 21845 |\n| 29 | -21846 | 0 | 46 | 21845 |\n| 29 | -21846 | 0 | 47 | 21845 |\n| 29+ | 21845 | 1 | 42 | -21846 |\n| 30 | 21845 | 1 | 42 | 21845 |\n| 30+ | -21846 | 1 | 43 | 21845 |\n| 31 | -21846 | 1 | 43 | -21846 |\n| 31+ | -21846 | 0 | 40 | 21845 |\n| 32 | -21846 | 0 | 40 | 21845 |\n| 32 | -21846 | 0 | 41 | 21845 |\n| 32 | -21846 | 0 | 42 | 21845 |\n| 32 | -21846 | 0 | 43 | -21846 |\n| 32 | -21846 | 0 | 44 | 21845 |\n| 32 | -21846 | 0 | 45 | 21845 |\n| 32 | -21846 | 0 | 46 | 21845 |\n| 32 | -21846 | 0 | 47 | 21845 |\n| 32+ | 21845 | 1 | 43 | -21846 |\n| 33 | 21845 | 1 | 43 | 21845 |\n| 33+ | -21846 | 1 | 44 | 21845 |\n| 34 | -21846 | 1 | 44 | -21846 |\n| 34+ | -21846 | 0 | 40 | 21845 |\n| 35 | -21846 | 0 | 40 | 21845 |\n| 35 | -21846 | 0 | 41 | 21845 |\n| 35 | -21846 | 0 | 42 | 21845 |\n| 35 | -21846 | 0 | 43 | 21845 |\n| 35 | -21846 | 0 | 44 | -21846 |\n| 35 | -21846 | 0 | 45 | 21845 |\n| 35 | -21846 | 0 | 46 | 21845 |\n| 35 | -21846 | 0 | 47 | 21845 |\n| 35+ | 21845 | 1 | 44 | -21846 |\n| 36 | 21845 | 1 | 44 | 21845 |\n| 36+ | -21846 | 1 | 45 | 21845 |\n| 37 | -21846 | 1 | 45 | -21846 |\n| 37+ | -21846 | 0 | 40 | 21845 |\n| 38 | -21846 | 0 | 40 | 21845 |\n| 38 | -21846 | 0 | 41 | 21845 |\n| 38 | -21846 | 0 | 42 | 21845 |\n| 38 | -21846 | 0 | 43 | 21845 |\n| 38 | -21846 | 0 | 44 | 21845 |\n| 38 | -21846 | 0 | 45 | -21846 |\n| 38 | -21846 | 0 | 46 | 21845 |\n| 38 | -21846 | 0 | 47 | 21845 |\n| 38+ | 21845 | 1 | 45 | -21846 |\n| 39 | 21845 | 1 | 45 | 21845 |\n| 39+ | -21846 | 1 | 46 | 21845 |\n| 40 | -21846 | 1 | 46 | -21846 |\n| 40+ | -21846 | 0 | 40 | 21845 |\n| 41 | -21846 | 0 | 40 | 21845 |\n| 41 | -21846 | 0 | 41 | 21845 |\n| 41 | -21846 | 0 | 42 | 21845 |\n| 41 | -21846 | 0 | 43 | 21845 |\n| 41 | -21846 | 0 | 44 | 21845 |\n| 41 | -21846 | 0 | 45 | 21845 |\n| 41 | -21846 | 0 | 46 | -21846 |\n| 41 | -21846 | 0 | 47 | 21845 |\n| 41+ | 21845 | 1 | 46 | -21846 |\n| 42 | 21845 | 1 | 46 | 21845 |\n| 42+ | -21846 | 1 | 47 | 21845 |\n| 43 | -21846 | 1 | 47 | -21846 |\n| 43+ | -21846 | 0 | 40 | 21845 |\n| 44 | -21846 | 0 | 40 | 21845 |\n| 44 | -21846 | 0 | 41 | 21845 |\n| 44 | -21846 | 0 | 42 | 21845 |\n| 44 | -21846 | 0 | 43 | 21845 |\n| 44 | -21846 | 0 | 44 | 21845 |\n| 44 | -21846 | 0 | 45 | 21845 |\n| 44 | -21846 | 0 | 46 | 21845 |\n| 44 | -21846 | 0 | 47 | -21846 |\n| 44+ | 21845 | 1 | 47 | -21846 |\n| 45 | 21845 | 1 | 47 | 21845 |\n| 45+ | 21845 | 0 | 40 | 21845 |\n| 46 | 21845 | 0 | 40 | 21845 |\n| 46 | 21845 | 0 | 41 | 21845 |\n| 46 | 21845 | 0 | 42 | 21845 |\n| 46 | 21845 | 0 | 43 | 21845 |\n| 46 | 21845 | 0 | 44 | 21845 |\n| 46 | 21845 | 0 | 45 | 21845 |\n| 46 | 21845 | 0 | 46 | 21845 |\n| 46 | 21845 | 0 | 47 | 21845 |\n| 46+ | 21845 | 0 | 5 | 0 |\n| 47 | 21845 | 0 | 5 | 0 |\n| 47 | 21845 | 0 | 13 | 1313 |\n| 47 | 21845 | 0 | 21 | 0 |\n| 47 | 21845 | 0 | 29 | 0 |\n| 47 | 21845 | 0 | 37 | 0 |\n| 47 | 21845 | 0 | 45 | 21845 |\n| 47 | 21845 | 0 | 53 | 0 |\n| 47 | 21845 | 0 | 61 | 0 |\n| 47+ | 21845 | 1 | 5 | 0 |\n| 48 | 21845 | 1 | 5 | 21845 |\n| 48+ | 21845 | 1 | 13 | 1313 |\n| 49 | 21845 | 1 | 13 | 21845 |\n| 49+ | 21845 | 1 | 21 | 0 |\n| 50 | 21845 | 1 | 21 | 21845 |\n| 50+ | 21845 | 1 | 29 | 0 |\n| 51 | 21845 | 1 | 29 | 21845 |\n| 51+ | 21845 | 1 | 37 | 0 |\n| 52 | 21845 | 1 | 37 | 21845 |\n| 52+ | 21845 | 1 | 45 | 21845 |\n| 53 | 21845 | 1 | 45 | 21845 |\n| 53+ | 21845 | 1 | 53 | 0 |\n| 54 | 21845 | 1 | 53 | 21845 |\n| 54+ | 21845 | 1 | 61 | 0 |\n| 55 | 21845 | 1 | 61 | 21845 |\n| 55+ | 21845 | 0 | 5 | 21845 |\n| 56 | 21845 | 0 | 5 | 21845 |\n| 56 | 21845 | 0 | 13 | 21845 |\n| 56 | 21845 | 0 | 21 | 21845 |\n| 56 | 21845 | 0 | 29 | 21845 |\n| 56 | 21845 | 0 | 37 | 21845 |\n| 56 | 21845 | 0 | 45 | 21845 |\n| 56 | 21845 | 0 | 53 | 21845 |\n| 56 | 21845 | 0 | 61 | 21845 |\n| 56+ | -21846 | 1 | 5 | 21845 |\n| 57 | -21846 | 1 | 5 | -21846 |\n| 57+ | -21846 | 0 | 5 | -21846 |\n| 58 | -21846 | 0 | 5 | -21846 |\n| 58 | -21846 | 0 | 13 | 21845 |\n| 58 | -21846 | 0 | 21 | 21845 |\n| 58 | -21846 | 0 | 29 | 21845 |\n| 58 | -21846 | 0 | 37 | 21845 |\n| 58 | -21846 | 0 | 45 | 21845 |\n| 58 | -21846 | 0 | 53 | 21845 |\n| 58 | -21846 | 0 | 61 | 21845 |\n| 58+ | 21845 | 1 | 5 | -21846 |\n| 59 | 21845 | 1 | 5 | 21845 |\n| 59+ | -21846 | 1 | 13 | 21845 |\n| 60 | -21846 | 1 | 13 | -21846 |\n| 60+ | -21846 | 0 | 5 | 21845 |\n| 61 | -21846 | 0 | 5 | 21845 |\n| 61 | -21846 | 0 | 13 | -21846 |\n| 61 | -21846 | 0 | 21 | 21845 |\n| 61 | -21846 | 0 | 29 | 21845 |\n| 61 | -21846 | 0 | 37 | 21845 |\n| 61 | -21846 | 0 | 45 | 21845 |\n| 61 | -21846 | 0 | 53 | 21845 |\n| 61 | -21846 | 0 | 61 | 21845 |\n| 61+ | 21845 | 1 | 13 | -21846 |\n| 62 | 21845 | 1 | 13 | 21845 |\n| 62+ | -21846 | 1 | 21 | 21845 |\n| 63 | -21846 | 1 | 21 | -21846 |\n| 63+ | -21846 | 0 | 5 | 21845 |\n| 64 | -21846 | 0 | 5 | 21845 |\n| 64 | -21846 | 0 | 13 | 21845 |\n| 64 | -21846 | 0 | 21 | -21846 |\n| 64 | -21846 | 0 | 29 | 21845 |\n| 64 | -21846 | 0 | 37 | 21845 |\n| 64 | -21846 | 0 | 45 | 21845 |\n| 64 | -21846 | 0 | 53 | 21845 |\n| 64 | -21846 | 0 | 61 | 21845 |\n| 64+ | 21845 | 1 | 21 | -21846 |\n| 65 | 21845 | 1 | 21 | 21845 |\n| 65+ | -21846 | 1 | 29 | 21845 |\n| 66 | -21846 | 1 | 29 | -21846 |\n| 66+ | -21846 | 0 | 5 | 21845 |\n| 67 | -21846 | 0 | 5 | 21845 |\n| 67 | -21846 | 0 | 13 | 21845 |\n| 67 | -21846 | 0 | 21 | 21845 |\n| 67 | -21846 | 0 | 29 | -21846 |\n| 67 | -21846 | 0 | 37 | 21845 |\n| 67 | -21846 | 0 | 45 | 21845 |\n| 67 | -21846 | 0 | 53 | 21845 |\n| 67 | -21846 | 0 | 61 | 21845 |\n| 67+ | 21845 | 1 | 29 | -21846 |\n| 68 | 21845 | 1 | 29 | 21845 |\n| 68+ | -21846 | 1 | 37 | 21845 |\n| 69 | -21846 | 1 | 37 | -21846 |\n| 69+ | -21846 | 0 | 5 | 21845 |\n| 70 | -21846 | 0 | 5 | 21845 |\n| 70 | -21846 | 0 | 13 | 21845 |\n| 70 | -21846 | 0 | 21 | 21845 |\n| 70 | -21846 | 0 | 29 | 21845 |\n| 70 | -21846 | 0 | 37 | -21846 |\n| 70 | -21846 | 0 | 45 | 21845 |\n| 70 | -21846 | 0 | 53 | 21845 |\n| 70 | -21846 | 0 | 61 | 21845 |\n| 70+ | 21845 | 1 | 37 | -21846 |\n| 71 | 21845 | 1 | 37 | 21845 |\n| 71+ | -21846 | 1 | 45 | 21845 |\n| 72 | -21846 | 1 | 45 | -21846 |\n| 72+ | -21846 | 0 | 5 | 21845 |\n| 73 | -21846 | 0 | 5 | 21845 |\n| 73 | -21846 | 0 | 13 | 21845 |\n| 73 | -21846 | 0 | 21 | 21845 |\n| 73 | -21846 | 0 | 29 | 21845 |\n| 73 | -21846 | 0 | 37 | 21845 |\n| 73 | -21846 | 0 | 45 | -21846 |\n| 73 | -21846 | 0 | 53 | 21845 |\n| 73 | -21846 | 0 | 61 | 21845 |\n| 73+ | 21845 | 1 | 45 | -21846 |\n| 74 | 21845 | 1 | 45 | 21845 |\n| 74+ | -21846 | 1 | 53 | 21845 |\n| 75 | -21846 | 1 | 53 | -21846 |\n| 75+ | -21846 | 0 | 5 | 21845 |\n| 76 | -21846 | 0 | 5 | 21845 |\n| 76 | -21846 | 0 | 13 | 21845 |\n| 76 | -21846 | 0 | 21 | 21845 |\n| 76 | -21846 | 0 | 29 | 21845 |\n| 76 | -21846 | 0 | 37 | 21845 |\n| 76 | -21846 | 0 | 45 | 21845 |\n| 76 | -21846 | 0 | 53 | -21846 |\n| 76 | -21846 | 0 | 61 | 21845 |\n| 76+ | 21845 | 1 | 53 | -21846 |\n| 77 | 21845 | 1 | 53 | 21845 |\n| 77+ | -21846 | 1 | 61 | 21845 |\n| 78 | -21846 | 1 | 61 | -21846 |\n| 78+ | -21846 | 0 | 5 | 21845 |\n| 79 | -21846 | 0 | 5 | 21845 |\n| 79 | -21846 | 0 | 13 | 21845 |\n| 79 | -21846 | 0 | 21 | 21845 |\n| 79 | -21846 | 0 | 29 | 21845 |\n| 79 | -21846 | 0 | 37 | 21845 |\n| 79 | -21846 | 0 | 45 | 21845 |\n| 79 | -21846 | 0 | 53 | 21845 |\n| 79 | -21846 | 0 | 61 | -21846 |\n| 79+ | 21845 | 1 | 61 | -21846 |\n| 80 | 21845 | 1 | 61 | 21845 |\n| 80+ | 21845 | 0 | 5 | 21845 |\n| 81 | 21845 | 0 | 5 | 21845 |\n| 81 | 21845 | 0 | 13 | 21845 |\n| 81 | 21845 | 0 | 21 | 21845 |\n| 81 | 21845 | 0 | 29 | 21845 |\n| 81 | 21845 | 0 | 37 | 21845 |\n| 81 | 21845 | 0 | 45 | 21845 |\n| 81 | 21845 | 0 | 53 | 21845 |\n| 81 | 21845 | 0 | 61 | 21845 |"},RAM512:{"RAM512.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM512.hdl\n/**\n * Memory of 512 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM512 {\n IN in[16], load, address[9];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM512.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM512.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.3.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 13099,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 130,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 4729,\nset address 472,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 130,\neval,\noutput;\n\nset in 5119,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 511,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 472,\neval,\noutput;\n\nset address 511,\neval,\noutput;\n\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\nset load 1,\nset address %B010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B010101001,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B010101011,\neval,\noutput;\nset address %B010101100,\neval,\noutput;\nset address %B010101101,\neval,\noutput;\nset address %B010101110,\neval,\noutput;\nset address %B010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B000101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B000101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B001101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B011101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B100101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B101101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B110101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n\nset load 1,\nset address %B111101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010,\neval,\noutput;\nset address %B010101010,\neval,\noutput;\nset address %B011101010,\neval,\noutput;\nset address %B100101010,\neval,\noutput;\nset address %B101101010,\neval,\noutput;\nset address %B110101010,\neval,\noutput;\nset address %B111101010,\neval,\noutput;\n',"RAM512.cmp":"|time | in |load|address| out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 13099 | 0 | 0 | 0 |\n| 3 | 13099 | 0 | 0 | 0 |\n| 3+ | 13099 | 1 | 130 | 0 |\n| 4 | 13099 | 1 | 130 | 13099 |\n| 4+ | 13099 | 0 | 0 | 0 |\n| 5 | 13099 | 0 | 0 | 0 |\n| 5+ | 4729 | 0 | 472 | 0 |\n| 6 | 4729 | 0 | 472 | 0 |\n| 6+ | 4729 | 1 | 472 | 0 |\n| 7 | 4729 | 1 | 472 | 4729 |\n| 7+ | 4729 | 0 | 472 | 4729 |\n| 8 | 4729 | 0 | 472 | 4729 |\n| 8 | 4729 | 0 | 130 | 13099 |\n| 8+ | 5119 | 0 | 130 | 13099 |\n| 9 | 5119 | 0 | 130 | 13099 |\n| 9+ | 5119 | 1 | 511 | 0 |\n| 10 | 5119 | 1 | 511 | 5119 |\n| 10+ | 5119 | 0 | 511 | 5119 |\n| 11 | 5119 | 0 | 511 | 5119 |\n| 11 | 5119 | 0 | 472 | 4729 |\n| 11 | 5119 | 0 | 511 | 5119 |\n| 11+ | 5119 | 0 | 168 | 0 |\n| 12 | 5119 | 0 | 168 | 0 |\n| 12 | 5119 | 0 | 169 | 0 |\n| 12 | 5119 | 0 | 170 | 0 |\n| 12 | 5119 | 0 | 171 | 0 |\n| 12 | 5119 | 0 | 172 | 0 |\n| 12 | 5119 | 0 | 173 | 0 |\n| 12 | 5119 | 0 | 174 | 0 |\n| 12 | 5119 | 0 | 175 | 0 |\n| 12+ | 21845 | 1 | 168 | 0 |\n| 13 | 21845 | 1 | 168 | 21845 |\n| 13+ | 21845 | 1 | 169 | 0 |\n| 14 | 21845 | 1 | 169 | 21845 |\n| 14+ | 21845 | 1 | 170 | 0 |\n| 15 | 21845 | 1 | 170 | 21845 |\n| 15+ | 21845 | 1 | 171 | 0 |\n| 16 | 21845 | 1 | 171 | 21845 |\n| 16+ | 21845 | 1 | 172 | 0 |\n| 17 | 21845 | 1 | 172 | 21845 |\n| 17+ | 21845 | 1 | 173 | 0 |\n| 18 | 21845 | 1 | 173 | 21845 |\n| 18+ | 21845 | 1 | 174 | 0 |\n| 19 | 21845 | 1 | 174 | 21845 |\n| 19+ | 21845 | 1 | 175 | 0 |\n| 20 | 21845 | 1 | 175 | 21845 |\n| 20+ | 21845 | 0 | 168 | 21845 |\n| 21 | 21845 | 0 | 168 | 21845 |\n| 21 | 21845 | 0 | 169 | 21845 |\n| 21 | 21845 | 0 | 170 | 21845 |\n| 21 | 21845 | 0 | 171 | 21845 |\n| 21 | 21845 | 0 | 172 | 21845 |\n| 21 | 21845 | 0 | 173 | 21845 |\n| 21 | 21845 | 0 | 174 | 21845 |\n| 21 | 21845 | 0 | 175 | 21845 |\n| 21+ | -21846 | 1 | 168 | 21845 |\n| 22 | -21846 | 1 | 168 | -21846 |\n| 22+ | -21846 | 0 | 168 | -21846 |\n| 23 | -21846 | 0 | 168 | -21846 |\n| 23 | -21846 | 0 | 169 | 21845 |\n| 23 | -21846 | 0 | 170 | 21845 |\n| 23 | -21846 | 0 | 171 | 21845 |\n| 23 | -21846 | 0 | 172 | 21845 |\n| 23 | -21846 | 0 | 173 | 21845 |\n| 23 | -21846 | 0 | 174 | 21845 |\n| 23 | -21846 | 0 | 175 | 21845 |\n| 23+ | 21845 | 1 | 168 | -21846 |\n| 24 | 21845 | 1 | 168 | 21845 |\n| 24+ | -21846 | 1 | 169 | 21845 |\n| 25 | -21846 | 1 | 169 | -21846 |\n| 25+ | -21846 | 0 | 168 | 21845 |\n| 26 | -21846 | 0 | 168 | 21845 |\n| 26 | -21846 | 0 | 169 | -21846 |\n| 26 | -21846 | 0 | 170 | 21845 |\n| 26 | -21846 | 0 | 171 | 21845 |\n| 26 | -21846 | 0 | 172 | 21845 |\n| 26 | -21846 | 0 | 173 | 21845 |\n| 26 | -21846 | 0 | 174 | 21845 |\n| 26 | -21846 | 0 | 175 | 21845 |\n| 26+ | 21845 | 1 | 169 | -21846 |\n| 27 | 21845 | 1 | 169 | 21845 |\n| 27+ | -21846 | 1 | 170 | 21845 |\n| 28 | -21846 | 1 | 170 | -21846 |\n| 28+ | -21846 | 0 | 168 | 21845 |\n| 29 | -21846 | 0 | 168 | 21845 |\n| 29 | -21846 | 0 | 169 | 21845 |\n| 29 | -21846 | 0 | 170 | -21846 |\n| 29 | -21846 | 0 | 171 | 21845 |\n| 29 | -21846 | 0 | 172 | 21845 |\n| 29 | -21846 | 0 | 173 | 21845 |\n| 29 | -21846 | 0 | 174 | 21845 |\n| 29 | -21846 | 0 | 175 | 21845 |\n| 29+ | 21845 | 1 | 170 | -21846 |\n| 30 | 21845 | 1 | 170 | 21845 |\n| 30+ | -21846 | 1 | 171 | 21845 |\n| 31 | -21846 | 1 | 171 | -21846 |\n| 31+ | -21846 | 0 | 168 | 21845 |\n| 32 | -21846 | 0 | 168 | 21845 |\n| 32 | -21846 | 0 | 169 | 21845 |\n| 32 | -21846 | 0 | 170 | 21845 |\n| 32 | -21846 | 0 | 171 | -21846 |\n| 32 | -21846 | 0 | 172 | 21845 |\n| 32 | -21846 | 0 | 173 | 21845 |\n| 32 | -21846 | 0 | 174 | 21845 |\n| 32 | -21846 | 0 | 175 | 21845 |\n| 32+ | 21845 | 1 | 171 | -21846 |\n| 33 | 21845 | 1 | 171 | 21845 |\n| 33+ | -21846 | 1 | 172 | 21845 |\n| 34 | -21846 | 1 | 172 | -21846 |\n| 34+ | -21846 | 0 | 168 | 21845 |\n| 35 | -21846 | 0 | 168 | 21845 |\n| 35 | -21846 | 0 | 169 | 21845 |\n| 35 | -21846 | 0 | 170 | 21845 |\n| 35 | -21846 | 0 | 171 | 21845 |\n| 35 | -21846 | 0 | 172 | -21846 |\n| 35 | -21846 | 0 | 173 | 21845 |\n| 35 | -21846 | 0 | 174 | 21845 |\n| 35 | -21846 | 0 | 175 | 21845 |\n| 35+ | 21845 | 1 | 172 | -21846 |\n| 36 | 21845 | 1 | 172 | 21845 |\n| 36+ | -21846 | 1 | 173 | 21845 |\n| 37 | -21846 | 1 | 173 | -21846 |\n| 37+ | -21846 | 0 | 168 | 21845 |\n| 38 | -21846 | 0 | 168 | 21845 |\n| 38 | -21846 | 0 | 169 | 21845 |\n| 38 | -21846 | 0 | 170 | 21845 |\n| 38 | -21846 | 0 | 171 | 21845 |\n| 38 | -21846 | 0 | 172 | 21845 |\n| 38 | -21846 | 0 | 173 | -21846 |\n| 38 | -21846 | 0 | 174 | 21845 |\n| 38 | -21846 | 0 | 175 | 21845 |\n| 38+ | 21845 | 1 | 173 | -21846 |\n| 39 | 21845 | 1 | 173 | 21845 |\n| 39+ | -21846 | 1 | 174 | 21845 |\n| 40 | -21846 | 1 | 174 | -21846 |\n| 40+ | -21846 | 0 | 168 | 21845 |\n| 41 | -21846 | 0 | 168 | 21845 |\n| 41 | -21846 | 0 | 169 | 21845 |\n| 41 | -21846 | 0 | 170 | 21845 |\n| 41 | -21846 | 0 | 171 | 21845 |\n| 41 | -21846 | 0 | 172 | 21845 |\n| 41 | -21846 | 0 | 173 | 21845 |\n| 41 | -21846 | 0 | 174 | -21846 |\n| 41 | -21846 | 0 | 175 | 21845 |\n| 41+ | 21845 | 1 | 174 | -21846 |\n| 42 | 21845 | 1 | 174 | 21845 |\n| 42+ | -21846 | 1 | 175 | 21845 |\n| 43 | -21846 | 1 | 175 | -21846 |\n| 43+ | -21846 | 0 | 168 | 21845 |\n| 44 | -21846 | 0 | 168 | 21845 |\n| 44 | -21846 | 0 | 169 | 21845 |\n| 44 | -21846 | 0 | 170 | 21845 |\n| 44 | -21846 | 0 | 171 | 21845 |\n| 44 | -21846 | 0 | 172 | 21845 |\n| 44 | -21846 | 0 | 173 | 21845 |\n| 44 | -21846 | 0 | 174 | 21845 |\n| 44 | -21846 | 0 | 175 | -21846 |\n| 44+ | 21845 | 1 | 175 | -21846 |\n| 45 | 21845 | 1 | 175 | 21845 |\n| 45+ | 21845 | 0 | 168 | 21845 |\n| 46 | 21845 | 0 | 168 | 21845 |\n| 46 | 21845 | 0 | 169 | 21845 |\n| 46 | 21845 | 0 | 170 | 21845 |\n| 46 | 21845 | 0 | 171 | 21845 |\n| 46 | 21845 | 0 | 172 | 21845 |\n| 46 | 21845 | 0 | 173 | 21845 |\n| 46 | 21845 | 0 | 174 | 21845 |\n| 46 | 21845 | 0 | 175 | 21845 |\n| 46+ | 21845 | 0 | 42 | 0 |\n| 47 | 21845 | 0 | 42 | 0 |\n| 47 | 21845 | 0 | 106 | 0 |\n| 47 | 21845 | 0 | 170 | 21845 |\n| 47 | 21845 | 0 | 234 | 0 |\n| 47 | 21845 | 0 | 298 | 0 |\n| 47 | 21845 | 0 | 362 | 0 |\n| 47 | 21845 | 0 | 426 | 0 |\n| 47 | 21845 | 0 | 490 | 0 |\n| 47+ | 21845 | 1 | 42 | 0 |\n| 48 | 21845 | 1 | 42 | 21845 |\n| 48+ | 21845 | 1 | 106 | 0 |\n| 49 | 21845 | 1 | 106 | 21845 |\n| 49+ | 21845 | 1 | 170 | 21845 |\n| 50 | 21845 | 1 | 170 | 21845 |\n| 50+ | 21845 | 1 | 234 | 0 |\n| 51 | 21845 | 1 | 234 | 21845 |\n| 51+ | 21845 | 1 | 298 | 0 |\n| 52 | 21845 | 1 | 298 | 21845 |\n| 52+ | 21845 | 1 | 362 | 0 |\n| 53 | 21845 | 1 | 362 | 21845 |\n| 53+ | 21845 | 1 | 426 | 0 |\n| 54 | 21845 | 1 | 426 | 21845 |\n| 54+ | 21845 | 1 | 490 | 0 |\n| 55 | 21845 | 1 | 490 | 21845 |\n| 55+ | 21845 | 0 | 42 | 21845 |\n| 56 | 21845 | 0 | 42 | 21845 |\n| 56 | 21845 | 0 | 106 | 21845 |\n| 56 | 21845 | 0 | 170 | 21845 |\n| 56 | 21845 | 0 | 234 | 21845 |\n| 56 | 21845 | 0 | 298 | 21845 |\n| 56 | 21845 | 0 | 362 | 21845 |\n| 56 | 21845 | 0 | 426 | 21845 |\n| 56 | 21845 | 0 | 490 | 21845 |\n| 56+ | -21846 | 1 | 42 | 21845 |\n| 57 | -21846 | 1 | 42 | -21846 |\n| 57+ | -21846 | 0 | 42 | -21846 |\n| 58 | -21846 | 0 | 42 | -21846 |\n| 58 | -21846 | 0 | 106 | 21845 |\n| 58 | -21846 | 0 | 170 | 21845 |\n| 58 | -21846 | 0 | 234 | 21845 |\n| 58 | -21846 | 0 | 298 | 21845 |\n| 58 | -21846 | 0 | 362 | 21845 |\n| 58 | -21846 | 0 | 426 | 21845 |\n| 58 | -21846 | 0 | 490 | 21845 |\n| 58+ | 21845 | 1 | 42 | -21846 |\n| 59 | 21845 | 1 | 42 | 21845 |\n| 59+ | -21846 | 1 | 106 | 21845 |\n| 60 | -21846 | 1 | 106 | -21846 |\n| 60+ | -21846 | 0 | 42 | 21845 |\n| 61 | -21846 | 0 | 42 | 21845 |\n| 61 | -21846 | 0 | 106 | -21846 |\n| 61 | -21846 | 0 | 170 | 21845 |\n| 61 | -21846 | 0 | 234 | 21845 |\n| 61 | -21846 | 0 | 298 | 21845 |\n| 61 | -21846 | 0 | 362 | 21845 |\n| 61 | -21846 | 0 | 426 | 21845 |\n| 61 | -21846 | 0 | 490 | 21845 |\n| 61+ | 21845 | 1 | 106 | -21846 |\n| 62 | 21845 | 1 | 106 | 21845 |\n| 62+ | -21846 | 1 | 170 | 21845 |\n| 63 | -21846 | 1 | 170 | -21846 |\n| 63+ | -21846 | 0 | 42 | 21845 |\n| 64 | -21846 | 0 | 42 | 21845 |\n| 64 | -21846 | 0 | 106 | 21845 |\n| 64 | -21846 | 0 | 170 | -21846 |\n| 64 | -21846 | 0 | 234 | 21845 |\n| 64 | -21846 | 0 | 298 | 21845 |\n| 64 | -21846 | 0 | 362 | 21845 |\n| 64 | -21846 | 0 | 426 | 21845 |\n| 64 | -21846 | 0 | 490 | 21845 |\n| 64+ | 21845 | 1 | 170 | -21846 |\n| 65 | 21845 | 1 | 170 | 21845 |\n| 65+ | -21846 | 1 | 234 | 21845 |\n| 66 | -21846 | 1 | 234 | -21846 |\n| 66+ | -21846 | 0 | 42 | 21845 |\n| 67 | -21846 | 0 | 42 | 21845 |\n| 67 | -21846 | 0 | 106 | 21845 |\n| 67 | -21846 | 0 | 170 | 21845 |\n| 67 | -21846 | 0 | 234 | -21846 |\n| 67 | -21846 | 0 | 298 | 21845 |\n| 67 | -21846 | 0 | 362 | 21845 |\n| 67 | -21846 | 0 | 426 | 21845 |\n| 67 | -21846 | 0 | 490 | 21845 |\n| 67+ | 21845 | 1 | 234 | -21846 |\n| 68 | 21845 | 1 | 234 | 21845 |\n| 68+ | -21846 | 1 | 298 | 21845 |\n| 69 | -21846 | 1 | 298 | -21846 |\n| 69+ | -21846 | 0 | 42 | 21845 |\n| 70 | -21846 | 0 | 42 | 21845 |\n| 70 | -21846 | 0 | 106 | 21845 |\n| 70 | -21846 | 0 | 170 | 21845 |\n| 70 | -21846 | 0 | 234 | 21845 |\n| 70 | -21846 | 0 | 298 | -21846 |\n| 70 | -21846 | 0 | 362 | 21845 |\n| 70 | -21846 | 0 | 426 | 21845 |\n| 70 | -21846 | 0 | 490 | 21845 |\n| 70+ | 21845 | 1 | 298 | -21846 |\n| 71 | 21845 | 1 | 298 | 21845 |\n| 71+ | -21846 | 1 | 362 | 21845 |\n| 72 | -21846 | 1 | 362 | -21846 |\n| 72+ | -21846 | 0 | 42 | 21845 |\n| 73 | -21846 | 0 | 42 | 21845 |\n| 73 | -21846 | 0 | 106 | 21845 |\n| 73 | -21846 | 0 | 170 | 21845 |\n| 73 | -21846 | 0 | 234 | 21845 |\n| 73 | -21846 | 0 | 298 | 21845 |\n| 73 | -21846 | 0 | 362 | -21846 |\n| 73 | -21846 | 0 | 426 | 21845 |\n| 73 | -21846 | 0 | 490 | 21845 |\n| 73+ | 21845 | 1 | 362 | -21846 |\n| 74 | 21845 | 1 | 362 | 21845 |\n| 74+ | -21846 | 1 | 426 | 21845 |\n| 75 | -21846 | 1 | 426 | -21846 |\n| 75+ | -21846 | 0 | 42 | 21845 |\n| 76 | -21846 | 0 | 42 | 21845 |\n| 76 | -21846 | 0 | 106 | 21845 |\n| 76 | -21846 | 0 | 170 | 21845 |\n| 76 | -21846 | 0 | 234 | 21845 |\n| 76 | -21846 | 0 | 298 | 21845 |\n| 76 | -21846 | 0 | 362 | 21845 |\n| 76 | -21846 | 0 | 426 | -21846 |\n| 76 | -21846 | 0 | 490 | 21845 |\n| 76+ | 21845 | 1 | 426 | -21846 |\n| 77 | 21845 | 1 | 426 | 21845 |\n| 77+ | -21846 | 1 | 490 | 21845 |\n| 78 | -21846 | 1 | 490 | -21846 |\n| 78+ | -21846 | 0 | 42 | 21845 |\n| 79 | -21846 | 0 | 42 | 21845 |\n| 79 | -21846 | 0 | 106 | 21845 |\n| 79 | -21846 | 0 | 170 | 21845 |\n| 79 | -21846 | 0 | 234 | 21845 |\n| 79 | -21846 | 0 | 298 | 21845 |\n| 79 | -21846 | 0 | 362 | 21845 |\n| 79 | -21846 | 0 | 426 | 21845 |\n| 79 | -21846 | 0 | 490 | -21846 |\n| 79+ | 21845 | 1 | 490 | -21846 |\n| 80 | 21845 | 1 | 490 | 21845 |\n| 80+ | 21845 | 0 | 42 | 21845 |\n| 81 | 21845 | 0 | 42 | 21845 |\n| 81 | 21845 | 0 | 106 | 21845 |\n| 81 | 21845 | 0 | 170 | 21845 |\n| 81 | 21845 | 0 | 234 | 21845 |\n| 81 | 21845 | 0 | 298 | 21845 |\n| 81 | 21845 | 0 | 362 | 21845 |\n| 81 | 21845 | 0 | 426 | 21845 |\n| 81 | 21845 | 0 | 490 | 21845 |"},RAM4K:{"RAM4K.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM4K.hdl\n/**\n * Memory of 4K 16-bit registers.\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n */\nCHIP RAM4K {\n IN in[16], load, address[12];\n OUT out[16];\n\n PARTS:\n //// Replace this comment with your code.\n}',"RAM4K.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM4K.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.4.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 1111,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 1111,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 3513,\nset address 3513,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 1111,\neval,\noutput;\n\nset in 4095,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 4095,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 3513,\neval,\noutput;\n\nset address 4095,\neval,\noutput;\n\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\nset load 1,\nset address %B101010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B101010101001,\neval,\noutput;\nset address %B101010101010,\neval,\noutput;\nset address %B101010101011,\neval,\noutput;\nset address %B101010101100,\neval,\noutput;\nset address %B101010101101,\neval,\noutput;\nset address %B101010101110,\neval,\noutput;\nset address %B101010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B000101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B000101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B001101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B001101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B011101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B011101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B100101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B100101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B101101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B101101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B111101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;\n\nset load 1,\nset address %B111101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B000101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B001101010101,\neval,\noutput;\nset address %B010101010101,\neval,\noutput;\nset address %B011101010101,\neval,\noutput;\nset address %B100101010101,\neval,\noutput;\nset address %B101101010101,\neval,\noutput;\nset address %B110101010101,\neval,\noutput;\nset address %B111101010101,\neval,\noutput;',"RAM4K.cmp":"|time | in |load|address | out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 1111 | 0 | 0 | 0 |\n| 3 | 1111 | 0 | 0 | 0 |\n| 3+ | 1111 | 1 | 1111 | 0 |\n| 4 | 1111 | 1 | 1111 | 1111 |\n| 4+ | 1111 | 0 | 0 | 0 |\n| 5 | 1111 | 0 | 0 | 0 |\n| 5+ | 3513 | 0 | 3513 | 0 |\n| 6 | 3513 | 0 | 3513 | 0 |\n| 6+ | 3513 | 1 | 3513 | 0 |\n| 7 | 3513 | 1 | 3513 | 3513 |\n| 7+ | 3513 | 0 | 3513 | 3513 |\n| 8 | 3513 | 0 | 3513 | 3513 |\n| 8 | 3513 | 0 | 1111 | 1111 |\n| 8+ | 4095 | 0 | 1111 | 1111 |\n| 9 | 4095 | 0 | 1111 | 1111 |\n| 9+ | 4095 | 1 | 4095 | 0 |\n| 10 | 4095 | 1 | 4095 | 4095 |\n| 10+ | 4095 | 0 | 4095 | 4095 |\n| 11 | 4095 | 0 | 4095 | 4095 |\n| 11 | 4095 | 0 | 3513 | 3513 |\n| 11 | 4095 | 0 | 4095 | 4095 |\n| 11+ | 4095 | 0 | 2728 | 0 |\n| 12 | 4095 | 0 | 2728 | 0 |\n| 12 | 4095 | 0 | 2729 | 0 |\n| 12 | 4095 | 0 | 2730 | 0 |\n| 12 | 4095 | 0 | 2731 | 0 |\n| 12 | 4095 | 0 | 2732 | 0 |\n| 12 | 4095 | 0 | 2733 | 0 |\n| 12 | 4095 | 0 | 2734 | 0 |\n| 12 | 4095 | 0 | 2735 | 0 |\n| 12+ | 21845 | 1 | 2728 | 0 |\n| 13 | 21845 | 1 | 2728 | 21845 |\n| 13+ | 21845 | 1 | 2729 | 0 |\n| 14 | 21845 | 1 | 2729 | 21845 |\n| 14+ | 21845 | 1 | 2730 | 0 |\n| 15 | 21845 | 1 | 2730 | 21845 |\n| 15+ | 21845 | 1 | 2731 | 0 |\n| 16 | 21845 | 1 | 2731 | 21845 |\n| 16+ | 21845 | 1 | 2732 | 0 |\n| 17 | 21845 | 1 | 2732 | 21845 |\n| 17+ | 21845 | 1 | 2733 | 0 |\n| 18 | 21845 | 1 | 2733 | 21845 |\n| 18+ | 21845 | 1 | 2734 | 0 |\n| 19 | 21845 | 1 | 2734 | 21845 |\n| 19+ | 21845 | 1 | 2735 | 0 |\n| 20 | 21845 | 1 | 2735 | 21845 |\n| 20+ | 21845 | 0 | 2728 | 21845 |\n| 21 | 21845 | 0 | 2728 | 21845 |\n| 21 | 21845 | 0 | 2729 | 21845 |\n| 21 | 21845 | 0 | 2730 | 21845 |\n| 21 | 21845 | 0 | 2731 | 21845 |\n| 21 | 21845 | 0 | 2732 | 21845 |\n| 21 | 21845 | 0 | 2733 | 21845 |\n| 21 | 21845 | 0 | 2734 | 21845 |\n| 21 | 21845 | 0 | 2735 | 21845 |\n| 21+ | -21846 | 1 | 2728 | 21845 |\n| 22 | -21846 | 1 | 2728 | -21846 |\n| 22+ | -21846 | 0 | 2728 | -21846 |\n| 23 | -21846 | 0 | 2728 | -21846 |\n| 23 | -21846 | 0 | 2729 | 21845 |\n| 23 | -21846 | 0 | 2730 | 21845 |\n| 23 | -21846 | 0 | 2731 | 21845 |\n| 23 | -21846 | 0 | 2732 | 21845 |\n| 23 | -21846 | 0 | 2733 | 21845 |\n| 23 | -21846 | 0 | 2734 | 21845 |\n| 23 | -21846 | 0 | 2735 | 21845 |\n| 23+ | 21845 | 1 | 2728 | -21846 |\n| 24 | 21845 | 1 | 2728 | 21845 |\n| 24+ | -21846 | 1 | 2729 | 21845 |\n| 25 | -21846 | 1 | 2729 | -21846 |\n| 25+ | -21846 | 0 | 2728 | 21845 |\n| 26 | -21846 | 0 | 2728 | 21845 |\n| 26 | -21846 | 0 | 2729 | -21846 |\n| 26 | -21846 | 0 | 2730 | 21845 |\n| 26 | -21846 | 0 | 2731 | 21845 |\n| 26 | -21846 | 0 | 2732 | 21845 |\n| 26 | -21846 | 0 | 2733 | 21845 |\n| 26 | -21846 | 0 | 2734 | 21845 |\n| 26 | -21846 | 0 | 2735 | 21845 |\n| 26+ | 21845 | 1 | 2729 | -21846 |\n| 27 | 21845 | 1 | 2729 | 21845 |\n| 27+ | -21846 | 1 | 2730 | 21845 |\n| 28 | -21846 | 1 | 2730 | -21846 |\n| 28+ | -21846 | 0 | 2728 | 21845 |\n| 29 | -21846 | 0 | 2728 | 21845 |\n| 29 | -21846 | 0 | 2729 | 21845 |\n| 29 | -21846 | 0 | 2730 | -21846 |\n| 29 | -21846 | 0 | 2731 | 21845 |\n| 29 | -21846 | 0 | 2732 | 21845 |\n| 29 | -21846 | 0 | 2733 | 21845 |\n| 29 | -21846 | 0 | 2734 | 21845 |\n| 29 | -21846 | 0 | 2735 | 21845 |\n| 29+ | 21845 | 1 | 2730 | -21846 |\n| 30 | 21845 | 1 | 2730 | 21845 |\n| 30+ | -21846 | 1 | 2731 | 21845 |\n| 31 | -21846 | 1 | 2731 | -21846 |\n| 31+ | -21846 | 0 | 2728 | 21845 |\n| 32 | -21846 | 0 | 2728 | 21845 |\n| 32 | -21846 | 0 | 2729 | 21845 |\n| 32 | -21846 | 0 | 2730 | 21845 |\n| 32 | -21846 | 0 | 2731 | -21846 |\n| 32 | -21846 | 0 | 2732 | 21845 |\n| 32 | -21846 | 0 | 2733 | 21845 |\n| 32 | -21846 | 0 | 2734 | 21845 |\n| 32 | -21846 | 0 | 2735 | 21845 |\n| 32+ | 21845 | 1 | 2731 | -21846 |\n| 33 | 21845 | 1 | 2731 | 21845 |\n| 33+ | -21846 | 1 | 2732 | 21845 |\n| 34 | -21846 | 1 | 2732 | -21846 |\n| 34+ | -21846 | 0 | 2728 | 21845 |\n| 35 | -21846 | 0 | 2728 | 21845 |\n| 35 | -21846 | 0 | 2729 | 21845 |\n| 35 | -21846 | 0 | 2730 | 21845 |\n| 35 | -21846 | 0 | 2731 | 21845 |\n| 35 | -21846 | 0 | 2732 | -21846 |\n| 35 | -21846 | 0 | 2733 | 21845 |\n| 35 | -21846 | 0 | 2734 | 21845 |\n| 35 | -21846 | 0 | 2735 | 21845 |\n| 35+ | 21845 | 1 | 2732 | -21846 |\n| 36 | 21845 | 1 | 2732 | 21845 |\n| 36+ | -21846 | 1 | 2733 | 21845 |\n| 37 | -21846 | 1 | 2733 | -21846 |\n| 37+ | -21846 | 0 | 2728 | 21845 |\n| 38 | -21846 | 0 | 2728 | 21845 |\n| 38 | -21846 | 0 | 2729 | 21845 |\n| 38 | -21846 | 0 | 2730 | 21845 |\n| 38 | -21846 | 0 | 2731 | 21845 |\n| 38 | -21846 | 0 | 2732 | 21845 |\n| 38 | -21846 | 0 | 2733 | -21846 |\n| 38 | -21846 | 0 | 2734 | 21845 |\n| 38 | -21846 | 0 | 2735 | 21845 |\n| 38+ | 21845 | 1 | 2733 | -21846 |\n| 39 | 21845 | 1 | 2733 | 21845 |\n| 39+ | -21846 | 1 | 2734 | 21845 |\n| 40 | -21846 | 1 | 2734 | -21846 |\n| 40+ | -21846 | 0 | 2728 | 21845 |\n| 41 | -21846 | 0 | 2728 | 21845 |\n| 41 | -21846 | 0 | 2729 | 21845 |\n| 41 | -21846 | 0 | 2730 | 21845 |\n| 41 | -21846 | 0 | 2731 | 21845 |\n| 41 | -21846 | 0 | 2732 | 21845 |\n| 41 | -21846 | 0 | 2733 | 21845 |\n| 41 | -21846 | 0 | 2734 | -21846 |\n| 41 | -21846 | 0 | 2735 | 21845 |\n| 41+ | 21845 | 1 | 2734 | -21846 |\n| 42 | 21845 | 1 | 2734 | 21845 |\n| 42+ | -21846 | 1 | 2735 | 21845 |\n| 43 | -21846 | 1 | 2735 | -21846 |\n| 43+ | -21846 | 0 | 2728 | 21845 |\n| 44 | -21846 | 0 | 2728 | 21845 |\n| 44 | -21846 | 0 | 2729 | 21845 |\n| 44 | -21846 | 0 | 2730 | 21845 |\n| 44 | -21846 | 0 | 2731 | 21845 |\n| 44 | -21846 | 0 | 2732 | 21845 |\n| 44 | -21846 | 0 | 2733 | 21845 |\n| 44 | -21846 | 0 | 2734 | 21845 |\n| 44 | -21846 | 0 | 2735 | -21846 |\n| 44+ | 21845 | 1 | 2735 | -21846 |\n| 45 | 21845 | 1 | 2735 | 21845 |\n| 45+ | 21845 | 0 | 2728 | 21845 |\n| 46 | 21845 | 0 | 2728 | 21845 |\n| 46 | 21845 | 0 | 2729 | 21845 |\n| 46 | 21845 | 0 | 2730 | 21845 |\n| 46 | 21845 | 0 | 2731 | 21845 |\n| 46 | 21845 | 0 | 2732 | 21845 |\n| 46 | 21845 | 0 | 2733 | 21845 |\n| 46 | 21845 | 0 | 2734 | 21845 |\n| 46 | 21845 | 0 | 2735 | 21845 |\n| 46+ | 21845 | 0 | 341 | 0 |\n| 47 | 21845 | 0 | 341 | 0 |\n| 47 | 21845 | 0 | 853 | 0 |\n| 47 | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 1877 | 0 |\n| 47 | 21845 | 0 | 2389 | 0 |\n| 47 | 21845 | 0 | 2901 | 0 |\n| 47 | 21845 | 0 | 3413 | 0 |\n| 47 | 21845 | 0 | 3925 | 0 |\n| 47+ | 21845 | 1 | 341 | 0 |\n| 48 | 21845 | 1 | 341 | 21845 |\n| 48+ | 21845 | 1 | 853 | 0 |\n| 49 | 21845 | 1 | 853 | 21845 |\n| 49+ | 21845 | 1 | 1365 | 0 |\n| 50 | 21845 | 1 | 1365 | 21845 |\n| 50+ | 21845 | 1 | 1877 | 0 |\n| 51 | 21845 | 1 | 1877 | 21845 |\n| 51+ | 21845 | 1 | 2389 | 0 |\n| 52 | 21845 | 1 | 2389 | 21845 |\n| 52+ | 21845 | 1 | 2901 | 0 |\n| 53 | 21845 | 1 | 2901 | 21845 |\n| 53+ | 21845 | 1 | 3413 | 0 |\n| 54 | 21845 | 1 | 3413 | 21845 |\n| 54+ | 21845 | 1 | 3925 | 0 |\n| 55 | 21845 | 1 | 3925 | 21845 |\n| 55+ | 21845 | 0 | 341 | 21845 |\n| 56 | 21845 | 0 | 341 | 21845 |\n| 56 | 21845 | 0 | 853 | 21845 |\n| 56 | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 1877 | 21845 |\n| 56 | 21845 | 0 | 2389 | 21845 |\n| 56 | 21845 | 0 | 2901 | 21845 |\n| 56 | 21845 | 0 | 3413 | 21845 |\n| 56 | 21845 | 0 | 3925 | 21845 |\n| 56+ | -21846 | 1 | 341 | 21845 |\n| 57 | -21846 | 1 | 341 | -21846 |\n| 57+ | -21846 | 0 | 341 | -21846 |\n| 58 | -21846 | 0 | 341 | -21846 |\n| 58 | -21846 | 0 | 853 | 21845 |\n| 58 | -21846 | 0 | 1365 | 21845 |\n| 58 | -21846 | 0 | 1877 | 21845 |\n| 58 | -21846 | 0 | 2389 | 21845 |\n| 58 | -21846 | 0 | 2901 | 21845 |\n| 58 | -21846 | 0 | 3413 | 21845 |\n| 58 | -21846 | 0 | 3925 | 21845 |\n| 58+ | 21845 | 1 | 341 | -21846 |\n| 59 | 21845 | 1 | 341 | 21845 |\n| 59+ | -21846 | 1 | 853 | 21845 |\n| 60 | -21846 | 1 | 853 | -21846 |\n| 60+ | -21846 | 0 | 341 | 21845 |\n| 61 | -21846 | 0 | 341 | 21845 |\n| 61 | -21846 | 0 | 853 | -21846 |\n| 61 | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 1877 | 21845 |\n| 61 | -21846 | 0 | 2389 | 21845 |\n| 61 | -21846 | 0 | 2901 | 21845 |\n| 61 | -21846 | 0 | 3413 | 21845 |\n| 61 | -21846 | 0 | 3925 | 21845 |\n| 61+ | 21845 | 1 | 853 | -21846 |\n| 62 | 21845 | 1 | 853 | 21845 |\n| 62+ | -21846 | 1 | 1365 | 21845 |\n| 63 | -21846 | 1 | 1365 | -21846 |\n| 63+ | -21846 | 0 | 341 | 21845 |\n| 64 | -21846 | 0 | 341 | 21845 |\n| 64 | -21846 | 0 | 853 | 21845 |\n| 64 | -21846 | 0 | 1365 | -21846 |\n| 64 | -21846 | 0 | 1877 | 21845 |\n| 64 | -21846 | 0 | 2389 | 21845 |\n| 64 | -21846 | 0 | 2901 | 21845 |\n| 64 | -21846 | 0 | 3413 | 21845 |\n| 64 | -21846 | 0 | 3925 | 21845 |\n| 64+ | 21845 | 1 | 1365 | -21846 |\n| 65 | 21845 | 1 | 1365 | 21845 |\n| 65+ | -21846 | 1 | 1877 | 21845 |\n| 66 | -21846 | 1 | 1877 | -21846 |\n| 66+ | -21846 | 0 | 341 | 21845 |\n| 67 | -21846 | 0 | 341 | 21845 |\n| 67 | -21846 | 0 | 853 | 21845 |\n| 67 | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 1877 | -21846 |\n| 67 | -21846 | 0 | 2389 | 21845 |\n| 67 | -21846 | 0 | 2901 | 21845 |\n| 67 | -21846 | 0 | 3413 | 21845 |\n| 67 | -21846 | 0 | 3925 | 21845 |\n| 67+ | 21845 | 1 | 1877 | -21846 |\n| 68 | 21845 | 1 | 1877 | 21845 |\n| 68+ | -21846 | 1 | 2389 | 21845 |\n| 69 | -21846 | 1 | 2389 | -21846 |\n| 69+ | -21846 | 0 | 341 | 21845 |\n| 70 | -21846 | 0 | 341 | 21845 |\n| 70 | -21846 | 0 | 853 | 21845 |\n| 70 | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 1877 | 21845 |\n| 70 | -21846 | 0 | 2389 | -21846 |\n| 70 | -21846 | 0 | 2901 | 21845 |\n| 70 | -21846 | 0 | 3413 | 21845 |\n| 70 | -21846 | 0 | 3925 | 21845 |\n| 70+ | 21845 | 1 | 2389 | -21846 |\n| 71 | 21845 | 1 | 2389 | 21845 |\n| 71+ | -21846 | 1 | 2901 | 21845 |\n| 72 | -21846 | 1 | 2901 | -21846 |\n| 72+ | -21846 | 0 | 341 | 21845 |\n| 73 | -21846 | 0 | 341 | 21845 |\n| 73 | -21846 | 0 | 853 | 21845 |\n| 73 | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 1877 | 21845 |\n| 73 | -21846 | 0 | 2389 | 21845 |\n| 73 | -21846 | 0 | 2901 | -21846 |\n| 73 | -21846 | 0 | 3413 | 21845 |\n| 73 | -21846 | 0 | 3925 | 21845 |\n| 73+ | 21845 | 1 | 2901 | -21846 |\n| 74 | 21845 | 1 | 2901 | 21845 |\n| 74+ | -21846 | 1 | 3413 | 21845 |\n| 75 | -21846 | 1 | 3413 | -21846 |\n| 75+ | -21846 | 0 | 341 | 21845 |\n| 76 | -21846 | 0 | 341 | 21845 |\n| 76 | -21846 | 0 | 853 | 21845 |\n| 76 | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 1877 | 21845 |\n| 76 | -21846 | 0 | 2389 | 21845 |\n| 76 | -21846 | 0 | 2901 | 21845 |\n| 76 | -21846 | 0 | 3413 | -21846 |\n| 76 | -21846 | 0 | 3925 | 21845 |\n| 76+ | 21845 | 1 | 3413 | -21846 |\n| 77 | 21845 | 1 | 3413 | 21845 |\n| 77+ | -21846 | 1 | 3925 | 21845 |\n| 78 | -21846 | 1 | 3925 | -21846 |\n| 78+ | -21846 | 0 | 341 | 21845 |\n| 79 | -21846 | 0 | 341 | 21845 |\n| 79 | -21846 | 0 | 853 | 21845 |\n| 79 | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 1877 | 21845 |\n| 79 | -21846 | 0 | 2389 | 21845 |\n| 79 | -21846 | 0 | 2901 | 21845 |\n| 79 | -21846 | 0 | 3413 | 21845 |\n| 79 | -21846 | 0 | 3925 | -21846 |\n| 79+ | 21845 | 1 | 3925 | -21846 |\n| 80 | 21845 | 1 | 3925 | 21845 |\n| 80+ | 21845 | 0 | 341 | 21845 |\n| 81 | 21845 | 0 | 341 | 21845 |\n| 81 | 21845 | 0 | 853 | 21845 |\n| 81 | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 1877 | 21845 |\n| 81 | 21845 | 0 | 2389 | 21845 |\n| 81 | 21845 | 0 | 2901 | 21845 |\n| 81 | 21845 | 0 | 3413 | 21845 |\n| 81 | 21845 | 0 | 3925 | 21845 |"},RAM16K:{"RAM16K.hdl":y,"RAM16K.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/3/b/RAM16K.tst\n\noutput-list time%S1.3.1 in%D1.6.1 load%B2.1.1 address%D2.5.2 out%D1.6.1;\n\nset in 0,\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset in 4321,\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 4321,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 12345,\nset address 12345,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 4321,\neval,\noutput;\n\nset in 16383,\ntick,\noutput;\ntock,\noutput;\n\nset load 1,\nset address 16383,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 12345,\neval,\noutput;\n\nset address 16383,\neval,\noutput;\n\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101010,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101011,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101100,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101110,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101111,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101000,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101000,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101001,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101001,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101010,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101010,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101011,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101011,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101100,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101100,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101110,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101110,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10101010101111,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\nset load 1,\nset address %B10101010101111,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B10101010101000,\ntick,\noutput;\ntock,\noutput;\nset address %B10101010101001,\neval,\noutput;\nset address %B10101010101010,\neval,\noutput;\nset address %B10101010101011,\neval,\noutput;\nset address %B10101010101100,\neval,\noutput;\nset address %B10101010101101,\neval,\noutput;\nset address %B10101010101110,\neval,\noutput;\nset address %B10101010101111,\neval,\noutput;\n\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset in %B0101010101010101,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10110101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11110101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B00110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B00110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B01010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B01110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B01110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B10010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B10110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B10110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11010101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B11010101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\nset address %B11110101010101,\nset in %B1010101010101010,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;\n\nset load 1,\nset address %B11110101010101,\nset in %B0101010101010101,\ntick,\noutput,\ntock,\noutput;\n\nset load 0,\nset address %B00010101010101,\ntick,\noutput;\ntock,\noutput;\nset address %B00110101010101,\neval,\noutput;\nset address %B01010101010101,\neval,\noutput;\nset address %B01110101010101,\neval,\noutput;\nset address %B10010101010101,\neval,\noutput;\nset address %B10110101010101,\neval,\noutput;\nset address %B11010101010101,\neval,\noutput;\nset address %B11110101010101,\neval,\noutput;',"RAM16K.cmp":"|time | in |load| address | out |\n| 0+ | 0 | 0 | 0 | 0 |\n| 1 | 0 | 0 | 0 | 0 |\n| 1+ | 0 | 1 | 0 | 0 |\n| 2 | 0 | 1 | 0 | 0 |\n| 2+ | 4321 | 0 | 0 | 0 |\n| 3 | 4321 | 0 | 0 | 0 |\n| 3+ | 4321 | 1 | 4321 | 0 |\n| 4 | 4321 | 1 | 4321 | 4321 |\n| 4+ | 4321 | 0 | 0 | 0 |\n| 5 | 4321 | 0 | 0 | 0 |\n| 5+ | 12345 | 0 | 12345 | 0 |\n| 6 | 12345 | 0 | 12345 | 0 |\n| 6+ | 12345 | 1 | 12345 | 0 |\n| 7 | 12345 | 1 | 12345 | 12345 |\n| 7+ | 12345 | 0 | 12345 | 12345 |\n| 8 | 12345 | 0 | 12345 | 12345 |\n| 8 | 12345 | 0 | 4321 | 4321 |\n| 8+ | 16383 | 0 | 4321 | 4321 |\n| 9 | 16383 | 0 | 4321 | 4321 |\n| 9+ | 16383 | 1 | 16383 | 0 |\n| 10 | 16383 | 1 | 16383 | 16383 |\n| 10+ | 16383 | 0 | 16383 | 16383 |\n| 11 | 16383 | 0 | 16383 | 16383 |\n| 11 | 16383 | 0 | 12345 | 12345 |\n| 11 | 16383 | 0 | 16383 | 16383 |\n| 11+ | 16383 | 0 | 10920 | 0 |\n| 12 | 16383 | 0 | 10920 | 0 |\n| 12 | 16383 | 0 | 10921 | 0 |\n| 12 | 16383 | 0 | 10922 | 0 |\n| 12 | 16383 | 0 | 10923 | 0 |\n| 12 | 16383 | 0 | 10924 | 0 |\n| 12 | 16383 | 0 | 10925 | 0 |\n| 12 | 16383 | 0 | 10926 | 0 |\n| 12 | 16383 | 0 | 10927 | 0 |\n| 12+ | 21845 | 1 | 10920 | 0 |\n| 13 | 21845 | 1 | 10920 | 21845 |\n| 13+ | 21845 | 1 | 10921 | 0 |\n| 14 | 21845 | 1 | 10921 | 21845 |\n| 14+ | 21845 | 1 | 10922 | 0 |\n| 15 | 21845 | 1 | 10922 | 21845 |\n| 15+ | 21845 | 1 | 10923 | 0 |\n| 16 | 21845 | 1 | 10923 | 21845 |\n| 16+ | 21845 | 1 | 10924 | 0 |\n| 17 | 21845 | 1 | 10924 | 21845 |\n| 17+ | 21845 | 1 | 10925 | 0 |\n| 18 | 21845 | 1 | 10925 | 21845 |\n| 18+ | 21845 | 1 | 10926 | 0 |\n| 19 | 21845 | 1 | 10926 | 21845 |\n| 19+ | 21845 | 1 | 10927 | 0 |\n| 20 | 21845 | 1 | 10927 | 21845 |\n| 20+ | 21845 | 0 | 10920 | 21845 |\n| 21 | 21845 | 0 | 10920 | 21845 |\n| 21 | 21845 | 0 | 10921 | 21845 |\n| 21 | 21845 | 0 | 10922 | 21845 |\n| 21 | 21845 | 0 | 10923 | 21845 |\n| 21 | 21845 | 0 | 10924 | 21845 |\n| 21 | 21845 | 0 | 10925 | 21845 |\n| 21 | 21845 | 0 | 10926 | 21845 |\n| 21 | 21845 | 0 | 10927 | 21845 |\n| 21+ | -21846 | 1 | 10920 | 21845 |\n| 22 | -21846 | 1 | 10920 | -21846 |\n| 22+ | -21846 | 0 | 10920 | -21846 |\n| 23 | -21846 | 0 | 10920 | -21846 |\n| 23 | -21846 | 0 | 10921 | 21845 |\n| 23 | -21846 | 0 | 10922 | 21845 |\n| 23 | -21846 | 0 | 10923 | 21845 |\n| 23 | -21846 | 0 | 10924 | 21845 |\n| 23 | -21846 | 0 | 10925 | 21845 |\n| 23 | -21846 | 0 | 10926 | 21845 |\n| 23 | -21846 | 0 | 10927 | 21845 |\n| 23+ | 21845 | 1 | 10920 | -21846 |\n| 24 | 21845 | 1 | 10920 | 21845 |\n| 24+ | -21846 | 1 | 10921 | 21845 |\n| 25 | -21846 | 1 | 10921 | -21846 |\n| 25+ | -21846 | 0 | 10920 | 21845 |\n| 26 | -21846 | 0 | 10920 | 21845 |\n| 26 | -21846 | 0 | 10921 | -21846 |\n| 26 | -21846 | 0 | 10922 | 21845 |\n| 26 | -21846 | 0 | 10923 | 21845 |\n| 26 | -21846 | 0 | 10924 | 21845 |\n| 26 | -21846 | 0 | 10925 | 21845 |\n| 26 | -21846 | 0 | 10926 | 21845 |\n| 26 | -21846 | 0 | 10927 | 21845 |\n| 26+ | 21845 | 1 | 10921 | -21846 |\n| 27 | 21845 | 1 | 10921 | 21845 |\n| 27+ | -21846 | 1 | 10922 | 21845 |\n| 28 | -21846 | 1 | 10922 | -21846 |\n| 28+ | -21846 | 0 | 10920 | 21845 |\n| 29 | -21846 | 0 | 10920 | 21845 |\n| 29 | -21846 | 0 | 10921 | 21845 |\n| 29 | -21846 | 0 | 10922 | -21846 |\n| 29 | -21846 | 0 | 10923 | 21845 |\n| 29 | -21846 | 0 | 10924 | 21845 |\n| 29 | -21846 | 0 | 10925 | 21845 |\n| 29 | -21846 | 0 | 10926 | 21845 |\n| 29 | -21846 | 0 | 10927 | 21845 |\n| 29+ | 21845 | 1 | 10922 | -21846 |\n| 30 | 21845 | 1 | 10922 | 21845 |\n| 30+ | -21846 | 1 | 10923 | 21845 |\n| 31 | -21846 | 1 | 10923 | -21846 |\n| 31+ | -21846 | 0 | 10920 | 21845 |\n| 32 | -21846 | 0 | 10920 | 21845 |\n| 32 | -21846 | 0 | 10921 | 21845 |\n| 32 | -21846 | 0 | 10922 | 21845 |\n| 32 | -21846 | 0 | 10923 | -21846 |\n| 32 | -21846 | 0 | 10924 | 21845 |\n| 32 | -21846 | 0 | 10925 | 21845 |\n| 32 | -21846 | 0 | 10926 | 21845 |\n| 32 | -21846 | 0 | 10927 | 21845 |\n| 32+ | 21845 | 1 | 10923 | -21846 |\n| 33 | 21845 | 1 | 10923 | 21845 |\n| 33+ | -21846 | 1 | 10924 | 21845 |\n| 34 | -21846 | 1 | 10924 | -21846 |\n| 34+ | -21846 | 0 | 10920 | 21845 |\n| 35 | -21846 | 0 | 10920 | 21845 |\n| 35 | -21846 | 0 | 10921 | 21845 |\n| 35 | -21846 | 0 | 10922 | 21845 |\n| 35 | -21846 | 0 | 10923 | 21845 |\n| 35 | -21846 | 0 | 10924 | -21846 |\n| 35 | -21846 | 0 | 10925 | 21845 |\n| 35 | -21846 | 0 | 10926 | 21845 |\n| 35 | -21846 | 0 | 10927 | 21845 |\n| 35+ | 21845 | 1 | 10924 | -21846 |\n| 36 | 21845 | 1 | 10924 | 21845 |\n| 36+ | -21846 | 1 | 10925 | 21845 |\n| 37 | -21846 | 1 | 10925 | -21846 |\n| 37+ | -21846 | 0 | 10920 | 21845 |\n| 38 | -21846 | 0 | 10920 | 21845 |\n| 38 | -21846 | 0 | 10921 | 21845 |\n| 38 | -21846 | 0 | 10922 | 21845 |\n| 38 | -21846 | 0 | 10923 | 21845 |\n| 38 | -21846 | 0 | 10924 | 21845 |\n| 38 | -21846 | 0 | 10925 | -21846 |\n| 38 | -21846 | 0 | 10926 | 21845 |\n| 38 | -21846 | 0 | 10927 | 21845 |\n| 38+ | 21845 | 1 | 10925 | -21846 |\n| 39 | 21845 | 1 | 10925 | 21845 |\n| 39+ | -21846 | 1 | 10926 | 21845 |\n| 40 | -21846 | 1 | 10926 | -21846 |\n| 40+ | -21846 | 0 | 10920 | 21845 |\n| 41 | -21846 | 0 | 10920 | 21845 |\n| 41 | -21846 | 0 | 10921 | 21845 |\n| 41 | -21846 | 0 | 10922 | 21845 |\n| 41 | -21846 | 0 | 10923 | 21845 |\n| 41 | -21846 | 0 | 10924 | 21845 |\n| 41 | -21846 | 0 | 10925 | 21845 |\n| 41 | -21846 | 0 | 10926 | -21846 |\n| 41 | -21846 | 0 | 10927 | 21845 |\n| 41+ | 21845 | 1 | 10926 | -21846 |\n| 42 | 21845 | 1 | 10926 | 21845 |\n| 42+ | -21846 | 1 | 10927 | 21845 |\n| 43 | -21846 | 1 | 10927 | -21846 |\n| 43+ | -21846 | 0 | 10920 | 21845 |\n| 44 | -21846 | 0 | 10920 | 21845 |\n| 44 | -21846 | 0 | 10921 | 21845 |\n| 44 | -21846 | 0 | 10922 | 21845 |\n| 44 | -21846 | 0 | 10923 | 21845 |\n| 44 | -21846 | 0 | 10924 | 21845 |\n| 44 | -21846 | 0 | 10925 | 21845 |\n| 44 | -21846 | 0 | 10926 | 21845 |\n| 44 | -21846 | 0 | 10927 | -21846 |\n| 44+ | 21845 | 1 | 10927 | -21846 |\n| 45 | 21845 | 1 | 10927 | 21845 |\n| 45+ | 21845 | 0 | 10920 | 21845 |\n| 46 | 21845 | 0 | 10920 | 21845 |\n| 46 | 21845 | 0 | 10921 | 21845 |\n| 46 | 21845 | 0 | 10922 | 21845 |\n| 46 | 21845 | 0 | 10923 | 21845 |\n| 46 | 21845 | 0 | 10924 | 21845 |\n| 46 | 21845 | 0 | 10925 | 21845 |\n| 46 | 21845 | 0 | 10926 | 21845 |\n| 46 | 21845 | 0 | 10927 | 21845 |\n| 46+ | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 1365 | 0 |\n| 47 | 21845 | 0 | 3413 | 0 |\n| 47 | 21845 | 0 | 5461 | 0 |\n| 47 | 21845 | 0 | 7509 | 0 |\n| 47 | 21845 | 0 | 9557 | 0 |\n| 47 | 21845 | 0 | 11605 | 0 |\n| 47 | 21845 | 0 | 13653 | 0 |\n| 47 | 21845 | 0 | 15701 | 0 |\n| 47+ | 21845 | 1 | 1365 | 0 |\n| 48 | 21845 | 1 | 1365 | 21845 |\n| 48+ | 21845 | 1 | 3413 | 0 |\n| 49 | 21845 | 1 | 3413 | 21845 |\n| 49+ | 21845 | 1 | 5461 | 0 |\n| 50 | 21845 | 1 | 5461 | 21845 |\n| 50+ | 21845 | 1 | 7509 | 0 |\n| 51 | 21845 | 1 | 7509 | 21845 |\n| 51+ | 21845 | 1 | 9557 | 0 |\n| 52 | 21845 | 1 | 9557 | 21845 |\n| 52+ | 21845 | 1 | 11605 | 0 |\n| 53 | 21845 | 1 | 11605 | 21845 |\n| 53+ | 21845 | 1 | 13653 | 0 |\n| 54 | 21845 | 1 | 13653 | 21845 |\n| 54+ | 21845 | 1 | 15701 | 0 |\n| 55 | 21845 | 1 | 15701 | 21845 |\n| 55+ | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 1365 | 21845 |\n| 56 | 21845 | 0 | 3413 | 21845 |\n| 56 | 21845 | 0 | 5461 | 21845 |\n| 56 | 21845 | 0 | 7509 | 21845 |\n| 56 | 21845 | 0 | 9557 | 21845 |\n| 56 | 21845 | 0 | 11605 | 21845 |\n| 56 | 21845 | 0 | 13653 | 21845 |\n| 56 | 21845 | 0 | 15701 | 21845 |\n| 56+ | -21846 | 1 | 1365 | 21845 |\n| 57 | -21846 | 1 | 1365 | -21846 |\n| 57+ | -21846 | 0 | 1365 | -21846 |\n| 58 | -21846 | 0 | 1365 | -21846 |\n| 58 | -21846 | 0 | 3413 | 21845 |\n| 58 | -21846 | 0 | 5461 | 21845 |\n| 58 | -21846 | 0 | 7509 | 21845 |\n| 58 | -21846 | 0 | 9557 | 21845 |\n| 58 | -21846 | 0 | 11605 | 21845 |\n| 58 | -21846 | 0 | 13653 | 21845 |\n| 58 | -21846 | 0 | 15701 | 21845 |\n| 58+ | 21845 | 1 | 1365 | -21846 |\n| 59 | 21845 | 1 | 1365 | 21845 |\n| 59+ | -21846 | 1 | 3413 | 21845 |\n| 60 | -21846 | 1 | 3413 | -21846 |\n| 60+ | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 1365 | 21845 |\n| 61 | -21846 | 0 | 3413 | -21846 |\n| 61 | -21846 | 0 | 5461 | 21845 |\n| 61 | -21846 | 0 | 7509 | 21845 |\n| 61 | -21846 | 0 | 9557 | 21845 |\n| 61 | -21846 | 0 | 11605 | 21845 |\n| 61 | -21846 | 0 | 13653 | 21845 |\n| 61 | -21846 | 0 | 15701 | 21845 |\n| 61+ | 21845 | 1 | 3413 | -21846 |\n| 62 | 21845 | 1 | 3413 | 21845 |\n| 62+ | -21846 | 1 | 5461 | 21845 |\n| 63 | -21846 | 1 | 5461 | -21846 |\n| 63+ | -21846 | 0 | 1365 | 21845 |\n| 64 | -21846 | 0 | 1365 | 21845 |\n| 64 | -21846 | 0 | 3413 | 21845 |\n| 64 | -21846 | 0 | 5461 | -21846 |\n| 64 | -21846 | 0 | 7509 | 21845 |\n| 64 | -21846 | 0 | 9557 | 21845 |\n| 64 | -21846 | 0 | 11605 | 21845 |\n| 64 | -21846 | 0 | 13653 | 21845 |\n| 64 | -21846 | 0 | 15701 | 21845 |\n| 64+ | 21845 | 1 | 5461 | -21846 |\n| 65 | 21845 | 1 | 5461 | 21845 |\n| 65+ | -21846 | 1 | 7509 | 21845 |\n| 66 | -21846 | 1 | 7509 | -21846 |\n| 66+ | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 1365 | 21845 |\n| 67 | -21846 | 0 | 3413 | 21845 |\n| 67 | -21846 | 0 | 5461 | 21845 |\n| 67 | -21846 | 0 | 7509 | -21846 |\n| 67 | -21846 | 0 | 9557 | 21845 |\n| 67 | -21846 | 0 | 11605 | 21845 |\n| 67 | -21846 | 0 | 13653 | 21845 |\n| 67 | -21846 | 0 | 15701 | 21845 |\n| 67+ | 21845 | 1 | 7509 | -21846 |\n| 68 | 21845 | 1 | 7509 | 21845 |\n| 68+ | -21846 | 1 | 9557 | 21845 |\n| 69 | -21846 | 1 | 9557 | -21846 |\n| 69+ | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 1365 | 21845 |\n| 70 | -21846 | 0 | 3413 | 21845 |\n| 70 | -21846 | 0 | 5461 | 21845 |\n| 70 | -21846 | 0 | 7509 | 21845 |\n| 70 | -21846 | 0 | 9557 | -21846 |\n| 70 | -21846 | 0 | 11605 | 21845 |\n| 70 | -21846 | 0 | 13653 | 21845 |\n| 70 | -21846 | 0 | 15701 | 21845 |\n| 70+ | 21845 | 1 | 9557 | -21846 |\n| 71 | 21845 | 1 | 9557 | 21845 |\n| 71+ | -21846 | 1 | 11605 | 21845 |\n| 72 | -21846 | 1 | 11605 | -21846 |\n| 72+ | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 1365 | 21845 |\n| 73 | -21846 | 0 | 3413 | 21845 |\n| 73 | -21846 | 0 | 5461 | 21845 |\n| 73 | -21846 | 0 | 7509 | 21845 |\n| 73 | -21846 | 0 | 9557 | 21845 |\n| 73 | -21846 | 0 | 11605 | -21846 |\n| 73 | -21846 | 0 | 13653 | 21845 |\n| 73 | -21846 | 0 | 15701 | 21845 |\n| 73+ | 21845 | 1 | 11605 | -21846 |\n| 74 | 21845 | 1 | 11605 | 21845 |\n| 74+ | -21846 | 1 | 13653 | 21845 |\n| 75 | -21846 | 1 | 13653 | -21846 |\n| 75+ | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 1365 | 21845 |\n| 76 | -21846 | 0 | 3413 | 21845 |\n| 76 | -21846 | 0 | 5461 | 21845 |\n| 76 | -21846 | 0 | 7509 | 21845 |\n| 76 | -21846 | 0 | 9557 | 21845 |\n| 76 | -21846 | 0 | 11605 | 21845 |\n| 76 | -21846 | 0 | 13653 | -21846 |\n| 76 | -21846 | 0 | 15701 | 21845 |\n| 76+ | 21845 | 1 | 13653 | -21846 |\n| 77 | 21845 | 1 | 13653 | 21845 |\n| 77+ | -21846 | 1 | 15701 | 21845 |\n| 78 | -21846 | 1 | 15701 | -21846 |\n| 78+ | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 1365 | 21845 |\n| 79 | -21846 | 0 | 3413 | 21845 |\n| 79 | -21846 | 0 | 5461 | 21845 |\n| 79 | -21846 | 0 | 7509 | 21845 |\n| 79 | -21846 | 0 | 9557 | 21845 |\n| 79 | -21846 | 0 | 11605 | 21845 |\n| 79 | -21846 | 0 | 13653 | 21845 |\n| 79 | -21846 | 0 | 15701 | -21846 |\n| 79+ | 21845 | 1 | 15701 | -21846 |\n| 80 | 21845 | 1 | 15701 | 21845 |\n| 80+ | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 1365 | 21845 |\n| 81 | 21845 | 0 | 3413 | 21845 |\n| 81 | 21845 | 0 | 5461 | 21845 |\n| 81 | 21845 | 0 | 7509 | 21845 |\n| 81 | 21845 | 0 | 9557 | 21845 |\n| 81 | 21845 | 0 | 11605 | 21845 |\n| 81 | 21845 | 0 | 13653 | 21845 |\n| 81 | 21845 | 0 | 15701 | 21845 |"}},A={DFF:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/03/DFF.hdl\n/**\n * Data Flip-flop:\n * maintains its current value:\n * out(t+1) = in(t)\n */\nCHIP DFF {\n IN in;\n OUT out;\n\n PARTS:\n BUILTIN DFF;\n CLOCKED in;\n}'};async function T(n){await n.pushd("/projects/03"),await(0,r.cL)(n,R),await n.popd()}async function b(n){await n.pushd("/projects/03"),await c(n,R,".tst"),await c(n,R,".cmp"),await n.popd()}const g={Mult:{"Mult.asm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/Mult.asm\n\n// Multiplies R0 and R1 and stores the result in R2.\n// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)\n// The algorithm is based on repetitive addition.\n\n//// Replace this comment with your code.',"Mult.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/mult/Mult.tst\n\n// Tests the Mult program, designed to compute R2 = R0 * R1.\n// Tests the program by having it multiply several sets of\n// R0 and R1 values.\n\noutput-list RAM[0]%D2.6.2 RAM[1]%D2.6.2 RAM[2]%D2.6.2;\n\nset RAM[0] 0, // Sets R0 and R1 to some input values\nset RAM[1] 0,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 20 {\n ticktock;\n}\nset RAM[0] 0, // Restores R0 and R1 in case the program changed them\nset RAM[1] 0,\noutput;\n\nset PC 0,\nset RAM[0] 1, // Sets R0 and R1 to some input values\nset RAM[1] 0,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 50 {\n ticktock;\n}\nset RAM[0] 1, // Restores R0 and R1 in case the program changed them\nset RAM[1] 0,\noutput;\n\nset PC 0,\nset RAM[0] 0, // Sets R0 and R1 to some input values\nset RAM[1] 2,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 80 {\n ticktock;\n}\nset RAM[0] 0, // Restores R0 and R1 in case the program changed them\nset RAM[1] 2,\noutput;\n\nset PC 0,\nset RAM[0] 3, // Sets R0 and R1 to some input values\nset RAM[1] 1,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 120 {\n ticktock;\n}\nset RAM[0] 3, // Restores R0 and R1 in case the program changed them\nset RAM[1] 1,\noutput;\n\nset PC 0,\nset RAM[0] 2, // Sets R0 and R1 to some input values\nset RAM[1] 4,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 150 {\n ticktock;\n}\nset RAM[0] 2, // Restores R0 and R1 in case the program changed them\nset RAM[1] 4,\noutput;\n\nset PC 0,\nset RAM[0] 6, // Sets R0 and R1 to some input values\nset RAM[1] 7,\nset RAM[2] -1; // Ensures that the program initialized R2 to 0\nrepeat 210 {\n ticktock;\n}\nset RAM[0] 6, // Restores R0 and R1 in case the program changed them\nset RAM[1] 7,\noutput;',"Mult.cmp":"| RAM[0] | RAM[1] | RAM[2] |\n| 0 | 0 | 0 |\n| 1 | 0 | 0 |\n| 0 | 2 | 0 |\n| 3 | 1 | 3 |\n| 2 | 4 | 8 |\n| 6 | 7 | 42 |"},Fill:{"Fill.asm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/Fill.asm\n\n// Runs an infinite loop that listens to the keyboard input. \n// When a key is pressed (any key), the program blackens the screen,\n// i.e. writes "black" in every pixel. When no key is pressed, \n// the screen should be cleared.\n\n//// Replace this comment with your code.',"Fill.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/fill/Fill.tst\n\n// Tests the Fill.hack program in the CPU emulator.\n\necho "Select the highest speed and \'enable keyboard\'. Then press any key for some time, and inspect the screen.";\n\nrepeat {\n ticktock;\n}',"FillAutomatic.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/4/fill/FillAutomatic\n\n// This script can be used to test the Fill program automatically, \n// rather than interactively. Specifically, the script sets the keyboard\n// memory map (RAM[24576]) to 0, 1, and then again to 0. This simulates the \n// acts of leaving the keyboard untouched, pressing some key, and then releasing\n// the key. After each one of these simulated events, the script outputs the values\n// of some selected registers from the screen memory map (RAM[16384]-RAM[24576]).\n// This is done in order to test that these registers are set to 000...0 or 111....1, \n// as mandated by how the Fill program should react to the keyboard events.\n\noutput-list RAM[16384]%D2.6.2 RAM[17648]%D2.6.2 RAM[18349]%D2.6.2 RAM[19444]%D2.6.2 RAM[20771]%D2.6.2 RAM[21031]%D2.6.2 RAM[22596]%D2.6.2 RAM[23754]%D2.6.2 RAM[24575]%D2.6.2;\n\nset RAM[24576] 0, // the keyboard is untouched\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is white\n\nset RAM[24576] 1, // a keyboard key is pressed\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is black\n\nset RAM[24576] 0, // the keyboard is untouched\nrepeat 1000000 {\n ticktock;\n}\noutput; // tests that the screen is white',"FillAutomatic.cmp":"|RAM[16384]|RAM[17648]|RAM[18349]|RAM[19444]|RAM[20771]|RAM[21031]|RAM[22596]|RAM[23754]|RAM[24575]|\n| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n| -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 |\n| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |"}};async function w(n){await n.pushd("/projects/04"),await(0,r.cL)(n,g),await n.popd()}async function S(n){await n.pushd("/projects/04"),await c(n,g,".tst"),await c(n,g,".cmp"),await n.popd()}const C="\n0000000000000010\n1110110000010000\n0000000000000011\n1110000010010000\n0000000000000000\n1110001100001000\n",x="0000000000000000\n1111110000010000\n0000000000000001\n1111010011010000\n0000000000001010\n1110001100000001\n0000000000000001\n1111110000010000\n0000000000001100\n1110101010000111\n0000000000000000\n1111110000010000\n0000000000000010\n1110001100001000\n0000000000001110\n1110101010000111",D="\n0000000000000000\n1111110000010000\n0000000000010111\n1110001100000110\n0000000000010000\n1110001100001000\n0100000000000000\n1110110000010000\n0000000000010001\n1110001100001000\n0000000000010001\n1111110000100000\n1110111010001000\n0000000000010001\n1111110000010000\n0000000000100000\n1110000010010000\n0000000000010001\n1110001100001000\n0000000000010000\n1111110010011000\n0000000000001010\n1110001100000001\n0000000000010111\n1110101010000111",P={Memory:{"Memory.hdl":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/Memory.hdl\n/**\n * The complete address space of the Hack computer\'s memory,\n * including RAM and memory-mapped I/O. \n * The chip facilitates read and write operations, as follows:\n * Read: out(t) = Memory[address(t)](t)\n * Write: if load(t-1) then Memory[address(t-1)](t) = in(t-1)\n * In words: the chip always outputs the value stored at the memory \n * location specified by address. If load=1, the in value is loaded \n * into the memory location specified by address. This value becomes \n * available through the out output from the next time step onward.\n * Address space rules:\n * Only the upper 16K+8K+1 words of the Memory chip are used. \n * Access to address>0x6000 is invalid and reads 0. Access to any address\n * in the range 0x4000-0x5FFF results in accessing the screen memory \n * map. Access to address 0x6000 results in accessing the keyboard \n * memory map. The behavior in these addresses is described in the Screen\n * and Keyboard chip specifications given in the lectures and the book.\n */\nCHIP Memory {\n IN in[16], load, address[15];\n OUT out[16];\n\n PARTS:\n\t//// Replace this comment with your code.\n}',"Memory.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Memory.tst\n\n// Tests the Memory chip by inputting values to selected addresses, \n// verifying that these addresses were indeed written to, and verifying \n// that other addresses were not accessed by mistake. In particular, we \n// focus on probing the registers in addresses 'lower RAM', 'upper RAM',\n// and 'Screen', which correspond to 0, %X2000, and %X4000 in Hexadecimal \n// (0, 8192 (8K), and 16385 (16K+1) in decimal).\n\noutput-list in%D1.6.1 load%B2.1.2 address%B1.15.1 out%D1.6.1;\n\necho \"Before you run this script, select the 'Screen' option from the 'View' menu\";\n\n// We've noticed a common design mistake in several students' Memory.hdl files.\n// This error leads to zeros being written in the offset of inactive memory segments\n// instead of the intended location. To identify this issue, the test should check not\n// only for incorrect writes into the wrong segment but also for any unexpected changes.\n// To prepare for this, we've initialized the memory with a specific number in the areas\n// where these erroneous writes might happen.\n\n//// Sets RAM[2000], RAM[4000] = 12345 (for the following overwrite test)\nset in 12345, set load 1, set address %X2000, tick, output; tock, output;\nset address %X4000, tick, output; tock, output;\n\nset in -1,\t\t\t\t// Sets RAM[0] = -1\nset load 1,\nset address 0,\ntick,\noutput;\ntock,\noutput;\n\nset in 9999,\t\t\t// RAM[0] holds value\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address %X2000,\t\t// Did not also write to upper RAM or Screen\neval,\noutput;\nset address %X4000,\neval,\noutput;\n\n//// Sets RAM[0], RAM[4000] = 12345 (for following overwrite test)\nset in 12345, set load 1, set address %X0000, tick, output; tock, output;\nset address %X4000, tick, output; tock, output;\n\nset in 2222,\t\t\t// Sets RAM[2000] = 2222\nset load 1,\nset address %X2000,\ntick,\noutput;\ntock,\noutput;\n\nset in 9999,\t\t\t// RAM[2000] holds value\nset load 0,\ntick,\noutput;\ntock,\noutput;\n\nset address 0,\t\t\t// Did not also write to lower RAM or Screen\neval,\noutput;\nset address %X4000,\neval,\noutput;\n\nset load 0,\t\t\t\t// Low order address bits connected\nset address %X0001, eval, output;\nset address %X0002, eval, output;\nset address %X0004, eval, output;\nset address %X0008, eval, output;\nset address %X0010, eval, output;\nset address %X0020, eval, output;\nset address %X0040, eval, output;\nset address %X0080, eval, output;\nset address %X0100, eval, output;\nset address %X0200, eval, output;\nset address %X0400, eval, output;\nset address %X0800, eval, output;\nset address %X1000, eval, output;\nset address %X2000, eval, output;\n\nset address %X1234,\t\t// RAM[1234] = 1234\nset in 1234,\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %X2234,\t\t// Did not also write to upper RAM or Screen \neval, output;\nset address %X6234,\neval, output;\n\nset address %X2345,\t\t// RAM[2345] = 2345\nset in 2345,\nset load 1,\ntick,\noutput;\ntock,\noutput;\n\nset load 0,\nset address %X0345,\t\t// Did not also write to lower RAM or Screen \neval, output;\nset address %X4345,\neval, output;\n\n//// Clears the overwrite detection value from the screen\nset in 0, set load 1, set address %X4000, tick, output; tock, output;\n\n// Keyboard test\n\nset address 24576,\necho \"Click the Keyboard icon and hold down the 'K' key (uppercase) until you see the next message...\",\n// It's important to keep holding the key down since if the system is busy,\n// the memory will zero itself before being outputted.\n\nwhile out <> 75 {\n tick, tock; // tick, tock prevents hang if sync. parts used in KB path.\n}\n\nclear-echo,\noutput;\n\n// Screen test\n\n//// Sets RAM[0FCF], RAM[2FCF] = 12345 (for following overwrite test)\nset in 12345, set load 1, set address %X0FCF, tick, output; tock, output;\nset address %X2FCF, tick, output; tock, output;\n\nset load 1,\nset in -1,\nset address %X4FCF,\ntick,\ntock,\noutput,\n\nset address %X504F,\ntick,\ntock,\noutput;\n\nset address %X0FCF,\t\t// Did not also write to lower or upper RAM\neval,\noutput;\nset address %X2FCF,\neval,\noutput;\n\nset load 0,\t\t\t\t// Low order address bits connected\nset address %X4FCE, eval, output;\nset address %X4FCD, eval, output;\nset address %X4FCB, eval, output;\nset address %X4FC7, eval, output;\nset address %X4FDF, eval, output;\nset address %X4FEF, eval, output;\nset address %X4F8F, eval, output;\nset address %X4F4F, eval, output;\nset address %X4ECF, eval, output;\nset address %X4DCF, eval, output;\nset address %X4BCF, eval, output;\nset address %X47CF, eval, output;\nset address %X5FCF, eval, output;\n\nset load 0,\nset address 24576,\necho \"Two horizontal lines should be in the middle of the screen. Hold down 'Y' (uppercase) until you see the next message ...\",\n// It's important to keep holding the key down since if the system is busy,\n// the memory will zero itself before being outputted.\n\nwhile out <> 89 {\n tick, tock; // tick, tock prevents hang if sync. parts used in KB path.\n}\n\nclear-echo,\noutput;","Memory.cmp":"| in |load | address | out |\n| 12345 | 1 | 010000000000000 | 0 |\n| 12345 | 1 | 010000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 0 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| -1 | 1 | 000000000000000 | 0 |\n| -1 | 1 | 000000000000000 | -1 |\n| 9999 | 0 | 000000000000000 | -1 |\n| 9999 | 0 | 000000000000000 | -1 |\n| 9999 | 0 | 010000000000000 | 12345 |\n| 9999 | 0 | 100000000000000 | 12345 |\n| 12345 | 1 | 000000000000000 | -1 |\n| 12345 | 1 | 000000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| 12345 | 1 | 100000000000000 | 12345 |\n| 2222 | 1 | 010000000000000 | 12345 |\n| 2222 | 1 | 010000000000000 | 2222 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 9999 | 0 | 000000000000000 | 12345 |\n| 9999 | 0 | 100000000000000 | 12345 |\n| 9999 | 0 | 000000000000001 | 0 |\n| 9999 | 0 | 000000000000010 | 0 |\n| 9999 | 0 | 000000000000100 | 0 |\n| 9999 | 0 | 000000000001000 | 0 |\n| 9999 | 0 | 000000000010000 | 0 |\n| 9999 | 0 | 000000000100000 | 0 |\n| 9999 | 0 | 000000001000000 | 0 |\n| 9999 | 0 | 000000010000000 | 0 |\n| 9999 | 0 | 000000100000000 | 0 |\n| 9999 | 0 | 000001000000000 | 0 |\n| 9999 | 0 | 000010000000000 | 0 |\n| 9999 | 0 | 000100000000000 | 0 |\n| 9999 | 0 | 001000000000000 | 0 |\n| 9999 | 0 | 010000000000000 | 2222 |\n| 1234 | 1 | 001001000110100 | 0 |\n| 1234 | 1 | 001001000110100 | 1234 |\n| 1234 | 0 | 010001000110100 | 0 |\n| 1234 | 0 | 110001000110100 | 0 |\n| 2345 | 1 | 010001101000101 | 0 |\n| 2345 | 1 | 010001101000101 | 2345 |\n| 2345 | 0 | 000001101000101 | 0 |\n| 2345 | 0 | 100001101000101 | 0 |\n| 0 | 1 | 100000000000000 | 12345 |\n| 0 | 1 | 100000000000000 | 0 |\n| 0 | 1 | 110000000000000 | 75 |\n| 12345 | 1 | 000111111001111 | 0 |\n| 12345 | 1 | 000111111001111 | 12345 |\n| 12345 | 1 | 010111111001111 | 0 |\n| 12345 | 1 | 010111111001111 | 12345 |\n| -1 | 1 | 100111111001111 | -1 |\n| -1 | 1 | 101000001001111 | -1 |\n| -1 | 1 | 000111111001111 | 12345 |\n| -1 | 1 | 010111111001111 | 12345 |\n| -1 | 0 | 100111111001110 | 0 |\n| -1 | 0 | 100111111001101 | 0 |\n| -1 | 0 | 100111111001011 | 0 |\n| -1 | 0 | 100111111000111 | 0 |\n| -1 | 0 | 100111111011111 | 0 |\n| -1 | 0 | 100111111101111 | 0 |\n| -1 | 0 | 100111110001111 | 0 |\n| -1 | 0 | 100111101001111 | 0 |\n| -1 | 0 | 100111011001111 | 0 |\n| -1 | 0 | 100110111001111 | 0 |\n| -1 | 0 | 100101111001111 | 0 |\n| -1 | 0 | 100011111001111 | 0 |\n| -1 | 0 | 101111111001111 | 0 |\n| -1 | 0 | 110000000000000 | 89 |"},CPU:{"CPU.hdl":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU.hdl\n/**\n * The Hack Central Processing unit (CPU).\n * Parses the binary code in the instruction input and executes it according to the\n * Hack machine language specification. In the case of a C-instruction, computes the\n * function specified by the instruction. If the instruction specifies to read a memory\n * value, the inM input is expected to contain this value. If the instruction specifies\n * to write a value to the memory, sets the outM output to this value, sets the addressM\n * output to the target address, and asserts the writeM output (when writeM = 0, any\n * value may appear in outM).\n * If the reset input is 0, computes the address of the next instruction and sets the\n * pc output to that value. If the reset input is 1, sets pc to 0.\n * Note: The outM and writeM outputs are combinational: they are affected by the\n * instruction's execution during the current cycle. The addressM and pc outputs are\n * clocked: although they are affected by the instruction's execution, they commit to\n * their new values only in the next cycle.\n */\nCHIP CPU {\n\n IN inM[16], // M value input (M = contents of RAM[A])\n instruction[16], // Instruction for execution\n reset; // Signals whether to re-start the current\n // program (reset==1) or continue executing\n // the current program (reset==0).\n\n OUT outM[16], // M value output\n writeM, // Write to M? \n addressM[15], // Address in data memory (of M)\n pc[15]; // address of next instruction\n\n PARTS:\n\t//// Replace this comment with your code.\n}","CPU.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU.tst\n\noutput-list time%S0.4.0 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.3 addressM%D0.5.0 pc%D0.5.0 DRegister[]%D1.6.1;\n\n\nset instruction %B0011000000111001, // @12345\ntick, output, tock, output;\n\nset instruction %B1110110000010000, // D=A\ntick, output, tock, output;\n\nset instruction %B0101101110100000, // @23456\ntick, output, tock, output;\n\nset instruction %B1110000111010000, // D=A-D\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000001111101001, // @1001\ntick, output, tock, output;\n\nset instruction %B1110001110011000, // MD=D-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1111010011010000, // D=D-M\nset inM 11111,\ntick, output, tock, output;\n\nset instruction %B0000000000001110, // @14\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;jlt\ntick, output, tock, output;\n\nset instruction %B0000001111100111, // @999\ntick, output, tock, output;\n\nset instruction %B1110110111100000, // A=A+1\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000000000010101, // @21\ntick, output, tock, output;\n\nset instruction %B1110011111000010, // D+1;jeq\ntick, output, tock, output;\n\nset instruction %B0000000000000010, // @2\ntick, output, tock, output;\n\nset instruction %B1110000010010000, // D=D+A\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110111010010000, // D=-1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110101010010000, // D=0\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110111111010000, // D=1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset reset 1;\ntick, output, tock, output;\n\nset instruction %B0111111111111111, // @32767\nset reset 0;\ntick, output, tock, output;',"CPU.cmp":"|time| inM | instruction |reset| outM |writeM |addre| pc |DRegiste|\n|0+ | 0|0011000000111001| 0 |*******| 0 | 0| 0| 0 |\n|1 | 0|0011000000111001| 0 |*******| 0 |12345| 1| 0 |\n|1+ | 0|1110110000010000| 0 |*******| 0 |12345| 1| 12345 |\n|2 | 0|1110110000010000| 0 |*******| 0 |12345| 2| 12345 |\n|2+ | 0|0101101110100000| 0 |*******| 0 |12345| 2| 12345 |\n|3 | 0|0101101110100000| 0 |*******| 0 |23456| 3| 12345 |\n|3+ | 0|1110000111010000| 0 |*******| 0 |23456| 3| 11111 |\n|4 | 0|1110000111010000| 0 |*******| 0 |23456| 4| 11111 |\n|4+ | 0|0000001111101000| 0 |*******| 0 |23456| 4| 11111 |\n|5 | 0|0000001111101000| 0 |*******| 0 | 1000| 5| 11111 |\n|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| 11111 |\n|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| 11111 |\n|6+ | 0|0000001111101001| 0 |*******| 0 | 1000| 6| 11111 |\n|7 | 0|0000001111101001| 0 |*******| 0 | 1001| 7| 11111 |\n|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| 11110 |\n|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| 11110 |\n|8+ | 0|0000001111101000| 0 |*******| 0 | 1001| 8| 11110 |\n|9 | 0|0000001111101000| 0 |*******| 0 | 1000| 9| 11110 |\n|9+ | 11111|1111010011010000| 0 |*******| 0 | 1000| 9| -1 |\n|10 | 11111|1111010011010000| 0 |*******| 0 | 1000| 10| -1 |\n|10+ | 11111|0000000000001110| 0 |*******| 0 | 1000| 10| -1 |\n|11 | 11111|0000000000001110| 0 |*******| 0 | 14| 11| -1 |\n|11+ | 11111|1110001100000100| 0 |*******| 0 | 14| 11| -1 |\n|12 | 11111|1110001100000100| 0 |*******| 0 | 14| 14| -1 |\n|12+ | 11111|0000001111100111| 0 |*******| 0 | 14| 14| -1 |\n|13 | 11111|0000001111100111| 0 |*******| 0 | 999| 15| -1 |\n|13+ | 11111|1110110111100000| 0 |*******| 0 | 999| 15| -1 |\n|14 | 11111|1110110111100000| 0 |*******| 0 | 1000| 16| -1 |\n|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| -1 |\n|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| -1 |\n|15+ | 11111|0000000000010101| 0 |*******| 0 | 1000| 17| -1 |\n|16 | 11111|0000000000010101| 0 |*******| 0 | 21| 18| -1 |\n|16+ | 11111|1110011111000010| 0 |*******| 0 | 21| 18| -1 |\n|17 | 11111|1110011111000010| 0 |*******| 0 | 21| 21| -1 |\n|17+ | 11111|0000000000000010| 0 |*******| 0 | 21| 21| -1 |\n|18 | 11111|0000000000000010| 0 |*******| 0 | 2| 22| -1 |\n|18+ | 11111|1110000010010000| 0 |*******| 0 | 2| 22| 1 |\n|19 | 11111|1110000010010000| 0 |*******| 0 | 2| 23| 1 |\n|19+ | 11111|0000001111101000| 0 |*******| 0 | 2| 23| 1 |\n|20 | 11111|0000001111101000| 0 |*******| 0 | 1000| 24| 1 |\n|20+ | 11111|1110111010010000| 0 |*******| 0 | 1000| 24| -1 |\n|21 | 11111|1110111010010000| 0 |*******| 0 | 1000| 25| -1 |\n|21+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 25| -1 |\n|22 | 11111|1110001100000001| 0 |*******| 0 | 1000| 26| -1 |\n|22+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 26| -1 |\n|23 | 11111|1110001100000010| 0 |*******| 0 | 1000| 27| -1 |\n|23+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 27| -1 |\n|24 | 11111|1110001100000011| 0 |*******| 0 | 1000| 28| -1 |\n|24+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 28| -1 |\n|25 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| -1 |\n|25+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| -1 |\n|26 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| -1 |\n|26+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| -1 |\n|27 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| -1 |\n|27+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| -1 |\n|28 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| -1 |\n|28+ | 11111|1110101010010000| 0 |*******| 0 | 1000| 1000| 0 |\n|29 | 11111|1110101010010000| 0 |*******| 0 | 1000| 1001| 0 |\n|29+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| 0 |\n|30 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1002| 0 |\n|30+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1002| 0 |\n|31 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| 0 |\n|31+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 0 |\n|32 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 0 |\n|32+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| 0 |\n|33 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| 0 |\n|33+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| 0 |\n|34 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1002| 0 |\n|34+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1002| 0 |\n|35 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| 0 |\n|35+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 0 |\n|36 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 0 |\n|36+ | 11111|1110111111010000| 0 |*******| 0 | 1000| 1000| 1 |\n|37 | 11111|1110111111010000| 0 |*******| 0 | 1000| 1001| 1 |\n|37+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| 1 |\n|38 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1000| 1 |\n|38+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| 1 |\n|39 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1001| 1 |\n|39+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1001| 1 |\n|40 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 1 |\n|40+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| 1 |\n|41 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| 1 |\n|41+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| 1 |\n|42 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| 1 |\n|42+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| 1 |\n|43 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1001| 1 |\n|43+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1001| 1 |\n|44 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 1 |\n|44+ | 11111|1110001100000111| 1 |*******| 0 | 1000| 1000| 1 |\n|45 | 11111|1110001100000111| 1 |*******| 0 | 1000| 0| 1 |\n|45+ | 11111|0111111111111111| 0 |*******| 0 | 1000| 0| 1 |\n|46 | 11111|0111111111111111| 0 |*******| 0 |32767| 1| 1 |","CPU-external.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/CPU-external.tst\n\noutput-list time%S0.4.0 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.3 addressM%D0.5.0 pc%D0.5.0;\n\n\nset instruction %B0011000000111001, // @12345\ntick, output, tock, output;\n\nset instruction %B1110110000010000, // D=A\ntick, output, tock, output;\n\nset instruction %B0101101110100000, // @23456\ntick, output, tock, output;\n\nset instruction %B1110000111010000, // D=A-D\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000001111101001, // @1001\ntick, output, tock, output;\n\nset instruction %B1110001110011000, // MD=D-1\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1111010011010000, // D=D-M\nset inM 11111,\ntick, output, tock, output;\n\nset instruction %B0000000000001110, // @14\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;jlt\ntick, output, tock, output;\n\nset instruction %B0000001111100111, // @999\ntick, output, tock, output;\n\nset instruction %B1110110111100000, // A=A+1\ntick, output, tock, output;\n\nset instruction %B1110001100001000, // M=D\ntick, output, tock, output;\n\nset instruction %B0000000000010101, // @21\ntick, output, tock, output;\n\nset instruction %B1110011111000010, // D+1;jeq\ntick, output, tock, output;\n\nset instruction %B0000000000000010, // @2\ntick, output, tock, output;\n\nset instruction %B1110000010010000, // D=D+A\ntick, output, tock, output;\n\nset instruction %B0000001111101000, // @1000\ntick, output, tock, output;\n\nset instruction %B1110111010010000, // D=-1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110101010010000, // D=0\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset instruction %B1110111111010000, // D=1\ntick, output, tock, output;\n\nset instruction %B1110001100000001, // D;JGT\ntick, output, tock, output;\n\nset instruction %B1110001100000010, // D;JEQ\ntick, output, tock, output;\n\nset instruction %B1110001100000011, // D;JGE\ntick, output, tock, output;\n\nset instruction %B1110001100000100, // D;JLT\ntick, output, tock, output;\n\nset instruction %B1110001100000101, // D;JNE\ntick, output, tock, output;\n\nset instruction %B1110001100000110, // D;JLE\ntick, output, tock, output;\n\nset instruction %B1110001100000111, // D;JMP\ntick, output, tock, output;\n\nset reset 1;\ntick, output, tock, output;\n\nset instruction %B0111111111111111, // @32767\nset reset 0;\ntick, output, tock, output;',"CPU-external.cmp":"|time| inM | instruction |reset| outM |writeM |addre| pc |\n|0+ | 0|0011000000111001| 0 | 0| 0 | 0| 0|\n|1 | 0|0011000000111001| 0 | 0| 0 |12345| 1|\n|1+ | 0|1110110000010000| 0 | 12345| 0 |12345| 1|\n|2 | 0|1110110000010000| 0 | 12345| 0 |12345| 2|\n|2+ | 0|0101101110100000| 0 | 0| 0 |12345| 2|\n|3 | 0|0101101110100000| 0 | 0| 0 |23456| 3|\n|3+ | 0|1110000111010000| 0 | 11111| 0 |23456| 3|\n|4 | 0|1110000111010000| 0 | 12345| 0 |23456| 4|\n|4+ | 0|0000001111101000| 0 | -11111| 0 |23456| 4|\n|5 | 0|0000001111101000| 0 | -11111| 0 | 1000| 5|\n|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5|\n|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6|\n|6+ | 0|0000001111101001| 0 | -11111| 0 | 1000| 6|\n|7 | 0|0000001111101001| 0 | -11111| 0 | 1001| 7|\n|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7|\n|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8|\n|8+ | 0|0000001111101000| 0 | -11110| 0 | 1001| 8|\n|9 | 0|0000001111101000| 0 | -11110| 0 | 1000| 9|\n|9+ | 11111|1111010011010000| 0 | -1| 0 | 1000| 9|\n|10 | 11111|1111010011010000| 0 | -11112| 0 | 1000| 10|\n|10+ | 11111|0000000000001110| 0 | 1000| 0 | 1000| 10|\n|11 | 11111|0000000000001110| 0 | 14| 0 | 14| 11|\n|11+ | 11111|1110001100000100| 0 | -1| 0 | 14| 11|\n|12 | 11111|1110001100000100| 0 | -1| 0 | 14| 14|\n|12+ | 11111|0000001111100111| 0 | 1| 0 | 14| 14|\n|13 | 11111|0000001111100111| 0 | 1| 0 | 999| 15|\n|13+ | 11111|1110110111100000| 0 | 1000| 0 | 999| 15|\n|14 | 11111|1110110111100000| 0 | 1001| 0 | 1000| 16|\n|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16|\n|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17|\n|15+ | 11111|0000000000010101| 0 | 1000| 0 | 1000| 17|\n|16 | 11111|0000000000010101| 0 | 21| 0 | 21| 18|\n|16+ | 11111|1110011111000010| 0 | 0| 0 | 21| 18|\n|17 | 11111|1110011111000010| 0 | 0| 0 | 21| 21|\n|17+ | 11111|0000000000000010| 0 | 21| 0 | 21| 21|\n|18 | 11111|0000000000000010| 0 | 2| 0 | 2| 22|\n|18+ | 11111|1110000010010000| 0 | 1| 0 | 2| 22|\n|19 | 11111|1110000010010000| 0 | 3| 0 | 2| 23|\n|19+ | 11111|0000001111101000| 0 | -1| 0 | 2| 23|\n|20 | 11111|0000001111101000| 0 | -1| 0 | 1000| 24|\n|20+ | 11111|1110111010010000| 0 | -1| 0 | 1000| 24|\n|21 | 11111|1110111010010000| 0 | -1| 0 | 1000| 25|\n|21+ | 11111|1110001100000001| 0 | -1| 0 | 1000| 25|\n|22 | 11111|1110001100000001| 0 | -1| 0 | 1000| 26|\n|22+ | 11111|1110001100000010| 0 | -1| 0 | 1000| 26|\n|23 | 11111|1110001100000010| 0 | -1| 0 | 1000| 27|\n|23+ | 11111|1110001100000011| 0 | -1| 0 | 1000| 27|\n|24 | 11111|1110001100000011| 0 | -1| 0 | 1000| 28|\n|24+ | 11111|1110001100000100| 0 | -1| 0 | 1000| 28|\n|25 | 11111|1110001100000100| 0 | -1| 0 | 1000| 1000|\n|25+ | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000|\n|26 | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000|\n|26+ | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000|\n|27 | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000|\n|27+ | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000|\n|28 | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000|\n|28+ | 11111|1110101010010000| 0 | 0| 0 | 1000| 1000|\n|29 | 11111|1110101010010000| 0 | 0| 0 | 1000| 1001|\n|29+ | 11111|1110001100000001| 0 | 0| 0 | 1000| 1001|\n|30 | 11111|1110001100000001| 0 | 0| 0 | 1000| 1002|\n|30+ | 11111|1110001100000010| 0 | 0| 0 | 1000| 1002|\n|31 | 11111|1110001100000010| 0 | 0| 0 | 1000| 1000|\n|31+ | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000|\n|32 | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000|\n|32+ | 11111|1110001100000100| 0 | 0| 0 | 1000| 1000|\n|33 | 11111|1110001100000100| 0 | 0| 0 | 1000| 1001|\n|33+ | 11111|1110001100000101| 0 | 0| 0 | 1000| 1001|\n|34 | 11111|1110001100000101| 0 | 0| 0 | 1000| 1002|\n|34+ | 11111|1110001100000110| 0 | 0| 0 | 1000| 1002|\n|35 | 11111|1110001100000110| 0 | 0| 0 | 1000| 1000|\n|35+ | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000|\n|36 | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000|\n|36+ | 11111|1110111111010000| 0 | 1| 0 | 1000| 1000|\n|37 | 11111|1110111111010000| 0 | 1| 0 | 1000| 1001|\n|37+ | 11111|1110001100000001| 0 | 1| 0 | 1000| 1001|\n|38 | 11111|1110001100000001| 0 | 1| 0 | 1000| 1000|\n|38+ | 11111|1110001100000010| 0 | 1| 0 | 1000| 1000|\n|39 | 11111|1110001100000010| 0 | 1| 0 | 1000| 1001|\n|39+ | 11111|1110001100000011| 0 | 1| 0 | 1000| 1001|\n|40 | 11111|1110001100000011| 0 | 1| 0 | 1000| 1000|\n|40+ | 11111|1110001100000100| 0 | 1| 0 | 1000| 1000|\n|41 | 11111|1110001100000100| 0 | 1| 0 | 1000| 1001|\n|41+ | 11111|1110001100000101| 0 | 1| 0 | 1000| 1001|\n|42 | 11111|1110001100000101| 0 | 1| 0 | 1000| 1000|\n|42+ | 11111|1110001100000110| 0 | 1| 0 | 1000| 1000|\n|43 | 11111|1110001100000110| 0 | 1| 0 | 1000| 1001|\n|43+ | 11111|1110001100000111| 0 | 1| 0 | 1000| 1001|\n|44 | 11111|1110001100000111| 0 | 1| 0 | 1000| 1000|\n|44+ | 11111|1110001100000111| 1 | 1| 0 | 1000| 1000|\n|45 | 11111|1110001100000111| 1 | 1| 0 | 1000| 0|\n|45+ | 11111|0111111111111111| 0 | 1| 0 | 1000| 0|\n|46 | 11111|0111111111111111| 0 | 1| 0 |32767| 1|\n"},Computer:{"Computer.hdl":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/Computer.hdl\n/**\n * The Hack computer, consisting of CPU, ROM and RAM.\n * When reset = 0, the program stored in the ROM executes.\n * When reset = 1, the program's execution restarts. \n * Thus, to start running the currently loaded program,\n * set reset to 1, and then set it to 0. \n * From this point onwards, the user is at the mercy of the software.\n * Depending on the program's code, and whether the code is correct,\n * the screen may show some output, the user may be expected to enter\n * some input using the keyboard, or the program may do some procerssing. \n */\nCHIP Computer {\n\n IN reset;\n\n PARTS:\n //// Replace this comment with your code.\n}","ComputerAdd.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerAdd.tst\n\n// Tests the Computer chip by having it execute the program Add.hack.\n// The program adds up the constants 2 and 3 and writes the result in RAM[0]. \n\n// Tracks the values of the time, reset bit, A-register, D-register,\n// program counter, R0, R1, and R2.\noutput-list time%S1.3.1 reset%B2.1.2 ARegister[0]%D1.7.1 DRegister[0]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Add.hack into the computer\'s instruction memory \nROM32K load Add.hack,\noutput;\n\n// First run (at the beginning PC=0)\nrepeat 6 {\n tick, tock, output;\n}\n\n// Resets the PC\nset reset 1,\nset RAM16K[0] 0,\ntick, tock, output;\n\n// Second run, to check that the PC was reset correctly.\nset reset 0,\n\nrepeat 6 {\n tick, tock, output;\n}',"ComputerAdd.cmp":"|time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0 | 0| 0 | 0 | 0 |\n| 1 | 0 | 2 | 0 | 1| 0 | 0 | 0 |\n| 2 | 0 | 2 | 2 | 2| 0 | 0 | 0 |\n| 3 | 0 | 3 | 2 | 3| 0 | 0 | 0 |\n| 4 | 0 | 3 | 5 | 4| 0 | 0 | 0 |\n| 5 | 0 | 0 | 5 | 5| 0 | 0 | 0 |\n| 6 | 0 | 0 | 5 | 6| 5 | 0 | 0 |\n| 7 | 1 | 0 | 5 | 0| 0 | 0 | 0 |\n| 8 | 0 | 2 | 5 | 1| 0 | 0 | 0 |\n| 9 | 0 | 2 | 2 | 2| 0 | 0 | 0 |\n| 10 | 0 | 3 | 2 | 3| 0 | 0 | 0 |\n| 11 | 0 | 3 | 5 | 4| 0 | 0 | 0 |\n| 12 | 0 | 0 | 5 | 5| 0 | 0 | 0 |\n| 13 | 0 | 0 | 5 | 6| 5 | 0 | 0 |","ComputerMax.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerMax.tst\n\n// Tests the Computer chip by having it execute the program Max.hack.\n// The program computes maximum(R0, R1) and writes the result in RAM[2].\n\n// Tracks the values of the time, reset bit, A-register, D-register,\n// program counter, R0, R1, and R2.\noutput-list time%S1.3.1 reset%B2.1.2 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Add.hack into the computer\'s instruction memory \nROM32K load Max.hack,\n\n// first run: computes max(3,5)\nset RAM16K[0] 3,\nset RAM16K[1] 5,\noutput;\n\nrepeat 14 {\n tick, tock, output;\n}\n\n// resets the PC\nset reset 1,\ntick, tock, output;\n\n// second run: computes max(23456,12345)\nset reset 0,\nset RAM16K[0] 23456,\nset RAM16K[1] 12345,\noutput;\n\n// The run on these inputs requires less cycles (different branching)\nrepeat 10 {\n tick, tock, output;\n}\n',"ComputerMax.cmp":"|time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0 | 0| 3 | 5 | 0 |\n| 1 | 0 | 0 | 0 | 1| 3 | 5 | 0 |\n| 2 | 0 | 0 | 3 | 2| 3 | 5 | 0 |\n| 3 | 0 | 1 | 3 | 3| 3 | 5 | 0 |\n| 4 | 0 | 1 | -2 | 4| 3 | 5 | 0 |\n| 5 | 0 | 10 | -2 | 5| 3 | 5 | 0 |\n| 6 | 0 | 10 | -2 | 6| 3 | 5 | 0 |\n| 7 | 0 | 1 | -2 | 7| 3 | 5 | 0 |\n| 8 | 0 | 1 | 5 | 8| 3 | 5 | 0 |\n| 9 | 0 | 12 | 5 | 9| 3 | 5 | 0 |\n| 10 | 0 | 12 | 5 | 12| 3 | 5 | 0 |\n| 11 | 0 | 2 | 5 | 13| 3 | 5 | 0 |\n| 12 | 0 | 2 | 5 | 14| 3 | 5 | 5 |\n| 13 | 0 | 14 | 5 | 15| 3 | 5 | 5 |\n| 14 | 0 | 14 | 5 | 14| 3 | 5 | 5 |\n| 15 | 1 | 14 | 5 | 0| 3 | 5 | 5 |\n| 15 | 0 | 14 | 5 | 0| 23456 | 12345 | 5 |\n| 16 | 0 | 0 | 5 | 1| 23456 | 12345 | 5 |\n| 17 | 0 | 0 | 23456 | 2| 23456 | 12345 | 5 |\n| 18 | 0 | 1 | 23456 | 3| 23456 | 12345 | 5 |\n| 19 | 0 | 1 | 11111 | 4| 23456 | 12345 | 5 |\n| 20 | 0 | 10 | 11111 | 5| 23456 | 12345 | 5 |\n| 21 | 0 | 10 | 11111 | 10| 23456 | 12345 | 5 |\n| 22 | 0 | 0 | 11111 | 11| 23456 | 12345 | 5 |\n| 23 | 0 | 0 | 23456 | 12| 23456 | 12345 | 5 |\n| 24 | 0 | 2 | 23456 | 13| 23456 | 12345 | 5 |\n| 25 | 0 | 2 | 23456 | 14| 23456 | 12345 | 23456 |","ComputerRect.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/5/ComputerRect.tst\n\n// Tests the Computer chip by having it execute the program Rect.hack.\n// The program draws a rectangle of width 16 pixels and length RAM[0]\n// at the top left corner of the screen.\n\n// Tracks the values of the time, A-register, D-register, program counter, R0, R1, and R2.\noutput-list time%S1.3.1 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;\n\n// Loads the binary program Rect.hack into the computer's instruction memory \nROM32K load Rect.hack,\n\necho \"Before you run this script, select the 'Screen' option from the 'View' menu\";\n\necho \"A small rectangle should be drawn at the top left of the screen (the 'Screen' option of the 'View' menu should be selected.)\";\n\n// Draws a rectangle consisting of 4 rows (each 16 pixels wide)\nset RAM16K[0] 4,\noutput;\n\nrepeat 63 {\n tick, tock, output;\n}","ComputerRect.cmp":"|time |ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|\n| 0 | 0 | 0 | 0| 4 | 0 | 0 |\n| 1 | 0 | 0 | 1| 4 | 0 | 0 |\n| 2 | 0 | 4 | 2| 4 | 0 | 0 |\n| 3 | 23 | 4 | 3| 4 | 0 | 0 |\n| 4 | 23 | 4 | 4| 4 | 0 | 0 |\n| 5 | 16 | 4 | 5| 4 | 0 | 0 |\n| 6 | 16 | 4 | 6| 4 | 0 | 0 |\n| 7 | 16384 | 4 | 7| 4 | 0 | 0 |\n| 8 | 16384 | 16384 | 8| 4 | 0 | 0 |\n| 9 | 17 | 16384 | 9| 4 | 0 | 0 |\n| 10 | 17 | 16384 | 10| 4 | 0 | 0 |\n| 11 | 17 | 16384 | 11| 4 | 0 | 0 |\n| 12 | 16384 | 16384 | 12| 4 | 0 | 0 |\n| 13 | 16384 | 16384 | 13| 4 | 0 | 0 |\n| 14 | 17 | 16384 | 14| 4 | 0 | 0 |\n| 15 | 17 | 16384 | 15| 4 | 0 | 0 |\n| 16 | 32 | 16384 | 16| 4 | 0 | 0 |\n| 17 | 32 | 16416 | 17| 4 | 0 | 0 |\n| 18 | 17 | 16416 | 18| 4 | 0 | 0 |\n| 19 | 17 | 16416 | 19| 4 | 0 | 0 |\n| 20 | 16 | 16416 | 20| 4 | 0 | 0 |\n| 21 | 16 | 3 | 21| 4 | 0 | 0 |\n| 22 | 10 | 3 | 22| 4 | 0 | 0 |\n| 23 | 10 | 3 | 10| 4 | 0 | 0 |\n| 24 | 17 | 3 | 11| 4 | 0 | 0 |\n| 25 | 16416 | 3 | 12| 4 | 0 | 0 |\n| 26 | 16416 | 3 | 13| 4 | 0 | 0 |\n| 27 | 17 | 3 | 14| 4 | 0 | 0 |\n| 28 | 17 | 16416 | 15| 4 | 0 | 0 |\n| 29 | 32 | 16416 | 16| 4 | 0 | 0 |\n| 30 | 32 | 16448 | 17| 4 | 0 | 0 |\n| 31 | 17 | 16448 | 18| 4 | 0 | 0 |\n| 32 | 17 | 16448 | 19| 4 | 0 | 0 |\n| 33 | 16 | 16448 | 20| 4 | 0 | 0 |\n| 34 | 16 | 2 | 21| 4 | 0 | 0 |\n| 35 | 10 | 2 | 22| 4 | 0 | 0 |\n| 36 | 10 | 2 | 10| 4 | 0 | 0 |\n| 37 | 17 | 2 | 11| 4 | 0 | 0 |\n| 38 | 16448 | 2 | 12| 4 | 0 | 0 |\n| 39 | 16448 | 2 | 13| 4 | 0 | 0 |\n| 40 | 17 | 2 | 14| 4 | 0 | 0 |\n| 41 | 17 | 16448 | 15| 4 | 0 | 0 |\n| 42 | 32 | 16448 | 16| 4 | 0 | 0 |\n| 43 | 32 | 16480 | 17| 4 | 0 | 0 |\n| 44 | 17 | 16480 | 18| 4 | 0 | 0 |\n| 45 | 17 | 16480 | 19| 4 | 0 | 0 |\n| 46 | 16 | 16480 | 20| 4 | 0 | 0 |\n| 47 | 16 | 1 | 21| 4 | 0 | 0 |\n| 48 | 10 | 1 | 22| 4 | 0 | 0 |\n| 49 | 10 | 1 | 10| 4 | 0 | 0 |\n| 50 | 17 | 1 | 11| 4 | 0 | 0 |\n| 51 | 16480 | 1 | 12| 4 | 0 | 0 |\n| 52 | 16480 | 1 | 13| 4 | 0 | 0 |\n| 53 | 17 | 1 | 14| 4 | 0 | 0 |\n| 54 | 17 | 16480 | 15| 4 | 0 | 0 |\n| 55 | 32 | 16480 | 16| 4 | 0 | 0 |\n| 56 | 32 | 16512 | 17| 4 | 0 | 0 |\n| 57 | 17 | 16512 | 18| 4 | 0 | 0 |\n| 58 | 17 | 16512 | 19| 4 | 0 | 0 |\n| 59 | 16 | 16512 | 20| 4 | 0 | 0 |\n| 60 | 16 | 0 | 21| 4 | 0 | 0 |\n| 61 | 10 | 0 | 22| 4 | 0 | 0 |\n| 62 | 10 | 0 | 23| 4 | 0 | 0 |\n| 63 | 23 | 0 | 24| 4 | 0 | 0 |"}},I={Screen:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Screen.hdl\n/**\n * The Screen (memory map).\n * Same functionality as a 16-bit 8K RAM:\n * If load is asserted, the value of the register selected by\n * address is set to in; Otherwise, the value does not change.\n * The value of the selected register is emitted by out.\n *\n * This built-in implementation has the side effect of continuously \n * refreshing a visual 256 by 512 black-and-white screen, simulated \n * by the simulator. Each row in the visual screen is represented \n * by 32 consecutive 16-bit words, starting at the top left corner \n * of the visual screen. Thus the pixel at row r from the top and \n * column c from the left (0<=r<256, 0<=c<512) reflects the c%16 \n * bit (counting from LSB to MSB) of the word found in Screen[r*32+c/16]. \n */\nCHIP Screen {\n IN in[16], // what to write\n load, // write-enable bit\n address[13]; // where to read/write\n OUT out[16]; // Screen value at the given address\n\n PARTS:\n BUILTIN Screen;\n CLOCKED in, load;\n}',Keyboard:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/Keyboard.hdl\n/**\n * The keyboard (memory map).\n * Outputs the character code of the currently pressed key,\n * or 0 if no key is pressed.\n *\n * This built-in implementation has a visualization side effect.\n */\nCHIP Keyboard {\n OUT out[16];\n\n PARTS:\n BUILTIN Keyboard;\n}',DRegister:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/DRegister.hdl\n/**\n * A 16-bit register named DRegister with the same functionality\n * of the Register chip:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value.\n * out(t+1) = (load(t), in(t), out(t))\n *\n * This built-in implementation has a visualization side effect.\n */\nCHIP DRegister {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n BUILTIN DRegister;\n CLOCKED in, load;\n}',ARegister:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/ARegister.hdl\n/**\n * A 16-bit register named ARegister with the same functionality\n * of the Register chip:\n * If load is asserted, the register\'s value is set to in;\n * Otherwise, the register maintains its current value.\n * out(t+1) = (load(t), in(t), out(t))\n *\n * This built-in implementation has a visualization side effect.\n */\n CHIP ARegister {\n IN in[16], load;\n OUT out[16];\n\n PARTS:\n BUILTIN ARegister;\n CLOCKED in, load;\n}',ROM32K:'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/05/ROM32K.hdl\n/**\n * Read-Only memory (ROM) of 32K registers, each 16-bit wide.\n * Facilitates data read, as follows:\n * out(t) = ROM32K[address(t)](t)\n * In words: the chip outputs the value stored at the \n * memory location specified by address.\n *\n * Can be used as the instruction memory of the Hack computer.\n * To that end, the built-in chip implementation supports the handling \n * of the "ROM32K load Xxx" script command, where Xxx is the name of a\n * text file containing a program written in the binary Hack machine language.\n * When the simulator encounters such a command in a test script,\n * the file\'s contents is loaded into the simulated ROM32K chip.\n */\n CHIP ROM32K {\n IN address[15];\n OUT out[16];\n\n PARTS:\n BUILTIN ROM32K;\n}',RAM16K:y.replace("//// Replace this comment with your code.","BUILTIN RAM16K;")};async function F(n){await n.pushd("/projects/05"),await(0,r.cL)(n,P),await n.popd(),await n.pushd("/samples"),await n.writeFile("Add.hack",C),await n.writeFile("Max.hack",x),await n.writeFile("Rect.hack",D),await n.popd()}async function N(n){await n.pushd("/projects/05"),await c(n,P,".tst"),await c(n,P,".cmp"),await n.popd()}const E={SimpleAdd:{"SimpleAdd.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAdd.vm\n\n// Pushes and adds two constants.\n\npush constant 7\npush constant 8\nadd\n',"SimpleAddVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAddVME.tst\n\n// Tests and illustrates SimpleAdd.vm on the VM simulator.\n\nload SimpleAdd.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 3 { // SimpleAdd.vm has 3 VM commands\n vmstep;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;\noutput;',"SimpleAdd.cmp":"| RAM[0] | RAM[256] |\n| 257 | 15 |\n","SimpleAdd.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/SimpleAdd/SimpleAdd.tst\n\n// Tests SimpleAdd.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer \n\nrepeat 60 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D2.6.2 RAM[256]%D2.6.2;\noutput;\n'},StackTest:{"StackTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTest.vm\n\n// Executes a sequence of arithmetic and logical operations on the stack. \n\npush constant 17\npush constant 17\neq\npush constant 17\npush constant 16\neq\npush constant 16\npush constant 17\neq\npush constant 892\npush constant 891\nlt\npush constant 891\npush constant 892\nlt\npush constant 891\npush constant 891\nlt\npush constant 32767\npush constant 32766\ngt\npush constant 32766\npush constant 32767\ngt\npush constant 32766\npush constant 32766\ngt\npush constant 57\npush constant 31\npush constant 53\nadd\npush constant 112\nsub\nneg\nand\npush constant 82\nor\nnot\n',"StackTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTestVME.tst\n\n// Tests and illustrates StackTest.vm on the VM simulator.\n\nload StackTest.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 38 { // StackTest.vm has 38 VM commands\n vmstep;\n}\n\n// Outputs the stack pointer (RAM[0]) and the stack contents: RAM[256]-RAM[265]\noutput-list RAM[0]%D2.6.2 \n RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;\noutput;\noutput-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;\noutput;\n',"StackTest.cmp":"| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] |\n| 266 | -1 | 0 | 0 | 0 | -1 |\n| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] |\n| 0 | -1 | 0 | 0 | -91 |\n","StackTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/StackArithmetic/StackTest/StackTest.tst\n\n// Tests StackTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 1000 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the stack pointer and the stack contents: RAM[256]-RAM[265]\noutput-list RAM[0]%D2.6.2 \n RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2;\noutput;\noutput-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2;\noutput;\n'},BasicTest:{"BasicTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTest.vm\n\n// Executes pop and push commands.\n\npush constant 10\npop local 0\npush constant 21\npush constant 22\npop argument 2\npop argument 1\npush constant 36\npop this 6\npush constant 42\npush constant 45\npop that 5\npop that 2\npush constant 510\npop temp 6\npush local 0\npush that 5\nadd\npush argument 1\nsub\npush this 6\npush this 6\nadd\nsub\npush temp 6\nadd\n',"BasicTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTestVME.tst\n\n// Tests and illustrates BasicTest.vm on the VM simulator.\n// Starts by setting the stack pointer and the base addresses\n// of relevant memory segments to selected RAM addresses.\n\nload BasicTest.vm,\n\nset sp 256, // stack pointer\nset local 300, // base address of the local segment\nset argument 400, // base address of the argument segment\nset this 3000, // base address of the this segment\nset that 3010, // base address of the that segment\n\nrepeat 25 { // BasicTest.vm has 25 VM commands\n vmstep;\n}\n\n// Outputs the value at the stack\'s base and some values from the tested memory segments\noutput-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 \n RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1\n RAM[3015]%D1.6.1 RAM[11]%D1.6.1;\noutput;\n',"BasicTest.cmp":"|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] |\n| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 |","BasicTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/BasicTest/BasicTest.tst\n\n// Tests BasicTest.asm on the CPU emulator.\n\nset RAM[0] 256, // stack pointer\nset RAM[1] 300, // base address of the local segment\nset RAM[2] 400, // base address of the argument segment\nset RAM[3] 3000, // base address of the this segment\nset RAM[4] 3010, // base address of the that segment\n\nrepeat 600 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base and some values from the tested memory segments\noutput-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 \n RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1\n RAM[3015]%D1.6.1 RAM[11]%D1.6.1;\noutput;\n'},PointerTest:{"PointerTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTest.vm\n\n// Executes pop and push commands using the \n// pointer, this, and that segments.\n\npush constant 3030\npop pointer 0\npush constant 3040\npop pointer 1\npush constant 32\npop this 2\npush constant 46\npop that 6\npush pointer 0\npush pointer 1\nadd\npush this 2\nsub\npush that 6\nadd\n',"PointerTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTestVME.tst\n\n// Tests and illustrates PointerTest.vm on the VM simulator.\n\nload PointerTest.vm,\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 15 { // PointerTest.vm has 15 VM commands\n vmstep;\n}\n\n// Outputs the stack base, THIS, THAT, and\n// some values from the the this and that segments\noutput-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1\n RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;\noutput;\n',"PointerTest.cmp":"|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|\n | 6084 | 3030 | 3040 | 32 | 46 |","PointerTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/PointerTest/PointerTest.tst\n\n// Tests PointerTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 450 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base, THIS, THAT, and\n// some values from the the this and that segments\noutput-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 \n RAM[4]%D1.6.1 RAM[3032]%D1.6.1 RAM[3046]%D1.6.1;\noutput;\n'},StaticTest:{"StaticTest.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTest.vm\n\n// Executes pop and push commands using the static segment.\n\npush constant 111\npush constant 333\npush constant 888\npop static 8\npop static 3\npop static 1\npush static 3\npush static 1\nsub\npush static 8\nadd\n',"StaticTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTestVME.tst\n\n// Tests and illustrates StaticTest.vm on the VM simulator.\n\nload StaticTest.vm,\n\nset sp 256, // initializes the stack pointer\n\nrepeat 11 { // StaticTest.vm has 11 VM commands\n vmstep;\n}\n\n// Outputs the value at the stack\'s base \noutput-list RAM[256]%D1.6.1;\noutput;\n',"StaticTest.cmp":"|RAM[256]|\n| 1110 |","StaticTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/7/MemoryAccess/StaticTest/StaticTest.tst\n\n// Tests StaticTest.asm on the CPU emulator.\n\nset RAM[0] 256, // initializes the stack pointer\n\nrepeat 200 { // enough cycles to complete the execution\n ticktock;\n}\n\n// Outputs the value at the stack\'s base \noutput-list RAM[256]%D1.6.1;\noutput;\n'}};async function z(n){await n.pushd("/projects/07"),await(0,r.cL)(n,E),await n.popd()}async function O(n){await n.pushd("/projects/07"),await c(n,E,".tst"),await c(n,E,"VME.tst"),await c(n,E,".cmp"),await n.popd()}const j={BasicLoop:{"BasicLoop.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoop.vm\n\n// Computes the sum 1 + 2 + ... + n and pushes the result onto\n// the stack. The value n is given in argument[0], which must be \n// initialized by the caller of this code.\n\n\tpush constant 0 \n\tpop local 0 // sum = 0\nlabel LOOP\n\tpush argument 0 \n\tpush local 0\n\tadd\n\tpop local 0\t // sum = sum + n\n\tpush argument 0\n\tpush constant 1\n\tsub\n\tpop argument 0 // n--\n\tpush argument 0\n\tif-goto LOOP // if n > 0, goto LOOP\n\tpush local 0 // else, pushes sum to the stack\'s top\n',"BasicLoopVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoopVME.tst\n\n// Tests and illustrates BasicLoop.vm on the VM emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0].\n\nload BasicLoop.vm,\n\nset sp 256,\nset local 300,\nset argument 400,\nset argument[0] 3,\n\nrepeat 33 {\n \tvmstep;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D1.6.1 RAM[256]%D1.6.1;\noutput;\n',"BasicLoop.cmp":"| RAM[0] |RAM[256]|\n| 257 | 6 |\n","BasicLoop.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/BasicLoop/BasicLoop.tst\n\n// Tests BasicLoop.asm on the CPU emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0].\n\nset RAM[0] 256, // SP\nset RAM[1] 300, // LCL\nset RAM[2] 400, // ARG\nset RAM[400] 3, // argument 0\n\nrepeat 600 {\n\tticktock;\n}\n\n// Outputs the stack pointer and the value at the stack\'s base\noutput-list RAM[0]%D1.6.1 RAM[256]%D1.6.1;\noutput;\n'},FibonacciSeries:{"FibonacciSeries.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeries.vm\n\n// Puts the first n elements of the Fibonacci series in the memory,\n// starting at address addr. n and addr are given in argument[0] and\n// argument[1], which must be initialized by the caller of this code.\n\n\tpush argument 1 // sets THAT, the base address of the\n\tpop pointer 1 // that segment, to argument[1]\n\tpush constant 0 // sets the series\' first and second\n\tpop that 0 // elements to 0 and 1, respectively \n\tpush constant 1 \n\tpop that 1 \n\tpush argument 0 // sets n, the number of remaining elements\n\tpush constant 2 // to be computed, to argument[0] minus 2,\n\tsub // since 2 elements were already computed.\n\tpop argument 0 \n\nlabel LOOP\n\tpush argument 0\n\tif-goto COMPUTE_ELEMENT // if n > 0, goto COMPUTE_ELEMENT\n\tgoto END // otherwise, goto END\n\nlabel COMPUTE_ELEMENT\n // that[2] = that[0] + that[1]\n\tpush that 0\n\tpush that 1\n\tadd\n\tpop that 2\n\t// THAT += 1 (updates the base address of that)\n\tpush pointer 1\n\tpush constant 1\n\tadd\n\tpop pointer 1 \n\t// updates n-- and loops \n\tpush argument 0\n\tpush constant 1\n\tsub\n\tpop argument 0 \n\tgoto LOOP\n\nlabel END\n',"FibonacciSeriesVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst\n\n// Tests and illustrates FibonacciSeries.vm on the VM emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0] to n and argument [1] to the base address\n// of the generated series.\n\nload FibonacciSeries.vm,\n\nset sp 256,\nset local 300,\nset argument 400,\nset argument[0] 6,\nset argument[1] 3000,\n\nrepeat 73 {\n\tvmstep;\n}\n\n// Outputs the series of values generated and written by the code.\noutput-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 \n RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2;\noutput;\n',"FibonacciSeries.cmp":"|RAM[3000]|RAM[3001]|RAM[3002]|RAM[3003]|RAM[3004]|RAM[3005]|\n| 0 | 1 | 1 | 2 | 3 | 5 |\n","FibonacciSeries.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/ProgramFlow/FibonacciSeries/FibonacciSeries.tst\n\n// Tests FibonacciSeries.asm on the CPU emulator.\n// Before executing the code, initializes the stack pointer\n// and the base addresses of the local and argument segments,\n// and sets argument[0] and argument [1].\n\nset RAM[0] 256, // SP\nset RAM[1] 300, // LCL\nset RAM[2] 400, // ARG\nset RAM[400] 6, // argument[0], n\nset RAM[401] 3000, // argument[1], base address of the generated series\n\nrepeat 1100 {\n\tticktock;\n}\n\n// Outputs the series of values generated and written by the code.\noutput-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 \n RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2;\noutput;\n'},SimpleFunction:{"SimpleFunction.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunction.vm\n\n// Performs a simple calculation and returns the result.\n// argument[0] and argument[1] must be set by the caller.\n\nfunction SimpleFunction.test 2\n\tpush local 0\n\tpush local 1\n\tadd\n\tnot\n\tpush argument 0\n\tadd\n\tpush argument 1\n\tsub\n\treturn\n',"SimpleFunctionVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst\n\n// Tests and illustrates SimpleFunction.vm in the VM emulator. \n// Before executing the code, initializes the stack pointer\n// and the base addresses of some of the memory segments, \n// and sets some values in the argument segment.\n\nload SimpleFunction.vm,\n\nset sp 317,\nset local 317,\nset argument 310,\nset this 3000,\nset that 4000,\nset argument[0] 1234,\nset argument[1] 37,\nset argument[2] 9,\nset argument[3] 305,\nset argument[4] 300,\nset argument[5] 3010,\nset argument[6] 4010,\n\nrepeat 10 {\n\tvmstep;\n}\n\n// Outputs SP, LCL, ARG, THIS, THAT, and the return value.\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 \n RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1;\noutput;\n',"SimpleFunction.cmp":"| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] |RAM[310]|\n| 311 | 305 | 300 | 3010 | 4010 | 1196 |\n","SimpleFunction.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/SimpleFunction/SimpleFunction.tst\n\n// Tests SimpleFunction.asm in the CPU emulator.\n// In particular, tests how the assembly implementation of the 'function'\n// VM command initializes local variables, and how the assembly implementation\n// of the 'return' VM command handles the return value, SP, LCL, ARG, THIS, and THAT. \n// Before executing the code, initializes the stack pointer and the pointers of some\n// of the memory segments, and sets some values in the argument segment.\n\nset RAM[0] 317, // SP\nset RAM[1] 317, // LCL\nset RAM[2] 310, // ARG\nset RAM[3] 3000, // THIS\nset RAM[4] 4000, // THAT\nset RAM[310] 1234, \nset RAM[311] 37, \nset RAM[312] 1000, \nset RAM[313] 305,\nset RAM[314] 300,\nset RAM[315] 3010,\nset RAM[316] 4010, \n\nrepeat 300 {\n\tticktock;\n}\n\n// Outputs SP, LCL, ARG, THIS, THAT, and the return value.\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 \n RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1;\noutput;\n"},NestedCall:{"Sys.vm":"// Sys.vm. Tested by the NestedCall test script.\n// Consists of three functions: Sys.init, Sys.main, and Sys.add12.\n\n// Calls Sys.main() and stores a return value in temp 1.\n// Does not return (enters infinite loop).\n// The VM implementation starts running the Sys.init function, by default.\nfunction Sys.init 0\n\tpush constant 4000\t// tests that THIS and THAT are handled correctly\n\tpop pointer 0\n\tpush constant 5000\n\tpop pointer 1\n\tcall Sys.main 0\n\tpop temp 1\n\tlabel LOOP\n\tgoto LOOP\n\n// Sets locals 1, 2 and 3 to some values. Leaves locals 0 and 4 unchanged, \n// to test that the 'function' VM command initliazes them to 0 (the test \n// script sets them to -1 before this code starts running).\n// Calls Sys.add12(123) and stores the return value (should be 135) in temp 0.\n// Returns local 0 + local 1 + local 2 + local 3 + local 4 (should be 456), to \n// confirm that locals were not mangled by the function call.\nfunction Sys.main 5\n\tpush constant 4001\n\tpop pointer 0\n\tpush constant 5001\n\tpop pointer 1\n\tpush constant 200\n\tpop local 1\n\tpush constant 40\n\tpop local 2\n\tpush constant 6\n\tpop local 3\n\tpush constant 123\n\tcall Sys.add12 1\n\tpop temp 0\n\tpush local 0\n\tpush local 1\n\tpush local 2\n\tpush local 3\n\tpush local 4\n\tadd\n\tadd\n\tadd\n\tadd\n\treturn\n\n// Returns (argument 0) + 12.\nfunction Sys.add12 0\n\tpush constant 4002\n\tpop pointer 0\n\tpush constant 5002\n\tpop pointer 1\n\tpush argument 0\n\tpush constant 12\n\tadd\n\treturn\n","NestedCallVME.tst":"// Tests and illustrates how the VM implementation handles function-call-and-return,\n// by executing the functions in Sys.vm in the VM emulator.\n// In particular, loads and runs the functions in Sys.vm.\n\nload Sys.vm,\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1;\n\nset RAM[0] 261,\nset RAM[1] 261,\nset RAM[2] 256,\nset RAM[3] -3,\nset RAM[4] -4,\nset RAM[5] -1, // test results\nset RAM[6] -1,\nset RAM[256] 1234, // fake stack frame from call Sys.init\nset RAM[257] -1,\nset RAM[258] -2,\nset RAM[259] -3,\nset RAM[260] -4,\n\nset RAM[261] -1, // Initialize stack to check for local segment\nset RAM[262] -1, // being cleared to zero.\nset RAM[263] -1,\nset RAM[264] -1,\nset RAM[265] -1,\nset RAM[266] -1,\nset RAM[267] -1,\nset RAM[268] -1,\nset RAM[269] -1,\nset RAM[270] -1,\nset RAM[271] -1,\nset RAM[272] -1,\nset RAM[273] -1,\nset RAM[274] -1,\nset RAM[275] -1,\nset RAM[276] -1,\nset RAM[277] -1,\nset RAM[278] -1,\nset RAM[279] -1,\nset RAM[280] -1,\nset RAM[281] -1,\nset RAM[282] -1,\nset RAM[283] -1,\nset RAM[284] -1,\nset RAM[285] -1,\nset RAM[286] -1,\nset RAM[287] -1,\nset RAM[288] -1,\nset RAM[289] -1,\nset RAM[290] -1,\nset RAM[291] -1,\nset RAM[292] -1,\nset RAM[293] -1,\nset RAM[294] -1,\nset RAM[295] -1,\nset RAM[296] -1,\nset RAM[297] -1,\nset RAM[298] -1,\nset RAM[299] -1,\n\nset sp 261,\nset local 261,\nset argument 256,\nset this 3000,\nset that 4000;\n\nrepeat 50 {\n\tvmstep;\n}\noutput;\n","NestedCall.cmp":"| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] |\n| 261 | 261 | 256 | 4000 | 5000 | 135 | 246 |\n","NestedCall.tst":"// Tests how the VM implementation handles function-call-and-return,\n// by executing the functions in Sys.vm.\n// In particular, loads and runs NestedCall.asm, which results when \n// the VM translator is applied to the NestedCall folder, which \n// includes only one VM file: Sys.vm.\n\nset RAM[0] 261,\nset RAM[1] 261,\nset RAM[2] 256,\nset RAM[3] -3,\nset RAM[4] -4,\nset RAM[5] -1, // test results\nset RAM[6] -1,\nset RAM[256] 1234, // fake stack frame from call Sys.init\nset RAM[257] -1,\nset RAM[258] -2,\nset RAM[259] -3,\nset RAM[260] -4,\n\nset RAM[261] -1, // Initializes the stack, to check that the local segment\nset RAM[262] -1, // is initialized to zeros by the 'function' VM command.\nset RAM[263] -1,\nset RAM[264] -1,\nset RAM[265] -1,\nset RAM[266] -1,\nset RAM[267] -1,\nset RAM[268] -1,\nset RAM[269] -1,\nset RAM[270] -1,\nset RAM[271] -1,\nset RAM[272] -1,\nset RAM[273] -1,\nset RAM[274] -1,\nset RAM[275] -1,\nset RAM[276] -1,\nset RAM[277] -1,\nset RAM[278] -1,\nset RAM[279] -1,\nset RAM[280] -1,\nset RAM[281] -1,\nset RAM[282] -1,\nset RAM[283] -1,\nset RAM[284] -1,\nset RAM[285] -1,\nset RAM[286] -1,\nset RAM[287] -1,\nset RAM[288] -1,\nset RAM[289] -1,\nset RAM[290] -1,\nset RAM[291] -1,\nset RAM[292] -1,\nset RAM[293] -1,\nset RAM[294] -1,\nset RAM[295] -1,\nset RAM[296] -1,\nset RAM[297] -1,\nset RAM[298] -1,\nset RAM[299] -1,\n\nrepeat 4000 {\n\tticktock;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1;\noutput;\n"},FibonacciElement:{"Sys.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/Sys.vm\n\n// Containts one function: Sys.init.\n\n// Pushes a constant n onto the stack, and calls the Main.fibonacii\n// function, which computes the n\'th element of the Fibonacci series.\n// Note that by convention, the Sys.init function is called "automatically" \n// by the bootstrap code generated by the VM translator.\nfunction Sys.init 0\n // Computes fibonacci(4)\n\tpush constant 4\n\t// Calls the function, informing that one argument was pushed onto the stack\n\tcall Main.fibonacci 1\nlabel END \n\tgoto END // loops infinitely',"Main.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/Main.vm\n\n// Contains one function: Main.fibonacci.\n\n// Computes the n\'th element of the Fibonacci series, recursively.\n// n is given in argument[0]. Called by the Sys.init function \n// (part of the Sys.vm file), which sets argument[0] to an input\n// value and then calls Main.fibonacci.\nfunction Main.fibonacci 0\n\tpush argument 0\n\tpush constant 2\n\tlt \n\tif-goto N_LT_2 \n\tgoto N_GE_2\nlabel N_LT_2 // if n < 2 returns n\n\tpush argument 0 \n\treturn\nlabel N_GE_2 // if n >= 2 returns fib(n - 2) + fib(n - 1)\n\tpush argument 0\n\tpush constant 2\n\tsub\n\tcall Main.fibonacci 1 // computes fib(n - 2)\n\tpush argument 0\n\tpush constant 1\n\tsub\n\tcall Main.fibonacci 1 // computes fib(n - 1)\n\tadd // returns fib(n - 1) + fib(n - 2)\n\treturn\n',"FibonacciElementVME.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/FibonacciElementVME.tst\n\n// Tests and illustrates the given Fibonacci element program on the VM emulator.\n\nload,\n\nset sp 261,\n\nrepeat 110 {\n vmstep;\n}\n\n// Outputs the stack pointer and the value at the stack's base.\n// That's where the implementation should put the return value. \noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;\noutput;\n","FibonacciElement.cmp":"| RAM[0] |RAM[261]|\n| 262 | 3 |\n","FibonacciElement.tst":"// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/FibonacciElement/FibonacciElement.tst\n\n// Tests FibonacciElement.asm on the CPU emulator. \n// FibonacciElement.asm results from translating Main.vm and Sys.vm into\n// a single assembly program, stored in the file FibonacciElement.asm.\n\nrepeat 6000 {\n\tticktock;\n}\n\n// Outputs the stack pointer and the value at the stack's base.\n// That's where the implementation should put the return value.\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1;\noutput;\n"},StaticsTest:{"Class1.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Class1.vm\n\n// Stores two supplied arguments in static[0] and static[1].\nfunction Class1.set 0\n\tpush argument 0\n\tpop static 0\n\tpush argument 1\n\tpop static 1\n\tpush constant 0\n\treturn\n\n// Returns static[0] - static[1].\nfunction Class1.get 0\n\tpush static 0\n\tpush static 1\n\tsub\n\treturn',"Class2.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Class2.vm\n\n// Stores two supplied arguments in static[0] and static[1].\nfunction Class2.set 0\n\tpush argument 0\n\tpop static 0\n\tpush argument 1\n\tpop static 1\n\tpush constant 0\n\treturn\n\n// Returns static[0] - static[1].\nfunction Class2.get 0\n\tpush static 0\n\tpush static 1\n\tsub\n\treturn',"Sys.vm":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/Sys.vm\n\n// Tests that different functions, stored in two different \n// class files, manipulate the static segment correctly. \n\nfunction Sys.init 0\n\tpush constant 6\n\tpush constant 8\n\tcall Class1.set 2\n\tpop temp 0 // dumps the return value\n\tpush constant 23\n\tpush constant 15\n\tcall Class2.set 2\n\tpop temp 0 // dumps the return value\n\tcall Class1.get 0\n\tcall Class2.get 0\nlabel END\n\tgoto END',"StaticsTestVME.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/StaticsTestVME.tst\n\n// Tests and illustrates the statics test on the VM emulator.\n\nload,\n\nset sp 261,\n\nrepeat 36 {\n\tvmstep;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1;\noutput;\n',"StaticsTest.cmp":"| RAM[0] |RAM[261]|RAM[262]|\n| 263 | -2 | 8 |\n","StaticsTest.tst":'// This file is part of www.nand2tetris.org\n// and the book "The Elements of Computing Systems"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/8/FunctionCalls/StaticsTest/StaticsTest.tst\n\n// Tests StaticTest.asm in the CPU emulator.\n// This assembly file results from translating the staticsTest folder.\n\nset RAM[0] 256,\n\nrepeat 2500 {\n\tticktock;\n}\n\noutput-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1;\noutput;\n'}};async function L(n){await n.pushd("/projects/08"),await(0,r.cL)(n,j),await n.popd()}async function U(n){await n.pushd("/projects/08"),await c(n,j,".tst"),await c(n,j,"VME.tst"),await c(n,j,".cmp"),await n.popd()}var H=e(9828);const K={"01":s,"02":o,"03":u,"05":d},X={"07":i,"08":p},V={1:s,2:o,3:u,4:a,5:d,6:H,7:i,8:p};let W=!1;const J=async(n,t)=>{if(!W){W=!0,t??=[1,2,3,4,6,5,7,8];for(const e of t)Object.keys(V).includes(e.toString())&&await V[e].resetFiles(n);W=!1}},G=async(n,t)=>{if(!W){W=!0,t??=[1,2,3,4,5,7,8];for(const e of t)Object.keys(V).includes(e.toString())&&await V[e].resetTests(n);W=!1}},_={...l,...m,...R,...P,...E,...j}}}]);
\ No newline at end of file
diff --git a/static/js/598.183c6bb5.chunk.js b/static/js/598.183c6bb5.chunk.js
new file mode 100644
index 000000000..6709855ac
--- /dev/null
+++ b/static/js/598.183c6bb5.chunk.js
@@ -0,0 +1 @@
+"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[598],{6598:(e,l,a)=>{a.r(l),a.d(l,{Compiler:()=>g,default:()=>b});var t=a(6458),s=a(8256),n=a(4544),i=a(910),o=a(1916),r=a(8878),d=a(8330),c=a(3508),u=a(2675),h=a(1384),x=a(8029),m=a(3600),v=a(5168),j=a(3499),p=a(782);const g=()=>{const{setStatus:e}=(0,r.useContext)(i.L),{tracking:l}=(0,r.useContext)(x.BR),{stores:a,setTool:g}=(0,r.useContext)(m.NQ),{state:b,dispatch:C,actions:k}=a.compiler,[N,w]=(0,r.useState)(0),[S,E]=(0,r.useState)(!1),T=(0,r.useRef)(null);(0,r.useEffect)((()=>{g("compiler")}),[g]);(0,r.useEffect)((()=>{S||(()=>{const l=b.compiled[b.selected];var a,t;l&&e(l.valid?"":null!==(a=null===(t=l.error)||void 0===t?void 0:t.message)&&void 0!==a?a:"")})()}),[b.selected,b.files,S]);const _=(0,r.useCallback)((e=>{C.current({action:"setSelected",payload:e}),l.trackEvent("tab","change",e)}),[l]);(0,r.useEffect)((()=>{w(Object.keys(b.files).indexOf(b.selected))}),[b.selected]);const F=(0,c.s)(),R=(0,p.jsx)(y,{title:"Create New File",buttonText:"Create",dialog:F,isValid:e=>{var l;return null!==(l=(null===e||void 0===e?void 0:e.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/))&&!Object.keys(b.files).includes(e))&&void 0!==l&&l},onExit:async e=>{e&&(await k.writeFile(e),_(e),E(!1))}});return(0,p.jsxs)("div",{className:"Page CompilerPage grid",children:[(0,p.jsx)(d.N_,{ref:T,to:j.Ay.vm.href,style:{display:"none"}}),R,(0,p.jsx)(v.Z,{className:"code",header:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{children:(0,p.jsx)(t.x6,{id:"wdxz7K"})}),(0,p.jsxs)("div",{className:"flex row flex-1",children:[(0,p.jsx)("button",{"data-tooltip":s.Ru._({id:"FZeS2z"}),"data-placement":"right",className:"flex-0",onClick:async()=>{const l=await(0,o.EH)(),a=new n.Q2(new o.Ik(l));C.current({action:"setTitle",payload:`${l.name} / *.jack`});0==(await a.scandir("/")).filter((e=>e.isFile()&&e.name.endsWith(".jack"))).length?(e("No .jack files in the selected folder"),E(!0)):(e(""),E(!1)),k.loadProject(a)},children:"\ud83d\udcc2"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{"data-tooltip":s.Ru._({id:"oXeVWH"}),"data-placement":"right",className:"flex-0",onClick:()=>{b.fs?F.open():e("No project folder loaded")},children:"+"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{className:"flex-0","data-tooltip":"Compile all the opened Jack files","data-placement":"bottom",onClick:()=>{b.isValid&&(k.compile(),e("Compiled successfully"))},disabled:!b.isValid,children:"Compile"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{className:"flex-0",disabled:!b.isCompiled,"data-tooltip":s.Ru._({id:"1/5eLk"}),"data-placement":"bottom",onClick:()=>{var e;b.title&&a.vm.dispatch.current({action:"setTitle",payload:b.title.replace(".jack",".vm")}),a.vm.actions.loadVm((()=>{const e=[];for(const a of Object.keys(b.files)){var l;let t=null!==(l=b.compiled[a].vm)&&void 0!==l?l:"";t=`// Compiled ${a}.jack:\n`.concat(t),e.push({name:a,content:t})}return e})()),null===(e=T.current)||void 0===e||e.click()},children:"Run"})]})]}),children:(0,p.jsx)(h.w,{tabIndex:{value:N,set:w},children:Object.keys(b.files).map((e=>(0,p.jsx)(h.o,{title:`${e}.jack`,onSelect:()=>_(e),style:{backgroundColor:b.compiled[e].valid?void 0:"#ffaaaa"},children:(0,p.jsx)(u.K,{value:b.files[e],onChange:l=>{k.writeFile(e,l)},error:b.compiled[e].error,language:"jack"})},e)))})})]})},b=g;function f(){return(0,p.jsx)("div",{style:{width:"0.25vw"}})}const y=({title:e,buttonText:l,dialog:a,isValid:s,onExit:n})=>{const[i,o]=(0,r.useState)();return(0,p.jsx)("dialog",{open:a.isOpen,children:(0,p.jsxs)("article",{children:[(0,p.jsxs)("header",{children:[(0,p.jsx)(t.x6,{id:"pDgeaz",values:{title:e}}),(0,p.jsx)("a",{className:"close",href:"#root",onClick:e=>{e.preventDefault(),n(),a.close()}})]}),(0,p.jsxs)("main",{children:[(0,p.jsxs)("div",{className:"flex row",children:[(0,p.jsx)("input",{value:i,onChange:e=>o(e.target.value)}),(0,p.jsx)("span",{children:".jack"})]}),(0,p.jsx)("button",{disabled:!s(null!==i&&void 0!==i?i:""),onClick:()=>{a.close(),o(""),n(i)},children:l})]})]})})}},2675:(e,l,a)=>{a.d(l,{K:()=>c});var t=a(6458),s=a(8878),n=a(8029),i=a(782);const o=(0,s.lazy)((()=>Promise.all([a.e(983),a.e(535),a.e(965)]).then(a.bind(a,8965)))),r=({error:e})=>e?(0,i.jsxs)("details",{className:"ErrorPanel",open:!0,children:[(0,i.jsx)("summary",{role:"button",className:"secondary",children:(0,i.jsx)(t.x6,{id:"1tSpqV"})}),(0,i.jsx)("pre",{children:(0,i.jsx)("code",{children:null===e||void 0===e?void 0:e.message})})]}):(0,i.jsx)(i.Fragment,{}),d=({value:e,onChange:l,language:a,disabled:t=!1})=>{const[n,o]=(0,s.useState)(e);return(0,i.jsx)("textarea",{"data-testid":`editor-${a}`,disabled:t,value:n,onChange:e=>{var a;const t=null===(a=e.target)||void 0===a?void 0:a.value;o(t),l(t)}})},c=({className:e="",style:l={},disabled:a=!1,value:t,error:c,onChange:u,onCursorPositionChange:h,grammar:x,language:m,highlight:v,highlightType:j="highlight",customDecorations:p=[],dynamicHeight:g=!1,alwaysRecenter:b=!0,lineNumberTransform:f})=>{const{monaco:y}=(0,s.useContext)(n.BR);return(0,i.jsx)("div",{className:`Editor ${g?"dynamic-height":""} ${e}`,style:l,children:y.canUse&&y.wants?(0,i.jsx)(s.Suspense,{fallback:"Loading...",children:(0,i.jsx)(o,{value:t,onChange:u,onCursorPositionChange:h,language:m,error:c,disabled:a,highlight:v,highlightType:j,customDecorations:p,dynamicHeight:g,alwaysRecenter:b,lineNumberTransform:f})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d,{value:t,onChange:u,language:m,disabled:a}),(0,i.jsx)(r,{error:c})]})})}},5168:(e,l,a)=>{a.d(l,{p:()=>n,Z:()=>s});var t=a(782);const s=e=>{var l;return(0,t.jsxs)("article",{className:["panel",null!==(l=e.className)&&void 0!==l?l:"",e.isEditorPanel?"editor":""].join(" "),children:[e.header&&(0,t.jsx)("header",{children:e.header}),(0,t.jsx)("main",{children:e.children}),e.footer&&(0,t.jsx)("footer",{children:e.footer})]})},n=e=>{var l;return(0,t.jsxs)("details",{className:null!==(l=e.className)&&void 0!==l?l:"",open:e.open,style:e.style,children:[(0,t.jsx)("summary",{children:(0,t.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})}},1384:(e,l,a)=>{a.d(l,{o:()=>n,w:()=>i});var t=a(8878),s=a(782);const n=e=>{const l=(0,t.useId)(),a=`tab-${l}`,n=`panel-${l}`;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{role:"tab",id:a,"aria-controls":n,style:e.style,children:(0,s.jsxs)("label",{children:[e.title,(0,s.jsx)("input",{type:"radio",name:e.parent,"aria-controls":n,value:a,checked:e.checked,onChange:l=>{var a;return 1==l.target.checked&&(null===(a=e.onSelect)||void 0===a?void 0:a.call(e))}})]})}),(0,s.jsx)("div",{role:"tabpanel",id:n,"aria-labelledby":a,children:e.children})]})},i=e=>{var l,a,n,i;const o=(0,t.useId)(),[r,d]=(0,t.useState)(0),c=null!==(l=null===(a=e.tabIndex)||void 0===a?void 0:a.value)&&void 0!==l?l:r,u=null!==(n=null===(i=e.tabIndex)||void 0===i?void 0:i.set)&&void 0!==n?n:d;return(0,s.jsx)("section",{role:"tablist",style:{"--tab-count":e.children.length},children:t.Children.map(e.children,((e,l)=>(0,t.cloneElement)(e,{checked:l===c,parent:o,idx:l,onSelect:()=>{var a,t;u(l),null===(a=e.props)||void 0===a||null===(t=a.onSelect)||void 0===t||t.call(a)}})))})}}}]);
\ No newline at end of file
diff --git a/static/js/598.beb31f34.chunk.js b/static/js/598.beb31f34.chunk.js
deleted file mode 100644
index c15a35e97..000000000
--- a/static/js/598.beb31f34.chunk.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[598],{6598:(e,l,a)=>{a.r(l),a.d(l,{Compiler:()=>g,default:()=>b});var t=a(6458),s=a(8256),n=a(4544),i=a(910),o=a(1916),r=a(8878),d=a(8330),c=a(3508),u=a(2675),h=a(1384),x=a(8029),m=a(3600),v=a(5168),j=a(3499),p=a(782);const g=()=>{const{setStatus:e}=(0,r.useContext)(i.L),{tracking:l}=(0,r.useContext)(x.BR),{stores:a,setTool:g}=(0,r.useContext)(m.NQ),{state:b,dispatch:C,actions:k}=a.compiler,[N,w]=(0,r.useState)(0),S=(0,r.useRef)(null);(0,r.useEffect)((()=>{g("compiler")}),[g]);(0,r.useEffect)((()=>{(()=>{const l=b.compiled[b.selected];var a,t;l&&e(l.valid?"":null!==(a=null===(t=l.error)||void 0===t?void 0:t.message)&&void 0!==a?a:"")})()}),[b.selected,b.files]);const E=(0,r.useCallback)((e=>{C.current({action:"setSelected",payload:e}),l.trackEvent("tab","change",e)}),[l]);(0,r.useEffect)((()=>{w(Object.keys(b.files).indexOf(b.selected))}),[b.selected]);const T=(0,c.s)(),_=(0,p.jsx)(y,{title:"Create New File",buttonText:"Create",dialog:T,isValid:e=>{var l;return null!==(l=(null===e||void 0===e?void 0:e.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/))&&!Object.keys(b.files).includes(e))&&void 0!==l&&l},onExit:async e=>{e&&(await k.writeFile(e),E(e))}});return(0,p.jsxs)("div",{className:"Page CompilerPage grid",children:[(0,p.jsx)(d.N_,{ref:S,to:j.Ay.vm.href,style:{display:"none"}}),_,(0,p.jsx)(v.Z,{className:"code",header:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{children:(0,p.jsx)(t.x6,{id:"wdxz7K"})}),(0,p.jsxs)("div",{className:"flex row flex-1",children:[(0,p.jsx)("button",{"data-tooltip":s.Ru._({id:"FZeS2z"}),"data-placement":"right",className:"flex-0",onClick:async()=>{const l=await(0,o.EH)(),a=new n.Q2(new o.Ik(l));C.current({action:"setTitle",payload:`${l.name} / *.jack`}),e(""),k.loadProject(a)},children:"\ud83d\udcc2"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{"data-tooltip":s.Ru._({id:"oXeVWH"}),"data-placement":"right",className:"flex-0",onClick:()=>{b.fs?T.open():e("No project folder loaded")},children:"+"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{className:"flex-0","data-tooltip":"Compile all the opened Jack files","data-placement":"bottom",onClick:()=>{b.isValid&&(k.compile(),e("Compiled successfully"))},disabled:!b.isValid,children:"Compile"}),(0,p.jsx)(f,{}),(0,p.jsx)("button",{className:"flex-0",disabled:!b.isCompiled,"data-tooltip":s.Ru._({id:"1/5eLk"}),"data-placement":"bottom",onClick:()=>{var e;b.title&&a.vm.dispatch.current({action:"setTitle",payload:b.title.replace(".jack",".vm")}),a.vm.actions.loadVm((()=>{const e=[];for(const a of Object.keys(b.files)){var l;let t=null!==(l=b.compiled[a].vm)&&void 0!==l?l:"";t=`// Compiled ${a}.jack:\n`.concat(t),e.push({name:a,content:t})}return e})()),null===(e=S.current)||void 0===e||e.click()},children:"Run"})]})]}),children:(0,p.jsx)(h.w,{tabIndex:{value:N,set:w},children:Object.keys(b.files).map((e=>(0,p.jsx)(h.o,{title:`${e}.jack`,onSelect:()=>E(e),style:{backgroundColor:b.compiled[e].valid?void 0:"#ffaaaa"},children:(0,p.jsx)(u.K,{value:b.files[e],onChange:l=>{k.writeFile(e,l)},error:b.compiled[e].error,language:"jack"})},e)))})})]})},b=g;function f(){return(0,p.jsx)("div",{style:{width:"0.25vw"}})}const y=({title:e,buttonText:l,dialog:a,isValid:s,onExit:n})=>{const[i,o]=(0,r.useState)();return(0,p.jsx)("dialog",{open:a.isOpen,children:(0,p.jsxs)("article",{children:[(0,p.jsxs)("header",{children:[(0,p.jsx)(t.x6,{id:"pDgeaz",values:{title:e}}),(0,p.jsx)("a",{className:"close",href:"#root",onClick:e=>{e.preventDefault(),n(),a.close()}})]}),(0,p.jsxs)("main",{children:[(0,p.jsxs)("div",{className:"flex row",children:[(0,p.jsx)("input",{value:i,onChange:e=>o(e.target.value)}),(0,p.jsx)("span",{children:".jack"})]}),(0,p.jsx)("button",{disabled:!s(null!==i&&void 0!==i?i:""),onClick:()=>{a.close(),o(""),n(i)},children:l})]})]})})}},2675:(e,l,a)=>{a.d(l,{K:()=>c});var t=a(6458),s=a(8878),n=a(8029),i=a(782);const o=(0,s.lazy)((()=>Promise.all([a.e(983),a.e(535),a.e(965)]).then(a.bind(a,8965)))),r=({error:e})=>e?(0,i.jsxs)("details",{className:"ErrorPanel",open:!0,children:[(0,i.jsx)("summary",{role:"button",className:"secondary",children:(0,i.jsx)(t.x6,{id:"1tSpqV"})}),(0,i.jsx)("pre",{children:(0,i.jsx)("code",{children:null===e||void 0===e?void 0:e.message})})]}):(0,i.jsx)(i.Fragment,{}),d=({value:e,onChange:l,language:a,disabled:t=!1})=>{const[n,o]=(0,s.useState)(e);return(0,i.jsx)("textarea",{"data-testid":`editor-${a}`,disabled:t,value:n,onChange:e=>{var a;const t=null===(a=e.target)||void 0===a?void 0:a.value;o(t),l(t)}})},c=({className:e="",style:l={},disabled:a=!1,value:t,error:c,onChange:u,onCursorPositionChange:h,grammar:x,language:m,highlight:v,highlightType:j="highlight",customDecorations:p=[],dynamicHeight:g=!1,alwaysRecenter:b=!0,lineNumberTransform:f})=>{const{monaco:y}=(0,s.useContext)(n.BR);return(0,i.jsx)("div",{className:`Editor ${g?"dynamic-height":""} ${e}`,style:l,children:y.canUse&&y.wants?(0,i.jsx)(s.Suspense,{fallback:"Loading...",children:(0,i.jsx)(o,{value:t,onChange:u,onCursorPositionChange:h,language:m,error:c,disabled:a,highlight:v,highlightType:j,customDecorations:p,dynamicHeight:g,alwaysRecenter:b,lineNumberTransform:f})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d,{value:t,onChange:u,language:m,disabled:a}),(0,i.jsx)(r,{error:c})]})})}},5168:(e,l,a)=>{a.d(l,{p:()=>n,Z:()=>s});var t=a(782);const s=e=>{var l;return(0,t.jsxs)("article",{className:["panel",null!==(l=e.className)&&void 0!==l?l:"",e.isEditorPanel?"editor":""].join(" "),children:[e.header&&(0,t.jsx)("header",{children:e.header}),(0,t.jsx)("main",{children:e.children}),e.footer&&(0,t.jsx)("footer",{children:e.footer})]})},n=e=>{var l;return(0,t.jsxs)("details",{className:null!==(l=e.className)&&void 0!==l?l:"",open:e.open,style:e.style,children:[(0,t.jsx)("summary",{children:(0,t.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})}},1384:(e,l,a)=>{a.d(l,{o:()=>n,w:()=>i});var t=a(8878),s=a(782);const n=e=>{const l=(0,t.useId)(),a=`tab-${l}`,n=`panel-${l}`;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{role:"tab",id:a,"aria-controls":n,style:e.style,children:(0,s.jsxs)("label",{children:[e.title,(0,s.jsx)("input",{type:"radio",name:e.parent,"aria-controls":n,value:a,checked:e.checked,onChange:l=>{var a;return 1==l.target.checked&&(null===(a=e.onSelect)||void 0===a?void 0:a.call(e))}})]})}),(0,s.jsx)("div",{role:"tabpanel",id:n,"aria-labelledby":a,children:e.children})]})},i=e=>{var l,a,n,i;const o=(0,t.useId)(),[r,d]=(0,t.useState)(0),c=null!==(l=null===(a=e.tabIndex)||void 0===a?void 0:a.value)&&void 0!==l?l:r,u=null!==(n=null===(i=e.tabIndex)||void 0===i?void 0:i.set)&&void 0!==n?n:d;return(0,s.jsx)("section",{role:"tablist",style:{"--tab-count":e.children.length},children:t.Children.map(e.children,((e,l)=>(0,t.cloneElement)(e,{checked:l===c,parent:o,idx:l,onSelect:()=>{var a,t;u(l),null===(a=e.props)||void 0===a||null===(t=a.onSelect)||void 0===t||t.call(a)}})))})}}}]);
\ No newline at end of file
diff --git a/static/js/main.66e9b6eb.js b/static/js/main.9984f23c.js
similarity index 98%
rename from static/js/main.66e9b6eb.js
rename to static/js/main.9984f23c.js
index 4e84def72..516d78ac5 100644
--- a/static/js/main.66e9b6eb.js
+++ b/static/js/main.9984f23c.js
@@ -1,2 +1,2 @@
-/*! For license information please see main.66e9b6eb.js.LICENSE.txt */
-(()=>{"use strict";var e={8029:(e,t,n)=>{n.d(t,{BR:()=>c,Us:()=>u});var r=n(4544),i=n(8878),s=n(3508),a=n(6073),o=n(5270);function l(){const e=!0,[t,n]=(0,i.useState)(e),r=(0,i.useCallback)((e=>{n(!!e)}),[e]);return{canUse:e,wants:t,toggle:r}}function u(e=new r.Q2){const[t,n]=(0,i.useState)("system");return{monaco:l(),settings:(0,s.s)(),filePicker:(0,a.g3)(),tracking:(0,o.z1)(),theme:t,setTheme:n}}const c=(0,i.createContext)({monaco:{canUse:!0,wants:!0,toggle(){}},filePicker:{close(){},open(){},select:e=>Promise.reject(""),isOpen:!1,suffix:void 0},settings:{close(){},open(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept(){},reject(){},trackEvent(){},trackPage(){}},theme:"system",setTheme(){}})},3600:(e,t,n)=>{n.d(t,{NQ:()=>G,qK:()=>q});var r=n(5874),i=n(7076),s=n(4666),a=n(7844),o=n(8878),l=n(1593),u=n(910);class c{asm={instructions:[]};current=-1;done=!1;symbols=[];variables=new Map;lines=[];lineNumbers=[];getResult(){return this.lines.join("\n")}load(e,t){this.symbols=[{name:"R0",value:"0"},{name:"R1",value:"1"},{name:"R2",value:"2"},{name:"...",value:""},{name:"R15",value:"15"},{name:"SCREEN",value:i.L7.toString()},{name:"KBD",value:i.ky.toString()}],this.variables.clear(),this.asm=e;const n=(0,s.EU)(e,((e,t,n)=>{n?this.variables.set(t,{name:e,isHidden:!0}):this.symbols.push({name:e,value:t.toString()})}));return(0,r.ys)(n)?n:(e.instructions=e.instructions.filter((({type:e})=>"L"!==e)),this.resolveLineNumbers(t),this.reset(),(0,r.Ok)())}resolveLineNumbers(e){this.lineNumbers=Array(e);let t=0;for(const n of this.asm.instructions)"A"!==n.type&&"C"!==n.type||void 0==n.span||(this.lineNumbers[n.span.line]=t,t+=1)}step(e){if(this.current>=this.asm.instructions.length-1)return;this.current+=1;const t=this.asm.instructions[this.current];if("A"===t.type||"C"===t.type){e.sourceHighlight=t.span;const n=(0,s.ld)(this.asm.instructions[this.current]);if(void 0===n)return;if(this.lines.push(`${(0,a.e5)(n)}`),e.resultHighlight={start:17*this.current,end:17*(this.current+1),line:-1},e.sourceHighlight&&e.highlightMap.set(e.sourceHighlight,e.resultHighlight),(0,s.J$)(t)){const e=this.variables.get(t.value);void 0!=e&&e.isHidden&&(this.symbols.push({name:e.name,value:t.value.toString()}),e.isHidden=!1)}this.current===this.asm.instructions.length-1&&(this.done=!0)}}resetSymbols(){for(const t of this.variables.values())t.isHidden=!0;const e=new Set(Array.from(this.variables.values()).map((e=>e.name)));this.symbols=this.symbols.filter((t=>!e.has(t.name)))}reset(){this.current=-1,this.lines=[],this.done=!1,this.resetSymbols()}}function p(){const{setStatus:e,fs:t}=(0,o.useContext)(u.L),n=(0,o.useRef)((()=>{})),{initialState:i,reducers:a,actions:p}=(0,o.useMemo)((()=>function(e,t,n){const i=new c,a={resultHighlight:void 0,sourceHighlight:void 0,highlightMap:new Map};let o,l=!0,u=!1,p=!1,d=!1;const h={setAsm(e,{asm:t,path:n}){e.asm=t,n&&(e.path=n)},setCmp(e,{cmp:n,name:r}){e.compare=n,e.compareName=r,t("Loaded compare file")},setError(e,n){n&&t(n.message),e.error=n},update(e){e.translating=p,e.current=i.current,e.result=i.getResult(),e.symbols=Array.from(i.symbols),e.lineNumbers=Array.from(i.lineNumbers),e.sourceHighlight=a.sourceHighlight,e.resultHighlight=a.resultHighlight,e.compareError=d},compare(e){const n=e.result.split("\n"),r=e.compare.split("\n").filter((e=>""!=e.trim()));if(n.length!=r.length)return d=!0,void t("Comparison failed - different lengths");for(let i=0;i{this.compileAsm(e)}))},saveAsm(t){o&&e.writeFile(o,t)},compileAsm(e){this.reset();const a=s.y0.parse(e);if((0,r.ys)(a))return n.current({action:"setError",payload:(0,r._)(a)}),void(u=!1);const o=i.load((0,r.Ok)(a),e.split("\n").length);if((0,r.ys)(o))return n.current({action:"setError",payload:(0,r._)(o)}),void(u=!1);u=i.asm.instructions.length>0,t(""),n.current({action:"setError"}),n.current({action:"update"})},setAnimate(e){l=e},step:()=>(u&&(p=!0),i.step(a),(l||i.done)&&n.current({action:"update"}),i.done&&t("Translation done."),i.done),compare(){n.current({action:"compare"}),this.updateHighlight(a.resultHighlight?.start??0,!1),n.current({action:"update"})},updateHighlight(e,t){if(!d){for(const[n,r]of a.highlightMap)(t&&n.start<=e&&e<=n.end||!t&&r.start<=e&&e<=r.end)&&(a.sourceHighlight=n,a.resultHighlight=r);n.current({action:"update"})}},resetHighlightInfo(){a.sourceHighlight=void 0,a.resultHighlight=void 0,a.highlightMap.clear()},reset(){d=!1,p=!1,t("Reset"),i.reset(),this.resetHighlightInfo(),n.current({action:"update"})},clear(){this.setAsm(""),n.current({action:"setTitle",payload:void 0}),n.current({action:"setCmp",payload:""}),this.reset()},overrideState(e){if(this.resetHighlightInfo(),this.setAsm(e.asm,e.path),n.current({action:"setCmp",payload:{cmp:e.compare,name:e.compareName}}),e.translating)for(let t=0;t<=e.current;t++)this.step();n.current({action:"update"})}};return{initialState:{asm:"",path:void 0,translating:!1,current:-1,resultHighlight:void 0,sourceHighlight:void 0,symbols:[],result:"",compare:"",compareName:void 0,lineNumbers:[],compareError:!1,config:{speed:2}},reducers:h,actions:f}}(t,e,n)),[e,n]),[d,h]=(0,l.A)(a,i);return n.current=h,{state:d,dispatch:n,actions:p}}var d=n(3180),h=n(3977),f=n(9563);const m='Jack <: Base {\n Root := Class\n\n whitespace = (lineComment | comment | space)\n\n class = "class" whitespace+\n Class = class jackIdentifier OpenBrace ClassVarDec* SubroutineDec* CloseBrace\n\n type = ("int" | "char" | "boolean" | jackIdentifier) whitespace+\n\n classVarType = ("static" | "field") whitespace+\n ClassVarDec = classVarType type jackIdentifier TrailingIdentifier* Semi\n TrailingIdentifier = Comma jackIdentifier\n\n void = "void" whitespace+\n returnType = (type | void) \n subroutineType = ("constructor" | "function" | "method") whitespace+\n SubroutineDec = subroutineType returnType jackIdentifier OpenParen ParameterList CloseParen SubroutineBody\n\n\n Parameter = type jackIdentifier\n Parameters = Parameter TrailingParameter*\n TrailingParameter = Comma Parameter\n ParameterList = Parameters?\n\n SubroutineBody = OpenBrace VarDec* Statement* CloseBrace\n\n var = "var" whitespace+\n VarDec = var type jackIdentifier TrailingIdentifier* Semi\n\n Statement = LetStatement | IfStatement | WhileStatement | DoStatement | ReturnStatement\n\n arrayAccessStart = jackIdentifier openSquare\n ArrayAccess = arrayAccessStart Expression CloseSquare\n\n let = "let" whitespace+\n LetTarget = ArrayAccess | jackIdentifier\n LetStatement = let LetTarget Equal Expression Semi\n\n IfStatement = "if" OpenParen Expression CloseParen OpenBrace Statement* CloseBrace ElseBlock?\n ElseBlock = "else" OpenBrace Statement* CloseBrace\n\n WhileStatement = "while" OpenParen Expression CloseParen OpenBrace Statement* CloseBrace\n\n do = "do" whitespace+\n DoStatement = do SubroutineCall Semi\n\n return = "return"\n returnWithSpace = "return" whitespace+\n ReturnStatement = EmptyReturn | ReturnValue\n EmptyReturn = return Semi\n ReturnValue = returnWithSpace Expression Semi\n\n op = "+" | "-" | "*" | "/" | "&" | "|" | "<" | ">" | "="\n ExpressionPart = op Term\n Expression = Term ExpressionPart*\n\n integerConstant = digit+\n stringConstant = doubleQuote (~doubleQuote ~newline any)* doubleQuote\n keywordConstant = "true" | "false" | "null" | "this"\n\n GroupedExpression = OpenParen Expression CloseParen\n\n unaryOp = "-" | "~"\n UnaryExpression = unaryOp Term\n\n Term = integerConstant | stringConstant | keywordConstant | SubroutineCall | ArrayAccess | jackIdentifier | GroupedExpression | UnaryExpression\n\n compoundIdentifier = jackIdentifier dot jackIdentifier\n SubroutineName = compoundIdentifier | jackIdentifier\n SubroutineCall = SubroutineName OpenParen ExpressionList CloseParen\n\n ExpressionList = Expressions?\n Expressions = Expression TrailingExpression*\n TrailingExpression = Comma Expression\n\n jackIdentifier = letter (alnum | underscore)*\n}',g=new Set(["int","boolean","char"]);const y=(0,f.qN)(m,h.lN),v=y.extendSemantics(h.JE);function b(e){return e.children.map((e=>e.statement))}v.addAttribute("Root",{Root(e){return this.class}}),v.addAttribute("class",{Class:(e,t,n,r,i,s)=>({name:{value:t.sourceString,span:(0,h.Ln)(t.source)},varDecs:r.children.map((e=>e.classVarDec)),subroutines:i.children.map((e=>e.subroutineDec))})}),v.addAttribute("classVarDec",{ClassVarDec:(e,t,n,r,i)=>({varType:e.sourceString.trim(),type:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},names:[n.sourceString,...r.children.map((e=>e.child(1).sourceString))]})}),v.addAttribute("subroutineDec",{SubroutineDec:(e,t,n,r,i,s,a)=>({type:e.sourceString.trim(),returnType:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},name:{value:n.sourceString,span:(0,h.Ln)(n.source)},parameters:i.parameterList,body:a.subroutineBody})}),v.addAttribute("parameter",{Parameter:(e,t)=>({type:{value:e.sourceString.trim(),span:(0,h.Ln)(e.source)},name:t.sourceString})}),v.addAttribute("parameterList",{ParameterList:e=>e.child(0)?.parameters??[]}),v.addAttribute("parameters",{Parameters:(e,t)=>[e.parameter,...t.children.map((e=>e.child(1).parameter))]}),v.addAttribute("subroutineBody",{SubroutineBody:(e,t,n,r)=>({varDecs:t.children.map((e=>e.varDec)),statements:b(n)})}),v.addAttribute("varDec",{VarDec:(e,t,n,r,i)=>({type:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},names:[n.sourceString,...r.children.map((e=>e.child(1).sourceString))]})}),v.addAttribute("statement",{LetStatement(e,t,n,r,i){return"variable"==t.term.termType?{statementType:"letStatement",name:{value:t.term.name,span:t.term.span},value:r.expression,span:(0,h.Ln)(this.source)}:{statementType:"letStatement",name:t.term.name,arrayIndex:t.term.index,value:r.expression,span:(0,h.Ln)(this.source)}},IfStatement:(e,t,n,r,i,s,a,o)=>({statementType:"ifStatement",condition:n.expression,body:b(s),else:o.child(0)?.else??[]}),WhileStatement:(e,t,n,r,i,s,a)=>({statementType:"whileStatement",condition:n.expression,body:b(s)}),DoStatement:(e,t,n)=>({statementType:"doStatement",call:t.term}),EmptyReturn(e,t){return{statementType:"returnStatement",span:(0,h.Ln)(this.source)}},ReturnValue(e,t,n){return{statementType:"returnStatement",value:t.expression,span:(0,h.Ln)(this.source)}}}),v.addAttribute("else",{ElseBlock:(e,t,n,r)=>b(n)}),v.addAttribute("term",{integerConstant:e=>({termType:"numericLiteral",value:Number(e.sourceString)}),stringConstant(e,t,n){return{termType:"stringLiteral",value:this.sourceString.slice(1,-1)}},keywordConstant(e){return{termType:"keywordLiteral",value:this.sourceString}},SubroutineCall(e,t,n,r){return{termType:"subroutineCall",name:{value:e.sourceString,span:(0,h.Ln)(e.source)},parameters:n.expressionList,span:(0,h.Ln)(this.source)}},ArrayAccess(e,t,n){const r=e.child(0);return{termType:"arrayAccess",name:{value:r.sourceString,span:(0,h.Ln)(r.source)},index:t.expression,span:(0,h.Ln)(this.source)}},jackIdentifier(e,t){return{termType:"variable",name:`${e.sourceString}${t.sourceString}`,span:(0,h.Ln)(this.source)}},GroupedExpression:(e,t,n)=>({termType:"groupedExpression",expression:t.expression}),UnaryExpression:(e,t)=>({termType:"unaryExpression",op:e.sourceString,term:t.term})}),v.addAttribute("expressionList",{ExpressionList:e=>e.child(0)?.expressions??[]}),v.addAttribute("expressions",{Expressions:(e,t)=>[e.expression,...t.children.map((e=>e.child(1).expression))]}),v.addAttribute("expression",{Expression:(e,t)=>({nodeType:"expression",term:e.term,rest:t.children.map((e=>e.expressionPart))})}),v.addAttribute("expressionPart",{ExpressionPart:(e,t)=>({op:e.sourceString,term:t.term})});const w={parser:y,grammar:m,semantics:v,parse:(0,h.Q5)(y,v,(e=>e.class))};var S=n(2548);class x{id;hasReturn=!1;children=[];static count=0;constructor(){this.id=x.count,x.count+=1}alwaysReturns(){const e=new Set;return function t(n){if(n.hasReturn)return!0;if(0===n.children.length)return!1;e.add(n);for(const r of n.children)if(!e.has(r)&&!t(r))return!1;return!0}(this)}getLeafs(){const e=new Set,t=new Set;return function n(r){if(0===r.children.length)e.add(r);else{t.add(r);for(const e of r.children)t.has(e)||n(e)}}(this),Array.from(e)}}function k(e,t,n){const i=new x;n.children.push(i),n=i;const s=I(e.body,t),a=I(e.else,t);if((0,r.ys)(s))return s;if((0,r.ys)(a))return a;const o=(0,r.oA)(s),l=(0,r.oA)(a);n.children.push(o,l);const u=o.getLeafs().concat(l.getLeafs());n=new x;for(const r of u)r.children.push(n);return(0,r.Ok)(n)}function _(e,t,n){const i=new x;n.children.push(i),n=i;const s=I(e.body,t);if((0,r.ys)(s))return s;const a=(0,r.oA)(s);for(const r of a.getLeafs())r.children.push(n);const o=new x;return n.children.push(a,o),n=o,(0,r.Ok)(n)}function I(e,t){const n=new x;let i,s=n;for(const a of e)switch(a.statementType){case"letStatement":case"doStatement":break;case"returnStatement":if("void"!=t&&void 0==a.value)return(0,r._)((0,h.$5)("A non void subroutine must return a value",a.span));s.hasReturn=!0;break;case"ifStatement":if(i=k(a,t,s),(0,r.ys)(i))return i;s=(0,r.oA)(i);break;case"whileStatement":if(i=_(a,t,s),(0,r.ys)(i))return i;s=(0,r.oA)(i)}return(0,r.Ok)(n)}function A(e){const t=I(e.body.statements,e.returnType.value);return(0,r.ys)(t)?t:(0,r.oA)(t).alwaysReturns()?(0,r.Ok)():(0,r._)((0,h.$5)(`Subroutine ${e.name.value}: not all code paths return a value`,e.name.span))}const C=new Set(["Sys","Screen","Output","Keyboard","String","Array","Memory","Math"]);function E(e){return C.has(e)}function O(e){return void 0!=e.message}function P(e){return e.charAt(0).toUpperCase()+e.slice(1)}function L(e){const t=new Set;for(const n of e.subroutines){if(t.has(n.name.value))return(0,r._)((0,h.$5)(`Subroutine ${n.name.value} already declared`,n.name.span));t.add(n.name.value);const e=A(n);if((0,r.ys)(e))return e}return(0,r.Ok)()}const R={"+":"add","-":"sub","*":"call Math.multiply 2","/":"call Math.divide 2","&":"and","|":"or","<":"lt",">":"gt","=":"eq"},N={"-":"neg","~":"not"};class T{instructions=[];globalSymbolTable={};localSymbolTable={};className="";classes={};labelNum=0;fieldNum=0;staticNum=0;localNum=0;get output(){return Array.from(this.instructions)}varData(e){return this.localSymbolTable[e]||this.globalSymbolTable[e]}var(e){let t,n;"string"==typeof e?t=e:"string"==typeof e.name?(t=e.name,n=e.span):(t=e.name.value,n=e.name.span);const r=this.varData(t);if(!r)throw(0,h.$5)(`Undeclared variable ${t}`,n);return`${r.segment} ${r.index}`}write(...e){this.instructions.push(...e)}getLabel(){const e=`L${this.labelNum}`;return this.labelNum+=1,e}compile(e,t){this.className=e.name.value,this.classes=t??{};for(const n of e.varDecs)this.compileClassVarDec(n);for(const n of e.subroutines)this.compileSubroutineDec(n);return(0,r.Ok)(this.instructions.map((e=>e.startsWith("function")||e.startsWith("label")?e:" ".concat(e))).join("\n"))}validateType(e,t){var n;if(n=e,!(g.has(n)||E(e)||this.classes[e]))throw(0,h.$5)(`Unknown type ${e}`,t)}validateReturnType(e,t){"void"!=e&&this.validateType(e,t)}compileClassVarDec(e){this.validateType(e.type.value,e.type.span);for(const t of e.names)"field"==e.varType?(this.globalSymbolTable[t]={type:e.type.value,segment:"this",index:this.fieldNum},this.fieldNum+=1):(this.globalSymbolTable[t]={type:e.type.value,segment:"static",index:this.staticNum},this.staticNum+=1)}compileVarDec(e){this.validateType(e.type.value,e.type.span);for(const t of e.names)this.localSymbolTable[t]={type:e.type.value,segment:"local",index:this.localNum},this.localNum+=1}registerArgs(e,t=!1){let n=0;for(const r of e)this.validateType(r.type.value,r.type.span),this.localSymbolTable[r.name]={type:r.type.value,segment:"argument",index:n+(t?1:0)},n+=1}compileSubroutineDec(e){switch(this.validateReturnType(e.returnType.value,e.returnType.span),e.type){case"method":this.compileMethod(e);break;case"constructor":this.compileConstructor(e);break;case"function":this.compileFunction(e)}}compileSubroutineStart(e,t=!1){this.localSymbolTable={},this.localNum=0,this.registerArgs(e.parameters,t);const n=e.body.varDecs.map((e=>e.names.length)).reduce(((e,t)=>e+t),0);this.write(`function ${this.className}.${e.name.value} ${n}`);for(const r of e.body.varDecs)this.compileVarDec(r)}compileFunction(e){this.compileSubroutineStart(e),this.compileStatements(e.body.statements)}compileMethod(e){this.compileSubroutineStart(e,!0),this.write("push argument 0","pop pointer 0"),this.compileStatements(e.body.statements)}compileConstructor(e){this.compileSubroutineStart(e),this.write(`push constant ${this.fieldNum}`,"call Memory.alloc 1","pop pointer 0"),this.compileStatements(e.body.statements)}compileExpression(e){this.compileTerm(e.term);for(const t of e.rest)this.compileTerm(t.term),this.compileOp(t.op)}compileOp(e){this.write(R[e])}compileTerm(e){switch(e.termType){case"numericLiteral":this.write(`push constant ${e.value}`);break;case"stringLiteral":this.compileStringLiteral(e.value);break;case"variable":this.write(`push ${this.var(e)}`);break;case"keywordLiteral":this.compileKeywordLiteral(e.value);break;case"subroutineCall":this.compileSubroutineCall(e);break;case"arrayAccess":this.compileExpression(e.index),this.write(`push ${this.var(e)}`,"add","pop pointer 1","push that 0");break;case"groupedExpression":this.compileExpression(e.expression);break;case"unaryExpression":this.compileTerm(e.term),this.write(N[e.op])}}validateArgNum(e,t,n){const r=n.parameters.length;if(t!=r)throw(0,h.$5)(`${e} expected ${t} arguments, got ${r}`,n.span)}validateSubroutineCall(e,t,n,r){const i=S.P[`${e}.${t}`];if(!i){if(E(e))throw(0,h.$5)(`Class ${e} doesn't contain a subroutine ${t}`,n.span);if(this.classes[e]){for(const i of this.classes[e].subroutines)if(i.name.value==t){if("method"==i.type&&!r)throw(0,h.$5)(`Method ${e}.${t} was called as a function/constructor`,n.name.span);if("method"!=i.type&&r)throw(0,h.$5)(`${P(i.name.value)} ${e}.${t} was called as a method`,n.name.span);return void this.validateArgNum(`${e}.${t}`,i.parameters.length,n)}throw(0,h.$5)(`Class ${e} doesn't contain a function/constructor ${t}`,n.name.span)}throw(0,h.$5)(`Class ${e} doesn't exist`,n.name.span)}if("method"==i.type&&!r)throw(0,h.$5)(`Method ${e}.${t} was called as a function/constructor`,n.name.span);if("method"!=i.type&&r)throw(0,h.$5)(`${P(i.type)} ${e}.${t} was called as a method`,n.name.span);this.validateArgNum(`${e}.${t}`,r?i.nArgs-1:i.nArgs,n)}classifySubroutineCall(e){let t,n="",r="";if(e.name.value.includes(".")){const[i,s]=e.name.value.split(".",2);r=s;const a=this.varData(i);a?(t=this.var(i),n=a.type):n=i}else t="pointer 0",n=this.className,r=e.name.value;return this.validateSubroutineCall(n,r,e,void 0!=t),{className:n,subroutineName:r,object:t}}compileSubroutineCall(e){const t=this.classifySubroutineCall(e);t.object&&this.write(`push ${t.object}`);for(const n of e.parameters)this.compileExpression(n);this.write(`call ${t.className}.${t.subroutineName} ${e.parameters.length+(t.object?1:0)}`)}compileStringLiteral(e){this.write(`push constant ${e.length}`,"call String.new 1");for(let t=0;t!O(t)))),i={};for(const[a,o]of Object.entries(t))if(O(o))i[a]=o;else try{const e=(new T).compile(o,n);(0,r.ys)(e)?i[a]=(0,r._)(e):i[a]=(0,r.Ok)(e)}catch(s){i[a]=s}return i}(e.files);e.compiled={};for(const[n,r]of Object.entries(t))e.compiled[n]="string"===typeof r?{valid:!0,vm:r}:{valid:!1,error:r};e.isValid=Object.keys(e.files).every((t=>e.compiled[t].valid))},writeCompiled(e){if(Object.values(e.compiled).every((e=>e.valid)))for(const[t,r]of Object.entries(e.compiled))r.vm&&n?.writeFile(`${t}.vm`,r.vm);e.isCompiled=!0},setSelected(e,t){e.selected=t},setTitle(e,t){e.title=t}},actions:{async loadProject(e){this.reset(),n=e,t.current({action:"setFs",payload:n});const r={};for(const t of(await n.scandir("/")).filter((e=>e.isFile()&&e.name.endsWith(".jack"))))r[t.name.replace(".jack","")]=await n.readFile(t.name);this.loadFiles(r)},async loadFiles(e){t.current({action:"setFiles",payload:e}),Object.entries(e).length>0&&t.current({action:"setSelected",payload:Object.keys(e)[0]})},async writeFile(e,r){r??=function(e){return`class ${e} {\n\n}\n`}(e),t.current({action:"setFile",payload:{name:e,content:r}}),n&&await n.writeFile(`${e}.jack`,r)},async reset(){n=void 0,t.current({action:"reset"})},async compile(){t.current({action:"writeCompiled"})}}}}var F=n(6554),j=n(6418),D=n(7365),$=n(1296),z=n(4256);function V(e,t){const n=new z.X(e.cpu.RAM,t),r=new z.X(e.cpu.ROM,t),s=new z.X(e.cpu.Screen,t),a=new i.PC(new z.X(e.cpu.RAM,t));return{A:e.cpu.A,D:e.cpu.D,PC:e.cpu.PC,RAM:n,ROM:r,Screen:s,Keyboard:a}}function U(){const{fs:e,setStatus:t,storage:n}=(0,o.useContext)(u.L),s=(0,o.useRef)((()=>{})),{initialState:a,reducers:c,actions:p}=(0,o.useMemo)((()=>function(e,t,n,s){let a=new j.b,o=!0,l=!0,u="",c=[],p="";const d={update(e){e.sim=V(a,s),e.test.highlight=a.currentStep?.span,e.test.valid=l,e.path=u,e.tests=Array.from(c),e.test.name=p},setTest(e,{tst:t,cmp:n}){e.test.tst=t??e.test.tst,e.test.cmp=n??e.test.cmp,e.test.out=""},testStep(e){e.test.out=a.log(),this.update(e)},testFinished(e){if(""===e.test.cmp.trim())return;const n=(0,D.U)(e.test.cmp.trim(),a.log().trim());t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},setTitle(e,t){e.title=t},updateConfig(e,t){e.config={...e.config,...t}}},h={tick(){a.cpu.tick()},setAnimate(e){o=e},async setPath(t){u=t;const n=u.split("/").slice(0,-1).join("/"),r=await e.scandir(n);c=r.filter((e=>e.name.endsWith(".tst"))).map((e=>e.name)),c.length>0?this.loadTest(c[0]):(p="Default",this.compileTest("repeat {\n ticktock;\n}","")),s.current({action:"update"})},async testStep(){const e=await a.step();return(o||e)&&s.current({action:"testStep"}),e&&s.current({action:"testFinished"}),e},resetRAM(){a.cpu.RAM.loadBytes([]),s.current({action:"update"}),t("Reset RAM")},toggleUseTest(){s.current({action:"update"})},reset(){a.reset(),s.current({action:"update"})},clear(){this.replaceROM(new i.n9),this.resetRAM(),this.clearTest(),this.reset(),s.current({action:"setTitle",payload:void 0})},clearTest(){this.compileTest("repeat {\n ticktock;\n}",""),s.current({action:"update"})},replaceROM(e){a=new j.b(e),this.clearTest()},compileTest(e,n){s.current({action:"setTest",payload:{tst:e,cmp:n}});const i=F.uG.parse(e);return(0,r.ys)(i)?(t(`Failed to parse test - ${(0,r._)(i).message}`),l=!1,s.current({action:"update"}),!1):(l=!0,a=j.b.from((0,r.Ok)(i),a.cpu.ROM,t),s.current({action:"update"}),!0)},async loadTest(n){const i=u.split("/").slice(0,-1).join("/"),s=await(0,$.g)(e,`${i}/${n}`);if((0,r.ys)(s))return void t("Failed to load test");p=n;const{tst:a,cmp:o}=(0,r.oA)(s);this.compileTest(a,o??"")}};return{initialState:{sim:V(a,s),test:{highlight:a.currentStep?.span,name:"",tst:"repeat {\n ticktock;\n}",cmp:"",out:"",valid:!0},path:"",tests:[],config:{romFormat:"asm",ramFormat:"dec",screenScale:1,speed:2,testSpeed:2}},reducers:d,actions:h}}(e,t,0,s)),[e,t,n,s]),[d,h]=(0,l.A)(c,a);return s.current=h,{state:d,dispatch:s,actions:p}}var B=n(8849),W=n(782);function H(){const[e,t]=(0,o.useState)(),[n,r]=(0,o.useState)(),i=(0,d.C1)(),s=U(),a=p(),c=(0,B.vw)(),h=function(){const{setStatus:e}=(0,o.useContext)(u.L),t=(0,o.useRef)((()=>{})),{initialState:n,reducers:r,actions:i}=(0,o.useMemo)((()=>M(0,t)),[e,t]),[s,a]=(0,l.A)(r,n);return t.current=a,{state:s,dispatch:t,actions:i}}();return(0,o.useEffect)((()=>{i.actions.initialize()}),[i.actions]),(0,o.useEffect)((()=>{c.actions.initialize()}),[c.actions]),(0,o.useEffect)((()=>{switch(n){case"cpu":t(s.state.title);break;case"asm":t(a.state.title);break;case"vm":t(c.state.title);break;case"compiler":t(h.state.title);break;default:t(void 0)}}),[n,s.state.title,a.state.title,c.state.title,h.state.title]),{setTool:r,title:e,stores:{chip:i,cpu:s,asm:a,vm:c,compiler:h}}}const G=(0,o.createContext)({});function q(e){const t=H();return(0,W.jsx)(G.Provider,{value:t,children:e.children})}},3015:(e,t,n)=>{n.d(t,{I:()=>i});var r=n(782);const i=({name:e})=>(0,r.jsx)("span",{className:"material-symbols-outlined",children:e})},3508:(e,t,n)=>{n.d(t,{s:()=>i});var r=n(8878);function i(){const[e,t]=(0,r.useState)(!1);return{isOpen:e,open(){t(!0)},close(){t(!1)}}}},6073:(e,t,n)=>{n.d(t,{Nk:()=>g,g3:()=>d});var r=n(6458),i=n(910),s=n(8878),a=n(8029),o=n(3015),l=n(3508),u=n(3569),c=n(782);const p="file selected";function d(){const e=(0,l.s)(),[t,n]=(0,s.useState)(),[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1),o=(0,s.useRef)(),u=(0,s.useCallback)((async t=>{var r;return"string"===typeof t.suffix&&(t.suffix=[t.suffix]),n(t.suffix),i(null!==(r=t.allowFolders)&&void 0!==r&&r),e.open(),new Promise((e=>{o.current=e}))}),[e,o]);return{...e,select:async e=>(a.current=!1,await u(e)),selectAllowLocal:async e=>(a.current=!0,u(e)),[p]:o,suffix:t,allowFolders:r,allowLocal:a.current}}const h=({onClick:e,onDoubleClick:t,stats:n,highlighted:r=!1,disabled:i=!1})=>(0,c.jsx)("div",{children:(0,c.jsxs)("button",{className:"flex row justify-start outline "+(r?"":"secondary"),style:{textAlign:"left",color:i?"var(--disabled)":void 0},onClick:n=>{1==n.detail?null===e||void 0===e||e():2==n.detail&&(null===t||void 0===t||t())},children:[(0,c.jsx)(o.I,{name:n.isDirectory()?"folder":"draft"}),n.name]})});async function f(e,t,n){for(const r of await t.scandir(n))if(r.isDirectory()){const i=e.folder(r.name);i&&await f(i,t,`${n}/${r.name}`)}else e.file(r.name,await t.readFile(`${n}/${r.name}`))}function m(e,t){return t.map((t=>e.endsWith(t))).reduce(((e,t)=>e||t),!1)}const g=()=>{const{fs:e,setStatus:t}=(0,s.useContext)(i.L),{filePicker:n}=(0,s.useContext)(a.BR),[o,l]=(0,s.useState)([]),[d,g]=(0,s.useState)(""),y=e.cwd();(0,s.useEffect)((()=>{"/"==e.cwd()&&v("projects")}),[e]),(0,s.useEffect)((()=>{e.scandir(e.cwd()).then((e=>{l(e)}))}),[e,y,l]);const v=(0,s.useCallback)((t=>{e.cd(t),e.scandir(e.cwd()).then((e=>{l(e)}))}),[e,g,l]),b=(0,s.useCallback)((t=>{g(`${"/"==e.cwd()?"":e.cwd()}/${t}`)}),[g]),w=(0,s.useCallback)((()=>{var e,t;n.close(),null===(e=(t=n[p]).current)||void 0===e||e.call(t,d)}),[d,n,t]),S=(0,s.useRef)(null),x=(0,s.useRef)(null);return(0,c.jsxs)("dialog",{open:n.isOpen,children:[(0,c.jsx)("input",{type:"file",ref:S,onChange:async()=>{if(S.current&&S.current.files){var e,t;const r=S.current.files[0];null===(e=(t=n[p]).current)||void 0===e||e.call(t,{name:r.name,content:await r.text()}),n.close()}},style:{display:"none"}}),(0,c.jsxs)("article",{className:"file-select flex",children:[(0,c.jsxs)("header",{children:[(0,c.jsx)("p",{children:(0,c.jsx)(r.x6,{id:"+yPBXI"})}),(0,c.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:e=>{e.preventDefault(),n.close()},children:"close"})]}),(0,c.jsxs)("main",{children:[(0,c.jsx)("a",{ref:x,style:{display:"none"}}),(0,c.jsx)("div",{children:(0,c.jsx)("b",{children:e.cwd()})}),"/"!==e.cwd()&&(0,c.jsx)(h,{stats:{isDirectory:()=>!0,isFile:()=>!1,name:".."},onDoubleClick:()=>v("..")}),o.map((e=>(0,c.jsx)(h,{stats:e,highlighted:e.name===d.split("/").pop(),onClick:()=>b(e.name),onDoubleClick:()=>{e.isDirectory()&&v(e.name)},disabled:e.name.includes(".")&&void 0!=n.suffix&&!m(e.name,n.suffix)},e.name)))]}),(0,c.jsxs)("footer",{children:[(0,c.jsx)("button",{disabled:!d||".."==d||void 0!=n.suffix&&d.includes(".")&&!m(d,n.suffix)||!n.allowFolders&&!d.includes("."),onClick:w,children:"Select"}),n.allowLocal&&(0,c.jsx)("button",{onClick:()=>{var e;null===(e=S.current)||void 0===e||e.click()},children:"Select local file"}),(0,c.jsx)("button",{onClick:async()=>{var t;if(!x.current)return;const n=await(0,u.e)();await f(n,e,d);const r=await n.generateAsync({type:"blob"}),i=URL.createObjectURL(r);x.current.href=i,x.current.download=null!==(t=d.split("/").pop())&&void 0!==t?t:d,x.current.click(),URL.revokeObjectURL(i)},"data-tooltip":"Download all files in this folder into a zip",disabled:""==d||d.includes("."),children:"Download"})]})]})]})}},3569:(e,t,n)=>{async function r(e){const t=await i();for(const r of e)t.file(r.name,await r.content);const n=await t.generateAsync({type:"blob"});return URL.createObjectURL(n)}async function i(){const{default:e}=await n.e(608).then(n.t.bind(n,5608,23));return new e}n.d(t,{e:()=>i,y:()=>r})},5270:(e,t,n)=>{n.d(t,{w:()=>v,dQ:()=>b,z1:()=>y});var r,i=n(1092),s=n(2469),a=n(8878),o=n(782);const l="/tracking/canTrack",u="yes",c="no",p="",d=[u,c];let h=!1;const f=null!==(r={NODE_ENV:"production",PUBLIC_URL:"/web-ide",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.GA4_ID)&&void 0!==r?r:"G-0VTR5BJFQP";function m(e){i.Ay.send({hitType:"pageview",page:e})}function g(e,t,n,r){var a,o;if(h)return;const l="string"===typeof e?{category:e,action:(0,s.Z1)(t),label:n&&r?{label:n,value:r}:void 0}:e;i.Ay.event({category:l.category,action:l.action,nonInteraction:!l.interaction,label:null===(a=l.label)||void 0===a?void 0:a.label,value:null===(o=l.label)||void 0===o?void 0:o.value})}function y(){var e;const t=null!==(e=localStorage[l])&&void 0!==e?e:p,[n,r]=(0,a.useState)(t===u),[s,o]=(0,a.useState)(d.includes(t)||"1"===navigator.doNotTrack);return{canTrack:n,haveAsked:s,accept:(0,a.useCallback)((()=>{localStorage[l]=u,r(!0),o(!0),i.Ay.initialize(f),i.Ay.send("pageview")}),[r,o]),reject:(0,a.useCallback)((()=>{localStorage[l]=c,r(!1),o(!0),h=!0}),[r,o]),trackEvent:g,trackPage:m}}function v(){const{accept:e,reject:t,haveAsked:n}=y(),[r,i]=(0,a.useState)(!n),s=(0,a.useCallback)((()=>{i(!1)}),[i]),l=(0,a.useCallback)((()=>{e(),s()}),[e,s]),u=(0,a.useCallback)((()=>{t(),s()}),[t,s]);return(0,o.jsx)(o.Fragment,{children:r&&(0,o.jsxs)("div",{id:"trackingBanner",className:"flex row",children:[(0,o.jsx)("div",{className:"flex-1",children:(0,o.jsx)(b,{})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("a",{href:"#reject",role:"button",className:"reject",onClick:u,children:"Reject"}),(0,o.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:l,children:"Accept"}),(0,o.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:s,children:"\ud835\uddb7"})]})]})})}function b(){return(0,o.jsxs)("p",{style:{margin:0},children:["This site uses Google Analytics to gather information that will improve the user experience. This only includes anonymous interaction data, and never shares your code."," ",(0,o.jsx)("a",{href:"www.google.com/policies/privacy/partners/",children:"How Google uses data."})]})}},3499:(e,t,n)=>{n.d(t,{Ay:()=>m,It:()=>f,p3:()=>h});var r=n(8878),i=n(782);const s=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(787)]).then(n.bind(n,7737)))),a=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(744)]).then(n.bind(n,5178)))),o=(0,r.lazy)((()=>n.e(519).then(n.bind(n,5519)))),l=(0,r.lazy)((()=>n.e(323).then(n.bind(n,1323)))),u=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(34)]).then(n.bind(n,1496)))),c=(0,r.lazy)((()=>n.e(598).then(n.bind(n,6598)))),p=(0,r.lazy)((()=>n.e(408).then(n.bind(n,2408)))),d=(0,r.lazy)((()=>Promise.all([n.e(656),n.e(614)]).then(n.bind(n,3614)))),h="lastRoute",f={chip:"Hardware Simulator",cpu:"CPU Emulator",asm:"Assembler",vm:"VM Emulator",bitmap:"Bitmap Editor",compiler:"Jack Compiler"},m={chip:{href:"/chip",tool:"chip",target:(0,i.jsx)(s,{})},cpu:{href:"/cpu",tool:"cpu",target:(0,i.jsx)(a,{})},asm:{href:"/asm",tool:"asm",target:(0,i.jsx)(o,{})},vm:{href:"/vm",tool:"vm",target:(0,i.jsx)(u,{})},compiler:{href:"/compiler",tool:"compiler",target:(0,i.jsx)(c,{})},bitmap:{href:"/bitmap",tool:"bitmap",target:(0,i.jsx)(l,{})},util:{href:"/util",target:(0,i.jsx)(p,{})},about:{href:"/about",target:(0,i.jsx)(d,{})}}},1642:(e,t,n)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;tp,Gh:()=>N,HS:()=>T,Oi:()=>o,Rr:()=>d,pX:()=>$,pb:()=>O,rc:()=>i,tH:()=>D,ue:()=>m,yD:()=>R,zR:()=>a}),function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(i||(i={}));const s="popstate";function a(e){return void 0===e&&(e={}),h((function(e,t){let{pathname:n,search:r,hash:i}=e.location;return c("",{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"===typeof t?t:p(t)}),null,e)}function o(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function l(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function u(e,t){return{usr:e.state,key:e.key,idx:t}}function c(e,t,n,i){return void 0===n&&(n=null),r({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?d(t):t,{state:n,key:t&&t.key||i||Math.random().toString(36).substr(2,8)})}function p(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(t+="#"===r.charAt(0)?r:"#"+r),t}function d(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function h(e,t,n,a){void 0===a&&(a={});let{window:l=document.defaultView,v5Compat:d=!1}=a,h=l.history,f=i.Pop,m=null,g=y();function y(){return(h.state||{idx:null}).idx}function v(){f=i.Pop;let e=y(),t=null==e?null:e-g;g=e,m&&m({action:f,location:w.location,delta:t})}function b(e){let t="null"!==l.location.origin?l.location.origin:l.location.href,n="string"===typeof e?e:p(e);return n=n.replace(/ $/,"%20"),o(t,"No window.location.(origin|href) available to create URL for href: "+n),new URL(n,t)}null==g&&(g=0,h.replaceState(r({},h.state,{idx:g}),""));let w={get action(){return f},get location(){return e(l,h)},listen(e){if(m)throw new Error("A history only accepts one active listener");return l.addEventListener(s,v),m=e,()=>{l.removeEventListener(s,v),m=null}},createHref:e=>t(l,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){f=i.Push;let r=c(w.location,e,t);n&&n(r,e),g=y()+1;let s=u(r,g),a=w.createHref(r);try{h.pushState(s,"",a)}catch(o){if(o instanceof DOMException&&"DataCloneError"===o.name)throw o;l.location.assign(a)}d&&m&&m({action:f,location:w.location,delta:1})},replace:function(e,t){f=i.Replace;let r=c(w.location,e,t);n&&n(r,e),g=y();let s=u(r,g),a=w.createHref(r);h.replaceState(s,"",a),d&&m&&m({action:f,location:w.location,delta:0})},go:e=>h.go(e)};return w}var f;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(f||(f={}));new Set(["lazy","caseSensitive","path","id","index","children"]);function m(e,t,n){void 0===n&&(n="/");let r=O(("string"===typeof t?d(t):t).pathname||"/",n);if(null==r)return null;let i=g(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]));return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(i);let s=null;for(let a=0;null==s&&a{let a={relativePath:void 0===s?e.path||"":s,caseSensitive:!0===e.caseSensitive,childrenIndex:i,route:e};a.relativePath.startsWith("/")&&(o(a.relativePath.startsWith(r),'Absolute route path "'+a.relativePath+'" nested under path "'+r+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),a.relativePath=a.relativePath.slice(r.length));let l=T([r,a.relativePath]),u=n.concat(a);e.children&&e.children.length>0&&(o(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),g(e.children,t,u,l)),(null!=e.path||e.index)&&t.push({path:l,score:I(l,e.index),routesMeta:u})};return e.forEach(((e,t)=>{var n;if(""!==e.path&&null!=(n=e.path)&&n.includes("?"))for(let r of y(e.path))i(e,t,r);else i(e,t)})),t}function y(e){let t=e.split("/");if(0===t.length)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(0===r.length)return i?[s,""]:[s];let a=y(r.join("/")),o=[];return o.push(...a.map((e=>""===e?s:[s,e].join("/")))),i&&o.push(...a),o.map((t=>e.startsWith("/")&&""===t?"/":t))}const v=/^:[\w-]+$/,b=3,w=2,S=1,x=10,k=-2,_=e=>"*"===e;function I(e,t){let n=e.split("/"),r=n.length;return n.some(_)&&(r+=k),t&&(r+=w),n.filter((e=>!_(e))).reduce(((e,t)=>e+(v.test(t)?b:""===t?S:x)),r)}function A(e,t){let{routesMeta:n}=e,r={},i="/",s=[];for(let a=0;a(r.push({paramName:t,isOptional:null!=n}),n?"/?([^\\/]+)?":"/([^\\/]+)")));e.endsWith("*")?(r.push({paramName:"*"}),i+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":""!==e&&"/"!==e&&(i+="(?:(?=\\/|$))");let s=new RegExp(i,t?void 0:"i");return[s,r]}(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce(((e,t,n)=>{let{paramName:r,isOptional:i}=t;if("*"===r){let e=o[n]||"";a=s.slice(0,s.length-e.length).replace(/(.)\/+$/,"$1")}const l=o[n];return e[r]=i&&!l?void 0:(l||"").replace(/%2F/g,"/"),e}),{}),pathname:s,pathnameBase:a,pattern:e}}function E(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return l(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function O(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&"/"!==r?null:e.slice(n)||"/"}function P(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the `to."+n+'` field. Alternatively you may provide the full path as a string in and the router will parse it for you.'}function L(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function R(e,t){let n=L(e);return t?n.map(((t,n)=>n===e.length-1?t.pathname:t.pathnameBase)):n.map((e=>e.pathnameBase))}function N(e,t,n,i){let s;void 0===i&&(i=!1),"string"===typeof e?s=d(e):(s=r({},e),o(!s.pathname||!s.pathname.includes("?"),P("?","pathname","search",s)),o(!s.pathname||!s.pathname.includes("#"),P("#","pathname","hash",s)),o(!s.search||!s.search.includes("#"),P("#","search","hash",s)));let a,l=""===e||""===s.pathname,u=l?"/":s.pathname;if(null==u)a=n;else{let e=t.length-1;if(!i&&u.startsWith("..")){let t=u.split("/");for(;".."===t[0];)t.shift(),e-=1;s.pathname=t.join("/")}a=e>=0?t[e]:"/"}let c=function(e,t){void 0===t&&(t="/");let{pathname:n,search:r="",hash:i=""}="string"===typeof e?d(e):e,s=n?n.startsWith("/")?n:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(n,t):t;return{pathname:s,search:F(r),hash:j(i)}}(s,a),p=u&&"/"!==u&&u.endsWith("/"),h=(l||"."===u)&&n.endsWith("/");return c.pathname.endsWith("/")||!p&&!h||(c.pathname+="/"),c}const T=e=>e.join("/").replace(/\/\/+/g,"/"),M=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),F=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",j=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class D extends Error{}function $(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}const z=["post","put","patch","delete"],V=(new Set(z),["get",...z]);new Set(V),new Set([301,302,303,307,308]),new Set([307,308]);Symbol("deferred")},2777:(e,t,n)=>{var r=n(8878),i=n(7116);function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;nt}return!1}(t,n,i,r)&&(n=null),r||null===i?function(e){return!!p.call(f,e)||!p.call(h,e)&&(d.test(e)?f[e]=!0:(h[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=null===n?3!==i.type&&"":n:(t=i.attributeName,r=i.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(i=i.type)||4===i&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!1,!1)})),g.xlinkHref=new m("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!0,!0)}));var w=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for("react.element"),x=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),C=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),R=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var N=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var T=Symbol.iterator;function M(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=T&&e[T]||e["@@iterator"])?e:null}var F,j=Object.assign;function D(e){if(void 0===F)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||""}return"\n"+F+e}var $=!1;function z(e,t){if(!e||$)return"";$=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&"string"===typeof u.stack){for(var i=u.stack.split("\n"),s=r.stack.split("\n"),a=i.length-1,o=s.length-1;1<=a&&0<=o&&i[a]!==s[o];)o--;for(;1<=a&&0<=o;a--,o--)if(i[a]!==s[o]){if(1!==a||1!==o)do{if(a--,0>--o||i[a]!==s[o]){var l="\n"+i[a].replace(" at new "," at ");return e.displayName&&l.includes("")&&(l=l.replace("",e.displayName)),l}}while(1<=a&&0<=o);break}}}finally{$=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?D(e):""}function V(e){switch(e.tag){case 5:return D(e.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return e=z(e.type,!1);case 11:return e=z(e.type.render,!1);case 1:return e=z(e.type,!0);default:return""}}function U(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case k:return"Fragment";case x:return"Portal";case I:return"Profiler";case _:return"StrictMode";case O:return"Suspense";case P:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case C:return(e.displayName||"Context")+".Consumer";case A:return(e._context.displayName||"Context")+".Provider";case E:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case L:return null!==(t=e.displayName||null)?t:U(e.type)||"Memo";case R:t=e._payload,e=e._init;try{return U(e(t))}catch(n){}}return null}function B(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return U(t);case 8:return t===_?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof t)return t.displayName||t.name||null;if("string"===typeof t)return t}return null}function W(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function H(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function G(e){e._valueTracker||(e._valueTracker=function(e){var t=H(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function q(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=H(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function K(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Q(e,t){var n=t.checked;return j({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function Y(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=W(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function X(e,t){null!=(t=t.checked)&&b(e,"checked",t,!1)}function J(e,t){X(e,t);var n=W(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?ee(e,t.type,n):t.hasOwnProperty("defaultValue")&&ee(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Z(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function ee(e,t,n){"number"===t&&K(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var te=Array.isArray;function ne(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction((function(){return ce(e,t)}))}:ce);function de(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var he={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fe=["Webkit","ms","Moz","O"];function me(e,t,n){return null==t||"boolean"===typeof t||""===t?"":n||"number"!==typeof t||0===t||he.hasOwnProperty(e)&&he[e]?(""+t).trim():t+"px"}function ge(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),i=me(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}Object.keys(he).forEach((function(e){fe.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),he[t]=he[e]}))}));var ye=j({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ve(e,t){if(t){if(ye[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(s(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(s(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(s(62))}}function be(e,t){if(-1===e.indexOf("-"))return"string"===typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var we=null;function Se(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,ke=null,_e=null;function Ie(e){if(e=bi(e)){if("function"!==typeof xe)throw Error(s(280));var t=e.stateNode;t&&(t=Si(t),xe(e.stateNode,e.type,t))}}function Ae(e){ke?_e?_e.push(e):_e=[e]:ke=e}function Ce(){if(ke){var e=ke,t=_e;if(_e=ke=null,Ie(e),t)for(e=0;e>>=0,0===e?32:31-(ot(e)/lt|0)|0},ot=Math.log,lt=Math.LN2;var ut=64,ct=4194304;function pt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function dt(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=268435455&n;if(0!==a){var o=a&~i;0!==o?r=pt(o):0!==(s&=a)&&(r=pt(s))}else 0!==(a=n&~i)?r=pt(a):0!==s&&(r=pt(s));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&i)&&((i=r&-r)>=(s=t&-t)||16===i&&0!==(4194240&s)))return t;if(0!==(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function yt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-at(t)]=n}function vt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-at(n),i=1<=Mn),Dn=String.fromCharCode(32),$n=!1;function zn(e,t){switch(e){case"keyup":return-1!==Nn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vn(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var Un=!1;var Bn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Bn[e.type]:"textarea"===t}function Hn(e,t,n,r){Ae(r),0<(t=Gr(t,"onChange")).length&&(n=new cn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gn=null,qn=null;function Kn(e){Dr(e,0)}function Qn(e){if(q(wi(e)))return e}function Yn(e,t){if("change"===e)return t}var Xn=!1;if(c){var Jn;if(c){var Zn="oninput"in document;if(!Zn){var er=document.createElement("div");er.setAttribute("oninput","return;"),Zn="function"===typeof er.oninput}Jn=Zn}else Jn=!1;Xn=Jn&&(!document.documentMode||9=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ur(r)}}function pr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?pr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function dr(){for(var e=window,t=K();t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=K((e=t.contentWindow).document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function fr(e){var t=dr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&pr(n.ownerDocument.documentElement,n)){if(null!==r&&hr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=void 0===r.end?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=cr(n,s);var a=cr(n,r);i&&a&&(1!==e.rangeCount||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&((t=t.createRange()).setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"===typeof n.focus&&n.focus(),n=0;n=document.documentMode,gr=null,yr=null,vr=null,br=!1;function wr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;br||null==gr||gr!==K(r)||("selectionStart"in(r=gr)&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},vr&&lr(vr,r)||(vr=r,0<(r=Gr(yr,"onSelect")).length&&(t=new cn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=gr)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xr={animationend:Sr("Animation","AnimationEnd"),animationiteration:Sr("Animation","AnimationIteration"),animationstart:Sr("Animation","AnimationStart"),transitionend:Sr("Transition","TransitionEnd")},kr={},_r={};function Ir(e){if(kr[e])return kr[e];if(!xr[e])return e;var t,n=xr[e];for(t in n)if(n.hasOwnProperty(t)&&t in _r)return kr[e]=n[t];return e}c&&(_r=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);var Ar=Ir("animationend"),Cr=Ir("animationiteration"),Er=Ir("animationstart"),Or=Ir("transitionend"),Pr=new Map,Lr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Rr(e,t){Pr.set(e,t),l(t,[e])}for(var Nr=0;Nrki||(e.current=xi[ki],xi[ki]=null,ki--)}function Ai(e,t){ki++,xi[ki]=e.current,e.current=t}var Ci={},Ei=_i(Ci),Oi=_i(!1),Pi=Ci;function Li(e,t){var n=e.type.contextTypes;if(!n)return Ci;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i,s={};for(i in n)s[i]=t[i];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ri(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Ni(){Ii(Oi),Ii(Ei)}function Ti(e,t,n){if(Ei.current!==Ci)throw Error(s(168));Ai(Ei,t),Ai(Oi,n)}function Mi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!==typeof r.getChildContext)return n;for(var i in r=r.getChildContext())if(!(i in t))throw Error(s(108,B(e)||"Unknown",i));return j({},n,r)}function Fi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ci,Pi=Ei.current,Ai(Ei,e),Ai(Oi,Oi.current),!0}function ji(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Mi(e,t,Pi),r.__reactInternalMemoizedMergedChildContext=e,Ii(Oi),Ii(Ei),Ai(Ei,e)):Ii(Oi),Ai(Oi,n)}var Di=null,$i=!1,zi=!1;function Vi(e){null===Di?Di=[e]:Di.push(e)}function Ui(){if(!zi&&null!==Di){zi=!0;var e=0,t=bt;try{var n=Di;for(bt=1;e>=a,i-=a,Yi=1<<32-at(t)+i|n<m?(g=p,p=null):g=p.sibling;var y=h(i,p,o[m],l);if(null===y){null===p&&(p=g);break}e&&p&&null===y.alternate&&t(i,p),s=a(y,s,m),null===c?u=y:c.sibling=y,c=y,p=g}if(m===o.length)return n(i,p),is&&Ji(i,m),u;if(null===p){for(;mg?(y=m,m=null):y=m.sibling;var b=h(i,m,v.value,u);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(i,m),o=a(b,o,g),null===p?c=b:p.sibling=b,p=b,m=y}if(v.done)return n(i,m),is&&Ji(i,g),c;if(null===m){for(;!v.done;g++,v=l.next())null!==(v=d(i,v.value,u))&&(o=a(v,o,g),null===p?c=v:p.sibling=v,p=v);return is&&Ji(i,g),c}for(m=r(i,m);!v.done;g++,v=l.next())null!==(v=f(m,i,g,v.value,u))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),o=a(v,o,g),null===p?c=v:p.sibling=v,p=v);return e&&m.forEach((function(e){return t(i,e)})),is&&Ji(i,g),c}return function e(r,s,a,l){if("object"===typeof a&&null!==a&&a.type===k&&null===a.key&&(a=a.props.children),"object"===typeof a&&null!==a){switch(a.$$typeof){case S:e:{for(var u=a.key,c=s;null!==c;){if(c.key===u){if((u=a.type)===k){if(7===c.tag){n(r,c.sibling),(s=i(c,a.props.children)).return=r,r=s;break e}}else if(c.elementType===u||"object"===typeof u&&null!==u&&u.$$typeof===R&&vs(u)===c.type){n(r,c.sibling),(s=i(c,a.props)).ref=gs(r,c,a),s.return=r,r=s;break e}n(r,c);break}t(r,c),c=c.sibling}a.type===k?((s=Mu(a.props.children,r.mode,l,a.key)).return=r,r=s):((l=Tu(a.type,a.key,a.props,null,r.mode,l)).ref=gs(r,s,a),l.return=r,r=l)}return o(r);case x:e:{for(c=a.key;null!==s;){if(s.key===c){if(4===s.tag&&s.stateNode.containerInfo===a.containerInfo&&s.stateNode.implementation===a.implementation){n(r,s.sibling),(s=i(s,a.children||[])).return=r,r=s;break e}n(r,s);break}t(r,s),s=s.sibling}(s=Du(a,r.mode,l)).return=r,r=s}return o(r);case R:return e(r,s,(c=a._init)(a._payload),l)}if(te(a))return m(r,s,a,l);if(M(a))return g(r,s,a,l);ys(r,a)}return"string"===typeof a&&""!==a||"number"===typeof a?(a=""+a,null!==s&&6===s.tag?(n(r,s.sibling),(s=i(s,a)).return=r,r=s):(n(r,s),(s=ju(a,r.mode,l)).return=r,r=s),o(r)):n(r,s)}}var ws=bs(!0),Ss=bs(!1),xs=_i(null),ks=null,_s=null,Is=null;function As(){Is=_s=ks=null}function Cs(e){var t=xs.current;Ii(xs),e._currentValue=t}function Es(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Os(e,t){ks=e,Is=_s=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(bo=!0),e.firstContext=null)}function Ps(e){var t=e._currentValue;if(Is!==e)if(e={context:e,memoizedValue:t,next:null},null===_s){if(null===ks)throw Error(s(308));_s=e,ks.dependencies={lanes:0,firstContext:e}}else _s=_s.next=e;return t}var Ls=null;function Rs(e){null===Ls?Ls=[e]:Ls.push(e)}function Ns(e,t,n,r){var i=t.interleaved;return null===i?(n.next=n,Rs(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ts(e,r)}function Ts(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Ms=!1;function Fs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function js(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ds(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function $s(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,0!==(2&El)){var i=r.pending;return null===i?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ts(e,n)}return null===(i=r.interleaved)?(t.next=t,Rs(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ts(e,n)}function zs(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}function Vs(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var i=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===s?i=s=a:s=s.next=a,n=n.next}while(null!==n);null===s?i=s=t:s=s.next=t}else i=s=t;return n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Us(e,t,n,r){var i=e.updateQueue;Ms=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,o=i.shared.pending;if(null!==o){i.shared.pending=null;var l=o,u=l.next;l.next=null,null===a?s=u:a.next=u,a=l;var c=e.alternate;null!==c&&((o=(c=c.updateQueue).lastBaseUpdate)!==a&&(null===o?c.firstBaseUpdate=u:o.next=u,c.lastBaseUpdate=l))}if(null!==s){var p=i.baseState;for(a=0,c=u=l=null,o=s;;){var d=o.lane,h=o.eventTime;if((r&d)===d){null!==c&&(c=c.next={eventTime:h,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,m=o;switch(d=t,h=n,m.tag){case 1:if("function"===typeof(f=m.payload)){p=f.call(h,p,d);break e}p=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null===(d="function"===typeof(f=m.payload)?f.call(h,p,d):f)||void 0===d)break e;p=j({},p,d);break e;case 2:Ms=!0}}null!==o.callback&&0!==o.lane&&(e.flags|=64,null===(d=i.effects)?i.effects=[o]:d.push(o))}else h={eventTime:h,lane:d,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===c?(u=c=h,l=p):c=c.next=h,a|=d;if(null===(o=o.next)){if(null===(o=i.shared.pending))break;o=(d=o).next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}if(null===c&&(l=p),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,null!==(t=i.shared.interleaved)){i=t;do{a|=i.lane,i=i.next}while(i!==t)}else null===s&&(i.shared.lanes=0);Fl|=a,e.lanes=a,e.memoizedState=p}}function Bs(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;tn?n:4,e(!0);var r=ia.transition;ia.transition={};try{e(!1),t()}finally{bt=n,ia.transition=r}}function Ha(){return va().memoizedState}function Ga(e,t,n){var r=tu(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ka(e))Qa(t,n);else if(null!==(n=Ns(e,t,n,r))){nu(n,e,r,eu()),Ya(n,t,r)}}function qa(e,t,n){var r=tu(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ka(e))Qa(t,i);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=s(a,n);if(i.hasEagerState=!0,i.eagerState=o,or(o,a)){var l=t.interleaved;return null===l?(i.next=i,Rs(t)):(i.next=l.next,l.next=i),void(t.interleaved=i)}}catch(u){}null!==(n=Ns(e,t,i,r))&&(nu(n,e,r,i=eu()),Ya(n,t,r))}}function Ka(e){var t=e.alternate;return e===aa||null!==t&&t===aa}function Qa(e,t){ca=ua=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ya(e,t,n){if(0!==(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}var Xa={readContext:Ps,useCallback:ha,useContext:ha,useEffect:ha,useImperativeHandle:ha,useInsertionEffect:ha,useLayoutEffect:ha,useMemo:ha,useReducer:ha,useRef:ha,useState:ha,useDebugValue:ha,useDeferredValue:ha,useTransition:ha,useMutableSource:ha,useSyncExternalStore:ha,useId:ha,unstable_isNewReconciler:!1},Ja={readContext:Ps,useCallback:function(e,t){return ya().memoizedState=[e,void 0===t?null:t],e},useContext:Ps,useEffect:Ta,useImperativeHandle:function(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Ra(4194308,4,Da.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ra(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ra(4,2,e,t)},useMemo:function(e,t){var n=ya();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ya();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ga.bind(null,aa,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ya().memoizedState=e},useState:Oa,useDebugValue:za,useDeferredValue:function(e){return ya().memoizedState=e},useTransition:function(){var e=Oa(!1),t=e[0];return e=Wa.bind(null,e[1]),ya().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=aa,i=ya();if(is){if(void 0===n)throw Error(s(407));n=n()}else{if(n=t(),null===Ol)throw Error(s(349));0!==(30&sa)||_a(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ta(Aa.bind(null,r,a,e),[e]),r.flags|=2048,Pa(9,Ia.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=ya(),t=Ol.identifierPrefix;if(is){var n=Xi;t=":"+t+"R"+(n=(Yi&~(1<<32-at(Yi)-1)).toString(32)+n),0<(n=pa++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=da++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Za={readContext:Ps,useCallback:Va,useContext:Ps,useEffect:Ma,useImperativeHandle:$a,useInsertionEffect:Fa,useLayoutEffect:ja,useMemo:Ua,useReducer:wa,useRef:La,useState:function(){return wa(ba)},useDebugValue:za,useDeferredValue:function(e){return Ba(va(),oa.memoizedState,e)},useTransition:function(){return[wa(ba)[0],va().memoizedState]},useMutableSource:xa,useSyncExternalStore:ka,useId:Ha,unstable_isNewReconciler:!1},eo={readContext:Ps,useCallback:Va,useContext:Ps,useEffect:Ma,useImperativeHandle:$a,useInsertionEffect:Fa,useLayoutEffect:ja,useMemo:Ua,useReducer:Sa,useRef:La,useState:function(){return Sa(ba)},useDebugValue:za,useDeferredValue:function(e){var t=va();return null===oa?t.memoizedState=e:Ba(t,oa.memoizedState,e)},useTransition:function(){return[Sa(ba)[0],va().memoizedState]},useMutableSource:xa,useSyncExternalStore:ka,useId:Ha,unstable_isNewReconciler:!1};function to(e,t){if(e&&e.defaultProps){for(var n in t=j({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function no(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:j({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var ro={isMounted:function(e){return!!(e=e._reactInternals)&&Ue(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Ds(r,i);s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=$s(e,s,i))&&(nu(t,e,i,r),zs(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Ds(r,i);s.tag=1,s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=$s(e,s,i))&&(nu(t,e,i,r),zs(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=eu(),r=tu(e),i=Ds(n,r);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),null!==(t=$s(e,i,r))&&(nu(t,e,r,n),zs(t,e,r))}};function io(e,t,n,r,i,s,a){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,s,a):!t.prototype||!t.prototype.isPureReactComponent||(!lr(n,r)||!lr(i,s))}function so(e,t,n){var r=!1,i=Ci,s=t.contextType;return"object"===typeof s&&null!==s?s=Ps(s):(i=Ri(t)?Pi:Ei.current,s=(r=null!==(r=t.contextTypes)&&void 0!==r)?Li(e,i):Ci),t=new t(n,s),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=ro,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function ao(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ro.enqueueReplaceState(t,t.state,null)}function oo(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Fs(e);var s=t.contextType;"object"===typeof s&&null!==s?i.context=Ps(s):(s=Ri(t)?Pi:Ei.current,i.context=Li(e,s)),i.state=e.memoizedState,"function"===typeof(s=t.getDerivedStateFromProps)&&(no(e,t,s,n),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&ro.enqueueReplaceState(i,i.state,null),Us(e,n,i,r),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4194308)}function lo(e,t){try{var n="",r=t;do{n+=V(r),r=r.return}while(r);var i=n}catch(s){i="\nError generating stack: "+s.message+"\n"+s.stack}return{value:e,source:t,stack:i,digest:null}}function uo(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function co(e,t){try{console.error(t.value)}catch(n){setTimeout((function(){throw n}))}}var po="function"===typeof WeakMap?WeakMap:Map;function ho(e,t,n){(n=Ds(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Wl||(Wl=!0,Hl=r),co(0,t)},n}function fo(e,t,n){(n=Ds(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"===typeof r){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){co(0,t)}}var s=e.stateNode;return null!==s&&"function"===typeof s.componentDidCatch&&(n.callback=function(){co(0,t),"function"!==typeof r&&(null===Gl?Gl=new Set([this]):Gl.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function mo(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new po;var i=new Set;r.set(t,i)}else void 0===(i=r.get(t))&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Iu.bind(null,e,t,n),t.then(e,e))}function go(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function yo(e,t,n,r,i){return 0===(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Ds(-1,1)).tag=2,$s(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=i,e)}var vo=w.ReactCurrentOwner,bo=!1;function wo(e,t,n,r){t.child=null===e?Ss(t,null,n,r):ws(t,e.child,n,r)}function So(e,t,n,r,i){n=n.render;var s=t.ref;return Os(t,i),r=ma(e,t,n,r,s,i),n=ga(),null===e||bo?(is&&n&&es(t),t.flags|=1,wo(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function xo(e,t,n,r,i){if(null===e){var s=n.type;return"function"!==typeof s||Ru(s)||void 0!==s.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Tu(n.type,null,r,t,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,ko(e,t,s,r,i))}if(s=e.child,0===(e.lanes&i)){var a=s.memoizedProps;if((n=null!==(n=n.compare)?n:lr)(a,r)&&e.ref===t.ref)return Wo(e,t,i)}return t.flags|=1,(e=Nu(s,r)).ref=t.ref,e.return=t,t.child=e}function ko(e,t,n,r,i){if(null!==e){var s=e.memoizedProps;if(lr(s,r)&&e.ref===t.ref){if(bo=!1,t.pendingProps=r=s,0===(e.lanes&i))return t.lanes=e.lanes,Wo(e,t,i);0!==(131072&e.flags)&&(bo=!0)}}return Ao(e,t,n,r,i)}function _o(e,t,n){var r=t.pendingProps,i=r.children,s=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0===(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ai(Nl,Rl),Rl|=n;else{if(0===(1073741824&n))return e=null!==s?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ai(Nl,Rl),Rl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==s?s.baseLanes:n,Ai(Nl,Rl),Rl|=r}else null!==s?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ai(Nl,Rl),Rl|=r;return wo(e,t,i,n),t.child}function Io(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ao(e,t,n,r,i){var s=Ri(n)?Pi:Ei.current;return s=Li(t,s),Os(t,i),n=ma(e,t,n,r,s,i),r=ga(),null===e||bo?(is&&r&&es(t),t.flags|=1,wo(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function Co(e,t,n,r,i){if(Ri(n)){var s=!0;Fi(t)}else s=!1;if(Os(t,i),null===t.stateNode)Bo(e,t),so(t,n,r),oo(t,n,r,i),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var l=a.context,u=n.contextType;"object"===typeof u&&null!==u?u=Ps(u):u=Li(t,u=Ri(n)?Pi:Ei.current);var c=n.getDerivedStateFromProps,p="function"===typeof c||"function"===typeof a.getSnapshotBeforeUpdate;p||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==r||l!==u)&&ao(t,a,r,u),Ms=!1;var d=t.memoizedState;a.state=d,Us(t,r,a,i),l=t.memoizedState,o!==r||d!==l||Oi.current||Ms?("function"===typeof c&&(no(t,n,c,r),l=t.memoizedState),(o=Ms||io(t,n,o,r,d,l,u))?(p||"function"!==typeof a.UNSAFE_componentWillMount&&"function"!==typeof a.componentWillMount||("function"===typeof a.componentWillMount&&a.componentWillMount(),"function"===typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"===typeof a.componentDidMount&&(t.flags|=4194308)):("function"===typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=u,r=o):("function"===typeof a.componentDidMount&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,js(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:to(t.type,o),a.props=u,p=t.pendingProps,d=a.context,"object"===typeof(l=n.contextType)&&null!==l?l=Ps(l):l=Li(t,l=Ri(n)?Pi:Ei.current);var h=n.getDerivedStateFromProps;(c="function"===typeof h||"function"===typeof a.getSnapshotBeforeUpdate)||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==p||d!==l)&&ao(t,a,r,l),Ms=!1,d=t.memoizedState,a.state=d,Us(t,r,a,i);var f=t.memoizedState;o!==p||d!==f||Oi.current||Ms?("function"===typeof h&&(no(t,n,h,r),f=t.memoizedState),(u=Ms||io(t,n,u,r,d,f,l)||!1)?(c||"function"!==typeof a.UNSAFE_componentWillUpdate&&"function"!==typeof a.componentWillUpdate||("function"===typeof a.componentWillUpdate&&a.componentWillUpdate(r,f,l),"function"===typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,f,l)),"function"===typeof a.componentDidUpdate&&(t.flags|=4),"function"===typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),a.props=r,a.state=f,a.context=l,r=u):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Eo(e,t,n,r,s,i)}function Eo(e,t,n,r,i,s){Io(e,t);var a=0!==(128&t.flags);if(!r&&!a)return i&&ji(t,n,!1),Wo(e,t,s);r=t.stateNode,vo.current=t;var o=a&&"function"!==typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&a?(t.child=ws(t,e.child,null,s),t.child=ws(t,null,o,s)):wo(e,t,o,s),t.memoizedState=r.state,i&&ji(t,n,!0),t.child}function Oo(e){var t=e.stateNode;t.pendingContext?Ti(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Ti(0,t.context,!1),Qs(e,t.containerInfo)}function Po(e,t,n,r,i){return hs(),fs(i),t.flags|=256,wo(e,t,n,r),t.child}var Lo,Ro,No,To,Mo={dehydrated:null,treeContext:null,retryLane:0};function Fo(e){return{baseLanes:e,cachePool:null,transitions:null}}function jo(e,t,n){var r,i=t.pendingProps,a=Zs.current,o=!1,l=0!==(128&t.flags);if((r=l)||(r=(null===e||null!==e.memoizedState)&&0!==(2&a)),r?(o=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(a|=1),Ai(Zs,1&a),null===e)return us(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0===(1&t.mode)?t.lanes=1:"$!"===e.data?t.lanes=8:t.lanes=1073741824,null):(l=i.children,e=i.fallback,o?(i=t.mode,o=t.child,l={mode:"hidden",children:l},0===(1&i)&&null!==o?(o.childLanes=0,o.pendingProps=l):o=Fu(l,i,0,null),e=Mu(e,i,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Fo(n),t.memoizedState=Mo,e):Do(t,l));if(null!==(a=e.memoizedState)&&null!==(r=a.dehydrated))return function(e,t,n,r,i,a,o){if(n)return 256&t.flags?(t.flags&=-257,$o(e,t,o,r=uo(Error(s(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=Fu({mode:"visible",children:r.children},i,0,null),(a=Mu(a,i,o,null)).flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,0!==(1&t.mode)&&ws(t,e.child,null,o),t.child.memoizedState=Fo(o),t.memoizedState=Mo,a);if(0===(1&t.mode))return $o(e,t,o,null);if("$!"===i.data){if(r=i.nextSibling&&i.nextSibling.dataset)var l=r.dgst;return r=l,$o(e,t,o,r=uo(a=Error(s(419)),r,void 0))}if(l=0!==(o&e.childLanes),bo||l){if(null!==(r=Ol)){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}0!==(i=0!==(i&(r.suspendedLanes|o))?0:i)&&i!==a.retryLane&&(a.retryLane=i,Ts(e,i),nu(r,e,i,-1))}return mu(),$o(e,t,o,r=uo(Error(s(421))))}return"$?"===i.data?(t.flags|=128,t.child=e.child,t=Cu.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,rs=ui(i.nextSibling),ns=t,is=!0,ss=null,null!==e&&(qi[Ki++]=Yi,qi[Ki++]=Xi,qi[Ki++]=Qi,Yi=e.id,Xi=e.overflow,Qi=t),t=Do(t,r.children),t.flags|=4096,t)}(e,t,l,i,r,a,n);if(o){o=i.fallback,l=t.mode,r=(a=e.child).sibling;var u={mode:"hidden",children:i.children};return 0===(1&l)&&t.child!==a?((i=t.child).childLanes=0,i.pendingProps=u,t.deletions=null):(i=Nu(a,u)).subtreeFlags=14680064&a.subtreeFlags,null!==r?o=Nu(r,o):(o=Mu(o,l,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,l=null===(l=e.child.memoizedState)?Fo(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~n,t.memoizedState=Mo,i}return e=(o=e.child).sibling,i=Nu(o,{mode:"visible",children:i.children}),0===(1&t.mode)&&(i.lanes=n),i.return=t,i.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=i,t.memoizedState=null,i}function Do(e,t){return(t=Fu({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function $o(e,t,n,r){return null!==r&&fs(r),ws(t,e.child,null,n),(e=Do(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function zo(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Es(e.return,t,n)}function Vo(e,t,n,r,i){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function Uo(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(wo(e,t,r.children,n),0!==(2&(r=Zs.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zo(e,n,t);else if(19===e.tag)zo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ai(Zs,r),0===(1&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;null!==n;)null!==(e=n.alternate)&&null===ea(e)&&(i=n),n=n.sibling;null===(n=i)?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Vo(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===ea(e)){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Vo(t,!0,n,null,s);break;case"together":Vo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Bo(e,t){0===(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wo(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),Fl|=t.lanes,0===(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(s(153));if(null!==t.child){for(n=Nu(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Nu(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function Ho(e,t){if(!is)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Go(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=14680064&i.subtreeFlags,r|=14680064&i.flags,i.return=e,i=i.sibling;else for(i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function qo(e,t,n){var r=t.pendingProps;switch(ts(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Go(t),null;case 1:case 17:return Ri(t.type)&&Ni(),Go(t),null;case 3:return r=t.stateNode,Ys(),Ii(Oi),Ii(Ei),na(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(ps(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,null!==ss&&(au(ss),ss=null))),Ro(e,t),Go(t),null;case 5:Js(t);var i=Ks(qs.current);if(n=t.type,null!==e&&null!=t.stateNode)No(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(s(166));return Go(t),null}if(e=Ks(Hs.current),ps(t)){r=t.stateNode,n=t.type;var a=t.memoizedProps;switch(r[di]=t,r[hi]=a,e=0!==(1&t.mode),n){case"dialog":$r("cancel",r),$r("close",r);break;case"iframe":case"object":case"embed":$r("load",r);break;case"video":case"audio":for(i=0;i<\/script>",e=e.removeChild(e.firstChild)):"string"===typeof r.is?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),"select"===n&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[di]=t,e[hi]=r,Lo(e,t,!1,!1),t.stateNode=e;e:{switch(l=be(n,r),n){case"dialog":$r("cancel",e),$r("close",e),i=r;break;case"iframe":case"object":case"embed":$r("load",e),i=r;break;case"video":case"audio":for(i=0;iUl&&(t.flags|=128,r=!0,Ho(a,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=ea(l))){if(t.flags|=128,r=!0,null!==(n=e.updateQueue)&&(t.updateQueue=n,t.flags|=4),Ho(a,!0),null===a.tail&&"hidden"===a.tailMode&&!l.alternate&&!is)return Go(t),null}else 2*Xe()-a.renderingStartTime>Ul&&1073741824!==n&&(t.flags|=128,r=!0,Ho(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(null!==(n=a.last)?n.sibling=l:t.child=l,a.last=l)}return null!==a.tail?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Xe(),t.sibling=null,n=Zs.current,Ai(Zs,r?1&n|2:1&n),t):(Go(t),null);case 22:case 23:return pu(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!==(1&t.mode)?0!==(1073741824&Rl)&&(Go(t),6&t.subtreeFlags&&(t.flags|=8192)):Go(t),null;case 24:case 25:return null}throw Error(s(156,t.tag))}function Ko(e,t){switch(ts(t),t.tag){case 1:return Ri(t.type)&&Ni(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Ys(),Ii(Oi),Ii(Ei),na(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 5:return Js(t),null;case 13:if(Ii(Zs),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(s(340));hs()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return Ii(Zs),null;case 4:return Ys(),null;case 10:return Cs(t.type._context),null;case 22:case 23:return pu(),null;default:return null}}Lo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Ro=function(){},No=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ks(Hs.current);var s,a=null;switch(n){case"input":i=Q(e,i),r=Q(e,r),a=[];break;case"select":i=j({},i,{value:void 0}),r=j({},r,{value:void 0}),a=[];break;case"textarea":i=re(e,i),r=re(e,r),a=[];break;default:"function"!==typeof i.onClick&&"function"===typeof r.onClick&&(e.onclick=Zr)}for(c in ve(n,r),n=null,i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&null!=i[c])if("style"===c){var l=i[c];for(s in l)l.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else"dangerouslySetInnerHTML"!==c&&"children"!==c&&"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&"autoFocus"!==c&&(o.hasOwnProperty(c)?a||(a=[]):(a=a||[]).push(c,null));for(c in r){var u=r[c];if(l=null!=i?i[c]:void 0,r.hasOwnProperty(c)&&u!==l&&(null!=u||null!=l))if("style"===c)if(l){for(s in l)!l.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in u)u.hasOwnProperty(s)&&l[s]!==u[s]&&(n||(n={}),n[s]=u[s])}else n||(a||(a=[]),a.push(c,n)),n=u;else"dangerouslySetInnerHTML"===c?(u=u?u.__html:void 0,l=l?l.__html:void 0,null!=u&&l!==u&&(a=a||[]).push(c,u)):"children"===c?"string"!==typeof u&&"number"!==typeof u||(a=a||[]).push(c,""+u):"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&(o.hasOwnProperty(c)?(null!=u&&"onScroll"===c&&$r("scroll",e),a||l===u||(a=[])):(a=a||[]).push(c,u))}n&&(a=a||[]).push("style",n);var c=a;(t.updateQueue=c)&&(t.flags|=4)}},To=function(e,t,n,r){n!==r&&(t.flags|=4)};var Qo=!1,Yo=!1,Xo="function"===typeof WeakSet?WeakSet:Set,Jo=null;function Zo(e,t){var n=e.ref;if(null!==n)if("function"===typeof n)try{n(null)}catch(r){_u(e,t,r)}else n.current=null}function el(e,t,n){try{n()}catch(r){_u(e,t,r)}}var tl=!1;function nl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,void 0!==s&&el(t,n,s)}i=i.next}while(i!==r)}}function rl(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function il(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"===typeof t?t(e):t.current=e}}function sl(e){var t=e.alternate;null!==t&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[di],delete t[hi],delete t[mi],delete t[gi],delete t[yi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function al(e){return 5===e.tag||3===e.tag||4===e.tag}function ol(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||al(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function ll(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=Zr));else if(4!==r&&null!==(e=e.child))for(ll(e,t,n),e=e.sibling;null!==e;)ll(e,t,n),e=e.sibling}function ul(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(ul(e,t,n),e=e.sibling;null!==e;)ul(e,t,n),e=e.sibling}var cl=null,pl=!1;function dl(e,t,n){for(n=n.child;null!==n;)hl(e,t,n),n=n.sibling}function hl(e,t,n){if(st&&"function"===typeof st.onCommitFiberUnmount)try{st.onCommitFiberUnmount(it,n)}catch(o){}switch(n.tag){case 5:Yo||Zo(n,t);case 6:var r=cl,i=pl;cl=null,dl(e,t,n),pl=i,null!==(cl=r)&&(pl?(e=cl,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):cl.removeChild(n.stateNode));break;case 18:null!==cl&&(pl?(e=cl,n=n.stateNode,8===e.nodeType?li(e.parentNode,n):1===e.nodeType&&li(e,n),Ut(e)):li(cl,n.stateNode));break;case 4:r=cl,i=pl,cl=n.stateNode.containerInfo,pl=!0,dl(e,t,n),cl=r,pl=i;break;case 0:case 11:case 14:case 15:if(!Yo&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,void 0!==a&&(0!==(2&s)||0!==(4&s))&&el(n,t,a),i=i.next}while(i!==r)}dl(e,t,n);break;case 1:if(!Yo&&(Zo(n,t),"function"===typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){_u(n,t,o)}dl(e,t,n);break;case 21:dl(e,t,n);break;case 22:1&n.mode?(Yo=(r=Yo)||null!==n.memoizedState,dl(e,t,n),Yo=r):dl(e,t,n);break;default:dl(e,t,n)}}function fl(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Xo),t.forEach((function(t){var r=Eu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function ml(e,t){var n=t.deletions;if(null!==n)for(var r=0;ri&&(i=o),r&=~a}if(r=i,10<(r=(120>(r=Xe()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_l(r/1960))-r)){e.timeoutHandle=ri(Su.bind(null,e,zl,Bl),r);break}Su(e,zl,Bl);break;default:throw Error(s(329))}}}return ru(e,Xe()),e.callbackNode===n?iu.bind(null,e):null}function su(e,t){var n=$l;return e.current.memoizedState.isDehydrated&&(du(e,t).flags|=256),2!==(e=gu(e,t))&&(t=zl,zl=n,null!==t&&au(t)),e}function au(e){null===zl?zl=e:zl.push.apply(zl,e)}function ou(e,t){for(t&=~Dl,t&=~jl,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0e?16:e,null===Kl)var r=!1;else{if(e=Kl,Kl=null,Ql=0,0!==(6&El))throw Error(s(331));var i=El;for(El|=4,Jo=e.current;null!==Jo;){var a=Jo,o=a.child;if(0!==(16&Jo.flags)){var l=a.deletions;if(null!==l){for(var u=0;uXe()-Vl?du(e,0):Dl|=n),ru(e,t)}function Au(e,t){0===t&&(0===(1&e.mode)?t=1:(t=ct,0===(130023424&(ct<<=1))&&(ct=4194304)));var n=eu();null!==(e=Ts(e,t))&&(yt(e,t,n),ru(e,n))}function Cu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Au(e,n)}function Eu(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}null!==r&&r.delete(t),Au(e,n)}function Ou(e,t){return qe(e,t)}function Pu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lu(e,t,n,r){return new Pu(e,t,n,r)}function Ru(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Nu(e,t){var n=e.alternate;return null===n?((n=Lu(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Tu(e,t,n,r,i,a){var o=2;if(r=e,"function"===typeof e)Ru(e)&&(o=1);else if("string"===typeof e)o=5;else e:switch(e){case k:return Mu(n.children,i,a,t);case _:o=8,i|=8;break;case I:return(e=Lu(12,n,t,2|i)).elementType=I,e.lanes=a,e;case O:return(e=Lu(13,n,t,i)).elementType=O,e.lanes=a,e;case P:return(e=Lu(19,n,t,i)).elementType=P,e.lanes=a,e;case N:return Fu(n,i,a,t);default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case A:o=10;break e;case C:o=9;break e;case E:o=11;break e;case L:o=14;break e;case R:o=16,r=null;break e}throw Error(s(130,null==e?e:typeof e,""))}return(t=Lu(o,n,t,i)).elementType=e,t.type=r,t.lanes=a,t}function Mu(e,t,n,r){return(e=Lu(7,e,r,t)).lanes=n,e}function Fu(e,t,n,r){return(e=Lu(22,e,r,t)).elementType=N,e.lanes=n,e.stateNode={isHidden:!1},e}function ju(e,t,n){return(e=Lu(6,e,null,t)).lanes=n,e}function Du(e,t,n){return(t=Lu(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function $u(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gt(0),this.expirationTimes=gt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function zu(e,t,n,r,i,s,a,o,l){return e=new $u(e,t,n,o,l),1===t?(t=1,!0===s&&(t|=8)):t=0,s=Lu(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fs(s),e}function Vu(e){if(!e)return Ci;e:{if(Ue(e=e._reactInternals)!==e||1!==e.tag)throw Error(s(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ri(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(s(171))}if(1===e.tag){var n=e.type;if(Ri(n))return Mi(e,n,t)}return t}function Uu(e,t,n,r,i,s,a,o,l){return(e=zu(n,r,!0,e,0,s,0,o,l)).context=Vu(null),n=e.current,(s=Ds(r=eu(),i=tu(n))).callback=void 0!==t&&null!==t?t:null,$s(n,s,i),e.current.lanes=i,yt(e,i,r),ru(e,r),e}function Bu(e,t,n,r){var i=t.current,s=eu(),a=tu(i);return n=Vu(n),null===t.context?t.context=n:t.pendingContext=n,(t=Ds(s,a)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=$s(i,t,a))&&(nu(e,i,a,s),zs(e,i,a)),a}function Wu(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function Hu(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n{var r=n(8815);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},8815:(e,t,n)=>{!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(2777)},5817:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=e||"";t&&(s=e.toString().trim().replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,(function(e,t,r){return t>0&&t+e.length!==r.length&&e.search(n)>-1&&":"!==r.charAt(t-2)&&("-"!==r.charAt(t+e.length)||"-"===r.charAt(t-1))&&r.charAt(t-1).search(/[^\s-]/)<0?e.toLowerCase():e.substr(1).search(/[A-Z]|\../)>-1?e:e.charAt(0).toUpperCase()+e.substr(1)})));i&&(s=function(e){if(function(e){return"string"===typeof e&&-1!==e.indexOf("@")}(e))return console.warn("This arg looks like an email address, redacting."),r;return e}(s));return s};var n=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;var r="REDACTED (Potential Email Address)"},5068:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.GA4=void 0;var r=l(n(5189)),i=l(n(5817)),s=["eventCategory","eventAction","eventLabel","eventValue","hitType"],a=["title","location"],o=["page","hitType"];function l(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function p(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n2&&void 0!==arguments[2]?arguments[2]:"https://www.googletagmanager.com/gtag/js";if("undefined"!==typeof window&&"undefined"!==typeof document&&!t._hasLoadedGA){var i=document.createElement("script");i.async=!0,i.src="".concat(r,"?id=").concat(e),n&&i.setAttribute("nonce",n),document.body.appendChild(i),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},t._hasLoadedGA=!0}})),v(this,"_toGtagOptions",(function(e){if(e){var t={cookieUpdate:"cookie_update",cookieExpires:"cookie_expires",cookieDomain:"cookie_domain",cookieFlags:"cookie_flags",userId:"user_id",clientId:"client_id",anonymizeIp:"anonymize_ip",contentGroup1:"content_group1",contentGroup2:"content_group2",contentGroup3:"content_group3",contentGroup4:"content_group4",contentGroup5:"content_group5",allowAdFeatures:"allow_google_signals",allowAdPersonalizationSignals:"allow_ad_personalization_signals",nonInteraction:"non_interaction",page:"page_path",hitCallback:"event_callback"};return Object.entries(e).reduce((function(e,n){var r=f(n,2),i=r[0],s=r[1];return t[i]?e[t[i]]=s:e[i]=s,e}),{})}})),v(this,"initialize",(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("Require GA_MEASUREMENT_ID");var r="string"===typeof e?[{trackingId:e}]:e;t._currentMeasurementId=r[0].trackingId;var i=n.gaOptions,s=n.gtagOptions,a=n.nonce,o=n.testMode,l=void 0!==o&&o,u=n.gtagUrl;if(t._testMode=l,l||t._loadGA(t._currentMeasurementId,a,u),t.isInitialized||(t._gtag("js",new Date),r.forEach((function(e){var n=h(h(h({},t._toGtagOptions(h(h({},i),e.gaOptions))),s),e.gtagOptions);Object.keys(n).length?t._gtag("config",e.trackingId,n):t._gtag("config",e.trackingId)}))),t.isInitialized=!0,!l){var c=p(t._queueGtag);for(t._queueGtag=[],t._isQueuing=!1;c.length;){var d=c.shift();t._gtag.apply(t,p(d)),"get"===d[0]&&(t._isQueuing=!0)}}})),v(this,"set",(function(e){e?"object"===c(e)?(0===Object.keys(e).length&&console.warn("empty `fieldsObject` given to .set()"),t._gaCommand("set",e)):console.warn("Expected `fieldsObject` arg to be an Object"):console.warn("`fieldsObject` is required in .set()")})),v(this,"_gaCommandSendEvent",(function(e,n,r,i,s){t._gtag("event",n,h(h({event_category:e,event_label:r,value:i},s&&{non_interaction:s.nonInteraction}),t._toGtagOptions(s)))})),v(this,"_gaCommandSendEventParameters",(function(){for(var e=arguments.length,n=new Array(e),r=0;r1?n-1:0),i=1;i{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.Ay=void 0;var i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!==typeof e)return{default:e};var n=s(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(5068));function s(e){if("function"!==typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(s=function(e){return e?n:t})(e)}i.GA4;var a=i.default;t.Ay=a},8330:(e,t,n)=>{var r,i;n.d(t,{Kd:()=>h,N_:()=>g});var s=n(8878),a=n(8815),o=n(3229),l=n(1642);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(i[n]=e[n]);return i}new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);const p=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"];try{window.__reactRouterVersion="6"}catch(b){}new Map;const d=(r||(r=n.t(s,2))).startTransition;(i||(i=n.t(a,2))).flushSync,(r||(r=n.t(s,2))).useId;function h(e){let{basename:t,children:n,future:r,window:i}=e,a=s.useRef();null==a.current&&(a.current=(0,l.zR)({window:i,v5Compat:!0}));let u=a.current,[c,p]=s.useState({action:u.action,location:u.location}),{v7_startTransition:h}=r||{},f=s.useCallback((e=>{h&&d?d((()=>p(e))):p(e)}),[p,h]);return s.useLayoutEffect((()=>u.listen(f)),[u,f]),s.createElement(o.Ix,{basename:t,children:n,location:c.location,navigationType:c.action,navigator:u,future:r})}const f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,g=s.forwardRef((function(e,t){let n,{onClick:r,relative:i,reloadDocument:a,replace:d,state:h,target:g,to:y,preventScrollReset:v,unstable_viewTransition:w}=e,S=c(e,p),{basename:x}=s.useContext(o.jb),k=!1;if("string"===typeof y&&m.test(y)&&(n=y,f))try{let e=new URL(window.location.href),t=y.startsWith("//")?new URL(e.protocol+y):new URL(y),n=(0,l.pb)(t.pathname,x);t.origin===e.origin&&null!=n?y=n+t.search+t.hash:k=!0}catch(b){}let _=(0,o.$P)(y,{relative:i}),I=function(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:u,unstable_viewTransition:c}=void 0===t?{}:t,p=(0,o.Zp)(),d=(0,o.zy)(),h=(0,o.x$)(e,{relative:u});return s.useCallback((t=>{if(function(e,t){return 0===e.button&&(!t||"_self"===t)&&!function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)}(t,n)){t.preventDefault();let n=void 0!==r?r:(0,l.AO)(d)===(0,l.AO)(h);p(e,{replace:n,state:i,preventScrollReset:a,relative:u,unstable_viewTransition:c})}}),[d,p,h,r,i,n,e,a,u,c])}(y,{replace:d,state:h,target:g,preventScrollReset:v,relative:i,unstable_viewTransition:w});return s.createElement("a",u({},S,{href:n||_,onClick:k||a?r:function(e){r&&r(e),e.defaultPrevented||I(e)},ref:t,target:g}))}));var y,v;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(y||(y={})),function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(v||(v={}))},3229:(e,t,n)=>{var r;n.d(t,{$P:()=>h,BV:()=>T,C5:()=>L,Ix:()=>N,Zp:()=>y,jb:()=>u,qh:()=>R,x$:()=>v,zy:()=>m});var i=n(8878),s=n(1642);function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t{n.current=!0})),i.useCallback((function(r,i){void 0===i&&(i={}),n.current&&("number"===typeof r?e.navigate(r):e.navigate(r,a({fromRouteId:t},i)))}),[e,t])}():function(){f()||(0,s.Oi)(!1);let e=i.useContext(o),{basename:t,future:n,navigator:r}=i.useContext(u),{matches:a}=i.useContext(p),{pathname:l}=m(),c=JSON.stringify((0,s.yD)(a,n.v7_relativeSplatPath)),d=i.useRef(!1);return g((()=>{d.current=!0})),i.useCallback((function(n,i){if(void 0===i&&(i={}),!d.current)return;if("number"===typeof n)return void r.go(n);let a=(0,s.Gh)(n,JSON.parse(c),l,"path"===i.relative);null==e&&"/"!==t&&(a.pathname="/"===a.pathname?t:(0,s.HS)([t,a.pathname])),(i.replace?r.replace:r.push)(a,i.state,i)}),[t,r,c,l,e])}()}function v(e,t){let{relative:n}=void 0===t?{}:t,{future:r}=i.useContext(u),{matches:a}=i.useContext(p),{pathname:o}=m(),l=JSON.stringify((0,s.yD)(a,r.v7_relativeSplatPath));return i.useMemo((()=>(0,s.Gh)(e,JSON.parse(l),o,"path"===n)),[e,l,o,n])}function b(e,t,n,r){f()||(0,s.Oi)(!1);let{navigator:o}=i.useContext(u),{matches:l}=i.useContext(p),d=l[l.length-1],h=d?d.params:{},g=(d&&d.pathname,d?d.pathnameBase:"/");d&&d.route;let y,v=m();if(t){var b;let e="string"===typeof t?(0,s.Rr)(t):t;"/"===g||(null==(b=e.pathname)?void 0:b.startsWith(g))||(0,s.Oi)(!1),y=e}else y=v;let w=y.pathname||"/",S=w;if("/"!==g){let e=g.replace(/^\//,"").split("/");S="/"+w.replace(/^\//,"").split("/").slice(e.length).join("/")}let x=(0,s.ue)(e,{pathname:S});let k=_(x&&x.map((e=>Object.assign({},e,{params:Object.assign({},h,e.params),pathname:(0,s.HS)([g,o.encodeLocation?o.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?g:(0,s.HS)([g,o.encodeLocation?o.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,n,r);return t&&k?i.createElement(c.Provider,{value:{location:a({pathname:"/",search:"",hash:"",state:null,key:"default"},y),navigationType:s.rc.Pop}},k):k}function w(){let e=function(){var e;let t=i.useContext(d),n=E(A.UseRouteError),r=O(A.UseRouteError);if(void 0!==t)return t;return null==(e=n.errors)?void 0:e[r]}(),t=(0,s.pX)(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r};return i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},t),n?i.createElement("pre",{style:a},n):null,null)}const S=i.createElement(w,null);class x extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?i.createElement(p.Provider,{value:this.props.routeContext},i.createElement(d.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function k(e){let{routeContext:t,match:n,children:r}=e,s=i.useContext(o);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),i.createElement(p.Provider,{value:t},r)}function _(e,t,n,r){var a;if(void 0===t&&(t=[]),void 0===n&&(n=null),void 0===r&&(r=null),null==e){var o;if(null==(o=n)||!o.errors)return null;e=n.matches}let l=e,u=null==(a=n)?void 0:a.errors;if(null!=u){let e=l.findIndex((e=>e.route.id&&void 0!==(null==u?void 0:u[e.route.id])));e>=0||(0,s.Oi)(!1),l=l.slice(0,Math.min(l.length,e+1))}let c=!1,p=-1;if(n&&r&&r.v7_partialHydration)for(let i=0;i=0?l.slice(0,p+1):[l[0]];break}}}return l.reduceRight(((e,r,s)=>{let a,o=!1,d=null,h=null;var f;n&&(a=u&&r.route.id?u[r.route.id]:void 0,d=r.route.errorElement||S,c&&(p<0&&0===s?(f="route-fallback",!1||P[f]||(P[f]=!0),o=!0,h=null):p===s&&(o=!0,h=r.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,s+1)),g=()=>{let t;return t=a?d:o?h:r.route.Component?i.createElement(r.route.Component,null):r.route.element?r.route.element:e,i.createElement(k,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:null!=n},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||0===s)?i.createElement(x,{location:n.location,revalidation:n.revalidation,component:d,error:a,children:g(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):g()}),null)}var I=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(I||{}),A=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(A||{});function C(e){let t=i.useContext(o);return t||(0,s.Oi)(!1),t}function E(e){let t=i.useContext(l);return t||(0,s.Oi)(!1),t}function O(e){let t=function(e){let t=i.useContext(p);return t||(0,s.Oi)(!1),t}(),n=t.matches[t.matches.length-1];return n.route.id||(0,s.Oi)(!1),n.route.id}const P={};(r||(r=n.t(i,2))).startTransition;function L(e){let{to:t,replace:n,state:r,relative:a}=e;f()||(0,s.Oi)(!1);let{future:o,static:l}=i.useContext(u),{matches:c}=i.useContext(p),{pathname:d}=m(),h=y(),g=(0,s.Gh)(t,(0,s.yD)(c,o.v7_relativeSplatPath),d,"path"===a),v=JSON.stringify(g);return i.useEffect((()=>h(JSON.parse(v),{replace:n,state:r,relative:a})),[h,v,a,n,r]),null}function R(e){(0,s.Oi)(!1)}function N(e){let{basename:t="/",children:n=null,location:r,navigationType:o=s.rc.Pop,navigator:l,static:p=!1,future:d}=e;f()&&(0,s.Oi)(!1);let h=t.replace(/^\/*/,"/"),m=i.useMemo((()=>({basename:h,navigator:l,static:p,future:a({v7_relativeSplatPath:!1},d)})),[h,d,l,p]);"string"===typeof r&&(r=(0,s.Rr)(r));let{pathname:g="/",search:y="",hash:v="",state:b=null,key:w="default"}=r,S=i.useMemo((()=>{let e=(0,s.pb)(g,h);return null==e?null:{location:{pathname:e,search:y,hash:v,state:b,key:w},navigationType:o}}),[h,g,y,v,b,w,o]);return null==S?null:i.createElement(u.Provider,{value:m},i.createElement(c.Provider,{children:n,value:S}))}function T(e){let{children:t,location:n}=e;return b(M(t),n)}new Promise((()=>{}));i.Component;function M(e,t){void 0===t&&(t=[]);let n=[];return i.Children.forEach(e,((e,r)=>{if(!i.isValidElement(e))return;let a=[...t,r];if(e.type===i.Fragment)return void n.push.apply(n,M(e.props.children,a));e.type!==R&&(0,s.Oi)(!1),e.props.index&&e.props.children&&(0,s.Oi)(!1);let o={id:e.props.id||a.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(o.children=M(e.props.children,a)),n.push(o)})),n}},1406:(e,t,n)=>{var r=n(8878),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,s={},u=null,c=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)a.call(t,r)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:u,ref:c,props:s,_owner:o.current}}t.Fragment=s,t.jsx=u,t.jsxs=u},33:(e,t)=>{var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=b.prototype=new v;w.constructor=b,m(w,y.prototype),w.isPureReactComponent=!0;var S=Array.isArray,x=Object.prototype.hasOwnProperty,k={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};function I(e,t,r){var i,s={},a=null,o=null;if(null!=t)for(i in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(a=""+t.key),t)x.call(t,i)&&!_.hasOwnProperty(i)&&(s[i]=t[i]);var l=arguments.length-2;if(1===l)s.children=r;else if(1{e.exports=n(33)},782:(e,t,n)=>{e.exports=n(1406)},9169:(e,t)=>{function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,i=e[r];if(!(0>>1;rs(l,n))us(c,l)?(e[r]=c,e[u]=n,r=u):(e[r]=l,e[o]=n,r=o);else{if(!(us(c,n)))break e;e[r]=c,e[u]=n,r=u}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"===typeof performance&&"function"===typeof performance.now){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],c=[],p=1,d=null,h=3,f=!1,m=!1,g=!1,y="function"===typeof setTimeout?setTimeout:null,v="function"===typeof clearTimeout?clearTimeout:null,b="undefined"!==typeof setImmediate?setImmediate:null;function w(e){for(var t=r(c);null!==t;){if(null===t.callback)i(c);else{if(!(t.startTime<=e))break;i(c),t.sortIndex=t.expirationTime,n(u,t)}t=r(c)}}function S(e){if(g=!1,w(e),!m)if(null!==r(u))m=!0,N(x);else{var t=r(c);null!==t&&T(S,t.startTime-e)}}function x(e,n){m=!1,g&&(g=!1,v(A),A=-1),f=!0;var s=h;try{for(w(n),d=r(u);null!==d&&(!(d.expirationTime>n)||e&&!O());){var a=d.callback;if("function"===typeof a){d.callback=null,h=d.priorityLevel;var o=a(d.expirationTime<=n);n=t.unstable_now(),"function"===typeof o?d.callback=o:d===r(u)&&i(u),w(n)}else i(u);d=r(u)}if(null!==d)var l=!0;else{var p=r(c);null!==p&&T(S,p.startTime-n),l=!1}return l}finally{d=null,h=s,f=!1}}"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k,_=!1,I=null,A=-1,C=5,E=-1;function O(){return!(t.unstable_now()-Ee||125a?(e.sortIndex=s,n(c,e),null===r(u)&&e===r(c)&&(g?(v(A),A=-1):g=!0,T(S,s-a))):(e.sortIndex=o,n(u,e),m||f||(m=!0,N(x))),e},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}},7116:(e,t,n)=>{e.exports=n(9169)},5384:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.errorMessages=t.ErrorType=void 0,function(e){e.MalformedUnicode="MALFORMED_UNICODE",e.MalformedHexadecimal="MALFORMED_HEXADECIMAL",e.CodePointLimit="CODE_POINT_LIMIT",e.OctalDeprecation="OCTAL_DEPRECATION",e.EndOfString="END_OF_STRING"}(n=t.ErrorType||(t.ErrorType={})),t.errorMessages=new Map([[n.MalformedUnicode,"malformed Unicode character escape sequence"],[n.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[n.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[n.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[n.EndOfString,"malformed escape sequence at end of string"]])},2527:(e,t,n)=>{t.MH=void 0;const r=n(5384);function i(e,t,n){const i=function(e){return e.match(/[^a-f0-9]/i)?NaN:parseInt(e,16)}(e);if(Number.isNaN(i)||void 0!==n&&n!==e.length)throw new SyntaxError(r.errorMessages.get(t));return i}function s(e,t){const n=i(e,r.ErrorType.MalformedUnicode,4);if(void 0!==t){const e=i(t,r.ErrorType.MalformedUnicode,4);return String.fromCharCode(n,e)}return String.fromCharCode(n)}const a=new Map([["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t","\t"],["v","\v"],["0","\0"]]);const o=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function l(e,t=!1){return e.replace(o,(function(e,n,o,l,u,c,p,d,h){if(void 0!==n)return"\\";if(void 0!==o)return function(e){const t=i(e,r.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(t)}(o);if(void 0!==l)return function(e){if("{"!==(t=e).charAt(0)||"}"!==t.charAt(t.length-1))throw new SyntaxError(r.errorMessages.get(r.ErrorType.MalformedUnicode));var t;const n=i(e.slice(1,-1),r.ErrorType.MalformedUnicode);try{return String.fromCodePoint(n)}catch(s){throw s instanceof RangeError?new SyntaxError(r.errorMessages.get(r.ErrorType.CodePointLimit)):s}}(l);if(void 0!==u)return s(u,c);if(void 0!==p)return s(p);if("0"===d)return"\0";if(void 0!==d)return function(e,t=!1){if(t)throw new SyntaxError(r.errorMessages.get(r.ErrorType.OctalDeprecation));const n=parseInt(e,8);return String.fromCharCode(n)}(d,!t);if(void 0!==h)return f=h,a.get(f)||f;var f;throw new SyntaxError(r.errorMessages.get(r.ErrorType.EndOfString))}))}t.MH=l},7365:(e,t,n)=>{n.d(t,{U:()=>a,_:()=>o});var r=n(5874),i=n(7589);function s(e,t){const n=[];for(let r=0;r({span:{start:e.start+f,end:e.end+f,line:e.line},type:"error-cell"})))),f+=e.expectedLine.length+1,h.push(e.expectedLine),m.push({span:{start:f,end:f+e.expectedLine.length,line:r},type:"correct-line"}),m.push(...e.correctCellSpans.map((e=>({span:{start:e.start+f,end:e.end+f,line:h.length},type:"correct-cell"})))),f+=e.givenLine.length+1):(h.push(p[r]),f+=p[r].length+1)}let y=h.join("\n");return y.endsWith("\n")&&(y=y.substring(0,y.length-1)),{text:y,failureNum:u.length,decorations:m,lineNumbers:g}}function l(e,t){const n=e.split("|").filter((e=>""!=e)),r=Array.from(n),i=[];let s=0;for(let l=0;l{n.d(t,{g:()=>i});var r=n(5874);async function i(e,t){try{const i=await e.readFile(t);let s;try{const n=t.replace("VME.tst",".tst").replace(".tst",".cmp");s=await e.readFile(n)}catch(n){}return(0,r.Ok)({tst:i,cmp:s})}catch(n){return(0,r._)(n)}}},7490:(e,t,n)=>{n.d(t,{vl:()=>h,ZB:()=>c,wG:()=>g,FX:()=>d});var r=n(782),i=n(742),s=n(8878),a=n(2469),o=n(6980);class l{signBehaviors=new Map;constructor(e,t){if(o.Mo.has(e)){const n=(0,a.Z1)(o.Mo.get(e)?.()),r=[...n.ins.entries(),...n.outs.entries()];for(const e of r)this.signBehaviors.set(e.name,!t||!t.includes(e.name))}}isSigned(e){return this.signBehaviors.get(e)}}const u=new Map([["Mux4Way16",["sel"]],["Mux8Way16",["sel"]],["DMux4Way",["sel"]],["DMux8Way",["sel"]],["RAM8",["address"]],["RAM64",["address"]],["RAM512",["address"]],["RAM4K",["address"]],["RAM16K",["address"]],["Screen",["address"]],["Memory",["address"]],["CPU",["addressM","pc"]]]),c=(0,s.createContext)({});function p(e){return{pin:e,bits:(0,i.y)(0,e.width).map((t=>[t,e.voltage(t)])).reverse()}}function d(e){return[...e.entries()].map(p)}const h=e=>{const{inPins:t,outPins:n,internalPins:i}=e.sim,s=(a=e.sim.chip[0].name??"",new l(a,u.get(a)));var a;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:"\n table.pinout th {\n font-weight: bold;\n }\n\n table.pinout tbody td:first-child {\n text-align: right;\n --font-size: 1rem;\n width: 0;\n white-space: nowrap;\n border-right: var(--border-width) solid var(--table-border-color);\n }\n\n table.pinout tbody button {\n --font-size: 0.875em;\n font-family: var(--font-family-monospace);\n max-width: 2em;\n }\n "}),(0,r.jsx)("table",{className:"pinout",children:(0,r.jsxs)("tbody",{children:[(0,r.jsx)(f,{pins:t,header:"Input pins",toggle:e.toggle,setInputValid:e.setInputValid,displayInfo:s}),(0,r.jsx)(f,{pins:n,header:"Output pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s}),!e.hideInternal&&(0,r.jsx)(f,{pins:i,header:"Internal pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s})]})})]})},f=e=>(0,r.jsxs)(r.Fragment,{children:[e.pins.length>0&&(0,r.jsx)("tr",{children:(0,r.jsx)("th",{colSpan:2,children:e.header})}),[...e.pins].map((t=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:t.pin.name}),(0,r.jsx)("td",{children:(0,r.jsx)(m,{pin:t,toggle:e.toggle,disabled:e.disabled,enableEdit:e.enableEdit,signed:e.displayInfo.isSigned(t.pin.name),setInputValid:e.setInputValid,internal:"Internal pins"===e.header})})]},t.pin.name)))]}),m=({pin:e,toggle:t,disabled:n=!1,enableEdit:i=!0,signed:a=!0,setInputValid:o,internal:l=!1})=>{const[u,p]=(0,s.useState)(!0);let d=!0;const[h,f]=(0,s.useState)(""),m=(0,s.useContext)(c);m instanceof g&&m.registerCallback((()=>{p(!0)}));const y=e=>{d=e,o?.(e)},v=n=>{for(let r=0;r>r&1)&&t?.(e.pin,r)};return(0,s.useEffect)((()=>{if(!u&&d){let t=0;if(a&&e.bits[0][1]){for(const[n,r]of e.bits)n(0,r.jsx)("button",{disabled:n,style:l?{backgroundColor:"grey"}:{},onClick:()=>t?.(e.pin,i),"data-testid":`pin-${i}`,children:s},i))):(0,r.jsx)("input",{className:"colored",value:h,onChange:t=>{(t=>{const n=t.replace(/[^\d]/g,""),r=a&&"-"===t[0]?`-${n}`:n;if(f(r),isNaN(parseInt(r)))y(!1);else{const t=parseInt(r);!a&&t>=Math.pow(2,e.bits.length)||a&&(t>=Math.pow(2,e.bits.length-1)||t<-Math.pow(2,e.bits.length-1))?y(!1):(v(t),y(!0))}})(t.target.value)},disabled:!i})}),e.bits.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{width:"1em"}}),(0,r.jsx)("button",{className:"pin-control",onClick:()=>{p(!u)},children:u?"dec":"bin"})]})]})};class g{callbacks=[];registerCallback(e){this.callbacks.push(e)}reset(){for(const e of this.callbacks)e()}}},1593:(e,t,n)=>{n.d(t,{A:()=>q,b:()=>K});var r=Symbol.for("immer-nothing"),i=Symbol.for("immer-draftable"),s=Symbol.for("immer-state");function a(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var o=Object.getPrototypeOf;function l(e){return!!e&&!!e[s]}function u(e){return!!e&&(p(e)||Array.isArray(e)||!!e[i]||!!e.constructor?.[i]||g(e)||y(e))}var c=Object.prototype.constructor.toString();function p(e){if(!e||"object"!==typeof e)return!1;const t=o(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===c}function d(e,t){0===h(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,r)=>t(r,n,e)))}function h(e){const t=e[s];return t?t.type_:Array.isArray(e)?1:g(e)?2:y(e)?3:0}function f(e,t){return 2===h(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function m(e,t,n){const r=h(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function g(e){return e instanceof Map}function y(e){return e instanceof Set}function v(e){return e.copy_||e.base_}function b(e,t){if(g(e))return new Map(e);if(y(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=p(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[s];let n=Reflect.ownKeys(t);for(let r=0;r1&&(e.set=e.add=e.clear=e.delete=S),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>w(t,!0)))),e}function S(){a(2)}function x(e){return Object.isFrozen(e)}var k,_={};function I(e){const t=_[e];return t||a(0),t}function A(){return k}function C(e,t){t&&(I("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function E(e){O(e),e.drafts_.forEach(L),e.drafts_=null}function O(e){e===k&&(k=e.parent_)}function P(e){return k={drafts_:[],parent_:k,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function L(e){const t=e[s];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function R(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[s].modified_&&(E(t),a(4)),u(e)&&(e=N(t,e),t.parent_||M(t,e)),t.patches_&&I("Patches").generateReplacementPatches_(n[s].base_,e,t.patches_,t.inversePatches_)):e=N(t,n,[]),E(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==r?e:void 0}function N(e,t,n){if(x(t))return t;const r=t[s];if(!r)return d(t,((i,s)=>T(e,r,t,i,s,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return M(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let i=t,s=!1;3===r.type_&&(i=new Set(t),t.clear(),s=!0),d(i,((i,a)=>T(e,r,t,i,a,n,s))),M(e,t,!1),n&&e.patches_&&I("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function T(e,t,n,r,i,s,a){if(l(i)){const a=N(e,i,s&&t&&3!==t.type_&&!f(t.assigned_,r)?s.concat(r):void 0);if(m(n,r,a),!l(a))return;e.canAutoFreeze_=!1}else a&&n.add(i);if(u(i)&&!x(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;N(e,i),t&&t.scope_.parent_||"symbol"===typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||M(e,i)}}function M(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&w(t,n)}var F={get(e,t){if(t===s)return e;const n=v(e);if(!f(n,t))return function(e,t,n){const r=$(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!u(r)?r:r===D(e.base_,t)?(V(e),e.copy_[t]=U(r,e)):r},has:(e,t)=>t in v(e),ownKeys:e=>Reflect.ownKeys(v(e)),set(e,t,n){const r=$(v(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=D(v(e),t),o=r?.[s];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((i=n)===(a=r)?0!==i||1/i===1/a:i!==i&&a!==a)&&(void 0!==n||f(e.base_,t)))return!0;V(e),z(e)}var i,a;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==D(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,V(e),z(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=v(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){a(11)},getPrototypeOf:e=>o(e.base_),setPrototypeOf(){a(12)}},j={};function D(e,t){const n=e[s];return(n?v(n):e)[t]}function $(e,t){if(!(t in e))return;let n=o(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=o(n)}}function z(e){e.modified_||(e.modified_=!0,e.parent_&&z(e.parent_))}function V(e){e.copy_||(e.copy_=b(e.base_,e.scope_.immer_.useStrictShallowCopy_))}d(F,((e,t)=>{j[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),j.deleteProperty=function(e,t){return j.set.call(this,e,t,void 0)},j.set=function(e,t,n){return F.set.call(this,e[0],t,n,e[0])};function U(e,t){const n=g(e)?I("MapSet").proxyMap_(e,t):y(e)?I("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:A(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=F;n&&(i=[r],s=j);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}(e,t);return(t?t.scope_:A()).drafts_.push(n),n}function B(e){if(!u(e)||x(e))return e;const t=e[s];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=b(e,t.scope_.immer_.useStrictShallowCopy_)}else n=b(e,!0);return d(n,((e,t)=>{m(n,e,B(t))})),t&&(t.finalized_=!1),n}var W=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"===typeof e&&"function"!==typeof t){const n=t;t=e;const r=this;return function(e=n,...i){return r.produce(e,(e=>t.call(this,e,...i)))}}let i;if("function"!==typeof t&&a(6),void 0!==n&&"function"!==typeof n&&a(7),u(e)){const r=P(this),s=U(e,void 0);let a=!0;try{i=t(s),a=!1}finally{a?E(r):O(r)}return C(r,n),R(i,r)}if(!e||"object"!==typeof e){if(i=t(e),void 0===i&&(i=e),i===r&&(i=void 0),this.autoFreeze_&&w(i,!0),n){const t=[],r=[];I("Patches").generateReplacementPatches_(e,i,t,r),n(t,r)}return i}a(1)},this.produceWithPatches=(e,t)=>{if("function"===typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;return[this.produce(e,t,((e,t)=>{n=e,r=t})),n,r]},"boolean"===typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"===typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){u(e)||a(8),l(e)&&(e=function(e){l(e)||a(10);return B(e)}(e));const t=P(this),n=U(e,void 0);return n[s].isManual_=!0,O(t),n}finishDraft(e,t){const n=e&&e[s];n&&n.isManual_||a(9);const{scope_:r}=n;return C(r,t),R(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=I("Patches").applyPatches_;return l(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},H=W.produce;W.produceWithPatches.bind(W),W.setAutoFreeze.bind(W),W.setUseStrictShallowCopy.bind(W),W.applyPatches.bind(W),W.createDraft.bind(W),W.finishDraft.bind(W);var G=n(8878);function q(e,t){return(0,G.useReducer)(((t,n)=>H(t,(t=>{e[n.action](t,n.payload)}))),t)}function K(e){const[t,n]=(0,G.useState)(e);return(0,G.useEffect)((()=>{n(e)}),[e]),[t,n]}},910:(e,t,n)=>{n.d(t,{L:()=>h,A:()=>d});var r=n(4544),i=n(8878),s=n(1916),a=n(2469);const o="NAND2TetrisIndexedDB",l=1,u="FileSystemAccess",c="Handler";function p(){return new Promise(((e,t)=>{const n=window.indexedDB.open(o,l);n.onsuccess=()=>{e(n.result)},n.onerror=()=>{t(n.error)},n.onupgradeneeded=e=>{n.result.createObjectStore(u)}}))}function d(){const e=(0,i.useMemo)((()=>new r.JU),[]),[t,n]=(0,i.useState)(new r.Q2(e)),[l,d]=(0,i.useState)(),h=(0,i.useCallback)((i=>{const a=new r.Q2(new s.Le(new s.Ik(i),e));a.cd(t.cwd()),n(a),d(i.name)}),[n,d]);(0,i.useEffect)((()=>{l||async function(){const e=await p();return new Promise(((t,n)=>{const r=e.transaction([u],"readonly"),i=r.objectStore(u).get(c);i.onsuccess=()=>{const e=i.result;void 0===e?t():((0,a.vA)(e instanceof FileSystemDirectoryHandle,`Retrieved ${c} in ${u} in ${o} is not a FileSystemDirectoryHandle`),t(e))},r.onerror=()=>{console.error("Error in loading FileSystemDirectoryHandle transaction",{err:r.error}),n(r.error)},i.onerror=()=>{console.error("Error in FileSystemDirectoryHandle handleRequest",{err:i.error}),n(i.error)}}))}().then((e=>{e&&h(e)}))}),[l,h]);const f="showDirectoryPicker"in window,m=(0,i.useCallback)((async(e=!1)=>{if(!f||l&&!e)return;const t=await(0,s.EH)(),n=await async function(e){const t=(await p()).transaction([u],"readwrite");return t.objectStore(u).add(e,c),t.commit(),new Promise(((n,r)=>{t.oncomplete=()=>{n(e)},t.onerror=()=>{r(t.error)}}))}(t);h(n)}),[l,h]),g=(0,i.useCallback)((async()=>{l&&(await async function(){const e=(await p()).transaction([u],"readwrite");return e.objectStore(u).delete(c),new Promise(((t,n)=>{e.oncomplete=()=>{t()},e.onerror=()=>{n(e.error)}}))}(),n(new r.Q2(e)),d(void 0))}),[l,e]),[y,v]=(0,i.useState)("");return{fs:t,status:y,setStatus:v,storage:localStorage,canUpgradeFs:f,upgradeFs:m,closeFs:g,upgraded:l}}const h=(0,i.createContext)({fs:new r.Q2(new r.JU),canUpgradeFs:!1,upgradeFs(){},closeFs(){},status:"",setStatus(){},storage:{}})},1916:(e,t,n)=>{n.d(t,{EH:()=>s,Ik:()=>a,Le:()=>o});var r=n(4544);function i(e){return e.split(r.d$).slice(0,-1).join(r.d$)}function s(){return window.showDirectoryPicker({id:"nand2tetris",mode:"readwrite",startIn:"documents"})}class a{baseDir;constructor(e){this.baseDir=e}async getFolder(e,t=!1){let n=this.baseDir;const i=e.split(r.d$).slice(1).filter((e=>""!=e.trim()));for(const r of i)n=await n.getDirectoryHandle(r,{create:t});return n}async copyFile(e,t){throw new Error("unimplemented: FileSystemAccessFileSystemAdapter::copyFile")}async mkdir(e){this.getFolder(e,!0)}async readFile(e){const t=await this.getFolder(i(e));return(await(await t.getFileHandle((0,r.P8)(e))).getFile()).text()}async writeFile(e,t){const n=await this.getFolder(i(e),!0),s=await(await n.getFileHandle((0,r.P8)(e),{create:!0})).createWritable();await s.write(t),await s.close()}async readdir(e){const t=await this.getFolder(e),n=[];for await(const[r,i]of t.entries())n.push(r);return n}async scandir(e){const t=await this.getFolder(e),n=[];for await(const[r,i]of t.entries())n.push({name:r,isDirectory:()=>"directory"==i.kind,isFile:()=>"file"==i.kind});return n}async stat(e){const t=await this.getFolder(i(e));for await(const[n,i]of t.entries())if(n==(0,r.P8)(e))return{name:n,isDirectory:()=>"directory"==i.kind,isFile:()=>"file"==i.kind};return{name:(0,r.P8)(e),isDirectory:()=>!1,isFile:()=>!1}}async rm(e){const t=await this.getFolder(i(e),!0);await t.removeEntry((0,r.P8)(e),{recursive:!0})}}class o{adapter;nextAdapter;constructor(e,t){this.adapter=e,this.nextAdapter=t}stat(e){return this.adapter.stat(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.stat(e);throw t}))}readdir(e){return this.adapter.readdir(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.readdir(e);throw t}))}scandir(e){return this.adapter.scandir(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.scandir(e);throw t}))}async mkdir(e){return this.nextAdapter&&await this.nextAdapter.mkdir(e),this.adapter.mkdir(e)}async copyFile(e,t){return this.nextAdapter&&await this.nextAdapter.copyFile(e,t),this.adapter.copyFile(e,t)}readFile(e){return this.adapter.readFile(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.readFile(e);throw t}))}async writeFile(e,t){return this.nextAdapter&&await(this.nextAdapter?.writeFile(e,t)),this.adapter.writeFile(e,t)}async rm(e){return this.nextAdapter&&await this.nextAdapter.rm(e),this.adapter.rm(e)}}},3180:(e,t,n)=>{n.d(t,{C1:()=>A,GH:()=>S,NY:()=>b,XC:()=>v});var r=n(4641),i=n(5874),s=n(8878),a=n(8463),o=n(7738),l=n(6980),u=n(9651),c=n(1164),p=n(6554),d=n(1106),h=n(7490),f=n(1593),m=n(2469),g=n(7365),y=n(910);const v="noScreen",b=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function w(e){return e in a.O?a.O[e]:a.Kx[e].concat(a.a5[e])}function S(e,t){return a.Kx[e].includes(t)}async function x(e,t){const r=await async function(e,t){const{ChipProjects:r}=await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288));return S(e,t)?r[e].BUILTIN_CHIPS[t]:r[e].CHIPS[t][`${t}.hdl`]}(e,t);if(S(e,t))return r;const i="//// Replace this comment with your code.",s=`BUILTIN ${t};`;return r.includes(i)?r.replace(i,s):r.replace("PARTS:",`PARTS:\n ${s}`)}function k(e,t=!1,n=!1){return{clocked:e.clocked,inPins:(0,h.FX)(e.ins),outPins:(0,h.FX)(e.outs),internalPins:(0,h.FX)(e.pins),chip:[e],pending:t,invalid:n}}const _=c.z.get();function I(e,t,s,h){const f=function(e){const t=e["/chip/project"]??"01";return{project:t,chips:w(t),chipName:e["/chip/chip"]??a.a5[t][0]}}(s);let{project:y,chipName:b}=f;const{chips:I}=f;let A=new u.ti,C=[],E=new d.BX,O=!1,P=!1,L=!1;const R={setFiles(e,{hdl:t=e.files.hdl,tst:n=e.files.tst,cmp:r=e.files.cmp,out:i=""}){e.files.hdl=t,e.files.tst=n,e.files.cmp=r,e.files.out=i},updateChip(e,t){e.sim=k(A,t?.pending??e.sim.pending,t?.invalid??e.sim.invalid),e.controls.error=e.sim.invalid?t?.error??e.controls.error:void 0},setProject(e,t){const n=w(t),r=e.controls.chipName&&n.includes(e.controls.chipName)?e.controls.chipName:n[0];e.controls.project=t,e.controls.chips=n,this.setChip(e,r)},setChip(e,t){e.controls.chipName=t,e.controls.tests=Array.from(C),e.controls.hasBuiltin=l.Mo.has(t),e.controls.builtinOnly=S(e.controls.project,t)},setTest(e,t){e.controls.testName=t},setVisualizationParams(e,t){e.controls.visualizationParameters=new Set(t)},testRunning(e){e.controls.runningTest=!0},testFinished(e){e.controls.runningTest=!1;const n=(0,g.U)(e.files.cmp.trim(),e.files.out.trim());Promise.resolve().then((()=>{t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")}))},updateTestStep(e){if(e.files.out=E?.log()??"",E?.currentStep?.span)e.controls.span=E.currentStep.span;else if(E.done){const t=e.files.tst.length;e.controls.span={start:t-1,end:t,line:e.files.tst.split("\n").length}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})},updateConfig(e,t){e.config={...e.config,...t}}},N={setProject(e){y=s["/chip/project"]=e,h.current({action:"setProject",payload:y}),this.setChip(a.a5[y][0])},async setChip(e,t=s["/chip/project"]??"01"){b=s["/chip/chip"]=e,P=S(t,b),P?this.useBuiltin():(await this.loadChip(t,b),O&&this.useBuiltin()),await this.initializeTest(e),h.current({action:"setChip",payload:b})},setTest(e){h.current({action:"setTest",payload:e}),h.current({action:"setVisualizationParams",payload:new Set("ComputerAdd.tst"==e||"ComputerMax.tst"==e?[v]:[])}),this.loadTest(e)},reset(){c.z.get().reset(),A.reset(),E.reset(),h.current({action:"setFiles",payload:{}}),h.current({action:"updateChip"})},async updateFiles({hdl:e,tst:n,cmp:i}){L=!1,h.current({action:"setFiles",payload:{hdl:e,tst:n,cmp:i}});try{e&&await this.compileChip(e),n&&this.compileTest(n)}catch(s){t((0,r.V)(s))}h.current({action:"updateChip",payload:{invalid:L}}),L||t("HDL code: No syntax errors")},async compileChip(e){A.remove();const n=await(0,o.qg)(e,b);if((0,i.ys)(n)){const e=(0,i._)(n);return t((0,i._)(n).message),L=!0,void h.current({action:"updateChip",payload:{invalid:!0,error:e}})}this.replaceChip((0,i.Ok)(n))},replaceChip(e){const t=A.ins;for(const[n,{busVoltage:r}]of t){const t=e.ins.get(n);t&&(t.busVoltage=r)}_.reset(),e.eval(),A=e,A.reset(),E=E.with(A).reset(),h.current({action:"updateChip",payload:{invalid:!1}}),h.current({action:"updateTestStep"})},async loadChip(t,n){s["/chip/chip"]=n;const r=await e.readFile((i="hdl",`/projects/${t}/${n}/${n}.${i}`)).catch((()=>function(e){return`CHIP ${e} {\n IN in;\n OUT out;\n PARTS:\n}`}(n)));var i;h.current({action:"setFiles",payload:{hdl:r}}),await this.compileChip(r)},async initializeTest(t){C=(await e.scandir(`/projects/${y}/${t}`)).filter((e=>e.name.endsWith(".tst"))).map((e=>e.name)),C.length>0&&await this.setTest(C[0])},async loadTest(t){const[n,r]=await Promise.all([e.readFile(`/projects/${y}/${b}/${t}`).catch((()=>"repeat 10 {\n tick,\n tock;\n}")),e.readFile(`/projects/${y}/${b}/${t}`.replace(".tst",".cmp")).catch((()=>"| in|out|"))]);h.current({action:"setFiles",payload:{cmp:r,tst:n}}),this.compileTest(n)},async saveChip(n,r=y,i=b){h.current({action:"setFiles",payload:{hdl:n}});const s=`/projects/${r}/${i}/${i}.hdl`;await e.writeFile(s,n),t(`Saved ${s}`)},toggle(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<await Promise.all(a.a5[y].map((t=>({name:`${t}.hdl`,content:e.readFile(`/projects/${y}/${t}/${t}.hdl`)}))))};return{initialState:{controls:{project:y,chips:I,chipName:b,tests:C,testName:"",hasBuiltin:l.Mo.has(b),builtinOnly:S(y,b),runningTest:!1,error:void 0,visualizationParameters:new Set},files:{hdl:"",cmp:"",tst:"",out:""},sim:k(new u.ti),config:{speed:2}},reducers:R,actions:N}}function A(){const{fs:e,setStatus:t,storage:n}=(0,s.useContext)(y.L),r=(0,s.useRef)((()=>{})),{initialState:i,reducers:a,actions:o}=(0,s.useMemo)((()=>I(e,t,n,r)),[e,t,n,r]),[l,u]=(0,f.A)(a,i);return r.current=u,{state:l,dispatch:r,actions:o}}},4256:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(7076);class i extends r.qN{dispatch;constructor(e,t){super(e,e.size,0),this.dispatch=t}async load(e,t){await super.load(e,t),this.dispatch.current({action:"update"})}}},8849:(e,t,n)=>{n.d(t,{$:()=>w,vw:()=>x});var r=n(5874),i=n(8463),s=n(7076),a=n(6554),o=n(9563),l=n(3977);const u='Vm <: Base {\n Root := Vm\n\n Vm = newline* VmInstructionLine* VmInstruction?\n\n space := comment | " " | "\t"\n whitespace = lineComment | comment | space\n\n VmInstructionLine = VmInstruction newline+\n VmInstruction =\n | StackInstruction\n | OpInstruction\n | FunctionInstruction\n | CallInstruction\n | ReturnInstruction\n | GotoInstruction\n | LabelInstruction\n \n StackInstruction = (push | pop) MemorySegment Number\n OpInstruction = Add | Sub | Neg | Lt | Gt | Eq | And | Or | Not\n FunctionInstruction = function Name Number \n CallInstruction = call Name Number\n ReturnInstruction = return\n LabelInstruction = label Name\n GotoInstruction = (goto | ifGoto) Name\n\n MemorySegment = argument | local | static | constant | this | that | pointer | temp\n\n push = "push" whitespace+\n pop = "pop" whitespace+\n function = "function" whitespace+\n call = "call" whitespace+\n return = "return"\n goto = "goto" whitespace+\n ifGoto = "if-goto" whitespace+\n label = "label" whitespace+\n\n argument = "argument" whitespace+\n local = "local" whitespace+\n static = "static" whitespace+\n constant = "constant" whitespace+\n this = "this" whitespace+\n that = "that" whitespace+\n pointer = "pointer" whitespace+\n temp = "temp" whitespace+\n\n Add = "add" \n Sub = "sub" \n Neg = "neg" \n Eq = "eq"\n Lt = "lt" \n Gt = "gt" \n And = "and" \n Or = "or" \n Not = "not"\n}',c=(0,o.qN)(u,l.lN),p=c.extendSemantics(l.JE);p.addAttribute("op",{push:(e,t)=>"push",pop:(e,t)=>"pop",function:(e,t)=>"function",call:(e,t)=>"call",return:e=>"return",goto:(e,t)=>"goto",ifGoto:(e,t)=>"if-goto",label:(e,t)=>"label",Add:e=>"add",Sub:e=>"sub",Neg:e=>"neg",Eq:e=>"eq",Lt:e=>"lt",Gt:e=>"gt",And:e=>"and",Or:e=>"or",Not:e=>"not"}),p.addAttribute("segment",{argument:(e,t)=>"argument",local:(e,t)=>"local",static:(e,t)=>"static",constant:(e,t)=>"constant",this:(e,t)=>"this",that:(e,t)=>"that",pointer:(e,t)=>"pointer",temp:(e,t)=>"temp"}),p.addAttribute("instruction",{StackInstruction({op:e},{segment:t},n){return{op:e,segment:t,offset:Number(n.sourceString),span:(0,l.Ln)(this.source)}},OpInstruction({op:e}){return{op:e,span:(0,l.Ln)(this.source)}},FunctionInstruction(e,{name:t},n){return{op:"function",name:t,nVars:Number(n.sourceString),span:(0,l.Ln)(this.source)}},CallInstruction(e,{name:t},n){return{op:"call",name:t,nArgs:Number(n.sourceString),span:(0,l.Ln)(this.source)}},ReturnInstruction(e){return{op:"return",span:(0,l.Ln)(this.source)}},LabelInstruction(e,{name:t}){return{op:"label",label:t,span:(0,l.Ln)(this.source)}},GotoInstruction({op:e},{name:t}){return{op:e,label:t,span:(0,l.Ln)(this.source)}},VmInstructionLine:(e,t)=>e.instruction}),p.addAttribute("vm",{Vm(e,t,n){const r=t.children.map((e=>e.instruction))??[];return{instructions:n.child(0)?[...r,n.child(0).instruction]:r}}}),p.addAttribute("root",{Root:({vm:e})=>e});const d={grammar:u,semantics:p,parser:c,parse:(0,l.Q5)(c,p)};var h=n(8783),f=n(5087),m=n(8878),g=n(7365),y=n(1593),v=n(910),b=n(4256);const w="repeat {\n\tvmstep;\n}";function S(e,t,n,r){const i=new b.X(e.vm.RAM,t),a=new b.X(e.vm.Screen,t),o=new s.PC(new b.X(e.vm.RAM,t)),l=e.vm.derivedLine();let u=[];try{u=e.vm.vmStack().reverse()}catch(c){n("Runtime error: Invalid stack")}return{Keyboard:o,RAM:i,Screen:a,Stack:u,Prog:e.vm.program,Statics:[...e.vm.memory.map(((e,t)=>t),16,16+e.vm.getStaticCount())],Temp:[...e.vm.memory.map(((e,t)=>t),5,13)],AddedSysInit:e.vm.addedSysInit,highlight:l,showHighlight:r}}function x(){const{fs:e,setStatus:t,storage:n}=(0,m.useContext)(v.L),s=(0,m.useRef)((()=>{})),{initialState:o,reducers:l,actions:u}=(0,m.useMemo)((()=>function(e,t,n,s){const o=(0,r.oA)(d.parse(i.J5));let l=(0,r.oA)(f.Vm.build(o.instructions)),u=new h.Y(t).with(l),c=!1,p=!0,m="",y=!0;const v={setVm(e,t){e.files.vm=t},setTst(e,{tst:t,cmp:n}){e.files.tst=t,e.files.cmp=n??""},setExitCode(e,t){e.controls.exitCode=t},setValid(e,t){e.controls.valid=t},setShowHighlight(e,t){e.vm.showHighlight=t},setError(e,n){n?(e.controls.valid=!1,t(n?.message)):e.controls.valid=!0,e.controls.error=n},setPath(e,t){e.test.path=t},update(e){e.vm=S(u,s,t,y),e.test.highlight=u.currentStep?.span},setAnimate(e,t){e.controls.animate=t},testStep(e){e.files.out=u.log()},testFinished(e){const n=(0,g.U)(e.files.cmp.trim(),e.files.out);t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},setTitle(e,t){e.title=t},updateConfig(e,t){e.config={...e.config,...t}}},b={vm:S(u,s,t,!0),controls:{exitCode:void 0,runningTest:!1,animate:!0,valid:!0},test:{highlight:void 0,path:"/"},files:{vm:"",tst:w,cmp:"",out:""},config:{ram1Format:"dec",ram2Format:"dec",screenScale:1,speed:2,testSpeed:2}},x={setVm(e){if(y=!1,s.current({action:"setVm",payload:e}),m==e)return;m=e;const t=d.parse(e);if((0,r.ys)(t))return s.current({action:"setError",payload:(0,r._)(t)}),!1;const n=(0,r.oA)(t).instructions,i=f.Vm.build(n);return this.replaceVm(i)},loadVm(e){y=!1;for(const r of e)r.content.endsWith("\n")&&(r.content=r.content.slice(0,-1));const t=e.map((e=>e.content)).join("\n");if(s.current({action:"setVm",payload:t}),m==t)return;m=t;const n=[];let i=0;for(const o of e){const e=d.parse(o.content);if((0,r.ys)(e))return s.current({action:"setError",payload:(0,r._)(e)}),!1;const t=(0,r.oA)(e).instructions;for(const n of t)void 0!=n.span?.line&&(n.span.line+=i);i+=o.content.split("\n").length,n.push({name:o.name,instructions:t})}const a=f.Vm.buildFromFiles(n);return this.replaceVm(a)},replaceVm:e=>(0,r.ys)(e)?(s.current({action:"setError",payload:(0,r._)(e)}),!1):(s.current({action:"setError"}),t("Compiled VM code successfully"),l=(0,r.oA)(e),u.vm=l,s.current({action:"update"}),!0),loadTest(n,i,o){s.current({action:"setTst",payload:{tst:i,cmp:o}});const c=a.uG.parse(i);return(0,r.ys)(c)?(s.current({action:"setValid",payload:!1}),t("Failed to parse test"),!1):(s.current({action:"setValid",payload:!0}),t("Parsed tst"),l.reset(),u=h.Y.from((0,r.oA)(c),n,(e=>{this.loadVm(e)}),t).using(e),u.vm=l,s.current({action:"update"}),!0)},setAnimate(e){p=e,s.current({action:"setAnimate",payload:e})},async testStep(){y=!0;let e=!1;try{return e=await u.step(),s.current({action:"testStep"}),e&&s.current({action:"testFinished"}),p&&s.current({action:"update"}),e}catch(n){return t(`Runtime error: ${n.message}`),s.current({action:"setValid",payload:!1}),!0}},setPaused(e=!0){l.setPaused(e)},step(){y=!0;try{let e=!1;const t=l.step();return void 0!==t&&(e=!0,s.current({action:"setExitCode",payload:t})),p&&s.current({action:"update"}),e}catch(e){return t(`Runtime error: ${e.message}`),s.current({action:"setValid",payload:!1}),!0}},reset(){y=!0,u.reset(),l.reset(),s.current({action:"update"}),s.current({action:"setExitCode",payload:void 0}),s.current({action:"setValid",payload:!0})},toggleUseTest(){c=!c,s.current({action:"update"})},initialize(){s.current({action:"setTitle",payload:void 0}),this.setVm(i.J5)}};return{initialState:b,reducers:v,actions:x}}(e,t,0,s)),[e,t,n,s]),[c,p]=(0,y.A)(l,o);return s.current=p,{state:c,dispatch:s,actions:u}}},2469:(e,t,n)=>{n.d(t,{H8:()=>a,Z1:()=>s,vA:()=>i});class r extends Error{constructor(e="Assertion failed"){super(e)}}function i(e,t){if(!e)throw new r(t instanceof Function?t():t)}function s(e,t="Assertion failed: value does not exist"){return i(null!=e,t),e}function a(e,t=`Unexpected value ${e}`){throw new Error(t instanceof Function?t():t)}},4641:(e,t,n)=>{n.d(t,{V:()=>r});const r=e=>{if((e=>"function"===typeof e?.toString||"string"===typeof e)(e)){const t=e.toString();return"[object Object]"===t?JSON.stringify(e):t}return JSON.stringify(e)}},4544:(e,t,n)=>{n.d(t,{JU:()=>h,P8:()=>u,Q2:()=>p,cL:()=>f,d$:()=>a});const r={SEP:"\\",WD:"C:\\\\",isAbsolute:e=>Boolean(e.match(new RegExp("^[a-zA-Z]:\\\\")))},i={SEP:"/",WD:"/",isAbsolute:e=>"/"==e[0]},s="undefined"!==typeof process&&"win32"==process.platform?r:i,a=s.SEP,o=s.WD,l=s.isAbsolute;function u(e){e.endsWith(a)&&(e=e.substring(0,e.length-1));return e.split(a).at(-1)??""}function c(...e){const t=[];for(const n of e)for(const e of n.split(a))switch(e){case"":case".":break;case"..":t.pop();break;default:t.push(e)}return(s==i?a:"")+t.join(a)}class p{adapter;wd=o;stack=[];constructor(e=new d){this.adapter=e}cwd(){return this.wd}cd(e){this.wd=this.p(e)}pushd(e){this.stack.push(this.wd),this.cd(e)}popd(){this.stack.length>0&&(this.wd=this.stack.pop())}stat(e){return this.adapter.stat(this.p(e))}scandir(e){return this.adapter.scandir(this.p(e))}readdir(e){return this.adapter.readdir(this.p(e))}mkdir(e){return this.adapter.mkdir(this.p(e))}copyFile(e,t){return this.adapter.copyFile(this.p(e),this.p(t))}readFile(e){return this.adapter.readFile(this.p(e))}writeFile(e,t){return this.adapter.writeFile(this.p(e),t)}rm(e){return this.adapter.rm(this.p(e))}p(e){return l(e)?e:c(this.cwd(),e)}}class d{fs;constructor(e={}){this.fs=e}stat(e){return new Promise(((t,n)=>{if(this.fs[e])return t({name:u(e),isDirectory:()=>!1,isFile:()=>!0});e.endsWith(a)||(e+=a);for(let r of Object.keys(this.fs))if(r.startsWith(e))return t({name:u(e),isDirectory:()=>!0,isFile:()=>!1});n()}))}async scandir(e){return(await this.readdir(e)).map((t=>{let n=void 0!==this.fs[c(e,t)];return{name:t,isDirectory:()=>!n,isFile:()=>n}}))}readdir(e){return e.endsWith(a)||(e+=a),new Promise((t=>{let n=new Set;for(const r of Object.keys(this.fs))if(r.startsWith(e)){const t=r.indexOf(a,e.length+1),i=r.substring(e.length,-1===t?void 0:t);n.add(i)}return t([...n].sort())}))}mkdir(e){return Promise.resolve()}copyFile(e,t){return new Promise((n=>{this.fs[t]=this.fs[e],n()}))}readFile(e){return new Promise(((t,n)=>{let r=this.fs[e];if(void 0===r){n(new Error(`File Not Found ${e}`))}else t(r)}))}writeFile(e,t){return new Promise((n=>{this.fs[e]=t,n()}))}rm(e){return new Promise((t=>{delete this.fs[e],t()}))}}class h extends d{constructor(){super(window.localStorage)}}async function f(e,t){for(const[n,r]of Object.entries(t))"string"===typeof r?await e.writeFile(n,r):(e.cd(n),await f(e,r),e.cd(".."))}},742:(e,t,n)=>{function r(e,t,n=1){const r=[];for(let i=e;ir})},5874:(e,t,n)=>{n.d(t,{HQ:()=>i,Ok:()=>a,_:()=>o,oA:()=>l,ys:()=>s});const r=e=>null===e;const i=e=>Object.prototype.hasOwnProperty.call(e??{},"ok"),s=e=>Object.prototype.hasOwnProperty.call(e,"err");function a(e){return i(e)?e.ok:{ok:e,map(e){return e(a(this))}}}function o(e){return e.err??{err:e,map(e){return this}}}function l(e){if(r(e))throw new Error("Attempted to unwrap None");if(s(e))throw o(e);return i(e)?a(e):e}},8256:(e,t,n)=>{n.d(t,{Ru:()=>k});var r=n(2527);const i=e=>"string"===typeof e,s=new Map,a="en";function o(e){return[...Array.isArray(e)?e:[e],a]}function l(e,t,n){const r=o(e);return p((()=>d("date",r,n)),(()=>new Intl.DateTimeFormat(r,n))).format(i(t)?new Date(t):t)}function u(e,t,n){const r=o(e);return p((()=>d("number",r,n)),(()=>new Intl.NumberFormat(r,n))).format(t)}function c(e,t,n,{offset:r=0,...i}){const s=o(e),a=t?p((()=>d("plural-ordinal",s)),(()=>new Intl.PluralRules(s,{type:"ordinal"}))):p((()=>d("plural-cardinal",s)),(()=>new Intl.PluralRules(s,{type:"cardinal"})));return i[n]??i[a.select(n-r)]??i.other}function p(e,t){const n=e();let r=s.get(n);return r||(r=t(),s.set(n,r)),r}function d(e,t,n){return`${e}-${t.join("-")}-${JSON.stringify(n)}`}const h=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g,f="%__lingui_octothorpe__%",m=(e,t)=>t[e]??t.other;function g(e,t,n){return(s={},a)=>{const o=((e,t,n={})=>{const r=t||e,i=e=>"object"===typeof e?e:n[e]||{style:e},s=(e,t)=>{const s=Object.keys(n).length?i("number"):void 0,a=u(r,e,s);return t.replace(new RegExp(f,"g"),a)};return{plural:(e,t)=>{const{offset:n=0}=t,i=c(r,!1,e,t);return s(e-n,i)},selectordinal:(e,t)=>{const{offset:n=0}=t,i=c(r,!0,e,t);return s(e-n,i)},select:m,number:(e,t)=>u(r,e,i(t)),date:(e,t)=>l(r,e,i(t))}})(t,n,a),p=(e,t=!1)=>Array.isArray(e)?e.reduce(((e,n)=>{if("#"===n&&t)return e+f;if(i(n))return e+n;const[r,a,l]=n;let u,c={};if("plural"===a||"selectordinal"===a||"select"===a?Object.entries(l).forEach((([e,t])=>{c[e]=p(t,"plural"===a||"selectordinal"===a)})):c=l,a){u=(0,o[a])(s[r],c)}else u=s[r];return null==u?e:e+u}),""):e,d=p(e);return i(d)&&h.test(d)?(0,r.MH)(d.trim()):i(d)?d.trim():d?String(d):""}}var y=Object.defineProperty,v=(e,t,n)=>(((e,t,n)=>{t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class b{constructor(){v(this,"_events",{})}on(e,t){var n;return(n=this._events)[e]??(n[e]=[]),this._events[e].push(t),()=>this.removeListener(e,t)}removeListener(e,t){const n=this._getListeners(e);if(!n)return;const r=n.indexOf(t);~r&&n.splice(r,1)}emit(e,...t){const n=this._getListeners(e);n&&n.map((e=>e.apply(this,t)))}_getListeners(e){const t=this._events[e];return!!Array.isArray(t)&&t}}var w=Object.defineProperty,S=(e,t,n)=>(((e,t,n)=>{t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class x extends b{constructor(e){super(),S(this,"_locale",""),S(this,"_locales"),S(this,"_localeData",{}),S(this,"_messages",{}),S(this,"_missing"),S(this,"t",this._.bind(this)),null!=e.missing&&(this._missing=e.missing),null!=e.messages&&this.load(e.messages),null!=e.localeData&&this.loadLocaleData(e.localeData),("string"===typeof e.locale||e.locales)&&this.activate(e.locale??a,e.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){return this._messages[this._locale]??{}}get localeData(){return this._localeData[this._locale]??{}}_loadLocaleData(e,t){const n=this._localeData[e];n?Object.assign(n,t):this._localeData[e]=t}loadLocaleData(e,t){null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((t=>this._loadLocaleData(t,e[t]))),this.emit("change")}_load(e,t){const n=this._messages[e];n?Object.assign(n,t):this._messages[e]=t}load(e,t){"string"==typeof e&&"object"===typeof t?this._load(e,t):Object.entries(e).forEach((([e,t])=>this._load(e,t))),this.emit("change")}loadAndActivate({locale:e,locales:t,messages:n}){this._locale=e,this._locales=t||void 0,this._messages[this._locale]=n,this.emit("change")}activate(e,t){this._locale=e,this._locales=t,this.emit("change")}_(e,t,n){let r=n?.message;e||(e=""),i(e)||(t=e.values||t,r=e.message,e=e.id);const s=this.messages[e],a=void 0===s,o=this._missing;if(o&&a)return"function"===typeof o?o(this._locale,e):o;a&&this.emit("missing",{id:e,locale:this._locale});let l=s||r||e;return i(l)&&h.test(l)?JSON.parse(`"${l}"`):i(l)?l:g(l,this._locale,this._locales)(t,n?.formats)}date(e,t){return l(this._locales||this._locale,e,t)}number(e,t){return u(this._locales||this._locale,e,t)}}const k=function(e={}){return new x(e)}()},6458:(e,t,n)=>{n.d(t,{CY:()=>f,x6:()=>m});var r=n(8878);const i=/<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/,s=/(?:\r\n|\r|\n)/g,a={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0};function o(e,t={}){const n=u(0,"$lingui$"),c=e.replace(s,"").split(i);if(1===c.length)return e;const p=[],d=c.shift();d&&p.push(d);for(const[i,s,u]of l(c)){let e="undefined"!==typeof i?t[i]:void 0;(!e||a[e.type]&&s)&&(e?console.error(`${e.type} is a void element tag therefore it must have no children`):console.error(`Can't use element at index '${i}' as it is not declared in the original translation`),e=r.createElement(r.Fragment)),Array.isArray(e)&&(e=r.createElement(r.Fragment,{},e)),p.push(r.cloneElement(e,{key:n()},s?o(s,t):e.props.children)),u&&p.push(u)}return p}function l(e){if(!e.length)return[];const[t,n,r,i]=e.slice(0,4);return[[t||r,n||"",i]].concat(l(e.slice(4,e.length)))}const u=(e=0,t="")=>()=>`${t}_${e++}`;function c(e){const{render:t,component:n,id:i,message:s,formats:a,lingui:{i18n:l,defaultComponent:u}}=e,c={...e.values},d={...e.components};c&&Object.keys(c).forEach((e=>{const t=c[e];if(!(r.isValidElement(t)||Array.isArray(t)&&t.every(r.isValidElement)))return;const n=Object.keys(d).length;d[n]=t,c[e]=`<${n}/>`}));const h=l&&"function"===typeof l._?l._(i,c,{message:s,formats:a}):i,f=h?o(h,d):null;if(null===t||null===n)return f;const m=u||p,g={id:i,message:s,translation:f,isTranslated:i!==f&&s!==f,children:f};if(t&&n)console.error("You can't use both `component` and `render` prop at the same time. `component` is ignored.");else if(t&&"function"!==typeof t)console.error(`Invalid value supplied to prop \`render\`. It must be a function, provided ${t}`);else if(n&&"function"!==typeof n)return console.error(`Invalid value supplied to prop \`component\`. It must be a React component, provided ${n}`),r.createElement(m,g,f);if("function"===typeof t)return t(g);const y=n||m;return r.createElement(y,g,f)}const p=({children:e})=>r.createElement(r.Fragment,null,e),d=r.createContext(null),h=e=>r.useContext(d);const f=({i18n:e,defaultComponent:t,children:n})=>{const i=r.useRef(e.locale),s=r.useCallback((()=>({i18n:e,defaultComponent:t,_:e.t.bind(e)})),[e,t]),[a,o]=r.useState(s());return r.useEffect((()=>{const t=()=>{i.current=e.locale,o(s())},n=e.on("change",t);return i.current!==e.locale&&t(),n}),[e,s]),i.current?r.createElement(d.Provider,{value:a},n):null};function m(e){let t;const n=h(t);return r.createElement(c,{...e,lingui:n})}},9563:(e,t,n)=>{n.d(t,{qN:()=>at});var r={};n.r(r),n.d(r,{CV:()=>m,b0:()=>s,vA:()=>a,Ms:()=>p,xA:()=>o,$L:()=>c,pX:()=>h,lO:()=>d,Ho:()=>f,ux:()=>u,repeatStr:()=>l,qj:()=>y,rE:()=>v});const i={};for(let ot=0;ot<128;ot++)i[ot]=String.fromCharCode(ot);function s(e){const t=e||"";return function(){throw new Error("this method "+t+" is abstract! (it has no implementation in class "+this.constructor.name+")")}}function a(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t,n){let r;Object.defineProperty(e,t,{get(){return r||(r=n.call(this)),r}})}function l(e,t){return new Array(t+1).join(e)}function u(e,t){return function(e,t){const n=[];for(;t-- >0;)n.push(e());return n}((()=>e),t)}function c(e){const t=[];for(let n=0;n{t.indexOf(e)<0&&t.push(e)})),t}function d(e){const t=e[0];return t===t.toUpperCase()}function h(e){return!d(e)}function f(e,t,n){const r=n||" ";return e.lengthString.fromCodePoint(parseInt(e,16));function y(e){if("\\"!==e.charAt(0))return e;switch(e.charAt(1)){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"x":return g(e.slice(2,4));case"u":return"{"===e.charAt(2)?g(e.slice(3,-1)):g(e.slice(2,6));default:return e.charAt(1)}}function v(e){if(null==e)return String(e);const t=Object.prototype.toString.call(e);try{let n;return n=e.constructor&&e.constructor.name?e.constructor.name:0===t.indexOf("[object ")?t.slice(8,-1):typeof e,n+": "+JSON.stringify(String(e))}catch(n){return t}}const b={Lu:/\p{Lu}/u,Ll:/\p{Ll}/u,Lt:/\p{Lt}/u,Lm:/\p{Lm}/u,Lo:/\p{Lo}/u,Nl:/\p{Nl}/u,Nd:/\p{Nd}/u,Mn:/\p{Mn}/u,Mc:/\p{Mc}/u,Pc:/\p{Pc}/u,Zs:/\p{Zs}/u,L:/\p{Letter}/u,Ltmo:/\p{Lt}|\p{Lm}|\p{Lo}/u};class w{constructor(){if(this.constructor===w)throw new Error("PExpr cannot be instantiated -- it's abstract")}withSource(e){return e&&(this.source=e.trimmed()),this}}const S=Object.create(w.prototype),x=Object.create(w.prototype);class k extends w{constructor(e){super(),this.obj=e}}class _ extends w{constructor(e,t){super(),this.from=e,this.to=t,this.matchCodePoint=e.length>1||t.length>1}}class I extends w{constructor(e){super(),this.index=e}}class A extends w{constructor(e){super(),this.terms=e}}class C extends A{constructor(e,t,n){super([n,e.rules[t].body]),this.superGrammar=e,this.name=t,this.body=n}}class E extends A{constructor(e,t,n,r){const i=e.rules[t].body;super([...n,i,...r]),this.superGrammar=e,this.ruleName=t,this.expansionPos=n.length}}class O extends w{constructor(e){super(),this.factors=e}}class P extends w{constructor(e){super(),this.expr=e}}class L extends P{}class R extends P{}class N extends P{}L.prototype.operator="*",R.prototype.operator="+",N.prototype.operator="?",L.prototype.minNumMatches=0,R.prototype.minNumMatches=1,N.prototype.minNumMatches=0,L.prototype.maxNumMatches=Number.POSITIVE_INFINITY,R.prototype.maxNumMatches=Number.POSITIVE_INFINITY,N.prototype.maxNumMatches=1;class T extends w{constructor(e){super(),this.expr=e}}class M extends w{constructor(e){super(),this.expr=e}}class F extends w{constructor(e){super(),this.expr=e}}class j extends w{constructor(e,t=[]){super(),this.ruleName=e,this.args=t}isSyntactic(){return d(this.ruleName)}toMemoKey(){return this._memoKey||Object.defineProperty(this,"_memoKey",{value:this.toString()}),this._memoKey}}class D extends w{constructor(e){super(),this.category=e,this.pattern=b[e]}}function $(e,t){let n;return t?(n=new Error(t.getLineAndColumnMessage()+e),n.shortMessage=e,n.interval=t):n=new Error(e),n}function z(){return $("Interval sources don't match")}function V(e,t,n){return $("Rule "+e+" is not declared in grammar "+t,n)}function U(e,t,n,r){let i="Duplicate declaration for rule '"+e+"' in grammar '"+t+"'";return t!==n&&(i+=" (originally declared in '"+n+"')"),$(i,r)}function B(e,t,n,r){return $("Wrong number of parameters for rule "+e+" (expected "+t+", got "+n+")",r)}function W(e,t,n){return $("Duplicate parameter names in rule "+e+": "+t.join(", "),n)}function H(e,t){return $("Incorrect argument type: expected "+e,t.source)}function G(e,t){const n=t.length>0?t[t.length-1].args:[];let r="Nullable expression "+e.expr.substituteParams(n)+" is not allowed inside '"+e.operator+"' (possible infinite loop)";if(t.length>0){r+="\nApplication stack (most recent application last):\n"+t.map((e=>new j(e.ruleName,e.args))).join("\n")}return $(r,e.expr.source)}function q(e,t,n,r){return $("Rule "+e+" involves an alternation which has inconsistent arity (expected "+t+", got "+n+")",r.source)}function K(e){if(1===e.length)throw e[0];if(e.length>1)throw function(e){const t=e.map((e=>e.message));return $(["Errors:"].concat(t).join("\n- "),e[0].interval)}(e)}function Q(e,t,n){const r=e.length;return(e.slice(0,n)+t+e.slice(n+t.length)).substr(0,r)}function Y(...e){const t=this,{offset:n}=t,{repeatStr:i}=r,s=new m;s.append("Line "+t.lineNum+", col "+t.colNum+":\n");const o=function(e){let t=0;return e.map((e=>{const n=e.toString();return t=Math.max(t,n.length),n})).map((e=>f(e,t)))}([null==t.prevLine?0:t.lineNum-1,t.lineNum,null==t.nextLine?0:t.lineNum+1]),l=(e,t,n)=>{s.append(n+o[e]+" | "+t+"\n")};null!=t.prevLine&&l(0,t.prevLine," "),l(1,t.line,"> ");const u=t.line.length;let c=i(" ",u+1);for(let r=0;r=0&&s<=o,"range start must be >= 0 and <= end");const l=n-t.colNum+1;s=Math.max(0,s-l),o=Math.min(o-l,u),c=Q(c,i("~",o-s),s)}const p=2+o[1].length+3;return s.append(i(" ",p)),c=Q(c,"^",t.colNum-1),s.append(c.replace(/ +$/,"")+"\n"),null!=t.nextLine&&l(2,t.nextLine," "),s.contents()}let X=[];function J(e){X.push(e)}function Z(e,t){let n=1,r=1,i=0,s=0,a=null,o=null,l=-1;for(;i=0&&(o=e.slice(l,s).replace(/\r?\n$/,""));return{offset:t,lineNum:n,colNum:r,line:e.slice(s,u).replace(/\r$/,""),prevLine:o,nextLine:a,toString:Y}}function ee(e,t,...n){return Z(e,t).toString(...n)}const te=(()=>{let e=0;return t=>""+t+e++})();class ne{constructor(e,t,n){this.sourceString=e,this.startIdx=t,this.endIdx=n}get contents(){return void 0===this._contents&&(this._contents=this.sourceString.slice(this.startIdx,this.endIdx)),this._contents}get length(){return this.endIdx-this.startIdx}coverageWith(...e){return ne.coverage(...e,this)}collapsedLeft(){return new ne(this.sourceString,this.startIdx,this.startIdx)}collapsedRight(){return new ne(this.sourceString,this.endIdx,this.endIdx)}getLineAndColumn(){return Z(this.sourceString,this.startIdx)}getLineAndColumnMessage(){const e=[this.startIdx,this.endIdx];return ee(this.sourceString,this.startIdx,e)}minus(e){if(this.sourceString!==e.sourceString)throw z();return this.startIdx===e.startIdx&&this.endIdx===e.endIdx?[]:this.startIdx=e.startIdx&&this.endIdx<=e.endIdx,"other interval does not cover this one"),new ne(this.sourceString,this.startIdx-e.startIdx,this.endIdx-e.startIdx)}trimmed(){const{contents:e}=this,t=this.startIdx+e.match(/^\s*/)[0].length,n=this.endIdx-e.match(/\s*$/)[0].length;return new ne(this.sourceString,t,n)}subInterval(e,t){const n=this.startIdx+e;return new ne(this.sourceString,n,n+t)}}ne.coverage=function(e,...t){let{startIdx:n,endIdx:r}=e;for(const i of t){if(i.sourceString!==e.sourceString)throw z();n=Math.min(n,i.startIdx),r=Math.max(r,i.endIdx)}return new ne(e.sourceString,n,r)};class re{constructor(e){this.source=e,this.pos=0,this.examinedLength=0}atEnd(){const e=this.pos>=this.source.length;return this.examinedLength=Math.max(this.examinedLength,this.pos+1),e}next(){const e=this.source[this.pos++];return this.examinedLength=Math.max(this.examinedLength,this.pos),e}nextCharCode(){const e=this.next();return e&&e.charCodeAt(0)}nextCodePoint(){const e=this.source.slice(this.pos++).codePointAt(0);return e>65535&&(this.pos+=1),this.examinedLength=Math.max(this.examinedLength,this.pos),e}matchString(e,t){let n;if(t){for(n=0;n!e.isFluffy()));for(let n=0;n0&&(n===t.length-1?e.append(t.length>2?", or ":" or "):e.append(", ")),e.append(t[n].toString());return e.contents()}getInterval(){const e=this.getRightmostFailurePosition();return new ne(this.input,e,e)}}class se{constructor(){this.applicationMemoKeyStack=[],this.memo={},this.maxExaminedLength=0,this.maxRightmostFailureOffset=-1,this.currentLeftRecursion=void 0}isActive(e){return this.applicationMemoKeyStack.indexOf(e.toMemoKey())>=0}enter(e){this.applicationMemoKeyStack.push(e.toMemoKey())}exit(){this.applicationMemoKeyStack.pop()}startLeftRecursion(e,t){t.isLeftRecursion=!0,t.headApplication=e,t.nextLeftRecursion=this.currentLeftRecursion,this.currentLeftRecursion=t;const{applicationMemoKeyStack:n}=this,r=n.indexOf(e.toMemoKey())+1,i=n.slice(r);t.isInvolved=function(e){return i.indexOf(e)>=0},t.updateInvolvedApplicationMemoKeys=function(){for(let e=r;e{const i=n[r];e+i.examinedLength>t?delete n[r]:(this.maxExaminedLength=Math.max(this.maxExaminedLength,i.examinedLength),this.maxRightmostFailureOffset=Math.max(this.maxRightmostFailureOffset,i.rightmostFailureOffset))}))}}const ae="\u22c5",oe="\u2409",le="\u240a",ue="\u240d",ce={succeeded:1,isRootNode:2,isImplicitSpaces:4,isMemoized:8,isHeadOfLeftRecursion:16,terminatesLR:32};function pe(e){return"string"===typeof e?e.replace(/ /g,ae).replace(/\t/g,oe).replace(/\n/g,le).replace(/\r/g,ue):String(e)}class de{constructor(e,t,n,r,i,s,a){this.input=e,this.pos=this.pos1=t,this.pos2=n,this.source=new ne(e,t,n),this.expr=r,this.bindings=s,this.children=a||[],this.terminatingLREntry=null,this._flags=i?ce.succeeded:0}get displayString(){return this.expr.toDisplayString()}clone(){return this.cloneWithExpr(this.expr)}cloneWithExpr(e){const t=new de(this.input,this.pos,this.pos2,e,this.succeeded,this.bindings,this.children);return t.isHeadOfLeftRecursion=this.isHeadOfLeftRecursion,t.isImplicitSpaces=this.isImplicitSpaces,t.isMemoized=this.isMemoized,t.isRootNode=this.isRootNode,t.terminatesLR=this.terminatesLR,t.terminatingLREntry=this.terminatingLREntry,t}recordLRTermination(e,t){this.terminatingLREntry=new de(this.input,this.pos,this.pos2,this.expr,!1,[t],[e]),this.terminatingLREntry.terminatesLR=!0}walk(e,t){let n=e;function r(e,i,s){let a=!0;n.enter&&n.enter.call(t,e,i,s)===de.prototype.SKIP&&(a=!1),a&&(e.children.forEach((t=>{r(t,e,s+1)})),n.exit&&n.exit.call(t,e,i,s))}"function"===typeof n&&(n={enter:n}),this.isRootNode?this.children.forEach((e=>{r(e,null,0)})):r(this,null,0)}toString(){const e=new m;return this.walk(((t,n,r)=>{if(!t)return this.SKIP;if("Alt"!==t.expr.constructor.name){if(e.append(function(e,t,n){const r=pe(e.slice(t,t+n));return r.length{const t=ce[e];Object.defineProperty(de.prototype,e,{get(){return 0!==(this._flags&t)},set(e){e?this._flags|=t:this._flags&=~t}})})),w.prototype.allowsSkippingPrecedingSpace=s("allowsSkippingPrecedingSpace"),S.allowsSkippingPrecedingSpace=x.allowsSkippingPrecedingSpace=j.prototype.allowsSkippingPrecedingSpace=k.prototype.allowsSkippingPrecedingSpace=_.prototype.allowsSkippingPrecedingSpace=D.prototype.allowsSkippingPrecedingSpace=function(){return!0},A.prototype.allowsSkippingPrecedingSpace=P.prototype.allowsSkippingPrecedingSpace=F.prototype.allowsSkippingPrecedingSpace=M.prototype.allowsSkippingPrecedingSpace=T.prototype.allowsSkippingPrecedingSpace=I.prototype.allowsSkippingPrecedingSpace=O.prototype.allowsSkippingPrecedingSpace=function(){return!1},J((e=>{he=e})),w.prototype.assertAllApplicationsAreValid=function(e,t){fe=0,this._assertAllApplicationsAreValid(e,t)},w.prototype._assertAllApplicationsAreValid=s("_assertAllApplicationsAreValid"),S._assertAllApplicationsAreValid=x._assertAllApplicationsAreValid=k.prototype._assertAllApplicationsAreValid=_.prototype._assertAllApplicationsAreValid=I.prototype._assertAllApplicationsAreValid=D.prototype._assertAllApplicationsAreValid=function(e,t){},F.prototype._assertAllApplicationsAreValid=function(e,t){fe++,this.expr._assertAllApplicationsAreValid(e,t),fe--},A.prototype._assertAllApplicationsAreValid=function(e,t){for(let n=0;n{if(n._assertAllApplicationsAreValid(e,t,o),1!==n.getArity())throw function(e,t){return $("Invalid parameter to rule "+e+": "+t+" has arity "+t.getArity()+", but parameter expressions must have arity 1",t.source)}(this.ruleName,n)}))},w.prototype.assertChoicesHaveUniformArity=s("assertChoicesHaveUniformArity"),S.assertChoicesHaveUniformArity=x.assertChoicesHaveUniformArity=k.prototype.assertChoicesHaveUniformArity=_.prototype.assertChoicesHaveUniformArity=I.prototype.assertChoicesHaveUniformArity=F.prototype.assertChoicesHaveUniformArity=D.prototype.assertChoicesHaveUniformArity=function(e){},A.prototype.assertChoicesHaveUniformArity=function(e){if(0===this.terms.length)return;const t=this.terms[0].getArity();for(let n=0;n{t.assertIteratedExprsAreNotNullable(e)}))};class ge{constructor(e){this.matchLength=e}get ctorName(){throw new Error("subclass responsibility")}numChildren(){return this.children?this.children.length:0}childAt(e){if(this.children)return this.children[e]}indexOfChild(e){return this.children.indexOf(e)}hasChildren(){return this.numChildren()>0}hasNoChildren(){return!this.hasChildren()}onlyChild(){if(1!==this.numChildren())throw new Error("cannot get only child of a node of type "+this.ctorName+" (it has "+this.numChildren()+" children)");return this.firstChild()}firstChild(){if(this.hasNoChildren())throw new Error("cannot get first child of a "+this.ctorName+" node, which has no children");return this.childAt(0)}lastChild(){if(this.hasNoChildren())throw new Error("cannot get last child of a "+this.ctorName+" node, which has no children");return this.childAt(this.numChildren()-1)}childBefore(e){const t=this.indexOfChild(e);if(t<0)throw new Error("Node.childBefore() called w/ an argument that is not a child");if(0===t)throw new Error("cannot get child before first child");return this.childAt(t-1)}childAfter(e){const t=this.indexOfChild(e);if(t<0)throw new Error("Node.childAfter() called w/ an argument that is not a child");if(t===this.numChildren()-1)throw new Error("cannot get child after last child");return this.childAt(t+1)}isTerminal(){return!1}isNonterminal(){return!1}isIteration(){return!1}isOptional(){return!1}}class ye extends ge{get ctorName(){return"_terminal"}isTerminal(){return!0}get primitiveValue(){throw new Error("The `primitiveValue` property was removed in Ohm v17.")}}class ve extends ge{constructor(e,t,n,r){super(r),this.ruleName=e,this.children=t,this.childOffsets=n}get ctorName(){return this.ruleName}isNonterminal(){return!0}isLexical(){return h(this.ctorName)}isSyntactic(){return d(this.ctorName)}}class be extends ge{constructor(e,t,n,r){super(n),this.children=e,this.childOffsets=t,this.optional=r}get ctorName(){return"_iter"}isIteration(){return!0}isOptional(){return this.optional}}function we(e,t){const n={};if(e.source&&t){const r=e.source.relativeTo(t);n.sourceInterval=[r.startIdx,r.endIdx]}return n}function Se(e){return/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(e)}function xe(e){const t=Object.create(null);e.forEach((e=>{t[e]=(t[e]||0)+1})),Object.keys(t).forEach((n=>{if(t[n]<=1)return;let r=1;e.forEach(((t,i)=>{t===n&&(e[i]=t+"_"+r++)}))}))}w.prototype.eval=s("eval"),S.eval=function(e){const{inputStream:t}=e,n=t.pos,r=t.nextCodePoint();return void 0!==r?(e.pushBinding(new ye(String.fromCodePoint(r).length),n),!0):(e.processFailure(n,this),!1)},x.eval=function(e){const{inputStream:t}=e,n=t.pos;return t.atEnd()?(e.pushBinding(new ye(0),n),!0):(e.processFailure(n,this),!1)},k.prototype.eval=function(e){const{inputStream:t}=e,n=t.pos;return t.matchString(this.obj)?(e.pushBinding(new ye(this.obj.length),n),!0):(e.processFailure(n,this),!1)},_.prototype.eval=function(e){const{inputStream:t}=e,n=t.pos,r=this.matchCodePoint?t.nextCodePoint():t.nextCharCode();return void 0!==r&&this.from.codePointAt(0)<=r&&r<=this.to.codePointAt(0)?(e.pushBinding(new ye(String.fromCodePoint(r).length),n),!0):(e.processFailure(n,this),!1)},I.prototype.eval=function(e){return e.eval(e.currentApplication().args[this.index])},F.prototype.eval=function(e){e.enterLexifiedContext();const t=e.eval(this.expr);return e.exitLexifiedContext(),t},A.prototype.eval=function(e){for(let t=0;t0){const e=i[r-1],t=s[r-1],n=t[t.length-1]+e[e.length-1].matchLength;u=s[0][0],c=n-u}const p=this instanceof N;for(a=0;an.outputRecipe(e,t))))},C.prototype.outputRecipe=function(e,t){return this.terms[0].outputRecipe(e,t)},E.prototype.outputRecipe=function(e,t){const n=this.terms.slice(0,this.expansionPos),r=this.terms.slice(this.expansionPos+1);return["splice",we(this,t),n.map((n=>n.outputRecipe(e,t))),r.map((n=>n.outputRecipe(e,t)))]},O.prototype.outputRecipe=function(e,t){return["seq",we(this,t)].concat(this.factors.map((n=>n.outputRecipe(e,t))))},L.prototype.outputRecipe=R.prototype.outputRecipe=N.prototype.outputRecipe=T.prototype.outputRecipe=M.prototype.outputRecipe=F.prototype.outputRecipe=function(e,t){return[this.constructor.name.toLowerCase(),we(this,t),this.expr.outputRecipe(e,t)]},j.prototype.outputRecipe=function(e,t){return["app",we(this,t),this.ruleName,this.args.map((n=>n.outputRecipe(e,t)))]},D.prototype.outputRecipe=function(e,t){return["unicodeChar",we(this,t),this.category]},w.prototype.introduceParams=s("introduceParams"),S.introduceParams=x.introduceParams=k.prototype.introduceParams=_.prototype.introduceParams=I.prototype.introduceParams=D.prototype.introduceParams=function(e){return this},A.prototype.introduceParams=function(e){return this.terms.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},O.prototype.introduceParams=function(e){return this.factors.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},P.prototype.introduceParams=T.prototype.introduceParams=M.prototype.introduceParams=F.prototype.introduceParams=function(e){return this.expr=this.expr.introduceParams(e),this},j.prototype.introduceParams=function(e){const t=e.indexOf(this.ruleName);if(t>=0){if(this.args.length>0)throw new Error("Parameterized rules cannot be passed as arguments to another rule.");return new I(t).withSource(this.source)}return this.args.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},w.prototype.isNullable=function(e){return this._isNullable(e,Object.create(null))},w.prototype._isNullable=s("_isNullable"),S._isNullable=_.prototype._isNullable=I.prototype._isNullable=R.prototype._isNullable=D.prototype._isNullable=function(e,t){return!1},x._isNullable=function(e,t){return!0},k.prototype._isNullable=function(e,t){return"string"===typeof this.obj&&""===this.obj},A.prototype._isNullable=function(e,t){return 0===this.terms.length||this.terms.some((n=>n._isNullable(e,t)))},O.prototype._isNullable=function(e,t){return this.factors.every((n=>n._isNullable(e,t)))},L.prototype._isNullable=N.prototype._isNullable=T.prototype._isNullable=M.prototype._isNullable=function(e,t){return!0},F.prototype._isNullable=function(e,t){return this.expr._isNullable(e,t)},j.prototype._isNullable=function(e,t){const n=this.toMemoKey();if(!Object.prototype.hasOwnProperty.call(t,n)){const{body:r}=e.rules[this.ruleName],i=r.substituteParams(this.args);t[n]=!1,t[n]=i._isNullable(e,t)}return t[n]},w.prototype.substituteParams=s("substituteParams"),S.substituteParams=x.substituteParams=k.prototype.substituteParams=_.prototype.substituteParams=D.prototype.substituteParams=function(e){return this},I.prototype.substituteParams=function(e){return e[this.index]},A.prototype.substituteParams=function(e){return new A(this.terms.map((t=>t.substituteParams(e))))},O.prototype.substituteParams=function(e){return new O(this.factors.map((t=>t.substituteParams(e))))},P.prototype.substituteParams=T.prototype.substituteParams=M.prototype.substituteParams=F.prototype.substituteParams=function(e){return new this.constructor(this.expr.substituteParams(e))},j.prototype.substituteParams=function(e){if(0===this.args.length)return this;{const t=this.args.map((t=>t.substituteParams(e)));return new j(this.ruleName,t)}},w.prototype.toArgumentNameList=s("toArgumentNameList"),S.toArgumentNameList=function(e,t){return["any"]},x.toArgumentNameList=function(e,t){return["end"]},k.prototype.toArgumentNameList=function(e,t){return"string"===typeof this.obj&&/^[_a-zA-Z0-9]+$/.test(this.obj)?["_"+this.obj]:["$"+e]},_.prototype.toArgumentNameList=function(e,t){let n=this.from+"_to_"+this.to;return Se(n)||(n="_"+n),Se(n)||(n="$"+e),[n]},A.prototype.toArgumentNameList=function(e,t){const n=this.terms.map((t=>t.toArgumentNameList(e,!0))),r=[],i=n[0].length;for(let s=0;s{const r=t.toArgumentNameList(e,!0);n=n.concat(r),e+=r.length})),t||xe(n),n},P.prototype.toArgumentNameList=function(e,t){const n=this.expr.toArgumentNameList(e,t).map((e=>"s"===e[e.length-1]?e+"es":e+"s"));return t||xe(n),n},N.prototype.toArgumentNameList=function(e,t){return this.expr.toArgumentNameList(e,t).map((e=>"opt"+e[0].toUpperCase()+e.slice(1)))},T.prototype.toArgumentNameList=function(e,t){return[]},M.prototype.toArgumentNameList=F.prototype.toArgumentNameList=function(e,t){return this.expr.toArgumentNameList(e,t)},j.prototype.toArgumentNameList=function(e,t){return[this.ruleName]},D.prototype.toArgumentNameList=function(e,t){return["$"+e]},I.prototype.toArgumentNameList=function(e,t){return["param"+this.index]},w.prototype.toDisplayString=s("toDisplayString"),A.prototype.toDisplayString=O.prototype.toDisplayString=function(){return this.source?this.source.trimmed().contents:"["+this.constructor.name+"]"},S.toDisplayString=x.toDisplayString=P.prototype.toDisplayString=T.prototype.toDisplayString=M.prototype.toDisplayString=F.prototype.toDisplayString=k.prototype.toDisplayString=_.prototype.toDisplayString=I.prototype.toDisplayString=function(){return this.toString()},j.prototype.toDisplayString=function(){if(this.args.length>0){const e=this.args.map((e=>e.toDisplayString()));return this.ruleName+"<"+e.join(",")+">"}return this.ruleName},D.prototype.toDisplayString=function(){return"Unicode ["+this.category+"] character"};class ke{constructor(e,t,n){if(!function(e){return"description"===e||"string"===e||"code"===e}(n))throw new Error("invalid Failure type: "+n);this.pexpr=e,this.text=t,this.type=n,this.fluffy=!1}getPExpr(){return this.pexpr}getText(){return this.text}getType(){return this.type}isDescription(){return"description"===this.type}isStringTerminal(){return"string"===this.type}isCode(){return"code"===this.type}isFluffy(){return this.fluffy}makeFluffy(){this.fluffy=!0}clearFluffy(){this.fluffy=!1}subsumes(e){return this.getText()===e.getText()&&this.type===e.type&&(!this.isFluffy()||this.isFluffy()&&e.isFluffy())}toString(){return"string"===this.type?JSON.stringify(this.getText()):this.getText()}clone(){const e=new ke(this.pexpr,this.text,this.type);return this.isFluffy()&&e.makeFluffy(),e}toKey(){return this.toString()+"#"+this.type}}w.prototype.toFailure=s("toFailure"),S.toFailure=function(e){return new ke(this,"any object","description")},x.toFailure=function(e){return new ke(this,"end of input","description")},k.prototype.toFailure=function(e){return new ke(this,this.obj,"string")},_.prototype.toFailure=function(e){return new ke(this,JSON.stringify(this.from)+".."+JSON.stringify(this.to),"code")},T.prototype.toFailure=function(e){const t=this.expr===S?"nothing":"not "+this.expr.toFailure(e);return new ke(this,t,"description")},M.prototype.toFailure=function(e){return this.expr.toFailure(e)},j.prototype.toFailure=function(e){let{description:t}=e.rules[this.ruleName];if(!t){t=(/^[aeiouAEIOU]/.test(this.ruleName)?"an":"a")+" "+this.ruleName}return new ke(this,t,"description")},D.prototype.toFailure=function(e){return new ke(this,"a Unicode ["+this.category+"] character","description")},A.prototype.toFailure=function(e){const t="("+this.terms.map((t=>t.toFailure(e))).join(" or ")+")";return new ke(this,t,"description")},O.prototype.toFailure=function(e){const t="("+this.factors.map((t=>t.toFailure(e))).join(" ")+")";return new ke(this,t,"description")},P.prototype.toFailure=function(e){const t="("+this.expr.toFailure(e)+this.operator+")";return new ke(this,t,"description")},w.prototype.toString=s("toString"),S.toString=function(){return"any"},x.toString=function(){return"end"},k.prototype.toString=function(){return JSON.stringify(this.obj)},_.prototype.toString=function(){return JSON.stringify(this.from)+".."+JSON.stringify(this.to)},I.prototype.toString=function(){return"$"+this.index},F.prototype.toString=function(){return"#("+this.expr.toString()+")"},A.prototype.toString=function(){return 1===this.terms.length?this.terms[0].toString():"("+this.terms.map((e=>e.toString())).join(" | ")+")"},O.prototype.toString=function(){return 1===this.factors.length?this.factors[0].toString():"("+this.factors.map((e=>e.toString())).join(" ")+")"},P.prototype.toString=function(){return this.expr+this.operator},T.prototype.toString=function(){return"~"+this.expr},M.prototype.toString=function(){return"&"+this.expr},j.prototype.toString=function(){if(this.args.length>0){const e=this.args.map((e=>e.toString()));return this.ruleName+"<"+e.join(",")+">"}return this.ruleName},D.prototype.toString=function(){return"\\p{"+this.category+"}"};class _e extends w{constructor(e){super(),this.obj=e}_getString(e){const t=e.currentApplication().args[this.obj.index];return a(t instanceof k,"expected a Terminal expression"),t.obj}allowsSkippingPrecedingSpace(){return!0}eval(e){const{inputStream:t}=e,n=t.pos,r=this._getString(e);return t.matchString(r,!0)?(e.pushBinding(new ye(r.length),n),!0):(e.processFailure(n,this),!1)}getArity(){return 1}substituteParams(e){return new _e(this.obj.substituteParams(e))}toDisplayString(){return this.obj.toDisplayString()+" (case-insensitive)"}toFailure(e){return new ke(this,this.obj.toFailure(e)+" (case-insensitive)","description")}_isNullable(e,t){return this.obj._isNullable(e,t)}}J((e=>{me=e.rules.applySyntactic.body}));const Ie=new j("spaces");class Ae{constructor(e,t,n){this.matcher=e,this.startExpr=t,this.grammar=e.grammar,this.input=e.getInput(),this.inputStream=new re(this.input),this.memoTable=e._memoTable,this.userData=void 0,this.doNotMemoize=!1,this._bindings=[],this._bindingOffsets=[],this._applicationStack=[],this._posStack=[0],this.inLexifiedContextStack=[!1],this.rightmostFailurePosition=-1,this._rightmostFailurePositionStack=[],this._recordedFailuresStack=[],void 0!==n&&(this.positionToRecordFailures=n,this.recordedFailures=Object.create(null))}posToOffset(e){return e-this._posStack[this._posStack.length-1]}enterApplication(e,t){this._posStack.push(this.inputStream.pos),this._applicationStack.push(t),this.inLexifiedContextStack.push(!1),e.enter(t),this._rightmostFailurePositionStack.push(this.rightmostFailurePosition),this.rightmostFailurePosition=-1}exitApplication(e,t){const n=this._posStack.pop();this._applicationStack.pop(),this.inLexifiedContextStack.pop(),e.exit(),this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,this._rightmostFailurePositionStack.pop()),t&&this.pushBinding(t,n)}enterLexifiedContext(){this.inLexifiedContextStack.push(!0)}exitLexifiedContext(){this.inLexifiedContextStack.pop()}currentApplication(){return this._applicationStack[this._applicationStack.length-1]}inSyntacticContext(){const e=this.currentApplication();return e?e.isSyntactic()&&!this.inLexifiedContext():this.startExpr.factors[0].isSyntactic()}inLexifiedContext(){return this.inLexifiedContextStack[this.inLexifiedContextStack.length-1]}skipSpaces(){return this.pushFailuresInfo(),this.eval(Ie),this.popBinding(),this.popFailuresInfo(),this.inputStream.pos}skipSpacesIfInSyntacticContext(){return this.inSyntacticContext()?this.skipSpaces():this.inputStream.pos}maybeSkipSpacesBefore(e){return e.allowsSkippingPrecedingSpace()&&e!==Ie?this.skipSpacesIfInSyntacticContext():this.inputStream.pos}pushBinding(e,t){this._bindings.push(e),this._bindingOffsets.push(this.posToOffset(t))}popBinding(){this._bindings.pop(),this._bindingOffsets.pop()}numBindings(){return this._bindings.length}truncateBindings(e){for(;this._bindings.length>e;)this.popBinding()}getCurrentPosInfo(){return this.getPosInfo(this.inputStream.pos)}getPosInfo(e){let t=this.memoTable[e];return t||(t=this.memoTable[e]=new se),t}processFailure(e,t){if(this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,e),this.recordedFailures&&e===this.positionToRecordFailures){const e=this.currentApplication();e&&(t=t.substituteParams(e.args)),this.recordFailure(t.toFailure(this.grammar),!1)}}recordFailure(e,t){const n=e.toKey();this.recordedFailures[n]?this.recordedFailures[n].isFluffy()&&!e.isFluffy()&&this.recordedFailures[n].clearFluffy():this.recordedFailures[n]=t?e.clone():e}recordFailures(e,t){Object.keys(e).forEach((n=>{this.recordFailure(e[n],t)}))}cloneRecordedFailures(){if(!this.recordedFailures)return;const e=Object.create(null);return Object.keys(this.recordedFailures).forEach((t=>{e[t]=this.recordedFailures[t].clone()})),e}getRightmostFailurePosition(){return this.rightmostFailurePosition}_getRightmostFailureOffset(){return this.rightmostFailurePosition>=0?this.posToOffset(this.rightmostFailurePosition):-1}getMemoizedTraceEntry(e,t){const n=this.memoTable[e];if(n&&t instanceof j){const e=n.memo[t.toMemoKey()];if(e&&e.traceEntry){const n=e.traceEntry.cloneWithExpr(t);return n.isMemoized=!0,n}}return null}getTraceEntry(e,t,n,r){if(t instanceof j){const e=this.currentApplication(),n=e?e.args:[];t=t.substituteParams(n)}return this.getMemoizedTraceEntry(e,t)||new de(this.input,e,this.inputStream.pos,t,n,r,this.trace)}isTracing(){return!!this.trace}hasNecessaryInfo(e){return!(this.trace&&!e.traceEntry)&&(!this.recordedFailures||this.inputStream.pos+e.rightmostFailureOffset!==this.positionToRecordFailures||!!e.failuresAtRightmostPosition)}useMemoizedResult(e,t){this.trace&&this.trace.push(t.traceEntry);const n=this.inputStream.pos+t.rightmostFailureOffset;return this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,n),this.recordedFailures&&this.positionToRecordFailures===n&&t.failuresAtRightmostPosition&&this.recordFailures(t.failuresAtRightmostPosition,!0),this.inputStream.examinedLength=Math.max(this.inputStream.examinedLength,t.examinedLength+e),!!t.value&&(this.inputStream.pos+=t.matchLength,this.pushBinding(t.value,e),!0)}eval(e){const{inputStream:t}=this,n=this._bindings.length,r=this.userData;let i;this.recordedFailures&&(i=this.recordedFailures,this.recordedFailures=Object.create(null));const s=t.pos,a=this.maybeSkipSpacesBefore(e);let o;this.trace&&(o=this.trace,this.trace=[]);const l=e.eval(this);if(this.trace){const t=this._bindings.slice(n),r=this.getTraceEntry(a,e,l,t);r.isImplicitSpaces=e===Ie,r.isRootNode=e===this.startExpr,o.push(r),this.trace=o}return l?this.recordedFailures&&t.pos===this.positionToRecordFailures&&Object.keys(this.recordedFailures).forEach((e=>{this.recordedFailures[e].makeFluffy()})):(t.pos=s,this.truncateBindings(n),this.userData=r),this.recordedFailures&&this.recordFailures(i,!1),e===me&&this.skipSpaces(),l}getMatchResult(){let e;this.grammar._setUpMatchState(this),this.eval(this.startExpr),this.recordedFailures&&(e=Object.keys(this.recordedFailures).map((e=>this.recordedFailures[e])));const t=this._bindings[0];return t&&(t.grammar=this.grammar),new ie(this.matcher,this.input,this.startExpr,t,this._bindingOffsets[0],this.rightmostFailurePosition,e)}getTrace(){this.trace=[];const e=this.getMatchResult(),t=this.trace[this.trace.length-1];return t.result=e,t}pushFailuresInfo(){this._rightmostFailurePositionStack.push(this.rightmostFailurePosition),this._recordedFailuresStack.push(this.recordedFailures)}popFailuresInfo(){this.rightmostFailurePosition=this._rightmostFailurePositionStack.pop(),this.recordedFailures=this._recordedFailuresStack.pop()}}class Ce{constructor(e){this.grammar=e,this._memoTable=[],this._input="",this._isMemoTableStale=!1}_resetMemoTable(){this._memoTable=[],this._isMemoTableStale=!1}getInput(){return this._input}setInput(e){return this._input!==e&&this.replaceInputRange(0,this._input.length,e),this}replaceInputRange(e,t,n){const r=this._input,i=this._memoTable;if(e<0||e>r.length||t<0||t>r.length||e>t)throw new Error("Invalid indices: "+e+" and "+t);this._input=r.slice(0,e)+n+r.slice(t),this._input!==r&&i.length>0&&(this._isMemoTableStale=!0);const s=i.slice(t);i.length=e;for(let a=0;aObject.prototype.hasOwnProperty.call(e,t);class Pe{constructor(e,t,n){this._node=e,this.source=t,this._baseInterval=n,e.isNonterminal()&&a(t===n),this._childWrappers=[]}_forgetMemoizedResultFor(e){delete this._node[this._semantics.attributeKeys[e]],this.children.forEach((t=>{t._forgetMemoizedResultFor(e)}))}child(e){if(!(0<=e&&ee._node)),r=new be(n,[],-1,!1),i=this._semantics.wrap(r,null,null);return i._childWrappers=t,i}get children(){return this._children()}get ctorName(){return this._node.ctorName}get numChildren(){return this._node.numChildren()}get sourceString(){return this.source.contents}}class Le{constructor(e,t){const n=this;if(this.grammar=e,this.checkedActionDicts=!1,this.Wrapper=class extends(t?t.Wrapper:Pe){constructor(e,t,r){super(e,t,r),n.checkActionDictsIfHaventAlready(),this._semantics=n}toString(){return"[semantics wrapper for "+n.grammar.name+"]"}},this.super=t,t){if(!e.equals(this.super.grammar)&&!e._inheritsFrom(this.super.grammar))throw new Error("Cannot extend a semantics for grammar '"+this.super.grammar.name+"' for use with grammar '"+e.name+"' (not a sub-grammar)");this.operations=Object.create(this.super.operations),this.attributes=Object.create(this.super.attributes),this.attributeKeys=Object.create(null);for(const e in this.attributes)Object.defineProperty(this.attributeKeys,e,{value:te(e)})}else this.operations=Object.create(null),this.attributes=Object.create(null),this.attributeKeys=Object.create(null)}toString(){return"[semantics for "+this.grammar.name+"]"}checkActionDictsIfHaventAlready(){this.checkedActionDicts||(this.checkActionDicts(),this.checkedActionDicts=!0)}checkActionDicts(){let e;for(e in this.operations)this.operations[e].checkActionDict(this.grammar);for(e in this.attributes)this.attributes[e].checkActionDict(this.grammar)}toRecipe(e){function t(e){return e.super!==Le.BuiltInSemantics._getSemantics()}let n="(function(g) {\n";if(t(this)){n+=" var semantics = "+this.super.toRecipe(!0)+"(g";const e=this.super.grammar;let t=this.grammar;for(;t!==e;)n+=".superGrammar",t=t.superGrammar;n+=");\n",n+=" return g.extendSemantics(semantics)"}else n+=" return g.createSemantics()";return["Operation","Attribute"].forEach((e=>{const r=this[e.toLowerCase()+"s"];Object.keys(r).forEach((i=>{const{actionDict:s,formals:a,builtInDefault:o}=r[i];let l,u=i;a.length>0&&(u+="("+a.join(", ")+")"),l=t(this)&&this.super[e.toLowerCase()+"s"][i]?"extend"+e:"add"+e,n+="\n ."+l+"("+JSON.stringify(u)+", {";const c=[];Object.keys(s).forEach((e=>{if(s[e]!==o){let t=s[e].toString().trim();t=t.replace(/^.*\(/,"function("),c.push("\n "+JSON.stringify(e)+": "+t)}})),n+=c.join(",")+"\n })"}))})),n+=";\n })",e||(n="(function() {\n var grammar = this.fromRecipe("+this.grammar.toRecipe()+");\n var semantics = "+n+"(grammar);\n return semantics;\n});\n"),n}addOperationOrAttribute(e,t,n){const r=e+"s",i=Re(t,e),{name:s}=i,{formals:a}=i;this.assertNewName(s,e);const o=function(e,t,n){return function(...r){const i=(this._semantics.operations[t]||this._semantics.attributes[t]).formals.map((e=>this.args[e]));if(this.isIteration()||1!==r.length)throw function(e,t,n,r){let i=r.slice(0,-1).map((e=>{const t=" "+e[0].name+" > "+e[1];return 3===e.length?t+" for '"+e[2]+"'":t})).join("\n");i+="\n "+t+" > "+e;let s="";"_iter"===e&&(s=["\nNOTE: as of Ohm v16, there is no default action for iteration nodes \u2014 see "," https://ohmjs.org/d/dsa for details."].join("\n"));const a=$([`Missing semantic action for '${e}' in ${n} '${t}'.${s}`,"Action stack (most recent call last):",i].join("\n"));return a.name="missingSemanticAction",a}(this.ctorName,t,e,Ee);return n.apply(r[0],i)}}(e,s,c),l={_default:o};Object.keys(n).forEach((e=>{l[e]=n[e]}));const u="operation"===e?new Ne(s,a,l,o):new Te(s,l,o);function c(...t){const n=this._semantics[r][s];if(arguments.length!==n.formals.length)throw new Error("Invalid number of arguments passed to "+s+" "+e+" (expected "+n.formals.length+", got "+arguments.length+")");const i=Object.create(null);for(const[e,r]of Object.entries(t)){i[n.formals[e]]=r}const a=this.args;this.args=i;const o=n.execute(this._semantics,this);return this.args=a,o}u.checkActionDict(this.grammar),this[r][s]=u,"operation"===e?(this.Wrapper.prototype[s]=c,this.Wrapper.prototype[s].toString=function(){return"["+s+" operation]"}):(Object.defineProperty(this.Wrapper.prototype,s,{get:c,configurable:!0}),Object.defineProperty(this.attributeKeys,s,{value:te(s)}))}extendOperationOrAttribute(e,t,n){const r=e+"s";if(Re(t,"attribute"),!this.super||!(t in this.super[r]))throw new Error("Cannot extend "+e+" '"+t+"': did not inherit an "+e+" with that name");if(Oe(this[r],t))throw new Error("Cannot extend "+e+" '"+t+"' again");const i=this[r][t].formals,s=this[r][t].actionDict,a=Object.create(s);Object.keys(n).forEach((e=>{a[e]=n[e]})),this[r][t]="operation"===e?new Ne(t,i,a):new Te(t,a),this[r][t].checkActionDict(this.grammar)}assertNewName(e,t){if(Oe(Pe.prototype,e))throw new Error("Cannot add "+t+" '"+e+"': that's a reserved name");if(e in this.operations)throw new Error("Cannot add "+t+" '"+e+"': an operation with that name already exists");if(e in this.attributes)throw new Error("Cannot add "+t+" '"+e+"': an attribute with that name already exists")}wrap(e,t,n){const r=n||t;return e instanceof this.Wrapper?e:new this.Wrapper(e,t,r)}}function Re(e,t){if(!Le.prototypeGrammar)return a(-1===e.indexOf("(")),{name:e,formals:[]};const n=Le.prototypeGrammar.match(e,"operation"===t?"OperationSignature":"AttributeSignature");if(n.failed())throw new Error(n.message);return Le.prototypeGrammarSemantics(n).parse()}Le.createSemantics=function(e,t){const n=new Le(e,void 0!==t?t:Le.BuiltInSemantics._getSemantics()),r=function(t){if(!(t instanceof ie))throw new TypeError("Semantics expected a MatchResult, but got "+v(t));if(t.failed())throw new TypeError("cannot apply Semantics to "+t.toString());const r=t._cst;if(r.grammar!==e)throw new Error("Cannot use a MatchResult from grammar '"+r.grammar.name+"' with a semantics for '"+e.name+"'");const i=new re(t.input);return n.wrap(r,i.interval(t._cstOffset,t.input.length))};return r.addOperation=function(e,t){return n.addOperationOrAttribute("operation",e,t),r},r.extendOperation=function(e,t){return n.extendOperationOrAttribute("operation",e,t),r},r.addAttribute=function(e,t){return n.addOperationOrAttribute("attribute",e,t),r},r.extendAttribute=function(e,t){return n.extendOperationOrAttribute("attribute",e,t),r},r._getActionDict=function(t){const r=n.operations[t]||n.attributes[t];if(!r)throw new Error('"'+t+'" is not a valid operation or attribute name in this semantics for "'+e.name+'"');return r.actionDict},r._remove=function(e){let t;return e in n.operations?(t=n.operations[e],delete n.operations[e]):e in n.attributes&&(t=n.attributes[e],delete n.attributes[e]),delete n.Wrapper.prototype[e],t},r.getOperationNames=function(){return Object.keys(n.operations)},r.getAttributeNames=function(){return Object.keys(n.attributes)},r.getGrammar=function(){return n.grammar},r.toRecipe=function(e){return n.toRecipe(e)},r.toString=n.toString.bind(n),r._getSemantics=function(){return n},r};class Ne{constructor(e,t,n,r){this.name=e,this.formals=t,this.actionDict=n,this.builtInDefault=r}checkActionDict(e){e._checkTopDownActionDict(this.typeName,this.name,this.actionDict)}execute(e,t){try{const{ctorName:e}=t._node;let n=this.actionDict[e];return n?(Ee.push([this,e]),n.apply(t,t._children())):t.isNonterminal()&&(n=this.actionDict._nonterminal,n)?(Ee.push([this,"_nonterminal",e]),n.apply(t,t._children())):(Ee.push([this,"default action",e]),this.actionDict._default.apply(t,t._children()))}finally{Ee.pop()}}}Ne.prototype.typeName="operation";class Te extends Ne{constructor(e,t,n){super(e,[],t,n)}execute(e,t){const n=t._node,r=e.attributeKeys[this.name];return Oe(n,r)||(n[r]=Ne.prototype.execute.call(this,e,t)),n[r]}}Te.prototype.typeName="attribute";const Me=["_iter","_terminal","_nonterminal","_default"];function Fe(e){return Object.keys(e.rules).sort().map((t=>e.rules[t]))}let je,De;class $e{constructor(e,t,n,r){if(this.name=e,this.superGrammar=t,this.rules=n,r){if(!(r in n))throw new Error("Invalid start rule: '"+r+"' is not a rule in grammar '"+e+"'");this.defaultStartRule=r}this._matchStateInitializer=void 0,this.supportsIncrementalParsing=!0}matcher(){return new Ce(this)}isBuiltIn(){return this===$e.ProtoBuiltInRules||this===$e.BuiltInRules}equals(e){if(this===e)return!0;if(null==e||this.name!==e.name||this.defaultStartRule!==e.defaultStartRule||this.superGrammar!==e.superGrammar&&!this.superGrammar.equals(e.superGrammar))return!1;const t=Fe(this),n=Fe(e);return t.length===n.length&&t.every(((e,t)=>e.description===n[t].description&&e.formals.join(",")===n[t].formals.join(",")&&e.body.toString()===n[t].body.toString()))}match(e,t){const n=this.matcher();return n.replaceInputRange(0,0,e),n.match(t)}trace(e,t){const n=this.matcher();return n.replaceInputRange(0,0,e),n.trace(t)}createSemantics(){return Le.createSemantics(this)}extendSemantics(e){return Le.createSemantics(this,e._getSemantics())}_checkTopDownActionDict(e,t,n){const r=[];for(const i in n){const e=n[i];if(!Me.includes(i)&&!(i in this.rules)){r.push(`'${i}' is not a valid semantic action for '${this.name}'`);continue}if("function"!==typeof e){r.push(`'${i}' must be a function in an action dictionary for '${this.name}'`);continue}const t=e.length,s=this._topDownActionArity(i);if(t!==s){let e;e="_iter"===i||"_nonterminal"===i?`it should use a rest parameter, e.g. \`${i}(...children) {}\`. NOTE: this is new in Ohm v16 \u2014 see https://ohmjs.org/d/ati for details.`:`expected ${s}, got ${t}`,r.push(`Semantic action '${i}' has the wrong arity: ${e}`)}}if(r.length>0){const n=r.map((e=>"- "+e)),i=new Error([`Found errors in the action dictionary of the '${t}' ${e}:`,...n].join("\n"));throw i.problems=r,i}}_topDownActionArity(e){return Me.includes(e)?0:this.rules[e].body.getArity()}_inheritsFrom(e){let t=this.superGrammar;for(;t;){if(t.equals(e,!0))return!0;t=t.superGrammar}return!1}toRecipe(e=void 0){const t={};this.source&&(t.source=this.source.contents);let n=null;this.defaultStartRule&&(n=this.defaultStartRule);const r={};Object.keys(this.rules).forEach((e=>{const t=this.rules[e],{body:n}=t,i=!this.superGrammar||!this.superGrammar.rules[e];let s;s=i?"define":n instanceof C?"extend":"override";const a={};if(t.source&&this.source){const e=t.source.relativeTo(this.source);a.sourceInterval=[e.startIdx,e.endIdx]}const o=i?t.description:null,l=n.outputRecipe(t.formals,this.source);r[e]=[s,a,o,t.formals,l]}));let i="null";e?i=e:this.superGrammar&&!this.superGrammar.isBuiltIn()&&(i=this.superGrammar.toRecipe());const s=[...["grammar",t,this.name].map(JSON.stringify),i,...[n,r].map(JSON.stringify)];return`[${s.join(",")}]`.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}toOperationActionDictionaryTemplate(){return this._toOperationOrAttributeActionDictionaryTemplate()}toAttributeActionDictionaryTemplate(){return this._toOperationOrAttributeActionDictionaryTemplate()}_toOperationOrAttributeActionDictionaryTemplate(){const e=new m;e.append("{");let t=!0;for(const n in this.rules){const{body:r}=this.rules[n];t?t=!1:e.append(","),e.append("\n"),e.append(" "),this.addSemanticActionTemplate(n,r,e)}return e.append("\n}"),e.contents()}addSemanticActionTemplate(e,t,n){n.append(e),n.append(": function(");const r=this._topDownActionArity(e);n.append(u("_",r).join(", ")),n.append(") {\n"),n.append(" }")}parseApplication(e){let t;if(-1===e.indexOf("<"))t=new j(e);else{const n=je.match(e,"Base_application");t=De(n,{})}if(!(t.ruleName in this.rules))throw V(t.ruleName,this.name);const{formals:n}=this.rules[t.ruleName];if(n.length!==t.args.length){const{source:e}=this.rules[t.ruleName];throw B(t.ruleName,n.length,t.args.length,e)}return t}_setUpMatchState(e){this._matchStateInitializer&&this._matchStateInitializer(e)}}$e.ProtoBuiltInRules=new $e("ProtoBuiltInRules",void 0,{any:{body:S,formals:[],description:"any character",primitive:!0},end:{body:x,formals:[],description:"end of input",primitive:!0},caseInsensitive:{body:new _e(new I(0)),formals:["str"],primitive:!0},lower:{body:new D("Ll"),formals:[],description:"a lowercase letter",primitive:!0},upper:{body:new D("Lu"),formals:[],description:"an uppercase letter",primitive:!0},unicodeLtmo:{body:new D("Ltmo"),formals:[],description:"a Unicode character in Lt, Lm, or Lo",primitive:!0},spaces:{body:new L(new j("space")),formals:[]},space:{body:new _("\0"," "),formals:[],description:"a space"}}),$e.initApplicationParser=function(e,t){je=e,De=t};class ze{constructor(e){this.name=e}sourceInterval(e,t){return this.source.subInterval(e,t-e)}ensureSuperGrammar(){return this.superGrammar||this.withSuperGrammar("BuiltInRules"===this.name?$e.ProtoBuiltInRules:$e.BuiltInRules),this.superGrammar}ensureSuperGrammarRuleForOverriding(e,t){const n=this.ensureSuperGrammar().rules[e];if(!n)throw r=e,i=this.superGrammar.name,$("Cannot override rule "+r+" because it is not declared in "+i,t);var r,i;return n}installOverriddenOrExtendedRule(e,t,n,r){const i=c(t);if(i.length>0)throw W(e,i,r);const s=this.ensureSuperGrammar().rules[e],a=s.formals,o=a?a.length:0;if(t.length!==o)throw B(e,o,t.length,r);return this.install(e,t,n,s.description,r)}install(e,t,n,r,i,s=!1){return this.rules[e]={body:n.introduceParams(t),formals:t,description:r,source:i,primitive:s},this}withSuperGrammar(e){if(this.superGrammar)throw new Error("the super grammar of a GrammarDecl cannot be set more than once");return this.superGrammar=e,this.rules=Object.create(e.rules),e.isBuiltIn()||(this.defaultStartRule=e.defaultStartRule),this}withDefaultStartRule(e){return this.defaultStartRule=e,this}withSource(e){return this.source=new re(e).interval(0,e.length),this}build(){const e=new $e(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule);e._matchStateInitializer=e.superGrammar._matchStateInitializer,e.supportsIncrementalParsing=e.superGrammar.supportsIncrementalParsing;const t=[];let n=!1;return Object.keys(e.rules).forEach((r=>{const{body:i}=e.rules[r];try{i.assertChoicesHaveUniformArity(r)}catch(s){t.push(s)}try{i.assertAllApplicationsAreValid(r,e)}catch(s){t.push(s),n=!0}})),n||Object.keys(e.rules).forEach((n=>{const{body:r}=e.rules[n];try{r.assertIteratedExprsAreNotNullable(e,[])}catch(i){t.push(i)}})),t.length>0&&K(t),this.source&&(e.source=this.source),e}define(e,t,n,r,i,s){if(this.ensureSuperGrammar(),this.superGrammar.rules[e])throw U(e,this.name,this.superGrammar.name,i);if(this.rules[e])throw U(e,this.name,this.name,i);const a=c(t);if(a.length>0)throw W(e,a,i);return this.install(e,t,n,r,i,s)}override(e,t,n,r,i){return this.ensureSuperGrammarRuleForOverriding(e,i),this.installOverriddenOrExtendedRule(e,t,n,i),this}extend(e,t,n,r,i){if(!this.ensureSuperGrammar().rules[e])throw s=e,a=this.superGrammar.name,$("Cannot extend rule "+s+" because it is not declared in "+a,i);var s,a;const o=new C(this.superGrammar,e,n);return o.source=n.source,this.installOverriddenOrExtendedRule(e,t,o,i),this}}class Ve{constructor(){this.currentDecl=null,this.currentRuleName=null}newGrammar(e){return new ze(e)}grammar(e,t,n,r,i){const s=new ze(t);return n&&s.withSuperGrammar(n instanceof $e?n:this.fromRecipe(n)),r&&s.withDefaultStartRule(r),e&&e.source&&s.withSource(e.source),this.currentDecl=s,Object.keys(i).forEach((e=>{this.currentRuleName=e;const t=i[e],n=t[0],r=t[1],a=t[2],o=t[3],l=this.fromRecipe(t[4]);let u;s.source&&r&&r.sourceInterval&&(u=s.source.subInterval(r.sourceInterval[0],r.sourceInterval[1]-r.sourceInterval[0])),s[n](e,o,l,a,u)})),this.currentRuleName=this.currentDecl=null,s.build()}terminal(e){return new k(e)}range(e,t){return new _(e,t)}param(e){return new I(e)}alt(...e){let t=[];for(let n of e)n instanceof w||(n=this.fromRecipe(n)),n instanceof A?t=t.concat(n.terms):t.push(n);return 1===t.length?t[0]:new A(t)}seq(...e){let t=[];for(let n of e)n instanceof w||(n=this.fromRecipe(n)),n instanceof O?t=t.concat(n.factors):t.push(n);return 1===t.length?t[0]:new O(t)}star(e){return e instanceof w||(e=this.fromRecipe(e)),new L(e)}plus(e){return e instanceof w||(e=this.fromRecipe(e)),new R(e)}opt(e){return e instanceof w||(e=this.fromRecipe(e)),new N(e)}not(e){return e instanceof w||(e=this.fromRecipe(e)),new T(e)}lookahead(e){return e instanceof w||(e=this.fromRecipe(e)),new M(e)}lex(e){return e instanceof w||(e=this.fromRecipe(e)),new F(e)}app(e,t){return t&&t.length>0&&(t=t.map((function(e){return e instanceof w?e:this.fromRecipe(e)}),this)),new j(e,t)}splice(e,t){return new E(this.currentDecl.superGrammar,this.currentRuleName,e.map((e=>this.fromRecipe(e))),t.map((e=>this.fromRecipe(e))))}fromRecipe(e){const t="grammar"===e[0]?e.slice(1):e.slice(2),n=this[e[0]](...t),r=e[1];return r&&r.sourceInterval&&this.currentDecl&&n.withSource(this.currentDecl.sourceInterval(...r.sourceInterval)),n}}function Ue(e){return"function"===typeof e?e.call(new Ve):("string"===typeof e&&(e=JSON.parse(e)),(new Ve).fromRecipe(e))}const Be=Ue(["grammar",{source:'BuiltInRules {\n\n alnum (an alpha-numeric character)\n = letter\n | digit\n\n letter (a letter)\n = lower\n | upper\n | unicodeLtmo\n\n digit (a digit)\n = "0".."9"\n\n hexDigit (a hexadecimal digit)\n = digit\n | "a".."f"\n | "A".."F"\n\n ListOf\n = NonemptyListOf\n | EmptyListOf\n\n NonemptyListOf\n = elem (sep elem)*\n\n EmptyListOf\n = /* nothing */\n\n listOf\n = nonemptyListOf\n | emptyListOf\n\n nonemptyListOf\n = elem (sep elem)*\n\n emptyListOf\n = /* nothing */\n\n // Allows a syntactic rule application within a lexical context.\n applySyntactic = app\n}'},"BuiltInRules",null,null,{alnum:["define",{sourceInterval:[18,78]},"an alpha-numeric character",[],["alt",{sourceInterval:[60,78]},["app",{sourceInterval:[60,66]},"letter",[]],["app",{sourceInterval:[73,78]},"digit",[]]]],letter:["define",{sourceInterval:[82,142]},"a letter",[],["alt",{sourceInterval:[107,142]},["app",{sourceInterval:[107,112]},"lower",[]],["app",{sourceInterval:[119,124]},"upper",[]],["app",{sourceInterval:[131,142]},"unicodeLtmo",[]]]],digit:["define",{sourceInterval:[146,177]},"a digit",[],["range",{sourceInterval:[169,177]},"0","9"]],hexDigit:["define",{sourceInterval:[181,254]},"a hexadecimal digit",[],["alt",{sourceInterval:[219,254]},["app",{sourceInterval:[219,224]},"digit",[]],["range",{sourceInterval:[231,239]},"a","f"],["range",{sourceInterval:[246,254]},"A","F"]]],ListOf:["define",{sourceInterval:[258,336]},null,["elem","sep"],["alt",{sourceInterval:[282,336]},["app",{sourceInterval:[282,307]},"NonemptyListOf",[["param",{sourceInterval:[297,301]},0],["param",{sourceInterval:[303,306]},1]]],["app",{sourceInterval:[314,336]},"EmptyListOf",[["param",{sourceInterval:[326,330]},0],["param",{sourceInterval:[332,335]},1]]]]],NonemptyListOf:["define",{sourceInterval:[340,388]},null,["elem","sep"],["seq",{sourceInterval:[372,388]},["param",{sourceInterval:[372,376]},0],["star",{sourceInterval:[377,388]},["seq",{sourceInterval:[378,386]},["param",{sourceInterval:[378,381]},1],["param",{sourceInterval:[382,386]},0]]]]],EmptyListOf:["define",{sourceInterval:[392,434]},null,["elem","sep"],["seq",{sourceInterval:[438,438]}]],listOf:["define",{sourceInterval:[438,516]},null,["elem","sep"],["alt",{sourceInterval:[462,516]},["app",{sourceInterval:[462,487]},"nonemptyListOf",[["param",{sourceInterval:[477,481]},0],["param",{sourceInterval:[483,486]},1]]],["app",{sourceInterval:[494,516]},"emptyListOf",[["param",{sourceInterval:[506,510]},0],["param",{sourceInterval:[512,515]},1]]]]],nonemptyListOf:["define",{sourceInterval:[520,568]},null,["elem","sep"],["seq",{sourceInterval:[552,568]},["param",{sourceInterval:[552,556]},0],["star",{sourceInterval:[557,568]},["seq",{sourceInterval:[558,566]},["param",{sourceInterval:[558,561]},1],["param",{sourceInterval:[562,566]},0]]]]],emptyListOf:["define",{sourceInterval:[572,682]},null,["elem","sep"],["seq",{sourceInterval:[685,685]}]],applySyntactic:["define",{sourceInterval:[685,710]},null,["app"],["param",{sourceInterval:[707,710]},0]]}]);$e.BuiltInRules=Be,function(e){X.forEach((t=>{t(e)})),X=null}($e.BuiltInRules);const We=Ue(["grammar",{source:'Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? "{" Rule* "}"\n\n SuperGrammar\n = "<:" ident\n\n Rule\n = ident Formals? ruleDescr? "=" RuleBody -- define\n | ident Formals? ":=" OverrideRuleBody -- override\n | ident Formals? "+=" RuleBody -- extend\n\n RuleBody\n = "|"? NonemptyListOf\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n OverrideRuleBody\n = "|"? NonemptyListOf\n\n OverrideTopLevelTerm\n = "..." -- superSplice\n | TopLevelTerm\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = NonemptyListOf\n\n Seq\n = Iter*\n\n Iter\n = Pred "*" -- star\n | Pred "+" -- plus\n | Pred "?" -- opt\n | Pred\n\n Pred\n = "~" Lex -- not\n | "&" Lex -- lookahead\n | Lex\n\n Lex\n = "#" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? "=" | ":=" | "+=") -- application\n | oneCharTerminal ".." oneCharTerminal -- range\n | terminal -- terminal\n | "(" Alt ")" -- paren\n\n ruleDescr (a rule description)\n = "(" ruleDescrText ")"\n\n ruleDescrText\n = (~")" any)*\n\n caseName\n = "--" (~"\\n" space)* name (~"\\n" space)* ("\\n" | &"}")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = "\\"" terminalChar* "\\""\n\n oneCharTerminal\n = "\\"" terminalChar "\\""\n\n terminalChar\n = escapeChar\n | ~"\\\\" ~"\\"" ~"\\n" "\\u{0}".."\\u{10FFFF}"\n\n escapeChar (an escape sequence)\n = "\\\\\\\\" -- backslash\n | "\\\\\\"" -- doubleQuote\n | "\\\\\\\'" -- singleQuote\n | "\\\\b" -- backspace\n | "\\\\n" -- lineFeed\n | "\\\\r" -- carriageReturn\n | "\\\\t" -- tab\n | "\\\\u{" hexDigit hexDigit? hexDigit?\n hexDigit? hexDigit? hexDigit? "}" -- unicodeCodePoint\n | "\\\\u" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | "\\\\x" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = "//" (~"\\n" any)* &("\\n" | end) -- singleLine\n | "/*" (~"*/" any)* "*/" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = "<:" | "=" | ":=" | "+=" | "*" | "+" | "?" | "~" | "&"\n\n punctuation = "<" | ">" | "," | "--"\n}'},"Ohm",null,"Grammars",{Grammars:["define",{sourceInterval:[9,32]},null,[],["star",{sourceInterval:[24,32]},["app",{sourceInterval:[24,31]},"Grammar",[]]]],Grammar:["define",{sourceInterval:[36,83]},null,[],["seq",{sourceInterval:[50,83]},["app",{sourceInterval:[50,55]},"ident",[]],["opt",{sourceInterval:[56,69]},["app",{sourceInterval:[56,68]},"SuperGrammar",[]]],["terminal",{sourceInterval:[70,73]},"{"],["star",{sourceInterval:[74,79]},["app",{sourceInterval:[74,78]},"Rule",[]]],["terminal",{sourceInterval:[80,83]},"}"]]],SuperGrammar:["define",{sourceInterval:[87,116]},null,[],["seq",{sourceInterval:[106,116]},["terminal",{sourceInterval:[106,110]},"<:"],["app",{sourceInterval:[111,116]},"ident",[]]]],Rule_define:["define",{sourceInterval:[131,181]},null,[],["seq",{sourceInterval:[131,170]},["app",{sourceInterval:[131,136]},"ident",[]],["opt",{sourceInterval:[137,145]},["app",{sourceInterval:[137,144]},"Formals",[]]],["opt",{sourceInterval:[146,156]},["app",{sourceInterval:[146,155]},"ruleDescr",[]]],["terminal",{sourceInterval:[157,160]},"="],["app",{sourceInterval:[162,170]},"RuleBody",[]]]],Rule_override:["define",{sourceInterval:[188,248]},null,[],["seq",{sourceInterval:[188,235]},["app",{sourceInterval:[188,193]},"ident",[]],["opt",{sourceInterval:[194,202]},["app",{sourceInterval:[194,201]},"Formals",[]]],["terminal",{sourceInterval:[214,218]},":="],["app",{sourceInterval:[219,235]},"OverrideRuleBody",[]]]],Rule_extend:["define",{sourceInterval:[255,305]},null,[],["seq",{sourceInterval:[255,294]},["app",{sourceInterval:[255,260]},"ident",[]],["opt",{sourceInterval:[261,269]},["app",{sourceInterval:[261,268]},"Formals",[]]],["terminal",{sourceInterval:[281,285]},"+="],["app",{sourceInterval:[286,294]},"RuleBody",[]]]],Rule:["define",{sourceInterval:[120,305]},null,[],["alt",{sourceInterval:[131,305]},["app",{sourceInterval:[131,170]},"Rule_define",[]],["app",{sourceInterval:[188,235]},"Rule_override",[]],["app",{sourceInterval:[255,294]},"Rule_extend",[]]]],RuleBody:["define",{sourceInterval:[309,362]},null,[],["seq",{sourceInterval:[324,362]},["opt",{sourceInterval:[324,328]},["terminal",{sourceInterval:[324,327]},"|"]],["app",{sourceInterval:[329,362]},"NonemptyListOf",[["app",{sourceInterval:[344,356]},"TopLevelTerm",[]],["terminal",{sourceInterval:[358,361]},"|"]]]]],TopLevelTerm_inline:["define",{sourceInterval:[385,408]},null,[],["seq",{sourceInterval:[385,397]},["app",{sourceInterval:[385,388]},"Seq",[]],["app",{sourceInterval:[389,397]},"caseName",[]]]],TopLevelTerm:["define",{sourceInterval:[366,418]},null,[],["alt",{sourceInterval:[385,418]},["app",{sourceInterval:[385,397]},"TopLevelTerm_inline",[]],["app",{sourceInterval:[415,418]},"Seq",[]]]],OverrideRuleBody:["define",{sourceInterval:[422,491]},null,[],["seq",{sourceInterval:[445,491]},["opt",{sourceInterval:[445,449]},["terminal",{sourceInterval:[445,448]},"|"]],["app",{sourceInterval:[450,491]},"NonemptyListOf",[["app",{sourceInterval:[465,485]},"OverrideTopLevelTerm",[]],["terminal",{sourceInterval:[487,490]},"|"]]]]],OverrideTopLevelTerm_superSplice:["define",{sourceInterval:[522,543]},null,[],["terminal",{sourceInterval:[522,527]},"..."]],OverrideTopLevelTerm:["define",{sourceInterval:[495,562]},null,[],["alt",{sourceInterval:[522,562]},["app",{sourceInterval:[522,527]},"OverrideTopLevelTerm_superSplice",[]],["app",{sourceInterval:[550,562]},"TopLevelTerm",[]]]],Formals:["define",{sourceInterval:[566,606]},null,[],["seq",{sourceInterval:[580,606]},["terminal",{sourceInterval:[580,583]},"<"],["app",{sourceInterval:[584,602]},"ListOf",[["app",{sourceInterval:[591,596]},"ident",[]],["terminal",{sourceInterval:[598,601]},","]]],["terminal",{sourceInterval:[603,606]},">"]]],Params:["define",{sourceInterval:[610,647]},null,[],["seq",{sourceInterval:[623,647]},["terminal",{sourceInterval:[623,626]},"<"],["app",{sourceInterval:[627,643]},"ListOf",[["app",{sourceInterval:[634,637]},"Seq",[]],["terminal",{sourceInterval:[639,642]},","]]],["terminal",{sourceInterval:[644,647]},">"]]],Alt:["define",{sourceInterval:[651,685]},null,[],["app",{sourceInterval:[661,685]},"NonemptyListOf",[["app",{sourceInterval:[676,679]},"Seq",[]],["terminal",{sourceInterval:[681,684]},"|"]]]],Seq:["define",{sourceInterval:[689,704]},null,[],["star",{sourceInterval:[699,704]},["app",{sourceInterval:[699,703]},"Iter",[]]]],Iter_star:["define",{sourceInterval:[719,736]},null,[],["seq",{sourceInterval:[719,727]},["app",{sourceInterval:[719,723]},"Pred",[]],["terminal",{sourceInterval:[724,727]},"*"]]],Iter_plus:["define",{sourceInterval:[743,760]},null,[],["seq",{sourceInterval:[743,751]},["app",{sourceInterval:[743,747]},"Pred",[]],["terminal",{sourceInterval:[748,751]},"+"]]],Iter_opt:["define",{sourceInterval:[767,783]},null,[],["seq",{sourceInterval:[767,775]},["app",{sourceInterval:[767,771]},"Pred",[]],["terminal",{sourceInterval:[772,775]},"?"]]],Iter:["define",{sourceInterval:[708,794]},null,[],["alt",{sourceInterval:[719,794]},["app",{sourceInterval:[719,727]},"Iter_star",[]],["app",{sourceInterval:[743,751]},"Iter_plus",[]],["app",{sourceInterval:[767,775]},"Iter_opt",[]],["app",{sourceInterval:[790,794]},"Pred",[]]]],Pred_not:["define",{sourceInterval:[809,824]},null,[],["seq",{sourceInterval:[809,816]},["terminal",{sourceInterval:[809,812]},"~"],["app",{sourceInterval:[813,816]},"Lex",[]]]],Pred_lookahead:["define",{sourceInterval:[831,852]},null,[],["seq",{sourceInterval:[831,838]},["terminal",{sourceInterval:[831,834]},"&"],["app",{sourceInterval:[835,838]},"Lex",[]]]],Pred:["define",{sourceInterval:[798,862]},null,[],["alt",{sourceInterval:[809,862]},["app",{sourceInterval:[809,816]},"Pred_not",[]],["app",{sourceInterval:[831,838]},"Pred_lookahead",[]],["app",{sourceInterval:[859,862]},"Lex",[]]]],Lex_lex:["define",{sourceInterval:[876,892]},null,[],["seq",{sourceInterval:[876,884]},["terminal",{sourceInterval:[876,879]},"#"],["app",{sourceInterval:[880,884]},"Base",[]]]],Lex:["define",{sourceInterval:[866,903]},null,[],["alt",{sourceInterval:[876,903]},["app",{sourceInterval:[876,884]},"Lex_lex",[]],["app",{sourceInterval:[899,903]},"Base",[]]]],Base_application:["define",{sourceInterval:[918,979]},null,[],["seq",{sourceInterval:[918,963]},["app",{sourceInterval:[918,923]},"ident",[]],["opt",{sourceInterval:[924,931]},["app",{sourceInterval:[924,930]},"Params",[]]],["not",{sourceInterval:[932,963]},["alt",{sourceInterval:[934,962]},["seq",{sourceInterval:[934,948]},["opt",{sourceInterval:[934,944]},["app",{sourceInterval:[934,943]},"ruleDescr",[]]],["terminal",{sourceInterval:[945,948]},"="]],["terminal",{sourceInterval:[951,955]},":="],["terminal",{sourceInterval:[958,962]},"+="]]]]],Base_range:["define",{sourceInterval:[986,1041]},null,[],["seq",{sourceInterval:[986,1022]},["app",{sourceInterval:[986,1001]},"oneCharTerminal",[]],["terminal",{sourceInterval:[1002,1006]},".."],["app",{sourceInterval:[1007,1022]},"oneCharTerminal",[]]]],Base_terminal:["define",{sourceInterval:[1048,1106]},null,[],["app",{sourceInterval:[1048,1056]},"terminal",[]]],Base_paren:["define",{sourceInterval:[1113,1168]},null,[],["seq",{sourceInterval:[1113,1124]},["terminal",{sourceInterval:[1113,1116]},"("],["app",{sourceInterval:[1117,1120]},"Alt",[]],["terminal",{sourceInterval:[1121,1124]},")"]]],Base:["define",{sourceInterval:[907,1168]},null,[],["alt",{sourceInterval:[918,1168]},["app",{sourceInterval:[918,963]},"Base_application",[]],["app",{sourceInterval:[986,1022]},"Base_range",[]],["app",{sourceInterval:[1048,1056]},"Base_terminal",[]],["app",{sourceInterval:[1113,1124]},"Base_paren",[]]]],ruleDescr:["define",{sourceInterval:[1172,1231]},"a rule description",[],["seq",{sourceInterval:[1210,1231]},["terminal",{sourceInterval:[1210,1213]},"("],["app",{sourceInterval:[1214,1227]},"ruleDescrText",[]],["terminal",{sourceInterval:[1228,1231]},")"]]],ruleDescrText:["define",{sourceInterval:[1235,1266]},null,[],["star",{sourceInterval:[1255,1266]},["seq",{sourceInterval:[1256,1264]},["not",{sourceInterval:[1256,1260]},["terminal",{sourceInterval:[1257,1260]},")"]],["app",{sourceInterval:[1261,1264]},"any",[]]]]],caseName:["define",{sourceInterval:[1270,1338]},null,[],["seq",{sourceInterval:[1285,1338]},["terminal",{sourceInterval:[1285,1289]},"--"],["star",{sourceInterval:[1290,1304]},["seq",{sourceInterval:[1291,1302]},["not",{sourceInterval:[1291,1296]},["terminal",{sourceInterval:[1292,1296]},"\n"]],["app",{sourceInterval:[1297,1302]},"space",[]]]],["app",{sourceInterval:[1305,1309]},"name",[]],["star",{sourceInterval:[1310,1324]},["seq",{sourceInterval:[1311,1322]},["not",{sourceInterval:[1311,1316]},["terminal",{sourceInterval:[1312,1316]},"\n"]],["app",{sourceInterval:[1317,1322]},"space",[]]]],["alt",{sourceInterval:[1326,1337]},["terminal",{sourceInterval:[1326,1330]},"\n"],["lookahead",{sourceInterval:[1333,1337]},["terminal",{sourceInterval:[1334,1337]},"}"]]]]],name:["define",{sourceInterval:[1342,1382]},"a name",[],["seq",{sourceInterval:[1363,1382]},["app",{sourceInterval:[1363,1372]},"nameFirst",[]],["star",{sourceInterval:[1373,1382]},["app",{sourceInterval:[1373,1381]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[1386,1418]},null,[],["alt",{sourceInterval:[1402,1418]},["terminal",{sourceInterval:[1402,1405]},"_"],["app",{sourceInterval:[1412,1418]},"letter",[]]]],nameRest:["define",{sourceInterval:[1422,1452]},null,[],["alt",{sourceInterval:[1437,1452]},["terminal",{sourceInterval:[1437,1440]},"_"],["app",{sourceInterval:[1447,1452]},"alnum",[]]]],ident:["define",{sourceInterval:[1456,1489]},"an identifier",[],["app",{sourceInterval:[1485,1489]},"name",[]]],terminal:["define",{sourceInterval:[1493,1531]},null,[],["seq",{sourceInterval:[1508,1531]},["terminal",{sourceInterval:[1508,1512]},'"'],["star",{sourceInterval:[1513,1526]},["app",{sourceInterval:[1513,1525]},"terminalChar",[]]],["terminal",{sourceInterval:[1527,1531]},'"']]],oneCharTerminal:["define",{sourceInterval:[1535,1579]},null,[],["seq",{sourceInterval:[1557,1579]},["terminal",{sourceInterval:[1557,1561]},'"'],["app",{sourceInterval:[1562,1574]},"terminalChar",[]],["terminal",{sourceInterval:[1575,1579]},'"']]],terminalChar:["define",{sourceInterval:[1583,1660]},null,[],["alt",{sourceInterval:[1602,1660]},["app",{sourceInterval:[1602,1612]},"escapeChar",[]],["seq",{sourceInterval:[1621,1660]},["not",{sourceInterval:[1621,1626]},["terminal",{sourceInterval:[1622,1626]},"\\"]],["not",{sourceInterval:[1627,1632]},["terminal",{sourceInterval:[1628,1632]},'"']],["not",{sourceInterval:[1633,1638]},["terminal",{sourceInterval:[1634,1638]},"\n"]],["range",{sourceInterval:[1639,1660]},"\0","\udbff\udfff"]]]],escapeChar_backslash:["define",{sourceInterval:[1703,1758]},null,[],["terminal",{sourceInterval:[1703,1709]},"\\\\"]],escapeChar_doubleQuote:["define",{sourceInterval:[1765,1822]},null,[],["terminal",{sourceInterval:[1765,1771]},'\\"']],escapeChar_singleQuote:["define",{sourceInterval:[1829,1886]},null,[],["terminal",{sourceInterval:[1829,1835]},"\\'"]],escapeChar_backspace:["define",{sourceInterval:[1893,1948]},null,[],["terminal",{sourceInterval:[1893,1898]},"\\b"]],escapeChar_lineFeed:["define",{sourceInterval:[1955,2009]},null,[],["terminal",{sourceInterval:[1955,1960]},"\\n"]],escapeChar_carriageReturn:["define",{sourceInterval:[2016,2076]},null,[],["terminal",{sourceInterval:[2016,2021]},"\\r"]],escapeChar_tab:["define",{sourceInterval:[2083,2132]},null,[],["terminal",{sourceInterval:[2083,2088]},"\\t"]],escapeChar_unicodeCodePoint:["define",{sourceInterval:[2139,2243]},null,[],["seq",{sourceInterval:[2139,2221]},["terminal",{sourceInterval:[2139,2145]},"\\u{"],["app",{sourceInterval:[2146,2154]},"hexDigit",[]],["opt",{sourceInterval:[2155,2164]},["app",{sourceInterval:[2155,2163]},"hexDigit",[]]],["opt",{sourceInterval:[2165,2174]},["app",{sourceInterval:[2165,2173]},"hexDigit",[]]],["opt",{sourceInterval:[2188,2197]},["app",{sourceInterval:[2188,2196]},"hexDigit",[]]],["opt",{sourceInterval:[2198,2207]},["app",{sourceInterval:[2198,2206]},"hexDigit",[]]],["opt",{sourceInterval:[2208,2217]},["app",{sourceInterval:[2208,2216]},"hexDigit",[]]],["terminal",{sourceInterval:[2218,2221]},"}"]]],escapeChar_unicodeEscape:["define",{sourceInterval:[2250,2309]},null,[],["seq",{sourceInterval:[2250,2291]},["terminal",{sourceInterval:[2250,2255]},"\\u"],["app",{sourceInterval:[2256,2264]},"hexDigit",[]],["app",{sourceInterval:[2265,2273]},"hexDigit",[]],["app",{sourceInterval:[2274,2282]},"hexDigit",[]],["app",{sourceInterval:[2283,2291]},"hexDigit",[]]]],escapeChar_hexEscape:["define",{sourceInterval:[2316,2371]},null,[],["seq",{sourceInterval:[2316,2339]},["terminal",{sourceInterval:[2316,2321]},"\\x"],["app",{sourceInterval:[2322,2330]},"hexDigit",[]],["app",{sourceInterval:[2331,2339]},"hexDigit",[]]]],escapeChar:["define",{sourceInterval:[1664,2371]},"an escape sequence",[],["alt",{sourceInterval:[1703,2371]},["app",{sourceInterval:[1703,1709]},"escapeChar_backslash",[]],["app",{sourceInterval:[1765,1771]},"escapeChar_doubleQuote",[]],["app",{sourceInterval:[1829,1835]},"escapeChar_singleQuote",[]],["app",{sourceInterval:[1893,1898]},"escapeChar_backspace",[]],["app",{sourceInterval:[1955,1960]},"escapeChar_lineFeed",[]],["app",{sourceInterval:[2016,2021]},"escapeChar_carriageReturn",[]],["app",{sourceInterval:[2083,2088]},"escapeChar_tab",[]],["app",{sourceInterval:[2139,2221]},"escapeChar_unicodeCodePoint",[]],["app",{sourceInterval:[2250,2291]},"escapeChar_unicodeEscape",[]],["app",{sourceInterval:[2316,2339]},"escapeChar_hexEscape",[]]]],space:["extend",{sourceInterval:[2375,2394]},null,[],["app",{sourceInterval:[2387,2394]},"comment",[]]],comment_singleLine:["define",{sourceInterval:[2412,2458]},null,[],["seq",{sourceInterval:[2412,2443]},["terminal",{sourceInterval:[2412,2416]},"//"],["star",{sourceInterval:[2417,2429]},["seq",{sourceInterval:[2418,2427]},["not",{sourceInterval:[2418,2423]},["terminal",{sourceInterval:[2419,2423]},"\n"]],["app",{sourceInterval:[2424,2427]},"any",[]]]],["lookahead",{sourceInterval:[2430,2443]},["alt",{sourceInterval:[2432,2442]},["terminal",{sourceInterval:[2432,2436]},"\n"],["app",{sourceInterval:[2439,2442]},"end",[]]]]]],comment_multiLine:["define",{sourceInterval:[2465,2501]},null,[],["seq",{sourceInterval:[2465,2487]},["terminal",{sourceInterval:[2465,2469]},"/*"],["star",{sourceInterval:[2470,2482]},["seq",{sourceInterval:[2471,2480]},["not",{sourceInterval:[2471,2476]},["terminal",{sourceInterval:[2472,2476]},"*/"]],["app",{sourceInterval:[2477,2480]},"any",[]]]],["terminal",{sourceInterval:[2483,2487]},"*/"]]],comment:["define",{sourceInterval:[2398,2501]},null,[],["alt",{sourceInterval:[2412,2501]},["app",{sourceInterval:[2412,2443]},"comment_singleLine",[]],["app",{sourceInterval:[2465,2487]},"comment_multiLine",[]]]],tokens:["define",{sourceInterval:[2505,2520]},null,[],["star",{sourceInterval:[2514,2520]},["app",{sourceInterval:[2514,2519]},"token",[]]]],token:["define",{sourceInterval:[2524,2600]},null,[],["alt",{sourceInterval:[2532,2600]},["app",{sourceInterval:[2532,2540]},"caseName",[]],["app",{sourceInterval:[2543,2550]},"comment",[]],["app",{sourceInterval:[2553,2558]},"ident",[]],["app",{sourceInterval:[2561,2569]},"operator",[]],["app",{sourceInterval:[2572,2583]},"punctuation",[]],["app",{sourceInterval:[2586,2594]},"terminal",[]],["app",{sourceInterval:[2597,2600]},"any",[]]]],operator:["define",{sourceInterval:[2604,2669]},null,[],["alt",{sourceInterval:[2615,2669]},["terminal",{sourceInterval:[2615,2619]},"<:"],["terminal",{sourceInterval:[2622,2625]},"="],["terminal",{sourceInterval:[2628,2632]},":="],["terminal",{sourceInterval:[2635,2639]},"+="],["terminal",{sourceInterval:[2642,2645]},"*"],["terminal",{sourceInterval:[2648,2651]},"+"],["terminal",{sourceInterval:[2654,2657]},"?"],["terminal",{sourceInterval:[2660,2663]},"~"],["terminal",{sourceInterval:[2666,2669]},"&"]]],punctuation:["define",{sourceInterval:[2673,2709]},null,[],["alt",{sourceInterval:[2687,2709]},["terminal",{sourceInterval:[2687,2690]},"<"],["terminal",{sourceInterval:[2693,2696]},">"],["terminal",{sourceInterval:[2699,2702]},","],["terminal",{sourceInterval:[2705,2709]},"--"]]]}]),He=Object.create(w.prototype);function Ge(e,t){for(const n in e)if(n===t)return!0;return!1}function qe(e,t,n){const r=new Ve;let i,s,o,l=!1;const u=(n||We).createSemantics().addOperation("visit",{Grammars:e=>e.children.map((e=>e.visit())),Grammar(e,n,s,a,o){const l=e.visit();i=r.newGrammar(l),n.child(0)&&n.child(0).visit(),a.children.map((e=>e.visit()));const u=i.build();if(u.source=this.source.trimmed(),Ge(t,l))throw function(e,t){return $("Grammar "+e.name+" is already declared in this namespace")}(u);return t[l]=u,u},SuperGrammar(e,n){const r=n.visit();if("null"===r)i.withSuperGrammar(null);else{if(!t||!Ge(t,r))throw function(e,t,n){return $(t?`Grammar ${e} is not declared in namespace '${t}'`:"Undeclared grammar "+e,n)}(r,t,n.source);i.withSuperGrammar(t[r])}},Rule_define(e,t,n,r,a){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[],i.defaultStartRule||i.ensureSuperGrammar()===$e.ProtoBuiltInRules||i.withDefaultStartRule(s);const l=a.visit(),u=n.children.map((e=>e.visit()))[0],c=this.source.trimmed();return i.define(s,o,l,u,c)},Rule_override(e,t,n,r){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[];const a=this.source.trimmed();i.ensureSuperGrammarRuleForOverriding(s,a),l=!0;const u=r.visit();return l=!1,i.override(s,o,u,null,a)},Rule_extend(e,t,n,r){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[];const a=r.visit(),l=this.source.trimmed();return i.extend(s,o,a,null,l)},RuleBody(e,t){return r.alt(...t.visit()).withSource(this.source)},OverrideRuleBody(e,t){const n=t.visit(),a=n.indexOf(He);if(a>=0){const e=n.slice(0,a),t=n.slice(a+1);return t.forEach((e=>{if(e===He)throw $("'...' can appear at most once in a rule body",e.source)})),new E(i.superGrammar,s,e,t).withSource(this.source)}return r.alt(...n).withSource(this.source)},Formals:(e,t,n)=>t.visit(),Params:(e,t,n)=>t.visit(),Alt(e){return r.alt(...e.visit()).withSource(this.source)},TopLevelTerm_inline(e,t){const n=s+"_"+t.visit(),a=e.visit(),u=this.source.trimmed(),c=!(i.superGrammar&&i.superGrammar.rules[n]);l&&!c?i.override(n,o,a,null,u):i.define(n,o,a,null,u);const p=o.map((e=>r.app(e)));return r.app(n,p).withSource(a.source)},OverrideTopLevelTerm_superSplice:e=>He,Seq(e){return r.seq(...e.children.map((e=>e.visit()))).withSource(this.source)},Iter_star(e,t){return r.star(e.visit()).withSource(this.source)},Iter_plus(e,t){return r.plus(e.visit()).withSource(this.source)},Iter_opt(e,t){return r.opt(e.visit()).withSource(this.source)},Pred_not(e,t){return r.not(t.visit()).withSource(this.source)},Pred_lookahead(e,t){return r.lookahead(t.visit()).withSource(this.source)},Lex_lex(e,t){return r.lex(t.visit()).withSource(this.source)},Base_application(e,t){const n=t.children.map((e=>e.visit()))[0]||[];return r.app(e.visit(),n).withSource(this.source)},Base_range(e,t,n){return r.range(e.visit(),n.visit()).withSource(this.source)},Base_terminal(e){return r.terminal(e.visit()).withSource(this.source)},Base_paren:(e,t,n)=>t.visit(),ruleDescr:(e,t,n)=>t.visit(),ruleDescrText(e){return this.sourceString.trim()},caseName:(e,t,n,r,i)=>n.visit(),name(e,t){return this.sourceString},nameFirst(e){},nameRest(e){},terminal:(e,t,n)=>t.children.map((e=>e.visit())).join(""),oneCharTerminal:(e,t,n)=>t.visit(),escapeChar(e){try{return y(this.sourceString)}catch(t){if(t instanceof RangeError&&t.message.startsWith("Invalid code point "))throw function(e){const t=e._node;a(t&&t.isNonterminal()&&"escapeChar_unicodeCodePoint"===t.ctorName);const n=e.children.slice(1,-1).map((e=>e.source)),r=n[0].coverageWith(...n.slice(1));return $(`U+${r.contents} is not a valid Unicode code point`,r)}(e);throw t}},NonemptyListOf:(e,t,n)=>[e.visit()].concat(n.children.map((e=>e.visit()))),EmptyListOf:()=>[],_terminal(){return this.sourceString}});return u(e).visit()}const Ke=Ue(["grammar",{source:'OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = "(" ListOf ")"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n}'},"OperationsAndAttributes",null,"AttributeSignature",{AttributeSignature:["define",{sourceInterval:[29,58]},null,[],["app",{sourceInterval:[54,58]},"name",[]]],OperationSignature:["define",{sourceInterval:[62,100]},null,[],["seq",{sourceInterval:[87,100]},["app",{sourceInterval:[87,91]},"name",[]],["opt",{sourceInterval:[92,100]},["app",{sourceInterval:[92,99]},"Formals",[]]]]],Formals:["define",{sourceInterval:[104,143]},null,[],["seq",{sourceInterval:[118,143]},["terminal",{sourceInterval:[118,121]},"("],["app",{sourceInterval:[122,139]},"ListOf",[["app",{sourceInterval:[129,133]},"name",[]],["terminal",{sourceInterval:[135,138]},","]]],["terminal",{sourceInterval:[140,143]},")"]]],name:["define",{sourceInterval:[147,187]},"a name",[],["seq",{sourceInterval:[168,187]},["app",{sourceInterval:[168,177]},"nameFirst",[]],["star",{sourceInterval:[178,187]},["app",{sourceInterval:[178,186]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[191,223]},null,[],["alt",{sourceInterval:[207,223]},["terminal",{sourceInterval:[207,210]},"_"],["app",{sourceInterval:[217,223]},"letter",[]]]],nameRest:["define",{sourceInterval:[227,257]},null,[],["alt",{sourceInterval:[242,257]},["terminal",{sourceInterval:[242,245]},"_"],["app",{sourceInterval:[252,257]},"alnum",[]]]]}]);!function(e){const t={empty(){return this.iteration()},nonEmpty(e,t,n){return this.iteration([e].concat(n.children))}};Le.BuiltInSemantics=Le.createSemantics(e,null).addOperation("asIteration",{emptyListOf:t.empty,nonemptyListOf:t.nonEmpty,EmptyListOf:t.empty,NonemptyListOf:t.nonEmpty})}($e.BuiltInRules),function(e){Le.prototypeGrammarSemantics=e.createSemantics().addOperation("parse",{AttributeSignature:e=>({name:e.parse(),formals:[]}),OperationSignature:(e,t)=>({name:e.parse(),formals:t.children.map((e=>e.parse()))[0]||[]}),Formals:(e,t,n)=>t.asIteration().children.map((e=>e.parse())),name(e,t){return this.sourceString}}),Le.prototypeGrammar=e}(Ke);const Qe="an indented block",Ye="a dedent",Xe=1114112;class Je extends re{constructor(e){super(e.input),this.state=e}_indentationAt(e){return this.state.userData[e]||0}atEnd(){return super.atEnd()&&0===this._indentationAt(this.pos)}next(){if(0===this._indentationAt(this.pos))return super.next();this.examinedLength=Math.max(this.examinedLength,this.pos)}nextCharCode(){return 0!==this._indentationAt(this.pos)?(this.examinedLength=Math.max(this.examinedLength,this.pos),Xe):super.nextCharCode()}nextCodePoint(){return 0!==this._indentationAt(this.pos)?(this.examinedLength=Math.max(this.examinedLength,this.pos),Xe):super.nextCodePoint()}}class Ze extends w{constructor(e=!0){super(),this.isIndent=e}allowsSkippingPrecedingSpace(){return!0}eval(e){const{inputStream:t}=e,n=e.userData;e.doNotMemoize=!0;const r=t.pos,i=this.isIndent?1:-1;return(n[r]||0)*i>0?(e.userData=Object.create(n),e.userData[r]-=i,e.pushBinding(new ye(0),r),!0):(e.processFailure(r,this),!1)}getArity(){return 1}_assertAllApplicationsAreValid(e,t){}_isNullable(e,t){return!1}assertChoicesHaveUniformArity(e){}assertIteratedExprsAreNotNullable(e){}introduceParams(e){return this}substituteParams(e){return this}toString(){return this.isIndent?"indent":"dedent"}toDisplayString(){return this.toString()}toFailure(e){const t=this.isIndent?Qe:Ye;return new ke(this,t,"description")}}const et=new j("indent"),tt=new j("dedent"),nt=new E(Be,"any",[et,tt],[]),rt=(new Ve).newGrammar("IndentationSensitive").withSuperGrammar(Be).define("indent",[],new Ze(!0),Qe,void 0,!0).define("dedent",[],new Ze(!1),Ye,void 0,!0).extend("any",[],nt,"any character",void 0).build();Object.assign(rt,{_matchStateInitializer(e){e.userData=function(e){let t=0;const n=[0],r=()=>n[n.length-1],i={},s=/( *).*(?:$|\r?\n|\r)/g;let a;for(;null!=(a=s.exec(e));){const[e,s]=a;if(0===e.length)break;const o=s.length,l=r(),u=t+o;if(o>l)n.push(o),i[u]=1;else if(o1&&(i[t]=1-n.length),i}(e.input),e.inputStream=new Je(e)},supportsIncrementalParsing:!1}),$e.initApplicationParser(We,qe);const it=e=>!!e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e);function st(e,t){const n=We.match(e,"Grammars");if(n.failed())throw function(e){const t=new Error;return Object.defineProperty(t,"message",{enumerable:!0,get:()=>e.message}),Object.defineProperty(t,"shortMessage",{enumerable:!0,get:()=>"Expected "+e.getExpectedText()}),t.interval=e.getInterval(),t}(n);return qe(n,t)}function at(e,t){const n=function(e,t){const n=Object.create(t||{});if("string"!==typeof e){if(!it(e))throw new TypeError("Expected string as first argument, got "+v(e));e=e.toString()}return st(e,n),n}(e,t),r=Object.keys(n);if(0===r.length)throw new Error("Missing grammar definition");if(r.length>1){const e=n[r[1]].source;throw new Error(ee(e.sourceString,e.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return n[r[0]]}},8463:(e,t,n)=>{n.d(t,{Kx:()=>i,O:()=>a,a5:()=>s,J5:()=>r});const r="function Main.fibonacci 0\n push argument 0\n push constant 2\n lt // checks if n<2\n if-goto IF_TRUE\n goto IF_FALSE\n label IF_TRUE // if n<2, return n\n push argument 0 \n return\n label IF_FALSE // if n>=2, returns fib(n-2)+fib(n-1)\n push argument 0\n push constant 2\n sub\n call Main.fibonacci 1 // computes fib(n-2)\n push argument 0\n push constant 1\n sub\n call Main.fibonacci 1 // computes fib(n-1)\n add // returns fib(n-1) + fib(n-2)\n return\nfunction Sys.init 0\n push constant 4\n call Main.fibonacci 1 // computes the 4'th fibonacci element\nlabel WHILE\n goto WHILE // loops infinitely\n",i={"01":["Nand"],"02":[],"03":["DFF"],"05":["Screen","Keyboard","DRegister","ARegister","ROM32K","RAM16K"]},s={"01":["Not","And","Or","Xor","Mux","DMux","Not16","And16","Or16","Mux16","Or8Way","Mux4Way16","Mux8Way16","DMux4Way","DMux8Way"],"02":["HalfAdder","FullAdder","Add16","Inc16","ALU"],"03":["Bit","Register","RAM8","RAM64","RAM512","RAM4K","RAM16K","PC"],"05":["Memory","CPU","Computer"]},a={"05":["Memory","CPU","Computer","Screen","Keyboard","DRegister","ARegister","ROM32K","RAM16K"]}},5777:(e,t,n)=>{async function r(e,t){(await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288))).resetFiles(e,t)}async function i(e,t){(await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288))).resetTests(e,t)}async function s(e){(await Promise.all([n.e(828),n.e(297)]).then(n.bind(n,9297))).loadSamples(e)}async function a(e){(await n.e(269).then(n.bind(n,1269))).loadSolutions(e)}n.r(t),n.d(t,{default:()=>l,loadSamples:()=>s,loadSolutions:()=>a,loaders:()=>o,resetFiles:()=>r,resetTests:()=>i});const o={resetFiles:r,loadSolutions:a,loadSamples:s},l=o},7738:(e,t,n)=>{n.d(t,{qg:()=>u});var r=n(5874),i=n(3977),s=n(5005),a=n(6980),o=n(9651);function l(e){const t=e.start??0;return void 0===e.end?(0,r.Ok)(void 0):e.end>=t?(0,r.Ok)(e.end-t+1):(0,r._)((0,i.$5)("Bus start index should be less than or equal to bus end index",e.span))}async function u(e,t){const n=s.xP.parse(e.toString());return(0,r.ys)(n)?n:p((0,r.Ok)(n),void 0,t)}async function c(e,t){if((0,a.KQ)(e)||void 0===t)return await(0,a.M1)(e);try{const n=await t.readFile(`${e}.hdl`),i=s.xP.parse(n);let a;if((0,r.HQ)(i)){const e=await p((0,r.Ok)(i),t);a=(0,r.ys)(e)?(0,r._)(new Error((0,r._)(e).message)):e}else a=(0,r._)(new Error("HDL Was not parsed"));return a}catch(n){return(0,r._)(new Error(`Could not load chip ${e}.hdl`))}}async function p(e,t,n){return await new y(e,t,n).build()}function d(e){if(void 0!=e.start&&void 0!=e.end)return e.end-e.start+1}function h(e){return void 0!=e.start&&void 0!=e.end?`${e.pin}[${e.start}..${e.end}]`:e.pin}function f(e,t){const n=l(e),i=l(t);return(0,r.ys)(n)?n:(0,r.ys)(i)?i:(0,r.Ok)({to:{name:e.pin.toString(),start:e.start??0,width:(0,r.Ok)(n)},from:{name:t.pin.toString(),start:t.start??0,width:(0,r.Ok)(i)}})}function m(e){if(void 0!=e.start&&void 0!=e.end){const t=[];for(let n=e.start;n<=e.end;n++)t.push(n);return t}return[-1]}function g(e,t){let n;const s=t.get(e.pin);if(s)if(s.has(-1))n=e.start??-1;else if(void 0!==e.start&&void 0!==e.end)for(const r of m(e))s.has(r)&&(n=r),s.add(r);else s.add(-1);else t.set(e.pin,new Set(m(e)));return void 0!=n?(0,r._)((0,i.$5)(`Cannot write to pin ${e.pin}${-1!=n?`[${n}]`:""} multiple times`,e.span)):(0,r.Ok)()}class y{parts;fs;expectedName;chip;internalPins=new Map;inPins=new Map;outPins=new Map;wires=[];constructor(e,t,n){this.parts=e,this.expectedName=n,this.fs=t,this.chip=new o.vu(e.ins.map((({pin:e,width:t})=>({pin:e.toString(),width:t}))),e.outs.map((({pin:e,width:t})=>({pin:e.toString(),width:t}))),e.name.value,[],e.clocked)}async build(){if(this.expectedName&&this.parts.name.value!=this.expectedName)return(0,r._)((0,i.$5)("Wrong chip name",this.parts.name.span));if("BUILTIN"===this.parts.parts)return await(0,a.M1)(this.parts.name.value);const e=await this.wireParts();if((0,r.ys)(e))return e;this.chip.clockedPins=new Set([...this.chip.ins.entries(),...this.chip.outs.entries()].map((e=>e.name)).filter((e=>this.chip.isClockedPin(e)))),this.chip.sortParts();for(const t of this.chip.parts)t.subscribeToClock();return(0,r.Ok)(this.chip)}async wireParts(){if("BUILTIN"===this.parts.parts)return(0,r.Ok)();for(const t of this.parts.parts){const e=await c(t.name,this.fs);if((0,r.ys)(e))return(0,r._)((0,i.$5)(`Undefined chip name: ${t.name}`,t.span));const n=(0,r.Ok)(e);if(n.name==this.chip.name)return(0,r._)((0,i.$5)(`Cannot use chip ${n.name} to implement itself`,t.span));const s=this.wirePart(t,n);if((0,r.ys)(s))return s}let e=this.validateInternalPins();return(0,r.ys)(e)?e:(e=this.validateWireWidths(),(0,r.ys)(e)?e:(0,r.Ok)())}checkLoops(e,t){const n=new Set,s=new Set;let a;for(const{lhs:r,rhs:i}of e.wires)if(t.isInPin(r.pin)){if(s.has(i.pin)){a=i.pin;break}n.add(i.pin)}else if(t.isOutPin(r.pin)){if(n.has(i.pin)){a=i.pin;break}s.add(i.pin)}return a?(0,r._)((0,i.$5)(`Looping wire ${a}`,e.span)):(0,r.Ok)()}wirePart(e,t){const n=this.checkLoops(e,t);if((0,r.ys)(n))return n;const s=[];this.inPins.clear();for(const{lhs:i,rhs:o}of e.wires){const e=this.validateWire(t,i,o);if((0,r.ys)(e))return e;const n=f(i,o);if((0,r.ys)(n))return n;s.push((0,r.Ok)(n))}try{const n=this.chip.wire(t,s);if((0,r.ys)(n)){const t=(0,r._)(n);return(0,r._)((0,i.$5)(t.message,t.lhs?e.wires[t.wireIndex].lhs.span:e.wires[t.wireIndex].rhs.span))}return(0,r.Ok)()}catch(a){return(0,r._)((0,i.$5)(a.message,e.span))}}validateWire(e,t,n){if(e.isInPin(t.pin)){const e=this.validateInputWire(t,n);if((0,r.ys)(e))return e}else{if(!e.isOutPin(t.pin))return(0,r._)((0,i.$5)(`Undefined pin name: ${t.pin}`,t.span));{const i=this.validateOutputWire(e,t,n);if((0,r.ys)(i))return i}}return(0,o.KK)(n.pin)||this.wires.push({partChip:e,lhs:t,rhs:n}),(0,r.Ok)()}validateInputWire(e,t){let n=this.validateInputSource(t);if((0,r.ys)(n))return n;if(n=g(e,this.inPins),(0,r.ys)(n))return n;if(this.chip.isInternalPin(t.pin)){const e=this.internalPins.get(t.pin);void 0==e?this.internalPins.set(t.pin,{isDefined:!1,firstUse:t.span}):e.firstUse=e.firstUse.start{n.d(t,{N4:()=>u,Sc:()=>y,Z8:()=>g,ce:()=>d,ff:()=>c,s3:()=>p});var r=n(7721),i=n(7076),s=n(6983),a=n(7844),o=n(9651),l=n(836);class u extends l.XK{constructor(){super(15,"ROM")}async load(e,t){try{(await(0,s.Hh)(e,t)).map(((e,t)=>this.at(t).busVoltage=e))}catch(n){throw new Error(`ROM32K Failed to load file ${t}`)}}}class c extends l.XK{static SIZE=i.RL;static OFFSET=i.L7;constructor(){super(13,"Screen")}}class p extends o.vu{static OFFSET=i.ky;constructor(){super([],["out[16]"],"Keyboard")}getKey(){return this.out().busVoltage}setKey(e){this.out().busVoltage=65535&e}clearKey(){this.out().busVoltage=0}get(e){return e===this.name?new o.xo(this.name,this.getKey()):super.get(e)}}class d extends o._b{ram=new l.jV;screen=new c;keyboard=new p;address=0;constructor(){super(["in[16]","load","address[15])"],["out[16]"],"Memory",[],["in","load"]),this.parts.push(this.keyboard),this.parts.push(this.screen),this.parts.push(this.ram)}tick(){const e=this.in("load").voltage();if(this.address=this.in("address").busVoltage,e){const e=this.in().busVoltage;this.address>=p.OFFSET||(this.address>=c.OFFSET?this.screen.at(this.address-c.OFFSET).busVoltage=e:this.ram.at(this.address).busVoltage=e)}}tock(){this.eval()}eval(){if(!this.ram)return;this.address=this.in("address").busVoltage;let e=0;e=this.address>=p.OFFSET?this.keyboard?.out().busVoltage??0:this.address>=c.OFFSET?this.screen?.at(this.address-c.OFFSET).busVoltage??0:this.ram?.at(this.address).busVoltage??0,this.out().busVoltage=e}in(e){if(e?.startsWith("RAM16K")){const t=(0,a.ZR)(e.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.ram.at(t)}if(e?.startsWith("Screen")){const t=(0,a.ZR)(e.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.screen.at(t)}return super.in(e)}get(e,t=0){return e.startsWith("RAM16K")?this.at(16383&t):e.startsWith("Screen")?this.at(t&8191+c.OFFSET):e.startsWith("Keyboard")?this.at(p.OFFSET):e.startsWith("Memory")?this.at(t):super.get(e,t)}at(e){return e>=p.OFFSET?this.keyboard.out():e>=c.OFFSET?this.screen.at(e-c.OFFSET):this.ram.at(e)}reset(){this.address=0,this.ram.reset(),this.screen.reset(),super.reset()}}class h extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.D}set busVoltage(e){this.cpu.D=e}}class f extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.A}set busVoltage(e){this.cpu.A=e}}class m extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.PC}set busVoltage(e){this.cpu.PC=e}}class g extends o._b{_state=(0,r.p$)();get state(){return this._state}constructor(){super(["inM[16]","instruction[16]","reset"],["outM[16]","writeM","addressM[15]","pc[15]"],"CPU",[],["pc","addressM","reset"])}tick(){const[e,t]=(0,r.gV)(this.cpuInput(),this._state);this._state=e,this.out("writeM").pull(t?o.RY:o.$L),this.out("outM").busVoltage=this._state.ALU??0}tock(){if(!this._state)return;const[e,t]=(0,r.I8)(this.cpuInput(),this._state);this._state=t,this.out("addressM").busVoltage=e.addressM??0,this.out("outM").busVoltage=e.outM??0,this.out("writeM").pull(e.writeM?o.RY:o.$L),this.out("pc").busVoltage=this._state?.PC??0}cpuInput(){return{inM:this.in("inM").busVoltage,instruction:this.in("instruction").busVoltage,reset:1===this.in("reset").busVoltage}}get(e,t){return e?.startsWith("ARegister")?new f("ARegister",this._state):e?.startsWith("DRegister")?new h("DRegister",this._state):e?.startsWith("PC")?new m("PC",this._state):super.get(e,t)}reset(){this._state=(0,r.p$)(),this._state.PC=-1,super.reset()}}class y extends o.vu{cpu=new g;ram=new d;rom=new u;constructor(){super(["reset"],[]),this.wire(this.cpu,[{from:{name:"reset",start:0},to:{name:"reset",start:0}},{from:{name:"instruction",start:0},to:{name:"instruction",start:0}},{from:{name:"oldOutM",start:0},to:{name:"inM",start:0}},{from:{name:"writeM",start:0},to:{name:"writeM",start:0}},{from:{name:"addressM",start:0},to:{name:"addressM",start:0}},{from:{name:"newInM",start:0},to:{name:"outM",start:0}},{from:{name:"pc",start:0},to:{name:"pc",start:0}}]),this.wire(this.rom,[{from:{name:"pc",start:0},to:{name:"address",start:0}},{from:{name:"instruction",start:0},to:{name:"out",start:0}}]),this.wire(this.ram,[{from:{name:"newInM",start:0},to:{name:"in",start:0}},{from:{name:"writeM",start:0},to:{name:"load",start:0}},{from:{name:"addressM",start:0},to:{name:"address",start:0}},{from:{name:"oldOutM",start:0},to:{name:"out",start:0}}]);for(const e of[...this.ins.entries(),...this.outs.entries()])this.isClockedPin(e.name)&&this.clockedPins.add(e.name)}eval(){super.eval()}get(e,t){return e.startsWith("PC")||e.startsWith("ARegister")||e.startsWith("DRegister")?this.cpu.get(e):e.startsWith("RAM16K")?this.ram.get(e,t):super.get(e,t)}async load(e,t){return await this.rom.load(e,t)}}},6980:(e,t,n)=>{n.d(t,{Hs:()=>L,Mo:()=>U,M1:()=>W,KQ:()=>B});var r=n(5874),i=n(9651);class s extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[1===e&&1===t?i.RY:i.$L]}(e,t);this.out().pull(n)}}class a extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[e&t&65535]}(e,t);this.out().busVoltage=n}}class o extends i.vu{constructor(){super(["in","sel"],["a","b"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").voltage(),[n,r]=function(e,t){return[t===i.$L&&e===i.RY?i.RY:i.$L,t===i.RY&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r)}}class l extends i.vu{constructor(){super(["in","sel[2]"],["a","b","c","d"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").busVoltage,[n,r,s,a]=function(e,t){return[0===t&&e===i.RY?i.RY:i.$L,1===t&&e===i.RY?i.RY:i.$L,2===t&&e===i.RY?i.RY:i.$L,3===t&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r),this.out("c").pull(s),this.out("d").pull(a)}}class u extends i.vu{constructor(){super(["in","sel[3]"],["a","b","c","d","e","f","g","h"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").busVoltage,[n,r,s,a,o,l,u,c]=function(e,t){return[0===t&&e===i.RY?i.RY:i.$L,1===t&&e===i.RY?i.RY:i.$L,2===t&&e===i.RY?i.RY:i.$L,3===t&&e===i.RY?i.RY:i.$L,4===t&&e===i.RY?i.RY:i.$L,5===t&&e===i.RY?i.RY:i.$L,6===t&&e===i.RY?i.RY:i.$L,7===t&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r),this.out("c").pull(s),this.out("d").pull(a),this.out("e").pull(o),this.out("f").pull(l),this.out("g").pull(u),this.out("h").pull(c)}}function c(e,t,n){return[n===i.$L?e:t]}function p(e,t,n,r,i){const s=1&i;return 0===(2&i)?c(e,t,s):c(n,r,s)}class d extends i.vu{constructor(){super(["a","b","sel"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),n=this.in("sel").voltage(),[r]=function(e,t,n){return[n===i.$L?e:t]}(e,t,n);this.out().pull(r)}}class h extends i.vu{constructor(){super(["a[16]","b[16]","sel"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("sel").voltage(),[r]=c(e,t,n);this.out().busVoltage=r}}class f extends i.vu{constructor(){super(["a[16]","b[16]","c[16]","d[16]","sel[2]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("c").busVoltage,r=this.in("d").busVoltage,i=this.in("sel").busVoltage,[s]=p(e,t,n,r,i);this.out().busVoltage=s}}class m extends i.vu{constructor(){super(["a[16]","b[16]","c[16]","d[16]","e[16]","f[16]","g[16]","h[16]","sel[3]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("c").busVoltage,r=this.in("d").busVoltage,i=this.in("e").busVoltage,s=this.in("f").busVoltage,a=this.in("g").busVoltage,o=this.in("h").busVoltage,l=this.in("sel").busVoltage,[u]=function(e,t,n,r,i,s,a,o,l){const u=3&l;return 0===(4&l)?p(e,t,n,r,u):p(i,s,a,o,u)}(e,t,n,r,i,s,a,o,l);this.out().busVoltage=u}}var g=n(7844);class y extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[1===e&&1===t?i.$L:i.RY]}(e,t);this.out().pull(n)}}class v extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage;this.out().busVoltage=(0,g.xu)(e,t)}}class b extends i.vu{constructor(){super(["in"],["out"])}eval(){const e=this.in("in").voltage(),[t]=[e===i.$L?i.RY:i.$L];this.out().pull(t)}}class w extends i.vu{constructor(){super(["in[16]"],["out[16]"])}eval(){const[e]=[65535&~this.in().busVoltage];this.out().busVoltage=e}}function S(e,t){return[1===e||1===t?i.RY:i.$L]}class x extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=S(e,t);this.out().pull(n)}}class k extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[65535&(e|t)]}(e,t);this.out().busVoltage=n}}class _ extends i.vu{constructor(){super(["in[8]"],["out"],"Or8way")}eval(){const e=this.in().busVoltage,[t]=[0===(255&e)?i.$L:i.RY];this.out().pull(t)}}class I extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[e===i.RY&&t===i.$L||e===i.$L&&t===i.RY?i.RY:i.$L]}(e,t);this.out().pull(n)}}class A extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[65535&(e^t)]}(e,t);this.out().busVoltage=n}}function C(e,t){return[e+t&65535]}class E extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"],"Add16")}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=C(e,t);this.out().busVoltage=n}}var O=n(8739);class P extends i.vu{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]"],"ALU")}eval(){const e=this.in("x").busVoltage,t=this.in("y").busVoltage,n=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0),[r]=(0,O.v0)(n,e,t);this.out().busVoltage=r}}class L extends i.vu{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]","zr","ng"],"ALU")}eval(){const e=this.in("x").busVoltage,t=this.in("y").busVoltage,n=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0),[r,s]=(0,O.v0)(n,e,t),a=s===O.iI.Negative?i.RY:i.$L,o=s===O.iI.Zero?i.RY:i.$L;this.out("out").busVoltage=r,this.out("ng").pull(a),this.out("zr").pull(o)}op(){return(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0)}}i.vu;function R(e,t){return[1===e&&0===t||0===e&&1===t?i.RY:i.$L,1===e&&1===t?i.RY:i.$L]}class N extends i.vu{constructor(){super(["a","b"],["sum","carry"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n,r]=R(e,t);this.out("sum").pull(n),this.out("carry").pull(r)}}class T extends i.vu{constructor(){super(["a","b","c"],["sum","carry"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),n=this.in("c").voltage(),[r,i]=function(e,t,n){const[r,i]=R(e,t),[s,a]=R(r,n),[o]=S(i,a);return[s,o]}(e,t,n);this.out("sum").pull(r),this.out("carry").pull(i)}}class M extends i.vu{constructor(){super(["in[16]"],["out[16]"],"Inc16")}eval(){const e=this.in().busVoltage,[t]=C(e,1);this.out().busVoltage=t}}var F=n(7738);const j={CPU:"CHIP CPU {\n\n IN inM[16], // M value input (M = contents of RAM[A])\n instruction[16], // Instruction for execution\n reset; // Signals whether to re-start the current\n // program (reset==1) or continue executing\n // the current program (reset==0).\n\n OUT outM[16], // M value output\n writeM, // Write to M? \n addressM[15], // Address in data memory (of M)\n pc[15]; // address of next instruction\n\n PARTS:\n Mux16(a=instruction, b=ALUoutput, sel=instruction[15], out=Ainput);\n Not(in=instruction[15], out=Ainstruction);\n Or(a=Ainstruction, b=instruction[5], out=loadA);\n ARegister(in=Ainput, load=loadA, out=Aoutput, out[0..14]=addressM);\n\n And(a=instruction[15], b=instruction[4], out=loadD);\n DRegister(in=ALUoutput, load=loadD, out=Doutput);\n\n Mux16(a=Aoutput, b=inM, sel=instruction[12], out=ALUsecondInput);\n\n ALU(x=Doutput, y=ALUsecondInput, \n zx=instruction[11], nx=instruction[10], \n zy=instruction[9], ny=instruction[8],\n f=instruction[7], no=instruction[6], \n out=ALUoutput, out=outM, ng=negative, zr=zero);\n\n And(a=instruction[15], b=instruction[3], out=writeM);\n\n Or(a=negative, b=zero, out=notPositive);\n Not(in=notPositive, out=positive);\n\n And(a=positive, b=instruction[0], out=j1);\n And(a=zero, b=instruction[1], out=j2);\n And(a=negative, b=instruction[2], out=j3);\n Or(a=j1, b=j2, out=jTemp);\n Or(a=jTemp, b=j3, out=jumpIfC);\n And(a=jumpIfC, b=instruction[15], out=jump);\n\n PC(reset=reset, inc=true, load=jump, in=Aoutput, out[0..14]=pc);\n}"};var D=n(7761),$=n(2331);class z extends i._b{constructor(e){super(["in"],["out"],e,["t"],["in"])}tick(){const e=this.in().voltage();this.pin("t").pull(e)}tock(){const e=this.pin("t").voltage();this.out().pull(e)}}var V=n(836);const U=new Map([["Nand",y],["Nand16",v],["Not",b],["Not16",w],["And",s],["And16",a],["Or",x],["Or16",k],["Or8Way",_],["XOr",I],["XOr16",A],["Xor",I],["Xor16",A],["Mux",d],["Mux16",h],["Mux4Way16",f],["Mux8Way16",m],["DMux",o],["DMux4Way",l],["DMux8Way",u],["HalfAdder",N],["FullAdder",T],["Add16",E],["Inc16",M],["ALU",L],["ALUNoStat",P],["DFF",z],["Bit",$.G],["Register",$.UZ],["ARegister",$.UZ],["DRegister",$.UZ],["PC",$.PC],["RAM8",V.Z4],["RAM64",V.JG],["RAM512",V.fn],["RAM4K",V.g0],["RAM16K",V.jV],["ROM32K",D.N4],["Screen",D.ff],["Keyboard",D.s3],["CPU",D.Z8],["Computer",D.Sc],["Memory",D.ce],["ARegister",$.s$],["DRegister",$.s$]].map((([e,t])=>[e,()=>{const n=new t;return n.name=e,n}])));function B(e){return U.has(e)}async function W(e){if(j[e]){const t=await(0,F.qg)(j[e],e);return(0,r.ys)(t)?(0,r._)(new Error((0,r._)(t).message)):t}const t=U.get(e);return t?(0,r.Ok)(t()):(0,r._)(new Error(`Chip ${e} not in builtin registry`))}},2331:(e,t,n)=>{n.d(t,{G:()=>i,PC:()=>l,UZ:()=>a,s$:()=>o});var r=n(9651);class i extends r._b{bit=r.$L;constructor(e){super(["in","load"],["out"],e,[],["in","load"])}tick(){this.in("load").voltage()===r.RY&&(this.bit=this.in().voltage())}tock(){this.out().pull(this.bit??0)}reset(){this.bit=r.$L,super.reset()}}class s extends r.z7{register;constructor(e,t){super(e),this.register=t}get busVoltage(){return 65535&this.register.bits}set busVoltage(e){this.register.bits=65535&e}}class a extends r._b{bits=0;constructor(e){super(["in[16]","load"],["out[16]"],e,[],["in","load"])}tick(){this.in("load").voltage()===r.RY&&(this.bits=65535&this.in().busVoltage)}tock(){this.out().busVoltage=65535&this.bits}get(e,t){return e===this.name?new s(this.name,this):super.get(e,t)}reset(){this.bits=0,super.reset()}}class o extends a{}class l extends r._b{bits=0;constructor(e){super(["in[16]","reset","load","inc"],["out[16]"],e,[],["in","reset","load","inc"])}tick(){this.in("reset").voltage()===r.RY?this.bits=0:this.in("load").voltage()===r.RY?this.bits=65535&this.in().busVoltage:this.in("inc").voltage()===r.RY&&(this.bits+=1)}tock(){this.out().busVoltage=65535&this.bits}get(e,t){return e===this.name?new s(this.name,this):super.get(e,t)}reset(){this.bits=0,super.reset()}}},836:(e,t,n)=>{n.d(t,{JG:()=>u,XK:()=>a,Z4:()=>l,fn:()=>c,g0:()=>p,jV:()=>d});var r=n(2469),i=n(7076),s=n(9651);class a extends s._b{width;_memory;_nextData=0;_address=0;get memory(){return this._memory}get address(){return this._address}constructor(e,t){super(["in[16]","load",`address[${e}]`],["out[16]"],t,[],["in","load"]),this.width=e,this._memory=new i.ce(Math.pow(2,this.width))}tick(){const e=this.in("load").voltage();this._address=this.in("address").busVoltage,e&&(this._nextData=this.in().busVoltage,this._memory.set(this._address,this._nextData))}tock(){this.out().busVoltage=this._memory?.get(this._address)??0}eval(){const e=this.in("address").busVoltage;this.out().busVoltage=this._memory?.get(e)??0}at(e){return(0,r.vA)(e`Request out of bounds (${e} >= ${this._memory.size})`)),new o(`${this.name}[${e}]`,e,this._memory)}get(e,t){return e===this.name?this.at(t??0):super.get(e)}reset(){this._memory.reset(),super.reset()}}class o extends s.z7{index;ram;constructor(e,t,n){super(e),this.index=t,this.ram=n}get busVoltage(){return this.ram.get(this.index)}set busVoltage(e){this.ram.set(this.index,e)}}class l extends a{constructor(){super(3,"RAM8")}}class u extends a{constructor(){super(6,"RAM64")}}class c extends a{constructor(){super(9,"RAM512")}}class p extends a{constructor(){super(12,"RAM4K")}}class d extends a{constructor(){super(14,"RAM16K")}}},9651:(e,t,n)=>{n.d(t,{$L:()=>l,KK:()=>u,RY:()=>o,_b:()=>x,ti:()=>S,vu:()=>w,xo:()=>h,z7:()=>c});var r=n(2469),i=n(742),s=n(5874),a=n(1164);const o=1,l=0;function u(e){return"false"===e||"true"===e||"0"===e||"1"===e}class c{name;width;state;next=[];constructor(e,t=1){this.name=e,this.width=t,this.state=(0,i.y)(0,this.width).map((()=>l))}ensureWidth(e){(0,r.vA)(e<=16,`Cannot widen past 16 to ${e} bits`),this.widthl))])}connect(e){this.next.push(e),e.busVoltage=this.busVoltage}pull(e,t=0){(0,r.vA)(t>=0&&tn.pull(e,t)))}voltage(e=0){return(0,r.vA)(e>=0&&e>t;this.next.forEach((e=>e.busVoltage=this.busVoltage))}get busVoltage(){return(0,i.y)(0,this.width).reduce(((e,t)=>e|this.state[t]<=0&&t+n<=e.width,`Mismatched InSubBus dimensions on ${e.name} (${n} + ${t} > ${e.width})`),this.connect(e)}pull(e,t=0){(0,r.vA)(t>=0&&t=0&&e>this.start&k(this.width)}connect(e){(0,r.vA)(this.start+this.width<=e.width,`Mismatched InSubBus connection dimensions (From ${e.name} to ${this.name})`),this.bus=e}}class d extends c{bus;start;width;constructor(e,t,n=1){super(e.name),this.bus=e,this.start=t,this.width=n,(0,r.vA)(t>=0&&n<=e.width,"Mismatched OutSubBus dimensions"),this.connect(e)}set busVoltage(e){this.bus.busVoltage=(e&k(this.width+this.start))>>this.start}get busVoltage(){return this.bus.busVoltage&k(this.width)}connect(e){(0,r.vA)(this.width<=e.width,"Mismatched OutSubBus connection dimensions"),this.bus=e}}class h extends c{value;constructor(e,t){super(e,16),this.value=t}pullHigh(e=0){}pullLow(e=0){}voltage(e=0){return 1&this.busVoltage}set busVoltage(e){}get busVoltage(){return this.value}}const f=new h("true",65535),m=new h("false",0);function g(e){const{pin:t,w:n}=e.match(/(?[a-zA-Z]+)(\[(?\d+)\])?/)?.groups;return{pin:t,width:n?Number(n):1}}class y{map=new Map;insert(e){const{name:t}=e;(0,r.vA)(!this.map.has(t),`Pins already has ${t}!`),this.map.set(t,e)}emplace(e,t){if(this.has(e))return this.get(e);{const n=new c(e,t);return this.insert(n),n}}has(e){return this.map.has(e)}get(e){return this.map.get(e)}entries(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}function v(e,t,n){return e+t<=n.width?(0,s.Ok)():(0,s._)(`Sub-bus index out of range (${n.name} has width ${n.width})`)}let b=0;class w{name;id=b++;ins=new y;outs=new y;pins=new y;insToPart=new Map;partToOuts=new Map;parts=[];clockedPins;clockSubscription;get clocked(){if(this.clockedPins.size>0)return!0;for(const e of this.parts)if(e.clocked)return!0;return!1}constructor(e,t,n,r=[],i=[]){this.name=n;for(const s of e){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.ins.insert(new c(e,t))}for(const s of t){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.outs.insert(new c(e,t))}for(const s of r){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.pins.insert(new c(e,t))}this.clockedPins=new Set(i),this.subscribeToClock()}subscribeToClock(){this.clockSubscription?.unsubscribe(),this.clockSubscription=a.z.subscribe((()=>this.eval()))}reset(){for(const[e,t]of this.ins)t.busVoltage=0;for(const e of this.parts)e.reset();this.eval()}in(e="in"){return(0,r.vA)(this.hasIn(e),`No in pin ${e}`),this.ins.get(e)}out(e="out"){return(0,r.vA)(this.hasOut(e),`No in pin ${e}`),this.outs.get(e)}hasIn(e){return this.ins.has(e)}hasOut(e){return this.outs.has(e)}pin(e){return(0,r.vA)(this.pins.has(e)),this.pins.get(e)}get(e,t){return this.ins.has(e)?this.ins.get(e):this.outs.has(e)?this.outs.get(e):this.pins.has(e)?this.pins.get(e):this.getBuiltin(e,t)}getBuiltin(e,t=0){if(_.includes(e))for(const n of this.parts){const r=n.get(e,t);if(r)return r}}isInPin(e){return this.ins.has(e)}isOutPin(e){return this.outs.has(e)}isExternalPin(e){return this.isInPin(e)||this.isOutPin(e)||u(e)}isInternalPin(e){return!this.isExternalPin(e)}pathExists(e,t){const n=[e];for(;n.length>0;){const e=(0,r.Z1)(n.pop());if("string"==typeof e){if(e==t)return!0;n.push(...this.insToPart.get(e)??[])}else n.push(...this.partToOuts.get(e)??[])}return!1}isClockedPin(e){return this.isInPin(e)?![...this.outs].some((([t,n])=>this.pathExists(e,t))):![...this.ins].some((([t,n])=>this.pathExists(t,e)))}hasConnection(e,t){return[...this.partToOuts.get(e)??[]].some((e=>this.insToPart.get(e)?.has(t)))}wire(e,t){for(let n=0;n({part:e,isReturning:!1})));for(;i.length>0;){const s=(0,r.Z1)(i.pop());if(s.isReturning)t.add(s.part),e.push(s.part);else if(!t.has(s.part)){if(n.has(s.part))continue;n.add(s.part),i.push({part:s.part,isReturning:!0});for(const e of this.partToOuts.get(s.part)??[])i.push(...Array.from(this.insToPart.get(e)??[]).filter((e=>!t.has(e))).map((e=>({part:e,isReturning:!1}))))}}this.parts=e.reverse()}findPin(e,t){return"true"===e||"1"===e?f:"false"===e||"0"===e?m:this.ins.has(e)?this.ins.get(e):this.outs.has(e)?this.outs.get(e):this.pins.emplace(e,t)}wireOutPin(e,t,n){const i=(0,r.Z1)(e.outs.get(t.name),(()=>`Cannot wire to missing pin ${t.name}`));t.width??=i.width;let a=this.findPin(n.name,n.width??t.width);const o=this.pins.has(a.name);if(n.width??=a.width,a instanceof h)return(0,s._)({message:"Cannot wire to constant bus",lhs:!0});if(o&&a instanceof c&&a.ensureWidth(n.start+n.width),n.start>0||n.width!==a.width){const e=v(n.start,n.width,a);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!0});a=new p(a,n.start,n.width)}if(t.start>0||t.width!==i.width){const e=v(t.start,t.width,i);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!1});a=new d(a,t.start,t.width)}if(i.connect(a),!e.clockedPins.has(i.name)){const t=this.partToOuts.get(e)??new Set;t.add(a.name),this.partToOuts.set(e,t)}return(0,s.Ok)()}wireInPin(e,t,n){let i=(0,r.Z1)(e.ins.get(t.name),(()=>`Cannot wire to missing pin ${t.name}`));t.width??=i.width;const a=this.findPin(n.name,n.width??t.width);if(n.width??=a.width,t.start>0||t.width!==i.width){const e=v(t.start,t.width,i);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!0});i=new p(i,t.start,t.width)}if(!["true","false"].includes(a.name)&&(n.start>0||n.width!==a.width)){const e=v(n.start,n.width,a);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!1});i=new d(i,n.start,n.width)}if(a.connect(i),!e.clockedPins.has(i.name)){const t=this.insToPart.get(a.name)??new Set;t.add(e),this.insToPart.set(a.name,t)}return(0,s.Ok)()}eval(){for(const e of this.parts)f.next.forEach((e=>e.busVoltage=f.busVoltage)),m.next.forEach((e=>e.busVoltage=m.busVoltage)),e.eval()}tick(){this.eval()}tock(){this.eval()}remove(){this.clockSubscription?.unsubscribe();for(const e of this.parts)e.remove()}async load(e,t){for(const n of this.parts)"ROM32K"===n.name&&await n.load(e,t)}}class S extends w{constructor(){super([],[]),this.outs.insert(m)}}class x extends w{get clocked(){return!0}subscribeToClock(){this.clockSubscription?.unsubscribe(),this.clockSubscription=a.z.subscribe((({level:e})=>{e===l?this.tock():this.tick()}))}remove(){this.clockSubscription?.unsubscribe(),super.remove()}reset(){super.reset(),this.tick(),this.tock()}}function k(e){return Math.pow(2,e)-1}const _=["Register","ARegister","DRegister","PC","RAM8","RAM64","RAM512","RAM4K","RAM16K","ROM32K","Screen","Keyboard","Memory"]},1164:(e,t,n)=>{n.d(t,{z:()=>B});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function s(e){var t="function"===typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"===typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"===typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(o){i={error:o}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,s=n.observers;return r||i?h:(this.currentObservers=null,s.push(e),new d((function(){t.currentObservers=null,p(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new T;return e.source=this,e},t.create=function(e,t){return new D(e,t)},t}(T),D=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return i(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:h},t}(j),$=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return i(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(j),z=n(2469),V=n(9651);let U;class B{level=V.$L;ticks=0;static get(){return void 0===U&&(U=new B),U}static subscribe(e){return B.get().$.subscribe(e)}get isHigh(){return this.level===V.RY}get isLow(){return this.level===V.$L}subject=new $({level:this.level,ticks:this.ticks});frameSubject=new j;resetSubject=new j;$=this.subject;frame$=this.frameSubject;reset$=this.resetSubject;next(){this.subject.next({level:this.level,ticks:this.ticks})}constructor(){}reset(){this.level=V.$L,this.ticks=0,this.next(),this.resetSubject.next()}tick(){(0,z.vA)(this.level===V.$L,"Can only tick up from LOW"),this.level=V.RY,this.next()}tock(){(0,z.vA)(this.level===V.RY,"Can only tock down from HIGH"),this.level=V.$L,this.ticks+=1,this.next()}toggle(){this.level===V.RY?this.tock():this.tick()}eval(){this.tick(),this.tock()}frame(){this.frameSubject.next()}toString(){return`${this.ticks}${this.level===V.RY?"+":""}`}}},8739:(e,t,n)=>{n.d(t,{Lo:()=>a,Nt:()=>l,Qv:()=>p,_0:()=>s,ft:()=>d,iI:()=>h,nf:()=>i,qn:()=>m,uW:()=>u,v0:()=>f});const r=new Set(["0","1","-1","D","A","!D","!A","-D","-A","D+1","A+1","D-1","A-1","D+A","D-A","A-D","D&A","D|A"]);function i(e){return r.has(e)||r.has(e.replace("M","A"))}const s={op:{42:"0",63:"1",58:"-1",12:"x",48:"y",13:"!x",49:"!y",15:"-x",51:"-y",31:"x+1",55:"y+1",14:"x-1",50:"y-1",2:"x+y",19:"x-y",7:"y-x",0:"x&y",21:"x|y"}},a={asm:{0:42,1:63,"-1":58,D:12,A:48,"!D":13,"!A":49,"-D":15,"-A":51,"D+1":31,"A+1":55,"D-1":14,"A-1":50,"D+A":2,"D-A":19,"A-D":7,"D&A":0,"D|A":21},op:{42:"0",63:"1",58:"-1",12:"D",48:"A",13:"!D",49:"!A",15:"-D",51:"-A",31:"D+1",55:"A+1",14:"D-1",50:"A-1",2:"D+A",19:"D-A",7:"A-D",0:"D&A",21:"D|A"},getOp:e=>a.asm[e.replace("M","A")]},o=new Set(["","M","D","MD","A","AM","AD","AMD"]);function l(e){return o.has(e)}const u={asm:{"":0,M:1,D:2,MD:3,A:4,AM:5,AD:6,AMD:7},op:{0:"",1:"M",2:"D",3:"MD",4:"A",5:"AM",6:"AD",7:"AMD"}},c=new Set(["","JGT","JEQ","JGE","JLT","JNE","JLE","JMP"]);function p(e){return c.has(e)}const d={asm:{"":0,JGT:1,JEQ:2,JGE:3,JLT:4,JNE:5,JLE:6,JMP:7},op:{0:"",1:"JGT",2:"JEQ",3:"JGE",4:"JLT",5:"JNE",6:"JLE",7:"JMP"}},h={1:"Positive",0:"Zero",15:"Negative",Positive:1,Zero:0,Negative:15};function f(e,t,n){let r=0;switch(e){case 42:r=0;break;case 63:r=1;break;case 58:r=-1;break;case 12:r=t;break;case 48:r=n;break;case 13:r=~t;break;case 49:r=~n;break;case 15:r=-t;break;case 51:r=-n;break;case 31:r=t+1;break;case 55:r=n+1;break;case 14:r=t-1;break;case 50:r=n-1;break;case 2:r=t+n;break;case 19:r=t-n;break;case 7:r=n-t;break;case 0:r=t&n;break;case 21:r=t|n}r&=65535;return[r,0===r?h.Zero:32768&r?h.Negative:h.Positive]}function m(e,t,n){32&e&&(t=0),16&e&&(t=65535&~t),8&e&&(n=0),4&e&&(n=65535&~n);let r=65535&(2&e?t+n:t&n);1&e&&(r=65535&~r);return[r,0===r?h.Zero:32768&r?h.Negative:h.Positive]}},7721:(e,t,n)=>{n.d(t,{D4:()=>o,I8:()=>u,Z8:()=>c,gV:()=>l,p$:()=>s});var r=n(8739),i=n(7076);function s(){return{A:0,D:0,PC:0,ALU:0,flag:r.iI.Zero}}const a={c:32768,x1:36864,x2:36864,am:36864,op:4032,d1:32800,d2:32784,d3:32776,j1:32769,j2:32770,j3:32772};function o(e){function t(t){return(e&t)===t}return{c:t(a.c),x1:t(a.x1),x2:t(a.x2),am:t(a.am),op:(e&a.op)>>6,d1:t(a.d1),d2:t(a.d2),d3:t(a.d3),j1:t(a.j1),j2:t(a.j2),j3:t(a.j3)}}function l({inM:e,instruction:t},{A:n,D:i,PC:s}){const a=o(t),l=a.am?e:n,[u,c]=(0,r.v0)(a.op,i,l);return a.d2&&(i=u),[{A:n,D:i,PC:s+1,ALU:u,flag:c},a.d3,u]}function u({inM:e,instruction:t,reset:n},{A:i,D:s,PC:a,ALU:l,flag:u}){const c=o(t),p=c.j1&&u===r.iI.Positive,d=c.j2&&u===r.iI.Zero,h=c.j3&&u===r.iI.Negative;a=n?0:p||d||h?i:a,c.c?c.d1&&(i=l):i=32767&t;const f=c.am?e:i,m=(0,r.v0)(c.op,s,f);l=m[0],u=m[1];return[{addressM:i,outM:l,writeM:c.d3},{A:i,D:s,ALU:l,flag:u,PC:a}]}class c{RAM;ROM;Screen;Keyboard;#e=0;#t=0;#n=0;#r={A:0,D:0,PC:0,ALU:0,flag:r.iI.Zero};get state(){return this.#r}get PC(){return this.#e}get A(){return this.#t}get D(){return this.#n}setA(e){this.#t=e}setD(e){this.#n=e}setPC(e){this.#e=e}constructor({RAM:e=new i.XK,ROM:t}){this.RAM=e,this.ROM=t,this.Screen=new i.qN(this.RAM,i.RL,i.L7),this.Keyboard=new i.PC(this.RAM)}reset(){this.#e=0,this.#t=0,this.#n=0}tick(){const e=this.#t,t={inM:this.RAM.get(this.#t),instruction:this.ROM.get(this.#e),reset:!1},[n,i,s]=l(t,{A:this.#t,D:this.#n,PC:this.#e,ALU:this.#n,flag:r.iI.Zero});i&&this.RAM.set(e,s);const[a,{A:o,D:c,PC:p}]=u(t,n);this.#t=o,this.#n=c,this.#e=p}}},7076:(e,t,n)=>{n.d(t,{L7:()=>l,PC:()=>m,RL:()=>p,XK:()=>y,ce:()=>h,dh:()=>u,hR:()=>o,ky:()=>d,n9:()=>g,pc:()=>c,qN:()=>f});var r=n(2469),i=n(6983),s=n(7496),a=n(7844);const o=["bin","dec","hex","asm"],l=16384,u=256,c=32,p=u*c,d=24576;class h{memory;get size(){return this.memory.length}constructor(e){this.memory=new Int16Array(e)}get(e){return e<0||e>=this.size?65535:this.memory[e]??0}set(e,t){e>=0&&et))}}class f{parent;size;offset;constructor(e,t,n){this.parent=e,this.size=t,this.offset=n}get(e){return e<0||e>=this.size?65535:this.parent.get(this.offset+e)}set(e,t,n=!0){e>=0&&e=0&&et))}}class m extends f{constructor(e){super(e,1,24576)}getKey(){return this.get(0)}setKey(e){this.set(0,65535&e)}clearKey(){this.set(0,0)}}class g extends h{static SIZE=32768;constructor(e){if(e){const t=new Int16Array(g.SIZE);t.set(e),super(t)}else super(g.SIZE)}}class y extends h{keyboard=new f(this,1,d);screen=new f(this,p,l);static SIZE=24577;constructor(){super(y.SIZE)}}},6983:(e,t,n)=>{n.d(t,{Hh:()=>i});var r=n(9547);async function i(e,t){if(t.endsWith(".hack"))return async function(e,t){return r.aU(await e.readFile(t))}(e,t);if(t.endsWith(".asm"))return async function(e,t){return r.aY(await e.readFile(t))}(e,t);throw new Error(`Cannot load file without hack or asm extension ${t}`)}},4666:(e,t,n)=>{n.d(t,{y0:()=>b,EU:()=>f,J$:()=>d,ld:()=>m});var r=n(2469),i=n(8739),s=n(7076),a=n(7496),o=n(3977),l=n(5874);const u='ASM <: Base {\n Root := ASM\n ASM = intermediateInstruction* instruction?\n \n instruction = label|aInstruction|cInstruction\n intermediateInstruction = instruction space+\n\n label = openParen identifier closeParen\n aInstruction = at (identifier | decNumber)\n cInstruction = assign? op jmp?\n\n assignChar = "A" | "M" | "D"\n opChar = assignChar | "0" | "1" | "!" | "-" | "+" | "|" | "&"\n \n assign = assignChar+ equal\n op = opChar+\n\n jmp = semi ("JGT" | "JEQ" | "JGE" | "JLT" | "JNE" | "JLE" | "JMP")\n}';const c=(0,n(9563).qN)(u,o.lN),p=c.extendSemantics(o.JE);function d(e){return"A"==e.type&&void 0!==e.value}function h(e){return"A"==e.type&&void 0!==e.label}function f(e,t){let n=16;const i=new Map([["R0",0],["R1",1],["R2",2],["R3",3],["R4",4],["R5",5],["R6",6],["R7",7],["R8",8],["R9",9],["R10",10],["R11",11],["R12",12],["R13",13],["R14",14],["R15",15],["SP",0],["LCL",1],["ARG",2],["THIS",3],["THAT",4],["SCREEN",s.L7],["KBD",s.ky]]);const a=[];let u=0;for(const r of e.instructions)if("L"!==r.type)u+=1,"A"===r.type&&h(r)&&a.push(r);else{if(i.has(r.label))return(0,l._)((0,o.$5)(`Duplicate label ${r.label}`,r.span));i.set(r.label,u),t?.(r.label,u,!1)}return a.forEach((function(e){const s=(a=e.label,i.has(a)||(i.set(a,n),t?.(a,n,!0),n+=1),(0,r.Z1)(i.get(a),`Label not in symbols: ${a}`));var a;e.value=s,delete e.label})),(0,l.Ok)()}p.addAttribute("root",{Root(e){return this.asm}}),p.addAttribute("asm",{ASM(e,t){const n=e.children.map((e=>e.intermediateInstruction))??[];return{instructions:t.child(0)?[...n,t.child(0).instruction]:n}}}),p.addAttribute("intermediateInstruction",{intermediateInstruction:(e,t)=>e.instruction}),p.addAttribute("instruction",{aInstruction(e,t){return g(t.value,(0,o.Ln)(this.source))},cInstruction(e,t,n){const r=function(e){let t=e.child(0)?.child(0)?.sourceString??"";if("DM"==t&&(t="MD"),"ADM"==t&&(t="AMD"),""!=t&&!(0,i.Nt)(t)){const n=t.split("").reverse().join(""),r=(0,i.Nt)(n)?`. Did you mean ${n}?`:"";throw(0,o.$5)(`Invalid ASM target: ${t}${r}`,(0,o.Ln)(e.source))}return t}(e),s=function(e){const t=e.sourceString;if(!(0,i.nf)(t)){const n=t.split("").reverse().join(""),r=(0,i.nf)(n)?`. Did you mean ${n}?`:"";throw(0,o.$5)(`Invalid ASM value: ${e.sourceString}${r}`,(0,o.Ln)(e.source))}return t}(t),a=n.child(0)?.child(1)?.sourceString??"";return y(r,s,a,(0,o.Ln)(this.source))},label(e,{name:t},n){return v(t,(0,o.Ln)(this.source))}});function m(e){if("A"===e.type){if(h(e))throw new Error("ASM Emitting unfilled A instruction");return e.value}if("C"===e.type)return(0,a.m)(e.isM,e.op,e.store??0,e.jump??0)}const g=(e,t)=>"string"===typeof e?{type:"A",label:e,span:t}:{type:"A",value:e,span:t},y=(e,t,n,r)=>{const s={type:"C",op:i.Lo.getOp(t),isM:t.includes("M"),span:r};return n&&(s.jump=i.ft.asm[n]),e&&(s.store=i.uW.asm[e]),s},v=(e,t)=>({type:"L",label:e,span:t}),b={grammar:u,semantics:p,parser:c,parse:(0,o.Q5)(c,p),passes:{fillLabel:f,emit:function(e){return e.instructions.map(m).filter((e=>void 0!==e))}},A:g,C:y,AC:(e,t,n,r)=>[g(e),y(t,n,r)],L:v}},3977:(e,t,n)=>{n.d(t,{JE:()=>o,$5:()=>u,lN:()=>a,Q5:()=>c,Ln:()=>p});var r=n(5874),i=n(9563),s=n(7844);const a={Base:(0,i.qN)('\nBase {\n Root = Value*\n\n At = at\n Bang = bang\n Bar = bar\n CloseAngle = closeAngle\n CloseBrace = closeBrace\n CloseParen = closeParen\n CloseSquare = closeSquare\n Comma = comma\n Dollar = dollar\n Dot = dot\n DoubleQuote = doubleQuote\n Equal = equal\n OpenAngle = openAngle\n OpenBrace = openBrace\n OpenParen = openParen\n OpenSquare = openSquare\n Percent = percent\n Semi = semi\n Underscore = underscore\n\n at = "@"\n bang = "!"\n bar = "|"\n closeAngle = ">"\n closeBrace = "}"\n closeParen = ")"\n closeSquare = "]"\n comma = ","\n dollar = "$"\n dot = "."\n doubleQuote = "\\""\n equal = "="\n minus = "-"\n newline = "\\r"? "\\n"\n openAngle = "<"\n openBrace = "{"\n openParen = "("\n openSquare = "["\n percent = "%"\n semi = ";"\n underscore = "_"\n\n Value = identifier | number | boolean\n\n boolean = true | false\n True = true\n False = false\n true = "true"\n false = "false"\n\n Name = identifier\n identifier = (letter|underscore|dot|dollar) (alnum|underscore|dot|dollar)*\n\n Number = number\n number = hexNumber | decNumber | binNumber\n binNumber = ("%B") ("0"|"1")+\n hexNumber = ("%X") hexDigit+\n decNumber = ("%D")? (wholeDec | realDec)\n wholeDec = minus? digit+\n realDec = minus? digit* "." digit+\n\n String = DoubleQuote (~doubleQuote any)* doubleQuote\n \n spaces := (lineComment | comment | space)*\n commentStart = "/*"\n commentEnd = "*/"\n comment = commentStart (~commentEnd any)* commentEnd\n lineCommentStart = "//"\n lineComment = lineCommentStart (~"\\n" any)*\n\n List = NonemptyListOf sep?\n EmptyList = EmptyList sep?\n}')},o=a.Base.createSemantics();o.extendOperation("asIteration",{List:(e,t)=>e.asIteration()}),o.addAttribute("value",{decNumber:(e,t)=>(0,s.ZR)(t.sourceString),wholeDec:(e,t)=>(0,s.ZR)(t.sourceString),binNumber:(e,t)=>(0,s.Yp)(t.sourceString),hexNumber:(e,t)=>(0,s.l8)(t.sourceString),Number:e=>e.value,Name:e=>e.name,identifier(e,t){return this.sourceString}}),o.addAttribute("name",{identifier(e,t){return this.sourceString},Name(e){return this.child(0)?.name}}),o.addAttribute("String",{String:(e,t,n)=>t.sourceString});const l="HDL statement has a syntax error";function u(e,t){const n=e.match(/Line \d+, col \d+: (?.*)/),r=n?.groups?.message?n.groups.message:e;return{message:`${void 0!=t?.line?`Line ${t.line}: `:""}${r}`,span:t}}function c(e,t,n=(({root:e})=>e)){return function(i){try{const s=e.match(i);if(s.succeeded()){const e=t(s),i=n(e);return(0,r.Ok)(i)}return(0,r._)(u(s.shortMessage??l,p(s.getInterval())))}catch(s){return(0,r._)(s)}}}function p(e){return{start:e.startIdx,end:e.endIdx,line:e.getLineAndColumn().lineNum}}},7589:(e,t,n)=>{n.d(t,{dl:()=>l});var r=n(9563),i=n(3977);const s="\nCmp <: Base {\n Root := line*\n line = bar cell+ newline?\n cell = cellvalue bar\n cellvalue = (~(bar|newline) any)*\n}",a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.addAttribute("cell",{cell:(e,t)=>e.sourceString}),o.addAttribute("line",{line:(e,t,n)=>t.children.map((e=>e.cell))}),o.addAttribute("root",{Root:e=>e.children.map((e=>e.line))});const l={grammar:s,semantics:o,parser:a,parse:(0,i.Q5)(a,o)}},5005:(e,t,n)=>{n.d(t,{xP:()=>l});var r=n(9563),i=n(3977);const s='\nHdl <: Base{\n Root := Chip\n identifier := (letter|underscore) (alnum|underscore)*\n Name := identifier\n Chip = "CHIP" Name OpenBrace ChipBody CloseBrace\n ChipBody = InList? OutList? PartList ClockedList?\n InList = "IN" PinList Semi\n OutList = "OUT" PinList Semi\n PartList = BuiltinPart | Parts\n PinList = List\n PinDecl = Name PinWidth?\n PinWidth = OpenSquare decNumber CloseSquare\n BuiltinPart = "BUILTIN" Semi\n Parts = "PARTS:" Part*\n Part = Name "(" Wires ")" Semi\n Wires = List\n Wire = WireSide Equal (WireSide | True | False) \n WireSide = Name SubBus? \n SubBus = OpenSquare decNumber subBusRest? CloseSquare\n subBusRest = ".." decNumber\n ClockedList = "CLOCKED" SimplePinList Semi\n SimplePinList = List\n}',a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.addAttribute("SubBus",{SubBus(e,t,n,r){const i=t.value;return{start:i,end:n.child(0)?.child(1)?.value??i}}}),o.addAttribute("WireSide",{WireSide({name:e},t){const{start:n,end:r}=t.child(0)?.SubBus??{start:void 0,end:void 0};return{pin:e,start:n,end:r,span:(0,i.Ln)(this.source)}}}),o.addAttribute("Wire",{Wire(e,t,n){const r=n.isTerminal()?{pin:n.sourceString}:n.WireSide;return{lhs:e.WireSide,rhs:r}}}),o.addAttribute("Wires",{Wires:e=>e.asIteration().children.map((e=>e.Wire))}),o.addAttribute("Part",{Part({name:e},t,{Wires:n},r,s){return{name:e,wires:n,span:(0,i.Ln)(this.source)}}}),o.addAttribute("Parts",{Parts:(e,t)=>t.children.map((e=>e.Part)),BuiltinPart:(e,t)=>"BUILTIN"}),o.addAttribute("PartList",{PartList:e=>e.Parts}),o.addAttribute("Clocked",{ClockedList:(e,t,n)=>t.asIteration().children.map((({sourceString:e})=>e))??[]}),o.addAttribute("PinDecl",{PinDecl:({name:e},t)=>({pin:e,width:t.child(0)?.child(1)?.value??1})}),o.addAttribute("PinList",{PinList:e=>e.asIteration().children.map((e=>e.PinDecl))}),o.addAttribute("Chip",{Chip:(e,t,n,r,s)=>({name:{value:t.sourceString,span:(0,i.Ln)(t.source)},ins:r.child(0).child(0)?.child(1)?.PinList??[],outs:r.child(1).child(0)?.child(1)?.PinList??[],parts:r.child(2).PartList??[],clocked:r.child(3).child(0)?.Clocked})}),o.addAttribute("Root",{Root:e=>e.child(0)?.Chip});const l={parser:a,grammar:s,semantics:o,parse:(0,i.Q5)(a,o,(e=>e.Chip))}},6554:(e,t,n)=>{n.d(t,{uG:()=>l});var r=n(9563),i=n(3977);const s='\nTst <: Base {\n Root := Tst\n Tst = (TstStatement | TstRepeat | TstWhile)+\n\n TstRepeat = Repeat Number? OpenBrace TstCommand+ CloseBrace\n TstWhile = While Condition OpenBrace TstCommand+ CloseBrace\n TstStatement = TstCommand\n\n TstCommand = TstOperation Separator\n Separator = (Semi | Bang | Comma)\n\n TstOperation =\n | TstFileOperation\n | TstOutputListOperation\n | TstEvalOperation\n | TstSetOperation\n | TstOutputOperation\n | TstEchoOperation\n | TstClearEchoOperation\n | TstLoadROMOperation\n\n TstLoadROMOperation = ROM32K Load FileName\n TstFileOperation = FileOperation FileName?\n TstOutputListOperation = "output-list" OutputFormat+\n OutputFormat = Name Index? FormatSpec?\n FormatSpec = percent FormatStyle wholeDec dot wholeDec dot wholeDec\n TstSetOperation = Set Name Index? Number\n Index = OpenSquare wholeDec? CloseSquare\n Condition = Value CompareOp Value\n TstEvalOperation = Eval | TickTock | Tick | Tock | VmStep\n TstOutputOperation = Output\n TstEchoOperation = Echo String\n TstClearEchoOperation = ClearEcho\n\n FileName = Name\n FileOperation = "load" | "output-file" | "compare-to"\n\n Set = "set"\n Eval = "eval"\n Tick = "tick"\n Tock = "tock"\n TickTock = "ticktock"\n VmStep = "vmstep"\n Echo = "echo"\n Repeat = "repeat"\n ClearEcho = "clear-echo"\n Output = "output"\n OutputList = "output-list"\n FormatStyle = "B"|"D"|"S"|"X"\n ROM32K = "ROM32K"\n Load = "load"\n While = "while"\n\n CompareOp = "<>" | "<=" | ">=" | "=" | "<" | ">"\n}',a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.extendAttribute("value",{Index:(e,t,n)=>t?.child(0)?.value??-1}),o.extendAttribute("name",{FileName:({name:e})=>e}),o.addAttribute("index",{Index:(e,t,n)=>t.child(0)?.value??0}),o.addAttribute("formatSpec",{FormatSpec:(e,{sourceString:t},{value:n},r,{value:i},s,{value:a})=>({style:t,width:i,lpad:n,rpad:a})}),o.addAttribute("format",{OutputFormat:({name:e},t,n)=>({id:e,builtin:void 0!==t?.child(0),address:t?.child(0)?.value??-1,format:n?.child(0)?.formatSpec})}),o.addAttribute("operation",{TstEvalOperation:e=>({op:e.sourceString}),TstOutputOperation:e=>({op:"output"}),TstOutputListOperation:(e,t)=>({op:"output-list",spec:t.children.map((e=>e.format))}),TstSetOperation(e,{name:t},n,{value:r}){const i={op:"set",id:t,value:r},s=n.child(0)?.child(1)?.child(0);return s&&(i.index=s.value),i},TstEchoOperation:(e,t)=>({op:"echo",message:t.String}),TstClearEchoOperation:e=>({op:"clear-echo"}),TstLoadROMOperation:(e,t,{name:n})=>({op:"loadRom",file:n}),TstFileOperation:(e,t)=>({op:e.sourceString,file:t?.sourceString})}),o.addAttribute("command",{TstCommand(e,t){return{op:e.operation,separator:t.sourceString,span:(0,i.Ln)(this.source)}}}),o.addAttribute("condition",{Condition:({value:e},{sourceString:t},{value:n})=>({left:e,right:n,op:t})}),o.addAttribute("statement",{TstWhile(e,t,n,r,s){return{statements:r.children.map((e=>e.command)),condition:t.condition,span:(0,i.Ln)(this.source)}},TstRepeat(e,t,n,r,s){return{statements:r.children.map((e=>e.command)),count:t.sourceString?Number(t.sourceString):-1,span:(0,i.Ln)(this.source)}},TstStatement:e=>e.command}),o.addAttribute("tst",{Tst:e=>({lines:e.children.map((e=>e.statement))})}),o.addAttribute("root",{Root:({tst:e})=>e});const l={grammar:s,semantics:o,parser:a,parse:(0,i.Q5)(a,o)}},9547:(e,t,n)=>{n.d(t,{aU:()=>o,aY:()=>a,yt:()=>l});var r=n(5874),i=n(4666),s=n(7844);async function a(e){const t=(0,r.oA)(i.y0.parse(e));return i.y0.passes.fillLabel(t),i.y0.passes.emit(t)}async function o(e){return e.split("\n").filter((e=>""!==e.trim())).map(s.Yp)}async function l(e){return e.split("\n").filter((e=>""!==e.trim())).map(s._Q)}},9976:(e,t,n)=>{n.d(t,{G:()=>p});var r=n(2469),i=n(1106),s=n(6418),a=n(4867),o=n(8783);function l(e){return void 0!==e.op}function u(e){return void 0!==e.condition}function c(e){const{op:t}=e;switch(t){case"tick":return new i.IJ;case"tock":return new i.CX;case"ticktock":return new s.z;case"eval":return new i.Nq;case"vmstep":return new o.a;case"output":return new a.ik;case"set":return new a.jl(e.id,e.value,e.index);case"output-list":return new a.Ad(e.spec);case"echo":return new a.S0(e.message);case"clear-echo":return new a.Tn;case"loadRom":return new a.fK(e.file);case"load":return new a.hh(e.file);case"output-file":case"compare-to":return;default:(0,r.H8)(t,`Unknown tst operation ${t}`)}}function p(e,t){let n,r=[],i=e,s=[];for(const o of t.lines){if(l(o))i=e,s=[o];else{const t=u(o)?new a.eB(new a.kW(o.condition.left,o.condition.right,o.condition.op)):new a.UM(o.count);t.span=o.span,e.addInstruction(t),i=t,s=o.statements}for(const e of s){const t=c(e.op);if(void 0!==t&&(void 0===n?n=o.span:n.end=o.span.end,i.addInstruction(t),r.push(t)),","!=e.separator){";"==e.separator?i.addInstruction(new a.fe(n??e.span)):"!"==e.separator&&i.addInstruction(new a.Ge(n??e.span));for(const t of r)t.span=n??e.span;n=void 0,r=[]}}}return e.reset(),e}},1106:(e,t,n)=>{n.d(t,{BX:()=>o,CX:()=>c,IJ:()=>u,Nq:()=>l});var r=n(9651),i=n(1164),s=n(9976),a=n(9937);class o extends a.V{chip=new r.ti;get chipId(){return this.chip.id}clock=i.z.get();static from(e,t){const n=new o(t);return(0,s.G)(n,e)}with(e){return this.chip=e,this}hasVar(e){return"time"===e||(e=`${e}`,this.chip.hasIn(e)||this.chip.hasOut(e))}getVar(e,t){if("time"===(e=`${e}`))return this.clock.toString();const n=this.chip.get(e,t);return n?n instanceof r.z7?n.busVoltage:n.voltage():0}getWidth(e,t){const n=this.chip.get(e,t);return n?n.width:0}setVar(e,t,n){const i=this.chip.get(e,n);i instanceof r.z7?i.busVoltage=t:i?.pull(0===t?r.$L:r.RY)}eval(){this.chip.eval()}tick(){this.chip.eval(),this.clock.tick()}tock(){this.chip.eval(),this.clock.tock()}async loadROM(e){await this.chip.load(this.fs,e)}async run(){this.clock.reset(),await super.run()}}class l{_chipTestInstruction_=!0;async do(e){e.eval()}*steps(){yield this}}class u{_chipTestInstruction_=!0;async do(e){e.tick()}*steps(){yield this}}class c{_chipTestInstruction_=!0;async do(e){e.tock()}*steps(){yield this}}},6418:(e,t,n)=>{n.d(t,{b:()=>o,z:()=>l});var r=n(7721),i=n(7076),s=n(9976),a=n(9937);class o extends a.V{cpu;ticks=0;static from(e,t,n){const r=new o(t,n);return(0,s.G)(r,e)}constructor(e=new i.n9,t){super(t),this.cpu=new r.Z8({ROM:e}),this.reset()}reset(){return super.reset(),this.cpu.reset(),this.ticks=0,this}hasVar(e){return"number"!==typeof e&&!("A"!==e&&"D"!==e&&"PC"!==e&&"time"!==e&&!e.startsWith("RAM"))}getVar(e,t){switch(e){case"A":return this.cpu.A;case"D":return this.cpu.D;case"PC":return this.cpu.PC;case"time":return this.ticks;case"RAM":return void 0===t?0:this.cpu.RAM.get(t)}if("number"===typeof e)return 0;if(e.startsWith("RAM")){const t=Number(e.substring(4,e.length-1));return this.cpu.RAM.get(t)}return 0}getWidth(e,t){return 16}setVar(e,t,n){switch(e){case"A":this.cpu.setA(t);break;case"D":this.cpu.setD(t);break;case"PC":this.cpu.setPC(t);break;case"RAM":this.cpu.RAM.set(n??0,t)}}ticktock(){this.ticks+=1,this.cpu.tick()}async loadROM(e){await this.cpu.ROM.load(this.fs,e)}}class l{_cpuTestInstruction_=!0;async do(e){e.ticktock()}*steps(){yield this}}},4867:(e,t,n)=>{n.d(t,{Ad:()=>l,Ge:()=>s,S0:()=>h,Tn:()=>f,UM:()=>c,eB:()=>d,fK:()=>m,fe:()=>i,hh:()=>g,ik:()=>o,jl:()=>a,kW:()=>p});class r{span;constructor(e){this.span=e}async do(){}*steps(){yield this}}class i extends r{}class s extends r{}class a{variable;value;index;constructor(e,t,n){this.variable=e,this.value=t,this.index=n}async do(e){e.setVar(this.variable,this.value,this.index)}*steps(){yield this}}class o{async do(e){e.output()}*steps(){yield this}}class l{outputs=[];constructor(e=[]){for(const t of e)this.addOutput(t)}addOutput(e){this.outputs.push({id:e.id,style:e.format?.style??"B",len:e.format?.width??-1,lpad:e.format?.lpad??1,rpad:e.format?.rpad??1,builtin:e.builtin,address:e.address})}async do(e){e.outputList(this.outputs),e.header()}*steps(){yield this}}class u{instructions=[];span;addInstruction(e){this.instructions.push(e)}async do(e){for(const t of this.instructions)t.do(e)}*steps(e){yield this}}class c extends u{repeat;constructor(e){super(),this.repeat=e}async do(){}*innerSteps(e){for(const t of this.instructions)yield*t.steps(e)}*steps(e){if(-1===this.repeat)for(yield this;;)yield*this.innerSteps(e);else for(let t=0;t":return`${t}`!==`${n}`}else switch(this.op){case"<":return t":return t>n;case">=":return t>=n;case"=":return t===n;case"<>":return t!==n}return!1}}class d extends u{condition;constructor(e){super(),this.condition=e}*steps(e){for(;this.condition.check(e);){yield this;for(const t of this.instructions)yield*t.steps(e)}}}class h{content;constructor(e){this.content=e}async do(e){e.echo(this.content)}*steps(){yield this}}class f{async do(e){e.clearEcho()}*steps(){yield this}}class m{file;constructor(e){this.file=e}async do(e){e.fs.pushd("/samples"),await e.loadROM(this.file),e.fs.popd()}*steps(){yield this}}class g{file;constructor(e){this.file=e}async do(e){await e.load(this.file)}*steps(){yield this}}},9937:(e,t,n)=>{n.d(t,{V:()=>l});var r=n(2469),i=n(4544),s=n(7844);class a{variable;fmt;lPad;rPad;len;index;builtin;constructor(e,t="%B1.1.1",n,i,s,a,o){if(this.variable=e,t.startsWith("%")&&void 0===n&&void 0===i&&void 0===s){const{fmt:e,lPad:n,rPad:r,len:i}=t.match(/^%(?[BDXS])(?\d+)\.(?\d+)\.(?\d+)$/)?.groups;this.fmt=e,this.lPad=parseInt(n),this.rPad=parseInt(r),this.len=parseInt(i),this.builtin=!1,this.index=-1}else(0,r.vA)(["B","X","D","S"].includes(t[0])),this.fmt=t[0],this.len=n??3,this.lPad=i??1,this.rPad=s??1,this.builtin=a??!1,this.index=o??-1}header(e){let t=`${this.variable}`;if(this.builtin){t=`${t}[${this.index>=0?this.index:""}]`}return t.length>this.len+this.lPad+this.rPad?t.substring(0,this.len+this.lPad+this.rPad):this.padCenter(t)}print(e){const t=e.getVar(this.variable,this.index);if("S"===this.fmt)return this.padLeft(t);const n=(0,{B:s.e5,D:s.FN,X:s.uh}[this.fmt])(t);return"D"===this.fmt?this.padRight(n):this.padLeft(n.slice(n.length-this.len))}padCenter(e){const t=this.lPad+this.len+this.rPad,n=Math.floor((t-e.length)/2),r=t-n-e.length,i=n+e.length,s=i+r;return e=(e=e.padStart(i)).padEnd(s)}padLeft(e){e=e.substring(0,this.len);const t=this.rPad+this.len,n=this.lPad+t;return e=(e=e.padEnd(t)).padStart(n)}padRight(e){e=e.substring(0,this.len);const t=this.lPad+this.len,n=this.rPad+t;return e=(e=e.padStart(t)).padEnd(n)}}var o=n(4867);class l{instructions=[];_outputList=[];_log="";fs=new i.Q2;doEcho;constructor(e){this.doEcho=e}setFileSystem(e){return this.fs=e,this}echo(e){this.doEcho?.(e)}clearEcho(){this.doEcho?.("")}async loadROM(e){}async load(e){}async compareTo(e){}outputFile(e){}createOutputs(e){return e.map((e=>{if(-1===e.len)if("time"===e.id)e.len=7,e.style="S";else{const t=this.getWidth(e.id,e.address);"B"===e.style?e.len=t:"D"===e.style?e.len=Math.ceil(Math.log(t)):"X"===e.style&&(e.len=Math.ceil(t/4))}return new a(e.id,e.style,e.len,e.lpad,e.rpad,e.builtin,e.address)}))}outputList(e){this._outputList=this.createOutputs(e)}addInstruction(e){this.instructions.push(e)}reset(){return this._steps=function*(e){for(const t of e.instructions)yield*t.steps(e)}(this),this._step=this._steps.next(),this._log="",this}_steps;_step;get steps(){return void 0===this._steps&&(this.reset(),this._steps=(0,r.Z1)(this._steps,"Reset did not initialize steps"),this._step=(0,r.Z1)(this._step,"Reset did not find first step")),this._steps}get currentStep(){return this._step?.value}get done(){return this._step?.done??!1}async step(){for(;!this._step.done;){if(await this._step.value.do(this),this._step=this.steps.next(),this._step.value instanceof o.fe)return this._step=this.steps.next(),!1;if(this._step.value instanceof o.Ge)return!0}return!0}async run(){for(this.reset();!await this.step(););}breakpoints=new Map;addBreakpoint(e,t){this.breakpoints.set(e,t)}clearBreakpoints(){this.breakpoints.clear()}output(){const e=this._outputList.map((e=>e.print(this)));this._log+=`|${e.join("|")}|\n`}header(){const e=this._outputList.map((e=>e.header(this)));this._log+=`|${e.join("|")}|\n`}log(){return this._log}}},8783:(e,t,n)=>{n.d(t,{Y:()=>o,a:()=>l});var r=n(7076),i=n(5087),s=n(9976),a=n(9937);class o extends a.V{vm=new i.Vm;loadAction;dir;static from(e,t,n,r){const i=new o(r);return i.dir=t?.split("/").slice(0,-1).join("/"),i.loadAction=n,(0,s.G)(i,e)}using(e){return this.fs=e,this}with(e){return this.vm=e,this}hasVar(e,t){return"string"!==typeof e&&(t=e,e="RAM"),"RAM"===e&&void 0!==t&&t>0&&t{n.d(t,{k:()=>i,m:()=>a,op:()=>s});var r=n(8739);function i(e){return 32768&e?function(e){e&=65535;const t=(4096&e)>>12,n=(4032&e)>>6,i=(56&e)>>3,s=7&e;if(void 0===r.Lo.op[n])return"#ERR";let a=r.Lo.op[n];t&&(a=a.replace(/A/g,"M"));const o=r.uW.op[i],l=r.ft.op[s];let u=a;o&&(u=`${o}=${u}`);l&&(u=`${u};${l}`);return u}(e):function(e){return"@"+(32767&e).toString(10)}(e)}function s(e){return"@"===e[0]?function(e){return parseInt(e.substring(1),10)}(e):function(e){const t=e.match(/(?:(?.+)=)?(.+)(?:;(?.+))?/),{assignExists:n,jumpExists:i}=t?.groups??{},s=e.match(/(?:(?[AMD]{1,3})=)?(?[-+!01ADM&|]{1,3})(?:;(?JGT|JLT|JGE|JLE|JEQ|JMP))?/);let{assign:o,jump:l}=s?.groups??{};const{operation:u}=s?.groups??{};if(o=o??(n?void 0:""),l=l??(i?void 0:""),s?.[0]!=e||!(0,r.Nt)(o)||!(0,r.Qv)(l)||!(0,r.nf)(u))throw new Error("Invalid c instruction");const c=u.includes("M"),p=r.uW.asm[o],d=r.ft.asm[l],h=r.Lo.getOp(u);return a(c,h,p,d)}(e)}function a(e,t,n,r){return 57344+(e?4096:0)+(t<<6)+(n<<3)+r}},7844:(e,t,n)=>{n.d(t,{FN:()=>h,Yp:()=>u,ZR:()=>l,_Q:()=>c,ad:()=>f,e5:()=>d,l8:()=>o,uh:()=>p,xu:()=>m});const r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];function i(e){return r[e]??"X"}function s(e){switch(e){case 0:return"0000";case 1:return"0001";case 2:return"0010";case 3:return"0011";case 4:return"0100";case 5:return"0101";case 6:return"0110";case 7:return"0111";case 8:return"1000";case 9:return"1001";case 10:return"1010";case 11:return"1011";case 12:return"1100";case 13:return"1101";case 14:return"1110";case 15:return"1111";default:return"erro"}}function a(e,t){return 65535&parseInt(e.replace(/[^\d a-f A-F +-.]/g,""),t)}function o(e){return a(e,16)}function l(e){return a(e,10)}function u(e){return a(e.replaceAll(" ",""),2)}function c(e){return e.toUpperCase().includes("X")?o(e):l(e)}function p(e){return`0x${i((61440&e)>>12)}${i((3840&e)>>8)}${i((240&e)>>4)}${i(15&e)}`}function d(e,t=16){return`${s((61440&e)>>12)}${s((3840&e)>>8)}${s((240&e)>>4)}${s(15&e)}`.substring(16-t)}function h(e){return 32768===(e&=65535)?"-32768":32768&e?`-${e=1+~e&32767}`:`${e}`}function f(e){return`${e&=65535}`}function m(e,t){let n=~((e&=65535)&(t&=65535));return n&=65535,n}},2548:(e,t,n)=>{n.d(t,{P:()=>a});var r=n(270),i=n(8032);function s(e,t){const n=[];for(let r=0;r{const[n,r]=s(e,2);return n*r&65535},nArgs:2,type:"function"},"Math.divide":{func:(e,t)=>{const[n,i]=s(e,2);return 0==i?(t.sys.error(r.X.DIVIDE_BY_ZERO),0):65535&Math.floor(n/i)},nArgs:2,type:"function"},"Math.min":{func:(e,t)=>{const[n,r]=s(e,2);return 65535&Math.min(n,r)},nArgs:2,type:"function"},"Math.max":{func:(e,t)=>{const[n,r]=s(e,2);return 65535&Math.max(n,r)},nArgs:2,type:"function"},"Math.sqrt":{func:(e,t)=>{const[n]=s(e,1);return n<0?(t.sys.error(r.X.SQRT_NEG),0):65535&Math.floor(Math.sqrt(n))},nArgs:1,type:"function"},"Math.abs":{func:(e,t)=>{const[n]=s(e,1);return 65535&Math.abs(n)},nArgs:1,type:"function"},"Screen.clearScreen":{func:(e,t)=>(t.screen.clear(),0),nArgs:0,type:"function"},"Screen.setColor":{func:(e,t)=>{const[n]=s(e,1);return t.screen.color=0!==n,0},nArgs:1,type:"function"},"Screen.drawPixel":{func:(e,t)=>{const[n,r]=s(e,2);return t.screen.drawPixel(n,r),0},nArgs:2,type:"function"},"Screen.drawLine":{func:(e,t)=>{const[n,r,i,a]=s(e,4);return t.screen.drawLine(n,r,i,a),0},nArgs:4,type:"function"},"Screen.drawRectangle":{func:(e,t)=>{const[n,r,i,a]=s(e,4);return t.screen.drawRect(n,r,i,a),0},nArgs:4,type:"function"},"Screen.drawCircle":{func:(e,t)=>{const[n,r,i]=s(e,3);return t.screen.drawCircle(n,r,i),0},nArgs:3,type:"function"},"Memory.peek":{func:(e,t)=>{const[n]=s(e,1);return e.get(n)},nArgs:1,type:"function"},"Memory.poke":{func:(e,t)=>{const[n,r]=s(e,2);return e.set(n,r),0},nArgs:2,type:"function"},"Memory.alloc":{func:(e,t)=>{const[n]=s(e,1);return t.memory.alloc(n)},nArgs:1,type:"function"},"Memory.deAlloc":{func:(e,t)=>{const[n]=s(e,1);return t.memory.deAlloc(n),0},nArgs:1,type:"function"},"Array.new":{func:(e,t)=>{const[n]=s(e,1);return n<=0?(t.sys.error(r.X.ARRAY_SIZE_NOT_POSITIVE),0):t.memory.alloc(n)},nArgs:1,type:"constructor"},"Array.dispose":{func:(e,t)=>{const[n]=s(e,1);return t.memory.deAlloc(n),0},nArgs:1,type:"method"},"String.new":{func:(e,t)=>{const[n]=s(e,1);return t.string.new(n)},nArgs:1,type:"constructor"},"String.dispose":{func:(e,t)=>{const[n]=s(e,1);return t.string.dispose(n),0},nArgs:1,type:"method"},"String.length":{func:(e,t)=>{const[n]=s(e,1);return t.string.length(n)},nArgs:1,type:"method"},"String.charAt":{func:(e,t)=>{const[n,r]=s(e,2);return t.string.charAt(n,r)},nArgs:2,type:"method"},"String.setCharAt":{func:(e,t)=>{const[n,r,i]=s(e,3);return t.string.setCharAt(n,r,i),0},nArgs:3,type:"method"},"String.appendChar":{func:(e,t)=>{const[n,r]=s(e,2);return t.string.appendChar(n,r)},nArgs:2,type:"method"},"String.eraseLastChar":{func:(e,t)=>{const[n]=s(e,1);return t.string.eraseLastChar(n),0},nArgs:1,type:"method"},"String.intValue":{func:(e,t)=>{const[n]=s(e,1);return t.string.intValue(n)},nArgs:1,type:"method"},"String.setInt":{func:(e,t)=>{const[n,r]=s(e,2);return t.string.setInt(n,r),0},nArgs:2,type:"method"},"String.backSpace":{func:(e,t)=>i.G_,nArgs:0,type:"function"},"String.doubleQuote":{func:(e,t)=>i.MD,nArgs:0,type:"function"},"String.newLine":{func:(e,t)=>i.qK,nArgs:0,type:"function"},"Output.moveCursor":{func:(e,t)=>{const[n,r]=s(e,2);return t.output.moveCursor(n,r),0},nArgs:2,type:"function"},"Output.printChar":{func:(e,t)=>{const[n]=s(e,1);return t.output.printChar(n),0},nArgs:1,type:"function"},"Output.printString":{func:(e,t)=>{const[n]=s(e,1);return t.output.printString(n),0},nArgs:1,type:"function"},"Output.printInt":{func:(e,t)=>{const[n]=s(e,1);return t.output.printInt(n),0},nArgs:1,type:"function"},"Output.println":{func:(e,t)=>(t.output.println(),0),nArgs:0,type:"function"},"Output.backSpace":{func:(e,t)=>(t.output.backspace(),0),nArgs:0,type:"function"},"Keyboard.keyPressed":{func:(e,t)=>t.keyboard.keyPressed(),nArgs:0,type:"function"},"Keyboard.readChar":{func:(e,t)=>(t.keyboard.readChar(),0),nArgs:0,type:"function"},"Keyboard.readLine":{func:(e,t)=>{const[n]=s(e,1);return t.keyboard.readLine(n),0},nArgs:1,type:"function"},"Keyboard.readInt":{func:(e,t)=>{const[n]=s(e,1);return t.keyboard.readInt(n),0},nArgs:1,type:"function"},"Sys.halt":{func:(e,t)=>(t.sys.halt(),0),nArgs:0,type:"function"},"Sys.error":{func:(e,t)=>{const[n]=s(e,1);return t.sys.error(n),0},nArgs:1,type:"function"},"Sys.wait":{func:(e,t)=>{const[n]=s(e,1);return t.sys.wait(n),0},nArgs:1,type:"function"}}},270:(e,t,n)=>{var r;function i(e){return Object.values(r).includes(e)}n.d(t,{U:()=>i,X:()=>r}),function(e){e[e.SYS_WAIT_DURATION_NOT_POSITIVE=1]="SYS_WAIT_DURATION_NOT_POSITIVE",e[e.ARRAY_SIZE_NOT_POSITIVE=2]="ARRAY_SIZE_NOT_POSITIVE",e[e.DIVIDE_BY_ZERO=3]="DIVIDE_BY_ZERO",e[e.SQRT_NEG=4]="SQRT_NEG",e[e.ALLOC_SIZE_NOT_POSITIVE=5]="ALLOC_SIZE_NOT_POSITIVE",e[e.HEAP_OVERFLOW=6]="HEAP_OVERFLOW",e[e.ILLEGAL_PIXEL_COORD=7]="ILLEGAL_PIXEL_COORD",e[e.ILLEGAL_LINE_COORD=8]="ILLEGAL_LINE_COORD",e[e.ILLEGAL_RECT_COORD=9]="ILLEGAL_RECT_COORD",e[e.ILLEGAL_CENTER_COORD=12]="ILLEGAL_CENTER_COORD",e[e.ILLEGAL_RADIUS=13]="ILLEGAL_RADIUS",e[e.STRING_LENGTH_NEG=14]="STRING_LENGTH_NEG",e[e.GET_CHAR_INDEX_OUT_OF_BOUNDS=15]="GET_CHAR_INDEX_OUT_OF_BOUNDS",e[e.SET_CHAR_INDEX_OUT_OF_BOUNDS=16]="SET_CHAR_INDEX_OUT_OF_BOUNDS",e[e.STRING_FULL=17]="STRING_FULL",e[e.STRING_EMPTY=18]="STRING_EMPTY",e[e.STRING_INSUFFICIENT_CAPACITY=19]="STRING_INSUFFICIENT_CAPACITY",e[e.ILLEGAL_CURSOR_LOCATION=20]="ILLEGAL_CURSOR_LOCATION"}(r||(r={}))},8032:(e,t,n)=>{n.d(t,{Fz:()=>u,G_:()=>s,MD:()=>a,eY:()=>l,qK:()=>i});var r=n(270);const i=128,s=129,a=34;function o(e){return e-48}function l(e){return e.toString().split("").map((e=>e.charCodeAt(0)))}class u{memory;os;constructor(e,t){this.memory=e,this.os=t}new(e){e<=0&&this.os.sys.error(r.X.STRING_LENGTH_NEG);const t=this.os.memory.alloc(e+2);return this.os.sys.halted?0:(this.memory.set(t,e),this.memory.set(t+1,0),t)}dispose(e){this.os.memory.deAlloc(e)}maxLength(e){return this.memory.get(e)}length(e){return this.memory.get(e+1)}setLength(e,t){this.memory.set(e+1,t)}charAt(e,t){return t<0||t>=this.length(e)?(this.os.sys.error(r.X.GET_CHAR_INDEX_OUT_OF_BOUNDS),0):this.memory.get(e+t+2)}setCharAt(e,t,n){t<0||t>=this.length(e)?this.os.sys.error(r.X.SET_CHAR_INDEX_OUT_OF_BOUNDS):this.memory.set(e+t+2,n)}appendChar(e,t){const n=this.length(e);return n==this.maxLength(e)?(this.os.sys.error(r.X.STRING_FULL),0):(this.setLength(e,n+1),this.setCharAt(e,n,t),e)}eraseLastChar(e){const t=this.length(e);0!=t?this.setLength(e,t-1):this.os.sys.error(r.X.STRING_EMPTY)}intValue(e){const t=[],n=45==this.charAt(e,0);for(let s=n?1:0;s=48&&r<=57);s++)t.push(o(this.charAt(e,s)));var r;const i=t.reduce(((e,t)=>10*e+t),0);return n?-i:i}setInt(e,t){const n=l(t);if(n.length>this.maxLength(e))this.os.sys.error(r.X.STRING_INSUFFICIENT_CAPACITY);else{this.setLength(e,0);for(const t of n)this.appendChar(e,t)}}}},5087:(e,t,n)=>{n.d(t,{IG:()=>w,h0:()=>S,Vm:()=>x});var r=n(5874),i=n(3977),s=n(2548),a=n(7076);class o extends a.XK{strict=!0;get SP(){return this.get(0)}set SP(e){this.set(0,e)}get LCL(){return this.get(1)}set LCL(e){this.set(1,e)}get ARG(){return this.get(2)}set ARG(e){this.set(2,e)}get THIS(){return this.get(3)}set THIS(e){this.set(3,e)}get THAT(){return this.get(4)}set THAT(e){this.set(4,e)}get statics(){const e=[];for(let t=16;t<256;t++)e.push(this.get(t));return e}constructor(){super(),this.set(0,256)}baseSegment(e,t){if(this.strict&&(t<0||t>32767))return(0,r._)(new Error(`Illegal offset value ${t} (must be between 0 and 32767)`));switch(e){case"argument":return(0,r.Ok)(this.ARG+t);case"constant":return(0,r.Ok)(t);case"local":return(0,r.Ok)(this.LCL+t);case"pointer":if(this.strict&&t>1)throw new Error(`pointer out of bounds access (pointer can be 0 for this, 1 for that, but got ${t}`);return(0,r.Ok)(0===t?3:4);case"static":return this.strict&&t>239?(0,r._)(new Error(`Cannot access statics beyond 239: ${t}`)):(0,r.Ok)(16+t);case"temp":return this.strict&&t>7?(0,r._)(new Error(`Temp out of bounds access (temp can be 0 to 7, but got ${t}`)):(0,r.Ok)(5+t);case"that":return(0,r.Ok)(this.THAT+t);case"this":return(0,r.Ok)(this.THIS+t)}}getSegment(e,t){if("constant"===e){if(this.strict&&(t<0||t>32767))throw new Error(`Illegal offset value ${t} (must be between 0 and 32767)`);return t}const n=this.baseSegment(e,t);if((0,r.ys)(n))throw(0,r._)(n);return this.get((0,r.Ok)(n))}setSegment(e,t,n){const i=this.baseSegment(e,t);if((0,r.ys)(i))throw(0,r._)(i);this.set((0,r.Ok)(i),n)}argument(e){return this.getSegment("argument",e)}local(e){return this.getSegment("local",e)}static(e){return this.getSegment("static",e)}constant(e){return this.getSegment("constant",e)}this(e){return this.getSegment("this",e)}that(e){return this.getSegment("that",e)}pointer(e){return this.getSegment("pointer",e)}temp(e){return this.getSegment("temp",e)}push(e){const t=this.SP;this.set(t,e),this.set(0,t+1)}pop(){if(this.strict&&256===this.SP)throw new Error("Cannot pop the stack below 256 in strict mode");this.set(0,this.SP-1);return this.get(this.SP)}pushFrame(e,t,n){const r=this.SP,i=r-t;this.set(r,e),this.set(r+1,this.LCL),this.set(r+2,this.ARG),this.set(r+3,this.THIS),this.set(r+4,this.THAT),this.set(2,i),this.set(1,r+5);const s=r+5;for(let a=0;at),a,a+t)]},locals:{base:o,count:n,values:[...this.map(((e,t)=>t),o,o+n)]},stack:{base:l,count:u,values:[...this.map(((e,t)=>t),l,l+u)]},this:{base:l,count:r,values:[...this.map(((e,t)=>t),this.THIS,this.THIS+r)]},that:{base:l,count:i,values:[...this.map(((e,t)=>t),this.THAT,this.THAT+i)]},frame:{RET:this.get(e),LCL:this.LCL,ARG:this.ARG,THIS:this.THIS,THAT:this.THAT}}}getVmState(e=240){const t=[...this.map(((e,t)=>t),5,13)],n=[...this.map(((e,t)=>t),13,16)],r=[...this.map(((e,t)=>t),16,16+e)];return{"0: SP":this.SP,"1: LCL":this.LCL,"2: ARG":this.ARG,"3: THIS":this.THIS,"4: THAT":this.THAT,temps:t,internal:n,static:r}}binOp(e){const t=65535&e(this.get(this.SP-2),this.get(this.SP-1));this.set(this.SP-2,t),this.set(0,this.SP-1)}unOp(e){const t=65535&e(this.get(this.SP-1));this.set(this.SP-1,t)}comp(e){this.binOp(((t,n)=>e(t,n)?-1:0))}}var l=n(8032);class u{memory;os;animationFrameId=void 0;cancel=!1;constructor(e,t){this.memory=e,this.os=t}keyPressed(){return this.memory.get(a.ky)}readCharLoop(e){let t=!1,n=0;const r=()=>{if(this.cancel)return;let i=!1;this.os.paused||(t||0===this.keyPressed()||(t=!0,n=this.keyPressed()),t&&0===this.keyPressed()&&(i=!0,e(n))),i||(this.animationFrameId=requestAnimationFrame(r))};r()}readChar(){this.os.sys.block(),this.os.output.drawCursor(),new Promise((e=>{this.readCharLoop(e)})).then((e=>{this.os.output.printChar(e),this.os.sys.release(e)}))}readLineLoop(e){const t=this.os.string.new(100);this.os.sys.halted&&e(0);let n=!1,r=0;const i=()=>{if(this.cancel)return;let s=!1;this.os.paused||(n||0==this.keyPressed()||(n=!0,r=this.keyPressed()),n&&0==this.keyPressed()&&(n=!1,r==l.G_?(this.os.string.length(t)>0&&this.os.output.backspace(),this.os.string.eraseLastChar(t)):r==l.qK?(e(t),s=!0):(this.os.string.appendChar(t,r),this.os.sys.halted&&e(0),this.os.output.printChar(r),this.os.output.drawCursor()))),s||(this.animationFrameId=requestAnimationFrame(i))};i()}readLine(e){this.os.sys.block(),this.os.output.printString(e),this.os.output.drawCursor(),new Promise((e=>{this.readLineLoop(e)})).then((e=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(e)}))}readInt(e){this.os.sys.block(),this.os.output.printString(e),this.os.output.drawCursor(),new Promise((e=>{this.readLineLoop(e)})).then((e=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(this.os.string.intValue(e))}))}dispose(){this.cancel=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}var c=n(270);class p{memory;os;freeSegments=[{address:2048,length:14336}];constructor(e,t){this.memory=e,this.os=t}alloc(e){if(e<=0)return this.os.sys.error(c.X.ARRAY_SIZE_NOT_POSITIVE),0;for(let t=0;t=e){const r=n.address;return n.address+=e+1,n.length-=e+1,0===n.length&&this.freeSegments.splice(t,1),this.memory.set(r,e),r+1}}return this.os.sys.error(c.X.HEAP_OVERFLOW),0}deAlloc(e){const t=this.memory.get(e-1);this.freeSegments.push({address:e-1,length:t+1})}}const d=function(){const e=new Array(126);return e[32]=h([" "," "," "," "," "," "," "," "," "," "," "]),e[33]=h([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[34]=h([" \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588 \u2588 "," "," "," "," "," "," "," "," "]),e[35]=h([" "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 "," "," "]),e[36]=h([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),e[37]=h([" "," ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," "," "]),e[38]=h([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),e[39]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),e[40]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[41]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[42]=h([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "," "]),e[43]=h([" "," "," "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),e[44]=h([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),e[45]=h([" "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "," "]),e[46]=h([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[47]=h([" "," "," \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588 "," "," "]),e[48]=h([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),e[49]=h([" \u2588\u2588 "," \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[50]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[51]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[52]=h([" \u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588 \u2588\u2588 ","\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[53]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[54]=h([" \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[55]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[56]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[57]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),e[58]=h([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),e[59]=h([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[60]=h([" "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[61]=h([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "]),e[62]=h([" "," ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," "," "]),e[64]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[63]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[65]=h([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[66]=h(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[67]=h([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),e[68]=h(["\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),e[69]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[70]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),e[71]=h([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," "," "]),e[72]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[73]=h([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[74]=h([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),e[75]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[76]=h(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[77]=h(["\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[78]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[79]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[80]=h(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),e[81]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "]),e[82]=h(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[83]=h([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[84]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[85]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[86]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[87]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),e[88]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[89]=h(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[90]=h(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[91]=h([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[92]=h([" "," ","\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588 "," "," "]),e[94]=h([" \u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),e[95]=h([" "," "," "," "," "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "]),e[96]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),e[97]=h([" "," "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),e[98]=h(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[99]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[100]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[101]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[102]=h([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),e[103]=h([" "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),e[104]=h(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[105]=h([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[106]=h([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),e[107]=h(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[108]=h([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[109]=h([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 "," "," "]),e[110]=h([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[111]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[112]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "]),e[113]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),e[114]=h([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),e[115]=h([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),e[116]=h([" \u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),e[117]=h([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),e[118]=h([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),e[119]=h([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),e[120]=h([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),e[121]=h([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "]),e[122]=h([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),e[123]=h([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),e[124]=h([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),e[125]=h(["\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),e[126]=h([" \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),e}();function h(e){return e.map((e=>e.split("").map((e=>"\u2588"==e))))}const f=new Array(a.RL).fill(0),m=!0;class g{memory;os;color=m;constructor(e,t){this.memory=e,this.os=t}clear(){this.memory.screen.loadBytes(f)}outOfBounds(e,t){return e<0||e>16*a.pc||t<0||t>a.dh}drawPixel(e,t){if(this.outOfBounds(e,t))return void this.os.sys.error(c.X.ILLEGAL_PIXEL_COORD);const n=32*t+Math.floor(e/16);let r=this.memory.screen.get(n);this.color?r|=1<181)this.os.sys.error(c.X.ILLEGAL_RADIUS);else for(let r=-n;r<=n;r++)this.drawLine(e-Math.floor(Math.sqrt(n*n-r*r)),t+r,e+Math.floor(Math.sqrt(n*n-r*r)),t+r)}}class y{os;col=0;row=0;lastColor=!1;constructor(e){this.os=e}setColor(e){this.lastColor=this.os.screen.color,this.os.screen.color=e}restoreColor(){this.os.screen.color=this.lastColor}clearChar(){this.setColor(false),this.os.screen.drawRect(8*this.col,11*this.row,8*(this.col+1),11*(this.row+1)),this.restoreColor()}moveCursor(e,t){e<0||e>22||t<0||t>64?this.os.sys.error(c.X.ILLEGAL_CURSOR_LOCATION):(this.row=e,this.col=t,this.drawCursor())}println(){this.row+=1,this.col=0}drawCursor(){this.clearChar(),this.setColor(m),this.os.screen.drawRect(8*this.col+2,11*this.row+2,8*(this.col+1)-2,11*(this.row+1)-2),this.restoreColor()}printChar(e){const t=d[e];if(t){this.clearChar(),this.setColor(m);for(let e=0;e{this.cancelWait||(t+=r,t>=e?this.release():this.animationFrameId=requestAnimationFrame(n))};n(0)}halt(){this._halted=!0,this._exitCode=0}error(e){this.os.output.printJsString(`ERR${e}`),this._halted=!0,this._exitCode=e}dispose(){this.cancelWait=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}class b{vmMemory;screen;memory;string;output;keyboard;sys;paused=!1;constructor(e){this.vmMemory=e,this.screen=new g(this.vmMemory,this),this.memory=new p(this.vmMemory,this),this.string=new l.Fz(this.vmMemory,this),this.output=new y(this),this.keyboard=new u(this.vmMemory,this),this.sys=new v(this)}dispose(){this.keyboard.dispose(),this.sys.dispose()}}const w="__implicit",S={name:"Sys.init",labels:{},nVars:0,opBase:0,operations:[{op:"function",name:"Sys.init",nVars:0},{op:"call",name:"Main.main",nArgs:0}]};class x{memory=new o;os=new b(this.memory);functionMap={};executionStack=[];entry="";segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}};functions=[];program=[];addedSysInit=!1;staticCount=0;statics={};getStaticCount(){return this.staticCount}returnLine=void 0;registerStatic(e,t){const n=e.split(".")[0],r=this.statics[n]??[];this.statics[n]=r;const i=r[t]??this.staticCount++;return r[t]=i,i}registerStatics(){for(const e of Object.values(this.functionMap))for(const t of e.operations)"push"!==t.op&&"pop"!==t.op||"static"!==t?.segment||(t.offset=this.registerStatic(e.name,t.offset))}static validateFile(e){for(const t of e.instructions)if("function"==t.op){const n=t.name.split(".");if(2!=n.length)return(0,r._)((0,i.$5)(`Illegal subroutine name ${t.name} (Expected .)`,t.span));if(n[0]!=e.name)return(0,r._)((0,i.$5)(`File name ${e.name} doesn't match class name ${n[0]} (at ${t.name})`,t.span))}return(0,r.Ok)()}static validateFiles(e){const t=new Set;for(const n of e){if(t.has(n.name))return(0,r._)((0,i.$5)(`File ${n.name} already exists`));const e=this.validateFile(n);if((0,r.ys)(e))return e;t.add(n.name)}return(0,r.Ok)()}validateStackInstructions(){for(const e of Object.values(this.functionMap))for(const t of e.operations)if("pop"==t.op||"push"==t.op){const e=this.memory.baseSegment(t.segment,t.offset);if((0,r.ys)(e))return(0,r._)((0,i.$5)((0,r._)(e).message,t.span))}return(0,r.Ok)()}static validateFunctions(e){const t=new Set,n=[];for(const s of e){if("function"==s.op){if(s.nVars<0||s.nVars>32767)return(0,r._)((0,i.$5)(`Illegal number of local variables ${s.nVars} (Expected 0-32767)`,s.span));t.add(s.name)}if("call"==s.op){if(s.nArgs<0||s.nArgs>32767)return(0,r._)((0,i.$5)(`Illegal number of arguments ${s.nArgs} (Expected 0-32767)`,s.span));n.push(s)}}for(const a of n)if(!t.has(a.name)){if(!s.P[a.name])return(0,r._)((0,i.$5)(`Undefined function ${a.name}`,a.span));if(s.P[a.name].nArgs!=a.nArgs)return(0,r._)((0,i.$5)(`OS function ${a.name} expects ${s.P[a.name].nArgs} arguments, not ${a.nArgs}`,a.span))}return(0,r.Ok)()}static buildFromFiles(e){let t=this.validateFiles(e);if((0,r.ys)(t))return t;const n=e.map((e=>e.instructions)).reduce(((e,t)=>e.concat(t)));if(t=this.validateFunctions(n),(0,r.ys)(t))return t;const i=new x,s=i.load(n);return(0,r.ys)(s)?s:i.bootstrap()}static build(e){const t=this.validateFunctions(e);if((0,r.ys)(t))return t;const n=new x,i=n.load(e);return(0,r.ys)(i)?i:n.bootstrap()}static buildFunction(e,t){if("function"!==e[t].op)throw new Error("Only call buildFunction at the initial Function instruction");const{name:n,nVars:s}=e[t],a={name:n,nVars:s,labels:{},operations:[{op:"function",name:n,nVars:s,span:e[t].span}],opBase:0},o=new Set,l={};t+=1;e:for(;tthis.currentFunction.operations.length)throw new Error(`Current operation step beyond end of function operations (${this.invocation.opPtr} > ${this.currentFunction.operations.length})`);return this.currentFunction.operations[this.invocation.opPtr]}}load(e,t=!1){t&&(this.functionMap={},this.statics={},this.staticCount=0),"function"!==e[0]?.op&&e.unshift({op:"function",name:w,nVars:0});let n=0;for(;ne.name===this.entry?-1:t.name===this.entry?1:0));let e=0;return this.program=this.functions.reduce(((t,n)=>(n.name!=S.name&&(n.opBase=e),e+=n.operations.length,t.concat(n.operations))),[]),this.reset(),(0,r.Ok)(this)}reset(){this.executionStack=[{function:this.entry,opPtr:1,frameBase:256,nArgs:0,thisInitialized:!1,thatInitialized:!1}],this.memory.reset(),this.memory.SP=256,this.segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}},this.os.dispose(),this.os=new b(this.memory)}validateStackOp(e){if(this.currentFunction?.name==this.entry){for(const t of["local","argument"])if(e.segment==t){if(this.segmentInitializations[t].initialized)return void(this.segmentInitializations[t].n=Math.max(e.offset+1,this.segmentInitializations[t].n));throw new Error(`The ${t} segment cannot be accessed since it was not initialized`)}if("this"==e.segment&&this.invocation.thisInitialized)return void(this.invocation.thisN=Math.max(e.offset+1,this.invocation.thisN??0))}if("argument"==e.segment&&e.offset>=this.invocation.nArgs)throw new Error("Argument offset out of bounds");if("local"==e.segment&&e.offset>=this.functionMap[this.invocation.function]?.nVars)throw new Error("Local offset out of bounds");if("this"==e.segment&&!this.invocation.thisInitialized)throw new Error("The this segment cannot be accessed since it was not initialized");if("that"==e.segment&&!this.invocation.thatInitialized)throw new Error("The that segment cannot be accessed since it was not initialized")}setPaused(e=!0){this.os.paused=e}step(){if(this.os.sys.halted)return this.os.sys.exitCode;if(this.os.sys.blocked)return;if(this.os.sys.released&&"call"==this.operation?.op){const e=this.os.sys.readReturnValue(),t=this.memory.SP-this.operation.nArgs;return this.memory.set(t,e),this.memory.SP=t+1,void(this.invocation.opPtr+=1)}if(void 0==this.operation)return this.os.sys.halt(),this.step();const e=this.operation;if("label"===e.op)return this.invocation.opPtr+=1,this.step();switch(e.op){case"push":{this.validateStackOp(e);const t=this.memory.getSegment(e.segment,e.offset);this.memory.push(t);break}case"pop":{this.validateStackOp(e);const t=this.memory.pop();this.memory.setSegment(e.segment,e.offset,t),"pointer"==e.segment&&(0==e.offset?(this.invocation.thisInitialized=!0,this.invocation.thisN=this.memory.get(this.memory.THIS-1)):1==e.offset&&(this.invocation.thatInitialized=!0));break}case"add":this.memory.binOp(((e,t)=>e+t));break;case"sub":this.memory.binOp(((e,t)=>e-t));break;case"neg":this.memory.unOp((e=>-e));break;case"and":this.memory.binOp(((e,t)=>e&t));break;case"or":this.memory.binOp(((e,t)=>e|t));break;case"not":this.memory.unOp((e=>~e));break;case"eq":this.memory.comp(((e,t)=>e===t));break;case"lt":this.memory.comp(((e,t)=>ee>t));break;case"goto":this.goto(e.label);break;case"if-goto":0!=this.memory.pop()&&this.goto(e.label);break;case"call":{const t=e.name;if(this.functionMap[t]){const n=this.memory.pushFrame(this.invocation.opPtr,e.nArgs,this.functionMap[t].nVars);this.executionStack.push({function:t,opPtr:0,nArgs:e.nArgs,frameBase:n,thisInitialized:!1,thatInitialized:!1})}else if(s.P[t]){const n=s.P[t].func(this.memory,this.os);if(this.os.sys.blocked)return;const r=this.memory.SP-e.nArgs;this.memory.set(r,n),this.memory.SP=r+1}break}case"return":{const e=this.derivedLine();this.executionStack.pop();const t=this.memory.popFrame();if(this.invocation.opPtr=t,0===this.executionStack.length)return this.returnLine=e,0;break}}this.invocation.opPtr+=1}goto(e){if(this.currentFunction){if(void 0===this.currentFunction.labels[e])throw new Error(`Attempting GOTO to unknown label ${e} in ${this.currentFunction.name}`);this.invocation.opPtr=this.currentFunction.labels[e]}}write(e){e.map((([e,t])=>{this.memory.set(e,t)}))}read(e){return e.map((e=>this.memory.get(e)))}vmStack(){return this.executionStack.map(((e,t)=>{const n=this.executionStack[t+1],r=n?n.frameBase-n.nArgs:this.memory.get(0);return this.makeFrame(e,r)}))}getUsedSegments(e){const t=new Set;for(const n of this.functionMap[e.function].operations)"push"!==n.op&&"pop"!=n.op||t.add(n.segment);return t}makeFrame(e=this.invocation,t){const n=this.functionMap[e.function];if(n.name===this.entry){const t=256+n.nVars,r=this.executionStack[1],i=r?r.frameBase-r.nArgs:this.memory.get(0),{ARG:s,LCL:a,THAT:o,THIS:l}=this.memory,u=this.segmentInitializations.argument.n,c=this.segmentInitializations.local.n,p=this.invocation.thisN??0;return{fn:n,args:{base:s,count:u,values:[...this.memory.map(((e,t)=>t),s,s+u)]},locals:{base:a,count:c,values:[...this.memory.map(((e,t)=>t),a,a+c)]},stack:{base:256,count:i-t,values:[...this.memory.map(((e,t)=>t),t,i)]},this:{base:l,count:p,values:[...this.memory.map(((e,t)=>t),l,l+p)]},that:{base:o,count:1,values:[this.memory.THAT]},frame:{ARG:s,LCL:a,RET:65535,THAT:o,THIS:l},usedSegments:this.getUsedSegments(e)}}const r=this.memory.getFrame(e.frameBase,e.nArgs,n.nVars,this.invocation.thisN??0,1,t);return r.fn=n,r.usedSegments=this.getUsedSegments(e),r}derivedLine(){return this.operation?.span?.line??this.returnLine??0}writeDebug(){const e=this.derivedLine(),t=Math.max(e-5,0),n=Math.min(e+3,this.program.length),r=this.program.slice(t,n).map(((n,r)=>`${r===e-t?"->":" "} ${function(e){switch(e.op){case"add":case"and":case"sub":case"eq":case"gt":case"lt":case"neg":case"not":case"or":case"return":return` ${e.op}`;case"goto":return` ${e.op} ${e.label}`;case"if-goto":return` ${e.op} ${e.label}`;case"label":return`${e.op} ${e.label}`;case"call":return` ${e.op} ${e.name} ${e.nArgs}`;case"function":return`${e.op} ${e.name} ${e.nVars}`;case"pop":return` ${e.op} ${e.segment} ${e.offset}`;case"push":return` ${e.op} ${e.segment} ${e.offset}`}}(n)}`)).join("\n"),i=this.vmStack().at(-1);return i?r+"\n\n"+function(e){return[`Frame: ${e.fn?.name??"Unknown Fn"} ARG:${e.frame.ARG} LCL:${e.frame.LCL}`,`Args: ${k(e.args)}`,`Lcls: ${k(e.locals)}`,`Stck: ${k(e.stack)}`].join("\n")}(i):r}}function k(e){return`[${e.base};${e.count}][${e.values.join(", ")}]`}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.m=e,n.amdO={},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;n.t=function(r,i){if(1&i&&(r=this(r)),8&i)return r;if("object"===typeof r&&r){if(4&i&&r.__esModule)return r;if(16&i&&"function"===typeof r.then)return r}var s=Object.create(null);n.r(s);var a={};e=e||[null,t({}),t([]),t(t)];for(var o=2&i&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>a[e]=()=>r[e]));return a.default=()=>r,n.d(s,a),s}})(),n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"static/js/"+e+"."+{34:"9f280457",269:"1e46835e",288:"1852c135",297:"2c45dab0",323:"14a08baf",408:"e6e0ca78",519:"0a360ef5",535:"74ad7816",537:"c02a5bfa",578:"b9f22ec3",598:"beb31f34",608:"6d63ee31",614:"12dbb7c0",656:"c1a30912",744:"e7730500",787:"781c176c",828:"e00c10f6",965:"0e3f3e65",983:"681012c4"}[e]+".chunk.js",n.miniCssF=e=>"static/css/"+e+"."+{34:"2a1f584b",408:"4548b55f",519:"829f2cf9",535:"a8c1f171",598:"4a56c158",744:"3fc532fa",787:"968be482"}[e]+".chunk.css",n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="@nand2tetris/web:";n.l=(r,i,s,a)=>{if(e[r])e[r].push(i);else{var o,l;if(void 0!==s)for(var u=document.getElementsByTagName("script"),c=0;c{o.onerror=o.onload=null,clearTimeout(h);var i=e[r];if(delete e[r],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(n))),t)return t(n)},h=setTimeout(d.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=d.bind(null,o.onerror),o.onload=d.bind(null,o.onload),l&&document.head.appendChild(o)}}})(),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/web-ide/",(()=>{if("undefined"!==typeof document){var e=e=>new Promise(((t,r)=>{var i=n.miniCssF(e),s=n.p+i;if(((e,t)=>{for(var n=document.getElementsByTagName("link"),r=0;r{var a=document.createElement("link");a.rel="stylesheet",a.type="text/css",n.nc&&(a.nonce=n.nc),a.onerror=a.onload=n=>{if(a.onerror=a.onload=null,"load"===n.type)i();else{var r=n&&n.type,o=n&&n.target&&n.target.href||t,l=new Error("Loading CSS chunk "+e+" failed.\n("+r+": "+o+")");l.name="ChunkLoadError",l.code="CSS_CHUNK_LOAD_FAILED",l.type=r,l.request=o,a.parentNode&&a.parentNode.removeChild(a),s(l)}},a.href=t,r?r.parentNode.insertBefore(a,r.nextSibling):document.head.appendChild(a)})(e,s,null,t,r)})),t={792:0};n.f.miniCss=(n,r)=>{t[n]?r.push(t[n]):0!==t[n]&&{34:1,408:1,519:1,535:1,598:1,744:1,787:1}[n]&&r.push(t[n]=e(n).then((()=>{t[n]=0}),(e=>{throw delete t[n],e})))}}})(),(()=>{var e={792:0};n.f.j=(t,r)=>{var i=n.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var s=new Promise(((n,r)=>i=e[t]=[n,r]));r.push(i[2]=s);var a=n.p+n.u(t),o=new Error;n.l(a,(r=>{if(n.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var s=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+s+": "+a+")",o.name="ChunkLoadError",o.type=s,o.request=a,i[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var i,s,[a,o,l]=r,u=0;if(a.some((t=>0!==e[t]))){for(i in o)n.o(o,i)&&(n.m[i]=o[i]);if(l)l(n)}for(t&&t(r);u{var e={};n.r(e),n.d(e,{messages:()=>_});var t={};n.r(t),n.d(t,{messages:()=>I});var r=n(8878),i=n(4664);const s=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function a(e,t){navigator.serviceWorker.register(e).then((e=>{e.onupdatefound=()=>{const n=e.installing;null!=n&&(n.onstatechange=()=>{"installed"===n.state&&(navigator.serviceWorker.controller?(console.log("New content is available and will be used when all tabs for this page are closed. See https://cra.link/PWA."),t&&t.onUpdate&&t.onUpdate(e)):(console.log("Content is cached for offline use."),t&&t.onSuccess&&t.onSuccess(e)))})}})).catch((e=>{console.error("Error during service worker registration:",e)}))}var o=n(8256),l=n(6458),u=n(910),c=n(5777);const p=(e,t)=>{const n=String(e).split("."),r=!n[1],i=Number(n[0])==e,s=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?1==s&&11!=a?"one":2==s&&12!=a?"two":3==s&&13!=a?"few":"other":1==e&&r?"one":"other"};var d=n(8330),h=n(3229),f=n(8029);const m={comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],["\\*/","comment","@pop"],[/[/*]/,"comment"]],string:[[/[^\\"]+/,"string"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]]},g={tokenizer:{root:[[/(@)(.+)/,["operator","keyword"]],[/(\()(.+)(\))/,["operator","keyword","operator"]],{include:"@whitespace"}],...m}},y={keywords:["class","int","char","boolean","void","let","function","method","constructor","var","if","do","while","else","return","true","false","null","this","field","static"],tokenizer:{root:[[/[a-zA-Z_][a-zA-Z0-9_]*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/\d+/,"number"],[/"[^"\n]*"/,"string"],{include:"@whitespace"}],...m}},v={defaultToken:"invalid",keywords:["CHIP","CPU","IN","OUT","PARTS","BUILTIN","CLOCKED"],chips:["Nand","Nand16","Not","Not16","And","And16","Or","Or16","Or8Way","XOr","XOr16","Xor","Xor16","Mux","Mux16","Mux4Way16","Mux8Way16","DMux","DMux4Way","DMux8Way","HalfAdder","FullAdder","Add16","Inc16","ALU","ALUNoStat","DFF","Bit","Register","ARegister","DRegister","PC","RAM8","RAM64","RAM512","RAM4K","RAM16K","ROM32K","Screen","Keyboard","CPU","Computer","Memory","ARegister","DRegister"],operators:["="],symbols:/[=]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/[a-zA-Z][a-zA-Z0-9]*/,{cases:{"@keywords":"keyword","@chips":"keyword.chip","@default":"identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/@\s*[a-zA-Z_$][\w$]*/,{token:"annotation",log:"annotation token: $0"}],[/0[xX][0-9a-fA-F]+/,"number.hex"],[/\d+(..\d+)?/,"number"],[/[;:,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/'[^\\']'/,"string"],[/(')(@escapes)(')/,["string","string.escape","string"]],[/@escapes/,"string.escape"],[/'/,"string.invalid"]],...m}},b={Add16:"Add16(a = , b = , out = );",ALU:"ALU(x= , y= , zx= , nx= , zy= , ny= , f= , no= , out= , zr= , ng= );",And:"And(a= , b= , out= );",And16:"And16(a= , b= , out= );",ARegister:"ARegister(in= , load= , out= );",Bit:"Bit(in= , load= , out= );",CPU:"CPU(inM= , instruction= , reset= , outM= , writeM= , addressM= , pc= );",DFF:"DFF(in= , out= );",DMux:"DMux(in= , sel= , a= , b= );",DMux4Way:"DMux4Way(in= , sel= , a= , b= , c= , d= );",DMux8Way:"DMux8Way(in= , sel= , a= , b= , c= , d= , e= , f= , g= , h= );",DRegister:"DRegister(in= , load= , out= );",HalfAdder:"HalfAdder(a= , b= , sum= , carry= );",FullAdder:"FullAdder(a= , b= , c= , sum= , carry= );",Inc16:"Inc16(in= , out= );",Keyboard:"Keyboard(out= );",Memory:"Memory(in= , load= , address= , out= );",Mux:"Mux(a= , b= , sel= , out= );",Mux16:"Mux16(a= , b= , sel= , out= );",Mux4Way16:"Mux4Way16(a= , b= , c= , d= , sel= , out= );",Mux8Way16:"Mux8Way16(a= , b= , c= , d= , e= , f= , g= , h= , sel= , out= );",Nand:"Nand(a= , b= , out= );",Not16:"Not16(in= , out= );",Not:"Not(in= , out= );",Or:"Or(a= , b= , out= );",Or8Way:"Or8Way(in= , out= );",Or16:"Or16(a= , b= , out= );",PC:"PC(in= , load= , inc= , reset= , out= );",RAM8:"RAM8(in= , load= , address= , out= );",RAM64:"RAM64(in= , load= , address= , out= );",RAM512:"RAM512(in= , load= , address= , out= );",RAM4K:"RAM4K(in= , load= , address= , out= );",RAM16K:"RAM16K(in= , load= , address= , out= );",Register:"Register(in= , load= , out= );",ROM32K:"ROM32K(address= , out= );",Screen:"Screen(in= , load= , address= , out= );",Xor:"Xor(a = , b = , out = );"},w={provideCompletionItems:()=>({suggestions:Object.entries(b).map((([e,t])=>({label:e,kind:1,insertText:t})))})},S={hdl:v,cmp:{tokenizer:{root:[[/[a-z_$][\w$]*/,"identifier"],[/[ \t\r\n]+/,"white"],[/\d+\+?/,"number"],[/[|]/,"delimiter"]]}},tst:{defaultToken:"invalid",keywords:["output-list","set","eval","output","echo","clear-echo","repeat","while","load"],tokenizer:{root:[[/%[BDSX]\d+\.\d+\.\d+/,"keyword"],[/ROM32K/,"keyword"],[/[a-zA-Z-]+/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/%X[0-9a-fA-F]+/,"number.hex"],[/(%D)?\d+/,"number"],[/%B[01]+/,"number"],{include:"@whitespace"},[/[{}]/,"@bracket"],[/<>/,"operator"],[/[[\].]/,"operator"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/[;:!,]/,"delimiter"]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],["\\*/","comment","@pop"],[/[/*]/,"comment"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],string:[[/[^\\"]+/,"string"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]]}},vm:{keywords:["push","pop","add","sub","neg","lt","gt","eq","and","or","not","function","call","return","label","goto","if-goto","argument","local","static","constant","this","that","pointer","temp"],tokenizer:{root:[[/if-goto/,"keyword"],[/[_a-zA-Z][_a-zA-Z0-9.$]*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/\d+/,"number"],{include:"@whitespace"}],...m}},asm:g,jack:y},x={hdl:w};let k=!1;const _=JSON.parse('{"pDgeaz":[["title"]],"Pza0F/":"Allocated memory size must be positive (Memory.alloc)","PH2rP+":"Allow anonymous interaction tracking","zh5lcC":"Array size must be positive (Array.new)","YBt9YP":"Beta","BUAJAb":"Binary Code","++LBSt":"Builtin","RsyXWz":"Cannot compute square root of a negative number (Math.sqrt)","Ow/xRO":"Cannot test a chip that has syntax errors","L3ICHv":"Change Local FileSystem","C7rK3y":"Chip","+yPBXI":"Choose file","3rHyAJ":"Clock","UV+b1H":"Compare Code","oXeVWH":"Create a new file in the currently opened folder","pvnfJD":"Dark","iGq+of":"Division by zero (Math.divide)","Ovrln6":"Download .hdl files","9dwWEz":"Duration must be positive (Sys.wait)","uBAxNB":"Editor","lYGfRP":"English","J3L683":"Eval","7Bj3x9":"Failed","A9bii0":"Failed to load local file system.","sER+bs":"Files","EqbNAN":"Heap overflow (Memory.alloc)","SLzG45":"Illegal center coordinates (Screen.drawCircle)","EQU4AC":"Illegal cursor location (Output.moveCursor)","y4CC1u":"Illegal line coordinates (Screen.drawLine)","Lo+J/U":"Illegal pixel coordinates (Screen.drawPixel)","ijwovO":"Illegal radius (Screen.drawCircle)","5tI3XX":"Illegal rectangle coordinates (Screen.drawRectangle)","fkP0ib":"Insufficient string capacity (String.setInt)","vXIe7J":"Language","1njn7W":"Light","1/5eLk":"Load the compiled code into the VM emulator","etZuY4":"Maximum length must be non-negative (String.new)","FZeS2z":"Open a folder containing Jack file(s)","1tSpqV":"Parse Error","nqMwPi":"Passed","e0NrBM":"Project","E+NWKU":"Pseudolocale","9aloPG":"References","rdShiY":"Registers","OfhWJH":"Reset","d2mxgE":"Samples","Tz0i8g":"Settings","wdxz7K":"Source","GbPVvk":"String index out of bounds (String.charAt)","IgLZZI":"String index out of bounds (String.setCharAt)","RE1zuN":"String is empty (String.eraseLastChar)","CACwfm":"String is full (String.appendChar)","LWSJ0G":"Symbol Table","RFMyN+":"Syntax errors in the HDL code or test","D+NlUC":"System","NnH3pK":"Test","FEr96N":"Theme","U0HZma":"Tracking","/QBhoT":"Use Local FileSystem","zQo0yv":"Use Monaco Editor","4d8jc9":["Using ",["upgraded"]],"q3JCcX":"Visualization","1qK+lw":"VM Code","2BSTzk":"VM Structures"}'),I=JSON.parse('{"pDgeaz":[["title"]],"Pza0F/":"\xc0\u013a\u013a\u014d\u0107\xe0\u0163\u0113\u010f m\u0113m\u014d\u0155\u0177 \u015b\u0129\u017a\u0113 m\u0169\u015b\u0163 \u0180\u0113 \u01a5\u014d\u015b\u0129\u0163\u0129v\u0113 (M\u0113m\u014d\u0155\u0177.\xe0\u013a\u013a\u014d\u0107)","PH2rP+":"\xc0\u013a\u013a\u014d\u0175 \xe0\u0144\u014d\u0144\u0177m\u014d\u0169\u015b \u0129\u0144\u0163\u0113\u0155\xe0\u0107\u0163\u0129\u014d\u0144 \u0163\u0155\xe0\u0107\u0137\u0129\u0144\u011d","zh5lcC":"\xc0\u0155\u0155\xe0\u0177 \u015b\u0129\u017a\u0113 m\u0169\u015b\u0163 \u0180\u0113 \u01a5\u014d\u015b\u0129\u0163\u0129v\u0113 (\xc0\u0155\u0155\xe0\u0177.\u0144\u0113\u0175)","YBt9YP":"\xdf\u0113\u0163\xe0","BUAJAb":"\xdf\u0129\u0144\xe0\u0155\u0177 \u0106\u014d\u010f\u0113","++LBSt":"\xdf\u0169\u0129\u013a\u0163\u0129\u0144","RsyXWz":"\u0106\xe0\u0144\u0144\u014d\u0163 \u0107\u014dm\u01a5\u0169\u0163\u0113 \u015b\u01eb\u0169\xe0\u0155\u0113 \u0155\u014d\u014d\u0163 \u014d\u0192 \xe0 \u0144\u0113\u011d\xe0\u0163\u0129v\u0113 \u0144\u0169m\u0180\u0113\u0155 (M\xe0\u0163\u0125.\u015b\u01eb\u0155\u0163)","Ow/xRO":"\u0106\xe0\u0144\u0144\u014d\u0163 \u0163\u0113\u015b\u0163 \xe0 \u0107\u0125\u0129\u01a5 \u0163\u0125\xe0\u0163 \u0125\xe0\u015b \u015b\u0177\u0144\u0163\xe0x \u0113\u0155\u0155\u014d\u0155\u015b","L3ICHv":"\u0106\u0125\xe0\u0144\u011d\u0113 \u0139\u014d\u0107\xe0\u013a \u0191\u0129\u013a\u0113\u015a\u0177\u015b\u0163\u0113m","C7rK3y":"\u0106\u0125\u0129\u01a5","+yPBXI":"\u0106\u0125\u014d\u014d\u015b\u0113 \u0192\u0129\u013a\u0113","3rHyAJ":"\u0106\u013a\u014d\u0107\u0137","UV+b1H":"\u0106\u014dm\u01a5\xe0\u0155\u0113 \u0106\u014d\u010f\u0113","oXeVWH":"\u0106\u0155\u0113\xe0\u0163\u0113 \xe0 \u0144\u0113\u0175 \u0192\u0129\u013a\u0113 \u0129\u0144 \u0163\u0125\u0113 \u0107\u0169\u0155\u0155\u0113\u0144\u0163\u013a\u0177 \u014d\u01a5\u0113\u0144\u0113\u010f \u0192\u014d\u013a\u010f\u0113\u0155","pvnfJD":"\u010e\xe0\u0155\u0137","iGq+of":"\u010e\u0129v\u0129\u015b\u0129\u014d\u0144 \u0180\u0177 \u017a\u0113\u0155\u014d (M\xe0\u0163\u0125.\u010f\u0129v\u0129\u010f\u0113)","Ovrln6":"\u010e\u014d\u0175\u0144\u013a\u014d\xe0\u010f .\u0125\u010f\u013a \u0192\u0129\u013a\u0113\u015b","9dwWEz":"\u010e\u0169\u0155\xe0\u0163\u0129\u014d\u0144 m\u0169\u015b\u0163 \u0180\u0113 \u01a5\u014d\u015b\u0129\u0163\u0129v\u0113 (\u015a\u0177\u015b.\u0175\xe0\u0129\u0163)","uBAxNB":"\u0112\u010f\u0129\u0163\u014d\u0155","lYGfRP":"\u0112\u0144\u011d\u013a\u0129\u015b\u0125","J3L683":"\u0112v\xe0\u013a","7Bj3x9":"\u0191\xe0\u0129\u013a\u0113\u010f","A9bii0":"\u0191\xe0\u0129\u013a\u0113\u010f \u0163\u014d \u013a\u014d\xe0\u010f \u013a\u014d\u0107\xe0\u013a \u0192\u0129\u013a\u0113 \u015b\u0177\u015b\u0163\u0113m.","sER+bs":"\u0191\u0129\u013a\u0113\u015b","EqbNAN":"\u0124\u0113\xe0\u01a5 \u014dv\u0113\u0155\u0192\u013a\u014d\u0175 (M\u0113m\u014d\u0155\u0177.\xe0\u013a\u013a\u014d\u0107)","SLzG45":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u0107\u0113\u0144\u0163\u0113\u0155 \u0107\u014d\u014d\u0155\u010f\u0129\u0144\xe0\u0163\u0113\u015b (\u015a\u0107\u0155\u0113\u0113\u0144.\u010f\u0155\xe0\u0175\u0106\u0129\u0155\u0107\u013a\u0113)","EQU4AC":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u0107\u0169\u0155\u015b\u014d\u0155 \u013a\u014d\u0107\xe0\u0163\u0129\u014d\u0144 (\u014c\u0169\u0163\u01a5\u0169\u0163.m\u014dv\u0113\u0106\u0169\u0155\u015b\u014d\u0155)","y4CC1u":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u013a\u0129\u0144\u0113 \u0107\u014d\u014d\u0155\u010f\u0129\u0144\xe0\u0163\u0113\u015b (\u015a\u0107\u0155\u0113\u0113\u0144.\u010f\u0155\xe0\u0175\u0139\u0129\u0144\u0113)","Lo+J/U":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u01a5\u0129x\u0113\u013a \u0107\u014d\u014d\u0155\u010f\u0129\u0144\xe0\u0163\u0113\u015b (\u015a\u0107\u0155\u0113\u0113\u0144.\u010f\u0155\xe0\u0175\u01a4\u0129x\u0113\u013a)","ijwovO":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u0155\xe0\u010f\u0129\u0169\u015b (\u015a\u0107\u0155\u0113\u0113\u0144.\u010f\u0155\xe0\u0175\u0106\u0129\u0155\u0107\u013a\u0113)","5tI3XX":"\u0128\u013a\u013a\u0113\u011d\xe0\u013a \u0155\u0113\u0107\u0163\xe0\u0144\u011d\u013a\u0113 \u0107\u014d\u014d\u0155\u010f\u0129\u0144\xe0\u0163\u0113\u015b (\u015a\u0107\u0155\u0113\u0113\u0144.\u010f\u0155\xe0\u0175\u0154\u0113\u0107\u0163\xe0\u0144\u011d\u013a\u0113)","fkP0ib":"\u0128\u0144\u015b\u0169\u0192\u0192\u0129\u0107\u0129\u0113\u0144\u0163 \u015b\u0163\u0155\u0129\u0144\u011d \u0107\xe0\u01a5\xe0\u0107\u0129\u0163\u0177 (\u015a\u0163\u0155\u0129\u0144\u011d.\u015b\u0113\u0163\u0128\u0144\u0163)","vXIe7J":"\u0139\xe0\u0144\u011d\u0169\xe0\u011d\u0113","1njn7W":"\u0139\u0129\u011d\u0125\u0163","1/5eLk":"\u0139\u014d\xe0\u010f \u0163\u0125\u0113 \u0107\u014dm\u01a5\u0129\u013a\u0113\u010f \u0107\u014d\u010f\u0113 \u0129\u0144\u0163\u014d \u0163\u0125\u0113 VM \u0113m\u0169\u013a\xe0\u0163\u014d\u0155","etZuY4":"M\xe0x\u0129m\u0169m \u013a\u0113\u0144\u011d\u0163\u0125 m\u0169\u015b\u0163 \u0180\u0113 \u0144\u014d\u0144-\u0144\u0113\u011d\xe0\u0163\u0129v\u0113 (\u015a\u0163\u0155\u0129\u0144\u011d.\u0144\u0113\u0175)","FZeS2z":"\u014c\u01a5\u0113\u0144 \xe0 \u0192\u014d\u013a\u010f\u0113\u0155 \u0107\u014d\u0144\u0163\xe0\u0129\u0144\u0129\u0144\u011d \u0135\xe0\u0107\u0137 \u0192\u0129\u013a\u0113(\u015b)","1tSpqV":"\u01a4\xe0\u0155\u015b\u0113 \u0112\u0155\u0155\u014d\u0155","nqMwPi":"\u01a4\xe0\u015b\u015b\u0113\u010f","e0NrBM":"\u01a4\u0155\u014d\u0134\u0113\u0107\u0163","E+NWKU":"\u01a4\u015b\u0113\u0169\u010f\u014d\u013a\u014d\u0107\xe0\u013a\u0113","9aloPG":"\u0154\u0113\u0192\u0113\u0155\u0113\u0144\u0107\u0113\u015b","rdShiY":"\u0154\u0113\u011d\u0129\u015b\u0163\u0113\u0155\u015b","OfhWJH":"\u0154\u0113\u015b\u0113\u0163","d2mxgE":"\u015a\xe0m\u01a5\u013a\u0113\u015b","Tz0i8g":"\u015a\u0113\u0163\u0163\u0129\u0144\u011d\u015b","wdxz7K":"\u015a\u014d\u0169\u0155\u0107\u0113","GbPVvk":"\u015a\u0163\u0155\u0129\u0144\u011d \u0129\u0144\u010f\u0113x \u014d\u0169\u0163 \u014d\u0192 \u0180\u014d\u0169\u0144\u010f\u015b (\u015a\u0163\u0155\u0129\u0144\u011d.\u0107\u0125\xe0\u0155\xc0\u0163)","IgLZZI":"\u015a\u0163\u0155\u0129\u0144\u011d \u0129\u0144\u010f\u0113x \u014d\u0169\u0163 \u014d\u0192 \u0180\u014d\u0169\u0144\u010f\u015b (\u015a\u0163\u0155\u0129\u0144\u011d.\u015b\u0113\u0163\u0106\u0125\xe0\u0155\xc0\u0163)","RE1zuN":"\u015a\u0163\u0155\u0129\u0144\u011d \u0129\u015b \u0113m\u01a5\u0163\u0177 (\u015a\u0163\u0155\u0129\u0144\u011d.\u0113\u0155\xe0\u015b\u0113\u0139\xe0\u015b\u0163\u0106\u0125\xe0\u0155)","CACwfm":"\u015a\u0163\u0155\u0129\u0144\u011d \u0129\u015b \u0192\u0169\u013a\u013a (\u015a\u0163\u0155\u0129\u0144\u011d.\xe0\u01a5\u01a5\u0113\u0144\u010f\u0106\u0125\xe0\u0155)","LWSJ0G":"\u015a\u0177m\u0180\u014d\u013a \u0162\xe0\u0180\u013a\u0113","RFMyN+":"\u015a\u0177\u0144\u0163\xe0x \u0113\u0155\u0155\u014d\u0155\u015b \u0129\u0144 \u0163\u0125\u0113 \u0124\u010e\u0139 \u0107\u014d\u010f\u0113 \u014d\u0155 \u0163\u0113\u015b\u0163","D+NlUC":"\u015a\u0177\u015b\u0163\u0113m","NnH3pK":"\u0162\u0113\u015b\u0163","FEr96N":"\u0162\u0125\u0113m\u0113","U0HZma":"\u0162\u0155\xe0\u0107\u0137\u0129\u0144\u011d","/QBhoT":"\u0168\u015b\u0113 \u0139\u014d\u0107\xe0\u013a \u0191\u0129\u013a\u0113\u015a\u0177\u015b\u0163\u0113m","zQo0yv":"\u0168\u015b\u0113 M\u014d\u0144\xe0\u0107\u014d \u0112\u010f\u0129\u0163\u014d\u0155","4d8jc9":["\u0168\u015b\u0129\u0144\u011d ",["upgraded"]],"q3JCcX":"V\u0129\u015b\u0169\xe0\u013a\u0129\u017a\xe0\u0163\u0129\u014d\u0144","1qK+lw":"VM \u0106\u014d\u010f\u0113","2BSTzk":"VM \u015a\u0163\u0155\u0169\u0107\u0163\u0169\u0155\u0113\u015b"}'),A=e,C=t;var E=n(6073),O=n(782);const P=function(){const{status:e}=(0,r.useContext)(u.L);return(0,O.jsx)("div",{children:e})},L=()=>(0,O.jsx)("footer",{className:"flex row justify-between",children:(0,O.jsx)(P,{})});var R=n(3600),N=n(3015),T=n(3499);function M(e,t,n){return{href:e.href,tool:e.tool,tooltip:null!==n&&void 0!==n?n:e.tool&&Object.keys(T.It).includes(e.tool)?T.It[e.tool]:"",icon:t,target:e.target}}const F={chip:"user_guide/chip.pdf",cpu:"user_guide/cpu.pdf",asm:"user_guide/asm.pdf",vm:"user_guide/vm.pdf",compiler:"user_guide/compiler.pdf"},j="Guide not available for this tool";const D=[M(T.Ay.chip,"memory"),M(T.Ay.cpu,"developer_board"),M(T.Ay.asm,"list_alt"),M(T.Ay.vm,"computer"),..."showDirectoryPicker"in window?[M(T.Ay.compiler,"code")]:[],M(T.Ay.bitmap,"grid_on"),M(T.Ay.util,"function","Converter Tool"),{onClick:async function(e){if(!F[e.pathname])return void e.baseContext.setStatus(j);const t=F[e.pathname];404!==(await fetch(t)).status?window.open(t,"_blank","width=1000,height=800"):e.baseContext.setStatus(j)},tooltip:"Guide",icon:"menu_book"},{href:"https://github.com/nand2tetris/web-ide/issues/new/choose",icon:"bug_report",tooltip:"Bug Report"},{onClick:e=>{e.appContext.settings.open()},icon:"settings",tooltip:"Settings"},M(T.Ay.about,"info","About")],$=()=>{const e=(0,r.useContext)(f.BR),t=(0,r.useContext)(u.L),{title:n,setTool:i}=(0,r.useContext)(R.NQ),{setStatus:s}=(0,r.useContext)(u.L),a={};for(const l of D)l.href&&(a[l.href]=(0,r.useRef)(null));const o=(0,h.zy)().pathname.replaceAll("/","");return(0,O.jsx)("header",{children:(0,O.jsxs)("nav",{style:{width:"100%"},children:[(0,O.jsx)("ul",{children:(0,O.jsxs)("li",{children:[(0,O.jsx)("strong",{children:(0,O.jsx)("a",{href:"https://nand2tetris.org",target:"_blank",rel:"noreferrer",children:"NAND2Tetris"})}),T.It[o]&&` / ${T.It[o]}`,n&&` / ${n}`]})}),(0,O.jsx)("ul",{className:"icon-list",children:D.map((({href:n,icon:r,onClick:l,tooltip:u,target:c,tool:p})=>(0,O.jsxs)("li",{"data-tooltip":u,"data-placement":"bottom",onClick:()=>{var r;(i(p),s(""),l)?null===l||void 0===l||l({appContext:e,baseContext:t,pathname:o}):n&&(c&&localStorage.setItem(T.p3,n),null===(r=a[n].current)||void 0===r||r.click())},children:[(0,O.jsx)(N.I,{name:r}),n&&(c?(0,O.jsx)(d.N_,{to:n,ref:a[n],style:{display:"none"}}):(0,O.jsx)("a",{href:n,target:"new",ref:a[n],style:{display:"none"}}))]},r)))})]})})};var z=n(5270);const V="version",U=9;function B(){var e;return Number(null!==(e=localStorage.getItem(V))&&void 0!==e?e:"0")}function W(e){localStorage.setItem(V,e.toString())}const H={0:async e=>{for(const t of["hdl","cmp","tst"])await e.writeFile(`/projects/01/Xor/Xor.${t}`,await e.readFile(`/projects/01/XOr/XOr.${t}`))},1:async e=>{await(0,c.resetFiles)(e,[4])},2:async e=>{await(0,c.resetTests)(e,[1])},3:async e=>{await(0,c.resetTests)(e)},4:async e=>{await(0,c.resetFiles)(e,[7,8])},5:async e=>{await(0,c.resetTests)(e,[3,5])},6:async e=>{await(0,c.resetTests)(e,[4])},7:async e=>{await(0,c.resetTests)(e,[1])},8:async e=>{await(0,c.resetFiles)(e,[6])}};var G=n(3508);const q=()=>{const{stores:e}=(0,r.useContext)(R.NQ),{fs:t,setStatus:i,canUpgradeFs:s,upgradeFs:a,closeFs:c,upgraded:p}=(0,r.useContext)(u.L),{settings:d,monaco:h,theme:m,setTheme:g,tracking:y}=(0,r.useContext)(f.BR),[v,b]=(0,r.useState)(!1),w=(0,r.useMemo)((()=>e=>{o.Ru.activate(e),t.writeFile("/locale",e)}),[t]);(0,r.useEffect)((()=>{t.readFile("/locale").then((e=>o.Ru.activate(e))).catch((()=>w("en")))}),[t,w]);const S=(0,G.s)(),x=(0,G.s)(),k=(0,O.jsx)("dialog",{open:S.isOpen,children:(0,O.jsx)("article",{children:(0,O.jsxs)("main",{children:[(0,O.jsx)("div",{style:{margin:"10px"},children:'The "reset files" action will result in erasing all the HDL files kept in your browser\'s memory, replacing them with a fresh set of skeletal HDL files. You may want to back-up your files before resetting them. Are you sure that you want to reset the files?'}),(0,O.jsxs)("div",{style:{display:"flex",justifyContent:"space-around",marginTop:"30px"},children:[(0,O.jsx)("button",{style:{width:"100px"},onClick:async()=>{await(async()=>{const r=B();localStorage.clear(),W(r),localStorage["/chip/project"]="01",localStorage["/chip/chip"]="Not";const i=await Promise.resolve().then(n.bind(n,5777));await i.resetFiles(t),e.chip.actions.initialize(),e.cpu.actions.clear(),e.asm.actions.clear(),e.vm.actions.initialize(),e.compiler.actions.reset()})(),S.close(),x.open()},children:"Yes"}),(0,O.jsx)("button",{style:{width:"100px"},onClick:()=>{S.close()},children:"Cancel"})]})]})})}),_=(0,O.jsx)("dialog",{open:x.isOpen,children:(0,O.jsxs)("article",{children:[(0,O.jsx)("header",{children:"Your files were reset"}),(0,O.jsx)("main",{children:(0,O.jsx)("button",{onClick:x.close,children:"Ok"})})]})});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("dialog",{open:d.isOpen,children:(0,O.jsxs)("article",{children:[(0,O.jsxs)("header",{children:[(0,O.jsx)("p",{children:(0,O.jsx)(l.x6,{id:"Tz0i8g"})}),(0,O.jsx)("a",{className:"close",href:"#root",onClick:e=>{e.preventDefault(),d.close()}})]}),(0,O.jsx)("main",{children:(0,O.jsxs)("dl",{children:[(0,O.jsx)("header",{children:(0,O.jsx)(l.x6,{id:"e0NrBM"})}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"9aloPG"})}),(0,O.jsxs)("dd",{children:[(0,O.jsx)("div",{children:(0,O.jsx)("a",{href:"https://nand2tetris.org",target:"_blank",rel:"noreferrer",children:"nand2tetris.org"})}),(0,O.jsx)("div",{children:(0,O.jsx)("a",{href:"https://github.com/davidsouther/nand2tetris",target:"_blank",rel:"noreferrer",children:"GitHub"})})]}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"sER+bs"})}),(0,O.jsxs)("dd",{children:[(0,O.jsx)(O.Fragment,{}),(0,O.jsx)("button",{onClick:async()=>{S.open()},children:(0,O.jsx)(l.x6,{id:"OfhWJH"})}),(0,O.jsx)("button",{onClick:async()=>{const e=await Promise.resolve().then(n.bind(n,5777));await e.loadSamples(t),i("Loaded sample files...")},children:(0,O.jsx)(l.x6,{id:"d2mxgE"})})]}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"vXIe7J"})}),(0,O.jsxs)("dd",{children:[(0,O.jsx)("button",{onClick:()=>w("en"),children:(0,O.jsx)(l.x6,{id:"lYGfRP"})}),(0,O.jsx)("button",{onClick:()=>w("en-PL"),children:(0,O.jsx)(l.x6,{id:"E+NWKU"})})]}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"uBAxNB"})}),(0,O.jsx)("dd",{children:(0,O.jsxs)("label",{children:[(0,O.jsx)("input",{type:"checkbox",name:"switch",role:"switch",checked:h.wants,disabled:!h.canUse,onChange:e=>h.toggle(e.target.checked)}),(0,O.jsx)(l.x6,{id:"zQo0yv"})]})}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"FEr96N"})}),(0,O.jsx)("dd",{children:(0,O.jsxs)("fieldset",{role:"group",children:[(0,O.jsxs)("label",{role:"button","aria-current":"light"===m,children:[(0,O.jsx)("input",{type:"radio",name:"theme",value:"light",checked:"light"===m,onChange:()=>g("light")}),(0,O.jsx)(l.x6,{id:"1njn7W"})]}),(0,O.jsxs)("label",{role:"button","aria-current":"dark"===m,children:[(0,O.jsx)("input",{type:"radio",name:"theme",value:"dark",checked:"dark"===m,onChange:()=>g("dark")}),(0,O.jsx)(l.x6,{id:"pvnfJD"})]}),(0,O.jsxs)("label",{role:"button","aria-current":"system"===m,children:[(0,O.jsx)("input",{type:"radio",name:"theme",value:"system",checked:"system"===m,onChange:()=>g("system")}),(0,O.jsx)(l.x6,{id:"D+NlUC"})]})]})}),(0,O.jsx)("dt",{children:(0,O.jsx)(l.x6,{id:"U0HZma"})}),(0,O.jsx)("dd",{children:(0,O.jsxs)("label",{children:[(0,O.jsx)("input",{type:"checkbox",name:"switch",role:"switch",checked:y.canTrack,onChange:e=>{e.target.checked?y.accept():y.reject()}}),(0,O.jsx)(l.x6,{id:"PH2rP+"}),(0,O.jsx)(z.dQ,{})]})})]})})]})}),k,_]})};class K extends r.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback({error:this.state.error}):this.props.children}}const Q=({error:e})=>{var t;return e?(0,O.jsxs)("div",{children:[(0,O.jsxs)("p",{children:[(0,O.jsxs)("b",{children:[null!==(t=e.name)&&void 0!==t?t:"Error",":"]})," ",e.message]}),e.stack&&(0,O.jsx)("pre",{children:(0,O.jsx)("code",{children:e.stack})}),e.cause?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{children:(0,O.jsx)("em",{children:"Caused by"})}),(0,O.jsx)(Q,{error:e.cause})]}):(0,O.jsx)(O.Fragment,{})]}):(0,O.jsx)("p",{children:"Unknown Error"})},Y=()=>{const[e,t]=(0,r.useState)();return(0,r.useEffect)((()=>{var e;const n=null!==(e=localStorage.getItem(T.p3))&&void 0!==e?e:"/chip";t(n)}),[]),e?(0,O.jsx)(h.C5,{to:e}):(0,O.jsx)(O.Fragment,{})};o.Ru.load("en",A.messages),o.Ru.load("en-PL",C.messages),o.Ru.loadLocaleData({en:{plurals:p},"en-US":{plurals:p},"en-PL":{plurals:p}}),o.Ru.activate(navigator.language);const X=function(){const e=(0,u.A)(),t=(0,f.Us)(),i=e.fs;return(0,r.useEffect)((()=>{!async function(){if(k)return;k=!0,k=!0;const{loader:e}=await n.e(983).then(n.bind(n,7983)),{languages:t}=await e.init();for(const[n,r]of Object.entries(S))t.register({id:n}),t.setMonarchTokensProvider(n,r),x[n]&&t.registerCompletionItemProvider(n,x[n]);k=!1}()}),[]),(0,r.useEffect)((()=>{i.stat("/projects/01/Not/Not.hdl").catch((async()=>{await c.loaders.resetFiles(i)})),async function(e){let t=B();for(;t{document.children[0].dataset.theme="system"===t.theme?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t.theme}),[t.theme]),(0,O.jsx)(l.CY,{i18n:o.Ru,children:(0,O.jsx)(u.L.Provider,{value:e,children:(0,O.jsx)(f.BR.Provider,{value:t,children:(0,O.jsxs)(R.qK,{children:[(0,O.jsx)(q,{}),(0,O.jsx)(E.Nk,{}),(0,O.jsxs)(d.Kd,{basename:"/web-ide",children:[(0,O.jsx)($,{}),(0,O.jsx)("main",{className:"flex flex-1",children:(0,O.jsx)(K,{fallback:Q,children:(0,O.jsx)(r.Suspense,{fallback:(0,O.jsx)("div",{children:"Loading..."}),children:(0,O.jsxs)(h.BV,{children:[(0,O.jsx)(h.qh,{path:"/",element:(0,O.jsx)(Y,{})}),Object.values(T.Ay).map((({href:e,target:t})=>(0,O.jsx)(h.qh,{path:e,element:t},e)))]})})})}),(0,O.jsx)(L,{}),(0,O.jsx)(z.w,{})]})]})})})})},J=e=>{e&&e instanceof Function&&n.e(578).then(n.bind(n,1578)).then((({getCLS:t,getFID:n,getFCP:r,getLCP:i,getTTFB:s})=>{t(e),n(e),r(e),i(e),s(e)}))};i.createRoot(document.getElementById("root")).render((0,O.jsx)(r.StrictMode,{children:(0,O.jsx)(X,{})})),function(e){if("serviceWorker"in navigator){if(new URL("/web-ide",window.location.href).origin!==window.location.origin)return;window.addEventListener("load",(()=>{const t="/web-ide/service-worker.js";s?(!function(e,t){fetch(e,{headers:{"Service-Worker":"script"}}).then((n=>{const r=n.headers.get("content-type");404===n.status||null!=r&&-1===r.indexOf("javascript")?navigator.serviceWorker.ready.then((e=>{e.unregister().then((()=>{window.location.reload()}))})):a(e,t)})).catch((()=>{console.log("No internet connection found. App is running in offline mode.")}))}(t,e),navigator.serviceWorker.ready.then((()=>{console.log("This web app is being served cache-first by a service worker. To learn more, visit https://cra.link/PWA")}))):a(t,e)}))}}(),J()})()})();
\ No newline at end of file
+/*! For license information please see main.9984f23c.js.LICENSE.txt */
+(()=>{"use strict";var e={8029:(e,t,n)=>{n.d(t,{BR:()=>c,Us:()=>u});var r=n(4544),i=n(8878),s=n(3508),a=n(6073),o=n(5270);function l(){const e=!0,[t,n]=(0,i.useState)(e),r=(0,i.useCallback)((e=>{n(!!e)}),[e]);return{canUse:e,wants:t,toggle:r}}function u(e=new r.Q2){const[t,n]=(0,i.useState)("system");return{monaco:l(),settings:(0,s.s)(),filePicker:(0,a.g3)(),tracking:(0,o.z1)(),theme:t,setTheme:n}}const c=(0,i.createContext)({monaco:{canUse:!0,wants:!0,toggle(){}},filePicker:{close(){},open(){},select:e=>Promise.reject(""),isOpen:!1,suffix:void 0},settings:{close(){},open(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept(){},reject(){},trackEvent(){},trackPage(){}},theme:"system",setTheme(){}})},3600:(e,t,n)=>{n.d(t,{NQ:()=>G,qK:()=>q});var r=n(5874),i=n(7076),s=n(4666),a=n(7844),o=n(8878),l=n(1593),u=n(910);class c{asm={instructions:[]};current=-1;done=!1;symbols=[];variables=new Map;lines=[];lineNumbers=[];getResult(){return this.lines.join("\n")}load(e,t){this.symbols=[{name:"R0",value:"0"},{name:"R1",value:"1"},{name:"R2",value:"2"},{name:"...",value:""},{name:"R15",value:"15"},{name:"SCREEN",value:i.L7.toString()},{name:"KBD",value:i.ky.toString()}],this.variables.clear(),this.asm=e;const n=(0,s.EU)(e,((e,t,n)=>{n?this.variables.set(t,{name:e,isHidden:!0}):this.symbols.push({name:e,value:t.toString()})}));return(0,r.ys)(n)?n:(e.instructions=e.instructions.filter((({type:e})=>"L"!==e)),this.resolveLineNumbers(t),this.reset(),(0,r.Ok)())}resolveLineNumbers(e){this.lineNumbers=Array(e);let t=0;for(const n of this.asm.instructions)"A"!==n.type&&"C"!==n.type||void 0==n.span||(this.lineNumbers[n.span.line]=t,t+=1)}step(e){if(this.current>=this.asm.instructions.length-1)return;this.current+=1;const t=this.asm.instructions[this.current];if("A"===t.type||"C"===t.type){e.sourceHighlight=t.span;const n=(0,s.ld)(this.asm.instructions[this.current]);if(void 0===n)return;if(this.lines.push(`${(0,a.e5)(n)}`),e.resultHighlight={start:17*this.current,end:17*(this.current+1),line:-1},e.sourceHighlight&&e.highlightMap.set(e.sourceHighlight,e.resultHighlight),(0,s.J$)(t)){const e=this.variables.get(t.value);void 0!=e&&e.isHidden&&(this.symbols.push({name:e.name,value:t.value.toString()}),e.isHidden=!1)}this.current===this.asm.instructions.length-1&&(this.done=!0)}}resetSymbols(){for(const t of this.variables.values())t.isHidden=!0;const e=new Set(Array.from(this.variables.values()).map((e=>e.name)));this.symbols=this.symbols.filter((t=>!e.has(t.name)))}reset(){this.current=-1,this.lines=[],this.done=!1,this.resetSymbols()}}function p(){const{setStatus:e,fs:t}=(0,o.useContext)(u.L),n=(0,o.useRef)((()=>{})),{initialState:i,reducers:a,actions:p}=(0,o.useMemo)((()=>function(e,t,n){const i=new c,a={resultHighlight:void 0,sourceHighlight:void 0,highlightMap:new Map};let o,l=!0,u=!1,p=!1,d=!1;const h={setAsm(e,{asm:t,path:n}){e.asm=t,n&&(e.path=n)},setCmp(e,{cmp:n,name:r}){e.compare=n,e.compareName=r,t("Loaded compare file")},setError(e,n){n&&t(n.message),e.error=n},update(e){e.translating=p,e.current=i.current,e.result=i.getResult(),e.symbols=Array.from(i.symbols),e.lineNumbers=Array.from(i.lineNumbers),e.sourceHighlight=a.sourceHighlight,e.resultHighlight=a.resultHighlight,e.compareError=d},compare(e){const n=e.result.split("\n"),r=e.compare.split("\n").filter((e=>""!=e.trim()));if(n.length!=r.length)return d=!0,void t("Comparison failed - different lengths");for(let i=0;i{this.compileAsm(e)}))},saveAsm(t){o&&e.writeFile(o,t)},compileAsm(e){this.reset();const a=s.y0.parse(e);if((0,r.ys)(a))return n.current({action:"setError",payload:(0,r._)(a)}),void(u=!1);const o=i.load((0,r.Ok)(a),e.split("\n").length);if((0,r.ys)(o))return n.current({action:"setError",payload:(0,r._)(o)}),void(u=!1);u=i.asm.instructions.length>0,t(""),n.current({action:"setError"}),n.current({action:"update"})},setAnimate(e){l=e},step:()=>(u&&(p=!0),i.step(a),(l||i.done)&&n.current({action:"update"}),i.done&&t("Translation done."),i.done),compare(){n.current({action:"compare"}),this.updateHighlight(a.resultHighlight?.start??0,!1),n.current({action:"update"})},updateHighlight(e,t){if(!d){for(const[n,r]of a.highlightMap)(t&&n.start<=e&&e<=n.end||!t&&r.start<=e&&e<=r.end)&&(a.sourceHighlight=n,a.resultHighlight=r);n.current({action:"update"})}},resetHighlightInfo(){a.sourceHighlight=void 0,a.resultHighlight=void 0,a.highlightMap.clear()},reset(){d=!1,p=!1,t("Reset"),i.reset(),this.resetHighlightInfo(),n.current({action:"update"})},clear(){this.setAsm(""),n.current({action:"setTitle",payload:void 0}),n.current({action:"setCmp",payload:""}),this.reset()},overrideState(e){if(this.resetHighlightInfo(),this.setAsm(e.asm,e.path),n.current({action:"setCmp",payload:{cmp:e.compare,name:e.compareName}}),e.translating)for(let t=0;t<=e.current;t++)this.step();n.current({action:"update"})}};return{initialState:{asm:"",path:void 0,translating:!1,current:-1,resultHighlight:void 0,sourceHighlight:void 0,symbols:[],result:"",compare:"",compareName:void 0,lineNumbers:[],compareError:!1,config:{speed:2}},reducers:h,actions:f}}(t,e,n)),[e,n]),[d,h]=(0,l.A)(a,i);return n.current=h,{state:d,dispatch:n,actions:p}}var d=n(3180),h=n(3977),f=n(9563);const m='Jack <: Base {\n Root := Class\n\n whitespace = (lineComment | comment | space)\n\n class = "class" whitespace+\n Class = class jackIdentifier OpenBrace ClassVarDec* SubroutineDec* CloseBrace\n\n type = ("int" | "char" | "boolean" | jackIdentifier) whitespace+\n\n classVarType = ("static" | "field") whitespace+\n ClassVarDec = classVarType type jackIdentifier TrailingIdentifier* Semi\n TrailingIdentifier = Comma jackIdentifier\n\n void = "void" whitespace+\n returnType = (type | void) \n subroutineType = ("constructor" | "function" | "method") whitespace+\n SubroutineDec = subroutineType returnType jackIdentifier OpenParen ParameterList CloseParen SubroutineBody\n\n\n Parameter = type jackIdentifier\n Parameters = Parameter TrailingParameter*\n TrailingParameter = Comma Parameter\n ParameterList = Parameters?\n\n SubroutineBody = OpenBrace VarDec* Statement* CloseBrace\n\n var = "var" whitespace+\n VarDec = var type jackIdentifier TrailingIdentifier* Semi\n\n Statement = LetStatement | IfStatement | WhileStatement | DoStatement | ReturnStatement\n\n arrayAccessStart = jackIdentifier openSquare\n ArrayAccess = arrayAccessStart Expression CloseSquare\n\n let = "let" whitespace+\n LetTarget = ArrayAccess | jackIdentifier\n LetStatement = let LetTarget Equal Expression Semi\n\n IfStatement = "if" OpenParen Expression CloseParen OpenBrace Statement* CloseBrace ElseBlock?\n ElseBlock = "else" OpenBrace Statement* CloseBrace\n\n WhileStatement = "while" OpenParen Expression CloseParen OpenBrace Statement* CloseBrace\n\n do = "do" whitespace+\n DoStatement = do SubroutineCall Semi\n\n return = "return"\n returnWithSpace = "return" whitespace+\n ReturnStatement = EmptyReturn | ReturnValue\n EmptyReturn = return Semi\n ReturnValue = returnWithSpace Expression Semi\n\n op = "+" | "-" | "*" | "/" | "&" | "|" | "<" | ">" | "="\n ExpressionPart = op Term\n Expression = Term ExpressionPart*\n\n integerConstant = digit+\n stringConstant = doubleQuote (~doubleQuote ~newline any)* doubleQuote\n keywordConstant = "true" | "false" | "null" | "this"\n\n GroupedExpression = OpenParen Expression CloseParen\n\n unaryOp = "-" | "~"\n UnaryExpression = unaryOp Term\n\n Term = integerConstant | stringConstant | keywordConstant | SubroutineCall | ArrayAccess | jackIdentifier | GroupedExpression | UnaryExpression\n\n compoundIdentifier = jackIdentifier dot jackIdentifier\n SubroutineName = compoundIdentifier | jackIdentifier\n SubroutineCall = SubroutineName OpenParen ExpressionList CloseParen\n\n ExpressionList = Expressions?\n Expressions = Expression TrailingExpression*\n TrailingExpression = Comma Expression\n\n jackIdentifier = letter (alnum | underscore)*\n}',g=new Set(["int","boolean","char"]);const y=(0,f.qN)(m,h.lN),v=y.extendSemantics(h.JE);function b(e){return e.children.map((e=>e.statement))}v.addAttribute("Root",{Root(e){return this.class}}),v.addAttribute("class",{Class:(e,t,n,r,i,s)=>({name:{value:t.sourceString,span:(0,h.Ln)(t.source)},varDecs:r.children.map((e=>e.classVarDec)),subroutines:i.children.map((e=>e.subroutineDec))})}),v.addAttribute("classVarDec",{ClassVarDec:(e,t,n,r,i)=>({varType:e.sourceString.trim(),type:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},names:[n.sourceString,...r.children.map((e=>e.child(1).sourceString))]})}),v.addAttribute("subroutineDec",{SubroutineDec:(e,t,n,r,i,s,a)=>({type:e.sourceString.trim(),returnType:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},name:{value:n.sourceString,span:(0,h.Ln)(n.source)},parameters:i.parameterList,body:a.subroutineBody})}),v.addAttribute("parameter",{Parameter:(e,t)=>({type:{value:e.sourceString.trim(),span:(0,h.Ln)(e.source)},name:t.sourceString})}),v.addAttribute("parameterList",{ParameterList:e=>e.child(0)?.parameters??[]}),v.addAttribute("parameters",{Parameters:(e,t)=>[e.parameter,...t.children.map((e=>e.child(1).parameter))]}),v.addAttribute("subroutineBody",{SubroutineBody:(e,t,n,r)=>({varDecs:t.children.map((e=>e.varDec)),statements:b(n)})}),v.addAttribute("varDec",{VarDec:(e,t,n,r,i)=>({type:{value:t.sourceString.trim(),span:(0,h.Ln)(t.source)},names:[n.sourceString,...r.children.map((e=>e.child(1).sourceString))]})}),v.addAttribute("statement",{LetStatement(e,t,n,r,i){return"variable"==t.term.termType?{statementType:"letStatement",name:{value:t.term.name,span:t.term.span},value:r.expression,span:(0,h.Ln)(this.source)}:{statementType:"letStatement",name:t.term.name,arrayIndex:t.term.index,value:r.expression,span:(0,h.Ln)(this.source)}},IfStatement:(e,t,n,r,i,s,a,o)=>({statementType:"ifStatement",condition:n.expression,body:b(s),else:o.child(0)?.else??[]}),WhileStatement:(e,t,n,r,i,s,a)=>({statementType:"whileStatement",condition:n.expression,body:b(s)}),DoStatement:(e,t,n)=>({statementType:"doStatement",call:t.term}),EmptyReturn(e,t){return{statementType:"returnStatement",span:(0,h.Ln)(this.source)}},ReturnValue(e,t,n){return{statementType:"returnStatement",value:t.expression,span:(0,h.Ln)(this.source)}}}),v.addAttribute("else",{ElseBlock:(e,t,n,r)=>b(n)}),v.addAttribute("term",{integerConstant:e=>({termType:"numericLiteral",value:Number(e.sourceString)}),stringConstant(e,t,n){return{termType:"stringLiteral",value:this.sourceString.slice(1,-1)}},keywordConstant(e){return{termType:"keywordLiteral",value:this.sourceString}},SubroutineCall(e,t,n,r){return{termType:"subroutineCall",name:{value:e.sourceString,span:(0,h.Ln)(e.source)},parameters:n.expressionList,span:(0,h.Ln)(this.source)}},ArrayAccess(e,t,n){const r=e.child(0);return{termType:"arrayAccess",name:{value:r.sourceString,span:(0,h.Ln)(r.source)},index:t.expression,span:(0,h.Ln)(this.source)}},jackIdentifier(e,t){return{termType:"variable",name:`${e.sourceString}${t.sourceString}`,span:(0,h.Ln)(this.source)}},GroupedExpression:(e,t,n)=>({termType:"groupedExpression",expression:t.expression}),UnaryExpression:(e,t)=>({termType:"unaryExpression",op:e.sourceString,term:t.term})}),v.addAttribute("expressionList",{ExpressionList:e=>e.child(0)?.expressions??[]}),v.addAttribute("expressions",{Expressions:(e,t)=>[e.expression,...t.children.map((e=>e.child(1).expression))]}),v.addAttribute("expression",{Expression:(e,t)=>({nodeType:"expression",term:e.term,rest:t.children.map((e=>e.expressionPart))})}),v.addAttribute("expressionPart",{ExpressionPart:(e,t)=>({op:e.sourceString,term:t.term})});const w={parser:y,grammar:m,semantics:v,parse:(0,h.Q5)(y,v,(e=>e.class))};var S=n(2548);class x{id;hasReturn=!1;children=[];static count=0;constructor(){this.id=x.count,x.count+=1}alwaysReturns(){const e=new Set;return function t(n){if(n.hasReturn)return!0;if(0===n.children.length)return!1;e.add(n);for(const r of n.children)if(!e.has(r)&&!t(r))return!1;return!0}(this)}getLeafs(){const e=new Set,t=new Set;return function n(r){if(0===r.children.length)e.add(r);else{t.add(r);for(const e of r.children)t.has(e)||n(e)}}(this),Array.from(e)}}function k(e,t,n){const i=new x;n.children.push(i),n=i;const s=I(e.body,t),a=I(e.else,t);if((0,r.ys)(s))return s;if((0,r.ys)(a))return a;const o=(0,r.oA)(s),l=(0,r.oA)(a);n.children.push(o,l);const u=o.getLeafs().concat(l.getLeafs());n=new x;for(const r of u)r.children.push(n);return(0,r.Ok)(n)}function _(e,t,n){const i=new x;n.children.push(i),n=i;const s=I(e.body,t);if((0,r.ys)(s))return s;const a=(0,r.oA)(s);for(const r of a.getLeafs())r.children.push(n);const o=new x;return n.children.push(a,o),n=o,(0,r.Ok)(n)}function I(e,t){const n=new x;let i,s=n;for(const a of e)switch(a.statementType){case"letStatement":case"doStatement":break;case"returnStatement":if("void"!=t&&void 0==a.value)return(0,r._)((0,h.$5)("A non void subroutine must return a value",a.span));s.hasReturn=!0;break;case"ifStatement":if(i=k(a,t,s),(0,r.ys)(i))return i;s=(0,r.oA)(i);break;case"whileStatement":if(i=_(a,t,s),(0,r.ys)(i))return i;s=(0,r.oA)(i)}return(0,r.Ok)(n)}function A(e){const t=I(e.body.statements,e.returnType.value);return(0,r.ys)(t)?t:(0,r.oA)(t).alwaysReturns()?(0,r.Ok)():(0,r._)((0,h.$5)(`Subroutine ${e.name.value}: not all code paths return a value`,e.name.span))}const C=new Set(["Sys","Screen","Output","Keyboard","String","Array","Memory","Math"]);function E(e){return C.has(e)}function O(e){return void 0!=e.message}function P(e){return e.charAt(0).toUpperCase()+e.slice(1)}function L(e){const t=new Set;for(const n of e.subroutines){if(t.has(n.name.value))return(0,r._)((0,h.$5)(`Subroutine ${n.name.value} already declared`,n.name.span));t.add(n.name.value);const e=A(n);if((0,r.ys)(e))return e}return(0,r.Ok)()}const R={"+":"add","-":"sub","*":"call Math.multiply 2","/":"call Math.divide 2","&":"and","|":"or","<":"lt",">":"gt","=":"eq"},N={"-":"neg","~":"not"};class T{instructions=[];globalSymbolTable={};localSymbolTable={};className="";classes={};labelNum=0;fieldNum=0;staticNum=0;localNum=0;get output(){return Array.from(this.instructions)}varData(e){return this.localSymbolTable[e]||this.globalSymbolTable[e]}var(e){let t,n;"string"==typeof e?t=e:"string"==typeof e.name?(t=e.name,n=e.span):(t=e.name.value,n=e.name.span);const r=this.varData(t);if(!r)throw(0,h.$5)(`Undeclared variable ${t}`,n);return`${r.segment} ${r.index}`}write(...e){this.instructions.push(...e)}getLabel(){const e=`L${this.labelNum}`;return this.labelNum+=1,e}compile(e,t){this.className=e.name.value,this.classes=t??{};for(const n of e.varDecs)this.compileClassVarDec(n);for(const n of e.subroutines)this.compileSubroutineDec(n);return(0,r.Ok)(this.instructions.map((e=>e.startsWith("function")||e.startsWith("label")?e:" ".concat(e))).join("\n"))}validateType(e,t){var n;if(n=e,!(g.has(n)||E(e)||this.classes[e]))throw(0,h.$5)(`Unknown type ${e}`,t)}validateReturnType(e,t){"void"!=e&&this.validateType(e,t)}compileClassVarDec(e){this.validateType(e.type.value,e.type.span);for(const t of e.names)"field"==e.varType?(this.globalSymbolTable[t]={type:e.type.value,segment:"this",index:this.fieldNum},this.fieldNum+=1):(this.globalSymbolTable[t]={type:e.type.value,segment:"static",index:this.staticNum},this.staticNum+=1)}compileVarDec(e){this.validateType(e.type.value,e.type.span);for(const t of e.names)this.localSymbolTable[t]={type:e.type.value,segment:"local",index:this.localNum},this.localNum+=1}registerArgs(e,t=!1){let n=0;for(const r of e)this.validateType(r.type.value,r.type.span),this.localSymbolTable[r.name]={type:r.type.value,segment:"argument",index:n+(t?1:0)},n+=1}compileSubroutineDec(e){switch(this.validateReturnType(e.returnType.value,e.returnType.span),e.type){case"method":this.compileMethod(e);break;case"constructor":this.compileConstructor(e);break;case"function":this.compileFunction(e)}}compileSubroutineStart(e,t=!1){this.localSymbolTable={},this.localNum=0,this.registerArgs(e.parameters,t);const n=e.body.varDecs.map((e=>e.names.length)).reduce(((e,t)=>e+t),0);this.write(`function ${this.className}.${e.name.value} ${n}`);for(const r of e.body.varDecs)this.compileVarDec(r)}compileFunction(e){this.compileSubroutineStart(e),this.compileStatements(e.body.statements)}compileMethod(e){this.compileSubroutineStart(e,!0),this.write("push argument 0","pop pointer 0"),this.compileStatements(e.body.statements)}compileConstructor(e){this.compileSubroutineStart(e),this.write(`push constant ${this.fieldNum}`,"call Memory.alloc 1","pop pointer 0"),this.compileStatements(e.body.statements)}compileExpression(e){this.compileTerm(e.term);for(const t of e.rest)this.compileTerm(t.term),this.compileOp(t.op)}compileOp(e){this.write(R[e])}compileTerm(e){switch(e.termType){case"numericLiteral":this.write(`push constant ${e.value}`);break;case"stringLiteral":this.compileStringLiteral(e.value);break;case"variable":this.write(`push ${this.var(e)}`);break;case"keywordLiteral":this.compileKeywordLiteral(e.value);break;case"subroutineCall":this.compileSubroutineCall(e);break;case"arrayAccess":this.compileExpression(e.index),this.write(`push ${this.var(e)}`,"add","pop pointer 1","push that 0");break;case"groupedExpression":this.compileExpression(e.expression);break;case"unaryExpression":this.compileTerm(e.term),this.write(N[e.op])}}validateArgNum(e,t,n){const r=n.parameters.length;if(t!=r)throw(0,h.$5)(`${e} expected ${t} arguments, got ${r}`,n.span)}validateSubroutineCall(e,t,n,r){const i=S.P[`${e}.${t}`];if(!i){if(E(e))throw(0,h.$5)(`Class ${e} doesn't contain a subroutine ${t}`,n.span);if(this.classes[e]){for(const i of this.classes[e].subroutines)if(i.name.value==t){if("method"==i.type&&!r)throw(0,h.$5)(`Method ${e}.${t} was called as a function/constructor`,n.name.span);if("method"!=i.type&&r)throw(0,h.$5)(`${P(i.name.value)} ${e}.${t} was called as a method`,n.name.span);return void this.validateArgNum(`${e}.${t}`,i.parameters.length,n)}throw(0,h.$5)(`Class ${e} doesn't contain a function/constructor ${t}`,n.name.span)}throw(0,h.$5)(`Class ${e} doesn't exist`,n.name.span)}if("method"==i.type&&!r)throw(0,h.$5)(`Method ${e}.${t} was called as a function/constructor`,n.name.span);if("method"!=i.type&&r)throw(0,h.$5)(`${P(i.type)} ${e}.${t} was called as a method`,n.name.span);this.validateArgNum(`${e}.${t}`,r?i.nArgs-1:i.nArgs,n)}classifySubroutineCall(e){let t,n="",r="";if(e.name.value.includes(".")){const[i,s]=e.name.value.split(".",2);r=s;const a=this.varData(i);a?(t=this.var(i),n=a.type):n=i}else t="pointer 0",n=this.className,r=e.name.value;return this.validateSubroutineCall(n,r,e,void 0!=t),{className:n,subroutineName:r,object:t}}compileSubroutineCall(e){const t=this.classifySubroutineCall(e);t.object&&this.write(`push ${t.object}`);for(const n of e.parameters)this.compileExpression(n);this.write(`call ${t.className}.${t.subroutineName} ${e.parameters.length+(t.object?1:0)}`)}compileStringLiteral(e){this.write(`push constant ${e.length}`,"call String.new 1");for(let t=0;t!O(t)))),i={};for(const[a,o]of Object.entries(t))if(O(o))i[a]=o;else try{const e=(new T).compile(o,n);(0,r.ys)(e)?i[a]=(0,r._)(e):i[a]=(0,r.Ok)(e)}catch(s){i[a]=s}return i}(e.files);e.compiled={};for(const[n,r]of Object.entries(t))e.compiled[n]="string"===typeof r?{valid:!0,vm:r}:{valid:!1,error:r};e.isValid=Object.keys(e.files).every((t=>e.compiled[t].valid))},writeCompiled(e){if(Object.values(e.compiled).every((e=>e.valid)))for(const[t,r]of Object.entries(e.compiled))r.vm&&n?.writeFile(`${t}.vm`,r.vm);e.isCompiled=!0},setSelected(e,t){e.selected=t},setTitle(e,t){e.title=t}},actions:{async loadProject(e){this.reset(),n=e,t.current({action:"setFs",payload:n});const r={};for(const t of(await n.scandir("/")).filter((e=>e.isFile()&&e.name.endsWith(".jack"))))r[t.name.replace(".jack","")]=await n.readFile(t.name);this.loadFiles(r)},async loadFiles(e){t.current({action:"setFiles",payload:e}),Object.entries(e).length>0&&t.current({action:"setSelected",payload:Object.keys(e)[0]})},async writeFile(e,r){r??=function(e){return`class ${e} {\n\n}\n`}(e),t.current({action:"setFile",payload:{name:e,content:r}}),n&&await n.writeFile(`${e}.jack`,r)},async reset(){n=void 0,t.current({action:"reset"})},async compile(){t.current({action:"writeCompiled"})}}}}var F=n(6554),j=n(6418),D=n(7365),$=n(1296),z=n(4256);function V(e,t){const n=new z.X(e.cpu.RAM,t),r=new z.X(e.cpu.ROM,t),s=new z.X(e.cpu.Screen,t),a=new i.PC(new z.X(e.cpu.RAM,t));return{A:e.cpu.A,D:e.cpu.D,PC:e.cpu.PC,RAM:n,ROM:r,Screen:s,Keyboard:a}}function U(){const{fs:e,setStatus:t,storage:n}=(0,o.useContext)(u.L),s=(0,o.useRef)((()=>{})),{initialState:a,reducers:c,actions:p}=(0,o.useMemo)((()=>function(e,t,n,s){let a=new j.b,o=!0,l=!0,u="",c=[],p="";const d={update(e){e.sim=V(a,s),e.test.highlight=a.currentStep?.span,e.test.valid=l,e.path=u,e.tests=Array.from(c),e.test.name=p},setTest(e,{tst:t,cmp:n}){e.test.tst=t??e.test.tst,e.test.cmp=n??e.test.cmp,e.test.out=""},testStep(e){e.test.out=a.log(),this.update(e)},testFinished(e){if(""===e.test.cmp.trim())return;const n=(0,D.U)(e.test.cmp.trim(),a.log().trim());t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},setTitle(e,t){e.title=t},updateConfig(e,t){e.config={...e.config,...t}}},h={tick(){a.cpu.tick()},setAnimate(e){o=e},async setPath(t){u=t;const n=u.split("/").slice(0,-1).join("/"),r=await e.scandir(n);c=r.filter((e=>e.name.endsWith(".tst"))).map((e=>e.name)),c.length>0?this.loadTest(c[0]):(p="Default",this.compileTest("repeat {\n ticktock;\n}","")),s.current({action:"update"})},async testStep(){const e=await a.step();return(o||e)&&s.current({action:"testStep"}),e&&s.current({action:"testFinished"}),e},resetRAM(){a.cpu.RAM.loadBytes([]),s.current({action:"update"}),t("Reset RAM")},toggleUseTest(){s.current({action:"update"})},reset(){a.reset(),s.current({action:"update"})},clear(){this.replaceROM(new i.n9),this.resetRAM(),this.clearTest(),this.reset(),s.current({action:"setTitle",payload:void 0})},clearTest(){this.compileTest("repeat {\n ticktock;\n}",""),s.current({action:"update"})},replaceROM(e){a=new j.b(e),this.clearTest()},compileTest(e,n){s.current({action:"setTest",payload:{tst:e,cmp:n}});const i=F.uG.parse(e);return(0,r.ys)(i)?(t(`Failed to parse test - ${(0,r._)(i).message}`),l=!1,s.current({action:"update"}),!1):(l=!0,a=j.b.from((0,r.Ok)(i),a.cpu.ROM,t),s.current({action:"update"}),!0)},async loadTest(n){const i=u.split("/").slice(0,-1).join("/"),s=await(0,$.g)(e,`${i}/${n}`);if((0,r.ys)(s))return void t("Failed to load test");p=n;const{tst:a,cmp:o}=(0,r.oA)(s);this.compileTest(a,o??"")}};return{initialState:{sim:V(a,s),test:{highlight:a.currentStep?.span,name:"",tst:"repeat {\n ticktock;\n}",cmp:"",out:"",valid:!0},path:"",tests:[],config:{romFormat:"asm",ramFormat:"dec",screenScale:1,speed:2,testSpeed:2}},reducers:d,actions:h}}(e,t,0,s)),[e,t,n,s]),[d,h]=(0,l.A)(c,a);return s.current=h,{state:d,dispatch:s,actions:p}}var B=n(8849),W=n(782);function H(){const[e,t]=(0,o.useState)(),[n,r]=(0,o.useState)(),i=(0,d.C1)(),s=U(),a=p(),c=(0,B.vw)(),h=function(){const{setStatus:e}=(0,o.useContext)(u.L),t=(0,o.useRef)((()=>{})),{initialState:n,reducers:r,actions:i}=(0,o.useMemo)((()=>M(0,t)),[e,t]),[s,a]=(0,l.A)(r,n);return t.current=a,{state:s,dispatch:t,actions:i}}();return(0,o.useEffect)((()=>{i.actions.initialize()}),[i.actions]),(0,o.useEffect)((()=>{c.actions.initialize()}),[c.actions]),(0,o.useEffect)((()=>{switch(n){case"cpu":t(s.state.title);break;case"asm":t(a.state.title);break;case"vm":t(c.state.title);break;case"compiler":t(h.state.title);break;default:t(void 0)}}),[n,s.state.title,a.state.title,c.state.title,h.state.title]),{setTool:r,title:e,stores:{chip:i,cpu:s,asm:a,vm:c,compiler:h}}}const G=(0,o.createContext)({});function q(e){const t=H();return(0,W.jsx)(G.Provider,{value:t,children:e.children})}},3015:(e,t,n)=>{n.d(t,{I:()=>i});var r=n(782);const i=({name:e})=>(0,r.jsx)("span",{className:"material-symbols-outlined",children:e})},3508:(e,t,n)=>{n.d(t,{s:()=>i});var r=n(8878);function i(){const[e,t]=(0,r.useState)(!1);return{isOpen:e,open(){t(!0)},close(){t(!1)}}}},6073:(e,t,n)=>{n.d(t,{Nk:()=>g,g3:()=>d});var r=n(6458),i=n(910),s=n(8878),a=n(8029),o=n(3015),l=n(3508),u=n(3569),c=n(782);const p="file selected";function d(){const e=(0,l.s)(),[t,n]=(0,s.useState)(),[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1),o=(0,s.useRef)(),u=(0,s.useCallback)((async t=>{var r;return"string"===typeof t.suffix&&(t.suffix=[t.suffix]),n(t.suffix),i(null!==(r=t.allowFolders)&&void 0!==r&&r),e.open(),new Promise((e=>{o.current=e}))}),[e,o]);return{...e,select:async e=>(a.current=!1,await u(e)),selectAllowLocal:async e=>(a.current=!0,u(e)),[p]:o,suffix:t,allowFolders:r,allowLocal:a.current}}const h=({onClick:e,onDoubleClick:t,stats:n,highlighted:r=!1,disabled:i=!1})=>(0,c.jsx)("div",{children:(0,c.jsxs)("button",{className:"flex row justify-start outline "+(r?"":"secondary"),style:{textAlign:"left",color:i?"var(--disabled)":void 0},onClick:n=>{1==n.detail?null===e||void 0===e||e():2==n.detail&&(null===t||void 0===t||t())},children:[(0,c.jsx)(o.I,{name:n.isDirectory()?"folder":"draft"}),n.name]})});async function f(e,t,n){for(const r of await t.scandir(n))if(r.isDirectory()){const i=e.folder(r.name);i&&await f(i,t,`${n}/${r.name}`)}else e.file(r.name,await t.readFile(`${n}/${r.name}`))}function m(e,t){return t.map((t=>e.endsWith(t))).reduce(((e,t)=>e||t),!1)}const g=()=>{const{fs:e,setStatus:t}=(0,s.useContext)(i.L),{filePicker:n}=(0,s.useContext)(a.BR),[o,l]=(0,s.useState)([]),[d,g]=(0,s.useState)(""),y=e.cwd();(0,s.useEffect)((()=>{"/"==e.cwd()&&v("projects")}),[e]),(0,s.useEffect)((()=>{e.scandir(e.cwd()).then((e=>{l(e)}))}),[e,y,l]);const v=(0,s.useCallback)((t=>{e.cd(t),e.scandir(e.cwd()).then((e=>{l(e)}))}),[e,g,l]),b=(0,s.useCallback)((t=>{g(`${"/"==e.cwd()?"":e.cwd()}/${t}`)}),[g]),w=(0,s.useCallback)((()=>{var e,t;n.close(),null===(e=(t=n[p]).current)||void 0===e||e.call(t,d)}),[d,n,t]),S=(0,s.useRef)(null),x=(0,s.useRef)(null);return(0,c.jsxs)("dialog",{open:n.isOpen,children:[(0,c.jsx)("input",{type:"file",ref:S,onChange:async()=>{if(S.current&&S.current.files){var e,t;const r=S.current.files[0];null===(e=(t=n[p]).current)||void 0===e||e.call(t,{name:r.name,content:await r.text()}),n.close()}},style:{display:"none"}}),(0,c.jsxs)("article",{className:"file-select flex",children:[(0,c.jsxs)("header",{children:[(0,c.jsx)("p",{children:(0,c.jsx)(r.x6,{id:"+yPBXI"})}),(0,c.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:e=>{e.preventDefault(),n.close()},children:"close"})]}),(0,c.jsxs)("main",{children:[(0,c.jsx)("a",{ref:x,style:{display:"none"}}),(0,c.jsx)("div",{children:(0,c.jsx)("b",{children:e.cwd()})}),"/"!==e.cwd()&&(0,c.jsx)(h,{stats:{isDirectory:()=>!0,isFile:()=>!1,name:".."},onDoubleClick:()=>v("..")}),o.map((e=>(0,c.jsx)(h,{stats:e,highlighted:e.name===d.split("/").pop(),onClick:()=>b(e.name),onDoubleClick:()=>{e.isDirectory()&&v(e.name)},disabled:e.name.includes(".")&&void 0!=n.suffix&&!m(e.name,n.suffix)},e.name)))]}),(0,c.jsxs)("footer",{children:[(0,c.jsx)("button",{disabled:!d||".."==d||void 0!=n.suffix&&d.includes(".")&&!m(d,n.suffix)||!n.allowFolders&&!d.includes("."),onClick:w,children:"Select"}),n.allowLocal&&(0,c.jsx)("button",{onClick:()=>{var e;null===(e=S.current)||void 0===e||e.click()},children:"Select local file"}),(0,c.jsx)("button",{onClick:async()=>{var t;if(!x.current)return;const n=await(0,u.e)();await f(n,e,d);const r=await n.generateAsync({type:"blob"}),i=URL.createObjectURL(r);x.current.href=i,x.current.download=null!==(t=d.split("/").pop())&&void 0!==t?t:d,x.current.click(),URL.revokeObjectURL(i)},"data-tooltip":"Download all files in this folder into a zip",disabled:""==d||d.includes("."),children:"Download"})]})]})]})}},3569:(e,t,n)=>{async function r(e){const t=await i();for(const r of e)t.file(r.name,await r.content);const n=await t.generateAsync({type:"blob"});return URL.createObjectURL(n)}async function i(){const{default:e}=await n.e(608).then(n.t.bind(n,5608,23));return new e}n.d(t,{e:()=>i,y:()=>r})},5270:(e,t,n)=>{n.d(t,{w:()=>v,dQ:()=>b,z1:()=>y});var r,i=n(1092),s=n(2469),a=n(8878),o=n(782);const l="/tracking/canTrack",u="yes",c="no",p="",d=[u,c];let h=!1;const f=null!==(r={NODE_ENV:"production",PUBLIC_URL:"/web-ide",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.GA4_ID)&&void 0!==r?r:"G-0VTR5BJFQP";function m(e){i.Ay.send({hitType:"pageview",page:e})}function g(e,t,n,r){var a,o;if(h)return;const l="string"===typeof e?{category:e,action:(0,s.Z1)(t),label:n&&r?{label:n,value:r}:void 0}:e;i.Ay.event({category:l.category,action:l.action,nonInteraction:!l.interaction,label:null===(a=l.label)||void 0===a?void 0:a.label,value:null===(o=l.label)||void 0===o?void 0:o.value})}function y(){var e;const t=null!==(e=localStorage[l])&&void 0!==e?e:p,[n,r]=(0,a.useState)(t===u),[s,o]=(0,a.useState)(d.includes(t)||"1"===navigator.doNotTrack);return{canTrack:n,haveAsked:s,accept:(0,a.useCallback)((()=>{localStorage[l]=u,r(!0),o(!0),i.Ay.initialize(f),i.Ay.send("pageview")}),[r,o]),reject:(0,a.useCallback)((()=>{localStorage[l]=c,r(!1),o(!0),h=!0}),[r,o]),trackEvent:g,trackPage:m}}function v(){const{accept:e,reject:t,haveAsked:n}=y(),[r,i]=(0,a.useState)(!n),s=(0,a.useCallback)((()=>{i(!1)}),[i]),l=(0,a.useCallback)((()=>{e(),s()}),[e,s]),u=(0,a.useCallback)((()=>{t(),s()}),[t,s]);return(0,o.jsx)(o.Fragment,{children:r&&(0,o.jsxs)("div",{id:"trackingBanner",className:"flex row",children:[(0,o.jsx)("div",{className:"flex-1",children:(0,o.jsx)(b,{})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("a",{href:"#reject",role:"button",className:"reject",onClick:u,children:"Reject"}),(0,o.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:l,children:"Accept"}),(0,o.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:s,children:"\ud835\uddb7"})]})]})})}function b(){return(0,o.jsxs)("p",{style:{margin:0},children:["This site uses Google Analytics to gather information that will improve the user experience. This only includes anonymous interaction data, and never shares your code."," ",(0,o.jsx)("a",{href:"www.google.com/policies/privacy/partners/",children:"How Google uses data."})]})}},3499:(e,t,n)=>{n.d(t,{Ay:()=>m,It:()=>f,p3:()=>h});var r=n(8878),i=n(782);const s=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(787)]).then(n.bind(n,7737)))),a=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(744)]).then(n.bind(n,5178)))),o=(0,r.lazy)((()=>n.e(519).then(n.bind(n,5519)))),l=(0,r.lazy)((()=>n.e(323).then(n.bind(n,1323)))),u=(0,r.lazy)((()=>Promise.all([n.e(537),n.e(34)]).then(n.bind(n,1496)))),c=(0,r.lazy)((()=>n.e(598).then(n.bind(n,6598)))),p=(0,r.lazy)((()=>n.e(408).then(n.bind(n,2408)))),d=(0,r.lazy)((()=>Promise.all([n.e(656),n.e(614)]).then(n.bind(n,3614)))),h="lastRoute",f={chip:"Hardware Simulator",cpu:"CPU Emulator",asm:"Assembler",vm:"VM Emulator",bitmap:"Bitmap Editor",compiler:"Jack Compiler"},m={chip:{href:"/chip",tool:"chip",target:(0,i.jsx)(s,{})},cpu:{href:"/cpu",tool:"cpu",target:(0,i.jsx)(a,{})},asm:{href:"/asm",tool:"asm",target:(0,i.jsx)(o,{})},vm:{href:"/vm",tool:"vm",target:(0,i.jsx)(u,{})},compiler:{href:"/compiler",tool:"compiler",target:(0,i.jsx)(c,{})},bitmap:{href:"/bitmap",tool:"bitmap",target:(0,i.jsx)(l,{})},util:{href:"/util",target:(0,i.jsx)(p,{})},about:{href:"/about",target:(0,i.jsx)(d,{})}}},1642:(e,t,n)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;tp,Gh:()=>N,HS:()=>T,Oi:()=>o,Rr:()=>d,pX:()=>$,pb:()=>O,rc:()=>i,tH:()=>D,ue:()=>m,yD:()=>R,zR:()=>a}),function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(i||(i={}));const s="popstate";function a(e){return void 0===e&&(e={}),h((function(e,t){let{pathname:n,search:r,hash:i}=e.location;return c("",{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"===typeof t?t:p(t)}),null,e)}function o(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function l(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function u(e,t){return{usr:e.state,key:e.key,idx:t}}function c(e,t,n,i){return void 0===n&&(n=null),r({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?d(t):t,{state:n,key:t&&t.key||i||Math.random().toString(36).substr(2,8)})}function p(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(t+="#"===r.charAt(0)?r:"#"+r),t}function d(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function h(e,t,n,a){void 0===a&&(a={});let{window:l=document.defaultView,v5Compat:d=!1}=a,h=l.history,f=i.Pop,m=null,g=y();function y(){return(h.state||{idx:null}).idx}function v(){f=i.Pop;let e=y(),t=null==e?null:e-g;g=e,m&&m({action:f,location:w.location,delta:t})}function b(e){let t="null"!==l.location.origin?l.location.origin:l.location.href,n="string"===typeof e?e:p(e);return n=n.replace(/ $/,"%20"),o(t,"No window.location.(origin|href) available to create URL for href: "+n),new URL(n,t)}null==g&&(g=0,h.replaceState(r({},h.state,{idx:g}),""));let w={get action(){return f},get location(){return e(l,h)},listen(e){if(m)throw new Error("A history only accepts one active listener");return l.addEventListener(s,v),m=e,()=>{l.removeEventListener(s,v),m=null}},createHref:e=>t(l,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){f=i.Push;let r=c(w.location,e,t);n&&n(r,e),g=y()+1;let s=u(r,g),a=w.createHref(r);try{h.pushState(s,"",a)}catch(o){if(o instanceof DOMException&&"DataCloneError"===o.name)throw o;l.location.assign(a)}d&&m&&m({action:f,location:w.location,delta:1})},replace:function(e,t){f=i.Replace;let r=c(w.location,e,t);n&&n(r,e),g=y();let s=u(r,g),a=w.createHref(r);h.replaceState(s,"",a),d&&m&&m({action:f,location:w.location,delta:0})},go:e=>h.go(e)};return w}var f;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(f||(f={}));new Set(["lazy","caseSensitive","path","id","index","children"]);function m(e,t,n){void 0===n&&(n="/");let r=O(("string"===typeof t?d(t):t).pathname||"/",n);if(null==r)return null;let i=g(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]));return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(i);let s=null;for(let a=0;null==s&&a{let a={relativePath:void 0===s?e.path||"":s,caseSensitive:!0===e.caseSensitive,childrenIndex:i,route:e};a.relativePath.startsWith("/")&&(o(a.relativePath.startsWith(r),'Absolute route path "'+a.relativePath+'" nested under path "'+r+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),a.relativePath=a.relativePath.slice(r.length));let l=T([r,a.relativePath]),u=n.concat(a);e.children&&e.children.length>0&&(o(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),g(e.children,t,u,l)),(null!=e.path||e.index)&&t.push({path:l,score:I(l,e.index),routesMeta:u})};return e.forEach(((e,t)=>{var n;if(""!==e.path&&null!=(n=e.path)&&n.includes("?"))for(let r of y(e.path))i(e,t,r);else i(e,t)})),t}function y(e){let t=e.split("/");if(0===t.length)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(0===r.length)return i?[s,""]:[s];let a=y(r.join("/")),o=[];return o.push(...a.map((e=>""===e?s:[s,e].join("/")))),i&&o.push(...a),o.map((t=>e.startsWith("/")&&""===t?"/":t))}const v=/^:[\w-]+$/,b=3,w=2,S=1,x=10,k=-2,_=e=>"*"===e;function I(e,t){let n=e.split("/"),r=n.length;return n.some(_)&&(r+=k),t&&(r+=w),n.filter((e=>!_(e))).reduce(((e,t)=>e+(v.test(t)?b:""===t?S:x)),r)}function A(e,t){let{routesMeta:n}=e,r={},i="/",s=[];for(let a=0;a(r.push({paramName:t,isOptional:null!=n}),n?"/?([^\\/]+)?":"/([^\\/]+)")));e.endsWith("*")?(r.push({paramName:"*"}),i+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":""!==e&&"/"!==e&&(i+="(?:(?=\\/|$))");let s=new RegExp(i,t?void 0:"i");return[s,r]}(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce(((e,t,n)=>{let{paramName:r,isOptional:i}=t;if("*"===r){let e=o[n]||"";a=s.slice(0,s.length-e.length).replace(/(.)\/+$/,"$1")}const l=o[n];return e[r]=i&&!l?void 0:(l||"").replace(/%2F/g,"/"),e}),{}),pathname:s,pathnameBase:a,pattern:e}}function E(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return l(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function O(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&"/"!==r?null:e.slice(n)||"/"}function P(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the `to."+n+'` field. Alternatively you may provide the full path as a string in and the router will parse it for you.'}function L(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function R(e,t){let n=L(e);return t?n.map(((t,n)=>n===e.length-1?t.pathname:t.pathnameBase)):n.map((e=>e.pathnameBase))}function N(e,t,n,i){let s;void 0===i&&(i=!1),"string"===typeof e?s=d(e):(s=r({},e),o(!s.pathname||!s.pathname.includes("?"),P("?","pathname","search",s)),o(!s.pathname||!s.pathname.includes("#"),P("#","pathname","hash",s)),o(!s.search||!s.search.includes("#"),P("#","search","hash",s)));let a,l=""===e||""===s.pathname,u=l?"/":s.pathname;if(null==u)a=n;else{let e=t.length-1;if(!i&&u.startsWith("..")){let t=u.split("/");for(;".."===t[0];)t.shift(),e-=1;s.pathname=t.join("/")}a=e>=0?t[e]:"/"}let c=function(e,t){void 0===t&&(t="/");let{pathname:n,search:r="",hash:i=""}="string"===typeof e?d(e):e,s=n?n.startsWith("/")?n:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(n,t):t;return{pathname:s,search:F(r),hash:j(i)}}(s,a),p=u&&"/"!==u&&u.endsWith("/"),h=(l||"."===u)&&n.endsWith("/");return c.pathname.endsWith("/")||!p&&!h||(c.pathname+="/"),c}const T=e=>e.join("/").replace(/\/\/+/g,"/"),M=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),F=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",j=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class D extends Error{}function $(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}const z=["post","put","patch","delete"],V=(new Set(z),["get",...z]);new Set(V),new Set([301,302,303,307,308]),new Set([307,308]);Symbol("deferred")},2777:(e,t,n)=>{var r=n(8878),i=n(7116);function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;nt}return!1}(t,n,i,r)&&(n=null),r||null===i?function(e){return!!p.call(f,e)||!p.call(h,e)&&(d.test(e)?f[e]=!0:(h[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=null===n?3!==i.type&&"":n:(t=i.attributeName,r=i.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(i=i.type)||4===i&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!1,!1)})),g.xlinkHref=new m("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!0,!0)}));var w=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for("react.element"),x=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),C=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),R=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var N=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var T=Symbol.iterator;function M(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=T&&e[T]||e["@@iterator"])?e:null}var F,j=Object.assign;function D(e){if(void 0===F)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||""}return"\n"+F+e}var $=!1;function z(e,t){if(!e||$)return"";$=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&"string"===typeof u.stack){for(var i=u.stack.split("\n"),s=r.stack.split("\n"),a=i.length-1,o=s.length-1;1<=a&&0<=o&&i[a]!==s[o];)o--;for(;1<=a&&0<=o;a--,o--)if(i[a]!==s[o]){if(1!==a||1!==o)do{if(a--,0>--o||i[a]!==s[o]){var l="\n"+i[a].replace(" at new "," at ");return e.displayName&&l.includes("")&&(l=l.replace("",e.displayName)),l}}while(1<=a&&0<=o);break}}}finally{$=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?D(e):""}function V(e){switch(e.tag){case 5:return D(e.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return e=z(e.type,!1);case 11:return e=z(e.type.render,!1);case 1:return e=z(e.type,!0);default:return""}}function U(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case k:return"Fragment";case x:return"Portal";case I:return"Profiler";case _:return"StrictMode";case O:return"Suspense";case P:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case C:return(e.displayName||"Context")+".Consumer";case A:return(e._context.displayName||"Context")+".Provider";case E:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case L:return null!==(t=e.displayName||null)?t:U(e.type)||"Memo";case R:t=e._payload,e=e._init;try{return U(e(t))}catch(n){}}return null}function B(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return U(t);case 8:return t===_?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof t)return t.displayName||t.name||null;if("string"===typeof t)return t}return null}function W(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function H(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function G(e){e._valueTracker||(e._valueTracker=function(e){var t=H(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function q(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=H(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function K(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Q(e,t){var n=t.checked;return j({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function Y(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=W(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function X(e,t){null!=(t=t.checked)&&b(e,"checked",t,!1)}function J(e,t){X(e,t);var n=W(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?ee(e,t.type,n):t.hasOwnProperty("defaultValue")&&ee(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Z(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function ee(e,t,n){"number"===t&&K(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var te=Array.isArray;function ne(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction((function(){return ce(e,t)}))}:ce);function de(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var he={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fe=["Webkit","ms","Moz","O"];function me(e,t,n){return null==t||"boolean"===typeof t||""===t?"":n||"number"!==typeof t||0===t||he.hasOwnProperty(e)&&he[e]?(""+t).trim():t+"px"}function ge(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),i=me(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}Object.keys(he).forEach((function(e){fe.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),he[t]=he[e]}))}));var ye=j({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ve(e,t){if(t){if(ye[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(s(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(s(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(s(62))}}function be(e,t){if(-1===e.indexOf("-"))return"string"===typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var we=null;function Se(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,ke=null,_e=null;function Ie(e){if(e=bi(e)){if("function"!==typeof xe)throw Error(s(280));var t=e.stateNode;t&&(t=Si(t),xe(e.stateNode,e.type,t))}}function Ae(e){ke?_e?_e.push(e):_e=[e]:ke=e}function Ce(){if(ke){var e=ke,t=_e;if(_e=ke=null,Ie(e),t)for(e=0;e>>=0,0===e?32:31-(ot(e)/lt|0)|0},ot=Math.log,lt=Math.LN2;var ut=64,ct=4194304;function pt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function dt(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=268435455&n;if(0!==a){var o=a&~i;0!==o?r=pt(o):0!==(s&=a)&&(r=pt(s))}else 0!==(a=n&~i)?r=pt(a):0!==s&&(r=pt(s));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&i)&&((i=r&-r)>=(s=t&-t)||16===i&&0!==(4194240&s)))return t;if(0!==(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function yt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-at(t)]=n}function vt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-at(n),i=1<=Mn),Dn=String.fromCharCode(32),$n=!1;function zn(e,t){switch(e){case"keyup":return-1!==Nn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vn(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var Un=!1;var Bn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Bn[e.type]:"textarea"===t}function Hn(e,t,n,r){Ae(r),0<(t=Gr(t,"onChange")).length&&(n=new cn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gn=null,qn=null;function Kn(e){Dr(e,0)}function Qn(e){if(q(wi(e)))return e}function Yn(e,t){if("change"===e)return t}var Xn=!1;if(c){var Jn;if(c){var Zn="oninput"in document;if(!Zn){var er=document.createElement("div");er.setAttribute("oninput","return;"),Zn="function"===typeof er.oninput}Jn=Zn}else Jn=!1;Xn=Jn&&(!document.documentMode||9=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ur(r)}}function pr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?pr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function dr(){for(var e=window,t=K();t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=K((e=t.contentWindow).document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function fr(e){var t=dr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&pr(n.ownerDocument.documentElement,n)){if(null!==r&&hr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=void 0===r.end?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=cr(n,s);var a=cr(n,r);i&&a&&(1!==e.rangeCount||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&((t=t.createRange()).setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"===typeof n.focus&&n.focus(),n=0;n=document.documentMode,gr=null,yr=null,vr=null,br=!1;function wr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;br||null==gr||gr!==K(r)||("selectionStart"in(r=gr)&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},vr&&lr(vr,r)||(vr=r,0<(r=Gr(yr,"onSelect")).length&&(t=new cn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=gr)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xr={animationend:Sr("Animation","AnimationEnd"),animationiteration:Sr("Animation","AnimationIteration"),animationstart:Sr("Animation","AnimationStart"),transitionend:Sr("Transition","TransitionEnd")},kr={},_r={};function Ir(e){if(kr[e])return kr[e];if(!xr[e])return e;var t,n=xr[e];for(t in n)if(n.hasOwnProperty(t)&&t in _r)return kr[e]=n[t];return e}c&&(_r=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);var Ar=Ir("animationend"),Cr=Ir("animationiteration"),Er=Ir("animationstart"),Or=Ir("transitionend"),Pr=new Map,Lr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Rr(e,t){Pr.set(e,t),l(t,[e])}for(var Nr=0;Nrki||(e.current=xi[ki],xi[ki]=null,ki--)}function Ai(e,t){ki++,xi[ki]=e.current,e.current=t}var Ci={},Ei=_i(Ci),Oi=_i(!1),Pi=Ci;function Li(e,t){var n=e.type.contextTypes;if(!n)return Ci;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i,s={};for(i in n)s[i]=t[i];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ri(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Ni(){Ii(Oi),Ii(Ei)}function Ti(e,t,n){if(Ei.current!==Ci)throw Error(s(168));Ai(Ei,t),Ai(Oi,n)}function Mi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!==typeof r.getChildContext)return n;for(var i in r=r.getChildContext())if(!(i in t))throw Error(s(108,B(e)||"Unknown",i));return j({},n,r)}function Fi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ci,Pi=Ei.current,Ai(Ei,e),Ai(Oi,Oi.current),!0}function ji(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Mi(e,t,Pi),r.__reactInternalMemoizedMergedChildContext=e,Ii(Oi),Ii(Ei),Ai(Ei,e)):Ii(Oi),Ai(Oi,n)}var Di=null,$i=!1,zi=!1;function Vi(e){null===Di?Di=[e]:Di.push(e)}function Ui(){if(!zi&&null!==Di){zi=!0;var e=0,t=bt;try{var n=Di;for(bt=1;e>=a,i-=a,Yi=1<<32-at(t)+i|n<m?(g=p,p=null):g=p.sibling;var y=h(i,p,o[m],l);if(null===y){null===p&&(p=g);break}e&&p&&null===y.alternate&&t(i,p),s=a(y,s,m),null===c?u=y:c.sibling=y,c=y,p=g}if(m===o.length)return n(i,p),is&&Ji(i,m),u;if(null===p){for(;mg?(y=m,m=null):y=m.sibling;var b=h(i,m,v.value,u);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(i,m),o=a(b,o,g),null===p?c=b:p.sibling=b,p=b,m=y}if(v.done)return n(i,m),is&&Ji(i,g),c;if(null===m){for(;!v.done;g++,v=l.next())null!==(v=d(i,v.value,u))&&(o=a(v,o,g),null===p?c=v:p.sibling=v,p=v);return is&&Ji(i,g),c}for(m=r(i,m);!v.done;g++,v=l.next())null!==(v=f(m,i,g,v.value,u))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),o=a(v,o,g),null===p?c=v:p.sibling=v,p=v);return e&&m.forEach((function(e){return t(i,e)})),is&&Ji(i,g),c}return function e(r,s,a,l){if("object"===typeof a&&null!==a&&a.type===k&&null===a.key&&(a=a.props.children),"object"===typeof a&&null!==a){switch(a.$$typeof){case S:e:{for(var u=a.key,c=s;null!==c;){if(c.key===u){if((u=a.type)===k){if(7===c.tag){n(r,c.sibling),(s=i(c,a.props.children)).return=r,r=s;break e}}else if(c.elementType===u||"object"===typeof u&&null!==u&&u.$$typeof===R&&vs(u)===c.type){n(r,c.sibling),(s=i(c,a.props)).ref=gs(r,c,a),s.return=r,r=s;break e}n(r,c);break}t(r,c),c=c.sibling}a.type===k?((s=Mu(a.props.children,r.mode,l,a.key)).return=r,r=s):((l=Tu(a.type,a.key,a.props,null,r.mode,l)).ref=gs(r,s,a),l.return=r,r=l)}return o(r);case x:e:{for(c=a.key;null!==s;){if(s.key===c){if(4===s.tag&&s.stateNode.containerInfo===a.containerInfo&&s.stateNode.implementation===a.implementation){n(r,s.sibling),(s=i(s,a.children||[])).return=r,r=s;break e}n(r,s);break}t(r,s),s=s.sibling}(s=Du(a,r.mode,l)).return=r,r=s}return o(r);case R:return e(r,s,(c=a._init)(a._payload),l)}if(te(a))return m(r,s,a,l);if(M(a))return g(r,s,a,l);ys(r,a)}return"string"===typeof a&&""!==a||"number"===typeof a?(a=""+a,null!==s&&6===s.tag?(n(r,s.sibling),(s=i(s,a)).return=r,r=s):(n(r,s),(s=ju(a,r.mode,l)).return=r,r=s),o(r)):n(r,s)}}var ws=bs(!0),Ss=bs(!1),xs=_i(null),ks=null,_s=null,Is=null;function As(){Is=_s=ks=null}function Cs(e){var t=xs.current;Ii(xs),e._currentValue=t}function Es(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Os(e,t){ks=e,Is=_s=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(bo=!0),e.firstContext=null)}function Ps(e){var t=e._currentValue;if(Is!==e)if(e={context:e,memoizedValue:t,next:null},null===_s){if(null===ks)throw Error(s(308));_s=e,ks.dependencies={lanes:0,firstContext:e}}else _s=_s.next=e;return t}var Ls=null;function Rs(e){null===Ls?Ls=[e]:Ls.push(e)}function Ns(e,t,n,r){var i=t.interleaved;return null===i?(n.next=n,Rs(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ts(e,r)}function Ts(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Ms=!1;function Fs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function js(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ds(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function $s(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,0!==(2&El)){var i=r.pending;return null===i?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ts(e,n)}return null===(i=r.interleaved)?(t.next=t,Rs(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ts(e,n)}function zs(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}function Vs(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var i=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===s?i=s=a:s=s.next=a,n=n.next}while(null!==n);null===s?i=s=t:s=s.next=t}else i=s=t;return n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Us(e,t,n,r){var i=e.updateQueue;Ms=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,o=i.shared.pending;if(null!==o){i.shared.pending=null;var l=o,u=l.next;l.next=null,null===a?s=u:a.next=u,a=l;var c=e.alternate;null!==c&&((o=(c=c.updateQueue).lastBaseUpdate)!==a&&(null===o?c.firstBaseUpdate=u:o.next=u,c.lastBaseUpdate=l))}if(null!==s){var p=i.baseState;for(a=0,c=u=l=null,o=s;;){var d=o.lane,h=o.eventTime;if((r&d)===d){null!==c&&(c=c.next={eventTime:h,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,m=o;switch(d=t,h=n,m.tag){case 1:if("function"===typeof(f=m.payload)){p=f.call(h,p,d);break e}p=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null===(d="function"===typeof(f=m.payload)?f.call(h,p,d):f)||void 0===d)break e;p=j({},p,d);break e;case 2:Ms=!0}}null!==o.callback&&0!==o.lane&&(e.flags|=64,null===(d=i.effects)?i.effects=[o]:d.push(o))}else h={eventTime:h,lane:d,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===c?(u=c=h,l=p):c=c.next=h,a|=d;if(null===(o=o.next)){if(null===(o=i.shared.pending))break;o=(d=o).next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}if(null===c&&(l=p),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,null!==(t=i.shared.interleaved)){i=t;do{a|=i.lane,i=i.next}while(i!==t)}else null===s&&(i.shared.lanes=0);Fl|=a,e.lanes=a,e.memoizedState=p}}function Bs(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;tn?n:4,e(!0);var r=ia.transition;ia.transition={};try{e(!1),t()}finally{bt=n,ia.transition=r}}function Ha(){return va().memoizedState}function Ga(e,t,n){var r=tu(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ka(e))Qa(t,n);else if(null!==(n=Ns(e,t,n,r))){nu(n,e,r,eu()),Ya(n,t,r)}}function qa(e,t,n){var r=tu(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ka(e))Qa(t,i);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=s(a,n);if(i.hasEagerState=!0,i.eagerState=o,or(o,a)){var l=t.interleaved;return null===l?(i.next=i,Rs(t)):(i.next=l.next,l.next=i),void(t.interleaved=i)}}catch(u){}null!==(n=Ns(e,t,i,r))&&(nu(n,e,r,i=eu()),Ya(n,t,r))}}function Ka(e){var t=e.alternate;return e===aa||null!==t&&t===aa}function Qa(e,t){ca=ua=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ya(e,t,n){if(0!==(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}var Xa={readContext:Ps,useCallback:ha,useContext:ha,useEffect:ha,useImperativeHandle:ha,useInsertionEffect:ha,useLayoutEffect:ha,useMemo:ha,useReducer:ha,useRef:ha,useState:ha,useDebugValue:ha,useDeferredValue:ha,useTransition:ha,useMutableSource:ha,useSyncExternalStore:ha,useId:ha,unstable_isNewReconciler:!1},Ja={readContext:Ps,useCallback:function(e,t){return ya().memoizedState=[e,void 0===t?null:t],e},useContext:Ps,useEffect:Ta,useImperativeHandle:function(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Ra(4194308,4,Da.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ra(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ra(4,2,e,t)},useMemo:function(e,t){var n=ya();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ya();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ga.bind(null,aa,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ya().memoizedState=e},useState:Oa,useDebugValue:za,useDeferredValue:function(e){return ya().memoizedState=e},useTransition:function(){var e=Oa(!1),t=e[0];return e=Wa.bind(null,e[1]),ya().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=aa,i=ya();if(is){if(void 0===n)throw Error(s(407));n=n()}else{if(n=t(),null===Ol)throw Error(s(349));0!==(30&sa)||_a(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ta(Aa.bind(null,r,a,e),[e]),r.flags|=2048,Pa(9,Ia.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=ya(),t=Ol.identifierPrefix;if(is){var n=Xi;t=":"+t+"R"+(n=(Yi&~(1<<32-at(Yi)-1)).toString(32)+n),0<(n=pa++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=da++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Za={readContext:Ps,useCallback:Va,useContext:Ps,useEffect:Ma,useImperativeHandle:$a,useInsertionEffect:Fa,useLayoutEffect:ja,useMemo:Ua,useReducer:wa,useRef:La,useState:function(){return wa(ba)},useDebugValue:za,useDeferredValue:function(e){return Ba(va(),oa.memoizedState,e)},useTransition:function(){return[wa(ba)[0],va().memoizedState]},useMutableSource:xa,useSyncExternalStore:ka,useId:Ha,unstable_isNewReconciler:!1},eo={readContext:Ps,useCallback:Va,useContext:Ps,useEffect:Ma,useImperativeHandle:$a,useInsertionEffect:Fa,useLayoutEffect:ja,useMemo:Ua,useReducer:Sa,useRef:La,useState:function(){return Sa(ba)},useDebugValue:za,useDeferredValue:function(e){var t=va();return null===oa?t.memoizedState=e:Ba(t,oa.memoizedState,e)},useTransition:function(){return[Sa(ba)[0],va().memoizedState]},useMutableSource:xa,useSyncExternalStore:ka,useId:Ha,unstable_isNewReconciler:!1};function to(e,t){if(e&&e.defaultProps){for(var n in t=j({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function no(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:j({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var ro={isMounted:function(e){return!!(e=e._reactInternals)&&Ue(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Ds(r,i);s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=$s(e,s,i))&&(nu(t,e,i,r),zs(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Ds(r,i);s.tag=1,s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=$s(e,s,i))&&(nu(t,e,i,r),zs(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=eu(),r=tu(e),i=Ds(n,r);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),null!==(t=$s(e,i,r))&&(nu(t,e,r,n),zs(t,e,r))}};function io(e,t,n,r,i,s,a){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,s,a):!t.prototype||!t.prototype.isPureReactComponent||(!lr(n,r)||!lr(i,s))}function so(e,t,n){var r=!1,i=Ci,s=t.contextType;return"object"===typeof s&&null!==s?s=Ps(s):(i=Ri(t)?Pi:Ei.current,s=(r=null!==(r=t.contextTypes)&&void 0!==r)?Li(e,i):Ci),t=new t(n,s),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=ro,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function ao(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ro.enqueueReplaceState(t,t.state,null)}function oo(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Fs(e);var s=t.contextType;"object"===typeof s&&null!==s?i.context=Ps(s):(s=Ri(t)?Pi:Ei.current,i.context=Li(e,s)),i.state=e.memoizedState,"function"===typeof(s=t.getDerivedStateFromProps)&&(no(e,t,s,n),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&ro.enqueueReplaceState(i,i.state,null),Us(e,n,i,r),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4194308)}function lo(e,t){try{var n="",r=t;do{n+=V(r),r=r.return}while(r);var i=n}catch(s){i="\nError generating stack: "+s.message+"\n"+s.stack}return{value:e,source:t,stack:i,digest:null}}function uo(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function co(e,t){try{console.error(t.value)}catch(n){setTimeout((function(){throw n}))}}var po="function"===typeof WeakMap?WeakMap:Map;function ho(e,t,n){(n=Ds(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Wl||(Wl=!0,Hl=r),co(0,t)},n}function fo(e,t,n){(n=Ds(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"===typeof r){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){co(0,t)}}var s=e.stateNode;return null!==s&&"function"===typeof s.componentDidCatch&&(n.callback=function(){co(0,t),"function"!==typeof r&&(null===Gl?Gl=new Set([this]):Gl.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function mo(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new po;var i=new Set;r.set(t,i)}else void 0===(i=r.get(t))&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Iu.bind(null,e,t,n),t.then(e,e))}function go(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function yo(e,t,n,r,i){return 0===(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Ds(-1,1)).tag=2,$s(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=i,e)}var vo=w.ReactCurrentOwner,bo=!1;function wo(e,t,n,r){t.child=null===e?Ss(t,null,n,r):ws(t,e.child,n,r)}function So(e,t,n,r,i){n=n.render;var s=t.ref;return Os(t,i),r=ma(e,t,n,r,s,i),n=ga(),null===e||bo?(is&&n&&es(t),t.flags|=1,wo(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function xo(e,t,n,r,i){if(null===e){var s=n.type;return"function"!==typeof s||Ru(s)||void 0!==s.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Tu(n.type,null,r,t,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,ko(e,t,s,r,i))}if(s=e.child,0===(e.lanes&i)){var a=s.memoizedProps;if((n=null!==(n=n.compare)?n:lr)(a,r)&&e.ref===t.ref)return Wo(e,t,i)}return t.flags|=1,(e=Nu(s,r)).ref=t.ref,e.return=t,t.child=e}function ko(e,t,n,r,i){if(null!==e){var s=e.memoizedProps;if(lr(s,r)&&e.ref===t.ref){if(bo=!1,t.pendingProps=r=s,0===(e.lanes&i))return t.lanes=e.lanes,Wo(e,t,i);0!==(131072&e.flags)&&(bo=!0)}}return Ao(e,t,n,r,i)}function _o(e,t,n){var r=t.pendingProps,i=r.children,s=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0===(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ai(Nl,Rl),Rl|=n;else{if(0===(1073741824&n))return e=null!==s?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ai(Nl,Rl),Rl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==s?s.baseLanes:n,Ai(Nl,Rl),Rl|=r}else null!==s?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ai(Nl,Rl),Rl|=r;return wo(e,t,i,n),t.child}function Io(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ao(e,t,n,r,i){var s=Ri(n)?Pi:Ei.current;return s=Li(t,s),Os(t,i),n=ma(e,t,n,r,s,i),r=ga(),null===e||bo?(is&&r&&es(t),t.flags|=1,wo(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function Co(e,t,n,r,i){if(Ri(n)){var s=!0;Fi(t)}else s=!1;if(Os(t,i),null===t.stateNode)Bo(e,t),so(t,n,r),oo(t,n,r,i),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var l=a.context,u=n.contextType;"object"===typeof u&&null!==u?u=Ps(u):u=Li(t,u=Ri(n)?Pi:Ei.current);var c=n.getDerivedStateFromProps,p="function"===typeof c||"function"===typeof a.getSnapshotBeforeUpdate;p||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==r||l!==u)&&ao(t,a,r,u),Ms=!1;var d=t.memoizedState;a.state=d,Us(t,r,a,i),l=t.memoizedState,o!==r||d!==l||Oi.current||Ms?("function"===typeof c&&(no(t,n,c,r),l=t.memoizedState),(o=Ms||io(t,n,o,r,d,l,u))?(p||"function"!==typeof a.UNSAFE_componentWillMount&&"function"!==typeof a.componentWillMount||("function"===typeof a.componentWillMount&&a.componentWillMount(),"function"===typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"===typeof a.componentDidMount&&(t.flags|=4194308)):("function"===typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=u,r=o):("function"===typeof a.componentDidMount&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,js(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:to(t.type,o),a.props=u,p=t.pendingProps,d=a.context,"object"===typeof(l=n.contextType)&&null!==l?l=Ps(l):l=Li(t,l=Ri(n)?Pi:Ei.current);var h=n.getDerivedStateFromProps;(c="function"===typeof h||"function"===typeof a.getSnapshotBeforeUpdate)||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==p||d!==l)&&ao(t,a,r,l),Ms=!1,d=t.memoizedState,a.state=d,Us(t,r,a,i);var f=t.memoizedState;o!==p||d!==f||Oi.current||Ms?("function"===typeof h&&(no(t,n,h,r),f=t.memoizedState),(u=Ms||io(t,n,u,r,d,f,l)||!1)?(c||"function"!==typeof a.UNSAFE_componentWillUpdate&&"function"!==typeof a.componentWillUpdate||("function"===typeof a.componentWillUpdate&&a.componentWillUpdate(r,f,l),"function"===typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,f,l)),"function"===typeof a.componentDidUpdate&&(t.flags|=4),"function"===typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),a.props=r,a.state=f,a.context=l,r=u):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Eo(e,t,n,r,s,i)}function Eo(e,t,n,r,i,s){Io(e,t);var a=0!==(128&t.flags);if(!r&&!a)return i&&ji(t,n,!1),Wo(e,t,s);r=t.stateNode,vo.current=t;var o=a&&"function"!==typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&a?(t.child=ws(t,e.child,null,s),t.child=ws(t,null,o,s)):wo(e,t,o,s),t.memoizedState=r.state,i&&ji(t,n,!0),t.child}function Oo(e){var t=e.stateNode;t.pendingContext?Ti(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Ti(0,t.context,!1),Qs(e,t.containerInfo)}function Po(e,t,n,r,i){return hs(),fs(i),t.flags|=256,wo(e,t,n,r),t.child}var Lo,Ro,No,To,Mo={dehydrated:null,treeContext:null,retryLane:0};function Fo(e){return{baseLanes:e,cachePool:null,transitions:null}}function jo(e,t,n){var r,i=t.pendingProps,a=Zs.current,o=!1,l=0!==(128&t.flags);if((r=l)||(r=(null===e||null!==e.memoizedState)&&0!==(2&a)),r?(o=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(a|=1),Ai(Zs,1&a),null===e)return us(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0===(1&t.mode)?t.lanes=1:"$!"===e.data?t.lanes=8:t.lanes=1073741824,null):(l=i.children,e=i.fallback,o?(i=t.mode,o=t.child,l={mode:"hidden",children:l},0===(1&i)&&null!==o?(o.childLanes=0,o.pendingProps=l):o=Fu(l,i,0,null),e=Mu(e,i,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Fo(n),t.memoizedState=Mo,e):Do(t,l));if(null!==(a=e.memoizedState)&&null!==(r=a.dehydrated))return function(e,t,n,r,i,a,o){if(n)return 256&t.flags?(t.flags&=-257,$o(e,t,o,r=uo(Error(s(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=Fu({mode:"visible",children:r.children},i,0,null),(a=Mu(a,i,o,null)).flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,0!==(1&t.mode)&&ws(t,e.child,null,o),t.child.memoizedState=Fo(o),t.memoizedState=Mo,a);if(0===(1&t.mode))return $o(e,t,o,null);if("$!"===i.data){if(r=i.nextSibling&&i.nextSibling.dataset)var l=r.dgst;return r=l,$o(e,t,o,r=uo(a=Error(s(419)),r,void 0))}if(l=0!==(o&e.childLanes),bo||l){if(null!==(r=Ol)){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}0!==(i=0!==(i&(r.suspendedLanes|o))?0:i)&&i!==a.retryLane&&(a.retryLane=i,Ts(e,i),nu(r,e,i,-1))}return mu(),$o(e,t,o,r=uo(Error(s(421))))}return"$?"===i.data?(t.flags|=128,t.child=e.child,t=Cu.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,rs=ui(i.nextSibling),ns=t,is=!0,ss=null,null!==e&&(qi[Ki++]=Yi,qi[Ki++]=Xi,qi[Ki++]=Qi,Yi=e.id,Xi=e.overflow,Qi=t),t=Do(t,r.children),t.flags|=4096,t)}(e,t,l,i,r,a,n);if(o){o=i.fallback,l=t.mode,r=(a=e.child).sibling;var u={mode:"hidden",children:i.children};return 0===(1&l)&&t.child!==a?((i=t.child).childLanes=0,i.pendingProps=u,t.deletions=null):(i=Nu(a,u)).subtreeFlags=14680064&a.subtreeFlags,null!==r?o=Nu(r,o):(o=Mu(o,l,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,l=null===(l=e.child.memoizedState)?Fo(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~n,t.memoizedState=Mo,i}return e=(o=e.child).sibling,i=Nu(o,{mode:"visible",children:i.children}),0===(1&t.mode)&&(i.lanes=n),i.return=t,i.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=i,t.memoizedState=null,i}function Do(e,t){return(t=Fu({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function $o(e,t,n,r){return null!==r&&fs(r),ws(t,e.child,null,n),(e=Do(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function zo(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Es(e.return,t,n)}function Vo(e,t,n,r,i){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function Uo(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(wo(e,t,r.children,n),0!==(2&(r=Zs.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zo(e,n,t);else if(19===e.tag)zo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ai(Zs,r),0===(1&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;null!==n;)null!==(e=n.alternate)&&null===ea(e)&&(i=n),n=n.sibling;null===(n=i)?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Vo(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===ea(e)){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Vo(t,!0,n,null,s);break;case"together":Vo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Bo(e,t){0===(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wo(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),Fl|=t.lanes,0===(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(s(153));if(null!==t.child){for(n=Nu(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Nu(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function Ho(e,t){if(!is)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Go(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=14680064&i.subtreeFlags,r|=14680064&i.flags,i.return=e,i=i.sibling;else for(i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function qo(e,t,n){var r=t.pendingProps;switch(ts(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Go(t),null;case 1:case 17:return Ri(t.type)&&Ni(),Go(t),null;case 3:return r=t.stateNode,Ys(),Ii(Oi),Ii(Ei),na(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(ps(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,null!==ss&&(au(ss),ss=null))),Ro(e,t),Go(t),null;case 5:Js(t);var i=Ks(qs.current);if(n=t.type,null!==e&&null!=t.stateNode)No(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(s(166));return Go(t),null}if(e=Ks(Hs.current),ps(t)){r=t.stateNode,n=t.type;var a=t.memoizedProps;switch(r[di]=t,r[hi]=a,e=0!==(1&t.mode),n){case"dialog":$r("cancel",r),$r("close",r);break;case"iframe":case"object":case"embed":$r("load",r);break;case"video":case"audio":for(i=0;i<\/script>",e=e.removeChild(e.firstChild)):"string"===typeof r.is?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),"select"===n&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[di]=t,e[hi]=r,Lo(e,t,!1,!1),t.stateNode=e;e:{switch(l=be(n,r),n){case"dialog":$r("cancel",e),$r("close",e),i=r;break;case"iframe":case"object":case"embed":$r("load",e),i=r;break;case"video":case"audio":for(i=0;iUl&&(t.flags|=128,r=!0,Ho(a,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=ea(l))){if(t.flags|=128,r=!0,null!==(n=e.updateQueue)&&(t.updateQueue=n,t.flags|=4),Ho(a,!0),null===a.tail&&"hidden"===a.tailMode&&!l.alternate&&!is)return Go(t),null}else 2*Xe()-a.renderingStartTime>Ul&&1073741824!==n&&(t.flags|=128,r=!0,Ho(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(null!==(n=a.last)?n.sibling=l:t.child=l,a.last=l)}return null!==a.tail?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Xe(),t.sibling=null,n=Zs.current,Ai(Zs,r?1&n|2:1&n),t):(Go(t),null);case 22:case 23:return pu(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!==(1&t.mode)?0!==(1073741824&Rl)&&(Go(t),6&t.subtreeFlags&&(t.flags|=8192)):Go(t),null;case 24:case 25:return null}throw Error(s(156,t.tag))}function Ko(e,t){switch(ts(t),t.tag){case 1:return Ri(t.type)&&Ni(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Ys(),Ii(Oi),Ii(Ei),na(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 5:return Js(t),null;case 13:if(Ii(Zs),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(s(340));hs()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return Ii(Zs),null;case 4:return Ys(),null;case 10:return Cs(t.type._context),null;case 22:case 23:return pu(),null;default:return null}}Lo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Ro=function(){},No=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ks(Hs.current);var s,a=null;switch(n){case"input":i=Q(e,i),r=Q(e,r),a=[];break;case"select":i=j({},i,{value:void 0}),r=j({},r,{value:void 0}),a=[];break;case"textarea":i=re(e,i),r=re(e,r),a=[];break;default:"function"!==typeof i.onClick&&"function"===typeof r.onClick&&(e.onclick=Zr)}for(c in ve(n,r),n=null,i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&null!=i[c])if("style"===c){var l=i[c];for(s in l)l.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else"dangerouslySetInnerHTML"!==c&&"children"!==c&&"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&"autoFocus"!==c&&(o.hasOwnProperty(c)?a||(a=[]):(a=a||[]).push(c,null));for(c in r){var u=r[c];if(l=null!=i?i[c]:void 0,r.hasOwnProperty(c)&&u!==l&&(null!=u||null!=l))if("style"===c)if(l){for(s in l)!l.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in u)u.hasOwnProperty(s)&&l[s]!==u[s]&&(n||(n={}),n[s]=u[s])}else n||(a||(a=[]),a.push(c,n)),n=u;else"dangerouslySetInnerHTML"===c?(u=u?u.__html:void 0,l=l?l.__html:void 0,null!=u&&l!==u&&(a=a||[]).push(c,u)):"children"===c?"string"!==typeof u&&"number"!==typeof u||(a=a||[]).push(c,""+u):"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&(o.hasOwnProperty(c)?(null!=u&&"onScroll"===c&&$r("scroll",e),a||l===u||(a=[])):(a=a||[]).push(c,u))}n&&(a=a||[]).push("style",n);var c=a;(t.updateQueue=c)&&(t.flags|=4)}},To=function(e,t,n,r){n!==r&&(t.flags|=4)};var Qo=!1,Yo=!1,Xo="function"===typeof WeakSet?WeakSet:Set,Jo=null;function Zo(e,t){var n=e.ref;if(null!==n)if("function"===typeof n)try{n(null)}catch(r){_u(e,t,r)}else n.current=null}function el(e,t,n){try{n()}catch(r){_u(e,t,r)}}var tl=!1;function nl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,void 0!==s&&el(t,n,s)}i=i.next}while(i!==r)}}function rl(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function il(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"===typeof t?t(e):t.current=e}}function sl(e){var t=e.alternate;null!==t&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[di],delete t[hi],delete t[mi],delete t[gi],delete t[yi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function al(e){return 5===e.tag||3===e.tag||4===e.tag}function ol(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||al(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function ll(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=Zr));else if(4!==r&&null!==(e=e.child))for(ll(e,t,n),e=e.sibling;null!==e;)ll(e,t,n),e=e.sibling}function ul(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(ul(e,t,n),e=e.sibling;null!==e;)ul(e,t,n),e=e.sibling}var cl=null,pl=!1;function dl(e,t,n){for(n=n.child;null!==n;)hl(e,t,n),n=n.sibling}function hl(e,t,n){if(st&&"function"===typeof st.onCommitFiberUnmount)try{st.onCommitFiberUnmount(it,n)}catch(o){}switch(n.tag){case 5:Yo||Zo(n,t);case 6:var r=cl,i=pl;cl=null,dl(e,t,n),pl=i,null!==(cl=r)&&(pl?(e=cl,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):cl.removeChild(n.stateNode));break;case 18:null!==cl&&(pl?(e=cl,n=n.stateNode,8===e.nodeType?li(e.parentNode,n):1===e.nodeType&&li(e,n),Ut(e)):li(cl,n.stateNode));break;case 4:r=cl,i=pl,cl=n.stateNode.containerInfo,pl=!0,dl(e,t,n),cl=r,pl=i;break;case 0:case 11:case 14:case 15:if(!Yo&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,void 0!==a&&(0!==(2&s)||0!==(4&s))&&el(n,t,a),i=i.next}while(i!==r)}dl(e,t,n);break;case 1:if(!Yo&&(Zo(n,t),"function"===typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){_u(n,t,o)}dl(e,t,n);break;case 21:dl(e,t,n);break;case 22:1&n.mode?(Yo=(r=Yo)||null!==n.memoizedState,dl(e,t,n),Yo=r):dl(e,t,n);break;default:dl(e,t,n)}}function fl(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Xo),t.forEach((function(t){var r=Eu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function ml(e,t){var n=t.deletions;if(null!==n)for(var r=0;ri&&(i=o),r&=~a}if(r=i,10<(r=(120>(r=Xe()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_l(r/1960))-r)){e.timeoutHandle=ri(Su.bind(null,e,zl,Bl),r);break}Su(e,zl,Bl);break;default:throw Error(s(329))}}}return ru(e,Xe()),e.callbackNode===n?iu.bind(null,e):null}function su(e,t){var n=$l;return e.current.memoizedState.isDehydrated&&(du(e,t).flags|=256),2!==(e=gu(e,t))&&(t=zl,zl=n,null!==t&&au(t)),e}function au(e){null===zl?zl=e:zl.push.apply(zl,e)}function ou(e,t){for(t&=~Dl,t&=~jl,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0e?16:e,null===Kl)var r=!1;else{if(e=Kl,Kl=null,Ql=0,0!==(6&El))throw Error(s(331));var i=El;for(El|=4,Jo=e.current;null!==Jo;){var a=Jo,o=a.child;if(0!==(16&Jo.flags)){var l=a.deletions;if(null!==l){for(var u=0;uXe()-Vl?du(e,0):Dl|=n),ru(e,t)}function Au(e,t){0===t&&(0===(1&e.mode)?t=1:(t=ct,0===(130023424&(ct<<=1))&&(ct=4194304)));var n=eu();null!==(e=Ts(e,t))&&(yt(e,t,n),ru(e,n))}function Cu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Au(e,n)}function Eu(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}null!==r&&r.delete(t),Au(e,n)}function Ou(e,t){return qe(e,t)}function Pu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lu(e,t,n,r){return new Pu(e,t,n,r)}function Ru(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Nu(e,t){var n=e.alternate;return null===n?((n=Lu(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Tu(e,t,n,r,i,a){var o=2;if(r=e,"function"===typeof e)Ru(e)&&(o=1);else if("string"===typeof e)o=5;else e:switch(e){case k:return Mu(n.children,i,a,t);case _:o=8,i|=8;break;case I:return(e=Lu(12,n,t,2|i)).elementType=I,e.lanes=a,e;case O:return(e=Lu(13,n,t,i)).elementType=O,e.lanes=a,e;case P:return(e=Lu(19,n,t,i)).elementType=P,e.lanes=a,e;case N:return Fu(n,i,a,t);default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case A:o=10;break e;case C:o=9;break e;case E:o=11;break e;case L:o=14;break e;case R:o=16,r=null;break e}throw Error(s(130,null==e?e:typeof e,""))}return(t=Lu(o,n,t,i)).elementType=e,t.type=r,t.lanes=a,t}function Mu(e,t,n,r){return(e=Lu(7,e,r,t)).lanes=n,e}function Fu(e,t,n,r){return(e=Lu(22,e,r,t)).elementType=N,e.lanes=n,e.stateNode={isHidden:!1},e}function ju(e,t,n){return(e=Lu(6,e,null,t)).lanes=n,e}function Du(e,t,n){return(t=Lu(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function $u(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gt(0),this.expirationTimes=gt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function zu(e,t,n,r,i,s,a,o,l){return e=new $u(e,t,n,o,l),1===t?(t=1,!0===s&&(t|=8)):t=0,s=Lu(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fs(s),e}function Vu(e){if(!e)return Ci;e:{if(Ue(e=e._reactInternals)!==e||1!==e.tag)throw Error(s(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ri(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(s(171))}if(1===e.tag){var n=e.type;if(Ri(n))return Mi(e,n,t)}return t}function Uu(e,t,n,r,i,s,a,o,l){return(e=zu(n,r,!0,e,0,s,0,o,l)).context=Vu(null),n=e.current,(s=Ds(r=eu(),i=tu(n))).callback=void 0!==t&&null!==t?t:null,$s(n,s,i),e.current.lanes=i,yt(e,i,r),ru(e,r),e}function Bu(e,t,n,r){var i=t.current,s=eu(),a=tu(i);return n=Vu(n),null===t.context?t.context=n:t.pendingContext=n,(t=Ds(s,a)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=$s(i,t,a))&&(nu(e,i,a,s),zs(e,i,a)),a}function Wu(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function Hu(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n{var r=n(8815);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},8815:(e,t,n)=>{!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(2777)},5817:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=e||"";t&&(s=e.toString().trim().replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,(function(e,t,r){return t>0&&t+e.length!==r.length&&e.search(n)>-1&&":"!==r.charAt(t-2)&&("-"!==r.charAt(t+e.length)||"-"===r.charAt(t-1))&&r.charAt(t-1).search(/[^\s-]/)<0?e.toLowerCase():e.substr(1).search(/[A-Z]|\../)>-1?e:e.charAt(0).toUpperCase()+e.substr(1)})));i&&(s=function(e){if(function(e){return"string"===typeof e&&-1!==e.indexOf("@")}(e))return console.warn("This arg looks like an email address, redacting."),r;return e}(s));return s};var n=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;var r="REDACTED (Potential Email Address)"},5068:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.GA4=void 0;var r=l(n(5189)),i=l(n(5817)),s=["eventCategory","eventAction","eventLabel","eventValue","hitType"],a=["title","location"],o=["page","hitType"];function l(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function p(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n2&&void 0!==arguments[2]?arguments[2]:"https://www.googletagmanager.com/gtag/js";if("undefined"!==typeof window&&"undefined"!==typeof document&&!t._hasLoadedGA){var i=document.createElement("script");i.async=!0,i.src="".concat(r,"?id=").concat(e),n&&i.setAttribute("nonce",n),document.body.appendChild(i),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},t._hasLoadedGA=!0}})),v(this,"_toGtagOptions",(function(e){if(e){var t={cookieUpdate:"cookie_update",cookieExpires:"cookie_expires",cookieDomain:"cookie_domain",cookieFlags:"cookie_flags",userId:"user_id",clientId:"client_id",anonymizeIp:"anonymize_ip",contentGroup1:"content_group1",contentGroup2:"content_group2",contentGroup3:"content_group3",contentGroup4:"content_group4",contentGroup5:"content_group5",allowAdFeatures:"allow_google_signals",allowAdPersonalizationSignals:"allow_ad_personalization_signals",nonInteraction:"non_interaction",page:"page_path",hitCallback:"event_callback"};return Object.entries(e).reduce((function(e,n){var r=f(n,2),i=r[0],s=r[1];return t[i]?e[t[i]]=s:e[i]=s,e}),{})}})),v(this,"initialize",(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("Require GA_MEASUREMENT_ID");var r="string"===typeof e?[{trackingId:e}]:e;t._currentMeasurementId=r[0].trackingId;var i=n.gaOptions,s=n.gtagOptions,a=n.nonce,o=n.testMode,l=void 0!==o&&o,u=n.gtagUrl;if(t._testMode=l,l||t._loadGA(t._currentMeasurementId,a,u),t.isInitialized||(t._gtag("js",new Date),r.forEach((function(e){var n=h(h(h({},t._toGtagOptions(h(h({},i),e.gaOptions))),s),e.gtagOptions);Object.keys(n).length?t._gtag("config",e.trackingId,n):t._gtag("config",e.trackingId)}))),t.isInitialized=!0,!l){var c=p(t._queueGtag);for(t._queueGtag=[],t._isQueuing=!1;c.length;){var d=c.shift();t._gtag.apply(t,p(d)),"get"===d[0]&&(t._isQueuing=!0)}}})),v(this,"set",(function(e){e?"object"===c(e)?(0===Object.keys(e).length&&console.warn("empty `fieldsObject` given to .set()"),t._gaCommand("set",e)):console.warn("Expected `fieldsObject` arg to be an Object"):console.warn("`fieldsObject` is required in .set()")})),v(this,"_gaCommandSendEvent",(function(e,n,r,i,s){t._gtag("event",n,h(h({event_category:e,event_label:r,value:i},s&&{non_interaction:s.nonInteraction}),t._toGtagOptions(s)))})),v(this,"_gaCommandSendEventParameters",(function(){for(var e=arguments.length,n=new Array(e),r=0;r1?n-1:0),i=1;i{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.Ay=void 0;var i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!==typeof e)return{default:e};var n=s(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(5068));function s(e){if("function"!==typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(s=function(e){return e?n:t})(e)}i.GA4;var a=i.default;t.Ay=a},8330:(e,t,n)=>{var r,i;n.d(t,{Kd:()=>h,N_:()=>g});var s=n(8878),a=n(8815),o=n(3229),l=n(1642);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(i[n]=e[n]);return i}new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);const p=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"];try{window.__reactRouterVersion="6"}catch(b){}new Map;const d=(r||(r=n.t(s,2))).startTransition;(i||(i=n.t(a,2))).flushSync,(r||(r=n.t(s,2))).useId;function h(e){let{basename:t,children:n,future:r,window:i}=e,a=s.useRef();null==a.current&&(a.current=(0,l.zR)({window:i,v5Compat:!0}));let u=a.current,[c,p]=s.useState({action:u.action,location:u.location}),{v7_startTransition:h}=r||{},f=s.useCallback((e=>{h&&d?d((()=>p(e))):p(e)}),[p,h]);return s.useLayoutEffect((()=>u.listen(f)),[u,f]),s.createElement(o.Ix,{basename:t,children:n,location:c.location,navigationType:c.action,navigator:u,future:r})}const f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,g=s.forwardRef((function(e,t){let n,{onClick:r,relative:i,reloadDocument:a,replace:d,state:h,target:g,to:y,preventScrollReset:v,unstable_viewTransition:w}=e,S=c(e,p),{basename:x}=s.useContext(o.jb),k=!1;if("string"===typeof y&&m.test(y)&&(n=y,f))try{let e=new URL(window.location.href),t=y.startsWith("//")?new URL(e.protocol+y):new URL(y),n=(0,l.pb)(t.pathname,x);t.origin===e.origin&&null!=n?y=n+t.search+t.hash:k=!0}catch(b){}let _=(0,o.$P)(y,{relative:i}),I=function(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:u,unstable_viewTransition:c}=void 0===t?{}:t,p=(0,o.Zp)(),d=(0,o.zy)(),h=(0,o.x$)(e,{relative:u});return s.useCallback((t=>{if(function(e,t){return 0===e.button&&(!t||"_self"===t)&&!function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)}(t,n)){t.preventDefault();let n=void 0!==r?r:(0,l.AO)(d)===(0,l.AO)(h);p(e,{replace:n,state:i,preventScrollReset:a,relative:u,unstable_viewTransition:c})}}),[d,p,h,r,i,n,e,a,u,c])}(y,{replace:d,state:h,target:g,preventScrollReset:v,relative:i,unstable_viewTransition:w});return s.createElement("a",u({},S,{href:n||_,onClick:k||a?r:function(e){r&&r(e),e.defaultPrevented||I(e)},ref:t,target:g}))}));var y,v;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(y||(y={})),function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(v||(v={}))},3229:(e,t,n)=>{var r;n.d(t,{$P:()=>h,BV:()=>T,C5:()=>L,Ix:()=>N,Zp:()=>y,jb:()=>u,qh:()=>R,x$:()=>v,zy:()=>m});var i=n(8878),s=n(1642);function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t{n.current=!0})),i.useCallback((function(r,i){void 0===i&&(i={}),n.current&&("number"===typeof r?e.navigate(r):e.navigate(r,a({fromRouteId:t},i)))}),[e,t])}():function(){f()||(0,s.Oi)(!1);let e=i.useContext(o),{basename:t,future:n,navigator:r}=i.useContext(u),{matches:a}=i.useContext(p),{pathname:l}=m(),c=JSON.stringify((0,s.yD)(a,n.v7_relativeSplatPath)),d=i.useRef(!1);return g((()=>{d.current=!0})),i.useCallback((function(n,i){if(void 0===i&&(i={}),!d.current)return;if("number"===typeof n)return void r.go(n);let a=(0,s.Gh)(n,JSON.parse(c),l,"path"===i.relative);null==e&&"/"!==t&&(a.pathname="/"===a.pathname?t:(0,s.HS)([t,a.pathname])),(i.replace?r.replace:r.push)(a,i.state,i)}),[t,r,c,l,e])}()}function v(e,t){let{relative:n}=void 0===t?{}:t,{future:r}=i.useContext(u),{matches:a}=i.useContext(p),{pathname:o}=m(),l=JSON.stringify((0,s.yD)(a,r.v7_relativeSplatPath));return i.useMemo((()=>(0,s.Gh)(e,JSON.parse(l),o,"path"===n)),[e,l,o,n])}function b(e,t,n,r){f()||(0,s.Oi)(!1);let{navigator:o}=i.useContext(u),{matches:l}=i.useContext(p),d=l[l.length-1],h=d?d.params:{},g=(d&&d.pathname,d?d.pathnameBase:"/");d&&d.route;let y,v=m();if(t){var b;let e="string"===typeof t?(0,s.Rr)(t):t;"/"===g||(null==(b=e.pathname)?void 0:b.startsWith(g))||(0,s.Oi)(!1),y=e}else y=v;let w=y.pathname||"/",S=w;if("/"!==g){let e=g.replace(/^\//,"").split("/");S="/"+w.replace(/^\//,"").split("/").slice(e.length).join("/")}let x=(0,s.ue)(e,{pathname:S});let k=_(x&&x.map((e=>Object.assign({},e,{params:Object.assign({},h,e.params),pathname:(0,s.HS)([g,o.encodeLocation?o.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?g:(0,s.HS)([g,o.encodeLocation?o.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,n,r);return t&&k?i.createElement(c.Provider,{value:{location:a({pathname:"/",search:"",hash:"",state:null,key:"default"},y),navigationType:s.rc.Pop}},k):k}function w(){let e=function(){var e;let t=i.useContext(d),n=E(A.UseRouteError),r=O(A.UseRouteError);if(void 0!==t)return t;return null==(e=n.errors)?void 0:e[r]}(),t=(0,s.pX)(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r};return i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},t),n?i.createElement("pre",{style:a},n):null,null)}const S=i.createElement(w,null);class x extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?i.createElement(p.Provider,{value:this.props.routeContext},i.createElement(d.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function k(e){let{routeContext:t,match:n,children:r}=e,s=i.useContext(o);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),i.createElement(p.Provider,{value:t},r)}function _(e,t,n,r){var a;if(void 0===t&&(t=[]),void 0===n&&(n=null),void 0===r&&(r=null),null==e){var o;if(null==(o=n)||!o.errors)return null;e=n.matches}let l=e,u=null==(a=n)?void 0:a.errors;if(null!=u){let e=l.findIndex((e=>e.route.id&&void 0!==(null==u?void 0:u[e.route.id])));e>=0||(0,s.Oi)(!1),l=l.slice(0,Math.min(l.length,e+1))}let c=!1,p=-1;if(n&&r&&r.v7_partialHydration)for(let i=0;i=0?l.slice(0,p+1):[l[0]];break}}}return l.reduceRight(((e,r,s)=>{let a,o=!1,d=null,h=null;var f;n&&(a=u&&r.route.id?u[r.route.id]:void 0,d=r.route.errorElement||S,c&&(p<0&&0===s?(f="route-fallback",!1||P[f]||(P[f]=!0),o=!0,h=null):p===s&&(o=!0,h=r.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,s+1)),g=()=>{let t;return t=a?d:o?h:r.route.Component?i.createElement(r.route.Component,null):r.route.element?r.route.element:e,i.createElement(k,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:null!=n},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||0===s)?i.createElement(x,{location:n.location,revalidation:n.revalidation,component:d,error:a,children:g(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):g()}),null)}var I=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(I||{}),A=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(A||{});function C(e){let t=i.useContext(o);return t||(0,s.Oi)(!1),t}function E(e){let t=i.useContext(l);return t||(0,s.Oi)(!1),t}function O(e){let t=function(e){let t=i.useContext(p);return t||(0,s.Oi)(!1),t}(),n=t.matches[t.matches.length-1];return n.route.id||(0,s.Oi)(!1),n.route.id}const P={};(r||(r=n.t(i,2))).startTransition;function L(e){let{to:t,replace:n,state:r,relative:a}=e;f()||(0,s.Oi)(!1);let{future:o,static:l}=i.useContext(u),{matches:c}=i.useContext(p),{pathname:d}=m(),h=y(),g=(0,s.Gh)(t,(0,s.yD)(c,o.v7_relativeSplatPath),d,"path"===a),v=JSON.stringify(g);return i.useEffect((()=>h(JSON.parse(v),{replace:n,state:r,relative:a})),[h,v,a,n,r]),null}function R(e){(0,s.Oi)(!1)}function N(e){let{basename:t="/",children:n=null,location:r,navigationType:o=s.rc.Pop,navigator:l,static:p=!1,future:d}=e;f()&&(0,s.Oi)(!1);let h=t.replace(/^\/*/,"/"),m=i.useMemo((()=>({basename:h,navigator:l,static:p,future:a({v7_relativeSplatPath:!1},d)})),[h,d,l,p]);"string"===typeof r&&(r=(0,s.Rr)(r));let{pathname:g="/",search:y="",hash:v="",state:b=null,key:w="default"}=r,S=i.useMemo((()=>{let e=(0,s.pb)(g,h);return null==e?null:{location:{pathname:e,search:y,hash:v,state:b,key:w},navigationType:o}}),[h,g,y,v,b,w,o]);return null==S?null:i.createElement(u.Provider,{value:m},i.createElement(c.Provider,{children:n,value:S}))}function T(e){let{children:t,location:n}=e;return b(M(t),n)}new Promise((()=>{}));i.Component;function M(e,t){void 0===t&&(t=[]);let n=[];return i.Children.forEach(e,((e,r)=>{if(!i.isValidElement(e))return;let a=[...t,r];if(e.type===i.Fragment)return void n.push.apply(n,M(e.props.children,a));e.type!==R&&(0,s.Oi)(!1),e.props.index&&e.props.children&&(0,s.Oi)(!1);let o={id:e.props.id||a.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(o.children=M(e.props.children,a)),n.push(o)})),n}},1406:(e,t,n)=>{var r=n(8878),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,s={},u=null,c=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)a.call(t,r)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:u,ref:c,props:s,_owner:o.current}}t.Fragment=s,t.jsx=u,t.jsxs=u},33:(e,t)=>{var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=b.prototype=new v;w.constructor=b,m(w,y.prototype),w.isPureReactComponent=!0;var S=Array.isArray,x=Object.prototype.hasOwnProperty,k={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};function I(e,t,r){var i,s={},a=null,o=null;if(null!=t)for(i in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(a=""+t.key),t)x.call(t,i)&&!_.hasOwnProperty(i)&&(s[i]=t[i]);var l=arguments.length-2;if(1===l)s.children=r;else if(1{e.exports=n(33)},782:(e,t,n)=>{e.exports=n(1406)},9169:(e,t)=>{function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,i=e[r];if(!(0>>1;rs(l,n))us(c,l)?(e[r]=c,e[u]=n,r=u):(e[r]=l,e[o]=n,r=o);else{if(!(us(c,n)))break e;e[r]=c,e[u]=n,r=u}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"===typeof performance&&"function"===typeof performance.now){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],c=[],p=1,d=null,h=3,f=!1,m=!1,g=!1,y="function"===typeof setTimeout?setTimeout:null,v="function"===typeof clearTimeout?clearTimeout:null,b="undefined"!==typeof setImmediate?setImmediate:null;function w(e){for(var t=r(c);null!==t;){if(null===t.callback)i(c);else{if(!(t.startTime<=e))break;i(c),t.sortIndex=t.expirationTime,n(u,t)}t=r(c)}}function S(e){if(g=!1,w(e),!m)if(null!==r(u))m=!0,N(x);else{var t=r(c);null!==t&&T(S,t.startTime-e)}}function x(e,n){m=!1,g&&(g=!1,v(A),A=-1),f=!0;var s=h;try{for(w(n),d=r(u);null!==d&&(!(d.expirationTime>n)||e&&!O());){var a=d.callback;if("function"===typeof a){d.callback=null,h=d.priorityLevel;var o=a(d.expirationTime<=n);n=t.unstable_now(),"function"===typeof o?d.callback=o:d===r(u)&&i(u),w(n)}else i(u);d=r(u)}if(null!==d)var l=!0;else{var p=r(c);null!==p&&T(S,p.startTime-n),l=!1}return l}finally{d=null,h=s,f=!1}}"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k,_=!1,I=null,A=-1,C=5,E=-1;function O(){return!(t.unstable_now()-Ee||125a?(e.sortIndex=s,n(c,e),null===r(u)&&e===r(c)&&(g?(v(A),A=-1):g=!0,T(S,s-a))):(e.sortIndex=o,n(u,e),m||f||(m=!0,N(x))),e},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}},7116:(e,t,n)=>{e.exports=n(9169)},5384:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.errorMessages=t.ErrorType=void 0,function(e){e.MalformedUnicode="MALFORMED_UNICODE",e.MalformedHexadecimal="MALFORMED_HEXADECIMAL",e.CodePointLimit="CODE_POINT_LIMIT",e.OctalDeprecation="OCTAL_DEPRECATION",e.EndOfString="END_OF_STRING"}(n=t.ErrorType||(t.ErrorType={})),t.errorMessages=new Map([[n.MalformedUnicode,"malformed Unicode character escape sequence"],[n.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[n.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[n.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[n.EndOfString,"malformed escape sequence at end of string"]])},2527:(e,t,n)=>{t.MH=void 0;const r=n(5384);function i(e,t,n){const i=function(e){return e.match(/[^a-f0-9]/i)?NaN:parseInt(e,16)}(e);if(Number.isNaN(i)||void 0!==n&&n!==e.length)throw new SyntaxError(r.errorMessages.get(t));return i}function s(e,t){const n=i(e,r.ErrorType.MalformedUnicode,4);if(void 0!==t){const e=i(t,r.ErrorType.MalformedUnicode,4);return String.fromCharCode(n,e)}return String.fromCharCode(n)}const a=new Map([["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t","\t"],["v","\v"],["0","\0"]]);const o=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function l(e,t=!1){return e.replace(o,(function(e,n,o,l,u,c,p,d,h){if(void 0!==n)return"\\";if(void 0!==o)return function(e){const t=i(e,r.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(t)}(o);if(void 0!==l)return function(e){if("{"!==(t=e).charAt(0)||"}"!==t.charAt(t.length-1))throw new SyntaxError(r.errorMessages.get(r.ErrorType.MalformedUnicode));var t;const n=i(e.slice(1,-1),r.ErrorType.MalformedUnicode);try{return String.fromCodePoint(n)}catch(s){throw s instanceof RangeError?new SyntaxError(r.errorMessages.get(r.ErrorType.CodePointLimit)):s}}(l);if(void 0!==u)return s(u,c);if(void 0!==p)return s(p);if("0"===d)return"\0";if(void 0!==d)return function(e,t=!1){if(t)throw new SyntaxError(r.errorMessages.get(r.ErrorType.OctalDeprecation));const n=parseInt(e,8);return String.fromCharCode(n)}(d,!t);if(void 0!==h)return f=h,a.get(f)||f;var f;throw new SyntaxError(r.errorMessages.get(r.ErrorType.EndOfString))}))}t.MH=l},7365:(e,t,n)=>{n.d(t,{U:()=>a,_:()=>o});var r=n(5874),i=n(7589);function s(e,t){const n=[];for(let r=0;r({span:{start:e.start+f,end:e.end+f,line:e.line},type:"error-cell"})))),f+=e.expectedLine.length+1,h.push(e.expectedLine),m.push({span:{start:f,end:f+e.expectedLine.length,line:r},type:"correct-line"}),m.push(...e.correctCellSpans.map((e=>({span:{start:e.start+f,end:e.end+f,line:h.length},type:"correct-cell"})))),f+=e.givenLine.length+1):(h.push(p[r]),f+=p[r].length+1)}let y=h.join("\n");return y.endsWith("\n")&&(y=y.substring(0,y.length-1)),{text:y,failureNum:u.length,decorations:m,lineNumbers:g}}function l(e,t){const n=e.split("|").filter((e=>""!=e)),r=Array.from(n),i=[];let s=0;for(let l=0;l{n.d(t,{g:()=>i});var r=n(5874);async function i(e,t){try{const i=await e.readFile(t);let s;try{const n=t.replace("VME.tst",".tst").replace(".tst",".cmp");s=await e.readFile(n)}catch(n){}return(0,r.Ok)({tst:i,cmp:s})}catch(n){return(0,r._)(n)}}},7490:(e,t,n)=>{n.d(t,{vl:()=>h,ZB:()=>c,wG:()=>g,FX:()=>d});var r=n(782),i=n(742),s=n(8878),a=n(2469),o=n(6980);class l{signBehaviors=new Map;constructor(e,t){if(o.Mo.has(e)){const n=(0,a.Z1)(o.Mo.get(e)?.()),r=[...n.ins.entries(),...n.outs.entries()];for(const e of r)this.signBehaviors.set(e.name,!t||!t.includes(e.name))}}isSigned(e){return this.signBehaviors.get(e)}}const u=new Map([["Mux4Way16",["sel"]],["Mux8Way16",["sel"]],["DMux4Way",["sel"]],["DMux8Way",["sel"]],["RAM8",["address"]],["RAM64",["address"]],["RAM512",["address"]],["RAM4K",["address"]],["RAM16K",["address"]],["Screen",["address"]],["Memory",["address"]],["CPU",["addressM","pc"]]]),c=(0,s.createContext)({});function p(e){return{pin:e,bits:(0,i.y)(0,e.width).map((t=>[t,e.voltage(t)])).reverse()}}function d(e){return[...e.entries()].map(p)}const h=e=>{const{inPins:t,outPins:n,internalPins:i}=e.sim,s=(a=e.sim.chip[0].name??"",new l(a,u.get(a)));var a;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:"\n table.pinout th {\n font-weight: bold;\n }\n\n table.pinout tbody td:first-child {\n text-align: right;\n --font-size: 1rem;\n width: 0;\n white-space: nowrap;\n border-right: var(--border-width) solid var(--table-border-color);\n }\n\n table.pinout tbody button {\n --font-size: 0.875em;\n font-family: var(--font-family-monospace);\n max-width: 2em;\n }\n "}),(0,r.jsx)("table",{className:"pinout",children:(0,r.jsxs)("tbody",{children:[(0,r.jsx)(f,{pins:t,header:"Input pins",toggle:e.toggle,setInputValid:e.setInputValid,displayInfo:s}),(0,r.jsx)(f,{pins:n,header:"Output pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s}),!e.hideInternal&&(0,r.jsx)(f,{pins:i,header:"Internal pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s})]})})]})},f=e=>(0,r.jsxs)(r.Fragment,{children:[e.pins.length>0&&(0,r.jsx)("tr",{children:(0,r.jsx)("th",{colSpan:2,children:e.header})}),[...e.pins].map((t=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:t.pin.name}),(0,r.jsx)("td",{children:(0,r.jsx)(m,{pin:t,toggle:e.toggle,disabled:e.disabled,enableEdit:e.enableEdit,signed:e.displayInfo.isSigned(t.pin.name),setInputValid:e.setInputValid,internal:"Internal pins"===e.header})})]},t.pin.name)))]}),m=({pin:e,toggle:t,disabled:n=!1,enableEdit:i=!0,signed:a=!0,setInputValid:o,internal:l=!1})=>{const[u,p]=(0,s.useState)(!0);let d=!0;const[h,f]=(0,s.useState)(""),m=(0,s.useContext)(c);m instanceof g&&m.registerCallback((()=>{p(!0)}));const y=e=>{d=e,o?.(e)},v=n=>{for(let r=0;r>r&1)&&t?.(e.pin,r)};return(0,s.useEffect)((()=>{if(!u&&d){let t=0;if(a&&e.bits[0][1]){for(const[n,r]of e.bits)n(0,r.jsx)("button",{disabled:n,style:l?{backgroundColor:"grey"}:{},onClick:()=>t?.(e.pin,i),"data-testid":`pin-${i}`,children:s},i))):(0,r.jsx)("input",{className:"colored",value:h,onChange:t=>{(t=>{const n=t.replace(/[^\d]/g,""),r=a&&"-"===t[0]?`-${n}`:n;if(f(r),isNaN(parseInt(r)))y(!1);else{const t=parseInt(r);!a&&t>=Math.pow(2,e.bits.length)||a&&(t>=Math.pow(2,e.bits.length-1)||t<-Math.pow(2,e.bits.length-1))?y(!1):(v(t),y(!0))}})(t.target.value)},disabled:!i})}),e.bits.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{width:"1em"}}),(0,r.jsx)("button",{className:"pin-control",onClick:()=>{p(!u)},children:u?"dec":"bin"})]})]})};class g{callbacks=[];registerCallback(e){this.callbacks.push(e)}reset(){for(const e of this.callbacks)e()}}},1593:(e,t,n)=>{n.d(t,{A:()=>q,b:()=>K});var r=Symbol.for("immer-nothing"),i=Symbol.for("immer-draftable"),s=Symbol.for("immer-state");function a(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var o=Object.getPrototypeOf;function l(e){return!!e&&!!e[s]}function u(e){return!!e&&(p(e)||Array.isArray(e)||!!e[i]||!!e.constructor?.[i]||g(e)||y(e))}var c=Object.prototype.constructor.toString();function p(e){if(!e||"object"!==typeof e)return!1;const t=o(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===c}function d(e,t){0===h(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,r)=>t(r,n,e)))}function h(e){const t=e[s];return t?t.type_:Array.isArray(e)?1:g(e)?2:y(e)?3:0}function f(e,t){return 2===h(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function m(e,t,n){const r=h(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function g(e){return e instanceof Map}function y(e){return e instanceof Set}function v(e){return e.copy_||e.base_}function b(e,t){if(g(e))return new Map(e);if(y(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=p(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[s];let n=Reflect.ownKeys(t);for(let r=0;r1&&(e.set=e.add=e.clear=e.delete=S),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>w(t,!0)))),e}function S(){a(2)}function x(e){return Object.isFrozen(e)}var k,_={};function I(e){const t=_[e];return t||a(0),t}function A(){return k}function C(e,t){t&&(I("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function E(e){O(e),e.drafts_.forEach(L),e.drafts_=null}function O(e){e===k&&(k=e.parent_)}function P(e){return k={drafts_:[],parent_:k,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function L(e){const t=e[s];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function R(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[s].modified_&&(E(t),a(4)),u(e)&&(e=N(t,e),t.parent_||M(t,e)),t.patches_&&I("Patches").generateReplacementPatches_(n[s].base_,e,t.patches_,t.inversePatches_)):e=N(t,n,[]),E(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==r?e:void 0}function N(e,t,n){if(x(t))return t;const r=t[s];if(!r)return d(t,((i,s)=>T(e,r,t,i,s,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return M(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let i=t,s=!1;3===r.type_&&(i=new Set(t),t.clear(),s=!0),d(i,((i,a)=>T(e,r,t,i,a,n,s))),M(e,t,!1),n&&e.patches_&&I("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function T(e,t,n,r,i,s,a){if(l(i)){const a=N(e,i,s&&t&&3!==t.type_&&!f(t.assigned_,r)?s.concat(r):void 0);if(m(n,r,a),!l(a))return;e.canAutoFreeze_=!1}else a&&n.add(i);if(u(i)&&!x(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;N(e,i),t&&t.scope_.parent_||"symbol"===typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||M(e,i)}}function M(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&w(t,n)}var F={get(e,t){if(t===s)return e;const n=v(e);if(!f(n,t))return function(e,t,n){const r=$(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!u(r)?r:r===D(e.base_,t)?(V(e),e.copy_[t]=U(r,e)):r},has:(e,t)=>t in v(e),ownKeys:e=>Reflect.ownKeys(v(e)),set(e,t,n){const r=$(v(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=D(v(e),t),o=r?.[s];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((i=n)===(a=r)?0!==i||1/i===1/a:i!==i&&a!==a)&&(void 0!==n||f(e.base_,t)))return!0;V(e),z(e)}var i,a;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==D(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,V(e),z(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=v(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){a(11)},getPrototypeOf:e=>o(e.base_),setPrototypeOf(){a(12)}},j={};function D(e,t){const n=e[s];return(n?v(n):e)[t]}function $(e,t){if(!(t in e))return;let n=o(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=o(n)}}function z(e){e.modified_||(e.modified_=!0,e.parent_&&z(e.parent_))}function V(e){e.copy_||(e.copy_=b(e.base_,e.scope_.immer_.useStrictShallowCopy_))}d(F,((e,t)=>{j[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),j.deleteProperty=function(e,t){return j.set.call(this,e,t,void 0)},j.set=function(e,t,n){return F.set.call(this,e[0],t,n,e[0])};function U(e,t){const n=g(e)?I("MapSet").proxyMap_(e,t):y(e)?I("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:A(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=F;n&&(i=[r],s=j);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}(e,t);return(t?t.scope_:A()).drafts_.push(n),n}function B(e){if(!u(e)||x(e))return e;const t=e[s];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=b(e,t.scope_.immer_.useStrictShallowCopy_)}else n=b(e,!0);return d(n,((e,t)=>{m(n,e,B(t))})),t&&(t.finalized_=!1),n}var W=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"===typeof e&&"function"!==typeof t){const n=t;t=e;const r=this;return function(e=n,...i){return r.produce(e,(e=>t.call(this,e,...i)))}}let i;if("function"!==typeof t&&a(6),void 0!==n&&"function"!==typeof n&&a(7),u(e)){const r=P(this),s=U(e,void 0);let a=!0;try{i=t(s),a=!1}finally{a?E(r):O(r)}return C(r,n),R(i,r)}if(!e||"object"!==typeof e){if(i=t(e),void 0===i&&(i=e),i===r&&(i=void 0),this.autoFreeze_&&w(i,!0),n){const t=[],r=[];I("Patches").generateReplacementPatches_(e,i,t,r),n(t,r)}return i}a(1)},this.produceWithPatches=(e,t)=>{if("function"===typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;return[this.produce(e,t,((e,t)=>{n=e,r=t})),n,r]},"boolean"===typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"===typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){u(e)||a(8),l(e)&&(e=function(e){l(e)||a(10);return B(e)}(e));const t=P(this),n=U(e,void 0);return n[s].isManual_=!0,O(t),n}finishDraft(e,t){const n=e&&e[s];n&&n.isManual_||a(9);const{scope_:r}=n;return C(r,t),R(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=I("Patches").applyPatches_;return l(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},H=W.produce;W.produceWithPatches.bind(W),W.setAutoFreeze.bind(W),W.setUseStrictShallowCopy.bind(W),W.applyPatches.bind(W),W.createDraft.bind(W),W.finishDraft.bind(W);var G=n(8878);function q(e,t){return(0,G.useReducer)(((t,n)=>H(t,(t=>{e[n.action](t,n.payload)}))),t)}function K(e){const[t,n]=(0,G.useState)(e);return(0,G.useEffect)((()=>{n(e)}),[e]),[t,n]}},910:(e,t,n)=>{n.d(t,{L:()=>h,A:()=>d});var r=n(4544),i=n(8878),s=n(1916),a=n(2469);const o="NAND2TetrisIndexedDB",l=1,u="FileSystemAccess",c="Handler";function p(){return new Promise(((e,t)=>{const n=window.indexedDB.open(o,l);n.onsuccess=()=>{e(n.result)},n.onerror=()=>{t(n.error)},n.onupgradeneeded=e=>{n.result.createObjectStore(u)}}))}function d(){const e=(0,i.useMemo)((()=>new r.JU),[]),[t,n]=(0,i.useState)(new r.Q2(e)),[l,d]=(0,i.useState)(),h=(0,i.useCallback)((i=>{const a=new r.Q2(new s.Le(new s.Ik(i),e));a.cd(t.cwd()),n(a),d(i.name)}),[n,d]);(0,i.useEffect)((()=>{l||async function(){const e=await p();return new Promise(((t,n)=>{const r=e.transaction([u],"readonly"),i=r.objectStore(u).get(c);i.onsuccess=()=>{const e=i.result;void 0===e?t():((0,a.vA)(e instanceof FileSystemDirectoryHandle,`Retrieved ${c} in ${u} in ${o} is not a FileSystemDirectoryHandle`),t(e))},r.onerror=()=>{console.error("Error in loading FileSystemDirectoryHandle transaction",{err:r.error}),n(r.error)},i.onerror=()=>{console.error("Error in FileSystemDirectoryHandle handleRequest",{err:i.error}),n(i.error)}}))}().then((e=>{e&&h(e)}))}),[l,h]);const f="showDirectoryPicker"in window,m=(0,i.useCallback)((async(e=!1)=>{if(!f||l&&!e)return;const t=await(0,s.EH)(),n=await async function(e){const t=(await p()).transaction([u],"readwrite");return t.objectStore(u).add(e,c),t.commit(),new Promise(((n,r)=>{t.oncomplete=()=>{n(e)},t.onerror=()=>{r(t.error)}}))}(t);h(n)}),[l,h]),g=(0,i.useCallback)((async()=>{l&&(await async function(){const e=(await p()).transaction([u],"readwrite");return e.objectStore(u).delete(c),new Promise(((t,n)=>{e.oncomplete=()=>{t()},e.onerror=()=>{n(e.error)}}))}(),n(new r.Q2(e)),d(void 0))}),[l,e]),[y,v]=(0,i.useState)("");return{fs:t,status:y,setStatus:v,storage:localStorage,canUpgradeFs:f,upgradeFs:m,closeFs:g,upgraded:l}}const h=(0,i.createContext)({fs:new r.Q2(new r.JU),canUpgradeFs:!1,upgradeFs(){},closeFs(){},status:"",setStatus(){},storage:{}})},1916:(e,t,n)=>{n.d(t,{EH:()=>s,Ik:()=>a,Le:()=>o});var r=n(4544);function i(e){return e.split(r.d$).slice(0,-1).join(r.d$)}function s(){return window.showDirectoryPicker({id:"nand2tetris",mode:"readwrite",startIn:"documents"})}class a{baseDir;constructor(e){this.baseDir=e}async getFolder(e,t=!1){let n=this.baseDir;const i=e.split(r.d$).slice(1).filter((e=>""!=e.trim()));for(const r of i)n=await n.getDirectoryHandle(r,{create:t});return n}async copyFile(e,t){throw new Error("unimplemented: FileSystemAccessFileSystemAdapter::copyFile")}async mkdir(e){this.getFolder(e,!0)}async readFile(e){const t=await this.getFolder(i(e));return(await(await t.getFileHandle((0,r.P8)(e))).getFile()).text()}async writeFile(e,t){const n=await this.getFolder(i(e),!0),s=await(await n.getFileHandle((0,r.P8)(e),{create:!0})).createWritable();await s.write(t),await s.close()}async readdir(e){const t=await this.getFolder(e),n=[];for await(const[r,i]of t.entries())n.push(r);return n}async scandir(e){const t=await this.getFolder(e),n=[];for await(const[r,i]of t.entries())n.push({name:r,isDirectory:()=>"directory"==i.kind,isFile:()=>"file"==i.kind});return n}async stat(e){const t=await this.getFolder(i(e));for await(const[n,i]of t.entries())if(n==(0,r.P8)(e))return{name:n,isDirectory:()=>"directory"==i.kind,isFile:()=>"file"==i.kind};return{name:(0,r.P8)(e),isDirectory:()=>!1,isFile:()=>!1}}async rm(e){const t=await this.getFolder(i(e),!0);await t.removeEntry((0,r.P8)(e),{recursive:!0})}}class o{adapter;nextAdapter;constructor(e,t){this.adapter=e,this.nextAdapter=t}stat(e){return this.adapter.stat(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.stat(e);throw t}))}readdir(e){return this.adapter.readdir(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.readdir(e);throw t}))}scandir(e){return this.adapter.scandir(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.scandir(e);throw t}))}async mkdir(e){return this.nextAdapter&&await this.nextAdapter.mkdir(e),this.adapter.mkdir(e)}async copyFile(e,t){return this.nextAdapter&&await this.nextAdapter.copyFile(e,t),this.adapter.copyFile(e,t)}readFile(e){return this.adapter.readFile(e).catch((t=>{if(this.nextAdapter)return this.nextAdapter.readFile(e);throw t}))}async writeFile(e,t){return this.nextAdapter&&await(this.nextAdapter?.writeFile(e,t)),this.adapter.writeFile(e,t)}async rm(e){return this.nextAdapter&&await this.nextAdapter.rm(e),this.adapter.rm(e)}}},3180:(e,t,n)=>{n.d(t,{C1:()=>A,GH:()=>S,NY:()=>b,XC:()=>v});var r=n(4641),i=n(5874),s=n(8878),a=n(8463),o=n(7738),l=n(6980),u=n(9651),c=n(1164),p=n(6554),d=n(1106),h=n(7490),f=n(1593),m=n(2469),g=n(7365),y=n(910);const v="noScreen",b=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function w(e){return e in a.O?a.O[e]:a.Kx[e].concat(a.a5[e])}function S(e,t){return a.Kx[e].includes(t)}async function x(e,t){const r=await async function(e,t){const{ChipProjects:r}=await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288));return S(e,t)?r[e].BUILTIN_CHIPS[t]:r[e].CHIPS[t][`${t}.hdl`]}(e,t);if(S(e,t))return r;const i="//// Replace this comment with your code.",s=`BUILTIN ${t};`;return r.includes(i)?r.replace(i,s):r.replace("PARTS:",`PARTS:\n ${s}`)}function k(e,t=!1,n=!1){return{clocked:e.clocked,inPins:(0,h.FX)(e.ins),outPins:(0,h.FX)(e.outs),internalPins:(0,h.FX)(e.pins),chip:[e],pending:t,invalid:n}}const _=c.z.get();function I(e,t,s,h){const f=function(e){const t=e["/chip/project"]??"01";return{project:t,chips:w(t),chipName:e["/chip/chip"]??a.a5[t][0]}}(s);let{project:y,chipName:b}=f;const{chips:I}=f;let A=new u.ti,C=[],E=new d.BX,O=!1,P=!1,L=!1;const R={setFiles(e,{hdl:t=e.files.hdl,tst:n=e.files.tst,cmp:r=e.files.cmp,out:i=""}){e.files.hdl=t,e.files.tst=n,e.files.cmp=r,e.files.out=i},updateChip(e,t){e.sim=k(A,t?.pending??e.sim.pending,t?.invalid??e.sim.invalid),e.controls.error=e.sim.invalid?t?.error??e.controls.error:void 0},setProject(e,t){const n=w(t),r=e.controls.chipName&&n.includes(e.controls.chipName)?e.controls.chipName:n[0];e.controls.project=t,e.controls.chips=n,this.setChip(e,r)},setChip(e,t){e.controls.chipName=t,e.controls.tests=Array.from(C),e.controls.hasBuiltin=l.Mo.has(t),e.controls.builtinOnly=S(e.controls.project,t)},setTest(e,t){e.controls.testName=t},setVisualizationParams(e,t){e.controls.visualizationParameters=new Set(t)},testRunning(e){e.controls.runningTest=!0},testFinished(e){e.controls.runningTest=!1;const n=(0,g.U)(e.files.cmp.trim(),e.files.out.trim());Promise.resolve().then((()=>{t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")}))},updateTestStep(e){if(e.files.out=E?.log()??"",E?.currentStep?.span)e.controls.span=E.currentStep.span;else if(E.done){const t=e.files.tst.length;e.controls.span={start:t-1,end:t,line:e.files.tst.split("\n").length}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})},updateConfig(e,t){e.config={...e.config,...t}}},N={setProject(e){y=s["/chip/project"]=e,h.current({action:"setProject",payload:y}),this.setChip(a.a5[y][0])},async setChip(e,t=s["/chip/project"]??"01"){b=s["/chip/chip"]=e,P=S(t,b),P?this.useBuiltin():(await this.loadChip(t,b),O&&this.useBuiltin()),await this.initializeTest(e),h.current({action:"setChip",payload:b})},setTest(e){h.current({action:"setTest",payload:e}),h.current({action:"setVisualizationParams",payload:new Set("ComputerAdd.tst"==e||"ComputerMax.tst"==e?[v]:[])}),this.loadTest(e)},reset(){c.z.get().reset(),A.reset(),E.reset(),h.current({action:"setFiles",payload:{}}),h.current({action:"updateChip"})},async updateFiles({hdl:e,tst:n,cmp:i}){L=!1,h.current({action:"setFiles",payload:{hdl:e,tst:n,cmp:i}});try{e&&await this.compileChip(e),n&&this.compileTest(n)}catch(s){t((0,r.V)(s))}h.current({action:"updateChip",payload:{invalid:L}}),L||t("HDL code: No syntax errors")},async compileChip(e){A.remove();const n=await(0,o.qg)(e,b);if((0,i.ys)(n)){const e=(0,i._)(n);return t((0,i._)(n).message),L=!0,void h.current({action:"updateChip",payload:{invalid:!0,error:e}})}this.replaceChip((0,i.Ok)(n))},replaceChip(e){const t=A.ins;for(const[n,{busVoltage:r}]of t){const t=e.ins.get(n);t&&(t.busVoltage=r)}_.reset(),e.eval(),A=e,A.reset(),E=E.with(A).reset(),h.current({action:"updateChip",payload:{invalid:!1}}),h.current({action:"updateTestStep"})},async loadChip(t,n){s["/chip/chip"]=n;const r=await e.readFile((i="hdl",`/projects/${t}/${n}/${n}.${i}`)).catch((()=>function(e){return`CHIP ${e} {\n IN in;\n OUT out;\n PARTS:\n}`}(n)));var i;h.current({action:"setFiles",payload:{hdl:r}}),await this.compileChip(r)},async initializeTest(t){C=(await e.scandir(`/projects/${y}/${t}`)).filter((e=>e.name.endsWith(".tst"))).map((e=>e.name)),C.length>0&&await this.setTest(C[0])},async loadTest(t){const[n,r]=await Promise.all([e.readFile(`/projects/${y}/${b}/${t}`).catch((()=>"repeat 10 {\n tick,\n tock;\n}")),e.readFile(`/projects/${y}/${b}/${t}`.replace(".tst",".cmp")).catch((()=>"| in|out|"))]);h.current({action:"setFiles",payload:{cmp:r,tst:n}}),this.compileTest(n)},async saveChip(n,r=y,i=b){h.current({action:"setFiles",payload:{hdl:n}});const s=`/projects/${r}/${i}/${i}.hdl`;await e.writeFile(s,n),t(`Saved ${s}`)},toggle(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<await Promise.all(a.a5[y].map((t=>({name:`${t}.hdl`,content:e.readFile(`/projects/${y}/${t}/${t}.hdl`)}))))};return{initialState:{controls:{project:y,chips:I,chipName:b,tests:C,testName:"",hasBuiltin:l.Mo.has(b),builtinOnly:S(y,b),runningTest:!1,error:void 0,visualizationParameters:new Set},files:{hdl:"",cmp:"",tst:"",out:""},sim:k(new u.ti),config:{speed:2}},reducers:R,actions:N}}function A(){const{fs:e,setStatus:t,storage:n}=(0,s.useContext)(y.L),r=(0,s.useRef)((()=>{})),{initialState:i,reducers:a,actions:o}=(0,s.useMemo)((()=>I(e,t,n,r)),[e,t,n,r]),[l,u]=(0,f.A)(a,i);return r.current=u,{state:l,dispatch:r,actions:o}}},4256:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(7076);class i extends r.qN{dispatch;constructor(e,t){super(e,e.size,0),this.dispatch=t}async load(e,t){await super.load(e,t),this.dispatch.current({action:"update"})}}},8849:(e,t,n)=>{n.d(t,{$:()=>w,vw:()=>x});var r=n(5874),i=n(8463),s=n(7076),a=n(6554),o=n(9563),l=n(3977);const u='Vm <: Base {\n Root := Vm\n\n Vm = newline* VmInstructionLine* VmInstruction?\n\n space := comment | " " | "\t"\n whitespace = lineComment | comment | space\n\n VmInstructionLine = VmInstruction newline+\n VmInstruction =\n | StackInstruction\n | OpInstruction\n | FunctionInstruction\n | CallInstruction\n | ReturnInstruction\n | GotoInstruction\n | LabelInstruction\n \n StackInstruction = (push | pop) MemorySegment Number\n OpInstruction = Add | Sub | Neg | Lt | Gt | Eq | And | Or | Not\n FunctionInstruction = function Name Number \n CallInstruction = call Name Number\n ReturnInstruction = return\n LabelInstruction = label Name\n GotoInstruction = (goto | ifGoto) Name\n\n MemorySegment = argument | local | static | constant | this | that | pointer | temp\n\n push = "push" whitespace+\n pop = "pop" whitespace+\n function = "function" whitespace+\n call = "call" whitespace+\n return = "return"\n goto = "goto" whitespace+\n ifGoto = "if-goto" whitespace+\n label = "label" whitespace+\n\n argument = "argument" whitespace+\n local = "local" whitespace+\n static = "static" whitespace+\n constant = "constant" whitespace+\n this = "this" whitespace+\n that = "that" whitespace+\n pointer = "pointer" whitespace+\n temp = "temp" whitespace+\n\n Add = "add" \n Sub = "sub" \n Neg = "neg" \n Eq = "eq"\n Lt = "lt" \n Gt = "gt" \n And = "and" \n Or = "or" \n Not = "not"\n}',c=(0,o.qN)(u,l.lN),p=c.extendSemantics(l.JE);p.addAttribute("op",{push:(e,t)=>"push",pop:(e,t)=>"pop",function:(e,t)=>"function",call:(e,t)=>"call",return:e=>"return",goto:(e,t)=>"goto",ifGoto:(e,t)=>"if-goto",label:(e,t)=>"label",Add:e=>"add",Sub:e=>"sub",Neg:e=>"neg",Eq:e=>"eq",Lt:e=>"lt",Gt:e=>"gt",And:e=>"and",Or:e=>"or",Not:e=>"not"}),p.addAttribute("segment",{argument:(e,t)=>"argument",local:(e,t)=>"local",static:(e,t)=>"static",constant:(e,t)=>"constant",this:(e,t)=>"this",that:(e,t)=>"that",pointer:(e,t)=>"pointer",temp:(e,t)=>"temp"}),p.addAttribute("instruction",{StackInstruction({op:e},{segment:t},n){return{op:e,segment:t,offset:Number(n.sourceString),span:(0,l.Ln)(this.source)}},OpInstruction({op:e}){return{op:e,span:(0,l.Ln)(this.source)}},FunctionInstruction(e,{name:t},n){return{op:"function",name:t,nVars:Number(n.sourceString),span:(0,l.Ln)(this.source)}},CallInstruction(e,{name:t},n){return{op:"call",name:t,nArgs:Number(n.sourceString),span:(0,l.Ln)(this.source)}},ReturnInstruction(e){return{op:"return",span:(0,l.Ln)(this.source)}},LabelInstruction(e,{name:t}){return{op:"label",label:t,span:(0,l.Ln)(this.source)}},GotoInstruction({op:e},{name:t}){return{op:e,label:t,span:(0,l.Ln)(this.source)}},VmInstructionLine:(e,t)=>e.instruction}),p.addAttribute("vm",{Vm(e,t,n){const r=t.children.map((e=>e.instruction))??[];return{instructions:n.child(0)?[...r,n.child(0).instruction]:r}}}),p.addAttribute("root",{Root:({vm:e})=>e});const d={grammar:u,semantics:p,parser:c,parse:(0,l.Q5)(c,p)};var h=n(8783),f=n(5087),m=n(8878),g=n(7365),y=n(1593),v=n(910),b=n(4256);const w="repeat {\n\tvmstep;\n}";function S(e,t,n,r){const i=new b.X(e.vm.RAM,t),a=new b.X(e.vm.Screen,t),o=new s.PC(new b.X(e.vm.RAM,t)),l=e.vm.derivedLine();let u=[];try{u=e.vm.vmStack().reverse()}catch(c){n("Runtime error: Invalid stack")}return{Keyboard:o,RAM:i,Screen:a,Stack:u,Prog:e.vm.program,Statics:[...e.vm.memory.map(((e,t)=>t),16,16+e.vm.getStaticCount())],Temp:[...e.vm.memory.map(((e,t)=>t),5,13)],AddedSysInit:e.vm.addedSysInit,highlight:l,showHighlight:r}}function x(){const{fs:e,setStatus:t,storage:n}=(0,m.useContext)(v.L),s=(0,m.useRef)((()=>{})),{initialState:o,reducers:l,actions:u}=(0,m.useMemo)((()=>function(e,t,n,s){const o=(0,r.oA)(d.parse(i.J5));let l=(0,r.oA)(f.Vm.build(o.instructions)),u=new h.Y(t).with(l),c=!1,p=!0,m="",y=!0;const v={setVm(e,t){e.files.vm=t},setTst(e,{tst:t,cmp:n}){e.files.tst=t,e.files.cmp=n??""},setExitCode(e,t){e.controls.exitCode=t},setValid(e,t){e.controls.valid=t},setShowHighlight(e,t){e.vm.showHighlight=t},setError(e,n){n?(e.controls.valid=!1,t(n?.message)):e.controls.valid=!0,e.controls.error=n},setPath(e,t){e.test.path=t},update(e){e.vm=S(u,s,t,y),e.test.highlight=u.currentStep?.span},setAnimate(e,t){e.controls.animate=t},testStep(e){e.files.out=u.log()},testFinished(e){const n=(0,g.U)(e.files.cmp.trim(),e.files.out);t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},setTitle(e,t){e.title=t},updateConfig(e,t){e.config={...e.config,...t}}},b={vm:S(u,s,t,!0),controls:{exitCode:void 0,runningTest:!1,animate:!0,valid:!0},test:{highlight:void 0,path:"/"},files:{vm:"",tst:w,cmp:"",out:""},config:{ram1Format:"dec",ram2Format:"dec",screenScale:1,speed:2,testSpeed:2}},x={setVm(e){if(y=!1,s.current({action:"setVm",payload:e}),m==e)return;m=e;const t=d.parse(e);if((0,r.ys)(t))return s.current({action:"setError",payload:(0,r._)(t)}),!1;const n=(0,r.oA)(t).instructions,i=f.Vm.build(n);return this.replaceVm(i)},loadVm(e){y=!1;for(const r of e)r.content.endsWith("\n")&&(r.content=r.content.slice(0,-1));const t=e.map((e=>e.content)).join("\n");if(s.current({action:"setVm",payload:t}),m==t)return;m=t;const n=[];let i=0;for(const o of e){const e=d.parse(o.content);if((0,r.ys)(e))return s.current({action:"setError",payload:(0,r._)(e)}),!1;const t=(0,r.oA)(e).instructions;for(const n of t)void 0!=n.span?.line&&(n.span.line+=i);i+=o.content.split("\n").length,n.push({name:o.name,instructions:t})}const a=f.Vm.buildFromFiles(n);return this.replaceVm(a)},replaceVm:e=>(0,r.ys)(e)?(s.current({action:"setError",payload:(0,r._)(e)}),!1):(s.current({action:"setError"}),t("Compiled VM code successfully"),l=(0,r.oA)(e),u.vm=l,s.current({action:"update"}),!0),loadTest(n,i,o){s.current({action:"setTst",payload:{tst:i,cmp:o}});const c=a.uG.parse(i);return(0,r.ys)(c)?(s.current({action:"setValid",payload:!1}),t("Failed to parse test"),!1):(s.current({action:"setValid",payload:!0}),t("Parsed tst"),l.reset(),u=h.Y.from((0,r.oA)(c),n,(e=>{this.loadVm(e)}),t).using(e),u.vm=l,s.current({action:"update"}),!0)},setAnimate(e){p=e,s.current({action:"setAnimate",payload:e})},async testStep(){y=!0;let e=!1;try{return e=await u.step(),s.current({action:"testStep"}),e&&s.current({action:"testFinished"}),p&&s.current({action:"update"}),e}catch(n){return t(`Runtime error: ${n.message}`),s.current({action:"setValid",payload:!1}),!0}},setPaused(e=!0){l.setPaused(e)},step(){y=!0;try{let e=!1;const t=l.step();return void 0!==t&&(e=!0,s.current({action:"setExitCode",payload:t})),p&&s.current({action:"update"}),e}catch(e){return t(`Runtime error: ${e.message}`),s.current({action:"setValid",payload:!1}),!0}},reset(){y=!0,u.reset(),l.reset(),s.current({action:"update"}),s.current({action:"setExitCode",payload:void 0}),s.current({action:"setValid",payload:!0})},toggleUseTest(){c=!c,s.current({action:"update"})},initialize(){s.current({action:"setTitle",payload:void 0}),this.setVm(i.J5)}};return{initialState:b,reducers:v,actions:x}}(e,t,0,s)),[e,t,n,s]),[c,p]=(0,y.A)(l,o);return s.current=p,{state:c,dispatch:s,actions:u}}},2469:(e,t,n)=>{n.d(t,{H8:()=>a,Z1:()=>s,vA:()=>i});class r extends Error{constructor(e="Assertion failed"){super(e)}}function i(e,t){if(!e)throw new r(t instanceof Function?t():t)}function s(e,t="Assertion failed: value does not exist"){return i(null!=e,t),e}function a(e,t=`Unexpected value ${e}`){throw new Error(t instanceof Function?t():t)}},4641:(e,t,n)=>{n.d(t,{V:()=>r});const r=e=>{if((e=>"function"===typeof e?.toString||"string"===typeof e)(e)){const t=e.toString();return"[object Object]"===t?JSON.stringify(e):t}return JSON.stringify(e)}},4544:(e,t,n)=>{n.d(t,{JU:()=>h,P8:()=>u,Q2:()=>p,cL:()=>f,d$:()=>a});const r={SEP:"\\",WD:"C:\\\\",isAbsolute:e=>Boolean(e.match(new RegExp("^[a-zA-Z]:\\\\")))},i={SEP:"/",WD:"/",isAbsolute:e=>"/"==e[0]},s="undefined"!==typeof process&&"win32"==process.platform?r:i,a=s.SEP,o=s.WD,l=s.isAbsolute;function u(e){e.endsWith(a)&&(e=e.substring(0,e.length-1));return e.split(a).at(-1)??""}function c(...e){const t=[];for(const n of e)for(const e of n.split(a))switch(e){case"":case".":break;case"..":t.pop();break;default:t.push(e)}return(s==i?a:"")+t.join(a)}class p{adapter;wd=o;stack=[];constructor(e=new d){this.adapter=e}cwd(){return this.wd}cd(e){this.wd=this.p(e)}pushd(e){this.stack.push(this.wd),this.cd(e)}popd(){this.stack.length>0&&(this.wd=this.stack.pop())}stat(e){return this.adapter.stat(this.p(e))}scandir(e){return this.adapter.scandir(this.p(e))}readdir(e){return this.adapter.readdir(this.p(e))}mkdir(e){return this.adapter.mkdir(this.p(e))}copyFile(e,t){return this.adapter.copyFile(this.p(e),this.p(t))}readFile(e){return this.adapter.readFile(this.p(e))}writeFile(e,t){return this.adapter.writeFile(this.p(e),t)}rm(e){return this.adapter.rm(this.p(e))}p(e){return l(e)?e:c(this.cwd(),e)}}class d{fs;constructor(e={}){this.fs=e}stat(e){return new Promise(((t,n)=>{if(this.fs[e])return t({name:u(e),isDirectory:()=>!1,isFile:()=>!0});e.endsWith(a)||(e+=a);for(let r of Object.keys(this.fs))if(r.startsWith(e))return t({name:u(e),isDirectory:()=>!0,isFile:()=>!1});n()}))}async scandir(e){return(await this.readdir(e)).map((t=>{let n=void 0!==this.fs[c(e,t)];return{name:t,isDirectory:()=>!n,isFile:()=>n}}))}readdir(e){return e.endsWith(a)||(e+=a),new Promise((t=>{let n=new Set;for(const r of Object.keys(this.fs))if(r.startsWith(e)){const t=r.indexOf(a,e.length+1),i=r.substring(e.length,-1===t?void 0:t);n.add(i)}return t([...n].sort())}))}mkdir(e){return Promise.resolve()}copyFile(e,t){return new Promise((n=>{this.fs[t]=this.fs[e],n()}))}readFile(e){return new Promise(((t,n)=>{let r=this.fs[e];if(void 0===r){n(new Error(`File Not Found ${e}`))}else t(r)}))}writeFile(e,t){return new Promise((n=>{this.fs[e]=t,n()}))}rm(e){return new Promise((t=>{delete this.fs[e],t()}))}}class h extends d{constructor(){super(window.localStorage)}}async function f(e,t){for(const[n,r]of Object.entries(t))"string"===typeof r?await e.writeFile(n,r):(e.cd(n),await f(e,r),e.cd(".."))}},742:(e,t,n)=>{function r(e,t,n=1){const r=[];for(let i=e;ir})},5874:(e,t,n)=>{n.d(t,{HQ:()=>i,Ok:()=>a,_:()=>o,oA:()=>l,ys:()=>s});const r=e=>null===e;const i=e=>Object.prototype.hasOwnProperty.call(e??{},"ok"),s=e=>Object.prototype.hasOwnProperty.call(e,"err");function a(e){return i(e)?e.ok:{ok:e,map(e){return e(a(this))}}}function o(e){return e.err??{err:e,map(e){return this}}}function l(e){if(r(e))throw new Error("Attempted to unwrap None");if(s(e))throw o(e);return i(e)?a(e):e}},8256:(e,t,n)=>{n.d(t,{Ru:()=>k});var r=n(2527);const i=e=>"string"===typeof e,s=new Map,a="en";function o(e){return[...Array.isArray(e)?e:[e],a]}function l(e,t,n){const r=o(e);return p((()=>d("date",r,n)),(()=>new Intl.DateTimeFormat(r,n))).format(i(t)?new Date(t):t)}function u(e,t,n){const r=o(e);return p((()=>d("number",r,n)),(()=>new Intl.NumberFormat(r,n))).format(t)}function c(e,t,n,{offset:r=0,...i}){const s=o(e),a=t?p((()=>d("plural-ordinal",s)),(()=>new Intl.PluralRules(s,{type:"ordinal"}))):p((()=>d("plural-cardinal",s)),(()=>new Intl.PluralRules(s,{type:"cardinal"})));return i[n]??i[a.select(n-r)]??i.other}function p(e,t){const n=e();let r=s.get(n);return r||(r=t(),s.set(n,r)),r}function d(e,t,n){return`${e}-${t.join("-")}-${JSON.stringify(n)}`}const h=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g,f="%__lingui_octothorpe__%",m=(e,t)=>t[e]??t.other;function g(e,t,n){return(s={},a)=>{const o=((e,t,n={})=>{const r=t||e,i=e=>"object"===typeof e?e:n[e]||{style:e},s=(e,t)=>{const s=Object.keys(n).length?i("number"):void 0,a=u(r,e,s);return t.replace(new RegExp(f,"g"),a)};return{plural:(e,t)=>{const{offset:n=0}=t,i=c(r,!1,e,t);return s(e-n,i)},selectordinal:(e,t)=>{const{offset:n=0}=t,i=c(r,!0,e,t);return s(e-n,i)},select:m,number:(e,t)=>u(r,e,i(t)),date:(e,t)=>l(r,e,i(t))}})(t,n,a),p=(e,t=!1)=>Array.isArray(e)?e.reduce(((e,n)=>{if("#"===n&&t)return e+f;if(i(n))return e+n;const[r,a,l]=n;let u,c={};if("plural"===a||"selectordinal"===a||"select"===a?Object.entries(l).forEach((([e,t])=>{c[e]=p(t,"plural"===a||"selectordinal"===a)})):c=l,a){u=(0,o[a])(s[r],c)}else u=s[r];return null==u?e:e+u}),""):e,d=p(e);return i(d)&&h.test(d)?(0,r.MH)(d.trim()):i(d)?d.trim():d?String(d):""}}var y=Object.defineProperty,v=(e,t,n)=>(((e,t,n)=>{t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class b{constructor(){v(this,"_events",{})}on(e,t){var n;return(n=this._events)[e]??(n[e]=[]),this._events[e].push(t),()=>this.removeListener(e,t)}removeListener(e,t){const n=this._getListeners(e);if(!n)return;const r=n.indexOf(t);~r&&n.splice(r,1)}emit(e,...t){const n=this._getListeners(e);n&&n.map((e=>e.apply(this,t)))}_getListeners(e){const t=this._events[e];return!!Array.isArray(t)&&t}}var w=Object.defineProperty,S=(e,t,n)=>(((e,t,n)=>{t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class x extends b{constructor(e){super(),S(this,"_locale",""),S(this,"_locales"),S(this,"_localeData",{}),S(this,"_messages",{}),S(this,"_missing"),S(this,"t",this._.bind(this)),null!=e.missing&&(this._missing=e.missing),null!=e.messages&&this.load(e.messages),null!=e.localeData&&this.loadLocaleData(e.localeData),("string"===typeof e.locale||e.locales)&&this.activate(e.locale??a,e.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){return this._messages[this._locale]??{}}get localeData(){return this._localeData[this._locale]??{}}_loadLocaleData(e,t){const n=this._localeData[e];n?Object.assign(n,t):this._localeData[e]=t}loadLocaleData(e,t){null!=t?this._loadLocaleData(e,t):Object.keys(e).forEach((t=>this._loadLocaleData(t,e[t]))),this.emit("change")}_load(e,t){const n=this._messages[e];n?Object.assign(n,t):this._messages[e]=t}load(e,t){"string"==typeof e&&"object"===typeof t?this._load(e,t):Object.entries(e).forEach((([e,t])=>this._load(e,t))),this.emit("change")}loadAndActivate({locale:e,locales:t,messages:n}){this._locale=e,this._locales=t||void 0,this._messages[this._locale]=n,this.emit("change")}activate(e,t){this._locale=e,this._locales=t,this.emit("change")}_(e,t,n){let r=n?.message;e||(e=""),i(e)||(t=e.values||t,r=e.message,e=e.id);const s=this.messages[e],a=void 0===s,o=this._missing;if(o&&a)return"function"===typeof o?o(this._locale,e):o;a&&this.emit("missing",{id:e,locale:this._locale});let l=s||r||e;return i(l)&&h.test(l)?JSON.parse(`"${l}"`):i(l)?l:g(l,this._locale,this._locales)(t,n?.formats)}date(e,t){return l(this._locales||this._locale,e,t)}number(e,t){return u(this._locales||this._locale,e,t)}}const k=function(e={}){return new x(e)}()},6458:(e,t,n)=>{n.d(t,{CY:()=>f,x6:()=>m});var r=n(8878);const i=/<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/,s=/(?:\r\n|\r|\n)/g,a={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0};function o(e,t={}){const n=u(0,"$lingui$"),c=e.replace(s,"").split(i);if(1===c.length)return e;const p=[],d=c.shift();d&&p.push(d);for(const[i,s,u]of l(c)){let e="undefined"!==typeof i?t[i]:void 0;(!e||a[e.type]&&s)&&(e?console.error(`${e.type} is a void element tag therefore it must have no children`):console.error(`Can't use element at index '${i}' as it is not declared in the original translation`),e=r.createElement(r.Fragment)),Array.isArray(e)&&(e=r.createElement(r.Fragment,{},e)),p.push(r.cloneElement(e,{key:n()},s?o(s,t):e.props.children)),u&&p.push(u)}return p}function l(e){if(!e.length)return[];const[t,n,r,i]=e.slice(0,4);return[[t||r,n||"",i]].concat(l(e.slice(4,e.length)))}const u=(e=0,t="")=>()=>`${t}_${e++}`;function c(e){const{render:t,component:n,id:i,message:s,formats:a,lingui:{i18n:l,defaultComponent:u}}=e,c={...e.values},d={...e.components};c&&Object.keys(c).forEach((e=>{const t=c[e];if(!(r.isValidElement(t)||Array.isArray(t)&&t.every(r.isValidElement)))return;const n=Object.keys(d).length;d[n]=t,c[e]=`<${n}/>`}));const h=l&&"function"===typeof l._?l._(i,c,{message:s,formats:a}):i,f=h?o(h,d):null;if(null===t||null===n)return f;const m=u||p,g={id:i,message:s,translation:f,isTranslated:i!==f&&s!==f,children:f};if(t&&n)console.error("You can't use both `component` and `render` prop at the same time. `component` is ignored.");else if(t&&"function"!==typeof t)console.error(`Invalid value supplied to prop \`render\`. It must be a function, provided ${t}`);else if(n&&"function"!==typeof n)return console.error(`Invalid value supplied to prop \`component\`. It must be a React component, provided ${n}`),r.createElement(m,g,f);if("function"===typeof t)return t(g);const y=n||m;return r.createElement(y,g,f)}const p=({children:e})=>r.createElement(r.Fragment,null,e),d=r.createContext(null),h=e=>r.useContext(d);const f=({i18n:e,defaultComponent:t,children:n})=>{const i=r.useRef(e.locale),s=r.useCallback((()=>({i18n:e,defaultComponent:t,_:e.t.bind(e)})),[e,t]),[a,o]=r.useState(s());return r.useEffect((()=>{const t=()=>{i.current=e.locale,o(s())},n=e.on("change",t);return i.current!==e.locale&&t(),n}),[e,s]),i.current?r.createElement(d.Provider,{value:a},n):null};function m(e){let t;const n=h(t);return r.createElement(c,{...e,lingui:n})}},9563:(e,t,n)=>{n.d(t,{qN:()=>at});var r={};n.r(r),n.d(r,{CV:()=>m,b0:()=>s,vA:()=>a,Ms:()=>p,xA:()=>o,$L:()=>c,pX:()=>h,lO:()=>d,Ho:()=>f,ux:()=>u,repeatStr:()=>l,qj:()=>y,rE:()=>v});const i={};for(let ot=0;ot<128;ot++)i[ot]=String.fromCharCode(ot);function s(e){const t=e||"";return function(){throw new Error("this method "+t+" is abstract! (it has no implementation in class "+this.constructor.name+")")}}function a(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t,n){let r;Object.defineProperty(e,t,{get(){return r||(r=n.call(this)),r}})}function l(e,t){return new Array(t+1).join(e)}function u(e,t){return function(e,t){const n=[];for(;t-- >0;)n.push(e());return n}((()=>e),t)}function c(e){const t=[];for(let n=0;n{t.indexOf(e)<0&&t.push(e)})),t}function d(e){const t=e[0];return t===t.toUpperCase()}function h(e){return!d(e)}function f(e,t,n){const r=n||" ";return e.lengthString.fromCodePoint(parseInt(e,16));function y(e){if("\\"!==e.charAt(0))return e;switch(e.charAt(1)){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"x":return g(e.slice(2,4));case"u":return"{"===e.charAt(2)?g(e.slice(3,-1)):g(e.slice(2,6));default:return e.charAt(1)}}function v(e){if(null==e)return String(e);const t=Object.prototype.toString.call(e);try{let n;return n=e.constructor&&e.constructor.name?e.constructor.name:0===t.indexOf("[object ")?t.slice(8,-1):typeof e,n+": "+JSON.stringify(String(e))}catch(n){return t}}const b={Lu:/\p{Lu}/u,Ll:/\p{Ll}/u,Lt:/\p{Lt}/u,Lm:/\p{Lm}/u,Lo:/\p{Lo}/u,Nl:/\p{Nl}/u,Nd:/\p{Nd}/u,Mn:/\p{Mn}/u,Mc:/\p{Mc}/u,Pc:/\p{Pc}/u,Zs:/\p{Zs}/u,L:/\p{Letter}/u,Ltmo:/\p{Lt}|\p{Lm}|\p{Lo}/u};class w{constructor(){if(this.constructor===w)throw new Error("PExpr cannot be instantiated -- it's abstract")}withSource(e){return e&&(this.source=e.trimmed()),this}}const S=Object.create(w.prototype),x=Object.create(w.prototype);class k extends w{constructor(e){super(),this.obj=e}}class _ extends w{constructor(e,t){super(),this.from=e,this.to=t,this.matchCodePoint=e.length>1||t.length>1}}class I extends w{constructor(e){super(),this.index=e}}class A extends w{constructor(e){super(),this.terms=e}}class C extends A{constructor(e,t,n){super([n,e.rules[t].body]),this.superGrammar=e,this.name=t,this.body=n}}class E extends A{constructor(e,t,n,r){const i=e.rules[t].body;super([...n,i,...r]),this.superGrammar=e,this.ruleName=t,this.expansionPos=n.length}}class O extends w{constructor(e){super(),this.factors=e}}class P extends w{constructor(e){super(),this.expr=e}}class L extends P{}class R extends P{}class N extends P{}L.prototype.operator="*",R.prototype.operator="+",N.prototype.operator="?",L.prototype.minNumMatches=0,R.prototype.minNumMatches=1,N.prototype.minNumMatches=0,L.prototype.maxNumMatches=Number.POSITIVE_INFINITY,R.prototype.maxNumMatches=Number.POSITIVE_INFINITY,N.prototype.maxNumMatches=1;class T extends w{constructor(e){super(),this.expr=e}}class M extends w{constructor(e){super(),this.expr=e}}class F extends w{constructor(e){super(),this.expr=e}}class j extends w{constructor(e,t=[]){super(),this.ruleName=e,this.args=t}isSyntactic(){return d(this.ruleName)}toMemoKey(){return this._memoKey||Object.defineProperty(this,"_memoKey",{value:this.toString()}),this._memoKey}}class D extends w{constructor(e){super(),this.category=e,this.pattern=b[e]}}function $(e,t){let n;return t?(n=new Error(t.getLineAndColumnMessage()+e),n.shortMessage=e,n.interval=t):n=new Error(e),n}function z(){return $("Interval sources don't match")}function V(e,t,n){return $("Rule "+e+" is not declared in grammar "+t,n)}function U(e,t,n,r){let i="Duplicate declaration for rule '"+e+"' in grammar '"+t+"'";return t!==n&&(i+=" (originally declared in '"+n+"')"),$(i,r)}function B(e,t,n,r){return $("Wrong number of parameters for rule "+e+" (expected "+t+", got "+n+")",r)}function W(e,t,n){return $("Duplicate parameter names in rule "+e+": "+t.join(", "),n)}function H(e,t){return $("Incorrect argument type: expected "+e,t.source)}function G(e,t){const n=t.length>0?t[t.length-1].args:[];let r="Nullable expression "+e.expr.substituteParams(n)+" is not allowed inside '"+e.operator+"' (possible infinite loop)";if(t.length>0){r+="\nApplication stack (most recent application last):\n"+t.map((e=>new j(e.ruleName,e.args))).join("\n")}return $(r,e.expr.source)}function q(e,t,n,r){return $("Rule "+e+" involves an alternation which has inconsistent arity (expected "+t+", got "+n+")",r.source)}function K(e){if(1===e.length)throw e[0];if(e.length>1)throw function(e){const t=e.map((e=>e.message));return $(["Errors:"].concat(t).join("\n- "),e[0].interval)}(e)}function Q(e,t,n){const r=e.length;return(e.slice(0,n)+t+e.slice(n+t.length)).substr(0,r)}function Y(...e){const t=this,{offset:n}=t,{repeatStr:i}=r,s=new m;s.append("Line "+t.lineNum+", col "+t.colNum+":\n");const o=function(e){let t=0;return e.map((e=>{const n=e.toString();return t=Math.max(t,n.length),n})).map((e=>f(e,t)))}([null==t.prevLine?0:t.lineNum-1,t.lineNum,null==t.nextLine?0:t.lineNum+1]),l=(e,t,n)=>{s.append(n+o[e]+" | "+t+"\n")};null!=t.prevLine&&l(0,t.prevLine," "),l(1,t.line,"> ");const u=t.line.length;let c=i(" ",u+1);for(let r=0;r=0&&s<=o,"range start must be >= 0 and <= end");const l=n-t.colNum+1;s=Math.max(0,s-l),o=Math.min(o-l,u),c=Q(c,i("~",o-s),s)}const p=2+o[1].length+3;return s.append(i(" ",p)),c=Q(c,"^",t.colNum-1),s.append(c.replace(/ +$/,"")+"\n"),null!=t.nextLine&&l(2,t.nextLine," "),s.contents()}let X=[];function J(e){X.push(e)}function Z(e,t){let n=1,r=1,i=0,s=0,a=null,o=null,l=-1;for(;i=0&&(o=e.slice(l,s).replace(/\r?\n$/,""));return{offset:t,lineNum:n,colNum:r,line:e.slice(s,u).replace(/\r$/,""),prevLine:o,nextLine:a,toString:Y}}function ee(e,t,...n){return Z(e,t).toString(...n)}const te=(()=>{let e=0;return t=>""+t+e++})();class ne{constructor(e,t,n){this.sourceString=e,this.startIdx=t,this.endIdx=n}get contents(){return void 0===this._contents&&(this._contents=this.sourceString.slice(this.startIdx,this.endIdx)),this._contents}get length(){return this.endIdx-this.startIdx}coverageWith(...e){return ne.coverage(...e,this)}collapsedLeft(){return new ne(this.sourceString,this.startIdx,this.startIdx)}collapsedRight(){return new ne(this.sourceString,this.endIdx,this.endIdx)}getLineAndColumn(){return Z(this.sourceString,this.startIdx)}getLineAndColumnMessage(){const e=[this.startIdx,this.endIdx];return ee(this.sourceString,this.startIdx,e)}minus(e){if(this.sourceString!==e.sourceString)throw z();return this.startIdx===e.startIdx&&this.endIdx===e.endIdx?[]:this.startIdx=e.startIdx&&this.endIdx<=e.endIdx,"other interval does not cover this one"),new ne(this.sourceString,this.startIdx-e.startIdx,this.endIdx-e.startIdx)}trimmed(){const{contents:e}=this,t=this.startIdx+e.match(/^\s*/)[0].length,n=this.endIdx-e.match(/\s*$/)[0].length;return new ne(this.sourceString,t,n)}subInterval(e,t){const n=this.startIdx+e;return new ne(this.sourceString,n,n+t)}}ne.coverage=function(e,...t){let{startIdx:n,endIdx:r}=e;for(const i of t){if(i.sourceString!==e.sourceString)throw z();n=Math.min(n,i.startIdx),r=Math.max(r,i.endIdx)}return new ne(e.sourceString,n,r)};class re{constructor(e){this.source=e,this.pos=0,this.examinedLength=0}atEnd(){const e=this.pos>=this.source.length;return this.examinedLength=Math.max(this.examinedLength,this.pos+1),e}next(){const e=this.source[this.pos++];return this.examinedLength=Math.max(this.examinedLength,this.pos),e}nextCharCode(){const e=this.next();return e&&e.charCodeAt(0)}nextCodePoint(){const e=this.source.slice(this.pos++).codePointAt(0);return e>65535&&(this.pos+=1),this.examinedLength=Math.max(this.examinedLength,this.pos),e}matchString(e,t){let n;if(t){for(n=0;n!e.isFluffy()));for(let n=0;n0&&(n===t.length-1?e.append(t.length>2?", or ":" or "):e.append(", ")),e.append(t[n].toString());return e.contents()}getInterval(){const e=this.getRightmostFailurePosition();return new ne(this.input,e,e)}}class se{constructor(){this.applicationMemoKeyStack=[],this.memo={},this.maxExaminedLength=0,this.maxRightmostFailureOffset=-1,this.currentLeftRecursion=void 0}isActive(e){return this.applicationMemoKeyStack.indexOf(e.toMemoKey())>=0}enter(e){this.applicationMemoKeyStack.push(e.toMemoKey())}exit(){this.applicationMemoKeyStack.pop()}startLeftRecursion(e,t){t.isLeftRecursion=!0,t.headApplication=e,t.nextLeftRecursion=this.currentLeftRecursion,this.currentLeftRecursion=t;const{applicationMemoKeyStack:n}=this,r=n.indexOf(e.toMemoKey())+1,i=n.slice(r);t.isInvolved=function(e){return i.indexOf(e)>=0},t.updateInvolvedApplicationMemoKeys=function(){for(let e=r;e{const i=n[r];e+i.examinedLength>t?delete n[r]:(this.maxExaminedLength=Math.max(this.maxExaminedLength,i.examinedLength),this.maxRightmostFailureOffset=Math.max(this.maxRightmostFailureOffset,i.rightmostFailureOffset))}))}}const ae="\u22c5",oe="\u2409",le="\u240a",ue="\u240d",ce={succeeded:1,isRootNode:2,isImplicitSpaces:4,isMemoized:8,isHeadOfLeftRecursion:16,terminatesLR:32};function pe(e){return"string"===typeof e?e.replace(/ /g,ae).replace(/\t/g,oe).replace(/\n/g,le).replace(/\r/g,ue):String(e)}class de{constructor(e,t,n,r,i,s,a){this.input=e,this.pos=this.pos1=t,this.pos2=n,this.source=new ne(e,t,n),this.expr=r,this.bindings=s,this.children=a||[],this.terminatingLREntry=null,this._flags=i?ce.succeeded:0}get displayString(){return this.expr.toDisplayString()}clone(){return this.cloneWithExpr(this.expr)}cloneWithExpr(e){const t=new de(this.input,this.pos,this.pos2,e,this.succeeded,this.bindings,this.children);return t.isHeadOfLeftRecursion=this.isHeadOfLeftRecursion,t.isImplicitSpaces=this.isImplicitSpaces,t.isMemoized=this.isMemoized,t.isRootNode=this.isRootNode,t.terminatesLR=this.terminatesLR,t.terminatingLREntry=this.terminatingLREntry,t}recordLRTermination(e,t){this.terminatingLREntry=new de(this.input,this.pos,this.pos2,this.expr,!1,[t],[e]),this.terminatingLREntry.terminatesLR=!0}walk(e,t){let n=e;function r(e,i,s){let a=!0;n.enter&&n.enter.call(t,e,i,s)===de.prototype.SKIP&&(a=!1),a&&(e.children.forEach((t=>{r(t,e,s+1)})),n.exit&&n.exit.call(t,e,i,s))}"function"===typeof n&&(n={enter:n}),this.isRootNode?this.children.forEach((e=>{r(e,null,0)})):r(this,null,0)}toString(){const e=new m;return this.walk(((t,n,r)=>{if(!t)return this.SKIP;if("Alt"!==t.expr.constructor.name){if(e.append(function(e,t,n){const r=pe(e.slice(t,t+n));return r.length{const t=ce[e];Object.defineProperty(de.prototype,e,{get(){return 0!==(this._flags&t)},set(e){e?this._flags|=t:this._flags&=~t}})})),w.prototype.allowsSkippingPrecedingSpace=s("allowsSkippingPrecedingSpace"),S.allowsSkippingPrecedingSpace=x.allowsSkippingPrecedingSpace=j.prototype.allowsSkippingPrecedingSpace=k.prototype.allowsSkippingPrecedingSpace=_.prototype.allowsSkippingPrecedingSpace=D.prototype.allowsSkippingPrecedingSpace=function(){return!0},A.prototype.allowsSkippingPrecedingSpace=P.prototype.allowsSkippingPrecedingSpace=F.prototype.allowsSkippingPrecedingSpace=M.prototype.allowsSkippingPrecedingSpace=T.prototype.allowsSkippingPrecedingSpace=I.prototype.allowsSkippingPrecedingSpace=O.prototype.allowsSkippingPrecedingSpace=function(){return!1},J((e=>{he=e})),w.prototype.assertAllApplicationsAreValid=function(e,t){fe=0,this._assertAllApplicationsAreValid(e,t)},w.prototype._assertAllApplicationsAreValid=s("_assertAllApplicationsAreValid"),S._assertAllApplicationsAreValid=x._assertAllApplicationsAreValid=k.prototype._assertAllApplicationsAreValid=_.prototype._assertAllApplicationsAreValid=I.prototype._assertAllApplicationsAreValid=D.prototype._assertAllApplicationsAreValid=function(e,t){},F.prototype._assertAllApplicationsAreValid=function(e,t){fe++,this.expr._assertAllApplicationsAreValid(e,t),fe--},A.prototype._assertAllApplicationsAreValid=function(e,t){for(let n=0;n{if(n._assertAllApplicationsAreValid(e,t,o),1!==n.getArity())throw function(e,t){return $("Invalid parameter to rule "+e+": "+t+" has arity "+t.getArity()+", but parameter expressions must have arity 1",t.source)}(this.ruleName,n)}))},w.prototype.assertChoicesHaveUniformArity=s("assertChoicesHaveUniformArity"),S.assertChoicesHaveUniformArity=x.assertChoicesHaveUniformArity=k.prototype.assertChoicesHaveUniformArity=_.prototype.assertChoicesHaveUniformArity=I.prototype.assertChoicesHaveUniformArity=F.prototype.assertChoicesHaveUniformArity=D.prototype.assertChoicesHaveUniformArity=function(e){},A.prototype.assertChoicesHaveUniformArity=function(e){if(0===this.terms.length)return;const t=this.terms[0].getArity();for(let n=0;n{t.assertIteratedExprsAreNotNullable(e)}))};class ge{constructor(e){this.matchLength=e}get ctorName(){throw new Error("subclass responsibility")}numChildren(){return this.children?this.children.length:0}childAt(e){if(this.children)return this.children[e]}indexOfChild(e){return this.children.indexOf(e)}hasChildren(){return this.numChildren()>0}hasNoChildren(){return!this.hasChildren()}onlyChild(){if(1!==this.numChildren())throw new Error("cannot get only child of a node of type "+this.ctorName+" (it has "+this.numChildren()+" children)");return this.firstChild()}firstChild(){if(this.hasNoChildren())throw new Error("cannot get first child of a "+this.ctorName+" node, which has no children");return this.childAt(0)}lastChild(){if(this.hasNoChildren())throw new Error("cannot get last child of a "+this.ctorName+" node, which has no children");return this.childAt(this.numChildren()-1)}childBefore(e){const t=this.indexOfChild(e);if(t<0)throw new Error("Node.childBefore() called w/ an argument that is not a child");if(0===t)throw new Error("cannot get child before first child");return this.childAt(t-1)}childAfter(e){const t=this.indexOfChild(e);if(t<0)throw new Error("Node.childAfter() called w/ an argument that is not a child");if(t===this.numChildren()-1)throw new Error("cannot get child after last child");return this.childAt(t+1)}isTerminal(){return!1}isNonterminal(){return!1}isIteration(){return!1}isOptional(){return!1}}class ye extends ge{get ctorName(){return"_terminal"}isTerminal(){return!0}get primitiveValue(){throw new Error("The `primitiveValue` property was removed in Ohm v17.")}}class ve extends ge{constructor(e,t,n,r){super(r),this.ruleName=e,this.children=t,this.childOffsets=n}get ctorName(){return this.ruleName}isNonterminal(){return!0}isLexical(){return h(this.ctorName)}isSyntactic(){return d(this.ctorName)}}class be extends ge{constructor(e,t,n,r){super(n),this.children=e,this.childOffsets=t,this.optional=r}get ctorName(){return"_iter"}isIteration(){return!0}isOptional(){return this.optional}}function we(e,t){const n={};if(e.source&&t){const r=e.source.relativeTo(t);n.sourceInterval=[r.startIdx,r.endIdx]}return n}function Se(e){return/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(e)}function xe(e){const t=Object.create(null);e.forEach((e=>{t[e]=(t[e]||0)+1})),Object.keys(t).forEach((n=>{if(t[n]<=1)return;let r=1;e.forEach(((t,i)=>{t===n&&(e[i]=t+"_"+r++)}))}))}w.prototype.eval=s("eval"),S.eval=function(e){const{inputStream:t}=e,n=t.pos,r=t.nextCodePoint();return void 0!==r?(e.pushBinding(new ye(String.fromCodePoint(r).length),n),!0):(e.processFailure(n,this),!1)},x.eval=function(e){const{inputStream:t}=e,n=t.pos;return t.atEnd()?(e.pushBinding(new ye(0),n),!0):(e.processFailure(n,this),!1)},k.prototype.eval=function(e){const{inputStream:t}=e,n=t.pos;return t.matchString(this.obj)?(e.pushBinding(new ye(this.obj.length),n),!0):(e.processFailure(n,this),!1)},_.prototype.eval=function(e){const{inputStream:t}=e,n=t.pos,r=this.matchCodePoint?t.nextCodePoint():t.nextCharCode();return void 0!==r&&this.from.codePointAt(0)<=r&&r<=this.to.codePointAt(0)?(e.pushBinding(new ye(String.fromCodePoint(r).length),n),!0):(e.processFailure(n,this),!1)},I.prototype.eval=function(e){return e.eval(e.currentApplication().args[this.index])},F.prototype.eval=function(e){e.enterLexifiedContext();const t=e.eval(this.expr);return e.exitLexifiedContext(),t},A.prototype.eval=function(e){for(let t=0;t0){const e=i[r-1],t=s[r-1],n=t[t.length-1]+e[e.length-1].matchLength;u=s[0][0],c=n-u}const p=this instanceof N;for(a=0;an.outputRecipe(e,t))))},C.prototype.outputRecipe=function(e,t){return this.terms[0].outputRecipe(e,t)},E.prototype.outputRecipe=function(e,t){const n=this.terms.slice(0,this.expansionPos),r=this.terms.slice(this.expansionPos+1);return["splice",we(this,t),n.map((n=>n.outputRecipe(e,t))),r.map((n=>n.outputRecipe(e,t)))]},O.prototype.outputRecipe=function(e,t){return["seq",we(this,t)].concat(this.factors.map((n=>n.outputRecipe(e,t))))},L.prototype.outputRecipe=R.prototype.outputRecipe=N.prototype.outputRecipe=T.prototype.outputRecipe=M.prototype.outputRecipe=F.prototype.outputRecipe=function(e,t){return[this.constructor.name.toLowerCase(),we(this,t),this.expr.outputRecipe(e,t)]},j.prototype.outputRecipe=function(e,t){return["app",we(this,t),this.ruleName,this.args.map((n=>n.outputRecipe(e,t)))]},D.prototype.outputRecipe=function(e,t){return["unicodeChar",we(this,t),this.category]},w.prototype.introduceParams=s("introduceParams"),S.introduceParams=x.introduceParams=k.prototype.introduceParams=_.prototype.introduceParams=I.prototype.introduceParams=D.prototype.introduceParams=function(e){return this},A.prototype.introduceParams=function(e){return this.terms.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},O.prototype.introduceParams=function(e){return this.factors.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},P.prototype.introduceParams=T.prototype.introduceParams=M.prototype.introduceParams=F.prototype.introduceParams=function(e){return this.expr=this.expr.introduceParams(e),this},j.prototype.introduceParams=function(e){const t=e.indexOf(this.ruleName);if(t>=0){if(this.args.length>0)throw new Error("Parameterized rules cannot be passed as arguments to another rule.");return new I(t).withSource(this.source)}return this.args.forEach(((t,n,r)=>{r[n]=t.introduceParams(e)})),this},w.prototype.isNullable=function(e){return this._isNullable(e,Object.create(null))},w.prototype._isNullable=s("_isNullable"),S._isNullable=_.prototype._isNullable=I.prototype._isNullable=R.prototype._isNullable=D.prototype._isNullable=function(e,t){return!1},x._isNullable=function(e,t){return!0},k.prototype._isNullable=function(e,t){return"string"===typeof this.obj&&""===this.obj},A.prototype._isNullable=function(e,t){return 0===this.terms.length||this.terms.some((n=>n._isNullable(e,t)))},O.prototype._isNullable=function(e,t){return this.factors.every((n=>n._isNullable(e,t)))},L.prototype._isNullable=N.prototype._isNullable=T.prototype._isNullable=M.prototype._isNullable=function(e,t){return!0},F.prototype._isNullable=function(e,t){return this.expr._isNullable(e,t)},j.prototype._isNullable=function(e,t){const n=this.toMemoKey();if(!Object.prototype.hasOwnProperty.call(t,n)){const{body:r}=e.rules[this.ruleName],i=r.substituteParams(this.args);t[n]=!1,t[n]=i._isNullable(e,t)}return t[n]},w.prototype.substituteParams=s("substituteParams"),S.substituteParams=x.substituteParams=k.prototype.substituteParams=_.prototype.substituteParams=D.prototype.substituteParams=function(e){return this},I.prototype.substituteParams=function(e){return e[this.index]},A.prototype.substituteParams=function(e){return new A(this.terms.map((t=>t.substituteParams(e))))},O.prototype.substituteParams=function(e){return new O(this.factors.map((t=>t.substituteParams(e))))},P.prototype.substituteParams=T.prototype.substituteParams=M.prototype.substituteParams=F.prototype.substituteParams=function(e){return new this.constructor(this.expr.substituteParams(e))},j.prototype.substituteParams=function(e){if(0===this.args.length)return this;{const t=this.args.map((t=>t.substituteParams(e)));return new j(this.ruleName,t)}},w.prototype.toArgumentNameList=s("toArgumentNameList"),S.toArgumentNameList=function(e,t){return["any"]},x.toArgumentNameList=function(e,t){return["end"]},k.prototype.toArgumentNameList=function(e,t){return"string"===typeof this.obj&&/^[_a-zA-Z0-9]+$/.test(this.obj)?["_"+this.obj]:["$"+e]},_.prototype.toArgumentNameList=function(e,t){let n=this.from+"_to_"+this.to;return Se(n)||(n="_"+n),Se(n)||(n="$"+e),[n]},A.prototype.toArgumentNameList=function(e,t){const n=this.terms.map((t=>t.toArgumentNameList(e,!0))),r=[],i=n[0].length;for(let s=0;s{const r=t.toArgumentNameList(e,!0);n=n.concat(r),e+=r.length})),t||xe(n),n},P.prototype.toArgumentNameList=function(e,t){const n=this.expr.toArgumentNameList(e,t).map((e=>"s"===e[e.length-1]?e+"es":e+"s"));return t||xe(n),n},N.prototype.toArgumentNameList=function(e,t){return this.expr.toArgumentNameList(e,t).map((e=>"opt"+e[0].toUpperCase()+e.slice(1)))},T.prototype.toArgumentNameList=function(e,t){return[]},M.prototype.toArgumentNameList=F.prototype.toArgumentNameList=function(e,t){return this.expr.toArgumentNameList(e,t)},j.prototype.toArgumentNameList=function(e,t){return[this.ruleName]},D.prototype.toArgumentNameList=function(e,t){return["$"+e]},I.prototype.toArgumentNameList=function(e,t){return["param"+this.index]},w.prototype.toDisplayString=s("toDisplayString"),A.prototype.toDisplayString=O.prototype.toDisplayString=function(){return this.source?this.source.trimmed().contents:"["+this.constructor.name+"]"},S.toDisplayString=x.toDisplayString=P.prototype.toDisplayString=T.prototype.toDisplayString=M.prototype.toDisplayString=F.prototype.toDisplayString=k.prototype.toDisplayString=_.prototype.toDisplayString=I.prototype.toDisplayString=function(){return this.toString()},j.prototype.toDisplayString=function(){if(this.args.length>0){const e=this.args.map((e=>e.toDisplayString()));return this.ruleName+"<"+e.join(",")+">"}return this.ruleName},D.prototype.toDisplayString=function(){return"Unicode ["+this.category+"] character"};class ke{constructor(e,t,n){if(!function(e){return"description"===e||"string"===e||"code"===e}(n))throw new Error("invalid Failure type: "+n);this.pexpr=e,this.text=t,this.type=n,this.fluffy=!1}getPExpr(){return this.pexpr}getText(){return this.text}getType(){return this.type}isDescription(){return"description"===this.type}isStringTerminal(){return"string"===this.type}isCode(){return"code"===this.type}isFluffy(){return this.fluffy}makeFluffy(){this.fluffy=!0}clearFluffy(){this.fluffy=!1}subsumes(e){return this.getText()===e.getText()&&this.type===e.type&&(!this.isFluffy()||this.isFluffy()&&e.isFluffy())}toString(){return"string"===this.type?JSON.stringify(this.getText()):this.getText()}clone(){const e=new ke(this.pexpr,this.text,this.type);return this.isFluffy()&&e.makeFluffy(),e}toKey(){return this.toString()+"#"+this.type}}w.prototype.toFailure=s("toFailure"),S.toFailure=function(e){return new ke(this,"any object","description")},x.toFailure=function(e){return new ke(this,"end of input","description")},k.prototype.toFailure=function(e){return new ke(this,this.obj,"string")},_.prototype.toFailure=function(e){return new ke(this,JSON.stringify(this.from)+".."+JSON.stringify(this.to),"code")},T.prototype.toFailure=function(e){const t=this.expr===S?"nothing":"not "+this.expr.toFailure(e);return new ke(this,t,"description")},M.prototype.toFailure=function(e){return this.expr.toFailure(e)},j.prototype.toFailure=function(e){let{description:t}=e.rules[this.ruleName];if(!t){t=(/^[aeiouAEIOU]/.test(this.ruleName)?"an":"a")+" "+this.ruleName}return new ke(this,t,"description")},D.prototype.toFailure=function(e){return new ke(this,"a Unicode ["+this.category+"] character","description")},A.prototype.toFailure=function(e){const t="("+this.terms.map((t=>t.toFailure(e))).join(" or ")+")";return new ke(this,t,"description")},O.prototype.toFailure=function(e){const t="("+this.factors.map((t=>t.toFailure(e))).join(" ")+")";return new ke(this,t,"description")},P.prototype.toFailure=function(e){const t="("+this.expr.toFailure(e)+this.operator+")";return new ke(this,t,"description")},w.prototype.toString=s("toString"),S.toString=function(){return"any"},x.toString=function(){return"end"},k.prototype.toString=function(){return JSON.stringify(this.obj)},_.prototype.toString=function(){return JSON.stringify(this.from)+".."+JSON.stringify(this.to)},I.prototype.toString=function(){return"$"+this.index},F.prototype.toString=function(){return"#("+this.expr.toString()+")"},A.prototype.toString=function(){return 1===this.terms.length?this.terms[0].toString():"("+this.terms.map((e=>e.toString())).join(" | ")+")"},O.prototype.toString=function(){return 1===this.factors.length?this.factors[0].toString():"("+this.factors.map((e=>e.toString())).join(" ")+")"},P.prototype.toString=function(){return this.expr+this.operator},T.prototype.toString=function(){return"~"+this.expr},M.prototype.toString=function(){return"&"+this.expr},j.prototype.toString=function(){if(this.args.length>0){const e=this.args.map((e=>e.toString()));return this.ruleName+"<"+e.join(",")+">"}return this.ruleName},D.prototype.toString=function(){return"\\p{"+this.category+"}"};class _e extends w{constructor(e){super(),this.obj=e}_getString(e){const t=e.currentApplication().args[this.obj.index];return a(t instanceof k,"expected a Terminal expression"),t.obj}allowsSkippingPrecedingSpace(){return!0}eval(e){const{inputStream:t}=e,n=t.pos,r=this._getString(e);return t.matchString(r,!0)?(e.pushBinding(new ye(r.length),n),!0):(e.processFailure(n,this),!1)}getArity(){return 1}substituteParams(e){return new _e(this.obj.substituteParams(e))}toDisplayString(){return this.obj.toDisplayString()+" (case-insensitive)"}toFailure(e){return new ke(this,this.obj.toFailure(e)+" (case-insensitive)","description")}_isNullable(e,t){return this.obj._isNullable(e,t)}}J((e=>{me=e.rules.applySyntactic.body}));const Ie=new j("spaces");class Ae{constructor(e,t,n){this.matcher=e,this.startExpr=t,this.grammar=e.grammar,this.input=e.getInput(),this.inputStream=new re(this.input),this.memoTable=e._memoTable,this.userData=void 0,this.doNotMemoize=!1,this._bindings=[],this._bindingOffsets=[],this._applicationStack=[],this._posStack=[0],this.inLexifiedContextStack=[!1],this.rightmostFailurePosition=-1,this._rightmostFailurePositionStack=[],this._recordedFailuresStack=[],void 0!==n&&(this.positionToRecordFailures=n,this.recordedFailures=Object.create(null))}posToOffset(e){return e-this._posStack[this._posStack.length-1]}enterApplication(e,t){this._posStack.push(this.inputStream.pos),this._applicationStack.push(t),this.inLexifiedContextStack.push(!1),e.enter(t),this._rightmostFailurePositionStack.push(this.rightmostFailurePosition),this.rightmostFailurePosition=-1}exitApplication(e,t){const n=this._posStack.pop();this._applicationStack.pop(),this.inLexifiedContextStack.pop(),e.exit(),this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,this._rightmostFailurePositionStack.pop()),t&&this.pushBinding(t,n)}enterLexifiedContext(){this.inLexifiedContextStack.push(!0)}exitLexifiedContext(){this.inLexifiedContextStack.pop()}currentApplication(){return this._applicationStack[this._applicationStack.length-1]}inSyntacticContext(){const e=this.currentApplication();return e?e.isSyntactic()&&!this.inLexifiedContext():this.startExpr.factors[0].isSyntactic()}inLexifiedContext(){return this.inLexifiedContextStack[this.inLexifiedContextStack.length-1]}skipSpaces(){return this.pushFailuresInfo(),this.eval(Ie),this.popBinding(),this.popFailuresInfo(),this.inputStream.pos}skipSpacesIfInSyntacticContext(){return this.inSyntacticContext()?this.skipSpaces():this.inputStream.pos}maybeSkipSpacesBefore(e){return e.allowsSkippingPrecedingSpace()&&e!==Ie?this.skipSpacesIfInSyntacticContext():this.inputStream.pos}pushBinding(e,t){this._bindings.push(e),this._bindingOffsets.push(this.posToOffset(t))}popBinding(){this._bindings.pop(),this._bindingOffsets.pop()}numBindings(){return this._bindings.length}truncateBindings(e){for(;this._bindings.length>e;)this.popBinding()}getCurrentPosInfo(){return this.getPosInfo(this.inputStream.pos)}getPosInfo(e){let t=this.memoTable[e];return t||(t=this.memoTable[e]=new se),t}processFailure(e,t){if(this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,e),this.recordedFailures&&e===this.positionToRecordFailures){const e=this.currentApplication();e&&(t=t.substituteParams(e.args)),this.recordFailure(t.toFailure(this.grammar),!1)}}recordFailure(e,t){const n=e.toKey();this.recordedFailures[n]?this.recordedFailures[n].isFluffy()&&!e.isFluffy()&&this.recordedFailures[n].clearFluffy():this.recordedFailures[n]=t?e.clone():e}recordFailures(e,t){Object.keys(e).forEach((n=>{this.recordFailure(e[n],t)}))}cloneRecordedFailures(){if(!this.recordedFailures)return;const e=Object.create(null);return Object.keys(this.recordedFailures).forEach((t=>{e[t]=this.recordedFailures[t].clone()})),e}getRightmostFailurePosition(){return this.rightmostFailurePosition}_getRightmostFailureOffset(){return this.rightmostFailurePosition>=0?this.posToOffset(this.rightmostFailurePosition):-1}getMemoizedTraceEntry(e,t){const n=this.memoTable[e];if(n&&t instanceof j){const e=n.memo[t.toMemoKey()];if(e&&e.traceEntry){const n=e.traceEntry.cloneWithExpr(t);return n.isMemoized=!0,n}}return null}getTraceEntry(e,t,n,r){if(t instanceof j){const e=this.currentApplication(),n=e?e.args:[];t=t.substituteParams(n)}return this.getMemoizedTraceEntry(e,t)||new de(this.input,e,this.inputStream.pos,t,n,r,this.trace)}isTracing(){return!!this.trace}hasNecessaryInfo(e){return!(this.trace&&!e.traceEntry)&&(!this.recordedFailures||this.inputStream.pos+e.rightmostFailureOffset!==this.positionToRecordFailures||!!e.failuresAtRightmostPosition)}useMemoizedResult(e,t){this.trace&&this.trace.push(t.traceEntry);const n=this.inputStream.pos+t.rightmostFailureOffset;return this.rightmostFailurePosition=Math.max(this.rightmostFailurePosition,n),this.recordedFailures&&this.positionToRecordFailures===n&&t.failuresAtRightmostPosition&&this.recordFailures(t.failuresAtRightmostPosition,!0),this.inputStream.examinedLength=Math.max(this.inputStream.examinedLength,t.examinedLength+e),!!t.value&&(this.inputStream.pos+=t.matchLength,this.pushBinding(t.value,e),!0)}eval(e){const{inputStream:t}=this,n=this._bindings.length,r=this.userData;let i;this.recordedFailures&&(i=this.recordedFailures,this.recordedFailures=Object.create(null));const s=t.pos,a=this.maybeSkipSpacesBefore(e);let o;this.trace&&(o=this.trace,this.trace=[]);const l=e.eval(this);if(this.trace){const t=this._bindings.slice(n),r=this.getTraceEntry(a,e,l,t);r.isImplicitSpaces=e===Ie,r.isRootNode=e===this.startExpr,o.push(r),this.trace=o}return l?this.recordedFailures&&t.pos===this.positionToRecordFailures&&Object.keys(this.recordedFailures).forEach((e=>{this.recordedFailures[e].makeFluffy()})):(t.pos=s,this.truncateBindings(n),this.userData=r),this.recordedFailures&&this.recordFailures(i,!1),e===me&&this.skipSpaces(),l}getMatchResult(){let e;this.grammar._setUpMatchState(this),this.eval(this.startExpr),this.recordedFailures&&(e=Object.keys(this.recordedFailures).map((e=>this.recordedFailures[e])));const t=this._bindings[0];return t&&(t.grammar=this.grammar),new ie(this.matcher,this.input,this.startExpr,t,this._bindingOffsets[0],this.rightmostFailurePosition,e)}getTrace(){this.trace=[];const e=this.getMatchResult(),t=this.trace[this.trace.length-1];return t.result=e,t}pushFailuresInfo(){this._rightmostFailurePositionStack.push(this.rightmostFailurePosition),this._recordedFailuresStack.push(this.recordedFailures)}popFailuresInfo(){this.rightmostFailurePosition=this._rightmostFailurePositionStack.pop(),this.recordedFailures=this._recordedFailuresStack.pop()}}class Ce{constructor(e){this.grammar=e,this._memoTable=[],this._input="",this._isMemoTableStale=!1}_resetMemoTable(){this._memoTable=[],this._isMemoTableStale=!1}getInput(){return this._input}setInput(e){return this._input!==e&&this.replaceInputRange(0,this._input.length,e),this}replaceInputRange(e,t,n){const r=this._input,i=this._memoTable;if(e<0||e>r.length||t<0||t>r.length||e>t)throw new Error("Invalid indices: "+e+" and "+t);this._input=r.slice(0,e)+n+r.slice(t),this._input!==r&&i.length>0&&(this._isMemoTableStale=!0);const s=i.slice(t);i.length=e;for(let a=0;aObject.prototype.hasOwnProperty.call(e,t);class Pe{constructor(e,t,n){this._node=e,this.source=t,this._baseInterval=n,e.isNonterminal()&&a(t===n),this._childWrappers=[]}_forgetMemoizedResultFor(e){delete this._node[this._semantics.attributeKeys[e]],this.children.forEach((t=>{t._forgetMemoizedResultFor(e)}))}child(e){if(!(0<=e&&ee._node)),r=new be(n,[],-1,!1),i=this._semantics.wrap(r,null,null);return i._childWrappers=t,i}get children(){return this._children()}get ctorName(){return this._node.ctorName}get numChildren(){return this._node.numChildren()}get sourceString(){return this.source.contents}}class Le{constructor(e,t){const n=this;if(this.grammar=e,this.checkedActionDicts=!1,this.Wrapper=class extends(t?t.Wrapper:Pe){constructor(e,t,r){super(e,t,r),n.checkActionDictsIfHaventAlready(),this._semantics=n}toString(){return"[semantics wrapper for "+n.grammar.name+"]"}},this.super=t,t){if(!e.equals(this.super.grammar)&&!e._inheritsFrom(this.super.grammar))throw new Error("Cannot extend a semantics for grammar '"+this.super.grammar.name+"' for use with grammar '"+e.name+"' (not a sub-grammar)");this.operations=Object.create(this.super.operations),this.attributes=Object.create(this.super.attributes),this.attributeKeys=Object.create(null);for(const e in this.attributes)Object.defineProperty(this.attributeKeys,e,{value:te(e)})}else this.operations=Object.create(null),this.attributes=Object.create(null),this.attributeKeys=Object.create(null)}toString(){return"[semantics for "+this.grammar.name+"]"}checkActionDictsIfHaventAlready(){this.checkedActionDicts||(this.checkActionDicts(),this.checkedActionDicts=!0)}checkActionDicts(){let e;for(e in this.operations)this.operations[e].checkActionDict(this.grammar);for(e in this.attributes)this.attributes[e].checkActionDict(this.grammar)}toRecipe(e){function t(e){return e.super!==Le.BuiltInSemantics._getSemantics()}let n="(function(g) {\n";if(t(this)){n+=" var semantics = "+this.super.toRecipe(!0)+"(g";const e=this.super.grammar;let t=this.grammar;for(;t!==e;)n+=".superGrammar",t=t.superGrammar;n+=");\n",n+=" return g.extendSemantics(semantics)"}else n+=" return g.createSemantics()";return["Operation","Attribute"].forEach((e=>{const r=this[e.toLowerCase()+"s"];Object.keys(r).forEach((i=>{const{actionDict:s,formals:a,builtInDefault:o}=r[i];let l,u=i;a.length>0&&(u+="("+a.join(", ")+")"),l=t(this)&&this.super[e.toLowerCase()+"s"][i]?"extend"+e:"add"+e,n+="\n ."+l+"("+JSON.stringify(u)+", {";const c=[];Object.keys(s).forEach((e=>{if(s[e]!==o){let t=s[e].toString().trim();t=t.replace(/^.*\(/,"function("),c.push("\n "+JSON.stringify(e)+": "+t)}})),n+=c.join(",")+"\n })"}))})),n+=";\n })",e||(n="(function() {\n var grammar = this.fromRecipe("+this.grammar.toRecipe()+");\n var semantics = "+n+"(grammar);\n return semantics;\n});\n"),n}addOperationOrAttribute(e,t,n){const r=e+"s",i=Re(t,e),{name:s}=i,{formals:a}=i;this.assertNewName(s,e);const o=function(e,t,n){return function(...r){const i=(this._semantics.operations[t]||this._semantics.attributes[t]).formals.map((e=>this.args[e]));if(this.isIteration()||1!==r.length)throw function(e,t,n,r){let i=r.slice(0,-1).map((e=>{const t=" "+e[0].name+" > "+e[1];return 3===e.length?t+" for '"+e[2]+"'":t})).join("\n");i+="\n "+t+" > "+e;let s="";"_iter"===e&&(s=["\nNOTE: as of Ohm v16, there is no default action for iteration nodes \u2014 see "," https://ohmjs.org/d/dsa for details."].join("\n"));const a=$([`Missing semantic action for '${e}' in ${n} '${t}'.${s}`,"Action stack (most recent call last):",i].join("\n"));return a.name="missingSemanticAction",a}(this.ctorName,t,e,Ee);return n.apply(r[0],i)}}(e,s,c),l={_default:o};Object.keys(n).forEach((e=>{l[e]=n[e]}));const u="operation"===e?new Ne(s,a,l,o):new Te(s,l,o);function c(...t){const n=this._semantics[r][s];if(arguments.length!==n.formals.length)throw new Error("Invalid number of arguments passed to "+s+" "+e+" (expected "+n.formals.length+", got "+arguments.length+")");const i=Object.create(null);for(const[e,r]of Object.entries(t)){i[n.formals[e]]=r}const a=this.args;this.args=i;const o=n.execute(this._semantics,this);return this.args=a,o}u.checkActionDict(this.grammar),this[r][s]=u,"operation"===e?(this.Wrapper.prototype[s]=c,this.Wrapper.prototype[s].toString=function(){return"["+s+" operation]"}):(Object.defineProperty(this.Wrapper.prototype,s,{get:c,configurable:!0}),Object.defineProperty(this.attributeKeys,s,{value:te(s)}))}extendOperationOrAttribute(e,t,n){const r=e+"s";if(Re(t,"attribute"),!this.super||!(t in this.super[r]))throw new Error("Cannot extend "+e+" '"+t+"': did not inherit an "+e+" with that name");if(Oe(this[r],t))throw new Error("Cannot extend "+e+" '"+t+"' again");const i=this[r][t].formals,s=this[r][t].actionDict,a=Object.create(s);Object.keys(n).forEach((e=>{a[e]=n[e]})),this[r][t]="operation"===e?new Ne(t,i,a):new Te(t,a),this[r][t].checkActionDict(this.grammar)}assertNewName(e,t){if(Oe(Pe.prototype,e))throw new Error("Cannot add "+t+" '"+e+"': that's a reserved name");if(e in this.operations)throw new Error("Cannot add "+t+" '"+e+"': an operation with that name already exists");if(e in this.attributes)throw new Error("Cannot add "+t+" '"+e+"': an attribute with that name already exists")}wrap(e,t,n){const r=n||t;return e instanceof this.Wrapper?e:new this.Wrapper(e,t,r)}}function Re(e,t){if(!Le.prototypeGrammar)return a(-1===e.indexOf("(")),{name:e,formals:[]};const n=Le.prototypeGrammar.match(e,"operation"===t?"OperationSignature":"AttributeSignature");if(n.failed())throw new Error(n.message);return Le.prototypeGrammarSemantics(n).parse()}Le.createSemantics=function(e,t){const n=new Le(e,void 0!==t?t:Le.BuiltInSemantics._getSemantics()),r=function(t){if(!(t instanceof ie))throw new TypeError("Semantics expected a MatchResult, but got "+v(t));if(t.failed())throw new TypeError("cannot apply Semantics to "+t.toString());const r=t._cst;if(r.grammar!==e)throw new Error("Cannot use a MatchResult from grammar '"+r.grammar.name+"' with a semantics for '"+e.name+"'");const i=new re(t.input);return n.wrap(r,i.interval(t._cstOffset,t.input.length))};return r.addOperation=function(e,t){return n.addOperationOrAttribute("operation",e,t),r},r.extendOperation=function(e,t){return n.extendOperationOrAttribute("operation",e,t),r},r.addAttribute=function(e,t){return n.addOperationOrAttribute("attribute",e,t),r},r.extendAttribute=function(e,t){return n.extendOperationOrAttribute("attribute",e,t),r},r._getActionDict=function(t){const r=n.operations[t]||n.attributes[t];if(!r)throw new Error('"'+t+'" is not a valid operation or attribute name in this semantics for "'+e.name+'"');return r.actionDict},r._remove=function(e){let t;return e in n.operations?(t=n.operations[e],delete n.operations[e]):e in n.attributes&&(t=n.attributes[e],delete n.attributes[e]),delete n.Wrapper.prototype[e],t},r.getOperationNames=function(){return Object.keys(n.operations)},r.getAttributeNames=function(){return Object.keys(n.attributes)},r.getGrammar=function(){return n.grammar},r.toRecipe=function(e){return n.toRecipe(e)},r.toString=n.toString.bind(n),r._getSemantics=function(){return n},r};class Ne{constructor(e,t,n,r){this.name=e,this.formals=t,this.actionDict=n,this.builtInDefault=r}checkActionDict(e){e._checkTopDownActionDict(this.typeName,this.name,this.actionDict)}execute(e,t){try{const{ctorName:e}=t._node;let n=this.actionDict[e];return n?(Ee.push([this,e]),n.apply(t,t._children())):t.isNonterminal()&&(n=this.actionDict._nonterminal,n)?(Ee.push([this,"_nonterminal",e]),n.apply(t,t._children())):(Ee.push([this,"default action",e]),this.actionDict._default.apply(t,t._children()))}finally{Ee.pop()}}}Ne.prototype.typeName="operation";class Te extends Ne{constructor(e,t,n){super(e,[],t,n)}execute(e,t){const n=t._node,r=e.attributeKeys[this.name];return Oe(n,r)||(n[r]=Ne.prototype.execute.call(this,e,t)),n[r]}}Te.prototype.typeName="attribute";const Me=["_iter","_terminal","_nonterminal","_default"];function Fe(e){return Object.keys(e.rules).sort().map((t=>e.rules[t]))}let je,De;class $e{constructor(e,t,n,r){if(this.name=e,this.superGrammar=t,this.rules=n,r){if(!(r in n))throw new Error("Invalid start rule: '"+r+"' is not a rule in grammar '"+e+"'");this.defaultStartRule=r}this._matchStateInitializer=void 0,this.supportsIncrementalParsing=!0}matcher(){return new Ce(this)}isBuiltIn(){return this===$e.ProtoBuiltInRules||this===$e.BuiltInRules}equals(e){if(this===e)return!0;if(null==e||this.name!==e.name||this.defaultStartRule!==e.defaultStartRule||this.superGrammar!==e.superGrammar&&!this.superGrammar.equals(e.superGrammar))return!1;const t=Fe(this),n=Fe(e);return t.length===n.length&&t.every(((e,t)=>e.description===n[t].description&&e.formals.join(",")===n[t].formals.join(",")&&e.body.toString()===n[t].body.toString()))}match(e,t){const n=this.matcher();return n.replaceInputRange(0,0,e),n.match(t)}trace(e,t){const n=this.matcher();return n.replaceInputRange(0,0,e),n.trace(t)}createSemantics(){return Le.createSemantics(this)}extendSemantics(e){return Le.createSemantics(this,e._getSemantics())}_checkTopDownActionDict(e,t,n){const r=[];for(const i in n){const e=n[i];if(!Me.includes(i)&&!(i in this.rules)){r.push(`'${i}' is not a valid semantic action for '${this.name}'`);continue}if("function"!==typeof e){r.push(`'${i}' must be a function in an action dictionary for '${this.name}'`);continue}const t=e.length,s=this._topDownActionArity(i);if(t!==s){let e;e="_iter"===i||"_nonterminal"===i?`it should use a rest parameter, e.g. \`${i}(...children) {}\`. NOTE: this is new in Ohm v16 \u2014 see https://ohmjs.org/d/ati for details.`:`expected ${s}, got ${t}`,r.push(`Semantic action '${i}' has the wrong arity: ${e}`)}}if(r.length>0){const n=r.map((e=>"- "+e)),i=new Error([`Found errors in the action dictionary of the '${t}' ${e}:`,...n].join("\n"));throw i.problems=r,i}}_topDownActionArity(e){return Me.includes(e)?0:this.rules[e].body.getArity()}_inheritsFrom(e){let t=this.superGrammar;for(;t;){if(t.equals(e,!0))return!0;t=t.superGrammar}return!1}toRecipe(e=void 0){const t={};this.source&&(t.source=this.source.contents);let n=null;this.defaultStartRule&&(n=this.defaultStartRule);const r={};Object.keys(this.rules).forEach((e=>{const t=this.rules[e],{body:n}=t,i=!this.superGrammar||!this.superGrammar.rules[e];let s;s=i?"define":n instanceof C?"extend":"override";const a={};if(t.source&&this.source){const e=t.source.relativeTo(this.source);a.sourceInterval=[e.startIdx,e.endIdx]}const o=i?t.description:null,l=n.outputRecipe(t.formals,this.source);r[e]=[s,a,o,t.formals,l]}));let i="null";e?i=e:this.superGrammar&&!this.superGrammar.isBuiltIn()&&(i=this.superGrammar.toRecipe());const s=[...["grammar",t,this.name].map(JSON.stringify),i,...[n,r].map(JSON.stringify)];return`[${s.join(",")}]`.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}toOperationActionDictionaryTemplate(){return this._toOperationOrAttributeActionDictionaryTemplate()}toAttributeActionDictionaryTemplate(){return this._toOperationOrAttributeActionDictionaryTemplate()}_toOperationOrAttributeActionDictionaryTemplate(){const e=new m;e.append("{");let t=!0;for(const n in this.rules){const{body:r}=this.rules[n];t?t=!1:e.append(","),e.append("\n"),e.append(" "),this.addSemanticActionTemplate(n,r,e)}return e.append("\n}"),e.contents()}addSemanticActionTemplate(e,t,n){n.append(e),n.append(": function(");const r=this._topDownActionArity(e);n.append(u("_",r).join(", ")),n.append(") {\n"),n.append(" }")}parseApplication(e){let t;if(-1===e.indexOf("<"))t=new j(e);else{const n=je.match(e,"Base_application");t=De(n,{})}if(!(t.ruleName in this.rules))throw V(t.ruleName,this.name);const{formals:n}=this.rules[t.ruleName];if(n.length!==t.args.length){const{source:e}=this.rules[t.ruleName];throw B(t.ruleName,n.length,t.args.length,e)}return t}_setUpMatchState(e){this._matchStateInitializer&&this._matchStateInitializer(e)}}$e.ProtoBuiltInRules=new $e("ProtoBuiltInRules",void 0,{any:{body:S,formals:[],description:"any character",primitive:!0},end:{body:x,formals:[],description:"end of input",primitive:!0},caseInsensitive:{body:new _e(new I(0)),formals:["str"],primitive:!0},lower:{body:new D("Ll"),formals:[],description:"a lowercase letter",primitive:!0},upper:{body:new D("Lu"),formals:[],description:"an uppercase letter",primitive:!0},unicodeLtmo:{body:new D("Ltmo"),formals:[],description:"a Unicode character in Lt, Lm, or Lo",primitive:!0},spaces:{body:new L(new j("space")),formals:[]},space:{body:new _("\0"," "),formals:[],description:"a space"}}),$e.initApplicationParser=function(e,t){je=e,De=t};class ze{constructor(e){this.name=e}sourceInterval(e,t){return this.source.subInterval(e,t-e)}ensureSuperGrammar(){return this.superGrammar||this.withSuperGrammar("BuiltInRules"===this.name?$e.ProtoBuiltInRules:$e.BuiltInRules),this.superGrammar}ensureSuperGrammarRuleForOverriding(e,t){const n=this.ensureSuperGrammar().rules[e];if(!n)throw r=e,i=this.superGrammar.name,$("Cannot override rule "+r+" because it is not declared in "+i,t);var r,i;return n}installOverriddenOrExtendedRule(e,t,n,r){const i=c(t);if(i.length>0)throw W(e,i,r);const s=this.ensureSuperGrammar().rules[e],a=s.formals,o=a?a.length:0;if(t.length!==o)throw B(e,o,t.length,r);return this.install(e,t,n,s.description,r)}install(e,t,n,r,i,s=!1){return this.rules[e]={body:n.introduceParams(t),formals:t,description:r,source:i,primitive:s},this}withSuperGrammar(e){if(this.superGrammar)throw new Error("the super grammar of a GrammarDecl cannot be set more than once");return this.superGrammar=e,this.rules=Object.create(e.rules),e.isBuiltIn()||(this.defaultStartRule=e.defaultStartRule),this}withDefaultStartRule(e){return this.defaultStartRule=e,this}withSource(e){return this.source=new re(e).interval(0,e.length),this}build(){const e=new $e(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule);e._matchStateInitializer=e.superGrammar._matchStateInitializer,e.supportsIncrementalParsing=e.superGrammar.supportsIncrementalParsing;const t=[];let n=!1;return Object.keys(e.rules).forEach((r=>{const{body:i}=e.rules[r];try{i.assertChoicesHaveUniformArity(r)}catch(s){t.push(s)}try{i.assertAllApplicationsAreValid(r,e)}catch(s){t.push(s),n=!0}})),n||Object.keys(e.rules).forEach((n=>{const{body:r}=e.rules[n];try{r.assertIteratedExprsAreNotNullable(e,[])}catch(i){t.push(i)}})),t.length>0&&K(t),this.source&&(e.source=this.source),e}define(e,t,n,r,i,s){if(this.ensureSuperGrammar(),this.superGrammar.rules[e])throw U(e,this.name,this.superGrammar.name,i);if(this.rules[e])throw U(e,this.name,this.name,i);const a=c(t);if(a.length>0)throw W(e,a,i);return this.install(e,t,n,r,i,s)}override(e,t,n,r,i){return this.ensureSuperGrammarRuleForOverriding(e,i),this.installOverriddenOrExtendedRule(e,t,n,i),this}extend(e,t,n,r,i){if(!this.ensureSuperGrammar().rules[e])throw s=e,a=this.superGrammar.name,$("Cannot extend rule "+s+" because it is not declared in "+a,i);var s,a;const o=new C(this.superGrammar,e,n);return o.source=n.source,this.installOverriddenOrExtendedRule(e,t,o,i),this}}class Ve{constructor(){this.currentDecl=null,this.currentRuleName=null}newGrammar(e){return new ze(e)}grammar(e,t,n,r,i){const s=new ze(t);return n&&s.withSuperGrammar(n instanceof $e?n:this.fromRecipe(n)),r&&s.withDefaultStartRule(r),e&&e.source&&s.withSource(e.source),this.currentDecl=s,Object.keys(i).forEach((e=>{this.currentRuleName=e;const t=i[e],n=t[0],r=t[1],a=t[2],o=t[3],l=this.fromRecipe(t[4]);let u;s.source&&r&&r.sourceInterval&&(u=s.source.subInterval(r.sourceInterval[0],r.sourceInterval[1]-r.sourceInterval[0])),s[n](e,o,l,a,u)})),this.currentRuleName=this.currentDecl=null,s.build()}terminal(e){return new k(e)}range(e,t){return new _(e,t)}param(e){return new I(e)}alt(...e){let t=[];for(let n of e)n instanceof w||(n=this.fromRecipe(n)),n instanceof A?t=t.concat(n.terms):t.push(n);return 1===t.length?t[0]:new A(t)}seq(...e){let t=[];for(let n of e)n instanceof w||(n=this.fromRecipe(n)),n instanceof O?t=t.concat(n.factors):t.push(n);return 1===t.length?t[0]:new O(t)}star(e){return e instanceof w||(e=this.fromRecipe(e)),new L(e)}plus(e){return e instanceof w||(e=this.fromRecipe(e)),new R(e)}opt(e){return e instanceof w||(e=this.fromRecipe(e)),new N(e)}not(e){return e instanceof w||(e=this.fromRecipe(e)),new T(e)}lookahead(e){return e instanceof w||(e=this.fromRecipe(e)),new M(e)}lex(e){return e instanceof w||(e=this.fromRecipe(e)),new F(e)}app(e,t){return t&&t.length>0&&(t=t.map((function(e){return e instanceof w?e:this.fromRecipe(e)}),this)),new j(e,t)}splice(e,t){return new E(this.currentDecl.superGrammar,this.currentRuleName,e.map((e=>this.fromRecipe(e))),t.map((e=>this.fromRecipe(e))))}fromRecipe(e){const t="grammar"===e[0]?e.slice(1):e.slice(2),n=this[e[0]](...t),r=e[1];return r&&r.sourceInterval&&this.currentDecl&&n.withSource(this.currentDecl.sourceInterval(...r.sourceInterval)),n}}function Ue(e){return"function"===typeof e?e.call(new Ve):("string"===typeof e&&(e=JSON.parse(e)),(new Ve).fromRecipe(e))}const Be=Ue(["grammar",{source:'BuiltInRules {\n\n alnum (an alpha-numeric character)\n = letter\n | digit\n\n letter (a letter)\n = lower\n | upper\n | unicodeLtmo\n\n digit (a digit)\n = "0".."9"\n\n hexDigit (a hexadecimal digit)\n = digit\n | "a".."f"\n | "A".."F"\n\n ListOf\n = NonemptyListOf\n | EmptyListOf\n\n NonemptyListOf\n = elem (sep elem)*\n\n EmptyListOf\n = /* nothing */\n\n listOf\n = nonemptyListOf\n | emptyListOf\n\n nonemptyListOf\n = elem (sep elem)*\n\n emptyListOf\n = /* nothing */\n\n // Allows a syntactic rule application within a lexical context.\n applySyntactic = app\n}'},"BuiltInRules",null,null,{alnum:["define",{sourceInterval:[18,78]},"an alpha-numeric character",[],["alt",{sourceInterval:[60,78]},["app",{sourceInterval:[60,66]},"letter",[]],["app",{sourceInterval:[73,78]},"digit",[]]]],letter:["define",{sourceInterval:[82,142]},"a letter",[],["alt",{sourceInterval:[107,142]},["app",{sourceInterval:[107,112]},"lower",[]],["app",{sourceInterval:[119,124]},"upper",[]],["app",{sourceInterval:[131,142]},"unicodeLtmo",[]]]],digit:["define",{sourceInterval:[146,177]},"a digit",[],["range",{sourceInterval:[169,177]},"0","9"]],hexDigit:["define",{sourceInterval:[181,254]},"a hexadecimal digit",[],["alt",{sourceInterval:[219,254]},["app",{sourceInterval:[219,224]},"digit",[]],["range",{sourceInterval:[231,239]},"a","f"],["range",{sourceInterval:[246,254]},"A","F"]]],ListOf:["define",{sourceInterval:[258,336]},null,["elem","sep"],["alt",{sourceInterval:[282,336]},["app",{sourceInterval:[282,307]},"NonemptyListOf",[["param",{sourceInterval:[297,301]},0],["param",{sourceInterval:[303,306]},1]]],["app",{sourceInterval:[314,336]},"EmptyListOf",[["param",{sourceInterval:[326,330]},0],["param",{sourceInterval:[332,335]},1]]]]],NonemptyListOf:["define",{sourceInterval:[340,388]},null,["elem","sep"],["seq",{sourceInterval:[372,388]},["param",{sourceInterval:[372,376]},0],["star",{sourceInterval:[377,388]},["seq",{sourceInterval:[378,386]},["param",{sourceInterval:[378,381]},1],["param",{sourceInterval:[382,386]},0]]]]],EmptyListOf:["define",{sourceInterval:[392,434]},null,["elem","sep"],["seq",{sourceInterval:[438,438]}]],listOf:["define",{sourceInterval:[438,516]},null,["elem","sep"],["alt",{sourceInterval:[462,516]},["app",{sourceInterval:[462,487]},"nonemptyListOf",[["param",{sourceInterval:[477,481]},0],["param",{sourceInterval:[483,486]},1]]],["app",{sourceInterval:[494,516]},"emptyListOf",[["param",{sourceInterval:[506,510]},0],["param",{sourceInterval:[512,515]},1]]]]],nonemptyListOf:["define",{sourceInterval:[520,568]},null,["elem","sep"],["seq",{sourceInterval:[552,568]},["param",{sourceInterval:[552,556]},0],["star",{sourceInterval:[557,568]},["seq",{sourceInterval:[558,566]},["param",{sourceInterval:[558,561]},1],["param",{sourceInterval:[562,566]},0]]]]],emptyListOf:["define",{sourceInterval:[572,682]},null,["elem","sep"],["seq",{sourceInterval:[685,685]}]],applySyntactic:["define",{sourceInterval:[685,710]},null,["app"],["param",{sourceInterval:[707,710]},0]]}]);$e.BuiltInRules=Be,function(e){X.forEach((t=>{t(e)})),X=null}($e.BuiltInRules);const We=Ue(["grammar",{source:'Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? "{" Rule* "}"\n\n SuperGrammar\n = "<:" ident\n\n Rule\n = ident Formals? ruleDescr? "=" RuleBody -- define\n | ident Formals? ":=" OverrideRuleBody -- override\n | ident Formals? "+=" RuleBody -- extend\n\n RuleBody\n = "|"? NonemptyListOf\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n OverrideRuleBody\n = "|"? NonemptyListOf\n\n OverrideTopLevelTerm\n = "..." -- superSplice\n | TopLevelTerm\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = NonemptyListOf\n\n Seq\n = Iter*\n\n Iter\n = Pred "*" -- star\n | Pred "+" -- plus\n | Pred "?" -- opt\n | Pred\n\n Pred\n = "~" Lex -- not\n | "&" Lex -- lookahead\n | Lex\n\n Lex\n = "#" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? "=" | ":=" | "+=") -- application\n | oneCharTerminal ".." oneCharTerminal -- range\n | terminal -- terminal\n | "(" Alt ")" -- paren\n\n ruleDescr (a rule description)\n = "(" ruleDescrText ")"\n\n ruleDescrText\n = (~")" any)*\n\n caseName\n = "--" (~"\\n" space)* name (~"\\n" space)* ("\\n" | &"}")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = "\\"" terminalChar* "\\""\n\n oneCharTerminal\n = "\\"" terminalChar "\\""\n\n terminalChar\n = escapeChar\n | ~"\\\\" ~"\\"" ~"\\n" "\\u{0}".."\\u{10FFFF}"\n\n escapeChar (an escape sequence)\n = "\\\\\\\\" -- backslash\n | "\\\\\\"" -- doubleQuote\n | "\\\\\\\'" -- singleQuote\n | "\\\\b" -- backspace\n | "\\\\n" -- lineFeed\n | "\\\\r" -- carriageReturn\n | "\\\\t" -- tab\n | "\\\\u{" hexDigit hexDigit? hexDigit?\n hexDigit? hexDigit? hexDigit? "}" -- unicodeCodePoint\n | "\\\\u" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | "\\\\x" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = "//" (~"\\n" any)* &("\\n" | end) -- singleLine\n | "/*" (~"*/" any)* "*/" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = "<:" | "=" | ":=" | "+=" | "*" | "+" | "?" | "~" | "&"\n\n punctuation = "<" | ">" | "," | "--"\n}'},"Ohm",null,"Grammars",{Grammars:["define",{sourceInterval:[9,32]},null,[],["star",{sourceInterval:[24,32]},["app",{sourceInterval:[24,31]},"Grammar",[]]]],Grammar:["define",{sourceInterval:[36,83]},null,[],["seq",{sourceInterval:[50,83]},["app",{sourceInterval:[50,55]},"ident",[]],["opt",{sourceInterval:[56,69]},["app",{sourceInterval:[56,68]},"SuperGrammar",[]]],["terminal",{sourceInterval:[70,73]},"{"],["star",{sourceInterval:[74,79]},["app",{sourceInterval:[74,78]},"Rule",[]]],["terminal",{sourceInterval:[80,83]},"}"]]],SuperGrammar:["define",{sourceInterval:[87,116]},null,[],["seq",{sourceInterval:[106,116]},["terminal",{sourceInterval:[106,110]},"<:"],["app",{sourceInterval:[111,116]},"ident",[]]]],Rule_define:["define",{sourceInterval:[131,181]},null,[],["seq",{sourceInterval:[131,170]},["app",{sourceInterval:[131,136]},"ident",[]],["opt",{sourceInterval:[137,145]},["app",{sourceInterval:[137,144]},"Formals",[]]],["opt",{sourceInterval:[146,156]},["app",{sourceInterval:[146,155]},"ruleDescr",[]]],["terminal",{sourceInterval:[157,160]},"="],["app",{sourceInterval:[162,170]},"RuleBody",[]]]],Rule_override:["define",{sourceInterval:[188,248]},null,[],["seq",{sourceInterval:[188,235]},["app",{sourceInterval:[188,193]},"ident",[]],["opt",{sourceInterval:[194,202]},["app",{sourceInterval:[194,201]},"Formals",[]]],["terminal",{sourceInterval:[214,218]},":="],["app",{sourceInterval:[219,235]},"OverrideRuleBody",[]]]],Rule_extend:["define",{sourceInterval:[255,305]},null,[],["seq",{sourceInterval:[255,294]},["app",{sourceInterval:[255,260]},"ident",[]],["opt",{sourceInterval:[261,269]},["app",{sourceInterval:[261,268]},"Formals",[]]],["terminal",{sourceInterval:[281,285]},"+="],["app",{sourceInterval:[286,294]},"RuleBody",[]]]],Rule:["define",{sourceInterval:[120,305]},null,[],["alt",{sourceInterval:[131,305]},["app",{sourceInterval:[131,170]},"Rule_define",[]],["app",{sourceInterval:[188,235]},"Rule_override",[]],["app",{sourceInterval:[255,294]},"Rule_extend",[]]]],RuleBody:["define",{sourceInterval:[309,362]},null,[],["seq",{sourceInterval:[324,362]},["opt",{sourceInterval:[324,328]},["terminal",{sourceInterval:[324,327]},"|"]],["app",{sourceInterval:[329,362]},"NonemptyListOf",[["app",{sourceInterval:[344,356]},"TopLevelTerm",[]],["terminal",{sourceInterval:[358,361]},"|"]]]]],TopLevelTerm_inline:["define",{sourceInterval:[385,408]},null,[],["seq",{sourceInterval:[385,397]},["app",{sourceInterval:[385,388]},"Seq",[]],["app",{sourceInterval:[389,397]},"caseName",[]]]],TopLevelTerm:["define",{sourceInterval:[366,418]},null,[],["alt",{sourceInterval:[385,418]},["app",{sourceInterval:[385,397]},"TopLevelTerm_inline",[]],["app",{sourceInterval:[415,418]},"Seq",[]]]],OverrideRuleBody:["define",{sourceInterval:[422,491]},null,[],["seq",{sourceInterval:[445,491]},["opt",{sourceInterval:[445,449]},["terminal",{sourceInterval:[445,448]},"|"]],["app",{sourceInterval:[450,491]},"NonemptyListOf",[["app",{sourceInterval:[465,485]},"OverrideTopLevelTerm",[]],["terminal",{sourceInterval:[487,490]},"|"]]]]],OverrideTopLevelTerm_superSplice:["define",{sourceInterval:[522,543]},null,[],["terminal",{sourceInterval:[522,527]},"..."]],OverrideTopLevelTerm:["define",{sourceInterval:[495,562]},null,[],["alt",{sourceInterval:[522,562]},["app",{sourceInterval:[522,527]},"OverrideTopLevelTerm_superSplice",[]],["app",{sourceInterval:[550,562]},"TopLevelTerm",[]]]],Formals:["define",{sourceInterval:[566,606]},null,[],["seq",{sourceInterval:[580,606]},["terminal",{sourceInterval:[580,583]},"<"],["app",{sourceInterval:[584,602]},"ListOf",[["app",{sourceInterval:[591,596]},"ident",[]],["terminal",{sourceInterval:[598,601]},","]]],["terminal",{sourceInterval:[603,606]},">"]]],Params:["define",{sourceInterval:[610,647]},null,[],["seq",{sourceInterval:[623,647]},["terminal",{sourceInterval:[623,626]},"<"],["app",{sourceInterval:[627,643]},"ListOf",[["app",{sourceInterval:[634,637]},"Seq",[]],["terminal",{sourceInterval:[639,642]},","]]],["terminal",{sourceInterval:[644,647]},">"]]],Alt:["define",{sourceInterval:[651,685]},null,[],["app",{sourceInterval:[661,685]},"NonemptyListOf",[["app",{sourceInterval:[676,679]},"Seq",[]],["terminal",{sourceInterval:[681,684]},"|"]]]],Seq:["define",{sourceInterval:[689,704]},null,[],["star",{sourceInterval:[699,704]},["app",{sourceInterval:[699,703]},"Iter",[]]]],Iter_star:["define",{sourceInterval:[719,736]},null,[],["seq",{sourceInterval:[719,727]},["app",{sourceInterval:[719,723]},"Pred",[]],["terminal",{sourceInterval:[724,727]},"*"]]],Iter_plus:["define",{sourceInterval:[743,760]},null,[],["seq",{sourceInterval:[743,751]},["app",{sourceInterval:[743,747]},"Pred",[]],["terminal",{sourceInterval:[748,751]},"+"]]],Iter_opt:["define",{sourceInterval:[767,783]},null,[],["seq",{sourceInterval:[767,775]},["app",{sourceInterval:[767,771]},"Pred",[]],["terminal",{sourceInterval:[772,775]},"?"]]],Iter:["define",{sourceInterval:[708,794]},null,[],["alt",{sourceInterval:[719,794]},["app",{sourceInterval:[719,727]},"Iter_star",[]],["app",{sourceInterval:[743,751]},"Iter_plus",[]],["app",{sourceInterval:[767,775]},"Iter_opt",[]],["app",{sourceInterval:[790,794]},"Pred",[]]]],Pred_not:["define",{sourceInterval:[809,824]},null,[],["seq",{sourceInterval:[809,816]},["terminal",{sourceInterval:[809,812]},"~"],["app",{sourceInterval:[813,816]},"Lex",[]]]],Pred_lookahead:["define",{sourceInterval:[831,852]},null,[],["seq",{sourceInterval:[831,838]},["terminal",{sourceInterval:[831,834]},"&"],["app",{sourceInterval:[835,838]},"Lex",[]]]],Pred:["define",{sourceInterval:[798,862]},null,[],["alt",{sourceInterval:[809,862]},["app",{sourceInterval:[809,816]},"Pred_not",[]],["app",{sourceInterval:[831,838]},"Pred_lookahead",[]],["app",{sourceInterval:[859,862]},"Lex",[]]]],Lex_lex:["define",{sourceInterval:[876,892]},null,[],["seq",{sourceInterval:[876,884]},["terminal",{sourceInterval:[876,879]},"#"],["app",{sourceInterval:[880,884]},"Base",[]]]],Lex:["define",{sourceInterval:[866,903]},null,[],["alt",{sourceInterval:[876,903]},["app",{sourceInterval:[876,884]},"Lex_lex",[]],["app",{sourceInterval:[899,903]},"Base",[]]]],Base_application:["define",{sourceInterval:[918,979]},null,[],["seq",{sourceInterval:[918,963]},["app",{sourceInterval:[918,923]},"ident",[]],["opt",{sourceInterval:[924,931]},["app",{sourceInterval:[924,930]},"Params",[]]],["not",{sourceInterval:[932,963]},["alt",{sourceInterval:[934,962]},["seq",{sourceInterval:[934,948]},["opt",{sourceInterval:[934,944]},["app",{sourceInterval:[934,943]},"ruleDescr",[]]],["terminal",{sourceInterval:[945,948]},"="]],["terminal",{sourceInterval:[951,955]},":="],["terminal",{sourceInterval:[958,962]},"+="]]]]],Base_range:["define",{sourceInterval:[986,1041]},null,[],["seq",{sourceInterval:[986,1022]},["app",{sourceInterval:[986,1001]},"oneCharTerminal",[]],["terminal",{sourceInterval:[1002,1006]},".."],["app",{sourceInterval:[1007,1022]},"oneCharTerminal",[]]]],Base_terminal:["define",{sourceInterval:[1048,1106]},null,[],["app",{sourceInterval:[1048,1056]},"terminal",[]]],Base_paren:["define",{sourceInterval:[1113,1168]},null,[],["seq",{sourceInterval:[1113,1124]},["terminal",{sourceInterval:[1113,1116]},"("],["app",{sourceInterval:[1117,1120]},"Alt",[]],["terminal",{sourceInterval:[1121,1124]},")"]]],Base:["define",{sourceInterval:[907,1168]},null,[],["alt",{sourceInterval:[918,1168]},["app",{sourceInterval:[918,963]},"Base_application",[]],["app",{sourceInterval:[986,1022]},"Base_range",[]],["app",{sourceInterval:[1048,1056]},"Base_terminal",[]],["app",{sourceInterval:[1113,1124]},"Base_paren",[]]]],ruleDescr:["define",{sourceInterval:[1172,1231]},"a rule description",[],["seq",{sourceInterval:[1210,1231]},["terminal",{sourceInterval:[1210,1213]},"("],["app",{sourceInterval:[1214,1227]},"ruleDescrText",[]],["terminal",{sourceInterval:[1228,1231]},")"]]],ruleDescrText:["define",{sourceInterval:[1235,1266]},null,[],["star",{sourceInterval:[1255,1266]},["seq",{sourceInterval:[1256,1264]},["not",{sourceInterval:[1256,1260]},["terminal",{sourceInterval:[1257,1260]},")"]],["app",{sourceInterval:[1261,1264]},"any",[]]]]],caseName:["define",{sourceInterval:[1270,1338]},null,[],["seq",{sourceInterval:[1285,1338]},["terminal",{sourceInterval:[1285,1289]},"--"],["star",{sourceInterval:[1290,1304]},["seq",{sourceInterval:[1291,1302]},["not",{sourceInterval:[1291,1296]},["terminal",{sourceInterval:[1292,1296]},"\n"]],["app",{sourceInterval:[1297,1302]},"space",[]]]],["app",{sourceInterval:[1305,1309]},"name",[]],["star",{sourceInterval:[1310,1324]},["seq",{sourceInterval:[1311,1322]},["not",{sourceInterval:[1311,1316]},["terminal",{sourceInterval:[1312,1316]},"\n"]],["app",{sourceInterval:[1317,1322]},"space",[]]]],["alt",{sourceInterval:[1326,1337]},["terminal",{sourceInterval:[1326,1330]},"\n"],["lookahead",{sourceInterval:[1333,1337]},["terminal",{sourceInterval:[1334,1337]},"}"]]]]],name:["define",{sourceInterval:[1342,1382]},"a name",[],["seq",{sourceInterval:[1363,1382]},["app",{sourceInterval:[1363,1372]},"nameFirst",[]],["star",{sourceInterval:[1373,1382]},["app",{sourceInterval:[1373,1381]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[1386,1418]},null,[],["alt",{sourceInterval:[1402,1418]},["terminal",{sourceInterval:[1402,1405]},"_"],["app",{sourceInterval:[1412,1418]},"letter",[]]]],nameRest:["define",{sourceInterval:[1422,1452]},null,[],["alt",{sourceInterval:[1437,1452]},["terminal",{sourceInterval:[1437,1440]},"_"],["app",{sourceInterval:[1447,1452]},"alnum",[]]]],ident:["define",{sourceInterval:[1456,1489]},"an identifier",[],["app",{sourceInterval:[1485,1489]},"name",[]]],terminal:["define",{sourceInterval:[1493,1531]},null,[],["seq",{sourceInterval:[1508,1531]},["terminal",{sourceInterval:[1508,1512]},'"'],["star",{sourceInterval:[1513,1526]},["app",{sourceInterval:[1513,1525]},"terminalChar",[]]],["terminal",{sourceInterval:[1527,1531]},'"']]],oneCharTerminal:["define",{sourceInterval:[1535,1579]},null,[],["seq",{sourceInterval:[1557,1579]},["terminal",{sourceInterval:[1557,1561]},'"'],["app",{sourceInterval:[1562,1574]},"terminalChar",[]],["terminal",{sourceInterval:[1575,1579]},'"']]],terminalChar:["define",{sourceInterval:[1583,1660]},null,[],["alt",{sourceInterval:[1602,1660]},["app",{sourceInterval:[1602,1612]},"escapeChar",[]],["seq",{sourceInterval:[1621,1660]},["not",{sourceInterval:[1621,1626]},["terminal",{sourceInterval:[1622,1626]},"\\"]],["not",{sourceInterval:[1627,1632]},["terminal",{sourceInterval:[1628,1632]},'"']],["not",{sourceInterval:[1633,1638]},["terminal",{sourceInterval:[1634,1638]},"\n"]],["range",{sourceInterval:[1639,1660]},"\0","\udbff\udfff"]]]],escapeChar_backslash:["define",{sourceInterval:[1703,1758]},null,[],["terminal",{sourceInterval:[1703,1709]},"\\\\"]],escapeChar_doubleQuote:["define",{sourceInterval:[1765,1822]},null,[],["terminal",{sourceInterval:[1765,1771]},'\\"']],escapeChar_singleQuote:["define",{sourceInterval:[1829,1886]},null,[],["terminal",{sourceInterval:[1829,1835]},"\\'"]],escapeChar_backspace:["define",{sourceInterval:[1893,1948]},null,[],["terminal",{sourceInterval:[1893,1898]},"\\b"]],escapeChar_lineFeed:["define",{sourceInterval:[1955,2009]},null,[],["terminal",{sourceInterval:[1955,1960]},"\\n"]],escapeChar_carriageReturn:["define",{sourceInterval:[2016,2076]},null,[],["terminal",{sourceInterval:[2016,2021]},"\\r"]],escapeChar_tab:["define",{sourceInterval:[2083,2132]},null,[],["terminal",{sourceInterval:[2083,2088]},"\\t"]],escapeChar_unicodeCodePoint:["define",{sourceInterval:[2139,2243]},null,[],["seq",{sourceInterval:[2139,2221]},["terminal",{sourceInterval:[2139,2145]},"\\u{"],["app",{sourceInterval:[2146,2154]},"hexDigit",[]],["opt",{sourceInterval:[2155,2164]},["app",{sourceInterval:[2155,2163]},"hexDigit",[]]],["opt",{sourceInterval:[2165,2174]},["app",{sourceInterval:[2165,2173]},"hexDigit",[]]],["opt",{sourceInterval:[2188,2197]},["app",{sourceInterval:[2188,2196]},"hexDigit",[]]],["opt",{sourceInterval:[2198,2207]},["app",{sourceInterval:[2198,2206]},"hexDigit",[]]],["opt",{sourceInterval:[2208,2217]},["app",{sourceInterval:[2208,2216]},"hexDigit",[]]],["terminal",{sourceInterval:[2218,2221]},"}"]]],escapeChar_unicodeEscape:["define",{sourceInterval:[2250,2309]},null,[],["seq",{sourceInterval:[2250,2291]},["terminal",{sourceInterval:[2250,2255]},"\\u"],["app",{sourceInterval:[2256,2264]},"hexDigit",[]],["app",{sourceInterval:[2265,2273]},"hexDigit",[]],["app",{sourceInterval:[2274,2282]},"hexDigit",[]],["app",{sourceInterval:[2283,2291]},"hexDigit",[]]]],escapeChar_hexEscape:["define",{sourceInterval:[2316,2371]},null,[],["seq",{sourceInterval:[2316,2339]},["terminal",{sourceInterval:[2316,2321]},"\\x"],["app",{sourceInterval:[2322,2330]},"hexDigit",[]],["app",{sourceInterval:[2331,2339]},"hexDigit",[]]]],escapeChar:["define",{sourceInterval:[1664,2371]},"an escape sequence",[],["alt",{sourceInterval:[1703,2371]},["app",{sourceInterval:[1703,1709]},"escapeChar_backslash",[]],["app",{sourceInterval:[1765,1771]},"escapeChar_doubleQuote",[]],["app",{sourceInterval:[1829,1835]},"escapeChar_singleQuote",[]],["app",{sourceInterval:[1893,1898]},"escapeChar_backspace",[]],["app",{sourceInterval:[1955,1960]},"escapeChar_lineFeed",[]],["app",{sourceInterval:[2016,2021]},"escapeChar_carriageReturn",[]],["app",{sourceInterval:[2083,2088]},"escapeChar_tab",[]],["app",{sourceInterval:[2139,2221]},"escapeChar_unicodeCodePoint",[]],["app",{sourceInterval:[2250,2291]},"escapeChar_unicodeEscape",[]],["app",{sourceInterval:[2316,2339]},"escapeChar_hexEscape",[]]]],space:["extend",{sourceInterval:[2375,2394]},null,[],["app",{sourceInterval:[2387,2394]},"comment",[]]],comment_singleLine:["define",{sourceInterval:[2412,2458]},null,[],["seq",{sourceInterval:[2412,2443]},["terminal",{sourceInterval:[2412,2416]},"//"],["star",{sourceInterval:[2417,2429]},["seq",{sourceInterval:[2418,2427]},["not",{sourceInterval:[2418,2423]},["terminal",{sourceInterval:[2419,2423]},"\n"]],["app",{sourceInterval:[2424,2427]},"any",[]]]],["lookahead",{sourceInterval:[2430,2443]},["alt",{sourceInterval:[2432,2442]},["terminal",{sourceInterval:[2432,2436]},"\n"],["app",{sourceInterval:[2439,2442]},"end",[]]]]]],comment_multiLine:["define",{sourceInterval:[2465,2501]},null,[],["seq",{sourceInterval:[2465,2487]},["terminal",{sourceInterval:[2465,2469]},"/*"],["star",{sourceInterval:[2470,2482]},["seq",{sourceInterval:[2471,2480]},["not",{sourceInterval:[2471,2476]},["terminal",{sourceInterval:[2472,2476]},"*/"]],["app",{sourceInterval:[2477,2480]},"any",[]]]],["terminal",{sourceInterval:[2483,2487]},"*/"]]],comment:["define",{sourceInterval:[2398,2501]},null,[],["alt",{sourceInterval:[2412,2501]},["app",{sourceInterval:[2412,2443]},"comment_singleLine",[]],["app",{sourceInterval:[2465,2487]},"comment_multiLine",[]]]],tokens:["define",{sourceInterval:[2505,2520]},null,[],["star",{sourceInterval:[2514,2520]},["app",{sourceInterval:[2514,2519]},"token",[]]]],token:["define",{sourceInterval:[2524,2600]},null,[],["alt",{sourceInterval:[2532,2600]},["app",{sourceInterval:[2532,2540]},"caseName",[]],["app",{sourceInterval:[2543,2550]},"comment",[]],["app",{sourceInterval:[2553,2558]},"ident",[]],["app",{sourceInterval:[2561,2569]},"operator",[]],["app",{sourceInterval:[2572,2583]},"punctuation",[]],["app",{sourceInterval:[2586,2594]},"terminal",[]],["app",{sourceInterval:[2597,2600]},"any",[]]]],operator:["define",{sourceInterval:[2604,2669]},null,[],["alt",{sourceInterval:[2615,2669]},["terminal",{sourceInterval:[2615,2619]},"<:"],["terminal",{sourceInterval:[2622,2625]},"="],["terminal",{sourceInterval:[2628,2632]},":="],["terminal",{sourceInterval:[2635,2639]},"+="],["terminal",{sourceInterval:[2642,2645]},"*"],["terminal",{sourceInterval:[2648,2651]},"+"],["terminal",{sourceInterval:[2654,2657]},"?"],["terminal",{sourceInterval:[2660,2663]},"~"],["terminal",{sourceInterval:[2666,2669]},"&"]]],punctuation:["define",{sourceInterval:[2673,2709]},null,[],["alt",{sourceInterval:[2687,2709]},["terminal",{sourceInterval:[2687,2690]},"<"],["terminal",{sourceInterval:[2693,2696]},">"],["terminal",{sourceInterval:[2699,2702]},","],["terminal",{sourceInterval:[2705,2709]},"--"]]]}]),He=Object.create(w.prototype);function Ge(e,t){for(const n in e)if(n===t)return!0;return!1}function qe(e,t,n){const r=new Ve;let i,s,o,l=!1;const u=(n||We).createSemantics().addOperation("visit",{Grammars:e=>e.children.map((e=>e.visit())),Grammar(e,n,s,a,o){const l=e.visit();i=r.newGrammar(l),n.child(0)&&n.child(0).visit(),a.children.map((e=>e.visit()));const u=i.build();if(u.source=this.source.trimmed(),Ge(t,l))throw function(e,t){return $("Grammar "+e.name+" is already declared in this namespace")}(u);return t[l]=u,u},SuperGrammar(e,n){const r=n.visit();if("null"===r)i.withSuperGrammar(null);else{if(!t||!Ge(t,r))throw function(e,t,n){return $(t?`Grammar ${e} is not declared in namespace '${t}'`:"Undeclared grammar "+e,n)}(r,t,n.source);i.withSuperGrammar(t[r])}},Rule_define(e,t,n,r,a){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[],i.defaultStartRule||i.ensureSuperGrammar()===$e.ProtoBuiltInRules||i.withDefaultStartRule(s);const l=a.visit(),u=n.children.map((e=>e.visit()))[0],c=this.source.trimmed();return i.define(s,o,l,u,c)},Rule_override(e,t,n,r){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[];const a=this.source.trimmed();i.ensureSuperGrammarRuleForOverriding(s,a),l=!0;const u=r.visit();return l=!1,i.override(s,o,u,null,a)},Rule_extend(e,t,n,r){s=e.visit(),o=t.children.map((e=>e.visit()))[0]||[];const a=r.visit(),l=this.source.trimmed();return i.extend(s,o,a,null,l)},RuleBody(e,t){return r.alt(...t.visit()).withSource(this.source)},OverrideRuleBody(e,t){const n=t.visit(),a=n.indexOf(He);if(a>=0){const e=n.slice(0,a),t=n.slice(a+1);return t.forEach((e=>{if(e===He)throw $("'...' can appear at most once in a rule body",e.source)})),new E(i.superGrammar,s,e,t).withSource(this.source)}return r.alt(...n).withSource(this.source)},Formals:(e,t,n)=>t.visit(),Params:(e,t,n)=>t.visit(),Alt(e){return r.alt(...e.visit()).withSource(this.source)},TopLevelTerm_inline(e,t){const n=s+"_"+t.visit(),a=e.visit(),u=this.source.trimmed(),c=!(i.superGrammar&&i.superGrammar.rules[n]);l&&!c?i.override(n,o,a,null,u):i.define(n,o,a,null,u);const p=o.map((e=>r.app(e)));return r.app(n,p).withSource(a.source)},OverrideTopLevelTerm_superSplice:e=>He,Seq(e){return r.seq(...e.children.map((e=>e.visit()))).withSource(this.source)},Iter_star(e,t){return r.star(e.visit()).withSource(this.source)},Iter_plus(e,t){return r.plus(e.visit()).withSource(this.source)},Iter_opt(e,t){return r.opt(e.visit()).withSource(this.source)},Pred_not(e,t){return r.not(t.visit()).withSource(this.source)},Pred_lookahead(e,t){return r.lookahead(t.visit()).withSource(this.source)},Lex_lex(e,t){return r.lex(t.visit()).withSource(this.source)},Base_application(e,t){const n=t.children.map((e=>e.visit()))[0]||[];return r.app(e.visit(),n).withSource(this.source)},Base_range(e,t,n){return r.range(e.visit(),n.visit()).withSource(this.source)},Base_terminal(e){return r.terminal(e.visit()).withSource(this.source)},Base_paren:(e,t,n)=>t.visit(),ruleDescr:(e,t,n)=>t.visit(),ruleDescrText(e){return this.sourceString.trim()},caseName:(e,t,n,r,i)=>n.visit(),name(e,t){return this.sourceString},nameFirst(e){},nameRest(e){},terminal:(e,t,n)=>t.children.map((e=>e.visit())).join(""),oneCharTerminal:(e,t,n)=>t.visit(),escapeChar(e){try{return y(this.sourceString)}catch(t){if(t instanceof RangeError&&t.message.startsWith("Invalid code point "))throw function(e){const t=e._node;a(t&&t.isNonterminal()&&"escapeChar_unicodeCodePoint"===t.ctorName);const n=e.children.slice(1,-1).map((e=>e.source)),r=n[0].coverageWith(...n.slice(1));return $(`U+${r.contents} is not a valid Unicode code point`,r)}(e);throw t}},NonemptyListOf:(e,t,n)=>[e.visit()].concat(n.children.map((e=>e.visit()))),EmptyListOf:()=>[],_terminal(){return this.sourceString}});return u(e).visit()}const Ke=Ue(["grammar",{source:'OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = "(" ListOf ")"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n}'},"OperationsAndAttributes",null,"AttributeSignature",{AttributeSignature:["define",{sourceInterval:[29,58]},null,[],["app",{sourceInterval:[54,58]},"name",[]]],OperationSignature:["define",{sourceInterval:[62,100]},null,[],["seq",{sourceInterval:[87,100]},["app",{sourceInterval:[87,91]},"name",[]],["opt",{sourceInterval:[92,100]},["app",{sourceInterval:[92,99]},"Formals",[]]]]],Formals:["define",{sourceInterval:[104,143]},null,[],["seq",{sourceInterval:[118,143]},["terminal",{sourceInterval:[118,121]},"("],["app",{sourceInterval:[122,139]},"ListOf",[["app",{sourceInterval:[129,133]},"name",[]],["terminal",{sourceInterval:[135,138]},","]]],["terminal",{sourceInterval:[140,143]},")"]]],name:["define",{sourceInterval:[147,187]},"a name",[],["seq",{sourceInterval:[168,187]},["app",{sourceInterval:[168,177]},"nameFirst",[]],["star",{sourceInterval:[178,187]},["app",{sourceInterval:[178,186]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[191,223]},null,[],["alt",{sourceInterval:[207,223]},["terminal",{sourceInterval:[207,210]},"_"],["app",{sourceInterval:[217,223]},"letter",[]]]],nameRest:["define",{sourceInterval:[227,257]},null,[],["alt",{sourceInterval:[242,257]},["terminal",{sourceInterval:[242,245]},"_"],["app",{sourceInterval:[252,257]},"alnum",[]]]]}]);!function(e){const t={empty(){return this.iteration()},nonEmpty(e,t,n){return this.iteration([e].concat(n.children))}};Le.BuiltInSemantics=Le.createSemantics(e,null).addOperation("asIteration",{emptyListOf:t.empty,nonemptyListOf:t.nonEmpty,EmptyListOf:t.empty,NonemptyListOf:t.nonEmpty})}($e.BuiltInRules),function(e){Le.prototypeGrammarSemantics=e.createSemantics().addOperation("parse",{AttributeSignature:e=>({name:e.parse(),formals:[]}),OperationSignature:(e,t)=>({name:e.parse(),formals:t.children.map((e=>e.parse()))[0]||[]}),Formals:(e,t,n)=>t.asIteration().children.map((e=>e.parse())),name(e,t){return this.sourceString}}),Le.prototypeGrammar=e}(Ke);const Qe="an indented block",Ye="a dedent",Xe=1114112;class Je extends re{constructor(e){super(e.input),this.state=e}_indentationAt(e){return this.state.userData[e]||0}atEnd(){return super.atEnd()&&0===this._indentationAt(this.pos)}next(){if(0===this._indentationAt(this.pos))return super.next();this.examinedLength=Math.max(this.examinedLength,this.pos)}nextCharCode(){return 0!==this._indentationAt(this.pos)?(this.examinedLength=Math.max(this.examinedLength,this.pos),Xe):super.nextCharCode()}nextCodePoint(){return 0!==this._indentationAt(this.pos)?(this.examinedLength=Math.max(this.examinedLength,this.pos),Xe):super.nextCodePoint()}}class Ze extends w{constructor(e=!0){super(),this.isIndent=e}allowsSkippingPrecedingSpace(){return!0}eval(e){const{inputStream:t}=e,n=e.userData;e.doNotMemoize=!0;const r=t.pos,i=this.isIndent?1:-1;return(n[r]||0)*i>0?(e.userData=Object.create(n),e.userData[r]-=i,e.pushBinding(new ye(0),r),!0):(e.processFailure(r,this),!1)}getArity(){return 1}_assertAllApplicationsAreValid(e,t){}_isNullable(e,t){return!1}assertChoicesHaveUniformArity(e){}assertIteratedExprsAreNotNullable(e){}introduceParams(e){return this}substituteParams(e){return this}toString(){return this.isIndent?"indent":"dedent"}toDisplayString(){return this.toString()}toFailure(e){const t=this.isIndent?Qe:Ye;return new ke(this,t,"description")}}const et=new j("indent"),tt=new j("dedent"),nt=new E(Be,"any",[et,tt],[]),rt=(new Ve).newGrammar("IndentationSensitive").withSuperGrammar(Be).define("indent",[],new Ze(!0),Qe,void 0,!0).define("dedent",[],new Ze(!1),Ye,void 0,!0).extend("any",[],nt,"any character",void 0).build();Object.assign(rt,{_matchStateInitializer(e){e.userData=function(e){let t=0;const n=[0],r=()=>n[n.length-1],i={},s=/( *).*(?:$|\r?\n|\r)/g;let a;for(;null!=(a=s.exec(e));){const[e,s]=a;if(0===e.length)break;const o=s.length,l=r(),u=t+o;if(o>l)n.push(o),i[u]=1;else if(o1&&(i[t]=1-n.length),i}(e.input),e.inputStream=new Je(e)},supportsIncrementalParsing:!1}),$e.initApplicationParser(We,qe);const it=e=>!!e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e);function st(e,t){const n=We.match(e,"Grammars");if(n.failed())throw function(e){const t=new Error;return Object.defineProperty(t,"message",{enumerable:!0,get:()=>e.message}),Object.defineProperty(t,"shortMessage",{enumerable:!0,get:()=>"Expected "+e.getExpectedText()}),t.interval=e.getInterval(),t}(n);return qe(n,t)}function at(e,t){const n=function(e,t){const n=Object.create(t||{});if("string"!==typeof e){if(!it(e))throw new TypeError("Expected string as first argument, got "+v(e));e=e.toString()}return st(e,n),n}(e,t),r=Object.keys(n);if(0===r.length)throw new Error("Missing grammar definition");if(r.length>1){const e=n[r[1]].source;throw new Error(ee(e.sourceString,e.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return n[r[0]]}},8463:(e,t,n)=>{n.d(t,{Kx:()=>i,O:()=>a,a5:()=>s,J5:()=>r});const r="function Main.fibonacci 0\n push argument 0\n push constant 2\n lt // checks if n<2\n if-goto IF_TRUE\n goto IF_FALSE\n label IF_TRUE // if n<2, return n\n push argument 0 \n return\n label IF_FALSE // if n>=2, returns fib(n-2)+fib(n-1)\n push argument 0\n push constant 2\n sub\n call Main.fibonacci 1 // computes fib(n-2)\n push argument 0\n push constant 1\n sub\n call Main.fibonacci 1 // computes fib(n-1)\n add // returns fib(n-1) + fib(n-2)\n return\nfunction Sys.init 0\n push constant 4\n call Main.fibonacci 1 // computes the 4'th fibonacci element\nlabel WHILE\n goto WHILE // loops infinitely\n",i={"01":["Nand"],"02":[],"03":["DFF"],"05":["Screen","Keyboard","DRegister","ARegister","ROM32K","RAM16K"]},s={"01":["Not","And","Or","Xor","Mux","DMux","Not16","And16","Or16","Mux16","Or8Way","Mux4Way16","Mux8Way16","DMux4Way","DMux8Way"],"02":["HalfAdder","FullAdder","Add16","Inc16","ALU"],"03":["Bit","Register","RAM8","RAM64","RAM512","RAM4K","RAM16K","PC"],"05":["Memory","CPU","Computer"]},a={"05":["Memory","CPU","Computer","Screen","Keyboard","DRegister","ARegister","ROM32K","RAM16K"]}},5777:(e,t,n)=>{async function r(e,t){(await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288))).resetFiles(e,t)}async function i(e,t){(await Promise.all([n.e(828),n.e(288)]).then(n.bind(n,3288))).resetTests(e,t)}async function s(e){(await Promise.all([n.e(828),n.e(297)]).then(n.bind(n,9297))).loadSamples(e)}async function a(e){(await n.e(269).then(n.bind(n,1269))).loadSolutions(e)}n.r(t),n.d(t,{default:()=>l,loadSamples:()=>s,loadSolutions:()=>a,loaders:()=>o,resetFiles:()=>r,resetTests:()=>i});const o={resetFiles:r,loadSolutions:a,loadSamples:s},l=o},7738:(e,t,n)=>{n.d(t,{qg:()=>u});var r=n(5874),i=n(3977),s=n(5005),a=n(6980),o=n(9651);function l(e){const t=e.start??0;return void 0===e.end?(0,r.Ok)(void 0):e.end>=t?(0,r.Ok)(e.end-t+1):(0,r._)((0,i.$5)("Bus start index should be less than or equal to bus end index",e.span))}async function u(e,t){const n=s.xP.parse(e.toString());return(0,r.ys)(n)?n:p((0,r.Ok)(n),void 0,t)}async function c(e,t){if((0,a.KQ)(e)||void 0===t)return await(0,a.M1)(e);try{const n=await t.readFile(`${e}.hdl`),i=s.xP.parse(n);let a;if((0,r.HQ)(i)){const e=await p((0,r.Ok)(i),t);a=(0,r.ys)(e)?(0,r._)(new Error((0,r._)(e).message)):e}else a=(0,r._)(new Error("HDL Was not parsed"));return a}catch(n){return(0,r._)(new Error(`Could not load chip ${e}.hdl`))}}async function p(e,t,n){return await new y(e,t,n).build()}function d(e){if(void 0!=e.start&&void 0!=e.end)return e.end-e.start+1}function h(e){return void 0!=e.start&&void 0!=e.end?`${e.pin}[${e.start}..${e.end}]`:e.pin}function f(e,t){const n=l(e),i=l(t);return(0,r.ys)(n)?n:(0,r.ys)(i)?i:(0,r.Ok)({to:{name:e.pin.toString(),start:e.start??0,width:(0,r.Ok)(n)},from:{name:t.pin.toString(),start:t.start??0,width:(0,r.Ok)(i)}})}function m(e){if(void 0!=e.start&&void 0!=e.end){const t=[];for(let n=e.start;n<=e.end;n++)t.push(n);return t}return[-1]}function g(e,t){let n;const s=t.get(e.pin);if(s)if(s.has(-1))n=e.start??-1;else if(void 0!==e.start&&void 0!==e.end)for(const r of m(e))s.has(r)&&(n=r),s.add(r);else s.add(-1);else t.set(e.pin,new Set(m(e)));return void 0!=n?(0,r._)((0,i.$5)(`Cannot write to pin ${e.pin}${-1!=n?`[${n}]`:""} multiple times`,e.span)):(0,r.Ok)()}class y{parts;fs;expectedName;chip;internalPins=new Map;inPins=new Map;outPins=new Map;wires=[];constructor(e,t,n){this.parts=e,this.expectedName=n,this.fs=t,this.chip=new o.vu(e.ins.map((({pin:e,width:t})=>({pin:e.toString(),width:t}))),e.outs.map((({pin:e,width:t})=>({pin:e.toString(),width:t}))),e.name.value,[],e.clocked)}async build(){if(this.expectedName&&this.parts.name.value!=this.expectedName)return(0,r._)((0,i.$5)("Wrong chip name",this.parts.name.span));if("BUILTIN"===this.parts.parts)return await(0,a.M1)(this.parts.name.value);const e=await this.wireParts();if((0,r.ys)(e))return e;this.chip.clockedPins=new Set([...this.chip.ins.entries(),...this.chip.outs.entries()].map((e=>e.name)).filter((e=>this.chip.isClockedPin(e)))),this.chip.sortParts();for(const t of this.chip.parts)t.subscribeToClock();return(0,r.Ok)(this.chip)}async wireParts(){if("BUILTIN"===this.parts.parts)return(0,r.Ok)();for(const t of this.parts.parts){const e=await c(t.name,this.fs);if((0,r.ys)(e))return(0,r._)((0,i.$5)(`Undefined chip name: ${t.name}`,t.span));const n=(0,r.Ok)(e);if(n.name==this.chip.name)return(0,r._)((0,i.$5)(`Cannot use chip ${n.name} to implement itself`,t.span));const s=this.wirePart(t,n);if((0,r.ys)(s))return s}let e=this.validateInternalPins();return(0,r.ys)(e)?e:(e=this.validateWireWidths(),(0,r.ys)(e)?e:(0,r.Ok)())}checkLoops(e,t){const n=new Set,s=new Set;let a;for(const{lhs:r,rhs:i}of e.wires)if(t.isInPin(r.pin)){if(s.has(i.pin)){a=i.pin;break}n.add(i.pin)}else if(t.isOutPin(r.pin)){if(n.has(i.pin)){a=i.pin;break}s.add(i.pin)}return a?(0,r._)((0,i.$5)(`Looping wire ${a}`,e.span)):(0,r.Ok)()}wirePart(e,t){const n=this.checkLoops(e,t);if((0,r.ys)(n))return n;const s=[];this.inPins.clear();for(const{lhs:i,rhs:o}of e.wires){const e=this.validateWire(t,i,o);if((0,r.ys)(e))return e;const n=f(i,o);if((0,r.ys)(n))return n;s.push((0,r.Ok)(n))}try{const n=this.chip.wire(t,s);if((0,r.ys)(n)){const t=(0,r._)(n);return(0,r._)((0,i.$5)(t.message,t.lhs?e.wires[t.wireIndex].lhs.span:e.wires[t.wireIndex].rhs.span))}return(0,r.Ok)()}catch(a){return(0,r._)((0,i.$5)(a.message,e.span))}}validateWire(e,t,n){if(e.isInPin(t.pin)){const e=this.validateInputWire(t,n);if((0,r.ys)(e))return e}else{if(!e.isOutPin(t.pin))return(0,r._)((0,i.$5)(`Undefined pin name: ${t.pin}`,t.span));{const i=this.validateOutputWire(e,t,n);if((0,r.ys)(i))return i}}return(0,o.KK)(n.pin)||this.wires.push({partChip:e,lhs:t,rhs:n}),(0,r.Ok)()}validateInputWire(e,t){let n=this.validateInputSource(t);if((0,r.ys)(n))return n;if(n=g(e,this.inPins),(0,r.ys)(n))return n;if(this.chip.isInternalPin(t.pin)){const e=this.internalPins.get(t.pin);void 0==e?this.internalPins.set(t.pin,{isDefined:!1,firstUse:t.span}):e.firstUse=e.firstUse.start{n.d(t,{N4:()=>u,Sc:()=>y,Z8:()=>g,ce:()=>d,ff:()=>c,s3:()=>p});var r=n(7721),i=n(7076),s=n(6983),a=n(7844),o=n(9651),l=n(836);class u extends l.XK{constructor(){super(15,"ROM")}async load(e,t){try{(await(0,s.Hh)(e,t)).map(((e,t)=>this.at(t).busVoltage=e))}catch(n){throw new Error(`ROM32K Failed to load file ${t}`)}}}class c extends l.XK{static SIZE=i.RL;static OFFSET=i.L7;constructor(){super(13,"Screen")}}class p extends o.vu{static OFFSET=i.ky;constructor(){super([],["out[16]"],"Keyboard")}getKey(){return this.out().busVoltage}setKey(e){this.out().busVoltage=65535&e}clearKey(){this.out().busVoltage=0}get(e){return e===this.name?new o.xo(this.name,this.getKey()):super.get(e)}}class d extends o._b{ram=new l.jV;screen=new c;keyboard=new p;address=0;constructor(){super(["in[16]","load","address[15])"],["out[16]"],"Memory",[],["in","load"]),this.parts.push(this.keyboard),this.parts.push(this.screen),this.parts.push(this.ram)}tick(){const e=this.in("load").voltage();if(this.address=this.in("address").busVoltage,e){const e=this.in().busVoltage;this.address>=p.OFFSET||(this.address>=c.OFFSET?this.screen.at(this.address-c.OFFSET).busVoltage=e:this.ram.at(this.address).busVoltage=e)}}tock(){this.eval()}eval(){if(!this.ram)return;this.address=this.in("address").busVoltage;let e=0;e=this.address>=p.OFFSET?this.keyboard?.out().busVoltage??0:this.address>=c.OFFSET?this.screen?.at(this.address-c.OFFSET).busVoltage??0:this.ram?.at(this.address).busVoltage??0,this.out().busVoltage=e}in(e){if(e?.startsWith("RAM16K")){const t=(0,a.ZR)(e.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.ram.at(t)}if(e?.startsWith("Screen")){const t=(0,a.ZR)(e.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.screen.at(t)}return super.in(e)}get(e,t=0){return e.startsWith("RAM16K")?this.at(16383&t):e.startsWith("Screen")?this.at(t&8191+c.OFFSET):e.startsWith("Keyboard")?this.at(p.OFFSET):e.startsWith("Memory")?this.at(t):super.get(e,t)}at(e){return e>=p.OFFSET?this.keyboard.out():e>=c.OFFSET?this.screen.at(e-c.OFFSET):this.ram.at(e)}reset(){this.address=0,this.ram.reset(),this.screen.reset(),super.reset()}}class h extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.D}set busVoltage(e){this.cpu.D=e}}class f extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.A}set busVoltage(e){this.cpu.A=e}}class m extends o.z7{cpu;constructor(e,t){super(e),this.cpu=t}get busVoltage(){return this.cpu.PC}set busVoltage(e){this.cpu.PC=e}}class g extends o._b{_state=(0,r.p$)();get state(){return this._state}constructor(){super(["inM[16]","instruction[16]","reset"],["outM[16]","writeM","addressM[15]","pc[15]"],"CPU",[],["pc","addressM","reset"])}tick(){const[e,t]=(0,r.gV)(this.cpuInput(),this._state);this._state=e,this.out("writeM").pull(t?o.RY:o.$L),this.out("outM").busVoltage=this._state.ALU??0}tock(){if(!this._state)return;const[e,t]=(0,r.I8)(this.cpuInput(),this._state);this._state=t,this.out("addressM").busVoltage=e.addressM??0,this.out("outM").busVoltage=e.outM??0,this.out("writeM").pull(e.writeM?o.RY:o.$L),this.out("pc").busVoltage=this._state?.PC??0}cpuInput(){return{inM:this.in("inM").busVoltage,instruction:this.in("instruction").busVoltage,reset:1===this.in("reset").busVoltage}}get(e,t){return e?.startsWith("ARegister")?new f("ARegister",this._state):e?.startsWith("DRegister")?new h("DRegister",this._state):e?.startsWith("PC")?new m("PC",this._state):super.get(e,t)}reset(){this._state=(0,r.p$)(),this._state.PC=-1,super.reset()}}class y extends o.vu{cpu=new g;ram=new d;rom=new u;constructor(){super(["reset"],[]),this.wire(this.cpu,[{from:{name:"reset",start:0},to:{name:"reset",start:0}},{from:{name:"instruction",start:0},to:{name:"instruction",start:0}},{from:{name:"oldOutM",start:0},to:{name:"inM",start:0}},{from:{name:"writeM",start:0},to:{name:"writeM",start:0}},{from:{name:"addressM",start:0},to:{name:"addressM",start:0}},{from:{name:"newInM",start:0},to:{name:"outM",start:0}},{from:{name:"pc",start:0},to:{name:"pc",start:0}}]),this.wire(this.rom,[{from:{name:"pc",start:0},to:{name:"address",start:0}},{from:{name:"instruction",start:0},to:{name:"out",start:0}}]),this.wire(this.ram,[{from:{name:"newInM",start:0},to:{name:"in",start:0}},{from:{name:"writeM",start:0},to:{name:"load",start:0}},{from:{name:"addressM",start:0},to:{name:"address",start:0}},{from:{name:"oldOutM",start:0},to:{name:"out",start:0}}]);for(const e of[...this.ins.entries(),...this.outs.entries()])this.isClockedPin(e.name)&&this.clockedPins.add(e.name)}eval(){super.eval()}get(e,t){return e.startsWith("PC")||e.startsWith("ARegister")||e.startsWith("DRegister")?this.cpu.get(e):e.startsWith("RAM16K")?this.ram.get(e,t):super.get(e,t)}async load(e,t){return await this.rom.load(e,t)}}},6980:(e,t,n)=>{n.d(t,{Hs:()=>L,Mo:()=>U,M1:()=>W,KQ:()=>B});var r=n(5874),i=n(9651);class s extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[1===e&&1===t?i.RY:i.$L]}(e,t);this.out().pull(n)}}class a extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[e&t&65535]}(e,t);this.out().busVoltage=n}}class o extends i.vu{constructor(){super(["in","sel"],["a","b"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").voltage(),[n,r]=function(e,t){return[t===i.$L&&e===i.RY?i.RY:i.$L,t===i.RY&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r)}}class l extends i.vu{constructor(){super(["in","sel[2]"],["a","b","c","d"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").busVoltage,[n,r,s,a]=function(e,t){return[0===t&&e===i.RY?i.RY:i.$L,1===t&&e===i.RY?i.RY:i.$L,2===t&&e===i.RY?i.RY:i.$L,3===t&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r),this.out("c").pull(s),this.out("d").pull(a)}}class u extends i.vu{constructor(){super(["in","sel[3]"],["a","b","c","d","e","f","g","h"])}eval(){const e=this.in("in").voltage(),t=this.in("sel").busVoltage,[n,r,s,a,o,l,u,c]=function(e,t){return[0===t&&e===i.RY?i.RY:i.$L,1===t&&e===i.RY?i.RY:i.$L,2===t&&e===i.RY?i.RY:i.$L,3===t&&e===i.RY?i.RY:i.$L,4===t&&e===i.RY?i.RY:i.$L,5===t&&e===i.RY?i.RY:i.$L,6===t&&e===i.RY?i.RY:i.$L,7===t&&e===i.RY?i.RY:i.$L]}(e,t);this.out("a").pull(n),this.out("b").pull(r),this.out("c").pull(s),this.out("d").pull(a),this.out("e").pull(o),this.out("f").pull(l),this.out("g").pull(u),this.out("h").pull(c)}}function c(e,t,n){return[n===i.$L?e:t]}function p(e,t,n,r,i){const s=1&i;return 0===(2&i)?c(e,t,s):c(n,r,s)}class d extends i.vu{constructor(){super(["a","b","sel"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),n=this.in("sel").voltage(),[r]=function(e,t,n){return[n===i.$L?e:t]}(e,t,n);this.out().pull(r)}}class h extends i.vu{constructor(){super(["a[16]","b[16]","sel"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("sel").voltage(),[r]=c(e,t,n);this.out().busVoltage=r}}class f extends i.vu{constructor(){super(["a[16]","b[16]","c[16]","d[16]","sel[2]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("c").busVoltage,r=this.in("d").busVoltage,i=this.in("sel").busVoltage,[s]=p(e,t,n,r,i);this.out().busVoltage=s}}class m extends i.vu{constructor(){super(["a[16]","b[16]","c[16]","d[16]","e[16]","f[16]","g[16]","h[16]","sel[3]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,n=this.in("c").busVoltage,r=this.in("d").busVoltage,i=this.in("e").busVoltage,s=this.in("f").busVoltage,a=this.in("g").busVoltage,o=this.in("h").busVoltage,l=this.in("sel").busVoltage,[u]=function(e,t,n,r,i,s,a,o,l){const u=3&l;return 0===(4&l)?p(e,t,n,r,u):p(i,s,a,o,u)}(e,t,n,r,i,s,a,o,l);this.out().busVoltage=u}}var g=n(7844);class y extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[1===e&&1===t?i.$L:i.RY]}(e,t);this.out().pull(n)}}class v extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage;this.out().busVoltage=(0,g.xu)(e,t)}}class b extends i.vu{constructor(){super(["in"],["out"])}eval(){const e=this.in("in").voltage(),[t]=[e===i.$L?i.RY:i.$L];this.out().pull(t)}}class w extends i.vu{constructor(){super(["in[16]"],["out[16]"])}eval(){const[e]=[65535&~this.in().busVoltage];this.out().busVoltage=e}}function S(e,t){return[1===e||1===t?i.RY:i.$L]}class x extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=S(e,t);this.out().pull(n)}}class k extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[65535&(e|t)]}(e,t);this.out().busVoltage=n}}class _ extends i.vu{constructor(){super(["in[8]"],["out"],"Or8way")}eval(){const e=this.in().busVoltage,[t]=[0===(255&e)?i.$L:i.RY];this.out().pull(t)}}class I extends i.vu{constructor(){super(["a","b"],["out"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n]=function(e,t){return[e===i.RY&&t===i.$L||e===i.$L&&t===i.RY?i.RY:i.$L]}(e,t);this.out().pull(n)}}class A extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=function(e,t){return[65535&(e^t)]}(e,t);this.out().busVoltage=n}}function C(e,t){return[e+t&65535]}class E extends i.vu{constructor(){super(["a[16]","b[16]"],["out[16]"],"Add16")}eval(){const e=this.in("a").busVoltage,t=this.in("b").busVoltage,[n]=C(e,t);this.out().busVoltage=n}}var O=n(8739);class P extends i.vu{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]"],"ALU")}eval(){const e=this.in("x").busVoltage,t=this.in("y").busVoltage,n=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0),[r]=(0,O.v0)(n,e,t);this.out().busVoltage=r}}class L extends i.vu{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]","zr","ng"],"ALU")}eval(){const e=this.in("x").busVoltage,t=this.in("y").busVoltage,n=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0),[r,s]=(0,O.v0)(n,e,t),a=s===O.iI.Negative?i.RY:i.$L,o=s===O.iI.Zero?i.RY:i.$L;this.out("out").busVoltage=r,this.out("ng").pull(a),this.out("zr").pull(o)}op(){return(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage|0)}}i.vu;function R(e,t){return[1===e&&0===t||0===e&&1===t?i.RY:i.$L,1===e&&1===t?i.RY:i.$L]}class N extends i.vu{constructor(){super(["a","b"],["sum","carry"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),[n,r]=R(e,t);this.out("sum").pull(n),this.out("carry").pull(r)}}class T extends i.vu{constructor(){super(["a","b","c"],["sum","carry"])}eval(){const e=this.in("a").voltage(),t=this.in("b").voltage(),n=this.in("c").voltage(),[r,i]=function(e,t,n){const[r,i]=R(e,t),[s,a]=R(r,n),[o]=S(i,a);return[s,o]}(e,t,n);this.out("sum").pull(r),this.out("carry").pull(i)}}class M extends i.vu{constructor(){super(["in[16]"],["out[16]"],"Inc16")}eval(){const e=this.in().busVoltage,[t]=C(e,1);this.out().busVoltage=t}}var F=n(7738);const j={CPU:"CHIP CPU {\n\n IN inM[16], // M value input (M = contents of RAM[A])\n instruction[16], // Instruction for execution\n reset; // Signals whether to re-start the current\n // program (reset==1) or continue executing\n // the current program (reset==0).\n\n OUT outM[16], // M value output\n writeM, // Write to M? \n addressM[15], // Address in data memory (of M)\n pc[15]; // address of next instruction\n\n PARTS:\n Mux16(a=instruction, b=ALUoutput, sel=instruction[15], out=Ainput);\n Not(in=instruction[15], out=Ainstruction);\n Or(a=Ainstruction, b=instruction[5], out=loadA);\n ARegister(in=Ainput, load=loadA, out=Aoutput, out[0..14]=addressM);\n\n And(a=instruction[15], b=instruction[4], out=loadD);\n DRegister(in=ALUoutput, load=loadD, out=Doutput);\n\n Mux16(a=Aoutput, b=inM, sel=instruction[12], out=ALUsecondInput);\n\n ALU(x=Doutput, y=ALUsecondInput, \n zx=instruction[11], nx=instruction[10], \n zy=instruction[9], ny=instruction[8],\n f=instruction[7], no=instruction[6], \n out=ALUoutput, out=outM, ng=negative, zr=zero);\n\n And(a=instruction[15], b=instruction[3], out=writeM);\n\n Or(a=negative, b=zero, out=notPositive);\n Not(in=notPositive, out=positive);\n\n And(a=positive, b=instruction[0], out=j1);\n And(a=zero, b=instruction[1], out=j2);\n And(a=negative, b=instruction[2], out=j3);\n Or(a=j1, b=j2, out=jTemp);\n Or(a=jTemp, b=j3, out=jumpIfC);\n And(a=jumpIfC, b=instruction[15], out=jump);\n\n PC(reset=reset, inc=true, load=jump, in=Aoutput, out[0..14]=pc);\n}"};var D=n(7761),$=n(2331);class z extends i._b{constructor(e){super(["in"],["out"],e,["t"],["in"])}tick(){const e=this.in().voltage();this.pin("t").pull(e)}tock(){const e=this.pin("t").voltage();this.out().pull(e)}}var V=n(836);const U=new Map([["Nand",y],["Nand16",v],["Not",b],["Not16",w],["And",s],["And16",a],["Or",x],["Or16",k],["Or8Way",_],["XOr",I],["XOr16",A],["Xor",I],["Xor16",A],["Mux",d],["Mux16",h],["Mux4Way16",f],["Mux8Way16",m],["DMux",o],["DMux4Way",l],["DMux8Way",u],["HalfAdder",N],["FullAdder",T],["Add16",E],["Inc16",M],["ALU",L],["ALUNoStat",P],["DFF",z],["Bit",$.G],["Register",$.UZ],["ARegister",$.UZ],["DRegister",$.UZ],["PC",$.PC],["RAM8",V.Z4],["RAM64",V.JG],["RAM512",V.fn],["RAM4K",V.g0],["RAM16K",V.jV],["ROM32K",D.N4],["Screen",D.ff],["Keyboard",D.s3],["CPU",D.Z8],["Computer",D.Sc],["Memory",D.ce],["ARegister",$.s$],["DRegister",$.s$]].map((([e,t])=>[e,()=>{const n=new t;return n.name=e,n}])));function B(e){return U.has(e)}async function W(e){if(j[e]){const t=await(0,F.qg)(j[e],e);return(0,r.ys)(t)?(0,r._)(new Error((0,r._)(t).message)):t}const t=U.get(e);return t?(0,r.Ok)(t()):(0,r._)(new Error(`Chip ${e} not in builtin registry`))}},2331:(e,t,n)=>{n.d(t,{G:()=>i,PC:()=>l,UZ:()=>a,s$:()=>o});var r=n(9651);class i extends r._b{bit=r.$L;constructor(e){super(["in","load"],["out"],e,[],["in","load"])}tick(){this.in("load").voltage()===r.RY&&(this.bit=this.in().voltage())}tock(){this.out().pull(this.bit??0)}reset(){this.bit=r.$L,super.reset()}}class s extends r.z7{register;constructor(e,t){super(e),this.register=t}get busVoltage(){return 65535&this.register.bits}set busVoltage(e){this.register.bits=65535&e}}class a extends r._b{bits=0;constructor(e){super(["in[16]","load"],["out[16]"],e,[],["in","load"])}tick(){this.in("load").voltage()===r.RY&&(this.bits=65535&this.in().busVoltage)}tock(){this.out().busVoltage=65535&this.bits}get(e,t){return e===this.name?new s(this.name,this):super.get(e,t)}reset(){this.bits=0,super.reset()}}class o extends a{}class l extends r._b{bits=0;constructor(e){super(["in[16]","reset","load","inc"],["out[16]"],e,[],["in","reset","load","inc"])}tick(){this.in("reset").voltage()===r.RY?this.bits=0:this.in("load").voltage()===r.RY?this.bits=65535&this.in().busVoltage:this.in("inc").voltage()===r.RY&&(this.bits+=1)}tock(){this.out().busVoltage=65535&this.bits}get(e,t){return e===this.name?new s(this.name,this):super.get(e,t)}reset(){this.bits=0,super.reset()}}},836:(e,t,n)=>{n.d(t,{JG:()=>u,XK:()=>a,Z4:()=>l,fn:()=>c,g0:()=>p,jV:()=>d});var r=n(2469),i=n(7076),s=n(9651);class a extends s._b{width;_memory;_nextData=0;_address=0;get memory(){return this._memory}get address(){return this._address}constructor(e,t){super(["in[16]","load",`address[${e}]`],["out[16]"],t,[],["in","load"]),this.width=e,this._memory=new i.ce(Math.pow(2,this.width))}tick(){const e=this.in("load").voltage();this._address=this.in("address").busVoltage,e&&(this._nextData=this.in().busVoltage,this._memory.set(this._address,this._nextData))}tock(){this.out().busVoltage=this._memory?.get(this._address)??0}eval(){const e=this.in("address").busVoltage;this.out().busVoltage=this._memory?.get(e)??0}at(e){return(0,r.vA)(e`Request out of bounds (${e} >= ${this._memory.size})`)),new o(`${this.name}[${e}]`,e,this._memory)}get(e,t){return e===this.name?this.at(t??0):super.get(e)}reset(){this._memory.reset(),super.reset()}}class o extends s.z7{index;ram;constructor(e,t,n){super(e),this.index=t,this.ram=n}get busVoltage(){return this.ram.get(this.index)}set busVoltage(e){this.ram.set(this.index,e)}}class l extends a{constructor(){super(3,"RAM8")}}class u extends a{constructor(){super(6,"RAM64")}}class c extends a{constructor(){super(9,"RAM512")}}class p extends a{constructor(){super(12,"RAM4K")}}class d extends a{constructor(){super(14,"RAM16K")}}},9651:(e,t,n)=>{n.d(t,{$L:()=>l,KK:()=>u,RY:()=>o,_b:()=>x,ti:()=>S,vu:()=>w,xo:()=>h,z7:()=>c});var r=n(2469),i=n(742),s=n(5874),a=n(1164);const o=1,l=0;function u(e){return"false"===e||"true"===e||"0"===e||"1"===e}class c{name;width;state;next=[];constructor(e,t=1){this.name=e,this.width=t,this.state=(0,i.y)(0,this.width).map((()=>l))}ensureWidth(e){(0,r.vA)(e<=16,`Cannot widen past 16 to ${e} bits`),this.widthl))])}connect(e){this.next.push(e),e.busVoltage=this.busVoltage}pull(e,t=0){(0,r.vA)(t>=0&&tn.pull(e,t)))}voltage(e=0){return(0,r.vA)(e>=0&&e>t;this.next.forEach((e=>e.busVoltage=this.busVoltage))}get busVoltage(){return(0,i.y)(0,this.width).reduce(((e,t)=>e|this.state[t]<=0&&t+n<=e.width,`Mismatched InSubBus dimensions on ${e.name} (${n} + ${t} > ${e.width})`),this.connect(e)}pull(e,t=0){(0,r.vA)(t>=0&&t=0&&e>this.start&k(this.width)}connect(e){(0,r.vA)(this.start+this.width<=e.width,`Mismatched InSubBus connection dimensions (From ${e.name} to ${this.name})`),this.bus=e}}class d extends c{bus;start;width;constructor(e,t,n=1){super(e.name),this.bus=e,this.start=t,this.width=n,(0,r.vA)(t>=0&&n<=e.width,"Mismatched OutSubBus dimensions"),this.connect(e)}set busVoltage(e){this.bus.busVoltage=(e&k(this.width+this.start))>>this.start}get busVoltage(){return this.bus.busVoltage&k(this.width)}connect(e){(0,r.vA)(this.width<=e.width,"Mismatched OutSubBus connection dimensions"),this.bus=e}}class h extends c{value;constructor(e,t){super(e,16),this.value=t}pullHigh(e=0){}pullLow(e=0){}voltage(e=0){return 1&this.busVoltage}set busVoltage(e){}get busVoltage(){return this.value}}const f=new h("true",65535),m=new h("false",0);function g(e){const{pin:t,w:n}=e.match(/(?[a-zA-Z]+)(\[(?\d+)\])?/)?.groups;return{pin:t,width:n?Number(n):1}}class y{map=new Map;insert(e){const{name:t}=e;(0,r.vA)(!this.map.has(t),`Pins already has ${t}!`),this.map.set(t,e)}emplace(e,t){if(this.has(e))return this.get(e);{const n=new c(e,t);return this.insert(n),n}}has(e){return this.map.has(e)}get(e){return this.map.get(e)}entries(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}function v(e,t,n){return e+t<=n.width?(0,s.Ok)():(0,s._)(`Sub-bus index out of range (${n.name} has width ${n.width})`)}let b=0;class w{name;id=b++;ins=new y;outs=new y;pins=new y;insToPart=new Map;partToOuts=new Map;parts=[];clockedPins;clockSubscription;get clocked(){if(this.clockedPins.size>0)return!0;for(const e of this.parts)if(e.clocked)return!0;return!1}constructor(e,t,n,r=[],i=[]){this.name=n;for(const s of e){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.ins.insert(new c(e,t))}for(const s of t){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.outs.insert(new c(e,t))}for(const s of r){const{pin:e,width:t=1}=void 0!==s.pin?s:g(s);this.pins.insert(new c(e,t))}this.clockedPins=new Set(i),this.subscribeToClock()}subscribeToClock(){this.clockSubscription?.unsubscribe(),this.clockSubscription=a.z.subscribe((()=>this.eval()))}reset(){for(const[e,t]of this.ins)t.busVoltage=0;for(const e of this.parts)e.reset();this.eval()}in(e="in"){return(0,r.vA)(this.hasIn(e),`No in pin ${e}`),this.ins.get(e)}out(e="out"){return(0,r.vA)(this.hasOut(e),`No in pin ${e}`),this.outs.get(e)}hasIn(e){return this.ins.has(e)}hasOut(e){return this.outs.has(e)}pin(e){return(0,r.vA)(this.pins.has(e)),this.pins.get(e)}get(e,t){return this.ins.has(e)?this.ins.get(e):this.outs.has(e)?this.outs.get(e):this.pins.has(e)?this.pins.get(e):this.getBuiltin(e,t)}getBuiltin(e,t=0){if(_.includes(e))for(const n of this.parts){const r=n.get(e,t);if(r)return r}}isInPin(e){return this.ins.has(e)}isOutPin(e){return this.outs.has(e)}isExternalPin(e){return this.isInPin(e)||this.isOutPin(e)||u(e)}isInternalPin(e){return!this.isExternalPin(e)}pathExists(e,t){const n=[e];for(;n.length>0;){const e=(0,r.Z1)(n.pop());if("string"==typeof e){if(e==t)return!0;n.push(...this.insToPart.get(e)??[])}else n.push(...this.partToOuts.get(e)??[])}return!1}isClockedPin(e){return this.isInPin(e)?![...this.outs].some((([t,n])=>this.pathExists(e,t))):![...this.ins].some((([t,n])=>this.pathExists(t,e)))}hasConnection(e,t){return[...this.partToOuts.get(e)??[]].some((e=>this.insToPart.get(e)?.has(t)))}wire(e,t){for(let n=0;n({part:e,isReturning:!1})));for(;i.length>0;){const s=(0,r.Z1)(i.pop());if(s.isReturning)t.add(s.part),e.push(s.part);else if(!t.has(s.part)){if(n.has(s.part))continue;n.add(s.part),i.push({part:s.part,isReturning:!0});for(const e of this.partToOuts.get(s.part)??[])i.push(...Array.from(this.insToPart.get(e)??[]).filter((e=>!t.has(e))).map((e=>({part:e,isReturning:!1}))))}}this.parts=e.reverse()}findPin(e,t){return"true"===e||"1"===e?f:"false"===e||"0"===e?m:this.ins.has(e)?this.ins.get(e):this.outs.has(e)?this.outs.get(e):this.pins.emplace(e,t)}wireOutPin(e,t,n){const i=(0,r.Z1)(e.outs.get(t.name),(()=>`Cannot wire to missing pin ${t.name}`));t.width??=i.width;let a=this.findPin(n.name,n.width??t.width);const o=this.pins.has(a.name);if(n.width??=a.width,a instanceof h)return(0,s._)({message:"Cannot wire to constant bus",lhs:!0});if(o&&a instanceof c&&a.ensureWidth(n.start+n.width),n.start>0||n.width!==a.width){const e=v(n.start,n.width,a);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!0});a=new p(a,n.start,n.width)}if(t.start>0||t.width!==i.width){const e=v(t.start,t.width,i);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!1});a=new d(a,t.start,t.width)}if(i.connect(a),!e.clockedPins.has(i.name)){const t=this.partToOuts.get(e)??new Set;t.add(a.name),this.partToOuts.set(e,t)}return(0,s.Ok)()}wireInPin(e,t,n){let i=(0,r.Z1)(e.ins.get(t.name),(()=>`Cannot wire to missing pin ${t.name}`));t.width??=i.width;const a=this.findPin(n.name,n.width??t.width);if(n.width??=a.width,t.start>0||t.width!==i.width){const e=v(t.start,t.width,i);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!0});i=new p(i,t.start,t.width)}if(!["true","false"].includes(a.name)&&(n.start>0||n.width!==a.width)){const e=v(n.start,n.width,a);if((0,s.ys)(e))return(0,s._)({message:(0,s._)(e),lhs:!1});i=new d(i,n.start,n.width)}if(a.connect(i),!e.clockedPins.has(i.name)){const t=this.insToPart.get(a.name)??new Set;t.add(e),this.insToPart.set(a.name,t)}return(0,s.Ok)()}eval(){for(const e of this.parts)f.next.forEach((e=>e.busVoltage=f.busVoltage)),m.next.forEach((e=>e.busVoltage=m.busVoltage)),e.eval()}tick(){this.eval()}tock(){this.eval()}remove(){this.clockSubscription?.unsubscribe();for(const e of this.parts)e.remove()}async load(e,t){for(const n of this.parts)"ROM32K"===n.name&&await n.load(e,t)}}class S extends w{constructor(){super([],[]),this.outs.insert(m)}}class x extends w{get clocked(){return!0}subscribeToClock(){this.clockSubscription?.unsubscribe(),this.clockSubscription=a.z.subscribe((({level:e})=>{e===l?this.tock():this.tick()}))}remove(){this.clockSubscription?.unsubscribe(),super.remove()}reset(){super.reset(),this.tick(),this.tock()}}function k(e){return Math.pow(2,e)-1}const _=["Register","ARegister","DRegister","PC","RAM8","RAM64","RAM512","RAM4K","RAM16K","ROM32K","Screen","Keyboard","Memory"]},1164:(e,t,n)=>{n.d(t,{z:()=>B});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function s(e){var t="function"===typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"===typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"===typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(o){i={error:o}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,s=n.observers;return r||i?h:(this.currentObservers=null,s.push(e),new d((function(){t.currentObservers=null,p(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new T;return e.source=this,e},t.create=function(e,t){return new D(e,t)},t}(T),D=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return i(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:h},t}(j),$=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return i(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(j),z=n(2469),V=n(9651);let U;class B{level=V.$L;ticks=0;static get(){return void 0===U&&(U=new B),U}static subscribe(e){return B.get().$.subscribe(e)}get isHigh(){return this.level===V.RY}get isLow(){return this.level===V.$L}subject=new $({level:this.level,ticks:this.ticks});frameSubject=new j;resetSubject=new j;$=this.subject;frame$=this.frameSubject;reset$=this.resetSubject;next(){this.subject.next({level:this.level,ticks:this.ticks})}constructor(){}reset(){this.level=V.$L,this.ticks=0,this.next(),this.resetSubject.next()}tick(){(0,z.vA)(this.level===V.$L,"Can only tick up from LOW"),this.level=V.RY,this.next()}tock(){(0,z.vA)(this.level===V.RY,"Can only tock down from HIGH"),this.level=V.$L,this.ticks+=1,this.next()}toggle(){this.level===V.RY?this.tock():this.tick()}eval(){this.tick(),this.tock()}frame(){this.frameSubject.next()}toString(){return`${this.ticks}${this.level===V.RY?"+":""}`}}},8739:(e,t,n)=>{n.d(t,{Lo:()=>a,Nt:()=>l,Qv:()=>p,_0:()=>s,ft:()=>d,iI:()=>h,nf:()=>i,qn:()=>m,uW:()=>u,v0:()=>f});const r=new Set(["0","1","-1","D","A","!D","!A","-D","-A","D+1","A+1","D-1","A-1","D+A","D-A","A-D","D&A","D|A"]);function i(e){return r.has(e)||r.has(e.replace("M","A"))}const s={op:{42:"0",63:"1",58:"-1",12:"x",48:"y",13:"!x",49:"!y",15:"-x",51:"-y",31:"x+1",55:"y+1",14:"x-1",50:"y-1",2:"x+y",19:"x-y",7:"y-x",0:"x&y",21:"x|y"}},a={asm:{0:42,1:63,"-1":58,D:12,A:48,"!D":13,"!A":49,"-D":15,"-A":51,"D+1":31,"A+1":55,"D-1":14,"A-1":50,"D+A":2,"D-A":19,"A-D":7,"D&A":0,"D|A":21},op:{42:"0",63:"1",58:"-1",12:"D",48:"A",13:"!D",49:"!A",15:"-D",51:"-A",31:"D+1",55:"A+1",14:"D-1",50:"A-1",2:"D+A",19:"D-A",7:"A-D",0:"D&A",21:"D|A"},getOp:e=>a.asm[e.replace("M","A")]},o=new Set(["","M","D","MD","A","AM","AD","AMD"]);function l(e){return o.has(e)}const u={asm:{"":0,M:1,D:2,MD:3,A:4,AM:5,AD:6,AMD:7},op:{0:"",1:"M",2:"D",3:"MD",4:"A",5:"AM",6:"AD",7:"AMD"}},c=new Set(["","JGT","JEQ","JGE","JLT","JNE","JLE","JMP"]);function p(e){return c.has(e)}const d={asm:{"":0,JGT:1,JEQ:2,JGE:3,JLT:4,JNE:5,JLE:6,JMP:7},op:{0:"",1:"JGT",2:"JEQ",3:"JGE",4:"JLT",5:"JNE",6:"JLE",7:"JMP"}},h={1:"Positive",0:"Zero",15:"Negative",Positive:1,Zero:0,Negative:15};function f(e,t,n){let r=0;switch(e){case 42:r=0;break;case 63:r=1;break;case 58:r=-1;break;case 12:r=t;break;case 48:r=n;break;case 13:r=~t;break;case 49:r=~n;break;case 15:r=-t;break;case 51:r=-n;break;case 31:r=t+1;break;case 55:r=n+1;break;case 14:r=t-1;break;case 50:r=n-1;break;case 2:r=t+n;break;case 19:r=t-n;break;case 7:r=n-t;break;case 0:r=t&n;break;case 21:r=t|n}r&=65535;return[r,0===r?h.Zero:32768&r?h.Negative:h.Positive]}function m(e,t,n){32&e&&(t=0),16&e&&(t=65535&~t),8&e&&(n=0),4&e&&(n=65535&~n);let r=65535&(2&e?t+n:t&n);1&e&&(r=65535&~r);return[r,0===r?h.Zero:32768&r?h.Negative:h.Positive]}},7721:(e,t,n)=>{n.d(t,{D4:()=>o,I8:()=>u,Z8:()=>c,gV:()=>l,p$:()=>s});var r=n(8739),i=n(7076);function s(){return{A:0,D:0,PC:0,ALU:0,flag:r.iI.Zero}}const a={c:32768,x1:36864,x2:36864,am:36864,op:4032,d1:32800,d2:32784,d3:32776,j1:32769,j2:32770,j3:32772};function o(e){function t(t){return(e&t)===t}return{c:t(a.c),x1:t(a.x1),x2:t(a.x2),am:t(a.am),op:(e&a.op)>>6,d1:t(a.d1),d2:t(a.d2),d3:t(a.d3),j1:t(a.j1),j2:t(a.j2),j3:t(a.j3)}}function l({inM:e,instruction:t},{A:n,D:i,PC:s}){const a=o(t),l=a.am?e:n,[u,c]=(0,r.v0)(a.op,i,l);return a.d2&&(i=u),[{A:n,D:i,PC:s+1,ALU:u,flag:c},a.d3,u]}function u({inM:e,instruction:t,reset:n},{A:i,D:s,PC:a,ALU:l,flag:u}){const c=o(t),p=c.j1&&u===r.iI.Positive,d=c.j2&&u===r.iI.Zero,h=c.j3&&u===r.iI.Negative;a=n?0:p||d||h?i:a,c.c?c.d1&&(i=l):i=32767&t;const f=c.am?e:i,m=(0,r.v0)(c.op,s,f);l=m[0],u=m[1];return[{addressM:i,outM:l,writeM:c.d3},{A:i,D:s,ALU:l,flag:u,PC:a}]}class c{RAM;ROM;Screen;Keyboard;#e=0;#t=0;#n=0;#r={A:0,D:0,PC:0,ALU:0,flag:r.iI.Zero};get state(){return this.#r}get PC(){return this.#e}get A(){return this.#t}get D(){return this.#n}setA(e){this.#t=e}setD(e){this.#n=e}setPC(e){this.#e=e}constructor({RAM:e=new i.XK,ROM:t}){this.RAM=e,this.ROM=t,this.Screen=new i.qN(this.RAM,i.RL,i.L7),this.Keyboard=new i.PC(this.RAM)}reset(){this.#e=0,this.#t=0,this.#n=0}tick(){const e=this.#t,t={inM:this.RAM.get(this.#t),instruction:this.ROM.get(this.#e),reset:!1},[n,i,s]=l(t,{A:this.#t,D:this.#n,PC:this.#e,ALU:this.#n,flag:r.iI.Zero});i&&this.RAM.set(e,s);const[a,{A:o,D:c,PC:p}]=u(t,n);this.#t=o,this.#n=c,this.#e=p}}},7076:(e,t,n)=>{n.d(t,{L7:()=>l,PC:()=>m,RL:()=>p,XK:()=>y,ce:()=>h,dh:()=>u,hR:()=>o,ky:()=>d,n9:()=>g,pc:()=>c,qN:()=>f});var r=n(2469),i=n(6983),s=n(7496),a=n(7844);const o=["bin","dec","hex","asm"],l=16384,u=256,c=32,p=u*c,d=24576;class h{memory;get size(){return this.memory.length}constructor(e){this.memory=new Int16Array(e)}get(e){return e<0||e>=this.size?65535:this.memory[e]??0}set(e,t){e>=0&&et))}}class f{parent;size;offset;constructor(e,t,n){this.parent=e,this.size=t,this.offset=n}get(e){return e<0||e>=this.size?65535:this.parent.get(this.offset+e)}set(e,t,n=!0){e>=0&&e=0&&et))}}class m extends f{constructor(e){super(e,1,24576)}getKey(){return this.get(0)}setKey(e){this.set(0,65535&e)}clearKey(){this.set(0,0)}}class g extends h{static SIZE=32768;constructor(e){if(e){const t=new Int16Array(g.SIZE);t.set(e),super(t)}else super(g.SIZE)}}class y extends h{keyboard=new f(this,1,d);screen=new f(this,p,l);static SIZE=24577;constructor(){super(y.SIZE)}}},6983:(e,t,n)=>{n.d(t,{Hh:()=>i});var r=n(9547);async function i(e,t){if(t.endsWith(".hack"))return async function(e,t){return r.aU(await e.readFile(t))}(e,t);if(t.endsWith(".asm"))return async function(e,t){return r.aY(await e.readFile(t))}(e,t);throw new Error(`Cannot load file without hack or asm extension ${t}`)}},4666:(e,t,n)=>{n.d(t,{y0:()=>b,EU:()=>f,J$:()=>d,ld:()=>m});var r=n(2469),i=n(8739),s=n(7076),a=n(7496),o=n(3977),l=n(5874);const u='ASM <: Base {\n Root := ASM\n ASM = intermediateInstruction* instruction?\n \n instruction = label|aInstruction|cInstruction\n intermediateInstruction = instruction space+\n\n label = openParen identifier closeParen\n aInstruction = at (identifier | decNumber)\n cInstruction = assign? op jmp?\n\n assignChar = "A" | "M" | "D"\n opChar = assignChar | "0" | "1" | "!" | "-" | "+" | "|" | "&"\n \n assign = assignChar+ equal\n op = opChar+\n\n jmp = semi ("JGT" | "JEQ" | "JGE" | "JLT" | "JNE" | "JLE" | "JMP")\n}';const c=(0,n(9563).qN)(u,o.lN),p=c.extendSemantics(o.JE);function d(e){return"A"==e.type&&void 0!==e.value}function h(e){return"A"==e.type&&void 0!==e.label}function f(e,t){let n=16;const i=new Map([["R0",0],["R1",1],["R2",2],["R3",3],["R4",4],["R5",5],["R6",6],["R7",7],["R8",8],["R9",9],["R10",10],["R11",11],["R12",12],["R13",13],["R14",14],["R15",15],["SP",0],["LCL",1],["ARG",2],["THIS",3],["THAT",4],["SCREEN",s.L7],["KBD",s.ky]]);const a=[];let u=0;for(const r of e.instructions)if("L"!==r.type)u+=1,"A"===r.type&&h(r)&&a.push(r);else{if(i.has(r.label))return(0,l._)((0,o.$5)(`Duplicate label ${r.label}`,r.span));i.set(r.label,u),t?.(r.label,u,!1)}return a.forEach((function(e){const s=(a=e.label,i.has(a)||(i.set(a,n),t?.(a,n,!0),n+=1),(0,r.Z1)(i.get(a),`Label not in symbols: ${a}`));var a;e.value=s,delete e.label})),(0,l.Ok)()}p.addAttribute("root",{Root(e){return this.asm}}),p.addAttribute("asm",{ASM(e,t){const n=e.children.map((e=>e.intermediateInstruction))??[];return{instructions:t.child(0)?[...n,t.child(0).instruction]:n}}}),p.addAttribute("intermediateInstruction",{intermediateInstruction:(e,t)=>e.instruction}),p.addAttribute("instruction",{aInstruction(e,t){return g(t.value,(0,o.Ln)(this.source))},cInstruction(e,t,n){const r=function(e){let t=e.child(0)?.child(0)?.sourceString??"";if("DM"==t&&(t="MD"),"ADM"==t&&(t="AMD"),""!=t&&!(0,i.Nt)(t)){const n=t.split("").reverse().join(""),r=(0,i.Nt)(n)?`. Did you mean ${n}?`:"";throw(0,o.$5)(`Invalid ASM target: ${t}${r}`,(0,o.Ln)(e.source))}return t}(e),s=function(e){const t=e.sourceString;if(!(0,i.nf)(t)){const n=t.split("").reverse().join(""),r=(0,i.nf)(n)?`. Did you mean ${n}?`:"";throw(0,o.$5)(`Invalid ASM value: ${e.sourceString}${r}`,(0,o.Ln)(e.source))}return t}(t),a=n.child(0)?.child(1)?.sourceString??"";return y(r,s,a,(0,o.Ln)(this.source))},label(e,{name:t},n){return v(t,(0,o.Ln)(this.source))}});function m(e){if("A"===e.type){if(h(e))throw new Error("ASM Emitting unfilled A instruction");return e.value}if("C"===e.type)return(0,a.m)(e.isM,e.op,e.store??0,e.jump??0)}const g=(e,t)=>"string"===typeof e?{type:"A",label:e,span:t}:{type:"A",value:e,span:t},y=(e,t,n,r)=>{const s={type:"C",op:i.Lo.getOp(t),isM:t.includes("M"),span:r};return n&&(s.jump=i.ft.asm[n]),e&&(s.store=i.uW.asm[e]),s},v=(e,t)=>({type:"L",label:e,span:t}),b={grammar:u,semantics:p,parser:c,parse:(0,o.Q5)(c,p),passes:{fillLabel:f,emit:function(e){return e.instructions.map(m).filter((e=>void 0!==e))}},A:g,C:y,AC:(e,t,n,r)=>[g(e),y(t,n,r)],L:v}},3977:(e,t,n)=>{n.d(t,{JE:()=>o,$5:()=>u,lN:()=>a,Q5:()=>c,Ln:()=>p});var r=n(5874),i=n(9563),s=n(7844);const a={Base:(0,i.qN)('\nBase {\n Root = Value*\n\n At = at\n Bang = bang\n Bar = bar\n CloseAngle = closeAngle\n CloseBrace = closeBrace\n CloseParen = closeParen\n CloseSquare = closeSquare\n Comma = comma\n Dollar = dollar\n Dot = dot\n DoubleQuote = doubleQuote\n Equal = equal\n OpenAngle = openAngle\n OpenBrace = openBrace\n OpenParen = openParen\n OpenSquare = openSquare\n Percent = percent\n Semi = semi\n Underscore = underscore\n\n at = "@"\n bang = "!"\n bar = "|"\n closeAngle = ">"\n closeBrace = "}"\n closeParen = ")"\n closeSquare = "]"\n comma = ","\n dollar = "$"\n dot = "."\n doubleQuote = "\\""\n equal = "="\n minus = "-"\n newline = "\\r"? "\\n"\n openAngle = "<"\n openBrace = "{"\n openParen = "("\n openSquare = "["\n percent = "%"\n semi = ";"\n underscore = "_"\n\n Value = identifier | number | boolean\n\n boolean = true | false\n True = true\n False = false\n true = "true"\n false = "false"\n\n Name = identifier\n identifier = (letter|underscore|dot|dollar) (alnum|underscore|dot|dollar)*\n\n Number = number\n number = hexNumber | decNumber | binNumber\n binNumber = ("%B") ("0"|"1")+\n hexNumber = ("%X") hexDigit+\n decNumber = ("%D")? (wholeDec | realDec)\n wholeDec = minus? digit+\n realDec = minus? digit* "." digit+\n\n String = DoubleQuote (~doubleQuote any)* doubleQuote\n \n spaces := (lineComment | comment | space)*\n commentStart = "/*"\n commentEnd = "*/"\n comment = commentStart (~commentEnd any)* commentEnd\n lineCommentStart = "//"\n lineComment = lineCommentStart (~"\\n" any)*\n\n List = NonemptyListOf sep?\n EmptyList = EmptyList sep?\n}')},o=a.Base.createSemantics();o.extendOperation("asIteration",{List:(e,t)=>e.asIteration()}),o.addAttribute("value",{decNumber:(e,t)=>(0,s.ZR)(t.sourceString),wholeDec:(e,t)=>(0,s.ZR)(t.sourceString),binNumber:(e,t)=>(0,s.Yp)(t.sourceString),hexNumber:(e,t)=>(0,s.l8)(t.sourceString),Number:e=>e.value,Name:e=>e.name,identifier(e,t){return this.sourceString}}),o.addAttribute("name",{identifier(e,t){return this.sourceString},Name(e){return this.child(0)?.name}}),o.addAttribute("String",{String:(e,t,n)=>t.sourceString});const l="HDL statement has a syntax error";function u(e,t){const n=e.match(/Line \d+, col \d+: (?.*)/),r=n?.groups?.message?n.groups.message:e;return{message:`${void 0!=t?.line?`Line ${t.line}: `:""}${r}`,span:t}}function c(e,t,n=(({root:e})=>e)){return function(i){try{const s=e.match(i);if(s.succeeded()){const e=t(s),i=n(e);return(0,r.Ok)(i)}return(0,r._)(u(s.shortMessage??l,p(s.getInterval())))}catch(s){return(0,r._)(s)}}}function p(e){return{start:e.startIdx,end:e.endIdx,line:e.getLineAndColumn().lineNum}}},7589:(e,t,n)=>{n.d(t,{dl:()=>l});var r=n(9563),i=n(3977);const s="\nCmp <: Base {\n Root := line*\n line = bar cell+ newline?\n cell = cellvalue bar\n cellvalue = (~(bar|newline) any)*\n}",a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.addAttribute("cell",{cell:(e,t)=>e.sourceString}),o.addAttribute("line",{line:(e,t,n)=>t.children.map((e=>e.cell))}),o.addAttribute("root",{Root:e=>e.children.map((e=>e.line))});const l={grammar:s,semantics:o,parser:a,parse:(0,i.Q5)(a,o)}},5005:(e,t,n)=>{n.d(t,{xP:()=>l});var r=n(9563),i=n(3977);const s='\nHdl <: Base{\n Root := Chip\n identifier := (letter|underscore) (alnum|underscore)*\n Name := identifier\n Chip = "CHIP" Name OpenBrace ChipBody CloseBrace\n ChipBody = InList? OutList? PartList ClockedList?\n InList = "IN" PinList Semi\n OutList = "OUT" PinList Semi\n PartList = BuiltinPart | Parts\n PinList = List\n PinDecl = Name PinWidth?\n PinWidth = OpenSquare decNumber CloseSquare\n BuiltinPart = "BUILTIN" Semi\n Parts = "PARTS:" Part*\n Part = Name "(" Wires ")" Semi\n Wires = List\n Wire = WireSide Equal (WireSide | True | False) \n WireSide = Name SubBus? \n SubBus = OpenSquare decNumber subBusRest? CloseSquare\n subBusRest = ".." decNumber\n ClockedList = "CLOCKED" SimplePinList Semi\n SimplePinList = List\n}',a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.addAttribute("SubBus",{SubBus(e,t,n,r){const i=t.value;return{start:i,end:n.child(0)?.child(1)?.value??i}}}),o.addAttribute("WireSide",{WireSide({name:e},t){const{start:n,end:r}=t.child(0)?.SubBus??{start:void 0,end:void 0};return{pin:e,start:n,end:r,span:(0,i.Ln)(this.source)}}}),o.addAttribute("Wire",{Wire(e,t,n){const r=n.isTerminal()?{pin:n.sourceString}:n.WireSide;return{lhs:e.WireSide,rhs:r}}}),o.addAttribute("Wires",{Wires:e=>e.asIteration().children.map((e=>e.Wire))}),o.addAttribute("Part",{Part({name:e},t,{Wires:n},r,s){return{name:e,wires:n,span:(0,i.Ln)(this.source)}}}),o.addAttribute("Parts",{Parts:(e,t)=>t.children.map((e=>e.Part)),BuiltinPart:(e,t)=>"BUILTIN"}),o.addAttribute("PartList",{PartList:e=>e.Parts}),o.addAttribute("Clocked",{ClockedList:(e,t,n)=>t.asIteration().children.map((({sourceString:e})=>e))??[]}),o.addAttribute("PinDecl",{PinDecl:({name:e},t)=>({pin:e,width:t.child(0)?.child(1)?.value??1})}),o.addAttribute("PinList",{PinList:e=>e.asIteration().children.map((e=>e.PinDecl))}),o.addAttribute("Chip",{Chip:(e,t,n,r,s)=>({name:{value:t.sourceString,span:(0,i.Ln)(t.source)},ins:r.child(0).child(0)?.child(1)?.PinList??[],outs:r.child(1).child(0)?.child(1)?.PinList??[],parts:r.child(2).PartList??[],clocked:r.child(3).child(0)?.Clocked})}),o.addAttribute("Root",{Root:e=>e.child(0)?.Chip});const l={parser:a,grammar:s,semantics:o,parse:(0,i.Q5)(a,o,(e=>e.Chip))}},6554:(e,t,n)=>{n.d(t,{uG:()=>l});var r=n(9563),i=n(3977);const s='\nTst <: Base {\n Root := Tst\n Tst = (TstStatement | TstRepeat | TstWhile)+\n\n TstRepeat = Repeat Number? OpenBrace TstCommand+ CloseBrace\n TstWhile = While Condition OpenBrace TstCommand+ CloseBrace\n TstStatement = TstCommand\n\n TstCommand = TstOperation Separator\n Separator = (Semi | Bang | Comma)\n\n TstOperation =\n | TstFileOperation\n | TstOutputListOperation\n | TstEvalOperation\n | TstSetOperation\n | TstOutputOperation\n | TstEchoOperation\n | TstClearEchoOperation\n | TstLoadROMOperation\n\n TstLoadROMOperation = ROM32K Load FileName\n TstFileOperation = FileOperation FileName?\n TstOutputListOperation = "output-list" OutputFormat+\n OutputFormat = Name Index? FormatSpec?\n FormatSpec = percent FormatStyle wholeDec dot wholeDec dot wholeDec\n TstSetOperation = Set Name Index? Number\n Index = OpenSquare wholeDec? CloseSquare\n Condition = Value CompareOp Value\n TstEvalOperation = Eval | TickTock | Tick | Tock | VmStep\n TstOutputOperation = Output\n TstEchoOperation = Echo String\n TstClearEchoOperation = ClearEcho\n\n FileName = Name\n FileOperation = "load" | "output-file" | "compare-to"\n\n Set = "set"\n Eval = "eval"\n Tick = "tick"\n Tock = "tock"\n TickTock = "ticktock"\n VmStep = "vmstep"\n Echo = "echo"\n Repeat = "repeat"\n ClearEcho = "clear-echo"\n Output = "output"\n OutputList = "output-list"\n FormatStyle = "B"|"D"|"S"|"X"\n ROM32K = "ROM32K"\n Load = "load"\n While = "while"\n\n CompareOp = "<>" | "<=" | ">=" | "=" | "<" | ">"\n}',a=(0,r.qN)(s,i.lN),o=a.extendSemantics(i.JE);o.extendAttribute("value",{Index:(e,t,n)=>t?.child(0)?.value??-1}),o.extendAttribute("name",{FileName:({name:e})=>e}),o.addAttribute("index",{Index:(e,t,n)=>t.child(0)?.value??0}),o.addAttribute("formatSpec",{FormatSpec:(e,{sourceString:t},{value:n},r,{value:i},s,{value:a})=>({style:t,width:i,lpad:n,rpad:a})}),o.addAttribute("format",{OutputFormat:({name:e},t,n)=>({id:e,builtin:void 0!==t?.child(0),address:t?.child(0)?.value??-1,format:n?.child(0)?.formatSpec})}),o.addAttribute("operation",{TstEvalOperation:e=>({op:e.sourceString}),TstOutputOperation:e=>({op:"output"}),TstOutputListOperation:(e,t)=>({op:"output-list",spec:t.children.map((e=>e.format))}),TstSetOperation(e,{name:t},n,{value:r}){const i={op:"set",id:t,value:r},s=n.child(0)?.child(1)?.child(0);return s&&(i.index=s.value),i},TstEchoOperation:(e,t)=>({op:"echo",message:t.String}),TstClearEchoOperation:e=>({op:"clear-echo"}),TstLoadROMOperation:(e,t,{name:n})=>({op:"loadRom",file:n}),TstFileOperation:(e,t)=>({op:e.sourceString,file:t?.sourceString})}),o.addAttribute("command",{TstCommand(e,t){return{op:e.operation,separator:t.sourceString,span:(0,i.Ln)(this.source)}}}),o.addAttribute("condition",{Condition:({value:e},{sourceString:t},{value:n})=>({left:e,right:n,op:t})}),o.addAttribute("statement",{TstWhile(e,t,n,r,s){return{statements:r.children.map((e=>e.command)),condition:t.condition,span:(0,i.Ln)(this.source)}},TstRepeat(e,t,n,r,s){return{statements:r.children.map((e=>e.command)),count:t.sourceString?Number(t.sourceString):-1,span:(0,i.Ln)(this.source)}},TstStatement:e=>e.command}),o.addAttribute("tst",{Tst:e=>({lines:e.children.map((e=>e.statement))})}),o.addAttribute("root",{Root:({tst:e})=>e});const l={grammar:s,semantics:o,parser:a,parse:(0,i.Q5)(a,o)}},9547:(e,t,n)=>{n.d(t,{aU:()=>o,aY:()=>a,yt:()=>l});var r=n(5874),i=n(4666),s=n(7844);async function a(e){const t=(0,r.oA)(i.y0.parse(e));return i.y0.passes.fillLabel(t),i.y0.passes.emit(t)}async function o(e){return e.split("\n").filter((e=>""!==e.trim())).map(s.Yp)}async function l(e){return e.split("\n").filter((e=>""!==e.trim())).map(s._Q)}},9976:(e,t,n)=>{n.d(t,{G:()=>p});var r=n(2469),i=n(1106),s=n(6418),a=n(4867),o=n(8783);function l(e){return void 0!==e.op}function u(e){return void 0!==e.condition}function c(e){const{op:t}=e;switch(t){case"tick":return new i.IJ;case"tock":return new i.CX;case"ticktock":return new s.z;case"eval":return new i.Nq;case"vmstep":return new o.a;case"output":return new a.ik;case"set":return new a.jl(e.id,e.value,e.index);case"output-list":return new a.Ad(e.spec);case"echo":return new a.S0(e.message);case"clear-echo":return new a.Tn;case"loadRom":return new a.fK(e.file);case"load":return new a.hh(e.file);case"output-file":case"compare-to":return;default:(0,r.H8)(t,`Unknown tst operation ${t}`)}}function p(e,t){let n,r=[],i=e,s=[];for(const o of t.lines){if(l(o))i=e,s=[o];else{const t=u(o)?new a.eB(new a.kW(o.condition.left,o.condition.right,o.condition.op)):new a.UM(o.count);t.span=o.span,e.addInstruction(t),i=t,s=o.statements}for(const e of s){const t=c(e.op);if(void 0!==t&&(void 0===n?n=o.span:n.end=o.span.end,i.addInstruction(t),r.push(t)),","!=e.separator){";"==e.separator?i.addInstruction(new a.fe(n??e.span)):"!"==e.separator&&i.addInstruction(new a.Ge(n??e.span));for(const t of r)t.span=n??e.span;n=void 0,r=[]}}}return e.reset(),e}},1106:(e,t,n)=>{n.d(t,{BX:()=>o,CX:()=>c,IJ:()=>u,Nq:()=>l});var r=n(9651),i=n(1164),s=n(9976),a=n(9937);class o extends a.V{chip=new r.ti;get chipId(){return this.chip.id}clock=i.z.get();static from(e,t){const n=new o(t);return(0,s.G)(n,e)}with(e){return this.chip=e,this}hasVar(e){return"time"===e||(e=`${e}`,this.chip.hasIn(e)||this.chip.hasOut(e))}getVar(e,t){if("time"===(e=`${e}`))return this.clock.toString();const n=this.chip.get(e,t);return n?n instanceof r.z7?n.busVoltage:n.voltage():0}getWidth(e,t){const n=this.chip.get(e,t);return n?n.width:0}setVar(e,t,n){const i=this.chip.get(e,n);i instanceof r.z7?i.busVoltage=t:i?.pull(0===t?r.$L:r.RY)}eval(){this.chip.eval()}tick(){this.chip.eval(),this.clock.tick()}tock(){this.chip.eval(),this.clock.tock()}async loadROM(e){await this.chip.load(this.fs,e)}async run(){this.clock.reset(),await super.run()}}class l{_chipTestInstruction_=!0;async do(e){e.eval()}*steps(){yield this}}class u{_chipTestInstruction_=!0;async do(e){e.tick()}*steps(){yield this}}class c{_chipTestInstruction_=!0;async do(e){e.tock()}*steps(){yield this}}},6418:(e,t,n)=>{n.d(t,{b:()=>o,z:()=>l});var r=n(7721),i=n(7076),s=n(9976),a=n(9937);class o extends a.V{cpu;ticks=0;static from(e,t,n){const r=new o(t,n);return(0,s.G)(r,e)}constructor(e=new i.n9,t){super(t),this.cpu=new r.Z8({ROM:e}),this.reset()}reset(){return super.reset(),this.cpu.reset(),this.ticks=0,this}hasVar(e){return"number"!==typeof e&&!("A"!==e&&"D"!==e&&"PC"!==e&&"time"!==e&&!e.startsWith("RAM"))}getVar(e,t){switch(e){case"A":return this.cpu.A;case"D":return this.cpu.D;case"PC":return this.cpu.PC;case"time":return this.ticks;case"RAM":return void 0===t?0:this.cpu.RAM.get(t)}if("number"===typeof e)return 0;if(e.startsWith("RAM")){const t=Number(e.substring(4,e.length-1));return this.cpu.RAM.get(t)}return 0}getWidth(e,t){return 16}setVar(e,t,n){switch(e){case"A":this.cpu.setA(t);break;case"D":this.cpu.setD(t);break;case"PC":this.cpu.setPC(t);break;case"RAM":this.cpu.RAM.set(n??0,t)}}ticktock(){this.ticks+=1,this.cpu.tick()}async loadROM(e){await this.cpu.ROM.load(this.fs,e)}}class l{_cpuTestInstruction_=!0;async do(e){e.ticktock()}*steps(){yield this}}},4867:(e,t,n)=>{n.d(t,{Ad:()=>l,Ge:()=>s,S0:()=>h,Tn:()=>f,UM:()=>c,eB:()=>d,fK:()=>m,fe:()=>i,hh:()=>g,ik:()=>o,jl:()=>a,kW:()=>p});class r{span;constructor(e){this.span=e}async do(){}*steps(){yield this}}class i extends r{}class s extends r{}class a{variable;value;index;constructor(e,t,n){this.variable=e,this.value=t,this.index=n}async do(e){e.setVar(this.variable,this.value,this.index)}*steps(){yield this}}class o{async do(e){e.output()}*steps(){yield this}}class l{outputs=[];constructor(e=[]){for(const t of e)this.addOutput(t)}addOutput(e){this.outputs.push({id:e.id,style:e.format?.style??"B",len:e.format?.width??-1,lpad:e.format?.lpad??1,rpad:e.format?.rpad??1,builtin:e.builtin,address:e.address})}async do(e){e.outputList(this.outputs),e.header()}*steps(){yield this}}class u{instructions=[];span;addInstruction(e){this.instructions.push(e)}async do(e){for(const t of this.instructions)t.do(e)}*steps(e){yield this}}class c extends u{repeat;constructor(e){super(),this.repeat=e}async do(){}*innerSteps(e){for(const t of this.instructions)yield*t.steps(e)}*steps(e){if(-1===this.repeat)for(yield this;;)yield*this.innerSteps(e);else for(let t=0;t":return`${t}`!==`${n}`}else switch(this.op){case"<":return t":return t>n;case">=":return t>=n;case"=":return t===n;case"<>":return t!==n}return!1}}class d extends u{condition;constructor(e){super(),this.condition=e}*steps(e){for(;this.condition.check(e);){yield this;for(const t of this.instructions)yield*t.steps(e)}}}class h{content;constructor(e){this.content=e}async do(e){e.echo(this.content)}*steps(){yield this}}class f{async do(e){e.clearEcho()}*steps(){yield this}}class m{file;constructor(e){this.file=e}async do(e){e.fs.pushd("/samples"),await e.loadROM(this.file),e.fs.popd()}*steps(){yield this}}class g{file;constructor(e){this.file=e}async do(e){await e.load(this.file)}*steps(){yield this}}},9937:(e,t,n)=>{n.d(t,{V:()=>l});var r=n(2469),i=n(4544),s=n(7844);class a{variable;fmt;lPad;rPad;len;index;builtin;constructor(e,t="%B1.1.1",n,i,s,a,o){if(this.variable=e,t.startsWith("%")&&void 0===n&&void 0===i&&void 0===s){const{fmt:e,lPad:n,rPad:r,len:i}=t.match(/^%(?[BDXS])(?\d+)\.(?