@rohal12/spindle 0.16.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +2 -2
- package/src/action-registry.ts +2 -1
- package/src/components/Passage.tsx +69 -4
- package/src/components/PassageDialog.tsx +69 -0
- package/src/components/StoryInterface.tsx +2 -2
- package/src/components/macros/Button.tsx +33 -46
- package/src/components/macros/Checkbox.tsx +32 -35
- package/src/components/macros/Computed.tsx +49 -54
- package/src/components/macros/Cycle.tsx +43 -53
- package/src/components/macros/Dialog.tsx +40 -0
- package/src/components/macros/Do.tsx +15 -21
- package/src/components/macros/For.tsx +57 -75
- package/src/components/macros/Goto.tsx +18 -22
- package/src/components/macros/If.tsx +39 -53
- package/src/components/macros/Include.tsx +30 -46
- package/src/components/macros/Listbox.tsx +38 -48
- package/src/components/macros/MacroError.tsx +18 -0
- package/src/components/macros/MacroLink.tsx +38 -53
- package/src/components/macros/MenubarButtons.tsx +158 -0
- package/src/components/macros/Meter.tsx +35 -52
- package/src/components/macros/Numberbox.tsx +30 -47
- package/src/components/macros/PassageDisplay.tsx +37 -30
- package/src/components/macros/Print.tsx +19 -36
- package/src/components/macros/Radiobutton.tsx +33 -38
- package/src/components/macros/Repeat.tsx +49 -54
- package/src/components/macros/SaveManager.tsx +400 -0
- package/src/components/macros/Set.tsx +19 -24
- package/src/components/{SettingsDialog.tsx → macros/SettingsControls.tsx} +18 -36
- package/src/components/macros/Span.tsx +8 -0
- package/src/components/macros/Stop.tsx +11 -12
- package/src/components/macros/StoryTitle.tsx +16 -16
- package/src/components/macros/Switch.tsx +41 -59
- package/src/components/macros/Textarea.tsx +26 -45
- package/src/components/macros/Textbox.tsx +27 -44
- package/src/components/macros/Timed.tsx +54 -55
- package/src/components/macros/Type.tsx +61 -62
- package/src/components/macros/Unset.tsx +21 -22
- package/src/components/macros/Widget.tsx +11 -15
- package/src/components/macros/option-utils.ts +13 -0
- package/src/define-macro.ts +154 -0
- package/src/expression.ts +10 -8
- package/src/index.tsx +7 -0
- package/src/macros/register-builtins.ts +5 -7
- package/src/markup/ast.ts +11 -16
- package/src/markup/render.tsx +0 -13
- package/src/saves/save-manager.ts +43 -0
- package/src/saves/types.ts +9 -2
- package/src/store.ts +283 -52
- package/src/story-api.ts +33 -12
- package/src/styles.css +37 -68
- package/src/components/PassageLink.tsx +0 -49
- package/src/components/SaveLoadDialog.tsx +0 -408
- package/src/components/macros/Back.tsx +0 -32
- package/src/components/macros/Forward.tsx +0 -34
- package/src/components/macros/QuickLoad.tsx +0 -42
- package/src/components/macros/QuickSave.tsx +0 -30
- package/src/components/macros/Restart.tsx +0 -35
- package/src/components/macros/Saves.tsx +0 -24
- package/src/components/macros/SettingsButton.tsx +0 -28
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.2.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type===\"childList\")for(const a of o.addedNodes)a.tagName===\"LINK\"&&a.rel===\"modulepreload\"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?o.credentials=\"include\":i.crossOrigin===\"anonymous\"?o.credentials=\"omit\":o.credentials=\"same-origin\",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var bt,R,Ii,Ue,Sr,Ei,Ai,Pi,Jn,wn,Cn,$i,Mt={},Vt=[],ya=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,vt=Array.isArray;function Ie(e,t){for(var n in t)e[n]=t[n];return e}function Xn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function be(e,t,n){var r,i,o,a={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?bt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return ft(e,a,r,i,null)}function ft(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ii,__i:-1,__u:0};return i==null&&R.vnode!=null&&R.vnode(o),o}function ba(){return{current:null}}function K(e){return e.children}function Ee(e,t){this.props=e,this.context=t}function Ze(e,t){if(t==null)return e.__?Ze(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?Ze(e):null}function va(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=Ie({},t);o.__v=t.__v+1,R.vnode&&R.vnode(o),er(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ze(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,zi(r,o,i),t.__e=t.__=null,o.__e!=n&&Ti(o)}}function Ti(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ti(e)}function In(e){(!e.__d&&(e.__d=!0)&&Ue.push(e)&&!Bt.__r++||Sr!=R.debounceRendering)&&((Sr=R.debounceRendering)||Ei)(Bt)}function Bt(){for(var e,t=1;Ue.length;)Ue.length>t&&Ue.sort(Ai),e=Ue.shift(),t=Ue.length,va(e);Bt.__r=0}function Di(e,t,n,r,i,o,a,s,u,l,h){var c,d,f,g,k,I,b,x=r&&r.__k||Vt,w=t.length;for(u=xa(n,t,x,u,w),c=0;c<w;c++)(f=n.__k[c])!=null&&(d=f.__i!=-1&&x[f.__i]||Mt,f.__i=c,I=er(e,f,d,i,o,a,s,u,l,h),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&tr(d.ref,null,f),h.push(f.ref,f.__c||g,f)),k==null&&g!=null&&(k=g),(b=!!(4&f.__u))||d.__k===f.__k?u=Fi(f,u,e,b):typeof f.type==\"function\"&&I!==void 0?u=I:g&&(u=g.nextSibling),f.__u&=-7);return n.__e=k,u}function xa(e,t,n,r,i){var o,a,s,u,l,h=n.length,c=h,d=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!=\"boolean\"&&typeof a!=\"function\"?(typeof a==\"string\"||typeof a==\"number\"||typeof a==\"bigint\"||a.constructor==String?a=e.__k[o]=ft(null,a,null,null,null):vt(a)?a=e.__k[o]=ft(K,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=ft(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,u=o+d,a.__=e,a.__b=e.__b+1,s=null,(l=a.__i=ka(a,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>h?d--:i<h&&d++),typeof a.type!=\"function\"&&(a.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,a.__u|=4))):e.__k[o]=null;if(c)for(o=0;o<h;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=Ze(s)),Ri(s,s));return r}function Fi(e,t,n,r){var i,o;if(typeof e.type==\"function\"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=Fi(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ze(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Fe(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(vt(e)?e.some(function(n){Fe(n,t)}):t.push(e)),t}function ka(e,t,n,r){var i,o,a,s=e.key,u=e.type,l=t[n],h=l!=null&&(2&l.__u)==0;if(l===null&&s==null||h&&s==l.key&&u==l.type)return n;if(r>(h?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((l=t[a=i>=0?i--:o++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return a}return-1}function wr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ya.test(t)?n:n+\"px\"}function Ct(e,t,n,r,i){var o,a;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||wr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||wr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(Pi,\"$1\")),a=t.toLowerCase(),t=a in e||t==\"onFocusOut\"||t==\"onFocusIn\"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=Jn,e.addEventListener(t,o?Cn:wn,o)):e.removeEventListener(t,o?Cn:wn,o);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Cr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Jn++;else if(t.t<n.u)return;return n(R.event?R.event(t):t)}}}function er(e,t,n,r,i,o,a,s,u,l){var h,c,d,f,g,k,I,b,x,w,F,A,v,O,z,V=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),o=[s=t.__e=n.__e]),(h=R.__b)&&h(t);e:if(typeof V==\"function\")try{if(b=t.props,x=\"prototype\"in V&&V.prototype.render,w=(h=V.contextType)&&r[h.__c],F=h?w?w.props.value:h.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(x?t.__c=c=new V(b,F):(t.__c=c=new Ee(b,F),c.constructor=V,c.render=wa),w&&w.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),x&&c.__s==null&&(c.__s=c.state),x&&V.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ie({},c.__s)),Ie(c.__s,V.getDerivedStateFromProps(b,c.__s))),f=c.props,g=c.state,c.__v=t,d)x&&V.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&V.getDerivedStateFromProps==null&&b!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,F),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,F)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),Vt.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&a.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,F),x&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,g,k)})}if(c.context=F,c.props=b,c.__P=e,c.__e=!1,A=R.__r,v=0,x)c.state=c.__s,c.__d=!1,A&&A(t),h=c.render(c.props,c.state,c.context),Vt.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,A&&A(t),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++v<25);c.state=c.__s,c.getChildContext!=null&&(r=Ie(Ie({},r),c.getChildContext())),x&&!d&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(f,g)),O=h!=null&&h.type===K&&h.key==null?Oi(h.props.children):h,s=Di(e,vt(O)?O:[O],t,n,r,i,o,a,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&a.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||o!=null)if(y.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(z=o.length;z--;)Xn(o[z]);En(t)}else t.__e=n.__e,t.__k=n.__k,y.then||En(t);R.__e(y,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Sa(n.__e,t,n,r,i,o,a,u,l);return(h=R.diffed)&&h(t),128&t.__u?void 0:s}function En(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(En))}function zi(e,t,n){for(var r=0;r<n.length;r++)tr(n[r],n[++r],n[++r]);R.__c&&R.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){R.__e(o,i.__v)}})}function Oi(e){return typeof e!=\"object\"||e==null||e.__b>0?e:vt(e)?e.map(Oi):Ie({},e)}function Sa(e,t,n,r,i,o,a,s,u){var l,h,c,d,f,g,k,I=n.props||Mt,b=t.props,x=t.type;if(x==\"svg\"?i=\"http://www.w3.org/2000/svg\":x==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),o!=null){for(l=0;l<o.length;l++)if((f=o[l])&&\"setAttribute\"in f==!!x&&(x?f.localName==x:f.nodeType==3)){e=f,o[l]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),s&&(R.__m&&R.__m(t,o),s=!1),o=null}if(x==null)I===b||s&&e.data==b||(e.data=b);else{if(o=o&&bt.call(e.childNodes),!s&&o!=null)for(I={},l=0;l<e.attributes.length;l++)I[(f=e.attributes[l]).name]=f.value;for(l in I)f=I[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||Ct(e,l,null,f,i);for(l in b)f=b[l],l==\"children\"?d=f:l==\"dangerouslySetInnerHTML\"?h=f:l==\"value\"?g=f:l==\"checked\"?k=f:s&&typeof f!=\"function\"||I[l]===f||Ct(e,l,f,I[l],i);if(h)s||c&&(h.__html==c.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Di(t.type==\"template\"?e.content:e,vt(d)?d:[d],t,n,r,x==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,o,a,o?o[0]:n.__k&&Ze(n,0),s,u),o!=null)for(l=o.length;l--;)Xn(o[l]);s||(l=\"value\",x==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[l]||x==\"progress\"&&!g||x==\"option\"&&g!=I[l])&&Ct(e,l,g,I[l],i),l=\"checked\",k!=null&&k!=e[l]&&Ct(e,l,k,I[l],i))}return e}function tr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){R.__e(i,n)}}function Ri(e,t,n){var r,i;if(R.unmount&&R.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||tr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){R.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ri(r[i],t,n||typeof e.type!=\"function\");n||Xn(e.__e),e.__c=e.__=e.__e=void 0}function wa(e,t,n){return this.constructor(e,n)}function Je(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),R.__&&R.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],a=[],er(t,e=(!r&&n||t).__k=be(K,null,[e]),i||Mt,Mt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?bt.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),zi(o,e,a)}function Ni(e,t){Je(e,t,Ni)}function Ca(e,t,n){var r,i,o,a,s=Ie({},e.props);for(o in e.type&&e.type.defaultProps&&(a=e.type.defaultProps),t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:s[o]=t[o]===void 0&&a!=null?a[o]:t[o];return arguments.length>2&&(s.children=arguments.length>3?bt.call(arguments,2):n),ft(e.type,s,r||e.key,i||e.ref,null)}function Jt(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&r.forEach(function(a){a.__e=!0,In(a)})},this.sub=function(o){r.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){r&&r.delete(o),a&&a.call(o)}}),n.children}return t.__c=\"__cC\"+$i++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}bt=Vt.slice,R={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Ii=0,Ee.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ie({},this.state),typeof e==\"function\"&&(e=e(Ie({},n),this.props)),e&&Ie(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),In(this))},Ee.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),In(this))},Ee.prototype.render=K,Ue=[],Ei=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ai=function(e,t){return e.__v.__b-t.__v.__b},Bt.__r=0,Pi=/(PointerCapture)$|Capture$/i,Jn=0,wn=Cr(!1),Cn=Cr(!0),$i=0;var Ia=0;function _(e,t,n,r,i,o){t||(t={});var a,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?a=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ia,__i:-1,__u:0,__source:i,__self:o};if(typeof e==\"function\"&&(a=e.defaultProps))for(s in a)u[s]===void 0&&(u[s]=a[s]);return R.vnode&&R.vnode(l),l}var Ne,Q,mn,Ir,Xe=0,Li=[],G=R,Er=G.__b,Ar=G.__r,Pr=G.diffed,$r=G.__c,Tr=G.unmount,Dr=G.__;function nt(e,t){G.__h&&G.__h(Q,e,Xe||t),Xe=0;var n=Q.__H||(Q.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return Xe=1,nr(Hi,e)}function nr(e,t,n){var r=nt(Ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Hi(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=Q,!Q.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return d.__c});if(h.every(function(d){return!d.__N}))return!o||o.call(this,s,u,l);var c=r.__c.props!==s;return h.some(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(c=!0)}}),o&&o.call(this,s,u,l)||c};Q.__f=!0;var o=Q.shouldComponentUpdate,a=Q.componentWillUpdate;Q.componentWillUpdate=function(s,u,l){if(this.__e){var h=o;o=void 0,i(s,u,l),o=h}a&&a.call(this,s,u,l)},Q.shouldComponentUpdate=i}return r.__N||r.__}function Ae(e,t){var n=nt(Ne++,3);!G.__s&&rr(n.__H,t)&&(n.__=e,n.u=t,Q.__H.__h.push(n))}function xe(e,t){var n=nt(Ne++,4);!G.__s&&rr(n.__H,t)&&(n.__=e,n.u=t,Q.__h.push(n))}function pe(e){return Xe=5,Pe(function(){return{current:e}},[])}function Mi(e,t,n){Xe=6,xe(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function Pe(e,t){var n=nt(Ne++,7);return rr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ze(e,t){return Xe=8,Pe(function(){return e},t)}function ke(e){var t=Q.context[e.__c],n=nt(Ne++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(Q)),t.props.value):e.__}function Vi(e,t){G.useDebugValue&&G.useDebugValue(t?t(e):e)}function Bi(){var e=nt(Ne++,11);if(!e.__){for(var t=Q.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function Ea(){for(var e;e=Li.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Dt),t.__h.some(An),t.__h=[]}catch(n){t.__h=[],G.__e(n,e.__v)}}}G.__b=function(e){Q=null,Er&&Er(e)},G.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Dr&&Dr(e,t)},G.__r=function(e){Ar&&Ar(e),Ne=0;var t=(Q=e.__c).__H;t&&(mn===Q?(t.__h=[],Q.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Dt),t.__h.some(An),t.__h=[],Ne=0)),mn=Q},G.diffed=function(e){Pr&&Pr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Li.push(t)!==1&&Ir===G.requestAnimationFrame||((Ir=G.requestAnimationFrame)||Aa)(Ea)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),mn=Q=null},G.__c=function(e,t){t.some(function(n){try{n.__h.some(Dt),n.__h=n.__h.filter(function(r){return!r.__||An(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],G.__e(r,n.__v)}}),$r&&$r(e,t)},G.unmount=function(e){Tr&&Tr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Dt(r)}catch(i){t=i}}),n.__H=void 0,t&&G.__e(t,n.__v))};var Fr=typeof requestAnimationFrame==\"function\";function Aa(e){var t,n=function(){clearTimeout(r),Fr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Fr&&(t=requestAnimationFrame(n))}function Dt(e){var t=Q,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),Q=t}function An(e){var t=Q;e.__c=e.__(),Q=t}function rr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Hi(e,t){return typeof t==\"function\"?t(e):t}const zr=e=>{let t;const n=new Set,r=(l,h)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=h??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},Pa=(e=>e?zr(e):zr);function qi(e,t){for(var n in t)e[n]=t[n];return e}function Pn(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function Ui(e,t){var n=t(),r=Y({t:{__:n,u:t}}),i=r[0].t,o=r[1];return xe(function(){i.__=n,i.u=t,gn(i)&&o({t:i})},[e,n,t]),Ae(function(){return gn(i)&&o({t:i}),e(function(){gn(i)&&o({t:i})})},[e]),n}function gn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function ji(e){e()}function Wi(e){return e}function Qi(){return[!1,ji]}var Gi=xe;function $n(e,t){this.props=e,this.context=t}function $a(e,t){function n(i){var o=this.props.ref,a=o==i.ref;return!a&&o&&(o.call?o(null):o.current=null),t?!t(this.props,i)||!a:Pn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,be(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}($n.prototype=new Ee).isPureReactComponent=!0,$n.prototype.shouldComponentUpdate=function(e,t){return Pn(this.props,e)||Pn(this.state,t)};var Or=R.__b;R.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Or&&Or(e)};var Ta=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Da(e){function t(n){var r=qi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ta,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Rr=function(e,t){return e==null?null:Fe(Fe(e).map(t))},Fa={map:Rr,forEach:Rr,count:function(e){return e?Fe(e).length:0},only:function(e){var t=Fe(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Fe},za=R.__e;R.__e=function(e,t,n,r){if(e.then){for(var i,o=t;o=o.__;)if((i=o.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}za(e,t,n,r)};var Nr=R.unmount;function Ki(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=qi({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return Ki(r,t,n)})),e}function Yi(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Yi(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Ft(){this.__u=0,this.o=null,this.__b=null}function Zi(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Oa(e){var t,n,r,i=null;function o(a){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?be(i,a):null}return o.displayName=\"Lazy\",o.__f=!0,o}function ct(){this.i=null,this.l=null}R.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Nr&&Nr(e)},(Ft.prototype=new Ee).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Zi(r.__v),o=!1,a=function(){o||r.__z||(o=!0,n.__R=null,i?i(u):u())};n.__R=a;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Yi(l,l.__c.__P,l.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.__P=s,h.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(a,a)},Ft.prototype.componentWillUnmount=function(){this.o=[]},Ft.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=Ki(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&be(K,null,e.fallback);return i&&(i.__u&=-33),[be(K,null,t.__a?null:e.children),i]};var Lr=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Ra(e){return this.getChildContext=function(){return e.context},e.children}function Na(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Je(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,o){this.childNodes.push(i),t.h.insertBefore(i,o)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Je(be(Ra,{context:t.context},e.__v),t.v)}function La(e,t){var n=be(Na,{__v:e,h:t});return n.containerInfo=t,n}(ct.prototype=new Ee).__a=function(e){var t=this,n=Zi(t.__v),r=t.l.get(e);return r[0]++,function(i){var o=function(){t.props.revealOrder?(r.push(i),Lr(t,e,r)):i()};n?n(o):o()}},ct.prototype.render=function(e){this.i=null,this.l=new Map;var t=Fe(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},ct.prototype.componentDidUpdate=ct.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Lr(e,n,t)})};var Ji=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ma=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Va=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ba=/[A-Z0-9]/g,Ha=typeof document<\"u\",qa=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ua(e,t,n){return t.__k==null&&(t.textContent=\"\"),Je(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ja(e,t,n){return Ni(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ee.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ee.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Mr=R.event;function Wa(){}function Qa(){return this.cancelBubble}function Ga(){return this.defaultPrevented}R.event=function(e){return Mr&&(e=Mr(e)),e.persist=Wa,e.isPropagationStopped=Qa,e.isDefaultPrevented=Ga,e.nativeEvent=e};var ir,Ka={enumerable:!1,configurable:!0,get:function(){return this.class}},Vr=R.vnode;R.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},o=r.indexOf(\"-\")===-1;for(var a in n){var s=n[a];if(!(a===\"value\"&&\"defaultValue\"in n&&s==null||Ha&&a===\"children\"&&r===\"noscript\"||a===\"class\"||a===\"className\")){var u=a.toLowerCase();a===\"defaultValue\"&&\"value\"in n&&n.value==null?a=\"value\":a===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?a=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||qa(n.type)?u===\"onfocus\"?a=\"onfocusin\":u===\"onblur\"?a=\"onfocusout\":Va.test(a)&&(a=u):u=a=\"oninput\":o&&Ma.test(a)?a=a.replace(Ba,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[a=u]&&(a=\"oninputCapture\"),i[a]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Fe(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Fe(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Ka)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ji,Vr&&Vr(e)};var Br=R.__r;R.__r=function(e){Br&&Br(e),ir=e.__c};var Hr=R.diffed;R.diffed=function(e){Hr&&Hr(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),ir=null};var Ya={ReactCurrentDispatcher:{current:{readContext:function(e){return ir.__n[e.__c].props.value},useCallback:ze,useContext:ke,useDebugValue:Vi,useDeferredValue:Wi,useEffect:Ae,useId:Bi,useImperativeHandle:Mi,useInsertionEffect:Gi,useLayoutEffect:xe,useMemo:Pe,useReducer:nr,useRef:pe,useState:Y,useSyncExternalStore:Ui,useTransition:Qi}}};function Za(e){return be.bind(null,e)}function Xt(e){return!!e&&e.$$typeof===Ji}function Ja(e){return Xt(e)&&e.type===K}function Xa(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function es(e){return Xt(e)?Ca.apply(null,arguments):e}function ts(e){return!!e.__k&&(Je(null,e),!0)}function ns(e){return e&&(e.base||e.nodeType===1&&e)||null}var rs=function(e,t){return e(t)},is=function(e,t){return e(t)},os=K,as=Xt,It={useState:Y,useId:Bi,useReducer:nr,useEffect:Ae,useLayoutEffect:xe,useInsertionEffect:Gi,useTransition:Qi,useDeferredValue:Wi,useSyncExternalStore:Ui,startTransition:ji,useRef:pe,useImperativeHandle:Mi,useMemo:Pe,useCallback:ze,useContext:ke,useDebugValue:Vi,version:\"18.3.1\",Children:Fa,render:Ua,hydrate:ja,unmountComponentAtNode:ts,createPortal:La,createElement:be,createContext:Jt,createFactory:Za,cloneElement:es,createRef:ba,Fragment:K,isValidElement:Xt,isElement:as,isFragment:Ja,isMemo:Xa,findDOMNode:ns,Component:Ee,PureComponent:$n,memo:$a,forwardRef:Da,flushSync:is,unstable_batchedUpdates:rs,StrictMode:os,Suspense:Ft,SuspenseList:ct,lazy:Oa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ya};const ss=e=>e;function ls(e,t=ss){const n=It.useSyncExternalStore(e.subscribe,It.useCallback(()=>t(e.getState()),[e,t]),It.useCallback(()=>t(e.getInitialState()),[e,t]));return It.useDebugValue(n),n}const us=e=>{const t=Pa(e),n=r=>ls(t,r);return Object.assign(n,t),n},cs=(e=>us);var Xi=Symbol.for(\"immer-nothing\"),qr=Symbol.for(\"immer-draftable\"),oe=Symbol.for(\"immer-state\");function ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ce=Object,et=ce.getPrototypeOf,Ht=\"constructor\",en=\"prototype\",Tn=\"configurable\",qt=\"enumerable\",zt=\"writable\",dt=\"value\",Le=e=>!!e&&!!e[oe];function Oe(e){return e?eo(e)||nn(e)||!!e[qr]||!!e[Ht]?.[qr]||rn(e)||on(e):!1}var fs=ce[en][Ht].toString(),Ur=new WeakMap;function eo(e){if(!e||!or(e))return!1;const t=et(e);if(t===null||t===ce[en])return!0;const n=ce.hasOwnProperty.call(t,Ht)&&t[Ht];if(n===Object)return!0;if(!Ke(n))return!1;let r=Ur.get(n);return r===void 0&&(r=Function.toString.call(n),Ur.set(n,r)),r===fs}function tn(e,t,n=!0){xt(e)===0?(n?Reflect.ownKeys(e):ce.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function xt(e){const t=e[oe];return t?t.type_:nn(e)?1:rn(e)?2:on(e)?3:0}var jr=(e,t,n=xt(e))=>n===2?e.has(t):ce[en].hasOwnProperty.call(e,t),Dn=(e,t,n=xt(e))=>n===2?e.get(t):e[t],Ut=(e,t,n,r=xt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function hs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var nn=Array.isArray,rn=e=>e instanceof Map,on=e=>e instanceof Set,or=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",_n=e=>typeof e==\"boolean\";function ds(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var De=e=>e.copy_||e.base_,ar=e=>e.modified_?e.copy_:e.base_;function Fn(e,t){if(rn(e))return new Map(e);if(on(e))return new Set(e);if(nn(e))return Array[en].slice.call(e);const n=eo(e);if(t===!0||t===\"class_only\"&&!n){const r=ce.getOwnPropertyDescriptors(e);delete r[oe];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const a=i[o],s=r[a];s[zt]===!1&&(s[zt]=!0,s[Tn]=!0),(s.get||s.set)&&(r[a]={[Tn]:!0,[zt]:!0,[qt]:s[qt],[dt]:e[a]})}return ce.create(et(e),r)}else{const r=et(e);if(r!==null&&n)return{...e};const i=ce.create(r);return ce.assign(i,e)}}function sr(e,t=!1){return an(e)||Le(e)||!Oe(e)||(xt(e)>1&&ce.defineProperties(e,{set:Et,add:Et,clear:Et,delete:Et}),ce.freeze(e),t&&tn(e,(n,r)=>{sr(r,!0)},!1)),e}function ps(){ye(2)}var Et={[dt]:ps};function an(e){return e===null||!or(e)?!0:ce.isFrozen(e)}var jt=\"MapSet\",zn=\"Patches\",Wr=\"ArrayMethods\",to={};function je(e){const t=to[e];return t||ye(0,e),t}var Qr=e=>!!to[e],pt,no=()=>pt,ms=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Qr(jt)?je(jt):void 0,arrayMethodsPlugin_:Qr(Wr)?je(Wr):void 0});function Gr(e,t){t&&(e.patchPlugin_=je(zn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function On(e){Rn(e),e.drafts_.forEach(gs),e.drafts_=null}function Rn(e){e===pt&&(pt=e.parent_)}var Kr=e=>pt=ms(pt,e);function gs(e){const t=e[oe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Yr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[oe].modified_&&(On(t),ye(4)),Oe(e)&&(e=Zr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[oe].base_,e,t)}else e=Zr(t,n);return _s(t,e,!0),On(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Xi?e:void 0}function Zr(e,t){if(an(t))return t;const n=t[oe];if(!n)return Wt(t,e.handledSet_,e);if(!sn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);oo(n,e)}return n.copy_}function _s(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&sr(t,n)}function ro(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var sn=(e,t)=>e.scope_===t,ys=[];function io(e,t,n,r){const i=De(e),o=e.type_;if(r!==void 0&&Dn(i,r,o)===t){Ut(i,r,n,o);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;tn(i,(u,l)=>{if(Le(l)){const h=s.get(l)||[];h.push(u),s.set(l,h)}})}const a=e.draftLocations_.get(t)??ys;for(const s of a)Ut(i,s,n,o)}function bs(e,t,n){e.callbacks_.push(function(i){const o=t;if(!o||!sn(o,i))return;i.mapSetPlugin_?.fixSetContents(o);const a=ar(o);io(e,o.draft_??o,a,n),oo(o,i)})}function oo(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}ro(e)}}function vs(e,t,n){const{scope_:r}=e;if(Le(n)){const i=n[oe];sn(i,r)&&i.callbacks_.push(function(){Ot(e);const a=ar(i);io(e,n,a,t)})}else Oe(n)&&e.callbacks_.push(function(){const o=De(e);e.type_===3?o.has(n)&&Wt(n,r.handledSet_,r):Dn(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Wt(Dn(e.copy_,t,e.type_),r.handledSet_,r)})}function Wt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Le(e)||t.has(e)||!Oe(e)||an(e)||(t.add(e),tn(e,(r,i)=>{if(Le(i)){const o=i[oe];if(sn(o,n)){const a=ar(o);Ut(e,r,a,e.type_),ro(o)}}else Oe(i)&&Wt(i,t,n)})),e}function xs(e,t){const n=nn(e),r={type_:n?1:0,scope_:t?t.scope_:no(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,o=Qt;n&&(i=[r],o=mt);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return r.draft_=s,r.revoke_=a,[s,r]}var Qt={get(e,t){if(t===oe)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=De(e);if(!jr(i,t,e.type_))return ks(e,i,t);const o=i[t];if(e.finalized_||!Oe(o)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&ds(t))return o;if(o===yn(e.base_,t)){Ot(e);const a=e.type_===1?+t:t,s=Ln(e.scope_,o,e,a);return e.copy_[a]=s}return o},has(e,t){return t in De(e)},ownKeys(e){return Reflect.ownKeys(De(e))},set(e,t,n){const r=ao(De(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=yn(De(e),t),o=i?.[oe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(hs(n,i)&&(n!==void 0||jr(e.base_,t,e.type_)))return!0;Ot(e),Nn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),vs(e,t,n)),!0},deleteProperty(e,t){return Ot(e),yn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Nn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=De(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[zt]:!0,[Tn]:e.type_!==1||t!==\"length\",[qt]:r[qt],[dt]:n[t]}},defineProperty(){ye(11)},getPrototypeOf(e){return et(e.base_)},setPrototypeOf(){ye(12)}},mt={};for(let e in Qt){let t=Qt[e];mt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}mt.deleteProperty=function(e,t){return mt.set.call(this,e,t,void 0)};mt.set=function(e,t,n){return Qt.set.call(this,e[0],t,n,e[0])};function yn(e,t){const n=e[oe];return(n?De(n):e)[t]}function ks(e,t,n){const r=ao(t,n);return r?dt in r?r[dt]:r.get?.call(e.draft_):void 0}function ao(e,t){if(!(t in e))return;let n=et(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=et(n)}}function Nn(e){e.modified_||(e.modified_=!0,e.parent_&&Nn(e.parent_))}function Ot(e){e.copy_||(e.assigned_=new Map,e.copy_=Fn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ss=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ke(t)&&!Ke(n)){const o=n;n=t;const a=this;return function(u=o,...l){return a.produce(u,h=>n.call(this,h,...l))}}Ke(n)||ye(6),r!==void 0&&!Ke(r)&&ye(7);let i;if(Oe(t)){const o=Kr(this),a=Ln(o,t,void 0);let s=!0;try{i=n(a),s=!1}finally{s?On(o):Rn(o)}return Gr(o,r),Yr(i,o)}else if(!t||!or(t)){if(i=n(t),i===void 0&&(i=t),i===Xi&&(i=void 0),this.autoFreeze_&&sr(i,!0),r){const o=[],a=[];je(zn).generateReplacementPatches_(t,i,{patches_:o,inversePatches_:a}),r(o,a)}return i}else ye(1,t)},this.produceWithPatches=(t,n)=>{if(Ke(t))return(a,...s)=>this.produceWithPatches(a,u=>t(u,...s));let r,i;return[this.produce(t,n,(a,s)=>{r=a,i=s}),r,i]},_n(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),_n(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),_n(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Oe(e)||ye(8),Le(e)&&(e=ws(e));const t=Kr(this),n=Ln(t,e,void 0);return n[oe].isManual_=!0,Rn(t),n}finishDraft(e,t){const n=e&&e[oe];(!n||!n.isManual_)&&ye(9);const{scope_:r}=n;return Gr(r,t),Yr(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=je(zn).applyPatches_;return Le(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Ln(e,t,n,r){const[i,o]=rn(t)?je(jt).proxyMap_(t,n):on(t)?je(jt).proxySet_(t,n):xs(t,n);return(n?.scope_??no()).drafts_.push(i),o.callbacks_=n?.callbacks_??[],o.key_=r,n&&r!==void 0?bs(n,o,r):o.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:l}=u;o.modified_&&l&&l.generatePatches_(o,[],u)}),i}function ws(e){return Le(e)||ye(10,e),so(e)}function so(e){if(!Oe(e)||an(e))return e;const t=e[oe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Fn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Fn(e,!0);return tn(n,(i,o)=>{Ut(n,i,so(o))},r),t&&(t.finalized_=!1),n}var Cs=new Ss,Is=Cs.produce;const Es=e=>(t,n,r)=>(r.setState=(i,o,...a)=>{const s=typeof i==\"function\"?Is(i):i;return t(s,o,...a)},e(r.setState,n,r)),As=Es,Ps=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),$s=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Ts(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function Jr(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function Xr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const o=e[i];i++;let a=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))a+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,a+=e.slice(s,i);else{i=s;break}}else break;a&&(o===\".\"?n.push(a):r=a)}return{className:n.join(\" \"),id:r,endIdx:i}}function Ds(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const o=e[t];t++;const a=t;for(;t<e.length&&e[t]!==o;)t++;n[i]=e.slice(a,t),t<e.length&&t++}else{const o=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(o,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function kt(e){const t=[];let n=0,r=0;function i(o){o>r&&t.push({type:\"text\",value:e.slice(r,o),start:r,end:o})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const o=n;n+=2;let a,s;if(e[n]===\".\"||e[n]===\"#\"){const g=Xr(e,n);a=g.className||void 0,s=g.id||void 0,n=g.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=o+2,r=o;continue}const h=e.slice(l,n);n+=2;const{display:c,target:d}=Ts(h),f={type:\"link\",display:c,target:d,start:o,end:n};a&&(f.className=a),s&&(f.id=s),t.push(f),r=n;continue}if(e[n]===\"{\"){const o=n;let a=e[n+1],s,u;if(a===\".\"||a===\"#\"){i(n);const l=Xr(e,n+1);s=l.className||void 0,u=l.id||void 0;let h=l.endIdx;e[h]===\" \"&&h++;const c=e[h];if(c===\"$\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"variable\",start:o,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=o+1,r=o;continue}if(c===\"_\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"temporary\",start:o,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=o+1,r=o;continue}if(c===\"@\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"local\",start:o,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=o+1,r=o;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=h;let d=1;const f=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=o+1,r=o;continue}const g=e.slice(f,n);n++;const{name:k,rawArgs:I,isClose:b}=Jr(g),x={type:\"macro\",name:k,rawArgs:I,isClose:b,start:o,end:n};s&&(x.className=s),u&&(x.id=u),t.push(x),r=n;continue}n=o+1,r=o;continue}if(a===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"variable\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"temporary\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"local\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a!==void 0&&(a===\"/\"||/[a-zA-Z]/.test(a))){i(n),n++;let l=1;const h=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=o+1,r=o;continue}const c=e.slice(h,n);n++;const{name:d,rawArgs:f,isClose:g}=Jr(c);t.push({type:\"macro\",name:d,rawArgs:f,isClose:g,start:o,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const o=n;let a=n+1;const s=e[a]===\"/\";s&&a++;const u=a;for(;a<e.length&&/[a-zA-Z0-9]/.test(e[a]);)a++;const l=e.slice(u,a).toLowerCase();if(l&&Ps.has(l))if(s){for(;a<e.length&&/\\s/.test(e[a]);)a++;if(e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:o,end:a}),r=a,n=a;continue}}else{const h=Ds(e,a);a=h.endIdx;let c=$s.has(l);if(e[a]===\"/\"&&(c=!0,a++),e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:h.attributes,isClose:!1,isSelfClose:c,start:o,end:a}),r=a,n=a;continue}}n++;continue}n++}return i(e.length),t}const Fs=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),ei={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},zs=new Set([\"if\",\"switch\",\"timed\"]);function St(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"link\",display:i.display,target:i.target};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const o={type:\"variable\",name:i.name,scope:i.scope};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"html\"||a.node.tag!==i.tag){const s=a.node.type===\"html\"?`</${a.node.tag}>`:`{/${a.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(a.node);break}const o={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:o,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==i.name){const a=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${a} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(ei[i.name]){const o=ei[i.name],a=n.length>0?n[n.length-1].node:null;if(!a||a.type!==\"macro\"||a.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),a.branches.push(s);break}if(Fs.has(i.name)){const o={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(zs.has(i.name)){const a={rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),o.branches=[a]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}break}default:{const o=i;throw new Error(`Unknown token type: ${o.type}`)}}if(n.length>0){const i=n[n.length-1],o=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${o} (opened at character ${i.start})`)}return t}function lo(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function uo(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let rt=!1,wt=\"\",We=0,tt=null;function Os(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,wt=n,We=0,tt=lo(uo(n)),rt=!0}function Mn(e,t){wt=e,We=0,tt=lo(uo(e)),rt=!0;for(let n=0;n<t;n++)tt();We=t}function Rt(){rt=!1,wt=\"\",We=0,tt=null}function Nt(){return rt?{seed:wt,pull:We}:null}function lr(){return!rt||!tt?Math.random():(We++,tt())}function co(e,t){return e>t&&([e,t]=[t,e]),Math.floor(lr()*(t-e+1))+e}function Rs(){return rt}function Ns(){return wt}function Ls(){return We}const Ms=500,qe=new Map,Vs=/\\$(\\w+)/g,Bs=/\\b_(\\w+)/g,Hs=/@(\\w+)/g;function qs(e){return e.replace(Vs,'variables[\"$1\"]').replace(Bs,'temporary[\"$1\"]').replace(Hs,'locals[\"$1\"]')}function ur(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=qs(n),n=\"\")}for(;r<e.length;){const o=e.charAt(r);if(o==='\"'||o===\"'\"){i();const a=o;let s=a;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===a){s+=a,r++;break}else s+=u,r++}t+=s;continue}if(o===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const a=e.charAt(r);if(a===\"\\\\\"&&r+1<e.length)t+=a+e.charAt(r+1),r+=2;else if(a===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=ur(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(a===\"`\"){t+=\"`\",r++;break}else t+=a,r++}continue}n+=o,r++}return i(),t}const Us=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function fo(e,t){const n=qe.get(e);if(n)return qe.delete(e),qe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Us+t);if(qe.set(e,r),qe.size>Ms){const i=qe.keys().next().value;i!==void 0&&qe.delete(i)}return r}let At=null,ti=null,ni=null;function ho(){const e=S.getState(),{visitCounts:t,renderCounts:n}=e;if(At&&ti===t&&ni===n)return At;const r=f=>t[f]??0,i=f=>r(f)>0,o=(...f)=>f.some(g=>r(g)>0),a=(...f)=>f.every(g=>r(g)>0),s=f=>n[f]??0;return At={currentPassage:()=>{const f=S.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=S.getState();if(f.historyIndex<=0)return;const g=f.history[f.historyIndex-1]?.passage;return g?f.storyData?.passages.get(g):void 0},visited:r,hasVisited:i,hasVisitedAny:o,hasVisitedAll:a,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(g=>s(g)>0),hasRenderedAll:(...f)=>f.every(g=>s(g)>0),random:lr,randomInt:co},ti=t,ni=n,At}function ve(e,t,n,r={}){const o=`return (${ur(e)});`;return fo(o,o)(t,n,r,ho())}function Vn(e,t,n,r={}){const i=ur(e);fo(\"exec:\"+i,i)(t,n,r,ho())}const js=\"spindle\",Ws=1;let Pt=null,bn=null;function Me(){return bn||(bn={saves:new Map,playthroughs:new Map,meta:new Map}),bn}function Qs(){return Pt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Pt=new Promise((e,t)=>{const n=indexedDB.open(js,Ws);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),Pt))}function Ve(e,t){return Qs().then(n=>n.transaction(e,t).objectStore(e))}function Be(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function ln(e){try{const t=await Ve(\"saves\",\"readwrite\");await Be(t.put(e))}catch{Me().saves.set(e.meta.id,e)}}async function un(e){try{const t=await Ve(\"saves\",\"readonly\");return await Be(t.get(e))??void 0}catch{return Me().saves.get(e)}}async function Gs(e){try{const t=await Ve(\"saves\",\"readwrite\");await Be(t.delete(e))}catch{Me().saves.delete(e)}}async function Ks(e){try{const n=(await Ve(\"saves\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Me().saves.values()].filter(t=>t.meta.ifid===e)}}async function po(e){try{const t=await Ve(\"playthroughs\",\"readwrite\");await Be(t.put(e))}catch{Me().playthroughs.set(e.id,e)}}async function cr(e){try{const n=(await Ve(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Me().playthroughs.values()].filter(t=>t.ifid===e)}}async function fr(e){try{const t=await Ve(\"meta\",\"readonly\"),n=await Be(t.get(e));return n?n.value:void 0}catch{return Me().meta.get(e)}}async function mo(e,t){try{const n=await Ve(\"meta\",\"readwrite\");await Be(n.put({key:e,value:t}))}catch{Me().meta.set(e,t)}}const go=new Map,cn=new Map;function Ys(e,t){go.set(e,t),cn.set(t,e)}function Zs(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function X(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const o=i.constructor;if(cn.get(o)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(Zs(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Bn=\"__spindle_class__\",Hn=\"__spindle_data__\";function Gt(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const o=i.constructor,a=cn.get(o);if(a!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Bn]:a,[Hn]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Kt(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(a=>t(a));const r=n;if(Bn in r&&Hn in r){const a=r[Bn],s=r[Hn],u=go.get(a);if(!u){console.warn(`spindle: Class \"${a}\" not registered. Falling back to plain object.`);const h={};for(const c of Object.keys(s))h[c]=t(s[c]);return h}const l=Object.create(u.prototype);for(const h of Object.keys(s))l[h]=t(s[h]);return l}const i=r.constructor;if(cn.has(i))return n;const o={};for(const a of Object.keys(r))o[a]=t(r[a]);return o}return t(e)}let qn=null,Un=null,ri=!1;function Js(e){qn=e}function Xs(e){Un=e}function el(e){if(Un)try{const i=new Function(\"passage\",\"variables\",Un)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(qn)try{const r=qn(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function tl(){ri||(ri=!0)}async function ii(e){const n=(await cr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await po(i),await mo(`currentPlaythroughId.${e}`,r),r}async function nl(e){return fr(`currentPlaythroughId.${e}`)}async function _o(e,t,n,r={}){const i=new Date().toISOString(),o={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:el(n),passage:n.passage,custom:r},a=X(n);a.variables=Gt(a.variables),a.history=a.history.map(u=>({...u,variables:Gt(u.variables)}));const s={meta:o,payload:a};return await ln(s),s}async function yo(e,t){const n=await un(e);if(!n)return;const r=X(t);r.variables=Gt(r.variables),r.history=r.history.map(o=>({...o,variables:Gt(o.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await ln(i),i}async function rl(e){const t=await un(e);if(!t)return;const n=t.payload;return n.variables=Kt(n.variables),n.history=n.history.map(r=>({...r,variables:Kt(r.variables)})),n}async function il(e){await Gs(e)}async function ol(e,t){const n=await un(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await ln(r)}async function al(e){const[t,n]=await Promise.all([Ks(e),cr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const o=[],a=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of a){const u=i.get(s.id)??[];o.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||o.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const bo=\"autosave.\";async function sl(e,t,n){const r=`${bo}${e}`,i=await fr(r);if(i){const a=await yo(i,n);if(a)return a}const o=await _o(e,t,n,{isAutosave:!0});return await mo(r,o.meta.id),o}async function ll(e){const t=`${bo}${e}`,n=await fr(t);if(n)return rl(n)}async function ul(e){const t=await un(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function cl(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=X(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await cr(t)).some(o=>o.id===n.meta.playthroughId)){const o={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await po(o)}return await ln(n),n}function fl(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Vn(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(o=>o.type===\"text\"?o.value:\"\").join(\"\");Vn(i,t,n)}}}function vo(){const e=S.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=kt(t.content),r=St(n),i=X(e.variables),o=X(e.temporary);fl(r,i,o);for(const s of Object.keys(i))i[s]!==e.variables[s]&&e.setVariable(s,i[s]);for(const s of Object.keys(o))o[s]!==e.temporary[s]&&e.setTemporary(s,o[s]);const a=e.storyData.passages.get(\"SaveTitle\");a&&Xs(a.content)}function oi(e){e?.prng?Mn(e.prng.seed,e.prng.pull):e&&Rt()}const S=cs()(As((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",saveError:null,loadError:null,init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const o=X(r);e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=o,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,variables:X(o),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}});const a=n.ifid;tl().then(async()=>{const s=await nl(a);if(s)e(u=>{u.playthroughId=s});else{const u=await ii(a);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:X(i.variables),timestamp:Date.now(),prng:Nt()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=X(r.variables),n.temporary={}}),oi(t().history[t().historyIndex])},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=X(r.variables),n.temporary={}}),oi(t().history[t().historyIndex])},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Rt();const o=X(r);e(a=>{a.currentPassage=i.name,a.variables=o,a.temporary={},a.history=[{passage:i.name,variables:X(o),timestamp:Date.now()}],a.historyIndex=0,a.visitCounts={[i.name]:1},a.renderCounts={[i.name]:1}}),vo(),ii(n.ifid).then(a=>{e(s=>{s.playthroughId=a})}).catch(a=>console.error(\"spindle: failed to start new playthrough\",a))},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:o,history:a,historyIndex:s,visitCounts:u,renderCounts:l}=t();if(!n)return;const h={passage:i,variables:X(o),history:X(a),historyIndex:s,visitCounts:{...u},renderCounts:{...l},prng:Nt()};e(c=>{c.saveError=null}),sl(n.ifid,r,h).then(()=>{e(c=>{c.saveVersion++})}).catch(c=>{console.error(\"spindle: failed to quick save\",c),e(d=>{d.saveError=c instanceof Error?c.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),ll(n.ifid).then(r=>{r&&(e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}}),r.prng?Mn(r.prng.seed,r.prng.pull):Rt())}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:o,visitCounts:a,renderCounts:s}=t();return{passage:n,variables:X(r),history:X(i),historyIndex:o,visitCounts:{...a},renderCounts:{...s},prng:Nt()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Kt(n.variables),r.history=n.history.map(i=>({...i,variables:Kt(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?Mn(n.prng.seed,n.prng.pull):Rt()}}))),Yt=new Map,jn=new Set,Wn=new Map;function hl(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Wn.get(r)??0)+1;return Wn.set(r,i),i===1?r:`${r}:${i}`}function dl(e){return Yt.set(e.id,e),si(),()=>{Yt.delete(e.id),si()}}function ai(){return Array.from(Yt.values())}function pl(e){return Yt.get(e)}function ml(){Wn.clear()}function gl(e){return jn.add(e),()=>{jn.delete(e)}}function si(){for(const e of jn)e()}function ae(e){const t=pe(\"\");t.current||(t.current=hl(e.type,e.key,e.authorId));const n=t.current;return xe(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),dl(r)}),n}function $e(){const e=S(r=>r.variables),t=S(r=>r.temporary),n=ke(it);return Pe(()=>[e,t,n],[e,t,n])}const _l=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,yl=/\\{[\\$_@][\\w.]+\\}/;function xo(e){return yl.test(e)}function bl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function ko(e,t,n,r){return e.replace(_l,(i,o)=>{const a=o[0],u=o.slice(1).split(\".\"),l=u[0];let h;return a===\"$\"?h=t[l]:a===\"_\"?h=n[l]:h=r[l],u.length>1&&(h=bl(h,u)),h==null?\"\":String(h)})}function de(){const[e,t,n]=$e();return ze(r=>r===void 0||!xo(r)?r:ko(r,e,t,n),[e,t,n])}function vl({target:e,className:t,id:n,children:r}){const i=S(u=>u.navigate),o=de();t=o(t),n=o(n);const a=u=>{u.preventDefault(),i(e)};ae({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return _(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function xl({name:e,scope:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const o=ke(it),a=e.split(\".\"),s=a[0],u=S(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in o?o[s]:void 0:l=u;for(let c=1;c<a.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=a[c];l=l[d]}const h=l==null?\"\":String(l);return n||r?_(\"span\",{id:r,class:n,children:h}):_(K,{children:h})}function kl(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const s=e[a];if(i){n+=s,s===i&&e[a-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const o=n.trim();return o&&t.push(o),t}function Sl({body:e,parentValues:t,ownKeys:n}){const[r,i]=Y(()=>({...t,...n})),o=pe(r);o.current=r;const a=ze(()=>o.current,[]),s=ze((l,h)=>{i(c=>({...c,[l]:h}))},[]),u=Pe(()=>({update:s,getValues:a}),[s,a]);return _(ot.Provider,{value:u,children:_(it.Provider,{value:r,children:me(e)})})}function wl({body:e,params:t,rawArgs:n}){const r=ke(it),[i,o,a]=$e();if(t.length===0||!n)return _(K,{children:me(e)});const s=kl(n),u={};for(let l=0;l<t.length;l++){const h=t[l],c=s[l];let d;if(c!==void 0)try{d=ve(c,i,o,a)}catch{d=void 0}u[h.startsWith(\"@\")?h.slice(1):h]=d}return _(Sl,{body:e,parentValues:r,ownKeys:u})}const So=new Map;function wo(e,t,n){So.set(e.toLowerCase(),{body:t,params:n})}function Cl(e){return So.get(e.toLowerCase())}const Co=new Map;function M(e,t){Co.set(e.toLowerCase(),t)}function Il(e){return Co.get(e.toLowerCase())}const Io=new Set;function fn(e){Io.add(e.toLowerCase())}function El(e){return Io.has(e.toLowerCase())}const li=document.createElement(\"i\");function Eo(e){const t=\"&\"+e+\";\";li.innerHTML=t;const n=li.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function he(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function te(e,t){return e.length>0?(he(e,e.length,0,t),e):t}const Qn={}.hasOwnProperty;function Al(e){const t={};let n=-1;for(;++n<e.length;)Pl(t,e[n]);return t}function Pl(e,t){let n;for(n in t){const i=(Qn.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Qn.call(i,a)||(i[a]=[]);const s=o[a];$l(i[a],Array.isArray(s)?s:s?[s]:[])}}}function $l(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);he(e,0,0,r)}function Tl(e){const t={};let n=-1;for(;++n<e.length;)Dl(t,e[n]);return t}function Dl(e,t){let n;for(n in t){const i=(Qn.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o)i[a]=o[a]}}function Fl(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const zl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ao(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+zl[n]+\";\"}}function gt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ce=He(/[A-Za-z]/),fe=He(/[\\dA-Za-z]/),Ol=He(/[#-'*+\\--9=?A-Z^-~]/);function Gn(e){return e!==null&&(e<32||e===127)}const Kn=He(/\\d/),Rl=He(/[\\dA-Fa-f]/),Nl=He(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function ne(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Ll=He(/\\p{P}|\\p{S}/u),Ml=He(/\\s/);function He(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function $t(e,t){const n=Ao(Vl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),o=n.indexOf(\"#\"),a=n.indexOf(\"/\");return r<0||a>-1&&r>a||i>-1&&r>i||o>-1&&r>o||t.test(n.slice(0,r))?n:\"\"}function Vl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a=\"\";if(o===37&&fe(e.charCodeAt(n+1))&&fe(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const s=e.charCodeAt(n+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a=\"�\"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const ui={}.hasOwnProperty,ci=/^(https?|ircs?|mailto|xmpp)$/i,Bl=/^https?$/i;function Hl(e){const t=e||{};let n=!0;const r={},i=[[]],o=[],a=[],u=Tl([{enter:{blockQuote:N,codeFenced:ge,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:E,codeText:ca,content:Jo,definition:Wo,definitionDestinationString:Go,definitionLabelString:I,definitionTitleString:I,emphasis:la,htmlFlow:sa,htmlText:yr,image:U,label:I,link:W,listItemMarker:P,listItemValue:y,listOrdered:z,listUnordered:V,paragraph:Z,reference:I,resource:Qe,resourceDestinationString:Ge,resourceTitleString:I,setextHeading:ea,strong:ua},exit:{atxHeading:na,atxHeadingSequence:Xo,autolinkEmail:_a,autolinkProtocol:ga,blockQuote:J,characterEscapeValue:st,characterReferenceMarkerHexadecimal:br,characterReferenceMarkerNumeric:br,characterReferenceValue:ma,codeFenced:p,codeFencedFence:ue,codeFencedFenceInfo:m,codeFencedFenceMeta:O,codeFlowValue:aa,codeIndented:p,codeText:fa,codeTextData:st,data:st,definition:Zo,definitionDestinationString:Ko,definitionLabelString:Qo,definitionTitleString:Yo,emphasis:ha,hardBreakEscape:gr,hardBreakTrailing:gr,htmlFlow:_r,htmlFlowData:st,htmlText:_r,htmlTextData:st,image:mr,label:at,labelText:j,lineEnding:oa,link:mr,listOrdered:$,listUnordered:H,paragraph:le,reference:O,referenceString:Re,resource:O,resourceDestinationString:pn,resourceTitleString:jo,setextHeading:ia,setextHeadingLineSequence:ra,setextHeadingText:ta,strong:da,thematicBreak:pa}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:a},h={buffer:I,encode:v,getData:k,lineEndingIfNeeded:A,options:t,raw:w,resume:b,setData:g,tag:x};let c=t.defaultLineEnding;return d;function d(C){let T=-1,ee=0;const _e=[];let Se=[],Te=[];for(;++T<C.length;)!c&&(C[T][1].type===\"lineEnding\"||C[T][1].type===\"lineEndingBlank\")&&(c=C[T][2].sliceSerialize(C[T][1])),(C[T][1].type===\"listOrdered\"||C[T][1].type===\"listUnordered\")&&(C[T][0]===\"enter\"?_e.push(T):f(C.slice(_e.pop(),T))),C[T][1].type===\"definition\"&&(C[T][0]===\"enter\"?(Te=te(Te,C.slice(ee,T)),ee=T):(Se=te(Se,C.slice(ee,T+1)),ee=T+1));Se=te(Se,Te),Se=te(Se,C.slice(ee)),T=-1;const we=Se;for(u.enter.null&&u.enter.null.call(h);++T<C.length;){const vr=u[we[T][0]],xr=we[T][1].type,kr=vr[xr];ui.call(vr,xr)&&kr&&kr.call({sliceSerialize:we[T][2].sliceSerialize,...h},we[T][1])}return u.exit.null&&u.exit.null.call(h),i[0].join(\"\")}function f(C){const T=C.length;let ee=0,_e=0,Se=!1,Te;for(;++ee<T;){const we=C[ee];if(we[1]._container)Te=void 0,we[0]===\"enter\"?_e++:_e--;else switch(we[1].type){case\"listItemPrefix\":{we[0]===\"exit\"&&(Te=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{we[0]===\"enter\"&&!_e&&(Te?Te=void 0:Se=!0);break}default:Te=void 0}}C[0][1]._loose=Se}function g(C,T){l[C]=T}function k(C){return l[C]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function x(C){n&&(g(\"lastWasTag\",!0),i[i.length-1].push(C))}function w(C){g(\"lastWasTag\"),i[i.length-1].push(C)}function F(){w(c||`\n`)}function A(){const C=i[i.length-1],T=C[C.length-1],ee=T?T.charCodeAt(T.length-1):null;ee===10||ee===13||ee===null||F()}function v(C){return k(\"ignoreEncode\")?C:Ao(C)}function O(){b()}function z(C){a.push(!C._loose),A(),x(\"<ol\"),g(\"expectFirstItem\",!0)}function V(C){a.push(!C._loose),A(),x(\"<ul\"),g(\"expectFirstItem\",!0)}function y(C){if(k(\"expectFirstItem\")){const T=Number.parseInt(this.sliceSerialize(C),10);T!==1&&x(' start=\"'+v(String(T))+'\"')}}function P(){k(\"expectFirstItem\")?x(\">\"):q(),A(),x(\"<li>\"),g(\"expectFirstItem\"),g(\"lastWasTag\")}function $(){q(),a.pop(),F(),x(\"</ol>\")}function H(){q(),a.pop(),F(),x(\"</ul>\")}function q(){k(\"lastWasTag\")&&!k(\"slurpAllLineEndings\")&&A(),x(\"</li>\"),g(\"slurpAllLineEndings\")}function N(){a.push(!1),A(),x(\"<blockquote>\")}function J(){a.pop(),A(),x(\"</blockquote>\"),g(\"slurpAllLineEndings\")}function Z(){a[a.length-1]||(A(),x(\"<p>\")),g(\"slurpAllLineEndings\")}function le(){a[a.length-1]?g(\"slurpAllLineEndings\",!0):x(\"</p>\")}function ge(){A(),x(\"<pre><code\"),g(\"fencesCount\",0)}function m(){const C=b();x(' class=\"language-'+C+'\"')}function ue(){const C=k(\"fencesCount\")||0;C||(x(\">\"),g(\"slurpOneLineEnding\",!0)),g(\"fencesCount\",C+1)}function E(){A(),x(\"<pre><code>\")}function p(){const C=k(\"fencesCount\");C!==void 0&&C<2&&l.tightStack.length>0&&!k(\"lastWasTag\")&&F(),k(\"flowCodeSeenData\")&&A(),x(\"</code></pre>\"),C!==void 0&&C<2&&A(),g(\"flowCodeSeenData\"),g(\"fencesCount\"),g(\"slurpOneLineEnding\")}function U(){o.push({image:!0}),n=void 0}function W(){o.push({})}function j(C){o[o.length-1].labelId=this.sliceSerialize(C)}function at(){o[o.length-1].label=b()}function Re(C){o[o.length-1].referenceId=this.sliceSerialize(C)}function Qe(){I(),o[o.length-1].destination=\"\"}function Ge(){I(),g(\"ignoreEncode\",!0)}function pn(){o[o.length-1].destination=b(),g(\"ignoreEncode\")}function jo(){o[o.length-1].title=b()}function mr(){let C=o.length-1;const T=o[C],ee=T.referenceId||T.labelId,_e=T.destination===void 0?r[gt(ee)]:T;for(n=!0;C--;)if(o[C].image){n=void 0;break}T.image?(x('<img src=\"'+$t(_e.destination,t.allowDangerousProtocol?void 0:Bl)+'\" alt=\"'),w(T.label),x('\"')):x('<a href=\"'+$t(_e.destination,t.allowDangerousProtocol?void 0:ci)+'\"'),x(_e.title?' title=\"'+_e.title+'\"':\"\"),T.image?x(\" />\"):(x(\">\"),w(T.label),x(\"</a>\")),o.pop()}function Wo(){I(),o.push({})}function Qo(C){b(),o[o.length-1].labelId=this.sliceSerialize(C)}function Go(){I(),g(\"ignoreEncode\",!0)}function Ko(){o[o.length-1].destination=b(),g(\"ignoreEncode\")}function Yo(){o[o.length-1].title=b()}function Zo(){const C=o[o.length-1],T=gt(C.labelId);b(),ui.call(r,T)||(r[T]=o[o.length-1]),o.pop()}function Jo(){g(\"slurpAllLineEndings\",!0)}function Xo(C){k(\"headingRank\")||(g(\"headingRank\",this.sliceSerialize(C).length),A(),x(\"<h\"+k(\"headingRank\")+\">\"))}function ea(){I(),g(\"slurpAllLineEndings\")}function ta(){g(\"slurpAllLineEndings\",!0)}function na(){x(\"</h\"+k(\"headingRank\")+\">\"),g(\"headingRank\")}function ra(C){g(\"headingRank\",this.sliceSerialize(C).charCodeAt(0)===61?1:2)}function ia(){const C=b();A(),x(\"<h\"+k(\"headingRank\")+\">\"),w(C),x(\"</h\"+k(\"headingRank\")+\">\"),g(\"slurpAllLineEndings\"),g(\"headingRank\")}function st(C){w(v(this.sliceSerialize(C)))}function oa(C){if(!k(\"slurpAllLineEndings\")){if(k(\"slurpOneLineEnding\")){g(\"slurpOneLineEnding\");return}if(k(\"inCodeText\")){w(\" \");return}w(v(this.sliceSerialize(C)))}}function aa(C){w(v(this.sliceSerialize(C))),g(\"flowCodeSeenData\",!0)}function gr(){x(\"<br />\")}function sa(){A(),yr()}function _r(){g(\"ignoreEncode\")}function yr(){t.allowDangerousHtml&&g(\"ignoreEncode\",!0)}function la(){x(\"<em>\")}function ua(){x(\"<strong>\")}function ca(){g(\"inCodeText\",!0),x(\"<code>\")}function fa(){g(\"inCodeText\"),x(\"</code>\")}function ha(){x(\"</em>\")}function da(){x(\"</strong>\")}function pa(){A(),x(\"<hr />\")}function br(C){g(\"characterReferenceType\",C.type)}function ma(C){const T=this.sliceSerialize(C),ee=k(\"characterReferenceType\")?Fl(T,k(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Eo(T);w(v(ee)),g(\"characterReferenceType\")}function ga(C){const T=this.sliceSerialize(C);x('<a href=\"'+$t(T,t.allowDangerousProtocol?void 0:ci)+'\">'),w(v(T)),x(\"</a>\")}function _a(C){const T=this.sliceSerialize(C);x('<a href=\"'+$t(\"mailto:\"+T)+'\">'),w(v(T)),x(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&o++<i?(e.consume(u),s):(e.exit(n),t(u))}}const ql={tokenize:Ul};function Ul(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),o(s)}function o(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,a(s)}function a(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return D(s)?(e.consume(s),e.exit(\"chunkText\"),o):(e.consume(s),a)}}const jl={tokenize:Wl},fi={tokenize:Ql};function Wl(e){const t=this,n=[];let r=0,i,o,a;return s;function s(w){if(r<n.length){const F=n[r];return t.containerState=F[1],e.attempt(F[0].continuation,u,l)(w)}return l(w)}function u(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const F=t.events.length;let A=F,v;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){v=t.events[A][1].end;break}b(r);let O=F;for(;O<t.events.length;)t.events[O][1].end={...v},O++;return he(t.events,A+1,0,t.events.slice(F)),t.events.length=O,l(w)}return s(w)}function l(w){if(r===n.length){if(!i)return d(w);if(i.currentConstruct&&i.currentConstruct.concrete)return g(w);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fi,h,c)(w)}function h(w){return i&&x(),b(r),d(w)}function c(w){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(w)}function d(w){return t.containerState={},e.attempt(fi,f,g)(w)}function f(w){return r++,n.push([t.currentConstruct,t.containerState]),d(w)}function g(w){if(w===null){i&&x(),b(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:o}),k(w)}function k(w){if(w===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(w);return}return D(w)?(e.consume(w),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(w),k)}function I(w,F){const A=t.sliceStream(w);if(F&&A.push(null),w.previous=o,o&&(o.next=w),o=w,i.defineSkip(w.start),i.write(A),t.parser.lazy[w.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<a&&(!i.events[v][1].end||i.events[v][1].end.offset>a))return;const O=t.events.length;let z=O,V,y;for(;z--;)if(t.events[z][0]===\"exit\"&&t.events[z][1].type===\"chunkFlow\"){if(V){y=t.events[z][1].end;break}V=!0}for(b(r),v=O;v<t.events.length;)t.events[v][1].end={...y},v++;he(t.events,z+1,0,t.events.slice(O)),t.events.length=v}}function b(w){let F=n.length;for(;F-- >w;){const A=n[F];t.containerState=A[1],A[0].exit.call(t,e)}n.length=w}function x(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ql(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Zt(e){if(e===null||ne(e)||Ml(e))return 1;if(Ll(e))return 2}function hn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Yn={name:\"attention\",resolveAll:Gl,tokenize:Kl};function Gl(e,t){let n=-1,r,i,o,a,s,u,l,h;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};hi(c,-u),hi(d,u),a={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},o={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=te(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=te(l,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"enter\",o,t]]),l=te(l,hn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=te(l,[[\"exit\",o,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,l=te(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):h=0,he(e,r-1,n-r+3,l),n=r+l.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Kl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Zt(r);let o;return a;function a(u){return o=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===o)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),h=Zt(u),c=!h||h===2&&i||n.includes(u),d=!i||i===2&&h||n.includes(r);return l._open=!!(o===42?c:c&&(i||!d)),l._close=!!(o===42?d:d&&(h||!c)),t(u)}}function hi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Yl={name:\"autolink\",tokenize:Zl};function Zl(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),o}function o(f){return Ce(f)?(e.consume(f),a):f===64?n(f):l(f)}function a(f){return f===43||f===45||f===46||fe(f)?(r=1,s(f)):l(f)}function s(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||fe(f))&&r++<32?(e.consume(f),s):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||Gn(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),h):Ol(f)?(e.consume(f),l):n(f)}function h(f){return fe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(f)}function d(f){if((f===45||fe(f))&&r++<63){const g=f===45?d:c;return e.consume(f),g}return n(f)}}const dn={partial:!0,tokenize:Jl};function Jl(e,t,n){return r;function r(o){return L(o)?B(e,i,\"linePrefix\")(o):i(o)}function i(o){return o===null||D(o)?t(o):n(o)}}const Po={continuation:{tokenize:eu},exit:tu,name:\"blockQuote\",tokenize:Xl};function Xl(e,t,n){const r=this;return i;function i(a){if(a===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(a),e.exit(\"blockQuoteMarker\"),o}return n(a)}function o(a){return L(a)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(a),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(a))}}function eu(e,t,n){const r=this;return i;function i(a){return L(a)?B(e,o,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(a):o(a)}function o(a){return e.attempt(Po,t,n)(a)}}function tu(e){e.exit(\"blockQuote\")}const $o={name:\"characterEscape\",tokenize:nu};function nu(e,t,n){return r;function r(o){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(o),e.exit(\"escapeMarker\"),i}function i(o){return Nl(o)?(e.enter(\"characterEscapeValue\"),e.consume(o),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(o)}}const To={name:\"characterReference\",tokenize:ru};function ru(e,t,n){const r=this;let i=0,o,a;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),o=31,a=fe,h(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),o=6,a=Rl,h):(e.enter(\"characterReferenceValue\"),o=7,a=Kn,h(c))}function h(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return a===fe&&!Eo(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return a(c)&&i++<o?(e.consume(c),h):n(c)}}const di={partial:!0,tokenize:ou},pi={concrete:!0,name:\"codeFenced\",tokenize:iu};function iu(e,t,n){const r=this,i={partial:!0,tokenize:A};let o=0,a=0,s;return u;function u(v){return l(v)}function l(v){const O=r.events[r.events.length-1];return o=O&&O[1].type===\"linePrefix\"?O[2].sliceSerialize(O[1],!0).length:0,s=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),h(v)}function h(v){return v===s?(a++,e.consume(v),h):a<3?n(v):(e.exit(\"codeFencedFenceSequence\"),L(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||D(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(di,k,F)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,f,\"whitespace\")(v)):v===96&&v===s?n(v):(e.consume(v),d)}function f(v){return v===null||D(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),g(v))}function g(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===s?n(v):(e.consume(v),g)}function k(v){return e.attempt(i,F,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return o>0&&L(v)?B(e,x,\"linePrefix\",o+1)(v):x(v)}function x(v){return v===null||D(v)?e.check(di,k,F)(v):(e.enter(\"codeFlowValue\"),w(v))}function w(v){return v===null||D(v)?(e.exit(\"codeFlowValue\"),x(v)):(e.consume(v),w)}function F(v){return e.exit(\"codeFenced\"),t(v)}function A(v,O,z){let V=0;return y;function y(N){return v.enter(\"lineEnding\"),v.consume(N),v.exit(\"lineEnding\"),P}function P(N){return v.enter(\"codeFencedFence\"),L(N)?B(v,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(N):$(N)}function $(N){return N===s?(v.enter(\"codeFencedFenceSequence\"),H(N)):z(N)}function H(N){return N===s?(V++,v.consume(N),H):V>=a?(v.exit(\"codeFencedFenceSequence\"),L(N)?B(v,q,\"whitespace\")(N):q(N)):z(N)}function q(N){return N===null||D(N)?(v.exit(\"codeFencedFence\"),O(N)):z(N)}}}function ou(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const vn={name:\"codeIndented\",tokenize:su},au={partial:!0,tokenize:lu};function su(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,o,\"linePrefix\",5)(l)}function o(l){const h=r.events[r.events.length-1];return h&&h[1].type===\"linePrefix\"&&h[2].sliceSerialize(h[1],!0).length>=4?a(l):n(l)}function a(l){return l===null?u(l):D(l)?e.attempt(au,a,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||D(l)?(e.exit(\"codeFlowValue\"),a(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function lu(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):D(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),i):B(e,o,\"linePrefix\",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):D(a)?i(a):n(a)}}const uu={name:\"codeText\",previous:fu,resolve:cu,tokenize:hu};function cu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function fu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function hu(e,t,n){let r=0,i,o;return a;function a(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(o=e.enter(\"codeTextSequence\"),i=0,h(c)):D(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||D(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(o.type=\"codeTextData\",l(c))}}class du{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&<(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),lt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),lt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);lt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);lt(this.left,n.reverse())}}}function lt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Do(e){const t={};let n=-1,r,i,o,a,s,u,l;const h=new du(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type===\"chunkFlow\"&&h.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type===\"lineEndingBlank\"&&(o+=2),o<u.length&&u[o][1].type===\"content\"))for(;++o<u.length&&u[o][1].type!==\"content\";)u[o][1].type===\"chunkText\"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,pu(h,n)),n=t[n],l=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=h.get(o),a[1].type===\"lineEnding\"||a[1].type===\"lineEndingBlank\")a[0]===\"enter\"&&(i&&(h.get(i)[1].type=\"lineEndingBlank\"),a[1].type=\"lineEnding\",i=o);else if(!(a[1].type===\"linePrefix\"||a[1].type===\"listItemIndent\"))break;i&&(r[1].end={...h.get(i)[1].start},s=h.slice(i,n),s.unshift(r),h.splice(i,n-i+1,s))}}return he(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!l}function pu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const s=a.events,u=[],l={};let h,c,d=-1,f=n,g=0,k=0;const I=[k];for(;f;){for(;e.get(++i)[1]!==f;);o.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(k=d+1,I.push(k),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):I.pop(),d=I.length;d--;){const b=s.slice(I[d],I[d+1]),x=o.pop();u.push([x,x+b.length-1]),e.splice(x,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[g+u[d][0]]=g+u[d][1],g+=u[d][1]-u[d][0]-1;return l}const mu={resolve:_u,tokenize:yu},gu={partial:!0,tokenize:bu};function _u(e){return Do(e),e}function yu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?o(s):D(s)?e.check(gu,a,o)(s):(e.consume(s),i)}function o(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function a(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function bu(e,t,n){const r=this;return i;function i(a){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),B(e,o,\"linePrefix\")}function o(a){if(a===null||D(a))return n(a);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Fo(e,t,n,r,i,o,a,s,u){const l=u||Number.POSITIVE_INFINITY;let h=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(b),e.exit(o),d):b===null||b===32||b===41||Gn(b)?n(b):(e.enter(r),e.enter(a),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),k(b))}function d(b){return b===62?(e.enter(o),e.consume(b),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(b))}function f(b){return b===62?(e.exit(\"chunkString\"),e.exit(s),d(b)):b===null||b===60||D(b)?n(b):(e.consume(b),b===92?g:f)}function g(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function k(b){return!h&&(b===null||b===41||ne(b))?(e.exit(\"chunkString\"),e.exit(s),e.exit(a),e.exit(r),t(b)):h<l&&b===40?(e.consume(b),h++,k):b===41?(e.consume(b),h--,k):b===null||b===32||b===40||Gn(b)?n(b):(e.consume(b),b===92?I:k)}function I(b){return b===40||b===41||b===92?(e.consume(b),k):k(b)}}function zo(e,t,n,r,i,o){const a=this;let s=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(o),h}function h(f){return s>999||f===null||f===91||f===93&&!u||f===94&&!s&&\"_hiddenFootnoteSupport\"in a.parser.constructs?n(f):f===93?(e.exit(o),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):D(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),h):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||D(f)||s++>999?(e.exit(\"chunkString\"),h(f)):(e.consume(f),u||(u=!L(f)),f===92?d:c)}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function Oo(e,t,n,r,i,o){let a;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,u):n(d)}function u(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(o),l(d))}function l(d){return d===a?(e.exit(o),u(a)):d===null?n(d):D(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),h(d))}function h(d){return d===a||d===null||D(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:h)}function c(d){return d===a||d===92?(e.consume(d),h):h(d)}}function ht(e,t){let n;return r;function r(i){return D(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const vu={name:\"definition\",tokenize:ku},xu={partial:!0,tokenize:Su};function ku(e,t,n){const r=this;let i;return o;function o(f){return e.enter(\"definition\"),a(f)}function a(f){return zo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return ne(f)?ht(e,l)(f):l(f)}function l(f){return Fo(e,h,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function h(f){return e.attempt(xu,c,c)(f)}function c(f){return L(f)?B(e,d,\"whitespace\")(f):d(f)}function d(f){return f===null||D(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function Su(e,t,n){return r;function r(s){return ne(s)?ht(e,i)(s):n(s)}function i(s){return Oo(e,o,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function o(s){return L(s)?B(e,a,\"whitespace\")(s):a(s)}function a(s){return s===null||D(s)?t(s):n(s)}}const wu={name:\"hardBreakEscape\",tokenize:Cu};function Cu(e,t,n){return r;function r(o){return e.enter(\"hardBreakEscape\"),e.consume(o),i}function i(o){return D(o)?(e.exit(\"hardBreakEscape\"),t(o)):n(o)}}const Iu={name:\"headingAtx\",resolve:Eu,tokenize:Au};function Eu(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},o={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},he(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]])),e}function Au(e,t,n){let r=0;return i;function i(h){return e.enter(\"atxHeading\"),o(h)}function o(h){return e.enter(\"atxHeadingSequence\"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||ne(h)?(e.exit(\"atxHeadingSequence\"),s(h)):n(h)}function s(h){return h===35?(e.enter(\"atxHeadingSequence\"),u(h)):h===null||D(h)?(e.exit(\"atxHeading\"),t(h)):L(h)?B(e,s,\"whitespace\")(h):(e.enter(\"atxHeadingText\"),l(h))}function u(h){return h===35?(e.consume(h),u):(e.exit(\"atxHeadingSequence\"),s(h))}function l(h){return h===null||h===35||ne(h)?(e.exit(\"atxHeadingText\"),s(h)):(e.consume(h),l)}}const Pu=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],mi=[\"pre\",\"script\",\"style\",\"textarea\"],$u={concrete:!0,name:\"htmlFlow\",resolveTo:Fu,tokenize:zu},Tu={partial:!0,tokenize:Ru},Du={partial:!0,tokenize:Ou};function Fu(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function zu(e,t,n){const r=this;let i,o,a,s,u;return l;function l(p){return h(p)}function h(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),o=!0,k):p===63?(e.consume(p),i=3,r.interrupt?t:m):Ce(p)?(e.consume(p),a=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,f):p===91?(e.consume(p),i=5,s=0,g):Ce(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function f(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function g(p){const U=\"CDATA[\";return p===U.charCodeAt(s++)?(e.consume(p),s===U.length?r.interrupt?t:$:g):n(p)}function k(p){return Ce(p)?(e.consume(p),a=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||ne(p)){const U=p===47,W=a.toLowerCase();return!U&&!o&&mi.includes(W)?(i=1,r.interrupt?t(p):$(p)):Pu.includes(a.toLowerCase())?(i=6,U?(e.consume(p),b):r.interrupt?t(p):$(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):o?x(p):w(p))}return p===45||fe(p)?(e.consume(p),a+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:$):n(p)}function x(p){return L(p)?(e.consume(p),x):y(p)}function w(p){return p===47?(e.consume(p),y):p===58||p===95||Ce(p)?(e.consume(p),F):L(p)?(e.consume(p),w):y(p)}function F(p){return p===45||p===46||p===58||p===95||fe(p)?(e.consume(p),F):A(p)}function A(p){return p===61?(e.consume(p),v):L(p)?(e.consume(p),A):w(p)}function v(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,O):L(p)?(e.consume(p),v):z(p)}function O(p){return p===u?(e.consume(p),u=null,V):p===null||D(p)?n(p):(e.consume(p),O)}function z(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||ne(p)?A(p):(e.consume(p),z)}function V(p){return p===47||p===62||L(p)?w(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||D(p)?$(p):L(p)?(e.consume(p),P):n(p)}function $(p){return p===45&&i===2?(e.consume(p),J):p===60&&i===1?(e.consume(p),Z):p===62&&i===4?(e.consume(p),ue):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),ge):D(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Tu,E,H)(p)):p===null||D(p)?(e.exit(\"htmlFlowData\"),H(p)):(e.consume(p),$)}function H(p){return e.check(Du,q,E)(p)}function q(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),N}function N(p){return p===null||D(p)?H(p):(e.enter(\"htmlFlowData\"),$(p))}function J(p){return p===45?(e.consume(p),m):$(p)}function Z(p){return p===47?(e.consume(p),a=\"\",le):$(p)}function le(p){if(p===62){const U=a.toLowerCase();return mi.includes(U)?(e.consume(p),ue):$(p)}return Ce(p)&&a.length<8?(e.consume(p),a+=String.fromCharCode(p),le):$(p)}function ge(p){return p===93?(e.consume(p),m):$(p)}function m(p){return p===62?(e.consume(p),ue):p===45&&i===2?(e.consume(p),m):$(p)}function ue(p){return p===null||D(p)?(e.exit(\"htmlFlowData\"),E(p)):(e.consume(p),ue)}function E(p){return e.exit(\"htmlFlow\"),t(p)}}function Ou(e,t,n){const r=this;return i;function i(a){return D(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Ru(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(dn,t,n)}}const Nu={name:\"htmlText\",tokenize:Lu};function Lu(e,t,n){const r=this;let i,o,a;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),A):m===63?(e.consume(m),w):Ce(m)?(e.consume(m),z):n(m)}function l(m){return m===45?(e.consume(m),h):m===91?(e.consume(m),o=0,g):Ce(m)?(e.consume(m),x):n(m)}function h(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):D(m)?(a=c,Z(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?J(m):m===45?d(m):c(m)}function g(m){const ue=\"CDATA[\";return m===ue.charCodeAt(o++)?(e.consume(m),o===ue.length?k:g):n(m)}function k(m){return m===null?n(m):m===93?(e.consume(m),I):D(m)?(a=k,Z(m)):(e.consume(m),k)}function I(m){return m===93?(e.consume(m),b):k(m)}function b(m){return m===62?J(m):m===93?(e.consume(m),b):k(m)}function x(m){return m===null||m===62?J(m):D(m)?(a=x,Z(m)):(e.consume(m),x)}function w(m){return m===null?n(m):m===63?(e.consume(m),F):D(m)?(a=w,Z(m)):(e.consume(m),w)}function F(m){return m===62?J(m):w(m)}function A(m){return Ce(m)?(e.consume(m),v):n(m)}function v(m){return m===45||fe(m)?(e.consume(m),v):O(m)}function O(m){return D(m)?(a=O,Z(m)):L(m)?(e.consume(m),O):J(m)}function z(m){return m===45||fe(m)?(e.consume(m),z):m===47||m===62||ne(m)?V(m):n(m)}function V(m){return m===47?(e.consume(m),J):m===58||m===95||Ce(m)?(e.consume(m),y):D(m)?(a=V,Z(m)):L(m)?(e.consume(m),V):J(m)}function y(m){return m===45||m===46||m===58||m===95||fe(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),$):D(m)?(a=P,Z(m)):L(m)?(e.consume(m),P):V(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,H):D(m)?(a=$,Z(m)):L(m)?(e.consume(m),$):(e.consume(m),q)}function H(m){return m===i?(e.consume(m),i=void 0,N):m===null?n(m):D(m)?(a=H,Z(m)):(e.consume(m),H)}function q(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||ne(m)?V(m):(e.consume(m),q)}function N(m){return m===47||m===62||ne(m)?V(m):n(m)}function J(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function Z(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),le}function le(m){return L(m)?B(e,ge,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ge(m)}function ge(m){return e.enter(\"htmlTextData\"),a(m)}}const hr={name:\"labelEnd\",resolveAll:Hu,resolveTo:qu,tokenize:Uu},Mu={tokenize:ju},Vu={tokenize:Wu},Bu={tokenize:Qu};function Hu(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&he(e,0,e.length,n),e}function qu(e,t){let n=e.length,r=0,i,o,a,s;for(;n--;)if(i=e[n][1],o){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(a){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(o=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(a=n);const u={type:e[o][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[o][1].start},end:{...e[a][1].end}},h={type:\"labelText\",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=te(s,e.slice(o+1,o+r+3)),s=te(s,[[\"enter\",h,t]]),s=te(s,hn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),s=te(s,[[\"exit\",h,t],e[a-2],e[a-1],[\"exit\",l,t]]),s=te(s,e.slice(a+1)),s=te(s,[[\"exit\",u,t]]),he(e,o,e.length,s),e}function Uu(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return s;function s(d){return o?o._inactive?c(d):(a=r.parser.defined.includes(gt(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Mu,h,a?h:c)(d):d===91?e.attempt(Vu,h,a?l:c)(d):a?h(d):c(d)}function l(d){return e.attempt(Bu,h,c)(d)}function h(d){return t(d)}function c(d){return o._balanced=!0,n(d)}}function ju(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return ne(c)?ht(e,o)(c):o(c)}function o(c){return c===41?h(c):Fo(e,a,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function a(c){return ne(c)?ht(e,u)(c):h(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Oo(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):h(c)}function l(c){return ne(c)?ht(e,h)(c):h(c)}function h(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Wu(e,t,n){const r=this;return i;function i(s){return zo.call(r,e,o,a,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function o(s){return r.parser.defined.includes(gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function a(s){return n(s)}}function Qu(e,t,n){return r;function r(o){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),i}function i(o){return o===93?(e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(o)}}const Gu={name:\"labelStartImage\",resolveAll:hr.resolveAll,tokenize:Ku};function Ku(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),o}function o(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),a):n(s)}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const Yu={name:\"labelStartLink\",resolveAll:hr.resolveAll,tokenize:Zu};function Zu(e,t,n){const r=this;return i;function i(a){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(a),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),o}function o(a){return a===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(a):t(a)}}const xn={name:\"lineEnding\",tokenize:Ju};function Ju(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Lt={name:\"thematicBreak\",tokenize:Xu};function Xu(e,t,n){let r=0,i;return o;function o(l){return e.enter(\"thematicBreak\"),a(l)}function a(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||D(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,s,\"whitespace\")(l):s(l))}}const se={continuation:{tokenize:rc},exit:oc,name:\"list\",tokenize:nc},ec={partial:!0,tokenize:ac},tc={partial:!0,tokenize:ic};function nc(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(f){const g=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(g===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:Kn(f)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(Lt,n,l)(f):l(f);if(!r.interrupt||f===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(f)}return n(f)}function u(f){return Kn(f)&&++a<10?(e.consume(f),u):(!r.interrupt||a<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(dn,r.interrupt?n:h,e.attempt(ec,d,c))}function h(f){return r.containerState.initialBlankLine=!0,o++,d(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),d):n(f)}function d(f){return r.containerState.size=o+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function rc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(dn,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tc,t,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(se,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function ic(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type===\"listItemIndent\"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function oc(e){e.exit(this.containerState.type)}function ac(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!L(o)&&a&&a[1].type===\"listItemPrefixWhitespace\"?t(o):n(o)}}const gi={name:\"setextUnderline\",resolveTo:sc,tokenize:lc};function sc(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!o&&e[n][1].type===\"definition\"&&(o=n);const a={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",o?(e.splice(i,0,[\"enter\",a,t]),e.splice(o+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push([\"exit\",a,t]),e}function lc(e,t,n){const r=this;let i;return o;function o(l){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!==\"lineEnding\"&&r.events[h][1].type!==\"linePrefix\"&&r.events[h][1].type!==\"content\"){c=r.events[h][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,a(l)):n(l)}function a(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||D(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const uc={tokenize:cc};function cc(e){const t=this,n=e.attempt(dn,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mu,i)),\"linePrefix\")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEndingBlank\"),e.consume(o),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const fc={resolveAll:No()},hc=Ro(\"string\"),dc=Ro(\"text\");function Ro(e){return{resolveAll:No(e===\"text\"?pc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,s);return a;function a(h){return l(h)?o(h):s(h)}function s(h){if(h===null){n.consume(h);return}return n.enter(\"data\"),n.consume(h),u}function u(h){return l(h)?(n.exit(\"data\"),o(h)):(n.consume(h),u)}function l(h){if(h===null)return!0;const c=i[h];let d=-1;if(c)for(;++d<c.length;){const f=c[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function No(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type===\"data\"&&(o=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function pc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,a=-1,s=0,u;for(;o--;){const l=i[o];if(typeof l==\"string\"){for(a=l.length;l.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(l===-2)u=!0,s++;else if(l!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const mc={42:se,43:se,45:se,48:se,49:se,50:se,51:se,52:se,53:se,54:se,55:se,56:se,57:se,62:Po},gc={91:vu},_c={[-2]:vn,[-1]:vn,32:vn},yc={35:Iu,42:Lt,45:[gi,Lt],60:$u,61:gi,95:Lt,96:pi,126:pi},bc={38:To,92:$o},vc={[-5]:xn,[-4]:xn,[-3]:xn,33:Gu,38:To,42:Yn,60:[Yl,Nu],91:Yu,92:[wu,$o],93:hr,95:Yn,96:uu},xc={null:[Yn,fc]},kc={null:[42,95]},Sc={null:[]},wc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kc,contentInitial:gc,disable:Sc,document:mc,flow:yc,flowInitial:_c,insideSpan:xc,string:bc,text:vc},Symbol.toStringTag,{value:\"Module\"}));function Cc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let a=[],s=[];const u={attempt:O(A),check:O(v),consume:x,enter:w,exit:F,interrupt:O(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:k,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:c};let h=t.tokenize.call(l,u);return t.resolveAll&&o.push(t),l;function c(P){return a=te(a,P),I(),a[a.length-1]!==null?[]:(z(t,0),l.events=hn(o,l.events,l),l.events)}function d(P,$){return Ec(f(P),$)}function f(P){return Ic(a,P)}function g(){const{_bufferIndex:P,_index:$,line:H,column:q,offset:N}=r;return{_bufferIndex:P,_index:$,line:H,column:q,offset:N}}function k(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<a.length;){const $=a[r._index];if(typeof $==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(P){h=h(P)}function x(P){D(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function w(P,$){const H=$||{};return H.type=P,H.start=g(),l.events.push([\"enter\",H,l]),s.push(H),H}function F(P){const $=s.pop();return $.end=g(),l.events.push([\"exit\",$,l]),$}function A(P,$){z(P,$.from)}function v(P,$){$.restore()}function O(P,$){return H;function H(q,N,J){let Z,le,ge,m;return Array.isArray(q)?E(q):\"tokenize\"in q?E([q]):ue(q);function ue(j){return at;function at(Re){const Qe=Re!==null&&j[Re],Ge=Re!==null&&j.null,pn=[...Array.isArray(Qe)?Qe:Qe?[Qe]:[],...Array.isArray(Ge)?Ge:Ge?[Ge]:[]];return E(pn)(Re)}}function E(j){return Z=j,le=0,j.length===0?J:p(j[le])}function p(j){return at;function at(Re){return m=V(),ge=j,j.partial||(l.currentConstruct=j),j.name&&l.parser.constructs.disable.null.includes(j.name)?W():j.tokenize.call($?Object.assign(Object.create(l),$):l,u,U,W)(Re)}}function U(j){return P(ge,m),N}function W(j){return m.restore(),++le<Z.length?p(Z[le]):J}}}function z(P,$){P.resolveAll&&!o.includes(P)&&o.push(P),P.resolve&&he(l.events,$,l.events.length-$,P.resolve(l.events.slice($),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function V(){const P=g(),$=l.previous,H=l.currentConstruct,q=l.events.length,N=Array.from(s);return{from:q,restore:J};function J(){r=P,l.previous=$,l.currentConstruct=H,l.events.length=q,s=N,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Ic(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const s=a[0];typeof s==\"string\"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Ec(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o==\"string\")a=o;else switch(o){case-5:{a=\"\\r\";break}case-4:{a=`\n`;break}case-3:{a=`\\r\n`;break}case-2:{a=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;a=\" \";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join(\"\")}function Ac(e){const r={constructs:Al([wc,...(e||{}).extensions||[]]),content:i(ql),defined:[],document:i(jl),flow:i(uc),lazy:{},string:i(hc),text:i(dc)};return r;function i(o){return a;function a(s){return Cc(r,o,s)}}}function Pc(e){for(;!Do(e););return e}const _i=/[\\0\\t\\n\\r]/g;function $c(){let e=1,t=\"\",n=!0,r;return i;function i(o,a,s){const u=[];let l,h,c,d,f;for(o=t+(typeof o==\"string\"?o.toString():new TextDecoder(a||void 0).decode(o)),c=0,t=\"\",n&&(o.charCodeAt(0)===65279&&c++,n=void 0);c<o.length;){if(_i.lastIndex=c,l=_i.exec(o),d=l&&l.index!==void 0?l.index:o.length,f=o.charCodeAt(d),!l){t=o.slice(c);break}if(f===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(o.slice(c,d)),e+=d-c),f){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Tc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Hl(n)(Pc(Ac(n).document().write($c()(e,t,!0))))}const kn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Dc(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=kn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=kn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Fc)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+kn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Fc(e,t){return t===\"|\"?t:e}class zc{constructor(){this.map=[]}add(t,n,r){Oc(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const o of i)t.push(o);i=r.pop()}this.map.length=0}}function Oc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Rc(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const o=r.length-1;r[o]=r[o]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Nc(){return{flow:{null:{name:\"table\",tokenize:Lc,resolveAll:Mc}}}}function Lc(e,t,n){const r=this;let i=0,o=0,a;return s;function s(y){let P=r.events.length-1;for(;P>-1;){const q=r.events[P][1].type;if(q===\"lineEnding\"||q===\"linePrefix\")P--;else break}const $=P>-1?r.events[P][1].type:null,H=$===\"tableHead\"||$===\"tableRow\"?v:u;return H===v&&r.parser.lazy[r.now().line]?n(y):H(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(a=!0,o+=1),h(y)}function h(y){return y===null?n(y):D(y)?o>1?(o=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),f):n(y):L(y)?B(e,h,\"whitespace\")(y):(o+=1,a&&(a=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),a=!0,h):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||ne(y)?(e.exit(\"data\"),h(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function f(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),a=!1,L(y)?B(e,g,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):g(y))}function g(y){return y===45||y===58?I(y):y===124?(a=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),k):A(y)}function k(y){return L(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(o+=1,a=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(o+=1,b(y)):y===null||D(y)?F(y):A(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),x(y)):A(y)}function x(y){return y===45?(e.consume(y),x):y===58?(a=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),w):(e.exit(\"tableDelimiterFiller\"),w(y))}function w(y){return L(y)?B(e,F,\"whitespace\")(y):F(y)}function F(y){return y===124?g(y):y===null||D(y)?!a||i!==o?A(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):A(y)}function A(y){return n(y)}function v(y){return e.enter(\"tableRow\"),O(y)}function O(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),O):y===null||D(y)?(e.exit(\"tableRow\"),t(y)):L(y)?B(e,O,\"whitespace\")(y):(e.enter(\"data\"),z(y))}function z(y){return y===null||y===124||ne(y)?(e.exit(\"data\"),O(y)):(e.consume(y),y===92?V:z)}function V(y){return y===92||y===124?(e.consume(y),z):z(y)}}function Mc(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],s=!1,u=0,l,h,c;const d=new zc;for(;++n<e.length;){const f=e[n],g=f[1];f[0]===\"enter\"?g.type===\"tableHead\"?(s=!1,u!==0&&(yi(d,t,u,l,h),h=void 0,u=0),l={type:\"table\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",l,t]])):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(r=!0,c=void 0,o=[0,0,0,0],a=[0,n+1,0,0],s&&(s=!1,h={type:\"tableBody\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",h,t]])),i=g.type===\"tableDelimiterRow\"?2:h?3:1):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],c=Tt(d,t,o,i,void 0,c),o=[0,0,0,0]),a[2]=n)):g.type===\"tableCellDivider\"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],c=Tt(d,t,o,i,void 0,c)),o=a,a=[o[1],n,0,0])):g.type===\"tableHead\"?(s=!0,u=n):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(u=n,o[1]!==0?(a[0]=a[1],c=Tt(d,t,o,i,n,c)):a[1]!==0&&(c=Tt(d,t,a,i,n,c)),i=0):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")&&(a[3]=n)}for(u!==0&&yi(d,t,u,l,h),d.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=Rc(t.events,n))}return e}function Tt(e,t,n,r,i,o){const a=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(o.end=Object.assign({},Ye(t.events,n[0])),e.add(n[0],0,[[\"exit\",o,t]]));const u=Ye(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",o,t]]),n[2]!==0){const l=Ye(t.events,n[2]),h=Ye(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],f=t.events[n[3]];if(d[1].end=Object.assign({},f[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const g=n[2]+1,k=n[3]-n[2]-1;e.add(g,k,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(o.end=Object.assign({},Ye(t.events,i)),e.add(i,0,[[\"exit\",o,t]]),o=void 0),o}function yi(e,t,n,r,i){const o=[],a=Ye(t.events,n);i&&(i.end=Object.assign({},a),o.push([\"exit\",i,t])),r.end=Object.assign({},a),o.push([\"exit\",r,t]),e.add(n+1,0,o)}function Ye(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Vc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Bc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,s){let u=-1;for(;++u<a.length;)if(a[u][0]===\"enter\"&&a[u][1].type===\"strikethroughSequenceTemporary\"&&a[u][1]._close){let l=u;for(;l--;)if(a[l][0]===\"exit\"&&a[l][1].type===\"strikethroughSequenceTemporary\"&&a[l][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[l][1].end.offset-a[l][1].start.offset){a[u][1].type=\"strikethroughSequence\",a[l][1].type=\"strikethroughSequence\";const h={type:\"strikethrough\",start:Object.assign({},a[l][1].start),end:Object.assign({},a[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},a[l][1].end),end:Object.assign({},a[u][1].start)},d=[[\"enter\",h,s],[\"enter\",a[l][1],s],[\"exit\",a[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&he(d,d.length,0,hn(f,a.slice(l+1,u),s)),he(d,d.length,0,[[\"exit\",c,s],[\"enter\",a[u][1],s],[\"exit\",a[u][1],s],[\"exit\",h,s]]),he(a,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type===\"strikethroughSequenceTemporary\"&&(a[u][1].type=\"data\");return a}function o(a,s,u){const l=this.previous,h=this.events;let c=0;return d;function d(g){return l===126&&h[h.length-1][1].type!==\"characterEscape\"?u(g):(a.enter(\"strikethroughSequenceTemporary\"),f(g))}function f(g){const k=Zt(l);if(g===126)return c>1?u(g):(a.consume(g),c++,f);if(c<2&&!n)return u(g);const I=a.exit(\"strikethroughSequenceTemporary\"),b=Zt(g);return I._open=!b||b===2&&!!k,I._close=!k||k===2&&!!b,s(g)}}}function Hc(e){return Tc(e,{allowDangerousHtml:!0,extensions:[Nc(),Bc()],htmlExtensions:[Dc(),Vc()]})}const qc={update:()=>{},getValues:()=>({})},it=Jt({}),ot=Jt(qc);function Uc(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,o)=>Lo(i,o,t));return _(K,{children:r})}function Lo(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),o=r.getAttribute(\"data-tw\");if(o!=null)return n[parseInt(o,10)];const a={key:t};for(const u of Array.from(r.attributes))a[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>Lo(u,l,n));return be(i,a,...s)}return null}function jc({node:e}){const t=de(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return be(e.tag,n,e.children.length>0?me(e.children):void 0)}function Wc(e,t){if(El(e.name))return null;const n=Cl(e.name);if(n)return _(wl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Il(e.name);return r?_(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):_(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function Zn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return _(vl,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return _(xl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Wc(e,t);case\"html\":return _(jc,{node:e},t);default:return e}}function Mo(e){return e.length===0?null:e.map((t,n)=>Zn(t,n))}function Qc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Gc(e){const t=S.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let o=1;o<n.length;o++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[o]]}return i==null?\"\":String(i)}function me(e){if(e.length===0)return null;if(!e.some(o=>o.type===\"text\"))return e.map((o,a)=>Zn(o,a));const n=[];let r=\"\";for(let o=0;o<e.length;o++){const a=e[o];if(a.type===\"text\")r+=a.value.replace(/^[ \\t]{4,}/gm,\" \");else if(a.type===\"variable\"&&Qc(r))r+=Gc(a);else{const s=n.length;n.push(Zn(a,o)),r+=`<span data-tw=\"${s}\"></span>`}}const i=Hc(r);return Uc(i,n)}const Kc=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Yc(){const t=S(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Kc;try{const r=kt(n),i=St(r);return _(K,{children:me(i)})}catch(r){return _(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Zc(){const e=S(n=>n.storyData),t=S(n=>n.currentPassage);return Ae(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),S.getState().save()):r.key===\"F9\"&&(r.preventDefault(),S.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?_(\"div\",{class:\"loading\",children:\"Loading...\"}):_(Yc,{})}function Jc(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",o=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",h=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(d.getAttribute(\"pid\")||\"0\",10),g=d.getAttribute(\"name\")||\"\",k=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(F=>F.length>0),I=d.textContent||\"\",b={},x=new Set([\"pid\",\"name\",\"tags\"]);for(const F of d.attributes)x.has(F.name)||(b[F.name]=F.value);const w={pid:f,name:g,tags:k,metadata:b,content:I};h.set(g,w),c.set(f,w)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:o,passages:h,passagesById:c,userCSS:s,userScript:l}}const ut=new Map;let re={},bi=!1;function Vo(){return`spindle.${S.getState().storyData?.ifid||\"unknown\"}.settings`}function Xc(){localStorage.setItem(Vo(),JSON.stringify(re))}function Sn(){if(!bi){bi=!0;try{const e=localStorage.getItem(Vo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(re={...re,...t})}}catch{}}}const _t={addToggle(e,t){ut.set(e,{type:\"toggle\",config:t}),e in re||(re[e]=t.default),Sn()},addList(e,t){ut.set(e,{type:\"list\",config:t}),e in re||(re[e]=t.default),Sn()},addRange(e,t){ut.set(e,{type:\"range\",config:t}),e in re||(re[e]=t.default),Sn()},get(e){return re[e]},getToggle(e){const t=re[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=re[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=re[e];return typeof t==\"number\"?t:0},set(e,t){re[e]=t,Xc()},getAll(){return{...re}},getDefinitions(){return ut},hasAny(){return ut.size>0}};function ef(){return{get(e){return S.getState().variables[e]},set(e,t){const n=S.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){S.getState().navigate(e)},back(){S.getState().goBack()},forward(){S.getState().goForward()},restart(){S.getState().restart()},save(e){S.getState().save(e)},load(e){S.getState().load(e)},hasSave(e){return S.getState().hasSave(e)},visited(e){return S.getState().visitCounts[e]??0},hasVisited(e){return(S.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return S.getState().renderCounts[e]??0},hasRendered(e){return(S.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=S.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=S.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return S.getState().storyData?.name||\"\"},get passage(){return S.getState().currentPassage},settings:_t,registerClass(e,t){Ys(e,t)},saves:{setTitleGenerator(e){Js(e)}},getActions(){return ai()},performAction(e,t){const n=pl(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=S.getState().currentPassage;return S.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return gl(t);if(e===\"variableChanged\"){let n={...S.getState().variables};return S.subscribe(r=>{const i={};let o=!1;const a=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of a)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},o=!0);n={...r.variables},o&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ai())})})})},random(){return lr()},randomInt(e,t){return co(e,t)},prng:{init(e,t){Os(e,t);const{historyIndex:n}=S.getState();S.setState(r=>{const i=r.history[n];i&&(i.prng=Nt())})},isEnabled(){return Rs()},get seed(){return Ns()},get pull(){return Ls()}}}}function tf(){window.Story=ef()}const nf=/^\\$(\\w+)\\s*=\\s*(.+)$/,vi=/\\$(\\w+(?:\\.\\w+)*)/g,xi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,rf=new Set([\"number\",\"string\",\"boolean\"]);function Bo(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,Bo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!rf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function of(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(nf);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,o,a]=i;let s;try{s=new Function(\"return (\"+a+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${o} = ${a}\": ${l instanceof Error?l.message:l}`)}const u=Bo(s);t.set(o,{...u,name:o,default:s})}return t}function af(e){const t=new Set;let n;for(xi.lastIndex=0;(n=xi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function sf(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const o=t.get(i);if(!o)return`Undeclared variable: $${e}`;let a=o;for(let s=1;s<r.length;s++){const u=r[s];if(a.type===\"array\")return null;if(a.type!==\"object\"||!a.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${a.type})`;const l=a.fields.get(u);if(!l)return null;a=l}return null}function lf(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const o=af(i.content);let a;for(vi.lastIndex=0;(a=vi.exec(i.content))!==null;){const s=a[1],u=sf(s,t,o);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function uf(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function yt(e,t,n){const r=S.getState(),i=X(r.variables),o=X(r.temporary),a={...t};Vn(e,i,o,a);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(o))o[s]!==r.temporary[s]&&r.setTemporary(s,o[s]);for(const s of Object.keys(a))a[s]!==t[s]&&n(s,a[s])}function Ho(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function ie(){const e=S.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Ho(t):\"\"}function cf({rawArgs:e}){const{update:t,getValues:n}=ke(ot),r=pe(!1);if(!r.current){r.current=!0;try{yt(e,n(),t)}catch(i){return console.error(`spindle: Error in {set ${e}}${ie()}:`,i),null}}return null}M(\"set\",cf);function ff({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const[i,o,a]=$e();try{const s=ve(e,i,o,a),u=s==null?\"\":String(s);return t||n?_(\"span\",{id:n,class:t,children:u}):_(K,{children:u})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{print error${ie()}: ${s instanceof Error?s.message:String(s)}}`})}}M(\"print\",ff);function hf(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const o=t.slice(0,r).trim(),a=t.slice(r+1).trim();if(!o.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${o}\"`);return{target:o,expr:a}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function df(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function ki(e,t,n,r,i,o,a){const s=S.getState();let u;try{u=ve(e,r,i,o)}catch(h){console.error(`spindle: Error in {computed ${a}}${ie()}:`,h);return}const l=n?s.temporary[t]:s.variables[t];df(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}function pf({rawArgs:e}){const[t,n,r]=$e();let i,o;try{({target:i,expr:o}=hf(e))}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{computed error${ie()}: ${l instanceof Error?l.message:String(l)}}`})}const a=i.startsWith(\"_\"),s=i.slice(1),u=pe(!1);if(!u.current){u.current=!0;const l=S.getState();ki(o,s,a,l.variables,l.temporary,r,e)}return xe(()=>{ki(o,s,a,t,n,r,e)},[t,n,r]),null}M(\"computed\",pf);function mf(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const o=gf(r);if(o.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:o[0],maxExpr:o.slice(1).join(\" \"),labelMode:n}}function gf(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const o=e[i];if(o===\"(\"||o===\"[\")r++,n+=o;else if(o===\")\"||o===\"]\")r--,n+=o;else if(/\\s/.test(o)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=o}return n.length>0&&t.push(n),t}function _f(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function yf({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const[i,o,a]=$e();try{const{currentExpr:s,maxExpr:u,labelMode:l}=mf(e),h=Number(ve(s,i,o,a)),c=Number(ve(u,i,o,a)),d=c===0?0:Math.max(0,Math.min(100,h/c*100)),f=_f(h,c,l),g=[\"macro-meter\",t].filter(Boolean).join(\" \");return _(\"div\",{class:g,id:n,children:[_(\"div\",{class:\"macro-meter-fill\",style:`width: ${d}%`}),f!=null&&_(\"span\",{class:\"macro-meter-label\",children:f})]})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{meter error: ${s instanceof Error?s.message:String(s)}}`})}}M(\"meter\",yf);function bf({branches:e=[]}){const t=de(),[n,r,i]=$e();function o(a){const s=me(a.children),u=t(a.className),l=t(a.id);return u||l?_(\"span\",{id:l,class:u,children:s}):_(K,{children:s})}for(const a of e){if(a.rawArgs===\"\")return o(a);try{if(ve(a.rawArgs,n,r,i))return o(a)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{if error${ie()}: ${s instanceof Error?s.message:String(s)}}`})}}return null}M(\"if\",bf);function vf(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),o=i[0],a=i.length>1?i[1]:null;if(!o.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${o}\"`);if(a&&!a.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${a}\"`);return{itemVar:o.slice(1),indexVar:a?a.slice(1):null,listExpr:r}}function xf({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,o]=Y(()=>({...e,...t,...n})),a=pe(i);a.current=i;const s=ze(()=>a.current,[]),u=ze((h,c)=>{o(d=>({...d,[h]:c}))},[]),l=Pe(()=>({update:u,getValues:s}),[u,s]);return _(ot.Provider,{value:l,children:_(it.Provider,{value:i,children:me(r)})})}function kf({rawArgs:e,children:t=[],className:n,id:r}){const i=de();n=i(n),r=i(r);const o=ke(it),[a,s,u]=$e();let l;try{l=vf(e)}catch(k){return _(\"span\",{class:\"error\",title:String(k),children:`{for error${ie()}: ${k instanceof Error?k.message:String(k)}}`})}const{itemVar:h,indexVar:c,listExpr:d}=l;let f;try{const k=ve(d,a,s,u);if(!Array.isArray(k))return _(\"span\",{class:\"error\",children:`{for error${ie()}: expression did not evaluate to an array}`});f=k}catch(k){return _(\"span\",{class:\"error\",title:String(k),children:`{for error${ie()}: ${k instanceof Error?k.message:String(k)}}`})}const g=f.map((k,I)=>{const b={[h]:k,...c?{[c]:I}:void 0};return _(xf,{parentValues:o,ownKeys:b,initialValues:{},children:t},I)});return n||r?_(\"span\",{id:r,class:n,children:g}):_(K,{children:g})}M(\"for\",kf);function dr(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Sf({children:e=[]}){const t=dr(e),{update:n,getValues:r}=ke(ot);return xe(()=>{try{yt(t,r(),n)}catch(i){console.error(`spindle: Error in {do}${ie()}:`,i)}},[]),null}M(\"do\",Sf);function wf({rawArgs:e,children:t=[],className:n,id:r}){const i=de();n=i(n),r=i(r);const{update:o,getValues:a}=ke(ot),s=()=>{try{yt(e,a(),o)}catch(l){console.error(`spindle: Error in {button ${e}}${ie()}:`,l)}};ae({type:\"button\",key:e,authorId:r,label:dr(t)||e,perform:s});const u=n?`macro-button ${n}`:\"macro-button\";return _(\"button\",{id:r,class:u,onClick:s,children:Mo(t)})}M(\"button\",wf);function Cf(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Si(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")try{yt(r.rawArgs,t,n)}catch(i){console.error(`spindle: Error in {link} child {set}${ie()}:`,i)}else if(r.name===\"do\"){const i=dr(r.children);try{yt(i,t,n)}catch(o){console.error(`spindle: Error in {link} child {do}${ie()}:`,o)}}}}function If({rawArgs:e,children:t=[],className:n,id:r}){const i=de();n=i(n),r=i(r);const{display:o,passage:a}=Cf(e),{update:s,getValues:u}=ke(ot),l=c=>{c.preventDefault(),Si(t,u(),s),a&&S.getState().navigate(a)};ae({type:\"link\",key:a||o,authorId:r,label:o,target:a??void 0,perform:()=>{Si(t,u(),s),a&&S.getState().navigate(a)}});const h=n?`macro-link ${n}`:\"macro-link\";return _(\"a\",{id:r,class:h,href:\"#\",onClick:l,children:o})}M(\"link\",If);function Ef({rawArgs:e,branches:t=[]}){const[n,r,i]=$e();let o;try{o=ve(e,n,r,i)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{switch error${ie()}: ${s instanceof Error?s.message:String(s)}}`})}let a=null;for(let s=1;s<t.length;s++){const u=t[s];if(u.rawArgs===\"\"){a=u;continue}try{const l=ve(u.rawArgs,n,r,i);if(o===l)return _(K,{children:me(u.children)})}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{case error${ie()}: ${l instanceof Error?l.message:String(l)}}`})}}return a?_(K,{children:me(a.children)}):null}M(\"switch\",Ef);fn(\"case\");fn(\"default\");function pr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Af({branches:e=[]}){const t=de(),n=Pe(()=>e.map(l=>({delay:l.rawArgs?pr(l.rawArgs):0,nodes:l.children,className:l.className,id:l.id})),[e]),[r,i]=Y(-1);if(Ae(()=>{if(r>=n.length-1)return;const l=r+1,h=n[l].delay,c=setTimeout(()=>{i(l)},h);return()=>clearTimeout(c)},[r,n]),r<0)return null;const o=n[r],a=me(o.nodes),s=t(o.className),u=t(o.id);return s||u?_(\"span\",{id:u,class:s,children:a}):_(K,{children:a})}M(\"timed\",Af);fn(\"next\");const qo=Jt({stop:()=>{}});function Pf({rawArgs:e,children:t=[],className:n,id:r}){const[i,o]=Pe(()=>{const g=k=>{if(!k||!xo(k))return k;const I=S.getState();return ko(k,I.variables,I.temporary,{})};return[g(n),g(r)]},[n,r]),a=pr(e),[s,u]=Y(0),[l,h]=Y(!1),c=ze(()=>h(!0),[]);if(Ae(()=>{if(l)return;const g=setInterval(()=>{u(k=>k+1)},a);return()=>clearInterval(g)},[a,l]),s===0&&!l)return null;const d=i?`macro-repeat ${i}`:void 0,f=_(qo.Provider,{value:{stop:c},children:_(\"span\",{children:me(t)},s)});return d||o?_(\"span\",{id:o,class:d,children:f}):f}M(\"repeat\",Pf);function $f(e){const{stop:t}=ke(qo);return xe(()=>{t()},[t]),null}M(\"stop\",$f);function Tf({rawArgs:e,children:t=[],className:n,id:r}){const i=de();n=i(n),r=i(r);const o=pr(e),a=pe(null),[s,u]=Y(0),[l,h]=Y(0);Ae(()=>{if(a.current){const f=a.current.textContent||\"\";u(f.length)}},[]),Ae(()=>{if(s===0||l>=s)return;const f=setInterval(()=>{h(g=>g>=s?(clearInterval(f),g):g+1)},o);return()=>clearInterval(f)},[s,o]);const c=l>=s&&s>0,d=[\"macro-type\",c?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return _(\"span\",{id:r,class:d,ref:a,style:{clipPath:(s>0&&!c,void 0)},children:[_(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!c?`inset(0 ${(s-l)/s*100}% 0 0)`:void 0},children:Mo(t)}),!c&&s>0&&_(\"span\",{class:\"macro-type-cursor\"})]})}M(\"type\",Tf);function Df(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}function Ff({rawArgs:e,children:t=[]}){const{name:n,params:r}=Df(e);return xe(()=>{wo(n,t,r)},[]),null}M(\"widget\",Ff);function zf({className:e,id:t}){const n=S(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return _(\"span\",{id:t,class:r,children:n})}M(\"story-title\",zf);function Of({className:e,id:t}){const n=S(o=>o.goBack),r=S(o=>o.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}M(\"back\",Of);function Rf({className:e,id:t}){const n=S(o=>o.goForward),r=S(o=>o.historyIndex<o.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}M(\"forward\",Rf);function Nf({className:e,id:t}){const n=S(o=>o.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ae({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),_(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}M(\"restart\",Nf);function Lf({className:e,id:t}){const n=S(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),_(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}M(\"quicksave\",Lf);function Mf({className:e,id:t}){const n=S(s=>s.load),r=S(s=>s.hasSave);S(s=>s.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",o=!r(),a=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ae({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:o,perform:()=>n()}),_(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:o,onClick:a,children:\"QuickLoad\"})}M(\"quickload\",Mf);function Vf({name:e,def:t}){const[n,r]=Y(()=>_t.get(e)),i=o=>{r(o),_t.set(e,o)};switch(t.type){case\"toggle\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"input\",{type:\"checkbox\",checked:!!n,onChange:o=>i(o.target.checked)})]});case\"list\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"select\",{value:String(n),onChange:o=>i(o.target.value),children:t.config.options.map(o=>_(\"option\",{value:o,children:o},o))})]});case\"range\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:[t.config.label,\": \",String(n)]}),_(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:o=>i(parseFloat(o.target.value))})]})}}function Bf({onClose:e}){const t=_t.getDefinitions();return _(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:_(\"div\",{class:\"settings-panel\",children:[_(\"div\",{class:\"settings-header\",children:[_(\"span\",{children:\"Settings\"}),_(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>_(Vf,{name:r,def:i},r))})]})})}function Hf({className:e,id:t}){const[n,r]=Y(!1);if(!_t.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return _(K,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&_(Bf,{onClose:()=>r(!1)})]})}M(\"settings\",Hf);function qf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Uf(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<30?`${o}d ago`:new Date(e).toLocaleDateString()}function jf(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Wf({onClose:e}){const[t,n]=Y(\"load\"),[r,i]=Y([]),[o,a]=Y(!0),[s,u]=Y(null),[l,h]=Y(()=>new Set),[c,d]=Y(null),[f,g]=Y(\"\"),k=pe(null),I=pe(null),b=S(E=>E.storyData),x=S(E=>E.playthroughId),w=S(E=>E.getSavePayload),F=S(E=>E.loadFromPayload),A=b?.ifid??\"\",v=ze(async()=>{if(!A)return;const E=await al(A);i(E),a(!1)},[A]);Ae(()=>{v()},[v]),Ae(()=>{c&&k.current&&(k.current.focus(),k.current.select())},[c]);const O=pe(),z=(E,p=\"success\")=>{clearTimeout(O.current),u({text:E,type:p}),O.current=window.setTimeout(()=>u(null),3e3)},V=E=>{h(p=>{const U=new Set(p);return U.has(E)?U.delete(E):U.add(E),U})},y=async()=>{if(!(!A||!x))try{const E=w();await _o(A,x,E),z(\"Save created\"),await v()}catch{z(\"Failed to create save\",\"error\")}},P=async E=>{try{const p=w();await yo(E,p),z(\"Save overwritten\"),await v()}catch{z(\"Failed to overwrite save\",\"error\")}},$=async E=>{try{F(E.payload),z(\"Game loaded\"),setTimeout(e,500)}catch{z(\"Failed to load save\",\"error\")}},H=async E=>{if(confirm(\"Delete this save?\"))try{await il(E),z(\"Save deleted\"),await v()}catch{z(\"Failed to delete save\",\"error\")}},q=E=>{d(E.meta.id),g(E.meta.title)},N=async()=>{if(!(!c||!f.trim()))try{await ol(c,f.trim()),d(null),z(\"Save renamed\"),await v()}catch{z(\"Failed to rename\",\"error\")}},J=E=>{E.key===\"Enter\"?N():E.key===\"Escape\"&&d(null)},Z=async E=>{try{const p=await ul(E);if(!p)return;const U=new Blob([JSON.stringify(p,null,2)],{type:\"application/json\"}),W=URL.createObjectURL(U),j=document.createElement(\"a\");j.href=W,j.download=`save-${p.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,j.click(),URL.revokeObjectURL(W),z(\"Save exported\")}catch{z(\"Failed to export save\",\"error\")}},le=()=>{I.current?.click()},ge=async E=>{const p=E.target,U=p.files?.[0];if(U){p.value=\"\";try{const W=await U.text(),j=JSON.parse(W);if(!qf(j))throw new Error(\"Invalid save file format\");await cl(j,A),z(\"Save imported\"),await v()}catch(W){z(W instanceof Error?W.message:\"Failed to import save\",\"error\")}}},m=E=>{E.target.classList.contains(\"saves-overlay\")&&e()},ue=r.reduce((E,p)=>E+p.saves.length,0);return _(\"div\",{class:\"saves-overlay\",onClick:m,children:_(\"div\",{class:\"saves-panel\",children:[_(\"div\",{class:\"saves-header\",children:[_(\"div\",{class:\"saves-header-left\",children:_(\"div\",{class:\"saves-mode-toggle\",children:[_(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),_(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),_(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"saves-toolbar\",children:[_(\"button\",{class:\"saves-toolbar-button\",onClick:le,children:\"Import\"}),_(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ge})]}),_(\"div\",{class:\"saves-body\",children:[o?_(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):ue===0&&t===\"load\"?_(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(E=>{const p=l.has(E.playthrough.id),U=E.playthrough.id===x;return t===\"save\"&&!U||t===\"load\"&&E.saves.length===0&&!U?null:_(\"div\",{class:\"playthrough-group\",children:[_(\"div\",{class:\"playthrough-header\",onClick:()=>V(E.playthrough.id),children:[_(\"span\",{class:`playthrough-chevron ${p?\"\":\"open\"}`,children:\"▶\"}),_(\"span\",{class:\"playthrough-label\",children:[E.playthrough.label,U?\" (current)\":\"\"]}),_(\"span\",{class:\"playthrough-date\",children:jf(E.playthrough.createdAt)})]}),!p&&_(\"div\",{class:\"playthrough-saves\",children:[E.saves.map(W=>_(\"div\",{class:\"save-slot\",children:[_(\"div\",{class:\"save-slot-info\",children:[c===W.meta.id?_(\"input\",{ref:k,class:\"save-rename-input\",value:f,onInput:j=>g(j.target.value),onKeyDown:J,onBlur:N}):_(\"div\",{class:\"save-slot-title\",children:W.meta.title}),_(\"div\",{class:\"save-slot-meta\",children:[_(\"span\",{children:W.meta.passage}),_(\"span\",{children:Uf(W.meta.updatedAt)})]})]}),_(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?_(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(W.meta.id),children:\"Save Here\"}):_(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(W),children:\"Load\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>q(W),children:\"Rename\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>Z(W.meta.id),children:\"Export\"}),_(\"button\",{class:\"save-slot-action danger\",onClick:()=>H(W.meta.id),children:\"Delete\"})]})]},W.meta.id)),t===\"save\"&&U&&_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})]})]},E.playthrough.id)}),t===\"save\"&&!o&&!r.some(E=>E.playthrough.id===x)&&_(\"div\",{class:\"playthrough-group\",children:_(\"div\",{class:\"playthrough-saves\",children:_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})})})]}),s&&_(\"div\",{class:`saves-status ${s.type===\"error\"?\"error\":\"\"}`,children:s.text})]})})}function Qf({className:e,id:t}){const[n,r]=Y(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return _(K,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&_(Wf,{onClose:()=>r(!1)})]})}M(\"saves\",Qf);function Gf({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const i=S(f=>f.storyData),[o,a,s]=$e();if(!i)return null;let u;try{const f=ve(e,o,a,s);u=String(f)}catch{u=e.replace(/^[\"']|[\"']$/g,\"\")}const l=i.passages.get(u);if(l&&S.getState().trackRender(u),!l)return _(\"span\",{class:\"error\",children:`{include${ie()}: passage \"${u}\" not found}`});const h=kt(l.content),c=St(h),d=me(c);return t||n?_(\"span\",{id:n,class:t,children:d}):_(K,{children:d})}M(\"include\",Gf);function Kf({rawArgs:e}){const[t,n,r]=$e();return xe(()=>{let i;try{const o=ve(e,t,n,r);i=String(o)}catch{i=e.replace(/^[\"']|[\"']$/g,\"\")}S.getState().navigate(i)},[]),null}M(\"goto\",Kf);function Yf({rawArgs:e}){const t=pe(!1);if(!t.current){t.current=!0;const n=S.getState(),r=e.trim();r.startsWith(\"$\")?n.deleteVariable(r.slice(1)):r.startsWith(\"_\")?n.deleteTemporary(r.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${r}\"`)}return null}M(\"unset\",Yf);function Zf(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Jf({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Zf(e),o=r.startsWith(\"$\")?r.slice(1):r,a=S(l=>l.variables[o]),s=S(l=>l.setVariable);ae({type:\"textbox\",key:`$${o}`,authorId:n,label:i||o,variable:o,value:a,perform:l=>s(o,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return _(\"input\",{type:\"text\",id:n,class:u,value:a==null?\"\":String(a),placeholder:i,onInput:l=>s(o,l.target.value)})}M(\"textbox\",Jf);function Xf(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function eh({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Xf(e),o=r.startsWith(\"$\")?r.slice(1):r,a=S(l=>l.variables[o]),s=S(l=>l.setVariable);ae({type:\"numberbox\",key:`$${o}`,authorId:n,label:i||o,variable:o,value:a,perform:l=>s(o,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return _(\"input\",{type:\"number\",id:n,class:u,value:a==null?\"\":String(a),placeholder:i,onInput:l=>{const h=l.target.value;s(o,h===\"\"?0:Number(h))}})}M(\"numberbox\",eh);function th(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function nh({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=th(e),o=r.startsWith(\"$\")?r.slice(1):r,a=S(l=>l.variables[o]),s=S(l=>l.setVariable);ae({type:\"textarea\",key:`$${o}`,authorId:n,label:i||o,variable:o,value:a,perform:l=>s(o,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return _(\"textarea\",{id:n,class:u,value:a==null?\"\":String(a),placeholder:i,onInput:l=>s(o,l.target.value)})}M(\"textarea\",nh);function rh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}function ih({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=rh(e),o=r.startsWith(\"$\")?r.slice(1):r,a=S(l=>l.variables[o]),s=S(l=>l.setVariable);ae({type:\"checkbox\",key:`$${o}`,authorId:n,label:i||o,variable:o,value:!!a,perform:l=>s(o,l!==void 0?!!l:!a)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return _(\"label\",{id:n,class:u,children:[_(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>s(o,!a)}),i?` ${i}`:null]})}M(\"checkbox\",ih);function oh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}function ah({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:o}=oh(e),a=r.startsWith(\"$\")?r.slice(1):r,s=S(h=>h.variables[a]),u=S(h=>h.setVariable);ae({type:\"radiobutton\",key:`$${a}:${i}`,authorId:n,label:o||i,variable:a,value:s,perform:()=>u(a,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return _(\"label\",{id:n,class:l,children:[_(\"input\",{type:\"radio\",name:`radio-${a}`,checked:s===i,onChange:()=>u(a,i)}),o?` ${o}`:null]})}M(\"radiobutton\",ah);function Uo(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function sh({rawArgs:e,children:t=[],className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),o=i.startsWith(\"$\")?i.slice(1):i,a=S(h=>h.variables[o]),s=S(h=>h.setVariable),u=Uo(t);ae({type:\"listbox\",key:`$${o}`,authorId:r,label:o,variable:o,options:u,value:a,perform:h=>{h!==void 0&&s(o,String(h))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return _(\"select\",{id:r,class:l,value:a==null?\"\":String(a),onChange:h=>s(o,h.target.value),children:u.map(h=>_(\"option\",{value:h,children:h},h))})}M(\"listbox\",sh);fn(\"option\");function lh({rawArgs:e,children:t=[],className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),o=i.startsWith(\"$\")?i.slice(1):i,a=S(c=>c.variables[o]),s=S(c=>c.setVariable),u=Uo(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(a))+1)%u.length;s(o,u[d])};ae({type:\"cycle\",key:`$${o}`,authorId:r,label:a==null?u[0]||\"\":String(a),variable:o,options:u,value:a,perform:c=>{c!==void 0?s(o,c):l()}});const h=n?`macro-cycle ${n}`:\"macro-cycle\";return _(\"button\",{id:r,class:h,onClick:l,children:a==null?u[0]||\"\":String(a)})}M(\"cycle\",lh);function uh({passage:e}){const t=Pe(()=>{try{const n=kt(e.content),r=St(n);return me(r)}catch(n){return _(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Ho(e),\": \",n.message]})}},[e.content,e.name]);return _(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}function ch({className:e,id:t}){const n=de();e=n(e),t=n(t);const r=S(a=>a.currentPassage),o=S(a=>a.storyData)?.passages.get(r);return o?_(\"div\",{id:t??\"story\",class:e??\"story\",children:_(uh,{passage:o},r)}):_(\"div\",{class:\"error\",children:[\"Error: Passage “\",r,\"” not found.\"]})}M(\"passage\",ch);function wi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const o of t){const a=document.createElement(\"li\");a.textContent=o,i.appendChild(a)}n.appendChild(i),e.appendChild(n)}function Ci(){const e=Jc();if(tf(),e.userCSS){const u=document.createElement(\"style\");u.textContent=e.userCSS,document.head.appendChild(u)}if(e.userScript)try{new Function(e.userScript)()}catch(u){console.error(\"spindle: Error in story JavaScript:\",u)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const u=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",l=document.getElementById(\"root\");throw l&&wi(l,[u]),new Error(`spindle: ${u}`)}const r=of(n.content),i=lf(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&wi(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=uf(r),S.getState().init(e,t),vo();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=kt(u.content),h=St(l);for(const c of h)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),f=d[0].replace(/[\"']/g,\"\"),g=d.slice(1).filter(k=>k.startsWith(\"$\")||k.startsWith(\"_\")||k.startsWith(\"@\"));wo(f,c.children,g)}}let o=\"\";S.subscribe(u=>{u.currentPassage!==o&&(o=u.currentPassage,ml())});const a=e.passages.get(\"StoryInterface\");a&&!a.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const s=document.getElementById(\"root\");if(!s)throw new Error('spindle: No <div id=\"root\"> element found.');Je(_(Zc,{}),s),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Ci):Ci();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.18.1","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Nt,R,Mi,He,Fr,Li,Vi,Bi,ar,Nn,$n,Hi,Xt={},en=[],To=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$t=Array.isArray;function Se(e,t){for(var n in t)e[n]=t[n];return e}function or(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function le(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Nt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return vt(e,o,r,i,null)}function vt(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Mi,__i:-1,__u:0};return i==null&&R.vnode!=null&&R.vnode(a),a}function No(){return{current:null}}function K(e){return e.children}function we(e,t){this.props=e,this.context=t}function it(e,t){if(t==null)return e.__?it(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?it(e):null}function $o(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Se({},t);a.__v=t.__v+1,R.vnode&&R.vnode(a),sr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??it(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Wi(r,a,i),t.__e=t.__=null,a.__e!=n&&Ui(a)}}function Ui(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ui(e)}function Fn(e){(!e.__d&&(e.__d=!0)&&He.push(e)&&!tn.__r++||Fr!=R.debounceRendering)&&((Fr=R.debounceRendering)||Li)(tn)}function tn(){for(var e,t=1;He.length;)He.length>t&&He.sort(Vi),e=He.shift(),t=He.length,$o(e);tn.__r=0}function qi(e,t,n,r,i,a,o,s,u,l,f){var c,d,h,p,w,x,_,v=r&&r.__k||en,k=t.length;for(u=Fo(n,t,v,u,k),c=0;c<k;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&v[h.__i]||Xt,h.__i=c,x=sr(e,h,d,i,a,o,s,u,l,f),p=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&lr(d.ref,null,h),f.push(h.ref,h.__c||p,h)),w==null&&p!=null&&(w=p),(_=!!(4&h.__u))||d.__k===h.__k?u=ji(h,u,e,_):typeof h.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),h.__u&=-7);return n.__e=w,u}function Fo(e,t,n,r,i){var a,o,s,u,l,f=n.length,c=f,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=vt(null,o,null,null,null):$t(o)?o=e.__k[a]=vt(K,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=vt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+d,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=zo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>f?d--:i<f&&d++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=it(s)),Gi(s,s));return r}function ji(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=ji(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=it(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ee(e,t){return t=t||[],e==null||typeof e==\"boolean\"||($t(e)?e.some(function(n){Ee(n,t)}):t.push(e)),t}function zo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&u==l.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function zr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||To.test(t)?n:n+\"px\"}function Bt(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||zr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||zr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Bi,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=ar,e.addEventListener(t,a?$n:Nn,a)):e.removeEventListener(t,a?$n:Nn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Or(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=ar++;else if(t.t<n.u)return;return n(R.event?R.event(t):t)}}}function sr(e,t,n,r,i,a,o,s,u,l){var f,c,d,h,p,w,x,_,v,k,E,C,y,D,F,O=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=R.__b)&&f(t);e:if(typeof O==\"function\")try{if(_=t.props,v=\"prototype\"in O&&O.prototype.render,k=(f=O.contextType)&&r[f.__c],E=f?k?k.props.value:f.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(v?t.__c=c=new O(_,E):(t.__c=c=new we(_,E),c.constructor=O,c.render=Ro),k&&k.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),v&&c.__s==null&&(c.__s=c.state),v&&O.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Se({},c.__s)),Se(c.__s,O.getDerivedStateFromProps(_,c.__s))),h=c.props,p=c.state,c.__v=t,d)v&&O.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),v&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(v&&O.getDerivedStateFromProps==null&&_!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,E),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,E)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),en.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),v&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,p,w)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,C=R.__r,y=0,v)c.state=c.__s,c.__d=!1,C&&C(t),f=c.render(c.props,c.state,c.context),en.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,C&&C(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Se(Se({},r),c.getChildContext())),v&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,p)),D=f!=null&&f.type===K&&f.key==null?Qi(f.props.children):f,s=qi(e,$t(D)?D:[D],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(F=a.length;F--;)or(a[F]);zn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||zn(t);R.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Oo(n.__e,t,n,r,i,a,o,u,l);return(f=R.diffed)&&f(t),128&t.__u?void 0:s}function zn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(zn))}function Wi(e,t,n){for(var r=0;r<n.length;r++)lr(n[r],n[++r],n[++r]);R.__c&&R.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){R.__e(a,i.__v)}})}function Qi(e){return typeof e!=\"object\"||e==null||e.__b>0?e:$t(e)?e.map(Qi):Se({},e)}function Oo(e,t,n,r,i,a,o,s,u){var l,f,c,d,h,p,w,x=n.props||Xt,_=t.props,v=t.type;if(v==\"svg\"?i=\"http://www.w3.org/2000/svg\":v==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&\"setAttribute\"in h==!!v&&(v?h.localName==v:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&(R.__m&&R.__m(t,a),s=!1),a=null}if(v==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Nt.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(h=e.attributes[l]).name]=h.value;for(l in x)h=x[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Bt(e,l,null,h,i);for(l in _)h=_[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?p=h:l==\"checked\"?w=h:s&&typeof h!=\"function\"||x[l]===h||Bt(e,l,h,x[l],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),qi(t.type==\"template\"?e.content:e,$t(d)?d:[d],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&it(n,0),s,u),a!=null)for(l=a.length;l--;)or(a[l]);s||(l=\"value\",v==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||v==\"progress\"&&!p||v==\"option\"&&p!=x[l])&&Bt(e,l,p,x[l],i),l=\"checked\",w!=null&&w!=e[l]&&Bt(e,l,w,x[l],i))}return e}function lr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){R.__e(i,n)}}function Gi(e,t,n){var r,i;if(R.unmount&&R.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||lr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){R.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Gi(r[i],t,n||typeof e.type!=\"function\");n||or(e.__e),e.__c=e.__=e.__e=void 0}function Ro(e,t,n){return this.constructor(e,n)}function at(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),R.__&&R.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],sr(t,e=(!r&&n||t).__k=le(K,null,[e]),i||Xt,Xt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Nt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Wi(a,e,o)}function Ki(e,t){at(e,t,Ki)}function Mo(e,t,n){var r,i,a,o,s=Se({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?Nt.call(arguments,2):n),vt(e.type,s,r||e.key,i||e.ref,null)}function Ft(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,Fn(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+Hi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Nt=en.slice,R={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Mi=0,we.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Se({},this.state),typeof e==\"function\"&&(e=e(Se({},n),this.props)),e&&Se(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Fn(this))},we.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Fn(this))},we.prototype.render=K,He=[],Li=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Vi=function(e,t){return e.__v.__b-t.__v.__b},tn.__r=0,Bi=/(PointerCapture)$|Capture$/i,ar=0,Nn=Or(!1),$n=Or(!0),Hi=0;var Lo=0;function S(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lo,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return R.vnode&&R.vnode(l),l}var Fe,W,wn,Rr,ot=0,Yi=[],Q=R,Mr=Q.__b,Lr=Q.__r,Vr=Q.diffed,Br=Q.__c,Hr=Q.unmount,Ur=Q.__;function ut(e,t){Q.__h&&Q.__h(W,e,ot||t),ot=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function te(e){return ot=1,ur(ea,e)}function ur(e,t,n){var r=ut(Fe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ea(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(d){return d.__c});if(f.every(function(d){return!d.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return f.some(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var f=a;a=void 0,i(s,u,l),a=f}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function ze(e,t){var n=ut(Fe++,3);!Q.__s&&cr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function Ze(e,t){var n=ut(Fe++,4);!Q.__s&&cr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function Ae(e){return ot=5,ce(function(){return{current:e}},[])}function Zi(e,t,n){ot=6,Ze(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function ce(e,t){var n=ut(Fe++,7);return cr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return ot=8,ce(function(){return e},t)}function Te(e){var t=W.context[e.__c],n=ut(Fe++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ji(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function Xi(){var e=ut(Fe++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function Vo(){for(var e;e=Yi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Gt),t.__h.some(On),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Mr&&Mr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ur&&Ur(e,t)},Q.__r=function(e){Lr&&Lr(e),Fe=0;var t=(W=e.__c).__H;t&&(wn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Gt),t.__h.some(On),t.__h=[],Fe=0)),wn=W},Q.diffed=function(e){Vr&&Vr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Yi.push(t)!==1&&Rr===Q.requestAnimationFrame||((Rr=Q.requestAnimationFrame)||Bo)(Vo)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),wn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Gt),n.__h=n.__h.filter(function(r){return!r.__||On(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Br&&Br(e,t)},Q.unmount=function(e){Hr&&Hr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Gt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var qr=typeof requestAnimationFrame==\"function\";function Bo(e){var t,n=function(){clearTimeout(r),qr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);qr&&(t=requestAnimationFrame(n))}function Gt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function On(e){var t=W;e.__c=e.__(),W=t}function cr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ea(e,t){return typeof t==\"function\"?t(e):t}const jr=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(h=>h(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},Ho=(e=>e?jr(e):jr);function ta(e,t){for(var n in t)e[n]=t[n];return e}function Rn(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function na(e,t){var n=t(),r=te({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Ze(function(){i.__=n,i.u=t,kn(i)&&a({t:i})},[e,n,t]),ze(function(){return kn(i)&&a({t:i}),e(function(){kn(i)&&a({t:i})})},[e]),n}function kn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function ra(e){e()}function ia(e){return e}function aa(){return[!1,ra]}var oa=Ze;function Mn(e,t){this.props=e,this.context=t}function Uo(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:Rn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,le(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Mn.prototype=new we).isPureReactComponent=!0,Mn.prototype.shouldComponentUpdate=function(e,t){return Rn(this.props,e)||Rn(this.state,t)};var Wr=R.__b;R.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Wr&&Wr(e)};var qo=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function jo(e){function t(n){var r=ta({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=qo,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Qr=function(e,t){return e==null?null:Ee(Ee(e).map(t))},Wo={map:Qr,forEach:Qr,count:function(e){return e?Ee(e).length:0},only:function(e){var t=Ee(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ee},Qo=R.__e;R.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Qo(e,t,n,r)};var Gr=R.unmount;function sa(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=ta({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return sa(r,t,n)})),e}function la(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return la(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Kt(){this.__u=0,this.o=null,this.__b=null}function ua(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Go(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?le(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function yt(){this.i=null,this.l=null}R.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Gr&&Gr(e)},(Kt.prototype=new we).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ua(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=la(l,l.__c.__P,l.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=s,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Kt.prototype.componentWillUnmount=function(){this.o=[]},Kt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=sa(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&le(K,null,e.fallback);return i&&(i.__u&=-33),[le(K,null,t.__a?null:e.children),i]};var Kr=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Ko(e){return this.getChildContext=function(){return e.context},e.children}function Yo(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){at(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}at(le(Ko,{context:t.context},e.__v),t.v)}function Zo(e,t){var n=le(Yo,{__v:e,h:t});return n.containerInfo=t,n}(yt.prototype=new we).__a=function(e){var t=this,n=ua(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Kr(t,e,r)):i()};n?n(a):a()}},yt.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ee(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},yt.prototype.componentDidUpdate=yt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Kr(e,n,t)})};var ca=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Jo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Xo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,es=/[A-Z0-9]/g,ts=typeof document<\"u\",ns=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function rs(e,t,n){return t.__k==null&&(t.textContent=\"\"),at(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function is(e,t,n){return Ki(e,t),typeof n==\"function\"&&n(),e?e.__c:null}we.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(we.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Yr=R.event;function as(){}function os(){return this.cancelBubble}function ss(){return this.defaultPrevented}R.event=function(e){return Yr&&(e=Yr(e)),e.persist=as,e.isPropagationStopped=os,e.isDefaultPrevented=ss,e.nativeEvent=e};var fr,ls={enumerable:!1,configurable:!0,get:function(){return this.class}},Zr=R.vnode;R.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||ts&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ns(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":Xo.test(o)&&(o=u):u=o=\"oninput\":a&&Jo.test(o)?o=o.replace(es,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ee(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ee(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",ls)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=ca,Zr&&Zr(e)};var Jr=R.__r;R.__r=function(e){Jr&&Jr(e),fr=e.__c};var Xr=R.diffed;R.diffed=function(e){Xr&&Xr(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),fr=null};var us={ReactCurrentDispatcher:{current:{readContext:function(e){return fr.__n[e.__c].props.value},useCallback:Pe,useContext:Te,useDebugValue:Ji,useDeferredValue:ia,useEffect:ze,useId:Xi,useImperativeHandle:Zi,useInsertionEffect:oa,useLayoutEffect:Ze,useMemo:ce,useReducer:ur,useRef:Ae,useState:te,useSyncExternalStore:na,useTransition:aa}}};function cs(e){return le.bind(null,e)}function dn(e){return!!e&&e.$$typeof===ca}function fs(e){return dn(e)&&e.type===K}function hs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function ds(e){return dn(e)?Mo.apply(null,arguments):e}function ps(e){return!!e.__k&&(at(null,e),!0)}function ms(e){return e&&(e.base||e.nodeType===1&&e)||null}var gs=function(e,t){return e(t)},_s=function(e,t){return e(t)},ys=K,bs=dn,Ht={useState:te,useId:Xi,useReducer:ur,useEffect:ze,useLayoutEffect:Ze,useInsertionEffect:oa,useTransition:aa,useDeferredValue:ia,useSyncExternalStore:na,startTransition:ra,useRef:Ae,useImperativeHandle:Zi,useMemo:ce,useCallback:Pe,useContext:Te,useDebugValue:Ji,version:\"18.3.1\",Children:Wo,render:rs,hydrate:is,unmountComponentAtNode:ps,createPortal:Zo,createElement:le,createContext:Ft,createFactory:cs,cloneElement:ds,createRef:No,Fragment:K,isValidElement:dn,isElement:bs,isFragment:fs,isMemo:hs,findDOMNode:ms,Component:we,PureComponent:Mn,memo:Uo,forwardRef:jo,flushSync:_s,unstable_batchedUpdates:gs,StrictMode:ys,Suspense:Kt,SuspenseList:yt,lazy:Go,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:us};const vs=e=>e;function Ss(e,t=vs){const n=Ht.useSyncExternalStore(e.subscribe,Ht.useCallback(()=>t(e.getState()),[e,t]),Ht.useCallback(()=>t(e.getInitialState()),[e,t]));return Ht.useDebugValue(n),n}const ws=e=>{const t=Ho(e),n=r=>Ss(t,r);return Object.assign(n,t),n},ks=(e=>ws);var hr=Symbol.for(\"immer-nothing\"),St=Symbol.for(\"immer-draftable\"),X=Symbol.for(\"immer-state\");function re(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var fe=Object,Qe=fe.getPrototypeOf,xt=\"constructor\",zt=\"prototype\",Ln=\"configurable\",nn=\"enumerable\",Yt=\"writable\",Ct=\"value\",De=e=>!!e&&!!e[X];function ke(e){return e?fa(e)||Rt(e)||!!e[St]||!!e[xt]?.[St]||Mt(e)||Lt(e):!1}var xs=fe[zt][xt].toString(),ei=new WeakMap;function fa(e){if(!e||!st(e))return!1;const t=Qe(e);if(t===null||t===fe[zt])return!0;const n=fe.hasOwnProperty.call(t,xt)&&t[xt];if(n===Object)return!0;if(!Ue(n))return!1;let r=ei.get(n);return r===void 0&&(r=Function.toString.call(n),ei.set(n,r)),r===xs}function Ot(e,t,n=!0){Ge(e)===0?(n?Reflect.ownKeys(e):fe.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Ge(e){const t=e[X];return t?t.type_:Rt(e)?1:Mt(e)?2:Lt(e)?3:0}var wt=(e,t,n=Ge(e))=>n===2?e.has(t):fe[zt].hasOwnProperty.call(e,t),Ce=(e,t,n=Ge(e))=>n===2?e.get(t):e[t],rn=(e,t,n,r=Ge(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Cs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Rt=Array.isArray,Mt=e=>e instanceof Map,Lt=e=>e instanceof Set,st=e=>typeof e==\"object\",Ue=e=>typeof e==\"function\",xn=e=>typeof e==\"boolean\";function Is(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Es=e=>st(e)?e?.[X]:null,Ie=e=>e.copy_||e.base_,dr=e=>e.modified_?e.copy_:e.base_;function Vn(e,t){if(Mt(e))return new Map(e);if(Lt(e))return new Set(e);if(Rt(e))return Array[zt].slice.call(e);const n=fa(e);if(t===!0||t===\"class_only\"&&!n){const r=fe.getOwnPropertyDescriptors(e);delete r[X];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Yt]===!1&&(s[Yt]=!0,s[Ln]=!0),(s.get||s.set)&&(r[o]={[Ln]:!0,[Yt]:!0,[nn]:s[nn],[Ct]:e[o]})}return fe.create(Qe(e),r)}else{const r=Qe(e);if(r!==null&&n)return{...e};const i=fe.create(r);return fe.assign(i,e)}}function pr(e,t=!1){return pn(e)||De(e)||!ke(e)||(Ge(e)>1&&fe.defineProperties(e,{set:Ut,add:Ut,clear:Ut,delete:Ut}),fe.freeze(e),t&&Ot(e,(n,r)=>{pr(r,!0)},!1)),e}function As(){re(2)}var Ut={[Ct]:As};function pn(e){return e===null||!st(e)?!0:fe.isFrozen(e)}var an=\"MapSet\",on=\"Patches\",ti=\"ArrayMethods\",sn={};function Ke(e){const t=sn[e];return t||re(0,e),t}var ni=e=>!!sn[e];function Ps(e,t){sn[e]||(sn[e]=t)}var It,ha=()=>It,Ds=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ni(an)?Ke(an):void 0,arrayMethodsPlugin_:ni(ti)?Ke(ti):void 0});function ri(e,t){t&&(e.patchPlugin_=Ke(on),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Bn(e){Hn(e),e.drafts_.forEach(Ts),e.drafts_=null}function Hn(e){e===It&&(It=e.parent_)}var ii=e=>It=Ds(It,e);function Ts(e){const t=e[X];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ai(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[X].modified_&&(Bn(t),re(4)),ke(e)&&(e=oi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[X].base_,e,t)}else e=oi(t,n);return Ns(t,e,!0),Bn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hr?e:void 0}function oi(e,t){if(pn(t))return t;const n=t[X];if(!n)return ln(t,e.handledSet_,e);if(!mn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);ma(n,e)}return n.copy_}function Ns(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&pr(t,n)}function da(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var mn=(e,t)=>e.scope_===t,$s=[];function pa(e,t,n,r){const i=Ie(e),a=e.type_;if(r!==void 0&&Ce(i,r,a)===t){rn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ot(i,(u,l)=>{if(De(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??$s;for(const s of o)rn(i,s,n,a)}function Fs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!mn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=dr(a);pa(e,a.draft_??a,o,n),ma(a,i)})}function ma(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}da(e)}}function zs(e,t,n){const{scope_:r}=e;if(De(n)){const i=n[X];mn(i,r)&&i.callbacks_.push(function(){Zt(e);const o=dr(i);pa(e,n,o,t)})}else ke(n)&&e.callbacks_.push(function(){const a=Ie(e);e.type_===3?a.has(n)&&ln(n,r.handledSet_,r):Ce(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&ln(Ce(e.copy_,t,e.type_),r.handledSet_,r)})}function ln(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||De(e)||t.has(e)||!ke(e)||pn(e)||(t.add(e),Ot(e,(r,i)=>{if(De(i)){const a=i[X];if(mn(a,n)){const o=dr(a);rn(e,r,o,e.type_),da(a)}}else ke(i)&&ln(i,t,n)})),e}function Os(e,t){const n=Rt(e),r={type_:n?1:0,scope_:t?t.scope_:ha(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=un;n&&(i=[r],a=Et);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var un={get(e,t){if(t===X)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Ie(e);if(!wt(i,t,e.type_))return Rs(e,i,t);const a=i[t];if(e.finalized_||!ke(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Is(t))return a;if(a===Cn(e.base_,t)){Zt(e);const o=e.type_===1?+t:t,s=qn(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Ie(e)},ownKeys(e){return Reflect.ownKeys(Ie(e))},set(e,t,n){const r=ga(Ie(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Cn(Ie(e),t),a=i?.[X];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Cs(n,i)&&(n!==void 0||wt(e.base_,t,e.type_)))return!0;Zt(e),Un(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),zs(e,t,n)),!0},deleteProperty(e,t){return Zt(e),Cn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Un(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ie(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Yt]:!0,[Ln]:e.type_!==1||t!==\"length\",[nn]:r[nn],[Ct]:n[t]}},defineProperty(){re(11)},getPrototypeOf(e){return Qe(e.base_)},setPrototypeOf(){re(12)}},Et={};for(let e in un){let t=un[e];Et[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Et.deleteProperty=function(e,t){return Et.set.call(this,e,t,void 0)};Et.set=function(e,t,n){return un.set.call(this,e[0],t,n,e[0])};function Cn(e,t){const n=e[X];return(n?Ie(n):e)[t]}function Rs(e,t,n){const r=ga(t,n);return r?Ct in r?r[Ct]:r.get?.call(e.draft_):void 0}function ga(e,t){if(!(t in e))return;let n=Qe(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Qe(n)}}function Un(e){e.modified_||(e.modified_=!0,e.parent_&&Un(e.parent_))}function Zt(e){e.copy_||(e.assigned_=new Map,e.copy_=Vn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ms=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ue(t)&&!Ue(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,f=>n.call(this,f,...l))}}Ue(n)||re(6),r!==void 0&&!Ue(r)&&re(7);let i;if(ke(t)){const a=ii(this),o=qn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Bn(a):Hn(a)}return ri(a,r),ai(i,a)}else if(!t||!st(t)){if(i=n(t),i===void 0&&(i=t),i===hr&&(i=void 0),this.autoFreeze_&&pr(i,!0),r){const a=[],o=[];Ke(on).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else re(1,t)},this.produceWithPatches=(t,n)=>{if(Ue(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},xn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),xn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),xn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ke(e)||re(8),De(e)&&(e=Ls(e));const t=ii(this),n=qn(t,e,void 0);return n[X].isManual_=!0,Hn(t),n}finishDraft(e,t){const n=e&&e[X];(!n||!n.isManual_)&&re(9);const{scope_:r}=n;return ri(r,t),ai(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ke(on).applyPatches_;return De(e)?r(e,t):this.produce(e,i=>r(i,t))}};function qn(e,t,n,r){const[i,a]=Mt(t)?Ke(an).proxyMap_(t,n):Lt(t)?Ke(an).proxySet_(t,n):Os(t,n);return(n?.scope_??ha()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Fs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Ls(e){return De(e)||re(10,e),_a(e)}function _a(e){if(!ke(e)||pn(e))return e;const t=e[X];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Vn(e,!0);return Ot(n,(i,a)=>{rn(n,i,_a(a))},r),t&&(t.finalized_=!1),n}function Vs(){function t(p,w=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Es(Ce(x,p.key_)),v=Ce(x,p.key_);if(v===void 0||v!==p.draft_&&v!==p.base_&&v!==p.copy_||_!=null&&_.base_!==p.base_)return null;const k=p.parent_.type_===3;let E;if(k){const C=p.parent_;E=Array.from(C.drafts_.keys()).indexOf(p.key_)}else E=p.key_;if(!(k&&x.size>E||wt(x,E)))return null;w.push(E)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let x=p;for(let _=0;_<w.length-1;_++){const v=w[_];if(x=Ce(x,v),!st(x)||x===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:v}=x;switch(p.type_){case 0:case 2:return u(p,w,_,v);case 1:return s(p,w,_,v);case 3:return l(p,w,_,v)}}function s(p,w,x,_){let{base_:v,assigned_:k}=p,E=p.copy_;E.length<v.length&&([v,E]=[E,v],[x,_]=[_,x]);const C=p.allIndicesReassigned_===!0;for(let y=0;y<v.length;y++){const D=E[y],F=v[y];if((C||k?.get(y.toString()))&&D!==F){const b=D?.[X];if(b&&b.modified_)continue;const P=w.concat([y]);x.push({op:r,path:P,value:h(D)}),_.push({op:r,path:P,value:h(F)})}}for(let y=v.length;y<E.length;y++){const D=w.concat([y]);x.push({op:i,path:D,value:h(E[y])})}for(let y=E.length-1;v.length<=y;--y){const D=w.concat([y]);_.push({op:a,path:D})}}function u(p,w,x,_){const{base_:v,copy_:k,type_:E}=p;Ot(p.assigned_,(C,y)=>{const D=Ce(v,C,E),F=Ce(k,C,E),O=y?wt(v,C)?r:i:a;if(D===F&&O===r)return;const b=w.concat(C);x.push(O===a?{op:O,path:b}:{op:O,path:b,value:h(F)}),_.push(O===i?{op:a,path:b}:O===a?{op:i,path:b,value:h(D)}:{op:r,path:b,value:h(D)})})}function l(p,w,x,_){let{base_:v,copy_:k}=p,E=0;v.forEach(C=>{if(!k.has(C)){const y=w.concat([E]);x.push({op:a,path:y,value:C}),_.unshift({op:i,path:y,value:C})}E++}),E=0,k.forEach(C=>{if(!v.has(C)){const y=w.concat([E]);x.push({op:i,path:y,value:C}),_.unshift({op:a,path:y,value:C})}E++})}function f(p,w,x){const{patches_:_,inversePatches_:v}=x;_.push({op:r,path:[],value:w===hr?void 0:w}),v.push({op:r,path:[],value:p})}function c(p,w){return w.forEach(x=>{const{path:_,op:v}=x;let k=p;for(let D=0;D<_.length-1;D++){const F=Ge(k);let O=_[D];typeof O!=\"string\"&&typeof O!=\"number\"&&(O=\"\"+O),(F===0||F===1)&&(O===\"__proto__\"||O===xt)&&re(19),Ue(k)&&O===zt&&re(19),k=Ce(k,O),st(k)||re(18,_.join(\"/\"))}const E=Ge(k),C=d(x.value),y=_[_.length-1];switch(v){case r:switch(E){case 2:return k.set(y,C);case 3:re(16);default:return k[y]=C}case i:switch(E){case 1:return y===\"-\"?k.push(C):k.splice(y,0,C);case 2:return k.set(y,C);case 3:return k.add(C);default:return k[y]=C}case a:switch(E){case 1:return k.splice(y,1);case 2:return k.delete(y);case 3:return k.delete(x.value);default:return delete k[y]}default:re(17,v)}}),p}function d(p){if(!ke(p))return p;if(Rt(p))return p.map(d);if(Mt(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,d(_)]));if(Lt(p))return new Set(Array.from(p).map(d));const w=Object.create(Qe(p));for(const x in p)w[x]=d(p[x]);return wt(p,St)&&(w[St]=p[St]),w}function h(p){return De(p)?d(p):p}Ps(on,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var At=new Ms,Bs=At.produce,Hs=At.produceWithPatches.bind(At),rt=At.applyPatches.bind(At);const Us=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Bs(i):i;return t(s,a,...o)},e(r.setState,n,r)),qs=Us,js=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),Ws=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Qs(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function si(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function li(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function Gs(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function ct(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=li(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const f=e.slice(l,n);n+=2;const{display:c,target:d}=Qs(f),h={type:\"link\",display:c,target:d,start:a,end:n};o&&(h.className=o),s&&(h.id=s),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=li(e,n+1);s=l.className||void 0,u=l.id||void 0;let f=l.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let d=1;const h=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const p=e.slice(h,n);n++;const{name:w,rawArgs:x,isClose:_}=si(p),v={type:\"macro\",name:w,rawArgs:x,isClose:_,start:a,end:n};s&&(v.className=s),u&&(v.id=u),t.push(v),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const f=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:d,rawArgs:h,isClose:p}=si(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&js.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const f=Gs(e,o);o=f.endIdx;let c=Ws.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ks=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\"]),ui={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Ys=new Set([\"if\",\"switch\",\"timed\"]);function ft(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const o=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${o} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(ui[i.name]){const a=ui[i.name],o=n.length>0?n[n.length-1].node:null;if(!o||o.type!==\"macro\"||o.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches.push(s);break}if(Ks.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(Ys.has(i.name)){const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),a.branches=[o]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function ya(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function ba(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let ht=!1,Vt=\"\",Ye=0,lt=null;function Zs(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Vt=n,Ye=0,lt=ya(ba(n)),ht=!0}function va(e,t){Vt=e,Ye=0,lt=ya(ba(e)),ht=!0;for(let n=0;n<t;n++)lt();Ye=t}function jn(){ht=!1,Vt=\"\",Ye=0,lt=null}function cn(){return ht?{seed:Vt,pull:Ye}:null}function mr(){return!ht||!lt?Math.random():(Ye++,lt())}function Sa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(mr()*(t-e+1))+e}function Js(){return ht}function Xs(){return Vt}function el(){return Ye}const tl=500,Be=new Map,nl=/\\$(\\w+)/g,rl=/\\b_(\\w+)/g,il=/@(\\w+)/g;function al(e){return e.replace(nl,'variables[\"$1\"]').replace(rl,'temporary[\"$1\"]').replace(il,'locals[\"$1\"]')}function gr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=al(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=gr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const ol=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function wa(e,t){const n=Be.get(e);if(n)return Be.delete(e),Be.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",ol+t);if(Be.set(e,r),Be.size>tl){const i=Be.keys().next().value;i!==void 0&&Be.delete(i)}return r}let qt=null,ci=null,fi=null;function ka(){const e=A.getState(),{visitCounts:t,renderCounts:n}=e;if(qt&&ci===t&&fi===n)return qt;const r=h=>t[h??A.getState().currentPassage]??0,i=h=>r(h)>0,a=(...h)=>h.some(p=>r(p)>0),o=(...h)=>h.every(p=>r(p)>0),s=h=>n[h??A.getState().currentPassage]??0;return qt={currentPassage:()=>{const h=A.getState();return h.storyData?.passages.get(h.currentPassage)},previousPassage:()=>{const h=A.getState();if(h.historyIndex<=0)return;const p=h.history[h.historyIndex-1]?.passage;return p?h.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:h=>s(h)>0,hasRenderedAny:(...h)=>h.some(p=>s(p)>0),hasRenderedAll:(...h)=>h.every(p=>s(p)>0),random:mr,randomInt:Sa},ci=t,fi=n,qt}function _r(e,t,n,r={}){const a=`return (${gr(e)});`;return wa(a,a)(t,n,r,ka())}function Wn(e,t,n,r={}){const i=gr(e);wa(\"exec:\"+i,i)(t,n,r,ka())}const sl=\"spindle\",ll=1;let jt=null,In=null;function Re(){return In||(In={saves:new Map,playthroughs:new Map,meta:new Map}),In}function ul(){return jt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(jt=new Promise((e,t)=>{const n=indexedDB.open(sl,ll);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),jt))}function Me(e,t){return ul().then(n=>n.transaction(e,t).objectStore(e))}function Le(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function gn(e){try{const t=await Me(\"saves\",\"readwrite\");await Le(t.put(e))}catch{Re().saves.set(e.meta.id,e)}}async function _n(e){try{const t=await Me(\"saves\",\"readonly\");return await Le(t.get(e))??void 0}catch{return Re().saves.get(e)}}async function cl(e){try{const t=await Me(\"saves\",\"readwrite\");await Le(t.delete(e))}catch{Re().saves.delete(e)}}async function fl(e){try{const n=(await Me(\"saves\",\"readonly\")).index(\"ifid\");return await Le(n.getAll(e))??[]}catch{return[...Re().saves.values()].filter(t=>t.meta.ifid===e)}}async function xa(e){try{const t=await Me(\"playthroughs\",\"readwrite\");await Le(t.put(e))}catch{Re().playthroughs.set(e.id,e)}}async function yr(e){try{const n=(await Me(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Le(n.getAll(e))??[]}catch{return[...Re().playthroughs.values()].filter(t=>t.ifid===e)}}async function br(e){try{const t=await Me(\"meta\",\"readonly\"),n=await Le(t.get(e));return n?n.value:void 0}catch{return Re().meta.get(e)}}async function Ca(e,t){try{const n=await Me(\"meta\",\"readwrite\");await Le(n.put({key:e,value:t}))}catch{Re().meta.set(e,t)}}const Ia=new Map,yn=new Map;function hl(e,t){Ia.set(e,t),yn.set(t,e)}function dl(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Z(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(yn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(dl(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Qn=\"__spindle_class__\",Gn=\"__spindle_data__\";function je(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=yn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Qn]:o,[Gn]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function We(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(o=>t(o));const r=n;if(Qn in r&&Gn in r){const o=r[Qn],s=r[Gn],u=Ia.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(s))f[c]=t(s[c]);return f}const l=Object.create(u.prototype);for(const f of Object.keys(s))l[f]=t(s[f]);return l}const i=r.constructor;if(yn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Kn=null,Yn=null,hi=!1;function pl(e){Kn=e}function ml(e){Yn=e}function gl(e){if(Yn)try{const i=new Function(\"passage\",\"variables\",Yn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Kn)try{const r=Kn(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function _l(){hi||(hi=!0)}async function di(e){const n=(await yr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await xa(i),await Ca(`currentPlaythroughId.${e}`,r),r}async function yl(e){return br(`currentPlaythroughId.${e}`)}async function Ea(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:gl(n),passage:n.passage,custom:r},o=Z(n);o.variables=je(o.variables),o.history=o.history.map(u=>({...u,variables:je(u.variables)}));const s={meta:a,payload:o};return await gn(s),s}async function Aa(e,t){const n=await _n(e);if(!n)return;const r=Z(t);r.variables=je(r.variables),r.history=r.history.map(a=>({...a,variables:je(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await gn(i),i}async function bl(e){const t=await _n(e);if(!t)return;const n=t.payload;return n.variables=We(n.variables),n.history=n.history.map(r=>({...r,variables:We(r.variables)})),n}async function vl(e){await cl(e)}async function Sl(e,t){const n=await _n(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await gn(r)}async function wl(e){const[t,n]=await Promise.all([fl(e),yr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const Pa=\"autosave.\";async function kl(e,t,n){const r=`${Pa}${e}`,i=await br(r);if(i){const o=await Aa(i,n);if(o)return o}const a=await Ea(e,t,n,{isAutosave:!0});return await Ca(r,a.meta.id),a}async function xl(e){const t=`${Pa}${e}`,n=await br(t);if(n)return bl(n)}const vr=\"spindle.session.\";function Cl(e,t){try{sessionStorage.setItem(`${vr}${e}`,JSON.stringify(t))}catch{}}function Il(e){try{const t=sessionStorage.getItem(`${vr}${e}`);if(!t)return;const n=JSON.parse(t);return n.variables=We(n.variables),n.history=n.history.map(r=>({...r,variables:We(r.variables)})),n}catch{return}}function El(e){try{sessionStorage.removeItem(`${vr}${e}`)}catch{}}async function Al(e){const t=await _n(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Pl(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=Z(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await yr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await xa(a)}return await gn(n),n}function Dl(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Wn(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Wn(i,t,n)}}}function Da(){const e=A.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=ct(t.content),r=ft(n),i=Z(e.variables),a=Z(e.temporary);Dl(r,i,a);for(const s of Object.keys(i))i[s]!==e.variables[s]&&e.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==e.temporary[s]&&e.setTemporary(s,a[s]);const o=e.storyData.passages.get(\"SaveTitle\");o&&ml(o.content)}Vs();const Tl=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let qe={},pe=[],$e={};function pi(e){return e.map(t=>({...t,value:t.value!==void 0?Z(t.value):void 0}))}function mi(e,t){const[,n,r]=Hs(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:pi(n),inverse:pi(r)}}function Nl(e){let t=qe;for(let n=0;n<e;n++)t=rt(t,pe[n].forward);return t}let me=[];function En(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(me.length>i.length&&(me.length=i.length),me.length<i.length)if(i.length-me.length===1){const l=i.length-1;me[l]={passage:i[l].passage,variables:je(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=qe;for(let f=0;f<i.length;f++)if(f>0&&(l=rt(l,pe[f-1].forward)),f>=me.length){const c=f===i.length-1?r:l;me[f]={passage:i[f].passage,variables:je(c),timestamp:i[f].timestamp,prng:i[f].prng}}}Cl(t.ifid,{passage:n,variables:je(r),history:me,historyIndex:a,visitCounts:o,renderCounts:s,prng:cn()})}}function gi(e){qe=e,pe=[],$e=e,me=[]}function _i(e){e?.prng?va(e.prng.seed,e.prng.pull):e&&jn()}const A=ks()(qs((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=Z(r);gi(Z(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),$e=t().variables;const o=n.ifid;_l().then(async()=>{const s=await yl(o);if(s)e(u=>{u.playthroughId=s});else{const u=await di(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Tl.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=mi($e,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),pe.length=o.historyIndex,pe.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:cn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)qe=rt(qe,pe[u].forward);o.history=o.history.slice(s),pe=pe.slice(s),me=me.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),$e=t().variables,En(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=Z(rt(r,pe[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),$e=t().variables,_i(t().history[t().historyIndex]),En(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=Z(rt(i,pe[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),$e=t().variables,_i(t().history[t().historyIndex]),En(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;jn();const a=Z(r);gi(Z(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),$e=t().variables,Da(),El(n.ifid),di(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),kl(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),xl(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=qe;for(let f=0;f<i.length;f++)f>0&&(l=rt(l,pe[f-1].forward)),u.push({passage:i[f].passage,variables:Z(l),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:Z(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:cn()}},loadFromPayload:n=>{const r=We(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=We(n.history[o].variables);i.push(mi(a,s)),a=s}qe=Z(r),pe=i,me=[],e(o=>{o.currentPassage=n.passage,o.variables=We(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=n.historyIndex,o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),$e=t().variables,n.prng?va(n.prng.seed,n.prng.pull):jn()},getHistoryVariables:n=>Z(Nl(n))})));function Sr(){const e=A(r=>r.variables),t=A(r=>r.temporary),n=Te(dt);return ce(()=>[e,t,n],[e,t,n])}const $l=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,Fl=/\\{[\\$_@][\\w.]+\\}/;function Ta(e){return Fl.test(e)}function zl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function Na(e,t,n,r){return e.replace($l,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let f;return o===\"$\"?f=t[l]:o===\"_\"?f=n[l]:f=r[l],u.length>1&&(f=zl(f,u)),f==null?\"\":String(f)})}function wr(){const[e,t,n]=Sr();return Pe(r=>r===void 0||!Ta(r)?r:Na(r,e,t,n),[e,t,n])}function Ol({name:e,scope:t,className:n,id:r}){const i=wr();n=i(n),r=i(r);const a=Te(dt),o=e.split(\".\"),s=o[0],u=A(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=o[c];l=l[d]}const f=l==null?\"\":String(l);return n||r?S(\"span\",{id:r,class:n,children:f}):S(K,{children:f})}function Rl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function Ml({body:e,parentValues:t,ownKeys:n}){const[r,i]=te(()=>({...t,...n})),a=Ae(r);a.current=r;const o=Pe(()=>a.current,[]),s=Pe((l,f)=>{i(c=>({...c,[l]:f}))},[]),u=ce(()=>({update:s,getValues:o}),[s,o]);return S(xr.Provider,{value:u,children:S(dt.Provider,{value:r,children:Je(e)})})}function Ll({body:e,params:t,rawArgs:n}){const r=Te(dt),[i,a,o]=Sr();if(t.length===0||!n)return S(K,{children:Je(e)});const s=Rl(n),u={};for(let l=0;l<t.length;l++){const f=t[l],c=s[l];let d;if(c!==void 0)try{d=_r(c,i,a,o)}catch{d=void 0}u[f.startsWith(\"@\")?f.slice(1):f]=d}return S(Ml,{body:e,parentValues:r,ownKeys:u})}const $a=new Map;function Fa(e,t,n){$a.set(e.toLowerCase(),{body:t,params:n})}function Vl(e){return $a.get(e.toLowerCase())}const za=new Map;function Bl(e,t){za.set(e.toLowerCase(),t)}function Hl(e){return za.get(e.toLowerCase())}const Oa=new Set;function Ul(e){Oa.add(e.toLowerCase())}function ql(e){return Oa.has(e.toLowerCase())}const yi=document.createElement(\"i\");function Ra(e){const t=\"&\"+e+\";\";yi.innerHTML=t;const n=yi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function de(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ne(e,t){return e.length>0?(de(e,e.length,0,t),e):t}const Zn={}.hasOwnProperty;function jl(e){const t={};let n=-1;for(;++n<e.length;)Wl(t,e[n]);return t}function Wl(e,t){let n;for(n in t){const i=(Zn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){Zn.call(i,o)||(i[o]=[]);const s=a[o];Ql(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Ql(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);de(e,0,0,r)}function Gl(e){const t={};let n=-1;for(;++n<e.length;)Kl(t,e[n]);return t}function Kl(e,t){let n;for(n in t){const i=(Zn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function Yl(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const Zl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ma(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Zl[n]+\";\"}}function Pt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const ve=Ve(/[A-Za-z]/),he=Ve(/[\\dA-Za-z]/),Jl=Ve(/[#-'*+\\--9=?A-Z^-~]/);function Jn(e){return e!==null&&(e<32||e===127)}const Xn=Ve(/\\d/),Xl=Ve(/[\\dA-Fa-f]/),eu=Ve(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function ie(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const tu=Ve(/\\p{P}|\\p{S}/u),nu=Ve(/\\s/);function Ve(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Wt(e,t){const n=Ma(ru(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function ru(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&he(e.charCodeAt(n+1))&&he(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o=\"�\"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const bi={}.hasOwnProperty,vi=/^(https?|ircs?|mailto|xmpp)$/i,iu=/^https?$/i;function au(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Gl([{enter:{blockQuote:M,codeFenced:ge,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:ko,content:co,definition:io,definitionDestinationString:oo,definitionLabelString:x,definitionTitleString:x,emphasis:So,htmlFlow:vo,htmlText:Pr,image:H,label:x,link:ae,listItemMarker:P,listItemValue:b,listOrdered:F,listUnordered:O,paragraph:G,reference:x,resource:et,resourceDestinationString:tt,resourceTitleString:x,setextHeading:ho,strong:wo},exit:{atxHeading:mo,atxHeadingSequence:fo,autolinkEmail:Do,autolinkProtocol:Po,blockQuote:Y,characterEscapeValue:mt,characterReferenceMarkerHexadecimal:Dr,characterReferenceMarkerNumeric:Dr,characterReferenceValue:Ao,codeFenced:m,codeFencedFence:T,codeFencedFenceInfo:g,codeFencedFenceMeta:D,codeFlowValue:bo,codeIndented:m,codeText:xo,codeTextData:mt,data:mt,definition:uo,definitionDestinationString:so,definitionLabelString:ao,definitionTitleString:lo,emphasis:Co,hardBreakEscape:Er,hardBreakTrailing:Er,htmlFlow:Ar,htmlFlowData:mt,htmlText:Ar,htmlTextData:mt,image:Ir,label:pt,labelText:J,lineEnding:yo,link:Ir,listOrdered:N,listUnordered:U,paragraph:ue,reference:D,referenceString:Ne,resource:D,resourceDestinationString:Sn,resourceTitleString:ro,setextHeading:_o,setextHeadingLineSequence:go,setextHeadingText:po,strong:Io,thematicBreak:Eo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},f={buffer:x,encode:y,getData:w,lineEndingIfNeeded:C,options:t,raw:k,resume:_,setData:p,tag:v};let c=t.defaultLineEnding;return d;function d(I){let $=-1,ee=0;const _e=[];let ye=[],xe=[];for(;++$<I.length;)!c&&(I[$][1].type===\"lineEnding\"||I[$][1].type===\"lineEndingBlank\")&&(c=I[$][2].sliceSerialize(I[$][1])),(I[$][1].type===\"listOrdered\"||I[$][1].type===\"listUnordered\")&&(I[$][0]===\"enter\"?_e.push($):h(I.slice(_e.pop(),$))),I[$][1].type===\"definition\"&&(I[$][0]===\"enter\"?(xe=ne(xe,I.slice(ee,$)),ee=$):(ye=ne(ye,I.slice(ee,$+1)),ee=$+1));ye=ne(ye,xe),ye=ne(ye,I.slice(ee)),$=-1;const be=ye;for(u.enter.null&&u.enter.null.call(f);++$<I.length;){const Tr=u[be[$][0]],Nr=be[$][1].type,$r=Tr[Nr];bi.call(Tr,Nr)&&$r&&$r.call({sliceSerialize:be[$][2].sliceSerialize,...f},be[$][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(I){const $=I.length;let ee=0,_e=0,ye=!1,xe;for(;++ee<$;){const be=I[ee];if(be[1]._container)xe=void 0,be[0]===\"enter\"?_e++:_e--;else switch(be[1].type){case\"listItemPrefix\":{be[0]===\"exit\"&&(xe=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{be[0]===\"enter\"&&!_e&&(xe?xe=void 0:ye=!0);break}default:xe=void 0}}I[0][1]._loose=ye}function p(I,$){l[I]=$}function w(I){return l[I]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function v(I){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(I))}function k(I){p(\"lastWasTag\"),i[i.length-1].push(I)}function E(){k(c||`\n`)}function C(){const I=i[i.length-1],$=I[I.length-1],ee=$?$.charCodeAt($.length-1):null;ee===10||ee===13||ee===null||E()}function y(I){return w(\"ignoreEncode\")?I:Ma(I)}function D(){_()}function F(I){o.push(!I._loose),C(),v(\"<ol\"),p(\"expectFirstItem\",!0)}function O(I){o.push(!I._loose),C(),v(\"<ul\"),p(\"expectFirstItem\",!0)}function b(I){if(w(\"expectFirstItem\")){const $=Number.parseInt(this.sliceSerialize(I),10);$!==1&&v(' start=\"'+y(String($))+'\"')}}function P(){w(\"expectFirstItem\")?v(\">\"):q(),C(),v(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function N(){q(),o.pop(),E(),v(\"</ol>\")}function U(){q(),o.pop(),E(),v(\"</ul>\")}function q(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&C(),v(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),C(),v(\"<blockquote>\")}function Y(){o.pop(),C(),v(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function G(){o[o.length-1]||(C(),v(\"<p>\")),p(\"slurpAllLineEndings\")}function ue(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):v(\"</p>\")}function ge(){C(),v(\"<pre><code\"),p(\"fencesCount\",0)}function g(){const I=_();v(' class=\"language-'+I+'\"')}function T(){const I=w(\"fencesCount\")||0;I||(v(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",I+1)}function j(){C(),v(\"<pre><code>\")}function m(){const I=w(\"fencesCount\");I!==void 0&&I<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&E(),w(\"flowCodeSeenData\")&&C(),v(\"</code></pre>\"),I!==void 0&&I<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function H(){a.push({image:!0}),n=void 0}function ae(){a.push({})}function J(I){a[a.length-1].labelId=this.sliceSerialize(I)}function pt(){a[a.length-1].label=_()}function Ne(I){a[a.length-1].referenceId=this.sliceSerialize(I)}function et(){x(),a[a.length-1].destination=\"\"}function tt(){x(),p(\"ignoreEncode\",!0)}function Sn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function ro(){a[a.length-1].title=_()}function Ir(){let I=a.length-1;const $=a[I],ee=$.referenceId||$.labelId,_e=$.destination===void 0?r[Pt(ee)]:$;for(n=!0;I--;)if(a[I].image){n=void 0;break}$.image?(v('<img src=\"'+Wt(_e.destination,t.allowDangerousProtocol?void 0:iu)+'\" alt=\"'),k($.label),v('\"')):v('<a href=\"'+Wt(_e.destination,t.allowDangerousProtocol?void 0:vi)+'\"'),v(_e.title?' title=\"'+_e.title+'\"':\"\"),$.image?v(\" />\"):(v(\">\"),k($.label),v(\"</a>\")),a.pop()}function io(){x(),a.push({})}function ao(I){_(),a[a.length-1].labelId=this.sliceSerialize(I)}function oo(){x(),p(\"ignoreEncode\",!0)}function so(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function lo(){a[a.length-1].title=_()}function uo(){const I=a[a.length-1],$=Pt(I.labelId);_(),bi.call(r,$)||(r[$]=a[a.length-1]),a.pop()}function co(){p(\"slurpAllLineEndings\",!0)}function fo(I){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(I).length),C(),v(\"<h\"+w(\"headingRank\")+\">\"))}function ho(){x(),p(\"slurpAllLineEndings\")}function po(){p(\"slurpAllLineEndings\",!0)}function mo(){v(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function go(I){p(\"headingRank\",this.sliceSerialize(I).charCodeAt(0)===61?1:2)}function _o(){const I=_();C(),v(\"<h\"+w(\"headingRank\")+\">\"),k(I),v(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function mt(I){k(y(this.sliceSerialize(I)))}function yo(I){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){k(\" \");return}k(y(this.sliceSerialize(I)))}}function bo(I){k(y(this.sliceSerialize(I))),p(\"flowCodeSeenData\",!0)}function Er(){v(\"<br />\")}function vo(){C(),Pr()}function Ar(){p(\"ignoreEncode\")}function Pr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function So(){v(\"<em>\")}function wo(){v(\"<strong>\")}function ko(){p(\"inCodeText\",!0),v(\"<code>\")}function xo(){p(\"inCodeText\"),v(\"</code>\")}function Co(){v(\"</em>\")}function Io(){v(\"</strong>\")}function Eo(){C(),v(\"<hr />\")}function Dr(I){p(\"characterReferenceType\",I.type)}function Ao(I){const $=this.sliceSerialize(I),ee=w(\"characterReferenceType\")?Yl($,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ra($);k(y(ee)),p(\"characterReferenceType\")}function Po(I){const $=this.sliceSerialize(I);v('<a href=\"'+Wt($,t.allowDangerousProtocol?void 0:vi)+'\">'),k(y($)),v(\"</a>\")}function Do(I){const $=this.sliceSerialize(I);v('<a href=\"'+Wt(\"mailto:\"+$)+'\">'),k(y($)),v(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const ou={tokenize:su};function su(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return z(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const lu={tokenize:uu},Si={tokenize:cu};function uu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const E=t.events.length;let C=E,y;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){y=t.events[C][1].end;break}_(r);let D=E;for(;D<t.events.length;)t.events[D][1].end={...y},D++;return de(t.events,C+1,0,t.events.slice(E)),t.events.length=D,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return d(k);if(i.currentConstruct&&i.currentConstruct.concrete)return p(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Si,f,c)(k)}function f(k){return i&&v(),_(r),d(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(k)}function d(k){return t.containerState={},e.attempt(Si,h,p)(k)}function h(k){return r++,n.push([t.currentConstruct,t.containerState]),d(k)}function p(k){if(k===null){i&&v(),_(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(k)}function w(k){if(k===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(k);return}return z(k)?(e.consume(k),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),w)}function x(k,E){const C=t.sliceStream(k);if(E&&C.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(C),t.parser.lazy[k.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const D=t.events.length;let F=D,O,b;for(;F--;)if(t.events[F][0]===\"exit\"&&t.events[F][1].type===\"chunkFlow\"){if(O){b=t.events[F][1].end;break}O=!0}for(_(r),y=D;y<t.events.length;)t.events[y][1].end={...b},y++;de(t.events,F+1,0,t.events.slice(D)),t.events.length=y}}function _(k){let E=n.length;for(;E-- >k;){const C=n[E];t.containerState=C[1],C[0].exit.call(t,e)}n.length=k}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function cu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function fn(e){if(e===null||ie(e)||nu(e))return 1;if(tu(e))return 2}function bn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const er={name:\"attention\",resolveAll:fu,tokenize:hu};function fu(e,t){let n=-1,r,i,a,o,s,u,l,f;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};wi(c,-u),wi(d,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ne(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ne(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ne(l,bn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ne(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=ne(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,de(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function hu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=fn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),f=fn(u),c=!f||f===2&&i||n.includes(u),d=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(f||!c)),t(u)}}function wi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const du={name:\"autolink\",tokenize:pu};function pu(e,t,n){let r=0;return i;function i(h){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(h){return ve(h)?(e.consume(h),o):h===64?n(h):l(h)}function o(h){return h===43||h===45||h===46||he(h)?(r=1,s(h)):l(h)}function s(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||he(h))&&r++<32?(e.consume(h),s):(r=0,l(h))}function u(h){return h===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h===null||h===32||h===60||Jn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):Jl(h)?(e.consume(h),l):n(h)}function f(h){return he(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(h)}function d(h){if((h===45||he(h))&&r++<63){const p=h===45?d:c;return e.consume(h),p}return n(h)}}const vn={partial:!0,tokenize:mu};function mu(e,t,n){return r;function r(a){return L(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const La={continuation:{tokenize:_u},exit:yu,name:\"blockQuote\",tokenize:gu};function gu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function _u(e,t,n){const r=this;return i;function i(o){return L(o)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(La,t,n)(o)}}function yu(e){e.exit(\"blockQuote\")}const Va={name:\"characterEscape\",tokenize:bu};function bu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return eu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Ba={name:\"characterReference\",tokenize:vu};function vu(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=he,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Xl,f):(e.enter(\"characterReferenceValue\"),a=7,o=Xn,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===he&&!Ra(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),f):n(c)}}const ki={partial:!0,tokenize:wu},xi={concrete:!0,name:\"codeFenced\",tokenize:Su};function Su(e,t,n){const r=this,i={partial:!0,tokenize:C};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const D=r.events[r.events.length-1];return a=D&&D[1].type===\"linePrefix\"?D[2].sliceSerialize(D[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(y)}function f(y){return y===s?(o++,e.consume(y),f):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?B(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||z(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(ki,w,E)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(y))}function d(y){return y===null||z(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,h,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),d)}function h(y){return y===null||z(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||z(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function w(y){return e.attempt(i,E,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?B(e,v,\"linePrefix\",a+1)(y):v(y)}function v(y){return y===null||z(y)?e.check(ki,w,E)(y):(e.enter(\"codeFlowValue\"),k(y))}function k(y){return y===null||z(y)?(e.exit(\"codeFlowValue\"),v(y)):(e.consume(y),k)}function E(y){return e.exit(\"codeFenced\"),t(y)}function C(y,D,F){let O=0;return b;function b(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),P}function P(M){return y.enter(\"codeFencedFence\"),L(M)?B(y,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):N(M)}function N(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),U(M)):F(M)}function U(M){return M===s?(O++,y.consume(M),U):O>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?B(y,q,\"whitespace\")(M):q(M)):F(M)}function q(M){return M===null||z(M)?(y.exit(\"codeFencedFence\"),D(M)):F(M)}}}function wu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const An={name:\"codeIndented\",tokenize:xu},ku={partial:!0,tokenize:Cu};function xu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,a,\"linePrefix\",5)(l)}function a(l){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):z(l)?e.attempt(ku,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||z(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Cu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const Iu={name:\"codeText\",previous:Au,resolve:Eu,tokenize:Pu};function Eu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Au(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Pu(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):z(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||z(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class Du{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&>(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),gt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),gt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);gt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);gt(this.left,n.reverse())}}}function gt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ha(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new Du(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type===\"chunkFlow\"&&f.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Tu(f,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=f.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(f.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...f.get(i)[1].start},s=f.slice(i,n),s.unshift(r),f.splice(i,n-i+1,s))}}return de(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function Tu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let f,c,d=-1,h=n,p=0,w=0;const x=[w];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,x.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),d=x.length;d--;){const _=s.slice(x[d],x[d+1]),v=a.pop();u.push([v,v+_.length-1]),e.splice(v,2,_)}for(u.reverse(),d=-1;++d<u.length;)l[p+u[d][0]]=p+u[d][1],p+=u[d][1]-u[d][0]-1;return l}const Nu={resolve:Fu,tokenize:zu},$u={partial:!0,tokenize:Ou};function Fu(e){return Ha(e),e}function zu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):z(s)?e.check($u,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Ou(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Ua(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),d):_===null||_===32||_===41||Jn(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(_))}function d(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),d(_)):_===null||_===60||z(_)?n(_):(e.consume(_),_===92?p:h)}function p(_){return _===60||_===62||_===92?(e.consume(_),h):h(_)}function w(_){return!f&&(_===null||_===41||ie(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<l&&_===40?(e.consume(_),f++,w):_===41?(e.consume(_),f--,w):_===null||_===32||_===40||Jn(_)?n(_):(e.consume(_),_===92?x:w)}function x(_){return _===40||_===41||_===92?(e.consume(_),w):w(_)}}function qa(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(a),f}function f(h){return s>999||h===null||h===91||h===93&&!u||h===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):z(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(h))}function c(h){return h===null||h===91||h===93||z(h)||s++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!L(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function ja(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):n(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===o?(e.exit(a),u(o)):d===null?n(d):z(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===o||d===null||z(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:f)}function c(d){return d===o||d===92?(e.consume(d),f):f(d)}}function kt(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Ru={name:\"definition\",tokenize:Lu},Mu={partial:!0,tokenize:Vu};function Lu(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),o(h)}function o(h){return qa.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function s(h){return i=Pt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter(\"definitionMarker\"),e.consume(h),e.exit(\"definitionMarker\"),u):n(h)}function u(h){return ie(h)?kt(e,l)(h):l(h)}function l(h){return Ua(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(Mu,c,c)(h)}function c(h){return L(h)?B(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||z(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function Vu(e,t,n){return r;function r(s){return ie(s)?kt(e,i)(s):n(s)}function i(s){return ja(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?B(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const Bu={name:\"hardBreakEscape\",tokenize:Hu};function Hu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return z(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Uu={name:\"headingAtx\",resolve:qu,tokenize:ju};function qu(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},de(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function ju(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||ie(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||z(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?B(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),s(f))}function l(f){return f===null||f===35||ie(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),l)}}const Wu=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],Ci=[\"pre\",\"script\",\"style\",\"textarea\"],Qu={concrete:!0,name:\"htmlFlow\",resolveTo:Yu,tokenize:Zu},Gu={partial:!0,tokenize:Xu},Ku={partial:!0,tokenize:Ju};function Yu(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Zu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(m){return f(m)}function f(m){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(m),c}function c(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),a=!0,w):m===63?(e.consume(m),i=3,r.interrupt?t:g):ve(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function d(m){return m===45?(e.consume(m),i=2,h):m===91?(e.consume(m),i=5,s=0,p):ve(m)?(e.consume(m),i=4,r.interrupt?t:g):n(m)}function h(m){return m===45?(e.consume(m),r.interrupt?t:g):n(m)}function p(m){const H=\"CDATA[\";return m===H.charCodeAt(s++)?(e.consume(m),s===H.length?r.interrupt?t:N:p):n(m)}function w(m){return ve(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function x(m){if(m===null||m===47||m===62||ie(m)){const H=m===47,ae=o.toLowerCase();return!H&&!a&&Ci.includes(ae)?(i=1,r.interrupt?t(m):N(m)):Wu.includes(o.toLowerCase())?(i=6,H?(e.consume(m),_):r.interrupt?t(m):N(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(m):a?v(m):k(m))}return m===45||he(m)?(e.consume(m),o+=String.fromCharCode(m),x):n(m)}function _(m){return m===62?(e.consume(m),r.interrupt?t:N):n(m)}function v(m){return L(m)?(e.consume(m),v):b(m)}function k(m){return m===47?(e.consume(m),b):m===58||m===95||ve(m)?(e.consume(m),E):L(m)?(e.consume(m),k):b(m)}function E(m){return m===45||m===46||m===58||m===95||he(m)?(e.consume(m),E):C(m)}function C(m){return m===61?(e.consume(m),y):L(m)?(e.consume(m),C):k(m)}function y(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),u=m,D):L(m)?(e.consume(m),y):F(m)}function D(m){return m===u?(e.consume(m),u=null,O):m===null||z(m)?n(m):(e.consume(m),D)}function F(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||ie(m)?C(m):(e.consume(m),F)}function O(m){return m===47||m===62||L(m)?k(m):n(m)}function b(m){return m===62?(e.consume(m),P):n(m)}function P(m){return m===null||z(m)?N(m):L(m)?(e.consume(m),P):n(m)}function N(m){return m===45&&i===2?(e.consume(m),Y):m===60&&i===1?(e.consume(m),G):m===62&&i===4?(e.consume(m),T):m===63&&i===3?(e.consume(m),g):m===93&&i===5?(e.consume(m),ge):z(m)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Gu,j,U)(m)):m===null||z(m)?(e.exit(\"htmlFlowData\"),U(m)):(e.consume(m),N)}function U(m){return e.check(Ku,q,j)(m)}function q(m){return e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),M}function M(m){return m===null||z(m)?U(m):(e.enter(\"htmlFlowData\"),N(m))}function Y(m){return m===45?(e.consume(m),g):N(m)}function G(m){return m===47?(e.consume(m),o=\"\",ue):N(m)}function ue(m){if(m===62){const H=o.toLowerCase();return Ci.includes(H)?(e.consume(m),T):N(m)}return ve(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),ue):N(m)}function ge(m){return m===93?(e.consume(m),g):N(m)}function g(m){return m===62?(e.consume(m),T):m===45&&i===2?(e.consume(m),g):N(m)}function T(m){return m===null||z(m)?(e.exit(\"htmlFlowData\"),j(m)):(e.consume(m),T)}function j(m){return e.exit(\"htmlFlow\"),t(m)}}function Ju(e,t,n){const r=this;return i;function i(o){return z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Xu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(vn,t,n)}}const ec={name:\"htmlText\",tokenize:tc};function tc(e,t,n){const r=this;let i,a,o;return s;function s(g){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(g),u}function u(g){return g===33?(e.consume(g),l):g===47?(e.consume(g),C):g===63?(e.consume(g),k):ve(g)?(e.consume(g),F):n(g)}function l(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),a=0,p):ve(g)?(e.consume(g),v):n(g)}function f(g){return g===45?(e.consume(g),h):n(g)}function c(g){return g===null?n(g):g===45?(e.consume(g),d):z(g)?(o=c,G(g)):(e.consume(g),c)}function d(g){return g===45?(e.consume(g),h):c(g)}function h(g){return g===62?Y(g):g===45?d(g):c(g)}function p(g){const T=\"CDATA[\";return g===T.charCodeAt(a++)?(e.consume(g),a===T.length?w:p):n(g)}function w(g){return g===null?n(g):g===93?(e.consume(g),x):z(g)?(o=w,G(g)):(e.consume(g),w)}function x(g){return g===93?(e.consume(g),_):w(g)}function _(g){return g===62?Y(g):g===93?(e.consume(g),_):w(g)}function v(g){return g===null||g===62?Y(g):z(g)?(o=v,G(g)):(e.consume(g),v)}function k(g){return g===null?n(g):g===63?(e.consume(g),E):z(g)?(o=k,G(g)):(e.consume(g),k)}function E(g){return g===62?Y(g):k(g)}function C(g){return ve(g)?(e.consume(g),y):n(g)}function y(g){return g===45||he(g)?(e.consume(g),y):D(g)}function D(g){return z(g)?(o=D,G(g)):L(g)?(e.consume(g),D):Y(g)}function F(g){return g===45||he(g)?(e.consume(g),F):g===47||g===62||ie(g)?O(g):n(g)}function O(g){return g===47?(e.consume(g),Y):g===58||g===95||ve(g)?(e.consume(g),b):z(g)?(o=O,G(g)):L(g)?(e.consume(g),O):Y(g)}function b(g){return g===45||g===46||g===58||g===95||he(g)?(e.consume(g),b):P(g)}function P(g){return g===61?(e.consume(g),N):z(g)?(o=P,G(g)):L(g)?(e.consume(g),P):O(g)}function N(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),i=g,U):z(g)?(o=N,G(g)):L(g)?(e.consume(g),N):(e.consume(g),q)}function U(g){return g===i?(e.consume(g),i=void 0,M):g===null?n(g):z(g)?(o=U,G(g)):(e.consume(g),U)}function q(g){return g===null||g===34||g===39||g===60||g===61||g===96?n(g):g===47||g===62||ie(g)?O(g):(e.consume(g),q)}function M(g){return g===47||g===62||ie(g)?O(g):n(g)}function Y(g){return g===62?(e.consume(g),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(g)}function G(g){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),ue}function ue(g){return L(g)?B(e,ge,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(g):ge(g)}function ge(g){return e.enter(\"htmlTextData\"),o(g)}}const kr={name:\"labelEnd\",resolveAll:ac,resolveTo:oc,tokenize:sc},nc={tokenize:lc},rc={tokenize:uc},ic={tokenize:cc};function ac(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&de(e,0,e.length,n),e}function oc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ne(s,e.slice(a+1,a+r+3)),s=ne(s,[[\"enter\",f,t]]),s=ne(s,bn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ne(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ne(s,e.slice(o+1)),s=ne(s,[[\"exit\",u,t]]),de(e,a,e.length,s),e}function sc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(d){return a?a._inactive?c(d):(o=r.parser.defined.includes(Pt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(nc,f,o?f:c)(d):d===91?e.attempt(rc,f,o?l:c)(d):o?f(d):c(d)}function l(d){return e.attempt(ic,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function lc(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return ie(c)?kt(e,a)(c):a(c)}function a(c){return c===41?f(c):Ua(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ie(c)?kt(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?ja(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ie(c)?kt(e,f)(c):f(c)}function f(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function uc(e,t,n){const r=this;return i;function i(s){return qa.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Pt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function cc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const fc={name:\"labelStartImage\",resolveAll:kr.resolveAll,tokenize:hc};function hc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const dc={name:\"labelStartLink\",resolveAll:kr.resolveAll,tokenize:pc};function pc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Pn={name:\"lineEnding\",tokenize:mc};function mc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Jt={name:\"thematicBreak\",tokenize:gc};function gc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||z(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,s,\"whitespace\")(l):s(l))}}const se={continuation:{tokenize:vc},exit:wc,name:\"list\",tokenize:bc},_c={partial:!0,tokenize:kc},yc={partial:!0,tokenize:Sc};function bc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(h){const p=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:Xn(h)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(Jt,n,l)(h):l(h);if(!r.interrupt||h===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(h)}return n(h)}function u(h){return Xn(h)&&++o<10?(e.consume(h),u):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit(\"listItemValue\"),l(h)):n(h)}function l(h){return e.enter(\"listItemMarker\"),e.consume(h),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||h,e.check(vn,r.interrupt?n:f,e.attempt(_c,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return L(h)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(h),e.exit(\"listItemPrefixWhitespace\"),d):n(h)}function d(h){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(h)}}function vc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(vn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(yc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(se,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function Sc(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function wc(e){e.exit(this.containerState.type)}function kc(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Ii={name:\"setextUnderline\",resolveTo:xc,tokenize:Cc};function xc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function Cc(e,t,n){const r=this;let i;return a;function a(l){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!==\"lineEnding\"&&r.events[f][1].type!==\"linePrefix\"&&r.events[f][1].type!==\"content\"){c=r.events[f][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||z(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Ic={tokenize:Ec};function Ec(e){const t=this,n=e.attempt(vn,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Nu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Ac={resolveAll:Qa()},Pc=Wa(\"string\"),Dc=Wa(\"text\");function Wa(e){return{resolveAll:Qa(e===\"text\"?Tc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(f){return l(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),u}function u(f){return l(f)?(n.exit(\"data\"),a(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const c=i[f];let d=-1;if(c)for(;++d<c.length;){const h=c[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Qa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function Tc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const Nc={42:se,43:se,45:se,48:se,49:se,50:se,51:se,52:se,53:se,54:se,55:se,56:se,57:se,62:La},$c={91:Ru},Fc={[-2]:An,[-1]:An,32:An},zc={35:Uu,42:Jt,45:[Ii,Jt],60:Qu,61:Ii,95:Jt,96:xi,126:xi},Oc={38:Ba,92:Va},Rc={[-5]:Pn,[-4]:Pn,[-3]:Pn,33:fc,38:Ba,42:er,60:[du,ec],91:dc,92:[Bu,Va],93:kr,95:er,96:Iu},Mc={null:[er,Ac]},Lc={null:[42,95]},Vc={null:[]},Bc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Lc,contentInitial:$c,disable:Vc,document:Nc,flow:zc,flowInitial:Fc,insideSpan:Mc,string:Oc,text:Rc},Symbol.toStringTag,{value:\"Module\"}));function Hc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:D(C),check:D(y),consume:v,enter:k,exit:E,interrupt:D(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(P){return o=ne(o,P),x(),o[o.length-1]!==null?[]:(F(t,0),l.events=bn(a,l.events,l),l.events)}function d(P,N){return qc(h(P),N)}function h(P){return Uc(o,P)}function p(){const{_bufferIndex:P,_index:N,line:U,column:q,offset:M}=r;return{_bufferIndex:P,_index:N,line:U,column:q,offset:M}}function w(P){i[P.line]=P.column,b()}function x(){let P;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<N.length;)_(N.charCodeAt(r._bufferIndex));else _(N)}}function _(P){f=f(P)}function v(P){z(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,b()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function k(P,N){const U=N||{};return U.type=P,U.start=p(),l.events.push([\"enter\",U,l]),s.push(U),U}function E(P){const N=s.pop();return N.end=p(),l.events.push([\"exit\",N,l]),N}function C(P,N){F(P,N.from)}function y(P,N){N.restore()}function D(P,N){return U;function U(q,M,Y){let G,ue,ge,g;return Array.isArray(q)?j(q):\"tokenize\"in q?j([q]):T(q);function T(J){return pt;function pt(Ne){const et=Ne!==null&&J[Ne],tt=Ne!==null&&J.null,Sn=[...Array.isArray(et)?et:et?[et]:[],...Array.isArray(tt)?tt:tt?[tt]:[]];return j(Sn)(Ne)}}function j(J){return G=J,ue=0,J.length===0?Y:m(J[ue])}function m(J){return pt;function pt(Ne){return g=O(),ge=J,J.partial||(l.currentConstruct=J),J.name&&l.parser.constructs.disable.null.includes(J.name)?ae():J.tokenize.call(N?Object.assign(Object.create(l),N):l,u,H,ae)(Ne)}}function H(J){return P(ge,g),M}function ae(J){return g.restore(),++ue<G.length?m(G[ue]):Y}}}function F(P,N){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&de(l.events,N,l.events.length-N,P.resolve(l.events.slice(N),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function O(){const P=p(),N=l.previous,U=l.currentConstruct,q=l.events.length,M=Array.from(s);return{from:q,restore:Y};function Y(){r=P,l.previous=N,l.currentConstruct=U,l.events.length=q,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Uc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s==\"string\"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function qc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function jc(e){const r={constructs:jl([Bc,...(e||{}).extensions||[]]),content:i(ou),defined:[],document:i(lu),flow:i(Ic),lazy:{},string:i(Pc),text:i(Dc)};return r;function i(a){return o;function o(s){return Hc(r,a,s)}}}function Wc(e){for(;!Ha(e););return e}const Ei=/[\\0\\t\\n\\r]/g;function Qc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,f,c,d,h;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(Ei.lastIndex=c,l=Ei.exec(a),d=l&&l.index!==void 0?l.index:a.length,h=a.charCodeAt(d),!l){t=a.slice(c);break}if(h===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Gc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),au(n)(Wc(jc(n).document().write(Qc()(e,t,!0))))}const Dn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Kc(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Dn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Dn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Yc)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+Dn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Yc(e,t){return t===\"|\"?t:e}class Zc{constructor(){this.map=[]}add(t,n,r){Jc(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function Jc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Xc(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function ef(){return{flow:{null:{name:\"table\",tokenize:tf,resolveAll:nf}}}}function tf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let P=r.events.length-1;for(;P>-1;){const q=r.events[P][1].type;if(q===\"lineEnding\"||q===\"linePrefix\")P--;else break}const N=P>-1?r.events[P][1].type:null,U=N===\"tableHead\"||N===\"tableRow\"?y:u;return U===y&&r.parser.lazy[r.now().line]?n(b):U(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),f(b)}function f(b){return b===null?n(b):z(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),h):n(b):L(b)?B(e,f,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(b)))}function c(b){return b===null||b===124||ie(b)?(e.exit(\"data\"),f(b)):(e.consume(b),b===92?d:c)}function d(b){return b===92||b===124?(e.consume(b),c):c(b)}function h(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?B(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?x(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):C(b)}function w(b){return L(b)?B(e,x,\"whitespace\")(b):x(b)}function x(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),_):b===45?(a+=1,_(b)):b===null||z(b)?E(b):C(b)}function _(b){return b===45?(e.enter(\"tableDelimiterFiller\"),v(b)):C(b)}function v(b){return b===45?(e.consume(b),v):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(b))}function k(b){return L(b)?B(e,E,\"whitespace\")(b):E(b)}function E(b){return b===124?p(b):b===null||z(b)?!o||i!==a?C(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):C(b)}function C(b){return n(b)}function y(b){return e.enter(\"tableRow\"),D(b)}function D(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),D):b===null||z(b)?(e.exit(\"tableRow\"),t(b)):L(b)?B(e,D,\"whitespace\")(b):(e.enter(\"data\"),F(b))}function F(b){return b===null||b===124||ie(b)?(e.exit(\"data\"),D(b)):(e.consume(b),b===92?O:F)}function O(b){return b===92||b===124?(e.consume(b),F):F(b)}}function nf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,f,c;const d=new Zc;for(;++n<e.length;){const h=e[n],p=h[1];h[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Ai(d,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",f,t]])),i=p.type===\"tableDelimiterRow\"?2:f?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Qt(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Qt(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Qt(d,t,a,i,n,c)):o[1]!==0&&(c=Qt(d,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ai(d,t,u,l,f),d.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]===\"enter\"&&h[1].type===\"table\"&&(h[1]._align=Xc(t.events,n))}return e}function Qt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},nt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=nt(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=nt(t.events,n[2]),f=nt(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},nt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ai(e,t,n,r,i){const a=[],o=nt(t.events,n);i&&(i.end=Object.assign({},o),a.push([\"exit\",i,t])),r.end=Object.assign({},o),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function nt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function rf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function af(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},d=[[\"enter\",f,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],h=s.parser.constructs.insideSpan.null;h&&de(d,d.length,0,bn(h,o.slice(l+1,u),s)),de(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),de(o,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,f=this.events;let c=0;return d;function d(p){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),h(p))}function h(p){const w=fn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,h);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=fn(p);return x._open=!_||_===2&&!!w,x._close=!w||w===2&&!!_,s(p)}}}function of(e){return Gc(e,{allowDangerousHtml:!0,extensions:[ef(),af()],htmlExtensions:[Kc(),rf()]})}const sf={update:()=>{},getValues:()=>({})},dt=Ft({}),xr=Ft(sf);function lf(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Ga(i,a,t));return S(K,{children:r})}function Ga(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>Ga(u,l,n));return le(i,o,...s)}return null}function uf({node:e}){const t=wr(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return le(e.tag,n,e.children.length>0?Je(e.children):void 0)}function cf(e,t){if(ql(e.name))return null;const n=Vl(e.name);if(n)return S(Ll,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Hl(e.name);return r?S(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):S(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function tr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return S(Ol,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return cf(e,t);case\"html\":return S(uf,{node:e},t);default:return e}}function Ka(e){return e.length===0?null:e.map((t,n)=>tr(t,n))}function ff(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function hf(e){const t=A.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let a=1;a<n.length;a++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[a]]}return i==null?\"\":String(i)}function Je(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,o)=>tr(a,o));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const o=e[a];if(o.type===\"text\")r+=o.value.replace(/^[ \\t]{4,}/gm,\" \");else if(o.type===\"variable\"&&ff(r))r+=hf(o);else{const s=n.length;n.push(tr(o,a)),r+=`<span data-tw=\"${s}\"></span>`}}const i=of(r);return lf(i,n)}const df=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function pf(){const t=A(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:df;try{const r=ct(n),i=ft(r);return S(K,{children:Ka(i)})}catch(r){return S(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function mf(){const e=A(n=>n.storyData),t=A(n=>n.currentPassage);return ze(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),A.getState().save()):r.key===\"F9\"&&(r.preventDefault(),A.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?S(\"div\",{class:\"loading\",children:\"Loading...\"}):S(pf,{})}function gf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const h=parseInt(d.getAttribute(\"pid\")||\"0\",10),p=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),x=d.textContent||\"\",_={},v=new Set([\"pid\",\"name\",\"tags\"]);for(const E of d.attributes)v.has(E.name)||(_[E.name]=E.value);const k={pid:h,name:p,tags:w,metadata:_,content:x};f.set(p,k),c.set(h,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:l}}const _t=new Map;let oe={},Pi=!1;function Ya(){return`spindle.${A.getState().storyData?.ifid||\"unknown\"}.settings`}function _f(){localStorage.setItem(Ya(),JSON.stringify(oe))}function Tn(){if(!Pi){Pi=!0;try{const e=localStorage.getItem(Ya());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(oe={...oe,...t})}}catch{}}}const Dt={addToggle(e,t){_t.set(e,{type:\"toggle\",config:t}),e in oe||(oe[e]=t.default),Tn()},addList(e,t){_t.set(e,{type:\"list\",config:t}),e in oe||(oe[e]=t.default),Tn()},addRange(e,t){_t.set(e,{type:\"range\",config:t}),e in oe||(oe[e]=t.default),Tn()},get(e){return oe[e]},getToggle(e){const t=oe[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=oe[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=oe[e];return typeof t==\"number\"?t:0},set(e,t){oe[e]=t,_f()},getAll(){return{...oe}},getDefinitions(){return _t},hasAny(){return _t.size>0}};function nr(e,t,n){const r=A.getState(),i=Z(r.variables),a=Z(r.temporary),o={...t};Wn(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(s,o[s])}const hn=new Map,rr=new Set,ir=new Map;function yf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(ir.get(r)??0)+1;return ir.set(r,i),i===1?r:`${r}:${i}`}function bf(e){return hn.set(e.id,e),Ti(),()=>{hn.delete(e.id),Ti()}}function Di(){return Array.from(hn.values())}function vf(e){return hn.get(e)}function Sf(){ir.clear()}function wf(e){return rr.add(e),()=>{rr.delete(e)}}function Ti(){for(const e of rr)e()}function kf(e){const t=Ae(\"\");t.current||(t.current=yf(e.type,e.key,e.authorId));const n=t.current;return Ze(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),bf(r)}),n}function Za(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Ja(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Tt(){const e=A.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Ja(t):\"\"}function xf(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Cf(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function If(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Ef={useState:te,useRef:Ae,useEffect:ze,useLayoutEffect:Ze,useCallback:Pe,useMemo:ce,useContext:Te};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=wr(),r=a(r),i=a(i));const{update:o,getValues:s}=Te(xr),u={collectText:Za,sourceLocation:Tt,parseVarArgs:xf,extractOptions:Cf,h:le,renderNodes:Je,renderInlineNodes:Ka,hooks:Ef,useAction:kf,className:r,id:i,resolve:a,cls:If(e.name,r),mutate:l=>nr(l,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){u.merged=Sr();const l=u.merged;u.evaluate=f=>_r(f,l[0],l[1],l[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");u.varName=f,u.value=A(d=>d.variables[f]);const c=A(d=>d.setVariable);u.setValue=d=>c(f,d)}return u.wrap=l=>u.className||u.id?le(\"span\",{id:u.id,class:u.className},l):le(K,null,l),e.render(n,u)}if(Bl(e.name,t),e.subMacros)for(const n of e.subMacros)Ul(n)}function Af(){return{get(e){return A.getState().variables[e]},set(e,t){const n=A.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){A.getState().navigate(e)},back(){A.getState().goBack()},forward(){A.getState().goForward()},restart(){A.getState().restart()},save(e){A.getState().save(e)},load(e){A.getState().load(e)},hasSave(e){return A.getState().hasSave(e)},visited(e){const t=A.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=A.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=A.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=A.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=A.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=A.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=A.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=A.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return A.getState().storyData?.name||\"\"},get passage(){return A.getState().currentPassage},settings:Dt,registerClass(e,t){hl(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){pl(e)}},getActions(){return Di()},performAction(e,t){const n=vf(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=A.getState().currentPassage;return A.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return wf(t);if(e===\"variableChanged\"){let n={...A.getState().variables};return A.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Di())})})})},random(){return mr()},randomInt(e,t){return Sa(e,t)},config:{get maxHistory(){return A.getState().maxHistory},set maxHistory(e){A.getState().setMaxHistory(e)}},prng:{init(e,t){Zs(e,t);const{historyIndex:n}=A.getState();A.setState(r=>{const i=r.history[n];i&&(i.prng=cn())})},isEnabled(){return Js()},get seed(){return Xs()},get pull(){return el()}}}}function Pf(){window.Story=Af()}const Df=/^\\$(\\w+)\\s*=\\s*(.+)$/,Ni=/\\$(\\w+(?:\\.\\w+)*)/g,$i=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Tf=new Set([\"number\",\"string\",\"boolean\"]);function Xa(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,Xa(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Tf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Nf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Df);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=Xa(s);t.set(a,{...u,name:a,default:s})}return t}function $f(e){const t=new Set;let n;for($i.lastIndex=0;(n=$i.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Ff(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function zf(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=$f(i.content);let o;for(Ni.lastIndex=0;(o=Ni.exec(i.content))!==null;){const s=o[1],u=Ff(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Of(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Oe({macro:e,error:t}){return S(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Tt()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return S(Oe,{macro:\"print\",error:n})}}});function Rf(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function Mf(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function Fi(e,t,n,r,i,a,o){const s=A.getState();let u;try{u=_r(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${Tt()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];Mf(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=Rf(e))}catch(f){return S(Oe,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const f=A.getState();Fi(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Fi(o,u,s,n,r,i,e)},[n,r,i]),null}});function Lf(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=Vf(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function Vf(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function Bf(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=Lf(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=Bf(a,o,i),l=t.cls;return S(\"div\",{class:l,id:t.id,children:[S(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&S(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return S(Oe,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?S(\"span\",{id:o,class:a,children:i}):S(K,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return S(Oe,{macro:\"if\",error:i})}}return null}});function Hf(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function Uf({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=te(()=>({...e,...t,...n})),o=Ae(i);o.current=i;const s=Pe(()=>o.current,[]),u=Pe((f,c)=>{a(d=>({...d,[f]:c}))},[]),l=ce(()=>({update:u,getValues:s}),[u,s]);return S(xr.Provider,{value:l,children:S(dt.Provider,{value:i,children:Je(r)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=Te(dt);let i;try{i=Hf(e)}catch(f){return S(Oe,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const f=n.evaluate(s);if(!Array.isArray(f))return S(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=f}catch(f){return S(Oe,{macro:\"for\",error:f})}const l=u.map((f,c)=>{const d={[a]:f,...o?{[o]:c}:void 0};return S(Uf,{parentValues:r,ownKeys:d,initialValues:{},children:t},c)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=()=>{try{n.mutate(e)}catch(i){console.error(`spindle: Error in {button ${e}}${n.sourceLocation()}:`,i)}};return n.useAction({type:\"button\",key:e,authorId:n.id,label:n.collectText(t)||e,perform:r}),S(\"button\",{id:n.id,class:n.cls,onClick:r,children:n.renderInlineNodes(t)})}});function qf(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function zi(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")try{nr(r.rawArgs,t,n)}catch(i){console.error(`spindle: Error in {link} child {set}${Tt()}:`,i)}else if(r.name===\"do\"){const i=Za(r.children);try{nr(i,t,n)}catch(a){console.error(`spindle: Error in {link} child {do}${Tt()}:`,a)}}}}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=qf(e),a=o=>{o.preventDefault(),zi(t,n.getValues(),n.update),i&&A.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{zi(t,n.getValues(),n.update),i&&A.getState().navigate(i)}}),S(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return S(Oe,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return S(K,{children:n.renderNodes(o.children)})}catch(s){return S(Oe,{macro:\"case\",error:s})}}return i?S(K,{children:n.renderNodes(i.children)}):null}});function Cr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(h=>({delay:h.rawArgs?Cr(h.rawArgs):0,nodes:h.children,className:h.className,id:h.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const h=o+1,p=a[h].delay,w=setTimeout(()=>{s(h)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),f=t.resolve(u.className),c=t.resolve(u.id),d=f||c?S(\"span\",{id:c,class:f,children:l}):l;return t.wrap(d)}});const eo=Ft({stop:()=>{}});V({name:\"repeat\",render({rawArgs:e,children:t=[],className:n,id:r},i){const{useState:a,useEffect:o,useCallback:s,useMemo:u}=i.hooks,[l,f]=u(()=>{const k=E=>{if(!E||!Ta(E))return E;const C=A.getState();return Na(E,C.variables,C.temporary,{})};return[k(n),k(r)]},[n,r]),c=Cr(e),[d,h]=a(0),[p,w]=a(!1),x=s(()=>w(!0),[]);if(o(()=>{if(p)return;const k=setInterval(()=>{h(E=>E+1)},c);return()=>clearInterval(k)},[c,p]),d===0&&!p)return null;const _=l?`macro-repeat ${l}`:void 0,v=S(eo.Provider,{value:{stop:x},children:S(\"span\",{children:i.renderNodes(t)},d)});return _||f?S(\"span\",{id:f,class:_,children:v}):v}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(eo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Cr(e),s=a(null),[u,l]=r(0),[f,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||f>=u)return;const p=setInterval(()=>{c(w=>w>=u?(clearInterval(p),w):w+1)},o);return()=>clearInterval(p)},[u,o]);const d=f>=u&&u>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return S(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!d,void 0)},children:[S(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!d?`inset(0 ${(u-f)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&u>0&&S(\"span\",{class:\"macro-type-cursor\"})]})}});function jf(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=jf(e);return n.hooks.useLayoutEffect(()=>{Fa(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=A(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return S(\"span\",{id:t.id,class:r,children:n})}});const to=Ft(null);function no({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=A(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=ce(()=>{if(!o)return S(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=ct(o),c=ft(f);return Je(c)}catch(f){return S(\"div\",{class:\"error\",children:[\"Error in dialog: \",f.message]})}},[o]),u=f=>{f.target.classList.contains(\"dialog-overlay\")&&r()},l=n?`dialog-panel ${n}`:\"dialog-panel\";return S(to.Provider,{value:r,children:S(\"div\",{class:\"dialog-overlay\",onClick:u,children:S(\"div\",{class:l,children:[S(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),S(\"div\",{class:\"dialog-body\",children:s})]})})})}function Xe(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=e.dialog?te(!1):[!1,void 0],a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),S(K,{children:[S(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&S(no,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}Xe({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:A(e=>e.goBack),disabled:!A(e=>e.historyIndex>0)})});Xe({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:A(e=>e.goForward),disabled:!A(e=>e.historyIndex<e.history.length-1)})});Xe({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:A(e=>e.save)})});Xe({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=A(n=>n.load),t=A(n=>n.hasSave);return A(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});Xe({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:A(e=>e.restart)})});Xe({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});Xe({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Dt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",merged:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1);let a;try{const s=n.evaluate(e);a=String(s)}catch{a=e.replace(/^[\"']|[\"']$/g,\"\").trim()}const o=t.length?n.renderInlineNodes(t):a;return S(K,{children:[S(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:o}),r&&S(no,{passageName:a,onClose:()=>i(!1)})]})}});function Wf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Qf(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Gf(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Kf(){const[e,t]=te(\"load\"),[n,r]=te([]),[i,a]=te(!0),[o,s]=te(null),[u,l]=te(()=>new Set),[f,c]=te(null),[d,h]=te(\"\"),p=Ae(null),w=Ae(null),x=Te(to),_=A(T=>T.storyData),v=A(T=>T.playthroughId),k=A(T=>T.getSavePayload),E=A(T=>T.loadFromPayload),C=_?.ifid??\"\",y=Pe(async()=>{if(!C)return;const T=await wl(C);r(T),a(!1)},[C]);ze(()=>{y()},[y]),ze(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const D=Ae(),F=(T,j=\"success\")=>{clearTimeout(D.current),s({text:T,type:j}),D.current=window.setTimeout(()=>s(null),3e3)},O=T=>{l(j=>{const m=new Set(j);return m.has(T)?m.delete(T):m.add(T),m})},b=async()=>{if(!(!C||!v))try{const T=k();await Ea(C,v,T),F(\"Save created\"),await y()}catch{F(\"Failed to create save\",\"error\")}},P=async T=>{try{const j=k();await Aa(T,j),F(\"Save overwritten\"),await y()}catch{F(\"Failed to overwrite save\",\"error\")}},N=async T=>{try{E(T.payload),F(\"Game loaded\"),x&&setTimeout(x,500)}catch{F(\"Failed to load save\",\"error\")}},U=async T=>{if(confirm(\"Delete this save?\"))try{await vl(T),F(\"Save deleted\"),await y()}catch{F(\"Failed to delete save\",\"error\")}},q=T=>{c(T.meta.id),h(T.meta.title)},M=async()=>{if(!(!f||!d.trim()))try{await Sl(f,d.trim()),c(null),F(\"Save renamed\"),await y()}catch{F(\"Failed to rename\",\"error\")}},Y=T=>{T.key===\"Enter\"?M():T.key===\"Escape\"&&c(null)},G=async T=>{try{const j=await Al(T);if(!j)return;const m=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),H=URL.createObjectURL(m),ae=document.createElement(\"a\");ae.href=H,ae.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ae.click(),URL.revokeObjectURL(H),F(\"Save exported\")}catch{F(\"Failed to export save\",\"error\")}},ue=()=>{w.current?.click()},ge=async T=>{const j=T.target,m=j.files?.[0];if(m){j.value=\"\";try{const H=await m.text(),ae=JSON.parse(H);if(!Wf(ae))throw new Error(\"Invalid save file format\");await Pl(ae,C),F(\"Save imported\"),await y()}catch(H){F(H instanceof Error?H.message:\"Failed to import save\",\"error\")}}},g=n.reduce((T,j)=>T+j.saves.length,0);return S(\"div\",{class:\"save-manager\",children:[S(\"div\",{class:\"saves-header\",children:S(\"div\",{class:\"saves-header-left\",children:S(\"div\",{class:\"saves-mode-toggle\",children:[S(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),S(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),S(\"div\",{class:\"saves-toolbar\",children:[S(\"button\",{class:\"saves-toolbar-button\",onClick:ue,children:\"Import\"}),S(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ge})]}),S(\"div\",{class:\"saves-body\",children:[i?S(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):g===0&&e===\"load\"?S(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(T=>{const j=u.has(T.playthrough.id),m=T.playthrough.id===v;return e===\"save\"&&!m||e===\"load\"&&T.saves.length===0&&!m?null:S(\"div\",{class:\"playthrough-group\",children:[S(\"div\",{class:\"playthrough-header\",onClick:()=>O(T.playthrough.id),children:[S(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),S(\"span\",{class:\"playthrough-label\",children:[T.playthrough.label,m?\" (current)\":\"\"]}),S(\"span\",{class:\"playthrough-date\",children:Gf(T.playthrough.createdAt)})]}),!j&&S(\"div\",{class:\"playthrough-saves\",children:[T.saves.map(H=>S(\"div\",{class:\"save-slot\",children:[S(\"div\",{class:\"save-slot-info\",children:[f===H.meta.id?S(\"input\",{ref:p,class:\"save-rename-input\",value:d,onInput:ae=>h(ae.target.value),onKeyDown:Y,onBlur:M}):S(\"div\",{class:\"save-slot-title\",children:H.meta.title}),S(\"div\",{class:\"save-slot-meta\",children:[S(\"span\",{children:H.meta.passage}),S(\"span\",{children:Qf(H.meta.updatedAt)})]})]}),S(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?S(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(H.meta.id),children:\"Save Here\"}):S(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(H),children:\"Load\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>q(H),children:\"Rename\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>G(H.meta.id),children:\"Export\"}),S(\"button\",{class:\"save-slot-action danger\",onClick:()=>U(H.meta.id),children:\"Delete\"})]})]},H.meta.id)),e===\"save\"&&m&&S(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},T.playthrough.id)}),e===\"save\"&&!i&&!n.some(T=>T.playthrough.id===v)&&S(\"div\",{class:\"playthrough-group\",children:S(\"div\",{class:\"playthrough-saves\",children:S(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&S(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return S(Kf,{})}});function Yf({name:e,def:t}){const[n,r]=te(()=>Dt.get(e)),i=a=>{r(a),Dt.set(e,a)};switch(t.type){case\"toggle\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>S(\"option\",{value:a,children:a},a))})]});case\"range\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:[t.config.label,\": \",String(n)]}),S(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function Zf(){const e=Dt.getDefinitions();return S(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>S(Yf,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return S(Zf,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=A(u=>u.storyData);if(!n)return null;let r;try{const u=t.evaluate(e);r=String(u)}catch{r=e.replace(/^[\"']|[\"']$/g,\"\")}const i=n.passages.get(r);if(i&&A.getState().trackRender(r),!i)return S(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${r}\" not found}`});const a=ct(i.content),o=ft(a),s=t.renderNodes(o);return t.wrap(s)}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}A.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=A.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),S(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Jf(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}V({name:\"checkbox\",render({rawArgs:e},t){const{varName:n,label:r}=Jf(e),i=n.startsWith(\"$\")?n.slice(1):n,a=A(s=>s.variables[i]),o=A(s=>s.setVariable);return t.useAction({type:\"checkbox\",key:`$${i}`,authorId:t.id,label:r||i,variable:i,value:!!a,perform:s=>o(i,s!==void 0?!!s:!a)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>o(i,!a)}),r?` ${r}`:null]})}});function Xf(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}V({name:\"radiobutton\",render({rawArgs:e},t){const{varName:n,value:r,label:i}=Xf(e),a=n.startsWith(\"$\")?n.slice(1):n,o=A(u=>u.variables[a]),s=A(u=>u.setVariable);return t.useAction({type:\"radiobutton\",key:`$${a}:${r}`,authorId:t.id,label:i||r,variable:a,value:o,perform:()=>s(a,r)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"radio\",name:`radio-${a}`,checked:o===r,onChange:()=>s(a,r)}),i?` ${i}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),S(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>S(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const a=(n.indexOf(String(t.value))+1)%n.length;t.setValue(n[a])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),S(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function bt(e){const t=ct(e.content),n=ft(t);return Je(n)}const eh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function th({passage:e}){const t=A(d=>d.storyData),n=eh.has(e.name),[r,i]=te(!1),a=ce(()=>{try{return bt(e)}catch(d){return S(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Ja(e),\": \",d.message]})}},[e.content,e.name]),o=n?void 0:t?.passages.get(\"PassageHeader\"),s=n?void 0:t?.passages.get(\"PassageFooter\"),u=n?void 0:t?.passages.get(\"PassageDone\"),l=ce(()=>{if(!o)return null;try{return bt(o)}catch(d){return console.error(\"spindle: Error in PassageHeader:\",d),null}},[o?.content]),f=ce(()=>{if(!s)return null;try{return bt(s)}catch(d){return console.error(\"spindle: Error in PassageFooter:\",d),null}},[s?.content]);ze(()=>(u&&i(!0),()=>i(!1)),[e.name]);const c=ce(()=>{if(!r||!u)return null;try{return bt(u)}catch(d){return console.error(\"spindle: Error in PassageDone:\",d),null}},[r,u?.content]);return S(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:[l&&S(\"div\",{class:\"passage-header\",children:l}),a,f&&S(\"div\",{class:\"passage-footer\",children:f}),c&&S(\"div\",{hidden:!0,children:c})]})}V({name:\"passage\",interpolate:!0,render(e,t){const n=A(o=>o.currentPassage),r=A(o=>o.storyData),i=r?.passages.get(n);if(!i)return S(\"div\",{class:\"error\",children:[\"Error: Passage “\",n,\"” not found.\"]});const a=r?.passages.get(\"PassageReady\");return S(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[a&&S(\"div\",{hidden:!0,children:bt(a)},`ready-${n}`),S(th,{passage:i},n)]})}});function Oi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const o=document.createElement(\"li\");o.textContent=a,i.appendChild(o)}n.appendChild(i),e.appendChild(n)}function Ri(){const e=gf();if(Pf(),e.userCSS){const l=document.createElement(\"style\");l.textContent=e.userCSS,document.head.appendChild(l)}if(e.userScript)try{new Function(e.userScript)()}catch(l){console.error(\"spindle: Error in story JavaScript:\",l)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const l=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",f=document.getElementById(\"root\");throw f&&Oi(f,[l]),new Error(`spindle: ${l}`)}const r=Nf(n.content),i=zf(e.passages,r);if(i.length>0){const l=document.getElementById(\"root\");throw l&&Oi(l,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=Of(r),A.getState().init(e,t),Da();const a=Il(e.ifid);a&&A.getState().loadFromPayload(a);for(const[,l]of e.passages)if(l.tags.includes(\"widget\")){const f=ct(l.content),c=ft(f);for(const d of c)if(d.type===\"macro\"&&d.name===\"widget\"&&d.rawArgs){const h=d.rawArgs.trim().split(/\\s+/),p=h[0].replace(/[\"']/g,\"\"),w=h.slice(1).filter(x=>x.startsWith(\"$\")||x.startsWith(\"_\")||x.startsWith(\"@\"));Fa(p,d.children,w)}}let o=\"\";A.subscribe(l=>{l.currentPassage!==o&&(o=l.currentPassage,Sf())});const s=e.passages.get(\"StoryInterface\");s&&!s.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const u=document.getElementById(\"root\");if(!u)throw new Error('spindle: No <div id=\"root\"> element found.');at(S(mf,{}),u),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Ri):Ri();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|