@rohal12/spindle 0.42.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +1 -1
- package/src/components/macros/Computed.tsx +13 -5
- package/src/components/macros/ExprDisplay.tsx +8 -1
- package/src/components/macros/For.tsx +32 -23
- package/src/components/macros/Unset.tsx +3 -1
- package/src/components/macros/VarDisplay.tsx +4 -2
- package/src/components/macros/WidgetInvocation.tsx +28 -8
- package/src/define-macro.ts +11 -1
- package/src/execute-mutation.ts +12 -1
- package/src/expression.ts +14 -7
- package/src/hooks/use-interpolate.ts +3 -3
- package/src/hooks/use-merged-locals.ts +6 -4
- package/src/index.tsx +22 -1
- package/src/interpolation.ts +18 -7
- package/src/markup/ast.ts +1 -1
- package/src/markup/render.tsx +1 -0
- package/src/markup/tokenizer.ts +86 -1
- package/src/store.ts +26 -1
- package/src/story-api.ts +32 -4
- package/src/story-variables.ts +22 -9
- package/src/triggers.ts +7 -1
- package/types/index.d.ts +12 -3
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.42.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 Xt,F,va,Xe,ui,wa,Sa,ka,Rr,ir,ar,xa,Sn={},kn=[],ms=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function Mr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Y(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?Xt.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 Lt(e,o,r,i,null)}function Lt(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??++va,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function ys(){return{current:null}}function G(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function vt(e,t){if(t==null)return e.__?vt(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\"?vt(e):null}function _s(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Te({},t);a.__v=t.__v+1,F.vnode&&F.vnode(a),zr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??vt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Ea(r,a,i),t.__e=t.__=null,a.__e!=n&&Ca(a)}}function Ca(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}),Ca(e)}function or(e){(!e.__d&&(e.__d=!0)&&Xe.push(e)&&!xn.__r++||ui!=F.debounceRendering)&&((ui=F.debounceRendering)||wa)(xn)}function xn(){for(var e,t=1;Xe.length;)Xe.length>t&&Xe.sort(Sa),e=Xe.shift(),t=Xe.length,_s(e);xn.__r=0}function Ia(e,t,n,r,i,a,o,s,l,u,f){var c,p,d,h,y,k,_,S=r&&r.__k||kn,x=t.length;for(l=bs(n,t,S,l,x),c=0;c<x;c++)(d=n.__k[c])!=null&&(p=d.__i!=-1&&S[d.__i]||Sn,d.__i=c,k=zr(e,d,p,i,a,o,s,l,u,f),h=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&Fr(p.ref,null,d),f.push(d.ref,d.__c||h,d)),y==null&&h!=null&&(y=h),(_=!!(4&d.__u))||p.__k===d.__k?l=Pa(d,l,e,_):typeof d.type==\"function\"&&k!==void 0?l=k:h&&(l=h.nextSibling),d.__u&=-7);return n.__e=y,l}function bs(e,t,n,r,i){var a,o,s,l,u,f=n.length,c=f,p=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]=Lt(null,o,null,null,null):Zt(o)?o=e.__k[a]=Lt(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Lt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+p,o.__=e,o.__b=e.__b+1,s=null,(u=o.__i=vs(o,n,l,c))!=-1&&(c--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>f?p--:i<f&&p++),typeof o.type!=\"function\"&&(o.__u|=4)):u!=l&&(u==l-1?p--:u==l+1?p++:(u>l?p--:p++,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=vt(s)),$a(s,s));return r}function Pa(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=Pa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=vt(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ve(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Zt(e)?e.some(function(n){Ve(n,t)}):t.push(e)),t}function vs(e,t,n,r){var i,a,o,s=e.key,l=e.type,u=t[n],f=u!=null&&(2&u.__u)==0;if(u===null&&s==null||f&&s==u.key&&l==u.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((u=t[o=i>=0?i--:a++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return o}return-1}function ci(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ms.test(t)?n:n+\"px\"}function un(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||ci(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||ci(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(ka,\"$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=Rr,e.addEventListener(t,a?ar:ir,a)):e.removeEventListener(t,a?ar:ir,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 fi(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Rr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function zr(e,t,n,r,i,a,o,s,l,u){var f,c,p,d,h,y,k,_,S,x,E,I,b,$,A,D=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=F.__b)&&f(t);e:if(typeof D==\"function\")try{if(_=t.props,S=\"prototype\"in D&&D.prototype.render,x=(f=D.contextType)&&r[f.__c],E=f?x?x.props.value:f.__:r,n.__c?k=(c=t.__c=n.__c).__=c.__E:(S?t.__c=c=new D(_,E):(t.__c=c=new Ne(_,E),c.constructor=D,c.render=Ss),x&&x.sub(c),c.state||(c.state={}),c.__n=r,p=c.__d=!0,c.__h=[],c._sb=[]),S&&c.__s==null&&(c.__s=c.state),S&&D.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Te({},c.__s)),Te(c.__s,D.getDerivedStateFromProps(_,c.__s))),d=c.props,h=c.state,c.__v=t,p)S&&D.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),S&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(S&&D.getDerivedStateFromProps==null&&_!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,E),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,E)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(v){v&&(v.__=t)}),kn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),S&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,h,y)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=F.__r,b=0,S)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),kn.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++b<25);c.state=c.__s,c.getChildContext!=null&&(r=Te(Te({},r),c.getChildContext())),S&&!p&&c.getSnapshotBeforeUpdate!=null&&(y=c.getSnapshotBeforeUpdate(d,h)),$=f!=null&&f.type===G&&f.key==null?Aa(f.props.children):f,s=Ia(e,Zt($)?$:[$],t,n,r,i,a,o,s,l,u),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),k&&(c.__E=c.__=null)}catch(v){if(t.__v=null,l||a!=null)if(v.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(A=a.length;A--;)Mr(a[A]);sr(t)}else t.__e=n.__e,t.__k=n.__k,v.then||sr(t);F.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ws(n.__e,t,n,r,i,a,o,l,u);return(f=F.diffed)&&f(t),128&t.__u?void 0:s}function sr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(sr))}function Ea(e,t,n){for(var r=0;r<n.length;r++)Fr(n[r],n[++r],n[++r]);F.__c&&F.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){F.__e(a,i.__v)}})}function Aa(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Zt(e)?e.map(Aa):Te({},e)}function ws(e,t,n,r,i,a,o,s,l){var u,f,c,p,d,h,y,k=n.props||Sn,_=t.props,S=t.type;if(S==\"svg\"?i=\"http://www.w3.org/2000/svg\":S==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(u=0;u<a.length;u++)if((d=a[u])&&\"setAttribute\"in d==!!S&&(S?d.localName==S:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(S==null)return document.createTextNode(_);e=document.createElementNS(i,S,_.is&&_),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(S==null)k===_||s&&e.data==_||(e.data=_);else{if(a=a&&Xt.call(e.childNodes),!s&&a!=null)for(k={},u=0;u<e.attributes.length;u++)k[(d=e.attributes[u]).name]=d.value;for(u in k)d=k[u],u==\"dangerouslySetInnerHTML\"?c=d:u==\"children\"||u in _||u==\"value\"&&\"defaultValue\"in _||u==\"checked\"&&\"defaultChecked\"in _||un(e,u,null,d,i);for(u in _)d=_[u],u==\"children\"?p=d:u==\"dangerouslySetInnerHTML\"?f=d:u==\"value\"?h=d:u==\"checked\"?y=d:s&&typeof d!=\"function\"||k[u]===d||un(e,u,d,k[u],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Ia(t.type==\"template\"?e.content:e,Zt(p)?p:[p],t,n,r,S==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&vt(n,0),s,l),a!=null)for(u=a.length;u--;)Mr(a[u]);s||(u=\"value\",S==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[u]||S==\"progress\"&&!h||S==\"option\"&&h!=k[u])&&un(e,u,h,k[u],i),u=\"checked\",y!=null&&y!=e[u]&&un(e,u,y,k[u],i))}return e}function Fr(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){F.__e(i,n)}}function $a(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Fr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){F.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&$a(r[i],t,n||typeof e.type!=\"function\");n||Mr(e.__e),e.__c=e.__=e.__e=void 0}function Ss(e,t,n){return this.constructor(e,n)}function Pe(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),F.__&&F.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],zr(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||Sn,Sn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Xt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Ea(a,e,o)}function Da(e,t){Pe(e,t,Da)}function ks(e,t,n){var r,i,a,o,s=Te({},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?Xt.call(arguments,2):n),Lt(e.type,s,r||e.key,i||e.ref,null)}function Qe(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,or(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\"+xa++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Xt=kn.slice,F={__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}},va=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),or(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),or(this))},Ne.prototype.render=G,Xe=[],wa=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Sa=function(e,t){return e.__v.__b-t.__v.__b},xn.__r=0,ka=/(PointerCapture)$|Capture$/i,Rr=0,ir=fi(!1),ar=fi(!0),xa=0;var xs=0;function w(e,t,n,r,i,a){t||(t={});var o,s,l=t;if(\"ref\"in l)for(s in l={},t)s==\"ref\"?o=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--xs,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return F.vnode&&F.vnode(u),u}var Ke,W,Un,di,wt=0,Ta=[],K=F,hi=K.__b,pi=K.__r,gi=K.diffed,mi=K.__c,yi=K.unmount,_i=K.__;function xt(e,t){K.__h&&K.__h(W,e,wt||t),wt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ee(e){return wt=1,Or(za,e)}function Or(e,t,n){var r=xt(Ke++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):za(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(p){return p.__c});if(f.every(function(p){return!p.__N}))return!a||a.call(this,s,l,u);var c=r.__c.props!==s;return f.some(function(p){if(p.__N){var d=p.__[0];p.__=p.__N,p.__N=void 0,d!==p.__[0]&&(c=!0)}}),a&&a.call(this,s,l,u)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,l,u){if(this.__e){var f=a;a=void 0,i(s,l,u),a=f}o&&o.call(this,s,l,u)},W.shouldComponentUpdate=i}return r.__N||r.__}function ke(e,t){var n=xt(Ke++,3);!K.__s&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ct(e,t){var n=xt(Ke++,4);!K.__s&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return wt=5,pe(function(){return{current:e}},[])}function Na(e,t,n){wt=6,ct(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=xt(Ke++,7);return Lr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ge(e,t){return wt=8,pe(function(){return e},t)}function Q(e){var t=W.context[e.__c],n=xt(Ke++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ra(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Ma(){var e=xt(Ke++,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 Cs(){for(var e;e=Ta.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(mn),t.__h.some(lr),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,hi&&hi(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_i&&_i(e,t)},K.__r=function(e){pi&&pi(e),Ke=0;var t=(W=e.__c).__H;t&&(Un===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(mn),t.__h.some(lr),t.__h=[],Ke=0)),Un=W},K.diffed=function(e){gi&&gi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ta.push(t)!==1&&di===K.requestAnimationFrame||((di=K.requestAnimationFrame)||Is)(Cs)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Un=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(mn),n.__h=n.__h.filter(function(r){return!r.__||lr(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),mi&&mi(e,t)},K.unmount=function(e){yi&&yi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{mn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var bi=typeof requestAnimationFrame==\"function\";function Is(e){var t,n=function(){clearTimeout(r),bi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);bi&&(t=requestAnimationFrame(n))}function mn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function lr(e){var t=W;e.__c=e.__(),W=t}function Lr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function za(e,t){return typeof t==\"function\"?t(e):t}const vi=e=>{let t;const n=new Set,r=(u,f)=>{const c=typeof u==\"function\"?u(t):u;if(!Object.is(c,t)){const p=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(d=>d(t,p))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,i,s);return s},Ps=(e=>e?vi(e):vi);function Fa(e,t){for(var n in t)e[n]=t[n];return e}function ur(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 Oa(e,t){var n=t(),r=ee({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ct(function(){i.__=n,i.u=t,jn(i)&&a({t:i})},[e,n,t]),ke(function(){return jn(i)&&a({t:i}),e(function(){jn(i)&&a({t:i})})},[e]),n}function jn(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 La(e){e()}function Ba(e){return e}function Va(){return[!1,La]}var Ha=ct;function cr(e,t){this.props=e,this.context=t}function Es(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:ur(this.props,i)}function r(i){return this.shouldComponentUpdate=n,Y(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(cr.prototype=new Ne).isPureReactComponent=!0,cr.prototype.shouldComponentUpdate=function(e,t){return ur(this.props,e)||ur(this.state,t)};var wi=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),wi&&wi(e)};var As=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function $s(e){function t(n){var r=Fa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=As,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Si=function(e,t){return e==null?null:Ve(Ve(e).map(t))},Ds={map:Si,forEach:Si,count:function(e){return e?Ve(e).length:0},only:function(e){var t=Ve(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ve},Ts=F.__e;F.__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)}Ts(e,t,n,r)};var ki=F.unmount;function qa(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=Fa({},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 qa(r,t,n)})),e}function Ua(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ua(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 yn(){this.__u=0,this.o=null,this.__b=null}function ja(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ns(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?Y(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Ft(){this.i=null,this.l=null}F.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ki&&ki(e)},(yn.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ja(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(l):l())};n.__R=o;var s=n.__P;n.__P=null;var l=function(){if(!--r.__u){if(r.state.__a){var u=r.state.__a;r.__v.__k[0]=Ua(u,u.__c.__P,u.__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)},yn.prototype.componentWillUnmount=function(){this.o=[]},yn.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]=qa(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Y(G,null,e.fallback);return i&&(i.__u&=-33),[Y(G,null,t.__a?null:e.children),i]};var xi=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 Rs(e){return this.getChildContext=function(){return e.context},e.children}function Ms(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Pe(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)}}}Pe(Y(Rs,{context:t.context},e.__v),t.v)}function zs(e,t){var n=Y(Ms,{__v:e,h:t});return n.containerInfo=t,n}(Ft.prototype=new Ne).__a=function(e){var t=this,n=ja(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),xi(t,e,r)):i()};n?n(a):a()}},Ft.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ve(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},Ft.prototype.componentDidUpdate=Ft.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){xi(e,n,t)})};var Wa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Fs=/^(?: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]/,Os=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ls=/[A-Z0-9]/g,Bs=typeof document<\"u\",Vs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Hs(e,t,n){return t.__k==null&&(t.textContent=\"\"),Pe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function qs(e,t,n){return Da(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Ci=F.event;function Us(){}function js(){return this.cancelBubble}function Ws(){return this.defaultPrevented}F.event=function(e){return Ci&&(e=Ci(e)),e.persist=Us,e.isPropagationStopped=js,e.isDefaultPrevented=Ws,e.nativeEvent=e};var Br,Ks={enumerable:!1,configurable:!0,get:function(){return this.class}},Ii=F.vnode;F.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||Bs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var l=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":l===\"translate\"&&s===\"no\"?s=!1:l[0]===\"o\"&&l[1]===\"n\"?l===\"ondoubleclick\"?o=\"ondblclick\":l!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Vs(n.type)?l===\"onfocus\"?o=\"onfocusin\":l===\"onblur\"?o=\"onfocusout\":Os.test(o)&&(o=l):l=o=\"oninput\":a&&Fs.test(o)?o=o.replace(Ls,\"-$&\").toLowerCase():s===null&&(s=void 0),l===\"oninput\"&&i[o=l]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ve(n.children).forEach(function(u){u.props.selected=i.value.indexOf(u.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ve(n.children).forEach(function(u){u.props.selected=i.multiple?i.defaultValue.indexOf(u.props.value)!=-1:i.defaultValue==u.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Ks)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Wa,Ii&&Ii(e)};var Pi=F.__r;F.__r=function(e){Pi&&Pi(e),Br=e.__c};var Ei=F.diffed;F.diffed=function(e){Ei&&Ei(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),Br=null};var Qs={ReactCurrentDispatcher:{current:{readContext:function(e){return Br.__n[e.__c].props.value},useCallback:ge,useContext:Q,useDebugValue:Ra,useDeferredValue:Ba,useEffect:ke,useId:Ma,useImperativeHandle:Na,useInsertionEffect:Ha,useLayoutEffect:ct,useMemo:pe,useReducer:Or,useRef:se,useState:ee,useSyncExternalStore:Oa,useTransition:Va}}};function Gs(e){return Y.bind(null,e)}function Mn(e){return!!e&&e.$$typeof===Wa}function Ys(e){return Mn(e)&&e.type===G}function Js(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Xs(e){return Mn(e)?ks.apply(null,arguments):e}function Zs(e){return!!e.__k&&(Pe(null,e),!0)}function el(e){return e&&(e.base||e.nodeType===1&&e)||null}var tl=function(e,t){return e(t)},nl=function(e,t){return e(t)},rl=G,il=Mn,cn={useState:ee,useId:Ma,useReducer:Or,useEffect:ke,useLayoutEffect:ct,useInsertionEffect:Ha,useTransition:Va,useDeferredValue:Ba,useSyncExternalStore:Oa,startTransition:La,useRef:se,useImperativeHandle:Na,useMemo:pe,useCallback:ge,useContext:Q,useDebugValue:Ra,version:\"18.3.1\",Children:Ds,render:Hs,hydrate:qs,unmountComponentAtNode:Zs,createPortal:zs,createElement:Y,createContext:Qe,createFactory:Gs,cloneElement:Xs,createRef:ys,Fragment:G,isValidElement:Mn,isElement:il,isFragment:Ys,isMemo:Js,findDOMNode:el,Component:Ne,PureComponent:cr,memo:Es,forwardRef:$s,flushSync:nl,unstable_batchedUpdates:tl,StrictMode:rl,Suspense:yn,SuspenseList:Ft,lazy:Ns,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Qs};const al=e=>e;function ol(e,t=al){const n=cn.useSyncExternalStore(e.subscribe,cn.useCallback(()=>t(e.getState()),[e,t]),cn.useCallback(()=>t(e.getInitialState()),[e,t]));return cn.useDebugValue(n),n}const sl=e=>{const t=Ps(e),n=r=>ol(t,r);return Object.assign(n,t),n},ll=(e=>sl);var Vr=Symbol.for(\"immer-nothing\"),Bt=Symbol.for(\"immer-draftable\"),ne=Symbol.for(\"immer-state\");function oe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ye=Object,ot=ye.getPrototypeOf,jt=\"constructor\",en=\"prototype\",fr=\"configurable\",Cn=\"enumerable\",_n=\"writable\",Wt=\"value\",qe=e=>!!e&&!!e[ne];function Re(e){return e?Ka(e)||nn(e)||!!e[Bt]||!!e[jt]?.[Bt]||rn(e)||an(e):!1}var ul=ye[en][jt].toString(),Ai=new WeakMap;function Ka(e){if(!e||!St(e))return!1;const t=ot(e);if(t===null||t===ye[en])return!0;const n=ye.hasOwnProperty.call(t,jt)&&t[jt];if(n===Object)return!0;if(!Ze(n))return!1;let r=Ai.get(n);return r===void 0&&(r=Function.toString.call(n),Ai.set(n,r)),r===ul}function tn(e,t,n=!0){st(e)===0?(n?Reflect.ownKeys(e):ye.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function st(e){const t=e[ne];return t?t.type_:nn(e)?1:rn(e)?2:an(e)?3:0}var Vt=(e,t,n=st(e))=>n===2?e.has(t):ye[en].hasOwnProperty.call(e,t),Le=(e,t,n=st(e))=>n===2?e.get(t):e[t],In=(e,t,n,r=st(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function cl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var nn=Array.isArray,rn=e=>e instanceof Map,an=e=>e instanceof Set,St=e=>typeof e==\"object\",Ze=e=>typeof e==\"function\",Wn=e=>typeof e==\"boolean\";function fl(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var dl=e=>St(e)?e?.[ne]:null,Be=e=>e.copy_||e.base_,Hr=e=>e.modified_?e.copy_:e.base_;function dr(e,t){if(rn(e))return new Map(e);if(an(e))return new Set(e);if(nn(e))return Array[en].slice.call(e);const n=Ka(e);if(t===!0||t===\"class_only\"&&!n){const r=ye.getOwnPropertyDescriptors(e);delete r[ne];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[_n]===!1&&(s[_n]=!0,s[fr]=!0),(s.get||s.set)&&(r[o]={[fr]:!0,[_n]:!0,[Cn]:s[Cn],[Wt]:e[o]})}return ye.create(ot(e),r)}else{const r=ot(e);if(r!==null&&n)return{...e};const i=ye.create(r);return ye.assign(i,e)}}function qr(e,t=!1){return zn(e)||qe(e)||!Re(e)||(st(e)>1&&ye.defineProperties(e,{set:fn,add:fn,clear:fn,delete:fn}),ye.freeze(e),t&&tn(e,(n,r)=>{qr(r,!0)},!1)),e}function hl(){oe(2)}var fn={[Wt]:hl};function zn(e){return e===null||!St(e)?!0:ye.isFrozen(e)}var Pn=\"MapSet\",En=\"Patches\",$i=\"ArrayMethods\",An={};function lt(e){const t=An[e];return t||oe(0,e),t}var Di=e=>!!An[e];function pl(e,t){An[e]||(An[e]=t)}var Kt,Qa=()=>Kt,gl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Di(Pn)?lt(Pn):void 0,arrayMethodsPlugin_:Di($i)?lt($i):void 0});function Ti(e,t){t&&(e.patchPlugin_=lt(En),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hr(e){pr(e),e.drafts_.forEach(ml),e.drafts_=null}function pr(e){e===Kt&&(Kt=e.parent_)}var Ni=e=>Kt=gl(Kt,e);function ml(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ri(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(hr(t),oe(4)),Re(e)&&(e=Mi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Mi(t,n);return yl(t,e,!0),hr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Vr?e:void 0}function Mi(e,t){if(zn(t))return t;const n=t[ne];if(!n)return $n(t,e.handledSet_,e);if(!Fn(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);Ja(n,e)}return n.copy_}function yl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qr(t,n)}function Ga(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Fn=(e,t)=>e.scope_===t,_l=[];function Ya(e,t,n,r){const i=Be(e),a=e.type_;if(r!==void 0&&Le(i,r,a)===t){In(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;tn(i,(l,u)=>{if(qe(u)){const f=s.get(u)||[];f.push(l),s.set(u,f)}})}const o=e.draftLocations_.get(t)??_l;for(const s of o)In(i,s,n,a)}function bl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Fn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Hr(a);Ya(e,a.draft_??a,o,n),Ja(a,i)})}function Ja(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)}Ga(e)}}function vl(e,t,n){const{scope_:r}=e;if(qe(n)){const i=n[ne];Fn(i,r)&&i.callbacks_.push(function(){bn(e);const o=Hr(i);Ya(e,n,o,t)})}else Re(n)&&e.callbacks_.push(function(){const a=Be(e);e.type_===3?a.has(n)&&$n(n,r.handledSet_,r):Le(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&$n(Le(e.copy_,t,e.type_),r.handledSet_,r)})}function $n(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||qe(e)||t.has(e)||!Re(e)||zn(e)||(t.add(e),tn(e,(r,i)=>{if(qe(i)){const a=i[ne];if(Fn(a,n)){const o=Hr(a);In(e,r,o,e.type_),Ga(a)}}else Re(i)&&$n(i,t,n)})),e}function wl(e,t){const n=nn(e),r={type_:n?1:0,scope_:t?t.scope_:Qa(),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=Dn;n&&(i=[r],a=Qt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Dn={get(e,t){if(t===ne)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=Be(e);if(!Vt(i,t,e.type_))return Sl(e,i,t);const a=i[t];if(e.finalized_||!Re(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&fl(t))return a;if(a===Kn(e.base_,t)){bn(e);const o=e.type_===1?+t:t,s=mr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Be(e)},ownKeys(e){return Reflect.ownKeys(Be(e))},set(e,t,n){const r=Xa(Be(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Kn(Be(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(cl(n,i)&&(n!==void 0||Vt(e.base_,t,e.type_)))return!0;bn(e),gr(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),vl(e,t,n)),!0},deleteProperty(e,t){return bn(e),Kn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),gr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Be(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[_n]:!0,[fr]:e.type_!==1||t!==\"length\",[Cn]:r[Cn],[Wt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return ot(e.base_)},setPrototypeOf(){oe(12)}},Qt={};for(let e in Dn){let t=Dn[e];Qt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Qt.deleteProperty=function(e,t){return Qt.set.call(this,e,t,void 0)};Qt.set=function(e,t,n){return Dn.set.call(this,e[0],t,n,e[0])};function Kn(e,t){const n=e[ne];return(n?Be(n):e)[t]}function Sl(e,t,n){const r=Xa(t,n);return r?Wt in r?r[Wt]:r.get?.call(e.draft_):void 0}function Xa(e,t){if(!(t in e))return;let n=ot(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=ot(n)}}function gr(e){e.modified_||(e.modified_=!0,e.parent_&&gr(e.parent_))}function bn(e){e.copy_||(e.assigned_=new Map,e.copy_=dr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ze(t)&&!Ze(n)){const a=n;n=t;const o=this;return function(l=a,...u){return o.produce(l,f=>n.call(this,f,...u))}}Ze(n)||oe(6),r!==void 0&&!Ze(r)&&oe(7);let i;if(Re(t)){const a=Ni(this),o=mr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?hr(a):pr(a)}return Ti(a,r),Ri(i,a)}else if(!t||!St(t)){if(i=n(t),i===void 0&&(i=t),i===Vr&&(i=void 0),this.autoFreeze_&&qr(i,!0),r){const a=[],o=[];lt(En).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Ze(t))return(o,...s)=>this.produceWithPatches(o,l=>t(l,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},Wn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Wn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Wn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Re(e)||oe(8),qe(e)&&(e=xl(e));const t=Ni(this),n=mr(t,e,void 0);return n[ne].isManual_=!0,pr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return Ti(r,t),Ri(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=lt(En).applyPatches_;return qe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function mr(e,t,n,r){const[i,a]=rn(t)?lt(Pn).proxyMap_(t,n):an(t)?lt(Pn).proxySet_(t,n):wl(t,n);return(n?.scope_??Qa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?bl(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=l;a.modified_&&u&&u.generatePatches_(a,[],l)}),i}function xl(e){return qe(e)||oe(10,e),Za(e)}function Za(e){if(!Re(e)||zn(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=dr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=dr(e,!0);return tn(n,(i,a)=>{In(n,i,Za(a))},r),t&&(t.finalized_=!1),n}function Cl(){function t(h,y=[]){if(h.key_!==void 0){const k=h.parent_.copy_??h.parent_.base_,_=dl(Le(k,h.key_)),S=Le(k,h.key_);if(S===void 0||S!==h.draft_&&S!==h.base_&&S!==h.copy_||_!=null&&_.base_!==h.base_)return null;const x=h.parent_.type_===3;let E;if(x){const I=h.parent_;E=Array.from(I.drafts_.keys()).indexOf(h.key_)}else E=h.key_;if(!(x&&k.size>E||Vt(k,E)))return null;y.push(E)}if(h.parent_)return t(h.parent_,y);y.reverse();try{n(h.copy_,y)}catch{return null}return y}function n(h,y){let k=h;for(let _=0;_<y.length-1;_++){const S=y[_];if(k=Le(k,S),!St(k)||k===null)throw new Error(`Cannot resolve path at '${y.join(\"/\")}'`)}return k}const r=\"replace\",i=\"add\",a=\"remove\";function o(h,y,k){if(h.scope_.processedForPatches_.has(h))return;h.scope_.processedForPatches_.add(h);const{patches_:_,inversePatches_:S}=k;switch(h.type_){case 0:case 2:return l(h,y,_,S);case 1:return s(h,y,_,S);case 3:return u(h,y,_,S)}}function s(h,y,k,_){let{base_:S,assigned_:x}=h,E=h.copy_;E.length<S.length&&([S,E]=[E,S],[k,_]=[_,k]);const I=h.allIndicesReassigned_===!0;for(let b=0;b<S.length;b++){const $=E[b],A=S[b];if((I||x?.get(b.toString()))&&$!==A){const v=$?.[ne];if(v&&v.modified_)continue;const T=y.concat([b]);k.push({op:r,path:T,value:d($)}),_.push({op:r,path:T,value:d(A)})}}for(let b=S.length;b<E.length;b++){const $=y.concat([b]);k.push({op:i,path:$,value:d(E[b])})}for(let b=E.length-1;S.length<=b;--b){const $=y.concat([b]);_.push({op:a,path:$})}}function l(h,y,k,_){const{base_:S,copy_:x,type_:E}=h;tn(h.assigned_,(I,b)=>{const $=Le(S,I,E),A=Le(x,I,E),D=b?Vt(S,I)?r:i:a;if($===A&&D===r)return;const v=y.concat(I);k.push(D===a?{op:D,path:v}:{op:D,path:v,value:d(A)}),_.push(D===i?{op:a,path:v}:D===a?{op:i,path:v,value:d($)}:{op:r,path:v,value:d($)})})}function u(h,y,k,_){let{base_:S,copy_:x}=h,E=0;S.forEach(I=>{if(!x.has(I)){const b=y.concat([E]);k.push({op:a,path:b,value:I}),_.unshift({op:i,path:b,value:I})}E++}),E=0,x.forEach(I=>{if(!S.has(I)){const b=y.concat([E]);k.push({op:i,path:b,value:I}),_.unshift({op:a,path:b,value:I})}E++})}function f(h,y,k){const{patches_:_,inversePatches_:S}=k;_.push({op:r,path:[],value:y===Vr?void 0:y}),S.push({op:r,path:[],value:h})}function c(h,y){return y.forEach(k=>{const{path:_,op:S}=k;let x=h;for(let $=0;$<_.length-1;$++){const A=st(x);let D=_[$];typeof D!=\"string\"&&typeof D!=\"number\"&&(D=\"\"+D),(A===0||A===1)&&(D===\"__proto__\"||D===jt)&&oe(19),Ze(x)&&D===en&&oe(19),x=Le(x,D),St(x)||oe(18,_.join(\"/\"))}const E=st(x),I=p(k.value),b=_[_.length-1];switch(S){case r:switch(E){case 2:return x.set(b,I);case 3:oe(16);default:return x[b]=I}case i:switch(E){case 1:return b===\"-\"?x.push(I):x.splice(b,0,I);case 2:return x.set(b,I);case 3:return x.add(I);default:return x[b]=I}case a:switch(E){case 1:return x.splice(b,1);case 2:return x.delete(b);case 3:return x.delete(k.value);default:return delete x[b]}default:oe(17,S)}}),h}function p(h){if(!Re(h))return h;if(nn(h))return h.map(p);if(rn(h))return new Map(Array.from(h.entries()).map(([k,_])=>[k,p(_)]));if(an(h))return new Set(Array.from(h).map(p));const y=Object.create(ot(h));for(const k in h)y[k]=p(h[k]);return Vt(h,Bt)&&(y[Bt]=h[Bt]),y}function d(h){return qe(h)?p(h):h}pl(En,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Gt=new kl,Il=Gt.produce,Pl=Gt.produceWithPatches.bind(Gt),_t=Gt.applyPatches.bind(Gt);const El=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Il(i):i;return t(s,a,...o)},e(r.setState,n,r)),Al=El,$l=/[a-zA-Z]/,Dl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Tl(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 zi(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 Fi(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 Nl(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;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;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 gt(e,t){let n=1;for(;t<e.length&&n>0;)e[t]===\"{\"?n++:e[t]===\"}\"&&n--,n>0&&t++;return n===0?t:-1}function Ct(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const h=Fi(e,n);o=h.className||void 0,s=h.id||void 0,n=h.endIdx,e[n]===\" \"&&n++}let l=1;const u=n;for(;n<e.length&&l>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")l++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(l--,l===0)break;n+=2}else n++;if(l!==0){n=a+2,r=a;continue}const f=e.slice(u,n);n+=2;const{display:c,target:p}=Tl(f),d={type:\"link\",display:c,target:p,start:a,end:n};o&&(d.className=o),s&&(d.id=s),t.push(d),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,l;if(o===\".\"||o===\"#\"){i(n);const u=Fi(e,n+1);s=u.className||void 0,l=u.id||void 0;let f=u.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"variable\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=gt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"temporary\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=gt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"local\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=gt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let p=1;const d=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const h=e.slice(d,n);n++;const{name:y,rawArgs:k,isClose:_}=zi(h),S={type:\"macro\",name:y,rawArgs:k,isClose:_,start:a,end:n};s&&(S.className=s),l&&(S.id=l),t.push(S),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}const c=gt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}const c=gt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}const c=gt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,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 u=1;const f=n;for(;n<e.length&&u>0;)e[n]===\"{\"?u++:e[n]===\"}\"&&u--,u>0&&n++;if(u!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:p,rawArgs:d,isClose:h}=zi(c);t.push({type:\"macro\",name:p,rawArgs:d,isClose:h,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 l=o;for(;o<e.length&&/[a-zA-Z0-9-]/.test(e[o]);)o++;const u=e.slice(l,o),f=u.toLowerCase();if(u&&$l.test(u[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const c=Nl(e,o);o=c.endIdx;let p=Dl.has(f);if(e[o]===\"/\"&&(p=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:c.attributes,isClose:!1,isSelfClose:p,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const eo=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function yr(e){eo.add(e.toLowerCase())}const Oi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Rl=new Set([\"if\",\"switch\",\"timed\"]);function It(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\"expression\":{const a={type:\"expression\",expression:i.expression};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.toLowerCase()!==i.tag.toLowerCase()){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\":{const a=i.name.toLowerCase();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!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(Oi[a]){const o=Oi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const l={rawArgs:i.rawArgs,children:[]};i.className&&(l.className=i.className),i.id&&(l.id=i.id),s.branches.push(l);break}if(eo.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(Rl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}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:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}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 Ur(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Q(xe);return pe(()=>[e,t,n],[e,t,n])}function to(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 no(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let Pt=!1,on=\"\",ut=0,kt=null;function Ml(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,on=n,ut=0,kt=to(no(n)),Pt=!0}function ro(e,t){on=e,ut=0,kt=to(no(e)),Pt=!0;for(let n=0;n<t;n++)kt();ut=t}function _r(){Pt=!1,on=\"\",ut=0,kt=null}function Tn(){return Pt?{seed:on,pull:ut}:null}function jr(){return!Pt||!kt?Math.random():(ut++,kt())}function io(e,t){return e>t&&([e,t]=[t,e]),Math.floor(jr()*(t-e+1))+e}function zl(){return Pt}function Fl(){return on}function Ol(){return ut}const Ll=500,Ye=new Map,Bl=/\\$(\\w+)/g,Vl=/(?<![.\\w])_(\\w+)/g,Hl=/@(\\w+)/g;function ql(e){return e.replace(Bl,'variables[\"$1\"]').replace(Vl,'temporary[\"$1\"]').replace(Hl,'locals[\"$1\"]')}function Wr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=ql(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 l=e.charAt(r);if(l===\"\\\\\"&&r+1<e.length)s+=l+e.charAt(r+1),r+=2;else if(l===o){s+=o,r++;break}else s+=l,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,l=\"\";for(;r<e.length&&s>0;){const u=e.charAt(r);if(u===\"{\")s++,l+=u;else if(u===\"}\"){if(s--,s===0)break;l+=u}else if(u===\"\\\\\"&&r+1<e.length)l+=u+e.charAt(r+1),r++;else if(u==='\"'||u===\"'\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===u){l+=f,r++;break}else l+=f,r++}continue}else if(u===\"`\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===\"$\"&&e.charAt(r+1)===\"{\"){l+=\"${\",r+=2;let c=1;for(;r<e.length&&c>0;){const p=e.charAt(r);p===\"{\"?c++:p===\"}\"&&c--,c>0&&(l+=p),r++}l+=\"}\"}else if(f===\"`\"){l+=f,r++;break}else l+=f,r++}continue}else l+=u;r++}t+=Wr(l),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 Ul=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ao(e,t){const n=Ye.get(e);if(n)return Ye.delete(e),Ye.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Ul+t);if(Ye.set(e,r),Ye.size>Ll){const i=Ye.keys().next().value;i!==void 0&&Ye.delete(i)}return r}let dn=null,Li=null,Bi=null;function oo(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(dn&&Li===t&&Bi===n)return dn;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(h=>r(h)>0),o=(...d)=>d.every(h=>r(h)>0),s=d=>n[d??C.getState().currentPassage]??0;return dn={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const h=d.history[d.historyIndex-1]?.passage;return h?d.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(h=>s(h)>0),hasRenderedAll:(...d)=>d.every(h=>s(h)>0),random:jr,randomInt:io},Li=t,Bi=n,dn}function Et(e,t,n,r={}){const a=`return (${Wr(e)});`;return ao(a,a)(t,n,r,oo())}function so(e,t,n,r={}){const i=Wr(e);ao(\"exec:\"+i,i)(t,n,r,oo())}const jl=/\\{[\\$_@]\\w/;function Wl(e){return jl.test(e)}function Kl(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 Ql(e,t,n,r){const i=Et(e,t,n,r);return i==null?\"\":String(i)}function Gl(e,t,n,r){const i=e[0],o=e.slice(1).split(\".\"),s=o[0];let l;return i===\"$\"?l=t[s]:i===\"_\"?l=n[s]:l=r[s],o.length>1&&(l=Kl(l,o)),l==null?\"\":String(l)}function Yl(e,t,n,r){let i=\"\",a=0;for(;a<e.length;){if(e[a]!==\"{\"){const f=e.indexOf(\"{\",a);if(f===-1){i+=e.slice(a);break}i+=e.slice(a,f),a=f;continue}a++;const o=e[a];if(o!==\"$\"&&o!==\"_\"&&o!==\"@\"){i+=\"{\";continue}let s=1,l=a;for(;l<e.length&&s>0;)l++,e[l]===\"{\"?s++:e[l]===\"}\"&&s--;if(s!==0){i+=\"{\";continue}const u=e.slice(a,l);a=l+1,/^[\\$_@][\\w.]+$/.test(u)?i+=Gl(u,t,n,r):i+=Ql(u,t,n,r)}return i}function On(){const[e,t,n]=Ur();return ge(r=>r===void 0||!Wl(r)?r:Yl(r,e,t,n),[e,t,n])}function Jl({name:e,scope:t,className:n,id:r}){const i=On();n=i(n),r=i(r);const a=Q(xe),o=e.split(\".\"),s=o[0],l=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let u;t===\"local\"?u=s in a?a[s]:void 0:u=l;for(let c=1;c<o.length;c++){if(u==null||typeof u!=\"object\"){u=void 0;break}const p=o[c];u=u[p]}const f=u==null?\"\":String(u);return n||r?w(\"span\",{id:r,class:n,children:f}):w(G,{children:f})}function Xl({expression:e,className:t,id:n}){const r=On();t=r(t),n=r(n);const i=Q(xe),a=C(l=>l.variables),o=C(l=>l.temporary);let s;try{const l=Et(e,a,o,i);s=l==null?\"\":String(l)}catch{s=`{error: ${e}}`}return t||n?w(\"span\",{id:n,class:t,children:s}):w(G,{children:s})}function Zl(e){const t=e[0];return!!(t==='\"'||t===\"'\"||t===\"`\"||t===\"$\"||t===\"_\"||t===\"@\"||/\\d/.test(t)||(t===\"-\"||t===\"+\")&&e.length>1&&/\\d/.test(e[1])||t===\"(\"||t===\"[\"||t===\"{\"||/^(true|false|null|undefined)$/.test(e)||t===\"!\"&&e.length>1)}function eu(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const o=e[a];if(i){n+=o,o===i&&e[a-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(/\\s/.test(o)&&r===0){n&&(t.push(n),n=\"\");continue}n+=o}if(n&&t.push(n),t.length<2)return null;for(const a of t)if(!Zl(a))return null;return t}function tu(e){const t=[];let n=\"\",r=0,i=null,a=!1;for(let s=0;s<e.length;s++){const l=e[s];if(i){n+=l,l===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(l==='\"'||l===\"'\"||l===\"`\"){i=l,n+=l;continue}if(l===\"(\"||l===\"[\"||l===\"{\"){r++,n+=l;continue}if(l===\")\"||l===\"]\"||l===\"}\"){r--,n+=l;continue}if(l===\",\"&&r===0){a=!0,t.push(n.trim()),n=\"\";continue}n+=l}const o=n.trim();if(o&&t.push(o),!a&&t.length===1){const s=eu(t[0]);if(s)return s}return t}function nu({body:e,parentValues:t,ownKeys:n}){const r=Q(de),[i,a]=ee({}),o={...t,...n,...i},s=se(o);s.current=o;const l=ge(()=>s.current,[]),u=ge((c,p)=>{a(d=>({...d,[c]:p}))},[]),f=pe(()=>({update:u,getValues:l}),[u,l]);return w(sn.Provider,{value:f,children:w(xe.Provider,{value:o,children:Ee(e,{nobr:r,locals:o})})})}function ru({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(xe),a=Q(de),[o,s,l]=Ur(),u=r?.length?r:null;if(t.length===0||!n)return w(kr.Provider,{value:u,children:Ee(e,{nobr:a,locals:i})});const f=tu(n),c={};for(let p=0;p<t.length;p++){const d=t[p],h=f[p];let y;if(h!==void 0)try{y=Et(h,o,s,l)}catch{y=void 0}c[d.startsWith(\"@\")?d.slice(1):d]=y}return w(kr.Provider,{value:u,children:w(nu,{body:e,parentValues:i,ownKeys:c})})}const lo=new Map;function uo(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");lo.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function iu(e){return lo.get(e.toLowerCase())}const co=new Map;function au(e,t){co.set(e.toLowerCase(),t)}function ou(e){return co.get(e.toLowerCase())}const fo=new Set;function su(e){fo.add(e.toLowerCase())}function lu(e){return fo.has(e.toLowerCase())}const ho=new Map;function uu(e,t){ho.set(e.toLowerCase(),t)}function cu(){return Array.from(ho.values())}const Vi=document.createElement(\"i\");function po(e){const t=\"&\"+e+\";\";Vi.innerHTML=t;const n=Vi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function be(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 ae(e,t){return e.length>0?(be(e,e.length,0,t),e):t}const br={}.hasOwnProperty;function fu(e){const t={};let n=-1;for(;++n<e.length;)du(t,e[n]);return t}function du(e,t){let n;for(n in t){const i=(br.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){br.call(i,o)||(i[o]=[]);const s=a[o];hu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function hu(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);be(e,0,0,r)}function pu(e){const t={};let n=-1;for(;++n<e.length;)gu(t,e[n]);return t}function gu(e,t){let n;for(n in t){const i=(br.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 mu(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 yu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function go(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+yu[n]+\";\"}}function Yt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const De=Ge(/[A-Za-z]/),_e=Ge(/[\\dA-Za-z]/),_u=Ge(/[#-'*+\\--9=?A-Z^-~]/);function vr(e){return e!==null&&(e<32||e===127)}const wr=Ge(/\\d/),bu=Ge(/[\\dA-Fa-f]/),vu=Ge(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const wu=Ge(/\\p{P}|\\p{S}/u),Su=Ge(/\\s/);function Ge(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hn(e,t){const n=go(ku(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 ku(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&_e(e.charCodeAt(n+1))&&_e(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 Hi={}.hasOwnProperty,qi=/^(https?|ircs?|mailto|xmpp)$/i,xu=/^https?$/i;function Cu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=pu([{enter:{blockQuote:O,codeFenced:Ce,codeFencedFenceInfo:k,codeFencedFenceMeta:k,codeIndented:j,codeText:ls,content:Yo,definition:Uo,definitionDestinationString:Wo,definitionLabelString:k,definitionTitleString:k,emphasis:os,htmlFlow:as,htmlText:ii,image:q,label:k,link:ue,listItemMarker:T,listItemValue:v,listOrdered:A,listUnordered:D,paragraph:X,reference:k,resource:ht,resourceDestinationString:pt,resourceTitleString:k,setextHeading:Xo,strong:ss},exit:{atxHeading:es,atxHeadingSequence:Jo,autolinkEmail:gs,autolinkProtocol:ps,blockQuote:Z,characterEscapeValue:$t,characterReferenceMarkerHexadecimal:ai,characterReferenceMarkerNumeric:ai,characterReferenceValue:hs,codeFenced:g,codeFencedFence:R,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:is,codeIndented:g,codeText:us,codeTextData:$t,data:$t,definition:Go,definitionDestinationString:Ko,definitionLabelString:jo,definitionTitleString:Qo,emphasis:cs,hardBreakEscape:ni,hardBreakTrailing:ni,htmlFlow:ri,htmlFlowData:$t,htmlText:ri,htmlTextData:$t,image:ti,label:At,labelText:te,lineEnding:rs,link:ti,listOrdered:N,listUnordered:V,paragraph:me,reference:$,referenceString:je,resource:$,resourceDestinationString:qn,resourceTitleString:qo,setextHeading:ns,setextHeadingLineSequence:ts,setextHeadingText:Zo,strong:fs,thematicBreak:ds}},...t.htmlExtensions||[]]),u={definitions:r,tightStack:o},f={buffer:k,encode:b,getData:y,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:h,tag:S};let c=t.defaultLineEnding;return p;function p(P){let M=-1,re=0;const Ie=[];let Ae=[],Me=[];for(;++M<P.length;)!c&&(P[M][1].type===\"lineEnding\"||P[M][1].type===\"lineEndingBlank\")&&(c=P[M][2].sliceSerialize(P[M][1])),(P[M][1].type===\"listOrdered\"||P[M][1].type===\"listUnordered\")&&(P[M][0]===\"enter\"?Ie.push(M):d(P.slice(Ie.pop(),M))),P[M][1].type===\"definition\"&&(P[M][0]===\"enter\"?(Me=ae(Me,P.slice(re,M)),re=M):(Ae=ae(Ae,P.slice(re,M+1)),re=M+1));Ae=ae(Ae,Me),Ae=ae(Ae,P.slice(re)),M=-1;const $e=Ae;for(l.enter.null&&l.enter.null.call(f);++M<P.length;){const oi=l[$e[M][0]],si=$e[M][1].type,li=oi[si];Hi.call(oi,si)&&li&&li.call({sliceSerialize:$e[M][2].sliceSerialize,...f},$e[M][1])}return l.exit.null&&l.exit.null.call(f),i[0].join(\"\")}function d(P){const M=P.length;let re=0,Ie=0,Ae=!1,Me;for(;++re<M;){const $e=P[re];if($e[1]._container)Me=void 0,$e[0]===\"enter\"?Ie++:Ie--;else switch($e[1].type){case\"listItemPrefix\":{$e[0]===\"exit\"&&(Me=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{$e[0]===\"enter\"&&!Ie&&(Me?Me=void 0:Ae=!0);break}default:Me=void 0}}P[0][1]._loose=Ae}function h(P,M){u[P]=M}function y(P){return u[P]}function k(){i.push([])}function _(){return i.pop().join(\"\")}function S(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(c||`\n`)}function I(){const P=i[i.length-1],M=P[P.length-1],re=M?M.charCodeAt(M.length-1):null;re===10||re===13||re===null||E()}function b(P){return y(\"ignoreEncode\")?P:go(P)}function $(){_()}function A(P){o.push(!P._loose),I(),S(\"<ol\"),h(\"expectFirstItem\",!0)}function D(P){o.push(!P._loose),I(),S(\"<ul\"),h(\"expectFirstItem\",!0)}function v(P){if(y(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(P),10);M!==1&&S(' start=\"'+b(String(M))+'\"')}}function T(){y(\"expectFirstItem\")?S(\">\"):U(),I(),S(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),S(\"</ol>\")}function V(){U(),o.pop(),E(),S(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),S(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),S(\"<blockquote>\")}function Z(){o.pop(),I(),S(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),S(\"<p>\")),h(\"slurpAllLineEndings\")}function me(){o[o.length-1]?h(\"slurpAllLineEndings\",!0):S(\"</p>\")}function Ce(){I(),S(\"<pre><code\"),h(\"fencesCount\",0)}function m(){const P=_();S(' class=\"language-'+P+'\"')}function R(){const P=y(\"fencesCount\")||0;P||(S(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),S(\"<pre><code>\")}function g(){const P=y(\"fencesCount\");P!==void 0&&P<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&E(),y(\"flowCodeSeenData\")&&I(),S(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function At(){a[a.length-1].label=_()}function je(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function ht(){k(),a[a.length-1].destination=\"\"}function pt(){k(),h(\"ignoreEncode\",!0)}function qn(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function qo(){a[a.length-1].title=_()}function ti(){let P=a.length-1;const M=a[P],re=M.referenceId||M.labelId,Ie=M.destination===void 0?r[Yt(re)]:M;for(n=!0;P--;)if(a[P].image){n=void 0;break}M.image?(S('<img src=\"'+hn(Ie.destination,t.allowDangerousProtocol?void 0:xu)+'\" alt=\"'),x(M.label),S('\"')):S('<a href=\"'+hn(Ie.destination,t.allowDangerousProtocol?void 0:qi)+'\"'),S(Ie.title?' title=\"'+Ie.title+'\"':\"\"),M.image?S(\" />\"):(S(\">\"),x(M.label),S(\"</a>\")),a.pop()}function Uo(){k(),a.push({})}function jo(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function Wo(){k(),h(\"ignoreEncode\",!0)}function Ko(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Qo(){a[a.length-1].title=_()}function Go(){const P=a[a.length-1],M=Yt(P.labelId);_(),Hi.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Yo(){h(\"slurpAllLineEndings\",!0)}function Jo(P){y(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),S(\"<h\"+y(\"headingRank\")+\">\"))}function Xo(){k(),h(\"slurpAllLineEndings\")}function Zo(){h(\"slurpAllLineEndings\",!0)}function es(){S(\"</h\"+y(\"headingRank\")+\">\"),h(\"headingRank\")}function ts(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function ns(){const P=_();I(),S(\"<h\"+y(\"headingRank\")+\">\"),x(P),S(\"</h\"+y(\"headingRank\")+\">\"),h(\"slurpAllLineEndings\"),h(\"headingRank\")}function $t(P){x(b(this.sliceSerialize(P)))}function rs(P){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(b(this.sliceSerialize(P)))}}function is(P){x(b(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function ni(){S(\"<br />\")}function as(){I(),ii()}function ri(){h(\"ignoreEncode\")}function ii(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function os(){S(\"<em>\")}function ss(){S(\"<strong>\")}function ls(){h(\"inCodeText\",!0),S(\"<code>\")}function us(){h(\"inCodeText\"),S(\"</code>\")}function cs(){S(\"</em>\")}function fs(){S(\"</strong>\")}function ds(){I(),S(\"<hr />\")}function ai(P){h(\"characterReferenceType\",P.type)}function hs(P){const M=this.sliceSerialize(P),re=y(\"characterReferenceType\")?mu(M,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):po(M);x(b(re)),h(\"characterReferenceType\")}function ps(P){const M=this.sliceSerialize(P);S('<a href=\"'+hn(M,t.allowDangerousProtocol?void 0:qi)+'\">'),x(b(M)),S(\"</a>\")}function gs(P){const M=this.sliceSerialize(P);S('<a href=\"'+hn(\"mailto:\"+M)+'\">'),x(b(M)),S(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return L(l)?(e.enter(n),s(l)):t(l)}function s(l){return L(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const Iu={tokenize:Pu};function Pu(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\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const l=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return z(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Eu={tokenize:Au},Ui={tokenize:$u};function Au(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(x)}return u(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&S();const E=t.events.length;let I=E,b;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){b=t.events[I][1].end;break}_(r);let $=E;for(;$<t.events.length;)t.events[$][1].end={...b},$++;return be(t.events,I+1,0,t.events.slice(E)),t.events.length=$,u(x)}return s(x)}function u(x){if(r===n.length){if(!i)return p(x);if(i.currentConstruct&&i.currentConstruct.concrete)return h(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ui,f,c)(x)}function f(x){return i&&S(),_(r),p(x)}function c(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(x)}function p(x){return t.containerState={},e.attempt(Ui,d,h)(x)}function d(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function h(x){if(x===null){i&&S(),_(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),y(x)}function y(x){if(x===null){k(e.exit(\"chunkFlow\"),!0),_(0),e.consume(x);return}return z(x)?(e.consume(x),k(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),y)}function k(x,E){const I=t.sliceStream(x);if(E&&I.push(null),x.previous=a,a&&(a.next=x),a=x,i.defineSkip(x.start),i.write(I),t.parser.lazy[x.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<o&&(!i.events[b][1].end||i.events[b][1].end.offset>o))return;const $=t.events.length;let A=$,D,v;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){if(D){v=t.events[A][1].end;break}D=!0}for(_(r),b=$;b<t.events.length;)t.events[b][1].end={...v},b++;be(t.events,A+1,0,t.events.slice($)),t.events.length=b}}function _(x){let E=n.length;for(;E-- >x;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=x}function S(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function $u(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Nn(e){if(e===null||le(e)||Su(e))return 1;if(wu(e))return 2}function Ln(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 Sr={name:\"attention\",resolveAll:Du,tokenize:Tu};function Du(e,t){let n=-1,r,i,a,o,s,l,u,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;l=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},p={...e[n][1].start};ji(c,-l),ji(p,l),o={type:l>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:l>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:p},a={type:l>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=ae(u,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),u=ae(u,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),u=ae(u,Ln(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=ae(u,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=ae(u,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,be(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Tu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Nn(r);let a;return o;function o(l){return a=l,e.enter(\"attentionSequence\"),s(l)}function s(l){if(l===a)return e.consume(l),s;const u=e.exit(\"attentionSequence\"),f=Nn(l),c=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return u._open=!!(a===42?c:c&&(i||!p)),u._close=!!(a===42?p:p&&(f||!c)),t(l)}}function ji(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Nu={name:\"autolink\",tokenize:Ru};function Ru(e,t,n){let r=0;return i;function i(d){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(d){return De(d)?(e.consume(d),o):d===64?n(d):u(d)}function o(d){return d===43||d===45||d===46||_e(d)?(r=1,s(d)):u(d)}function s(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||_e(d))&&r++<32?(e.consume(d),s):(r=0,u(d))}function l(d){return d===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d===null||d===32||d===60||vr(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),f):_u(d)?(e.consume(d),u):n(d)}function f(d){return _e(d)?c(d):n(d)}function c(d){return d===46?(e.consume(d),r=0,f):d===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):p(d)}function p(d){if((d===45||_e(d))&&r++<63){const h=d===45?p:c;return e.consume(d),h}return n(d)}}const Bn={partial:!0,tokenize:Mu};function Mu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const mo={continuation:{tokenize:Fu},exit:Ou,name:\"blockQuote\",tokenize:zu};function zu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function Fu(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(mo,t,n)(o)}}function Ou(e){e.exit(\"blockQuote\")}const yo={name:\"characterEscape\",tokenize:Lu};function Lu(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 vu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const _o={name:\"characterReference\",tokenize:Bu};function Bu(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\"),l}function l(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),u):(e.enter(\"characterReferenceValue\"),a=31,o=_e,f(c))}function u(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=bu,f):(e.enter(\"characterReferenceValue\"),a=7,o=wr,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return o===_e&&!po(r.sliceSerialize(p))?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 Wi={partial:!0,tokenize:Hu},Ki={concrete:!0,name:\"codeFenced\",tokenize:Vu};function Vu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return l;function l(b){return u(b)}function u(b){const $=r.events[r.events.length-1];return a=$&&$[1].type===\"linePrefix\"?$[2].sliceSerialize($[1],!0).length:0,s=b,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(b)}function f(b){return b===s?(o++,e.consume(b),f):o<3?n(b):(e.exit(\"codeFencedFenceSequence\"),L(b)?H(e,c,\"whitespace\")(b):c(b))}function c(b){return b===null||z(b)?(e.exit(\"codeFencedFence\"),r.interrupt?t(b):e.check(Wi,y,E)(b)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(b))}function p(b){return b===null||z(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(b)):L(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,d,\"whitespace\")(b)):b===96&&b===s?n(b):(e.consume(b),p)}function d(b){return b===null||z(b)?c(b):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===null||z(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(b)):b===96&&b===s?n(b):(e.consume(b),h)}function y(b){return e.attempt(i,E,k)(b)}function k(b){return e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),_}function _(b){return a>0&&L(b)?H(e,S,\"linePrefix\",a+1)(b):S(b)}function S(b){return b===null||z(b)?e.check(Wi,y,E)(b):(e.enter(\"codeFlowValue\"),x(b))}function x(b){return b===null||z(b)?(e.exit(\"codeFlowValue\"),S(b)):(e.consume(b),x)}function E(b){return e.exit(\"codeFenced\"),t(b)}function I(b,$,A){let D=0;return v;function v(O){return b.enter(\"lineEnding\"),b.consume(O),b.exit(\"lineEnding\"),T}function T(O){return b.enter(\"codeFencedFence\"),L(O)?H(b,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(O):N(O)}function N(O){return O===s?(b.enter(\"codeFencedFenceSequence\"),V(O)):A(O)}function V(O){return O===s?(D++,b.consume(O),V):D>=o?(b.exit(\"codeFencedFenceSequence\"),L(O)?H(b,U,\"whitespace\")(O):U(O)):A(O)}function U(O){return O===null||z(O)?(b.exit(\"codeFencedFence\"),$(O)):A(O)}}}function Hu(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 Qn={name:\"codeIndented\",tokenize:Uu},qu={partial:!0,tokenize:ju};function Uu(e,t,n){const r=this;return i;function i(u){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(u)}function a(u){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):z(u)?e.attempt(qu,o,l)(u):(e.enter(\"codeFlowValue\"),s(u))}function s(u){return u===null||z(u)?(e.exit(\"codeFlowValue\"),o(u)):(e.consume(u),s)}function l(u){return e.exit(\"codeIndented\"),t(u)}}function ju(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const Wu={name:\"codeText\",previous:Qu,resolve:Ku,tokenize:Gu};function Ku(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 Qu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Gu(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\"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),l):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):z(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),l):(e.enter(\"codeTextData\"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit(\"codeTextData\"),l(c)):(e.consume(c),u)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",u(c))}}class Yu{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&&Dt(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),Dt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Dt(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);Dt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Dt(this.left,n.reverse())}}}function Dt(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 bo(e){const t={};let n=-1,r,i,a,o,s,l,u;const f=new Yu(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\"&&(l=r[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type===\"lineEndingBlank\"&&(a+=2),a<l.length&&l[a][1].type===\"content\"))for(;++a<l.length&&l[a][1].type!==\"content\";)l[a][1].type===\"chunkText\"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Ju(f,n)),n=t[n],u=!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 be(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function Ju(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,l=[],u={};let f,c,p=-1,d=n,h=0,y=0;const k=[y];for(;d;){for(;e.get(++i)[1]!==d;);a.push(i),d._tokenizer||(f=r.sliceStream(d),d.next||f.push(null),c&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=d,d=d.next}for(d=n;++p<s.length;)s[p][0]===\"exit\"&&s[p-1][0]===\"enter\"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(y=p+1,k.push(y),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),p=k.length;p--;){const _=s.slice(k[p],k[p+1]),S=a.pop();l.push([S,S+_.length-1]),e.splice(S,2,_)}for(l.reverse(),p=-1;++p<l.length;)u[h+l[p][0]]=h+l[p][1],h+=l[p][1]-l[p][0]-1;return u}const Xu={resolve:ec,tokenize:tc},Zu={partial:!0,tokenize:nc};function ec(e){return bo(e),e}function tc(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):z(s)?e.check(Zu,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 nc(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function vo(e,t,n,r,i,a,o,s,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),p):_===null||_===32||_===41||vr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),y(_))}function p(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),d(_))}function d(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),p(_)):_===null||_===60||z(_)?n(_):(e.consume(_),_===92?h:d)}function h(_){return _===60||_===62||_===92?(e.consume(_),d):d(_)}function y(_){return!f&&(_===null||_===41||le(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<u&&_===40?(e.consume(_),f++,y):_===41?(e.consume(_),f--,y):_===null||_===32||_===40||vr(_)?n(_):(e.consume(_),_===92?k:y)}function k(_){return _===40||_===41||_===92?(e.consume(_),y):y(_)}}function wo(e,t,n,r,i,a){const o=this;let s=0,l;return u;function u(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(a),f}function f(d){return s>999||d===null||d===91||d===93&&!l||d===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(d):d===93?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):z(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(d))}function c(d){return d===null||d===91||d===93||z(d)||s++>999?(e.exit(\"chunkString\"),f(d)):(e.consume(d),l||(l=!L(d)),d===92?p:c)}function p(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function So(e,t,n,r,i,a){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),u(p))}function u(p){return p===o?(e.exit(a),l(o)):p===null?n(p):z(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,u,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(p))}function f(p){return p===o||p===null||z(p)?(e.exit(\"chunkString\"),u(p)):(e.consume(p),p===92?c:f)}function c(p){return p===o||p===92?(e.consume(p),f):f(p)}}function Ht(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const rc={name:\"definition\",tokenize:ac},ic={partial:!0,tokenize:oc};function ac(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return wo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),l):n(d)}function l(d){return le(d)?Ht(e,u)(d):u(d)}function u(d){return vo(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(ic,c,c)(d)}function c(d){return L(d)?H(e,p,\"whitespace\")(d):p(d)}function p(d){return d===null||z(d)?(e.exit(\"definition\"),r.parser.defined.push(i),t(d)):n(d)}}function oc(e,t,n){return r;function r(s){return le(s)?Ht(e,i)(s):n(s)}function i(s){return So(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const sc={name:\"hardBreakEscape\",tokenize:lc};function lc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return z(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const uc={name:\"headingAtx\",resolve:cc,tokenize:fc};function cc(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\"},be(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function fc(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||le(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),l(f)):f===null||z(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit(\"atxHeadingSequence\"),s(f))}function u(f){return f===null||f===35||le(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),u)}}const dc=[\"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\"],Qi=[\"pre\",\"script\",\"style\",\"textarea\"],hc={concrete:!0,name:\"htmlFlow\",resolveTo:mc,tokenize:yc},pc={partial:!0,tokenize:bc},gc={partial:!0,tokenize:_c};function mc(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 yc(e,t,n){const r=this;let i,a,o,s,l;return u;function u(g){return f(g)}function f(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),p):g===47?(e.consume(g),a=!0,y):g===63?(e.consume(g),i=3,r.interrupt?t:m):De(g)?(e.consume(g),o=String.fromCharCode(g),k):n(g)}function p(g){return g===45?(e.consume(g),i=2,d):g===91?(e.consume(g),i=5,s=0,h):De(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function d(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function h(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:N:h):n(g)}function y(g){return De(g)?(e.consume(g),o=String.fromCharCode(g),k):n(g)}function k(g){if(g===null||g===47||g===62||le(g)){const q=g===47,ue=o.toLowerCase();return!q&&!a&&Qi.includes(ue)?(i=1,r.interrupt?t(g):N(g)):dc.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):N(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?S(g):x(g))}return g===45||_e(g)?(e.consume(g),o+=String.fromCharCode(g),k):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:N):n(g)}function S(g){return L(g)?(e.consume(g),S):v(g)}function x(g){return g===47?(e.consume(g),v):g===58||g===95||De(g)?(e.consume(g),E):L(g)?(e.consume(g),x):v(g)}function E(g){return g===45||g===46||g===58||g===95||_e(g)?(e.consume(g),E):I(g)}function I(g){return g===61?(e.consume(g),b):L(g)?(e.consume(g),I):x(g)}function b(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,$):L(g)?(e.consume(g),b):A(g)}function $(g){return g===l?(e.consume(g),l=null,D):g===null||z(g)?n(g):(e.consume(g),$)}function A(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||le(g)?I(g):(e.consume(g),A)}function D(g){return g===47||g===62||L(g)?x(g):n(g)}function v(g){return g===62?(e.consume(g),T):n(g)}function T(g){return g===null||z(g)?N(g):L(g)?(e.consume(g),T):n(g)}function N(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),R):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),Ce):z(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(pc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(gc,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),O}function O(g){return g===null||z(g)?V(g):(e.enter(\"htmlFlowData\"),N(g))}function Z(g){return g===45?(e.consume(g),m):N(g)}function X(g){return g===47?(e.consume(g),o=\"\",me):N(g)}function me(g){if(g===62){const q=o.toLowerCase();return Qi.includes(q)?(e.consume(g),R):N(g)}return De(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),me):N(g)}function Ce(g){return g===93?(e.consume(g),m):N(g)}function m(g){return g===62?(e.consume(g),R):g===45&&i===2?(e.consume(g),m):N(g)}function R(g){return g===null||z(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),R)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function _c(e,t,n){const r=this;return i;function i(o){return z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function bc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Bn,t,n)}}const vc={name:\"htmlText\",tokenize:wc};function wc(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),l}function l(m){return m===33?(e.consume(m),u):m===47?(e.consume(m),I):m===63?(e.consume(m),x):De(m)?(e.consume(m),A):n(m)}function u(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,h):De(m)?(e.consume(m),S):n(m)}function f(m){return m===45?(e.consume(m),d):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),p):z(m)?(o=c,X(m)):(e.consume(m),c)}function p(m){return m===45?(e.consume(m),d):c(m)}function d(m){return m===62?Z(m):m===45?p(m):c(m)}function h(m){const R=\"CDATA[\";return m===R.charCodeAt(a++)?(e.consume(m),a===R.length?y:h):n(m)}function y(m){return m===null?n(m):m===93?(e.consume(m),k):z(m)?(o=y,X(m)):(e.consume(m),y)}function k(m){return m===93?(e.consume(m),_):y(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):y(m)}function S(m){return m===null||m===62?Z(m):z(m)?(o=S,X(m)):(e.consume(m),S)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=x,X(m)):(e.consume(m),x)}function E(m){return m===62?Z(m):x(m)}function I(m){return De(m)?(e.consume(m),b):n(m)}function b(m){return m===45||_e(m)?(e.consume(m),b):$(m)}function $(m){return z(m)?(o=$,X(m)):L(m)?(e.consume(m),$):Z(m)}function A(m){return m===45||_e(m)?(e.consume(m),A):m===47||m===62||le(m)?D(m):n(m)}function D(m){return m===47?(e.consume(m),Z):m===58||m===95||De(m)?(e.consume(m),v):z(m)?(o=D,X(m)):L(m)?(e.consume(m),D):Z(m)}function v(m){return m===45||m===46||m===58||m===95||_e(m)?(e.consume(m),v):T(m)}function T(m){return m===61?(e.consume(m),N):z(m)?(o=T,X(m)):L(m)?(e.consume(m),T):D(m)}function N(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):z(m)?(o=N,X(m)):L(m)?(e.consume(m),N):(e.consume(m),U)}function V(m){return m===i?(e.consume(m),i=void 0,O):m===null?n(m):z(m)?(o=V,X(m)):(e.consume(m),V)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||le(m)?D(m):(e.consume(m),U)}function O(m){return m===47||m===62||le(m)?D(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function X(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),me}function me(m){return L(m)?H(e,Ce,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):Ce(m)}function Ce(m){return e.enter(\"htmlTextData\"),o(m)}}const Kr={name:\"labelEnd\",resolveAll:Cc,resolveTo:Ic,tokenize:Pc},Sc={tokenize:Ec},kc={tokenize:Ac},xc={tokenize:$c};function Cc(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&&be(e,0,e.length,n),e}function Ic(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 l={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},u={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\",l,t],[\"enter\",u,t]],s=ae(s,e.slice(a+1,a+r+3)),s=ae(s,[[\"enter\",f,t]]),s=ae(s,Ln(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ae(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",u,t]]),s=ae(s,e.slice(o+1)),s=ae(s,[[\"exit\",l,t]]),be(e,a,e.length,s),e}function Pc(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(p){return a?a._inactive?c(p):(o=r.parser.defined.includes(Yt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),l):n(p)}function l(p){return p===40?e.attempt(Sc,f,o?f:c)(p):p===91?e.attempt(kc,f,o?u:c)(p):o?f(p):c(p)}function u(p){return e.attempt(xc,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function Ec(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 le(c)?Ht(e,a)(c):a(c)}function a(c){return c===41?f(c):vo(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return le(c)?Ht(e,l)(c):f(c)}function s(c){return n(c)}function l(c){return c===34||c===39||c===40?So(e,u,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function u(c){return le(c)?Ht(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 Ac(e,t,n){const r=this;return i;function i(s){return wo.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function $c(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 Dc={name:\"labelStartImage\",resolveAll:Kr.resolveAll,tokenize:Tc};function Tc(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 Nc={name:\"labelStartLink\",resolveAll:Kr.resolveAll,tokenize:Rc};function Rc(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:Mc};function Mc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const vn={name:\"thematicBreak\",tokenize:zc};function zc(e,t,n){let r=0,i;return a;function a(u){return e.enter(\"thematicBreak\"),o(u)}function o(u){return i=u,s(u)}function s(u){return u===i?(e.enter(\"thematicBreakSequence\"),l(u)):r>=3&&(u===null||z(u))?(e.exit(\"thematicBreak\"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit(\"thematicBreakSequence\"),L(u)?H(e,s,\"whitespace\")(u):s(u))}}const he={continuation:{tokenize:Bc},exit:Hc,name:\"list\",tokenize:Lc},Fc={partial:!0,tokenize:qc},Oc={partial:!0,tokenize:Vc};function Lc(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(d){const h=r.containerState.type||(d===42||d===43||d===45?\"listUnordered\":\"listOrdered\");if(h===\"listUnordered\"?!r.containerState.marker||d===r.containerState.marker:wr(d)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(vn,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),l(d)}return n(d)}function l(d){return wr(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),u(d)):n(d)}function u(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(Bn,r.interrupt?n:f,e.attempt(Fc,p,c))}function f(d){return r.containerState.initialBlankLine=!0,a++,p(d)}function c(d){return L(d)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(d),e.exit(\"listItemPrefixWhitespace\"),p):n(d)}function p(d){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(d)}}function Bc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Oc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(he,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function Vc(e,t,n){const r=this;return H(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 Hc(e){e.exit(this.containerState.type)}function qc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Gi={name:\"setextUnderline\",resolveTo:Uc,tokenize:jc};function Uc(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 jc(e,t,n){const r=this;let i;return a;function a(u){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=u,o(u)):n(u)}function o(u){return e.enter(\"setextHeadingLineSequence\"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit(\"setextHeadingLineSequence\"),L(u)?H(e,l,\"lineSuffix\")(u):l(u))}function l(u){return u===null||z(u)?(e.exit(\"setextHeadingLine\"),t(u)):n(u)}}const Wc={tokenize:Kc};function Kc(e){const t=this,n=e.attempt(Bn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Xu,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 Qc={resolveAll:xo()},Gc=ko(\"string\"),Yc=ko(\"text\");function ko(e){return{resolveAll:xo(e===\"text\"?Jc: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 u(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),l}function l(f){return u(f)?(n.exit(\"data\"),a(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const c=i[f];let p=-1;if(c)for(;++p<c.length;){const d=c[p];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function xo(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 Jc(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,l;for(;a--;){const u=i[a];if(typeof u==\"string\"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||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={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,[\"enter\",u,t],[\"exit\",u,t]),n+=2)}n++}return e}const Xc={42:he,43:he,45:he,48:he,49:he,50:he,51:he,52:he,53:he,54:he,55:he,56:he,57:he,62:mo},Zc={91:rc},ef={[-2]:Qn,[-1]:Qn,32:Qn},tf={35:uc,42:vn,45:[Gi,vn],60:hc,61:Gi,95:vn,96:Ki,126:Ki},nf={38:_o,92:yo},rf={[-5]:Gn,[-4]:Gn,[-3]:Gn,33:Dc,38:_o,42:Sr,60:[Nu,vc],91:Nc,92:[sc,yo],93:Kr,95:Sr,96:Wu},af={null:[Sr,Qc]},of={null:[42,95]},sf={null:[]},lf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:of,contentInitial:Zc,disable:sf,document:Xc,flow:tf,flowInitial:ef,insideSpan:af,string:nf,text:rf},Symbol.toStringTag,{value:\"Module\"}));function uf(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 l={attempt:$(I),check:$(b),consume:S,enter:x,exit:E,interrupt:$(b,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:d,write:c};let f=t.tokenize.call(u,l);return t.resolveAll&&a.push(t),u;function c(T){return o=ae(o,T),k(),o[o.length-1]!==null?[]:(A(t,0),u.events=Ln(a,u.events,u),u.events)}function p(T,N){return ff(d(T),N)}function d(T){return cf(o,T)}function h(){const{_bufferIndex:T,_index:N,line:V,column:U,offset:O}=r;return{_bufferIndex:T,_index:N,line:V,column:U,offset:O}}function y(T){i[T.line]=T.column,v()}function k(){let T;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<N.length;)_(N.charCodeAt(r._bufferIndex));else _(N)}}function _(T){f=f(T)}function S(T){z(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,v()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=T}function x(T,N){const V=N||{};return V.type=T,V.start=h(),u.events.push([\"enter\",V,u]),s.push(V),V}function E(T){const N=s.pop();return N.end=h(),u.events.push([\"exit\",N,u]),N}function I(T,N){A(T,N.from)}function b(T,N){N.restore()}function $(T,N){return V;function V(U,O,Z){let X,me,Ce,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):R(U);function R(te){return At;function At(je){const ht=je!==null&&te[je],pt=je!==null&&te.null,qn=[...Array.isArray(ht)?ht:ht?[ht]:[],...Array.isArray(pt)?pt:pt?[pt]:[]];return j(qn)(je)}}function j(te){return X=te,me=0,te.length===0?Z:g(te[me])}function g(te){return At;function At(je){return m=D(),Ce=te,te.partial||(u.currentConstruct=te),te.name&&u.parser.constructs.disable.null.includes(te.name)?ue():te.tokenize.call(N?Object.assign(Object.create(u),N):u,l,q,ue)(je)}}function q(te){return T(Ce,m),O}function ue(te){return m.restore(),++me<X.length?g(X[me]):Z}}}function A(T,N){T.resolveAll&&!a.includes(T)&&a.push(T),T.resolve&&be(u.events,N,u.events.length-N,T.resolve(u.events.slice(N),u)),T.resolveTo&&(u.events=T.resolveTo(u.events,u))}function D(){const T=h(),N=u.previous,V=u.currentConstruct,U=u.events.length,O=Array.from(s);return{from:U,restore:Z};function Z(){r=T,u.previous=N,u.currentConstruct=V,u.events.length=U,s=O,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function cf(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 ff(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 df(e){const r={constructs:fu([lf,...(e||{}).extensions||[]]),content:i(Iu),defined:[],document:i(Eu),flow:i(Wc),lazy:{},string:i(Gc),text:i(Yc)};return r;function i(a){return o;function o(s){return uf(r,a,s)}}}function hf(e){for(;!bo(e););return e}const Yi=/[\\0\\t\\n\\r]/g;function pf(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const l=[];let u,f,c,p,d;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(Yi.lastIndex=c,u=Yi.exec(a),p=u&&u.index!==void 0?u.index:a.length,d=a.charCodeAt(p),!u){t=a.slice(c);break}if(d===10&&c===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<p&&(l.push(a.slice(c,p)),e+=p-c),d){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}function gf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Cu(n)(hf(df(n).document().write(pf()(e,t,!0))))}const Yn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function mf(){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=Yn[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=Yn[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,yf)),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\"+Yn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function yf(e,t){return t===\"|\"?t:e}class _f{constructor(){this.map=[]}add(t,n,r){bf(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 bf(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 vf(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 wf(){return{flow:{null:{name:\"table\",tokenize:Sf,resolveAll:kf}}}}function Sf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let T=r.events.length-1;for(;T>-1;){const U=r.events[T][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")T--;else break}const N=T>-1?r.events[T][1].type:null,V=N===\"tableHead\"||N===\"tableRow\"?b:l;return V===b&&r.parser.lazy[r.now().line]?n(v):V(v)}function l(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),u(v)}function u(v){return v===124||(o=!0,a+=1),f(v)}function f(v){return v===null?n(v):z(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),d):n(v):L(v)?H(e,f,\"whitespace\")(v):(a+=1,o&&(o=!1,i+=1),v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(v)))}function c(v){return v===null||v===124||le(v)?(e.exit(\"data\"),f(v)):(e.consume(v),v===92?p:c)}function p(v){return v===92||v===124?(e.consume(v),c):c(v)}function d(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,L(v)?H(e,h,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):h(v))}function h(v){return v===45||v===58?k(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),y):I(v)}function y(v){return L(v)?H(e,k,\"whitespace\")(v):k(v)}function k(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),_):v===45?(a+=1,_(v)):v===null||z(v)?E(v):I(v)}function _(v){return v===45?(e.enter(\"tableDelimiterFiller\"),S(v)):I(v)}function S(v){return v===45?(e.consume(v),S):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(v))}function x(v){return L(v)?H(e,E,\"whitespace\")(v):E(v)}function E(v){return v===124?h(v):v===null||z(v)?!o||i!==a?I(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):I(v)}function I(v){return n(v)}function b(v){return e.enter(\"tableRow\"),$(v)}function $(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),$):v===null||z(v)?(e.exit(\"tableRow\"),t(v)):L(v)?H(e,$,\"whitespace\")(v):(e.enter(\"data\"),A(v))}function A(v){return v===null||v===124||le(v)?(e.exit(\"data\"),$(v)):(e.consume(v),v===92?D:A)}function D(v){return v===92||v===124?(e.consume(v),A):A(v)}}function kf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,u,f,c;const p=new _f;for(;++n<e.length;){const d=e[n],h=d[1];d[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,l!==0&&(Ji(p,t,l,u,f),f=void 0,l=0),u={type:\"table\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",u,t]])):h.type===\"tableRow\"||h.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({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",f,t]])),i=h.type===\"tableDelimiterRow\"?2:f?3:1):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=pn(p,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):h.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=pn(p,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):h.type===\"tableHead\"?(s=!0,l=n):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(l=n,a[1]!==0?(o[0]=o[1],c=pn(p,t,a,i,n,c)):o[1]!==0&&(c=pn(p,t,o,i,n,c)),i=0):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(l!==0&&Ji(p,t,l,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]===\"enter\"&&d[1].type===\"table\"&&(d[1]._align=vf(t.events,n))}return e}function pn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},yt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const l=yt(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const u=yt(t.events,n[2]),f=yt(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const h=n[2]+1,y=n[3]-n[2]-1;e.add(h,y,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},yt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ji(e,t,n,r,i){const a=[],o=yt(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 yt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function xf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Cf(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 l=-1;for(;++l<o.length;)if(o[l][0]===\"enter\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]===\"exit\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type=\"strikethroughSequence\",o[u][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[[\"enter\",f,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"enter\",c,s]],d=s.parser.constructs.insideSpan.null;d&&be(p,p.length,0,Ln(d,o.slice(u+1,l),s)),be(p,p.length,0,[[\"exit\",c,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"exit\",f,s]]),be(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type===\"strikethroughSequenceTemporary\"&&(o[l][1].type=\"data\");return o}function a(o,s,l){const u=this.previous,f=this.events;let c=0;return p;function p(h){return u===126&&f[f.length-1][1].type!==\"characterEscape\"?l(h):(o.enter(\"strikethroughSequenceTemporary\"),d(h))}function d(h){const y=Nn(u);if(h===126)return c>1?l(h):(o.consume(h),c++,d);if(c<2&&!n)return l(h);const k=o.exit(\"strikethroughSequenceTemporary\"),_=Nn(h);return k._open=!_||_===2&&!!y,k._close=!y||y===2&&!!_,s(h)}}}function If(e){return gf(e,{allowDangerousHtml:!0,extensions:[wf(),Cf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[mf(),xf()]})}const Pf={update:e=>{throw new Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>({})},xe=Qe({}),sn=Qe(Pf),de=Qe(!1),Xi=Qe(!1),kr=Qe(null);function Ef(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>Co(a,o,t));return w(G,{children:i})}function Co(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const l of Array.from(r.attributes))o[l.name]=l.value;const s=Array.from(r.childNodes).map((l,u)=>Co(l,u,n));return Y(i,o,...s)}return null}function Af({node:e}){const t=On(),n=Q(de),r=Q(xe),i=Q(Xi),a={};for(const[u,f]of Object.entries(e.attributes))a[u]=t(f)??f;const o=e.tag.toLowerCase()===\"svg\",s=e.children.length>0?i||o?Qr(e.children):Ee(e.children,{nobr:n,locals:r}):void 0,l=Y(e.tag,a,s);return o?w(Xi.Provider,{value:!0,children:l}):l}function $f(){const e=Q(kr),t=Q(de),n=Q(xe);return!e||e.length===0?null:w(G,{children:Ee(e,{nobr:t,locals:n})})}function Df(e,t){if(lu(e.name))return null;const n=iu(e.name);if(n)return w(ru,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=ou(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function xr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w($f,{},t):w(Jl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return w(Xl,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Df(e,t);case\"html\":return w(Af,{node:e},t);default:return e}}function Qr(e){return e.length===0?null:e.map((t,n)=>xr(t,n))}function Tf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Nf(e,t){const n=C.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ee(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,l)=>xr(s,l));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const l=e[s];if(l.type===\"text\")i+=l.value;else if(l.type===\"variable\"&&Tf(i))i+=Nf(l,a);else{const u=r.length;r.push(xr(l,s)),i+=`<span data-tw=\"${u}\"></span>`}}const o=If(i);return Ef(o,r,t?.nobr)}function Rf(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)||i.history.length===0||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Mf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}function zf(){const e=new Map,t=new Map,n=new Map;return{type:\"memory\",async putSave(r){e.set(r.meta.id,r)},async getSave(r){return e.get(r)},async deleteSave(r){e.delete(r)},async getSavesByIfid(r){return[...e.values()].filter(i=>i.meta.ifid===r)},async deleteSavesByIfid(r){for(const i of[...e.keys()]){const a=e.get(i);a&&a.meta.ifid===r&&e.delete(i)}},async deleteSavesByPlaythrough(r){const i=[];for(const a of[...e.keys()]){const o=e.get(a);o&&o.meta.playthroughId===r&&(e.delete(a),i.push(a))}return i},async putPlaythrough(r){t.set(r.id,r)},async getPlaythroughsByIfid(r){return[...t.values()].filter(i=>i.ifid===r)},async deletePlaythroughsByIfid(r){for(const i of[...t.keys()]){const a=t.get(i);a&&a.ifid===r&&t.delete(i)}},async deletePlaythroughById(r){t.delete(r)},async getMeta(r){return n.get(r)},async setMeta(r,i){n.set(r,i)},async deleteMeta(r){n.delete(r)},async deleteMetaByPrefix(r){for(const i of[...n.keys()])i.startsWith(r)&&n.delete(i)},async deleteMetaByIfid(r){for(const i of[...n.keys()])i.includes(r)&&n.delete(i)},async getAllMetaKeys(){return[...n.keys()]},async destroy(){e.clear(),t.clear(),n.clear()}}}const ze=\"spindle.save.\",Tt=\"spindle.pt.\",Je=\"spindle.meta.\",mt=\"spindle.idx.saves.\",Nt=\"spindle.idx.pt.\",Rt=\"spindle.idx.saves-pt.\";function Oe(e){const t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function qt(e,t){localStorage.setItem(e,JSON.stringify(t))}function Fe(e){localStorage.removeItem(e)}function et(e){return Oe(e)??[]}function Jn(e,t){const n=et(e);n.includes(t)||(n.push(t),qt(e,n))}function Mt(e,t){const n=et(e).filter(r=>r!==t);qt(e,n)}function Ff(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;qt(`${ze}${t}`,e),Jn(`${mt}${e.meta.ifid}`,t),Jn(`${Rt}${e.meta.playthroughId}`,t)},async getSave(e){return Oe(`${ze}${e}`)},async deleteSave(e){const t=Oe(`${ze}${e}`);t&&(Mt(`${mt}${t.meta.ifid}`,e),Mt(`${Rt}${t.meta.playthroughId}`,e)),Fe(`${ze}${e}`)},async getSavesByIfid(e){const t=et(`${mt}${e}`),n=[];for(const r of t){const i=Oe(`${ze}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=et(`${mt}${e}`);for(const n of t){const r=Oe(`${ze}${n}`);r&&Mt(`${Rt}${r.meta.playthroughId}`,n),Fe(`${ze}${n}`)}Fe(`${mt}${e}`)},async deleteSavesByPlaythrough(e){const t=et(`${Rt}${e}`);for(const n of t){const r=Oe(`${ze}${n}`);r&&Mt(`${mt}${r.meta.ifid}`,n),Fe(`${ze}${n}`)}return Fe(`${Rt}${e}`),t},async putPlaythrough(e){qt(`${Tt}${e.id}`,e),Jn(`${Nt}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){const t=et(`${Nt}${e}`),n=[];for(const r of t){const i=Oe(`${Tt}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=et(`${Nt}${e}`);for(const n of t)Fe(`${Tt}${n}`);Fe(`${Nt}${e}`)},async deletePlaythroughById(e){const t=Oe(`${Tt}${e}`);t&&Mt(`${Nt}${t.ifid}`,e),Fe(`${Tt}${e}`)},async getMeta(e){return Oe(`${Je}${e}`)},async setMeta(e,t){qt(`${Je}${e}`,t)},async deleteMeta(e){Fe(`${Je}${e}`)},async deleteMetaByPrefix(e){const t=`${Je}${e}`;for(const n of Object.keys(localStorage))n.startsWith(t)&&localStorage.removeItem(n)},async deleteMetaByIfid(e){for(const t of Object.keys(localStorage))t.startsWith(Je)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){const e=[];for(const t of Object.keys(localStorage))t.startsWith(Je)&&e.push(t.slice(Je.length));return e},async destroy(){for(const e of Object.keys(localStorage))e.startsWith(\"spindle.\")&&localStorage.removeItem(e)}}}const Zi=\"spindle\",Of=1;function Lf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Zi,Of);s.onupgradeneeded=()=>{const l=s.result;if(!l.objectStoreNames.contains(\"saves\")){const u=l.createObjectStore(\"saves\",{keyPath:\"meta.id\"});u.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),u.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}l.objectStoreNames.contains(\"playthroughs\")||l.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),l.objectStoreNames.contains(\"meta\")||l.createObjectStore(\"meta\",{keyPath:\"key\"})},s.onsuccess=()=>a(s.result),s.onerror=()=>o(s.error)}),e)}function n(a,o){return t().then(s=>s.transaction(a,o).objectStore(a))}function r(a){return new Promise((o,s)=>{a.onsuccess=()=>o(a.result),a.onerror=()=>s(a.error)})}async function i(a,o,s){const u=(await n(a,\"readonly\")).index(o);return await r(u.getAll(s))??[]}return{type:\"indexeddb\",async putSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.put(a))},async getSave(a){const o=await n(\"saves\",\"readonly\");return await r(o.get(a))??void 0},async deleteSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.delete(a))},async getSavesByIfid(a){return i(\"saves\",\"ifid\",a)},async deleteSavesByIfid(a){const o=await i(\"saves\",\"ifid\",a),s=await n(\"saves\",\"readwrite\");for(const l of o)await r(s.delete(l.meta.id))},async deleteSavesByPlaythrough(a){const o=await i(\"saves\",\"playthroughId\",a),s=await n(\"saves\",\"readwrite\"),l=[];for(const u of o)await r(s.delete(u.meta.id)),l.push(u.meta.id);return l},async putPlaythrough(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.put(a))},async getPlaythroughsByIfid(a){return i(\"playthroughs\",\"ifid\",a)},async deletePlaythroughsByIfid(a){const o=await i(\"playthroughs\",\"ifid\",a),s=await n(\"playthroughs\",\"readwrite\");for(const l of o)await r(s.delete(l.id))},async deletePlaythroughById(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.delete(a))},async getMeta(a){const o=await n(\"meta\",\"readonly\"),s=await r(o.get(a));return s?s.value:void 0},async setMeta(a,o){const s=await n(\"meta\",\"readwrite\");await r(s.put({key:a,value:o}))},async deleteMeta(a){const o=await n(\"meta\",\"readwrite\");await r(o.delete(a))},async deleteMetaByPrefix(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.startsWith(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async deleteMetaByIfid(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.includes(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async getAllMetaKeys(){const a=await n(\"meta\",\"readonly\");return(await r(a.getAll())).map(s=>s.key)},async destroy(){(await t()).close(),e=null,await new Promise((o,s)=>{const l=indexedDB.deleteDatabase(Zi);l.onsuccess=()=>o(),l.onerror=()=>s(l.error)})}}}let bt=null;async function Bf(){if(typeof indexedDB<\"u\")try{return await new Promise((e,t)=>{const n=indexedDB.open(\"__spindle_probe__\",1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(\"__spindle_probe__\"),e()},n.onerror=()=>t(n.error)}),Lf()}catch{}if(typeof localStorage<\"u\")try{const e=\"__spindle_probe__\";localStorage.setItem(e,\"1\");const t=localStorage.getItem(e);if(localStorage.removeItem(e),t===\"1\")return Ff()}catch{}return zf()}async function J(){return bt||(bt=await Bf(),bt)}function Vf(){bt=null}function ea(){return bt?.type??\"memory\"}const Io=new Map,Vn=new Map;function Hf(e,t){Io.set(e,t),Vn.set(t,e)}function qf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ie(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 l=0;l<r.length;l++)s[l]=n(r[l]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[l,u]of r)s.set(n(l),n(u));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const l of r)s.add(n(l));return s}const a=i.constructor;if(Vn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}if(qf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}return r}return n(e)}const tt=\"__spindle_class__\",nt=\"__spindle_data__\";function it(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),{[tt]:\"__Date__\",[nt]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[tt]:\"__RegExp__\",[nt]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const l=r.map(u=>n(u));return t.delete(i),l}if(r instanceof Map){const l=[...r].map(([u,f])=>[n(u),n(f)]);return t.delete(i),{[tt]:\"__Map__\",[nt]:{entries:l}}}if(r instanceof Set){const l=[...r].map(u=>n(u));return t.delete(i),{[tt]:\"__Set__\",[nt]:{entries:l}}}const a=i.constructor,o=Vn.get(a);if(o!==void 0){const l={};for(const u of Object.keys(i))l[u]=n(i[u]);return t.delete(i),{[tt]:o,[nt]:l}}const s={};for(const l of Object.keys(i))s[l]=n(i[l]);return t.delete(i),s}return n(e)}function at(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(tt in r&&nt in r){const o=r[tt],s=r[nt];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const f=s.entries;return new Map(f.map(([c,p])=>[t(c),t(p)]))}if(o===\"__Set__\"){const f=s.entries;return new Set(f.map(c=>t(c)))}const l=Io.get(o);if(!l){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 u=Object.create(l.prototype);for(const f of Object.keys(s))u[f]=t(s[f]);return u}const i=r.constructor;if(Vn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Cr=null,Ir=null,ta=!1;function Uf(e){Cr=e}function jf(e){Ir=e}function Wf(e){if(Ir)try{const i=new Function(\"passage\",\"variables\",Ir)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Cr)try{const r=Cr(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 Kf(){ta||(ta=!0)}async function na(e){const t=await J(),r=(await t.getPlaythroughsByIfid(e)).length+1,i=crypto.randomUUID(),a={id:i,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await t.putPlaythrough(a),await t.setMeta(`currentPlaythroughId.${e}`,i),i}async function Qf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function Po(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Wf(n),passage:n.passage,custom:r},o=ie(n);o.variables=it(o.variables),o.history=o.history.map(l=>({...l,variables:it(l.variables)}));const s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function Eo(e,t,n){const r=await J(),i=await r.getSave(e);if(!i)return;const a=ie(t);a.variables=it(a.variables),a.history=a.history.map(s=>({...s,variables:it(s.variables)}));const o={meta:{...i.meta,updatedAt:new Date().toISOString(),passage:t.passage,...n!=null?{custom:{...i.meta.custom,...n}}:{}},payload:a};return o.meta.estimatedBytes=JSON.stringify(a).length,await r.putSave(o),o}async function Gf(e){const t=await(await J()).getSave(e);if(!t)return;const n=t.payload;return n.variables=at(n.variables),n.history=n.history.map(r=>({...r,variables:at(r.variables)})),n}async function Yf(e){await(await J()).deleteSave(e)}async function Jf(e,t){const n=await J(),r=await n.getSave(e);if(!r)return;const i={...r,meta:{...r.meta,title:t,updatedAt:new Date().toISOString()}};await n.putSave(i)}async function Xf(e){const t=await J(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(const l of r)i.set(l.id,l);const a=new Map;for(const l of n){const u=l.meta.playthroughId,f=a.get(u);f?f.push(l):a.set(u,[l])}for(const l of a.values())l.sort((u,f)=>new Date(f.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const o=[],s=[...i.values()].sort((l,u)=>new Date(u.createdAt).getTime()-new Date(l.createdAt).getTime());for(const l of s){const u=a.get(l.id)??[];o.push({playthrough:l,saves:u})}for(const[l,u]of a)i.has(l)||o.push({playthrough:{id:l,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const Zf=\"autosave.\",ed=\"slot.\",Hn=\"slotIndex.\";function ln(e,t){return t!=null?`${ed}${t}.${e}`:`${Zf}${e}`}async function td(e,t,n,r,i){const a=await J(),o=ln(e,r),s=await a.getMeta(o);if(s){const u=await Eo(s,n,i);if(u)return u}const l=await Po(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,l.meta.id),r!=null){const u=`${Hn}${e}`,f=await a.getMeta(u)??[];f.includes(r)||await a.setMeta(u,[...f,r])}return l}async function ra(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function nd(e,t){const n=ln(e,t),r=await(await J()).getMeta(n);if(r)return Gf(r)}async function Pr(e){const t={};await ra(e)&&(t[\"\"]=!0);const n=`${Hn}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await ra(e,i)&&(t[i]=!0);return t}async function Er(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(!i)return null;const a=await n.getSave(i);return a?{slot:t??\"\",title:a.meta.title,passage:a.meta.passage,createdAt:a.meta.createdAt,updatedAt:a.meta.updatedAt,custom:a.meta.custom??{}}:null}async function rd(e){const t=[],n=await Er(e);n&&t.push(n);const r=`${Hn}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await Er(e,a);o&&t.push(o)}return t}async function id(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${Hn}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Gr=\"spindle.session.\";function ad(e,t){try{sessionStorage.setItem(`${Gr}${e}`,JSON.stringify(t))}catch{}}function od(e){try{const t=sessionStorage.getItem(`${Gr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Mf(n))return;const r=n;return r.variables=at(r.variables),r.history=r.history.map(i=>({...i,variables:at(i.variables)})),r}catch{return}}function Ao(e){try{sessionStorage.removeItem(`${Gr}${e}`)}catch{}}async function sd(e){const t=await(await J()).getSave(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function ld(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=await J(),r=ie(e.save);if(r.meta.id=crypto.randomUUID(),r.meta.updatedAt=new Date().toISOString(),!(await n.getPlaythroughsByIfid(t)).some(o=>o.id===r.meta.playthroughId)){const o={id:r.meta.playthroughId,ifid:t,createdAt:r.meta.createdAt,label:\"Imported\"};await n.putPlaythrough(o)}return await n.putSave(r),r}async function ud(e){const t=await J(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e);let i=0;for(const a of n)if(a.meta.estimatedBytes!=null)i+=a.meta.estimatedBytes;else{const o=JSON.stringify(a.payload).length;a.meta.estimatedBytes=o,await t.putSave(a),i+=o}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}}async function $o(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Ao(e)}async function Do(){if(await(await J()).destroy(),Vf(),typeof sessionStorage<\"u\"){const t=[];for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);r?.startsWith(\"spindle.session.\")&&t.push(r)}for(const n of t)sessionStorage.removeItem(n)}}async function To(e,t){const n=await J(),r=await n.deleteSavesByPlaythrough(t);await n.deletePlaythroughById(t);const i=new Set(r),a=await n.getAllMetaKeys();for(const l of a)if(l.startsWith(\"slot.\")||l.startsWith(\"autosave.\")){const u=await n.getMeta(l);u&&i.has(u)&&await n.deleteMeta(l)}const o=`currentPlaythroughId.${e}`;await n.getMeta(o)===t&&await n.deleteMeta(o)}function No(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=Ct(t.content),i=It(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),Pe(Y(()=>Ee(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&jf(n.content)}const cd=new Set([\"storyinit\",\"beforerestart\",\"actionsChanged\",\"variableChanged\",\"beforesave\",\"aftersave\",\"beforeload\",\"afterload\",\"beforenavigate\",\"afternavigate\"]);let Ar=new Map;function fd(e,t){if(!cd.has(e))throw new Error(`spindle: Unknown event \"${e}\".`);let n=Ar.get(e);return n||(n=new Set,Ar.set(e,n)),n.add(t),()=>{n.delete(t)}}function ce(e,...t){const n=Ar.get(e);if(n)for(const r of[...n])r(...t)}let Ro=0,Se=[],Xn=!1,ft=[],Ut=null,He=null;function Yr(e){const t=C.getState();try{return!!Et(e,t.variables,t.temporary)}catch{return!1}}function Mo(e,t){const n=Ro++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Yr(e),priority:i?.priority??0};return Se.push(o),Se.sort((s,l)=>l.priority-s.priority),()=>{Se=Se.filter(s=>s.id!==n)}}function zo(e){Se=Se.filter(t=>t.name!==e)}function dd(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();so(n.run,r.variables,r.temporary)}n.dialog&&(ft.push({passageName:n.dialog}),Ut?.()),n.goto&&C.getState().navigate(n.goto)}}const hd=10;function pd(){if(!Xn){Xn=!0;try{for(let e=0;e<hd;e++){let t=!1;const n=[...Se];for(const r of n){if(!Se.includes(r))continue;const i=Yr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(Se=Se.filter(o=>o.id!==r.id)),dd(r))}if(!t)break}}finally{Xn=!1}}}function gd(){for(const e of Se)e.lastResult=Yr(e.condition)}function md(){Se=[],ft=[],Ro=0,He?.closeAll()}function yd(e){return Ut=e,ft.length>0&&e(),()=>{Ut===e&&(Ut=null)}}function _d(){return ft.shift()}function bd(){return ft.length}function vd(e){He?He.push(e):(ft.push(e),Ut?.())}function wd(){ft=[]}function Sd(e){return He=e,()=>{He===e&&(He=null)}}function kd(){He?.close()}function xd(){wd(),He?.closeAll()}function Cd(){return He?.isOpen()??!1}Cl();const Id=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let rt={},ve=[],We={};function ia(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function aa(e,t){const[,n,r]=Pl(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:ia(n),inverse:ia(r)}}function Pd(e){let t=rt;for(let n=0;n<e;n++)t=_t(t,ve[n].forward);return t}let we=[];function Zn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(we.length>i.length&&(we.length=i.length),we.length<i.length)if(i.length-we.length===1){const u=i.length-1;we[u]={passage:i[u].passage,variables:it(r),timestamp:i[u].timestamp,prng:i[u].prng}}else{let u=rt;for(let f=0;f<i.length;f++)if(f>0&&(u=_t(u,ve[f-1].forward)),f>=we.length){const c=f===i.length-1?r:u;we[f]={passage:i[f].passage,variables:it(c),timestamp:i[f].timestamp,prng:i[f].prng}}}ad(t.ifid,{passage:n,variables:it(r),history:we,historyIndex:a,visitCounts:o,renderCounts:s,prng:Tn()})}}function oa(e){rt=e,ve=[],We=e,we=[]}let $r=[],Jr=!1;function Ed(e){Jr&&$r.push(e)}function Fo(){Jr=!0}function Ad(){for(const e of $r)e();$r=[],Jr=!1}function sa(e){e?.prng?ro(e.prng.seed,e.prng.pull):e&&_r()}const C=ll()(Al((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=ie(r);oa(ie(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),We=t().variables;const o=n.ifid;Kf().then(async()=>{const s=await Qf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await na(o);e(f=>{f.playthroughId=u})}const l=await Pr(o);Object.keys(l).length>0&&e(u=>{u.knownSaves=l})}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Id.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=t().currentPassage;ce(\"beforenavigate\",n);const o=aa(We,i);e(s=>{s.temporary={},s.currentPassage=n,s.history=s.history.slice(0,s.historyIndex+1),ve.length=s.historyIndex,ve.push(o),s.history.push({passage:n,timestamp:Date.now(),prng:Tn()});const l=s.history.length-s.maxHistory;if(l>0){for(let u=0;u<l;u++)rt=_t(rt,ve[u].forward);s.history=s.history.slice(l),ve=ve.slice(l),we=we.slice(l)}s.historyIndex=s.history.length-1,s.visitCounts[n]=(s.visitCounts[n]??0)+1,s.renderCounts[n]=(s.renderCounts[n]??0)+1}),We=t().variables,Zn(t),ce(\"afternavigate\",n,a)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=t().currentPassage,a=t().history[n-1].passage;ce(\"beforenavigate\",a);const o=ie(_t(r,ve[n-1].inverse));e(s=>{s.historyIndex--,s.currentPassage=s.history[s.historyIndex].passage,s.variables=o,s.temporary={}}),We=t().variables,sa(t().history[t().historyIndex]),Zn(t),ce(\"afternavigate\",a,i)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=t().currentPassage,o=r[n+1].passage;ce(\"beforenavigate\",o);const s=ie(_t(i,ve[n].forward));e(l=>{l.historyIndex++,l.currentPassage=l.history[l.historyIndex].passage,l.variables=s,l.temporary={}}),We=t().variables,sa(t().history[t().historyIndex]),Zn(t),ce(\"afternavigate\",o,a)},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;e(s=>{s.renderDeferred=!1}),ce(\"beforerestart\");const a=t().renderDeferred;Ad(),_r(),md();const o=ie(r);oa(ie(o)),e(s=>{s.currentPassage=i.name,s.variables=o,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1},a||(s.renderDeferred=!1)}),We=t().variables,Fo(),No(),Ao(n.ifid),ce(\"storyinit\"),na(n.ifid).then(s=>{e(l=>{l.playthroughId=s})}).catch(s=>console.error(\"spindle: failed to start new playthrough\",s))},save:(n,r)=>{const{storyData:i,playthroughId:a}=t();if(!i)return;ce(\"beforesave\",n,r);const o=t().getSavePayload();e(s=>{s.saveError=null}),td(i.ifid,a,o,n,r).then(()=>{e(s=>{s.knownSaves={...s.knownSaves,[n??\"\"]:!0}}),ce(\"aftersave\",n)}).catch(s=>{console.error(\"spindle: failed to save\",s),e(l=>{l.saveError=s instanceof Error?s.message:\"Failed to save\"})})},load:n=>{const{storyData:r}=t();r&&(e(i=>{i.loadError=null}),nd(r.ifid,n).then(i=>{i&&t().loadFromPayload(i)}).catch(i=>{console.error(\"spindle: failed to load save\",i),e(a=>{a.loadError=i instanceof Error?i.message:\"Failed to load\"})}))},hasSave:n=>{const{storyData:r,knownSaves:i}=t();return r?(n??\"\")in i:!1},getSaveInfo:async n=>{const{storyData:r}=t();return r?Er(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?rd(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&id(r.ifid,n).then(()=>{e(i=>{const a=n??\"\",{[a]:o,...s}=i.knownSaves;i.knownSaves=s})}).catch(i=>{console.error(\"spindle: failed to delete save\",i)})},clearGameData:()=>{const{storyData:n}=t();n&&$o(n.ifid).then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear game data\",r)})},clearAllData:()=>{const{storyData:n}=t();n&&Do().then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear all data\",r)})},deletePlaythrough:n=>{const{storyData:r}=t();r&&To(r.ifid,n).then(async()=>{const i=await Pr(r.ifid);e(a=>{a.knownSaves=i})}).catch(i=>{console.error(\"spindle: failed to delete playthrough\",i)})},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),l=[];let u=rt;for(let f=0;f<i.length;f++)f>0&&(u=_t(u,ve[f-1].forward)),l.push({passage:i[f].passage,variables:ie(u),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:ie(r),history:l,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:Tn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}ce(\"beforeload\",void 0);const r=at(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=at(n.history[o].variables);i.push(aa(a,s)),a=s}rt=ie(r),ve=i,we=[],e(o=>{o.currentPassage=n.passage,o.variables=at(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=Math.max(0,Math.min(n.historyIndex,o.history.length-1)),o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),We=t().variables,n.prng?ro(n.prng.seed,n.prng.pull):_r(),ce(\"afterload\",void 0)},getHistoryVariables:n=>ie(Pd(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n},deferRender:()=>{e(n=>{n.renderDeferred=!0})},clearDeferredRender:()=>{e(n=>{n.renderDeferred=!1})}}))),$d=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Dd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:$d,r=t?.tags.includes(\"nobr\")??!1,i=pe(()=>{try{const a=Ct(n),o=It(a);return w(G,{children:Qr(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(de.Provider,{value:!0,children:i}):i}const Oo=Qe(null);function Xr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=se(r);a.current=r;const o=ge(()=>a.current(),[]),s=C(d=>d.storyData),u=(e?s?.passages.get(e):void 0)?.content??t,f=pe(()=>{if(!u)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const d=Ct(u),h=It(d);return Ee(h)}catch(d){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",d instanceof Error?d.message:String(d)]})}},[u]),c=d=>{d.target.classList.contains(\"dialog-overlay\")&&o()},p=n?`dialog-panel ${n}`:\"dialog-panel\";return w(Oo.Provider,{value:o,children:w(\"div\",{class:\"dialog-overlay\",onClick:c,children:w(\"div\",{class:p,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:f})]})})})}function Td(){const[e,t]=ee([]),n=se(e);n.current=e;const r=ge(o=>{t(s=>[...s,o])},[]),i=ge(()=>{t(o=>o.slice(0,-1))},[]),a=ge(()=>{t([])},[]);return ke(()=>Sd({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),ke(()=>yd(()=>{const o=[];for(;bd()>0;){const s=_d();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(G,{children:e.map((o,s)=>w(Xr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function Nd(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(ke(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(G,{children:[w(Dd,{}),w(Td,{})]});return n?w(de.Provider,{value:!0,children:r}):r}function Rd(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Md(){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||\"\",u=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const p of e.querySelectorAll(\"tw-passagedata\")){const d=parseInt(p.getAttribute(\"pid\")||\"0\",10),h=p.getAttribute(\"name\")||\"\",y=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),k=Rd(p.innerHTML),_={},S=new Set([\"pid\",\"name\",\"tags\"]);for(const E of p.attributes)S.has(E.name)||(_[E.name]=E.value);const x={pid:d,name:h,tags:y,metadata:_,content:k};f.set(h,x),c.set(d,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:u}}const zt=new Map;let fe={},la=!1;function Lo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function zd(){localStorage.setItem(Lo(),JSON.stringify(fe))}function er(){if(!la){la=!0;try{const e=localStorage.getItem(Lo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(fe={...fe,...t})}}catch{}}}const Jt={addToggle(e,t){zt.set(e,{type:\"toggle\",config:t}),e in fe||(fe[e]=t.default),er()},addList(e,t){zt.set(e,{type:\"list\",config:t}),e in fe||(fe[e]=t.default),er()},addRange(e,t){zt.set(e,{type:\"range\",config:t}),e in fe||(fe[e]=t.default),er()},get(e){return fe[e]},getToggle(e){const t=fe[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=fe[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=fe[e];return typeof t==\"number\"?t:0},set(e,t){fe[e]=t,zd()},getAll(){return{...fe}},getDefinitions(){return zt},hasAny(){return zt.size>0}};function Fd(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};so(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]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const Rn=new Map,Dr=new Map;function Od(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Dr.get(r)??0)+1;return Dr.set(r,i),i===1?r:`${r}:${i}`}function Ld(e){return Rn.set(e.id,e),ca(),()=>{Rn.delete(e.id),ca()}}function ua(){return Array.from(Rn.values())}function Bd(e){return Rn.get(e)}function Vd(){Dr.clear()}function ca(){ce(\"actionsChanged\")}function Hd(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=Od(e.type,e.key,e.authorId));const r=t.current;return ct(()=>{const i={id:r,type:e.type,label:e.label,perform:(...a)=>n.current(...a)};return e.target!==void 0&&(i.target=e.target),e.variable!==void 0&&(i.variable=e.variable),e.options!==void 0&&(i.options=e.options),e.value!==void 0&&(i.value=e.value),e.disabled!==void 0&&(i.disabled=e.disabled),Ld(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function qd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Bo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Zr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Bo(t):\"\"}function Ud(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 jd(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 Wd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Kd={useState:ee,useRef:se,useEffect:ke,useLayoutEffect:ct,useCallback:ge,useMemo:pe,useContext:Q};function fa(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function Qd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=On(),a=s(a),o=s(o));const{update:l,getValues:u}=Q(sn),f=Q(de),c=Q(xe),d={collectText:qd,sourceLocation:Zr,parseVarArgs:Ud,extractOptions:jd,h:Y,renderNodes:(h,y)=>Ee(h,{nobr:f,locals:c,...y}),renderInlineNodes:Qr,hooks:Kd,useAction:Hd,className:a,id:o,resolve:s,cls:Wd(e.name,a),mutate:h=>Fd(h,u(),l),update:l,getValues:u,wrap:h=>a||o?Y(\"span\",{id:o,class:a},h):Y(G,null,h)};if(e.merged){d.merged=Ur();const h=d.merged;d.evaluate=y=>Et(y,h[0],h[1],h[2])}if(e.storeVar){const y=(i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),k=y.split(\".\");d.varName=y,d.value=C(_=>fa(_.variables,k)),d.getValue=()=>fa(C.getState().variables,k),d.setValue=_=>{C.setState(S=>{Qd(S.variables,k,_)})}}return e.render(i,d)}au(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(uu(e.name,{name:e.name,block:r,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters,source:t}),e.subMacros)for(const i of e.subMacros)su(i);r&&yr(e.name)}let gn=null,Tr=null;function Gd(){return Tr}let da=!1;function Yd(){if(da)return;da=!0;let e={...C.getState().variables};C.subscribe(t=>{const n={};let r=!1;const i=new Set([...Object.keys(e),...Object.keys(t.variables)]);for(const a of i)t.variables[a]!==e[a]&&(n[a]={from:e[a],to:t.variables[a]},r=!0);e={...t.variables},r&&ce(\"variableChanged\",n)})}function Jd(){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,t){C.getState().save(e,t)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},getSaveInfo(e){return C.getState().getSaveInfo(e)},listSaves(){return C.getState().listSaves()},deleteSave(e){C.getState().deleteSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>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){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>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:Jt,registerClass(e,t){Hf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return cu()},saves:{setTitleGenerator(e){Uf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?ud(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:ea()}},async getQuota(){if(typeof navigator<\"u\"&&navigator.storage?.estimate)try{const e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},async clearGameData(){const e=C.getState().storyData?.ifid;e&&(await $o(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await Do(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await To(t.ifid,e);const n=await Pr(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return ea()}},getActions(){return ua()},performAction(e,t){const n=Bd(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){e===\"variableChanged\"&&Yd();const n=fd(e,t);return Ed(n),n},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ua())})})})},watch(e,t){return Mo(e,t)},unwatch(e){zo(e)},openDialog(e,t){vd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){kd()},closeAllDialogs(){xd()},isDialogOpen(){return Cd()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Tr=new Promise(e=>{gn=e})},ready(){gn&&(C.getState().clearDeferredRender(),gn(),gn=null,Tr=null)},random(){return jr()},randomInt(e,t){return io(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){Ml(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=Tn())})},isEnabled(){return zl()},get seed(){return Fl()},get pull(){return Ol()}}}}function Xd(){window.Story=Jd()}const Zd=/^\\$(\\w+)\\s*=\\s*(.+)$/,ha=/\\$(\\w+(?:\\.\\w+)*)/g,pa=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,eh=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(!eh.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function th(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Zd);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(u){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${u instanceof Error?u.message:u}`)}const l=Vo(s);t.set(a,{...l,name:a,default:s})}return t}function nh(e){const t=new Set;let n;for(pa.lastIndex=0;(n=pa.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function rh(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 l=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${l}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const u=o.fields.get(l);if(!u)return null;o=u}return null}function ih(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=nh(i.content);let o;for(ha.lastIndex=0;(o=ha.exec(i.content))!==null;){const s=o[1],l=rh(s,t,a);l&&n.push(`Passage \"${r}\": ${l}`)}}return n}function ah(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function wn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&wn(t.children))return!0;if(t.type===\"macro\"){if(wn(t.children))return!0;if(t.branches){for(const n of t.branches)if(wn(n.children))return!0}}}return!1}function Ue({macro:e,error:t}){return w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Zr()}: ${t instanceof Error?t.message:String(t)}}`})}B({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1),r=t.hooks.useRef(null);if(!n.current){n.current=!0;try{t.mutate(e)}catch(i){r.current=i,console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,i)}}return r.current?w(Ue,{macro:\"set\",error:r.current}):null}});B({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 w(Ue,{macro:\"print\",error:n})}}});function oh(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 sh(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 ga(e,t,n,r,i,a,o){let s;try{s=Et(e,r,i,a)}catch(u){console.error(`spindle: Error in {computed ${o}}${Zr()}:`,u);return}const l=n?i[t]:r[t];if(!sh(l,s)){const u=C.getState();n?u.setTemporary(t,s):u.setVariable(t,s)}}B({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=oh(e))}catch(f){return w(Ue,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),l=a.slice(1),u=t.hooks.useRef(!1);return u.current||(u.current=!0,ga(o,l,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{ga(o,l,s,n,r,i,e)},[n,r,i]),null}});function lh(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=uh(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 uh(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 ch(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}B({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=lh(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),l=ch(a,o,i),u=t.cls;return w(\"div\",{class:u,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),l!=null&&w(\"span\",{class:\"macro-meter-label\",children:l})]})}catch(n){return w(Ue,{macro:\"meter\",error:n})}}});B({name:\"if\",block:!0,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?w(\"span\",{id:o,class:a,children:i}):w(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 w(Ue,{macro:\"if\",error:i})}}return null}});function fh(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 dh({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=ee(()=>({...n})),o={...e,...t,...i},s=se(o);s.current=o;const l=ge(()=>s.current,[]),u=ge((p,d)=>{a(h=>({...h,[p]:d}))},[]),f=pe(()=>({update:u,getValues:l}),[u,l]),c=Q(de);return w(sn.Provider,{value:f,children:w(xe.Provider,{value:o,children:Ee(r,{nobr:c,locals:o})})})}B({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=Q(xe);let i;try{i=fh(e)}catch(f){return w(Ue,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let l;try{const f=n.evaluate(s);if(!Array.isArray(f))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});l=f}catch(f){return w(Ue,{macro:\"for\",error:f})}const u=l.map((f,c)=>{const p={[a]:f,...o?{[o]:c}:void 0};return w(dh,{parentValues:r,ownKeys:p,initialValues:{},children:t},`${c}-${JSON.stringify(f)}`)});return n.wrap(u)}});B({name:\"do\",block:!0,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}});B({name:\"button\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=Q(de),a=()=>{const o=document.createElement(\"div\"),s=Y(de.Provider,{value:i},Y(sn.Provider,{value:{update:n.update,getValues:n.getValues}},Y(xe.Provider,{value:n.getValues()},Ee(t))));Pe(s,o),Pe(null,o)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:a}),w(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function hh(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function ma(e,t,n,r){const i=document.createElement(\"div\"),a=Y(de.Provider,{value:r},Y(sn.Provider,{value:{update:n,getValues:t}},Y(xe.Provider,{value:t()},Ee(e))));Pe(a,i),Pe(null,i)}B({name:\"link\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=hh(e),a=Q(de),o=s=>{s.preventDefault(),ma(t,n.getValues,n.update,a),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{ma(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});B({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(Ue,{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 w(G,{children:n.renderNodes(o.children)})}catch(s){return w(Ue,{macro:\"case\",error:s})}}return i?w(G,{children:n.renderNodes(i.children)}):null}});function ei(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)}B({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?ei(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,y=setTimeout(()=>{s(d)},h);return()=>clearTimeout(y)},[o,a]),o<0)return t.wrap(null);const l=a[o],u=t.renderNodes(l.nodes),f=t.resolve(l.className),c=t.resolve(l.id),p=f||c?w(\"span\",{id:c,class:f,children:u}):u;return t.wrap(p)}});const Ho=Qe({stop:()=>{}});B({name:\"repeat\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=ei(e),[s,l]=r(0),[u,f]=r(!1),c=a(()=>f(!0),[]);if(i(()=>{if(u)return;const d=setInterval(()=>{l(h=>h+1)},o);return()=>clearInterval(d)},[o,u]),s===0&&!u)return null;const p=w(Ho.Provider,{value:{stop:c},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:p}):p}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Ho);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});B({name:\"type\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=ei(e),s=a(null),[l,u]=r(0),[f,c]=r(0),p=a(0);p.current=f,i(()=>{if(s.current){const y=s.current.textContent||\"\";u(y.length)}},[]),i(()=>{if(l===0||p.current>=l)return;const y=setInterval(()=>{c(k=>k>=l?(clearInterval(y),k):k+1)},o);return()=>clearInterval(y)},[l,o]);const d=f>=l&&l>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(l>0&&!d,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:l===0?\"hidden\":\"visible\",clipPath:l>0&&!d?`inset(0 ${(l-f)/l*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&l>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function ph(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}}B({name:\"widget\",block:!0,render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=ph(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{uo(r,t,i)},[r,a,o]),null}});B({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function dt(e){B({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=ee(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",l=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}),w(G,{children:[w(\"button\",{id:n.id,class:s,onClick:l,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Xr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}dt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});dt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});dt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});dt({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.knownSaves),{perform:()=>e(),disabled:!t()}}});dt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});dt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});dt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Jt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});B({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,l=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Xr,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function gh(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 mh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function yh(){const[e,t]=ee(\"load\"),[n,r]=ee([]),[i,a]=ee(!0),[o,s]=ee(null),[l,u]=ee(()=>new Set),[f,c]=ee(null),[p,d]=ee(\"\"),h=se(null),y=se(null),k=Q(Oo),_=C(R=>R.storyData),S=C(R=>R.playthroughId),x=C(R=>R.getSavePayload),E=C(R=>R.loadFromPayload),I=_?.ifid??\"\",b=ge(async()=>{if(!I)return;const R=await Xf(I);r(R),a(!1)},[I]);ke(()=>{b()},[b]),ke(()=>{f&&h.current&&(h.current.focus(),h.current.select())},[f]);const $=se(),A=(R,j=\"success\")=>{clearTimeout($.current),s({text:R,type:j}),$.current=window.setTimeout(()=>s(null),3e3)};ke(()=>()=>clearTimeout($.current),[]);const D=R=>{u(j=>{const g=new Set(j);return g.has(R)?g.delete(R):g.add(R),g})},v=async()=>{if(!(!I||!S))try{const R=x();await Po(I,S,R),A(\"Save created\"),await b()}catch{A(\"Failed to create save\",\"error\")}},T=async R=>{try{const j=x();await Eo(R,j),A(\"Save overwritten\"),await b()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async R=>{try{E(R.payload),A(\"Game loaded\"),k&&setTimeout(k,500)}catch{A(\"Failed to load save\",\"error\")}},V=async R=>{if(confirm(\"Delete this save?\"))try{await Yf(R),A(\"Save deleted\"),await b()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{c(R.meta.id),d(R.meta.title)},O=async()=>{if(!(!f||!p.trim()))try{await Jf(f,p.trim()),c(null),A(\"Save renamed\"),await b()}catch{A(\"Failed to rename\",\"error\")}},Z=R=>{R.key===\"Enter\"?O():R.key===\"Escape\"&&c(null)},X=async R=>{try{const j=await sd(R);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),ue=document.createElement(\"a\");ue.href=q,ue.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ue.click(),URL.revokeObjectURL(q),A(\"Save exported\")}catch{A(\"Failed to export save\",\"error\")}},me=()=>{y.current?.click()},Ce=async R=>{const j=R.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),ue=JSON.parse(q);if(!Rf(ue))throw new Error(\"Invalid save file format\");await ld(ue,I),A(\"Save imported\"),await b()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((R,j)=>R+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:me,children:\"Import\"}),w(\"input\",{ref:y,type:\"file\",accept:\".json\",style:\"display:none\",onChange:Ce})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(R=>{const j=l.has(R.playthrough.id),g=R.playthrough.id===S;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>D(R.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[R.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:mh(R.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[R.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?w(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>d(ue.target.value),onKeyDown:Z,onBlur:O}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:gh(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>T(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>X(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},R.playthrough.id)}),e===\"save\"&&!i&&!n.some(R=>R.playthrough.id===S)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return w(yh,{})}});function _h({name:e,def:t}){const[n,r]=ee(()=>Jt.get(e)),i=a=>{r(a),Jt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"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 bh(){const e=Jt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(_h,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(bh,{})}});B({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),l=Ct(o.content),u=It(l),f=r?t.renderInlineNodes(u):t.renderNodes(u,s?{nobr:!0}:void 0);return s?t.wrap(t.h(de.Provider,{value:!0},f)):t.wrap(f)}});B({name:\"nobr\",block:!0,render({children:e=[]},t){return t.wrap(t.h(de.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});B({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}});B({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)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _name, or @name), got \"${i}\"`)}return null}});B({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):\"\")}),w(\"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)})}});B({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)}),w(\"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))}})}});B({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):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function vh(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=vh(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function wh(e){const t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}B({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=wh(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({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))}}),w(\"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=>w(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};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()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Ot(e){const t=Ct(e.content),n=It(t),r=e.tags.includes(\"nobr\");return Ee(n,r?{nobr:!0}:void 0)}const Sh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function kh({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=Sh.has(e.name),[i,a]=ee(!1),o=pe(()=>{try{return Ot(e)}catch(y){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Bo(e),\":\",\" \",y instanceof Error?y.message:String(y)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),l=r?void 0:n?.passages.get(\"PassageFooter\"),u=r?void 0:n?.passages.get(\"PassageDone\"),f=pe(()=>{if(!s)return null;try{return Ot(s)}catch(y){return console.error(\"spindle: Error in PassageHeader:\",y),null}},[s?.content]),c=pe(()=>{if(!l)return null;try{return Ot(l)}catch(y){return console.error(\"spindle: Error in PassageFooter:\",y),null}},[l?.content]);ke(()=>(u&&a(!0),()=>a(!1)),[e.name]);const p=pe(()=>{if(!i||!u)return null;try{return Ot(u)}catch(y){return console.error(\"spindle: Error in PassageDone:\",y),null}},[i,u?.content]),d=e.tags.includes(\"nobr\"),h=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&w(\"div\",{class:\"passage-header\",children:f}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),p&&w(\"div\",{hidden:!0,children:p})]});return d?w(de.Provider,{value:!0,children:h}):h}const xh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Nr={type:\"fade-through\",duration:300,pause:50};function Ch(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!xh.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function tr(e){return{type:e.type,duration:e.duration??Nr.duration,pause:e.pause??Nr.pause}}function Ih(e,t,n){const r=Ch(e);return r?tr(r):t?tr(t):n?tr(n):{...Nr}}function ya(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function nr(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function rr(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(h=>h.currentPassage),r=C(h=>h.storyData),i=C(h=>h.renderDeferred),[a,o]=ee(n),s=se(\"fade\"),l=se(0),u=se(null),f=se([]),c=ge(()=>{for(const h of f.current)clearTimeout(h);f.current=[],rr(u.current)},[]);ke(()=>{const h=C.getState(),{history:y,historyIndex:k,transitionConfig:_}=h,S=h.consumeNextTransition(),x=l.current;l.current=y.length;const E=!a,I=y.length===1&&k===0&&x>1,b=y.length>1&&k===y.length-1&&x>1&&Math.abs(y.length-x)>1;if(n===a)return;c();const $=r?.passages.get(n);if(!$){s.current=\"none\",o(n);return}if(E||I||b){s.current=\"fade\",o(n);return}const A=Ih($.tags,S,_);s.current=A.type;const D=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){D&&nr(D,A),o(n);return}if(A.type===\"fade-through\"){if(!D){o(n);return}nr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ya(v,A.type);D.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{rr(D)},U);f.current=[V,O];return}if(A.type===\"crossfade\"){if(!D){o(n);return}nr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ya(v,A.type);D.classList.add(\"passage-container--crossfading\"),D.appendChild(T),o(n);const N=setTimeout(()=>{rr(D)},A.duration);f.current=[N];return}o(n)},[n]);const p=i?r?.passages.get(\"StoryLoading\")??null:a?r?.passages.get(a):null;if(!p&&a&&!i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",a,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[!i&&d&&w(\"div\",{hidden:!0,children:Ot(d)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:p&&w(kh,{passage:p,dataTransition:i?\"none\":s.current},i?\"loading\":a)})]})}});B({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},l=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let u;for(;(u=l.exec(o))!==null;){const c=u[1]??u[5],p=u[2]??u[3]??u[4];if(c)switch(c){case\"goto\":s.goto=p;break;case\"dialog\":s.dialog=p;break;case\"run\":s.run=p;break;case\"name\":s.name=p;break;case\"priority\":s.priority=p?Number(p):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,Mo(a,s)),null}});B({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,zo(r)),null}});const Ph='*,*: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-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.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}}';function _a(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 ba(){const e=Md(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Ph,document.head.appendChild(t),Xd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",y=document.getElementById(\"root\");throw y&&_a(y,[h]),new Error(`spindle: ${h}`)}const i=th(r.content),a=ih(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&_a(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=ah(i),C.getState().init(e,n),Fo(),No();const o=od(e.ifid);o&&C.getState().loadFromPayload(o),ce(\"storyinit\");const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){let y;for(;(y=s.exec(h.content))!==null;){const k=y[1],_=y[2];/\\{@children\\}/.test(_)&&yr(k)}s.lastIndex=0}for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const y=Ct(h.content),k=It(y);for(const _ of k)if(_.type===\"macro\"&&_.name===\"widget\"&&_.rawArgs){const S=_.rawArgs.trim().split(/\\s+/),x=S[0].replace(/[\"']/g,\"\"),E=S.slice(1).filter($=>$.startsWith(\"$\")||$.startsWith(\"_\")||$.startsWith(\"@\")),I=_.children,b=wn(I);uo(x,I,E,b),b&&yr(x)}}let l=\"\";C.subscribe(h=>{h.currentPassage!==l&&(l=h.currentPassage,Vd())});let u=C.getState().variables,f=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===f?pd():gd()),u=h.variables,f=h.historyIndex});const c=e.passages.get(\"StoryInterface\");c&&!c.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');Pe(w(Nd,{}),p);const d=Gd();d?d.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ba):ba();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.43.1","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xt,F,Sa,Ze,ui,ka,xa,Ca,Rr,ir,ar,Ia,Sn={},kn=[],_s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function Mr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(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?Xt.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 Lt(e,o,r,i,null)}function Lt(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??++Sa,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function bs(){return{current:null}}function Y(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function vt(e,t){if(t==null)return e.__?vt(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\"?vt(e):null}function vs(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Te({},t);a.__v=t.__v+1,F.vnode&&F.vnode(a),zr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??vt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,$a(r,a,i),t.__e=t.__=null,a.__e!=n&&Pa(a)}}function Pa(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}),Pa(e)}function or(e){(!e.__d&&(e.__d=!0)&&Ze.push(e)&&!xn.__r++||ui!=F.debounceRendering)&&((ui=F.debounceRendering)||ka)(xn)}function xn(){for(var e,t=1;Ze.length;)Ze.length>t&&Ze.sort(xa),e=Ze.shift(),t=Ze.length,vs(e);xn.__r=0}function Ea(e,t,n,r,i,a,o,s,l,u,f){var c,h,d,p,y,b,_,k=r&&r.__k||kn,x=t.length;for(l=ws(n,t,k,l,x),c=0;c<x;c++)(d=n.__k[c])!=null&&(h=d.__i!=-1&&k[d.__i]||Sn,d.__i=c,b=zr(e,d,h,i,a,o,s,l,u,f),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&Fr(h.ref,null,d),f.push(d.ref,d.__c||p,d)),y==null&&p!=null&&(y=p),(_=!!(4&d.__u))||h.__k===d.__k?l=Aa(d,l,e,_):typeof d.type==\"function\"&&b!==void 0?l=b:p&&(l=p.nextSibling),d.__u&=-7);return n.__e=y,l}function ws(e,t,n,r,i){var a,o,s,l,u,f=n.length,c=f,h=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]=Lt(null,o,null,null,null):Zt(o)?o=e.__k[a]=Lt(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Lt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+h,o.__=e,o.__b=e.__b+1,s=null,(u=o.__i=Ss(o,n,l,c))!=-1&&(c--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>f?h--:i<f&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):u!=l&&(u==l-1?h--:u==l+1?h++:(u>l?h--:h++,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=vt(s)),Ta(s,s));return r}function Aa(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=Aa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=vt(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ve(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Zt(e)?e.some(function(n){Ve(n,t)}):t.push(e)),t}function Ss(e,t,n,r){var i,a,o,s=e.key,l=e.type,u=t[n],f=u!=null&&(2&u.__u)==0;if(u===null&&s==null||f&&s==u.key&&l==u.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((u=t[o=i>=0?i--:a++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return o}return-1}function ci(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||_s.test(t)?n:n+\"px\"}function un(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||ci(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||ci(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Ca,\"$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=Rr,e.addEventListener(t,a?ar:ir,a)):e.removeEventListener(t,a?ar:ir,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 fi(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Rr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function zr(e,t,n,r,i,a,o,s,l,u){var f,c,h,d,p,y,b,_,k,x,E,I,v,D,A,$=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=F.__b)&&f(t);e:if(typeof $==\"function\")try{if(_=t.props,k=\"prototype\"in $&&$.prototype.render,x=(f=$.contextType)&&r[f.__c],E=f?x?x.props.value:f.__:r,n.__c?b=(c=t.__c=n.__c).__=c.__E:(k?t.__c=c=new $(_,E):(t.__c=c=new Ne(_,E),c.constructor=$,c.render=xs),x&&x.sub(c),c.state||(c.state={}),c.__n=r,h=c.__d=!0,c.__h=[],c._sb=[]),k&&c.__s==null&&(c.__s=c.state),k&&$.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Te({},c.__s)),Te(c.__s,$.getDerivedStateFromProps(_,c.__s))),d=c.props,p=c.state,c.__v=t,h)k&&$.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),k&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(k&&$.getDerivedStateFromProps==null&&_!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,E),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,E)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(w){w&&(w.__=t)}),kn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,p,y)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=F.__r,v=0,k)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),kn.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,I&&I(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=Te(Te({},r),c.getChildContext())),k&&!h&&c.getSnapshotBeforeUpdate!=null&&(y=c.getSnapshotBeforeUpdate(d,p)),D=f!=null&&f.type===Y&&f.key==null?Da(f.props.children):f,s=Ea(e,Zt(D)?D:[D],t,n,r,i,a,o,s,l,u),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),b&&(c.__E=c.__=null)}catch(w){if(t.__v=null,l||a!=null)if(w.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(A=a.length;A--;)Mr(a[A]);sr(t)}else t.__e=n.__e,t.__k=n.__k,w.then||sr(t);F.__e(w,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ks(n.__e,t,n,r,i,a,o,l,u);return(f=F.diffed)&&f(t),128&t.__u?void 0:s}function sr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(sr))}function $a(e,t,n){for(var r=0;r<n.length;r++)Fr(n[r],n[++r],n[++r]);F.__c&&F.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){F.__e(a,i.__v)}})}function Da(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Zt(e)?e.map(Da):Te({},e)}function ks(e,t,n,r,i,a,o,s,l){var u,f,c,h,d,p,y,b=n.props||Sn,_=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(u=0;u<a.length;u++)if((d=a[u])&&\"setAttribute\"in d==!!k&&(k?d.localName==k:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(k==null)return document.createTextNode(_);e=document.createElementNS(i,k,_.is&&_),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(k==null)b===_||s&&e.data==_||(e.data=_);else{if(a=a&&Xt.call(e.childNodes),!s&&a!=null)for(b={},u=0;u<e.attributes.length;u++)b[(d=e.attributes[u]).name]=d.value;for(u in b)d=b[u],u==\"dangerouslySetInnerHTML\"?c=d:u==\"children\"||u in _||u==\"value\"&&\"defaultValue\"in _||u==\"checked\"&&\"defaultChecked\"in _||un(e,u,null,d,i);for(u in _)d=_[u],u==\"children\"?h=d:u==\"dangerouslySetInnerHTML\"?f=d:u==\"value\"?p=d:u==\"checked\"?y=d:s&&typeof d!=\"function\"||b[u]===d||un(e,u,d,b[u],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Ea(t.type==\"template\"?e.content:e,Zt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&vt(n,0),s,l),a!=null)for(u=a.length;u--;)Mr(a[u]);s||(u=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[u]||k==\"progress\"&&!p||k==\"option\"&&p!=b[u])&&un(e,u,p,b[u],i),u=\"checked\",y!=null&&y!=e[u]&&un(e,u,y,b[u],i))}return e}function Fr(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){F.__e(i,n)}}function Ta(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Fr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){F.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ta(r[i],t,n||typeof e.type!=\"function\");n||Mr(e.__e),e.__c=e.__=e.__e=void 0}function xs(e,t,n){return this.constructor(e,n)}function Pe(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),F.__&&F.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],zr(t,e=(!r&&n||t).__k=G(Y,null,[e]),i||Sn,Sn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Xt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),$a(a,e,o)}function Na(e,t){Pe(e,t,Na)}function Cs(e,t,n){var r,i,a,o,s=Te({},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?Xt.call(arguments,2):n),Lt(e.type,s,r||e.key,i||e.ref,null)}function Ge(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,or(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\"+Ia++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Xt=kn.slice,F={__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}},Sa=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),or(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),or(this))},Ne.prototype.render=Y,Ze=[],ka=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xa=function(e,t){return e.__v.__b-t.__v.__b},xn.__r=0,Ca=/(PointerCapture)$|Capture$/i,Rr=0,ir=fi(!1),ar=fi(!0),Ia=0;var Is=0;function S(e,t,n,r,i,a){t||(t={});var o,s,l=t;if(\"ref\"in l)for(s in l={},t)s==\"ref\"?o=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Is,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return F.vnode&&F.vnode(u),u}var Qe,W,Un,di,wt=0,Ra=[],K=F,hi=K.__b,pi=K.__r,gi=K.diffed,mi=K.__c,yi=K.unmount,_i=K.__;function xt(e,t){K.__h&&K.__h(W,e,wt||t),wt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function te(e){return wt=1,Or(Oa,e)}function Or(e,t,n){var r=xt(Qe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Oa(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(h){return h.__c});if(f.every(function(h){return!h.__N}))return!a||a.call(this,s,l,u);var c=r.__c.props!==s;return f.some(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(c=!0)}}),a&&a.call(this,s,l,u)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,l,u){if(this.__e){var f=a;a=void 0,i(s,l,u),a=f}o&&o.call(this,s,l,u)},W.shouldComponentUpdate=i}return r.__N||r.__}function ke(e,t){var n=xt(Qe++,3);!K.__s&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ft(e,t){var n=xt(Qe++,4);!K.__s&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function le(e){return wt=5,ne(function(){return{current:e}},[])}function Ma(e,t,n){wt=6,ft(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 ne(e,t){var n=xt(Qe++,7);return Lr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ge(e,t){return wt=8,ne(function(){return e},t)}function Q(e){var t=W.context[e.__c],n=xt(Qe++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function za(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Fa(){var e=xt(Qe++,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 Ps(){for(var e;e=Ra.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(mn),t.__h.some(lr),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,hi&&hi(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_i&&_i(e,t)},K.__r=function(e){pi&&pi(e),Qe=0;var t=(W=e.__c).__H;t&&(Un===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(mn),t.__h.some(lr),t.__h=[],Qe=0)),Un=W},K.diffed=function(e){gi&&gi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ra.push(t)!==1&&di===K.requestAnimationFrame||((di=K.requestAnimationFrame)||Es)(Ps)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Un=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(mn),n.__h=n.__h.filter(function(r){return!r.__||lr(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),mi&&mi(e,t)},K.unmount=function(e){yi&&yi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{mn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var bi=typeof requestAnimationFrame==\"function\";function Es(e){var t,n=function(){clearTimeout(r),bi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);bi&&(t=requestAnimationFrame(n))}function mn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function lr(e){var t=W;e.__c=e.__(),W=t}function Lr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Oa(e,t){return typeof t==\"function\"?t(e):t}const vi=e=>{let t;const n=new Set,r=(u,f)=>{const c=typeof u==\"function\"?u(t):u;if(!Object.is(c,t)){const h=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(d=>d(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,i,s);return s},As=(e=>e?vi(e):vi);function La(e,t){for(var n in t)e[n]=t[n];return e}function ur(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 Ba(e,t){var n=t(),r=te({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ft(function(){i.__=n,i.u=t,jn(i)&&a({t:i})},[e,n,t]),ke(function(){return jn(i)&&a({t:i}),e(function(){jn(i)&&a({t:i})})},[e]),n}function jn(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 Va(e){e()}function Ha(e){return e}function qa(){return[!1,Va]}var Ua=ft;function cr(e,t){this.props=e,this.context=t}function $s(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:ur(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(cr.prototype=new Ne).isPureReactComponent=!0,cr.prototype.shouldComponentUpdate=function(e,t){return ur(this.props,e)||ur(this.state,t)};var wi=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),wi&&wi(e)};var Ds=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Ts(e){function t(n){var r=La({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ds,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Si=function(e,t){return e==null?null:Ve(Ve(e).map(t))},Ns={map:Si,forEach:Si,count:function(e){return e?Ve(e).length:0},only:function(e){var t=Ve(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ve},Rs=F.__e;F.__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)}Rs(e,t,n,r)};var ki=F.unmount;function ja(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=La({},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 ja(r,t,n)})),e}function Wa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Wa(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 yn(){this.__u=0,this.o=null,this.__b=null}function Ka(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ms(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?G(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Ft(){this.i=null,this.l=null}F.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ki&&ki(e)},(yn.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ka(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(l):l())};n.__R=o;var s=n.__P;n.__P=null;var l=function(){if(!--r.__u){if(r.state.__a){var u=r.state.__a;r.__v.__k[0]=Wa(u,u.__c.__P,u.__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)},yn.prototype.componentWillUnmount=function(){this.o=[]},yn.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]=ja(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&G(Y,null,e.fallback);return i&&(i.__u&=-33),[G(Y,null,t.__a?null:e.children),i]};var xi=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 zs(e){return this.getChildContext=function(){return e.context},e.children}function Fs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Pe(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)}}}Pe(G(zs,{context:t.context},e.__v),t.v)}function Os(e,t){var n=G(Fs,{__v:e,h:t});return n.containerInfo=t,n}(Ft.prototype=new Ne).__a=function(e){var t=this,n=Ka(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),xi(t,e,r)):i()};n?n(a):a()}},Ft.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ve(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},Ft.prototype.componentDidUpdate=Ft.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){xi(e,n,t)})};var Qa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ls=/^(?: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]/,Bs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Vs=/[A-Z0-9]/g,Hs=typeof document<\"u\",qs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Us(e,t,n){return t.__k==null&&(t.textContent=\"\"),Pe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function js(e,t,n){return Na(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Ci=F.event;function Ws(){}function Ks(){return this.cancelBubble}function Qs(){return this.defaultPrevented}F.event=function(e){return Ci&&(e=Ci(e)),e.persist=Ws,e.isPropagationStopped=Ks,e.isDefaultPrevented=Qs,e.nativeEvent=e};var Br,Gs={enumerable:!1,configurable:!0,get:function(){return this.class}},Ii=F.vnode;F.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||Hs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var l=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":l===\"translate\"&&s===\"no\"?s=!1:l[0]===\"o\"&&l[1]===\"n\"?l===\"ondoubleclick\"?o=\"ondblclick\":l!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||qs(n.type)?l===\"onfocus\"?o=\"onfocusin\":l===\"onblur\"?o=\"onfocusout\":Bs.test(o)&&(o=l):l=o=\"oninput\":a&&Ls.test(o)?o=o.replace(Vs,\"-$&\").toLowerCase():s===null&&(s=void 0),l===\"oninput\"&&i[o=l]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ve(n.children).forEach(function(u){u.props.selected=i.value.indexOf(u.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ve(n.children).forEach(function(u){u.props.selected=i.multiple?i.defaultValue.indexOf(u.props.value)!=-1:i.defaultValue==u.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Gs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Qa,Ii&&Ii(e)};var Pi=F.__r;F.__r=function(e){Pi&&Pi(e),Br=e.__c};var Ei=F.diffed;F.diffed=function(e){Ei&&Ei(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),Br=null};var Ys={ReactCurrentDispatcher:{current:{readContext:function(e){return Br.__n[e.__c].props.value},useCallback:ge,useContext:Q,useDebugValue:za,useDeferredValue:Ha,useEffect:ke,useId:Fa,useImperativeHandle:Ma,useInsertionEffect:Ua,useLayoutEffect:ft,useMemo:ne,useReducer:Or,useRef:le,useState:te,useSyncExternalStore:Ba,useTransition:qa}}};function Js(e){return G.bind(null,e)}function Mn(e){return!!e&&e.$$typeof===Qa}function Xs(e){return Mn(e)&&e.type===Y}function Zs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function el(e){return Mn(e)?Cs.apply(null,arguments):e}function tl(e){return!!e.__k&&(Pe(null,e),!0)}function nl(e){return e&&(e.base||e.nodeType===1&&e)||null}var rl=function(e,t){return e(t)},il=function(e,t){return e(t)},al=Y,ol=Mn,cn={useState:te,useId:Fa,useReducer:Or,useEffect:ke,useLayoutEffect:ft,useInsertionEffect:Ua,useTransition:qa,useDeferredValue:Ha,useSyncExternalStore:Ba,startTransition:Va,useRef:le,useImperativeHandle:Ma,useMemo:ne,useCallback:ge,useContext:Q,useDebugValue:za,version:\"18.3.1\",Children:Ns,render:Us,hydrate:js,unmountComponentAtNode:tl,createPortal:Os,createElement:G,createContext:Ge,createFactory:Js,cloneElement:el,createRef:bs,Fragment:Y,isValidElement:Mn,isElement:ol,isFragment:Xs,isMemo:Zs,findDOMNode:nl,Component:Ne,PureComponent:cr,memo:$s,forwardRef:Ts,flushSync:il,unstable_batchedUpdates:rl,StrictMode:al,Suspense:yn,SuspenseList:Ft,lazy:Ms,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ys};const sl=e=>e;function ll(e,t=sl){const n=cn.useSyncExternalStore(e.subscribe,cn.useCallback(()=>t(e.getState()),[e,t]),cn.useCallback(()=>t(e.getInitialState()),[e,t]));return cn.useDebugValue(n),n}const ul=e=>{const t=As(e),n=r=>ll(t,r);return Object.assign(n,t),n},cl=(e=>ul);var Vr=Symbol.for(\"immer-nothing\"),Bt=Symbol.for(\"immer-draftable\"),ie=Symbol.for(\"immer-state\");function se(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ye=Object,st=ye.getPrototypeOf,jt=\"constructor\",en=\"prototype\",fr=\"configurable\",Cn=\"enumerable\",_n=\"writable\",Wt=\"value\",qe=e=>!!e&&!!e[ie];function Re(e){return e?Ga(e)||nn(e)||!!e[Bt]||!!e[jt]?.[Bt]||rn(e)||an(e):!1}var fl=ye[en][jt].toString(),Ai=new WeakMap;function Ga(e){if(!e||!St(e))return!1;const t=st(e);if(t===null||t===ye[en])return!0;const n=ye.hasOwnProperty.call(t,jt)&&t[jt];if(n===Object)return!0;if(!et(n))return!1;let r=Ai.get(n);return r===void 0&&(r=Function.toString.call(n),Ai.set(n,r)),r===fl}function tn(e,t,n=!0){lt(e)===0?(n?Reflect.ownKeys(e):ye.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function lt(e){const t=e[ie];return t?t.type_:nn(e)?1:rn(e)?2:an(e)?3:0}var Vt=(e,t,n=lt(e))=>n===2?e.has(t):ye[en].hasOwnProperty.call(e,t),Le=(e,t,n=lt(e))=>n===2?e.get(t):e[t],In=(e,t,n,r=lt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function dl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var nn=Array.isArray,rn=e=>e instanceof Map,an=e=>e instanceof Set,St=e=>typeof e==\"object\",et=e=>typeof e==\"function\",Wn=e=>typeof e==\"boolean\";function hl(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var pl=e=>St(e)?e?.[ie]:null,Be=e=>e.copy_||e.base_,Hr=e=>e.modified_?e.copy_:e.base_;function dr(e,t){if(rn(e))return new Map(e);if(an(e))return new Set(e);if(nn(e))return Array[en].slice.call(e);const n=Ga(e);if(t===!0||t===\"class_only\"&&!n){const r=ye.getOwnPropertyDescriptors(e);delete r[ie];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[_n]===!1&&(s[_n]=!0,s[fr]=!0),(s.get||s.set)&&(r[o]={[fr]:!0,[_n]:!0,[Cn]:s[Cn],[Wt]:e[o]})}return ye.create(st(e),r)}else{const r=st(e);if(r!==null&&n)return{...e};const i=ye.create(r);return ye.assign(i,e)}}function qr(e,t=!1){return zn(e)||qe(e)||!Re(e)||(lt(e)>1&&ye.defineProperties(e,{set:fn,add:fn,clear:fn,delete:fn}),ye.freeze(e),t&&tn(e,(n,r)=>{qr(r,!0)},!1)),e}function gl(){se(2)}var fn={[Wt]:gl};function zn(e){return e===null||!St(e)?!0:ye.isFrozen(e)}var Pn=\"MapSet\",En=\"Patches\",$i=\"ArrayMethods\",An={};function ut(e){const t=An[e];return t||se(0,e),t}var Di=e=>!!An[e];function ml(e,t){An[e]||(An[e]=t)}var Kt,Ya=()=>Kt,yl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Di(Pn)?ut(Pn):void 0,arrayMethodsPlugin_:Di($i)?ut($i):void 0});function Ti(e,t){t&&(e.patchPlugin_=ut(En),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hr(e){pr(e),e.drafts_.forEach(_l),e.drafts_=null}function pr(e){e===Kt&&(Kt=e.parent_)}var Ni=e=>Kt=yl(Kt,e);function _l(e){const t=e[ie];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ri(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ie].modified_&&(hr(t),se(4)),Re(e)&&(e=Mi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ie].base_,e,t)}else e=Mi(t,n);return bl(t,e,!0),hr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Vr?e:void 0}function Mi(e,t){if(zn(t))return t;const n=t[ie];if(!n)return $n(t,e.handledSet_,e);if(!Fn(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);Za(n,e)}return n.copy_}function bl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qr(t,n)}function Ja(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Fn=(e,t)=>e.scope_===t,vl=[];function Xa(e,t,n,r){const i=Be(e),a=e.type_;if(r!==void 0&&Le(i,r,a)===t){In(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;tn(i,(l,u)=>{if(qe(u)){const f=s.get(u)||[];f.push(l),s.set(u,f)}})}const o=e.draftLocations_.get(t)??vl;for(const s of o)In(i,s,n,a)}function wl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Fn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Hr(a);Xa(e,a.draft_??a,o,n),Za(a,i)})}function Za(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)}Ja(e)}}function Sl(e,t,n){const{scope_:r}=e;if(qe(n)){const i=n[ie];Fn(i,r)&&i.callbacks_.push(function(){bn(e);const o=Hr(i);Xa(e,n,o,t)})}else Re(n)&&e.callbacks_.push(function(){const a=Be(e);e.type_===3?a.has(n)&&$n(n,r.handledSet_,r):Le(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&$n(Le(e.copy_,t,e.type_),r.handledSet_,r)})}function $n(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||qe(e)||t.has(e)||!Re(e)||zn(e)||(t.add(e),tn(e,(r,i)=>{if(qe(i)){const a=i[ie];if(Fn(a,n)){const o=Hr(a);In(e,r,o,e.type_),Ja(a)}}else Re(i)&&$n(i,t,n)})),e}function kl(e,t){const n=nn(e),r={type_:n?1:0,scope_:t?t.scope_:Ya(),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=Dn;n&&(i=[r],a=Qt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Dn={get(e,t){if(t===ie)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=Be(e);if(!Vt(i,t,e.type_))return xl(e,i,t);const a=i[t];if(e.finalized_||!Re(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&hl(t))return a;if(a===Kn(e.base_,t)){bn(e);const o=e.type_===1?+t:t,s=mr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Be(e)},ownKeys(e){return Reflect.ownKeys(Be(e))},set(e,t,n){const r=eo(Be(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Kn(Be(e),t),a=i?.[ie];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(dl(n,i)&&(n!==void 0||Vt(e.base_,t,e.type_)))return!0;bn(e),gr(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),Sl(e,t,n)),!0},deleteProperty(e,t){return bn(e),Kn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),gr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Be(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[_n]:!0,[fr]:e.type_!==1||t!==\"length\",[Cn]:r[Cn],[Wt]:n[t]}},defineProperty(){se(11)},getPrototypeOf(e){return st(e.base_)},setPrototypeOf(){se(12)}},Qt={};for(let e in Dn){let t=Dn[e];Qt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Qt.deleteProperty=function(e,t){return Qt.set.call(this,e,t,void 0)};Qt.set=function(e,t,n){return Dn.set.call(this,e[0],t,n,e[0])};function Kn(e,t){const n=e[ie];return(n?Be(n):e)[t]}function xl(e,t,n){const r=eo(t,n);return r?Wt in r?r[Wt]:r.get?.call(e.draft_):void 0}function eo(e,t){if(!(t in e))return;let n=st(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=st(n)}}function gr(e){e.modified_||(e.modified_=!0,e.parent_&&gr(e.parent_))}function bn(e){e.copy_||(e.assigned_=new Map,e.copy_=dr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Cl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(et(t)&&!et(n)){const a=n;n=t;const o=this;return function(l=a,...u){return o.produce(l,f=>n.call(this,f,...u))}}et(n)||se(6),r!==void 0&&!et(r)&&se(7);let i;if(Re(t)){const a=Ni(this),o=mr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?hr(a):pr(a)}return Ti(a,r),Ri(i,a)}else if(!t||!St(t)){if(i=n(t),i===void 0&&(i=t),i===Vr&&(i=void 0),this.autoFreeze_&&qr(i,!0),r){const a=[],o=[];ut(En).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else se(1,t)},this.produceWithPatches=(t,n)=>{if(et(t))return(o,...s)=>this.produceWithPatches(o,l=>t(l,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},Wn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Wn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Wn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Re(e)||se(8),qe(e)&&(e=Il(e));const t=Ni(this),n=mr(t,e,void 0);return n[ie].isManual_=!0,pr(t),n}finishDraft(e,t){const n=e&&e[ie];(!n||!n.isManual_)&&se(9);const{scope_:r}=n;return Ti(r,t),Ri(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=ut(En).applyPatches_;return qe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function mr(e,t,n,r){const[i,a]=rn(t)?ut(Pn).proxyMap_(t,n):an(t)?ut(Pn).proxySet_(t,n):kl(t,n);return(n?.scope_??Ya()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?wl(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=l;a.modified_&&u&&u.generatePatches_(a,[],l)}),i}function Il(e){return qe(e)||se(10,e),to(e)}function to(e){if(!Re(e)||zn(e))return e;const t=e[ie];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=dr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=dr(e,!0);return tn(n,(i,a)=>{In(n,i,to(a))},r),t&&(t.finalized_=!1),n}function Pl(){function t(p,y=[]){if(p.key_!==void 0){const b=p.parent_.copy_??p.parent_.base_,_=pl(Le(b,p.key_)),k=Le(b,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||_!=null&&_.base_!==p.base_)return null;const x=p.parent_.type_===3;let E;if(x){const I=p.parent_;E=Array.from(I.drafts_.keys()).indexOf(p.key_)}else E=p.key_;if(!(x&&b.size>E||Vt(b,E)))return null;y.push(E)}if(p.parent_)return t(p.parent_,y);y.reverse();try{n(p.copy_,y)}catch{return null}return y}function n(p,y){let b=p;for(let _=0;_<y.length-1;_++){const k=y[_];if(b=Le(b,k),!St(b)||b===null)throw new Error(`Cannot resolve path at '${y.join(\"/\")}'`)}return b}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,y,b){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:k}=b;switch(p.type_){case 0:case 2:return l(p,y,_,k);case 1:return s(p,y,_,k);case 3:return u(p,y,_,k)}}function s(p,y,b,_){let{base_:k,assigned_:x}=p,E=p.copy_;E.length<k.length&&([k,E]=[E,k],[b,_]=[_,b]);const I=p.allIndicesReassigned_===!0;for(let v=0;v<k.length;v++){const D=E[v],A=k[v];if((I||x?.get(v.toString()))&&D!==A){const w=D?.[ie];if(w&&w.modified_)continue;const T=y.concat([v]);b.push({op:r,path:T,value:d(D)}),_.push({op:r,path:T,value:d(A)})}}for(let v=k.length;v<E.length;v++){const D=y.concat([v]);b.push({op:i,path:D,value:d(E[v])})}for(let v=E.length-1;k.length<=v;--v){const D=y.concat([v]);_.push({op:a,path:D})}}function l(p,y,b,_){const{base_:k,copy_:x,type_:E}=p;tn(p.assigned_,(I,v)=>{const D=Le(k,I,E),A=Le(x,I,E),$=v?Vt(k,I)?r:i:a;if(D===A&&$===r)return;const w=y.concat(I);b.push($===a?{op:$,path:w}:{op:$,path:w,value:d(A)}),_.push($===i?{op:a,path:w}:$===a?{op:i,path:w,value:d(D)}:{op:r,path:w,value:d(D)})})}function u(p,y,b,_){let{base_:k,copy_:x}=p,E=0;k.forEach(I=>{if(!x.has(I)){const v=y.concat([E]);b.push({op:a,path:v,value:I}),_.unshift({op:i,path:v,value:I})}E++}),E=0,x.forEach(I=>{if(!k.has(I)){const v=y.concat([E]);b.push({op:i,path:v,value:I}),_.unshift({op:a,path:v,value:I})}E++})}function f(p,y,b){const{patches_:_,inversePatches_:k}=b;_.push({op:r,path:[],value:y===Vr?void 0:y}),k.push({op:r,path:[],value:p})}function c(p,y){return y.forEach(b=>{const{path:_,op:k}=b;let x=p;for(let D=0;D<_.length-1;D++){const A=lt(x);let $=_[D];typeof $!=\"string\"&&typeof $!=\"number\"&&($=\"\"+$),(A===0||A===1)&&($===\"__proto__\"||$===jt)&&se(19),et(x)&&$===en&&se(19),x=Le(x,$),St(x)||se(18,_.join(\"/\"))}const E=lt(x),I=h(b.value),v=_[_.length-1];switch(k){case r:switch(E){case 2:return x.set(v,I);case 3:se(16);default:return x[v]=I}case i:switch(E){case 1:return v===\"-\"?x.push(I):x.splice(v,0,I);case 2:return x.set(v,I);case 3:return x.add(I);default:return x[v]=I}case a:switch(E){case 1:return x.splice(v,1);case 2:return x.delete(v);case 3:return x.delete(b.value);default:return delete x[v]}default:se(17,k)}}),p}function h(p){if(!Re(p))return p;if(nn(p))return p.map(h);if(rn(p))return new Map(Array.from(p.entries()).map(([b,_])=>[b,h(_)]));if(an(p))return new Set(Array.from(p).map(h));const y=Object.create(st(p));for(const b in p)y[b]=h(p[b]);return Vt(p,Bt)&&(y[Bt]=p[Bt]),y}function d(p){return qe(p)?h(p):p}ml(En,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Gt=new Cl,El=Gt.produce,Al=Gt.produceWithPatches.bind(Gt),_t=Gt.applyPatches.bind(Gt);const $l=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?El(i):i;return t(s,a,...o)},e(r.setState,n,r)),Dl=$l,Tl=/[a-zA-Z]/,Nl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Rl(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 zi(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 Fi(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 Ml(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;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;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 We(e,t){let n=1;for(;t<e.length&&n>0;)e[t]===\"{\"?n++:e[t]===\"}\"&&n--,n>0&&t++;return n===0?t:-1}function Ct(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=Fi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let l=1;const u=n;for(;n<e.length&&l>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")l++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(l--,l===0)break;n+=2}else n++;if(l!==0){n=a+2,r=a;continue}const f=e.slice(u,n);n+=2;const{display:c,target:h}=Rl(f),d={type:\"link\",display:c,target:h,start:a,end:n};o&&(d.className=o),s&&(d.id=s),t.push(d),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,l;if(o===\".\"||o===\"#\"){i(n);const u=Fi(e,n+1);s=u.className||void 0,l=u.id||void 0;let f=u.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"variable\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const p=We(e,h);if(p!==-1){const y=e.slice(f,p);n=p+1;const b={type:\"expression\",expression:y,start:a,end:n};s&&(b.className=s),l&&(b.id=l),t.push(b),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"temporary\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const p=We(e,h);if(p!==-1){const y=e.slice(f,p);n=p+1;const b={type:\"expression\",expression:y,start:a,end:n};s&&(b.className=s),l&&(b.id=l),t.push(b),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"local\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const p=We(e,h);if(p!==-1){const y=e.slice(f,p);n=p+1;const b={type:\"expression\",expression:y,start:a,end:n};s&&(b.className=s),l&&(b.id=l),t.push(b),r=n;continue}n=a+1,r=a;continue}if(c===\"%\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"transient\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const p=We(e,h);if(p!==-1){const y=e.slice(f,p);n=p+1;const b={type:\"expression\",expression:y,start:a,end:n};s&&(b.className=s),l&&(b.id=l),t.push(b),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let h=1;const d=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=a+1,r=a;continue}const p=e.slice(d,n);n++;const{name:y,rawArgs:b,isClose:_}=zi(p),k={type:\"macro\",name:y,rawArgs:b,isClose:_,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}const c=We(e,u);if(c!==-1){const h=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:h,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}const c=We(e,u);if(c!==-1){const h=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:h,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}const c=We(e,u);if(c!==-1){const h=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:h,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"%\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"transient\",start:a,end:n}),r=n;continue}const c=We(e,u);if(c!==-1){const h=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:h,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 u=1;const f=n;for(;n<e.length&&u>0;)e[n]===\"{\"?u++:e[n]===\"}\"&&u--,u>0&&n++;if(u!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:h,rawArgs:d,isClose:p}=zi(c);t.push({type:\"macro\",name:h,rawArgs:d,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const l=o;for(;o<e.length&&/[a-zA-Z0-9-]/.test(e[o]);)o++;const u=e.slice(l,o),f=u.toLowerCase();if(u&&Tl.test(u[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const c=Ml(e,o);o=c.endIdx;let h=Nl.has(f);if(e[o]===\"/\"&&(h=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:c.attributes,isClose:!1,isSelfClose:h,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const no=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function yr(e){no.add(e.toLowerCase())}const Oi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},zl=new Set([\"if\",\"switch\",\"timed\"]);function It(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\"expression\":{const a={type:\"expression\",expression:i.expression};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.toLowerCase()!==i.tag.toLowerCase()){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\":{const a=i.name.toLowerCase();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!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(Oi[a]){const o=Oi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const l={rawArgs:i.rawArgs,children:[]};i.className&&(l.className=i.className),i.id&&(l.id=i.id),s.branches.push(l);break}if(no.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(zl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}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:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}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 Ur(){const e=C(i=>i.variables),t=C(i=>i.temporary),n=C(i=>i.transient),r=Q(xe);return ne(()=>[e,t,r,n],[e,t,r,n])}function ro(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 io(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let Pt=!1,on=\"\",ct=0,kt=null;function Fl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,on=n,ct=0,kt=ro(io(n)),Pt=!0}function ao(e,t){on=e,ct=0,kt=ro(io(e)),Pt=!0;for(let n=0;n<t;n++)kt();ct=t}function _r(){Pt=!1,on=\"\",ct=0,kt=null}function Tn(){return Pt?{seed:on,pull:ct}:null}function jr(){return!Pt||!kt?Math.random():(ct++,kt())}function oo(e,t){return e>t&&([e,t]=[t,e]),Math.floor(jr()*(t-e+1))+e}function Ol(){return Pt}function Ll(){return on}function Bl(){return ct}const Vl=500,Je=new Map,Hl=/\\$(\\w+)/g,ql=/(?<![.\\w])_(\\w+)/g,Ul=/@(\\w+)/g,jl=/(?<!\\w)%(\\w+)/g;function Wl(e){return e.replace(Hl,'variables[\"$1\"]').replace(ql,'temporary[\"$1\"]').replace(Ul,'locals[\"$1\"]').replace(jl,'transient[\"$1\"]')}function Wr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Wl(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 l=e.charAt(r);if(l===\"\\\\\"&&r+1<e.length)s+=l+e.charAt(r+1),r+=2;else if(l===o){s+=o,r++;break}else s+=l,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,l=\"\";for(;r<e.length&&s>0;){const u=e.charAt(r);if(u===\"{\")s++,l+=u;else if(u===\"}\"){if(s--,s===0)break;l+=u}else if(u===\"\\\\\"&&r+1<e.length)l+=u+e.charAt(r+1),r++;else if(u==='\"'||u===\"'\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===u){l+=f,r++;break}else l+=f,r++}continue}else if(u===\"`\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===\"$\"&&e.charAt(r+1)===\"{\"){l+=\"${\",r+=2;let c=1;for(;r<e.length&&c>0;){const h=e.charAt(r);h===\"{\"?c++:h===\"}\"&&c--,c>0&&(l+=h),r++}l+=\"}\"}else if(f===\"`\"){l+=f,r++;break}else l+=f,r++}continue}else l+=u;r++}t+=Wr(l),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 Kl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function so(e,t){const n=Je.get(e);if(n)return Je.delete(e),Je.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",\"transient\",Kl+t);if(Je.set(e,r),Je.size>Vl){const i=Je.keys().next().value;i!==void 0&&Je.delete(i)}return r}let dn=null,Li=null,Bi=null;function lo(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(dn&&Li===t&&Bi===n)return dn;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(p=>r(p)>0),o=(...d)=>d.every(p=>r(p)>0),s=d=>n[d??C.getState().currentPassage]??0;return dn={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const p=d.history[d.historyIndex-1]?.passage;return p?d.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(p=>s(p)>0),hasRenderedAll:(...d)=>d.every(p=>s(p)>0),random:jr,randomInt:oo},Li=t,Bi=n,dn}function Et(e,t,n,r={},i={}){const o=`return (${Wr(e)});`;return so(o,o)(t,n,r,lo(),i)}function uo(e,t,n,r={},i={}){const a=Wr(e);so(\"exec:\"+a,a)(t,n,r,lo(),i)}const Ql=/\\{[\\$_@%]\\w/;function Gl(e){return Ql.test(e)}function Yl(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 Jl(e,t,n,r,i={}){const a=Et(e,t,n,r,i);return a==null?\"\":String(a)}function Xl(e,t,n,r,i){const a=e[0],s=e.slice(1).split(\".\"),l=s[0];let u;return a===\"$\"?u=t[l]:a===\"_\"?u=n[l]:a===\"%\"?u=i[l]:u=r[l],s.length>1&&(u=Yl(u,s)),u==null?\"\":String(u)}function Zl(e,t,n,r,i={}){let a=\"\",o=0;for(;o<e.length;){if(e[o]!==\"{\"){const c=e.indexOf(\"{\",o);if(c===-1){a+=e.slice(o);break}a+=e.slice(o,c),o=c;continue}o++;const s=e[o];if(s!==\"$\"&&s!==\"_\"&&s!==\"@\"&&s!==\"%\"){a+=\"{\";continue}let l=1,u=o;for(;u<e.length&&l>0;)u++,e[u]===\"{\"?l++:e[u]===\"}\"&&l--;if(l!==0){a+=\"{\";continue}const f=e.slice(o,u);o=u+1,/^[\\$_@%][\\w.]+$/.test(f)?a+=Xl(f,t,n,r,i):a+=Jl(f,t,n,r,i)}return a}function On(){const[e,t,n,r]=Ur();return ge(i=>i===void 0||!Gl(i)?i:Zl(i,e,t,n,r),[e,t,n,r])}function eu({name:e,scope:t,className:n,id:r}){const i=On();n=i(n),r=i(r);const a=Q(xe),o=e.split(\".\"),s=o[0],l=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:t===\"transient\"?c.transient[s]:void 0);let u;t===\"local\"?u=s in a?a[s]:void 0:u=l;for(let c=1;c<o.length;c++){if(u==null||typeof u!=\"object\"){u=void 0;break}const h=o[c];u=u[h]}const f=u==null?\"\":String(u);return n||r?S(\"span\",{id:r,class:n,children:f}):S(Y,{children:f})}function tu({expression:e,className:t,id:n}){const r=On();t=r(t),n=r(n);const i=Q(xe),a=C(u=>u.variables),o=C(u=>u.temporary),s=C(u=>u.transient);let l;try{const u=Et(e,a,o,i,s);l=u==null?\"\":String(u)}catch{l=`{error: ${e}}`}return t||n?S(\"span\",{id:n,class:t,children:l}):S(Y,{children:l})}function nu(e){const t=e[0];return!!(t==='\"'||t===\"'\"||t===\"`\"||t===\"$\"||t===\"_\"||t===\"@\"||t===\"%\"||/\\d/.test(t)||(t===\"-\"||t===\"+\")&&e.length>1&&/\\d/.test(e[1])||t===\"(\"||t===\"[\"||t===\"{\"||/^(true|false|null|undefined)$/.test(e)||t===\"!\"&&e.length>1)}function ru(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const o=e[a];if(i){n+=o,o===i&&e[a-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(/\\s/.test(o)&&r===0){n&&(t.push(n),n=\"\");continue}n+=o}if(n&&t.push(n),t.length<2)return null;for(const a of t)if(!nu(a))return null;return t}function iu(e){const t=[];let n=\"\",r=0,i=null,a=!1;for(let s=0;s<e.length;s++){const l=e[s];if(i){n+=l,l===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(l==='\"'||l===\"'\"||l===\"`\"){i=l,n+=l;continue}if(l===\"(\"||l===\"[\"||l===\"{\"){r++,n+=l;continue}if(l===\")\"||l===\"]\"||l===\"}\"){r--,n+=l;continue}if(l===\",\"&&r===0){a=!0,t.push(n.trim()),n=\"\";continue}n+=l}const o=n.trim();if(o&&t.push(o),!a&&t.length===1){const s=ru(t[0]);if(s)return s}return t}function au({body:e,parentValues:t,ownKeys:n}){const r=Q(he),[i,a]=te({}),o=ne(()=>({...t,...n,...i}),[t,n,i]),s=le(o);s.current=o;const l=ge(()=>s.current,[]),u=ge((c,h)=>{a(d=>({...d,[c]:h}))},[]),f=ne(()=>({update:u,getValues:l}),[u,l]);return S(sn.Provider,{value:f,children:S(xe.Provider,{value:o,children:Ee(e,{nobr:r,locals:o})})})}function ou({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(xe),a=Q(he),[o,s,l,u]=Ur(),f=r?.length?r:null;if(t.length===0||!n)return S(kr.Provider,{value:f,children:Ee(e,{nobr:a,locals:i})});const c=iu(n),h=[];for(let p=0;p<t.length;p++){const y=c[p];let b;if(y!==void 0)try{b=Et(y,o,s,l,u)}catch{b=void 0}h.push(b)}const d=ne(()=>{const p={};for(let y=0;y<t.length;y++)p[t[y].startsWith(\"@\")?t[y].slice(1):t[y]]=h[y];return p},h);return S(kr.Provider,{value:f,children:S(au,{body:e,parentValues:i,ownKeys:d})})}const co=new Map;function fo(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");co.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function su(e){return co.get(e.toLowerCase())}const ho=new Map;function lu(e,t){ho.set(e.toLowerCase(),t)}function uu(e){return ho.get(e.toLowerCase())}const po=new Set;function cu(e){po.add(e.toLowerCase())}function fu(e){return po.has(e.toLowerCase())}const go=new Map;function du(e,t){go.set(e.toLowerCase(),t)}function hu(){return Array.from(go.values())}const Vi=document.createElement(\"i\");function mo(e){const t=\"&\"+e+\";\";Vi.innerHTML=t;const n=Vi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function be(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 oe(e,t){return e.length>0?(be(e,e.length,0,t),e):t}const br={}.hasOwnProperty;function pu(e){const t={};let n=-1;for(;++n<e.length;)gu(t,e[n]);return t}function gu(e,t){let n;for(n in t){const i=(br.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){br.call(i,o)||(i[o]=[]);const s=a[o];mu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function mu(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);be(e,0,0,r)}function yu(e){const t={};let n=-1;for(;++n<e.length;)_u(t,e[n]);return t}function _u(e,t){let n;for(n in t){const i=(br.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 bu(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 vu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function yo(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+vu[n]+\";\"}}function Yt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const De=Ye(/[A-Za-z]/),_e=Ye(/[\\dA-Za-z]/),wu=Ye(/[#-'*+\\--9=?A-Z^-~]/);function vr(e){return e!==null&&(e<32||e===127)}const wr=Ye(/\\d/),Su=Ye(/[\\dA-Fa-f]/),ku=Ye(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function ue(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const xu=Ye(/\\p{P}|\\p{S}/u),Cu=Ye(/\\s/);function Ye(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hn(e,t){const n=yo(Iu(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 Iu(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&_e(e.charCodeAt(n+1))&&_e(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 Hi={}.hasOwnProperty,qi=/^(https?|ircs?|mailto|xmpp)$/i,Pu=/^https?$/i;function Eu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=yu([{enter:{blockQuote:O,codeFenced:Ce,codeFencedFenceInfo:b,codeFencedFenceMeta:b,codeIndented:j,codeText:cs,content:Xo,definition:Wo,definitionDestinationString:Qo,definitionLabelString:b,definitionTitleString:b,emphasis:ls,htmlFlow:ss,htmlText:ii,image:q,label:b,link:ce,listItemMarker:T,listItemValue:w,listOrdered:A,listUnordered:$,paragraph:Z,reference:b,resource:pt,resourceDestinationString:gt,resourceTitleString:b,setextHeading:es,strong:us},exit:{atxHeading:ns,atxHeadingSequence:Zo,autolinkEmail:ys,autolinkProtocol:ms,blockQuote:ee,characterEscapeValue:$t,characterReferenceMarkerHexadecimal:ai,characterReferenceMarkerNumeric:ai,characterReferenceValue:gs,codeFenced:g,codeFencedFence:R,codeFencedFenceInfo:m,codeFencedFenceMeta:D,codeFlowValue:os,codeIndented:g,codeText:fs,codeTextData:$t,data:$t,definition:Jo,definitionDestinationString:Go,definitionLabelString:Ko,definitionTitleString:Yo,emphasis:ds,hardBreakEscape:ni,hardBreakTrailing:ni,htmlFlow:ri,htmlFlowData:$t,htmlText:ri,htmlTextData:$t,image:ti,label:At,labelText:re,lineEnding:as,link:ti,listOrdered:N,listUnordered:V,paragraph:me,reference:D,referenceString:je,resource:D,resourceDestinationString:qn,resourceTitleString:jo,setextHeading:is,setextHeadingLineSequence:rs,setextHeadingText:ts,strong:hs,thematicBreak:ps}},...t.htmlExtensions||[]]),u={definitions:r,tightStack:o},f={buffer:b,encode:v,getData:y,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:p,tag:k};let c=t.defaultLineEnding;return h;function h(P){let M=-1,ae=0;const Ie=[];let Ae=[],Me=[];for(;++M<P.length;)!c&&(P[M][1].type===\"lineEnding\"||P[M][1].type===\"lineEndingBlank\")&&(c=P[M][2].sliceSerialize(P[M][1])),(P[M][1].type===\"listOrdered\"||P[M][1].type===\"listUnordered\")&&(P[M][0]===\"enter\"?Ie.push(M):d(P.slice(Ie.pop(),M))),P[M][1].type===\"definition\"&&(P[M][0]===\"enter\"?(Me=oe(Me,P.slice(ae,M)),ae=M):(Ae=oe(Ae,P.slice(ae,M+1)),ae=M+1));Ae=oe(Ae,Me),Ae=oe(Ae,P.slice(ae)),M=-1;const $e=Ae;for(l.enter.null&&l.enter.null.call(f);++M<P.length;){const oi=l[$e[M][0]],si=$e[M][1].type,li=oi[si];Hi.call(oi,si)&&li&&li.call({sliceSerialize:$e[M][2].sliceSerialize,...f},$e[M][1])}return l.exit.null&&l.exit.null.call(f),i[0].join(\"\")}function d(P){const M=P.length;let ae=0,Ie=0,Ae=!1,Me;for(;++ae<M;){const $e=P[ae];if($e[1]._container)Me=void 0,$e[0]===\"enter\"?Ie++:Ie--;else switch($e[1].type){case\"listItemPrefix\":{$e[0]===\"exit\"&&(Me=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{$e[0]===\"enter\"&&!Ie&&(Me?Me=void 0:Ae=!0);break}default:Me=void 0}}P[0][1]._loose=Ae}function p(P,M){u[P]=M}function y(P){return u[P]}function b(){i.push([])}function _(){return i.pop().join(\"\")}function k(P){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){p(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(c||`\n`)}function I(){const P=i[i.length-1],M=P[P.length-1],ae=M?M.charCodeAt(M.length-1):null;ae===10||ae===13||ae===null||E()}function v(P){return y(\"ignoreEncode\")?P:yo(P)}function D(){_()}function A(P){o.push(!P._loose),I(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function $(P){o.push(!P._loose),I(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function w(P){if(y(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(P),10);M!==1&&k(' start=\"'+v(String(M))+'\"')}}function T(){y(\"expectFirstItem\")?k(\">\"):U(),I(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function N(){U(),o.pop(),E(),k(\"</ol>\")}function V(){U(),o.pop(),E(),k(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),k(\"<blockquote>\")}function ee(){o.pop(),I(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function Z(){o[o.length-1]||(I(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function me(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function Ce(){I(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const P=_();k(' class=\"language-'+P+'\"')}function R(){const P=y(\"fencesCount\")||0;P||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",P+1)}function j(){I(),k(\"<pre><code>\")}function g(){const P=y(\"fencesCount\");P!==void 0&&P<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&E(),y(\"flowCodeSeenData\")&&I(),k(\"</code></pre>\"),P!==void 0&&P<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ce(){a.push({})}function re(P){a[a.length-1].labelId=this.sliceSerialize(P)}function At(){a[a.length-1].label=_()}function je(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function pt(){b(),a[a.length-1].destination=\"\"}function gt(){b(),p(\"ignoreEncode\",!0)}function qn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function jo(){a[a.length-1].title=_()}function ti(){let P=a.length-1;const M=a[P],ae=M.referenceId||M.labelId,Ie=M.destination===void 0?r[Yt(ae)]:M;for(n=!0;P--;)if(a[P].image){n=void 0;break}M.image?(k('<img src=\"'+hn(Ie.destination,t.allowDangerousProtocol?void 0:Pu)+'\" alt=\"'),x(M.label),k('\"')):k('<a href=\"'+hn(Ie.destination,t.allowDangerousProtocol?void 0:qi)+'\"'),k(Ie.title?' title=\"'+Ie.title+'\"':\"\"),M.image?k(\" />\"):(k(\">\"),x(M.label),k(\"</a>\")),a.pop()}function Wo(){b(),a.push({})}function Ko(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function Qo(){b(),p(\"ignoreEncode\",!0)}function Go(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function Yo(){a[a.length-1].title=_()}function Jo(){const P=a[a.length-1],M=Yt(P.labelId);_(),Hi.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Xo(){p(\"slurpAllLineEndings\",!0)}function Zo(P){y(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(P).length),I(),k(\"<h\"+y(\"headingRank\")+\">\"))}function es(){b(),p(\"slurpAllLineEndings\")}function ts(){p(\"slurpAllLineEndings\",!0)}function ns(){k(\"</h\"+y(\"headingRank\")+\">\"),p(\"headingRank\")}function rs(P){p(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function is(){const P=_();I(),k(\"<h\"+y(\"headingRank\")+\">\"),x(P),k(\"</h\"+y(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function $t(P){x(v(this.sliceSerialize(P)))}function as(P){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(v(this.sliceSerialize(P)))}}function os(P){x(v(this.sliceSerialize(P))),p(\"flowCodeSeenData\",!0)}function ni(){k(\"<br />\")}function ss(){I(),ii()}function ri(){p(\"ignoreEncode\")}function ii(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function ls(){k(\"<em>\")}function us(){k(\"<strong>\")}function cs(){p(\"inCodeText\",!0),k(\"<code>\")}function fs(){p(\"inCodeText\"),k(\"</code>\")}function ds(){k(\"</em>\")}function hs(){k(\"</strong>\")}function ps(){I(),k(\"<hr />\")}function ai(P){p(\"characterReferenceType\",P.type)}function gs(P){const M=this.sliceSerialize(P),ae=y(\"characterReferenceType\")?bu(M,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):mo(M);x(v(ae)),p(\"characterReferenceType\")}function ms(P){const M=this.sliceSerialize(P);k('<a href=\"'+hn(M,t.allowDangerousProtocol?void 0:qi)+'\">'),x(v(M)),k(\"</a>\")}function ys(P){const M=this.sliceSerialize(P);k('<a href=\"'+hn(\"mailto:\"+M)+'\">'),x(v(M)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return L(l)?(e.enter(n),s(l)):t(l)}function s(l){return L(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const Au={tokenize:$u};function $u(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\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const l=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return z(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Du={tokenize:Tu},Ui={tokenize:Nu};function Tu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(x)}return u(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const E=t.events.length;let I=E,v;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){v=t.events[I][1].end;break}_(r);let D=E;for(;D<t.events.length;)t.events[D][1].end={...v},D++;return be(t.events,I+1,0,t.events.slice(E)),t.events.length=D,u(x)}return s(x)}function u(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return p(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ui,f,c)(x)}function f(x){return i&&k(),_(r),h(x)}function c(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(x)}function h(x){return t.containerState={},e.attempt(Ui,d,p)(x)}function d(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function p(x){if(x===null){i&&k(),_(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),y(x)}function y(x){if(x===null){b(e.exit(\"chunkFlow\"),!0),_(0),e.consume(x);return}return z(x)?(e.consume(x),b(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),y)}function b(x,E){const I=t.sliceStream(x);if(E&&I.push(null),x.previous=a,a&&(a.next=x),a=x,i.defineSkip(x.start),i.write(I),t.parser.lazy[x.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 D=t.events.length;let A=D,$,w;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){if($){w=t.events[A][1].end;break}$=!0}for(_(r),v=D;v<t.events.length;)t.events[v][1].end={...w},v++;be(t.events,A+1,0,t.events.slice(D)),t.events.length=v}}function _(x){let E=n.length;for(;E-- >x;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=x}function k(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Nu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Nn(e){if(e===null||ue(e)||Cu(e))return 1;if(xu(e))return 2}function Ln(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 Sr={name:\"attention\",resolveAll:Ru,tokenize:Mu};function Ru(e,t){let n=-1,r,i,a,o,s,l,u,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;l=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},h={...e[n][1].start};ji(c,-l),ji(h,l),o={type:l>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:l>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},a={type:l>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=oe(u,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),u=oe(u,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),u=oe(u,Ln(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=oe(u,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=oe(u,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,be(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Mu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Nn(r);let a;return o;function o(l){return a=l,e.enter(\"attentionSequence\"),s(l)}function s(l){if(l===a)return e.consume(l),s;const u=e.exit(\"attentionSequence\"),f=Nn(l),c=!f||f===2&&i||n.includes(l),h=!i||i===2&&f||n.includes(r);return u._open=!!(a===42?c:c&&(i||!h)),u._close=!!(a===42?h:h&&(f||!c)),t(l)}}function ji(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const zu={name:\"autolink\",tokenize:Fu};function Fu(e,t,n){let r=0;return i;function i(d){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(d){return De(d)?(e.consume(d),o):d===64?n(d):u(d)}function o(d){return d===43||d===45||d===46||_e(d)?(r=1,s(d)):u(d)}function s(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||_e(d))&&r++<32?(e.consume(d),s):(r=0,u(d))}function l(d){return d===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d===null||d===32||d===60||vr(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),f):wu(d)?(e.consume(d),u):n(d)}function f(d){return _e(d)?c(d):n(d)}function c(d){return d===46?(e.consume(d),r=0,f):d===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(d)}function h(d){if((d===45||_e(d))&&r++<63){const p=d===45?h:c;return e.consume(d),p}return n(d)}}const Bn={partial:!0,tokenize:Ou};function Ou(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const _o={continuation:{tokenize:Bu},exit:Vu,name:\"blockQuote\",tokenize:Lu};function Lu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function Bu(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(_o,t,n)(o)}}function Vu(e){e.exit(\"blockQuote\")}const bo={name:\"characterEscape\",tokenize:Hu};function Hu(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 ku(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const vo={name:\"characterReference\",tokenize:qu};function qu(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\"),l}function l(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),u):(e.enter(\"characterReferenceValue\"),a=31,o=_e,f(c))}function u(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Su,f):(e.enter(\"characterReferenceValue\"),a=7,o=wr,f(c))}function f(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===_e&&!mo(r.sliceSerialize(h))?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 Wi={partial:!0,tokenize:ju},Ki={concrete:!0,name:\"codeFenced\",tokenize:Uu};function Uu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return l;function l(v){return u(v)}function u(v){const D=r.events[r.events.length-1];return a=D&&D[1].type===\"linePrefix\"?D[2].sliceSerialize(D[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\"),L(v)?H(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||z(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(Wi,y,E)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(v))}function h(v){return v===null||z(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,d,\"whitespace\")(v)):v===96&&v===s?n(v):(e.consume(v),h)}function d(v){return v===null||z(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(v))}function p(v){return v===null||z(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===s?n(v):(e.consume(v),p)}function y(v){return e.attempt(i,E,b)(v)}function b(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),_}function _(v){return a>0&&L(v)?H(e,k,\"linePrefix\",a+1)(v):k(v)}function k(v){return v===null||z(v)?e.check(Wi,y,E)(v):(e.enter(\"codeFlowValue\"),x(v))}function x(v){return v===null||z(v)?(e.exit(\"codeFlowValue\"),k(v)):(e.consume(v),x)}function E(v){return e.exit(\"codeFenced\"),t(v)}function I(v,D,A){let $=0;return w;function w(O){return v.enter(\"lineEnding\"),v.consume(O),v.exit(\"lineEnding\"),T}function T(O){return v.enter(\"codeFencedFence\"),L(O)?H(v,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(O):N(O)}function N(O){return O===s?(v.enter(\"codeFencedFenceSequence\"),V(O)):A(O)}function V(O){return O===s?($++,v.consume(O),V):$>=o?(v.exit(\"codeFencedFenceSequence\"),L(O)?H(v,U,\"whitespace\")(O):U(O)):A(O)}function U(O){return O===null||z(O)?(v.exit(\"codeFencedFence\"),D(O)):A(O)}}}function ju(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 Qn={name:\"codeIndented\",tokenize:Ku},Wu={partial:!0,tokenize:Qu};function Ku(e,t,n){const r=this;return i;function i(u){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(u)}function a(u){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):z(u)?e.attempt(Wu,o,l)(u):(e.enter(\"codeFlowValue\"),s(u))}function s(u){return u===null||z(u)?(e.exit(\"codeFlowValue\"),o(u)):(e.consume(u),s)}function l(u){return e.exit(\"codeIndented\"),t(u)}}function Qu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const Gu={name:\"codeText\",previous:Ju,resolve:Yu,tokenize:Xu};function Yu(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 Ju(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Xu(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\"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),l):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):z(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),l):(e.enter(\"codeTextData\"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit(\"codeTextData\"),l(c)):(e.consume(c),u)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",u(c))}}class Zu{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&&Dt(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),Dt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Dt(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);Dt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Dt(this.left,n.reverse())}}}function Dt(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 wo(e){const t={};let n=-1,r,i,a,o,s,l,u;const f=new Zu(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\"&&(l=r[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type===\"lineEndingBlank\"&&(a+=2),a<l.length&&l[a][1].type===\"content\"))for(;++a<l.length&&l[a][1].type!==\"content\";)l[a][1].type===\"chunkText\"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,ec(f,n)),n=t[n],u=!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 be(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function ec(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,l=[],u={};let f,c,h=-1,d=n,p=0,y=0;const b=[y];for(;d;){for(;e.get(++i)[1]!==d;);a.push(i),d._tokenizer||(f=r.sliceStream(d),d.next||f.push(null),c&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=d,d=d.next}for(d=n;++h<s.length;)s[h][0]===\"exit\"&&s[h-1][0]===\"enter\"&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(y=h+1,b.push(y),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):b.pop(),h=b.length;h--;){const _=s.slice(b[h],b[h+1]),k=a.pop();l.push([k,k+_.length-1]),e.splice(k,2,_)}for(l.reverse(),h=-1;++h<l.length;)u[p+l[h][0]]=p+l[h][1],p+=l[h][1]-l[h][0]-1;return u}const tc={resolve:rc,tokenize:ic},nc={partial:!0,tokenize:ac};function rc(e){return wo(e),e}function ic(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):z(s)?e.check(nc,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 ac(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function So(e,t,n,r,i,a,o,s,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),h):_===null||_===32||_===41||vr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),y(_))}function h(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),d(_))}function d(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),h(_)):_===null||_===60||z(_)?n(_):(e.consume(_),_===92?p:d)}function p(_){return _===60||_===62||_===92?(e.consume(_),d):d(_)}function y(_){return!f&&(_===null||_===41||ue(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<u&&_===40?(e.consume(_),f++,y):_===41?(e.consume(_),f--,y):_===null||_===32||_===40||vr(_)?n(_):(e.consume(_),_===92?b:y)}function b(_){return _===40||_===41||_===92?(e.consume(_),y):y(_)}}function ko(e,t,n,r,i,a){const o=this;let s=0,l;return u;function u(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(a),f}function f(d){return s>999||d===null||d===91||d===93&&!l||d===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(d):d===93?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):z(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(d))}function c(d){return d===null||d===91||d===93||z(d)||s++>999?(e.exit(\"chunkString\"),f(d)):(e.consume(d),l||(l=!L(d)),d===92?h:c)}function h(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function xo(e,t,n,r,i,a){let o;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),u(h))}function u(h){return h===o?(e.exit(a),l(o)):h===null?n(h):z(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,u,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(h))}function f(h){return h===o||h===null||z(h)?(e.exit(\"chunkString\"),u(h)):(e.consume(h),h===92?c:f)}function c(h){return h===o||h===92?(e.consume(h),f):f(h)}}function Ht(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const oc={name:\"definition\",tokenize:lc},sc={partial:!0,tokenize:uc};function lc(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return ko.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),l):n(d)}function l(d){return ue(d)?Ht(e,u)(d):u(d)}function u(d){return So(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(sc,c,c)(d)}function c(d){return L(d)?H(e,h,\"whitespace\")(d):h(d)}function h(d){return d===null||z(d)?(e.exit(\"definition\"),r.parser.defined.push(i),t(d)):n(d)}}function uc(e,t,n){return r;function r(s){return ue(s)?Ht(e,i)(s):n(s)}function i(s){return xo(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const cc={name:\"hardBreakEscape\",tokenize:fc};function fc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return z(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const dc={name:\"headingAtx\",resolve:hc,tokenize:pc};function hc(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\"},be(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function pc(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||ue(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),l(f)):f===null||z(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit(\"atxHeadingSequence\"),s(f))}function u(f){return f===null||f===35||ue(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),u)}}const gc=[\"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\"],Qi=[\"pre\",\"script\",\"style\",\"textarea\"],mc={concrete:!0,name:\"htmlFlow\",resolveTo:bc,tokenize:vc},yc={partial:!0,tokenize:Sc},_c={partial:!0,tokenize:wc};function bc(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 vc(e,t,n){const r=this;let i,a,o,s,l;return u;function u(g){return f(g)}function f(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,y):g===63?(e.consume(g),i=3,r.interrupt?t:m):De(g)?(e.consume(g),o=String.fromCharCode(g),b):n(g)}function h(g){return g===45?(e.consume(g),i=2,d):g===91?(e.consume(g),i=5,s=0,p):De(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function d(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:N:p):n(g)}function y(g){return De(g)?(e.consume(g),o=String.fromCharCode(g),b):n(g)}function b(g){if(g===null||g===47||g===62||ue(g)){const q=g===47,ce=o.toLowerCase();return!q&&!a&&Qi.includes(ce)?(i=1,r.interrupt?t(g):N(g)):gc.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):N(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?k(g):x(g))}return g===45||_e(g)?(e.consume(g),o+=String.fromCharCode(g),b):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:N):n(g)}function k(g){return L(g)?(e.consume(g),k):w(g)}function x(g){return g===47?(e.consume(g),w):g===58||g===95||De(g)?(e.consume(g),E):L(g)?(e.consume(g),x):w(g)}function E(g){return g===45||g===46||g===58||g===95||_e(g)?(e.consume(g),E):I(g)}function I(g){return g===61?(e.consume(g),v):L(g)?(e.consume(g),I):x(g)}function v(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,D):L(g)?(e.consume(g),v):A(g)}function D(g){return g===l?(e.consume(g),l=null,$):g===null||z(g)?n(g):(e.consume(g),D)}function A(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||ue(g)?I(g):(e.consume(g),A)}function $(g){return g===47||g===62||L(g)?x(g):n(g)}function w(g){return g===62?(e.consume(g),T):n(g)}function T(g){return g===null||z(g)?N(g):L(g)?(e.consume(g),T):n(g)}function N(g){return g===45&&i===2?(e.consume(g),ee):g===60&&i===1?(e.consume(g),Z):g===62&&i===4?(e.consume(g),R):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),Ce):z(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(yc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(_c,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),O}function O(g){return g===null||z(g)?V(g):(e.enter(\"htmlFlowData\"),N(g))}function ee(g){return g===45?(e.consume(g),m):N(g)}function Z(g){return g===47?(e.consume(g),o=\"\",me):N(g)}function me(g){if(g===62){const q=o.toLowerCase();return Qi.includes(q)?(e.consume(g),R):N(g)}return De(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),me):N(g)}function Ce(g){return g===93?(e.consume(g),m):N(g)}function m(g){return g===62?(e.consume(g),R):g===45&&i===2?(e.consume(g),m):N(g)}function R(g){return g===null||z(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),R)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function wc(e,t,n){const r=this;return i;function i(o){return z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Sc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Bn,t,n)}}const kc={name:\"htmlText\",tokenize:xc};function xc(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),l}function l(m){return m===33?(e.consume(m),u):m===47?(e.consume(m),I):m===63?(e.consume(m),x):De(m)?(e.consume(m),A):n(m)}function u(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,p):De(m)?(e.consume(m),k):n(m)}function f(m){return m===45?(e.consume(m),d):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),h):z(m)?(o=c,Z(m)):(e.consume(m),c)}function h(m){return m===45?(e.consume(m),d):c(m)}function d(m){return m===62?ee(m):m===45?h(m):c(m)}function p(m){const R=\"CDATA[\";return m===R.charCodeAt(a++)?(e.consume(m),a===R.length?y:p):n(m)}function y(m){return m===null?n(m):m===93?(e.consume(m),b):z(m)?(o=y,Z(m)):(e.consume(m),y)}function b(m){return m===93?(e.consume(m),_):y(m)}function _(m){return m===62?ee(m):m===93?(e.consume(m),_):y(m)}function k(m){return m===null||m===62?ee(m):z(m)?(o=k,Z(m)):(e.consume(m),k)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=x,Z(m)):(e.consume(m),x)}function E(m){return m===62?ee(m):x(m)}function I(m){return De(m)?(e.consume(m),v):n(m)}function v(m){return m===45||_e(m)?(e.consume(m),v):D(m)}function D(m){return z(m)?(o=D,Z(m)):L(m)?(e.consume(m),D):ee(m)}function A(m){return m===45||_e(m)?(e.consume(m),A):m===47||m===62||ue(m)?$(m):n(m)}function $(m){return m===47?(e.consume(m),ee):m===58||m===95||De(m)?(e.consume(m),w):z(m)?(o=$,Z(m)):L(m)?(e.consume(m),$):ee(m)}function w(m){return m===45||m===46||m===58||m===95||_e(m)?(e.consume(m),w):T(m)}function T(m){return m===61?(e.consume(m),N):z(m)?(o=T,Z(m)):L(m)?(e.consume(m),T):$(m)}function N(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):z(m)?(o=N,Z(m)):L(m)?(e.consume(m),N):(e.consume(m),U)}function V(m){return m===i?(e.consume(m),i=void 0,O):m===null?n(m):z(m)?(o=V,Z(m)):(e.consume(m),V)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||ue(m)?$(m):(e.consume(m),U)}function O(m){return m===47||m===62||ue(m)?$(m):n(m)}function ee(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\"),me}function me(m){return L(m)?H(e,Ce,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):Ce(m)}function Ce(m){return e.enter(\"htmlTextData\"),o(m)}}const Kr={name:\"labelEnd\",resolveAll:Ec,resolveTo:Ac,tokenize:$c},Cc={tokenize:Dc},Ic={tokenize:Tc},Pc={tokenize:Nc};function Ec(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&&be(e,0,e.length,n),e}function Ac(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 l={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},u={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\",l,t],[\"enter\",u,t]],s=oe(s,e.slice(a+1,a+r+3)),s=oe(s,[[\"enter\",f,t]]),s=oe(s,Ln(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=oe(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",u,t]]),s=oe(s,e.slice(o+1)),s=oe(s,[[\"exit\",l,t]]),be(e,a,e.length,s),e}function $c(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(h){return a?a._inactive?c(h):(o=r.parser.defined.includes(Yt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),l):n(h)}function l(h){return h===40?e.attempt(Cc,f,o?f:c)(h):h===91?e.attempt(Ic,f,o?u:c)(h):o?f(h):c(h)}function u(h){return e.attempt(Pc,f,c)(h)}function f(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function Dc(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 ue(c)?Ht(e,a)(c):a(c)}function a(c){return c===41?f(c):So(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ue(c)?Ht(e,l)(c):f(c)}function s(c){return n(c)}function l(c){return c===34||c===39||c===40?xo(e,u,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function u(c){return ue(c)?Ht(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 Tc(e,t,n){const r=this;return i;function i(s){return ko.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Nc(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 Rc={name:\"labelStartImage\",resolveAll:Kr.resolveAll,tokenize:Mc};function Mc(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 zc={name:\"labelStartLink\",resolveAll:Kr.resolveAll,tokenize:Fc};function Fc(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:Oc};function Oc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const vn={name:\"thematicBreak\",tokenize:Lc};function Lc(e,t,n){let r=0,i;return a;function a(u){return e.enter(\"thematicBreak\"),o(u)}function o(u){return i=u,s(u)}function s(u){return u===i?(e.enter(\"thematicBreakSequence\"),l(u)):r>=3&&(u===null||z(u))?(e.exit(\"thematicBreak\"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit(\"thematicBreakSequence\"),L(u)?H(e,s,\"whitespace\")(u):s(u))}}const pe={continuation:{tokenize:qc},exit:jc,name:\"list\",tokenize:Hc},Bc={partial:!0,tokenize:Wc},Vc={partial:!0,tokenize:Uc};function Hc(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(d){const p=r.containerState.type||(d===42||d===43||d===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||d===r.containerState.marker:wr(d)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(vn,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),l(d)}return n(d)}function l(d){return wr(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),u(d)):n(d)}function u(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(Bn,r.interrupt?n:f,e.attempt(Bc,h,c))}function f(d){return r.containerState.initialBlankLine=!0,a++,h(d)}function c(d){return L(d)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(d),e.exit(\"listItemPrefixWhitespace\"),h):n(d)}function h(d){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(d)}}function qc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Vc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(pe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function Uc(e,t,n){const r=this;return H(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 jc(e){e.exit(this.containerState.type)}function Wc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Gi={name:\"setextUnderline\",resolveTo:Kc,tokenize:Qc};function Kc(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 Qc(e,t,n){const r=this;let i;return a;function a(u){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=u,o(u)):n(u)}function o(u){return e.enter(\"setextHeadingLineSequence\"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit(\"setextHeadingLineSequence\"),L(u)?H(e,l,\"lineSuffix\")(u):l(u))}function l(u){return u===null||z(u)?(e.exit(\"setextHeadingLine\"),t(u)):n(u)}}const Gc={tokenize:Yc};function Yc(e){const t=this,n=e.attempt(Bn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tc,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 Jc={resolveAll:Io()},Xc=Co(\"string\"),Zc=Co(\"text\");function Co(e){return{resolveAll:Io(e===\"text\"?ef: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 u(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),l}function l(f){return u(f)?(n.exit(\"data\"),a(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const c=i[f];let h=-1;if(c)for(;++h<c.length;){const d=c[h];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function Io(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 ef(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,l;for(;a--;){const u=i[a];if(typeof u==\"string\"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||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={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,[\"enter\",u,t],[\"exit\",u,t]),n+=2)}n++}return e}const tf={42:pe,43:pe,45:pe,48:pe,49:pe,50:pe,51:pe,52:pe,53:pe,54:pe,55:pe,56:pe,57:pe,62:_o},nf={91:oc},rf={[-2]:Qn,[-1]:Qn,32:Qn},af={35:dc,42:vn,45:[Gi,vn],60:mc,61:Gi,95:vn,96:Ki,126:Ki},of={38:vo,92:bo},sf={[-5]:Gn,[-4]:Gn,[-3]:Gn,33:Rc,38:vo,42:Sr,60:[zu,kc],91:zc,92:[cc,bo],93:Kr,95:Sr,96:Gu},lf={null:[Sr,Jc]},uf={null:[42,95]},cf={null:[]},ff=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:uf,contentInitial:nf,disable:cf,document:tf,flow:af,flowInitial:rf,insideSpan:lf,string:of,text:sf},Symbol.toStringTag,{value:\"Module\"}));function df(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 l={attempt:D(I),check:D(v),consume:k,enter:x,exit:E,interrupt:D(v,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:d,write:c};let f=t.tokenize.call(u,l);return t.resolveAll&&a.push(t),u;function c(T){return o=oe(o,T),b(),o[o.length-1]!==null?[]:(A(t,0),u.events=Ln(a,u.events,u),u.events)}function h(T,N){return pf(d(T),N)}function d(T){return hf(o,T)}function p(){const{_bufferIndex:T,_index:N,line:V,column:U,offset:O}=r;return{_bufferIndex:T,_index:N,line:V,column:U,offset:O}}function y(T){i[T.line]=T.column,w()}function b(){let T;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<N.length;)_(N.charCodeAt(r._bufferIndex));else _(N)}}function _(T){f=f(T)}function k(T){z(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,w()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=T}function x(T,N){const V=N||{};return V.type=T,V.start=p(),u.events.push([\"enter\",V,u]),s.push(V),V}function E(T){const N=s.pop();return N.end=p(),u.events.push([\"exit\",N,u]),N}function I(T,N){A(T,N.from)}function v(T,N){N.restore()}function D(T,N){return V;function V(U,O,ee){let Z,me,Ce,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):R(U);function R(re){return At;function At(je){const pt=je!==null&&re[je],gt=je!==null&&re.null,qn=[...Array.isArray(pt)?pt:pt?[pt]:[],...Array.isArray(gt)?gt:gt?[gt]:[]];return j(qn)(je)}}function j(re){return Z=re,me=0,re.length===0?ee:g(re[me])}function g(re){return At;function At(je){return m=$(),Ce=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?ce():re.tokenize.call(N?Object.assign(Object.create(u),N):u,l,q,ce)(je)}}function q(re){return T(Ce,m),O}function ce(re){return m.restore(),++me<Z.length?g(Z[me]):ee}}}function A(T,N){T.resolveAll&&!a.includes(T)&&a.push(T),T.resolve&&be(u.events,N,u.events.length-N,T.resolve(u.events.slice(N),u)),T.resolveTo&&(u.events=T.resolveTo(u.events,u))}function $(){const T=p(),N=u.previous,V=u.currentConstruct,U=u.events.length,O=Array.from(s);return{from:U,restore:ee};function ee(){r=T,u.previous=N,u.currentConstruct=V,u.events.length=U,s=O,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function hf(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 pf(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 gf(e){const r={constructs:pu([ff,...(e||{}).extensions||[]]),content:i(Au),defined:[],document:i(Du),flow:i(Gc),lazy:{},string:i(Xc),text:i(Zc)};return r;function i(a){return o;function o(s){return df(r,a,s)}}}function mf(e){for(;!wo(e););return e}const Yi=/[\\0\\t\\n\\r]/g;function yf(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const l=[];let u,f,c,h,d;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(Yi.lastIndex=c,u=Yi.exec(a),h=u&&u.index!==void 0?u.index:a.length,d=a.charCodeAt(h),!u){t=a.slice(c);break}if(d===10&&c===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<h&&(l.push(a.slice(c,h)),e+=h-c),d){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}function _f(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Eu(n)(mf(gf(n).document().write(yf()(e,t,!0))))}const Yn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function bf(){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=Yn[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=Yn[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,vf)),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\"+Yn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function vf(e,t){return t===\"|\"?t:e}class wf{constructor(){this.map=[]}add(t,n,r){Sf(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 Sf(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 kf(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 xf(){return{flow:{null:{name:\"table\",tokenize:Cf,resolveAll:If}}}}function Cf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(w){let T=r.events.length-1;for(;T>-1;){const U=r.events[T][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")T--;else break}const N=T>-1?r.events[T][1].type:null,V=N===\"tableHead\"||N===\"tableRow\"?v:l;return V===v&&r.parser.lazy[r.now().line]?n(w):V(w)}function l(w){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),u(w)}function u(w){return w===124||(o=!0,a+=1),f(w)}function f(w){return w===null?n(w):z(w)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(w),e.exit(\"lineEnding\"),d):n(w):L(w)?H(e,f,\"whitespace\")(w):(a+=1,o&&(o=!1,i+=1),w===124?(e.enter(\"tableCellDivider\"),e.consume(w),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(w)))}function c(w){return w===null||w===124||ue(w)?(e.exit(\"data\"),f(w)):(e.consume(w),w===92?h:c)}function h(w){return w===92||w===124?(e.consume(w),c):c(w)}function d(w){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(w):(e.enter(\"tableDelimiterRow\"),o=!1,L(w)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(w):p(w))}function p(w){return w===45||w===58?b(w):w===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(w),e.exit(\"tableCellDivider\"),y):I(w)}function y(w){return L(w)?H(e,b,\"whitespace\")(w):b(w)}function b(w){return w===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(w),e.exit(\"tableDelimiterMarker\"),_):w===45?(a+=1,_(w)):w===null||z(w)?E(w):I(w)}function _(w){return w===45?(e.enter(\"tableDelimiterFiller\"),k(w)):I(w)}function k(w){return w===45?(e.consume(w),k):w===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(w),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(w))}function x(w){return L(w)?H(e,E,\"whitespace\")(w):E(w)}function E(w){return w===124?p(w):w===null||z(w)?!o||i!==a?I(w):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(w)):I(w)}function I(w){return n(w)}function v(w){return e.enter(\"tableRow\"),D(w)}function D(w){return w===124?(e.enter(\"tableCellDivider\"),e.consume(w),e.exit(\"tableCellDivider\"),D):w===null||z(w)?(e.exit(\"tableRow\"),t(w)):L(w)?H(e,D,\"whitespace\")(w):(e.enter(\"data\"),A(w))}function A(w){return w===null||w===124||ue(w)?(e.exit(\"data\"),D(w)):(e.consume(w),w===92?$:A)}function $(w){return w===92||w===124?(e.consume(w),A):A(w)}}function If(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,u,f,c;const h=new wf;for(;++n<e.length;){const d=e[n],p=d[1];d[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,l!==0&&(Ji(h,t,l,u,f),f=void 0,l=0),u={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",u,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",f,t]])),i=p.type===\"tableDelimiterRow\"?2:f?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=pn(h,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=pn(h,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,l=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(l=n,a[1]!==0?(o[0]=o[1],c=pn(h,t,a,i,n,c)):o[1]!==0&&(c=pn(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(l!==0&&Ji(h,t,l,u,f),h.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]===\"enter\"&&d[1].type===\"table\"&&(d[1]._align=kf(t.events,n))}return e}function pn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},yt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const l=yt(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const u=yt(t.events,n[2]),f=yt(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const h=t.events[n[2]],d=t.events[n[3]];if(h[1].end=Object.assign({},d[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,y=n[3]-n[2]-1;e.add(p,y,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},yt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ji(e,t,n,r,i){const a=[],o=yt(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 yt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Pf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Ef(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 l=-1;for(;++l<o.length;)if(o[l][0]===\"enter\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]===\"exit\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type=\"strikethroughSequence\",o[u][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},h=[[\"enter\",f,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"enter\",c,s]],d=s.parser.constructs.insideSpan.null;d&&be(h,h.length,0,Ln(d,o.slice(u+1,l),s)),be(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"exit\",f,s]]),be(o,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type===\"strikethroughSequenceTemporary\"&&(o[l][1].type=\"data\");return o}function a(o,s,l){const u=this.previous,f=this.events;let c=0;return h;function h(p){return u===126&&f[f.length-1][1].type!==\"characterEscape\"?l(p):(o.enter(\"strikethroughSequenceTemporary\"),d(p))}function d(p){const y=Nn(u);if(p===126)return c>1?l(p):(o.consume(p),c++,d);if(c<2&&!n)return l(p);const b=o.exit(\"strikethroughSequenceTemporary\"),_=Nn(p);return b._open=!_||_===2&&!!y,b._close=!y||y===2&&!!_,s(p)}}}function Af(e){return _f(e,{allowDangerousHtml:!0,extensions:[xf(),Ef(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[bf(),Pf()]})}const $f={update:e=>{throw new Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>({})},xe=Ge({}),sn=Ge($f),he=Ge(!1),Xi=Ge(!1),kr=Ge(null);function Df(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>Po(a,o,t));return S(Y,{children:i})}function Po(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const l of Array.from(r.attributes))o[l.name]=l.value;const s=Array.from(r.childNodes).map((l,u)=>Po(l,u,n));return G(i,o,...s)}return null}function Tf({node:e}){const t=On(),n=Q(he),r=Q(xe),i=Q(Xi),a={};for(const[u,f]of Object.entries(e.attributes))a[u]=t(f)??f;const o=e.tag.toLowerCase()===\"svg\",s=e.children.length>0?i||o?Qr(e.children):Ee(e.children,{nobr:n,locals:r}):void 0,l=G(e.tag,a,s);return o?S(Xi.Provider,{value:!0,children:l}):l}function Nf(){const e=Q(kr),t=Q(he),n=Q(xe);return!e||e.length===0?null:S(Y,{children:Ee(e,{nobr:t,locals:n})})}function Rf(e,t){if(fu(e.name))return null;const n=su(e.name);if(n)return S(ou,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=uu(e.name);return r?S(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):S(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function xr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?S(Nf,{},t):S(eu,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return S(tu,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Rf(e,t);case\"html\":return S(Tf,{node:e},t);default:return e}}function Qr(e){return e.length===0?null:e.map((t,n)=>xr(t,n))}function Mf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function zf(e,t){const n=C.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:e.scope===\"transient\"?a=n.transient[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ee(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,l)=>xr(s,l));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const l=e[s];if(l.type===\"text\")i+=l.value;else if(l.type===\"variable\"&&Mf(i))i+=zf(l,a);else{const u=r.length;r.push(xr(l,s)),i+=`<span data-tw=\"${u}\"></span>`}}const o=Af(i);return Df(o,r,t?.nobr)}function Ff(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)||i.history.length===0||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Of(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}function Lf(){const e=new Map,t=new Map,n=new Map;return{type:\"memory\",async putSave(r){e.set(r.meta.id,r)},async getSave(r){return e.get(r)},async deleteSave(r){e.delete(r)},async getSavesByIfid(r){return[...e.values()].filter(i=>i.meta.ifid===r)},async deleteSavesByIfid(r){for(const i of[...e.keys()]){const a=e.get(i);a&&a.meta.ifid===r&&e.delete(i)}},async deleteSavesByPlaythrough(r){const i=[];for(const a of[...e.keys()]){const o=e.get(a);o&&o.meta.playthroughId===r&&(e.delete(a),i.push(a))}return i},async putPlaythrough(r){t.set(r.id,r)},async getPlaythroughsByIfid(r){return[...t.values()].filter(i=>i.ifid===r)},async deletePlaythroughsByIfid(r){for(const i of[...t.keys()]){const a=t.get(i);a&&a.ifid===r&&t.delete(i)}},async deletePlaythroughById(r){t.delete(r)},async getMeta(r){return n.get(r)},async setMeta(r,i){n.set(r,i)},async deleteMeta(r){n.delete(r)},async deleteMetaByPrefix(r){for(const i of[...n.keys()])i.startsWith(r)&&n.delete(i)},async deleteMetaByIfid(r){for(const i of[...n.keys()])i.includes(r)&&n.delete(i)},async getAllMetaKeys(){return[...n.keys()]},async destroy(){e.clear(),t.clear(),n.clear()}}}const ze=\"spindle.save.\",Tt=\"spindle.pt.\",Xe=\"spindle.meta.\",mt=\"spindle.idx.saves.\",Nt=\"spindle.idx.pt.\",Rt=\"spindle.idx.saves-pt.\";function Oe(e){const t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function qt(e,t){localStorage.setItem(e,JSON.stringify(t))}function Fe(e){localStorage.removeItem(e)}function tt(e){return Oe(e)??[]}function Jn(e,t){const n=tt(e);n.includes(t)||(n.push(t),qt(e,n))}function Mt(e,t){const n=tt(e).filter(r=>r!==t);qt(e,n)}function Bf(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;qt(`${ze}${t}`,e),Jn(`${mt}${e.meta.ifid}`,t),Jn(`${Rt}${e.meta.playthroughId}`,t)},async getSave(e){return Oe(`${ze}${e}`)},async deleteSave(e){const t=Oe(`${ze}${e}`);t&&(Mt(`${mt}${t.meta.ifid}`,e),Mt(`${Rt}${t.meta.playthroughId}`,e)),Fe(`${ze}${e}`)},async getSavesByIfid(e){const t=tt(`${mt}${e}`),n=[];for(const r of t){const i=Oe(`${ze}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=tt(`${mt}${e}`);for(const n of t){const r=Oe(`${ze}${n}`);r&&Mt(`${Rt}${r.meta.playthroughId}`,n),Fe(`${ze}${n}`)}Fe(`${mt}${e}`)},async deleteSavesByPlaythrough(e){const t=tt(`${Rt}${e}`);for(const n of t){const r=Oe(`${ze}${n}`);r&&Mt(`${mt}${r.meta.ifid}`,n),Fe(`${ze}${n}`)}return Fe(`${Rt}${e}`),t},async putPlaythrough(e){qt(`${Tt}${e.id}`,e),Jn(`${Nt}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){const t=tt(`${Nt}${e}`),n=[];for(const r of t){const i=Oe(`${Tt}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=tt(`${Nt}${e}`);for(const n of t)Fe(`${Tt}${n}`);Fe(`${Nt}${e}`)},async deletePlaythroughById(e){const t=Oe(`${Tt}${e}`);t&&Mt(`${Nt}${t.ifid}`,e),Fe(`${Tt}${e}`)},async getMeta(e){return Oe(`${Xe}${e}`)},async setMeta(e,t){qt(`${Xe}${e}`,t)},async deleteMeta(e){Fe(`${Xe}${e}`)},async deleteMetaByPrefix(e){const t=`${Xe}${e}`;for(const n of Object.keys(localStorage))n.startsWith(t)&&localStorage.removeItem(n)},async deleteMetaByIfid(e){for(const t of Object.keys(localStorage))t.startsWith(Xe)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){const e=[];for(const t of Object.keys(localStorage))t.startsWith(Xe)&&e.push(t.slice(Xe.length));return e},async destroy(){for(const e of Object.keys(localStorage))e.startsWith(\"spindle.\")&&localStorage.removeItem(e)}}}const Zi=\"spindle\",Vf=1;function Hf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Zi,Vf);s.onupgradeneeded=()=>{const l=s.result;if(!l.objectStoreNames.contains(\"saves\")){const u=l.createObjectStore(\"saves\",{keyPath:\"meta.id\"});u.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),u.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}l.objectStoreNames.contains(\"playthroughs\")||l.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),l.objectStoreNames.contains(\"meta\")||l.createObjectStore(\"meta\",{keyPath:\"key\"})},s.onsuccess=()=>a(s.result),s.onerror=()=>o(s.error)}),e)}function n(a,o){return t().then(s=>s.transaction(a,o).objectStore(a))}function r(a){return new Promise((o,s)=>{a.onsuccess=()=>o(a.result),a.onerror=()=>s(a.error)})}async function i(a,o,s){const u=(await n(a,\"readonly\")).index(o);return await r(u.getAll(s))??[]}return{type:\"indexeddb\",async putSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.put(a))},async getSave(a){const o=await n(\"saves\",\"readonly\");return await r(o.get(a))??void 0},async deleteSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.delete(a))},async getSavesByIfid(a){return i(\"saves\",\"ifid\",a)},async deleteSavesByIfid(a){const o=await i(\"saves\",\"ifid\",a),s=await n(\"saves\",\"readwrite\");for(const l of o)await r(s.delete(l.meta.id))},async deleteSavesByPlaythrough(a){const o=await i(\"saves\",\"playthroughId\",a),s=await n(\"saves\",\"readwrite\"),l=[];for(const u of o)await r(s.delete(u.meta.id)),l.push(u.meta.id);return l},async putPlaythrough(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.put(a))},async getPlaythroughsByIfid(a){return i(\"playthroughs\",\"ifid\",a)},async deletePlaythroughsByIfid(a){const o=await i(\"playthroughs\",\"ifid\",a),s=await n(\"playthroughs\",\"readwrite\");for(const l of o)await r(s.delete(l.id))},async deletePlaythroughById(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.delete(a))},async getMeta(a){const o=await n(\"meta\",\"readonly\"),s=await r(o.get(a));return s?s.value:void 0},async setMeta(a,o){const s=await n(\"meta\",\"readwrite\");await r(s.put({key:a,value:o}))},async deleteMeta(a){const o=await n(\"meta\",\"readwrite\");await r(o.delete(a))},async deleteMetaByPrefix(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.startsWith(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async deleteMetaByIfid(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.includes(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async getAllMetaKeys(){const a=await n(\"meta\",\"readonly\");return(await r(a.getAll())).map(s=>s.key)},async destroy(){(await t()).close(),e=null,await new Promise((o,s)=>{const l=indexedDB.deleteDatabase(Zi);l.onsuccess=()=>o(),l.onerror=()=>s(l.error)})}}}let bt=null;async function qf(){if(typeof indexedDB<\"u\")try{return await new Promise((e,t)=>{const n=indexedDB.open(\"__spindle_probe__\",1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(\"__spindle_probe__\"),e()},n.onerror=()=>t(n.error)}),Hf()}catch{}if(typeof localStorage<\"u\")try{const e=\"__spindle_probe__\";localStorage.setItem(e,\"1\");const t=localStorage.getItem(e);if(localStorage.removeItem(e),t===\"1\")return Bf()}catch{}return Lf()}async function J(){return bt||(bt=await qf(),bt)}function Uf(){bt=null}function ea(){return bt?.type??\"memory\"}const Eo=new Map,Vn=new Map;function jf(e,t){Eo.set(e,t),Vn.set(t,e)}function Wf(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 l=0;l<r.length;l++)s[l]=n(r[l]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[l,u]of r)s.set(n(l),n(u));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const l of r)s.add(n(l));return s}const a=i.constructor;if(Vn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}if(Wf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}return r}return n(e)}const nt=\"__spindle_class__\",rt=\"__spindle_data__\";function at(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),{[nt]:\"__Date__\",[rt]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[nt]:\"__RegExp__\",[rt]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const l=r.map(u=>n(u));return t.delete(i),l}if(r instanceof Map){const l=[...r].map(([u,f])=>[n(u),n(f)]);return t.delete(i),{[nt]:\"__Map__\",[rt]:{entries:l}}}if(r instanceof Set){const l=[...r].map(u=>n(u));return t.delete(i),{[nt]:\"__Set__\",[rt]:{entries:l}}}const a=i.constructor,o=Vn.get(a);if(o!==void 0){const l={};for(const u of Object.keys(i))l[u]=n(i[u]);return t.delete(i),{[nt]:o,[rt]:l}}const s={};for(const l of Object.keys(i))s[l]=n(i[l]);return t.delete(i),s}return n(e)}function ot(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(nt in r&&rt in r){const o=r[nt],s=r[rt];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const f=s.entries;return new Map(f.map(([c,h])=>[t(c),t(h)]))}if(o===\"__Set__\"){const f=s.entries;return new Set(f.map(c=>t(c)))}const l=Eo.get(o);if(!l){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 u=Object.create(l.prototype);for(const f of Object.keys(s))u[f]=t(s[f]);return u}const i=r.constructor;if(Vn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Cr=null,Ir=null,ta=!1;function Kf(e){Cr=e}function Qf(e){Ir=e}function Gf(e){if(Ir)try{const i=new Function(\"passage\",\"variables\",Ir)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Cr)try{const r=Cr(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 Yf(){ta||(ta=!0)}async function na(e){const t=await J(),r=(await t.getPlaythroughsByIfid(e)).length+1,i=crypto.randomUUID(),a={id:i,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await t.putPlaythrough(a),await t.setMeta(`currentPlaythroughId.${e}`,i),i}async function Jf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function Ao(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Gf(n),passage:n.passage,custom:r},o=X(n);o.variables=at(o.variables),o.history=o.history.map(l=>({...l,variables:at(l.variables)}));const s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function $o(e,t,n){const r=await J(),i=await r.getSave(e);if(!i)return;const a=X(t);a.variables=at(a.variables),a.history=a.history.map(s=>({...s,variables:at(s.variables)}));const o={meta:{...i.meta,updatedAt:new Date().toISOString(),passage:t.passage,...n!=null?{custom:{...i.meta.custom,...n}}:{}},payload:a};return o.meta.estimatedBytes=JSON.stringify(a).length,await r.putSave(o),o}async function Xf(e){const t=await(await J()).getSave(e);if(!t)return;const n=t.payload;return n.variables=ot(n.variables),n.history=n.history.map(r=>({...r,variables:ot(r.variables)})),n}async function Zf(e){await(await J()).deleteSave(e)}async function ed(e,t){const n=await J(),r=await n.getSave(e);if(!r)return;const i={...r,meta:{...r.meta,title:t,updatedAt:new Date().toISOString()}};await n.putSave(i)}async function td(e){const t=await J(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(const l of r)i.set(l.id,l);const a=new Map;for(const l of n){const u=l.meta.playthroughId,f=a.get(u);f?f.push(l):a.set(u,[l])}for(const l of a.values())l.sort((u,f)=>new Date(f.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const o=[],s=[...i.values()].sort((l,u)=>new Date(u.createdAt).getTime()-new Date(l.createdAt).getTime());for(const l of s){const u=a.get(l.id)??[];o.push({playthrough:l,saves:u})}for(const[l,u]of a)i.has(l)||o.push({playthrough:{id:l,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const nd=\"autosave.\",rd=\"slot.\",Hn=\"slotIndex.\";function ln(e,t){return t!=null?`${rd}${t}.${e}`:`${nd}${e}`}async function id(e,t,n,r,i){const a=await J(),o=ln(e,r),s=await a.getMeta(o);if(s){const u=await $o(s,n,i);if(u)return u}const l=await Ao(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,l.meta.id),r!=null){const u=`${Hn}${e}`,f=await a.getMeta(u)??[];f.includes(r)||await a.setMeta(u,[...f,r])}return l}async function ra(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function ad(e,t){const n=ln(e,t),r=await(await J()).getMeta(n);if(r)return Xf(r)}async function Pr(e){const t={};await ra(e)&&(t[\"\"]=!0);const n=`${Hn}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await ra(e,i)&&(t[i]=!0);return t}async function Er(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(!i)return null;const a=await n.getSave(i);return a?{slot:t??\"\",title:a.meta.title,passage:a.meta.passage,createdAt:a.meta.createdAt,updatedAt:a.meta.updatedAt,custom:a.meta.custom??{}}:null}async function od(e){const t=[],n=await Er(e);n&&t.push(n);const r=`${Hn}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await Er(e,a);o&&t.push(o)}return t}async function sd(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${Hn}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Gr=\"spindle.session.\";function ld(e,t){try{sessionStorage.setItem(`${Gr}${e}`,JSON.stringify(t))}catch{}}function ud(e){try{const t=sessionStorage.getItem(`${Gr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Of(n))return;const r=n;return r.variables=ot(r.variables),r.history=r.history.map(i=>({...i,variables:ot(i.variables)})),r}catch{return}}function Do(e){try{sessionStorage.removeItem(`${Gr}${e}`)}catch{}}async function cd(e){const t=await(await J()).getSave(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function fd(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=await J(),r=X(e.save);if(r.meta.id=crypto.randomUUID(),r.meta.updatedAt=new Date().toISOString(),!(await n.getPlaythroughsByIfid(t)).some(o=>o.id===r.meta.playthroughId)){const o={id:r.meta.playthroughId,ifid:t,createdAt:r.meta.createdAt,label:\"Imported\"};await n.putPlaythrough(o)}return await n.putSave(r),r}async function dd(e){const t=await J(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e);let i=0;for(const a of n)if(a.meta.estimatedBytes!=null)i+=a.meta.estimatedBytes;else{const o=JSON.stringify(a.payload).length;a.meta.estimatedBytes=o,await t.putSave(a),i+=o}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}}async function To(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Do(e)}async function No(){if(await(await J()).destroy(),Uf(),typeof sessionStorage<\"u\"){const t=[];for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);r?.startsWith(\"spindle.session.\")&&t.push(r)}for(const n of t)sessionStorage.removeItem(n)}}async function Ro(e,t){const n=await J(),r=await n.deleteSavesByPlaythrough(t);await n.deletePlaythroughById(t);const i=new Set(r),a=await n.getAllMetaKeys();for(const l of a)if(l.startsWith(\"slot.\")||l.startsWith(\"autosave.\")){const u=await n.getMeta(l);u&&i.has(u)&&await n.deleteMeta(l)}const o=`currentPlaythroughId.${e}`;await n.getMeta(o)===t&&await n.deleteMeta(o)}function Mo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=Ct(t.content),i=It(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),Pe(G(()=>Ee(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&Qf(n.content)}const hd=new Set([\"storyinit\",\"beforerestart\",\"actionsChanged\",\"variableChanged\",\"beforesave\",\"aftersave\",\"beforeload\",\"afterload\",\"beforenavigate\",\"afternavigate\"]);let Ar=new Map;function pd(e,t){if(!hd.has(e))throw new Error(`spindle: Unknown event \"${e}\".`);let n=Ar.get(e);return n||(n=new Set,Ar.set(e,n)),n.add(t),()=>{n.delete(t)}}function fe(e,...t){const n=Ar.get(e);if(n)for(const r of[...n])r(...t)}let zo=0,Se=[],Xn=!1,dt=[],Ut=null,He=null;function Yr(e){const t=C.getState();try{return!!Et(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Fo(e,t){const n=zo++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Yr(e),priority:i?.priority??0};return Se.push(o),Se.sort((s,l)=>l.priority-s.priority),()=>{Se=Se.filter(s=>s.id!==n)}}function Oo(e){Se=Se.filter(t=>t.name!==e)}function gd(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();uo(n.run,r.variables,r.temporary)}n.dialog&&(dt.push({passageName:n.dialog}),Ut?.()),n.goto&&C.getState().navigate(n.goto)}}const md=10;function yd(){if(!Xn){Xn=!0;try{for(let e=0;e<md;e++){let t=!1;const n=[...Se];for(const r of n){if(!Se.includes(r))continue;const i=Yr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(Se=Se.filter(o=>o.id!==r.id)),gd(r))}if(!t)break}}finally{Xn=!1}}}function _d(){for(const e of Se)e.lastResult=Yr(e.condition)}function bd(){Se=[],dt=[],zo=0,He?.closeAll()}function vd(e){return Ut=e,dt.length>0&&e(),()=>{Ut===e&&(Ut=null)}}function wd(){return dt.shift()}function Sd(){return dt.length}function kd(e){He?He.push(e):(dt.push(e),Ut?.())}function xd(){dt=[]}function Cd(e){return He=e,()=>{He===e&&(He=null)}}function Id(){He?.close()}function Pd(){xd(),He?.closeAll()}function Ed(){return He?.isOpen()??!1}Pl();const Ad=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryTransients\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let it={},ve=[],Ke={};function ia(e){return e.map(t=>({...t,value:t.value!==void 0?X(t.value):void 0}))}function aa(e,t){const[,n,r]=Al(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:ia(n),inverse:ia(r)}}function $d(e){let t=it;for(let n=0;n<e;n++)t=_t(t,ve[n].forward);return t}let we=[];function Zn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(we.length>i.length&&(we.length=i.length),we.length<i.length)if(i.length-we.length===1){const u=i.length-1;we[u]={passage:i[u].passage,variables:at(r),timestamp:i[u].timestamp,prng:i[u].prng}}else{let u=it;for(let f=0;f<i.length;f++)if(f>0&&(u=_t(u,ve[f-1].forward)),f>=we.length){const c=f===i.length-1?r:u;we[f]={passage:i[f].passage,variables:at(c),timestamp:i[f].timestamp,prng:i[f].prng}}}ld(t.ifid,{passage:n,variables:at(r),history:we,historyIndex:a,visitCounts:o,renderCounts:s,prng:Tn()})}}function oa(e){it=e,ve=[],Ke=e,we=[]}let $r=[],Jr=!1;function Dd(e){Jr&&$r.push(e)}function Lo(){Jr=!0}function Td(){for(const e of $r)e();$r=[],Jr=!1}function sa(e){e?.prng?ao(e.prng.seed,e.prng.pull):e&&_r()}const C=cl()(Dl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},transient:{},transientDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={},i={})=>{const a=n.passagesById.get(n.startNode);if(!a)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const o=X(r);oa(X(o)),e(l=>{l.storyData=n,l.currentPassage=a.name,l.variables=o,l.variableDefaults=r,l.transient=X(i),l.transientDefaults=i,l.temporary={},l.history=[{passage:a.name,timestamp:Date.now()}],l.historyIndex=0,l.visitCounts={[a.name]:1},l.renderCounts={[a.name]:1}}),Ke=t().variables;const s=n.ifid;Yf().then(async()=>{const l=await Jf(s);if(l)e(f=>{f.playthroughId=l});else{const f=await na(s);e(c=>{c.playthroughId=f})}const u=await Pr(s);Object.keys(u).length>0&&e(f=>{f.knownSaves=u})}).catch(l=>console.error(\"spindle: failed to init save system\",l))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Ad.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=t().currentPassage;fe(\"beforenavigate\",n);const o=aa(Ke,i);e(s=>{s.temporary={},s.currentPassage=n,s.history=s.history.slice(0,s.historyIndex+1),ve.length=s.historyIndex,ve.push(o),s.history.push({passage:n,timestamp:Date.now(),prng:Tn()});const l=s.history.length-s.maxHistory;if(l>0){for(let u=0;u<l;u++)it=_t(it,ve[u].forward);s.history=s.history.slice(l),ve=ve.slice(l),we=we.slice(l)}s.historyIndex=s.history.length-1,s.visitCounts[n]=(s.visitCounts[n]??0)+1,s.renderCounts[n]=(s.renderCounts[n]??0)+1}),Ke=t().variables,Zn(t),fe(\"afternavigate\",n,a)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=t().currentPassage,a=t().history[n-1].passage;fe(\"beforenavigate\",a);const o=X(_t(r,ve[n-1].inverse));e(s=>{s.historyIndex--,s.currentPassage=s.history[s.historyIndex].passage,s.variables=o,s.temporary={}}),Ke=t().variables,sa(t().history[t().historyIndex]),Zn(t),fe(\"afternavigate\",a,i)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=t().currentPassage,o=r[n+1].passage;fe(\"beforenavigate\",o);const s=X(_t(i,ve[n].forward));e(l=>{l.historyIndex++,l.currentPassage=l.history[l.historyIndex].passage,l.variables=s,l.temporary={}}),Ke=t().variables,sa(t().history[t().historyIndex]),Zn(t),fe(\"afternavigate\",o,a)},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]})},setTransient:(n,r)=>{e(i=>{i.transient[n]=r})},deleteTransient:n=>{e(r=>{delete r.transient[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;const a=n.passagesById.get(n.startNode);if(!a)return;e(l=>{l.renderDeferred=!1}),fe(\"beforerestart\");const o=t().renderDeferred;Td(),_r(),bd();const s=X(r);oa(X(s)),e(l=>{l.currentPassage=a.name,l.variables=s,l.transient=X(i),l.temporary={},l.history=[{passage:a.name,timestamp:Date.now()}],l.historyIndex=0,l.visitCounts={[a.name]:1},l.renderCounts={[a.name]:1},o||(l.renderDeferred=!1)}),Ke=t().variables,Lo(),Mo(),Do(n.ifid),fe(\"storyinit\"),na(n.ifid).then(l=>{e(u=>{u.playthroughId=l})}).catch(l=>console.error(\"spindle: failed to start new playthrough\",l))},save:(n,r)=>{const{storyData:i,playthroughId:a}=t();if(!i)return;fe(\"beforesave\",n,r);const o=t().getSavePayload();e(s=>{s.saveError=null}),id(i.ifid,a,o,n,r).then(()=>{e(s=>{s.knownSaves={...s.knownSaves,[n??\"\"]:!0}}),fe(\"aftersave\",n)}).catch(s=>{console.error(\"spindle: failed to save\",s),e(l=>{l.saveError=s instanceof Error?s.message:\"Failed to save\"})})},load:n=>{const{storyData:r}=t();r&&(e(i=>{i.loadError=null}),ad(r.ifid,n).then(i=>{i&&t().loadFromPayload(i)}).catch(i=>{console.error(\"spindle: failed to load save\",i),e(a=>{a.loadError=i instanceof Error?i.message:\"Failed to load\"})}))},hasSave:n=>{const{storyData:r,knownSaves:i}=t();return r?(n??\"\")in i:!1},getSaveInfo:async n=>{const{storyData:r}=t();return r?Er(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?od(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&sd(r.ifid,n).then(()=>{e(i=>{const a=n??\"\",{[a]:o,...s}=i.knownSaves;i.knownSaves=s})}).catch(i=>{console.error(\"spindle: failed to delete save\",i)})},clearGameData:()=>{const{storyData:n}=t();n&&To(n.ifid).then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear game data\",r)})},clearAllData:()=>{const{storyData:n}=t();n&&No().then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear all data\",r)})},deletePlaythrough:n=>{const{storyData:r}=t();r&&Ro(r.ifid,n).then(async()=>{const i=await Pr(r.ifid);e(a=>{a.knownSaves=i})}).catch(i=>{console.error(\"spindle: failed to delete playthrough\",i)})},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),l=[];let u=it;for(let f=0;f<i.length;f++)f>0&&(u=_t(u,ve[f-1].forward)),l.push({passage:i[f].passage,variables:X(u),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:X(r),history:l,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:Tn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}fe(\"beforeload\",void 0);const r=ot(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=ot(n.history[o].variables);i.push(aa(a,s)),a=s}it=X(r),ve=i,we=[],e(o=>{o.currentPassage=n.passage,o.variables=ot(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=Math.max(0,Math.min(n.historyIndex,o.history.length-1)),o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={},o.transient=X(t().transientDefaults)}),Ke=t().variables,n.prng?ao(n.prng.seed,n.prng.pull):_r(),fe(\"afterload\",void 0)},getHistoryVariables:n=>X($d(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n},deferRender:()=>{e(n=>{n.renderDeferred=!0})},clearDeferredRender:()=>{e(n=>{n.renderDeferred=!1})}}))),Nd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Rd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Nd,r=t?.tags.includes(\"nobr\")??!1,i=ne(()=>{try{const a=Ct(n),o=It(a);return S(Y,{children:Qr(o)})}catch(a){return S(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?S(he.Provider,{value:!0,children:i}):i}const Bo=Ge(null);function Xr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=le(r);a.current=r;const o=ge(()=>a.current(),[]),s=C(d=>d.storyData),u=(e?s?.passages.get(e):void 0)?.content??t,f=ne(()=>{if(!u)return S(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const d=Ct(u),p=It(d);return Ee(p)}catch(d){return S(\"div\",{class:\"error\",children:[\"Error in dialog: \",d instanceof Error?d.message:String(d)]})}},[u]),c=d=>{d.target.classList.contains(\"dialog-overlay\")&&o()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return S(Bo.Provider,{value:o,children:S(\"div\",{class:\"dialog-overlay\",onClick:c,children:S(\"div\",{class:h,children:[i&&S(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),S(\"div\",{class:\"dialog-body\",children:f})]})})})}function Md(){const[e,t]=te([]),n=le(e);n.current=e;const r=ge(o=>{t(s=>[...s,o])},[]),i=ge(()=>{t(o=>o.slice(0,-1))},[]),a=ge(()=>{t([])},[]);return ke(()=>Cd({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),ke(()=>vd(()=>{const o=[];for(;Sd()>0;){const s=wd();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:S(Y,{children:e.map((o,s)=>S(Xr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function zd(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(ke(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return S(\"div\",{class:\"loading\",children:\"Loading...\"});const r=S(Y,{children:[S(Rd,{}),S(Md,{})]});return n?S(he.Provider,{value:!0,children:r}):r}function Fd(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Od(){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||\"\",u=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const d=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",y=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),b=Fd(h.innerHTML),_={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const E of h.attributes)k.has(E.name)||(_[E.name]=E.value);const x={pid:d,name:p,tags:y,metadata:_,content:b};f.set(p,x),c.set(d,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:u}}const zt=new Map;let de={},la=!1;function Vo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Ld(){localStorage.setItem(Vo(),JSON.stringify(de))}function er(){if(!la){la=!0;try{const e=localStorage.getItem(Vo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(de={...de,...t})}}catch{}}}const Jt={addToggle(e,t){zt.set(e,{type:\"toggle\",config:t}),e in de||(de[e]=t.default),er()},addList(e,t){zt.set(e,{type:\"list\",config:t}),e in de||(de[e]=t.default),er()},addRange(e,t){zt.set(e,{type:\"range\",config:t}),e in de||(de[e]=t.default),er()},get(e){return de[e]},getToggle(e){const t=de[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=de[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=de[e];return typeof t==\"number\"?t:0},set(e,t){de[e]=t,Ld()},getAll(){return{...de}},getDefinitions(){return zt},hasAny(){return zt.size>0}};function Bd(e,t,n){const r=C.getState(),i=X(r.variables),a=X(r.temporary),o=X(r.transient),s={...t};uo(e,i,a,s,o);for(const l of Object.keys(i))i[l]!==r.variables[l]&&r.setVariable(l,i[l]);for(const l of Object.keys(a))a[l]!==r.temporary[l]&&r.setTemporary(l,a[l]);for(const l of Object.keys(o))o[l]!==r.transient[l]&&r.setTransient(l,o[l]);for(const l of Object.keys(s))s[l]!==t[l]&&n(l,s[l]);for(const l of Object.keys(r.variables))l in i||r.deleteVariable(l);for(const l of Object.keys(r.temporary))l in a||r.deleteTemporary(l);for(const l of Object.keys(r.transient))l in o||r.deleteTransient(l);for(const l of Object.keys(t))l in s||n(l,void 0)}const Rn=new Map,Dr=new Map;function Vd(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Dr.get(r)??0)+1;return Dr.set(r,i),i===1?r:`${r}:${i}`}function Hd(e){return Rn.set(e.id,e),ca(),()=>{Rn.delete(e.id),ca()}}function ua(){return Array.from(Rn.values())}function qd(e){return Rn.get(e)}function Ud(){Dr.clear()}function ca(){fe(\"actionsChanged\")}function jd(e){const t=le(\"\"),n=le(e.perform);n.current=e.perform,t.current||(t.current=Vd(e.type,e.key,e.authorId));const r=t.current;return ft(()=>{const i={id:r,type:e.type,label:e.label,perform:(...a)=>n.current(...a)};return e.target!==void 0&&(i.target=e.target),e.variable!==void 0&&(i.variable=e.variable),e.options!==void 0&&(i.options=e.options),e.value!==void 0&&(i.value=e.value),e.disabled!==void 0&&(i.disabled=e.disabled),Hd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Wd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Ho(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Zr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Ho(t):\"\"}function Kd(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 Qd(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 Gd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Yd={useState:te,useRef:le,useEffect:ke,useLayoutEffect:ft,useCallback:ge,useMemo:ne,useContext:Q};function fa(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function Jd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=On(),a=s(a),o=s(o));const{update:l,getValues:u}=Q(sn),f=Q(he),c=Q(xe),d={collectText:Wd,sourceLocation:Zr,parseVarArgs:Kd,extractOptions:Qd,h:G,renderNodes:(p,y)=>Ee(p,{nobr:f,locals:c,...y}),renderInlineNodes:Qr,hooks:Yd,useAction:jd,className:a,id:o,resolve:s,cls:Gd(e.name,a),mutate:p=>Bd(p,u(),l),update:l,getValues:u,wrap:p=>a||o?G(\"span\",{id:o,class:a},p):G(Y,null,p)};if(e.merged){d.merged=Ur();const p=d.merged;d.evaluate=y=>Et(y,p[0],p[1],p[2],p[3])}if(e.storeVar){const p=i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\";if(p.startsWith(\"%\"))return G(\"span\",{class:\"error\"},`{${e.name}}: transient variables (%${p.slice(1)}) cannot be bound to input macros`);const y=p.replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),b=y.split(\".\");d.varName=y,d.value=C(_=>fa(_.variables,b)),d.getValue=()=>fa(C.getState().variables,b),d.setValue=_=>{C.setState(k=>{Jd(k.variables,b,_)})}}return e.render(i,d)}lu(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(du(e.name,{name:e.name,block:r,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters,source:t}),e.subMacros)for(const i of e.subMacros)cu(i);r&&yr(e.name)}let gn=null,Tr=null;function Xd(){return Tr}let da=!1;function Zd(){if(da)return;da=!0;let e={...C.getState().variables},t={...C.getState().transient};C.subscribe(n=>{const r={};let i=!1;const a=new Set([...Object.keys(e),...Object.keys(n.variables)]);for(const s of a)n.variables[s]!==e[s]&&(r[s]={from:e[s],to:n.variables[s]},i=!0);const o=new Set([...Object.keys(t),...Object.keys(n.transient)]);for(const s of o)n.transient[s]!==t[s]&&(r[`%${s}`]={from:t[s],to:n.transient[s]},i=!0);e={...n.variables},t={...n.transient},i&&fe(\"variableChanged\",r)})}function eh(){return{get(e){return e.startsWith(\"%\")?C.getState().transient[e.slice(1)]:C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")e.startsWith(\"%\")?n.setTransient(e.slice(1),t):n.setVariable(e,t);else for(const[r,i]of Object.entries(e))r.startsWith(\"%\")?n.setTransient(r.slice(1),i):n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e,t){C.getState().save(e,t)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},getSaveInfo(e){return C.getState().getSaveInfo(e)},listSaves(){return C.getState().listSaves()},deleteSave(e){C.getState().deleteSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>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){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>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:Jt,registerClass(e,t){jf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return hu()},saves:{setTitleGenerator(e){Kf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?dd(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:ea()}},async getQuota(){if(typeof navigator<\"u\"&&navigator.storage?.estimate)try{const e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},async clearGameData(){const e=C.getState().storyData?.ifid;e&&(await To(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await No(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await Ro(t.ifid,e);const n=await Pr(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return ea()}},getActions(){return ua()},performAction(e,t){const n=qd(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){e===\"variableChanged\"&&Zd();const n=pd(e,t);return Dd(n),n},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ua())})})})},watch(e,t){return Fo(e,t)},unwatch(e){Oo(e)},openDialog(e,t){kd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Id()},closeAllDialogs(){Pd()},isDialogOpen(){return Ed()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Tr=new Promise(e=>{gn=e})},ready(){gn&&(C.getState().clearDeferredRender(),gn(),gn=null,Tr=null)},random(){return jr()},randomInt(e,t){return oo(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){Fl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=Tn())})},isEnabled(){return Ol()},get seed(){return Ll()},get pull(){return Bl()}}}}function th(){window.Story=eh()}function nh(e){const t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");return new RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}const ha=/\\$(\\w+(?:\\.\\w+)*)/g,pa=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,rh=new Set([\"number\",\"string\",\"boolean\"]);function qo(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,qo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!rh.has(t))throw new Error(`Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function ga(e,t=\"$\"){const n=new Map,r=nh(t),i=t===\"%\"?\"StoryTransients\":\"StoryVariables\";for(const a of e.split(`\n`)){const o=a.trim();if(!o)continue;const s=o.match(r);if(!s)throw new Error(`${i}: Invalid declaration: \"${o}\". Expected: ${t}name = value`);const[,l,u]=s;let f;try{f=new Function(\"return (\"+u+\")\")()}catch(h){throw new Error(`${i}: Failed to evaluate \"${t}${l} = ${u}\": ${h instanceof Error?h.message:h}`)}let c;try{c=qo(f)}catch(h){throw new Error(`${i}: ${h instanceof Error?h.message:h}`)}n.set(l,{...c,name:l,default:f})}return n}function ih(e){const t=new Set;let n;for(pa.lastIndex=0;(n=pa.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function ah(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 l=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${l}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const u=o.fields.get(l);if(!u)return null;o=u}return null}function oh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\"||r===\"StoryTransients\")continue;const a=ih(i.content);let o;for(ha.lastIndex=0;(o=ha.exec(i.content))!==null;){const s=o[1],l=ah(s,t,a);l&&n.push(`Passage \"${r}\": ${l}`)}}return n}function ma(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function wn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&wn(t.children))return!0;if(t.type===\"macro\"){if(wn(t.children))return!0;if(t.branches){for(const n of t.branches)if(wn(n.children))return!0}}}return!1}function Ue({macro:e,error:t}){return S(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Zr()}: ${t instanceof Error?t.message:String(t)}}`})}B({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1),r=t.hooks.useRef(null);if(!n.current){n.current=!0;try{t.mutate(e)}catch(i){r.current=i,console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,i)}}return r.current?S(Ue,{macro:\"set\",error:r.current}):null}});B({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return S(Ue,{macro:\"print\",error:n})}}});function sh(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 lh(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 ya(e,t,n,r,i,a,o,s,l){let u;try{u=Et(e,r,i,a,o)}catch(f){console.error(`spindle: Error in {computed ${s}}${Zr()}:`,f);return}if(!lh(l.current,u)){l.current=u;const f=C.getState();n?f.setTemporary(t,u):f.setVariable(t,u)}}B({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i,a]=t.merged;let o,s;try{({target:o,expr:s}=sh(e))}catch(h){return S(Ue,{macro:\"computed\",error:h})}const l=o.startsWith(\"_\"),u=o.slice(1),f=t.hooks.useRef(void 0),c=t.hooks.useRef(!1);return c.current||(c.current=!0,ya(s,u,l,n,r,i,a,e,f)),t.hooks.useLayoutEffect(()=>{ya(s,u,l,n,r,i,a,e,f)},[n,r,i,a]),null}});function uh(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=ch(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 ch(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 fh(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}B({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=uh(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),l=fh(a,o,i),u=t.cls;return S(\"div\",{class:u,id:t.id,children:[S(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),l!=null&&S(\"span\",{class:\"macro-meter-label\",children:l})]})}catch(n){return S(Ue,{macro:\"meter\",error:n})}}});B({name:\"if\",block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?S(\"span\",{id:o,class:a,children:i}):S(Y,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return S(Ue,{macro:\"if\",error:i})}}return null}});function dh(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 hh({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){const[o,s]=te(()=>({})),l=ne(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i]),u=ne(()=>({...e,...l,...o}),[e,l,o]),f=le(u);f.current=u;const c=ge(()=>f.current,[]),h=ge((y,b)=>{s(_=>({..._,[y]:b}))},[]),d=ne(()=>({update:h,getValues:c}),[h,c]),p=Q(he);return S(sn.Provider,{value:d,children:S(xe.Provider,{value:u,children:Ee(a,{nobr:p,locals:u})})})}B({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=Q(xe);let i;try{i=dh(e)}catch(f){return S(Ue,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let l;try{const f=n.evaluate(s);if(!Array.isArray(f))return S(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});l=f}catch(f){return S(Ue,{macro:\"for\",error:f})}const u=l.map((f,c)=>S(hh,{parentValues:r,itemVar:a,itemValue:f,indexVar:o,indexValue:c,children:t},`${c}-${JSON.stringify(f)}`));return n.wrap(u)}});B({name:\"do\",block:!0,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}});B({name:\"button\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=Q(he),a=()=>{const o=document.createElement(\"div\"),s=G(he.Provider,{value:i},G(sn.Provider,{value:{update:n.update,getValues:n.getValues}},G(xe.Provider,{value:n.getValues()},Ee(t))));Pe(s,o),Pe(null,o)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:a}),S(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function ph(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function _a(e,t,n,r){const i=document.createElement(\"div\"),a=G(he.Provider,{value:r},G(sn.Provider,{value:{update:n,getValues:t}},G(xe.Provider,{value:t()},Ee(e))));Pe(a,i),Pe(null,i)}B({name:\"link\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=ph(e),a=Q(he),o=s=>{s.preventDefault(),_a(t,n.getValues,n.update,a),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{_a(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),S(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});B({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return S(Ue,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return S(Y,{children:n.renderNodes(o.children)})}catch(s){return S(Ue,{macro:\"case\",error:s})}}return i?S(Y,{children:n.renderNodes(i.children)}):null}});function ei(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)}B({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?ei(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,p=a[d].delay,y=setTimeout(()=>{s(d)},p);return()=>clearTimeout(y)},[o,a]),o<0)return t.wrap(null);const l=a[o],u=t.renderNodes(l.nodes),f=t.resolve(l.className),c=t.resolve(l.id),h=f||c?S(\"span\",{id:c,class:f,children:u}):u;return t.wrap(h)}});const Uo=Ge({stop:()=>{}});B({name:\"repeat\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=ei(e),[s,l]=r(0),[u,f]=r(!1),c=a(()=>f(!0),[]);if(i(()=>{if(u)return;const d=setInterval(()=>{l(p=>p+1)},o);return()=>clearInterval(d)},[o,u]),s===0&&!u)return null;const h=S(Uo.Provider,{value:{stop:c},children:S(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?S(\"span\",{id:n.id,class:n.cls,children:h}):h}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Uo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});B({name:\"type\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=ei(e),s=a(null),[l,u]=r(0),[f,c]=r(0),h=a(0);h.current=f,i(()=>{if(s.current){const y=s.current.textContent||\"\";u(y.length)}},[]),i(()=>{if(l===0||h.current>=l)return;const y=setInterval(()=>{c(b=>b>=l?(clearInterval(y),b):b+1)},o);return()=>clearInterval(y)},[l,o]);const d=f>=l&&l>0,p=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return S(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(l>0&&!d,void 0)},children:[S(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:l===0?\"hidden\":\"visible\",clipPath:l>0&&!d?`inset(0 ${(l-f)/l*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&l>0&&S(\"span\",{class:\"macro-type-cursor\"})]})}});function gh(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}}B({name:\"widget\",block:!0,render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=gh(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{fo(r,t,i)},[r,a,o]),null}});B({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return S(\"span\",{id:t.id,class:r,children:n})}});function ht(e){B({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=te(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",l=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),S(Y,{children:[S(\"button\",{id:n.id,class:s,onClick:l,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&S(Xr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}ht({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});ht({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});ht({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});ht({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.knownSaves),{perform:()=>e(),disabled:!t()}}});ht({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});ht({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});ht({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Jt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});B({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,l=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return S(Y,{children:[S(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&S(Xr,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function mh(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 yh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function _h(){const[e,t]=te(\"load\"),[n,r]=te([]),[i,a]=te(!0),[o,s]=te(null),[l,u]=te(()=>new Set),[f,c]=te(null),[h,d]=te(\"\"),p=le(null),y=le(null),b=Q(Bo),_=C(R=>R.storyData),k=C(R=>R.playthroughId),x=C(R=>R.getSavePayload),E=C(R=>R.loadFromPayload),I=_?.ifid??\"\",v=ge(async()=>{if(!I)return;const R=await td(I);r(R),a(!1)},[I]);ke(()=>{v()},[v]),ke(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const D=le(),A=(R,j=\"success\")=>{clearTimeout(D.current),s({text:R,type:j}),D.current=window.setTimeout(()=>s(null),3e3)};ke(()=>()=>clearTimeout(D.current),[]);const $=R=>{u(j=>{const g=new Set(j);return g.has(R)?g.delete(R):g.add(R),g})},w=async()=>{if(!(!I||!k))try{const R=x();await Ao(I,k,R),A(\"Save created\"),await v()}catch{A(\"Failed to create save\",\"error\")}},T=async R=>{try{const j=x();await $o(R,j),A(\"Save overwritten\"),await v()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async R=>{try{E(R.payload),A(\"Game loaded\"),b&&setTimeout(b,500)}catch{A(\"Failed to load save\",\"error\")}},V=async R=>{if(confirm(\"Delete this save?\"))try{await Zf(R),A(\"Save deleted\"),await v()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{c(R.meta.id),d(R.meta.title)},O=async()=>{if(!(!f||!h.trim()))try{await ed(f,h.trim()),c(null),A(\"Save renamed\"),await v()}catch{A(\"Failed to rename\",\"error\")}},ee=R=>{R.key===\"Enter\"?O():R.key===\"Escape\"&&c(null)},Z=async R=>{try{const j=await cd(R);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),ce=document.createElement(\"a\");ce.href=q,ce.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ce.click(),URL.revokeObjectURL(q),A(\"Save exported\")}catch{A(\"Failed to export save\",\"error\")}},me=()=>{y.current?.click()},Ce=async R=>{const j=R.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),ce=JSON.parse(q);if(!Ff(ce))throw new Error(\"Invalid save file format\");await fd(ce,I),A(\"Save imported\"),await v()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((R,j)=>R+j.saves.length,0);return S(\"div\",{class:\"save-manager\",children:[S(\"div\",{class:\"saves-header\",children:S(\"div\",{class:\"saves-header-left\",children:S(\"div\",{class:\"saves-mode-toggle\",children:[S(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),S(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),S(\"div\",{class:\"saves-toolbar\",children:[S(\"button\",{class:\"saves-toolbar-button\",onClick:me,children:\"Import\"}),S(\"input\",{ref:y,type:\"file\",accept:\".json\",style:\"display:none\",onChange:Ce})]}),S(\"div\",{class:\"saves-body\",children:[i?S(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?S(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(R=>{const j=l.has(R.playthrough.id),g=R.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:S(\"div\",{class:\"playthrough-group\",children:[S(\"div\",{class:\"playthrough-header\",onClick:()=>$(R.playthrough.id),children:[S(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),S(\"span\",{class:\"playthrough-label\",children:[R.playthrough.label,g?\" (current)\":\"\"]}),S(\"span\",{class:\"playthrough-date\",children:yh(R.playthrough.createdAt)})]}),!j&&S(\"div\",{class:\"playthrough-saves\",children:[R.saves.map(q=>S(\"div\",{class:\"save-slot\",children:[S(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?S(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:ce=>d(ce.target.value),onKeyDown:ee,onBlur:O}):S(\"div\",{class:\"save-slot-title\",children:q.meta.title}),S(\"div\",{class:\"save-slot-meta\",children:[S(\"span\",{children:q.meta.passage}),S(\"span\",{children:mh(q.meta.updatedAt)})]})]}),S(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?S(\"button\",{class:\"save-slot-action primary\",onClick:()=>T(q.meta.id),children:\"Save Here\"}):S(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q),children:\"Load\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>Z(q.meta.id),children:\"Export\"}),S(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&S(\"button\",{class:\"save-slot-new\",onClick:w,children:\"+ New Save\"})]})]},R.playthrough.id)}),e===\"save\"&&!i&&!n.some(R=>R.playthrough.id===k)&&S(\"div\",{class:\"playthrough-group\",children:S(\"div\",{class:\"playthrough-saves\",children:S(\"button\",{class:\"save-slot-new\",onClick:w,children:\"+ New Save\"})})})]}),o&&S(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return S(_h,{})}});function bh({name:e,def:t}){const[n,r]=te(()=>Jt.get(e)),i=a=>{r(a),Jt.set(e,a)};switch(t.type){case\"toggle\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>S(\"option\",{value:a,children:a},a))})]});case\"range\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:[t.config.label,\": \",String(n)]}),S(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function vh(){const e=Jt.getDefinitions();return S(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>S(bh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return S(vh,{})}});B({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return S(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),l=Ct(o.content),u=It(l),f=r?t.renderInlineNodes(u):t.renderNodes(u,s?{nobr:!0}:void 0);return s?t.wrap(t.h(he.Provider,{value:!0},f)):t.wrap(f)}});B({name:\"nobr\",block:!0,render({children:e=[]},t){return t.wrap(t.h(he.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});B({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}});B({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)):i.startsWith(\"%\")?r.deleteTransient(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _name, %name, or @name), got \"${i}\"`)}return null}});B({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});B({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),S(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});B({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function wh(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=wh(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function Sh(e){const t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}B({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Sh(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),S(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>S(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),S(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Ot(e){const t=Ct(e.content),n=It(t),r=e.tags.includes(\"nobr\");return Ee(n,r?{nobr:!0}:void 0)}const kh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function xh({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=kh.has(e.name),[i,a]=te(!1),o=ne(()=>{try{return Ot(e)}catch(y){return S(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Ho(e),\":\",\" \",y instanceof Error?y.message:String(y)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),l=r?void 0:n?.passages.get(\"PassageFooter\"),u=r?void 0:n?.passages.get(\"PassageDone\"),f=ne(()=>{if(!s)return null;try{return Ot(s)}catch(y){return console.error(\"spindle: Error in PassageHeader:\",y),null}},[s?.content]),c=ne(()=>{if(!l)return null;try{return Ot(l)}catch(y){return console.error(\"spindle: Error in PassageFooter:\",y),null}},[l?.content]);ke(()=>(u&&a(!0),()=>a(!1)),[e.name]);const h=ne(()=>{if(!i||!u)return null;try{return Ot(u)}catch(y){return console.error(\"spindle: Error in PassageDone:\",y),null}},[i,u?.content]),d=e.tags.includes(\"nobr\"),p=S(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&S(\"div\",{class:\"passage-header\",children:f}),o,c&&S(\"div\",{class:\"passage-footer\",children:c}),h&&S(\"div\",{hidden:!0,children:h})]});return d?S(he.Provider,{value:!0,children:p}):p}const Ch=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Nr={type:\"fade-through\",duration:300,pause:50};function Ih(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Ch.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function tr(e){return{type:e.type,duration:e.duration??Nr.duration,pause:e.pause??Nr.pause}}function Ph(e,t,n){const r=Ih(e);return r?tr(r):t?tr(t):n?tr(n):{...Nr}}function ba(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function nr(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function rr(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(p=>p.currentPassage),r=C(p=>p.storyData),i=C(p=>p.renderDeferred),[a,o]=te(n),s=le(\"fade\"),l=le(0),u=le(null),f=le([]),c=ge(()=>{for(const p of f.current)clearTimeout(p);f.current=[],rr(u.current)},[]);ke(()=>{const p=C.getState(),{history:y,historyIndex:b,transitionConfig:_}=p,k=p.consumeNextTransition(),x=l.current;l.current=y.length;const E=!a,I=y.length===1&&b===0&&x>1,v=y.length>1&&b===y.length-1&&x>1&&Math.abs(y.length-x)>1;if(n===a)return;c();const D=r?.passages.get(n);if(!D){s.current=\"none\",o(n);return}if(E||I||v){s.current=\"fade\",o(n);return}const A=Ph(D.tags,k,_);s.current=A.type;const $=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){$&&nr($,A),o(n);return}if(A.type===\"fade-through\"){if(!$){o(n);return}nr($,A);const w=$.querySelector(\".passage\");if(!w){o(n);return}const T=ba(w,A.type);$.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{rr($)},U);f.current=[V,O];return}if(A.type===\"crossfade\"){if(!$){o(n);return}nr($,A);const w=$.querySelector(\".passage\");if(!w){o(n);return}const T=ba(w,A.type);$.classList.add(\"passage-container--crossfading\"),$.appendChild(T),o(n);const N=setTimeout(()=>{rr($)},A.duration);f.current=[N];return}o(n)},[n]);const h=i?r?.passages.get(\"StoryLoading\")??null:a?r?.passages.get(a):null;if(!h&&a&&!i)return S(\"div\",{class:\"error\",children:[\"Error: Passage “\",a,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return S(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[!i&&d&&S(\"div\",{hidden:!0,children:Ot(d)},`ready-${n}`),S(\"div\",{class:\"passage-container\",ref:u,children:h&&S(xh,{passage:h,dataTransition:i?\"none\":s.current},i?\"loading\":a)})]})}});B({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},l=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let u;for(;(u=l.exec(o))!==null;){const c=u[1]??u[5],h=u[2]??u[3]??u[4];if(c)switch(c){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,Fo(a,s)),null}});B({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,Oo(r)),null}});const Eh='*,*: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-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.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}}';function va(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 wa(){const e=Od(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Eh,document.head.appendChild(t),th(),e.userCSS){const b=document.createElement(\"style\");b.textContent=e.userCSS,document.head.appendChild(b)}if(e.userScript)try{new Function(e.userScript)()}catch(b){console.error(\"spindle: Error in story JavaScript:\",b)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const b=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",_=document.getElementById(\"root\");throw _&&va(_,[b]),new Error(`spindle: ${b}`)}const i=ga(r.content),a=oh(e.passages,i);let o={};const s=e.passages.get(\"StoryTransients\");if(s){const b=ga(s.content,\"%\");for(const _ of b.keys())i.has(_)&&a.push(`StoryTransients: Variable \"${_}\" is already declared in StoryVariables. Names must be unique across scopes.`);o=ma(b)}if(a.length>0){const b=document.getElementById(\"root\");throw b&&va(b,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=ma(i),C.getState().init(e,n,o),Lo(),Mo();const l=ud(e.ifid);l&&C.getState().loadFromPayload(l),fe(\"storyinit\");const u=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,b]of e.passages)if(b.tags.includes(\"widget\")){let _;for(;(_=u.exec(b.content))!==null;){const k=_[1],x=_[2];/\\{@children\\}/.test(x)&&yr(k)}u.lastIndex=0}for(const[,b]of e.passages)if(b.tags.includes(\"widget\")){const _=Ct(b.content),k=It(_);for(const x of k)if(x.type===\"macro\"&&x.name===\"widget\"&&x.rawArgs){const E=x.rawArgs.trim().split(/\\s+/),I=E[0].replace(/[\"']/g,\"\"),v=E.slice(1).filter($=>$.startsWith(\"$\")||$.startsWith(\"_\")||$.startsWith(\"@\")),D=x.children,A=wn(D);fo(I,D,v,A),A&&yr(I)}}let f=\"\";C.subscribe(b=>{b.currentPassage!==f&&(f=b.currentPassage,Ud())});let c=C.getState().variables,h=C.getState().historyIndex;C.subscribe(b=>{b.variables!==c&&(b.historyIndex===h?yd():_d()),c=b.variables,h=b.historyIndex});const d=e.passages.get(\"StoryInterface\");d&&!d.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');Pe(S(zd,{}),p);const y=Xd();y?y.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",wa):wa();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|