@rohal12/spindle 0.16.0 → 0.17.0
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 +1 -1
- package/src/action-registry.ts +2 -1
- package/src/components/PassageDialog.tsx +69 -0
- 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 +36 -51
- 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 +26 -29
- 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/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 +52 -63
- 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/macros/register-builtins.ts +4 -7
- package/src/markup/ast.ts +10 -16
- package/src/markup/render.tsx +0 -13
- package/src/story-api.ts +7 -0
- 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,Xn,Cn,In,$i,Mt={},Bt=[],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 er(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),tr(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 En(e){(!e.__d&&(e.__d=!0)&&Ue.push(e)&&!Vt.__r++||Sr!=R.debounceRendering)&&((Sr=R.debounceRendering)||Ei)(Vt)}function Vt(){for(var e,t=1;Ue.length;)Ue.length>t&&Ue.sort(Ai),e=Ue.shift(),t=Ue.length,va(e);Vt.__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||Bt,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=tr(e,f,d,i,o,a,s,u,l,h),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&nr(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=Xn,e.addEventListener(t,o?In:Cn,o)):e.removeEventListener(t,o?In:Cn,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=Xn++;else if(t.t<n.u)return;return n(R.event?R.event(t):t)}}}function tr(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,B=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 B==\"function\")try{if(b=t.props,x=\"prototype\"in B&&B.prototype.render,w=(h=B.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 B(b,F):(t.__c=c=new Ee(b,F),c.constructor=B,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&&B.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ie({},c.__s)),Ie(c.__s,B.getDerivedStateFromProps(b,c.__s))),f=c.props,g=c.state,c.__v=t,d)x&&B.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&B.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)}),Bt.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),Bt.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--;)er(o[z]);An(t)}else t.__e=n.__e,t.__k=n.__k,y.then||An(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 An(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(An))}function zi(e,t,n){for(var r=0;r<n.length;r++)nr(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--;)er(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 nr(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||nr(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||er(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=[],tr(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 Xt(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,En(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=Bt.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),En(this))},Ee.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),En(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},Vt.__r=0,Pi=/(PointerCapture)$|Capture$/i,Xn=0,Cn=Cr(!1),In=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,gn,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,rr(Hi,e)}function rr(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&&ir(n.__H,t)&&(n.__=e,n.u=t,Q.__H.__h.push(n))}function xe(e,t){var n=nt(Ne++,4);!G.__s&&ir(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 ir(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 Bi(e,t){G.useDebugValue&&G.useDebugValue(t?t(e):e)}function Vi(){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(Pn),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&&(gn===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(Pn),t.__h=[],Ne=0)),gn=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})),gn=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.__||Pn(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 Pn(e){var t=Q;e.__c=e.__(),Q=t}function ir(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 $n(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,_n(i)&&o({t:i})},[e,n,t]),Ae(function(){return _n(i)&&o({t:i}),e(function(){_n(i)&&o({t:i})})},[e]),n}function _n(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 Tn(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:$n(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}(Tn.prototype=new Ee).isPureReactComponent=!0,Tn.prototype.shouldComponentUpdate=function(e,t){return $n(this.props,e)||$n(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]/,Ba=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Va=/[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 or,Ka={enumerable:!1,configurable:!0,get:function(){return this.class}},Br=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\":Ba.test(a)&&(a=u):u=a=\"oninput\":o&&Ma.test(a)?a=a.replace(Va,\"-$&\").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,Br&&Br(e)};var Vr=R.__r;R.__r=function(e){Vr&&Vr(e),or=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),or=null};var Ya={ReactCurrentDispatcher:{current:{readContext:function(e){return or.__n[e.__c].props.value},useCallback:ze,useContext:ke,useDebugValue:Bi,useDeferredValue:Wi,useEffect:Ae,useId:Vi,useImperativeHandle:Mi,useInsertionEffect:Gi,useLayoutEffect:xe,useMemo:Pe,useReducer:rr,useRef:pe,useState:Y,useSyncExternalStore:Ui,useTransition:Qi}}};function Za(e){return be.bind(null,e)}function en(e){return!!e&&e.$$typeof===Ji}function Ja(e){return en(e)&&e.type===K}function Xa(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function es(e){return en(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=en,It={useState:Y,useId:Vi,useReducer:rr,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:Bi,version:\"18.3.1\",Children:Fa,render:Ua,hydrate:ja,unmountComponentAtNode:ts,createPortal:La,createElement:be,createContext:Xt,createFactory:Za,cloneElement:es,createRef:ba,Fragment:K,isValidElement:en,isElement:as,isFragment:Ja,isMemo:Xa,findDOMNode:ns,Component:Ee,PureComponent:Tn,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\",tn=\"prototype\",Dn=\"configurable\",qt=\"enumerable\",zt=\"writable\",dt=\"value\",Le=e=>!!e&&!!e[oe];function Oe(e){return e?eo(e)||rn(e)||!!e[qr]||!!e[Ht]?.[qr]||on(e)||an(e):!1}var fs=ce[tn][Ht].toString(),Ur=new WeakMap;function eo(e){if(!e||!ar(e))return!1;const t=et(e);if(t===null||t===ce[tn])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 nn(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_:rn(e)?1:on(e)?2:an(e)?3:0}var jr=(e,t,n=xt(e))=>n===2?e.has(t):ce[tn].hasOwnProperty.call(e,t),Fn=(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 rn=Array.isArray,on=e=>e instanceof Map,an=e=>e instanceof Set,ar=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",yn=e=>typeof e==\"boolean\";function ds(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var De=e=>e.copy_||e.base_,sr=e=>e.modified_?e.copy_:e.base_;function zn(e,t){if(on(e))return new Map(e);if(an(e))return new Set(e);if(rn(e))return Array[tn].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[Dn]=!0),(s.get||s.set)&&(r[a]={[Dn]:!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 lr(e,t=!1){return sn(e)||Le(e)||!Oe(e)||(xt(e)>1&&ce.defineProperties(e,{set:Et,add:Et,clear:Et,delete:Et}),ce.freeze(e),t&&nn(e,(n,r)=>{lr(r,!0)},!1)),e}function ps(){ye(2)}var Et={[dt]:ps};function sn(e){return e===null||!ar(e)?!0:ce.isFrozen(e)}var jt=\"MapSet\",On=\"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(On),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Rn(e){Nn(e),e.drafts_.forEach(gs),e.drafts_=null}function Nn(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_&&(Rn(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),Rn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Xi?e:void 0}function Zr(e,t){if(sn(t))return t;const n=t[oe];if(!n)return Wt(t,e.handledSet_,e);if(!ln(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_&&lr(t,n)}function ro(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ln=(e,t)=>e.scope_===t,ys=[];function io(e,t,n,r){const i=De(e),o=e.type_;if(r!==void 0&&Fn(i,r,o)===t){Ut(i,r,n,o);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;nn(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||!ln(o,i))return;i.mapSetPlugin_?.fixSetContents(o);const a=sr(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];ln(i,r)&&i.callbacks_.push(function(){Ot(e);const a=sr(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):Fn(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Wt(Fn(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)||sn(e)||(t.add(e),nn(e,(r,i)=>{if(Le(i)){const o=i[oe];if(ln(o,n)){const a=sr(o);Ut(e,r,a,e.type_),ro(o)}}else Oe(i)&&Wt(i,t,n)})),e}function xs(e,t){const n=rn(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===bn(e.base_,t)){Ot(e);const a=e.type_===1?+t:t,s=Mn(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=bn(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),Ln(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),bn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Ln(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,[Dn]: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 bn(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 Ln(e){e.modified_||(e.modified_=!0,e.parent_&&Ln(e.parent_))}function Ot(e){e.copy_||(e.assigned_=new Map,e.copy_=zn(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=Mn(o,t,void 0);let s=!0;try{i=n(a),s=!1}finally{s?Rn(o):Nn(o)}return Gr(o,r),Yr(i,o)}else if(!t||!ar(t)){if(i=n(t),i===void 0&&(i=t),i===Xi&&(i=void 0),this.autoFreeze_&&lr(i,!0),r){const o=[],a=[];je(On).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]},yn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),yn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),yn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Oe(e)||ye(8),Le(e)&&(e=ws(e));const t=Kr(this),n=Mn(t,e,void 0);return n[oe].isManual_=!0,Nn(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(On).applyPatches_;return Le(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Mn(e,t,n,r){const[i,o]=on(t)?je(jt).proxyMap_(t,n):an(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)||sn(e))return e;const t=e[oe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=zn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=zn(e,!0);return nn(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 Bn(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 ur(){return!rt||!tt?Math.random():(We++,tt())}function co(e,t){return e>t&&([e,t]=[t,e]),Math.floor(ur()*(t-e+1))+e}function Rs(){return rt}function Ns(){return wt}function Ls(){return We}const Ms=500,qe=new Map,Bs=/\\$(\\w+)/g,Vs=/\\b_(\\w+)/g,Hs=/@(\\w+)/g;function qs(e){return e.replace(Bs,'variables[\"$1\"]').replace(Vs,'temporary[\"$1\"]').replace(Hs,'locals[\"$1\"]')}function cr(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+=cr(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:ur,randomInt:co},ti=t,ni=n,At}function ve(e,t,n,r={}){const o=`return (${cr(e)});`;return fo(o,o)(t,n,r,ho())}function Vn(e,t,n,r={}){const i=cr(e);fo(\"exec:\"+i,i)(t,n,r,ho())}const js=\"spindle\",Ws=1;let Pt=null,vn=null;function Me(){return vn||(vn={saves:new Map,playthroughs:new Map,meta:new Map}),vn}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 Be(e,t){return Qs().then(n=>n.transaction(e,t).objectStore(e))}function Ve(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function un(e){try{const t=await Be(\"saves\",\"readwrite\");await Ve(t.put(e))}catch{Me().saves.set(e.meta.id,e)}}async function cn(e){try{const t=await Be(\"saves\",\"readonly\");return await Ve(t.get(e))??void 0}catch{return Me().saves.get(e)}}async function Gs(e){try{const t=await Be(\"saves\",\"readwrite\");await Ve(t.delete(e))}catch{Me().saves.delete(e)}}async function Ks(e){try{const n=(await Be(\"saves\",\"readonly\")).index(\"ifid\");return await Ve(n.getAll(e))??[]}catch{return[...Me().saves.values()].filter(t=>t.meta.ifid===e)}}async function po(e){try{const t=await Be(\"playthroughs\",\"readwrite\");await Ve(t.put(e))}catch{Me().playthroughs.set(e.id,e)}}async function fr(e){try{const n=(await Be(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Ve(n.getAll(e))??[]}catch{return[...Me().playthroughs.values()].filter(t=>t.ifid===e)}}async function hr(e){try{const t=await Be(\"meta\",\"readonly\"),n=await Ve(t.get(e));return n?n.value:void 0}catch{return Me().meta.get(e)}}async function mo(e,t){try{const n=await Be(\"meta\",\"readwrite\");await Ve(n.put({key:e,value:t}))}catch{Me().meta.set(e,t)}}const go=new Map,fn=new Map;function Ys(e,t){go.set(e,t),fn.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(fn.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 Hn=\"__spindle_class__\",qn=\"__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=fn.get(o);if(a!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Hn]:a,[qn]: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(Hn in r&&qn in r){const a=r[Hn],s=r[qn],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(fn.has(i))return n;const o={};for(const a of Object.keys(r))o[a]=t(r[a]);return o}return t(e)}let Un=null,jn=null,ri=!1;function Js(e){Un=e}function Xs(e){jn=e}function el(e){if(jn)try{const i=new Function(\"passage\",\"variables\",jn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Un)try{const r=Un(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 fr(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 hr(`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 un(s),s}async function yo(e,t){const n=await cn(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 un(i),i}async function rl(e){const t=await cn(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 cn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await un(r)}async function al(e){const[t,n]=await Promise.all([Ks(e),fr(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 hr(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 hr(t);if(n)return rl(n)}async function ul(e){const t=await cn(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 fr(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 un(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?Bn(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?Bn(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?Bn(n.prng.seed,n.prng.pull):Rt()}}))),Yt=new Map,Wn=new Set,Qn=new Map;function hl(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Qn.get(r)??0)+1;return Qn.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(){Qn.clear()}function gl(e){return Wn.add(e),()=>{Wn.delete(e)}}function si(){for(const e of Wn)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 hn(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 Gn={}.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=(Gn.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Gn.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=(Gn.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 Kn(e){return e!==null&&(e<32||e===127)}const Yn=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(Bl(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 Bl(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,Vl=/^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:B,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:mn,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 B(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 mn(){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:Vl)+'\" 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 V(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\"),V(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,B,y;for(;z--;)if(t.events[z][0]===\"exit\"&&t.events[z][1].type===\"chunkFlow\"){if(B){y=t.events[z][1].end;break}B=!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 V(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 dn(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 Zn={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,dn(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||Kn(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 pn={partial:!0,tokenize:Jl};function Jl(e,t,n){return r;function r(o){return L(o)?V(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)?V(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=Yn,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)?V(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\"),V(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)?V(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 B=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)?V(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?(B++,v.consume(N),H):B>=a?(v.exit(\"codeFencedFenceSequence\"),L(N)?V(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 xn={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\"),V(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):V(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\"),V(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||Kn(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||Kn(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\"),V(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)?V(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)?V(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)?V(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)?V(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,B):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 B(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(pn,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)?B(m):n(m)}function B(m){return m===47?(e.consume(m),J):m===58||m===95||Ce(m)?(e.consume(m),y):D(m)?(a=B,Z(m)):L(m)?(e.consume(m),B):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):B(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)?B(m):(e.consume(m),q)}function N(m){return m===47||m===62||ne(m)?B(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)?V(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 dr={name:\"labelEnd\",resolveAll:Hu,resolveTo:qu,tokenize:Uu},Mu={tokenize:ju},Bu={tokenize:Wu},Vu={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,dn(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(Bu,h,a?l:c)(d):a?h(d):c(d)}function l(d){return e.attempt(Vu,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:dr.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:dr.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 kn={name:\"lineEnding\",tokenize:Ju};function Ju(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),V(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)?V(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:Yn(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 Yn(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(pn,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(pn,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,V(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,V(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 V(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 V(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)?V(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(pn,r,e.attempt(this.parser.constructs.flowInitial,i,V(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]:xn,[-1]:xn,32:xn},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]:kn,[-4]:kn,[-3]:kn,33:Gu,38:To,42:Zn,60:[Yl,Nu],91:Yu,92:[wu,$o],93:dr,95:Zn,96:uu},xc={null:[Zn,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=dn(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,mn=[...Array.isArray(Qe)?Qe:Qe?[Qe]:[],...Array.isArray(Ge)?Ge:Ge?[Ge]:[]];return E(mn)(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=B(),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 B(){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 Sn={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=Sn[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=Sn[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\"+Sn[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)?V(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)?V(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)?V(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)?V(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)?V(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?B:z)}function B(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 Bc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Vc(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,dn(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(),Vc()],htmlExtensions:[Dc(),Bc()]})}const qc={update:()=>{},getValues:()=>({})},it=Xt({}),ot=Xt(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 Jn(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)=>Jn(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)=>Jn(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(Jn(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 Bo(){return`spindle.${S.getState().storyData?.ifid||\"unknown\"}.settings`}function Xc(){localStorage.setItem(Bo(),JSON.stringify(re))}function wn(){if(!bi){bi=!0;try{const e=localStorage.getItem(Bo());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),wn()},addList(e,t){ut.set(e,{type:\"list\",config:t}),e in re||(re[e]=t.default),wn()},addRange(e,t){ut.set(e,{type:\"range\",config:t}),e in re||(re[e]=t.default),wn()},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 ur()},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 Vo(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,Vo(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=Vo(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 pr(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Sf({children:e=[]}){const t=pr(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:pr(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=pr(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);hn(\"case\");hn(\"default\");function Jt(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({rawArgs:e,children:t=[],branches:n=[],className:r,id:i}){const o=de(),a=n[0];r=o(r??a?.className),i=o(i??a?.id);const s=Pe(()=>{const c=[];c.push({delay:Jt(e),nodes:t});for(const d of n){const f=d.rawArgs?Jt(d.rawArgs):0;c.push({delay:f,nodes:d.children})}return c},[e,t,n]),[u,l]=Y(-1);if(Ae(()=>{if(u>=s.length-1)return;const c=u+1,d=s[c].delay,f=setTimeout(()=>{l(c)},d);return()=>clearTimeout(f)},[u,s]),u<0)return null;const h=me(s[u].nodes);return r||i?_(\"span\",{id:i,class:r,children:h}):_(K,{children:h})}M(\"timed\",Af);hn(\"next\");const qo=Xt({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=Jt(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=Jt(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 Bf({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 Vf({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])=>_(Bf,{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&&_(Vf,{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)},B=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:()=>B(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);hn(\"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.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 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 _t,O,Ci,Me,wr,Ii,Ei,Ai,Gn,bn,vn,Pi,Ot={},Rt=[],yo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,yt=Array.isArray;function ye(e,t){for(var n in t)e[n]=t[n];return e}function Kn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function se(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?_t.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 ut(e,o,r,i,null)}function ut(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??++Ci,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function bo(){return{current:null}}function G(e){return e.children}function be(e,t){this.props=e,this.context=t}function Ge(e,t){if(t==null)return e.__?Ge(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\"?Ge(e):null}function vo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=ye({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Yn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ge(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,$i(r,a,i),t.__e=t.__=null,a.__e!=n&&Ti(a)}}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 kn(e){(!e.__d&&(e.__d=!0)&&Me.push(e)&&!Mt.__r++||wr!=O.debounceRendering)&&((wr=O.debounceRendering)||Ii)(Mt)}function Mt(){for(var e,t=1;Me.length;)Me.length>t&&Me.sort(Ei),e=Me.shift(),t=Me.length,vo(e);Mt.__r=0}function Ni(e,t,n,r,i,a,o,s,u,l,f){var c,d,h,g,S,I,b,k=r&&r.__k||Rt,w=t.length;for(u=ko(n,t,k,u,w),c=0;c<w;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&k[h.__i]||Ot,h.__i=c,I=Yn(e,h,d,i,a,o,s,u,l,f),g=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Zn(d.ref,null,h),f.push(h.ref,h.__c||g,h)),S==null&&g!=null&&(S=g),(b=!!(4&h.__u))||d.__k===h.__k?u=Di(h,u,e,b):typeof h.type==\"function\"&&I!==void 0?u=I:g&&(u=g.nextSibling),h.__u&=-7);return n.__e=S,u}function ko(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]=ut(null,o,null,null,null):yt(o)?o=e.__k[a]=ut(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=ut(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=wo(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=Ge(s)),Fi(s,s));return r}function Di(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=Di(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ge(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Se(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(yt(e)?e.some(function(n){Se(n,t)}):t.push(e)),t}function wo(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 Sr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||yo.test(t)?n:n+\"px\"}function wt(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||Sr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Sr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Ai,\"$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=Gn,e.addEventListener(t,a?vn:bn,a)):e.removeEventListener(t,a?vn:bn,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 xr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Gn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Yn(e,t,n,r,i,a,o,s,u,l){var f,c,d,h,g,S,I,b,k,w,N,E,v,F,z,L=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof L==\"function\")try{if(b=t.props,k=\"prototype\"in L&&L.prototype.render,w=(f=L.contextType)&&r[f.__c],N=f?w?w.props.value:f.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(k?t.__c=c=new L(b,N):(t.__c=c=new be(b,N),c.constructor=L,c.render=xo),w&&w.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),k&&c.__s==null&&(c.__s=c.state),k&&L.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=ye({},c.__s)),ye(c.__s,L.getDerivedStateFromProps(b,c.__s))),h=c.props,g=c.state,c.__v=t,d)k&&L.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),k&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(k&&L.getDerivedStateFromProps==null&&b!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,N),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,N)===!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(_){_&&(_.__=t)}),Rt.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,N),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,g,S)})}if(c.context=N,c.props=b,c.__P=e,c.__e=!1,E=O.__r,v=0,k)c.state=c.__s,c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),Rt.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),f=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=ye(ye({},r),c.getChildContext())),k&&!d&&c.getSnapshotBeforeUpdate!=null&&(S=c.getSnapshotBeforeUpdate(h,g)),F=f!=null&&f.type===G&&f.key==null?zi(f.props.children):f,s=Ni(e,yt(F)?F:[F],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),I&&(c.__E=c.__=null)}catch(_){if(t.__v=null,u||a!=null)if(_.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(z=a.length;z--;)Kn(a[z]);wn(t)}else t.__e=n.__e,t.__k=n.__k,_.then||wn(t);O.__e(_,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=So(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function wn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(wn))}function $i(e,t,n){for(var r=0;r<n.length;r++)Zn(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function zi(e){return typeof e!=\"object\"||e==null||e.__b>0?e:yt(e)?e.map(zi):ye({},e)}function So(e,t,n,r,i,a,o,s,u){var l,f,c,d,h,g,S,I=n.props||Ot,b=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"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==!!k&&(k?h.localName==k:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(b);e=document.createElementNS(i,k,b.is&&b),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)I===b||s&&e.data==b||(e.data=b);else{if(a=a&&_t.call(e.childNodes),!s&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(h=e.attributes[l]).name]=h.value;for(l in I)h=I[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||wt(e,l,null,h,i);for(l in b)h=b[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?g=h:l==\"checked\"?S=h:s&&typeof h!=\"function\"||I[l]===h||wt(e,l,h,I[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=\"\"),Ni(t.type==\"template\"?e.content:e,yt(d)?d:[d],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&Ge(n,0),s,u),a!=null)for(l=a.length;l--;)Kn(a[l]);s||(l=\"value\",k==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[l]||k==\"progress\"&&!g||k==\"option\"&&g!=I[l])&&wt(e,l,g,I[l],i),l=\"checked\",S!=null&&S!=e[l]&&wt(e,l,S,I[l],i))}return e}function Zn(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){O.__e(i,n)}}function Fi(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Zn(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Fi(r[i],t,n||typeof e.type!=\"function\");n||Kn(e.__e),e.__c=e.__=e.__e=void 0}function xo(e,t,n){return this.constructor(e,n)}function Ke(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],Yn(t,e=(!r&&n||t).__k=se(G,null,[e]),i||Ot,Ot,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?_t.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),$i(a,e,o)}function Oi(e,t){Ke(e,t,Oi)}function Co(e,t,n){var r,i,a,o,s=ye({},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?_t.call(arguments,2):n),ut(e.type,s,r||e.key,i||e.ref,null)}function bt(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,kn(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\"+Pi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}_t=Rt.slice,O={__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}},Ci=0,be.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ye({},this.state),typeof e==\"function\"&&(e=e(ye({},n),this.props)),e&&ye(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),kn(this))},be.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),kn(this))},be.prototype.render=G,Me=[],Ii=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ei=function(e,t){return e.__v.__b-t.__v.__b},Mt.__r=0,Ai=/(PointerCapture)$|Capture$/i,Gn=0,bn=xr(!1),vn=xr(!0),Pi=0;var Io=0;function y(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:--Io,__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 O.vnode&&O.vnode(l),l}var Pe,W,cn,Cr,Ye=0,Ri=[],Q=O,Ir=Q.__b,Er=Q.__r,Ar=Q.diffed,Pr=Q.__c,Tr=Q.unmount,Nr=Q.__;function Xe(e,t){Q.__h&&Q.__h(W,e,Ye||t),Ye=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ie(e){return Ye=1,Jn(Bi,e)}function Jn(e,t,n){var r=Xe(Pe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Bi(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 Le(e,t){var n=Xe(Pe++,3);!Q.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function He(e,t){var n=Xe(Pe++,4);!Q.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function xe(e){return Ye=5,ve(function(){return{current:e}},[])}function Mi(e,t,n){Ye=6,He(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 ve(e,t){var n=Xe(Pe++,7);return Xn(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ce(e,t){return Ye=8,ve(function(){return e},t)}function Ee(e){var t=W.context[e.__c],n=Xe(Pe++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Li(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function Vi(){var e=Xe(Pe++,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 Eo(){for(var e;e=Ri.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Pt),t.__h.some(Sn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Ir&&Ir(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Nr&&Nr(e,t)},Q.__r=function(e){Er&&Er(e),Pe=0;var t=(W=e.__c).__H;t&&(cn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Pt),t.__h.some(Sn),t.__h=[],Pe=0)),cn=W},Q.diffed=function(e){Ar&&Ar(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ri.push(t)!==1&&Cr===Q.requestAnimationFrame||((Cr=Q.requestAnimationFrame)||Ao)(Eo)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),cn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Pt),n.__h=n.__h.filter(function(r){return!r.__||Sn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Pr&&Pr(e,t)},Q.unmount=function(e){Tr&&Tr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Pt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Dr=typeof requestAnimationFrame==\"function\";function Ao(e){var t,n=function(){clearTimeout(r),Dr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Dr&&(t=requestAnimationFrame(n))}function Pt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Sn(e){var t=W;e.__c=e.__(),W=t}function Xn(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Bi(e,t){return typeof t==\"function\"?t(e):t}const $r=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},Po=(e=>e?$r(e):$r);function Hi(e,t){for(var n in t)e[n]=t[n];return e}function xn(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=ie({t:{__:n,u:t}}),i=r[0].t,a=r[1];return He(function(){i.__=n,i.u=t,fn(i)&&a({t:i})},[e,n,t]),Le(function(){return fn(i)&&a({t:i}),e(function(){fn(i)&&a({t:i})})},[e]),n}function fn(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 qi(e){e()}function ji(e){return e}function Wi(){return[!1,qi]}var Qi=He;function Cn(e,t){this.props=e,this.context=t}function To(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:xn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,se(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Cn.prototype=new be).isPureReactComponent=!0,Cn.prototype.shouldComponentUpdate=function(e,t){return xn(this.props,e)||xn(this.state,t)};var zr=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),zr&&zr(e)};var No=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Do(e){function t(n){var r=Hi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=No,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Fr=function(e,t){return e==null?null:Se(Se(e).map(t))},$o={map:Fr,forEach:Fr,count:function(e){return e?Se(e).length:0},only:function(e){var t=Se(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Se},zo=O.__e;O.__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)}zo(e,t,n,r)};var Or=O.unmount;function Gi(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=Hi({},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 Gi(r,t,n)})),e}function Ki(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ki(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 Tt(){this.__u=0,this.o=null,this.__b=null}function Yi(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Fo(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?se(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function lt(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Or&&Or(e)},(Tt.prototype=new be).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Yi(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]=Ki(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)},Tt.prototype.componentWillUnmount=function(){this.o=[]},Tt.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]=Gi(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&se(G,null,e.fallback);return i&&(i.__u&=-33),[se(G,null,t.__a?null:e.children),i]};var Rr=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 Oo(e){return this.getChildContext=function(){return e.context},e.children}function Ro(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ke(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)}}}Ke(se(Oo,{context:t.context},e.__v),t.v)}function Mo(e,t){var n=se(Ro,{__v:e,h:t});return n.containerInfo=t,n}(lt.prototype=new be).__a=function(e){var t=this,n=Yi(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Rr(t,e,r)):i()};n?n(a):a()}},lt.prototype.render=function(e){this.i=null,this.l=new Map;var t=Se(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},lt.prototype.componentDidUpdate=lt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Rr(e,n,t)})};var Zi=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Lo=/^(?: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]/,Vo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Bo=/[A-Z0-9]/g,Ho=typeof document<\"u\",Uo=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function qo(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ke(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function jo(e,t,n){return Oi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}be.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(be.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=O.event;function Wo(){}function Qo(){return this.cancelBubble}function Go(){return this.defaultPrevented}O.event=function(e){return Mr&&(e=Mr(e)),e.persist=Wo,e.isPropagationStopped=Qo,e.isDefaultPrevented=Go,e.nativeEvent=e};var er,Ko={enumerable:!1,configurable:!0,get:function(){return this.class}},Lr=O.vnode;O.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||Ho&&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\"||Uo(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":Vo.test(o)&&(o=u):u=o=\"oninput\":a&&Lo.test(o)?o=o.replace(Bo,\"-$&\").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=Se(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Se(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\",Ko)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Zi,Lr&&Lr(e)};var Vr=O.__r;O.__r=function(e){Vr&&Vr(e),er=e.__c};var Br=O.diffed;O.diffed=function(e){Br&&Br(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),er=null};var Yo={ReactCurrentDispatcher:{current:{readContext:function(e){return er.__n[e.__c].props.value},useCallback:Ce,useContext:Ee,useDebugValue:Li,useDeferredValue:ji,useEffect:Le,useId:Vi,useImperativeHandle:Mi,useInsertionEffect:Qi,useLayoutEffect:He,useMemo:ve,useReducer:Jn,useRef:xe,useState:ie,useSyncExternalStore:Ui,useTransition:Wi}}};function Zo(e){return se.bind(null,e)}function Kt(e){return!!e&&e.$$typeof===Zi}function Jo(e){return Kt(e)&&e.type===G}function Xo(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function es(e){return Kt(e)?Co.apply(null,arguments):e}function ts(e){return!!e.__k&&(Ke(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)},as=G,os=Kt,St={useState:ie,useId:Vi,useReducer:Jn,useEffect:Le,useLayoutEffect:He,useInsertionEffect:Qi,useTransition:Wi,useDeferredValue:ji,useSyncExternalStore:Ui,startTransition:qi,useRef:xe,useImperativeHandle:Mi,useMemo:ve,useCallback:Ce,useContext:Ee,useDebugValue:Li,version:\"18.3.1\",Children:$o,render:qo,hydrate:jo,unmountComponentAtNode:ts,createPortal:Mo,createElement:se,createContext:bt,createFactory:Zo,cloneElement:es,createRef:bo,Fragment:G,isValidElement:Kt,isElement:os,isFragment:Jo,isMemo:Xo,findDOMNode:ns,Component:be,PureComponent:Cn,memo:To,forwardRef:Do,flushSync:is,unstable_batchedUpdates:rs,StrictMode:as,Suspense:Tt,SuspenseList:lt,lazy:Fo,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Yo};const ss=e=>e;function ls(e,t=ss){const n=St.useSyncExternalStore(e.subscribe,St.useCallback(()=>t(e.getState()),[e,t]),St.useCallback(()=>t(e.getInitialState()),[e,t]));return St.useDebugValue(n),n}const us=e=>{const t=Po(e),n=r=>ls(t,r);return Object.assign(n,t),n},cs=(e=>us);var Ji=Symbol.for(\"immer-nothing\"),Hr=Symbol.for(\"immer-draftable\"),ae=Symbol.for(\"immer-state\");function pe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ue=Object,Ze=ue.getPrototypeOf,Lt=\"constructor\",Yt=\"prototype\",In=\"configurable\",Vt=\"enumerable\",Nt=\"writable\",ft=\"value\",Te=e=>!!e&&!!e[ae];function Ie(e){return e?Xi(e)||Jt(e)||!!e[Hr]||!!e[Lt]?.[Hr]||Xt(e)||en(e):!1}var fs=ue[Yt][Lt].toString(),Ur=new WeakMap;function Xi(e){if(!e||!tr(e))return!1;const t=Ze(e);if(t===null||t===ue[Yt])return!0;const n=ue.hasOwnProperty.call(t,Lt)&&t[Lt];if(n===Object)return!0;if(!We(n))return!1;let r=Ur.get(n);return r===void 0&&(r=Function.toString.call(n),Ur.set(n,r)),r===fs}function Zt(e,t,n=!0){vt(e)===0?(n?Reflect.ownKeys(e):ue.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function vt(e){const t=e[ae];return t?t.type_:Jt(e)?1:Xt(e)?2:en(e)?3:0}var qr=(e,t,n=vt(e))=>n===2?e.has(t):ue[Yt].hasOwnProperty.call(e,t),En=(e,t,n=vt(e))=>n===2?e.get(t):e[t],Bt=(e,t,n,r=vt(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 Jt=Array.isArray,Xt=e=>e instanceof Map,en=e=>e instanceof Set,tr=e=>typeof e==\"object\",We=e=>typeof e==\"function\",hn=e=>typeof e==\"boolean\";function ds(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var we=e=>e.copy_||e.base_,nr=e=>e.modified_?e.copy_:e.base_;function An(e,t){if(Xt(e))return new Map(e);if(en(e))return new Set(e);if(Jt(e))return Array[Yt].slice.call(e);const n=Xi(e);if(t===!0||t===\"class_only\"&&!n){const r=ue.getOwnPropertyDescriptors(e);delete r[ae];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Nt]===!1&&(s[Nt]=!0,s[In]=!0),(s.get||s.set)&&(r[o]={[In]:!0,[Nt]:!0,[Vt]:s[Vt],[ft]:e[o]})}return ue.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=ue.create(r);return ue.assign(i,e)}}function rr(e,t=!1){return tn(e)||Te(e)||!Ie(e)||(vt(e)>1&&ue.defineProperties(e,{set:xt,add:xt,clear:xt,delete:xt}),ue.freeze(e),t&&Zt(e,(n,r)=>{rr(r,!0)},!1)),e}function ps(){pe(2)}var xt={[ft]:ps};function tn(e){return e===null||!tr(e)?!0:ue.isFrozen(e)}var Ht=\"MapSet\",Pn=\"Patches\",jr=\"ArrayMethods\",ea={};function Ve(e){const t=ea[e];return t||pe(0,e),t}var Wr=e=>!!ea[e],ht,ta=()=>ht,ms=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Wr(Ht)?Ve(Ht):void 0,arrayMethodsPlugin_:Wr(jr)?Ve(jr):void 0});function Qr(e,t){t&&(e.patchPlugin_=Ve(Pn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Tn(e){Nn(e),e.drafts_.forEach(gs),e.drafts_=null}function Nn(e){e===ht&&(ht=e.parent_)}var Gr=e=>ht=ms(ht,e);function gs(e){const t=e[ae];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Kr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ae].modified_&&(Tn(t),pe(4)),Ie(e)&&(e=Yr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ae].base_,e,t)}else e=Yr(t,n);return _s(t,e,!0),Tn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ji?e:void 0}function Yr(e,t){if(tn(t))return t;const n=t[ae];if(!n)return Ut(t,e.handledSet_,e);if(!nn(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);ia(n,e)}return n.copy_}function _s(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&rr(t,n)}function na(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var nn=(e,t)=>e.scope_===t,ys=[];function ra(e,t,n,r){const i=we(e),a=e.type_;if(r!==void 0&&En(i,r,a)===t){Bt(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Zt(i,(u,l)=>{if(Te(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??ys;for(const s of o)Bt(i,s,n,a)}function bs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!nn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=nr(a);ra(e,a.draft_??a,o,n),ia(a,i)})}function ia(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)}na(e)}}function vs(e,t,n){const{scope_:r}=e;if(Te(n)){const i=n[ae];nn(i,r)&&i.callbacks_.push(function(){Dt(e);const o=nr(i);ra(e,n,o,t)})}else Ie(n)&&e.callbacks_.push(function(){const a=we(e);e.type_===3?a.has(n)&&Ut(n,r.handledSet_,r):En(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Ut(En(e.copy_,t,e.type_),r.handledSet_,r)})}function Ut(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Te(e)||t.has(e)||!Ie(e)||tn(e)||(t.add(e),Zt(e,(r,i)=>{if(Te(i)){const a=i[ae];if(nn(a,n)){const o=nr(a);Bt(e,r,o,e.type_),na(a)}}else Ie(i)&&Ut(i,t,n)})),e}function ks(e,t){const n=Jt(e),r={type_:n?1:0,scope_:t?t.scope_:ta(),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=qt;n&&(i=[r],a=dt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var qt={get(e,t){if(t===ae)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=we(e);if(!qr(i,t,e.type_))return ws(e,i,t);const a=i[t];if(e.finalized_||!Ie(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&ds(t))return a;if(a===dn(e.base_,t)){Dt(e);const o=e.type_===1?+t:t,s=$n(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in we(e)},ownKeys(e){return Reflect.ownKeys(we(e))},set(e,t,n){const r=aa(we(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=dn(we(e),t),a=i?.[ae];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(hs(n,i)&&(n!==void 0||qr(e.base_,t,e.type_)))return!0;Dt(e),Dn(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 Dt(e),dn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Dn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=we(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Nt]:!0,[In]:e.type_!==1||t!==\"length\",[Vt]:r[Vt],[ft]:n[t]}},defineProperty(){pe(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){pe(12)}},dt={};for(let e in qt){let t=qt[e];dt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}dt.deleteProperty=function(e,t){return dt.set.call(this,e,t,void 0)};dt.set=function(e,t,n){return qt.set.call(this,e[0],t,n,e[0])};function dn(e,t){const n=e[ae];return(n?we(n):e)[t]}function ws(e,t,n){const r=aa(t,n);return r?ft in r?r[ft]:r.get?.call(e.draft_):void 0}function aa(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Dn(e){e.modified_||(e.modified_=!0,e.parent_&&Dn(e.parent_))}function Dt(e){e.copy_||(e.assigned_=new Map,e.copy_=An(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(We(t)&&!We(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,f=>n.call(this,f,...l))}}We(n)||pe(6),r!==void 0&&!We(r)&&pe(7);let i;if(Ie(t)){const a=Gr(this),o=$n(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Tn(a):Nn(a)}return Qr(a,r),Kr(i,a)}else if(!t||!tr(t)){if(i=n(t),i===void 0&&(i=t),i===Ji&&(i=void 0),this.autoFreeze_&&rr(i,!0),r){const a=[],o=[];Ve(Pn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else pe(1,t)},this.produceWithPatches=(t,n)=>{if(We(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]},hn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),hn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),hn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ie(e)||pe(8),Te(e)&&(e=xs(e));const t=Gr(this),n=$n(t,e,void 0);return n[ae].isManual_=!0,Nn(t),n}finishDraft(e,t){const n=e&&e[ae];(!n||!n.isManual_)&&pe(9);const{scope_:r}=n;return Qr(r,t),Kr(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=Ve(Pn).applyPatches_;return Te(e)?r(e,t):this.produce(e,i=>r(i,t))}};function $n(e,t,n,r){const[i,a]=Xt(t)?Ve(Ht).proxyMap_(t,n):en(t)?Ve(Ht).proxySet_(t,n):ks(t,n);return(n?.scope_??ta()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?bs(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 xs(e){return Te(e)||pe(10,e),oa(e)}function oa(e){if(!Ie(e)||tn(e))return e;const t=e[ae];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=An(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=An(e,!0);return Zt(n,(i,a)=>{Bt(n,i,oa(a))},r),t&&(t.finalized_=!1),n}var Cs=new Ss,Is=Cs.produce;const Es=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Is(i):i;return t(s,a,...o)},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\"]),Ts=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Ns(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 Zr(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 Jr(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 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 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 et(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 g=Jr(e,n);o=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=a+2,r=a;continue}const f=e.slice(l,n);n+=2;const{display:c,target:d}=Ns(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=Jr(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 g={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),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 g={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),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 g={type:\"variable\",name:h,scope:\"local\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),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 g=e.slice(h,n);n++;const{name:S,rawArgs:I,isClose:b}=Zr(g),k={type:\"macro\",name:S,rawArgs:I,isClose:b,start:a,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),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:g}=Zr(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:g,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&&Ps.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=Ds(e,o);o=f.endIdx;let c=Ts.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 $s=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Xr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},zs=new Set([\"if\",\"switch\",\"timed\"]);function tt(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(Xr[i.name]){const a=Xr[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($s.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(zs.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 sa(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 la(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let nt=!1,kt=\"\",Be=0,Je=null;function Fs(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,kt=n,Be=0,Je=sa(la(n)),nt=!0}function zn(e,t){kt=e,Be=0,Je=sa(la(e)),nt=!0;for(let n=0;n<t;n++)Je();Be=t}function $t(){nt=!1,kt=\"\",Be=0,Je=null}function zt(){return nt?{seed:kt,pull:Be}:null}function ir(){return!nt||!Je?Math.random():(Be++,Je())}function ua(e,t){return e>t&&([e,t]=[t,e]),Math.floor(ir()*(t-e+1))+e}function Os(){return nt}function Rs(){return kt}function Ms(){return Be}const Ls=500,Re=new Map,Vs=/\\$(\\w+)/g,Bs=/\\b_(\\w+)/g,Hs=/@(\\w+)/g;function Us(e){return e.replace(Vs,'variables[\"$1\"]').replace(Bs,'temporary[\"$1\"]').replace(Hs,'locals[\"$1\"]')}function ar(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Us(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+=ar(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 qs=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ca(e,t){const n=Re.get(e);if(n)return Re.delete(e),Re.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",qs+t);if(Re.set(e,r),Re.size>Ls){const i=Re.keys().next().value;i!==void 0&&Re.delete(i)}return r}let Ct=null,ei=null,ti=null;function fa(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(Ct&&ei===t&&ti===n)return Ct;const r=h=>t[h]??0,i=h=>r(h)>0,a=(...h)=>h.some(g=>r(g)>0),o=(...h)=>h.every(g=>r(g)>0),s=h=>n[h]??0;return Ct={currentPassage:()=>{const h=C.getState();return h.storyData?.passages.get(h.currentPassage)},previousPassage:()=>{const h=C.getState();if(h.historyIndex<=0)return;const g=h.history[h.historyIndex-1]?.passage;return g?h.storyData?.passages.get(g):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:h=>s(h)>0,hasRenderedAny:(...h)=>h.some(g=>s(g)>0),hasRenderedAll:(...h)=>h.every(g=>s(g)>0),random:ir,randomInt:ua},ei=t,ti=n,Ct}function or(e,t,n,r={}){const a=`return (${ar(e)});`;return ca(a,a)(t,n,r,fa())}function Fn(e,t,n,r={}){const i=ar(e);ca(\"exec:\"+i,i)(t,n,r,fa())}const js=\"spindle\",Ws=1;let It=null,pn=null;function De(){return pn||(pn={saves:new Map,playthroughs:new Map,meta:new Map}),pn}function Qs(){return It||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(It=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)}),It))}function $e(e,t){return Qs().then(n=>n.transaction(e,t).objectStore(e))}function ze(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function rn(e){try{const t=await $e(\"saves\",\"readwrite\");await ze(t.put(e))}catch{De().saves.set(e.meta.id,e)}}async function an(e){try{const t=await $e(\"saves\",\"readonly\");return await ze(t.get(e))??void 0}catch{return De().saves.get(e)}}async function Gs(e){try{const t=await $e(\"saves\",\"readwrite\");await ze(t.delete(e))}catch{De().saves.delete(e)}}async function Ks(e){try{const n=(await $e(\"saves\",\"readonly\")).index(\"ifid\");return await ze(n.getAll(e))??[]}catch{return[...De().saves.values()].filter(t=>t.meta.ifid===e)}}async function ha(e){try{const t=await $e(\"playthroughs\",\"readwrite\");await ze(t.put(e))}catch{De().playthroughs.set(e.id,e)}}async function sr(e){try{const n=(await $e(\"playthroughs\",\"readonly\")).index(\"ifid\");return await ze(n.getAll(e))??[]}catch{return[...De().playthroughs.values()].filter(t=>t.ifid===e)}}async function lr(e){try{const t=await $e(\"meta\",\"readonly\"),n=await ze(t.get(e));return n?n.value:void 0}catch{return De().meta.get(e)}}async function da(e,t){try{const n=await $e(\"meta\",\"readwrite\");await ze(n.put({key:e,value:t}))}catch{De().meta.set(e,t)}}const pa=new Map,on=new Map;function Ys(e,t){pa.set(e,t),on.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 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(on.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(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 On=\"__spindle_class__\",Rn=\"__spindle_data__\";function jt(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=on.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[On]:o,[Rn]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Wt(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(On in r&&Rn in r){const o=r[On],s=r[Rn],u=pa.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(on.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Mn=null,Ln=null,ni=!1;function Js(e){Mn=e}function Xs(e){Ln=e}function el(e){if(Ln)try{const i=new Function(\"passage\",\"variables\",Ln)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Mn)try{const r=Mn(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(){ni||(ni=!0)}async function ri(e){const n=(await sr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await ha(i),await da(`currentPlaythroughId.${e}`,r),r}async function nl(e){return lr(`currentPlaythroughId.${e}`)}async function ma(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:el(n),passage:n.passage,custom:r},o=Z(n);o.variables=jt(o.variables),o.history=o.history.map(u=>({...u,variables:jt(u.variables)}));const s={meta:a,payload:o};return await rn(s),s}async function ga(e,t){const n=await an(e);if(!n)return;const r=Z(t);r.variables=jt(r.variables),r.history=r.history.map(a=>({...a,variables:jt(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await rn(i),i}async function rl(e){const t=await an(e);if(!t)return;const n=t.payload;return n.variables=Wt(n.variables),n.history=n.history.map(r=>({...r,variables:Wt(r.variables)})),n}async function il(e){await Gs(e)}async function al(e,t){const n=await an(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await rn(r)}async function ol(e){const[t,n]=await Promise.all([Ks(e),sr(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 _a=\"autosave.\";async function sl(e,t,n){const r=`${_a}${e}`,i=await lr(r);if(i){const o=await ga(i,n);if(o)return o}const a=await ma(e,t,n,{isAutosave:!0});return await da(r,a.meta.id),a}async function ll(e){const t=`${_a}${e}`,n=await lr(t);if(n)return rl(n)}async function ul(e){const t=await an(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=Z(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await sr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await ha(a)}return await rn(n),n}function fl(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Fn(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Fn(i,t,n)}}}function ya(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=et(t.content),r=tt(n),i=Z(e.variables),a=Z(e.temporary);fl(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&&Xs(o.content)}function ii(e){e?.prng?zn(e.prng.seed,e.prng.pull):e&&$t()}const C=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 a=Z(r);e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,variables:Z(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}});const o=n.ifid;tl().then(async()=>{const s=await nl(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ri(o);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:Z(i.variables),timestamp:Date.now(),prng:zt()}),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=Z(r.variables),n.temporary={}}),ii(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=Z(r.variables),n.temporary={}}),ii(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;$t();const a=Z(r);e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,variables:Z(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),ya(),ri(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,currentPassage:i,variables:a,history:o,historyIndex:s,visitCounts:u,renderCounts:l}=t();if(!n)return;const f={passage:i,variables:Z(a),history:Z(o),historyIndex:s,visitCounts:{...u},renderCounts:{...l},prng:zt()};e(c=>{c.saveError=null}),sl(n.ifid,r,f).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?zn(r.prng.seed,r.prng.pull):$t())}).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();return{passage:n,variables:Z(r),history:Z(i),historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:zt()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Wt(n.variables),r.history=n.history.map(i=>({...i,variables:Wt(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?zn(n.prng.seed,n.prng.pull):$t()}})));function ur(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Ee(rt);return ve(()=>[e,t,n],[e,t,n])}const hl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,dl=/\\{[\\$_@][\\w.]+\\}/;function ba(e){return dl.test(e)}function pl(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 va(e,t,n,r){return e.replace(hl,(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=pl(f,u)),f==null?\"\":String(f)})}function cr(){const[e,t,n]=ur();return Ce(r=>r===void 0||!ba(r)?r:va(r,e,t,n),[e,t,n])}function ml({name:e,scope:t,className:n,id:r}){const i=cr();n=i(n),r=i(r);const a=Ee(rt),o=e.split(\".\"),s=o[0],u=C(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?y(\"span\",{id:r,class:n,children:f}):y(G,{children:f})}function gl(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 _l({body:e,parentValues:t,ownKeys:n}){const[r,i]=ie(()=>({...t,...n})),a=xe(r);a.current=r;const o=Ce(()=>a.current,[]),s=Ce((l,f)=>{i(c=>({...c,[l]:f}))},[]),u=ve(()=>({update:s,getValues:o}),[s,o]);return y(hr.Provider,{value:u,children:y(rt.Provider,{value:r,children:Oe(e)})})}function yl({body:e,params:t,rawArgs:n}){const r=Ee(rt),[i,a,o]=ur();if(t.length===0||!n)return y(G,{children:Oe(e)});const s=gl(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=or(c,i,a,o)}catch{d=void 0}u[f.startsWith(\"@\")?f.slice(1):f]=d}return y(_l,{body:e,parentValues:r,ownKeys:u})}const ka=new Map;function wa(e,t,n){ka.set(e.toLowerCase(),{body:t,params:n})}function bl(e){return ka.get(e.toLowerCase())}const Sa=new Map;function vl(e,t){Sa.set(e.toLowerCase(),t)}function kl(e){return Sa.get(e.toLowerCase())}const xa=new Set;function wl(e){xa.add(e.toLowerCase())}function Sl(e){return xa.has(e.toLowerCase())}const ai=document.createElement(\"i\");function Ca(e){const t=\"&\"+e+\";\";ai.innerHTML=t;const n=ai.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function fe(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 ee(e,t){return e.length>0?(fe(e,e.length,0,t),e):t}const Vn={}.hasOwnProperty;function xl(e){const t={};let n=-1;for(;++n<e.length;)Cl(t,e[n]);return t}function Cl(e,t){let n;for(n in t){const i=(Vn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){Vn.call(i,o)||(i[o]=[]);const s=a[o];Il(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Il(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);fe(e,0,0,r)}function El(e){const t={};let n=-1;for(;++n<e.length;)Al(t,e[n]);return t}function Al(e,t){let n;for(n in t){const i=(Vn.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 Pl(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 Tl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ia(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Tl[n]+\";\"}}function pt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const _e=Fe(/[A-Za-z]/),ce=Fe(/[\\dA-Za-z]/),Nl=Fe(/[#-'*+\\--9=?A-Z^-~]/);function Bn(e){return e!==null&&(e<32||e===127)}const Hn=Fe(/\\d/),Dl=Fe(/[\\dA-Fa-f]/),$l=Fe(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function M(e){return e===-2||e===-1||e===32}const zl=Fe(/\\p{P}|\\p{S}/u),Fl=Fe(/\\s/);function Fe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Et(e,t){const n=Ia(Ol(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 Ol(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&ce(e.charCodeAt(n+1))&&ce(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 oi={}.hasOwnProperty,si=/^(https?|ircs?|mailto|xmpp)$/i,Rl=/^https?$/i;function Ml(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=El([{enter:{blockQuote:R,codeFenced:he,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:j,codeText:uo,content:Za,definition:ja,definitionDestinationString:Qa,definitionLabelString:I,definitionTitleString:I,emphasis:so,htmlFlow:oo,htmlText:_r,image:H,label:I,link:ne,listItemMarker:P,listItemValue:_,listOrdered:z,listUnordered:L,paragraph:K,reference:I,resource:qe,resourceDestinationString:je,resourceTitleString:I,setextHeading:Xa,strong:lo},exit:{atxHeading:to,atxHeadingSequence:Ja,autolinkEmail:_o,autolinkProtocol:go,blockQuote:Y,characterEscapeValue:at,characterReferenceMarkerHexadecimal:yr,characterReferenceMarkerNumeric:yr,characterReferenceValue:mo,codeFenced:p,codeFencedFence:A,codeFencedFenceInfo:m,codeFencedFenceMeta:F,codeFlowValue:ao,codeIndented:p,codeText:co,codeTextData:at,data:at,definition:Ya,definitionDestinationString:Ga,definitionLabelString:Wa,definitionTitleString:Ka,emphasis:fo,hardBreakEscape:mr,hardBreakTrailing:mr,htmlFlow:gr,htmlFlowData:at,htmlText:gr,htmlTextData:at,image:pr,label:it,labelText:J,lineEnding:io,link:pr,listOrdered:T,listUnordered:U,paragraph:le,reference:F,referenceString:Ae,resource:F,resourceDestinationString:un,resourceTitleString:qa,setextHeading:ro,setextHeadingLineSequence:no,setextHeadingText:eo,strong:ho,thematicBreak:po}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},f={buffer:I,encode:v,getData:S,lineEndingIfNeeded:E,options:t,raw:w,resume:b,setData:g,tag:k};let c=t.defaultLineEnding;return d;function d(x){let D=-1,X=0;const de=[];let me=[],ke=[];for(;++D<x.length;)!c&&(x[D][1].type===\"lineEnding\"||x[D][1].type===\"lineEndingBlank\")&&(c=x[D][2].sliceSerialize(x[D][1])),(x[D][1].type===\"listOrdered\"||x[D][1].type===\"listUnordered\")&&(x[D][0]===\"enter\"?de.push(D):h(x.slice(de.pop(),D))),x[D][1].type===\"definition\"&&(x[D][0]===\"enter\"?(ke=ee(ke,x.slice(X,D)),X=D):(me=ee(me,x.slice(X,D+1)),X=D+1));me=ee(me,ke),me=ee(me,x.slice(X)),D=-1;const ge=me;for(u.enter.null&&u.enter.null.call(f);++D<x.length;){const br=u[ge[D][0]],vr=ge[D][1].type,kr=br[vr];oi.call(br,vr)&&kr&&kr.call({sliceSerialize:ge[D][2].sliceSerialize,...f},ge[D][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(x){const D=x.length;let X=0,de=0,me=!1,ke;for(;++X<D;){const ge=x[X];if(ge[1]._container)ke=void 0,ge[0]===\"enter\"?de++:de--;else switch(ge[1].type){case\"listItemPrefix\":{ge[0]===\"exit\"&&(ke=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{ge[0]===\"enter\"&&!de&&(ke?ke=void 0:me=!0);break}default:ke=void 0}}x[0][1]._loose=me}function g(x,D){l[x]=D}function S(x){return l[x]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function k(x){n&&(g(\"lastWasTag\",!0),i[i.length-1].push(x))}function w(x){g(\"lastWasTag\"),i[i.length-1].push(x)}function N(){w(c||`\n`)}function E(){const x=i[i.length-1],D=x[x.length-1],X=D?D.charCodeAt(D.length-1):null;X===10||X===13||X===null||N()}function v(x){return S(\"ignoreEncode\")?x:Ia(x)}function F(){b()}function z(x){o.push(!x._loose),E(),k(\"<ol\"),g(\"expectFirstItem\",!0)}function L(x){o.push(!x._loose),E(),k(\"<ul\"),g(\"expectFirstItem\",!0)}function _(x){if(S(\"expectFirstItem\")){const D=Number.parseInt(this.sliceSerialize(x),10);D!==1&&k(' start=\"'+v(String(D))+'\"')}}function P(){S(\"expectFirstItem\")?k(\">\"):q(),E(),k(\"<li>\"),g(\"expectFirstItem\"),g(\"lastWasTag\")}function T(){q(),o.pop(),N(),k(\"</ol>\")}function U(){q(),o.pop(),N(),k(\"</ul>\")}function q(){S(\"lastWasTag\")&&!S(\"slurpAllLineEndings\")&&E(),k(\"</li>\"),g(\"slurpAllLineEndings\")}function R(){o.push(!1),E(),k(\"<blockquote>\")}function Y(){o.pop(),E(),k(\"</blockquote>\"),g(\"slurpAllLineEndings\")}function K(){o[o.length-1]||(E(),k(\"<p>\")),g(\"slurpAllLineEndings\")}function le(){o[o.length-1]?g(\"slurpAllLineEndings\",!0):k(\"</p>\")}function he(){E(),k(\"<pre><code\"),g(\"fencesCount\",0)}function m(){const x=b();k(' class=\"language-'+x+'\"')}function A(){const x=S(\"fencesCount\")||0;x||(k(\">\"),g(\"slurpOneLineEnding\",!0)),g(\"fencesCount\",x+1)}function j(){E(),k(\"<pre><code>\")}function p(){const x=S(\"fencesCount\");x!==void 0&&x<2&&l.tightStack.length>0&&!S(\"lastWasTag\")&&N(),S(\"flowCodeSeenData\")&&E(),k(\"</code></pre>\"),x!==void 0&&x<2&&E(),g(\"flowCodeSeenData\"),g(\"fencesCount\"),g(\"slurpOneLineEnding\")}function H(){a.push({image:!0}),n=void 0}function ne(){a.push({})}function J(x){a[a.length-1].labelId=this.sliceSerialize(x)}function it(){a[a.length-1].label=b()}function Ae(x){a[a.length-1].referenceId=this.sliceSerialize(x)}function qe(){I(),a[a.length-1].destination=\"\"}function je(){I(),g(\"ignoreEncode\",!0)}function un(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function qa(){a[a.length-1].title=b()}function pr(){let x=a.length-1;const D=a[x],X=D.referenceId||D.labelId,de=D.destination===void 0?r[pt(X)]:D;for(n=!0;x--;)if(a[x].image){n=void 0;break}D.image?(k('<img src=\"'+Et(de.destination,t.allowDangerousProtocol?void 0:Rl)+'\" alt=\"'),w(D.label),k('\"')):k('<a href=\"'+Et(de.destination,t.allowDangerousProtocol?void 0:si)+'\"'),k(de.title?' title=\"'+de.title+'\"':\"\"),D.image?k(\" />\"):(k(\">\"),w(D.label),k(\"</a>\")),a.pop()}function ja(){I(),a.push({})}function Wa(x){b(),a[a.length-1].labelId=this.sliceSerialize(x)}function Qa(){I(),g(\"ignoreEncode\",!0)}function Ga(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function Ka(){a[a.length-1].title=b()}function Ya(){const x=a[a.length-1],D=pt(x.labelId);b(),oi.call(r,D)||(r[D]=a[a.length-1]),a.pop()}function Za(){g(\"slurpAllLineEndings\",!0)}function Ja(x){S(\"headingRank\")||(g(\"headingRank\",this.sliceSerialize(x).length),E(),k(\"<h\"+S(\"headingRank\")+\">\"))}function Xa(){I(),g(\"slurpAllLineEndings\")}function eo(){g(\"slurpAllLineEndings\",!0)}function to(){k(\"</h\"+S(\"headingRank\")+\">\"),g(\"headingRank\")}function no(x){g(\"headingRank\",this.sliceSerialize(x).charCodeAt(0)===61?1:2)}function ro(){const x=b();E(),k(\"<h\"+S(\"headingRank\")+\">\"),w(x),k(\"</h\"+S(\"headingRank\")+\">\"),g(\"slurpAllLineEndings\"),g(\"headingRank\")}function at(x){w(v(this.sliceSerialize(x)))}function io(x){if(!S(\"slurpAllLineEndings\")){if(S(\"slurpOneLineEnding\")){g(\"slurpOneLineEnding\");return}if(S(\"inCodeText\")){w(\" \");return}w(v(this.sliceSerialize(x)))}}function ao(x){w(v(this.sliceSerialize(x))),g(\"flowCodeSeenData\",!0)}function mr(){k(\"<br />\")}function oo(){E(),_r()}function gr(){g(\"ignoreEncode\")}function _r(){t.allowDangerousHtml&&g(\"ignoreEncode\",!0)}function so(){k(\"<em>\")}function lo(){k(\"<strong>\")}function uo(){g(\"inCodeText\",!0),k(\"<code>\")}function co(){g(\"inCodeText\"),k(\"</code>\")}function fo(){k(\"</em>\")}function ho(){k(\"</strong>\")}function po(){E(),k(\"<hr />\")}function yr(x){g(\"characterReferenceType\",x.type)}function mo(x){const D=this.sliceSerialize(x),X=S(\"characterReferenceType\")?Pl(D,S(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ca(D);w(v(X)),g(\"characterReferenceType\")}function go(x){const D=this.sliceSerialize(x);k('<a href=\"'+Et(D,t.allowDangerousProtocol?void 0:si)+'\">'),w(v(D)),k(\"</a>\")}function _o(x){const D=this.sliceSerialize(x);k('<a href=\"'+Et(\"mailto:\"+D)+'\">'),w(v(D)),k(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return M(u)?(e.enter(n),s(u)):t(u)}function s(u){return M(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Ll={tokenize:Vl};function Vl(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 $(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Bl={tokenize:Hl},li={tokenize:Ul};function Hl(e){const t=this,n=[];let r=0,i,a,o;return s;function s(w){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,u,l)(w)}return l(w)}function u(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const N=t.events.length;let E=N,v;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){v=t.events[E][1].end;break}b(r);let F=N;for(;F<t.events.length;)t.events[F][1].end={...v},F++;return fe(t.events,E+1,0,t.events.slice(N)),t.events.length=F,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(li,f,c)(w)}function f(w){return i&&k(),b(r),d(w)}function c(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function d(w){return t.containerState={},e.attempt(li,h,g)(w)}function h(w){return r++,n.push([t.currentConstruct,t.containerState]),d(w)}function g(w){if(w===null){i&&k(),b(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),S(w)}function S(w){if(w===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(w);return}return $(w)?(e.consume(w),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(w),S)}function I(w,N){const E=t.sliceStream(w);if(N&&E.push(null),w.previous=a,a&&(a.next=w),a=w,i.defineSkip(w.start),i.write(E),t.parser.lazy[w.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;const F=t.events.length;let z=F,L,_;for(;z--;)if(t.events[z][0]===\"exit\"&&t.events[z][1].type===\"chunkFlow\"){if(L){_=t.events[z][1].end;break}L=!0}for(b(r),v=F;v<t.events.length;)t.events[v][1].end={..._},v++;fe(t.events,z+1,0,t.events.slice(F)),t.events.length=v}}function b(w){let N=n.length;for(;N-- >w;){const E=n[N];t.containerState=E[1],E[0].exit.call(t,e)}n.length=w}function k(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ul(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 Qt(e){if(e===null||te(e)||Fl(e))return 1;if(zl(e))return 2}function sn(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 Un={name:\"attention\",resolveAll:ql,tokenize:jl};function ql(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};ui(c,-u),ui(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=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ee(l,sn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(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=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,fe(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 jl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Qt(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=Qt(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 ui(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Wl={name:\"autolink\",tokenize:Ql};function Ql(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 _e(h)?(e.consume(h),o):h===64?n(h):l(h)}function o(h){return h===43||h===45||h===46||ce(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||ce(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||Bn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):Nl(h)?(e.consume(h),l):n(h)}function f(h){return ce(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||ce(h))&&r++<63){const g=h===45?d:c;return e.consume(h),g}return n(h)}}const ln={partial:!0,tokenize:Gl};function Gl(e,t,n){return r;function r(a){return M(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||$(a)?t(a):n(a)}}const Ea={continuation:{tokenize:Yl},exit:Zl,name:\"blockQuote\",tokenize:Kl};function Kl(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 M(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function Yl(e,t,n){const r=this;return i;function i(o){return M(o)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Ea,t,n)(o)}}function Zl(e){e.exit(\"blockQuote\")}const Aa={name:\"characterEscape\",tokenize:Jl};function Jl(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 $l(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Pa={name:\"characterReference\",tokenize:Xl};function Xl(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=ce,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=Dl,f):(e.enter(\"characterReferenceValue\"),a=7,o=Hn,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===ce&&!Ca(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 ci={partial:!0,tokenize:tu},fi={concrete:!0,name:\"codeFenced\",tokenize:eu};function eu(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,o=0,s;return u;function u(v){return l(v)}function l(v){const F=r.events[r.events.length-1];return a=F&&F[1].type===\"linePrefix\"?F[2].sliceSerialize(F[1],!0).length:0,s=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(v)}function f(v){return v===s?(o++,e.consume(v),f):o<3?n(v):(e.exit(\"codeFencedFenceSequence\"),M(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||$(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(ci,S,N)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||$(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):M(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,h,\"whitespace\")(v)):v===96&&v===s?n(v):(e.consume(v),d)}function h(v){return v===null||$(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),g(v))}function g(v){return v===null||$(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===s?n(v):(e.consume(v),g)}function S(v){return e.attempt(i,N,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return a>0&&M(v)?B(e,k,\"linePrefix\",a+1)(v):k(v)}function k(v){return v===null||$(v)?e.check(ci,S,N)(v):(e.enter(\"codeFlowValue\"),w(v))}function w(v){return v===null||$(v)?(e.exit(\"codeFlowValue\"),k(v)):(e.consume(v),w)}function N(v){return e.exit(\"codeFenced\"),t(v)}function E(v,F,z){let L=0;return _;function _(R){return v.enter(\"lineEnding\"),v.consume(R),v.exit(\"lineEnding\"),P}function P(R){return v.enter(\"codeFencedFence\"),M(R)?B(v,T,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):T(R)}function T(R){return R===s?(v.enter(\"codeFencedFenceSequence\"),U(R)):z(R)}function U(R){return R===s?(L++,v.consume(R),U):L>=o?(v.exit(\"codeFencedFenceSequence\"),M(R)?B(v,q,\"whitespace\")(R):q(R)):z(R)}function q(R){return R===null||$(R)?(v.exit(\"codeFencedFence\"),F(R)):z(R)}}}function tu(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 mn={name:\"codeIndented\",tokenize:ru},nu={partial:!0,tokenize:iu};function ru(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):$(l)?e.attempt(nu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||$(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function iu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):$(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):$(o)?i(o):n(o)}}const au={name:\"codeText\",previous:su,resolve:ou,tokenize:lu};function ou(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 su(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function lu(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)):$(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||$(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 uu{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&&ot(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),ot(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ot(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);ot(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ot(this.left,n.reverse())}}}function ot(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 Ta(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new uu(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,cu(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 fe(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function cu(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,g=0,S=0;const I=[S];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&&(S=d+1,I.push(S),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):I.pop(),d=I.length;d--;){const b=s.slice(I[d],I[d+1]),k=a.pop();u.push([k,k+b.length-1]),e.splice(k,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 fu={resolve:du,tokenize:pu},hu={partial:!0,tokenize:mu};function du(e){return Ta(e),e}function pu(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):$(s)?e.check(hu,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 mu(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||$(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 Na(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||Bn(b)?n(b):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),S(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===62?(e.exit(\"chunkString\"),e.exit(s),d(b)):b===null||b===60||$(b)?n(b):(e.consume(b),b===92?g:h)}function g(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function S(b){return!f&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(b)):f<l&&b===40?(e.consume(b),f++,S):b===41?(e.consume(b),f--,S):b===null||b===32||b===40||Bn(b)?n(b):(e.consume(b),b===92?I:S)}function I(b){return b===40||b===41||b===92?(e.consume(b),S):S(b)}}function Da(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):$(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||$(h)||s++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!M(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function $a(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):$(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||$(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 ct(e,t){let n;return r;function r(i){return $(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):M(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const gu={name:\"definition\",tokenize:yu},_u={partial:!0,tokenize:bu};function yu(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),o(h)}function o(h){return Da.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 te(h)?ct(e,l)(h):l(h)}function l(h){return Na(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(_u,c,c)(h)}function c(h){return M(h)?B(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||$(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function bu(e,t,n){return r;function r(s){return te(s)?ct(e,i)(s):n(s)}function i(s){return $a(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return M(s)?B(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||$(s)?t(s):n(s)}}const vu={name:\"hardBreakEscape\",tokenize:ku};function ku(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return $(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const wu={name:\"headingAtx\",resolve:Su,tokenize:xu};function Su(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\"},fe(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function xu(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||te(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||$(f)?(e.exit(\"atxHeading\"),t(f)):M(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||te(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),l)}}const Cu=[\"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\"],hi=[\"pre\",\"script\",\"style\",\"textarea\"],Iu={concrete:!0,name:\"htmlFlow\",resolveTo:Pu,tokenize:Tu},Eu={partial:!0,tokenize:Du},Au={partial:!0,tokenize:Nu};function Pu(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 Tu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(p){return f(p)}function f(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),a=!0,S):p===63?(e.consume(p),i=3,r.interrupt?t:m):_e(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,h):p===91?(e.consume(p),i=5,s=0,g):_e(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function h(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function g(p){const H=\"CDATA[\";return p===H.charCodeAt(s++)?(e.consume(p),s===H.length?r.interrupt?t:T:g):n(p)}function S(p){return _e(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const H=p===47,ne=o.toLowerCase();return!H&&!a&&hi.includes(ne)?(i=1,r.interrupt?t(p):T(p)):Cu.includes(o.toLowerCase())?(i=6,H?(e.consume(p),b):r.interrupt?t(p):T(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?k(p):w(p))}return p===45||ce(p)?(e.consume(p),o+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:T):n(p)}function k(p){return M(p)?(e.consume(p),k):_(p)}function w(p){return p===47?(e.consume(p),_):p===58||p===95||_e(p)?(e.consume(p),N):M(p)?(e.consume(p),w):_(p)}function N(p){return p===45||p===46||p===58||p===95||ce(p)?(e.consume(p),N):E(p)}function E(p){return p===61?(e.consume(p),v):M(p)?(e.consume(p),E):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,F):M(p)?(e.consume(p),v):z(p)}function F(p){return p===u?(e.consume(p),u=null,L):p===null||$(p)?n(p):(e.consume(p),F)}function z(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),z)}function L(p){return p===47||p===62||M(p)?w(p):n(p)}function _(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||$(p)?T(p):M(p)?(e.consume(p),P):n(p)}function T(p){return p===45&&i===2?(e.consume(p),Y):p===60&&i===1?(e.consume(p),K):p===62&&i===4?(e.consume(p),A):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),he):$(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Eu,j,U)(p)):p===null||$(p)?(e.exit(\"htmlFlowData\"),U(p)):(e.consume(p),T)}function U(p){return e.check(Au,q,j)(p)}function q(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||$(p)?U(p):(e.enter(\"htmlFlowData\"),T(p))}function Y(p){return p===45?(e.consume(p),m):T(p)}function K(p){return p===47?(e.consume(p),o=\"\",le):T(p)}function le(p){if(p===62){const H=o.toLowerCase();return hi.includes(H)?(e.consume(p),A):T(p)}return _e(p)&&o.length<8?(e.consume(p),o+=String.fromCharCode(p),le):T(p)}function he(p){return p===93?(e.consume(p),m):T(p)}function m(p){return p===62?(e.consume(p),A):p===45&&i===2?(e.consume(p),m):T(p)}function A(p){return p===null||$(p)?(e.exit(\"htmlFlowData\"),j(p)):(e.consume(p),A)}function j(p){return e.exit(\"htmlFlow\"),t(p)}}function Nu(e,t,n){const r=this;return i;function i(o){return $(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 Du(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(ln,t,n)}}const $u={name:\"htmlText\",tokenize:zu};function zu(e,t,n){const r=this;let i,a,o;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),E):m===63?(e.consume(m),w):_e(m)?(e.consume(m),z):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,g):_e(m)?(e.consume(m),k):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):$(m)?(o=c,K(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?Y(m):m===45?d(m):c(m)}function g(m){const A=\"CDATA[\";return m===A.charCodeAt(a++)?(e.consume(m),a===A.length?S:g):n(m)}function S(m){return m===null?n(m):m===93?(e.consume(m),I):$(m)?(o=S,K(m)):(e.consume(m),S)}function I(m){return m===93?(e.consume(m),b):S(m)}function b(m){return m===62?Y(m):m===93?(e.consume(m),b):S(m)}function k(m){return m===null||m===62?Y(m):$(m)?(o=k,K(m)):(e.consume(m),k)}function w(m){return m===null?n(m):m===63?(e.consume(m),N):$(m)?(o=w,K(m)):(e.consume(m),w)}function N(m){return m===62?Y(m):w(m)}function E(m){return _e(m)?(e.consume(m),v):n(m)}function v(m){return m===45||ce(m)?(e.consume(m),v):F(m)}function F(m){return $(m)?(o=F,K(m)):M(m)?(e.consume(m),F):Y(m)}function z(m){return m===45||ce(m)?(e.consume(m),z):m===47||m===62||te(m)?L(m):n(m)}function L(m){return m===47?(e.consume(m),Y):m===58||m===95||_e(m)?(e.consume(m),_):$(m)?(o=L,K(m)):M(m)?(e.consume(m),L):Y(m)}function _(m){return m===45||m===46||m===58||m===95||ce(m)?(e.consume(m),_):P(m)}function P(m){return m===61?(e.consume(m),T):$(m)?(o=P,K(m)):M(m)?(e.consume(m),P):L(m)}function T(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,U):$(m)?(o=T,K(m)):M(m)?(e.consume(m),T):(e.consume(m),q)}function U(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):$(m)?(o=U,K(m)):(e.consume(m),U)}function q(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?L(m):(e.consume(m),q)}function R(m){return m===47||m===62||te(m)?L(m):n(m)}function Y(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function K(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),le}function le(m){return M(m)?B(e,he,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):he(m)}function he(m){return e.enter(\"htmlTextData\"),o(m)}}const fr={name:\"labelEnd\",resolveAll:Mu,resolveTo:Lu,tokenize:Vu},Fu={tokenize:Bu},Ou={tokenize:Hu},Ru={tokenize:Uu};function Mu(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&&fe(e,0,e.length,n),e}function Lu(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=ee(s,e.slice(a+1,a+r+3)),s=ee(s,[[\"enter\",f,t]]),s=ee(s,sn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ee(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ee(s,e.slice(o+1)),s=ee(s,[[\"exit\",u,t]]),fe(e,a,e.length,s),e}function Vu(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(Fu,f,o?f:c)(d):d===91?e.attempt(Ou,f,o?l:c)(d):o?f(d):c(d)}function l(d){return e.attempt(Ru,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Bu(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 te(c)?ct(e,a)(c):a(c)}function a(c){return c===41?f(c):Na(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return te(c)?ct(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?$a(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return te(c)?ct(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 Hu(e,t,n){const r=this;return i;function i(s){return Da.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 Uu(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 qu={name:\"labelStartImage\",resolveAll:fr.resolveAll,tokenize:ju};function ju(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 Wu={name:\"labelStartLink\",resolveAll:fr.resolveAll,tokenize:Qu};function Qu(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 gn={name:\"lineEnding\",tokenize:Gu};function Gu(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Ft={name:\"thematicBreak\",tokenize:Ku};function Ku(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||$(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),M(l)?B(e,s,\"whitespace\")(l):s(l))}}const oe={continuation:{tokenize:Xu},exit:tc,name:\"list\",tokenize:Ju},Yu={partial:!0,tokenize:nc},Zu={partial:!0,tokenize:ec};function Ju(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 g=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(g===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:Hn(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(Ft,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 Hn(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(ln,r.interrupt?n:f,e.attempt(Yu,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return M(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 Xu(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ln,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||!M(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(Zu,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(oe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function ec(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 tc(e){e.exit(this.containerState.type)}function nc(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!M(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const di={name:\"setextUnderline\",resolveTo:rc,tokenize:ic};function rc(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 ic(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\"),M(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||$(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const ac={tokenize:oc};function oc(e){const t=this,n=e.attempt(ln,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(fu,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 sc={resolveAll:Fa()},lc=za(\"string\"),uc=za(\"text\");function za(e){return{resolveAll:Fa(e===\"text\"?cc: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 Fa(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 cc(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 fc={42:oe,43:oe,45:oe,48:oe,49:oe,50:oe,51:oe,52:oe,53:oe,54:oe,55:oe,56:oe,57:oe,62:Ea},hc={91:gu},dc={[-2]:mn,[-1]:mn,32:mn},pc={35:wu,42:Ft,45:[di,Ft],60:Iu,61:di,95:Ft,96:fi,126:fi},mc={38:Pa,92:Aa},gc={[-5]:gn,[-4]:gn,[-3]:gn,33:qu,38:Pa,42:Un,60:[Wl,$u],91:Wu,92:[vu,Aa],93:fr,95:Un,96:au},_c={null:[Un,sc]},yc={null:[42,95]},bc={null:[]},vc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:yc,contentInitial:hc,disable:bc,document:fc,flow:pc,flowInitial:dc,insideSpan:_c,string:mc,text:gc},Symbol.toStringTag,{value:\"Module\"}));function kc(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:F(E),check:F(v),consume:k,enter:w,exit:N,interrupt:F(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:S,events:[],now:g,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=ee(o,P),I(),o[o.length-1]!==null?[]:(z(t,0),l.events=sn(a,l.events,l),l.events)}function d(P,T){return Sc(h(P),T)}function h(P){return wc(o,P)}function g(){const{_bufferIndex:P,_index:T,line:U,column:q,offset:R}=r;return{_bufferIndex:P,_index:T,line:U,column:q,offset:R}}function S(P){i[P.line]=P.column,_()}function I(){let P;for(;r._index<o.length;){const T=o[r._index];if(typeof T==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<T.length;)b(T.charCodeAt(r._bufferIndex));else b(T)}}function b(P){f=f(P)}function k(P){$(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,_()):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 w(P,T){const U=T||{};return U.type=P,U.start=g(),l.events.push([\"enter\",U,l]),s.push(U),U}function N(P){const T=s.pop();return T.end=g(),l.events.push([\"exit\",T,l]),T}function E(P,T){z(P,T.from)}function v(P,T){T.restore()}function F(P,T){return U;function U(q,R,Y){let K,le,he,m;return Array.isArray(q)?j(q):\"tokenize\"in q?j([q]):A(q);function A(J){return it;function it(Ae){const qe=Ae!==null&&J[Ae],je=Ae!==null&&J.null,un=[...Array.isArray(qe)?qe:qe?[qe]:[],...Array.isArray(je)?je:je?[je]:[]];return j(un)(Ae)}}function j(J){return K=J,le=0,J.length===0?Y:p(J[le])}function p(J){return it;function it(Ae){return m=L(),he=J,J.partial||(l.currentConstruct=J),J.name&&l.parser.constructs.disable.null.includes(J.name)?ne():J.tokenize.call(T?Object.assign(Object.create(l),T):l,u,H,ne)(Ae)}}function H(J){return P(he,m),R}function ne(J){return m.restore(),++le<K.length?p(K[le]):Y}}}function z(P,T){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&fe(l.events,T,l.events.length-T,P.resolve(l.events.slice(T),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function L(){const P=g(),T=l.previous,U=l.currentConstruct,q=l.events.length,R=Array.from(s);return{from:q,restore:Y};function Y(){r=P,l.previous=T,l.currentConstruct=U,l.events.length=q,s=R,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function wc(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 Sc(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 xc(e){const r={constructs:xl([vc,...(e||{}).extensions||[]]),content:i(Ll),defined:[],document:i(Bl),flow:i(ac),lazy:{},string:i(lc),text:i(uc)};return r;function i(a){return o;function o(s){return kc(r,a,s)}}}function Cc(e){for(;!Ta(e););return e}const pi=/[\\0\\t\\n\\r]/g;function Ic(){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(pi.lastIndex=c,l=pi.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 Ec(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Ml(n)(Cc(xc(n).document().write(Ic()(e,t,!0))))}const _n={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Ac(){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=_n[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=_n[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,Pc)),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\"+_n[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Pc(e,t){return t===\"|\"?t:e}class Tc{constructor(){this.map=[]}add(t,n,r){Nc(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 Nc(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 Dc(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 $c(){return{flow:{null:{name:\"table\",tokenize:zc,resolveAll:Fc}}}}function zc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(_){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 T=P>-1?r.events[P][1].type:null,U=T===\"tableHead\"||T===\"tableRow\"?v:u;return U===v&&r.parser.lazy[r.now().line]?n(_):U(_)}function u(_){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(_)}function l(_){return _===124||(o=!0,a+=1),f(_)}function f(_){return _===null?n(_):$(_)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),h):n(_):M(_)?B(e,f,\"whitespace\")(_):(a+=1,o&&(o=!1,i+=1),_===124?(e.enter(\"tableCellDivider\"),e.consume(_),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(_)))}function c(_){return _===null||_===124||te(_)?(e.exit(\"data\"),f(_)):(e.consume(_),_===92?d:c)}function d(_){return _===92||_===124?(e.consume(_),c):c(_)}function h(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter(\"tableDelimiterRow\"),o=!1,M(_)?B(e,g,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?I(_):_===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(_),e.exit(\"tableCellDivider\"),S):E(_)}function S(_){return M(_)?B(e,I,\"whitespace\")(_):I(_)}function I(_){return _===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(_),e.exit(\"tableDelimiterMarker\"),b):_===45?(a+=1,b(_)):_===null||$(_)?N(_):E(_)}function b(_){return _===45?(e.enter(\"tableDelimiterFiller\"),k(_)):E(_)}function k(_){return _===45?(e.consume(_),k):_===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(_),e.exit(\"tableDelimiterMarker\"),w):(e.exit(\"tableDelimiterFiller\"),w(_))}function w(_){return M(_)?B(e,N,\"whitespace\")(_):N(_)}function N(_){return _===124?g(_):_===null||$(_)?!o||i!==a?E(_):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(_)):E(_)}function E(_){return n(_)}function v(_){return e.enter(\"tableRow\"),F(_)}function F(_){return _===124?(e.enter(\"tableCellDivider\"),e.consume(_),e.exit(\"tableCellDivider\"),F):_===null||$(_)?(e.exit(\"tableRow\"),t(_)):M(_)?B(e,F,\"whitespace\")(_):(e.enter(\"data\"),z(_))}function z(_){return _===null||_===124||te(_)?(e.exit(\"data\"),F(_)):(e.consume(_),_===92?L:z)}function L(_){return _===92||_===124?(e.consume(_),z):z(_)}}function Fc(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 Tc;for(;++n<e.length;){const h=e[n],g=h[1];h[0]===\"enter\"?g.type===\"tableHead\"?(s=!1,u!==0&&(mi(d,t,u,l,f),f=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,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",f,t]])),i=g.type===\"tableDelimiterRow\"?2:f?3:1):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=At(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):g.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=At(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):g.type===\"tableHead\"?(s=!0,u=n):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=At(d,t,a,i,n,c)):o[1]!==0&&(c=At(d,t,o,i,n,c)),i=0):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&mi(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=Dc(t.events,n))}return e}function At(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Qe(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Qe(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=Qe(t.events,n[2]),f=Qe(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 g=n[2]+1,S=n[3]-n[2]-1;e.add(g,S,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Qe(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function mi(e,t,n,r,i){const a=[],o=Qe(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 Qe(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Oc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Rc(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&&fe(d,d.length,0,sn(h,o.slice(l+1,u),s)),fe(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),fe(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(g){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(g):(o.enter(\"strikethroughSequenceTemporary\"),h(g))}function h(g){const S=Qt(l);if(g===126)return c>1?u(g):(o.consume(g),c++,h);if(c<2&&!n)return u(g);const I=o.exit(\"strikethroughSequenceTemporary\"),b=Qt(g);return I._open=!b||b===2&&!!S,I._close=!S||S===2&&!!b,s(g)}}}function Mc(e){return Ec(e,{allowDangerousHtml:!0,extensions:[$c(),Rc()],htmlExtensions:[Ac(),Oc()]})}const Lc={update:()=>{},getValues:()=>({})},rt=bt({}),hr=bt(Lc);function Vc(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Oa(i,a,t));return y(G,{children:r})}function Oa(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)=>Oa(u,l,n));return se(i,o,...s)}return null}function Bc({node:e}){const t=cr(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return se(e.tag,n,e.children.length>0?Oe(e.children):void 0)}function Hc(e,t){if(Sl(e.name))return null;const n=bl(e.name);if(n)return y(yl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=kl(e.name);return r?y(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):y(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function qn(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return y(ml,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Hc(e,t);case\"html\":return y(Bc,{node:e},t);default:return e}}function Uc(e){return e.length===0?null:e.map((t,n)=>qn(t,n))}function qc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function jc(e){const t=C.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 Oe(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,o)=>qn(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\"&&qc(r))r+=jc(o);else{const s=n.length;n.push(qn(o,a)),r+=`<span data-tw=\"${s}\"></span>`}}const i=Mc(r);return Vc(i,n)}const Wc=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Qc(){const t=C(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Wc;try{const r=et(n),i=tt(r);return y(G,{children:Oe(i)})}catch(r){return y(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Gc(){const e=C(n=>n.storyData),t=C(n=>n.currentPassage);return Le(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),C.getState().save()):r.key===\"F9\"&&(r.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?y(\"div\",{class:\"loading\",children:\"Loading...\"}):y(Qc,{})}function Kc(){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),g=d.getAttribute(\"name\")||\"\",S=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(N=>N.length>0),I=d.textContent||\"\",b={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const N of d.attributes)k.has(N.name)||(b[N.name]=N.value);const w={pid:h,name:g,tags:S,metadata:b,content:I};f.set(g,w),c.set(h,w)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:l}}const st=new Map;let re={},gi=!1;function Ra(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Yc(){localStorage.setItem(Ra(),JSON.stringify(re))}function yn(){if(!gi){gi=!0;try{const e=localStorage.getItem(Ra());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(re={...re,...t})}}catch{}}}const mt={addToggle(e,t){st.set(e,{type:\"toggle\",config:t}),e in re||(re[e]=t.default),yn()},addList(e,t){st.set(e,{type:\"list\",config:t}),e in re||(re[e]=t.default),yn()},addRange(e,t){st.set(e,{type:\"range\",config:t}),e in re||(re[e]=t.default),yn()},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,Yc()},getAll(){return{...re}},getDefinitions(){return st},hasAny(){return st.size>0}};function jn(e,t,n){const r=C.getState(),i=Z(r.variables),a=Z(r.temporary),o={...t};Fn(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 Gt=new Map,Wn=new Set,Qn=new Map;function Zc(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Qn.get(r)??0)+1;return Qn.set(r,i),i===1?r:`${r}:${i}`}function Jc(e){return Gt.set(e.id,e),yi(),()=>{Gt.delete(e.id),yi()}}function _i(){return Array.from(Gt.values())}function Xc(e){return Gt.get(e)}function ef(){Qn.clear()}function tf(e){return Wn.add(e),()=>{Wn.delete(e)}}function yi(){for(const e of Wn)e()}function nf(e){const t=xe(\"\");t.current||(t.current=Zc(e.type,e.key,e.authorId));const n=t.current;return He(()=>{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),Jc(r)}),n}function Ma(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function La(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function gt(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?La(t):\"\"}function rf(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 af(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 of(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const sf={useState:ie,useRef:xe,useEffect:Le,useLayoutEffect:He,useCallback:Ce,useMemo:ve,useContext:Ee};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=cr(),r=a(r),i=a(i));const{update:o,getValues:s}=Ee(hr),u={collectText:Ma,sourceLocation:gt,parseVarArgs:rf,extractOptions:af,h:se,renderNodes:Oe,renderInlineNodes:Uc,hooks:sf,useAction:nf,className:r,id:i,resolve:a,cls:of(e.name,r),mutate:l=>jn(l,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){u.merged=ur();const l=u.merged;u.evaluate=f=>or(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=C(d=>d.variables[f]);const c=C(d=>d.setVariable);u.setValue=d=>c(f,d)}return u.wrap=l=>u.className||u.id?se(\"span\",{id:u.id,class:u.className},l):se(G,null,l),e.render(n,u)}if(vl(e.name,t),e.subMacros)for(const n of e.subMacros)wl(n)}function lf(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e){C.getState().save(e)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},visited(e){return C.getState().visitCounts[e]??0},hasVisited(e){return(C.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return C.getState().renderCounts[e]??0},hasRendered(e){return(C.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.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 C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:mt,registerClass(e,t){Ys(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){Js(e)}},getActions(){return _i()},performAction(e,t){const n=Xc(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=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return tf(t);if(e===\"variableChanged\"){let n={...C.getState().variables};return C.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(_i())})})})},random(){return ir()},randomInt(e,t){return ua(e,t)},prng:{init(e,t){Fs(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=zt())})},isEnabled(){return Os()},get seed(){return Rs()},get pull(){return Ms()}}}}function uf(){window.Story=lf()}const cf=/^\\$(\\w+)\\s*=\\s*(.+)$/,bi=/\\$(\\w+(?:\\.\\w+)*)/g,vi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,ff=new Set([\"number\",\"string\",\"boolean\"]);function Va(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,Va(i));return{type:\"object\",fields:n}}const t=typeof e;if(!ff.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function hf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(cf);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=Va(s);t.set(a,{...u,name:a,default:s})}return t}function df(e){const t=new Set;let n;for(vi.lastIndex=0;(n=vi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function pf(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 mf(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=df(i.content);let o;for(bi.lastIndex=0;(o=bi.exec(i.content))!==null;){const s=o[1],u=pf(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function gf(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 Ne({macro:e,error:t}){return y(\"span\",{class:\"error\",title:String(t),children:`{${e} error${gt()}: ${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 y(Ne,{macro:\"print\",error:n})}}});function _f(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 yf(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,a,o){const s=C.getState();let u;try{u=or(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${gt()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];yf(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}=_f(e))}catch(f){return y(Ne,{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=C.getState();ki(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{ki(o,u,s,n,r,i,e)},[n,r,i]),null}});function bf(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 kf(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}=bf(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=kf(a,o,i),l=t.cls;return y(\"div\",{class:l,id:t.id,children:[y(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&y(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return y(Ne,{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?y(\"span\",{id:o,class:a,children:i}):y(G,{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 y(Ne,{macro:\"if\",error:i})}}return null}});function wf(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 Sf({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=ie(()=>({...e,...t,...n})),o=xe(i);o.current=i;const s=Ce(()=>o.current,[]),u=Ce((f,c)=>{a(d=>({...d,[f]:c}))},[]),l=ve(()=>({update:u,getValues:s}),[u,s]);return y(hr.Provider,{value:l,children:y(rt.Provider,{value:i,children:Oe(r)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=Ee(rt);let i;try{i=wf(e)}catch(f){return y(Ne,{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 y(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=f}catch(f){return y(Ne,{macro:\"for\",error:f})}const l=u.map((f,c)=>{const d={[a]:f,...o?{[o]:c}:void 0};return y(Sf,{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}),y(\"button\",{id:n.id,class:n.cls,onClick:r,children:n.renderInlineNodes(t)})}});function xf(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 wi(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")try{jn(r.rawArgs,t,n)}catch(i){console.error(`spindle: Error in {link} child {set}${gt()}:`,i)}else if(r.name===\"do\"){const i=Ma(r.children);try{jn(i,t,n)}catch(a){console.error(`spindle: Error in {link} child {do}${gt()}:`,a)}}}}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=xf(e),a=o=>{o.preventDefault(),wi(t,n.getValues(),n.update),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{wi(t,n.getValues(),n.update),i&&C.getState().navigate(i)}}),y(\"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 y(Ne,{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 y(G,{children:n.renderNodes(o.children)})}catch(s){return y(Ne,{macro:\"case\",error:s})}}return i?y(G,{children:n.renderNodes(i.children)}):null}});function dr(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(d=>({delay:d.rawArgs?dr(d.rawArgs):0,nodes:d.children,className:d.className,id:d.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const d=o+1,h=a[d].delay,g=setTimeout(()=>{s(d)},h);return()=>clearTimeout(g)},[o,a]),o<0)return null;const u=a[o],l=t.renderNodes(u.nodes),f=t.resolve(u.className),c=t.resolve(u.id);return f||c?y(\"span\",{id:c,class:f,children:l}):y(G,{children:l})}});const Ba=bt({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 w=N=>{if(!N||!ba(N))return N;const E=C.getState();return va(N,E.variables,E.temporary,{})};return[w(n),w(r)]},[n,r]),c=dr(e),[d,h]=a(0),[g,S]=a(!1),I=s(()=>S(!0),[]);if(o(()=>{if(g)return;const w=setInterval(()=>{h(N=>N+1)},c);return()=>clearInterval(w)},[c,g]),d===0&&!g)return null;const b=l?`macro-repeat ${l}`:void 0,k=y(Ba.Provider,{value:{stop:I},children:y(\"span\",{children:i.renderNodes(t)},d)});return b||f?y(\"span\",{id:f,class:b,children:k}):k}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Ba);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=dr(e),s=a(null),[u,l]=r(0),[f,c]=r(0);i(()=>{if(s.current){const g=s.current.textContent||\"\";l(g.length)}},[]),i(()=>{if(u===0||f>=u)return;const g=setInterval(()=>{c(S=>S>=u?(clearInterval(g),S):S+1)},o);return()=>clearInterval(g)},[u,o]);const d=f>=u&&u>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return y(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!d,void 0)},children:[y(\"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&&y(\"span\",{class:\"macro-type-cursor\"})]})}});function Cf(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}=Cf(e);return n.hooks.useLayoutEffect(()=>{wa(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return y(\"span\",{id:t.id,class:r,children:n})}});const Ha=bt(null);function Ua({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=C(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=ve(()=>{if(!o)return y(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=et(o),c=tt(f);return Oe(c)}catch(f){return y(\"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 y(Ha.Provider,{value:r,children:y(\"div\",{class:\"dialog-overlay\",onClick:u,children:y(\"div\",{class:l,children:[y(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),y(\"div\",{class:\"dialog-body\",children:s})]})})})}function Ue(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=e.dialog?ie(!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}),y(G,{children:[y(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&y(Ua,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}Ue({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});Ue({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});Ue({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});Ue({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=C(n=>n.load),t=C(n=>n.hasSave);return C(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});Ue({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});Ue({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});Ue({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!mt.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 y(G,{children:[y(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:o}),r&&y(Ua,{passageName:a,onClose:()=>i(!1)})]})}});function If(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 Ef(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 Af(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Pf(){const[e,t]=ie(\"load\"),[n,r]=ie([]),[i,a]=ie(!0),[o,s]=ie(null),[u,l]=ie(()=>new Set),[f,c]=ie(null),[d,h]=ie(\"\"),g=xe(null),S=xe(null),I=Ee(Ha),b=C(A=>A.storyData),k=C(A=>A.playthroughId),w=C(A=>A.getSavePayload),N=C(A=>A.loadFromPayload),E=b?.ifid??\"\",v=Ce(async()=>{if(!E)return;const A=await ol(E);r(A),a(!1)},[E]);Le(()=>{v()},[v]),Le(()=>{f&&g.current&&(g.current.focus(),g.current.select())},[f]);const F=xe(),z=(A,j=\"success\")=>{clearTimeout(F.current),s({text:A,type:j}),F.current=window.setTimeout(()=>s(null),3e3)},L=A=>{l(j=>{const p=new Set(j);return p.has(A)?p.delete(A):p.add(A),p})},_=async()=>{if(!(!E||!k))try{const A=w();await ma(E,k,A),z(\"Save created\"),await v()}catch{z(\"Failed to create save\",\"error\")}},P=async A=>{try{const j=w();await ga(A,j),z(\"Save overwritten\"),await v()}catch{z(\"Failed to overwrite save\",\"error\")}},T=async A=>{try{N(A.payload),z(\"Game loaded\"),I&&setTimeout(I,500)}catch{z(\"Failed to load save\",\"error\")}},U=async A=>{if(confirm(\"Delete this save?\"))try{await il(A),z(\"Save deleted\"),await v()}catch{z(\"Failed to delete save\",\"error\")}},q=A=>{c(A.meta.id),h(A.meta.title)},R=async()=>{if(!(!f||!d.trim()))try{await al(f,d.trim()),c(null),z(\"Save renamed\"),await v()}catch{z(\"Failed to rename\",\"error\")}},Y=A=>{A.key===\"Enter\"?R():A.key===\"Escape\"&&c(null)},K=async A=>{try{const j=await ul(A);if(!j)return;const p=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),H=URL.createObjectURL(p),ne=document.createElement(\"a\");ne.href=H,ne.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ne.click(),URL.revokeObjectURL(H),z(\"Save exported\")}catch{z(\"Failed to export save\",\"error\")}},le=()=>{S.current?.click()},he=async A=>{const j=A.target,p=j.files?.[0];if(p){j.value=\"\";try{const H=await p.text(),ne=JSON.parse(H);if(!If(ne))throw new Error(\"Invalid save file format\");await cl(ne,E),z(\"Save imported\"),await v()}catch(H){z(H instanceof Error?H.message:\"Failed to import save\",\"error\")}}},m=n.reduce((A,j)=>A+j.saves.length,0);return y(\"div\",{class:\"save-manager\",children:[y(\"div\",{class:\"saves-header\",children:y(\"div\",{class:\"saves-header-left\",children:y(\"div\",{class:\"saves-mode-toggle\",children:[y(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),y(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),y(\"div\",{class:\"saves-toolbar\",children:[y(\"button\",{class:\"saves-toolbar-button\",onClick:le,children:\"Import\"}),y(\"input\",{ref:S,type:\"file\",accept:\".json\",style:\"display:none\",onChange:he})]}),y(\"div\",{class:\"saves-body\",children:[i?y(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?y(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(A=>{const j=u.has(A.playthrough.id),p=A.playthrough.id===k;return e===\"save\"&&!p||e===\"load\"&&A.saves.length===0&&!p?null:y(\"div\",{class:\"playthrough-group\",children:[y(\"div\",{class:\"playthrough-header\",onClick:()=>L(A.playthrough.id),children:[y(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),y(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,p?\" (current)\":\"\"]}),y(\"span\",{class:\"playthrough-date\",children:Af(A.playthrough.createdAt)})]}),!j&&y(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(H=>y(\"div\",{class:\"save-slot\",children:[y(\"div\",{class:\"save-slot-info\",children:[f===H.meta.id?y(\"input\",{ref:g,class:\"save-rename-input\",value:d,onInput:ne=>h(ne.target.value),onKeyDown:Y,onBlur:R}):y(\"div\",{class:\"save-slot-title\",children:H.meta.title}),y(\"div\",{class:\"save-slot-meta\",children:[y(\"span\",{children:H.meta.passage}),y(\"span\",{children:Ef(H.meta.updatedAt)})]})]}),y(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?y(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(H.meta.id),children:\"Save Here\"}):y(\"button\",{class:\"save-slot-action primary\",onClick:()=>T(H),children:\"Load\"}),y(\"button\",{class:\"save-slot-action\",onClick:()=>q(H),children:\"Rename\"}),y(\"button\",{class:\"save-slot-action\",onClick:()=>K(H.meta.id),children:\"Export\"}),y(\"button\",{class:\"save-slot-action danger\",onClick:()=>U(H.meta.id),children:\"Delete\"})]})]},H.meta.id)),e===\"save\"&&p&&y(\"button\",{class:\"save-slot-new\",onClick:_,children:\"+ New Save\"})]})]},A.playthrough.id)}),e===\"save\"&&!i&&!n.some(A=>A.playthrough.id===k)&&y(\"div\",{class:\"playthrough-group\",children:y(\"div\",{class:\"playthrough-saves\",children:y(\"button\",{class:\"save-slot-new\",onClick:_,children:\"+ New Save\"})})})]}),o&&y(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return y(Pf,{})}});function Tf({name:e,def:t}){const[n,r]=ie(()=>mt.get(e)),i=a=>{r(a),mt.set(e,a)};switch(t.type){case\"toggle\":return y(\"label\",{class:\"settings-row\",children:[y(\"span\",{children:t.config.label}),y(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return y(\"label\",{class:\"settings-row\",children:[y(\"span\",{children:t.config.label}),y(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>y(\"option\",{value:a,children:a},a))})]});case\"range\":return y(\"label\",{class:\"settings-row\",children:[y(\"span\",{children:[t.config.label,\": \",String(n)]}),y(\"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 Nf(){const e=mt.getDefinitions();return y(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>y(Tf,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return y(Nf,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(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&&C.getState().trackRender(r),!i)return y(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${r}\" not found}`});const a=et(i.content),o=tt(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,\"\")}C.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=C.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):\"\")}),y(\"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)}),y(\"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):\"\")}),y(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Df(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}=Df(e),i=n.startsWith(\"$\")?n.slice(1):n,a=C(s=>s.variables[i]),o=C(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)}),y(\"label\",{id:t.id,class:t.cls,children:[y(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>o(i,!a)}),r?` ${r}`:null]})}});function $f(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}=$f(e),a=n.startsWith(\"$\")?n.slice(1):n,o=C(u=>u.variables[a]),s=C(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)}),y(\"label\",{id:t.id,class:t.cls,children:[y(\"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))}}),y(\"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=>y(\"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()}}),y(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});function zf({passage:e}){const t=ve(()=>{try{const n=et(e.content),r=tt(n);return Oe(r)}catch(n){return y(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",La(e),\": \",n.message]})}},[e.content,e.name]);return y(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(a=>a.currentPassage),i=C(a=>a.storyData)?.passages.get(n);return i?y(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:y(zf,{passage:i},n)}):y(\"div\",{class:\"error\",children:[\"Error: Passage “\",n,\"” not found.\"]})}});function Si(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 xi(){const e=Kc();if(uf(),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&&Si(l,[u]),new Error(`spindle: ${u}`)}const r=hf(n.content),i=mf(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&Si(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=gf(r),C.getState().init(e,t),ya();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=et(u.content),f=tt(l);for(const c of f)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),h=d[0].replace(/[\"']/g,\"\"),g=d.slice(1).filter(S=>S.startsWith(\"$\")||S.startsWith(\"_\")||S.startsWith(\"@\"));wa(h,c.children,g)}}let a=\"\";C.subscribe(u=>{u.currentPassage!==a&&(a=u.currentPassage,ef())});const o=e.passages.get(\"StoryInterface\");o&&!o.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.');Ke(y(Gc,{}),s),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",xi):xi();</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"})
|