From 63c28f21dcb543991fe98cb7504a676d1b6a4ba5 Mon Sep 17 00:00:00 2001 From: Neta London Date: Tue, 10 Oct 2023 12:30:40 +0300 Subject: [PATCH] Update build --- asset-manifest.json | 10 +++++----- chip/index.html | 2 +- guide/index.html | 2 +- index.html | 2 +- .../{605.bdf4e452.chunk.js => 605.764609f0.chunk.js} | 4 ++-- static/js/605.764609f0.chunk.js.map | 1 + static/js/605.bdf4e452.chunk.js.map | 1 - static/js/{main.7fd77d22.js => main.f457f1b6.js} | 6 +++--- ...d22.js.LICENSE.txt => main.f457f1b6.js.LICENSE.txt} | 0 .../js/{main.7fd77d22.js.map => main.f457f1b6.js.map} | 2 +- util/index.html | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) rename static/js/{605.bdf4e452.chunk.js => 605.764609f0.chunk.js} (71%) create mode 100644 static/js/605.764609f0.chunk.js.map delete mode 100644 static/js/605.bdf4e452.chunk.js.map rename static/js/{main.7fd77d22.js => main.f457f1b6.js} (99%) rename static/js/{main.7fd77d22.js.LICENSE.txt => main.f457f1b6.js.LICENSE.txt} (100%) rename static/js/{main.7fd77d22.js.map => main.f457f1b6.js.map} (99%) diff --git a/asset-manifest.json b/asset-manifest.json index e549497f..10fe9eb7 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,10 +1,10 @@ { "files": { "main.css": "/web-ide/static/css/main.2f41c32c.css", - "main.js": "/web-ide/static/js/main.7fd77d22.js", + "main.js": "/web-ide/static/js/main.f457f1b6.js", "static/js/2.0c1eab19.chunk.js": "/web-ide/static/js/2.0c1eab19.chunk.js", "static/css/605.17e509d9.chunk.css": "/web-ide/static/css/605.17e509d9.chunk.css", - "static/js/605.bdf4e452.chunk.js": "/web-ide/static/js/605.bdf4e452.chunk.js", + "static/js/605.764609f0.chunk.js": "/web-ide/static/js/605.764609f0.chunk.js", "static/js/506.f6bf6957.chunk.js": "/web-ide/static/js/506.f6bf6957.chunk.js", "static/js/568.4e6a571b.chunk.js": "/web-ide/static/js/568.4e6a571b.chunk.js", "static/js/277.355c3689.chunk.js": "/web-ide/static/js/277.355c3689.chunk.js", @@ -16,10 +16,10 @@ "static/js/356.1228c852.chunk.js": "/web-ide/static/js/356.1228c852.chunk.js", "index.html": "/web-ide/index.html", "main.2f41c32c.css.map": "/web-ide/static/css/main.2f41c32c.css.map", - "main.7fd77d22.js.map": "/web-ide/static/js/main.7fd77d22.js.map", + "main.f457f1b6.js.map": "/web-ide/static/js/main.f457f1b6.js.map", "2.0c1eab19.chunk.js.map": "/web-ide/static/js/2.0c1eab19.chunk.js.map", "605.17e509d9.chunk.css.map": "/web-ide/static/css/605.17e509d9.chunk.css.map", - "605.bdf4e452.chunk.js.map": "/web-ide/static/js/605.bdf4e452.chunk.js.map", + "605.764609f0.chunk.js.map": "/web-ide/static/js/605.764609f0.chunk.js.map", "506.f6bf6957.chunk.js.map": "/web-ide/static/js/506.f6bf6957.chunk.js.map", "568.4e6a571b.chunk.js.map": "/web-ide/static/js/568.4e6a571b.chunk.js.map", "277.355c3689.chunk.js.map": "/web-ide/static/js/277.355c3689.chunk.js.map", @@ -32,6 +32,6 @@ }, "entrypoints": [ "static/css/main.2f41c32c.css", - "static/js/main.7fd77d22.js" + "static/js/main.f457f1b6.js" ] } \ No newline at end of file diff --git a/chip/index.html b/chip/index.html index 89f517e8..9dd44f73 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/guide/index.html b/guide/index.html index 89f517e8..9dd44f73 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 89f517e8..9dd44f73 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/static/js/605.bdf4e452.chunk.js b/static/js/605.764609f0.chunk.js similarity index 71% rename from static/js/605.bdf4e452.chunk.js rename to static/js/605.764609f0.chunk.js index d1941113..f2059550 100644 --- a/static/js/605.bdf4e452.chunk.js +++ b/static/js/605.764609f0.chunk.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[605],{9605:function(e,t,n){n.r(t),n.d(t,{Chip:function(){return Jt},default:function(){return Gt}});var r=n(2951),i=n(1976),o=n(3243),a=n(7597),s=n(7591),c=n(4337),u=n(1092),l=n(7791),d=n(1026),f=n(8061),p=n(6167),h=n(649),v=n(7878),m=n(3300),g=n(3118),x=n(7039),b=n(3116),j=n(6329),y=n(6693),k=n(134),C=n(326),Z=function(e){var t,n=e.A,r=e.op,i=e.D,o=e.out,a=e.flag;return(0,v.jsxs)("div",{children:[(0,v.jsx)("span",{children:"ALU"}),(0,v.jsxs)("dl",{children:[(0,v.jsx)("dt",{children:"A"})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(n)}),(0,v.jsx)("dt",{children:"op"})," ",(0,v.jsx)("dd",{children:null!==(t=y.PH.op[r])&&void 0!==t?t:"(??)"}),(0,v.jsx)("dt",{children:"D"})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(i)}),(0,v.jsx)("dt",{children:"="})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(o)}),(0,v.jsx)("dd",{children:y.vU[a]})]})]})},w=function(e){var t=e.name,n=e.bits;return(0,v.jsxs)("div",{children:[t,": ",(0,C.E_)(n)]})},P={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152};var S=function(e){var t=e.keyboard,n=(0,p.useState)(!1),r=(0,d.Z)(n,2),i=r[0],o=r[1],a=(0,p.useState)(t.out().busVoltage),s=(0,d.Z)(a,2),c=s[0],u=s[1],l=(0,p.useCallback)((function(e){var n=function(e){var t=P[e.key];if(void 0!==t)return t;if(1===e.key.length){var n=e.key.charCodeAt(0);if(n>=32&&n<=126)return n}return 0}(e);0!==n&&(e.preventDefault(),t.setKey(n),u(t.out().busVoltage),o(!1))}),[t,o,u]),f=(0,p.useCallback)((function(){o(!0)}),[]);return(0,v.jsxs)("div",{className:"flex row align-baseline",children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(w,{name:"Keyboard",bits:c})}),(0,v.jsx)("div",{className:"flex-1",children:i?(0,v.jsx)("input",{ref:function(e){return null===e||void 0===e?void 0:e.focus()},type:"text",onKeyDown:l}):(0,v.jsx)("button",{onClick:f,children:"\u2328\ufe0f"})})]})},F=n(189),N={none:"0px",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},O={"":"",t:"Top",r:"Right",l:"Left",b:"Bottom",tl:"TopLeft",tr:"TopRight",bl:"BottomLeft",br:"BottomRight"},A={"1/4":"25%","1/2":"50%","3/4":"75%",full:"100%"};function E(e){return void 0!==O[e]}function I(e){return N[e]}function M(e){switch(e){case"t":return[].concat((0,h.Z)(M("tl")),(0,h.Z)(M("tr")));case"r":return[].concat((0,h.Z)(M("tr")),(0,h.Z)(M("br")));case"b":return[].concat((0,h.Z)(M("br")),(0,h.Z)(M("bl")));case"l":return[].concat((0,h.Z)(M("tl")),(0,h.Z)(M("bl")));default:return[O[e]]}}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";E(e)&&(t=e,e="");var n=I(e);return M(t).reduce((function(e,t){return""===t?e.borderRadius=n:e["border".concat(t,"Radius")]=n,e}),{})}var R=n(5838),D=n(7693);function H(e,t){var n;return void 0===e&&void 0!==A[t]&&(e=t),(0,F.Z)((0,F.Z)({},"inline"===t?{display:"inline-block"}:{}),{},{width:null!==(n=A[e])&&void 0!==n?n:"0"})}function _(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r3?t.i-4:t.i:Array.isArray(e)?1:G(e)?2:$(e)?3:0}function K(e,t){return 2===B(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function V(e,t){return 2===B(e)?e.get(t):e[t]}function W(e,t,n){var r=B(e);2===r?e.set(t,n):3===r?(e.delete(t),e.add(n)):e[t]=n}function J(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function G(e){return ke&&e instanceof Map}function $(e){return Ce&&e instanceof Set}function q(e){return e.o||e.t}function X(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Oe(e);delete t[Se];for(var n=Ne(t),r=0;r1&&(e.set=e.add=e.clear=e.delete=Q),Object.freeze(e),t&&z(e,(function(e,t){return Y(t,!0)}),!0)),e}function Q(){_(2)}function ee(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function te(e){var t=Ae[e];return t||_(18,e),t}function ne(){return je}function re(e,t){t&&(te("Patches"),e.u=[],e.s=[],e.v=t)}function ie(e){oe(e),e.p.forEach(se),e.p=null}function oe(e){e===je&&(je=e.l)}function ae(e){return je={p:[],l:je,h:e,m:!0,_:0}}function se(e){var t=e[Se];0===t.i||1===t.i?t.j():t.O=!0}function ce(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||te("ES5").S(t,e,r),r?(n[Se].P&&(ie(t),_(4)),U(e)&&(e=ue(t,e),t.l||de(t,e)),t.u&&te("Patches").M(n[Se].t,e,t.u,t.s)):e=ue(t,n,[]),ie(t),t.u&&t.v(t.u,t.s),e!==we?e:void 0}function ue(e,t,n){if(ee(t))return t;var r=t[Se];if(!r)return z(t,(function(i,o){return le(e,r,t,i,o,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return de(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=X(r.k):r.o;z(3===r.i?new Set(i):i,(function(t,o){return le(e,r,i,t,o,n)})),de(e,i,!1),n&&e.u&&te("Patches").R(r,n,e.u,e.s)}return r.o}function le(e,t,n,r,i,o){if(L(i)){var a=ue(e,i,o&&t&&3!==t.i&&!K(t.D,r)?o.concat(r):void 0);if(W(n,r,a),!L(a))return;e.m=!1}if(U(i)&&!ee(i)){if(!e.h.F&&e._<1)return;ue(e,i),t&&t.A.l||de(e,i)}}function de(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&Y(t,n)}function fe(e,t){var n=e[Se];return(n?q(n):e)[t]}function pe(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function he(e){e.P||(e.P=!0,e.l&&he(e.l))}function ve(e){e.o||(e.o=X(e.t))}function me(e,t,n){var r=G(t)?te("MapSet").N(t,n):$(t)?te("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:ne(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,o=Ee;n&&(i=[r],o=Ie);var a=Proxy.revocable(i,o),s=a.revoke,c=a.proxy;return r.k=c,r.j=s,c}(t,n):te("ES5").J(t,n);return(n?n.A:ne()).p.push(r),r}function ge(e){return L(e)||_(22,e),function e(t){if(!U(t))return t;var n,r=t[Se],i=B(t);if(r){if(!r.P&&(r.i<4||!te("ES5").K(r)))return r.t;r.I=!0,n=xe(t,i),r.I=!1}else n=xe(t,i);return z(n,(function(t,i){r&&V(r.t,t)===i||W(n,t,e(i))})),3===i?new Set(n):n}(e)}function xe(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return X(e)}var be,je,ye="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),ke="undefined"!=typeof Map,Ce="undefined"!=typeof Set,Ze="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,we=ye?Symbol.for("immer-nothing"):((be={})["immer-nothing"]=!0,be),Pe=ye?Symbol.for("immer-draftable"):"__$immer_draftable",Se=ye?Symbol.for("immer-state"):"__$immer_state",Fe=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),Ne="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Oe=Object.getOwnPropertyDescriptors||function(e){var t={};return Ne(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Ae={},Ee={get:function(e,t){if(t===Se)return e;var n=q(e);if(!K(n,t))return function(e,t,n){var r,i=pe(t,n);return i?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!U(r)?r:r===fe(e.t,t)?(ve(e),e.o[t]=me(e.A.h,r,e)):r},has:function(e,t){return t in q(e)},ownKeys:function(e){return Reflect.ownKeys(q(e))},set:function(e,t,n){var r=pe(q(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=fe(q(e),t),o=null==i?void 0:i[Se];if(o&&o.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(J(n,i)&&(void 0!==n||K(e.t,t)))return!0;ve(e),he(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==fe(e.t,t)||t in e.t?(e.D[t]=!1,ve(e),he(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=q(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){_(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){_(12)}},Ie={};z(Ee,(function(e,t){Ie[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ie.deleteProperty=function(e,t){return Ie.set.call(this,e,t,void 0)},Ie.set=function(e,t,n){return Ee.set.call(this,e[0],t,n,e[0])};var Me=function(){function e(e){var t=this;this.g=Ze,this.F=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var o=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,a=Array(r>1?r-1:0),s=1;s1?r-1:0),o=1;o=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=te("Patches").$;return L(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}(),Te=new Me,Re=Te.produce,De=(Te.produceWithPatches.bind(Te),Te.setAutoFreeze.bind(Te),Te.setUseProxies.bind(Te),Te.applyPatches.bind(Te),Te.createDraft.bind(Te),Te.finishDraft.bind(Te),Re);function He(e,t){return(0,p.useReducer)((function(t,n){return De(t,(function(t){e[n.action](t,n.payload)}))}),t)}function _e(e){var t=(0,p.useState)(e),n=(0,d.Z)(t,2),r=n[0],i=n[1];return(0,p.useEffect)((function(){i(e)}),[e]),[r,i]}var Le=0,Ue=1,ze=function(e){var t,n=(0,p.useState)(null!==(t=e.mode)&&void 0!==t?t:Le),r=(0,d.Z)(n,2),i=r[0],o=r[1],a=_e(e.value),s=(0,d.Z)(a,2),c=s[0],u=s[1],l=function(){return(0,v.jsx)("span",{style:(0,F.Z)({cursor:"text"},H("full","inline")),onClick:function(){o(Ue)},children:c})},f=(0,p.useCallback)((function(e){return null===e||void 0===e?void 0:e.select()}),[]),h=(0,p.useCallback)((function(t){var n,r;o(Le),u(null!==(n=t.value)&&void 0!==n?n:""),e.onChange(null!==(r=t.value)&&void 0!==r?r:"")}),[e,o,u]),m=function(){var e=(0,v.jsx)("span",{style:{display:"block",position:"relative"},children:(0,v.jsx)("input",{ref:f,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem"},onBlur:function(e){var t=e.target;return h(t)},onKeyPress:function(e){var t=e.key,n=e.target;"Enter"===t&&h(n)},type:"text",defaultValue:c})});return e};return function(){switch(i){case Ue:return m();case Le:return l();default:return(0,v.jsx)("span",{})}}()};function Be(e,t,n){var r=t.totalHeight,i=t.toleranceHeight,o=t.bufferedItems,a=t.settings,s=a.itemHeight,c=a.minIndex,u=a.maxIndex,l=c+Math.floor((e-i)/s),d=function(e,t,n,r,i){var o=Math.max(0,e,n),a=i(o,Math.min(t,n+r-1)-o);return(0,h.Z)(a)}(c,u,l,o,n),f=Math.max((l-c)*s,0);return{scrollTop:e,topPaddingHeight:f,bottomPaddingHeight:Math.max(r-(f+d.length*s),0),data:d}}var Ke=function(e){var t,n=(0,p.useRef)(null),r=(0,p.useMemo)((function(){var t,n=function(e){var t=e.minIndex,n=void 0===t?0:t,r=e.maxIndex,i=void 0===r?Number.MAX_SAFE_INTEGER:r,o=e.startIndex,a=void 0===o?0:o,s=e.itemHeight,c=void 0===s?20:s,u=e.count,l=void 0===u?Math.max(i-n,1):u,d=e.tolerance;return{minIndex:n,maxIndex:i,startIndex:a,itemHeight:c,count:l,tolerance:void 0===d?l:d}}(null!==(t=e.settings)&&void 0!==t?t:{}),r=function(e,t){var n=e.minIndex,r=e.maxIndex,i=e.startIndex,o=e.itemHeight,a=e.count,s=e.tolerance,c=a+2*s,u=Math.max(0,i-s-n),l=a*o,d=Math.min(r-n,1)*o,f=s*o,p=u*o,h={scrollTop:0,settings:e,viewportHeight:l,totalHeight:d,toleranceHeight:f,bufferedItems:c,topPaddingHeight:p,bottomPaddingHeight:d-(p+(l+2*f)),data:[]};return(0,F.Z)((0,F.Z)({},h),Be(p+f,h,t))}(n,e.get),i=function(e){return function(t,n){return(0,F.Z)((0,F.Z)({},t),Be(n,t,e))}}(e.get);return{settings:n,reducer:i,startState:r}}),[e.settings,e.get]),i=r.settings,o=r.startState,a=r.reducer,s=(0,p.useReducer)(a,o),c=(0,d.Z)(s,2),u=c[0],l=c[1];(0,p.useEffect)((function(){null!==n.current&&l(n.current.scrollTop)}),[i,e.row]);var f=(0,p.useCallback)((function(e){e&&(e.scrollTop=n.current?n.current.scrollTop:i.startIndex*i.itemHeight),n.current=e}),[n,i.startIndex,i.itemHeight]),h=u.data.map((function(t){return(0,v.jsx)("div",{style:{height:"".concat(i.itemHeight,"px")},children:e.row(t)},e.rowKey(t))}));return(0,v.jsxs)("div",{ref:f,style:{height:"".concat(u.viewportHeight,"px"),overflowY:"scroll",overflowAnchor:"none"},className:null!==(t=e.className)&&void 0!==t?t:"",onScroll:function(e){return l(e.target.scrollTop)},children:[(0,v.jsx)("div",{style:{height:"".concat(u.topPaddingHeight,"px")}}),h,(0,v.jsx)("div",{style:{height:"".concat(u.bottomPaddingHeight,"px")}})]})},Ve=function(e){var t=e.memory,n=e.jmp,r=void 0===n?{value:0}:n,i=e.highlight,o=void 0===i?-1:i,a=e.editable,s=void 0!==a&&a,c=e.format,u=void 0===c?C.E_:c,l=e.onChange,f=void 0===l?function(){}:l,h=(0,p.useMemo)((function(){return{count:Math.min(t.size,20),maxIndex:t.size,itemHeight:34,startIndex:r.value}}),[t.size,r]),m=(0,p.useCallback)((function(e,n){return t.range(e,e+n).map((function(t,n){return[n+e,t]}))}),[t]),g=(0,p.useCallback)((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)(We,{index:n,value:u(r),editable:s,highlight:n===o,onChange:f})}),[u,s,o,f]);return(0,v.jsx)(Ke,{settings:h,get:m,row:g,rowKey:function(e){return(0,d.Z)(e,1)[0]}})},We=function(e){var t=e.index,n=e.value,r=e.highlight,i=void 0!==r&&r,o=e.editable,a=void 0!==o&&o,s=e.onChange,c=void 0===s?function(){}:s;return(0,v.jsxs)("div",{style:{display:"flex",height:"100%"},children:[(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:(0,C.$v)(t)}),(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({flex:"1",textAlign:"right"},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:a?(0,v.jsx)(ze,{value:n,onChange:function(e){return c(t,e,Number(n))}}):(0,v.jsx)("span",{children:n})})]})},Je=function(e){var t=e.name,n=void 0===t?"Memory":t,r=e.highlight,i=void 0===r?-1:r,o=e.editable,a=void 0===o||o,s=e.memory,c=e.format,u=void 0===c?"dec":c,l=(0,p.useState)(u),f=(0,d.Z)(l,2),h=f[0],m=f[1],g=(0,p.useState)("0"),x=(0,d.Z)(g,2),b=x[0],j=x[1],y=(0,p.useState)({value:0}),k=(0,d.Z)(y,2),Z=k[0],w=k[1],P=function(){w({value:Number(b)})},S=(0,p.useCallback)((function(e,t){s.update(e,t,null!==h&&void 0!==h?h:"dec")}),[s,h]);return(0,v.jsxs)("article",{className:"panel",children:[(0,v.jsxs)("header",{children:[(0,v.jsx)("div",{children:n}),(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:function(){},className:"flex-0",children:"\ud83d\udcc2"}),(0,v.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Goto",onKeyDown:function(e){return"Enter"===e.key&&P()},onChange:function(e){var t=e.target.value;return j(null!==t&&void 0!==t?t:"0")}}),(0,v.jsx)("button",{onClick:P,className:"flex-0",children:"\u2935\ufe0f"}),R.I2.map((function(e){return(0,v.jsxs)("label",{className:"flex-0",role:"button","aria-current":e===h,children:[(0,v.jsx)("input",{type:"radio",name:n,value:e,checked:e===h,onChange:function(){return m(e)}}),e]},e)}))]})]}),(0,v.jsx)(Ve,{jmp:Z,memory:s,highlight:i,editable:a,format:function(e){return function(e,t){switch(e){case"bin":return(0,C.Ly)(t);case"hex":return(0,C.$v)(t);case"asm":return(0,D.a)(t);default:return(0,C.E_)(t)}}(h,e)},onChange:S})]})};var Ge=n(5541),$e=n(4408),qe=n(6531);function Xe(){return(0,$e.j)(qe.S.get())}var Ye=function(){var e=function(){var e=(0,p.useState)(Xe()),t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,p.useEffect)((function(){var e=qe.S.get().$.subscribe((function(){r(Xe())}));return function(){return e.unsubscribe()}}),[]),n}();return(0,v.jsx)("span",{style:{whiteSpace:"nowrap"},children:e})},Qe="white";function et(e,t,n){return 0===(e.get(32*n+(t/16|0))&1<0?(0,v.jsx)(v.Fragment,{children:r}):void 0}var it=n(8582),ot=n(1585);function at(e){return{pin:e,bits:(0,ot.w)(0,e.width).map((function(t){return[t,e.voltage(t)]})).reverse()}}function st(e){return(0,h.Z)(e.entries()).map(at)}var ct=function(e){var t=e.sim,n=t.inPins,r=t.outPins,i=t.internalPins;return(0,v.jsxs)(v.Fragment,{children:[(0,v.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,v.jsx)("table",{className:"pinout",children:(0,v.jsxs)("tbody",{children:[(0,v.jsx)(ut,{pins:n,header:"Input pins",toggle:e.toggle}),(0,v.jsx)(ut,{pins:r,header:"Output pins",disabled:e.sim.pending}),(0,v.jsx)(ut,{pins:i,header:"Internal pins",disabled:e.sim.pending})]})})]})},ut=function(e){return(0,v.jsxs)(v.Fragment,{children:[e.pins.length>0&&(0,v.jsx)("tr",{children:(0,v.jsx)("th",{colSpan:2,children:e.header})}),(0,h.Z)(e.pins).map((function(t){return(0,v.jsxs)("tr",{children:[(0,v.jsx)("td",{children:t.pin.name}),(0,v.jsx)("td",{children:(0,v.jsx)(lt,{pin:t,toggle:e.toggle,disabled:e.disabled})})]},t.pin.name)}))]})},lt=function(e){var t=e.pin,n=e.toggle,r=e.disabled,i=void 0!==r&&r;return(0,v.jsx)("fieldset",{role:"group",style:{width:"".concat(t.bits.length,"rem")},children:t.bits.map((function(e){var r=(0,d.Z)(e,2),o=r[0],a=r[1];return(0,v.jsx)("button",{onClick:function(){return null===n||void 0===n?void 0:n(t.pin,o)},disabled:i,"data-testid":"pin-".concat(o),children:a},o)}))})};var dt=function(e){var t=function(e){var t=(0,p.useRef)((function(){})),n=(0,p.useMemo)((function(){return function(e,t){var n={running:e.running,speed:e.speed,steps:e.steps},r=e.finishFrame.bind(e);return e.finishFrame=function(){r(),t.current({action:"update"})},{initialState:n,reducers:{update:function(t){t.running=e.running,t.speed=e.speed,t.steps=e.steps},setSteps:function(t,n){t.steps=n,e.steps=n},setSpeed:function(t,n){t.speed=n,e.speed=n}},actions:{frame:function(){e.frame()},start:function(){e.start(),t.current({action:"update"})},stop:function(){e.stop(),t.current({action:"update"})},reset:function(){e.reset(),t.current({action:"update"})}}}}(e,t)}),[e,t]),r=n.initialState,i=n.reducers,o=n.actions,a=He(i,r),s=(0,d.Z)(a,2),c=s[0],u=s[1];return t.current=u,{state:c,dispatch:t.current,actions:o}}(e.runner);return(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.frame()},"data-tooltip":"Step","data-placement":"bottom",children:"\u27a1\ufe0f"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.state.running?t.actions.stop():t.actions.start()},"data-tooltip":t.state.running?"Pause":"Play","data-placement":"bottom",children:t.state.running?"\u23f8":"\ufe0f\u23e9"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.reset()},"data-tooltip":"Reset","data-placement":"bottom",children:"\u23ee"}),(0,v.jsx)("select",{className:"flex-1",name:"speed",value:t.state.speed,onChange:function(e){var n,r;t.dispatch({action:"setSpeed",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.speed)})},disabled:t.state.running,children:[[1e3,"Slow"],[500,"Fast"],[16,"Faster"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{className:"flex-1",name:"steps",value:t.state.steps,onChange:function(e){var n,r;t.dispatch({action:"setSteps",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.steps)})},disabled:t.state.running,children:[[1,"1 Step"],[500,"500"],[1e3,"1000"],[2e3,"2000"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),e.children]})},ft=n(8365),pt=n(8090),ht=n(9647),vt=n(7538),mt=n(4649),gt=n(2648),xt=n(3943),bt=qe.S.get(),jt=new WeakMap,yt=new WeakMap,kt=new WeakMap,Ct=new WeakMap,Zt=function(){function e(){var t=this;(0,r.Z)(this,e),(0,mt.Z)(this,"steps",1),(0,mt.Z)(this,"speed",1e3),(0,vt.Z)(this,jt,{writable:!0,value:!1}),(0,vt.Z)(this,yt,{writable:!0,value:0}),(0,vt.Z)(this,kt,{writable:!0,value:0}),(0,vt.Z)(this,Ct,{writable:!0,value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){var n,r,i,o;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((0,xt.Z)(t,jt)){e.next=2;break}return e.abrupt("return");case 2:if(n=Date.now(),r=n-(0,xt.Z)(t,kt),(0,gt.Z)(t,kt,n),(0,gt.Z)(t,yt,(0,xt.Z)(t,yt)+r),!((0,xt.Z)(t,yt)>t.speed)){e.next=19;break}i=!1,o=0;case 9:if(!(o0&&void 0!==arguments[0]?arguments[0]:"";return n(e)},language:r,onMount:g})})},It=function(e){var t=e.className,n=void 0===t?"":t,r=e.style,i=void 0===r?{}:r,o=e.disabled,a=void 0!==o&&o,s=e.value,c=e.onChange,u=e.grammar,l=e.language,f=e.highlight,h=(0,p.useState)(),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=(0,p.useContext)(wt.Il).monaco,j=(0,p.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=u.match(e);x(t.failed()?t:void 0)}),[x,u]);(0,p.useEffect)((function(){return j(s)}),[j,s]);var y=(0,p.useMemo)((function(){return function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;return function(){for(var r=arguments.length,i=new Array(r),o=0;o0&&void 0!==arguments[0]?arguments[0]:"";c(e),y(e)}),[y,c]);return(0,v.jsx)("div",{className:"Editor ".concat(n),style:i,children:b.canUse&&b.wants?(0,v.jsx)(Et,{value:s,onChange:k,language:l,error:g,disabled:a,highlight:f}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(At,{value:s,onChange:k,language:l,disabled:a}),(0,v.jsx)(Ot,{error:g})]})})},Mt=function(e){var t;return(0,v.jsxs)("article",{className:["panel",null!==(t=e.className)&&void 0!==t?t:""].join(" "),children:[e.header&&(0,v.jsx)("header",{children:e.header}),(0,v.jsx)("main",{children:e.children}),e.footer&&(0,v.jsx)("footer",{children:e.footer})]})},Tt=function(e){var t;return(0,v.jsxs)("details",{className:null!==(t=e.className)&&void 0!==t?t:"",open:e.open,style:e.style,children:[(0,v.jsx)("summary",{children:(0,v.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})},Rt=n(726),Dt=n(4625),Ht=n(691),_t=n(1277),Lt=n(3389),Ut=n(8698),zt=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function Bt(e){return"CHIP ".concat(e," {\n IN in;\n OUT out;\n PARTS:\n}")}function Kt(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:e.clocked,inPins:st(e.ins),outPins:st(e.outs),internalPins:st(e.pins),chip:[e],pending:t,invalid:n}}var Vt=qe.S.get();function Wt(e,t,n,r){var i=function(e){var t,n,r=null!==(t=e["/chip/project"])&&void 0!==t?t:"01",i=_t.CHIP_PROJECTS[r];return{project:r,chips:i,chipName:null!==(n=e["/chip/chip"])&&void 0!==n?n:i[0]}}(n),o=i.project,a=i.chipName,s=i.chips,c=new j.P9,f=new Lt.l1,p=!1,v={setFiles:function(e,t){var n=t.hdl,r=void 0===n?e.files.hdl:n,i=t.tst,o=void 0===i?e.files.tst:i,a=t.cmp,s=void 0===a?e.files.cmp:a,c=t.out,u=void 0===c?"":c;e.files.hdl=r,e.files.tst=o,e.files.cmp=s,e.files.out=u},updateChip:function(e,t){var n,r,i,o,s,u;e.sim=Kt(c,null!==(n=null===t||void 0===t?void 0:t.pending)&&void 0!==n?n:e.sim.pending,null!==(r=null===t||void 0===t?void 0:t.invalid)&&void 0!==r?r:e.sim.invalid),e.controls.error=e.sim.invalid?null!==(i=null===t||void 0===t?void 0:t.error)&&void 0!==i?i:e.controls.error:"",e.controls.chips=_t.CHIP_PROJECTS[e.controls.project],e.controls.chipName=e.sim.invalid?null!==(o=null===t||void 0===t?void 0:t.chipName)&&void 0!==o?o:a:null!==(s=null!==(u=c.name)&&void 0!==u?u:null===t||void 0===t?void 0:t.chipName)&&void 0!==s?s:a,e.controls.chips.includes(e.controls.chipName)||(e.controls.chips=[].concat((0,h.Z)(e.controls.chips),[e.controls.chipName]))},setProject:function(e,t){var n=_t.CHIP_PROJECTS[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:function(e,t){e.controls.chipName=t,e.controls.hasBuiltin=g.zZ.has(t)},testRunning:function(e){e.controls.runningTest=!0},testFinished:function(e){e.controls.runningTest=!1;var n=e.files.out.trim()===e.files.cmp.trim();t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep:function(e){var t,n,r,i;if(e.files.out=null!==(t=null===(n=f)||void 0===n?void 0:n.log())&&void 0!==t?t:"",null!==(r=f)&&void 0!==r&&null!==(i=r.currentStep)&&void 0!==i&&i.span)e.controls.span=f.currentStep.span;else if(f.done){var o=e.files.tst.length;e.controls.span={start:o-1,end:o}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})}},m={setProject:function(e){o=n["/chip/project"]=e,r.current({action:"setProject",payload:o}),this.setChip(_t.CHIP_PROJECTS[o][0])},setChip:function(e){var t=arguments,i=this;return(0,l.Z)((0,u.Z)().mark((function o(){var s,c;return(0,u.Z)().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return c=t.length>1&&void 0!==t[1]?t[1]:null!==(s=n["/chip/project"])&&void 0!==s?s:_t.ChipProjects["01"],a=n["/chip/chip"]=e,r.current({action:"setChip",payload:a}),o.next=5,i.loadChip(c,a);case 5:p&&i.useBuiltin();case 6:case"end":return o.stop()}}),o)})))()},reset:function(){qe.S.get().reset(),c.reset(),f.reset(),r.current({action:"setFiles",payload:{}}),r.current({action:"updateChip"})},updateFiles:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var o,a,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(o=e.hdl,a=e.tst,s=e.cmp,r.current({action:"setFiles",payload:{hdl:o,tst:a,cmp:s}}),i.prev=2,!o){i.next=6;break}return i.next=6,n.compileChip(o);case 6:a&&n.compileTest(a),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),t((0,$e.j)(i.t0));case 12:case"end":return i.stop()}}),i,null,[[2,9]])})))()},compileChip:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var o,a,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(c.remove(),o=pt.Gq.parse(e),!(0,Dt.dZ)(o)){i.next=6;break}return t("Failed to parse chip"),r.current({action:"updateChip",payload:{invalid:!0,error:(0,$e.j)((0,Dt.UG)(o))}}),i.abrupt("return");case 6:return i.next=8,(0,Ht.J_)((0,Dt.Ok)(o));case 8:if(a=i.sent,!(0,Dt.dZ)(a)){i.next=14;break}return s=(0,$e.j)((0,Dt.UG)(a)),t(s),r.current({action:"updateChip",payload:{invalid:!0,error:s}}),i.abrupt("return");case 14:t("Compiled ".concat(c.name)),n.replaceChip((0,Dt.Ok)(a));case 16:case"end":return i.stop()}}),i)})))()},replaceChip:function(e){var t,n=c.ins,i=(0,Rt.Z)(n);try{for(i.s();!(t=i.n()).done;){var o=(0,d.Z)(t.value,2),a=o[0],s=o[1].busVoltage,u=e.ins.get(a);u&&(u.busVoltage=s)}}catch(l){i.e(l)}finally{i.f()}Vt.reset(),e.eval(),(c=e).reset(),f=f.with(c).reset(),r.current({action:"updateChip",payload:{invalid:!1}}),r.current({action:"updateTestStep"})},loadChip:function(t,i){var o=this;return(0,l.Z)((0,u.Z)().mark((function a(){var s,c,l,f,p,h;return(0,u.Z)().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return n["/chip/chip"]=i,s=function(e){return"/projects/".concat(t,"/").concat(i,"/").concat(i,".").concat(e)},a.next=4,Promise.all([e.readFile(s("hdl")).catch((function(){return Bt(i)})),e.readFile(s("tst")).catch((function(e){return console.log(e),"repeat 10 {\n tick,\n tock;\n}"})),e.readFile(s("cmp")).catch((function(){return"| in|out|"}))]);case 4:return c=a.sent,l=(0,d.Z)(c,3),f=l[0],p=l[1],h=l[2],r.current({action:"setFiles",payload:{hdl:f,tst:p,cmp:h}}),a.next=12,o.compileChip(f);case 12:o.compileTest(p);case 13:case"end":return a.stop()}}),a)})))()},saveChip:function(n){var i=arguments;return(0,l.Z)((0,u.Z)().mark((function s(){var c,l,d;return(0,u.Z)().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return c=i.length>1&&void 0!==i[1]?i[1]:o,l=i.length>2&&void 0!==i[2]?i[2]:a,r.current({action:"setFiles",payload:{hdl:n}}),d="/projects/".concat(c,"/").concat(l,"/").concat(l,".hdl"),s.next=6,e.writeFile(d,n);case 6:t("Saved ".concat(d));case 7:case"end":return s.stop()}}),s)})))()},toggle:function(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<0&&void 0!==e[0])||e[0],d=e.length>1?e[1]:void 0,l){i.next=7;break}return p=!1,i.next=6,n.loadChip(o,a);case 6:return i.abrupt("return");case 7:if(p=!0,f=null!==(s=c.name)&&void 0!==s?s:a,h=(0,g.cT)(f),!(0,Dt.dZ)(h)){i.next=13;break}return t("Failed to load builtin ".concat(f,": ").concat((0,$e.j)((0,Dt.UG)(h)))),i.abrupt("return");case 13:if(!d){i.next=16;break}return i.next=16,n.saveChip(d,o,a);case 16:v=_t.ChipProjects[o].CHIPS[f]["".concat(f,".hdl")],m=v.replace("PARTS:","PARTS:\n BUILTIN ".concat(f)),r.current({action:"setFiles",payload:{hdl:m}}),n.replaceChip((0,Dt.Ok)(h));case 20:case"end":return i.stop()}}),i)})))()},initialize:function(){var e=this;return(0,l.Z)((0,u.Z)().mark((function t(){return(0,u.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.loadChip(o,a);case 2:case"end":return t.stop()}}),t)})))()},compileTest:function(n){r.current({action:"setFiles",payload:{tst:n}});var i=ht.qH.parse(n);return(0,Dt.dZ)(i)?(t("Failed to parse test"),!1):(t("Parsed tst"),(f=Lt.l1.from((0,Dt.Ok)(i)).with(c).reset()).setFileSystem(e),r.current({action:"updateTestStep"}),!0)},runTest:function(t){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n.compileTest(t)){i.next=2;break}return i.abrupt("return");case 2:return r.current({action:"testRunning"}),e.pushd("/samples"),i.next=6,f.run();case 6:e.popd(),r.current({action:"updateTestStep"}),r.current({action:"testFinished"});case 9:case"end":return i.stop()}}),i)})))()},tick:function(){return this.stepTest()},stepTest:function(){return(0,l.Z)((0,u.Z)().mark((function e(){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(0,Ge.hu)(f.chipId===c.id,"Test and chip out of sync"),e.next=3,f.step();case 3:return t=e.sent,r.current({action:"updateTestStep"}),t&&r.current({action:"testFinished"}),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))()}};return{initialState:function(){var e={project:o,chips:s,chipName:a,hasBuiltin:g.zZ.has(a),runningTest:!1,error:""},n=(0,g.cT)(e.chipName);return(0,Dt.dZ)(n)?(t((0,$e.j)((0,Dt.UG)(n))),c=new j.P9):c=(0,Dt.Ok)(n),{controls:e,files:{hdl:"",cmp:"",tst:"",out:""},sim:Kt(c)}}(),reducers:v,actions:m}}var Jt=function(){var e=(0,p.useContext)(Ut.r),t=e.fs,n=e.setStatus,m=(0,p.useContext)(wt.Il),g=m.filePicker,x=m.tracking,b=function(){var e=(0,p.useContext)(Ut.r),t=e.fs,n=e.setStatus,r=e.storage,i=(0,p.useRef)((function(){})),o=(0,p.useMemo)((function(){return Wt(t,n,r,i)}),[t,n,r,i]),a=o.initialState,s=o.reducers,c=o.actions,u=He(s,a),l=(0,d.Z)(u,2),f=l[0],h=l[1];return i.current=h,{state:f,dispatch:i,actions:c}}(),j=b.state,y=b.actions,k=b.dispatch,C=_e(j.files.hdl),Z=(0,d.Z)(C,2),w=Z[0],P=Z[1],S=_e(j.files.tst),F=(0,d.Z)(S,2),N=F[0],O=F[1],A=_e(j.files.cmp),E=(0,d.Z)(A,2),I=E[0],M=E[1],T=_e(j.files.out),R=(0,d.Z)(T,1)[0];(0,p.useEffect)((function(){y.initialize()}),[y]),(0,p.useEffect)((function(){x.trackPage("/chip")}),[x]);(0,p.useEffect)((function(){x.trackEvent("action","setProject",j.controls.project),x.trackEvent("action","setChip",j.controls.chipName)}),[]);var D=(0,p.useCallback)((function(e){y.setProject(e),x.trackEvent("action","setProject",e)}),[y,x]),H=(0,p.useCallback)((function(e){y.setChip(e),x.trackEvent("action","setChip",e)}),[y,x]),_=(0,p.useCallback)((function(){y.eval(),x.trackEvent("action","eval")}),[y,x]),L=(0,p.useRef)((function(){}));L.current=(0,l.Z)((0,u.Z)().mark((function e(){var t,n,r,i=arguments;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:{},e.next=3,y.updateFiles({hdl:r.hdl,tst:null!==(t=r.tst)&&void 0!==t?t:N,cmp:null!==(n=r.cmp)&&void 0!==n?n:I});case 3:case"end":return e.stop()}}),e)})));var U=(0,p.useCallback)((0,l.Z)((0,u.Z)().mark((function e(){var r,i;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g.select();case 3:return r=e.sent,e.next=6,t.readFile(r);case 6:return i=e.sent,e.next=9,L.current({tst:i});case 9:e.next=15;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0),n("Failed to load into memory");case 15:case"end":return e.stop()}}),e,null,[[0,11]])}))),[g,n,t,L]),z=(0,p.useRef)();(0,p.useEffect)((function(){return z.current=new(function(e){(0,s.Z)(n,e);var t=(0,c.Z)(n);function n(){return(0,r.Z)(this,n),t.apply(this,arguments)}return(0,i.Z)(n,[{key:"reset",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L.current();case 2:return e.next=4,y.reset();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"finishFrame",value:function(){(0,o.Z)((0,a.Z)(n.prototype),"finishFrame",this).call(this),k.current({action:"updateTestStep"})}},{key:"tick",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",y.stepTest());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"toggle",value:function(){k.current({action:"updateTestStep"})}}]),n}(Zt)),function(){var e;null===(e=z.current)||void 0===e||e.stop()}}),[L,y,k]);var B=(0,p.useMemo)((function(){return{toggle:function(){y.clock(),x.trackEvent("action","toggleClock")},reset:function(){x.trackEvent("action","resetClock"),y.reset()}}}),[y]),K=(0,p.useState)(!1),V=(0,d.Z)(K,2),W=V[0],J=V[1],G=(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("select",{value:j.controls.project,onChange:function(e){var t=e.target.value;D(t)},"data-testid":"project-picker",children:zt.map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{value:j.controls.chipName,onChange:function(e){var t=e.target.value;H(t)},"data-testid":"chip-picker",children:j.controls.chips.map((function(e){return(0,v.jsx)("option",{value:e,children:e},e)}))}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){y.saveChip(w)},disabled:W,children:(0,v.jsx)(f.cC,{id:"Save"})})]})}),$=(0,v.jsx)(Mt,{className:"_hdl_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{tabIndex:0,children:"HDL"}),(0,v.jsx)("fieldset",{children:j.controls.hasBuiltin&&(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"checkbox",role:"switch",checked:W,onChange:function(){W?(J(!1),y.useBuiltin(!1)):(J(!0),y.useBuiltin(!0,w))}}),(0,v.jsx)(f.cC,{id:"Builtin"})]})}),G]}),children:(0,v.jsx)(It,{className:"flex-1",value:w,onChange:function(e){P(e),L.current(W?{}:{hdl:e})},grammar:pt.Gq.parser,language:"hdl",disabled:W})}),q=(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:_,onKeyDown:_,disabled:!j.sim.pending,children:(0,v.jsx)(f.cC,{id:"Eval"})}),(0,v.jsxs)("button",{onClick:B.toggle,style:{maxWidth:"initial"},disabled:!j.sim.clocked,children:[(0,v.jsx)(f.cC,{id:"Clock"}),":","\xa0",(0,v.jsx)(Ye,{})]}),(0,v.jsx)("button",{onClick:B.reset,style:{maxWidth:"initial"},disabled:!j.sim.clocked,children:(0,v.jsx)(f.cC,{id:"Reset"})})]}),X=function(e){return(0,h.Z)(e.parts).map((function(e,t){return["".concat(e.id,"_").concat(t),rt(e)]})).filter((function(e){var t=(0,d.Z)(e,2);return t[0],void 0!==t[1]}))}({parts:j.sim.chip}),Y=(0,v.jsx)(Mt,{className:"_parts_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{children:(0,v.jsx)(f.cC,{id:"Chip"})}),q]}),children:j.sim.invalid?(0,v.jsx)(f.cC,{id:"Invalid Chip"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ct,{sim:j.sim,toggle:y.toggle}),X.length>0&&(0,v.jsx)(Tt,{summary:(0,v.jsx)(f.cC,{id:"Visualizations"}),open:!0,children:(0,v.jsx)("main",{children:X.map((function(e){var t=(0,d.Z)(e,2);t[0];return t[1]}))})})]})}),Q=(0,p.useState)("tst"),ee=(0,d.Z)(Q,2),te=ee[0],ne=ee[1],re=(0,p.useCallback)((function(e){ne(e),x.trackEvent("tab","change",e)}),[x]),ie=(0,v.jsx)(Mt,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(f.cC,{id:"Test"})}),(0,v.jsx)("div",{className:"flex-2",children:z.current&&(0,v.jsx)(dt,{runner:z.current})}),(0,v.jsx)("div",{children:(0,v.jsxs)("button",{onClick:U,children:[(0,v.jsx)(Pt.J,{name:"upload_file"})," "]})})]}),children:(0,v.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,v.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===te,onChange:function(){return re("tst")}}),"Test Script"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,v.jsx)(It,{value:N,onChange:O,grammar:ht.qH.parser,language:"tst",highlight:j.controls.span})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===te,onChange:function(){return re("cmp")}}),"Compare File"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,v.jsx)(It,{value:I,onChange:M,grammar:ft.lA.parser,language:"cmp"})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===te,onChange:function(){return re("out")}}),"Output File"]})}),(0,v.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,v.jsx)(it.M,{cmp:I,out:R})})]})});return(0,v.jsxs)("div",{className:"ChipPage grid",children:[$,Y,ie]})},Gt=Jt}}]); -//# sourceMappingURL=605.bdf4e452.chunk.js.map \ No newline at end of file +"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[605],{9605:function(e,t,n){n.r(t),n.d(t,{Chip:function(){return Jt},default:function(){return Gt}});var r=n(2951),i=n(1976),o=n(3243),a=n(7597),s=n(7591),c=n(4337),u=n(1092),l=n(7791),d=n(1026),f=n(8061),p=n(6167),h=n(649),v=n(7878),m=n(3300),g=n(3118),x=n(7039),b=n(3116),j=n(6329),y=n(6693),k=n(134),C=n(326),Z=function(e){var t,n=e.A,r=e.op,i=e.D,o=e.out,a=e.flag;return(0,v.jsxs)("div",{children:[(0,v.jsx)("span",{children:"ALU"}),(0,v.jsxs)("dl",{children:[(0,v.jsx)("dt",{children:"A"})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(n)}),(0,v.jsx)("dt",{children:"op"})," ",(0,v.jsx)("dd",{children:null!==(t=y.PH.op[r])&&void 0!==t?t:"(??)"}),(0,v.jsx)("dt",{children:"D"})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(i)}),(0,v.jsx)("dt",{children:"="})," ",(0,v.jsx)("dd",{children:(0,C.Ly)(o)}),(0,v.jsx)("dd",{children:y.vU[a]})]})]})},w=function(e){var t=e.name,n=e.bits;return(0,v.jsxs)("div",{children:[t,": ",(0,C.E_)(n)]})},P={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152};var S=function(e){var t=e.keyboard,n=(0,p.useState)(!1),r=(0,d.Z)(n,2),i=r[0],o=r[1],a=(0,p.useState)(t.out().busVoltage),s=(0,d.Z)(a,2),c=s[0],u=s[1],l=(0,p.useCallback)((function(e){var n=function(e){var t=P[e.key];if(void 0!==t)return t;if(1===e.key.length){var n=e.key.charCodeAt(0);if(n>=32&&n<=126)return n}return 0}(e);0!==n&&(e.preventDefault(),t.setKey(n),u(t.out().busVoltage),o(!1))}),[t,o,u]),f=(0,p.useCallback)((function(){o(!0)}),[]);return(0,v.jsxs)("div",{className:"flex row align-baseline",children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(w,{name:"Keyboard",bits:c})}),(0,v.jsx)("div",{className:"flex-1",children:i?(0,v.jsx)("input",{ref:function(e){return null===e||void 0===e?void 0:e.focus()},type:"text",onKeyDown:l}):(0,v.jsx)("button",{onClick:f,children:"\u2328\ufe0f"})})]})},F=n(189),N={none:"0px",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},O={"":"",t:"Top",r:"Right",l:"Left",b:"Bottom",tl:"TopLeft",tr:"TopRight",bl:"BottomLeft",br:"BottomRight"},A={"1/4":"25%","1/2":"50%","3/4":"75%",full:"100%"};function E(e){return void 0!==O[e]}function I(e){return N[e]}function M(e){switch(e){case"t":return[].concat((0,h.Z)(M("tl")),(0,h.Z)(M("tr")));case"r":return[].concat((0,h.Z)(M("tr")),(0,h.Z)(M("br")));case"b":return[].concat((0,h.Z)(M("br")),(0,h.Z)(M("bl")));case"l":return[].concat((0,h.Z)(M("tl")),(0,h.Z)(M("bl")));default:return[O[e]]}}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";E(e)&&(t=e,e="");var n=I(e);return M(t).reduce((function(e,t){return""===t?e.borderRadius=n:e["border".concat(t,"Radius")]=n,e}),{})}var R=n(5838),D=n(7693);function H(e,t){var n;return void 0===e&&void 0!==A[t]&&(e=t),(0,F.Z)((0,F.Z)({},"inline"===t?{display:"inline-block"}:{}),{},{width:null!==(n=A[e])&&void 0!==n?n:"0"})}function _(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r3?t.i-4:t.i:Array.isArray(e)?1:G(e)?2:$(e)?3:0}function K(e,t){return 2===B(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function V(e,t){return 2===B(e)?e.get(t):e[t]}function W(e,t,n){var r=B(e);2===r?e.set(t,n):3===r?(e.delete(t),e.add(n)):e[t]=n}function J(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function G(e){return ke&&e instanceof Map}function $(e){return Ce&&e instanceof Set}function q(e){return e.o||e.t}function X(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Oe(e);delete t[Se];for(var n=Ne(t),r=0;r1&&(e.set=e.add=e.clear=e.delete=Q),Object.freeze(e),t&&z(e,(function(e,t){return Y(t,!0)}),!0)),e}function Q(){_(2)}function ee(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function te(e){var t=Ae[e];return t||_(18,e),t}function ne(){return je}function re(e,t){t&&(te("Patches"),e.u=[],e.s=[],e.v=t)}function ie(e){oe(e),e.p.forEach(se),e.p=null}function oe(e){e===je&&(je=e.l)}function ae(e){return je={p:[],l:je,h:e,m:!0,_:0}}function se(e){var t=e[Se];0===t.i||1===t.i?t.j():t.O=!0}function ce(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||te("ES5").S(t,e,r),r?(n[Se].P&&(ie(t),_(4)),U(e)&&(e=ue(t,e),t.l||de(t,e)),t.u&&te("Patches").M(n[Se].t,e,t.u,t.s)):e=ue(t,n,[]),ie(t),t.u&&t.v(t.u,t.s),e!==we?e:void 0}function ue(e,t,n){if(ee(t))return t;var r=t[Se];if(!r)return z(t,(function(i,o){return le(e,r,t,i,o,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return de(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=X(r.k):r.o;z(3===r.i?new Set(i):i,(function(t,o){return le(e,r,i,t,o,n)})),de(e,i,!1),n&&e.u&&te("Patches").R(r,n,e.u,e.s)}return r.o}function le(e,t,n,r,i,o){if(L(i)){var a=ue(e,i,o&&t&&3!==t.i&&!K(t.D,r)?o.concat(r):void 0);if(W(n,r,a),!L(a))return;e.m=!1}if(U(i)&&!ee(i)){if(!e.h.F&&e._<1)return;ue(e,i),t&&t.A.l||de(e,i)}}function de(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&Y(t,n)}function fe(e,t){var n=e[Se];return(n?q(n):e)[t]}function pe(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function he(e){e.P||(e.P=!0,e.l&&he(e.l))}function ve(e){e.o||(e.o=X(e.t))}function me(e,t,n){var r=G(t)?te("MapSet").N(t,n):$(t)?te("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:ne(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,o=Ee;n&&(i=[r],o=Ie);var a=Proxy.revocable(i,o),s=a.revoke,c=a.proxy;return r.k=c,r.j=s,c}(t,n):te("ES5").J(t,n);return(n?n.A:ne()).p.push(r),r}function ge(e){return L(e)||_(22,e),function e(t){if(!U(t))return t;var n,r=t[Se],i=B(t);if(r){if(!r.P&&(r.i<4||!te("ES5").K(r)))return r.t;r.I=!0,n=xe(t,i),r.I=!1}else n=xe(t,i);return z(n,(function(t,i){r&&V(r.t,t)===i||W(n,t,e(i))})),3===i?new Set(n):n}(e)}function xe(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return X(e)}var be,je,ye="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),ke="undefined"!=typeof Map,Ce="undefined"!=typeof Set,Ze="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,we=ye?Symbol.for("immer-nothing"):((be={})["immer-nothing"]=!0,be),Pe=ye?Symbol.for("immer-draftable"):"__$immer_draftable",Se=ye?Symbol.for("immer-state"):"__$immer_state",Fe=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),Ne="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Oe=Object.getOwnPropertyDescriptors||function(e){var t={};return Ne(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Ae={},Ee={get:function(e,t){if(t===Se)return e;var n=q(e);if(!K(n,t))return function(e,t,n){var r,i=pe(t,n);return i?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!U(r)?r:r===fe(e.t,t)?(ve(e),e.o[t]=me(e.A.h,r,e)):r},has:function(e,t){return t in q(e)},ownKeys:function(e){return Reflect.ownKeys(q(e))},set:function(e,t,n){var r=pe(q(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=fe(q(e),t),o=null==i?void 0:i[Se];if(o&&o.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(J(n,i)&&(void 0!==n||K(e.t,t)))return!0;ve(e),he(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==fe(e.t,t)||t in e.t?(e.D[t]=!1,ve(e),he(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=q(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){_(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){_(12)}},Ie={};z(Ee,(function(e,t){Ie[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ie.deleteProperty=function(e,t){return Ie.set.call(this,e,t,void 0)},Ie.set=function(e,t,n){return Ee.set.call(this,e[0],t,n,e[0])};var Me=function(){function e(e){var t=this;this.g=Ze,this.F=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var o=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,a=Array(r>1?r-1:0),s=1;s1?r-1:0),o=1;o=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=te("Patches").$;return L(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}(),Te=new Me,Re=Te.produce,De=(Te.produceWithPatches.bind(Te),Te.setAutoFreeze.bind(Te),Te.setUseProxies.bind(Te),Te.applyPatches.bind(Te),Te.createDraft.bind(Te),Te.finishDraft.bind(Te),Re);function He(e,t){return(0,p.useReducer)((function(t,n){return De(t,(function(t){e[n.action](t,n.payload)}))}),t)}function _e(e){var t=(0,p.useState)(e),n=(0,d.Z)(t,2),r=n[0],i=n[1];return(0,p.useEffect)((function(){i(e)}),[e]),[r,i]}var Le=0,Ue=1,ze=function(e){var t,n=(0,p.useState)(null!==(t=e.mode)&&void 0!==t?t:Le),r=(0,d.Z)(n,2),i=r[0],o=r[1],a=_e(e.value),s=(0,d.Z)(a,2),c=s[0],u=s[1],l=function(){return(0,v.jsx)("span",{style:(0,F.Z)({cursor:"text"},H("full","inline")),onClick:function(){o(Ue)},children:c})},f=(0,p.useCallback)((function(e){return null===e||void 0===e?void 0:e.select()}),[]),h=(0,p.useCallback)((function(t){var n,r;o(Le),u(null!==(n=t.value)&&void 0!==n?n:""),e.onChange(null!==(r=t.value)&&void 0!==r?r:"")}),[e,o,u]),m=function(){var e=(0,v.jsx)("span",{style:{display:"block",position:"relative"},children:(0,v.jsx)("input",{ref:f,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem"},onBlur:function(e){var t=e.target;return h(t)},onKeyPress:function(e){var t=e.key,n=e.target;"Enter"===t&&h(n)},type:"text",defaultValue:c})});return e};return function(){switch(i){case Ue:return m();case Le:return l();default:return(0,v.jsx)("span",{})}}()};function Be(e,t,n){var r=t.totalHeight,i=t.toleranceHeight,o=t.bufferedItems,a=t.settings,s=a.itemHeight,c=a.minIndex,u=a.maxIndex,l=c+Math.floor((e-i)/s),d=function(e,t,n,r,i){var o=Math.max(0,e,n),a=i(o,Math.min(t,n+r-1)-o);return(0,h.Z)(a)}(c,u,l,o,n),f=Math.max((l-c)*s,0);return{scrollTop:e,topPaddingHeight:f,bottomPaddingHeight:Math.max(r-(f+d.length*s),0),data:d}}var Ke=function(e){var t,n=(0,p.useRef)(null),r=(0,p.useMemo)((function(){var t,n=function(e){var t=e.minIndex,n=void 0===t?0:t,r=e.maxIndex,i=void 0===r?Number.MAX_SAFE_INTEGER:r,o=e.startIndex,a=void 0===o?0:o,s=e.itemHeight,c=void 0===s?20:s,u=e.count,l=void 0===u?Math.max(i-n,1):u,d=e.tolerance;return{minIndex:n,maxIndex:i,startIndex:a,itemHeight:c,count:l,tolerance:void 0===d?l:d}}(null!==(t=e.settings)&&void 0!==t?t:{}),r=function(e,t){var n=e.minIndex,r=e.maxIndex,i=e.startIndex,o=e.itemHeight,a=e.count,s=e.tolerance,c=a+2*s,u=Math.max(0,i-s-n),l=a*o,d=Math.min(r-n,1)*o,f=s*o,p=u*o,h={scrollTop:0,settings:e,viewportHeight:l,totalHeight:d,toleranceHeight:f,bufferedItems:c,topPaddingHeight:p,bottomPaddingHeight:d-(p+(l+2*f)),data:[]};return(0,F.Z)((0,F.Z)({},h),Be(p+f,h,t))}(n,e.get),i=function(e){return function(t,n){return(0,F.Z)((0,F.Z)({},t),Be(n,t,e))}}(e.get);return{settings:n,reducer:i,startState:r}}),[e.settings,e.get]),i=r.settings,o=r.startState,a=r.reducer,s=(0,p.useReducer)(a,o),c=(0,d.Z)(s,2),u=c[0],l=c[1];(0,p.useEffect)((function(){null!==n.current&&l(n.current.scrollTop)}),[i,e.row]);var f=(0,p.useCallback)((function(e){e&&(e.scrollTop=n.current?n.current.scrollTop:i.startIndex*i.itemHeight),n.current=e}),[n,i.startIndex,i.itemHeight]),h=u.data.map((function(t){return(0,v.jsx)("div",{style:{height:"".concat(i.itemHeight,"px")},children:e.row(t)},e.rowKey(t))}));return(0,v.jsxs)("div",{ref:f,style:{height:"".concat(u.viewportHeight,"px"),overflowY:"scroll",overflowAnchor:"none"},className:null!==(t=e.className)&&void 0!==t?t:"",onScroll:function(e){return l(e.target.scrollTop)},children:[(0,v.jsx)("div",{style:{height:"".concat(u.topPaddingHeight,"px")}}),h,(0,v.jsx)("div",{style:{height:"".concat(u.bottomPaddingHeight,"px")}})]})},Ve=function(e){var t=e.memory,n=e.jmp,r=void 0===n?{value:0}:n,i=e.highlight,o=void 0===i?-1:i,a=e.editable,s=void 0!==a&&a,c=e.format,u=void 0===c?C.E_:c,l=e.onChange,f=void 0===l?function(){}:l,h=(0,p.useMemo)((function(){return{count:Math.min(t.size,20),maxIndex:t.size,itemHeight:34,startIndex:r.value}}),[t.size,r]),m=(0,p.useCallback)((function(e,n){return t.range(e,e+n).map((function(t,n){return[n+e,t]}))}),[t]),g=(0,p.useCallback)((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)(We,{index:n,value:u(r),editable:s,highlight:n===o,onChange:f})}),[u,s,o,f]);return(0,v.jsx)(Ke,{settings:h,get:m,row:g,rowKey:function(e){return(0,d.Z)(e,1)[0]}})},We=function(e){var t=e.index,n=e.value,r=e.highlight,i=void 0!==r&&r,o=e.editable,a=void 0!==o&&o,s=e.onChange,c=void 0===s?function(){}:s;return(0,v.jsxs)("div",{style:{display:"flex",height:"100%"},children:[(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:(0,C.$v)(t)}),(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({flex:"1",textAlign:"right"},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:a?(0,v.jsx)(ze,{value:n,onChange:function(e){return c(t,e,Number(n))}}):(0,v.jsx)("span",{children:n})})]})},Je=function(e){var t=e.name,n=void 0===t?"Memory":t,r=e.highlight,i=void 0===r?-1:r,o=e.editable,a=void 0===o||o,s=e.memory,c=e.format,u=void 0===c?"dec":c,l=(0,p.useState)(u),f=(0,d.Z)(l,2),h=f[0],m=f[1],g=(0,p.useState)("0"),x=(0,d.Z)(g,2),b=x[0],j=x[1],y=(0,p.useState)({value:0}),k=(0,d.Z)(y,2),Z=k[0],w=k[1],P=function(){w({value:Number(b)})},S=(0,p.useCallback)((function(e,t){s.update(e,t,null!==h&&void 0!==h?h:"dec")}),[s,h]);return(0,v.jsxs)("article",{className:"panel",children:[(0,v.jsxs)("header",{children:[(0,v.jsx)("div",{children:n}),(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:function(){},className:"flex-0",children:"\ud83d\udcc2"}),(0,v.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Goto",onKeyDown:function(e){return"Enter"===e.key&&P()},onChange:function(e){var t=e.target.value;return j(null!==t&&void 0!==t?t:"0")}}),(0,v.jsx)("button",{onClick:P,className:"flex-0",children:"\u2935\ufe0f"}),R.I2.map((function(e){return(0,v.jsxs)("label",{className:"flex-0",role:"button","aria-current":e===h,children:[(0,v.jsx)("input",{type:"radio",name:n,value:e,checked:e===h,onChange:function(){return m(e)}}),e]},e)}))]})]}),(0,v.jsx)(Ve,{jmp:Z,memory:s,highlight:i,editable:a,format:function(e){return function(e,t){switch(e){case"bin":return(0,C.Ly)(t);case"hex":return(0,C.$v)(t);case"asm":return(0,D.a)(t);default:return(0,C.E_)(t)}}(h,e)},onChange:S})]})};var Ge=n(5541),$e=n(4408),qe=n(6531);function Xe(){return(0,$e.j)(qe.S.get())}var Ye=function(){var e=function(){var e=(0,p.useState)(Xe()),t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,p.useEffect)((function(){var e=qe.S.get().$.subscribe((function(){r(Xe())}));return function(){return e.unsubscribe()}}),[]),n}();return(0,v.jsx)("span",{style:{whiteSpace:"nowrap"},children:e})},Qe="white";function et(e,t,n){return 0===(e.get(32*n+(t/16|0))&1<0?(0,v.jsx)(v.Fragment,{children:r}):void 0}var it=n(8582),ot=n(1585);function at(e){return{pin:e,bits:(0,ot.w)(0,e.width).map((function(t){return[t,e.voltage(t)]})).reverse()}}function st(e){return(0,h.Z)(e.entries()).map(at)}var ct=function(e){var t=e.sim,n=t.inPins,r=t.outPins,i=t.internalPins;return(0,v.jsxs)(v.Fragment,{children:[(0,v.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,v.jsx)("table",{className:"pinout",children:(0,v.jsxs)("tbody",{children:[(0,v.jsx)(ut,{pins:n,header:"Input pins",toggle:e.toggle}),(0,v.jsx)(ut,{pins:r,header:"Output pins",disabled:e.sim.pending}),(0,v.jsx)(ut,{pins:i,header:"Internal pins",disabled:e.sim.pending})]})})]})},ut=function(e){return(0,v.jsxs)(v.Fragment,{children:[e.pins.length>0&&(0,v.jsx)("tr",{children:(0,v.jsx)("th",{colSpan:2,children:e.header})}),(0,h.Z)(e.pins).map((function(t){return(0,v.jsxs)("tr",{children:[(0,v.jsx)("td",{children:t.pin.name}),(0,v.jsx)("td",{children:(0,v.jsx)(lt,{pin:t,toggle:e.toggle,disabled:e.disabled})})]},t.pin.name)}))]})},lt=function(e){var t=e.pin,n=e.toggle,r=e.disabled,i=void 0!==r&&r;return(0,v.jsx)("fieldset",{role:"group",style:{width:"".concat(t.bits.length,"rem")},children:t.bits.map((function(e){var r=(0,d.Z)(e,2),o=r[0],a=r[1];return(0,v.jsx)("button",{onClick:function(){return null===n||void 0===n?void 0:n(t.pin,o)},disabled:i,"data-testid":"pin-".concat(o),children:a},o)}))})};var dt=function(e){var t=function(e){var t=(0,p.useRef)((function(){})),n=(0,p.useMemo)((function(){return function(e,t){var n={running:e.running,speed:e.speed,steps:e.steps},r=e.finishFrame.bind(e);return e.finishFrame=function(){r(),t.current({action:"update"})},{initialState:n,reducers:{update:function(t){t.running=e.running,t.speed=e.speed,t.steps=e.steps},setSteps:function(t,n){t.steps=n,e.steps=n},setSpeed:function(t,n){t.speed=n,e.speed=n}},actions:{frame:function(){e.frame()},start:function(){e.start(),t.current({action:"update"})},stop:function(){e.stop(),t.current({action:"update"})},reset:function(){e.reset(),t.current({action:"update"})}}}}(e,t)}),[e,t]),r=n.initialState,i=n.reducers,o=n.actions,a=He(i,r),s=(0,d.Z)(a,2),c=s[0],u=s[1];return t.current=u,{state:c,dispatch:t.current,actions:o}}(e.runner);return(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.frame()},"data-tooltip":"Step","data-placement":"bottom",children:"\u27a1\ufe0f"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.state.running?t.actions.stop():t.actions.start()},"data-tooltip":t.state.running?"Pause":"Play","data-placement":"bottom",children:t.state.running?"\u23f8":"\ufe0f\u23e9"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.reset()},"data-tooltip":"Reset","data-placement":"bottom",children:"\u23ee"}),(0,v.jsx)("select",{className:"flex-1",name:"speed",value:t.state.speed,onChange:function(e){var n,r;t.dispatch({action:"setSpeed",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.speed)})},disabled:t.state.running,children:[[1e3,"Slow"],[500,"Fast"],[16,"Faster"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{className:"flex-1",name:"steps",value:t.state.steps,onChange:function(e){var n,r;t.dispatch({action:"setSteps",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.steps)})},disabled:t.state.running,children:[[1,"1 Step"],[500,"500"],[1e3,"1000"],[2e3,"2000"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),e.children]})},ft=n(8365),pt=n(8090),ht=n(9647),vt=n(7538),mt=n(4649),gt=n(2648),xt=n(3943),bt=qe.S.get(),jt=new WeakMap,yt=new WeakMap,kt=new WeakMap,Ct=new WeakMap,Zt=function(){function e(){var t=this;(0,r.Z)(this,e),(0,mt.Z)(this,"steps",1),(0,mt.Z)(this,"speed",1e3),(0,vt.Z)(this,jt,{writable:!0,value:!1}),(0,vt.Z)(this,yt,{writable:!0,value:0}),(0,vt.Z)(this,kt,{writable:!0,value:0}),(0,vt.Z)(this,Ct,{writable:!0,value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){var n,r,i,o;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((0,xt.Z)(t,jt)){e.next=2;break}return e.abrupt("return");case 2:if(n=Date.now(),r=n-(0,xt.Z)(t,kt),(0,gt.Z)(t,kt,n),(0,gt.Z)(t,yt,(0,xt.Z)(t,yt)+r),!((0,xt.Z)(t,yt)>t.speed)){e.next=19;break}i=!1,o=0;case 9:if(!(o0&&void 0!==arguments[0]?arguments[0]:"";return n(e)},language:r,onMount:g})})},It=function(e){var t=e.className,n=void 0===t?"":t,r=e.style,i=void 0===r?{}:r,o=e.disabled,a=void 0!==o&&o,s=e.value,c=e.onChange,u=e.grammar,l=e.language,f=e.highlight,h=(0,p.useState)(),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=(0,p.useContext)(wt.Il).monaco,j=(0,p.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=u.match(e);x(t.failed()?t:void 0)}),[x,u]);(0,p.useEffect)((function(){return j(s)}),[j,s]);var y=(0,p.useMemo)((function(){return function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;return function(){for(var r=arguments.length,i=new Array(r),o=0;o0&&void 0!==arguments[0]?arguments[0]:"";c(e),y(e)}),[y,c]);return(0,v.jsx)("div",{className:"Editor ".concat(n),style:i,children:b.canUse&&b.wants?(0,v.jsx)(Et,{value:s,onChange:k,language:l,error:g,disabled:a,highlight:f}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(At,{value:s,onChange:k,language:l,disabled:a}),(0,v.jsx)(Ot,{error:g})]})})},Mt=function(e){var t;return(0,v.jsxs)("article",{className:["panel",null!==(t=e.className)&&void 0!==t?t:""].join(" "),children:[e.header&&(0,v.jsx)("header",{children:e.header}),(0,v.jsx)("main",{children:e.children}),e.footer&&(0,v.jsx)("footer",{children:e.footer})]})},Tt=function(e){var t;return(0,v.jsxs)("details",{className:null!==(t=e.className)&&void 0!==t?t:"",open:e.open,style:e.style,children:[(0,v.jsx)("summary",{children:(0,v.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})},Rt=n(726),Dt=n(4625),Ht=n(691),_t=n(1277),Lt=n(3389),Ut=n(8698),zt=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function Bt(e){return"CHIP ".concat(e," {\n IN in;\n OUT out;\n PARTS:\n}")}function Kt(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:e.clocked,inPins:st(e.ins),outPins:st(e.outs),internalPins:st(e.pins),chip:[e],pending:t,invalid:n}}var Vt=qe.S.get();function Wt(e,t,n,r){var i=function(e){var t,n,r=null!==(t=e["/chip/project"])&&void 0!==t?t:"01",i=_t.CHIP_PROJECTS[r];return{project:r,chips:i,chipName:null!==(n=e["/chip/chip"])&&void 0!==n?n:i[0]}}(n),o=i.project,a=i.chipName,s=i.chips,c=new j.P9,f=new Lt.l1,p=!1,v={setFiles:function(e,t){var n=t.hdl,r=void 0===n?e.files.hdl:n,i=t.tst,o=void 0===i?e.files.tst:i,a=t.cmp,s=void 0===a?e.files.cmp:a,c=t.out,u=void 0===c?"":c;e.files.hdl=r,e.files.tst=o,e.files.cmp=s,e.files.out=u},updateChip:function(e,t){var n,r,i,o,s,u;e.sim=Kt(c,null!==(n=null===t||void 0===t?void 0:t.pending)&&void 0!==n?n:e.sim.pending,null!==(r=null===t||void 0===t?void 0:t.invalid)&&void 0!==r?r:e.sim.invalid),e.controls.error=e.sim.invalid?null!==(i=null===t||void 0===t?void 0:t.error)&&void 0!==i?i:e.controls.error:"",e.controls.chips=_t.CHIP_PROJECTS[e.controls.project],e.controls.chipName=e.sim.invalid?null!==(o=null===t||void 0===t?void 0:t.chipName)&&void 0!==o?o:a:null!==(s=null!==(u=c.name)&&void 0!==u?u:null===t||void 0===t?void 0:t.chipName)&&void 0!==s?s:a,e.controls.chips.includes(e.controls.chipName)||(e.controls.chips=[].concat((0,h.Z)(e.controls.chips),[e.controls.chipName]))},setProject:function(e,t){var n=_t.CHIP_PROJECTS[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:function(e,t){e.controls.chipName=t,e.controls.hasBuiltin=g.zZ.has(t)},testRunning:function(e){e.controls.runningTest=!0},testFinished:function(e){e.controls.runningTest=!1;var n=e.files.out.trim()===e.files.cmp.trim();t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep:function(e){var t,n,r,i;if(e.files.out=null!==(t=null===(n=f)||void 0===n?void 0:n.log())&&void 0!==t?t:"",null!==(r=f)&&void 0!==r&&null!==(i=r.currentStep)&&void 0!==i&&i.span)e.controls.span=f.currentStep.span;else if(f.done){var o=e.files.tst.length;e.controls.span={start:o-1,end:o}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})}},m={setProject:function(e){o=n["/chip/project"]=e,r.current({action:"setProject",payload:o}),this.setChip(_t.CHIP_PROJECTS[o][0])},setChip:function(e){var t=arguments,i=this;return(0,l.Z)((0,u.Z)().mark((function o(){var s,c;return(0,u.Z)().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return c=t.length>1&&void 0!==t[1]?t[1]:null!==(s=n["/chip/project"])&&void 0!==s?s:"01",a=n["/chip/chip"]=e,r.current({action:"setChip",payload:a}),o.next=5,i.loadChip(c,a);case 5:p&&i.useBuiltin();case 6:case"end":return o.stop()}}),o)})))()},reset:function(){qe.S.get().reset(),c.reset(),f.reset(),r.current({action:"setFiles",payload:{}}),r.current({action:"updateChip"})},updateFiles:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var o,a,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(o=e.hdl,a=e.tst,s=e.cmp,r.current({action:"setFiles",payload:{hdl:o,tst:a,cmp:s}}),i.prev=2,!o){i.next=6;break}return i.next=6,n.compileChip(o);case 6:a&&n.compileTest(a),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),t((0,$e.j)(i.t0));case 12:case"end":return i.stop()}}),i,null,[[2,9]])})))()},compileChip:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var o,a,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(c.remove(),o=pt.Gq.parse(e),!(0,Dt.dZ)(o)){i.next=6;break}return t("Failed to parse chip"),r.current({action:"updateChip",payload:{invalid:!0,error:(0,$e.j)((0,Dt.UG)(o))}}),i.abrupt("return");case 6:return i.next=8,(0,Ht.J_)((0,Dt.Ok)(o));case 8:if(a=i.sent,!(0,Dt.dZ)(a)){i.next=14;break}return s=(0,$e.j)((0,Dt.UG)(a)),t(s),r.current({action:"updateChip",payload:{invalid:!0,error:s}}),i.abrupt("return");case 14:t("Compiled ".concat(c.name)),n.replaceChip((0,Dt.Ok)(a));case 16:case"end":return i.stop()}}),i)})))()},replaceChip:function(e){var t,n=c.ins,i=(0,Rt.Z)(n);try{for(i.s();!(t=i.n()).done;){var o=(0,d.Z)(t.value,2),a=o[0],s=o[1].busVoltage,u=e.ins.get(a);u&&(u.busVoltage=s)}}catch(l){i.e(l)}finally{i.f()}Vt.reset(),e.eval(),(c=e).reset(),f=f.with(c).reset(),r.current({action:"updateChip",payload:{invalid:!1}}),r.current({action:"updateTestStep"})},loadChip:function(t,i){var o=this;return(0,l.Z)((0,u.Z)().mark((function a(){var s,c,l,f,p,h;return(0,u.Z)().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return n["/chip/chip"]=i,s=function(e){return"/projects/".concat(t,"/").concat(i,"/").concat(i,".").concat(e)},a.next=4,Promise.all([e.readFile(s("hdl")).catch((function(){return Bt(i)})),e.readFile(s("tst")).catch((function(e){return console.log(e),"repeat 10 {\n tick,\n tock;\n}"})),e.readFile(s("cmp")).catch((function(){return"| in|out|"}))]);case 4:return c=a.sent,l=(0,d.Z)(c,3),f=l[0],p=l[1],h=l[2],r.current({action:"setFiles",payload:{hdl:f,tst:p,cmp:h}}),a.next=12,o.compileChip(f);case 12:o.compileTest(p);case 13:case"end":return a.stop()}}),a)})))()},saveChip:function(n){var i=arguments;return(0,l.Z)((0,u.Z)().mark((function s(){var c,l,d;return(0,u.Z)().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return c=i.length>1&&void 0!==i[1]?i[1]:o,l=i.length>2&&void 0!==i[2]?i[2]:a,r.current({action:"setFiles",payload:{hdl:n}}),d="/projects/".concat(c,"/").concat(l,"/").concat(l,".hdl"),s.next=6,e.writeFile(d,n);case 6:t("Saved ".concat(d));case 7:case"end":return s.stop()}}),s)})))()},toggle:function(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<0&&void 0!==e[0])||e[0],d=e.length>1?e[1]:void 0,l){i.next=7;break}return p=!1,i.next=6,n.loadChip(o,a);case 6:return i.abrupt("return");case 7:if(p=!0,f=null!==(s=c.name)&&void 0!==s?s:a,h=(0,g.cT)(f),!(0,Dt.dZ)(h)){i.next=13;break}return t("Failed to load builtin ".concat(f,": ").concat((0,$e.j)((0,Dt.UG)(h)))),i.abrupt("return");case 13:if(!d){i.next=16;break}return i.next=16,n.saveChip(d,o,a);case 16:v=_t.ChipProjects[o].CHIPS[f]["".concat(f,".hdl")],m=v.replace("PARTS:","PARTS:\n BUILTIN ".concat(f)),r.current({action:"setFiles",payload:{hdl:m}}),n.replaceChip((0,Dt.Ok)(h));case 20:case"end":return i.stop()}}),i)})))()},initialize:function(){var e=this;return(0,l.Z)((0,u.Z)().mark((function t(){return(0,u.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.loadChip(o,a);case 2:case"end":return t.stop()}}),t)})))()},compileTest:function(n){r.current({action:"setFiles",payload:{tst:n}});var i=ht.qH.parse(n);return(0,Dt.dZ)(i)?(t("Failed to parse test"),!1):(t("Parsed tst"),(f=Lt.l1.from((0,Dt.Ok)(i)).with(c).reset()).setFileSystem(e),r.current({action:"updateTestStep"}),!0)},runTest:function(t){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n.compileTest(t)){i.next=2;break}return i.abrupt("return");case 2:return r.current({action:"testRunning"}),e.pushd("/samples"),i.next=6,f.run();case 6:e.popd(),r.current({action:"updateTestStep"}),r.current({action:"testFinished"});case 9:case"end":return i.stop()}}),i)})))()},tick:function(){return this.stepTest()},stepTest:function(){return(0,l.Z)((0,u.Z)().mark((function e(){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(0,Ge.hu)(f.chipId===c.id,"Test and chip out of sync"),e.next=3,f.step();case 3:return t=e.sent,r.current({action:"updateTestStep"}),t&&r.current({action:"testFinished"}),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))()}};return{initialState:function(){var e={project:o,chips:s,chipName:a,hasBuiltin:g.zZ.has(a),runningTest:!1,error:""},n=(0,g.cT)(e.chipName);return(0,Dt.dZ)(n)?(t((0,$e.j)((0,Dt.UG)(n))),c=new j.P9):c=(0,Dt.Ok)(n),{controls:e,files:{hdl:"",cmp:"",tst:"",out:""},sim:Kt(c)}}(),reducers:v,actions:m}}var Jt=function(){var e=(0,p.useContext)(Ut.r),t=e.fs,n=e.setStatus,m=(0,p.useContext)(wt.Il),g=m.filePicker,x=m.tracking,b=function(){var e=(0,p.useContext)(Ut.r),t=e.fs,n=e.setStatus,r=e.storage,i=(0,p.useRef)((function(){})),o=(0,p.useMemo)((function(){return Wt(t,n,r,i)}),[t,n,r,i]),a=o.initialState,s=o.reducers,c=o.actions,u=He(s,a),l=(0,d.Z)(u,2),f=l[0],h=l[1];return i.current=h,{state:f,dispatch:i,actions:c}}(),j=b.state,y=b.actions,k=b.dispatch,C=_e(j.files.hdl),Z=(0,d.Z)(C,2),w=Z[0],P=Z[1],S=_e(j.files.tst),F=(0,d.Z)(S,2),N=F[0],O=F[1],A=_e(j.files.cmp),E=(0,d.Z)(A,2),I=E[0],M=E[1],T=_e(j.files.out),R=(0,d.Z)(T,1)[0];(0,p.useEffect)((function(){y.initialize()}),[y]),(0,p.useEffect)((function(){x.trackPage("/chip")}),[x]);(0,p.useEffect)((function(){x.trackEvent("action","setProject",j.controls.project),x.trackEvent("action","setChip",j.controls.chipName)}),[]);var D=(0,p.useCallback)((function(e){y.setProject(e),x.trackEvent("action","setProject",e)}),[y,x]),H=(0,p.useCallback)((function(e){y.setChip(e),x.trackEvent("action","setChip",e)}),[y,x]),_=(0,p.useCallback)((function(){y.eval(),x.trackEvent("action","eval")}),[y,x]),L=(0,p.useRef)((function(){}));L.current=(0,l.Z)((0,u.Z)().mark((function e(){var t,n,r,i=arguments;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:{},e.next=3,y.updateFiles({hdl:r.hdl,tst:null!==(t=r.tst)&&void 0!==t?t:N,cmp:null!==(n=r.cmp)&&void 0!==n?n:I});case 3:case"end":return e.stop()}}),e)})));var U=(0,p.useCallback)((0,l.Z)((0,u.Z)().mark((function e(){var r,i;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g.select();case 3:return r=e.sent,e.next=6,t.readFile(r);case 6:return i=e.sent,e.next=9,L.current({tst:i});case 9:e.next=15;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0),n("Failed to load into memory");case 15:case"end":return e.stop()}}),e,null,[[0,11]])}))),[g,n,t,L]),z=(0,p.useRef)();(0,p.useEffect)((function(){return z.current=new(function(e){(0,s.Z)(n,e);var t=(0,c.Z)(n);function n(){return(0,r.Z)(this,n),t.apply(this,arguments)}return(0,i.Z)(n,[{key:"reset",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L.current();case 2:return e.next=4,y.reset();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"finishFrame",value:function(){(0,o.Z)((0,a.Z)(n.prototype),"finishFrame",this).call(this),k.current({action:"updateTestStep"})}},{key:"tick",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",y.stepTest());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"toggle",value:function(){k.current({action:"updateTestStep"})}}]),n}(Zt)),function(){var e;null===(e=z.current)||void 0===e||e.stop()}}),[L,y,k]);var B=(0,p.useMemo)((function(){return{toggle:function(){y.clock(),x.trackEvent("action","toggleClock")},reset:function(){x.trackEvent("action","resetClock"),y.reset()}}}),[y]),K=(0,p.useState)(!1),V=(0,d.Z)(K,2),W=V[0],J=V[1],G=(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("select",{value:j.controls.project,onChange:function(e){var t=e.target.value;D(t)},"data-testid":"project-picker",children:zt.map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{value:j.controls.chipName,onChange:function(e){var t=e.target.value;H(t)},"data-testid":"chip-picker",children:j.controls.chips.map((function(e){return(0,v.jsx)("option",{value:e,children:e},e)}))}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){y.saveChip(w)},disabled:W,children:(0,v.jsx)(f.cC,{id:"Save"})})]})}),$=(0,v.jsx)(Mt,{className:"_hdl_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{tabIndex:0,children:"HDL"}),(0,v.jsx)("fieldset",{children:j.controls.hasBuiltin&&(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"checkbox",role:"switch",checked:W,onChange:function(){W?(J(!1),y.useBuiltin(!1)):(J(!0),y.useBuiltin(!0,w))}}),(0,v.jsx)(f.cC,{id:"Builtin"})]})}),G]}),children:(0,v.jsx)(It,{className:"flex-1",value:w,onChange:function(e){P(e),L.current(W?{}:{hdl:e})},grammar:pt.Gq.parser,language:"hdl",disabled:W})}),q=(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:_,onKeyDown:_,disabled:!j.sim.pending,children:(0,v.jsx)(f.cC,{id:"Eval"})}),(0,v.jsxs)("button",{onClick:B.toggle,style:{maxWidth:"initial"},disabled:!j.sim.clocked,children:[(0,v.jsx)(f.cC,{id:"Clock"}),":","\xa0",(0,v.jsx)(Ye,{})]}),(0,v.jsx)("button",{onClick:B.reset,style:{maxWidth:"initial"},disabled:!j.sim.clocked,children:(0,v.jsx)(f.cC,{id:"Reset"})})]}),X=function(e){return(0,h.Z)(e.parts).map((function(e,t){return["".concat(e.id,"_").concat(t),rt(e)]})).filter((function(e){var t=(0,d.Z)(e,2);return t[0],void 0!==t[1]}))}({parts:j.sim.chip}),Y=(0,v.jsx)(Mt,{className:"_parts_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{children:(0,v.jsx)(f.cC,{id:"Chip"})}),q]}),children:j.sim.invalid?(0,v.jsx)(f.cC,{id:"Invalid Chip"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ct,{sim:j.sim,toggle:y.toggle}),X.length>0&&(0,v.jsx)(Tt,{summary:(0,v.jsx)(f.cC,{id:"Visualizations"}),open:!0,children:(0,v.jsx)("main",{children:X.map((function(e){var t=(0,d.Z)(e,2);t[0];return t[1]}))})})]})}),Q=(0,p.useState)("tst"),ee=(0,d.Z)(Q,2),te=ee[0],ne=ee[1],re=(0,p.useCallback)((function(e){ne(e),x.trackEvent("tab","change",e)}),[x]),ie=(0,v.jsx)(Mt,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(f.cC,{id:"Test"})}),(0,v.jsx)("div",{className:"flex-2",children:z.current&&(0,v.jsx)(dt,{runner:z.current})}),(0,v.jsx)("div",{children:(0,v.jsxs)("button",{onClick:U,children:[(0,v.jsx)(Pt.J,{name:"upload_file"})," "]})})]}),children:(0,v.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,v.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===te,onChange:function(){return re("tst")}}),"Test Script"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,v.jsx)(It,{value:N,onChange:O,grammar:ht.qH.parser,language:"tst",highlight:j.controls.span})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===te,onChange:function(){return re("cmp")}}),"Compare File"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,v.jsx)(It,{value:I,onChange:M,grammar:ft.lA.parser,language:"cmp"})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===te,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===te,onChange:function(){return re("out")}}),"Output File"]})}),(0,v.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,v.jsx)(it.M,{cmp:I,out:R})})]})});return(0,v.jsxs)("div",{className:"ChipPage grid",children:[$,Y,ie]})},Gt=Jt}}]); +//# sourceMappingURL=605.764609f0.chunk.js.map \ No newline at end of file diff --git a/static/js/605.764609f0.chunk.js.map b/static/js/605.764609f0.chunk.js.map new file mode 100644 index 00000000..f9b2efd9 --- /dev/null +++ b/static/js/605.764609f0.chunk.js.map @@ -0,0 +1 @@ +{"version":3,"file":"static/js/605.764609f0.chunk.js","mappings":"qZAOaA,EAAe,SA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8X,GAAmB,MAAM,IACzC,oBAIN,gBACE9S,KAAK,WACL,kBAAgB,eAChBmD,GAAG,oBAAmB,UAEtB,SAACsH,GAAM,CACL/c,MAAOwf,EACPlS,SAAU0W,EACVhH,QAASgG,GAAAA,GAAAA,OACTrJ,SAAU,MACV1I,UAAWnP,EAAM6d,SAASc,UAG9B,gBACEnO,KAAK,MACLmD,GAAG,eACH,gBAAc,qBACd,gBAAmC,QAApByP,GAA0B,UAEzC,8BACE,kBACE/nB,KAAK,QACLrD,KAAK,YACL,gBAAc,oBACdkG,MAAM,MACN0S,QAA6B,QAApBwS,GACT5X,SAAU,kBAAM8X,GAAmB,MAAM,IACzC,qBAIN,gBACE9S,KAAK,WACL,kBAAgB,eAChBmD,GAAG,oBACHxI,MAAO,CAAEO,SAAU,YAAa,UAEhC,SAACuP,GAAM,CACL/c,MAAOyf,EACPnS,SAAU2W,EACVjH,QAASuI,GAAAA,GAAAA,OACT5L,SAAU,WAGd,gBACErH,KAAK,MACLmD,GAAG,eACH,gBAAc,oBACd,gBAAmC,QAApByP,GAA0B,UAEzC,8BACE,kBACE/nB,KAAK,QACLrD,KAAK,YACL,gBAAc,oBACdkG,MAAM,MACN0S,QAA6B,QAApBwS,GACT5X,SAAU,kBAAM8X,GAAmB,MAAM,IACzC,oBAIN,gBACE9S,KAAK,WACLmD,GAAG,oBACH,kBAAgB,eAAc,UAE9B,SAAC,KAAS,CAACgK,IAAKA,EAAKpmB,IAAKA,WAMlC,OACE,iBAAK0D,UAAU,gBAAe,UAC3B4nB,EACAM,EACAK,KAGP,EAEA,K","sources":["../../components/src/chips/alu.tsx","../../components/src/chips/register.tsx","../../components/src/chips/keyboard.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/constants.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/core.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/border.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/sizing.js","../../node_modules/immer/src/utils/errors.ts","../../node_modules/immer/src/utils/common.ts","../../node_modules/immer/src/utils/plugins.ts","../../node_modules/immer/src/core/scope.ts","../../node_modules/immer/src/core/finalize.ts","../../node_modules/immer/src/core/proxy.ts","../../node_modules/immer/src/core/immerClass.ts","../../node_modules/immer/src/core/current.ts","../../node_modules/immer/src/immer.ts","../../node_modules/immer/src/utils/env.ts","../../components/src/react.ts","../../components/src/inline_edit.tsx","../../components/src/virtual_scroll.tsx","../../components/src/chips/memory.tsx","../../components/src/clockface.tsx","../../components/src/chips/screen.tsx","../../components/src/chips/visualizations.tsx","../../components/src/pinout.tsx","../../components/src/runbar.tsx","../../components/src/timer.tsx","../../simulator/src/timer.ts","shell/editor.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/debounce.js","shell/panel.tsx","../../components/src/stores/chip.store.ts","pages/chip.tsx"],"sourcesContent":["import {\n COMMANDS,\n COMMANDS_OP,\n Flags,\n} from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { bin } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const ALUComponent = ({\n A,\n op,\n D,\n out,\n flag,\n}: {\n A: number;\n op: COMMANDS_OP;\n D: number;\n out: number;\n flag: keyof typeof Flags;\n}) => (\n
\n ALU\n
\n
A
{bin(A)}
\n
op
{COMMANDS.op[op] ?? \"(??)\"}
\n
D
{bin(D)}
\n
=
{bin(out)}
\n
{Flags[flag as keyof typeof Flags]}
\n
\n
\n);\n","import { dec } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const RegisterComponent = ({\n name,\n bits,\n}: {\n name: string;\n bits: number;\n}) => (\n
\n {name}: {dec(bits)}\n
\n);\n","import { Keyboard as KeyboardChip } from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { KeyboardEvent, useCallback, useState } from \"react\";\nimport { RegisterComponent } from \"./register.js\";\n\nconst KeyMap: Record = {\n // Delete: 127,\n Enter: 128,\n Backspace: 129,\n ArrowLeft: 130,\n ArrowUp: 131,\n ArrowRight: 132,\n ArrowDown: 133,\n Home: 134,\n End: 135,\n PageUp: 136,\n PageDown: 137,\n Insert: 138,\n Delete: 139,\n Escape: 140,\n F1: 141,\n F2: 142,\n F3: 143,\n F4: 144,\n F5: 145,\n F6: 146,\n F7: 147,\n F8: 148,\n F9: 149,\n F10: 150,\n F11: 151,\n F12: 152,\n};\n\nfunction keyPressToHackCharacter(keypress: KeyboardEvent): number {\n const mapping = KeyMap[keypress.key];\n if (mapping !== undefined) {\n return mapping;\n }\n if (keypress.key.length === 1) {\n const code = keypress.key.charCodeAt(0);\n if (code >= 32 && code <= 126) {\n return code;\n }\n }\n\n return 0;\n}\n\nexport const Keyboard = ({ keyboard }: { keyboard: KeyboardChip }) => {\n const [showPicker, setShowPicker] = useState(false);\n const [bits, setBits] = useState(keyboard.out().busVoltage);\n\n const setKey = useCallback(\n (event: KeyboardEvent) => {\n const key = keyPressToHackCharacter(event);\n if (key === 0) {\n return;\n }\n event.preventDefault();\n keyboard.setKey(key);\n setBits(keyboard.out().busVoltage);\n setShowPicker(false);\n },\n [keyboard, setShowPicker, setBits]\n );\n\n const changeKey = useCallback(() => {\n setShowPicker(true);\n }, []);\n\n return (\n
\n
\n \n
\n
\n {showPicker ? (\n e?.focus()} type=\"text\" onKeyDown={setKey} />\n ) : (\n \n )}\n
\n
\n );\n};\n","export const Sizes = {\n none: \"0px\",\n sm: \"0.125rem\",\n \"\": \"0.25rem\",\n md: \"0.375rem\",\n lg: \"0.5rem\",\n xl: \"0.75rem\",\n \"2xl\": \"1rem\",\n \"3xl\": \"1.5rem\",\n full: \"9999px\",\n};\nexport const Sides = {\n \"\": \"\",\n t: \"Top\",\n r: \"Right\",\n l: \"Left\",\n b: \"Bottom\",\n tl: \"TopLeft\",\n tr: \"TopRight\",\n bl: \"BottomLeft\",\n br: \"BottomRight\",\n};\nexport const Widths = {\n \"1/4\": \"25%\",\n \"1/2\": \"50%\",\n \"3/4\": \"75%\",\n full: \"100%\",\n};\n","import { Sides, Sizes } from \"./constants.js\";\nexport function isSide(v) {\n return Sides[v] !== undefined;\n}\nexport function isSize(v) {\n return Sizes[v] !== undefined;\n}\nexport function getSize(size) {\n return Sizes[size];\n}\nexport function getSide(side) {\n switch (side) {\n case \"t\":\n return [...getSide(\"tl\"), ...getSide(\"tr\")];\n case \"r\":\n return [...getSide(\"tr\"), ...getSide(\"br\")];\n case \"b\":\n return [...getSide(\"br\"), ...getSide(\"bl\")];\n case \"l\":\n return [...getSide(\"tl\"), ...getSide(\"bl\")];\n default:\n return [Sides[side]];\n }\n}\n","import { isSide, getSize, getSide } from \"./core.js\";\nexport function rounded(size = \"\", side = \"\") {\n if (isSide(size)) {\n side = size;\n size = \"\";\n }\n const sized = getSize(size);\n return getSide(side).reduce((prev, curr) => {\n if (curr === \"\") {\n prev.borderRadius = sized;\n }\n else {\n // @ts-ignore\n prev[`border${curr}Radius`] = sized;\n }\n return prev;\n }, {});\n}\nexport function border({ side = \"\", style = \"solid\", radius = \"\", width = 1, color = \"black\", }) {\n return {};\n}\nexport function inset(width, color1 = \"gray\", color2 = \"lightgray\") {\n return {\n ...border({ side: \"tl\", width, color: color1, radius: \"none\" }),\n ...border({ side: \"br\", width, color: color2, radius: \"none\" }),\n };\n}\n","import { Widths } from \"./constants.js\";\nexport function width(amount, block) {\n if (amount === undefined && Widths[block] !== undefined) {\n amount = block;\n }\n return {\n ...(block === \"inline\" ? { display: \"inline-block\" } : {}),\n width: Widths[amount] ?? \"0\",\n };\n}\n","const errors = {\n\t0: \"Illegal state\",\n\t1: \"Immer drafts cannot have computed properties\",\n\t2: \"This object has been frozen and should not be mutated\",\n\t3(data: any) {\n\t\treturn (\n\t\t\t\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n\t\t\tdata\n\t\t)\n\t},\n\t4: \"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",\n\t5: \"Immer forbids circular references\",\n\t6: \"The first or second argument to `produce` must be a function\",\n\t7: \"The third argument to `produce` must be a function or undefined\",\n\t8: \"First argument to `createDraft` must be a plain object, an array, or an immerable object\",\n\t9: \"First argument to `finishDraft` must be a draft returned by `createDraft`\",\n\t10: \"The given draft is already finalized\",\n\t11: \"Object.defineProperty() cannot be used on an Immer draft\",\n\t12: \"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t13: \"Immer only supports deleting array indices\",\n\t14: \"Immer only supports setting array indices and the 'length' property\",\n\t15(path: string) {\n\t\treturn \"Cannot apply patch, path doesn't resolve: \" + path\n\t},\n\t16: 'Sets cannot have \"replace\" patches.',\n\t17(op: string) {\n\t\treturn \"Unsupported patch operation: \" + op\n\t},\n\t18(plugin: string) {\n\t\treturn `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \\`enable${plugin}()\\` when initializing your application.`\n\t},\n\t20: \"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",\n\t21(thing: string) {\n\t\treturn `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`\n\t},\n\t22(thing: string) {\n\t\treturn `'current' expects a draft, got: ${thing}`\n\t},\n\t23(thing: string) {\n\t\treturn `'original' expects a draft, got: ${thing}`\n\t},\n\t24: \"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"\n} as const\n\nexport function die(error: keyof typeof errors, ...args: any[]): never {\n\tif (__DEV__) {\n\t\tconst e = errors[error]\n\t\tconst msg = !e\n\t\t\t? \"unknown error nr: \" + error\n\t\t\t: typeof e === \"function\"\n\t\t\t? e.apply(null, args as any)\n\t\t\t: e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}${\n\t\t\targs.length ? \" \" + args.map(s => `'${s}'`).join(\",\") : \"\"\n\t\t}. Find the full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","import {\n\tDRAFT_STATE,\n\tDRAFTABLE,\n\thasSet,\n\tObjectish,\n\tDrafted,\n\tAnyObject,\n\tAnyMap,\n\tAnySet,\n\tImmerState,\n\thasMap,\n\tArchtype,\n\tdie\n} from \"../internal\"\n\n/** Returns true if the given value is an Immer draft */\n/*#__PURE__*/\nexport function isDraft(value: any): boolean {\n\treturn !!value && !!value[DRAFT_STATE]\n}\n\n/** Returns true if the given value can be drafted by Immer */\n/*#__PURE__*/\nexport function isDraftable(value: any): boolean {\n\tif (!value) return false\n\treturn (\n\t\tisPlainObject(value) ||\n\t\tArray.isArray(value) ||\n\t\t!!value[DRAFTABLE] ||\n\t\t!!value.constructor?.[DRAFTABLE] ||\n\t\tisMap(value) ||\n\t\tisSet(value)\n\t)\n}\n\nconst objectCtorString = Object.prototype.constructor.toString()\n/*#__PURE__*/\nexport function isPlainObject(value: any): boolean {\n\tif (!value || typeof value !== \"object\") return false\n\tconst proto = Object.getPrototypeOf(value)\n\tif (proto === null) {\n\t\treturn true\n\t}\n\tconst Ctor =\n\t\tObject.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n\n\tif (Ctor === Object) return true\n\n\treturn (\n\t\ttypeof Ctor == \"function\" &&\n\t\tFunction.toString.call(Ctor) === objectCtorString\n\t)\n}\n\n/** Get the underlying object that is represented by the given draft */\n/*#__PURE__*/\nexport function original(value: T): T | undefined\nexport function original(value: Drafted): any {\n\tif (!isDraft(value)) die(23, value)\n\treturn value[DRAFT_STATE].base_\n}\n\n/*#__PURE__*/\nexport const ownKeys: (target: AnyObject) => PropertyKey[] =\n\ttypeof Reflect !== \"undefined\" && Reflect.ownKeys\n\t\t? Reflect.ownKeys\n\t\t: typeof Object.getOwnPropertySymbols !== \"undefined\"\n\t\t? obj =>\n\t\t\t\tObject.getOwnPropertyNames(obj).concat(\n\t\t\t\t\tObject.getOwnPropertySymbols(obj) as any\n\t\t\t\t)\n\t\t: /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport const getOwnPropertyDescriptors =\n\tObject.getOwnPropertyDescriptors ||\n\tfunction getOwnPropertyDescriptors(target: any) {\n\t\t// Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n\t\tconst res: any = {}\n\t\townKeys(target).forEach(key => {\n\t\t\tres[key] = Object.getOwnPropertyDescriptor(target, key)\n\t\t})\n\t\treturn res\n\t}\n\nexport function each(\n\tobj: T,\n\titer: (key: string | number, value: any, source: T) => void,\n\tenumerableOnly?: boolean\n): void\nexport function each(obj: any, iter: any, enumerableOnly = false) {\n\tif (getArchtype(obj) === Archtype.Object) {\n\t\t;(enumerableOnly ? Object.keys : ownKeys)(obj).forEach(key => {\n\t\t\tif (!enumerableOnly || typeof key !== \"symbol\") iter(key, obj[key], obj)\n\t\t})\n\t} else {\n\t\tobj.forEach((entry: any, index: any) => iter(index, entry, obj))\n\t}\n}\n\n/*#__PURE__*/\nexport function getArchtype(thing: any): Archtype {\n\t/* istanbul ignore next */\n\tconst state: undefined | ImmerState = thing[DRAFT_STATE]\n\treturn state\n\t\t? state.type_ > 3\n\t\t\t? state.type_ - 4 // cause Object and Array map back from 4 and 5\n\t\t\t: (state.type_ as any) // others are the same\n\t\t: Array.isArray(thing)\n\t\t? Archtype.Array\n\t\t: isMap(thing)\n\t\t? Archtype.Map\n\t\t: isSet(thing)\n\t\t? Archtype.Set\n\t\t: Archtype.Object\n}\n\n/*#__PURE__*/\nexport function has(thing: any, prop: PropertyKey): boolean {\n\treturn getArchtype(thing) === Archtype.Map\n\t\t? thing.has(prop)\n\t\t: Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\n/*#__PURE__*/\nexport function get(thing: AnyMap | AnyObject, prop: PropertyKey): any {\n\t// @ts-ignore\n\treturn getArchtype(thing) === Archtype.Map ? thing.get(prop) : thing[prop]\n}\n\n/*#__PURE__*/\nexport function set(thing: any, propOrOldValue: PropertyKey, value: any) {\n\tconst t = getArchtype(thing)\n\tif (t === Archtype.Map) thing.set(propOrOldValue, value)\n\telse if (t === Archtype.Set) {\n\t\tthing.delete(propOrOldValue)\n\t\tthing.add(value)\n\t} else thing[propOrOldValue] = value\n}\n\n/*#__PURE__*/\nexport function is(x: any, y: any): boolean {\n\t// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n\tif (x === y) {\n\t\treturn x !== 0 || 1 / x === 1 / y\n\t} else {\n\t\treturn x !== x && y !== y\n\t}\n}\n\n/*#__PURE__*/\nexport function isMap(target: any): target is AnyMap {\n\treturn hasMap && target instanceof Map\n}\n\n/*#__PURE__*/\nexport function isSet(target: any): target is AnySet {\n\treturn hasSet && target instanceof Set\n}\n/*#__PURE__*/\nexport function latest(state: ImmerState): any {\n\treturn state.copy_ || state.base_\n}\n\n/*#__PURE__*/\nexport function shallowCopy(base: any) {\n\tif (Array.isArray(base)) return Array.prototype.slice.call(base)\n\tconst descriptors = getOwnPropertyDescriptors(base)\n\tdelete descriptors[DRAFT_STATE as any]\n\tlet keys = ownKeys(descriptors)\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tconst key: any = keys[i]\n\t\tconst desc = descriptors[key]\n\t\tif (desc.writable === false) {\n\t\t\tdesc.writable = true\n\t\t\tdesc.configurable = true\n\t\t}\n\t\t// like object.assign, we will read any _own_, get/set accessors. This helps in dealing\n\t\t// with libraries that trap values, like mobx or vue\n\t\t// unlike object.assign, non-enumerables will be copied as well\n\t\tif (desc.get || desc.set)\n\t\t\tdescriptors[key] = {\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true, // could live with !!desc.set as well here...\n\t\t\t\tenumerable: desc.enumerable,\n\t\t\t\tvalue: base[key]\n\t\t\t}\n\t}\n\treturn Object.create(Object.getPrototypeOf(base), descriptors)\n}\n\n/**\n * Freezes draftable objects. Returns the original object.\n * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.\n *\n * @param obj\n * @param deep\n */\nexport function freeze(obj: T, deep?: boolean): T\nexport function freeze(obj: any, deep: boolean = false): T {\n\tif (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj\n\tif (getArchtype(obj) > 1 /* Map or Set */) {\n\t\tobj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any\n\t}\n\tObject.freeze(obj)\n\tif (deep) each(obj, (key, value) => freeze(value, true), true)\n\treturn obj\n}\n\nfunction dontMutateFrozenCollections() {\n\tdie(2)\n}\n\nexport function isFrozen(obj: any): boolean {\n\tif (obj == null || typeof obj !== \"object\") return true\n\t// See #600, IE dies on non-objects in Object.isFrozen\n\treturn Object.isFrozen(obj)\n}\n","import {\n\tImmerState,\n\tPatch,\n\tImmerScope,\n\tDrafted,\n\tAnyObject,\n\tImmerBaseState,\n\tAnyMap,\n\tAnySet,\n\tProxyType,\n\tdie\n} from \"../internal\"\n\n/** Plugin utilities */\nconst plugins: {\n\tPatches?: {\n\t\tgeneratePatches_(\n\t\t\tstate: ImmerState,\n\t\t\tbasePath: PatchPath,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tgenerateReplacementPatches_(\n\t\t\tbase: any,\n\t\t\treplacement: any,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tapplyPatches_(draft: T, patches: Patch[]): T\n\t}\n\tES5?: {\n\t\twillFinalizeES5_(scope: ImmerScope, result: any, isReplaced: boolean): void\n\t\tcreateES5Proxy_(\n\t\t\tbase: T,\n\t\t\tparent?: ImmerState\n\t\t): Drafted\n\t\thasChanges_(state: ES5ArrayState | ES5ObjectState): boolean\n\t}\n\tMapSet?: {\n\t\tproxyMap_(target: T, parent?: ImmerState): T\n\t\tproxySet_(target: T, parent?: ImmerState): T\n\t}\n} = {}\n\ntype Plugins = typeof plugins\n\nexport function getPlugin(\n\tpluginKey: K\n): Exclude {\n\tconst plugin = plugins[pluginKey]\n\tif (!plugin) {\n\t\tdie(18, pluginKey)\n\t}\n\t// @ts-ignore\n\treturn plugin\n}\n\nexport function loadPlugin(\n\tpluginKey: K,\n\timplementation: Plugins[K]\n): void {\n\tif (!plugins[pluginKey]) plugins[pluginKey] = implementation\n}\n\n/** ES5 Plugin */\n\ninterface ES5BaseState extends ImmerBaseState {\n\tassigned_: {[key: string]: any}\n\tparent_?: ImmerState\n\trevoked_: boolean\n}\n\nexport interface ES5ObjectState extends ES5BaseState {\n\ttype_: ProxyType.ES5Object\n\tdraft_: Drafted\n\tbase_: AnyObject\n\tcopy_: AnyObject | null\n}\n\nexport interface ES5ArrayState extends ES5BaseState {\n\ttype_: ProxyType.ES5Array\n\tdraft_: Drafted\n\tbase_: any\n\tcopy_: any\n}\n\n/** Map / Set plugin */\n\nexport interface MapState extends ImmerBaseState {\n\ttype_: ProxyType.Map\n\tcopy_: AnyMap | undefined\n\tassigned_: Map | undefined\n\tbase_: AnyMap\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\nexport interface SetState extends ImmerBaseState {\n\ttype_: ProxyType.Set\n\tcopy_: AnySet | undefined\n\tbase_: AnySet\n\tdrafts_: Map // maps the original value to the draft value in the new set\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\n/** Patches plugin */\n\nexport type PatchPath = (string | number)[]\n","import {\n\tPatch,\n\tPatchListener,\n\tDrafted,\n\tImmer,\n\tDRAFT_STATE,\n\tImmerState,\n\tProxyType,\n\tgetPlugin\n} from \"../internal\"\nimport {die} from \"../utils/errors\"\n\n/** Each scope represents a `produce` call. */\n\nexport interface ImmerScope {\n\tpatches_?: Patch[]\n\tinversePatches_?: Patch[]\n\tcanAutoFreeze_: boolean\n\tdrafts_: any[]\n\tparent_?: ImmerScope\n\tpatchListener_?: PatchListener\n\timmer_: Immer\n\tunfinalizedDrafts_: number\n}\n\nlet currentScope: ImmerScope | undefined\n\nexport function getCurrentScope() {\n\tif (__DEV__ && !currentScope) die(0)\n\treturn currentScope!\n}\n\nfunction createScope(\n\tparent_: ImmerScope | undefined,\n\timmer_: Immer\n): ImmerScope {\n\treturn {\n\t\tdrafts_: [],\n\t\tparent_,\n\t\timmer_,\n\t\t// Whenever the modified draft contains a draft from another scope, we\n\t\t// need to prevent auto-freezing so the unowned draft can be finalized.\n\t\tcanAutoFreeze_: true,\n\t\tunfinalizedDrafts_: 0\n\t}\n}\n\nexport function usePatchesInScope(\n\tscope: ImmerScope,\n\tpatchListener?: PatchListener\n) {\n\tif (patchListener) {\n\t\tgetPlugin(\"Patches\") // assert we have the plugin\n\t\tscope.patches_ = []\n\t\tscope.inversePatches_ = []\n\t\tscope.patchListener_ = patchListener\n\t}\n}\n\nexport function revokeScope(scope: ImmerScope) {\n\tleaveScope(scope)\n\tscope.drafts_.forEach(revokeDraft)\n\t// @ts-ignore\n\tscope.drafts_ = null\n}\n\nexport function leaveScope(scope: ImmerScope) {\n\tif (scope === currentScope) {\n\t\tcurrentScope = scope.parent_\n\t}\n}\n\nexport function enterScope(immer: Immer) {\n\treturn (currentScope = createScope(currentScope, immer))\n}\n\nfunction revokeDraft(draft: Drafted) {\n\tconst state: ImmerState = draft[DRAFT_STATE]\n\tif (\n\t\tstate.type_ === ProxyType.ProxyObject ||\n\t\tstate.type_ === ProxyType.ProxyArray\n\t)\n\t\tstate.revoke_()\n\telse state.revoked_ = true\n}\n","import {\n\tImmerScope,\n\tDRAFT_STATE,\n\tisDraftable,\n\tNOTHING,\n\tPatchPath,\n\teach,\n\thas,\n\tfreeze,\n\tImmerState,\n\tisDraft,\n\tSetState,\n\tset,\n\tProxyType,\n\tgetPlugin,\n\tdie,\n\trevokeScope,\n\tisFrozen,\n\tshallowCopy\n} from \"../internal\"\n\nexport function processResult(result: any, scope: ImmerScope) {\n\tscope.unfinalizedDrafts_ = scope.drafts_.length\n\tconst baseDraft = scope.drafts_![0]\n\tconst isReplaced = result !== undefined && result !== baseDraft\n\tif (!scope.immer_.useProxies_)\n\t\tgetPlugin(\"ES5\").willFinalizeES5_(scope, result, isReplaced)\n\tif (isReplaced) {\n\t\tif (baseDraft[DRAFT_STATE].modified_) {\n\t\t\trevokeScope(scope)\n\t\t\tdie(4)\n\t\t}\n\t\tif (isDraftable(result)) {\n\t\t\t// Finalize the result in case it contains (or is) a subset of the draft.\n\t\t\tresult = finalize(scope, result)\n\t\t\tif (!scope.parent_) maybeFreeze(scope, result)\n\t\t}\n\t\tif (scope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(\n\t\t\t\tbaseDraft[DRAFT_STATE].base_,\n\t\t\t\tresult,\n\t\t\t\tscope.patches_,\n\t\t\t\tscope.inversePatches_!\n\t\t\t)\n\t\t}\n\t} else {\n\t\t// Finalize the base draft.\n\t\tresult = finalize(scope, baseDraft, [])\n\t}\n\trevokeScope(scope)\n\tif (scope.patches_) {\n\t\tscope.patchListener_!(scope.patches_, scope.inversePatches_!)\n\t}\n\treturn result !== NOTHING ? result : undefined\n}\n\nfunction finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {\n\t// Don't recurse in tho recursive data structures\n\tif (isFrozen(value)) return value\n\n\tconst state: ImmerState = value[DRAFT_STATE]\n\t// A plain object, might need freezing, might contain drafts\n\tif (!state) {\n\t\teach(\n\t\t\tvalue,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, value, key, childValue, path),\n\t\t\ttrue // See #590, don't recurse into non-enumerable of non drafted objects\n\t\t)\n\t\treturn value\n\t}\n\t// Never finalize drafts owned by another scope.\n\tif (state.scope_ !== rootScope) return value\n\t// Unmodified draft, return the (frozen) original\n\tif (!state.modified_) {\n\t\tmaybeFreeze(rootScope, state.base_, true)\n\t\treturn state.base_\n\t}\n\t// Not finalized yet, let's do that now\n\tif (!state.finalized_) {\n\t\tstate.finalized_ = true\n\t\tstate.scope_.unfinalizedDrafts_--\n\t\tconst result =\n\t\t\t// For ES5, create a good copy from the draft first, with added keys and without deleted keys.\n\t\t\tstate.type_ === ProxyType.ES5Object || state.type_ === ProxyType.ES5Array\n\t\t\t\t? (state.copy_ = shallowCopy(state.draft_))\n\t\t\t\t: state.copy_\n\t\t// Finalize all children of the copy\n\t\t// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628\n\t\t// Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line\n\t\t// back to each(result, ....)\n\t\teach(\n\t\t\tstate.type_ === ProxyType.Set ? new Set(result) : result,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, result, key, childValue, path)\n\t\t)\n\t\t// everything inside is frozen, we can freeze here\n\t\tmaybeFreeze(rootScope, result, false)\n\t\t// first time finalizing, let's create those patches\n\t\tif (path && rootScope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generatePatches_(\n\t\t\t\tstate,\n\t\t\t\tpath,\n\t\t\t\trootScope.patches_,\n\t\t\t\trootScope.inversePatches_!\n\t\t\t)\n\t\t}\n\t}\n\treturn state.copy_\n}\n\nfunction finalizeProperty(\n\trootScope: ImmerScope,\n\tparentState: undefined | ImmerState,\n\ttargetObject: any,\n\tprop: string | number,\n\tchildValue: any,\n\trootPath?: PatchPath\n) {\n\tif (__DEV__ && childValue === targetObject) die(5)\n\tif (isDraft(childValue)) {\n\t\tconst path =\n\t\t\trootPath &&\n\t\t\tparentState &&\n\t\t\tparentState!.type_ !== ProxyType.Set && // Set objects are atomic since they have no keys.\n\t\t\t!has((parentState as Exclude).assigned_!, prop) // Skip deep patches for assigned keys.\n\t\t\t\t? rootPath!.concat(prop)\n\t\t\t\t: undefined\n\t\t// Drafts owned by `scope` are finalized here.\n\t\tconst res = finalize(rootScope, childValue, path)\n\t\tset(targetObject, prop, res)\n\t\t// Drafts from another scope must prevented to be frozen\n\t\t// if we got a draft back from finalize, we're in a nested produce and shouldn't freeze\n\t\tif (isDraft(res)) {\n\t\t\trootScope.canAutoFreeze_ = false\n\t\t} else return\n\t}\n\t// Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n\tif (isDraftable(childValue) && !isFrozen(childValue)) {\n\t\tif (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {\n\t\t\t// optimization: if an object is not a draft, and we don't have to\n\t\t\t// deepfreeze everything, and we are sure that no drafts are left in the remaining object\n\t\t\t// cause we saw and finalized all drafts already; we can stop visiting the rest of the tree.\n\t\t\t// This benefits especially adding large data tree's without further processing.\n\t\t\t// See add-data.js perf test\n\t\t\treturn\n\t\t}\n\t\tfinalize(rootScope, childValue)\n\t\t// immer deep freezes plain objects, so if there is no parent state, we freeze as well\n\t\tif (!parentState || !parentState.scope_.parent_)\n\t\t\tmaybeFreeze(rootScope, childValue)\n\t}\n}\n\nfunction maybeFreeze(scope: ImmerScope, value: any, deep = false) {\n\tif (scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {\n\t\tfreeze(value, deep)\n\t}\n}\n","import {\n\teach,\n\thas,\n\tis,\n\tisDraftable,\n\tshallowCopy,\n\tlatest,\n\tImmerBaseState,\n\tImmerState,\n\tDrafted,\n\tAnyObject,\n\tAnyArray,\n\tObjectish,\n\tgetCurrentScope,\n\tDRAFT_STATE,\n\tdie,\n\tcreateProxy,\n\tProxyType\n} from \"../internal\"\n\ninterface ProxyBaseState extends ImmerBaseState {\n\tassigned_: {\n\t\t[property: string]: boolean\n\t}\n\tparent_?: ImmerState\n\trevoke_(): void\n}\n\nexport interface ProxyObjectState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyObject\n\tbase_: any\n\tcopy_: any\n\tdraft_: Drafted\n}\n\nexport interface ProxyArrayState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyArray\n\tbase_: AnyArray\n\tcopy_: AnyArray | null\n\tdraft_: Drafted\n}\n\ntype ProxyState = ProxyObjectState | ProxyArrayState\n\n/**\n * Returns a new draft of the `base` object.\n *\n * The second argument is the parent draft-state (used internally).\n */\nexport function createProxyProxy(\n\tbase: T,\n\tparent?: ImmerState\n): Drafted {\n\tconst isArray = Array.isArray(base)\n\tconst state: ProxyState = {\n\t\ttype_: isArray ? ProxyType.ProxyArray : (ProxyType.ProxyObject as any),\n\t\t// Track which produce call this is associated with.\n\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t// True for both shallow and deep changes.\n\t\tmodified_: false,\n\t\t// Used during finalization.\n\t\tfinalized_: false,\n\t\t// Track which properties have been assigned (true) or deleted (false).\n\t\tassigned_: {},\n\t\t// The parent draft state.\n\t\tparent_: parent,\n\t\t// The base state.\n\t\tbase_: base,\n\t\t// The base proxy.\n\t\tdraft_: null as any, // set below\n\t\t// The base copy with any updated values.\n\t\tcopy_: null,\n\t\t// Called by the `produce` function.\n\t\trevoke_: null as any,\n\t\tisManual_: false\n\t}\n\n\t// the traps must target something, a bit like the 'real' base.\n\t// but also, we need to be able to determine from the target what the relevant state is\n\t// (to avoid creating traps per instance to capture the state in closure,\n\t// and to avoid creating weird hidden properties as well)\n\t// So the trick is to use 'state' as the actual 'target'! (and make sure we intercept everything)\n\t// Note that in the case of an array, we put the state in an array to have better Reflect defaults ootb\n\tlet target: T = state as any\n\tlet traps: ProxyHandler> = objectTraps\n\tif (isArray) {\n\t\ttarget = [state] as any\n\t\ttraps = arrayTraps\n\t}\n\n\tconst {revoke, proxy} = Proxy.revocable(target, traps)\n\tstate.draft_ = proxy as any\n\tstate.revoke_ = revoke\n\treturn proxy as any\n}\n\n/**\n * Object drafts\n */\nexport const objectTraps: ProxyHandler = {\n\tget(state, prop) {\n\t\tif (prop === DRAFT_STATE) return state\n\n\t\tconst source = latest(state)\n\t\tif (!has(source, prop)) {\n\t\t\t// non-existing or non-own property...\n\t\t\treturn readPropFromProto(state, source, prop)\n\t\t}\n\t\tconst value = source[prop]\n\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\treturn value\n\t\t}\n\t\t// Check for existing draft in modified state.\n\t\t// Assigned values are never drafted. This catches any drafts we created, too.\n\t\tif (value === peek(state.base_, prop)) {\n\t\t\tprepareCopy(state)\n\t\t\treturn (state.copy_![prop as any] = createProxy(\n\t\t\t\tstate.scope_.immer_,\n\t\t\t\tvalue,\n\t\t\t\tstate\n\t\t\t))\n\t\t}\n\t\treturn value\n\t},\n\thas(state, prop) {\n\t\treturn prop in latest(state)\n\t},\n\townKeys(state) {\n\t\treturn Reflect.ownKeys(latest(state))\n\t},\n\tset(\n\t\tstate: ProxyObjectState,\n\t\tprop: string /* strictly not, but helps TS */,\n\t\tvalue\n\t) {\n\t\tconst desc = getDescriptorFromProto(latest(state), prop)\n\t\tif (desc?.set) {\n\t\t\t// special case: if this write is captured by a setter, we have\n\t\t\t// to trigger it with the correct context\n\t\t\tdesc.set.call(state.draft_, value)\n\t\t\treturn true\n\t\t}\n\t\tif (!state.modified_) {\n\t\t\t// the last check is because we need to be able to distinguish setting a non-existing to undefined (which is a change)\n\t\t\t// from setting an existing property with value undefined to undefined (which is not a change)\n\t\t\tconst current = peek(latest(state), prop)\n\t\t\t// special case, if we assigning the original value to a draft, we can ignore the assignment\n\t\t\tconst currentState: ProxyObjectState = current?.[DRAFT_STATE]\n\t\t\tif (currentState && currentState.base_ === value) {\n\t\t\t\tstate.copy_![prop] = value\n\t\t\t\tstate.assigned_[prop] = false\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (is(value, current) && (value !== undefined || has(state.base_, prop)))\n\t\t\t\treturn true\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t}\n\n\t\tif (\n\t\t\tstate.copy_![prop] === value &&\n\t\t\t// special case: NaN\n\t\t\ttypeof value !== \"number\" &&\n\t\t\t// special case: handle new props with value 'undefined'\n\t\t\t(value !== undefined || prop in state.copy_)\n\t\t)\n\t\t\treturn true\n\n\t\t// @ts-ignore\n\t\tstate.copy_![prop] = value\n\t\tstate.assigned_[prop] = true\n\t\treturn true\n\t},\n\tdeleteProperty(state, prop: string) {\n\t\t// The `undefined` check is a fast path for pre-existing keys.\n\t\tif (peek(state.base_, prop) !== undefined || prop in state.base_) {\n\t\t\tstate.assigned_[prop] = false\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t} else {\n\t\t\t// if an originally not assigned property was deleted\n\t\t\tdelete state.assigned_[prop]\n\t\t}\n\t\t// @ts-ignore\n\t\tif (state.copy_) delete state.copy_[prop]\n\t\treturn true\n\t},\n\t// Note: We never coerce `desc.value` into an Immer draft, because we can't make\n\t// the same guarantee in ES5 mode.\n\tgetOwnPropertyDescriptor(state, prop) {\n\t\tconst owner = latest(state)\n\t\tconst desc = Reflect.getOwnPropertyDescriptor(owner, prop)\n\t\tif (!desc) return desc\n\t\treturn {\n\t\t\twritable: true,\n\t\t\tconfigurable: state.type_ !== ProxyType.ProxyArray || prop !== \"length\",\n\t\t\tenumerable: desc.enumerable,\n\t\t\tvalue: owner[prop]\n\t\t}\n\t},\n\tdefineProperty() {\n\t\tdie(11)\n\t},\n\tgetPrototypeOf(state) {\n\t\treturn Object.getPrototypeOf(state.base_)\n\t},\n\tsetPrototypeOf() {\n\t\tdie(12)\n\t}\n}\n\n/**\n * Array drafts\n */\n\nconst arrayTraps: ProxyHandler<[ProxyArrayState]> = {}\neach(objectTraps, (key, fn) => {\n\t// @ts-ignore\n\tarrayTraps[key] = function() {\n\t\targuments[0] = arguments[0][0]\n\t\treturn fn.apply(this, arguments)\n\t}\n})\narrayTraps.deleteProperty = function(state, prop) {\n\tif (__DEV__ && isNaN(parseInt(prop as any))) die(13)\n\t// @ts-ignore\n\treturn arrayTraps.set!.call(this, state, prop, undefined)\n}\narrayTraps.set = function(state, prop, value) {\n\tif (__DEV__ && prop !== \"length\" && isNaN(parseInt(prop as any))) die(14)\n\treturn objectTraps.set!.call(this, state[0], prop, value, state[0])\n}\n\n// Access a property without creating an Immer draft.\nfunction peek(draft: Drafted, prop: PropertyKey) {\n\tconst state = draft[DRAFT_STATE]\n\tconst source = state ? latest(state) : draft\n\treturn source[prop]\n}\n\nfunction readPropFromProto(state: ImmerState, source: any, prop: PropertyKey) {\n\tconst desc = getDescriptorFromProto(source, prop)\n\treturn desc\n\t\t? `value` in desc\n\t\t\t? desc.value\n\t\t\t: // This is a very special case, if the prop is a getter defined by the\n\t\t\t // prototype, we should invoke it with the draft as context!\n\t\t\t desc.get?.call(state.draft_)\n\t\t: undefined\n}\n\nfunction getDescriptorFromProto(\n\tsource: any,\n\tprop: PropertyKey\n): PropertyDescriptor | undefined {\n\t// 'in' checks proto!\n\tif (!(prop in source)) return undefined\n\tlet proto = Object.getPrototypeOf(source)\n\twhile (proto) {\n\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\tif (desc) return desc\n\t\tproto = Object.getPrototypeOf(proto)\n\t}\n\treturn undefined\n}\n\nexport function markChanged(state: ImmerState) {\n\tif (!state.modified_) {\n\t\tstate.modified_ = true\n\t\tif (state.parent_) {\n\t\t\tmarkChanged(state.parent_)\n\t\t}\n\t}\n}\n\nexport function prepareCopy(state: {base_: any; copy_: any}) {\n\tif (!state.copy_) {\n\t\tstate.copy_ = shallowCopy(state.base_)\n\t}\n}\n","import {\n\tIProduceWithPatches,\n\tIProduce,\n\tImmerState,\n\tDrafted,\n\tisDraftable,\n\tprocessResult,\n\tPatch,\n\tObjectish,\n\tDRAFT_STATE,\n\tDraft,\n\tPatchListener,\n\tisDraft,\n\tisMap,\n\tisSet,\n\tcreateProxyProxy,\n\tgetPlugin,\n\tdie,\n\thasProxies,\n\tenterScope,\n\trevokeScope,\n\tleaveScope,\n\tusePatchesInScope,\n\tgetCurrentScope,\n\tNOTHING,\n\tfreeze,\n\tcurrent\n} from \"../internal\"\n\ninterface ProducersFns {\n\tproduce: IProduce\n\tproduceWithPatches: IProduceWithPatches\n}\n\nexport class Immer implements ProducersFns {\n\tuseProxies_: boolean = hasProxies\n\n\tautoFreeze_: boolean = true\n\n\tconstructor(config?: {useProxies?: boolean; autoFreeze?: boolean}) {\n\t\tif (typeof config?.useProxies === \"boolean\")\n\t\t\tthis.setUseProxies(config!.useProxies)\n\t\tif (typeof config?.autoFreeze === \"boolean\")\n\t\t\tthis.setAutoFreeze(config!.autoFreeze)\n\t}\n\n\t/**\n\t * The `produce` function takes a value and a \"recipe function\" (whose\n\t * return value often depends on the base state). The recipe function is\n\t * free to mutate its first argument however it wants. All mutations are\n\t * only ever applied to a __copy__ of the base state.\n\t *\n\t * Pass only a function to create a \"curried producer\" which relieves you\n\t * from passing the recipe function every time.\n\t *\n\t * Only plain objects and arrays are made mutable. All other objects are\n\t * considered uncopyable.\n\t *\n\t * Note: This function is __bound__ to its `Immer` instance.\n\t *\n\t * @param {any} base - the initial state\n\t * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n\t * @param {Function} patchListener - optional function that will be called with all the patches produced here\n\t * @returns {any} a new state, or the initial state if nothing was modified\n\t */\n\tproduce: IProduce = (base: any, recipe?: any, patchListener?: any) => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\" && typeof recipe !== \"function\") {\n\t\t\tconst defaultBase = recipe\n\t\t\trecipe = base\n\n\t\t\tconst self = this\n\t\t\treturn function curriedProduce(\n\t\t\t\tthis: any,\n\t\t\t\tbase = defaultBase,\n\t\t\t\t...args: any[]\n\t\t\t) {\n\t\t\t\treturn self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore\n\t\t\t}\n\t\t}\n\n\t\tif (typeof recipe !== \"function\") die(6)\n\t\tif (patchListener !== undefined && typeof patchListener !== \"function\")\n\t\t\tdie(7)\n\n\t\tlet result\n\n\t\t// Only plain objects, arrays, and \"immerable classes\" are drafted.\n\t\tif (isDraftable(base)) {\n\t\t\tconst scope = enterScope(this)\n\t\t\tconst proxy = createProxy(this, base, undefined)\n\t\t\tlet hasError = true\n\t\t\ttry {\n\t\t\t\tresult = recipe(proxy)\n\t\t\t\thasError = false\n\t\t\t} finally {\n\t\t\t\t// finally instead of catch + rethrow better preserves original stack\n\t\t\t\tif (hasError) revokeScope(scope)\n\t\t\t\telse leaveScope(scope)\n\t\t\t}\n\t\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\tresult => {\n\t\t\t\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\t\t\t\treturn processResult(result, scope)\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\trevokeScope(scope)\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t}\n\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\treturn processResult(result, scope)\n\t\t} else if (!base || typeof base !== \"object\") {\n\t\t\tresult = recipe(base)\n\t\t\tif (result === undefined) result = base\n\t\t\tif (result === NOTHING) result = undefined\n\t\t\tif (this.autoFreeze_) freeze(result, true)\n\t\t\tif (patchListener) {\n\t\t\t\tconst p: Patch[] = []\n\t\t\t\tconst ip: Patch[] = []\n\t\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(base, result, p, ip)\n\t\t\t\tpatchListener(p, ip)\n\t\t\t}\n\t\t\treturn result\n\t\t} else die(21, base)\n\t}\n\n\tproduceWithPatches: IProduceWithPatches = (\n\t\tbase: any,\n\t\trecipe?: any,\n\t): any => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\") {\n\t\t\treturn (state: any, ...args: any[]) =>\n\t\t\t\tthis.produceWithPatches(state, (draft: any) => base(draft, ...args))\n\t\t}\n\n\t\tlet patches: Patch[], inversePatches: Patch[]\n\t\tconst result = this.produce(base, recipe, (p: Patch[], ip: Patch[]) => {\n\t\t\tpatches = p\n\t\t\tinversePatches = ip\n\t\t})\n\n\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\treturn result.then(nextState => [nextState, patches!, inversePatches!])\n\t\t}\n\t\treturn [result, patches!, inversePatches!]\n\t}\n\n\tcreateDraft(base: T): Draft {\n\t\tif (!isDraftable(base)) die(8)\n\t\tif (isDraft(base)) base = current(base)\n\t\tconst scope = enterScope(this)\n\t\tconst proxy = createProxy(this, base, undefined)\n\t\tproxy[DRAFT_STATE].isManual_ = true\n\t\tleaveScope(scope)\n\t\treturn proxy as any\n\t}\n\n\tfinishDraft>(\n\t\tdraft: D,\n\t\tpatchListener?: PatchListener\n\t): D extends Draft ? T : never {\n\t\tconst state: ImmerState = draft && (draft as any)[DRAFT_STATE]\n\t\tif (__DEV__) {\n\t\t\tif (!state || !state.isManual_) die(9)\n\t\t\tif (state.finalized_) die(10)\n\t\t}\n\t\tconst {scope_: scope} = state\n\t\tusePatchesInScope(scope, patchListener)\n\t\treturn processResult(undefined, scope)\n\t}\n\n\t/**\n\t * Pass true to automatically freeze all copies created by Immer.\n\t *\n\t * By default, auto-freezing is enabled.\n\t */\n\tsetAutoFreeze(value: boolean) {\n\t\tthis.autoFreeze_ = value\n\t}\n\n\t/**\n\t * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n\t * always faster than using ES5 proxies.\n\t *\n\t * By default, feature detection is used, so calling this is rarely necessary.\n\t */\n\tsetUseProxies(value: boolean) {\n\t\tif (value && !hasProxies) {\n\t\t\tdie(20)\n\t\t}\n\t\tthis.useProxies_ = value\n\t}\n\n\tapplyPatches(base: T, patches: Patch[]): T {\n\t\t// If a patch replaces the entire state, take that replacement as base\n\t\t// before applying patches\n\t\tlet i: number\n\t\tfor (i = patches.length - 1; i >= 0; i--) {\n\t\t\tconst patch = patches[i]\n\t\t\tif (patch.path.length === 0 && patch.op === \"replace\") {\n\t\t\t\tbase = patch.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// If there was a patch that replaced the entire state, start from the\n\t\t// patch after that.\n\t\tif (i > -1) {\n\t\t\tpatches = patches.slice(i + 1)\n\t\t}\n\n\t\tconst applyPatchesImpl = getPlugin(\"Patches\").applyPatches_\n\t\tif (isDraft(base)) {\n\t\t\t// N.B: never hits if some patch a replacement, patches are never drafts\n\t\t\treturn applyPatchesImpl(base, patches)\n\t\t}\n\t\t// Otherwise, produce a copy of the base state.\n\t\treturn this.produce(base, (draft: Drafted) =>\n\t\t\tapplyPatchesImpl(draft, patches)\n\t\t)\n\t}\n}\n\nexport function createProxy(\n\timmer: Immer,\n\tvalue: T,\n\tparent?: ImmerState\n): Drafted {\n\t// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft\n\tconst draft: Drafted = isMap(value)\n\t\t? getPlugin(\"MapSet\").proxyMap_(value, parent)\n\t\t: isSet(value)\n\t\t? getPlugin(\"MapSet\").proxySet_(value, parent)\n\t\t: immer.useProxies_\n\t\t? createProxyProxy(value, parent)\n\t\t: getPlugin(\"ES5\").createES5Proxy_(value, parent)\n\n\tconst scope = parent ? parent.scope_ : getCurrentScope()\n\tscope.drafts_.push(draft)\n\treturn draft\n}\n","import {\n\tdie,\n\tisDraft,\n\tshallowCopy,\n\teach,\n\tDRAFT_STATE,\n\tget,\n\tset,\n\tImmerState,\n\tisDraftable,\n\tArchtype,\n\tgetArchtype,\n\tgetPlugin\n} from \"../internal\"\n\n/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */\nexport function current(value: T): T\nexport function current(value: any): any {\n\tif (!isDraft(value)) die(22, value)\n\treturn currentImpl(value)\n}\n\nfunction currentImpl(value: any): any {\n\tif (!isDraftable(value)) return value\n\tconst state: ImmerState | undefined = value[DRAFT_STATE]\n\tlet copy: any\n\tconst archType = getArchtype(value)\n\tif (state) {\n\t\tif (\n\t\t\t!state.modified_ &&\n\t\t\t(state.type_ < 4 || !getPlugin(\"ES5\").hasChanges_(state as any))\n\t\t)\n\t\t\treturn state.base_\n\t\t// Optimization: avoid generating new drafts during copying\n\t\tstate.finalized_ = true\n\t\tcopy = copyHelper(value, archType)\n\t\tstate.finalized_ = false\n\t} else {\n\t\tcopy = copyHelper(value, archType)\n\t}\n\n\teach(copy, (key, childValue) => {\n\t\tif (state && get(state.base_, key) === childValue) return // no need to copy or search in something that didn't change\n\t\tset(copy, key, currentImpl(childValue))\n\t})\n\t// In the future, we might consider freezing here, based on the current settings\n\treturn archType === Archtype.Set ? new Set(copy) : copy\n}\n\nfunction copyHelper(value: any, archType: number): any {\n\t// creates a shallow copy, even if it is a map or set\n\tswitch (archType) {\n\t\tcase Archtype.Map:\n\t\t\treturn new Map(value)\n\t\tcase Archtype.Set:\n\t\t\t// Set will be cloned as array temporarily, so that we can replace individual items\n\t\t\treturn Array.from(value)\n\t}\n\treturn shallowCopy(value)\n}\n","import {\n\tIProduce,\n\tIProduceWithPatches,\n\tImmer,\n\tDraft,\n\tImmutable\n} from \"./internal\"\n\nexport {\n\tDraft,\n\tImmutable,\n\tPatch,\n\tPatchListener,\n\toriginal,\n\tcurrent,\n\tisDraft,\n\tisDraftable,\n\tNOTHING as nothing,\n\tDRAFTABLE as immerable,\n\tfreeze\n} from \"./internal\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce: IProduce = immer.produce\nexport default produce\n\n/**\n * Like `produce`, but `produceWithPatches` always returns a tuple\n * [nextState, patches, inversePatches] (instead of just the next state)\n */\nexport const produceWithPatches: IProduceWithPatches = immer.produceWithPatches.bind(\n\timmer\n)\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * Always freeze by default, even in production mode\n */\nexport const setAutoFreeze = immer.setAutoFreeze.bind(immer)\n\n/**\n * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n * always faster than using ES5 proxies.\n *\n * By default, feature detection is used, so calling this is rarely necessary.\n */\nexport const setUseProxies = immer.setUseProxies.bind(immer)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = immer.applyPatches.bind(immer)\n\n/**\n * Create an Immer draft from the given base state, which may be a draft itself.\n * The draft can be modified until you finalize it with the `finishDraft` function.\n */\nexport const createDraft = immer.createDraft.bind(immer)\n\n/**\n * Finalize an Immer draft from a `createDraft` call, returning the base state\n * (if no changes were made) or a modified copy. The draft must *not* be\n * mutated afterwards.\n *\n * Pass a function as the 2nd argument to generate Immer patches based on the\n * changes that were made.\n */\nexport const finishDraft = immer.finishDraft.bind(immer)\n\n/**\n * This function is actually a no-op, but can be used to cast an immutable type\n * to an draft type and make TypeScript happy\n *\n * @param value\n */\nexport function castDraft(value: T): Draft {\n\treturn value as any\n}\n\n/**\n * This function is actually a no-op, but can be used to cast a mutable type\n * to an immutable type and make TypeScript happy\n * @param value\n */\nexport function castImmutable(value: T): Immutable {\n\treturn value as any\n}\n\nexport {Immer}\n\nexport {enableES5} from \"./plugins/es5\"\nexport {enablePatches} from \"./plugins/patches\"\nexport {enableMapSet} from \"./plugins/mapset\"\nexport {enableAllPlugins} from \"./plugins/all\"\n","// Should be no imports here!\n\n// Some things that should be evaluated before all else...\n\n// We only want to know if non-polyfilled symbols are available\nconst hasSymbol =\n\ttypeof Symbol !== \"undefined\" && typeof Symbol(\"x\") === \"symbol\"\nexport const hasMap = typeof Map !== \"undefined\"\nexport const hasSet = typeof Set !== \"undefined\"\nexport const hasProxies =\n\ttypeof Proxy !== \"undefined\" &&\n\ttypeof Proxy.revocable !== \"undefined\" &&\n\ttypeof Reflect !== \"undefined\"\n\n/**\n * The sentinel value returned by producers to replace the draft with undefined.\n */\nexport const NOTHING: Nothing = hasSymbol\n\t? Symbol.for(\"immer-nothing\")\n\t: ({[\"immer-nothing\"]: true} as any)\n\n/**\n * To let Immer treat your class instances as plain immutable objects\n * (albeit with a custom prototype), you must define either an instance property\n * or a static property on each of your custom classes.\n *\n * Otherwise, your class instance will never be drafted, which means it won't be\n * safe to mutate in a produce callback.\n */\nexport const DRAFTABLE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-draftable\")\n\t: (\"__$immer_draftable\" as any)\n\nexport const DRAFT_STATE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-state\")\n\t: (\"__$immer_state\" as any)\n\n// Even a polyfilled Symbol might provide Symbol.iterator\nexport const iteratorSymbol: typeof Symbol.iterator =\n\t(typeof Symbol != \"undefined\" && Symbol.iterator) || (\"@@iterator\" as any)\n\n/** Use a class type for `nothing` so its type is unique */\nexport class Nothing {\n\t// This lets us do `Exclude`\n\t// @ts-ignore\n\tprivate _!: unique symbol\n}\n","import produce from \"immer\";\nimport { Dispatch, useEffect, useReducer, useState } from \"react\";\n\nexport function useImmerReducer<\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Reducers extends Record T | void>\n>(reducers: Reducers, initialState: T) {\n return useReducer(\n (\n state: T,\n command: {\n action: keyof Reducers;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload?: any;\n }\n ): T =>\n produce(state, (draft: T) => {\n reducers[command.action](draft, command.payload);\n }),\n initialState\n );\n}\n\nexport function useStateInitializer(init: T): [T, Dispatch] {\n const [state, setState] = useState(init);\n useEffect(() => {\n setState(init);\n }, [init]);\n return [state, setState];\n}\n","import { width } from \"@davidsouther/jiffies/lib/esm/dom/css/sizing.js\";\nimport { useCallback, useState } from \"react\";\nimport { useStateInitializer } from \"./react.js\";\n\nconst Mode = { VIEW: 0, EDIT: 1 };\n\nexport const InlineEdit = (props: {\n mode?: keyof typeof Mode;\n value: string;\n onChange: (value: string) => void;\n}) => {\n const [mode, setMode] = useState(props.mode ?? Mode.VIEW);\n const [value, setValue] = useStateInitializer(props.value);\n\n const render = () => {\n switch (mode) {\n case Mode.EDIT:\n return edit();\n case Mode.VIEW:\n return view();\n default:\n return ;\n }\n };\n\n const view = () => (\n {\n setMode(Mode.EDIT);\n }}\n >\n {value}\n \n );\n\n const doSelect = useCallback(\n (ref: HTMLInputElement | null) => ref?.select(),\n []\n );\n const doChange = useCallback(\n (target: HTMLInputElement) => {\n setMode(Mode.VIEW);\n setValue(target.value ?? \"\");\n props.onChange(target.value ?? \"\");\n },\n [props, setMode, setValue]\n );\n const edit = () => {\n const edit = (\n \n doChange(target)}\n onKeyPress={({ key, target }) => {\n if (key === \"Enter\") {\n doChange(target as HTMLInputElement);\n }\n }}\n type=\"text\"\n defaultValue={value}\n />\n \n );\n return edit;\n };\n\n return render();\n};\n\nexport default InlineEdit;\n","/* eslint-disable @typescript-eslint/ban-types */\nimport {\n Key,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from \"react\";\n\nexport interface VirtualScrollSettings {\n /**Minimum offset into the adapter. Default is 0. */\n minIndex: number;\n /** Maximum offset into the adapter. Default is Number.MAX_SAFE_INTEGER. */\n maxIndex: number;\n /** Initial index to start rendering from. Default is minIndex. */\n startIndex: number;\n /**\n * Number of items to render in visible area. Default is entire range from\n * minIndex to maxIndex.\n */\n count: number;\n /**\n * Maximum number of items to render on either side of the visible area.\n * Default is `count`.\n */\n tolerance: number;\n /** Height of each item, in pixels. Default is 20px. */\n itemHeight: number;\n}\n\nexport interface VirtualScrollDataAdapter {\n (offset: number, limit: number): Iterable;\n}\n\nexport function arrayAdapter(data: T[]): VirtualScrollDataAdapter {\n return (offset, limit) => data.slice(offset, offset + limit);\n}\n\nexport interface VirtualScrollProps {\n settings?: Partial;\n get: VirtualScrollDataAdapter;\n row: (t: T) => U;\n rowKey: (t: T) => Key;\n}\n\nexport function fillVirtualScrollSettings(\n settings: Partial\n): VirtualScrollSettings {\n const {\n minIndex = 0,\n maxIndex = Number.MAX_SAFE_INTEGER,\n startIndex = 0,\n itemHeight = 20,\n count = Math.max(maxIndex - minIndex, 1),\n tolerance = count,\n } = settings;\n\n return { minIndex, maxIndex, startIndex, itemHeight, count, tolerance };\n}\n\nexport function initialState(\n settings: VirtualScrollSettings,\n adapter: VirtualScrollDataAdapter\n): VirtualScrollState {\n // From Denis Hilt, https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/\n const { minIndex, maxIndex, startIndex, itemHeight, count, tolerance } =\n settings;\n const bufferedItems = count + 2 * tolerance;\n const itemsAbove = Math.max(0, startIndex - tolerance - minIndex);\n\n const viewportHeight = count * itemHeight;\n const totalHeight = Math.min(maxIndex - minIndex, 1) * itemHeight;\n const toleranceHeight = tolerance * itemHeight;\n const bufferHeight = viewportHeight + 2 * toleranceHeight;\n const topPaddingHeight = itemsAbove * itemHeight;\n const bottomPaddingHeight = totalHeight - (topPaddingHeight + bufferHeight);\n\n const state: VirtualScrollState = {\n scrollTop: 0,\n settings,\n viewportHeight,\n totalHeight,\n toleranceHeight,\n bufferedItems,\n topPaddingHeight,\n bottomPaddingHeight,\n data: [],\n };\n\n return {\n ...state,\n ...doScroll(topPaddingHeight + toleranceHeight, state, adapter),\n };\n}\n\nexport function getData(\n minIndex: number,\n maxIndex: number,\n offset: number,\n limit: number,\n get: VirtualScrollDataAdapter\n): T[] {\n const start = Math.max(0, minIndex, offset);\n const end = Math.min(maxIndex, offset + limit - 1);\n const data = get(start, end - start);\n return [...data];\n}\n\ninterface ScrollUpdate {\n scrollTop: number;\n topPaddingHeight: number;\n bottomPaddingHeight: number;\n data: T[];\n}\n\nexport function doScroll(\n scrollTop: number,\n state: VirtualScrollState,\n get: VirtualScrollDataAdapter\n): ScrollUpdate {\n const {\n totalHeight,\n toleranceHeight,\n bufferedItems,\n settings: { itemHeight, minIndex, maxIndex },\n } = state;\n const index =\n minIndex + Math.floor((scrollTop - toleranceHeight) / itemHeight);\n const data = getData(minIndex, maxIndex, index, bufferedItems, get);\n const topPaddingHeight = Math.max((index - minIndex) * itemHeight, 0);\n const bottomPaddingHeight = Math.max(\n totalHeight - (topPaddingHeight + data.length * itemHeight),\n 0\n );\n\n return { scrollTop, topPaddingHeight, bottomPaddingHeight, data };\n}\n\ninterface VirtualScrollState {\n settings: VirtualScrollSettings;\n scrollTop: number; // px\n bufferedItems: number; // count\n totalHeight: number; // px\n viewportHeight: number; // px\n topPaddingHeight: number; // px\n bottomPaddingHeight: number; // px\n toleranceHeight: number; // px\n data: T[];\n}\n\nconst scrollReducer =\n (get: VirtualScrollDataAdapter) =>\n (state: VirtualScrollState, scrollTop: number) => ({\n ...state,\n ...doScroll(scrollTop, state, get),\n });\n\nexport const VirtualScroll = (\n props: VirtualScrollProps & { className?: string }\n) => {\n const viewportRef = useRef(null);\n\n const { settings, startState, reducer } = useMemo(() => {\n const settings = fillVirtualScrollSettings(props.settings ?? {});\n const startState = initialState(settings, props.get);\n const reducer = scrollReducer(props.get);\n return { settings, reducer, startState };\n }, [props.settings, props.get]);\n\n const [state, dispatchScroll] = useReducer(reducer, startState);\n\n useEffect(() => {\n if (viewportRef.current !== null) {\n dispatchScroll(viewportRef.current.scrollTop);\n }\n }, [settings, props.row]);\n\n const initialScroll = useCallback(\n (div: HTMLDivElement | null) => {\n if (div) {\n div.scrollTop = viewportRef.current\n ? viewportRef.current.scrollTop\n : settings.startIndex * settings.itemHeight;\n }\n viewportRef.current = div;\n },\n [viewportRef, settings.startIndex, settings.itemHeight]\n );\n\n const rows = state.data.map((d) => (\n
\n {props.row(d)}\n
\n ));\n\n return (\n dispatchScroll((e.target as HTMLDivElement).scrollTop)}\n >\n
\n {rows}\n
\n
\n );\n};\n\nexport default VirtualScroll;\n","import { rounded } from \"@davidsouther/jiffies/lib/esm/dom/css/border.js\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\n\nimport {\n Format,\n FORMATS,\n Memory as MemoryChip,\n} from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { asm } from \"@nand2tetris/simulator/util/asm.js\";\nimport { bin, dec, hex } from \"@nand2tetris/simulator/util/twos.js\";\nimport InlineEdit from \"../inline_edit.js\";\nimport VirtualScroll, { VirtualScrollSettings } from \"../virtual_scroll.js\";\n\nconst ITEM_HEIGHT = 34;\n\nexport const MemoryBlock = ({\n memory,\n jmp = { value: 0 },\n highlight = -1,\n editable = false,\n format = dec,\n onChange = () => undefined,\n}: {\n jmp?: { value: number };\n memory: MemoryChip;\n highlight?: number;\n editable?: boolean;\n format?: (v: number) => string;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => {\n const settings = useMemo>(\n () => ({\n count: Math.min(memory.size, 20),\n maxIndex: memory.size,\n itemHeight: ITEM_HEIGHT,\n startIndex: jmp.value,\n }),\n [memory.size, jmp]\n );\n const get = useCallback(\n (offset: number, count: number) =>\n memory\n .range(offset, offset + count)\n .map((v, i) => [i + offset, v] as [number, number]),\n [memory]\n );\n const row = useCallback(\n ([i, v]: [number, number]) => (\n \n ),\n [format, editable, highlight, onChange]\n );\n\n return (\n \n settings={settings}\n get={get}\n row={row}\n rowKey={([i]) => i}\n />\n );\n};\n\nexport const MemoryCell = ({\n index,\n value,\n highlight = false,\n editable = false,\n onChange = () => undefined,\n}: {\n index: number;\n value: string;\n highlight?: boolean;\n editable?: boolean;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => (\n
\n \n {hex(index)}\n \n \n {editable ? (\n \n onChange(index, newValue, Number(value))\n }\n />\n ) : (\n {value}\n )}\n \n
\n);\n\nexport const Memory = ({\n name = \"Memory\",\n highlight = -1,\n editable = true,\n memory,\n format = \"dec\",\n}: {\n name?: string;\n editable?: boolean;\n highlight?: number;\n memory: MemoryChip;\n format: Format;\n}) => {\n const [fmt, setFormat] = useState(format);\n const [jmp, setJmp] = useState(\"0\");\n const [goto, setGoto] = useState({ value: 0 });\n\n const jumpTo = () => {\n setGoto({ value: Number(jmp) });\n };\n\n // const { filePicker, fs } = useContext(AppContext);\n // const doLoad = useCallback(async () => {\n // try {\n // const file = await filePicker.select();\n // await memory.load(fs, file);\n // } catch (e) {\n // console.error(e);\n // }\n // }, [fs, filePicker, memory]);\n\n const doLoad = () => undefined;\n\n const doUpdate = useCallback(\n (i: number, v: string) => {\n memory.update(i, v, fmt ?? \"dec\");\n },\n [memory, fmt]\n );\n\n return (\n
\n
\n
{name}
\n
\n \n key === \"Enter\" && jumpTo()}\n onChange={({ target: { value } }) => setJmp(value ?? \"0\")}\n />\n \n {FORMATS.map((option) => (\n \n setFormat(option)}\n />\n {option}\n \n ))}\n
\n
\n doFormat(fmt, v)}\n onChange={doUpdate}\n />\n
\n );\n};\n\nexport default Memory;\n\nfunction doFormat(format: Format, v: number): string {\n switch (format) {\n case \"bin\":\n return bin(v);\n case \"hex\":\n return hex(v);\n case \"asm\":\n return asm(v);\n case \"dec\":\n default:\n return dec(v);\n }\n}\n","import { useEffect, useMemo, useState } from \"react\";\n\nimport { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\n\nexport function useClock(actions: {\n tick?: () => void;\n toggle?: () => void;\n reset?: () => void;\n}) {\n const clock = useMemo(() => Clock.get(), []);\n\n useEffect(() => {\n const subscription = clock.$.subscribe(() => {\n actions.tick?.();\n });\n return () => subscription.unsubscribe();\n }, [actions, clock.$]);\n\n return {\n toggle() {\n clock.tick();\n actions.toggle?.();\n },\n\n reset() {\n clock.reset();\n actions.reset?.();\n },\n };\n}\n\nexport function useClockFrame(frameFinished: () => void) {\n useEffect(() => {\n const subscription = Clock.get().frame$.subscribe(() => {\n frameFinished();\n });\n return () => subscription.unsubscribe();\n }, [frameFinished]);\n}\n\nexport function displayClock() {\n return display(Clock.get());\n}\n\nexport function useClockface() {\n const [clockface, setClockface] = useState(displayClock());\n\n useEffect(() => {\n const subscription = Clock.get().$.subscribe(() => {\n setClockface(displayClock());\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return clockface;\n}\n\nexport const Clockface = () => {\n const clockface = useClockface();\n return {clockface};\n};\n","import { Memory } from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { assertExists } from \"@davidsouther/jiffies/lib/esm/assert.js\";\nimport { useCallback, useRef } from \"react\";\nimport { useClockFrame } from \"../clockface.js\";\n\nconst WHITE = \"white\";\nconst BLACK = \"black\";\ntype COLOR = typeof WHITE | typeof BLACK;\n\nexport interface ScreenMemory {\n get(idx: number): number;\n}\n\nexport function reduceScreen(memory: Memory, offset = 0): ScreenMemory {\n return {\n get(idx: number): number {\n return memory.get(offset + idx);\n },\n };\n}\n\nfunction get(mem: ScreenMemory, x: number, y: number): COLOR {\n const byte = mem.get(32 * y + ((x / 16) | 0));\n const bit = byte & (1 << x % 16);\n return bit === 0 ? WHITE : BLACK;\n}\n\nfunction set(data: Uint8ClampedArray, x: number, y: number, value: COLOR) {\n const pixel = (y * 512 + x) * 4;\n const color = value === WHITE ? 255 : 0;\n data[pixel] = color;\n data[pixel + 1] = color;\n data[pixel + 2] = color;\n data[pixel + 3] = 255;\n}\n\nfunction drawImage(ctx: CanvasRenderingContext2D, memory: ScreenMemory) {\n const image = assertExists(\n ctx.getImageData(0, 0, 512, 256),\n \"Failed to create Context2d\"\n );\n for (let col = 0; col < 512; col++) {\n for (let row = 0; row < 256; row++) {\n const color = get(memory, col, row);\n set(image.data, col, row, color);\n }\n }\n ctx.putImageData(image, 0, 0);\n}\n\nexport const Screen = ({ memory }: { memory: ScreenMemory }) => {\n const canvas = useRef();\n\n const draw = useCallback(() => {\n const ctx = canvas.current?.getContext(\"2d\") ?? undefined;\n\n if (ctx) {\n drawImage(ctx, memory);\n }\n }, [memory]);\n\n const ctxRef = useCallback(\n (ref: HTMLCanvasElement | null) => {\n canvas.current = ref ?? undefined;\n draw();\n },\n [canvas, draw]\n );\n\n useClockFrame(draw);\n\n return (\n
\n
Screen
\n
\n \n \n \n
\n
\n );\n};\n","import {\n Keyboard,\n Screen,\n} from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { ALU } from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n PC,\n VRegister,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/bit.js\";\nimport {\n RAM,\n RAM8,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/ram.js\";\nimport { Chip, HIGH } from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Flags } from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { CPU, decode } from \"@nand2tetris/simulator/cpu/cpu.js\";\nimport { ReactElement } from \"react\";\nimport { ALUComponent } from \"./alu.js\";\nimport { Keyboard as KeyboardComponent } from \"./keyboard.js\";\nimport { Memory as MemoryComponent } from \"./memory.js\";\nimport { RegisterComponent } from \"./register.js\";\nimport { Screen as ScreenComponent } from \"./screen.js\";\n\nexport function getBuiltinVisualization(part: Chip): ReactElement | undefined {\n switch (part.name) {\n case \"Register\":\n case \"ARegister\":\n case \"DRegister\":\n case \"PC\":\n case \"KEYBOARD\":\n case \"RAM8\":\n case \"RAM64\":\n case \"RAM512\":\n case \"RAM4K\":\n case \"RAM16K\":\n case \"ROM32K\":\n case \"Screen\":\n case \"Memory\":\n default:\n return undefined;\n }\n}\n\nexport function makeVisualization(chip: Chip): ReactElement | undefined {\n if (chip instanceof ALU) {\n return (\n \n );\n }\n if (chip instanceof VRegister) {\n return (\n \n );\n }\n if (chip instanceof PC) {\n return ;\n }\n if (chip instanceof Keyboard) {\n return ;\n }\n if (chip instanceof Screen) {\n return ;\n }\n if (chip instanceof RAM) {\n return (\n \n );\n }\n if (chip instanceof RAM8) {\n return RAM {chip.width};\n }\n if (chip instanceof CPU) {\n const bits = decode(chip.in(\"instruction\").busVoltage);\n return (\n <>\n \n \n \n \n \n );\n }\n\n const vis = [...chip.parts]\n .map(makeVisualization)\n .filter((v) => v !== undefined);\n return vis.length > 0 ? <>{vis} : undefined;\n}\n\nexport function makeVisualizationsWithId(chip: {\n parts: Chip[];\n}): [string, ReactElement][] {\n return [...chip.parts]\n .map((part, i): [string, ReactElement | undefined] => [\n `${part.id}_${i}`,\n makeVisualization(part),\n ])\n .filter(([_, v]) => v !== undefined) as [string, ReactElement][];\n}\n","// import { plural, Trans } from \"@lingui/macro\";\nimport {\n Pin as ChipPin,\n Pins,\n Voltage,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { range } from \"@davidsouther/jiffies/lib/esm/range.js\";\nimport { ChipSim } from \"./stores/chip.store.js\";\n\nexport interface ImmPin {\n bits: [number, Voltage][];\n pin: ChipPin;\n}\n\nexport function reducePin(pin: ChipPin) {\n return {\n pin,\n bits: range(0, pin.width)\n .map((i) => [i, pin.voltage(i)] as [number, Voltage])\n .reverse(),\n };\n}\n\nexport function reducePins(pins: Pins): ImmPin[] {\n return [...pins.entries()].map(reducePin);\n}\n\nexport interface PinoutPins {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}\n\nexport const FullPinout = (props: {\n sim: ChipSim;\n toggle: (pin: ChipPin, i: number | undefined) => void;\n}) => {\n const { inPins, outPins, internalPins } = props.sim;\n return (\n <>\n \n \n \n \n \n \n \n
\n \n );\n};\n\nexport const PinoutBlock = (\n props: PinoutPins & { header: string; disabled?: boolean }\n) => (\n <>\n {props.pins.length > 0 && (\n \n {props.header}\n \n )}\n {[...props.pins].map((immPin) => (\n \n {immPin.pin.name}\n \n \n \n \n ))}\n \n);\n\nexport const Pinout = ({\n pins,\n toggle,\n}: {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}) => {\n if (pins.length === 0) {\n return <>None;\n }\n return (\n \n \n \n \n \n \n \n \n {[...pins].map((immPin) => (\n \n \n \n \n ))}\n \n
NameValue
{immPin.pin.name}\n \n
\n );\n};\n\nconst Pin = ({\n pin,\n toggle,\n disabled = false,\n}: {\n pin: ImmPin;\n toggle: ((pin: ChipPin, bit?: number) => void) | undefined;\n disabled?: boolean;\n}) => {\n return (\n
\n {pin.bits.map(([i, v]) => (\n toggle?.(pin.pin, i)}\n disabled={disabled}\n data-testid={`pin-${i}`}\n >\n {v}\n \n ))}\n
\n );\n};\n","import { ReactNode } from \"react\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useTimer } from \"./timer.js\";\n\nexport const Runbar = (props: { runner: Timer; children?: ReactNode }) => {\n const runner = useTimer(props.runner);\n return (\n
\n runner.actions.frame()}\n data-tooltip={`Step`}\n data-placement=\"bottom\"\n >\n {/* */}\n ➡️\n \n \n runner.state.running ? runner.actions.stop() : runner.actions.start()\n }\n data-tooltip={runner.state.running ? `Pause` : `Play`}\n data-placement=\"bottom\"\n >\n {/* */}\n {runner.state.running ? \"⏸\" : \"️⏩\"}\n \n runner.actions.reset()}\n data-tooltip={`Reset`}\n data-placement=\"bottom\"\n >\n {/* */}⏮\n \n {\n runner.dispatch({\n action: \"setSpeed\",\n payload: Number(e.target?.value ?? runner.state.speed),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n // [2000, `Debug`], // For debugging, basically the same as clicking through\n [1000, `Slow`],\n [500, `Fast`],\n [16, `Faster`],\n ].map(([speed, label]) => (\n \n ))}\n \n {\n runner.dispatch({\n action: \"setSteps\",\n payload: Number(e.target?.value ?? runner.state.steps),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n [1, `1 Step`],\n [500, \"500\"],\n [1000, \"1000\"],\n [2000, \"2000\"],\n ].map(([steps, label]) => (\n \n ))}\n \n {props.children}\n
\n );\n};\n","import { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useImmerReducer } from \"./react.js\";\n\nexport interface TimerStoreState {\n steps: number;\n speed: number;\n running: boolean;\n}\n\nimport { Dispatch, MutableRefObject, useMemo, useRef } from \"react\";\nexport type TimerStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nconst makeTimerStore = (\n timer: Timer,\n dispatch: MutableRefObject\n) => {\n const initialState: TimerStoreState = {\n running: timer.running,\n speed: timer.speed,\n steps: timer.steps,\n };\n\n const finishFrame = timer.finishFrame.bind(timer);\n timer.finishFrame = function () {\n finishFrame();\n dispatch.current({ action: \"update\" });\n };\n\n const reducers = {\n update(state: TimerStoreState) {\n state.running = timer.running;\n state.speed = timer.speed;\n state.steps = timer.steps;\n },\n setSteps(state: TimerStoreState, steps: number) {\n state.steps = steps;\n timer.steps = steps;\n },\n setSpeed(state: TimerStoreState, speed: number) {\n state.speed = speed;\n timer.speed = speed;\n },\n };\n\n const actions = {\n frame() {\n timer.frame();\n },\n start() {\n timer.start();\n dispatch.current({ action: \"update\" });\n },\n stop() {\n timer.stop();\n dispatch.current({ action: \"update\" });\n },\n reset() {\n timer.reset();\n dispatch.current({ action: \"update\" });\n },\n };\n\n return { initialState, reducers, actions };\n};\n\nexport function useTimer(timer: Timer) {\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeTimerStore(timer, dispatch),\n [timer, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(reducers, initialState);\n\n dispatch.current = dispatcher;\n\n return { state, dispatch: dispatch.current, actions };\n}\n","import { Clock } from \"./chip/clock.js\";\n\nexport const MAX_STEPS = 1000;\n\nconst clock = Clock.get();\n\nexport abstract class Timer {\n frame() {\n this.tick();\n this.finishFrame();\n }\n\n abstract tick(): Promise | boolean;\n\n finishFrame() {\n clock.frame();\n }\n\n abstract reset(): void;\n\n abstract toggle(): void;\n\n steps = 1; // How many steps to take per update\n speed = 1000; // how often to update, in ms\n get running() {\n return this.#running;\n }\n\n #running = false;\n #sinceLastFrame = 0;\n #lastUpdate = 0;\n #run = async () => {\n if (!this.#running) {\n return;\n }\n const now = Date.now();\n const delta = now - this.#lastUpdate;\n this.#lastUpdate = now;\n this.#sinceLastFrame += delta;\n if (this.#sinceLastFrame > this.speed) {\n let done = false;\n for (let i = 0; i < Math.min(this.steps, MAX_STEPS) && !done; i++) {\n done = await this.tick();\n }\n this.finishFrame();\n if (done) {\n this.stop();\n }\n this.#sinceLastFrame -= this.speed;\n }\n requestAnimationFrame(this.#run);\n };\n\n start() {\n this.#running = true;\n this.#lastUpdate = Date.now() - this.speed;\n this.#run();\n this.toggle();\n }\n\n stop() {\n this.#running = false;\n this.toggle();\n }\n}\n","import { debounce } from \"@davidsouther/jiffies/lib/esm/debounce\";\nimport { Trans } from \"@lingui/macro\";\nimport MonacoEditor, { useMonaco } from \"@monaco-editor/react\";\nimport type * as monacoT from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { OnMount } from \"@monaco-editor/react\";\nimport ohm from \"ohm-js\";\nimport {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AppContext } from \"../App.context\";\n\nimport {\n Span,\n UNKNOWN_PARSE_ERROR,\n} from \"@nand2tetris/simulator/languages/base.js\";\n\nimport \"./editor.scss\";\n\nexport const ErrorPanel = ({ error }: { error?: ohm.MatchResult }) => {\n return error?.failed() ? (\n
\n \n Parse Error\n \n
\n        \n          {error?.message ?? error?.shortMessage ?? UNKNOWN_PARSE_ERROR}\n        \n      
\n
\n ) : (\n <>\n );\n};\n\nconst Textarea = ({\n value,\n onChange,\n language,\n disabled = false,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n disabled?: boolean;\n}) => {\n const [text, setText] = useState(value);\n return (\n {\n const value = e.target?.value;\n setText(value);\n onChange(value);\n }}\n />\n );\n};\n\nconst MONACO_LIGHT_THEME = \"vs\";\nconst MONACO_DARK_THEME = \"vs-dark\";\n\nconst makeHighlight = (\n monaco: typeof monacoT | null,\n editor: monacoT.editor.IStandaloneCodeEditor | undefined,\n highlight: Span | undefined,\n decorations: string[]\n): string[] => {\n if (!(editor && highlight)) return decorations;\n const model = editor.getModel();\n if (!model) return decorations;\n const start = model.getPositionAt(highlight.start);\n const end = model.getPositionAt(highlight.end);\n const range = monaco?.Range.fromPositions(start, end);\n const nextDecoration: monacoT.editor.IModelDeltaDecoration[] = [];\n if (range) {\n nextDecoration.push({\n range,\n options: { inlineClassName: \"highlight\" },\n });\n editor.revealRangeInCenter(range);\n }\n return editor.deltaDecorations(decorations, nextDecoration);\n};\n\nconst Monaco = ({\n value,\n onChange,\n language,\n error,\n disabled = false,\n highlight: currentHighlight,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n error?: ohm.MatchResult | undefined;\n disabled?: boolean;\n highlight?: Span;\n}) => {\n const { theme } = useContext(AppContext);\n const monaco = useMonaco();\n\n const editor = useRef();\n const decorations = useRef([]);\n const highlight = useRef(undefined);\n\n const codeTheme = useCallback(() => {\n const isDark =\n theme === \"system\"\n ? window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n : theme === \"dark\";\n return isDark ? MONACO_DARK_THEME : MONACO_LIGHT_THEME;\n }, [theme]);\n\n const doHighlight = useCallback(() => {\n decorations.current = makeHighlight(\n monaco,\n editor.current,\n // I'm not sure why this makes things work, but it is load bearing.\n // Removing the empty span will cause the initial first-statement\n // highlight in the test view to not show. Setting it to [0, 1] will\n // cause a 1-character highlight in the editor view, so don't do that\n // either.\n highlight.current ?? { start: 0, end: 0 },\n decorations.current\n );\n }, [decorations, monaco, editor, highlight]);\n\n // Mark and center highlighted spans\n useEffect(() => {\n highlight.current = currentHighlight;\n doHighlight();\n }, [currentHighlight]);\n\n // Set options when mounting\n const onMount: OnMount = useCallback(\n (ed) => {\n editor.current = ed;\n editor.current?.updateOptions({\n fontFamily: `\"JetBrains Mono\", source-code-pro, Menlo, Monaco,\n Consolas, \"Roboto Mono\", \"Ubuntu Monospace\", \"Noto Mono\", \"Oxygen Mono\",\n \"Liberation Mono\", monospace, \"Apple Color Emoji\", \"Segoe UI Emoji\",\n \"Segoe UI Symbol\", \"Noto Color Emoji\"`,\n fontSize: 16,\n minimap: {\n enabled: false,\n },\n theme: codeTheme(),\n scrollBeyondLastLine: false,\n });\n doHighlight();\n },\n [codeTheme]\n );\n\n // Set themes\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ theme: codeTheme() });\n }, [editor, codeTheme]);\n\n // Prevent editing disabled editors\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ readOnly: disabled });\n }, [editor, disabled]);\n\n // Add error markers on parse failure\n useEffect(() => {\n if (editor.current === undefined) return;\n if (monaco === null) return;\n const model = editor.current.getModel();\n if (model === null) return;\n if (error === undefined || error.succeeded()) {\n monaco.editor.setModelMarkers(model, language, []);\n return;\n }\n // Line 7, col 5:\n const { line, column, message } =\n /Line (?\\d+), col (?\\d+): (?.*)/.exec(\n error.shortMessage ?? \"\"\n )?.groups ?? { line: 1, column: 1, message: \"could not parse error\" };\n const startLineNumber = Number(line);\n const endLineNumber = startLineNumber;\n const startColumn = Number(column);\n const restOfLine = model\n .getLineContent(startLineNumber)\n .substring(startColumn - 1);\n let endColumn =\n startColumn + (restOfLine.match(/([^\\s]+)/)?.[0].length ?? 1);\n if (endColumn <= startColumn) {\n endColumn = startColumn + 1;\n }\n\n monaco.editor.setModelMarkers(model, language, [\n {\n message,\n startColumn,\n startLineNumber,\n endColumn,\n endLineNumber,\n severity: 8, // monacoT.MarkerSeverity.Error,\n },\n ]);\n }, [error, editor, monaco, language]);\n\n return (\n <>\n onChange(v)}\n language={language}\n onMount={onMount}\n />\n \n );\n};\n\nexport const Editor = ({\n className = \"\",\n style = {},\n disabled = false,\n value,\n onChange,\n grammar,\n language,\n highlight,\n}: {\n className?: string;\n style?: CSSProperties;\n disabled?: boolean;\n value: string;\n onChange: (source: string) => void;\n grammar: ohm.Grammar;\n language: string;\n highlight?: Span;\n}) => {\n const [error, setError] = useState();\n const { monaco } = useContext(AppContext);\n\n const parse = useCallback(\n (text = \"\") => {\n const parsed = grammar.match(text);\n setError(parsed.failed() ? parsed : undefined);\n },\n [setError, grammar]\n );\n\n useEffect(() => parse(value), [parse, value]);\n const doParse = useMemo(() => debounce(parse, 500), [parse]);\n\n const onChangeCB = useCallback(\n (text = \"\") => {\n onChange(text);\n doParse(text);\n },\n [doParse, onChange]\n );\n\n return (\n
\n {monaco.canUse && monaco.wants ? (\n \n ) : (\n <>\n \n \n \n )}\n
\n );\n};\n","export function debounce(fn, ms = 32) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => (clearTimeout(timer), fn(...args)), ms);\n return timer;\n };\n}\n","import { CSSProperties, ReactNode } from \"react\";\n\nexport const Panel = (props: {\n children: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}) => {\n return (\n
\n {props.header &&
{props.header}
}\n
{props.children}
\n {props.footer &&
{props.footer}
}\n
\n );\n};\n\nexport const Accordian = (props: {\n children: ReactNode;\n summary: ReactNode;\n className?: string;\n style?: CSSProperties;\n open?: boolean;\n}) => {\n return (\n \n \n
{props.summary}
\n
\n {props.children}\n \n );\n};\n","import { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { FileSystem } from \"@davidsouther/jiffies/lib/esm/fs.js\";\nimport { Err, isErr, Ok } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport { Dispatch, MutableRefObject, useContext, useMemo, useRef } from \"react\";\n\nimport { build as buildChip } from \"@nand2tetris/simulator/chip/builder.js\";\nimport {\n getBuiltinChip,\n REGISTRY,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n Chip,\n Chip as SimChip,\n Low,\n Pin,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\nimport { Span } from \"@nand2tetris/simulator/languages/base.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { ChipProjects, CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { ChipTest } from \"@nand2tetris/simulator/tst.js\";\n\nimport { ImmPin, reducePins } from \"../pinout.js\";\nimport { useImmerReducer } from \"../react.js\";\n\nimport { BaseContext } from \"./base.context.js\";\nimport { assert } from \"@davidsouther/jiffies/lib/esm/assert.js\";\n\nexport const PROJECT_NAMES = [\n [\"01\", `Project 1`],\n [\"02\", `Project 2`],\n [\"03\", `Project 3`],\n [\"05\", `Project 5`],\n];\n\nfunction findDropdowns(storage: Record) {\n const project =\n (storage[\"/chip/project\"] as keyof typeof CHIP_PROJECTS) ?? \"01\";\n const chips = CHIP_PROJECTS[project];\n const chipName = storage[\"/chip/chip\"] ?? chips[0];\n return { project, chips, chipName };\n}\n\nfunction makeHdl(name: string) {\n return `CHIP ${name} {\n IN in;\n OUT out;\n PARTS:\n}`;\n}\n\nfunction makeTst() {\n return `repeat 10 {\n tick,\n tock;\n}`;\n}\n\nfunction makeCmp() {\n return `| in|out|`;\n}\n\nexport interface ChipPageState {\n files: Files;\n sim: ChipSim;\n controls: ControlsState;\n}\n\nexport interface ChipSim {\n clocked: boolean;\n inPins: ImmPin[];\n outPins: ImmPin[];\n internalPins: ImmPin[];\n chip: [Chip];\n pending: boolean;\n invalid: boolean;\n}\n\nexport interface Files {\n hdl: string;\n cmp: string;\n tst: string;\n out: string;\n}\n\nexport interface ControlsState {\n project: keyof typeof CHIP_PROJECTS;\n chips: string[];\n chipName: string;\n hasBuiltin: boolean;\n runningTest: boolean;\n span?: Span;\n error: string;\n}\n\nfunction reduceChip(chip: SimChip, pending = false, invalid = false): ChipSim {\n return {\n clocked: chip.clocked,\n inPins: reducePins(chip.ins),\n outPins: reducePins(chip.outs),\n internalPins: reducePins(chip.pins),\n chip: [chip],\n pending,\n invalid,\n };\n}\n\nconst clock = Clock.get();\n\nexport type ChipStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nexport function makeChipStore(\n fs: FileSystem,\n setStatus: (status: string) => void,\n storage: Record,\n dispatch: MutableRefObject\n) {\n const dropdowns = findDropdowns(storage);\n let { project, chipName } = dropdowns;\n const { chips } = dropdowns;\n let chip = new Low();\n let test = new ChipTest();\n let usingBuiltin = false;\n\n const reducers = {\n setFiles(\n state: ChipPageState,\n {\n hdl = state.files.hdl,\n tst = state.files.tst,\n cmp = state.files.cmp,\n out = \"\",\n }: {\n hdl?: string;\n tst?: string;\n cmp?: string;\n out?: string;\n }\n ) {\n state.files.hdl = hdl;\n state.files.tst = tst;\n state.files.cmp = cmp;\n state.files.out = out;\n },\n\n updateChip(\n state: ChipPageState,\n payload?: {\n pending?: boolean;\n invalid?: boolean;\n chipName?: string;\n error?: string;\n }\n ) {\n state.sim = reduceChip(\n chip,\n payload?.pending ?? state.sim.pending,\n payload?.invalid ?? state.sim.invalid\n );\n state.controls.error = state.sim.invalid\n ? payload?.error ?? state.controls.error\n : \"\";\n state.controls.chips = CHIP_PROJECTS[state.controls.project];\n state.controls.chipName = state.sim.invalid\n ? payload?.chipName ?? chipName\n : chip.name ?? payload?.chipName ?? chipName;\n if (!state.controls.chips.includes(state.controls.chipName)) {\n state.controls.chips = [\n ...state.controls.chips,\n state.controls.chipName,\n ];\n }\n },\n\n setProject(state: ChipPageState, project: keyof typeof CHIP_PROJECTS) {\n const chips = CHIP_PROJECTS[project];\n const chipName =\n state.controls.chipName && chips.includes(state.controls.chipName)\n ? state.controls.chipName\n : chips[0];\n state.controls.project = project;\n state.controls.chips = chips;\n this.setChip(state, chipName);\n },\n\n setChip(state: ChipPageState, chipName: string) {\n state.controls.chipName = chipName;\n state.controls.hasBuiltin = REGISTRY.has(chipName);\n },\n\n testRunning(state: ChipPageState) {\n state.controls.runningTest = true;\n },\n\n testFinished(state: ChipPageState) {\n state.controls.runningTest = false;\n const passed = state.files.out.trim() === state.files.cmp.trim();\n setStatus(\n passed\n ? `Simulation successful: The output file is identical to the compare file`\n : `Simulation error: The output file differs from the compare file`\n );\n },\n\n updateTestStep(state: ChipPageState) {\n state.files.out = test?.log() ?? \"\";\n if (test?.currentStep?.span) {\n state.controls.span = test.currentStep.span;\n } else {\n if (test.done) {\n const end = state.files.tst.length;\n state.controls.span = {\n start: end - 1,\n end,\n };\n }\n }\n this.updateChip(state, {\n pending: state.sim.pending,\n invalid: state.sim.invalid,\n });\n },\n };\n\n const actions = {\n setProject(p: keyof typeof CHIP_PROJECTS) {\n project = storage[\"/chip/project\"] = p;\n dispatch.current({ action: \"setProject\", payload: project });\n this.setChip(CHIP_PROJECTS[project][0]);\n },\n\n async setChip(chip: string, project = storage[\"/chip/project\"] ?? \"01\") {\n chipName = storage[\"/chip/chip\"] = chip;\n dispatch.current({ action: \"setChip\", payload: chipName });\n await this.loadChip(project, chipName);\n if (usingBuiltin) {\n this.useBuiltin();\n }\n },\n\n reset() {\n Clock.get().reset();\n chip.reset();\n test.reset();\n dispatch.current({ action: \"setFiles\", payload: {} });\n dispatch.current({ action: \"updateChip\" });\n },\n\n async updateFiles({\n hdl,\n tst,\n cmp,\n }: {\n hdl?: string;\n tst?: string;\n cmp: string;\n }) {\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n try {\n if (hdl) {\n await this.compileChip(hdl);\n }\n if (tst) {\n this.compileTest(tst);\n }\n } catch (e) {\n setStatus(display(e));\n }\n },\n\n async compileChip(hdl: string) {\n chip.remove();\n const maybeParsed = HDL.parse(hdl);\n if (isErr(maybeParsed)) {\n setStatus(\"Failed to parse chip\");\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error: display(Err(maybeParsed)) },\n });\n return;\n }\n const maybeChip = await buildChip(Ok(maybeParsed));\n if (isErr(maybeChip)) {\n const error = display(Err(maybeChip));\n setStatus(error);\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error },\n });\n return;\n }\n setStatus(`Compiled ${chip.name}`);\n this.replaceChip(Ok(maybeChip));\n },\n\n replaceChip(nextChip: SimChip) {\n // Store current inPins\n const inPins = chip.ins;\n for (const [pin, { busVoltage }] of inPins) {\n const nextPin = nextChip.ins.get(pin);\n if (nextPin) {\n nextPin.busVoltage = busVoltage;\n }\n }\n clock.reset();\n nextChip.eval();\n chip = nextChip;\n chip.reset();\n test = test.with(chip).reset();\n dispatch.current({ action: \"updateChip\", payload: { invalid: false } });\n dispatch.current({ action: \"updateTestStep\" });\n },\n\n async loadChip(project: string, name: string) {\n storage[\"/chip/chip\"] = name;\n const fsName = (ext: string) =>\n `/projects/${project}/${name}/${name}.${ext}`;\n\n const [hdl, tst, cmp] = await Promise.all([\n fs.readFile(fsName(\"hdl\")).catch(() => makeHdl(name)),\n fs.readFile(fsName(\"tst\")).catch((e) => {\n console.log(e);\n return makeTst();\n }),\n fs.readFile(fsName(\"cmp\")).catch(() => makeCmp()),\n ]);\n\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n await this.compileChip(hdl);\n this.compileTest(tst);\n },\n\n async saveChip(hdl: string, prj = project, name = chipName) {\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n const path = `/projects/${prj}/${name}/${name}.hdl`;\n await fs.writeFile(path, hdl);\n setStatus(`Saved ${path}`);\n },\n\n toggle(pin: Pin, i: number | undefined) {\n if (i !== undefined) {\n pin.busVoltage = pin.busVoltage ^ (1 << i);\n } else {\n if (pin.width === 1) {\n pin.toggle();\n } else {\n pin.busVoltage += 1;\n }\n }\n dispatch.current({ action: \"updateChip\", payload: { pending: true } });\n },\n\n eval() {\n chip.eval();\n dispatch.current({ action: \"updateChip\", payload: { pending: false } });\n },\n\n clock() {\n clock.toggle();\n if (clock.isLow) {\n clock.frame();\n }\n dispatch.current({ action: \"updateChip\" });\n },\n\n async useBuiltin(doUseBuiltin = true, hdl?: string) {\n if (!doUseBuiltin) {\n usingBuiltin = false;\n await this.loadChip(project, chipName);\n return;\n }\n usingBuiltin = true;\n const builtinName = chip.name ?? chipName;\n const nextChip = getBuiltinChip(builtinName);\n if (isErr(nextChip)) {\n setStatus(\n `Failed to load builtin ${builtinName}: ${display(Err(nextChip))}`\n );\n return;\n }\n\n // Save hdl code that will be overwritten by the switch\n if (hdl) {\n await this.saveChip(hdl, project, chipName);\n }\n\n const template = (ChipProjects[project].CHIPS as any)[builtinName][\n `${builtinName}.hdl`\n ] as string;\n const builtinCode = template.replace(\n \"PARTS:\",\n `PARTS:\\n BUILTIN ${builtinName}`\n );\n dispatch.current({ action: \"setFiles\", payload: { hdl: builtinCode } });\n this.replaceChip(Ok(nextChip));\n },\n\n async initialize() {\n await this.loadChip(project, chipName);\n },\n\n compileTest(file: string) {\n dispatch.current({ action: \"setFiles\", payload: { tst: file } });\n const tst = TST.parse(file);\n\n if (isErr(tst)) {\n setStatus(`Failed to parse test`);\n return false;\n }\n setStatus(`Parsed tst`);\n\n test = ChipTest.from(Ok(tst)).with(chip).reset();\n test.setFileSystem(fs);\n dispatch.current({ action: \"updateTestStep\" });\n return true;\n },\n\n async runTest(file: string) {\n if (!this.compileTest(file)) {\n return;\n }\n dispatch.current({ action: \"testRunning\" });\n\n fs.pushd(\"/samples\");\n await test.run();\n fs.popd();\n\n dispatch.current({ action: \"updateTestStep\" });\n dispatch.current({ action: \"testFinished\" });\n },\n\n tick(): Promise {\n return this.stepTest();\n },\n\n async stepTest(): Promise {\n assert(test.chipId === chip.id, \"Test and chip out of sync\");\n const done = await test.step();\n dispatch.current({ action: \"updateTestStep\" });\n if (done) {\n dispatch.current({ action: \"testFinished\" });\n }\n return done;\n },\n };\n\n const initialState: ChipPageState = (() => {\n const controls: ControlsState = {\n project,\n chips,\n chipName,\n hasBuiltin: REGISTRY.has(chipName),\n runningTest: false,\n error: \"\",\n };\n\n const maybeChip = getBuiltinChip(controls.chipName);\n if (isErr(maybeChip)) {\n setStatus(display(Err(maybeChip)));\n chip = new Low();\n } else {\n chip = Ok(maybeChip);\n }\n\n const sim = reduceChip(chip);\n\n return {\n controls,\n files: {\n hdl: \"\",\n cmp: \"\",\n tst: \"\",\n out: \"\",\n },\n sim,\n };\n })();\n\n return { initialState, reducers, actions };\n}\n\nexport function useChipPageStore() {\n const { fs, setStatus, storage } = useContext(BaseContext);\n\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeChipStore(fs, setStatus, storage, dispatch),\n [fs, setStatus, storage, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(\n reducers as unknown as Record<\n string,\n (state: ChipPageState, action?: unknown) => ChipPageState\n >,\n initialState\n );\n dispatch.current = dispatcher;\n\n return { state, dispatch, actions };\n}\n","import { Trans } from \"@lingui/macro\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport \"./chip.scss\";\n\nimport { makeVisualizationsWithId } from \"@nand2tetris/components/chips/visualizations.js\";\nimport { Clockface } from \"@nand2tetris/components/clockface.js\";\nimport { DiffTable } from \"@nand2tetris/components/difftable.js\";\nimport { FullPinout } from \"@nand2tetris/components/pinout.js\";\nimport { useStateInitializer } from \"@nand2tetris/components/react.js\";\nimport { Runbar } from \"@nand2tetris/components/runbar.js\";\nimport { CMP } from \"@nand2tetris/simulator/languages/cmp.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { AppContext } from \"../App.context\";\nimport { Icon } from \"../pico/icon\";\nimport { Editor } from \"../shell/editor\";\nimport { Accordian, Panel } from \"../shell/panel\";\nimport {\n Files,\n PROJECT_NAMES,\n useChipPageStore,\n} from \"@nand2tetris/components/stores/chip.store.js\";\nimport { BaseContext } from \"@nand2tetris/components/stores/base.context.js\";\n\nexport const Chip = () => {\n const { fs, setStatus } = useContext(BaseContext);\n const { filePicker, tracking } = useContext(AppContext);\n const { state, actions, dispatch } = useChipPageStore();\n\n const [hdl, setHdl] = useStateInitializer(state.files.hdl);\n const [tst, setTst] = useStateInitializer(state.files.tst);\n const [cmp, setCmp] = useStateInitializer(state.files.cmp);\n const [out] = useStateInitializer(state.files.out);\n\n useEffect(() => {\n actions.initialize();\n }, [actions]);\n\n useEffect(() => {\n tracking.trackPage(\"/chip\");\n }, [tracking]);\n\n const saveChip = () => {\n actions.saveChip(hdl);\n };\n\n useEffect(() => {\n tracking.trackEvent(\"action\", \"setProject\", state.controls.project);\n tracking.trackEvent(\"action\", \"setChip\", state.controls.chipName);\n }, []);\n\n const setProject = useCallback(\n (project: keyof typeof CHIP_PROJECTS) => {\n actions.setProject(project);\n tracking.trackEvent(\"action\", \"setProject\", project);\n },\n [actions, tracking]\n );\n\n const setChip = useCallback(\n (chip: string) => {\n actions.setChip(chip);\n tracking.trackEvent(\"action\", \"setChip\", chip);\n },\n [actions, tracking]\n );\n\n const doEval = useCallback(() => {\n actions.eval();\n tracking.trackEvent(\"action\", \"eval\");\n }, [actions, tracking]);\n\n const compile = useRef<(files?: Partial) => void>(() => undefined);\n compile.current = async (files: Partial = {}) => {\n await actions.updateFiles({\n hdl: files.hdl,\n tst: files.tst ?? tst,\n cmp: files.cmp ?? cmp,\n });\n };\n\n const loadTest = useCallback(async () => {\n try {\n const path = await filePicker.select();\n const tst = await fs.readFile(path);\n await compile.current({ tst });\n } catch (e) {\n console.error(e);\n setStatus(`Failed to load into memory`);\n }\n }, [filePicker, setStatus, fs, compile]);\n\n const runner = useRef();\n useEffect(() => {\n runner.current = new (class ChipTimer extends Timer {\n async reset(): Promise {\n await compile.current();\n await actions.reset();\n }\n\n override finishFrame(): void {\n super.finishFrame();\n dispatch.current({ action: \"updateTestStep\" });\n }\n\n async tick(): Promise {\n return actions.stepTest();\n }\n\n toggle(): void {\n dispatch.current({ action: \"updateTestStep\" });\n }\n })();\n\n return () => {\n runner.current?.stop();\n };\n }, [compile, actions, dispatch]);\n\n const clockActions = useMemo(\n () => ({\n toggle() {\n actions.clock();\n tracking.trackEvent(\"action\", \"toggleClock\");\n },\n reset() {\n tracking.trackEvent(\"action\", \"resetClock\");\n actions.reset();\n },\n }),\n [actions]\n );\n\n const [useBuiltin, setUseBuiltin] = useState(false);\n const toggleUseBuiltin = () => {\n if (useBuiltin) {\n setUseBuiltin(false);\n actions.useBuiltin(false);\n } else {\n setUseBuiltin(true);\n actions.useBuiltin(true, hdl);\n }\n };\n\n const selectors = (\n <>\n
\n {\n setProject(value as keyof typeof CHIP_PROJECTS);\n }}\n data-testid=\"project-picker\"\n >\n {PROJECT_NAMES.map(([number, label]) => (\n \n ))}\n \n {\n setChip(value);\n }}\n data-testid=\"chip-picker\"\n >\n {state.controls.chips.map((chip) => (\n \n ))}\n \n \n
\n \n );\n const hdlPanel = (\n \n
HDL
\n
\n {state.controls.hasBuiltin && (\n \n )}\n
\n {selectors}\n \n }\n >\n {\n setHdl(source);\n compile.current(useBuiltin ? {} : { hdl: source });\n }}\n grammar={HDL.parser}\n language={\"hdl\"}\n disabled={useBuiltin}\n />\n \n );\n\n const chipButtons = (\n
\n \n \n Clock:{\"\\u00a0\"}\n \n \n \n Reset\n \n
\n );\n\n const visualizations: [string, ReactNode][] = makeVisualizationsWithId({\n parts: state.sim.chip,\n });\n\n const pinsPanel = (\n \n
\n Chip\n
\n {chipButtons}\n \n }\n >\n {state.sim.invalid ? (\n Invalid Chip\n ) : (\n <>\n \n {visualizations.length > 0 && (\n Visualizations} open={true}>\n
{visualizations.map(([_, v]) => v)}
\n
\n )}\n \n )}\n \n );\n\n const [selectedTestTab, doSetSelectedTestTab] = useState<\n \"tst\" | \"cmp\" | \"out\"\n >(\"tst\");\n\n const setSelectedTestTab = useCallback(\n (tab: typeof selectedTestTab) => {\n doSetSelectedTestTab(tab);\n tracking.trackEvent(\"tab\", \"change\", tab);\n },\n [tracking]\n );\n\n const testPanel = (\n \n
\n Test\n
\n
\n {runner.current && }\n
\n
\n \n
\n \n }\n >\n
\n \n \n
\n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n\n return (\n
\n {hdlPanel}\n {pinsPanel}\n {testPanel}\n
\n );\n};\n\nexport default Chip;\n"],"names":["ALUComponent","A","op","D","out","flag","_jsxs","children","_jsx","bin","COMMANDS","Flags","RegisterComponent","name","bits","dec","KeyMap","Enter","Backspace","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","Escape","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","Keyboard","keyboard","useState","showPicker","setShowPicker","busVoltage","setBits","setKey","useCallback","event","key","keypress","mapping","undefined","length","code","charCodeAt","keyPressToHackCharacter","preventDefault","changeKey","className","ref","e","focus","type","onKeyDown","onClick","Sizes","none","sm","md","lg","xl","full","Sides","t","r","l","b","tl","tr","bl","br","Widths","isSide","v","getSize","size","getSide","side","rounded","sized","reduce","prev","curr","borderRadius","width","amount","block","display","die","error","args","msg","Error","map","s","join","isDraft","value","DRAFT_STATE","isDraftable","proto","Object","getPrototypeOf","Ctor","hasOwnProperty","call","constructor","Function","toString","objectCtorString","Array","isArray","DRAFTABLE","_value$constructor","isMap","isSet","each","obj","iter","enumerableOnly","getArchtype","keys","ownKeys","forEach","entry","index","thing","state","type_","has","prop","prototype","get","set","propOrOldValue","delete","add","is","x","y","target","hasMap","Map","hasSet","Set","latest","copy_","base_","shallowCopy","base","slice","descriptors","getOwnPropertyDescriptors","i","desc","writable","configurable","enumerable","create","freeze","deep","isFrozen","clear","dontMutateFrozenCollections","getPlugin","pluginKey","plugin","plugins","getCurrentScope","currentScope","usePatchesInScope","scope","patchListener","patches_","inversePatches_","patchListener_","revokeScope","leaveScope","drafts_","revokeDraft","parent_","enterScope","immer","immer_","canAutoFreeze_","unfinalizedDrafts_","draft","revoke_","revoked_","processResult","result","baseDraft","isReplaced","useProxies_","willFinalizeES5_","modified_","finalize","maybeFreeze","generateReplacementPatches_","NOTHING","rootScope","path","childValue","finalizeProperty","scope_","finalized_","draft_","generatePatches_","parentState","targetObject","rootPath","res","assigned_","concat","autoFreeze_","peek","getDescriptorFromProto","source","getOwnPropertyDescriptor","markChanged","prepareCopy","createProxy","parent","proxyMap_","proxySet_","isManual_","traps","objectTraps","arrayTraps","Proxy","revocable","revoke","proxy","createES5Proxy_","push","current","currentImpl","copy","archType","hasChanges_","copyHelper","from","hasSymbol","Symbol","hasProxies","Reflect","for","iterator","getOwnPropertySymbols","getOwnPropertyNames","_desc$get","currentState","deleteProperty","owner","defineProperty","setPrototypeOf","fn","arguments","apply","this","Immer","config","recipe","defaultBase","self","_this","produce","_this2","hasError","Promise","then","p","ip","produceWithPatches","patches","inversePatches","n","nextState","useProxies","setUseProxies","autoFreeze","setAutoFreeze","createDraft","finishDraft","applyPatches","patch","applyPatchesImpl","applyPatches_","bind","useImmerReducer","reducers","initialState","useReducer","command","action","payload","useStateInitializer","init","setState","useEffect","Mode","props","mode","setMode","setValue","view","style","cursor","doSelect","select","doChange","onChange","edit","position","zIndex","left","marginTop","onBlur","onKeyPress","defaultValue","render","doScroll","scrollTop","totalHeight","toleranceHeight","bufferedItems","settings","itemHeight","minIndex","maxIndex","Math","floor","data","offset","limit","start","max","min","getData","topPaddingHeight","bottomPaddingHeight","viewportRef","useRef","useMemo","Number","MAX_SAFE_INTEGER","startIndex","count","tolerance","fillVirtualScrollSettings","startState","adapter","itemsAbove","viewportHeight","reducer","scrollReducer","dispatchScroll","row","initialScroll","div","rows","d","height","rowKey","overflowY","overflowAnchor","onScroll","MemoryBlock","memory","jmp","highlight","editable","format","range","MemoryCell","VirtualScroll","background","hex","flex","textAlign","InlineEdit","newValue","Memory","fmt","setFormat","setJmp","goto","setGoto","jumpTo","doUpdate","update","role","placeholder","FORMATS","option","checked","asm","doFormat","displayClock","Clock","Clockface","clockface","setClockface","subscription","$","subscribe","unsubscribe","useClockface","whiteSpace","WHITE","mem","pixel","color","Screen","frameFinished","canvas","draw","ctx","getContext","image","assertExists","getImageData","col","putImageData","drawImage","ctxRef","frame$","maxWidth","boxSizing","marginInline","margin","borderTop","borderLeft","borderBottom","borderRight","makeVisualization","chip","ALU","in","voltage","HIGH","VRegister","id","PC","KeyboardComponent","ScreenComponent","RAM","MemoryComponent","address","RAM8","CPU","decode","am","vis","parts","filter","reducePin","pin","reverse","reducePins","pins","entries","FullPinout","sim","inPins","outPins","internalPins","PinoutBlock","header","toggle","disabled","pending","colSpan","immPin","Pin","Runbar","runner","timer","dispatch","running","speed","steps","finishFrame","setSteps","setSpeed","actions","frame","stop","reset","makeTimerStore","dispatcher","useTimer","label","clock","Timer","now","Date","delta","done","tick","requestAnimationFrame","ErrorPanel","failed","open","message","shortMessage","UNKNOWN_PARSE_ERROR","Textarea","language","text","setText","Monaco","currentHighlight","theme","useContext","AppContext","monaco","useMonaco","editor","decorations","codeTheme","window","matchMedia","matches","doHighlight","model","getModel","getPositionAt","end","Range","fromPositions","nextDecoration","options","inlineClassName","revealRangeInCenter","deltaDecorations","makeHighlight","onMount","ed","updateOptions","fontFamily","fontSize","minimap","enabled","scrollBeyondLastLine","readOnly","succeeded","setModelMarkers","exec","groups","line","column","startLineNumber","endLineNumber","startColumn","endColumn","getLineContent","substring","match","severity","Editor","grammar","setError","parse","parsed","doParse","ms","clearTimeout","setTimeout","debounce","onChangeCB","canUse","wants","Panel","footer","Accordian","summary","PROJECT_NAMES","makeHdl","reduceChip","invalid","clocked","ins","outs","makeChipStore","fs","setStatus","storage","dropdowns","project","chips","CHIP_PROJECTS","chipName","findDropdowns","Low","test","ChipTest","usingBuiltin","setFiles","hdl","files","tst","cmp","updateChip","controls","includes","setProject","setChip","hasBuiltin","REGISTRY","testRunning","runningTest","testFinished","passed","trim","updateTestStep","log","currentStep","span","loadChip","useBuiltin","updateFiles","compileChip","compileTest","remove","maybeParsed","HDL","isErr","Err","buildChip","Ok","maybeChip","replaceChip","nextChip","nextPin","eval","with","fsName","ext","all","readFile","catch","console","saveChip","prj","writeFile","isLow","doUseBuiltin","builtinName","getBuiltinChip","template","ChipProjects","CHIPS","builtinCode","replace","initialize","file","TST","setFileSystem","runTest","pushd","run","popd","stepTest","assert","chipId","step","Chip","BaseContext","filePicker","tracking","useChipPageStore","setHdl","setTst","setCmp","trackPage","trackEvent","doEval","compile","loadTest","clockActions","setUseBuiltin","selectors","number","hdlPanel","tabIndex","chipButtons","visualizations","part","makeVisualizationsWithId","pinsPanel","selectedTestTab","doSetSelectedTestTab","setSelectedTestTab","tab","testPanel","CMP"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/605.bdf4e452.chunk.js.map b/static/js/605.bdf4e452.chunk.js.map deleted file mode 100644 index 1266b7ac..00000000 --- a/static/js/605.bdf4e452.chunk.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"static/js/605.bdf4e452.chunk.js","mappings":"qZAOaA,EAAe,SAAH,SACvBC,EAAC,EAADA,EACAC,EAAE,EAAFA,GACAC,EAAC,EAADA,EACAC,EAAG,EAAHA,IACAC,EAAI,EAAJA,KAAI,OAQJC,EAAAA,EAAAA,MAAAA,MAAAA,CAAAC,SAAAA,EAC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hH,QAASgG,GAAAA,GAAAA,OACTrJ,SAAU,MACV1I,UAAWnP,EAAM6d,SAASc,UAG9B,gBACEnO,KAAK,MACLmD,GAAG,eACH,gBAAc,qBACd,gBAAmC,QAApByP,GAA0B,UAEzC,8BACE,kBACE/nB,KAAK,QACLrD,KAAK,YACL,gBAAc,oBACdkG,MAAM,MACN0S,QAA6B,QAApBwS,GACT5X,SAAU,kBAAM8X,GAAmB,MAAM,IACzC,qBAIN,gBACE9S,KAAK,WACL,kBAAgB,eAChBmD,GAAG,oBACHxI,MAAO,CAAEO,SAAU,YAAa,UAEhC,SAACuP,GAAM,CACL/c,MAAOyf,EACPnS,SAAU2W,EACVjH,QAASuI,GAAAA,GAAAA,OACT5L,SAAU,WAGd,gBACErH,KAAK,MACLmD,GAAG,eACH,gBAAc,oBACd,gBAAmC,QAApByP,GAA0B,UAEzC,8BACE,kBACE/nB,KAAK,QACLrD,KAAK,YACL,gBAAc,oBACdkG,MAAM,MACN0S,QAA6B,QAApBwS,GACT5X,SAAU,kBAAM8X,GAAmB,MAAM,IACzC,oBAIN,gBACE9S,KAAK,WACLmD,GAAG,oBACH,kBAAgB,eAAc,UAE9B,SAAC,KAAS,CAACgK,IAAKA,EAAKpmB,IAAKA,WAMlC,OACE,iBAAK0D,UAAU,gBAAe,UAC3B4nB,EACAM,EACAK,KAGP,EAEA,K","sources":["../../components/src/chips/alu.tsx","../../components/src/chips/register.tsx","../../components/src/chips/keyboard.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/constants.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/core.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/border.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/sizing.js","../../node_modules/immer/src/utils/errors.ts","../../node_modules/immer/src/utils/common.ts","../../node_modules/immer/src/utils/plugins.ts","../../node_modules/immer/src/core/scope.ts","../../node_modules/immer/src/core/finalize.ts","../../node_modules/immer/src/core/proxy.ts","../../node_modules/immer/src/core/immerClass.ts","../../node_modules/immer/src/core/current.ts","../../node_modules/immer/src/immer.ts","../../node_modules/immer/src/utils/env.ts","../../components/src/react.ts","../../components/src/inline_edit.tsx","../../components/src/virtual_scroll.tsx","../../components/src/chips/memory.tsx","../../components/src/clockface.tsx","../../components/src/chips/screen.tsx","../../components/src/chips/visualizations.tsx","../../components/src/pinout.tsx","../../components/src/runbar.tsx","../../components/src/timer.tsx","../../simulator/src/timer.ts","shell/editor.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/debounce.js","shell/panel.tsx","../../components/src/stores/chip.store.ts","pages/chip.tsx"],"sourcesContent":["import {\n COMMANDS,\n COMMANDS_OP,\n Flags,\n} from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { bin } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const ALUComponent = ({\n A,\n op,\n D,\n out,\n flag,\n}: {\n A: number;\n op: COMMANDS_OP;\n D: number;\n out: number;\n flag: keyof typeof Flags;\n}) => (\n
\n ALU\n
\n
A
{bin(A)}
\n
op
{COMMANDS.op[op] ?? \"(??)\"}
\n
D
{bin(D)}
\n
=
{bin(out)}
\n
{Flags[flag as keyof typeof Flags]}
\n
\n
\n);\n","import { dec } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const RegisterComponent = ({\n name,\n bits,\n}: {\n name: string;\n bits: number;\n}) => (\n
\n {name}: {dec(bits)}\n
\n);\n","import { Keyboard as KeyboardChip } from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { KeyboardEvent, useCallback, useState } from \"react\";\nimport { RegisterComponent } from \"./register.js\";\n\nconst KeyMap: Record = {\n // Delete: 127,\n Enter: 128,\n Backspace: 129,\n ArrowLeft: 130,\n ArrowUp: 131,\n ArrowRight: 132,\n ArrowDown: 133,\n Home: 134,\n End: 135,\n PageUp: 136,\n PageDown: 137,\n Insert: 138,\n Delete: 139,\n Escape: 140,\n F1: 141,\n F2: 142,\n F3: 143,\n F4: 144,\n F5: 145,\n F6: 146,\n F7: 147,\n F8: 148,\n F9: 149,\n F10: 150,\n F11: 151,\n F12: 152,\n};\n\nfunction keyPressToHackCharacter(keypress: KeyboardEvent): number {\n const mapping = KeyMap[keypress.key];\n if (mapping !== undefined) {\n return mapping;\n }\n if (keypress.key.length === 1) {\n const code = keypress.key.charCodeAt(0);\n if (code >= 32 && code <= 126) {\n return code;\n }\n }\n\n return 0;\n}\n\nexport const Keyboard = ({ keyboard }: { keyboard: KeyboardChip }) => {\n const [showPicker, setShowPicker] = useState(false);\n const [bits, setBits] = useState(keyboard.out().busVoltage);\n\n const setKey = useCallback(\n (event: KeyboardEvent) => {\n const key = keyPressToHackCharacter(event);\n if (key === 0) {\n return;\n }\n event.preventDefault();\n keyboard.setKey(key);\n setBits(keyboard.out().busVoltage);\n setShowPicker(false);\n },\n [keyboard, setShowPicker, setBits]\n );\n\n const changeKey = useCallback(() => {\n setShowPicker(true);\n }, []);\n\n return (\n
\n
\n \n
\n
\n {showPicker ? (\n e?.focus()} type=\"text\" onKeyDown={setKey} />\n ) : (\n \n )}\n
\n
\n );\n};\n","export const Sizes = {\n none: \"0px\",\n sm: \"0.125rem\",\n \"\": \"0.25rem\",\n md: \"0.375rem\",\n lg: \"0.5rem\",\n xl: \"0.75rem\",\n \"2xl\": \"1rem\",\n \"3xl\": \"1.5rem\",\n full: \"9999px\",\n};\nexport const Sides = {\n \"\": \"\",\n t: \"Top\",\n r: \"Right\",\n l: \"Left\",\n b: \"Bottom\",\n tl: \"TopLeft\",\n tr: \"TopRight\",\n bl: \"BottomLeft\",\n br: \"BottomRight\",\n};\nexport const Widths = {\n \"1/4\": \"25%\",\n \"1/2\": \"50%\",\n \"3/4\": \"75%\",\n full: \"100%\",\n};\n","import { Sides, Sizes } from \"./constants.js\";\nexport function isSide(v) {\n return Sides[v] !== undefined;\n}\nexport function isSize(v) {\n return Sizes[v] !== undefined;\n}\nexport function getSize(size) {\n return Sizes[size];\n}\nexport function getSide(side) {\n switch (side) {\n case \"t\":\n return [...getSide(\"tl\"), ...getSide(\"tr\")];\n case \"r\":\n return [...getSide(\"tr\"), ...getSide(\"br\")];\n case \"b\":\n return [...getSide(\"br\"), ...getSide(\"bl\")];\n case \"l\":\n return [...getSide(\"tl\"), ...getSide(\"bl\")];\n default:\n return [Sides[side]];\n }\n}\n","import { isSide, getSize, getSide } from \"./core.js\";\nexport function rounded(size = \"\", side = \"\") {\n if (isSide(size)) {\n side = size;\n size = \"\";\n }\n const sized = getSize(size);\n return getSide(side).reduce((prev, curr) => {\n if (curr === \"\") {\n prev.borderRadius = sized;\n }\n else {\n // @ts-ignore\n prev[`border${curr}Radius`] = sized;\n }\n return prev;\n }, {});\n}\nexport function border({ side = \"\", style = \"solid\", radius = \"\", width = 1, color = \"black\", }) {\n return {};\n}\nexport function inset(width, color1 = \"gray\", color2 = \"lightgray\") {\n return {\n ...border({ side: \"tl\", width, color: color1, radius: \"none\" }),\n ...border({ side: \"br\", width, color: color2, radius: \"none\" }),\n };\n}\n","import { Widths } from \"./constants.js\";\nexport function width(amount, block) {\n if (amount === undefined && Widths[block] !== undefined) {\n amount = block;\n }\n return {\n ...(block === \"inline\" ? { display: \"inline-block\" } : {}),\n width: Widths[amount] ?? \"0\",\n };\n}\n","const errors = {\n\t0: \"Illegal state\",\n\t1: \"Immer drafts cannot have computed properties\",\n\t2: \"This object has been frozen and should not be mutated\",\n\t3(data: any) {\n\t\treturn (\n\t\t\t\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n\t\t\tdata\n\t\t)\n\t},\n\t4: \"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",\n\t5: \"Immer forbids circular references\",\n\t6: \"The first or second argument to `produce` must be a function\",\n\t7: \"The third argument to `produce` must be a function or undefined\",\n\t8: \"First argument to `createDraft` must be a plain object, an array, or an immerable object\",\n\t9: \"First argument to `finishDraft` must be a draft returned by `createDraft`\",\n\t10: \"The given draft is already finalized\",\n\t11: \"Object.defineProperty() cannot be used on an Immer draft\",\n\t12: \"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t13: \"Immer only supports deleting array indices\",\n\t14: \"Immer only supports setting array indices and the 'length' property\",\n\t15(path: string) {\n\t\treturn \"Cannot apply patch, path doesn't resolve: \" + path\n\t},\n\t16: 'Sets cannot have \"replace\" patches.',\n\t17(op: string) {\n\t\treturn \"Unsupported patch operation: \" + op\n\t},\n\t18(plugin: string) {\n\t\treturn `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \\`enable${plugin}()\\` when initializing your application.`\n\t},\n\t20: \"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",\n\t21(thing: string) {\n\t\treturn `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`\n\t},\n\t22(thing: string) {\n\t\treturn `'current' expects a draft, got: ${thing}`\n\t},\n\t23(thing: string) {\n\t\treturn `'original' expects a draft, got: ${thing}`\n\t},\n\t24: \"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"\n} as const\n\nexport function die(error: keyof typeof errors, ...args: any[]): never {\n\tif (__DEV__) {\n\t\tconst e = errors[error]\n\t\tconst msg = !e\n\t\t\t? \"unknown error nr: \" + error\n\t\t\t: typeof e === \"function\"\n\t\t\t? e.apply(null, args as any)\n\t\t\t: e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}${\n\t\t\targs.length ? \" \" + args.map(s => `'${s}'`).join(\",\") : \"\"\n\t\t}. Find the full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","import {\n\tDRAFT_STATE,\n\tDRAFTABLE,\n\thasSet,\n\tObjectish,\n\tDrafted,\n\tAnyObject,\n\tAnyMap,\n\tAnySet,\n\tImmerState,\n\thasMap,\n\tArchtype,\n\tdie\n} from \"../internal\"\n\n/** Returns true if the given value is an Immer draft */\n/*#__PURE__*/\nexport function isDraft(value: any): boolean {\n\treturn !!value && !!value[DRAFT_STATE]\n}\n\n/** Returns true if the given value can be drafted by Immer */\n/*#__PURE__*/\nexport function isDraftable(value: any): boolean {\n\tif (!value) return false\n\treturn (\n\t\tisPlainObject(value) ||\n\t\tArray.isArray(value) ||\n\t\t!!value[DRAFTABLE] ||\n\t\t!!value.constructor?.[DRAFTABLE] ||\n\t\tisMap(value) ||\n\t\tisSet(value)\n\t)\n}\n\nconst objectCtorString = Object.prototype.constructor.toString()\n/*#__PURE__*/\nexport function isPlainObject(value: any): boolean {\n\tif (!value || typeof value !== \"object\") return false\n\tconst proto = Object.getPrototypeOf(value)\n\tif (proto === null) {\n\t\treturn true\n\t}\n\tconst Ctor =\n\t\tObject.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n\n\tif (Ctor === Object) return true\n\n\treturn (\n\t\ttypeof Ctor == \"function\" &&\n\t\tFunction.toString.call(Ctor) === objectCtorString\n\t)\n}\n\n/** Get the underlying object that is represented by the given draft */\n/*#__PURE__*/\nexport function original(value: T): T | undefined\nexport function original(value: Drafted): any {\n\tif (!isDraft(value)) die(23, value)\n\treturn value[DRAFT_STATE].base_\n}\n\n/*#__PURE__*/\nexport const ownKeys: (target: AnyObject) => PropertyKey[] =\n\ttypeof Reflect !== \"undefined\" && Reflect.ownKeys\n\t\t? Reflect.ownKeys\n\t\t: typeof Object.getOwnPropertySymbols !== \"undefined\"\n\t\t? obj =>\n\t\t\t\tObject.getOwnPropertyNames(obj).concat(\n\t\t\t\t\tObject.getOwnPropertySymbols(obj) as any\n\t\t\t\t)\n\t\t: /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport const getOwnPropertyDescriptors =\n\tObject.getOwnPropertyDescriptors ||\n\tfunction getOwnPropertyDescriptors(target: any) {\n\t\t// Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n\t\tconst res: any = {}\n\t\townKeys(target).forEach(key => {\n\t\t\tres[key] = Object.getOwnPropertyDescriptor(target, key)\n\t\t})\n\t\treturn res\n\t}\n\nexport function each(\n\tobj: T,\n\titer: (key: string | number, value: any, source: T) => void,\n\tenumerableOnly?: boolean\n): void\nexport function each(obj: any, iter: any, enumerableOnly = false) {\n\tif (getArchtype(obj) === Archtype.Object) {\n\t\t;(enumerableOnly ? Object.keys : ownKeys)(obj).forEach(key => {\n\t\t\tif (!enumerableOnly || typeof key !== \"symbol\") iter(key, obj[key], obj)\n\t\t})\n\t} else {\n\t\tobj.forEach((entry: any, index: any) => iter(index, entry, obj))\n\t}\n}\n\n/*#__PURE__*/\nexport function getArchtype(thing: any): Archtype {\n\t/* istanbul ignore next */\n\tconst state: undefined | ImmerState = thing[DRAFT_STATE]\n\treturn state\n\t\t? state.type_ > 3\n\t\t\t? state.type_ - 4 // cause Object and Array map back from 4 and 5\n\t\t\t: (state.type_ as any) // others are the same\n\t\t: Array.isArray(thing)\n\t\t? Archtype.Array\n\t\t: isMap(thing)\n\t\t? Archtype.Map\n\t\t: isSet(thing)\n\t\t? Archtype.Set\n\t\t: Archtype.Object\n}\n\n/*#__PURE__*/\nexport function has(thing: any, prop: PropertyKey): boolean {\n\treturn getArchtype(thing) === Archtype.Map\n\t\t? thing.has(prop)\n\t\t: Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\n/*#__PURE__*/\nexport function get(thing: AnyMap | AnyObject, prop: PropertyKey): any {\n\t// @ts-ignore\n\treturn getArchtype(thing) === Archtype.Map ? thing.get(prop) : thing[prop]\n}\n\n/*#__PURE__*/\nexport function set(thing: any, propOrOldValue: PropertyKey, value: any) {\n\tconst t = getArchtype(thing)\n\tif (t === Archtype.Map) thing.set(propOrOldValue, value)\n\telse if (t === Archtype.Set) {\n\t\tthing.delete(propOrOldValue)\n\t\tthing.add(value)\n\t} else thing[propOrOldValue] = value\n}\n\n/*#__PURE__*/\nexport function is(x: any, y: any): boolean {\n\t// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n\tif (x === y) {\n\t\treturn x !== 0 || 1 / x === 1 / y\n\t} else {\n\t\treturn x !== x && y !== y\n\t}\n}\n\n/*#__PURE__*/\nexport function isMap(target: any): target is AnyMap {\n\treturn hasMap && target instanceof Map\n}\n\n/*#__PURE__*/\nexport function isSet(target: any): target is AnySet {\n\treturn hasSet && target instanceof Set\n}\n/*#__PURE__*/\nexport function latest(state: ImmerState): any {\n\treturn state.copy_ || state.base_\n}\n\n/*#__PURE__*/\nexport function shallowCopy(base: any) {\n\tif (Array.isArray(base)) return Array.prototype.slice.call(base)\n\tconst descriptors = getOwnPropertyDescriptors(base)\n\tdelete descriptors[DRAFT_STATE as any]\n\tlet keys = ownKeys(descriptors)\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tconst key: any = keys[i]\n\t\tconst desc = descriptors[key]\n\t\tif (desc.writable === false) {\n\t\t\tdesc.writable = true\n\t\t\tdesc.configurable = true\n\t\t}\n\t\t// like object.assign, we will read any _own_, get/set accessors. This helps in dealing\n\t\t// with libraries that trap values, like mobx or vue\n\t\t// unlike object.assign, non-enumerables will be copied as well\n\t\tif (desc.get || desc.set)\n\t\t\tdescriptors[key] = {\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true, // could live with !!desc.set as well here...\n\t\t\t\tenumerable: desc.enumerable,\n\t\t\t\tvalue: base[key]\n\t\t\t}\n\t}\n\treturn Object.create(Object.getPrototypeOf(base), descriptors)\n}\n\n/**\n * Freezes draftable objects. Returns the original object.\n * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.\n *\n * @param obj\n * @param deep\n */\nexport function freeze(obj: T, deep?: boolean): T\nexport function freeze(obj: any, deep: boolean = false): T {\n\tif (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj\n\tif (getArchtype(obj) > 1 /* Map or Set */) {\n\t\tobj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any\n\t}\n\tObject.freeze(obj)\n\tif (deep) each(obj, (key, value) => freeze(value, true), true)\n\treturn obj\n}\n\nfunction dontMutateFrozenCollections() {\n\tdie(2)\n}\n\nexport function isFrozen(obj: any): boolean {\n\tif (obj == null || typeof obj !== \"object\") return true\n\t// See #600, IE dies on non-objects in Object.isFrozen\n\treturn Object.isFrozen(obj)\n}\n","import {\n\tImmerState,\n\tPatch,\n\tImmerScope,\n\tDrafted,\n\tAnyObject,\n\tImmerBaseState,\n\tAnyMap,\n\tAnySet,\n\tProxyType,\n\tdie\n} from \"../internal\"\n\n/** Plugin utilities */\nconst plugins: {\n\tPatches?: {\n\t\tgeneratePatches_(\n\t\t\tstate: ImmerState,\n\t\t\tbasePath: PatchPath,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tgenerateReplacementPatches_(\n\t\t\tbase: any,\n\t\t\treplacement: any,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tapplyPatches_(draft: T, patches: Patch[]): T\n\t}\n\tES5?: {\n\t\twillFinalizeES5_(scope: ImmerScope, result: any, isReplaced: boolean): void\n\t\tcreateES5Proxy_(\n\t\t\tbase: T,\n\t\t\tparent?: ImmerState\n\t\t): Drafted\n\t\thasChanges_(state: ES5ArrayState | ES5ObjectState): boolean\n\t}\n\tMapSet?: {\n\t\tproxyMap_(target: T, parent?: ImmerState): T\n\t\tproxySet_(target: T, parent?: ImmerState): T\n\t}\n} = {}\n\ntype Plugins = typeof plugins\n\nexport function getPlugin(\n\tpluginKey: K\n): Exclude {\n\tconst plugin = plugins[pluginKey]\n\tif (!plugin) {\n\t\tdie(18, pluginKey)\n\t}\n\t// @ts-ignore\n\treturn plugin\n}\n\nexport function loadPlugin(\n\tpluginKey: K,\n\timplementation: Plugins[K]\n): void {\n\tif (!plugins[pluginKey]) plugins[pluginKey] = implementation\n}\n\n/** ES5 Plugin */\n\ninterface ES5BaseState extends ImmerBaseState {\n\tassigned_: {[key: string]: any}\n\tparent_?: ImmerState\n\trevoked_: boolean\n}\n\nexport interface ES5ObjectState extends ES5BaseState {\n\ttype_: ProxyType.ES5Object\n\tdraft_: Drafted\n\tbase_: AnyObject\n\tcopy_: AnyObject | null\n}\n\nexport interface ES5ArrayState extends ES5BaseState {\n\ttype_: ProxyType.ES5Array\n\tdraft_: Drafted\n\tbase_: any\n\tcopy_: any\n}\n\n/** Map / Set plugin */\n\nexport interface MapState extends ImmerBaseState {\n\ttype_: ProxyType.Map\n\tcopy_: AnyMap | undefined\n\tassigned_: Map | undefined\n\tbase_: AnyMap\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\nexport interface SetState extends ImmerBaseState {\n\ttype_: ProxyType.Set\n\tcopy_: AnySet | undefined\n\tbase_: AnySet\n\tdrafts_: Map // maps the original value to the draft value in the new set\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\n/** Patches plugin */\n\nexport type PatchPath = (string | number)[]\n","import {\n\tPatch,\n\tPatchListener,\n\tDrafted,\n\tImmer,\n\tDRAFT_STATE,\n\tImmerState,\n\tProxyType,\n\tgetPlugin\n} from \"../internal\"\nimport {die} from \"../utils/errors\"\n\n/** Each scope represents a `produce` call. */\n\nexport interface ImmerScope {\n\tpatches_?: Patch[]\n\tinversePatches_?: Patch[]\n\tcanAutoFreeze_: boolean\n\tdrafts_: any[]\n\tparent_?: ImmerScope\n\tpatchListener_?: PatchListener\n\timmer_: Immer\n\tunfinalizedDrafts_: number\n}\n\nlet currentScope: ImmerScope | undefined\n\nexport function getCurrentScope() {\n\tif (__DEV__ && !currentScope) die(0)\n\treturn currentScope!\n}\n\nfunction createScope(\n\tparent_: ImmerScope | undefined,\n\timmer_: Immer\n): ImmerScope {\n\treturn {\n\t\tdrafts_: [],\n\t\tparent_,\n\t\timmer_,\n\t\t// Whenever the modified draft contains a draft from another scope, we\n\t\t// need to prevent auto-freezing so the unowned draft can be finalized.\n\t\tcanAutoFreeze_: true,\n\t\tunfinalizedDrafts_: 0\n\t}\n}\n\nexport function usePatchesInScope(\n\tscope: ImmerScope,\n\tpatchListener?: PatchListener\n) {\n\tif (patchListener) {\n\t\tgetPlugin(\"Patches\") // assert we have the plugin\n\t\tscope.patches_ = []\n\t\tscope.inversePatches_ = []\n\t\tscope.patchListener_ = patchListener\n\t}\n}\n\nexport function revokeScope(scope: ImmerScope) {\n\tleaveScope(scope)\n\tscope.drafts_.forEach(revokeDraft)\n\t// @ts-ignore\n\tscope.drafts_ = null\n}\n\nexport function leaveScope(scope: ImmerScope) {\n\tif (scope === currentScope) {\n\t\tcurrentScope = scope.parent_\n\t}\n}\n\nexport function enterScope(immer: Immer) {\n\treturn (currentScope = createScope(currentScope, immer))\n}\n\nfunction revokeDraft(draft: Drafted) {\n\tconst state: ImmerState = draft[DRAFT_STATE]\n\tif (\n\t\tstate.type_ === ProxyType.ProxyObject ||\n\t\tstate.type_ === ProxyType.ProxyArray\n\t)\n\t\tstate.revoke_()\n\telse state.revoked_ = true\n}\n","import {\n\tImmerScope,\n\tDRAFT_STATE,\n\tisDraftable,\n\tNOTHING,\n\tPatchPath,\n\teach,\n\thas,\n\tfreeze,\n\tImmerState,\n\tisDraft,\n\tSetState,\n\tset,\n\tProxyType,\n\tgetPlugin,\n\tdie,\n\trevokeScope,\n\tisFrozen,\n\tshallowCopy\n} from \"../internal\"\n\nexport function processResult(result: any, scope: ImmerScope) {\n\tscope.unfinalizedDrafts_ = scope.drafts_.length\n\tconst baseDraft = scope.drafts_![0]\n\tconst isReplaced = result !== undefined && result !== baseDraft\n\tif (!scope.immer_.useProxies_)\n\t\tgetPlugin(\"ES5\").willFinalizeES5_(scope, result, isReplaced)\n\tif (isReplaced) {\n\t\tif (baseDraft[DRAFT_STATE].modified_) {\n\t\t\trevokeScope(scope)\n\t\t\tdie(4)\n\t\t}\n\t\tif (isDraftable(result)) {\n\t\t\t// Finalize the result in case it contains (or is) a subset of the draft.\n\t\t\tresult = finalize(scope, result)\n\t\t\tif (!scope.parent_) maybeFreeze(scope, result)\n\t\t}\n\t\tif (scope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(\n\t\t\t\tbaseDraft[DRAFT_STATE].base_,\n\t\t\t\tresult,\n\t\t\t\tscope.patches_,\n\t\t\t\tscope.inversePatches_!\n\t\t\t)\n\t\t}\n\t} else {\n\t\t// Finalize the base draft.\n\t\tresult = finalize(scope, baseDraft, [])\n\t}\n\trevokeScope(scope)\n\tif (scope.patches_) {\n\t\tscope.patchListener_!(scope.patches_, scope.inversePatches_!)\n\t}\n\treturn result !== NOTHING ? result : undefined\n}\n\nfunction finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {\n\t// Don't recurse in tho recursive data structures\n\tif (isFrozen(value)) return value\n\n\tconst state: ImmerState = value[DRAFT_STATE]\n\t// A plain object, might need freezing, might contain drafts\n\tif (!state) {\n\t\teach(\n\t\t\tvalue,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, value, key, childValue, path),\n\t\t\ttrue // See #590, don't recurse into non-enumerable of non drafted objects\n\t\t)\n\t\treturn value\n\t}\n\t// Never finalize drafts owned by another scope.\n\tif (state.scope_ !== rootScope) return value\n\t// Unmodified draft, return the (frozen) original\n\tif (!state.modified_) {\n\t\tmaybeFreeze(rootScope, state.base_, true)\n\t\treturn state.base_\n\t}\n\t// Not finalized yet, let's do that now\n\tif (!state.finalized_) {\n\t\tstate.finalized_ = true\n\t\tstate.scope_.unfinalizedDrafts_--\n\t\tconst result =\n\t\t\t// For ES5, create a good copy from the draft first, with added keys and without deleted keys.\n\t\t\tstate.type_ === ProxyType.ES5Object || state.type_ === ProxyType.ES5Array\n\t\t\t\t? (state.copy_ = shallowCopy(state.draft_))\n\t\t\t\t: state.copy_\n\t\t// Finalize all children of the copy\n\t\t// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628\n\t\t// Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line\n\t\t// back to each(result, ....)\n\t\teach(\n\t\t\tstate.type_ === ProxyType.Set ? new Set(result) : result,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, result, key, childValue, path)\n\t\t)\n\t\t// everything inside is frozen, we can freeze here\n\t\tmaybeFreeze(rootScope, result, false)\n\t\t// first time finalizing, let's create those patches\n\t\tif (path && rootScope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generatePatches_(\n\t\t\t\tstate,\n\t\t\t\tpath,\n\t\t\t\trootScope.patches_,\n\t\t\t\trootScope.inversePatches_!\n\t\t\t)\n\t\t}\n\t}\n\treturn state.copy_\n}\n\nfunction finalizeProperty(\n\trootScope: ImmerScope,\n\tparentState: undefined | ImmerState,\n\ttargetObject: any,\n\tprop: string | number,\n\tchildValue: any,\n\trootPath?: PatchPath\n) {\n\tif (__DEV__ && childValue === targetObject) die(5)\n\tif (isDraft(childValue)) {\n\t\tconst path =\n\t\t\trootPath &&\n\t\t\tparentState &&\n\t\t\tparentState!.type_ !== ProxyType.Set && // Set objects are atomic since they have no keys.\n\t\t\t!has((parentState as Exclude).assigned_!, prop) // Skip deep patches for assigned keys.\n\t\t\t\t? rootPath!.concat(prop)\n\t\t\t\t: undefined\n\t\t// Drafts owned by `scope` are finalized here.\n\t\tconst res = finalize(rootScope, childValue, path)\n\t\tset(targetObject, prop, res)\n\t\t// Drafts from another scope must prevented to be frozen\n\t\t// if we got a draft back from finalize, we're in a nested produce and shouldn't freeze\n\t\tif (isDraft(res)) {\n\t\t\trootScope.canAutoFreeze_ = false\n\t\t} else return\n\t}\n\t// Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n\tif (isDraftable(childValue) && !isFrozen(childValue)) {\n\t\tif (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {\n\t\t\t// optimization: if an object is not a draft, and we don't have to\n\t\t\t// deepfreeze everything, and we are sure that no drafts are left in the remaining object\n\t\t\t// cause we saw and finalized all drafts already; we can stop visiting the rest of the tree.\n\t\t\t// This benefits especially adding large data tree's without further processing.\n\t\t\t// See add-data.js perf test\n\t\t\treturn\n\t\t}\n\t\tfinalize(rootScope, childValue)\n\t\t// immer deep freezes plain objects, so if there is no parent state, we freeze as well\n\t\tif (!parentState || !parentState.scope_.parent_)\n\t\t\tmaybeFreeze(rootScope, childValue)\n\t}\n}\n\nfunction maybeFreeze(scope: ImmerScope, value: any, deep = false) {\n\tif (scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {\n\t\tfreeze(value, deep)\n\t}\n}\n","import {\n\teach,\n\thas,\n\tis,\n\tisDraftable,\n\tshallowCopy,\n\tlatest,\n\tImmerBaseState,\n\tImmerState,\n\tDrafted,\n\tAnyObject,\n\tAnyArray,\n\tObjectish,\n\tgetCurrentScope,\n\tDRAFT_STATE,\n\tdie,\n\tcreateProxy,\n\tProxyType\n} from \"../internal\"\n\ninterface ProxyBaseState extends ImmerBaseState {\n\tassigned_: {\n\t\t[property: string]: boolean\n\t}\n\tparent_?: ImmerState\n\trevoke_(): void\n}\n\nexport interface ProxyObjectState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyObject\n\tbase_: any\n\tcopy_: any\n\tdraft_: Drafted\n}\n\nexport interface ProxyArrayState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyArray\n\tbase_: AnyArray\n\tcopy_: AnyArray | null\n\tdraft_: Drafted\n}\n\ntype ProxyState = ProxyObjectState | ProxyArrayState\n\n/**\n * Returns a new draft of the `base` object.\n *\n * The second argument is the parent draft-state (used internally).\n */\nexport function createProxyProxy(\n\tbase: T,\n\tparent?: ImmerState\n): Drafted {\n\tconst isArray = Array.isArray(base)\n\tconst state: ProxyState = {\n\t\ttype_: isArray ? ProxyType.ProxyArray : (ProxyType.ProxyObject as any),\n\t\t// Track which produce call this is associated with.\n\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t// True for both shallow and deep changes.\n\t\tmodified_: false,\n\t\t// Used during finalization.\n\t\tfinalized_: false,\n\t\t// Track which properties have been assigned (true) or deleted (false).\n\t\tassigned_: {},\n\t\t// The parent draft state.\n\t\tparent_: parent,\n\t\t// The base state.\n\t\tbase_: base,\n\t\t// The base proxy.\n\t\tdraft_: null as any, // set below\n\t\t// The base copy with any updated values.\n\t\tcopy_: null,\n\t\t// Called by the `produce` function.\n\t\trevoke_: null as any,\n\t\tisManual_: false\n\t}\n\n\t// the traps must target something, a bit like the 'real' base.\n\t// but also, we need to be able to determine from the target what the relevant state is\n\t// (to avoid creating traps per instance to capture the state in closure,\n\t// and to avoid creating weird hidden properties as well)\n\t// So the trick is to use 'state' as the actual 'target'! (and make sure we intercept everything)\n\t// Note that in the case of an array, we put the state in an array to have better Reflect defaults ootb\n\tlet target: T = state as any\n\tlet traps: ProxyHandler> = objectTraps\n\tif (isArray) {\n\t\ttarget = [state] as any\n\t\ttraps = arrayTraps\n\t}\n\n\tconst {revoke, proxy} = Proxy.revocable(target, traps)\n\tstate.draft_ = proxy as any\n\tstate.revoke_ = revoke\n\treturn proxy as any\n}\n\n/**\n * Object drafts\n */\nexport const objectTraps: ProxyHandler = {\n\tget(state, prop) {\n\t\tif (prop === DRAFT_STATE) return state\n\n\t\tconst source = latest(state)\n\t\tif (!has(source, prop)) {\n\t\t\t// non-existing or non-own property...\n\t\t\treturn readPropFromProto(state, source, prop)\n\t\t}\n\t\tconst value = source[prop]\n\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\treturn value\n\t\t}\n\t\t// Check for existing draft in modified state.\n\t\t// Assigned values are never drafted. This catches any drafts we created, too.\n\t\tif (value === peek(state.base_, prop)) {\n\t\t\tprepareCopy(state)\n\t\t\treturn (state.copy_![prop as any] = createProxy(\n\t\t\t\tstate.scope_.immer_,\n\t\t\t\tvalue,\n\t\t\t\tstate\n\t\t\t))\n\t\t}\n\t\treturn value\n\t},\n\thas(state, prop) {\n\t\treturn prop in latest(state)\n\t},\n\townKeys(state) {\n\t\treturn Reflect.ownKeys(latest(state))\n\t},\n\tset(\n\t\tstate: ProxyObjectState,\n\t\tprop: string /* strictly not, but helps TS */,\n\t\tvalue\n\t) {\n\t\tconst desc = getDescriptorFromProto(latest(state), prop)\n\t\tif (desc?.set) {\n\t\t\t// special case: if this write is captured by a setter, we have\n\t\t\t// to trigger it with the correct context\n\t\t\tdesc.set.call(state.draft_, value)\n\t\t\treturn true\n\t\t}\n\t\tif (!state.modified_) {\n\t\t\t// the last check is because we need to be able to distinguish setting a non-existing to undefined (which is a change)\n\t\t\t// from setting an existing property with value undefined to undefined (which is not a change)\n\t\t\tconst current = peek(latest(state), prop)\n\t\t\t// special case, if we assigning the original value to a draft, we can ignore the assignment\n\t\t\tconst currentState: ProxyObjectState = current?.[DRAFT_STATE]\n\t\t\tif (currentState && currentState.base_ === value) {\n\t\t\t\tstate.copy_![prop] = value\n\t\t\t\tstate.assigned_[prop] = false\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (is(value, current) && (value !== undefined || has(state.base_, prop)))\n\t\t\t\treturn true\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t}\n\n\t\tif (\n\t\t\tstate.copy_![prop] === value &&\n\t\t\t// special case: NaN\n\t\t\ttypeof value !== \"number\" &&\n\t\t\t// special case: handle new props with value 'undefined'\n\t\t\t(value !== undefined || prop in state.copy_)\n\t\t)\n\t\t\treturn true\n\n\t\t// @ts-ignore\n\t\tstate.copy_![prop] = value\n\t\tstate.assigned_[prop] = true\n\t\treturn true\n\t},\n\tdeleteProperty(state, prop: string) {\n\t\t// The `undefined` check is a fast path for pre-existing keys.\n\t\tif (peek(state.base_, prop) !== undefined || prop in state.base_) {\n\t\t\tstate.assigned_[prop] = false\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t} else {\n\t\t\t// if an originally not assigned property was deleted\n\t\t\tdelete state.assigned_[prop]\n\t\t}\n\t\t// @ts-ignore\n\t\tif (state.copy_) delete state.copy_[prop]\n\t\treturn true\n\t},\n\t// Note: We never coerce `desc.value` into an Immer draft, because we can't make\n\t// the same guarantee in ES5 mode.\n\tgetOwnPropertyDescriptor(state, prop) {\n\t\tconst owner = latest(state)\n\t\tconst desc = Reflect.getOwnPropertyDescriptor(owner, prop)\n\t\tif (!desc) return desc\n\t\treturn {\n\t\t\twritable: true,\n\t\t\tconfigurable: state.type_ !== ProxyType.ProxyArray || prop !== \"length\",\n\t\t\tenumerable: desc.enumerable,\n\t\t\tvalue: owner[prop]\n\t\t}\n\t},\n\tdefineProperty() {\n\t\tdie(11)\n\t},\n\tgetPrototypeOf(state) {\n\t\treturn Object.getPrototypeOf(state.base_)\n\t},\n\tsetPrototypeOf() {\n\t\tdie(12)\n\t}\n}\n\n/**\n * Array drafts\n */\n\nconst arrayTraps: ProxyHandler<[ProxyArrayState]> = {}\neach(objectTraps, (key, fn) => {\n\t// @ts-ignore\n\tarrayTraps[key] = function() {\n\t\targuments[0] = arguments[0][0]\n\t\treturn fn.apply(this, arguments)\n\t}\n})\narrayTraps.deleteProperty = function(state, prop) {\n\tif (__DEV__ && isNaN(parseInt(prop as any))) die(13)\n\t// @ts-ignore\n\treturn arrayTraps.set!.call(this, state, prop, undefined)\n}\narrayTraps.set = function(state, prop, value) {\n\tif (__DEV__ && prop !== \"length\" && isNaN(parseInt(prop as any))) die(14)\n\treturn objectTraps.set!.call(this, state[0], prop, value, state[0])\n}\n\n// Access a property without creating an Immer draft.\nfunction peek(draft: Drafted, prop: PropertyKey) {\n\tconst state = draft[DRAFT_STATE]\n\tconst source = state ? latest(state) : draft\n\treturn source[prop]\n}\n\nfunction readPropFromProto(state: ImmerState, source: any, prop: PropertyKey) {\n\tconst desc = getDescriptorFromProto(source, prop)\n\treturn desc\n\t\t? `value` in desc\n\t\t\t? desc.value\n\t\t\t: // This is a very special case, if the prop is a getter defined by the\n\t\t\t // prototype, we should invoke it with the draft as context!\n\t\t\t desc.get?.call(state.draft_)\n\t\t: undefined\n}\n\nfunction getDescriptorFromProto(\n\tsource: any,\n\tprop: PropertyKey\n): PropertyDescriptor | undefined {\n\t// 'in' checks proto!\n\tif (!(prop in source)) return undefined\n\tlet proto = Object.getPrototypeOf(source)\n\twhile (proto) {\n\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\tif (desc) return desc\n\t\tproto = Object.getPrototypeOf(proto)\n\t}\n\treturn undefined\n}\n\nexport function markChanged(state: ImmerState) {\n\tif (!state.modified_) {\n\t\tstate.modified_ = true\n\t\tif (state.parent_) {\n\t\t\tmarkChanged(state.parent_)\n\t\t}\n\t}\n}\n\nexport function prepareCopy(state: {base_: any; copy_: any}) {\n\tif (!state.copy_) {\n\t\tstate.copy_ = shallowCopy(state.base_)\n\t}\n}\n","import {\n\tIProduceWithPatches,\n\tIProduce,\n\tImmerState,\n\tDrafted,\n\tisDraftable,\n\tprocessResult,\n\tPatch,\n\tObjectish,\n\tDRAFT_STATE,\n\tDraft,\n\tPatchListener,\n\tisDraft,\n\tisMap,\n\tisSet,\n\tcreateProxyProxy,\n\tgetPlugin,\n\tdie,\n\thasProxies,\n\tenterScope,\n\trevokeScope,\n\tleaveScope,\n\tusePatchesInScope,\n\tgetCurrentScope,\n\tNOTHING,\n\tfreeze,\n\tcurrent\n} from \"../internal\"\n\ninterface ProducersFns {\n\tproduce: IProduce\n\tproduceWithPatches: IProduceWithPatches\n}\n\nexport class Immer implements ProducersFns {\n\tuseProxies_: boolean = hasProxies\n\n\tautoFreeze_: boolean = true\n\n\tconstructor(config?: {useProxies?: boolean; autoFreeze?: boolean}) {\n\t\tif (typeof config?.useProxies === \"boolean\")\n\t\t\tthis.setUseProxies(config!.useProxies)\n\t\tif (typeof config?.autoFreeze === \"boolean\")\n\t\t\tthis.setAutoFreeze(config!.autoFreeze)\n\t}\n\n\t/**\n\t * The `produce` function takes a value and a \"recipe function\" (whose\n\t * return value often depends on the base state). The recipe function is\n\t * free to mutate its first argument however it wants. All mutations are\n\t * only ever applied to a __copy__ of the base state.\n\t *\n\t * Pass only a function to create a \"curried producer\" which relieves you\n\t * from passing the recipe function every time.\n\t *\n\t * Only plain objects and arrays are made mutable. All other objects are\n\t * considered uncopyable.\n\t *\n\t * Note: This function is __bound__ to its `Immer` instance.\n\t *\n\t * @param {any} base - the initial state\n\t * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n\t * @param {Function} patchListener - optional function that will be called with all the patches produced here\n\t * @returns {any} a new state, or the initial state if nothing was modified\n\t */\n\tproduce: IProduce = (base: any, recipe?: any, patchListener?: any) => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\" && typeof recipe !== \"function\") {\n\t\t\tconst defaultBase = recipe\n\t\t\trecipe = base\n\n\t\t\tconst self = this\n\t\t\treturn function curriedProduce(\n\t\t\t\tthis: any,\n\t\t\t\tbase = defaultBase,\n\t\t\t\t...args: any[]\n\t\t\t) {\n\t\t\t\treturn self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore\n\t\t\t}\n\t\t}\n\n\t\tif (typeof recipe !== \"function\") die(6)\n\t\tif (patchListener !== undefined && typeof patchListener !== \"function\")\n\t\t\tdie(7)\n\n\t\tlet result\n\n\t\t// Only plain objects, arrays, and \"immerable classes\" are drafted.\n\t\tif (isDraftable(base)) {\n\t\t\tconst scope = enterScope(this)\n\t\t\tconst proxy = createProxy(this, base, undefined)\n\t\t\tlet hasError = true\n\t\t\ttry {\n\t\t\t\tresult = recipe(proxy)\n\t\t\t\thasError = false\n\t\t\t} finally {\n\t\t\t\t// finally instead of catch + rethrow better preserves original stack\n\t\t\t\tif (hasError) revokeScope(scope)\n\t\t\t\telse leaveScope(scope)\n\t\t\t}\n\t\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\tresult => {\n\t\t\t\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\t\t\t\treturn processResult(result, scope)\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\trevokeScope(scope)\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t}\n\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\treturn processResult(result, scope)\n\t\t} else if (!base || typeof base !== \"object\") {\n\t\t\tresult = recipe(base)\n\t\t\tif (result === undefined) result = base\n\t\t\tif (result === NOTHING) result = undefined\n\t\t\tif (this.autoFreeze_) freeze(result, true)\n\t\t\tif (patchListener) {\n\t\t\t\tconst p: Patch[] = []\n\t\t\t\tconst ip: Patch[] = []\n\t\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(base, result, p, ip)\n\t\t\t\tpatchListener(p, ip)\n\t\t\t}\n\t\t\treturn result\n\t\t} else die(21, base)\n\t}\n\n\tproduceWithPatches: IProduceWithPatches = (\n\t\tbase: any,\n\t\trecipe?: any,\n\t): any => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\") {\n\t\t\treturn (state: any, ...args: any[]) =>\n\t\t\t\tthis.produceWithPatches(state, (draft: any) => base(draft, ...args))\n\t\t}\n\n\t\tlet patches: Patch[], inversePatches: Patch[]\n\t\tconst result = this.produce(base, recipe, (p: Patch[], ip: Patch[]) => {\n\t\t\tpatches = p\n\t\t\tinversePatches = ip\n\t\t})\n\n\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\treturn result.then(nextState => [nextState, patches!, inversePatches!])\n\t\t}\n\t\treturn [result, patches!, inversePatches!]\n\t}\n\n\tcreateDraft(base: T): Draft {\n\t\tif (!isDraftable(base)) die(8)\n\t\tif (isDraft(base)) base = current(base)\n\t\tconst scope = enterScope(this)\n\t\tconst proxy = createProxy(this, base, undefined)\n\t\tproxy[DRAFT_STATE].isManual_ = true\n\t\tleaveScope(scope)\n\t\treturn proxy as any\n\t}\n\n\tfinishDraft>(\n\t\tdraft: D,\n\t\tpatchListener?: PatchListener\n\t): D extends Draft ? T : never {\n\t\tconst state: ImmerState = draft && (draft as any)[DRAFT_STATE]\n\t\tif (__DEV__) {\n\t\t\tif (!state || !state.isManual_) die(9)\n\t\t\tif (state.finalized_) die(10)\n\t\t}\n\t\tconst {scope_: scope} = state\n\t\tusePatchesInScope(scope, patchListener)\n\t\treturn processResult(undefined, scope)\n\t}\n\n\t/**\n\t * Pass true to automatically freeze all copies created by Immer.\n\t *\n\t * By default, auto-freezing is enabled.\n\t */\n\tsetAutoFreeze(value: boolean) {\n\t\tthis.autoFreeze_ = value\n\t}\n\n\t/**\n\t * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n\t * always faster than using ES5 proxies.\n\t *\n\t * By default, feature detection is used, so calling this is rarely necessary.\n\t */\n\tsetUseProxies(value: boolean) {\n\t\tif (value && !hasProxies) {\n\t\t\tdie(20)\n\t\t}\n\t\tthis.useProxies_ = value\n\t}\n\n\tapplyPatches(base: T, patches: Patch[]): T {\n\t\t// If a patch replaces the entire state, take that replacement as base\n\t\t// before applying patches\n\t\tlet i: number\n\t\tfor (i = patches.length - 1; i >= 0; i--) {\n\t\t\tconst patch = patches[i]\n\t\t\tif (patch.path.length === 0 && patch.op === \"replace\") {\n\t\t\t\tbase = patch.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// If there was a patch that replaced the entire state, start from the\n\t\t// patch after that.\n\t\tif (i > -1) {\n\t\t\tpatches = patches.slice(i + 1)\n\t\t}\n\n\t\tconst applyPatchesImpl = getPlugin(\"Patches\").applyPatches_\n\t\tif (isDraft(base)) {\n\t\t\t// N.B: never hits if some patch a replacement, patches are never drafts\n\t\t\treturn applyPatchesImpl(base, patches)\n\t\t}\n\t\t// Otherwise, produce a copy of the base state.\n\t\treturn this.produce(base, (draft: Drafted) =>\n\t\t\tapplyPatchesImpl(draft, patches)\n\t\t)\n\t}\n}\n\nexport function createProxy(\n\timmer: Immer,\n\tvalue: T,\n\tparent?: ImmerState\n): Drafted {\n\t// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft\n\tconst draft: Drafted = isMap(value)\n\t\t? getPlugin(\"MapSet\").proxyMap_(value, parent)\n\t\t: isSet(value)\n\t\t? getPlugin(\"MapSet\").proxySet_(value, parent)\n\t\t: immer.useProxies_\n\t\t? createProxyProxy(value, parent)\n\t\t: getPlugin(\"ES5\").createES5Proxy_(value, parent)\n\n\tconst scope = parent ? parent.scope_ : getCurrentScope()\n\tscope.drafts_.push(draft)\n\treturn draft\n}\n","import {\n\tdie,\n\tisDraft,\n\tshallowCopy,\n\teach,\n\tDRAFT_STATE,\n\tget,\n\tset,\n\tImmerState,\n\tisDraftable,\n\tArchtype,\n\tgetArchtype,\n\tgetPlugin\n} from \"../internal\"\n\n/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */\nexport function current(value: T): T\nexport function current(value: any): any {\n\tif (!isDraft(value)) die(22, value)\n\treturn currentImpl(value)\n}\n\nfunction currentImpl(value: any): any {\n\tif (!isDraftable(value)) return value\n\tconst state: ImmerState | undefined = value[DRAFT_STATE]\n\tlet copy: any\n\tconst archType = getArchtype(value)\n\tif (state) {\n\t\tif (\n\t\t\t!state.modified_ &&\n\t\t\t(state.type_ < 4 || !getPlugin(\"ES5\").hasChanges_(state as any))\n\t\t)\n\t\t\treturn state.base_\n\t\t// Optimization: avoid generating new drafts during copying\n\t\tstate.finalized_ = true\n\t\tcopy = copyHelper(value, archType)\n\t\tstate.finalized_ = false\n\t} else {\n\t\tcopy = copyHelper(value, archType)\n\t}\n\n\teach(copy, (key, childValue) => {\n\t\tif (state && get(state.base_, key) === childValue) return // no need to copy or search in something that didn't change\n\t\tset(copy, key, currentImpl(childValue))\n\t})\n\t// In the future, we might consider freezing here, based on the current settings\n\treturn archType === Archtype.Set ? new Set(copy) : copy\n}\n\nfunction copyHelper(value: any, archType: number): any {\n\t// creates a shallow copy, even if it is a map or set\n\tswitch (archType) {\n\t\tcase Archtype.Map:\n\t\t\treturn new Map(value)\n\t\tcase Archtype.Set:\n\t\t\t// Set will be cloned as array temporarily, so that we can replace individual items\n\t\t\treturn Array.from(value)\n\t}\n\treturn shallowCopy(value)\n}\n","import {\n\tIProduce,\n\tIProduceWithPatches,\n\tImmer,\n\tDraft,\n\tImmutable\n} from \"./internal\"\n\nexport {\n\tDraft,\n\tImmutable,\n\tPatch,\n\tPatchListener,\n\toriginal,\n\tcurrent,\n\tisDraft,\n\tisDraftable,\n\tNOTHING as nothing,\n\tDRAFTABLE as immerable,\n\tfreeze\n} from \"./internal\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce: IProduce = immer.produce\nexport default produce\n\n/**\n * Like `produce`, but `produceWithPatches` always returns a tuple\n * [nextState, patches, inversePatches] (instead of just the next state)\n */\nexport const produceWithPatches: IProduceWithPatches = immer.produceWithPatches.bind(\n\timmer\n)\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * Always freeze by default, even in production mode\n */\nexport const setAutoFreeze = immer.setAutoFreeze.bind(immer)\n\n/**\n * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n * always faster than using ES5 proxies.\n *\n * By default, feature detection is used, so calling this is rarely necessary.\n */\nexport const setUseProxies = immer.setUseProxies.bind(immer)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = immer.applyPatches.bind(immer)\n\n/**\n * Create an Immer draft from the given base state, which may be a draft itself.\n * The draft can be modified until you finalize it with the `finishDraft` function.\n */\nexport const createDraft = immer.createDraft.bind(immer)\n\n/**\n * Finalize an Immer draft from a `createDraft` call, returning the base state\n * (if no changes were made) or a modified copy. The draft must *not* be\n * mutated afterwards.\n *\n * Pass a function as the 2nd argument to generate Immer patches based on the\n * changes that were made.\n */\nexport const finishDraft = immer.finishDraft.bind(immer)\n\n/**\n * This function is actually a no-op, but can be used to cast an immutable type\n * to an draft type and make TypeScript happy\n *\n * @param value\n */\nexport function castDraft(value: T): Draft {\n\treturn value as any\n}\n\n/**\n * This function is actually a no-op, but can be used to cast a mutable type\n * to an immutable type and make TypeScript happy\n * @param value\n */\nexport function castImmutable(value: T): Immutable {\n\treturn value as any\n}\n\nexport {Immer}\n\nexport {enableES5} from \"./plugins/es5\"\nexport {enablePatches} from \"./plugins/patches\"\nexport {enableMapSet} from \"./plugins/mapset\"\nexport {enableAllPlugins} from \"./plugins/all\"\n","// Should be no imports here!\n\n// Some things that should be evaluated before all else...\n\n// We only want to know if non-polyfilled symbols are available\nconst hasSymbol =\n\ttypeof Symbol !== \"undefined\" && typeof Symbol(\"x\") === \"symbol\"\nexport const hasMap = typeof Map !== \"undefined\"\nexport const hasSet = typeof Set !== \"undefined\"\nexport const hasProxies =\n\ttypeof Proxy !== \"undefined\" &&\n\ttypeof Proxy.revocable !== \"undefined\" &&\n\ttypeof Reflect !== \"undefined\"\n\n/**\n * The sentinel value returned by producers to replace the draft with undefined.\n */\nexport const NOTHING: Nothing = hasSymbol\n\t? Symbol.for(\"immer-nothing\")\n\t: ({[\"immer-nothing\"]: true} as any)\n\n/**\n * To let Immer treat your class instances as plain immutable objects\n * (albeit with a custom prototype), you must define either an instance property\n * or a static property on each of your custom classes.\n *\n * Otherwise, your class instance will never be drafted, which means it won't be\n * safe to mutate in a produce callback.\n */\nexport const DRAFTABLE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-draftable\")\n\t: (\"__$immer_draftable\" as any)\n\nexport const DRAFT_STATE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-state\")\n\t: (\"__$immer_state\" as any)\n\n// Even a polyfilled Symbol might provide Symbol.iterator\nexport const iteratorSymbol: typeof Symbol.iterator =\n\t(typeof Symbol != \"undefined\" && Symbol.iterator) || (\"@@iterator\" as any)\n\n/** Use a class type for `nothing` so its type is unique */\nexport class Nothing {\n\t// This lets us do `Exclude`\n\t// @ts-ignore\n\tprivate _!: unique symbol\n}\n","import produce from \"immer\";\nimport { Dispatch, useEffect, useReducer, useState } from \"react\";\n\nexport function useImmerReducer<\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Reducers extends Record T | void>\n>(reducers: Reducers, initialState: T) {\n return useReducer(\n (\n state: T,\n command: {\n action: keyof Reducers;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload?: any;\n }\n ): T =>\n produce(state, (draft: T) => {\n reducers[command.action](draft, command.payload);\n }),\n initialState\n );\n}\n\nexport function useStateInitializer(init: T): [T, Dispatch] {\n const [state, setState] = useState(init);\n useEffect(() => {\n setState(init);\n }, [init]);\n return [state, setState];\n}\n","import { width } from \"@davidsouther/jiffies/lib/esm/dom/css/sizing.js\";\nimport { useCallback, useState } from \"react\";\nimport { useStateInitializer } from \"./react.js\";\n\nconst Mode = { VIEW: 0, EDIT: 1 };\n\nexport const InlineEdit = (props: {\n mode?: keyof typeof Mode;\n value: string;\n onChange: (value: string) => void;\n}) => {\n const [mode, setMode] = useState(props.mode ?? Mode.VIEW);\n const [value, setValue] = useStateInitializer(props.value);\n\n const render = () => {\n switch (mode) {\n case Mode.EDIT:\n return edit();\n case Mode.VIEW:\n return view();\n default:\n return ;\n }\n };\n\n const view = () => (\n {\n setMode(Mode.EDIT);\n }}\n >\n {value}\n \n );\n\n const doSelect = useCallback(\n (ref: HTMLInputElement | null) => ref?.select(),\n []\n );\n const doChange = useCallback(\n (target: HTMLInputElement) => {\n setMode(Mode.VIEW);\n setValue(target.value ?? \"\");\n props.onChange(target.value ?? \"\");\n },\n [props, setMode, setValue]\n );\n const edit = () => {\n const edit = (\n \n doChange(target)}\n onKeyPress={({ key, target }) => {\n if (key === \"Enter\") {\n doChange(target as HTMLInputElement);\n }\n }}\n type=\"text\"\n defaultValue={value}\n />\n \n );\n return edit;\n };\n\n return render();\n};\n\nexport default InlineEdit;\n","/* eslint-disable @typescript-eslint/ban-types */\nimport {\n Key,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from \"react\";\n\nexport interface VirtualScrollSettings {\n /**Minimum offset into the adapter. Default is 0. */\n minIndex: number;\n /** Maximum offset into the adapter. Default is Number.MAX_SAFE_INTEGER. */\n maxIndex: number;\n /** Initial index to start rendering from. Default is minIndex. */\n startIndex: number;\n /**\n * Number of items to render in visible area. Default is entire range from\n * minIndex to maxIndex.\n */\n count: number;\n /**\n * Maximum number of items to render on either side of the visible area.\n * Default is `count`.\n */\n tolerance: number;\n /** Height of each item, in pixels. Default is 20px. */\n itemHeight: number;\n}\n\nexport interface VirtualScrollDataAdapter {\n (offset: number, limit: number): Iterable;\n}\n\nexport function arrayAdapter(data: T[]): VirtualScrollDataAdapter {\n return (offset, limit) => data.slice(offset, offset + limit);\n}\n\nexport interface VirtualScrollProps {\n settings?: Partial;\n get: VirtualScrollDataAdapter;\n row: (t: T) => U;\n rowKey: (t: T) => Key;\n}\n\nexport function fillVirtualScrollSettings(\n settings: Partial\n): VirtualScrollSettings {\n const {\n minIndex = 0,\n maxIndex = Number.MAX_SAFE_INTEGER,\n startIndex = 0,\n itemHeight = 20,\n count = Math.max(maxIndex - minIndex, 1),\n tolerance = count,\n } = settings;\n\n return { minIndex, maxIndex, startIndex, itemHeight, count, tolerance };\n}\n\nexport function initialState(\n settings: VirtualScrollSettings,\n adapter: VirtualScrollDataAdapter\n): VirtualScrollState {\n // From Denis Hilt, https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/\n const { minIndex, maxIndex, startIndex, itemHeight, count, tolerance } =\n settings;\n const bufferedItems = count + 2 * tolerance;\n const itemsAbove = Math.max(0, startIndex - tolerance - minIndex);\n\n const viewportHeight = count * itemHeight;\n const totalHeight = Math.min(maxIndex - minIndex, 1) * itemHeight;\n const toleranceHeight = tolerance * itemHeight;\n const bufferHeight = viewportHeight + 2 * toleranceHeight;\n const topPaddingHeight = itemsAbove * itemHeight;\n const bottomPaddingHeight = totalHeight - (topPaddingHeight + bufferHeight);\n\n const state: VirtualScrollState = {\n scrollTop: 0,\n settings,\n viewportHeight,\n totalHeight,\n toleranceHeight,\n bufferedItems,\n topPaddingHeight,\n bottomPaddingHeight,\n data: [],\n };\n\n return {\n ...state,\n ...doScroll(topPaddingHeight + toleranceHeight, state, adapter),\n };\n}\n\nexport function getData(\n minIndex: number,\n maxIndex: number,\n offset: number,\n limit: number,\n get: VirtualScrollDataAdapter\n): T[] {\n const start = Math.max(0, minIndex, offset);\n const end = Math.min(maxIndex, offset + limit - 1);\n const data = get(start, end - start);\n return [...data];\n}\n\ninterface ScrollUpdate {\n scrollTop: number;\n topPaddingHeight: number;\n bottomPaddingHeight: number;\n data: T[];\n}\n\nexport function doScroll(\n scrollTop: number,\n state: VirtualScrollState,\n get: VirtualScrollDataAdapter\n): ScrollUpdate {\n const {\n totalHeight,\n toleranceHeight,\n bufferedItems,\n settings: { itemHeight, minIndex, maxIndex },\n } = state;\n const index =\n minIndex + Math.floor((scrollTop - toleranceHeight) / itemHeight);\n const data = getData(minIndex, maxIndex, index, bufferedItems, get);\n const topPaddingHeight = Math.max((index - minIndex) * itemHeight, 0);\n const bottomPaddingHeight = Math.max(\n totalHeight - (topPaddingHeight + data.length * itemHeight),\n 0\n );\n\n return { scrollTop, topPaddingHeight, bottomPaddingHeight, data };\n}\n\ninterface VirtualScrollState {\n settings: VirtualScrollSettings;\n scrollTop: number; // px\n bufferedItems: number; // count\n totalHeight: number; // px\n viewportHeight: number; // px\n topPaddingHeight: number; // px\n bottomPaddingHeight: number; // px\n toleranceHeight: number; // px\n data: T[];\n}\n\nconst scrollReducer =\n (get: VirtualScrollDataAdapter) =>\n (state: VirtualScrollState, scrollTop: number) => ({\n ...state,\n ...doScroll(scrollTop, state, get),\n });\n\nexport const VirtualScroll = (\n props: VirtualScrollProps & { className?: string }\n) => {\n const viewportRef = useRef(null);\n\n const { settings, startState, reducer } = useMemo(() => {\n const settings = fillVirtualScrollSettings(props.settings ?? {});\n const startState = initialState(settings, props.get);\n const reducer = scrollReducer(props.get);\n return { settings, reducer, startState };\n }, [props.settings, props.get]);\n\n const [state, dispatchScroll] = useReducer(reducer, startState);\n\n useEffect(() => {\n if (viewportRef.current !== null) {\n dispatchScroll(viewportRef.current.scrollTop);\n }\n }, [settings, props.row]);\n\n const initialScroll = useCallback(\n (div: HTMLDivElement | null) => {\n if (div) {\n div.scrollTop = viewportRef.current\n ? viewportRef.current.scrollTop\n : settings.startIndex * settings.itemHeight;\n }\n viewportRef.current = div;\n },\n [viewportRef, settings.startIndex, settings.itemHeight]\n );\n\n const rows = state.data.map((d) => (\n
\n {props.row(d)}\n
\n ));\n\n return (\n dispatchScroll((e.target as HTMLDivElement).scrollTop)}\n >\n
\n {rows}\n
\n
\n );\n};\n\nexport default VirtualScroll;\n","import { rounded } from \"@davidsouther/jiffies/lib/esm/dom/css/border.js\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\n\nimport {\n Format,\n FORMATS,\n Memory as MemoryChip,\n} from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { asm } from \"@nand2tetris/simulator/util/asm.js\";\nimport { bin, dec, hex } from \"@nand2tetris/simulator/util/twos.js\";\nimport InlineEdit from \"../inline_edit.js\";\nimport VirtualScroll, { VirtualScrollSettings } from \"../virtual_scroll.js\";\n\nconst ITEM_HEIGHT = 34;\n\nexport const MemoryBlock = ({\n memory,\n jmp = { value: 0 },\n highlight = -1,\n editable = false,\n format = dec,\n onChange = () => undefined,\n}: {\n jmp?: { value: number };\n memory: MemoryChip;\n highlight?: number;\n editable?: boolean;\n format?: (v: number) => string;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => {\n const settings = useMemo>(\n () => ({\n count: Math.min(memory.size, 20),\n maxIndex: memory.size,\n itemHeight: ITEM_HEIGHT,\n startIndex: jmp.value,\n }),\n [memory.size, jmp]\n );\n const get = useCallback(\n (offset: number, count: number) =>\n memory\n .range(offset, offset + count)\n .map((v, i) => [i + offset, v] as [number, number]),\n [memory]\n );\n const row = useCallback(\n ([i, v]: [number, number]) => (\n \n ),\n [format, editable, highlight, onChange]\n );\n\n return (\n \n settings={settings}\n get={get}\n row={row}\n rowKey={([i]) => i}\n />\n );\n};\n\nexport const MemoryCell = ({\n index,\n value,\n highlight = false,\n editable = false,\n onChange = () => undefined,\n}: {\n index: number;\n value: string;\n highlight?: boolean;\n editable?: boolean;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => (\n
\n \n {hex(index)}\n \n \n {editable ? (\n \n onChange(index, newValue, Number(value))\n }\n />\n ) : (\n {value}\n )}\n \n
\n);\n\nexport const Memory = ({\n name = \"Memory\",\n highlight = -1,\n editable = true,\n memory,\n format = \"dec\",\n}: {\n name?: string;\n editable?: boolean;\n highlight?: number;\n memory: MemoryChip;\n format: Format;\n}) => {\n const [fmt, setFormat] = useState(format);\n const [jmp, setJmp] = useState(\"0\");\n const [goto, setGoto] = useState({ value: 0 });\n\n const jumpTo = () => {\n setGoto({ value: Number(jmp) });\n };\n\n // const { filePicker, fs } = useContext(AppContext);\n // const doLoad = useCallback(async () => {\n // try {\n // const file = await filePicker.select();\n // await memory.load(fs, file);\n // } catch (e) {\n // console.error(e);\n // }\n // }, [fs, filePicker, memory]);\n\n const doLoad = () => undefined;\n\n const doUpdate = useCallback(\n (i: number, v: string) => {\n memory.update(i, v, fmt ?? \"dec\");\n },\n [memory, fmt]\n );\n\n return (\n
\n
\n
{name}
\n
\n \n key === \"Enter\" && jumpTo()}\n onChange={({ target: { value } }) => setJmp(value ?? \"0\")}\n />\n \n {FORMATS.map((option) => (\n \n setFormat(option)}\n />\n {option}\n \n ))}\n
\n
\n doFormat(fmt, v)}\n onChange={doUpdate}\n />\n
\n );\n};\n\nexport default Memory;\n\nfunction doFormat(format: Format, v: number): string {\n switch (format) {\n case \"bin\":\n return bin(v);\n case \"hex\":\n return hex(v);\n case \"asm\":\n return asm(v);\n case \"dec\":\n default:\n return dec(v);\n }\n}\n","import { useEffect, useMemo, useState } from \"react\";\n\nimport { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\n\nexport function useClock(actions: {\n tick?: () => void;\n toggle?: () => void;\n reset?: () => void;\n}) {\n const clock = useMemo(() => Clock.get(), []);\n\n useEffect(() => {\n const subscription = clock.$.subscribe(() => {\n actions.tick?.();\n });\n return () => subscription.unsubscribe();\n }, [actions, clock.$]);\n\n return {\n toggle() {\n clock.tick();\n actions.toggle?.();\n },\n\n reset() {\n clock.reset();\n actions.reset?.();\n },\n };\n}\n\nexport function useClockFrame(frameFinished: () => void) {\n useEffect(() => {\n const subscription = Clock.get().frame$.subscribe(() => {\n frameFinished();\n });\n return () => subscription.unsubscribe();\n }, [frameFinished]);\n}\n\nexport function displayClock() {\n return display(Clock.get());\n}\n\nexport function useClockface() {\n const [clockface, setClockface] = useState(displayClock());\n\n useEffect(() => {\n const subscription = Clock.get().$.subscribe(() => {\n setClockface(displayClock());\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return clockface;\n}\n\nexport const Clockface = () => {\n const clockface = useClockface();\n return {clockface};\n};\n","import { Memory } from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { assertExists } from \"@davidsouther/jiffies/lib/esm/assert.js\";\nimport { useCallback, useRef } from \"react\";\nimport { useClockFrame } from \"../clockface.js\";\n\nconst WHITE = \"white\";\nconst BLACK = \"black\";\ntype COLOR = typeof WHITE | typeof BLACK;\n\nexport interface ScreenMemory {\n get(idx: number): number;\n}\n\nexport function reduceScreen(memory: Memory, offset = 0): ScreenMemory {\n return {\n get(idx: number): number {\n return memory.get(offset + idx);\n },\n };\n}\n\nfunction get(mem: ScreenMemory, x: number, y: number): COLOR {\n const byte = mem.get(32 * y + ((x / 16) | 0));\n const bit = byte & (1 << x % 16);\n return bit === 0 ? WHITE : BLACK;\n}\n\nfunction set(data: Uint8ClampedArray, x: number, y: number, value: COLOR) {\n const pixel = (y * 512 + x) * 4;\n const color = value === WHITE ? 255 : 0;\n data[pixel] = color;\n data[pixel + 1] = color;\n data[pixel + 2] = color;\n data[pixel + 3] = 255;\n}\n\nfunction drawImage(ctx: CanvasRenderingContext2D, memory: ScreenMemory) {\n const image = assertExists(\n ctx.getImageData(0, 0, 512, 256),\n \"Failed to create Context2d\"\n );\n for (let col = 0; col < 512; col++) {\n for (let row = 0; row < 256; row++) {\n const color = get(memory, col, row);\n set(image.data, col, row, color);\n }\n }\n ctx.putImageData(image, 0, 0);\n}\n\nexport const Screen = ({ memory }: { memory: ScreenMemory }) => {\n const canvas = useRef();\n\n const draw = useCallback(() => {\n const ctx = canvas.current?.getContext(\"2d\") ?? undefined;\n\n if (ctx) {\n drawImage(ctx, memory);\n }\n }, [memory]);\n\n const ctxRef = useCallback(\n (ref: HTMLCanvasElement | null) => {\n canvas.current = ref ?? undefined;\n draw();\n },\n [canvas, draw]\n );\n\n useClockFrame(draw);\n\n return (\n
\n
Screen
\n
\n \n \n \n
\n
\n );\n};\n","import {\n Keyboard,\n Screen,\n} from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { ALU } from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n PC,\n VRegister,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/bit.js\";\nimport {\n RAM,\n RAM8,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/ram.js\";\nimport { Chip, HIGH } from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Flags } from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { CPU, decode } from \"@nand2tetris/simulator/cpu/cpu.js\";\nimport { ReactElement } from \"react\";\nimport { ALUComponent } from \"./alu.js\";\nimport { Keyboard as KeyboardComponent } from \"./keyboard.js\";\nimport { Memory as MemoryComponent } from \"./memory.js\";\nimport { RegisterComponent } from \"./register.js\";\nimport { Screen as ScreenComponent } from \"./screen.js\";\n\nexport function getBuiltinVisualization(part: Chip): ReactElement | undefined {\n switch (part.name) {\n case \"Register\":\n case \"ARegister\":\n case \"DRegister\":\n case \"PC\":\n case \"KEYBOARD\":\n case \"RAM8\":\n case \"RAM64\":\n case \"RAM512\":\n case \"RAM4K\":\n case \"RAM16K\":\n case \"ROM32K\":\n case \"Screen\":\n case \"Memory\":\n default:\n return undefined;\n }\n}\n\nexport function makeVisualization(chip: Chip): ReactElement | undefined {\n if (chip instanceof ALU) {\n return (\n \n );\n }\n if (chip instanceof VRegister) {\n return (\n \n );\n }\n if (chip instanceof PC) {\n return ;\n }\n if (chip instanceof Keyboard) {\n return ;\n }\n if (chip instanceof Screen) {\n return ;\n }\n if (chip instanceof RAM) {\n return (\n \n );\n }\n if (chip instanceof RAM8) {\n return RAM {chip.width};\n }\n if (chip instanceof CPU) {\n const bits = decode(chip.in(\"instruction\").busVoltage);\n return (\n <>\n \n \n \n \n \n );\n }\n\n const vis = [...chip.parts]\n .map(makeVisualization)\n .filter((v) => v !== undefined);\n return vis.length > 0 ? <>{vis} : undefined;\n}\n\nexport function makeVisualizationsWithId(chip: {\n parts: Chip[];\n}): [string, ReactElement][] {\n return [...chip.parts]\n .map((part, i): [string, ReactElement | undefined] => [\n `${part.id}_${i}`,\n makeVisualization(part),\n ])\n .filter(([_, v]) => v !== undefined) as [string, ReactElement][];\n}\n","// import { plural, Trans } from \"@lingui/macro\";\nimport {\n Pin as ChipPin,\n Pins,\n Voltage,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { range } from \"@davidsouther/jiffies/lib/esm/range.js\";\nimport { ChipSim } from \"./stores/chip.store.js\";\n\nexport interface ImmPin {\n bits: [number, Voltage][];\n pin: ChipPin;\n}\n\nexport function reducePin(pin: ChipPin) {\n return {\n pin,\n bits: range(0, pin.width)\n .map((i) => [i, pin.voltage(i)] as [number, Voltage])\n .reverse(),\n };\n}\n\nexport function reducePins(pins: Pins): ImmPin[] {\n return [...pins.entries()].map(reducePin);\n}\n\nexport interface PinoutPins {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}\n\nexport const FullPinout = (props: {\n sim: ChipSim;\n toggle: (pin: ChipPin, i: number | undefined) => void;\n}) => {\n const { inPins, outPins, internalPins } = props.sim;\n return (\n <>\n \n \n \n \n \n \n \n
\n \n );\n};\n\nexport const PinoutBlock = (\n props: PinoutPins & { header: string; disabled?: boolean }\n) => (\n <>\n {props.pins.length > 0 && (\n \n {props.header}\n \n )}\n {[...props.pins].map((immPin) => (\n \n {immPin.pin.name}\n \n \n \n \n ))}\n \n);\n\nexport const Pinout = ({\n pins,\n toggle,\n}: {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}) => {\n if (pins.length === 0) {\n return <>None;\n }\n return (\n \n \n \n \n \n \n \n \n {[...pins].map((immPin) => (\n \n \n \n \n ))}\n \n
NameValue
{immPin.pin.name}\n \n
\n );\n};\n\nconst Pin = ({\n pin,\n toggle,\n disabled = false,\n}: {\n pin: ImmPin;\n toggle: ((pin: ChipPin, bit?: number) => void) | undefined;\n disabled?: boolean;\n}) => {\n return (\n
\n {pin.bits.map(([i, v]) => (\n toggle?.(pin.pin, i)}\n disabled={disabled}\n data-testid={`pin-${i}`}\n >\n {v}\n \n ))}\n
\n );\n};\n","import { ReactNode } from \"react\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useTimer } from \"./timer.js\";\n\nexport const Runbar = (props: { runner: Timer; children?: ReactNode }) => {\n const runner = useTimer(props.runner);\n return (\n
\n runner.actions.frame()}\n data-tooltip={`Step`}\n data-placement=\"bottom\"\n >\n {/* */}\n ➡️\n \n \n runner.state.running ? runner.actions.stop() : runner.actions.start()\n }\n data-tooltip={runner.state.running ? `Pause` : `Play`}\n data-placement=\"bottom\"\n >\n {/* */}\n {runner.state.running ? \"⏸\" : \"️⏩\"}\n \n runner.actions.reset()}\n data-tooltip={`Reset`}\n data-placement=\"bottom\"\n >\n {/* */}⏮\n \n {\n runner.dispatch({\n action: \"setSpeed\",\n payload: Number(e.target?.value ?? runner.state.speed),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n // [2000, `Debug`], // For debugging, basically the same as clicking through\n [1000, `Slow`],\n [500, `Fast`],\n [16, `Faster`],\n ].map(([speed, label]) => (\n \n ))}\n \n {\n runner.dispatch({\n action: \"setSteps\",\n payload: Number(e.target?.value ?? runner.state.steps),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n [1, `1 Step`],\n [500, \"500\"],\n [1000, \"1000\"],\n [2000, \"2000\"],\n ].map(([steps, label]) => (\n \n ))}\n \n {props.children}\n
\n );\n};\n","import { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useImmerReducer } from \"./react.js\";\n\nexport interface TimerStoreState {\n steps: number;\n speed: number;\n running: boolean;\n}\n\nimport { Dispatch, MutableRefObject, useMemo, useRef } from \"react\";\nexport type TimerStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nconst makeTimerStore = (\n timer: Timer,\n dispatch: MutableRefObject\n) => {\n const initialState: TimerStoreState = {\n running: timer.running,\n speed: timer.speed,\n steps: timer.steps,\n };\n\n const finishFrame = timer.finishFrame.bind(timer);\n timer.finishFrame = function () {\n finishFrame();\n dispatch.current({ action: \"update\" });\n };\n\n const reducers = {\n update(state: TimerStoreState) {\n state.running = timer.running;\n state.speed = timer.speed;\n state.steps = timer.steps;\n },\n setSteps(state: TimerStoreState, steps: number) {\n state.steps = steps;\n timer.steps = steps;\n },\n setSpeed(state: TimerStoreState, speed: number) {\n state.speed = speed;\n timer.speed = speed;\n },\n };\n\n const actions = {\n frame() {\n timer.frame();\n },\n start() {\n timer.start();\n dispatch.current({ action: \"update\" });\n },\n stop() {\n timer.stop();\n dispatch.current({ action: \"update\" });\n },\n reset() {\n timer.reset();\n dispatch.current({ action: \"update\" });\n },\n };\n\n return { initialState, reducers, actions };\n};\n\nexport function useTimer(timer: Timer) {\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeTimerStore(timer, dispatch),\n [timer, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(reducers, initialState);\n\n dispatch.current = dispatcher;\n\n return { state, dispatch: dispatch.current, actions };\n}\n","import { Clock } from \"./chip/clock.js\";\n\nexport const MAX_STEPS = 1000;\n\nconst clock = Clock.get();\n\nexport abstract class Timer {\n frame() {\n this.tick();\n this.finishFrame();\n }\n\n abstract tick(): Promise | boolean;\n\n finishFrame() {\n clock.frame();\n }\n\n abstract reset(): void;\n\n abstract toggle(): void;\n\n steps = 1; // How many steps to take per update\n speed = 1000; // how often to update, in ms\n get running() {\n return this.#running;\n }\n\n #running = false;\n #sinceLastFrame = 0;\n #lastUpdate = 0;\n #run = async () => {\n if (!this.#running) {\n return;\n }\n const now = Date.now();\n const delta = now - this.#lastUpdate;\n this.#lastUpdate = now;\n this.#sinceLastFrame += delta;\n if (this.#sinceLastFrame > this.speed) {\n let done = false;\n for (let i = 0; i < Math.min(this.steps, MAX_STEPS) && !done; i++) {\n done = await this.tick();\n }\n this.finishFrame();\n if (done) {\n this.stop();\n }\n this.#sinceLastFrame -= this.speed;\n }\n requestAnimationFrame(this.#run);\n };\n\n start() {\n this.#running = true;\n this.#lastUpdate = Date.now() - this.speed;\n this.#run();\n this.toggle();\n }\n\n stop() {\n this.#running = false;\n this.toggle();\n }\n}\n","import { debounce } from \"@davidsouther/jiffies/lib/esm/debounce\";\nimport { Trans } from \"@lingui/macro\";\nimport MonacoEditor, { useMonaco } from \"@monaco-editor/react\";\nimport type * as monacoT from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { OnMount } from \"@monaco-editor/react\";\nimport ohm from \"ohm-js\";\nimport {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AppContext } from \"../App.context\";\n\nimport {\n Span,\n UNKNOWN_PARSE_ERROR,\n} from \"@nand2tetris/simulator/languages/base.js\";\n\nimport \"./editor.scss\";\n\nexport const ErrorPanel = ({ error }: { error?: ohm.MatchResult }) => {\n return error?.failed() ? (\n
\n \n Parse Error\n \n
\n        \n          {error?.message ?? error?.shortMessage ?? UNKNOWN_PARSE_ERROR}\n        \n      
\n
\n ) : (\n <>\n );\n};\n\nconst Textarea = ({\n value,\n onChange,\n language,\n disabled = false,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n disabled?: boolean;\n}) => {\n const [text, setText] = useState(value);\n return (\n {\n const value = e.target?.value;\n setText(value);\n onChange(value);\n }}\n />\n );\n};\n\nconst MONACO_LIGHT_THEME = \"vs\";\nconst MONACO_DARK_THEME = \"vs-dark\";\n\nconst makeHighlight = (\n monaco: typeof monacoT | null,\n editor: monacoT.editor.IStandaloneCodeEditor | undefined,\n highlight: Span | undefined,\n decorations: string[]\n): string[] => {\n if (!(editor && highlight)) return decorations;\n const model = editor.getModel();\n if (!model) return decorations;\n const start = model.getPositionAt(highlight.start);\n const end = model.getPositionAt(highlight.end);\n const range = monaco?.Range.fromPositions(start, end);\n const nextDecoration: monacoT.editor.IModelDeltaDecoration[] = [];\n if (range) {\n nextDecoration.push({\n range,\n options: { inlineClassName: \"highlight\" },\n });\n editor.revealRangeInCenter(range);\n }\n return editor.deltaDecorations(decorations, nextDecoration);\n};\n\nconst Monaco = ({\n value,\n onChange,\n language,\n error,\n disabled = false,\n highlight: currentHighlight,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n error?: ohm.MatchResult | undefined;\n disabled?: boolean;\n highlight?: Span;\n}) => {\n const { theme } = useContext(AppContext);\n const monaco = useMonaco();\n\n const editor = useRef();\n const decorations = useRef([]);\n const highlight = useRef(undefined);\n\n const codeTheme = useCallback(() => {\n const isDark =\n theme === \"system\"\n ? window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n : theme === \"dark\";\n return isDark ? MONACO_DARK_THEME : MONACO_LIGHT_THEME;\n }, [theme]);\n\n const doHighlight = useCallback(() => {\n decorations.current = makeHighlight(\n monaco,\n editor.current,\n // I'm not sure why this makes things work, but it is load bearing.\n // Removing the empty span will cause the initial first-statement\n // highlight in the test view to not show. Setting it to [0, 1] will\n // cause a 1-character highlight in the editor view, so don't do that\n // either.\n highlight.current ?? { start: 0, end: 0 },\n decorations.current\n );\n }, [decorations, monaco, editor, highlight]);\n\n // Mark and center highlighted spans\n useEffect(() => {\n highlight.current = currentHighlight;\n doHighlight();\n }, [currentHighlight]);\n\n // Set options when mounting\n const onMount: OnMount = useCallback(\n (ed) => {\n editor.current = ed;\n editor.current?.updateOptions({\n fontFamily: `\"JetBrains Mono\", source-code-pro, Menlo, Monaco,\n Consolas, \"Roboto Mono\", \"Ubuntu Monospace\", \"Noto Mono\", \"Oxygen Mono\",\n \"Liberation Mono\", monospace, \"Apple Color Emoji\", \"Segoe UI Emoji\",\n \"Segoe UI Symbol\", \"Noto Color Emoji\"`,\n fontSize: 16,\n minimap: {\n enabled: false,\n },\n theme: codeTheme(),\n scrollBeyondLastLine: false,\n });\n doHighlight();\n },\n [codeTheme]\n );\n\n // Set themes\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ theme: codeTheme() });\n }, [editor, codeTheme]);\n\n // Prevent editing disabled editors\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ readOnly: disabled });\n }, [editor, disabled]);\n\n // Add error markers on parse failure\n useEffect(() => {\n if (editor.current === undefined) return;\n if (monaco === null) return;\n const model = editor.current.getModel();\n if (model === null) return;\n if (error === undefined || error.succeeded()) {\n monaco.editor.setModelMarkers(model, language, []);\n return;\n }\n // Line 7, col 5:\n const { line, column, message } =\n /Line (?\\d+), col (?\\d+): (?.*)/.exec(\n error.shortMessage ?? \"\"\n )?.groups ?? { line: 1, column: 1, message: \"could not parse error\" };\n const startLineNumber = Number(line);\n const endLineNumber = startLineNumber;\n const startColumn = Number(column);\n const restOfLine = model\n .getLineContent(startLineNumber)\n .substring(startColumn - 1);\n let endColumn =\n startColumn + (restOfLine.match(/([^\\s]+)/)?.[0].length ?? 1);\n if (endColumn <= startColumn) {\n endColumn = startColumn + 1;\n }\n\n monaco.editor.setModelMarkers(model, language, [\n {\n message,\n startColumn,\n startLineNumber,\n endColumn,\n endLineNumber,\n severity: 8, // monacoT.MarkerSeverity.Error,\n },\n ]);\n }, [error, editor, monaco, language]);\n\n return (\n <>\n onChange(v)}\n language={language}\n onMount={onMount}\n />\n \n );\n};\n\nexport const Editor = ({\n className = \"\",\n style = {},\n disabled = false,\n value,\n onChange,\n grammar,\n language,\n highlight,\n}: {\n className?: string;\n style?: CSSProperties;\n disabled?: boolean;\n value: string;\n onChange: (source: string) => void;\n grammar: ohm.Grammar;\n language: string;\n highlight?: Span;\n}) => {\n const [error, setError] = useState();\n const { monaco } = useContext(AppContext);\n\n const parse = useCallback(\n (text = \"\") => {\n const parsed = grammar.match(text);\n setError(parsed.failed() ? parsed : undefined);\n },\n [setError, grammar]\n );\n\n useEffect(() => parse(value), [parse, value]);\n const doParse = useMemo(() => debounce(parse, 500), [parse]);\n\n const onChangeCB = useCallback(\n (text = \"\") => {\n onChange(text);\n doParse(text);\n },\n [doParse, onChange]\n );\n\n return (\n
\n {monaco.canUse && monaco.wants ? (\n \n ) : (\n <>\n \n \n \n )}\n
\n );\n};\n","export function debounce(fn, ms = 32) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => (clearTimeout(timer), fn(...args)), ms);\n return timer;\n };\n}\n","import { CSSProperties, ReactNode } from \"react\";\n\nexport const Panel = (props: {\n children: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}) => {\n return (\n
\n {props.header &&
{props.header}
}\n
{props.children}
\n {props.footer &&
{props.footer}
}\n
\n );\n};\n\nexport const Accordian = (props: {\n children: ReactNode;\n summary: ReactNode;\n className?: string;\n style?: CSSProperties;\n open?: boolean;\n}) => {\n return (\n \n \n
{props.summary}
\n
\n {props.children}\n \n );\n};\n","import { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { FileSystem } from \"@davidsouther/jiffies/lib/esm/fs.js\";\nimport { Err, isErr, Ok } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport { Dispatch, MutableRefObject, useContext, useMemo, useRef } from \"react\";\n\nimport { build as buildChip } from \"@nand2tetris/simulator/chip/builder.js\";\nimport {\n getBuiltinChip,\n REGISTRY,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n Chip,\n Chip as SimChip,\n Low,\n Pin,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\nimport { Span } from \"@nand2tetris/simulator/languages/base.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { ChipProjects, CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { ChipTest } from \"@nand2tetris/simulator/tst.js\";\n\nimport { ImmPin, reducePins } from \"../pinout.js\";\nimport { useImmerReducer } from \"../react.js\";\n\nimport { BaseContext } from \"./base.context.js\";\nimport { assert } from \"@davidsouther/jiffies/lib/esm/assert.js\";\n\nexport const PROJECT_NAMES = [\n [\"01\", `Project 1`],\n [\"02\", `Project 2`],\n [\"03\", `Project 3`],\n [\"05\", `Project 5`],\n];\n\nfunction findDropdowns(storage: Record) {\n const project =\n (storage[\"/chip/project\"] as keyof typeof CHIP_PROJECTS) ?? \"01\";\n const chips = CHIP_PROJECTS[project];\n const chipName = storage[\"/chip/chip\"] ?? chips[0];\n return { project, chips, chipName };\n}\n\nfunction makeHdl(name: string) {\n return `CHIP ${name} {\n IN in;\n OUT out;\n PARTS:\n}`;\n}\n\nfunction makeTst() {\n return `repeat 10 {\n tick,\n tock;\n}`;\n}\n\nfunction makeCmp() {\n return `| in|out|`;\n}\n\nexport interface ChipPageState {\n files: Files;\n sim: ChipSim;\n controls: ControlsState;\n}\n\nexport interface ChipSim {\n clocked: boolean;\n inPins: ImmPin[];\n outPins: ImmPin[];\n internalPins: ImmPin[];\n chip: [Chip];\n pending: boolean;\n invalid: boolean;\n}\n\nexport interface Files {\n hdl: string;\n cmp: string;\n tst: string;\n out: string;\n}\n\nexport interface ControlsState {\n project: keyof typeof CHIP_PROJECTS;\n chips: string[];\n chipName: string;\n hasBuiltin: boolean;\n runningTest: boolean;\n span?: Span;\n error: string;\n}\n\nfunction reduceChip(chip: SimChip, pending = false, invalid = false): ChipSim {\n return {\n clocked: chip.clocked,\n inPins: reducePins(chip.ins),\n outPins: reducePins(chip.outs),\n internalPins: reducePins(chip.pins),\n chip: [chip],\n pending,\n invalid,\n };\n}\n\nconst clock = Clock.get();\n\nexport type ChipStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nexport function makeChipStore(\n fs: FileSystem,\n setStatus: (status: string) => void,\n storage: Record,\n dispatch: MutableRefObject\n) {\n const dropdowns = findDropdowns(storage);\n let { project, chipName } = dropdowns;\n const { chips } = dropdowns;\n let chip = new Low();\n let test = new ChipTest();\n let usingBuiltin = false;\n\n const reducers = {\n setFiles(\n state: ChipPageState,\n {\n hdl = state.files.hdl,\n tst = state.files.tst,\n cmp = state.files.cmp,\n out = \"\",\n }: {\n hdl?: string;\n tst?: string;\n cmp?: string;\n out?: string;\n }\n ) {\n state.files.hdl = hdl;\n state.files.tst = tst;\n state.files.cmp = cmp;\n state.files.out = out;\n },\n\n updateChip(\n state: ChipPageState,\n payload?: {\n pending?: boolean;\n invalid?: boolean;\n chipName?: string;\n error?: string;\n }\n ) {\n state.sim = reduceChip(\n chip,\n payload?.pending ?? state.sim.pending,\n payload?.invalid ?? state.sim.invalid\n );\n state.controls.error = state.sim.invalid\n ? payload?.error ?? state.controls.error\n : \"\";\n state.controls.chips = CHIP_PROJECTS[state.controls.project];\n state.controls.chipName = state.sim.invalid\n ? payload?.chipName ?? chipName\n : chip.name ?? payload?.chipName ?? chipName;\n if (!state.controls.chips.includes(state.controls.chipName)) {\n state.controls.chips = [\n ...state.controls.chips,\n state.controls.chipName,\n ];\n }\n },\n\n setProject(state: ChipPageState, project: keyof typeof CHIP_PROJECTS) {\n const chips = CHIP_PROJECTS[project];\n const chipName =\n state.controls.chipName && chips.includes(state.controls.chipName)\n ? state.controls.chipName\n : chips[0];\n state.controls.project = project;\n state.controls.chips = chips;\n this.setChip(state, chipName);\n },\n\n setChip(state: ChipPageState, chipName: string) {\n state.controls.chipName = chipName;\n state.controls.hasBuiltin = REGISTRY.has(chipName);\n },\n\n testRunning(state: ChipPageState) {\n state.controls.runningTest = true;\n },\n\n testFinished(state: ChipPageState) {\n state.controls.runningTest = false;\n const passed = state.files.out.trim() === state.files.cmp.trim();\n setStatus(\n passed\n ? `Simulation successful: The output file is identical to the compare file`\n : `Simulation error: The output file differs from the compare file`\n );\n },\n\n updateTestStep(state: ChipPageState) {\n state.files.out = test?.log() ?? \"\";\n if (test?.currentStep?.span) {\n state.controls.span = test.currentStep.span;\n } else {\n if (test.done) {\n const end = state.files.tst.length;\n state.controls.span = {\n start: end - 1,\n end,\n };\n }\n }\n this.updateChip(state, {\n pending: state.sim.pending,\n invalid: state.sim.invalid,\n });\n },\n };\n\n const actions = {\n setProject(p: keyof typeof CHIP_PROJECTS) {\n project = storage[\"/chip/project\"] = p;\n dispatch.current({ action: \"setProject\", payload: project });\n this.setChip(CHIP_PROJECTS[project][0]);\n },\n\n async setChip(\n chip: string,\n project = storage[\"/chip/project\"] ?? ChipProjects[\"01\"]\n ) {\n chipName = storage[\"/chip/chip\"] = chip;\n dispatch.current({ action: \"setChip\", payload: chipName });\n await this.loadChip(project, chipName);\n if (usingBuiltin) {\n this.useBuiltin();\n }\n },\n\n reset() {\n Clock.get().reset();\n chip.reset();\n test.reset();\n dispatch.current({ action: \"setFiles\", payload: {} });\n dispatch.current({ action: \"updateChip\" });\n },\n\n async updateFiles({\n hdl,\n tst,\n cmp,\n }: {\n hdl?: string;\n tst?: string;\n cmp: string;\n }) {\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n try {\n if (hdl) {\n await this.compileChip(hdl);\n }\n if (tst) {\n this.compileTest(tst);\n }\n } catch (e) {\n setStatus(display(e));\n }\n },\n\n async compileChip(hdl: string) {\n chip.remove();\n const maybeParsed = HDL.parse(hdl);\n if (isErr(maybeParsed)) {\n setStatus(\"Failed to parse chip\");\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error: display(Err(maybeParsed)) },\n });\n return;\n }\n const maybeChip = await buildChip(Ok(maybeParsed));\n if (isErr(maybeChip)) {\n const error = display(Err(maybeChip));\n setStatus(error);\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error },\n });\n return;\n }\n setStatus(`Compiled ${chip.name}`);\n this.replaceChip(Ok(maybeChip));\n },\n\n replaceChip(nextChip: SimChip) {\n // Store current inPins\n const inPins = chip.ins;\n for (const [pin, { busVoltage }] of inPins) {\n const nextPin = nextChip.ins.get(pin);\n if (nextPin) {\n nextPin.busVoltage = busVoltage;\n }\n }\n clock.reset();\n nextChip.eval();\n chip = nextChip;\n chip.reset();\n test = test.with(chip).reset();\n dispatch.current({ action: \"updateChip\", payload: { invalid: false } });\n dispatch.current({ action: \"updateTestStep\" });\n },\n\n async loadChip(project: string, name: string) {\n storage[\"/chip/chip\"] = name;\n const fsName = (ext: string) =>\n `/projects/${project}/${name}/${name}.${ext}`;\n\n const [hdl, tst, cmp] = await Promise.all([\n fs.readFile(fsName(\"hdl\")).catch(() => makeHdl(name)),\n fs.readFile(fsName(\"tst\")).catch((e) => {\n console.log(e);\n return makeTst();\n }),\n fs.readFile(fsName(\"cmp\")).catch(() => makeCmp()),\n ]);\n\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n await this.compileChip(hdl);\n this.compileTest(tst);\n },\n\n async saveChip(hdl: string, prj = project, name = chipName) {\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n const path = `/projects/${prj}/${name}/${name}.hdl`;\n await fs.writeFile(path, hdl);\n setStatus(`Saved ${path}`);\n },\n\n toggle(pin: Pin, i: number | undefined) {\n if (i !== undefined) {\n pin.busVoltage = pin.busVoltage ^ (1 << i);\n } else {\n if (pin.width === 1) {\n pin.toggle();\n } else {\n pin.busVoltage += 1;\n }\n }\n dispatch.current({ action: \"updateChip\", payload: { pending: true } });\n },\n\n eval() {\n chip.eval();\n dispatch.current({ action: \"updateChip\", payload: { pending: false } });\n },\n\n clock() {\n clock.toggle();\n if (clock.isLow) {\n clock.frame();\n }\n dispatch.current({ action: \"updateChip\" });\n },\n\n async useBuiltin(doUseBuiltin = true, hdl?: string) {\n if (!doUseBuiltin) {\n usingBuiltin = false;\n await this.loadChip(project, chipName);\n return;\n }\n usingBuiltin = true;\n const builtinName = chip.name ?? chipName;\n const nextChip = getBuiltinChip(builtinName);\n if (isErr(nextChip)) {\n setStatus(\n `Failed to load builtin ${builtinName}: ${display(Err(nextChip))}`\n );\n return;\n }\n\n // Save hdl code that will be overwritten by the switch\n if (hdl) {\n await this.saveChip(hdl, project, chipName);\n }\n\n const template = (ChipProjects[project].CHIPS as any)[builtinName][\n `${builtinName}.hdl`\n ] as string;\n const builtinCode = template.replace(\n \"PARTS:\",\n `PARTS:\\n BUILTIN ${builtinName}`\n );\n dispatch.current({ action: \"setFiles\", payload: { hdl: builtinCode } });\n this.replaceChip(Ok(nextChip));\n },\n\n async initialize() {\n await this.loadChip(project, chipName);\n },\n\n compileTest(file: string) {\n dispatch.current({ action: \"setFiles\", payload: { tst: file } });\n const tst = TST.parse(file);\n\n if (isErr(tst)) {\n setStatus(`Failed to parse test`);\n return false;\n }\n setStatus(`Parsed tst`);\n\n test = ChipTest.from(Ok(tst)).with(chip).reset();\n test.setFileSystem(fs);\n dispatch.current({ action: \"updateTestStep\" });\n return true;\n },\n\n async runTest(file: string) {\n if (!this.compileTest(file)) {\n return;\n }\n dispatch.current({ action: \"testRunning\" });\n\n fs.pushd(\"/samples\");\n await test.run();\n fs.popd();\n\n dispatch.current({ action: \"updateTestStep\" });\n dispatch.current({ action: \"testFinished\" });\n },\n\n tick(): Promise {\n return this.stepTest();\n },\n\n async stepTest(): Promise {\n assert(test.chipId === chip.id, \"Test and chip out of sync\");\n const done = await test.step();\n dispatch.current({ action: \"updateTestStep\" });\n if (done) {\n dispatch.current({ action: \"testFinished\" });\n }\n return done;\n },\n };\n\n const initialState: ChipPageState = (() => {\n const controls: ControlsState = {\n project,\n chips,\n chipName,\n hasBuiltin: REGISTRY.has(chipName),\n runningTest: false,\n error: \"\",\n };\n\n const maybeChip = getBuiltinChip(controls.chipName);\n if (isErr(maybeChip)) {\n setStatus(display(Err(maybeChip)));\n chip = new Low();\n } else {\n chip = Ok(maybeChip);\n }\n\n const sim = reduceChip(chip);\n\n return {\n controls,\n files: {\n hdl: \"\",\n cmp: \"\",\n tst: \"\",\n out: \"\",\n },\n sim,\n };\n })();\n\n return { initialState, reducers, actions };\n}\n\nexport function useChipPageStore() {\n const { fs, setStatus, storage } = useContext(BaseContext);\n\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeChipStore(fs, setStatus, storage, dispatch),\n [fs, setStatus, storage, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(\n reducers as unknown as Record<\n string,\n (state: ChipPageState, action?: unknown) => ChipPageState\n >,\n initialState\n );\n dispatch.current = dispatcher;\n\n return { state, dispatch, actions };\n}\n","import { Trans } from \"@lingui/macro\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport \"./chip.scss\";\n\nimport { makeVisualizationsWithId } from \"@nand2tetris/components/chips/visualizations.js\";\nimport { Clockface } from \"@nand2tetris/components/clockface.js\";\nimport { DiffTable } from \"@nand2tetris/components/difftable.js\";\nimport { FullPinout } from \"@nand2tetris/components/pinout.js\";\nimport { useStateInitializer } from \"@nand2tetris/components/react.js\";\nimport { Runbar } from \"@nand2tetris/components/runbar.js\";\nimport { CMP } from \"@nand2tetris/simulator/languages/cmp.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { AppContext } from \"../App.context\";\nimport { Icon } from \"../pico/icon\";\nimport { Editor } from \"../shell/editor\";\nimport { Accordian, Panel } from \"../shell/panel\";\nimport {\n Files,\n PROJECT_NAMES,\n useChipPageStore,\n} from \"@nand2tetris/components/stores/chip.store.js\";\nimport { BaseContext } from \"@nand2tetris/components/stores/base.context.js\";\n\nexport const Chip = () => {\n const { fs, setStatus } = useContext(BaseContext);\n const { filePicker, tracking } = useContext(AppContext);\n const { state, actions, dispatch } = useChipPageStore();\n\n const [hdl, setHdl] = useStateInitializer(state.files.hdl);\n const [tst, setTst] = useStateInitializer(state.files.tst);\n const [cmp, setCmp] = useStateInitializer(state.files.cmp);\n const [out] = useStateInitializer(state.files.out);\n\n useEffect(() => {\n actions.initialize();\n }, [actions]);\n\n useEffect(() => {\n tracking.trackPage(\"/chip\");\n }, [tracking]);\n\n const saveChip = () => {\n actions.saveChip(hdl);\n };\n\n useEffect(() => {\n tracking.trackEvent(\"action\", \"setProject\", state.controls.project);\n tracking.trackEvent(\"action\", \"setChip\", state.controls.chipName);\n }, []);\n\n const setProject = useCallback(\n (project: keyof typeof CHIP_PROJECTS) => {\n actions.setProject(project);\n tracking.trackEvent(\"action\", \"setProject\", project);\n },\n [actions, tracking]\n );\n\n const setChip = useCallback(\n (chip: string) => {\n actions.setChip(chip);\n tracking.trackEvent(\"action\", \"setChip\", chip);\n },\n [actions, tracking]\n );\n\n const doEval = useCallback(() => {\n actions.eval();\n tracking.trackEvent(\"action\", \"eval\");\n }, [actions, tracking]);\n\n const compile = useRef<(files?: Partial) => void>(() => undefined);\n compile.current = async (files: Partial = {}) => {\n await actions.updateFiles({\n hdl: files.hdl,\n tst: files.tst ?? tst,\n cmp: files.cmp ?? cmp,\n });\n };\n\n const loadTest = useCallback(async () => {\n try {\n const path = await filePicker.select();\n const tst = await fs.readFile(path);\n await compile.current({ tst });\n } catch (e) {\n console.error(e);\n setStatus(`Failed to load into memory`);\n }\n }, [filePicker, setStatus, fs, compile]);\n\n const runner = useRef();\n useEffect(() => {\n runner.current = new (class ChipTimer extends Timer {\n async reset(): Promise {\n await compile.current();\n await actions.reset();\n }\n\n override finishFrame(): void {\n super.finishFrame();\n dispatch.current({ action: \"updateTestStep\" });\n }\n\n async tick(): Promise {\n return actions.stepTest();\n }\n\n toggle(): void {\n dispatch.current({ action: \"updateTestStep\" });\n }\n })();\n\n return () => {\n runner.current?.stop();\n };\n }, [compile, actions, dispatch]);\n\n const clockActions = useMemo(\n () => ({\n toggle() {\n actions.clock();\n tracking.trackEvent(\"action\", \"toggleClock\");\n },\n reset() {\n tracking.trackEvent(\"action\", \"resetClock\");\n actions.reset();\n },\n }),\n [actions]\n );\n\n const [useBuiltin, setUseBuiltin] = useState(false);\n const toggleUseBuiltin = () => {\n if (useBuiltin) {\n setUseBuiltin(false);\n actions.useBuiltin(false);\n } else {\n setUseBuiltin(true);\n actions.useBuiltin(true, hdl);\n }\n };\n\n const selectors = (\n <>\n
\n {\n setProject(value as keyof typeof CHIP_PROJECTS);\n }}\n data-testid=\"project-picker\"\n >\n {PROJECT_NAMES.map(([number, label]) => (\n \n ))}\n \n {\n setChip(value);\n }}\n data-testid=\"chip-picker\"\n >\n {state.controls.chips.map((chip) => (\n \n ))}\n \n \n
\n \n );\n const hdlPanel = (\n \n
HDL
\n
\n {state.controls.hasBuiltin && (\n \n )}\n
\n {selectors}\n \n }\n >\n {\n setHdl(source);\n compile.current(useBuiltin ? {} : { hdl: source });\n }}\n grammar={HDL.parser}\n language={\"hdl\"}\n disabled={useBuiltin}\n />\n \n );\n\n const chipButtons = (\n
\n \n \n Clock:{\"\\u00a0\"}\n \n \n \n Reset\n \n
\n );\n\n const visualizations: [string, ReactNode][] = makeVisualizationsWithId({\n parts: state.sim.chip,\n });\n\n const pinsPanel = (\n \n
\n Chip\n
\n {chipButtons}\n \n }\n >\n {state.sim.invalid ? (\n Invalid Chip\n ) : (\n <>\n \n {visualizations.length > 0 && (\n Visualizations} open={true}>\n
{visualizations.map(([_, v]) => v)}
\n
\n )}\n \n )}\n \n );\n\n const [selectedTestTab, doSetSelectedTestTab] = useState<\n \"tst\" | \"cmp\" | \"out\"\n >(\"tst\");\n\n const setSelectedTestTab = useCallback(\n (tab: typeof selectedTestTab) => {\n doSetSelectedTestTab(tab);\n tracking.trackEvent(\"tab\", \"change\", tab);\n },\n [tracking]\n );\n\n const testPanel = (\n \n
\n Test\n
\n
\n {runner.current && }\n
\n
\n \n
\n \n }\n >\n
\n \n \n
\n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n\n return (\n
\n {hdlPanel}\n {pinsPanel}\n {testPanel}\n
\n );\n};\n\nexport default Chip;\n"],"names":["ALUComponent","A","op","D","out","flag","_jsxs","children","_jsx","bin","COMMANDS","Flags","RegisterComponent","name","bits","dec","KeyMap","Enter","Backspace","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","Escape","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","Keyboard","keyboard","useState","showPicker","setShowPicker","busVoltage","setBits","setKey","useCallback","event","key","keypress","mapping","undefined","length","code","charCodeAt","keyPressToHackCharacter","preventDefault","changeKey","className","ref","e","focus","type","onKeyDown","onClick","Sizes","none","sm","md","lg","xl","full","Sides","t","r","l","b","tl","tr","bl","br","Widths","isSide","v","getSize","size","getSide","side","rounded","sized","reduce","prev","curr","borderRadius","width","amount","block","display","die","error","args","msg","Error","map","s","join","isDraft","value","DRAFT_STATE","isDraftable","proto","Object","getPrototypeOf","Ctor","hasOwnProperty","call","constructor","Function","toString","objectCtorString","Array","isArray","DRAFTABLE","_value$constructor","isMap","isSet","each","obj","iter","enumerableOnly","getArchtype","keys","ownKeys","forEach","entry","index","thing","state","type_","has","prop","prototype","get","set","propOrOldValue","delete","add","is","x","y","target","hasMap","Map","hasSet","Set","latest","copy_","base_","shallowCopy","base","slice","descriptors","getOwnPropertyDescriptors","i","desc","writable","configurable","enumerable","create","freeze","deep","isFrozen","clear","dontMutateFrozenCollections","getPlugin","pluginKey","plugin","plugins","getCurrentScope","currentScope","usePatchesInScope","scope","patchListener","patches_","inversePatches_","patchListener_","revokeScope","leaveScope","drafts_","revokeDraft","parent_","enterScope","immer","immer_","canAutoFreeze_","unfinalizedDrafts_","draft","revoke_","revoked_","processResult","result","baseDraft","isReplaced","useProxies_","willFinalizeES5_","modified_","finalize","maybeFreeze","generateReplacementPatches_","NOTHING","rootScope","path","childValue","finalizeProperty","scope_","finalized_","draft_","generatePatches_","parentState","targetObject","rootPath","res","assigned_","concat","autoFreeze_","peek","getDescriptorFromProto","source","getOwnPropertyDescriptor","markChanged","prepareCopy","createProxy","parent","proxyMap_","proxySet_","isManual_","traps","objectTraps","arrayTraps","Proxy","revocable","revoke","proxy","createES5Proxy_","push","current","currentImpl","copy","archType","hasChanges_","copyHelper","from","hasSymbol","Symbol","hasProxies","Reflect","for","iterator","getOwnPropertySymbols","getOwnPropertyNames","_desc$get","currentState","deleteProperty","owner","defineProperty","setPrototypeOf","fn","arguments","apply","this","Immer","config","recipe","defaultBase","self","_this","produce","_this2","hasError","Promise","then","p","ip","produceWithPatches","patches","inversePatches","n","nextState","useProxies","setUseProxies","autoFreeze","setAutoFreeze","createDraft","finishDraft","applyPatches","patch","applyPatchesImpl","applyPatches_","bind","useImmerReducer","reducers","initialState","useReducer","command","action","payload","useStateInitializer","init","setState","useEffect","Mode","props","mode","setMode","setValue","view","style","cursor","doSelect","select","doChange","onChange","edit","position","zIndex","left","marginTop","onBlur","onKeyPress","defaultValue","render","doScroll","scrollTop","totalHeight","toleranceHeight","bufferedItems","settings","itemHeight","minIndex","maxIndex","Math","floor","data","offset","limit","start","max","min","getData","topPaddingHeight","bottomPaddingHeight","viewportRef","useRef","useMemo","Number","MAX_SAFE_INTEGER","startIndex","count","tolerance","fillVirtualScrollSettings","startState","adapter","itemsAbove","viewportHeight","reducer","scrollReducer","dispatchScroll","row","initialScroll","div","rows","d","height","rowKey","overflowY","overflowAnchor","onScroll","MemoryBlock","memory","jmp","highlight","editable","format","range","MemoryCell","VirtualScroll","background","hex","flex","textAlign","InlineEdit","newValue","Memory","fmt","setFormat","setJmp","goto","setGoto","jumpTo","doUpdate","update","role","placeholder","FORMATS","option","checked","asm","doFormat","displayClock","Clock","Clockface","clockface","setClockface","subscription","$","subscribe","unsubscribe","useClockface","whiteSpace","WHITE","mem","pixel","color","Screen","frameFinished","canvas","draw","ctx","getContext","image","assertExists","getImageData","col","putImageData","drawImage","ctxRef","frame$","maxWidth","boxSizing","marginInline","margin","borderTop","borderLeft","borderBottom","borderRight","makeVisualization","chip","ALU","in","voltage","HIGH","VRegister","id","PC","KeyboardComponent","ScreenComponent","RAM","MemoryComponent","address","RAM8","CPU","decode","am","vis","parts","filter","reducePin","pin","reverse","reducePins","pins","entries","FullPinout","sim","inPins","outPins","internalPins","PinoutBlock","header","toggle","disabled","pending","colSpan","immPin","Pin","Runbar","runner","timer","dispatch","running","speed","steps","finishFrame","setSteps","setSpeed","actions","frame","stop","reset","makeTimerStore","dispatcher","useTimer","label","clock","Timer","now","Date","delta","done","tick","requestAnimationFrame","ErrorPanel","failed","open","message","shortMessage","UNKNOWN_PARSE_ERROR","Textarea","language","text","setText","Monaco","currentHighlight","theme","useContext","AppContext","monaco","useMonaco","editor","decorations","codeTheme","window","matchMedia","matches","doHighlight","model","getModel","getPositionAt","end","Range","fromPositions","nextDecoration","options","inlineClassName","revealRangeInCenter","deltaDecorations","makeHighlight","onMount","ed","updateOptions","fontFamily","fontSize","minimap","enabled","scrollBeyondLastLine","readOnly","succeeded","setModelMarkers","exec","groups","line","column","startLineNumber","endLineNumber","startColumn","endColumn","getLineContent","substring","match","severity","Editor","grammar","setError","parse","parsed","doParse","ms","clearTimeout","setTimeout","debounce","onChangeCB","canUse","wants","Panel","footer","Accordian","summary","PROJECT_NAMES","makeHdl","reduceChip","invalid","clocked","ins","outs","makeChipStore","fs","setStatus","storage","dropdowns","project","chips","CHIP_PROJECTS","chipName","findDropdowns","Low","test","ChipTest","usingBuiltin","setFiles","hdl","files","tst","cmp","updateChip","controls","includes","setProject","setChip","hasBuiltin","REGISTRY","testRunning","runningTest","testFinished","passed","trim","updateTestStep","log","currentStep","span","ChipProjects","loadChip","useBuiltin","updateFiles","compileChip","compileTest","remove","maybeParsed","HDL","isErr","Err","buildChip","Ok","maybeChip","replaceChip","nextChip","nextPin","eval","with","fsName","ext","all","readFile","catch","console","saveChip","prj","writeFile","isLow","doUseBuiltin","builtinName","getBuiltinChip","template","CHIPS","builtinCode","replace","initialize","file","TST","setFileSystem","runTest","pushd","run","popd","stepTest","assert","chipId","step","Chip","BaseContext","filePicker","tracking","useChipPageStore","setHdl","setTst","setCmp","trackPage","trackEvent","doEval","compile","loadTest","clockActions","setUseBuiltin","selectors","number","hdlPanel","tabIndex","chipButtons","visualizations","part","makeVisualizationsWithId","pinsPanel","selectedTestTab","doSetSelectedTestTab","setSelectedTestTab","tab","testPanel","CMP"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.7fd77d22.js b/static/js/main.f457f1b6.js similarity index 99% rename from static/js/main.7fd77d22.js rename to static/js/main.f457f1b6.js index 541e6a24..3d866b7b 100644 --- a/static/js/main.7fd77d22.js +++ b/static/js/main.f457f1b6.js @@ -1,3 +1,3 @@ -/*! For license information please see main.7fd77d22.js.LICENSE.txt */ -!function(){var e={8016:function(e,t,n){"use strict";n.d(t,{Il:function(){return f},bp:function(){return s}});var r=n(1026),a=n(6167),o=n(9956),i=n(2147),l=n(7685),u=n(7203);function c(){var e=!0,t=(0,a.useState)(e),n=(0,r.Z)(t,2),o=n[0],i=n[1],l=(0,a.useCallback)((function(e){i(!!e)}),[e]);return{canUse:e,wants:o,toggle:l}}function s(){arguments.length>0&&void 0!==arguments[0]||new o.Wd;var e=(0,a.useState)("system"),t=(0,r.Z)(e,2),n=t[0],s=t[1];return{monaco:c(),settings:(0,i.R)(),filePicker:(0,l.ss)(),tracking:(0,u.rS)(),theme:n,setTheme:s}}var f=(0,a.createContext)({monaco:{canUse:!0,wants:!0,toggle:function(){}},filePicker:{close:function(){},open:function(){},select:function(){return Promise.reject("")},isOpen:!1},settings:{close:function(){},open:function(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept:function(){},reject:function(){},trackEvent:function(){},trackPage:function(){}},theme:"system",setTheme:function(){}})},9622:function(e){e.exports={messages:{"Allow anonymous interaction tracking":"\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",Builtin:"\xdf\u0169\u0129\u013a\u0163\u0129\u0144",Chip:"\u0106\u0125\u0129\u01a5","Choose file":"\u0106\u0125\u014d\u014d\u015b\u0113 \u0192\u0129\u013a\u0113",Clock:"\u0106\u013a\u014d\u0107\u0137",Dark:"\u010e\xe0\u0155\u0137",Editor:"\u0112\u010f\u0129\u0163\u014d\u0155",English:"\u0112\u0144\u011d\u013a\u0129\u015b\u0125",Eval:"\u0112v\xe0\u013a",Failed:"\u0191\xe0\u0129\u013a\u0113\u010f",Files:"\u0191\u0129\u013a\u0113\u015b","Invalid Chip":"\u0128\u0144v\xe0\u013a\u0129\u010f \u0106\u0125\u0129\u01a5",Language:"\u0139\xe0\u0144\u011d\u0169\xe0\u011d\u0113",Light:"\u0139\u0129\u011d\u0125\u0163","Parse Error":"\u01a4\xe0\u0155\u015b\u0113 \u0112\u0155\u0155\u014d\u0155",Passed:"\u01a4\xe0\u015b\u015b\u0113\u010f",Project:"\u01a4\u0155\u014d\u0134\u0113\u0107\u0163",Pseudolocale:"\u01a4\u015b\u0113\u0169\u010f\u014d\u013a\u014d\u0107\xe0\u013a\u0113",References:"\u0154\u0113\u0192\u0113\u0155\u0113\u0144\u0107\u0113\u015b",Reset:"\u0154\u0113\u015b\u0113\u0163",Samples:"\u015a\xe0m\u01a5\u013a\u0113\u015b",Save:"\u015a\xe0v\u0113",Settings:"\u015a\u0113\u0163\u0163\u0129\u0144\u011d\u015b",System:"\u015a\u0177\u015b\u0163\u0113m",Test:"\u0162\u0113\u015b\u0163",Theme:"\u0162\u0125\u0113m\u0113",Tracking:"\u0162\u0155\xe0\u0107\u0137\u0129\u0144\u011d","Use Monaco Editor":"\u0168\u015b\u0113 M\u014d\u0144\xe0\u0107\u014d \u0112\u010f\u0129\u0163\u014d\u0155",Visualizations:"V\u0129\u015b\u0169\xe0\u013a\u0129\u017a\xe0\u0163\u0129\u014d\u0144\u015b","{0}":[["0"]]}}},9270:function(e){e.exports={messages:{"Allow anonymous interaction tracking":"Allow anonymous interaction tracking",Builtin:"Builtin",Chip:"Chip","Choose file":"Choose file",Clock:"Clock",Dark:"Dark",Editor:"Editor",English:"English",Eval:"Eval",Failed:"Failed",Files:"Files","Invalid Chip":"Invalid Chip",Language:"Language",Light:"Light","Parse Error":"Parse Error",Passed:"Passed",Project:"Project",Pseudolocale:"Pseudolocale",References:"References",Reset:"Reset",Samples:"Samples",Save:"Save",Settings:"Settings",System:"System",Test:"Test",Theme:"Theme",Tracking:"Tracking","Use Monaco Editor":"Use Monaco Editor",Visualizations:"Visualizations","{0}":[["0"]]}}},659:function(e,t,n){"use strict";n.d(t,{J:function(){return a}});var r=n(7878),a=function(e){var t=e.name;return(0,r.jsx)("span",{className:"material-symbols-outlined",children:t})}},2147:function(e,t,n){"use strict";n.d(t,{R:function(){return o}});var r=n(1026),a=n(6167);function o(){var e=(0,a.useState)(!1),t=(0,r.Z)(e,2),n=t[0],o=t[1];return{isOpen:n,open:function(){o(!0)},close:function(){o(!1)}}}},7685:function(e,t,n){"use strict";n.d(t,{GB:function(){return y},ss:function(){return m}});var r=n(1026),a=n(4649),o=n(189),i=n(1092),l=n(7791),u=n(8061),c=n(8698),s=n(6167),f=n(8016),d=n(659),p=n(2147),h=n(7878),v="file selected";function m(){var e=(0,p.R)(),t=(0,s.useRef)(),n=(0,s.useCallback)((0,l.Z)((0,i.Z)().mark((function n(){return(0,i.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return e.open(),n.abrupt("return",new Promise((function(e){t.current=e})));case 2:case"end":return n.stop()}}),n)}))),[e,t]);return(0,o.Z)((0,o.Z)({},e),{},(0,a.Z)({select:n},v,t))}var g=function(e){var t=e.onSelect,n=e.stats,r=e.highlighted,a=void 0!==r&&r;return(0,h.jsx)("div",{children:(0,h.jsxs)("button",{className:"flex row justify-start outline ".concat(a?"":"secondary"),style:{textAlign:"left"},onClick:t,children:[(0,h.jsx)(d.J,{name:n.isDirectory()?"folder":"draft"}),n.name]})})},y=function(){var e=(0,s.useContext)(c.r),t=e.fs,n=e.setStatus,a=(0,s.useContext)(f.Il).filePicker,o=(0,s.useState)([]),i=(0,r.Z)(o,2),l=i[0],d=i[1],p=(0,s.useState)(""),m=(0,r.Z)(p,2),y=m[0],b=m[1],w=t.cwd();(0,s.useEffect)((function(){t.scandir(t.cwd()).then((function(e){d(e)}))}),[t,w,d]);var k=(0,s.useCallback)((function(e){b(""),t.cd(e),t.scandir(t.cwd()).then((function(e){d(e)}))}),[t,b,d]),S=(0,s.useCallback)((function(e){b(e)}),[b]),x=(0,s.useCallback)((function(){var e,t;n("Selected ".concat(y)),a.close(),null===(e=(t=a[v]).current)||void 0===e||e.call(t,y)}),[y,a,n]);return(0,h.jsx)("dialog",{open:a.isOpen,children:(0,h.jsxs)("article",{style:{width:"350px"},children:[(0,h.jsxs)("header",{children:[(0,h.jsx)("p",{children:(0,h.jsx)(u.cC,{id:"Choose file"})}),(0,h.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:function(e){e.preventDefault(),a.close()},children:"close"})]}),(0,h.jsxs)("main",{children:[(0,h.jsx)("div",{children:(0,h.jsx)("b",{children:t.cwd()})}),"/"!==t.cwd()&&(0,h.jsx)(g,{stats:{isDirectory:function(){return!0},isFile:function(){return!1},name:".."},onSelect:function(){return k("..")}}),l.map((function(e){return(0,h.jsx)(g,{stats:e,highlighted:e.name===y,onSelect:function(){return e.isDirectory()?k(e.name):S(e.name)}},e.name)}))]}),(0,h.jsx)("footer",{children:(0,h.jsx)("button",{disabled:!y,onClick:x,children:"Select"})})]})})}},7203:function(e,t,n){"use strict";n.d(t,{Hy:function(){return v},LK:function(){return m},rS:function(){return h}});var r=n(1026),a=n(132),o=n(5541),i=n(6167),l=n(7878),u="/tracking/canTrack",c="yes",s=[c,"no"],f=!1;function d(e){a.ZP.send({hitType:"pageview",page:e})}function p(e,t,n,r){var i,l;if(!f){var u="string"===typeof e?{category:e,action:(0,o.kP)(t),label:n&&r?{label:n,value:r}:void 0}:e;a.ZP.event({category:u.category,action:u.action,nonInteraction:!u.interaction,label:null===(i=u.label)||void 0===i?void 0:i.label,value:null===(l=u.label)||void 0===l?void 0:l.value})}}function h(){var e,t=null!==(e=localStorage[u])&&void 0!==e?e:"",n=(0,i.useState)(t===c),o=(0,r.Z)(n,2),l=o[0],h=o[1],v=(0,i.useState)(s.includes(t)||"1"===navigator.doNotTrack),m=(0,r.Z)(v,2),g=m[0],y=m[1];return{canTrack:l,haveAsked:g,accept:(0,i.useCallback)((function(){localStorage[u]=c,h(!0),y(!0),function(){var e;a.ZP.initialize(null!==(e={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!==e?e:"G-0VTR5BJFQP"),a.ZP.send("pageview")}()}),[h,y]),reject:(0,i.useCallback)((function(){localStorage[u]="no",h(!1),y(!0),f=!0}),[h,y]),trackEvent:p,trackPage:d}}function v(){var e=h(),t=e.accept,n=e.reject,a=e.haveAsked,o=(0,i.useState)(!a),u=(0,r.Z)(o,2),c=u[0],s=u[1],f=(0,i.useCallback)((function(){s(!1)}),[s]),d=(0,i.useCallback)((function(){t(),f()}),[t,f]),p=(0,i.useCallback)((function(){n(),f()}),[n,f]);return(0,l.jsx)(l.Fragment,{children:c&&(0,l.jsxs)("div",{id:"trackingBanner",className:"flex row",children:[(0,l.jsx)("div",{className:"flex-1",children:(0,l.jsx)(m,{})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("a",{href:"#reject",role:"button",className:"reject",onClick:p,children:"Reject"}),(0,l.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:d,children:"Accept"}),(0,l.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:f,children:"\ud835\uddb7"})]})]})})}function m(){return(0,l.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,l.jsx)("a",{href:"www.google.com/policies/privacy/partners/",children:"How Google uses data."})]})}},7536:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(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 o(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?e.apply(this,a):function(){for(var e=arguments.length,r=new Array(e),o=0;o1&&void 0!==arguments[1]?arguments[1]:{};m.initial(e),m.handler(t);var n={current:e},r=d(b)(n,t),a=d(y)(n),o=d(m.changes)(e),i=d(g)(n);function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e};return m.selector(e),e(n.current)}function u(e){f(r,a,o,i)(e)}return[l,u]}},k=w,S={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};var x=function(e){return function t(){for(var n=this,r=arguments.length,a=new Array(r),o=0;o=e.length?e.apply(this,a):function(){for(var e=arguments.length,r=new Array(e),o=0;o2&&void 0!==arguments[2])||arguments[2],r=(0,H.useRef)(!0);(0,H.useEffect)(r.current||!n?function(){r.current=!1}:e,t)};function ie(){}function le(e,t,n,r){return function(e,t){return e.editor.getModel(ue(e,t))}(e,r)||function(e,t,n,r){return e.editor.createModel(t,n,r&&ue(e,r))}(e,t,n,r)}function ue(e,t){return e.Uri.parse(t)}function ce(e){var t=e.original,n=e.modified,r=e.language,a=e.originalLanguage,o=e.modifiedLanguage,i=e.originalModelPath,l=e.modifiedModelPath,u=e.keepCurrentOriginalModel,c=e.keepCurrentModifiedModel,s=e.theme,f=e.loading,d=e.options,p=e.height,h=e.width,v=e.className,m=e.wrapperProps,g=e.beforeMount,y=e.onMount,b=(0,H.useState)(!1),w=(0,q.Z)(b,2),k=w[0],S=w[1],x=(0,H.useState)(!0),_=(0,q.Z)(x,2),E=_[0],C=_[1],O=(0,H.useRef)(null),P=(0,H.useRef)(null),j=(0,H.useRef)(null),T=(0,H.useRef)(y),L=(0,H.useRef)(g);ae((function(){var e=W.init();return e.then((function(e){return(P.current=e)&&C(!1)})).catch((function(e){return"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e)})),function(){return O.current?function(){var e,t,n=O.current.getModel();u||null===(e=n.original)||void 0===e||e.dispose();c||null===(t=n.modified)||void 0===t||t.dispose();O.current.dispose()}():e.cancel()}})),oe((function(){var e=O.current.getModifiedEditor();e.getOption(P.current.editor.EditorOption.readOnly)?e.setValue(n):n!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),e.pushUndoStop())}),[n],k),oe((function(){O.current.getModel().original.setValue(t)}),[t],k),oe((function(){var e=O.current.getModel(),t=e.original,n=e.modified;P.current.editor.setModelLanguage(t,a||r),P.current.editor.setModelLanguage(n,o||r)}),[r,a,o],k),oe((function(){P.current.editor.setTheme(s)}),[s],k),oe((function(){O.current.updateOptions(d)}),[d],k);var N=(0,H.useCallback)((function(){L.current(P.current);var e=le(P.current,t,a||r,i),u=le(P.current,n,o||r,l);O.current.setModel({original:e,modified:u})}),[r,n,o,t,a,i,l]),A=(0,H.useCallback)((function(){O.current=P.current.editor.createDiffEditor(j.current,(0,Q.Z)({automaticLayout:!0},d)),N(),P.current.editor.setTheme(s),S(!0)}),[d,s,N]);return(0,H.useEffect)((function(){k&&T.current(O.current,P.current)}),[k]),(0,H.useEffect)((function(){!E&&!k&&A()}),[E,k,A]),H.createElement(re,{width:h,height:p,isEditorReady:k,loading:f,_ref:j,className:v,wrapperProps:m})}ce.propTypes={original:K().string,modified:K().string,language:K().string,originalLanguage:K().string,modifiedLanguage:K().string,originalModelPath:K().string,modifiedModelPath:K().string,keepCurrentOriginalModel:K().bool,keepCurrentModifiedModel:K().bool,theme:K().string,loading:K().oneOfType([K().element,K().string]),options:K().object,width:K().oneOfType([K().number,K().string]),height:K().oneOfType([K().number,K().string]),className:K().string,wrapperProps:K().object,beforeMount:K().func,onMount:K().func},ce.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:ie,onMount:ie};var se=function(){var e=(0,H.useState)(W.__getMonacoInstance()),t=(0,q.Z)(e,2),n=t[0],r=t[1];return ae((function(){var e;return n||(e=W.init()).then((function(e){r(e)})),function(){var t;return null===(t=e)||void 0===t?void 0:t.cancel()}})),n};var fe=function(e){var t=(0,H.useRef)();return(0,H.useEffect)((function(){t.current=e}),[e]),t.current},de=new Map;function pe(e){var t=e.defaultValue,n=e.defaultLanguage,r=e.defaultPath,a=e.value,o=e.language,i=e.path,l=e.theme,u=e.line,c=e.loading,s=e.options,f=e.overrideServices,d=e.saveViewState,p=e.keepCurrentModel,h=e.width,v=e.height,m=e.className,g=e.wrapperProps,y=e.beforeMount,b=e.onMount,w=e.onChange,k=e.onValidate,S=(0,H.useState)(!1),x=(0,q.Z)(S,2),_=x[0],E=x[1],C=(0,H.useState)(!0),O=(0,q.Z)(C,2),P=O[0],j=O[1],T=(0,H.useRef)(null),L=(0,H.useRef)(null),N=(0,H.useRef)(null),A=(0,H.useRef)(b),R=(0,H.useRef)(y),M=(0,H.useRef)(null),D=(0,H.useRef)(a),z=fe(i),F=(0,H.useRef)(!1);ae((function(){var e=W.init();return e.then((function(e){return(T.current=e)&&j(!1)})).catch((function(e){return"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e)})),function(){return L.current?function(){var e,t;null===(e=M.current)||void 0===e||e.dispose(),p?d&&de.set(i,L.current.saveViewState()):null===(t=L.current.getModel())||void 0===t||t.dispose();L.current.dispose()}():e.cancel()}})),oe((function(){var e=le(T.current,t||a,n||o,i);e!==L.current.getModel()&&(d&&de.set(z,L.current.saveViewState()),L.current.setModel(e),d&&L.current.restoreViewState(de.get(i)))}),[i],_),oe((function(){L.current.updateOptions(s)}),[s],_),oe((function(){L.current.getOption(T.current.editor.EditorOption.readOnly)?L.current.setValue(a):a!==L.current.getValue()&&(L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),L.current.pushUndoStop())}),[a],_),oe((function(){T.current.editor.setModelLanguage(L.current.getModel(),o)}),[o],_),oe((function(){void 0!==u&&L.current.revealLine(u)}),[u],_),oe((function(){T.current.editor.setTheme(l)}),[l],_);var I=(0,H.useCallback)((function(){if(!F.current){R.current(T.current);var e=i||r,u=le(T.current,a||t,n||o,e);L.current=T.current.editor.create(N.current,(0,Q.Z)({model:u,automaticLayout:!0},s),f),d&&L.current.restoreViewState(de.get(e)),T.current.editor.setTheme(l),E(!0),F.current=!0}}),[t,n,r,a,o,i,s,f,d,l]);return(0,H.useEffect)((function(){_&&A.current(L.current,T.current)}),[_]),(0,H.useEffect)((function(){!P&&!_&&I()}),[P,_,I]),D.current=a,(0,H.useEffect)((function(){var e,t;_&&w&&(null===(e=M.current)||void 0===e||e.dispose(),M.current=null===(t=L.current)||void 0===t?void 0:t.onDidChangeModelContent((function(e){w(L.current.getValue(),e)})))}),[_,w]),(0,H.useEffect)((function(){if(_){var e=T.current.editor.onDidChangeMarkers((function(e){var t,n=null===(t=L.current.getModel())||void 0===t?void 0:t.uri;if(n&&e.find((function(e){return e.path===n.path}))){var r=T.current.editor.getModelMarkers({resource:n});null===k||void 0===k||k(r)}}));return function(){null===e||void 0===e||e.dispose()}}}),[_,k]),H.createElement(re,{width:h,height:v,isEditorReady:_,loading:c,_ref:N,className:m,wrapperProps:g})}pe.propTypes={defaultValue:K().string,defaultPath:K().string,defaultLanguage:K().string,value:K().string,language:K().string,path:K().string,theme:K().string,line:K().number,loading:K().oneOfType([K().element,K().string]),options:K().object,overrideServices:K().object,saveViewState:K().bool,keepCurrentModel:K().bool,width:K().oneOfType([K().number,K().string]),height:K().oneOfType([K().number,K().string]),className:K().string,wrapperProps:K().object,beforeMount:K().func,onMount:K().func,onChange:K().func,onValidate:K().func},pe.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:ie,onMount:ie,onValidate:ie};var he=pe,ve=(0,H.memo)(he)},5290:function(e){"use strict";function t(e,n,r,a){this.message=e,this.expected=n,this.found=r,this.location=a,this.name="SyntaxError","function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(t,Error),t.buildMessage=function(e,t){var n={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t,n="";for(t=0;t0){for(t=1,r=1;tpe&&(pe=fe,he=[]),he.push(e))}function Se(e,n,r){return new t(t.buildMessage(e,n),e,n,r)}function xe(){var e,t;for(e=[],t=_e();t!==a;)e.push(t),t=_e();return e}function _e(){var t,r,o;if(t=function(){var t,n,r,o;t=fe,123===e.charCodeAt(fe)?(n=s,fe++):(n=a,0===ve&&ke(f));n!==a&&Me()!==a&&(r=Ee())!==a&&Me()!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===ve&&ke(p)),o!==a?(t,t=n={type:"argument",arg:r}):(fe=t,t=a)):(fe=t,t=a);return t}(),t===a&&(t=function(){var t,r,o,i,l,u,c,y,b,w;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));if(r!==a)if(Me()!==a)if((o=Ee())!==a)if(Me()!==a)if(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a)if(Me()!==a)if(l=fe,e.substr(fe,6)===m?(u=m,fe+=6):(u=a,0===ve&&ke(g)),u!==a&&(l,x=u,n.strict&&De.unshift(!1),u=x),(l=u)!==a)if((u=Me())!==a)if(44===e.charCodeAt(fe)?(c=h,fe++):(c=a,0===ve&&ke(v)),c!==a)if(Me()!==a){if(y=[],(b=Ce())!==a)for(;b!==a;)y.push(b),b=Ce();else y=a;y!==a&&(b=Me())!==a?(125===e.charCodeAt(fe)?(w=d,fe++):(w=a,0===ve&&ke(p)),w!==a?(t,k=o,S=y,n.strict&&De.shift(),t=r={type:"select",arg:k,cases:S}):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;var k,S;var x;return t}(),t===a&&(t=function(){var t,r,o,i,l,u,c,m,g,S,x;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));if(r!==a)if(Me()!==a)if((o=Ee())!==a)if(Me()!==a)if(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a)if(Me()!==a)if(l=fe,e.substr(fe,6)===y?(u=y,fe+=6):(u=a,0===ve&&ke(b)),u===a&&(e.substr(fe,13)===w?(u=w,fe+=13):(u=a,0===ve&&ke(k))),u!==a&&(l,_=u,De.unshift(!0),u=_),(l=u)!==a)if((u=Me())!==a)if(44===e.charCodeAt(fe)?(c=h,fe++):(c=a,0===ve&&ke(v)),c!==a)if(Me()!==a)if(m=function(){var t,n,r,o,i;ve++,t=fe,n=Me(),n!==a?(e.substr(fe,6)===O?(r=O,fe+=6):(r=a,0===ve&&ke(P)),r!==a&&Me()!==a?(58===e.charCodeAt(fe)?(o=":",fe++):(o=a,0===ve&&ke(j)),o!==a&&Me()!==a&&(i=Re())!==a&&Me()!==a?(t,t=n=i):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a);ve--,t===a&&(n=a,0===ve&&ke(C));return t}(),m===a&&(m=null),m!==a){if(g=[],(S=Oe())!==a)for(;S!==a;)g.push(S),S=Oe();else g=a;g!==a&&(S=Me())!==a?(125===e.charCodeAt(fe)?(x=d,fe++):(x=a,0===ve&&ke(p)),x!==a?(t,t=r=function(e,t,r,a){var o=("selectordinal"===t?n.ordinal:n.cardinal)||["zero","one","two","few","many","other"];return o&&o.length&&a.forEach((function(n){if(isNaN(n.key)&&o.indexOf(n.key)<0)throw new Error("Invalid key `"+n.key+"` for argument `"+e+"`. Valid "+t+" keys for this locale are `"+o.join("`, `")+"`, and explicit keys like `=0`.")})),De.shift(),{type:t,arg:e,offset:r||0,cases:a}}(o,l,m,g)):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;var _;return t}(),t===a&&(t=function(){var t,r,o,i,l,u,c;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));r!==a&&Me()!==a&&(o=Ee())!==a&&Me()!==a?(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a&&Me()!==a?(l=function(){var t,r,o,i,l;e.substr(fe,6)===L?(t=L,fe+=6):(t=a,0===ve&&ke(N));t===a&&(e.substr(fe,4)===A?(t=A,fe+=4):(t=a,0===ve&&ke(R)),t===a&&(e.substr(fe,4)===M?(t=M,fe+=4):(t=a,0===ve&&ke(D)),t===a&&(e.substr(fe,8)===z?(t=z,fe+=8):(t=a,0===ve&&ke(F)),t===a&&(e.substr(fe,7)===I?(t=I,fe+=7):(t=a,0===ve&&ke(Z)),t===a&&(e.substr(fe,8)===U?(t=U,fe+=8):(t=a,0===ve&&ke(B)),t===a&&(t=fe,r=fe,ve++,e.substr(fe,6)===m?(o=m,fe+=6):(o=a,0===ve&&ke(g)),ve--,o===a?r=void 0:(fe=r,r=a),r!==a?(o=fe,ve++,e.substr(fe,6)===y?(i=y,fe+=6):(i=a,0===ve&&ke(b)),ve--,i===a?o=void 0:(fe=o,o=a),o!==a?(i=fe,ve++,e.substr(fe,13)===w?(l=w,fe+=13):(l=a,0===ve&&ke(k)),ve--,l===a?i=void 0:(fe=i,i=a),i!==a&&(l=Ee())!==a?(fe,(function(e){if(n.strict||/^\d/.test(e))return!1;switch(e.toLowerCase()){case"select":case"plural":case"selectordinal":return!1;default:return!0}}(l)?void 0:a)!==a?(t,t=r=l):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)))))));return t}(),l!==a&&Me()!==a?(u=function(){var t,r,o,i,l;if(t=fe,r=Me(),r!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===ve&&ke(v)),o!==a){for(i=[],l=_e();l!==a;)i.push(l),l=_e();i!==a?(fe,(l=(l=!n.strict)?void 0:a)!==a?(t,t=r={tokens:i}):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;if(t===a)if(t=fe,(r=Me())!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===ve&&ke(v)),o!==a){for(i=[],l=je();l!==a;)i.push(l),l=je();i!==a?(t,t=r={tokens:[i.join("")]}):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;return t}(),u===a&&(u=null),u!==a?(125===e.charCodeAt(fe)?(c=d,fe++):(c=a,0===ve&&ke(p)),c!==a?(t,t=r={type:"function",arg:o,key:l,param:u}):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a);return t}(),t===a&&(t=fe,35===e.charCodeAt(fe)?(r="#",fe++):(r=a,0===ve&&ke(l)),r!==a?(fe,(o=(o=u())?void 0:a)!==a?(t,t=r={type:"octothorpe"}):(fe=t,t=a)):(fe=t,t=a),t===a))))){if(t=fe,r=[],(o=Ae())!==a)for(;o!==a;)r.push(o),o=Ae();else r=a;r!==a&&(t,r=c(r)),t=r}return t}function Ee(){var t,n,r;if(ve++,t=fe,n=[],x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(_)),r!==a)for(;r!==a;)n.push(r),x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(_));else n=a;return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(S)),t}function Ce(){var e,t,n;return e=fe,Me()!==a&&(t=Ee())!==a&&Me()!==a&&(n=Pe())!==a?(e,e=E(t,n)):(fe=e,e=a),e}function Oe(){var t,n,r;return t=fe,Me()!==a?(n=function(){var t,n,r;t=Ee(),t===a&&(t=fe,61===e.charCodeAt(fe)?(n="=",fe++):(n=a,0===ve&&ke(T)),n!==a&&(r=Re())!==a?(t,t=n=r):(fe=t,t=a));return t}(),n!==a&&Me()!==a&&(r=Pe())!==a?(t,t=E(n,r)):(fe=t,t=a)):(fe=t,t=a),t}function Pe(){var t,n,r,o,i,l;if(t=fe,123===e.charCodeAt(fe)?(n=s,fe++):(n=a,0===ve&&ke(f)),n!==a)if(r=fe,(o=Me())!==a?(i=fe,ve++,123===e.charCodeAt(fe)?(l=s,fe++):(l=a,0===ve&&ke(f)),ve--,l!==a?(fe=i,i=void 0):i=a,i!==a?r=o=[o,i]:(fe=r,r=a)):(fe=r,r=a),r===a&&(r=null),r!==a){for(o=[],i=_e();i!==a;)o.push(i),i=_e();o!==a&&(i=Me())!==a?(125===e.charCodeAt(fe)?(l=d,fe++):(l=a,0===ve&&ke(p)),l!==a?(t,t=n=o):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;return t}function je(){var t,n,r,o;if(ve++,t=fe,n=[],$.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(W)),r!==a)for(;r!==a;)n.push(r),$.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(W));else n=a;if(n!==a&&(t,n=n.join("")),(t=n)===a&&(t=Te())===a&&(t=fe,39===e.charCodeAt(fe)?(n=H,fe++):(n=a,0===ve&&ke(Q)),n!==a&&(r=Le())!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&ke(Q)),o!==a?(t,t=n=r):(fe=t,t=a)):(fe=t,t=a),t===a))if(t=fe,123===e.charCodeAt(fe)?(n=s,fe++):(n=a,0===ve&&ke(f)),n!==a){for(r=[],o=je();o!==a;)r.push(o),o=je();r!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===ve&&ke(p)),o!==a?(t,n=function(e){return"{"+e.join("")+"}"}(r),t=n):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;return ve--,t===a&&(n=a,0===ve&&ke(V)),t}function Te(){var t,n;return ve++,t=fe,"''"===e.substr(fe,2)?(n="''",fe+=2):(n=a,0===ve&&ke(G)),n!==a&&(t,n="'"),ve--,(t=n)===a&&(n=a,0===ve&&ke(q)),t}function Le(){var t,n,r;if((t=Te())===a){if(t=fe,n=[],K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(Y)),r!==a)for(;r!==a;)n.push(r),K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(Y));else n=a;n!==a&&(t,n=c(n)),t=n}return t}function Ne(){var t,n,r,o,i,l;if(ve++,t=function(){var t,n,r,o;if(t=fe,"'{"===e.substr(fe,2)?(n="'{",fe+=2):(n=a,0===ve&&ke(X)),n!==a){for(r=[],o=Le();o!==a;)r.push(o),o=Le();r!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&ke(Q)),o!==a?(t,t=n="{"+r.join("")):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;if(t===a)if(t=fe,"'}"===e.substr(fe,2)?(n="'}",fe+=2):(n=a,0===ve&&ke(J)),n!==a){for(r=[],o=Le();o!==a;)r.push(o),o=Le();r!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&ke(Q)),o!==a?(t,t=n="}"+r.join("")):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;return t}(),t===a){if(t=fe,n=fe,r=fe,"'#"===e.substr(fe,2)?(o="'#",fe+=2):(o=a,0===ve&&ke(te)),o!==a){for(i=[],l=Le();l!==a;)i.push(l),l=Le();i!==a?(39===e.charCodeAt(fe)?(l=H,fe++):(l=a,0===ve&&ke(Q)),l!==a?(r,r=o="#"+i.join("")):(fe=r,r=a)):(fe=r,r=a)}else fe=r,r=a;r!==a?(fe,(o=(o=u())?void 0:a)!==a?n=r=[r,o]:(fe=n,n=a)):(fe=n,n=a),n!==a&&(t,n=n[0]),(t=n)===a&&(39===e.charCodeAt(fe)?(t=H,fe++):(t=a,0===ve&&ke(Q)))}return ve--,t===a&&(n=a,0===ve&&ke(ee)),t}function Ae(){var t,n;return(t=Te())===a&&(t=Ne())===a&&(t=fe,35===e.charCodeAt(fe)?(n="#",fe++):(n=a,0===ve&&ke(l)),n!==a?(fe,(!De[0]?void 0:a)!==a?(t,t=n):(fe=t,t=a)):(fe=t,t=a),t===a&&(t=function(){var t;return ve++,re.test(e.charAt(fe))?(t=e.charAt(fe),fe++):(t=a,0===ve&&ke(ae)),ve--,t===a&&0===ve&&ke(ne),t}())),t}function Re(){var t,n,r;if(ve++,t=fe,n=[],ie.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(le)),r!==a)for(;r!==a;)n.push(r),ie.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(le));else n=a;return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(oe)),t}function Me(){var t,n,r;for(ve++,t=fe,n=[],ce.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(se));r!==a;)n.push(r),ce.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(se));return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(ue)),t}var De=[!1];if((r=i())!==a&&fe===e.length)return r;throw r!==a&&fe