@rohal12/spindle 0.43.6 → 0.43.7
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 +14 -13
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.43.6","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 Jt,O,Sa,Ze,ui,ka,xa,Ca,Mr,ar,or,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 zr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Q(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?Jt.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&&O.vnode!=null&&O.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,O.vnode&&O.vnode(a),Or(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&&Ea(a)}}function Ea(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}),Ea(e)}function sr(e){(!e.__d&&(e.__d=!0)&&Ze.push(e)&&!xn.__r++||ui!=O.debounceRendering)&&((ui=O.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 Pa(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=Or(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=Mr,e.addEventListener(t,a?or:ar,a)):e.removeEventListener(t,a?or:ar,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=Mr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Or(e,t,n,r,i,a,o,s,l,u){var f,c,h,d,p,y,b,_,k,x,P,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=O.__b)&&f(t);e:if(typeof $==\"function\")try{if(_=t.props,k=\"prototype\"in $&&$.prototype.render,x=(f=$.contextType)&&r[f.__c],P=f?x?x.props.value:f.__:r,n.__c?b=(c=t.__c=n.__c).__=c.__E:(k?t.__c=c=new $(_,P):(t.__c=c=new Ne(_,P),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(_,P),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,P)===!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(S){S&&(S.__=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,P),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,p,y)})}if(c.context=P,c.props=_,c.__P=e,c.__e=!1,I=O.__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=Pa(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(S){if(t.__v=null,l||a!=null)if(S.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--;)zr(a[A]);lr(t)}else t.__e=n.__e,t.__k=n.__k,S.then||lr(t);O.__e(S,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=O.diffed)&&f(t),128&t.__u?void 0:s}function lr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(lr))}function $a(e,t,n){for(var r=0;r<n.length;r++)Fr(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function 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&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)b===_||s&&e.data==_||(e.data=_);else{if(a=a&&Jt.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=\"\"),Pa(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--;)zr(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){O.__e(i,n)}}function Ta(e,t,n){var r,i;if(O.unmount&&O.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){O.__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||zr(e.__e),e.__c=e.__=e.__e=void 0}function xs(e,t,n){return this.constructor(e,n)}function Ee(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],Or(t,e=(!r&&n||t).__k=Q(Y,null,[e]),i||Sn,Sn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Jt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),$a(a,e,o)}function Na(e,t){Ee(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?Jt.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,sr(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}Jt=kn.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},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),sr(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),sr(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,Mr=0,ar=fi(!1),or=fi(!0),Ia=0;var Is=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:--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 O.vnode&&O.vnode(u),u}var Qe,W,jn,di,wt=0,Ra=[],K=O,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,Lr(Fa,e)}function Lr(e,t,n){var r=xt(Qe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Fa(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&&Br(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ft(e,t){var n=xt(Qe++,4);!K.__s&&Br(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 Br(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 G(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 Oa(){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 Es(){for(var e;e=Ra.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(mn),t.__h.some(ur),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&&(jn===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(ur),t.__h=[],Qe=0)),jn=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)||Ps)(Es)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),jn=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.__||ur(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 Ps(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 ur(e){var t=W;e.__c=e.__(),W=t}function Br(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Fa(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 cr(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,Wn(i)&&a({t:i})},[e,n,t]),ke(function(){return Wn(i)&&a({t:i}),e(function(){Wn(i)&&a({t:i})})},[e]),n}function Wn(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 fr(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:cr(this.props,i)}function r(i){return this.shouldComponentUpdate=n,Q(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(fr.prototype=new Ne).isPureReactComponent=!0,fr.prototype.shouldComponentUpdate=function(e,t){return cr(this.props,e)||cr(this.state,t)};var wi=O.__b;O.__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=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Rs(e,t,n,r)};var ki=O.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?Q(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Ot(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),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&&Q(Y,null,e.fallback);return i&&(i.__u&=-33),[Q(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 Os(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ee(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)}}}Ee(Q(zs,{context:t.context},e.__v),t.v)}function Fs(e,t){var n=Q(Os,{__v:e,h:t});return n.containerInfo=t,n}(Ot.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()}},Ot.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},Ot.prototype.componentDidUpdate=Ot.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=\"\"),Ee(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=O.event;function Ws(){}function Ks(){return this.cancelBubble}function Qs(){return this.defaultPrevented}O.event=function(e){return Ci&&(e=Ci(e)),e.persist=Ws,e.isPropagationStopped=Ks,e.isDefaultPrevented=Qs,e.nativeEvent=e};var Vr,Gs={enumerable:!1,configurable:!0,get:function(){return this.class}},Ii=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||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 Ei=O.__r;O.__r=function(e){Ei&&Ei(e),Vr=e.__c};var Pi=O.diffed;O.diffed=function(e){Pi&&Pi(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),Vr=null};var Ys={ReactCurrentDispatcher:{current:{readContext:function(e){return Vr.__n[e.__c].props.value},useCallback:ge,useContext:G,useDebugValue:za,useDeferredValue:Ha,useEffect:ke,useId:Oa,useImperativeHandle:Ma,useInsertionEffect:Ua,useLayoutEffect:ft,useMemo:ne,useReducer:Lr,useRef:le,useState:te,useSyncExternalStore:Ba,useTransition:qa}}};function Xs(e){return Q.bind(null,e)}function zn(e){return!!e&&e.$$typeof===Qa}function Js(e){return zn(e)&&e.type===Y}function Zs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function el(e){return zn(e)?Cs.apply(null,arguments):e}function tl(e){return!!e.__k&&(Ee(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=zn,cn={useState:te,useId:Oa,useReducer:Lr,useEffect:ke,useLayoutEffect:ft,useInsertionEffect:Ua,useTransition:qa,useDeferredValue:Ha,useSyncExternalStore:Ba,startTransition:Va,useRef:le,useImperativeHandle:Ma,useMemo:ne,useCallback:ge,useContext:G,useDebugValue:za,version:\"18.3.1\",Children:Ns,render:Us,hydrate:js,unmountComponentAtNode:tl,createPortal:Fs,createElement:Q,createContext:Ge,createFactory:Xs,cloneElement:el,createRef:bs,Fragment:Y,isValidElement:zn,isElement:ol,isFragment:Js,isMemo:Zs,findDOMNode:nl,Component:Ne,PureComponent:fr,memo:$s,forwardRef:Ts,flushSync:il,unstable_batchedUpdates:rl,StrictMode:al,Suspense:yn,SuspenseList:Ot,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 Hr=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\",dr=\"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\",Kn=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_,qr=e=>e.modified_?e.copy_:e.base_;function hr(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[dr]=!0),(s.get||s.set)&&(r[o]={[dr]:!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 Ur(e,t=!1){return On(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)=>{Ur(r,!0)},!1)),e}function gl(){se(2)}var fn={[Wt]:gl};function On(e){return e===null||!St(e)?!0:ye.isFrozen(e)}var En=\"MapSet\",Pn=\"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(En)?ut(En):void 0,arrayMethodsPlugin_:Di($i)?ut($i):void 0});function Ti(e,t){t&&(e.patchPlugin_=ut(Pn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function pr(e){gr(e),e.drafts_.forEach(_l),e.drafts_=null}function gr(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_&&(pr(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),pr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Hr?e:void 0}function Mi(e,t){if(On(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_&&Ur(t,n)}function Xa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Fn=(e,t)=>e.scope_===t,vl=[];function Ja(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=qr(a);Ja(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)}Xa(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=qr(i);Ja(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)||On(e)||(t.add(e),tn(e,(r,i)=>{if(qe(i)){const a=i[ie];if(Fn(a,n)){const o=qr(a);In(e,r,o,e.type_),Xa(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===Qn(e.base_,t)){bn(e);const o=e.type_===1?+t:t,s=yr(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=Qn(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),mr(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),Qn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),mr(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,[dr]: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 Qn(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 mr(e){e.modified_||(e.modified_=!0,e.parent_&&mr(e.parent_))}function bn(e){e.copy_||(e.assigned_=new Map,e.copy_=hr(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=yr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?pr(a):gr(a)}return Ti(a,r),Ri(i,a)}else if(!t||!St(t)){if(i=n(t),i===void 0&&(i=t),i===Hr&&(i=void 0),this.autoFreeze_&&Ur(i,!0),r){const a=[],o=[];ut(Pn).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]},Kn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Kn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Kn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Re(e)||se(8),qe(e)&&(e=Il(e));const t=Ni(this),n=yr(t,e,void 0);return n[ie].isManual_=!0,gr(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(Pn).applyPatches_;return qe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function yr(e,t,n,r){const[i,a]=rn(t)?ut(En).proxyMap_(t,n):an(t)?ut(En).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)||On(e))return e;const t=e[ie];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=hr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=hr(e,!0);return tn(n,(i,a)=>{In(n,i,to(a))},r),t&&(t.finalized_=!1),n}function El(){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 P;if(x){const I=p.parent_;P=Array.from(I.drafts_.keys()).indexOf(p.key_)}else P=p.key_;if(!(x&&b.size>P||Vt(b,P)))return null;y.push(P)}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,P=p.copy_;P.length<k.length&&([k,P]=[P,k],[b,_]=[_,b]);const I=p.allIndicesReassigned_===!0;for(let v=0;v<k.length;v++){const D=P[v],A=k[v];if((I||x?.get(v.toString()))&&D!==A){const S=D?.[ie];if(S&&S.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<P.length;v++){const D=y.concat([v]);b.push({op:i,path:D,value:d(P[v])})}for(let v=P.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_:P}=p;tn(p.assigned_,(I,v)=>{const D=Le(k,I,P),A=Le(x,I,P),$=v?Vt(k,I)?r:i:a;if(D===A&&$===r)return;const S=y.concat(I);b.push($===a?{op:$,path:S}:{op:$,path:S,value:d(A)}),_.push($===i?{op:a,path:S}:$===a?{op:i,path:S,value:d(D)}:{op:r,path:S,value:d(D)})})}function u(p,y,b,_){let{base_:k,copy_:x}=p,P=0;k.forEach(I=>{if(!x.has(I)){const v=y.concat([P]);b.push({op:a,path:v,value:I}),_.unshift({op:i,path:v,value:I})}P++}),P=0,x.forEach(I=>{if(!k.has(I)){const v=y.concat([P]);b.push({op:i,path:v,value:I}),_.unshift({op:a,path:v,value:I})}P++})}function f(p,y,b){const{patches_:_,inversePatches_:k}=b;_.push({op:r,path:[],value:y===Hr?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 P=lt(x),I=h(b.value),v=_[_.length-1];switch(k){case r:switch(P){case 2:return x.set(v,I);case 3:se(16);default:return x[v]=I}case i:switch(P){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(P){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(Pn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Gt=new Cl,Pl=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\"?Pl(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 Oi(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=Oi(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=Oi(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 _r(e){no.add(e.toLowerCase())}const Fi={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(Fi[a]){const o=Fi[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 jr(){const e=C(i=>i.variables),t=C(i=>i.temporary),n=C(i=>i.transient),r=G(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 Et=!1,on=\"\",ct=0,kt=null;function Ol(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)),Et=!0}function ao(e,t){on=e,ct=0,kt=ro(io(e)),Et=!0;for(let n=0;n<t;n++)kt();ct=t}function br(){Et=!1,on=\"\",ct=0,kt=null}function Tn(){return Et?{seed:on,pull:ct}:null}function Wr(){return!Et||!kt?Math.random():(ct++,kt())}function oo(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Wr()*(t-e+1))+e}function Fl(){return Et}function Ll(){return on}function Bl(){return ct}const Vl=500,Xe=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 Kr(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+=Kr(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=Xe.get(e);if(n)return Xe.delete(e),Xe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",\"transient\",Kl+t);if(Xe.set(e,r),Xe.size>Vl){const i=Xe.keys().next().value;i!==void 0&&Xe.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:Wr,randomInt:oo},Li=t,Bi=n,dn}function Pt(e,t,n,r={},i={}){const o=`return (${Kr(e)});`;return so(o,o)(t,n,r,lo(),i)}function uo(e,t,n,r={},i={}){const a=Kr(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 Xl(e,t,n,r,i={}){const a=Pt(e,t,n,r,i);return a==null?\"\":String(a)}function Jl(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+=Jl(f,t,n,r,i):a+=Xl(f,t,n,r,i)}return a}function Ln(){const[e,t,n,r]=jr();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=Ln();n=i(n),r=i(r);const a=G(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?w(\"span\",{id:r,class:n,children:f}):w(Y,{children:f})}function tu({expression:e,className:t,id:n}){const r=Ln();t=r(t),n=r(n);const i=G(xe),a=C(u=>u.variables),o=C(u=>u.temporary),s=C(u=>u.transient);let l;try{const u=Pt(e,a,o,i,s);l=u==null?\"\":String(u)}catch{l=`{error: ${e}}`}return t||n?w(\"span\",{id:n,class:t,children:l}):w(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=G(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 w(sn.Provider,{value:f,children:w(xe.Provider,{value:o,children:Pe(e,{nobr:r,locals:o})})})}function ou({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=G(xe),a=G(he),[o,s,l,u]=jr(),f=r?.length?r:null;if(t.length===0||!n)return w(xr.Provider,{value:f,children:Pe(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=Pt(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 w(xr.Provider,{value:f,children:w(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 vr={}.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=(vr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){vr.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=(vr.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 wr(e){return e!==null&&(e<32||e===127)}const Sr=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,Eu=/^https?$/i;function Pu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=yu([{enter:{blockQuote:F,codeFenced:Ce,codeFencedFenceInfo:b,codeFencedFenceMeta:b,codeIndented:j,codeText:cs,content:Jo,definition:Wo,definitionDestinationString:Qo,definitionLabelString:b,definitionTitleString:b,emphasis:ls,htmlFlow:ss,htmlText:ii,image:q,label:b,link:ce,listItemMarker:T,listItemValue:S,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:Xo,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:Un,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(E){let M=-1,ae=0;const Ie=[];let Ae=[],Me=[];for(;++M<E.length;)!c&&(E[M][1].type===\"lineEnding\"||E[M][1].type===\"lineEndingBlank\")&&(c=E[M][2].sliceSerialize(E[M][1])),(E[M][1].type===\"listOrdered\"||E[M][1].type===\"listUnordered\")&&(E[M][0]===\"enter\"?Ie.push(M):d(E.slice(Ie.pop(),M))),E[M][1].type===\"definition\"&&(E[M][0]===\"enter\"?(Me=oe(Me,E.slice(ae,M)),ae=M):(Ae=oe(Ae,E.slice(ae,M+1)),ae=M+1));Ae=oe(Ae,Me),Ae=oe(Ae,E.slice(ae)),M=-1;const $e=Ae;for(l.enter.null&&l.enter.null.call(f);++M<E.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(E){const M=E.length;let ae=0,Ie=0,Ae=!1,Me;for(;++ae<M;){const $e=E[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}}E[0][1]._loose=Ae}function p(E,M){u[E]=M}function y(E){return u[E]}function b(){i.push([])}function _(){return i.pop().join(\"\")}function k(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function x(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function P(){x(c||`\n`)}function I(){const E=i[i.length-1],M=E[E.length-1],ae=M?M.charCodeAt(M.length-1):null;ae===10||ae===13||ae===null||P()}function v(E){return y(\"ignoreEncode\")?E:yo(E)}function D(){_()}function A(E){o.push(!E._loose),I(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function $(E){o.push(!E._loose),I(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function S(E){if(y(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(E),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(),P(),k(\"</ol>\")}function V(){U(),o.pop(),P(),k(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function F(){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 E=_();k(' class=\"language-'+E+'\"')}function R(){const E=y(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){I(),k(\"<pre><code>\")}function g(){const E=y(\"fencesCount\");E!==void 0&&E<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&P(),y(\"flowCodeSeenData\")&&I(),k(\"</code></pre>\"),E!==void 0&&E<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ce(){a.push({})}function re(E){a[a.length-1].labelId=this.sliceSerialize(E)}function At(){a[a.length-1].label=_()}function je(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function pt(){b(),a[a.length-1].destination=\"\"}function gt(){b(),p(\"ignoreEncode\",!0)}function Un(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function jo(){a[a.length-1].title=_()}function ti(){let E=a.length-1;const M=a[E],ae=M.referenceId||M.labelId,Ie=M.destination===void 0?r[Yt(ae)]:M;for(n=!0;E--;)if(a[E].image){n=void 0;break}M.image?(k('<img src=\"'+hn(Ie.destination,t.allowDangerousProtocol?void 0:Eu)+'\" 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(E){_(),a[a.length-1].labelId=this.sliceSerialize(E)}function Qo(){b(),p(\"ignoreEncode\",!0)}function Go(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function Yo(){a[a.length-1].title=_()}function Xo(){const E=a[a.length-1],M=Yt(E.labelId);_(),Hi.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Jo(){p(\"slurpAllLineEndings\",!0)}function Zo(E){y(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).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(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function is(){const E=_();I(),k(\"<h\"+y(\"headingRank\")+\">\"),x(E),k(\"</h\"+y(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function $t(E){x(v(this.sliceSerialize(E)))}function as(E){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(v(this.sliceSerialize(E)))}}function os(E){x(v(this.sliceSerialize(E))),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(E){p(\"characterReferenceType\",E.type)}function gs(E){const M=this.sliceSerialize(E),ae=y(\"characterReferenceType\")?bu(M,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):mo(M);x(v(ae)),p(\"characterReferenceType\")}function ms(E){const M=this.sliceSerialize(E);k('<a href=\"'+hn(M,t.allowDangerousProtocol?void 0:qi)+'\">'),x(v(M)),k(\"</a>\")}function ys(E){const M=this.sliceSerialize(E);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 P=n[r];return t.containerState=P[1],e.attempt(P[0].continuation,l,u)(x)}return u(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const P=t.events.length;let I=P,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=P;for(;D<t.events.length;)t.events[D][1].end={...v},D++;return be(t.events,I+1,0,t.events.slice(P)),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,P){const I=t.sliceStream(x);if(P&&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,$,S;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){if($){S=t.events[A][1].end;break}$=!0}for(_(r),v=D;v<t.events.length;)t.events[v][1].end={...S},v++;be(t.events,A+1,0,t.events.slice(D)),t.events.length=v}}function _(x){let P=n.length;for(;P-- >x;){const I=n[P];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 Bn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const kr={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,Bn(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:Ou};function Ou(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||wr(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 Vn={partial:!0,tokenize:Fu};function Fu(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=Sr,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,P)(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,P,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,P)(v):(e.enter(\"codeFlowValue\"),x(v))}function x(v){return v===null||z(v)?(e.exit(\"codeFlowValue\"),k(v)):(e.consume(v),x)}function P(v){return e.exit(\"codeFenced\"),t(v)}function I(v,D,A){let $=0;return S;function S(F){return v.enter(\"lineEnding\"),v.consume(F),v.exit(\"lineEnding\"),T}function T(F){return v.enter(\"codeFencedFence\"),L(F)?H(v,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(F):N(F)}function N(F){return F===s?(v.enter(\"codeFencedFenceSequence\"),V(F)):A(F)}function V(F){return F===s?($++,v.consume(F),V):$>=o?(v.exit(\"codeFencedFenceSequence\"),L(F)?H(v,U,\"whitespace\")(F):U(F)):A(F)}function U(F){return F===null||z(F)?(v.exit(\"codeFencedFence\"),D(F)):A(F)}}}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 Gn={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:Xu,resolve:Yu,tokenize:Ju};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 Xu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Ju(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||wr(_)?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||wr(_)?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):S(g)}function x(g){return g===47?(e.consume(g),S):g===58||g===95||De(g)?(e.consume(g),P):L(g)?(e.consume(g),x):S(g)}function P(g){return g===45||g===46||g===58||g===95||_e(g)?(e.consume(g),P):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 S(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\"),F}function F(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(Vn,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),P):z(m)?(o=x,Z(m)):(e.consume(m),x)}function P(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),S):z(m)?(o=$,Z(m)):L(m)?(e.consume(m),$):ee(m)}function S(m){return m===45||m===46||m===58||m===95||_e(m)?(e.consume(m),S):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,F):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 F(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 Qr={name:\"labelEnd\",resolveAll:Pc,resolveTo:Ac,tokenize:$c},Cc={tokenize:Dc},Ic={tokenize:Tc},Ec={tokenize:Nc};function Pc(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,Bn(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(Ec,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:Qr.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:Qr.resolveAll,tokenize:Oc};function Oc(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 Yn={name:\"lineEnding\",tokenize:Fc};function Fc(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:Sr(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 Sr(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(Vn,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(Vn,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(Vn,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 Xc={resolveAll:Io()},Jc=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]:Gn,[-1]:Gn,32:Gn},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]:Yn,[-4]:Yn,[-3]:Yn,33:Rc,38:vo,42:kr,60:[zu,kc],91:zc,92:[cc,bo],93:Qr,95:kr,96:Gu},lf={null:[kr,Xc]},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:P,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=Bn(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:F}=r;return{_bufferIndex:T,_index:N,line:V,column:U,offset:F}}function y(T){i[T.line]=T.column,S()}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,S()):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 P(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,F,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,Un=[...Array.isArray(pt)?pt:pt?[pt]:[],...Array.isArray(gt)?gt:gt?[gt]:[]];return j(Un)(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),F}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,F=Array.from(s);return{from:U,restore:ee};function ee(){r=T,u.previous=N,u.currentConstruct=V,u.events.length=U,s=F,S()}}function S(){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(Jc),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),Pu(n)(mf(gf(n).document().write(yf()(e,t,!0))))}const Xn={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=Xn[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=Xn[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\"+Xn[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(S){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(S):V(S)}function l(S){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),u(S)}function u(S){return S===124||(o=!0,a+=1),f(S)}function f(S){return S===null?n(S):z(S)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(S),e.exit(\"lineEnding\"),d):n(S):L(S)?H(e,f,\"whitespace\")(S):(a+=1,o&&(o=!1,i+=1),S===124?(e.enter(\"tableCellDivider\"),e.consume(S),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(S)))}function c(S){return S===null||S===124||ue(S)?(e.exit(\"data\"),f(S)):(e.consume(S),S===92?h:c)}function h(S){return S===92||S===124?(e.consume(S),c):c(S)}function d(S){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(S):(e.enter(\"tableDelimiterRow\"),o=!1,L(S)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(S):p(S))}function p(S){return S===45||S===58?b(S):S===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(S),e.exit(\"tableCellDivider\"),y):I(S)}function y(S){return L(S)?H(e,b,\"whitespace\")(S):b(S)}function b(S){return S===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(S),e.exit(\"tableDelimiterMarker\"),_):S===45?(a+=1,_(S)):S===null||z(S)?P(S):I(S)}function _(S){return S===45?(e.enter(\"tableDelimiterFiller\"),k(S)):I(S)}function k(S){return S===45?(e.consume(S),k):S===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(S),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(S))}function x(S){return L(S)?H(e,P,\"whitespace\")(S):P(S)}function P(S){return S===124?p(S):S===null||z(S)?!o||i!==a?I(S):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(S)):I(S)}function I(S){return n(S)}function v(S){return e.enter(\"tableRow\"),D(S)}function D(S){return S===124?(e.enter(\"tableCellDivider\"),e.consume(S),e.exit(\"tableCellDivider\"),D):S===null||z(S)?(e.exit(\"tableRow\"),t(S)):L(S)?H(e,D,\"whitespace\")(S):(e.enter(\"data\"),A(S))}function A(S){return S===null||S===124||ue(S)?(e.exit(\"data\"),D(S)):(e.consume(S),S===92?$:A)}function $(S){return S===92||S===124?(e.consume(S),A):A(S)}}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&&(Xi(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&&Xi(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 Xi(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 Ef(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Pf(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,Bn(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,t){const n=[\"codeIndented\"];return t?.inline&&n.push(\"list\",\"headingAtx\",\"setextUnderline\",\"thematicBreak\",\"blockQuote\"),_f(e,{allowDangerousHtml:!0,extensions:[xf(),Pf(),{disable:{null:n}}],htmlExtensions:[bf(),Ef()]})}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),Ji=Ge(!1),xr=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)=>Eo(a,o,t));return w(Y,{children:i})}function Eo(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)=>Eo(l,u,n));return Q(i,o,...s)}return null}const Tf=new Set([\"a\",\"abbr\",\"b\",\"bdi\",\"bdo\",\"br\",\"cite\",\"code\",\"data\",\"dfn\",\"em\",\"i\",\"kbd\",\"label\",\"mark\",\"meter\",\"output\",\"progress\",\"q\",\"rp\",\"rt\",\"ruby\",\"s\",\"samp\",\"small\",\"span\",\"strong\",\"sub\",\"sup\",\"time\",\"u\",\"var\",\"wbr\"]);function Nf({node:e}){const t=Ln(),n=G(he),r=G(xe),i=G(Ji),a={};for(const[f,c]of Object.entries(e.attributes))a[f]=t(c)??c;const o=e.tag.toLowerCase()===\"svg\",s=Tf.has(e.tag.toLowerCase()),l=e.children.length>0?i||o?Gr(e.children):Pe(e.children,{nobr:n,locals:r,inline:s}):void 0,u=Q(e.tag,a,l);return o?w(Ji.Provider,{value:!0,children:u}):u}function Rf(){const e=G(xr),t=G(he),n=G(xe);return!e||e.length===0?null:w(Y,{children:Pe(e,{nobr:t,locals:n})})}function Mf(e,t){if(fu(e.name))return null;const n=su(e.name);if(n)return w(ou,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=uu(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 Cr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(Rf,{},t):w(eu,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return w(tu,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Mf(e,t);case\"html\":return w(Nf,{node:e},t);default:return e}}function Gr(e){return e.length===0?null:e.map((t,n)=>Cr(t,n))}function zf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Of(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)}const Ff=/[*_`#|~\\[>\\\\\\-+=]|!\\[|\\d+\\./,Lf=/\\n\\s*\\n/,Bf=/(<span data-tw=\"\\d+\"><\\/span>)/,Vf=/^<span data-tw=\"(\\d+)\"><\\/span>$/,Hf=/<span data-tw=\"\\d+\"><\\/span>/g;function qf(e,t,n){const r=e.split(Bf),i=[];for(const a of r){const o=Vf.exec(a);o?i.push(t[parseInt(o[1],10)]):a&&i.push(a)}return n?w(Y,{children:i}):Q(\"p\",null,...i)}function Pe(e,t){if(e.length===0)return null;if(!e.some(l=>l.type===\"text\"&&(l.value.trim()!==\"\"||/\\n\\s*\\n/.test(l.value))))return e.map((l,u)=>Cr(l,u));const r=[];let i=\"\";const a=t?.locals??{};for(let l=0;l<e.length;l++){const u=e[l];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&zf(i))i+=Of(u,a);else{const f=r.length;r.push(Cr(u,l)),i+=`<span data-tw=\"${f}\"></span>`}}const o=i.replace(Hf,\"\");if(!Ff.test(o)&&!Lf.test(o))return qf(i,r,t?.nobr);const s=Af(i,{inline:t?.inline});return Df(s,r,t?.nobr)}function Uf(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 jf(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 Wf(){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 Fe(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 Oe(e){localStorage.removeItem(e)}function tt(e){return Fe(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 Kf(){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 Fe(`${ze}${e}`)},async deleteSave(e){const t=Fe(`${ze}${e}`);t&&(Mt(`${mt}${t.meta.ifid}`,e),Mt(`${Rt}${t.meta.playthroughId}`,e)),Oe(`${ze}${e}`)},async getSavesByIfid(e){const t=tt(`${mt}${e}`),n=[];for(const r of t){const i=Fe(`${ze}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=tt(`${mt}${e}`);for(const n of t){const r=Fe(`${ze}${n}`);r&&Mt(`${Rt}${r.meta.playthroughId}`,n),Oe(`${ze}${n}`)}Oe(`${mt}${e}`)},async deleteSavesByPlaythrough(e){const t=tt(`${Rt}${e}`);for(const n of t){const r=Fe(`${ze}${n}`);r&&Mt(`${mt}${r.meta.ifid}`,n),Oe(`${ze}${n}`)}return Oe(`${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=Fe(`${Tt}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=tt(`${Nt}${e}`);for(const n of t)Oe(`${Tt}${n}`);Oe(`${Nt}${e}`)},async deletePlaythroughById(e){const t=Fe(`${Tt}${e}`);t&&Mt(`${Nt}${t.ifid}`,e),Oe(`${Tt}${e}`)},async getMeta(e){return Fe(`${Je}${e}`)},async setMeta(e,t){qt(`${Je}${e}`,t)},async deleteMeta(e){Oe(`${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\",Qf=1;function Gf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Zi,Qf);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 Yf(){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)}),Gf()}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 Kf()}catch{}return Wf()}async function X(){return bt||(bt=await Yf(),bt)}function Xf(){bt=null}function ea(){return bt?.type??\"memory\"}const Po=new Map,Hn=new Map;function Jf(e,t){Po.set(e,t),Hn.set(t,e)}function Zf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function J(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(Hn.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(Zf(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=Hn.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=Po.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(Hn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Ir=null,Er=null,ta=!1;function ed(e){Ir=e}function td(e){Er=e}function nd(e){if(Er)try{const i=new Function(\"passage\",\"variables\",Er)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Ir)try{const r=Ir(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 rd(){ta||(ta=!0)}async function na(e){const t=await X(),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 id(e){return(await X()).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:nd(n),passage:n.passage,custom:r},o=J(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 X()).putSave(s),s}async function $o(e,t,n){const r=await X(),i=await r.getSave(e);if(!i)return;const a=J(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 ad(e){const t=await(await X()).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 od(e){await(await X()).deleteSave(e)}async function sd(e,t){const n=await X(),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 ld(e){const t=await X(),[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 ud=\"autosave.\",cd=\"slot.\",qn=\"slotIndex.\";function ln(e,t){return t!=null?`${cd}${t}.${e}`:`${ud}${e}`}async function fd(e,t,n,r,i){const a=await X(),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=`${qn}${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 X(),r=ln(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function dd(e,t){const n=ln(e,t),r=await(await X()).getMeta(n);if(r)return ad(r)}async function Pr(e){const t={};await ra(e)&&(t[\"\"]=!0);const n=`${qn}${e}`,r=await(await X()).getMeta(n)??[];for(const i of r)await ra(e,i)&&(t[i]=!0);return t}async function Ar(e,t){const n=await X(),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 hd(e){const t=[],n=await Ar(e);n&&t.push(n);const r=`${qn}${e}`,i=await(await X()).getMeta(r)??[];for(const a of i){const o=await Ar(e,a);o&&t.push(o)}return t}async function pd(e,t){const n=await X(),r=ln(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${qn}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Yr=\"spindle.session.\";function gd(e,t){try{sessionStorage.setItem(`${Yr}${e}`,JSON.stringify(t))}catch{}}function md(e){try{const t=sessionStorage.getItem(`${Yr}${e}`);if(!t)return;const n=JSON.parse(t);if(!jf(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(`${Yr}${e}`)}catch{}}async function yd(e){const t=await(await X()).getSave(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function _d(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 X(),r=J(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 bd(e){const t=await X(),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 X();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Do(e)}async function No(){if(await(await X()).destroy(),Xf(),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 X(),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),Ee(Q(()=>Pe(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&td(n.content)}const vd=new Set([\"storyinit\",\"beforerestart\",\"actionsChanged\",\"variableChanged\",\"beforesave\",\"aftersave\",\"beforeload\",\"afterload\",\"beforenavigate\",\"afternavigate\"]);let $r=new Map;function wd(e,t){if(!vd.has(e))throw new Error(`spindle: Unknown event \"${e}\".`);let n=$r.get(e);return n||(n=new Set,$r.set(e,n)),n.add(t),()=>{n.delete(t)}}function fe(e,...t){const n=$r.get(e);if(n)for(const r of[...n])r(...t)}let zo=0,Se=[],Zn=!1,dt=[],Ut=null,He=null;function Xr(e){const t=C.getState();try{return!!Pt(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Oo(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:Xr(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 Fo(e){Se=Se.filter(t=>t.name!==e)}function Sd(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 kd=10;function xd(){if(!Zn){Zn=!0;try{for(let e=0;e<kd;e++){let t=!1;const n=[...Se];for(const r of n){if(!Se.includes(r))continue;const i=Xr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(Se=Se.filter(o=>o.id!==r.id)),Sd(r))}if(!t)break}}finally{Zn=!1}}}function Cd(){for(const e of Se)e.lastResult=Xr(e.condition)}function Id(){Se=[],dt=[],zo=0,He?.closeAll()}function Ed(e){return Ut=e,dt.length>0&&e(),()=>{Ut===e&&(Ut=null)}}function Pd(){return dt.shift()}function Ad(){return dt.length}function $d(e){He?He.push(e):(dt.push(e),Ut?.())}function Dd(){dt=[]}function Td(e){return He=e,()=>{He===e&&(He=null)}}function Nd(){He?.close()}function Rd(){Dd(),He?.closeAll()}function Md(){return He?.isOpen()??!1}El();const zd=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?J(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 Od(e){let t=it;for(let n=0;n<e;n++)t=_t(t,ve[n].forward);return t}let we=[];function er(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}}}gd(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 Dr=[],Jr=!1;function Fd(e){Jr&&Dr.push(e)}function Lo(){Jr=!0}function Ld(){for(const e of Dr)e();Dr=[],Jr=!1}function sa(e){e?.prng?ao(e.prng.seed,e.prng.pull):e&&br()}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=J(r);oa(J(o)),e(l=>{l.storyData=n,l.currentPassage=a.name,l.variables=o,l.variableDefaults=r,l.transient=J(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;rd().then(async()=>{const l=await id(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(zd.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,er(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=J(_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]),er(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=J(_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]),er(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;Ld(),br(),Id();const s=J(r);oa(J(s)),e(l=>{l.currentPassage=a.name,l.variables=s,l.transient=J(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}),fd(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}),dd(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?Ar(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?hd(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&pd(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:J(u),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:J(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=J(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=J(t().transientDefaults)}),Ke=t().variables,n.prng?ao(n.prng.seed,n.prng.pull):br(),fe(\"afterload\",void 0)},getHistoryVariables:n=>J(Od(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})}}))),Bd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Vd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Bd,r=t?.tags.includes(\"nobr\")??!1,i=ne(()=>{try{const a=Ct(n),o=It(a);return w(Y,{children:Gr(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(he.Provider,{value:!0,children:i}):i}const Bo=Ge(null);function Zr({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 w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const d=Ct(u),p=It(d);return Pe(p)}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()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return w(Bo.Provider,{value:o,children:w(\"div\",{class:\"dialog-overlay\",onClick:c,children:w(\"div\",{class:h,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:f})]})})})}function Hd(){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(()=>Td({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),ke(()=>Ed(()=>{const o=[];for(;Ad()>0;){const s=Pd();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(Y,{children:e.map((o,s)=>w(Zr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function qd(){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(Y,{children:[w(Vd,{}),w(Hd,{})]});return n?w(he.Provider,{value:!0,children:r}):r}function Ud(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function jd(){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(P=>P.length>0),b=Ud(h.innerHTML),_={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const P of h.attributes)k.has(P.name)||(_[P.name]=P.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 Wd(){localStorage.setItem(Vo(),JSON.stringify(de))}function tr(){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 Xt={addToggle(e,t){zt.set(e,{type:\"toggle\",config:t}),e in de||(de[e]=t.default),tr()},addList(e,t){zt.set(e,{type:\"list\",config:t}),e in de||(de[e]=t.default),tr()},addRange(e,t){zt.set(e,{type:\"range\",config:t}),e in de||(de[e]=t.default),tr()},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,Wd()},getAll(){return{...de}},getDefinitions(){return zt},hasAny(){return zt.size>0}};function Kd(e,t,n){const r=C.getState(),i=J(r.variables),a=J(r.temporary),o=J(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,Tr=new Map;function Qd(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Tr.get(r)??0)+1;return Tr.set(r,i),i===1?r:`${r}:${i}`}function Gd(e){return Rn.set(e.id,e),ca(),()=>{Rn.delete(e.id),ca()}}function ua(){return Array.from(Rn.values())}function Yd(e){return Rn.get(e)}function Xd(){Tr.clear()}function ca(){fe(\"actionsChanged\")}function Jd(e){const t=le(\"\"),n=le(e.perform);n.current=e.perform,t.current||(t.current=Qd(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),Gd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Zd(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 Mn(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Ho(t):\"\"}function eh(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 th(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 nh(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const rh={useState:te,useRef:le,useEffect:ke,useLayoutEffect:ft,useCallback:ge,useMemo:ne,useContext:G};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 ih(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=Ln(),a=s(a),o=s(o));const{update:l,getValues:u}=G(sn),f=G(he),c=G(xe),d={collectText:Zd,sourceLocation:Mn,parseVarArgs:eh,extractOptions:th,h:Q,renderNodes:(p,y)=>Pe(p,{nobr:f,locals:c,...y}),renderInlineNodes:Gr,hooks:rh,useAction:Jd,className:a,id:o,resolve:s,cls:nh(e.name,a),mutate:p=>Kd(p,u(),l),update:l,getValues:u,wrap:p=>a||o?Q(\"span\",{id:o,class:a},p):Q(Y,null,p)};if(e.merged){d.merged=jr();const p=d.merged;d.evaluate=y=>Pt(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 Q(\"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=>{ih(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&&_r(e.name)}let gn=null,Nr=null;function ah(){return Nr}let da=!1;function oh(){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 sh(){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:Xt,registerClass(e,t){Jf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return hu()},saves:{setTitleGenerator(e){ed(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?bd(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=Yd(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\"&&oh();const n=wd(e,t);return Fd(n),n},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ua())})})})},watch(e,t){return Oo(e,t)},unwatch(e){Fo(e)},openDialog(e,t){$d({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Nd()},closeAllDialogs(){Rd()},isDialogOpen(){return Md()},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(),Nr=new Promise(e=>{gn=e})},ready(){gn&&(C.getState().clearDeferredRender(),gn(),gn=null,Nr=null)},random(){return Wr()},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){Ol(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=Tn())})},isEnabled(){return Fl()},get seed(){return Ll()},get pull(){return Bl()}}}}function lh(){window.Story=sh()}function uh(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,ch=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(!ch.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=uh(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 fh(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 dh(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 hh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\"||r===\"StoryTransients\")continue;const a=fh(i.content);let o;for(ha.lastIndex=0;(o=ha.exec(i.content))!==null;){const s=o[1],l=dh(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 w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Mn()}: ${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 ph(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, _name, or @name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function gh(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,u,f){let c;try{c=Pt(e,i,a,o,s)}catch(h){console.error(`spindle: Error in {computed ${l}}${Mn()}:`,h);return}if(!gh(u.current,c))if(u.current=c,r)try{f(t,c)}catch(h){console.error(`spindle: Error in {computed ${l}}${Mn()}:`,h)}else{const h=C.getState();n?h.setTemporary(t,c):h.setVariable(t,c)}}B({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i,a]=t.merged;let o,s;try{({target:o,expr:s}=ph(e))}catch(p){return w(Ue,{macro:\"computed\",error:p})}const l=o.startsWith(\"@\"),u=o.startsWith(\"_\"),f=o.slice(1),c=l?t.update:null,h=t.hooks.useRef(void 0),d=t.hooks.useRef(!1);return d.current||(d.current=!0,ya(s,f,u,l,n,r,i,a,e,h,c)),t.hooks.useLayoutEffect(()=>{ya(s,f,u,l,n,r,i,a,e,h,c)},[n,r,i,a]),null}});function mh(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=yh(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 yh(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 _h(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}=mh(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=_h(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(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 w(Ue,{macro:\"if\",error:i})}}return null}});function bh(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 vh({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=G(he);return w(sn.Provider,{value:d,children:w(xe.Provider,{value:u,children:Pe(a,{nobr:p,locals:u})})})}B({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=G(xe);let i;try{i=bh(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)=>w(vh,{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=G(he),a=()=>{const o=document.createElement(\"div\"),s=Q(he.Provider,{value:i},Q(sn.Provider,{value:{update:n.update,getValues:n.getValues}},Q(xe.Provider,{value:n.getValues()},Pe(t))));Ee(s,o),Ee(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 wh(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=Q(he.Provider,{value:r},Q(sn.Provider,{value:{update:n,getValues:t}},Q(xe.Provider,{value:t()},Pe(e))));Ee(a,i),Ee(null,i)}B({name:\"link\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=wh(e),a=G(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)}}),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(Y,{children:n.renderNodes(o.children)})}catch(s){return w(Ue,{macro:\"case\",error:s})}}return i?w(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?w(\"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=w(Uo.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: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 w(\"span\",{id:n.id,class:p,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 Sh(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}=Sh(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 w(\"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}),w(Y,{children:[w(\"button\",{id:n.id,class:s,onClick:l,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Zr,{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:()=>!Xt.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(Y,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Zr,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function kh(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 xh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Ch(){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=G(Bo),_=C(R=>R.storyData),k=C(R=>R.playthroughId),x=C(R=>R.getSavePayload),P=C(R=>R.loadFromPayload),I=_?.ifid??\"\",v=ge(async()=>{if(!I)return;const R=await ld(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})},S=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{P(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 od(R),A(\"Save deleted\"),await v()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{c(R.meta.id),d(R.meta.title)},F=async()=>{if(!(!f||!h.trim()))try{await sd(f,h.trim()),c(null),A(\"Save renamed\"),await v()}catch{A(\"Failed to rename\",\"error\")}},ee=R=>{R.key===\"Enter\"?F():R.key===\"Escape\"&&c(null)},Z=async R=>{try{const j=await yd(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(!Uf(ce))throw new Error(\"Invalid save file format\");await _d(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 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===k;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>$(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:xh(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:p,class:\"save-rename-input\",value:h,onInput:ce=>d(ce.target.value),onKeyDown:ee,onBlur:F}):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:kh(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:()=>Z(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:S,children:\"+ New Save\"})]})]},R.playthrough.id)}),e===\"save\"&&!i&&!n.some(R=>R.playthrough.id===k)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:S,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return w(Ch,{})}});function Ih({name:e,def:t}){const[n,r]=te(()=>Xt.get(e)),i=a=>{r(a),Xt.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 Eh(){const e=Xt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(Ih,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(Eh,{})}});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(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):\"\")}),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 Ph(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Ph(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 Ah(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}=Ah(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 Ft(e){const t=Ct(e.content),n=It(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const $h=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Dh({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=$h.has(e.name),[i,a]=te(!1),o=ne(()=>{try{return Ft(e)}catch(y){return w(\"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 Ft(s)}catch(y){return console.error(\"spindle: Error in PassageHeader:\",y),null}},[s?.content]),c=ne(()=>{if(!l)return null;try{return Ft(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 Ft(u)}catch(y){return console.error(\"spindle: Error in PassageDone:\",y),null}},[i,u?.content]),d=e.tags.includes(\"nobr\"),p=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}),h&&w(\"div\",{hidden:!0,children:h})]});return d?w(he.Provider,{value:!0,children:p}):p}const Th=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Rr={type:\"fade-through\",duration:300,pause:50};function Nh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Th.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 nr(e){return{type:e.type,duration:e.duration??Rr.duration,pause:e.pause??Rr.pause}}function Rh(e,t,n){const r=Nh(e);return r?nr(r):t?nr(t):n?nr(n):{...Rr}}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 rr(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 ir(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=[],ir(u.current)},[]);ke(()=>{const p=C.getState(),{history:y,historyIndex:b,transitionConfig:_}=p,k=p.consumeNextTransition(),x=l.current;l.current=y.length;const P=!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(P||I||v){s.current=\"fade\",o(n);return}const A=Rh(D.tags,k,_);s.current=A.type;const $=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){$&&rr($,A),o(n);return}if(A.type===\"fade-through\"){if(!$){o(n);return}rr($,A);const S=$.querySelector(\".passage\");if(!S){o(n);return}const T=ba(S,A.type);$.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,F=setTimeout(()=>{ir($)},U);f.current=[V,F];return}if(A.type===\"crossfade\"){if(!$){o(n);return}rr($,A);const S=$.querySelector(\".passage\");if(!S){o(n);return}const T=ba(S,A.type);$.classList.add(\"passage-container--crossfading\"),$.appendChild(T),o(n);const N=setTimeout(()=>{ir($)},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 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:Ft(d)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:h&&w(Dh,{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,Oo(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,Fo(r)),null}});const Mh='*,*: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=jd(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Mh,document.head.appendChild(t),lh(),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=hh(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=md(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)&&_r(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 P=x.rawArgs.trim().split(/\\s+/),I=P[0].replace(/[\"']/g,\"\"),v=P.slice(1).filter($=>$.startsWith(\"$\")||$.startsWith(\"_\")||$.startsWith(\"@\")),D=x.children,A=wn(D);fo(I,D,v,A),A&&_r(I)}}let f=\"\";C.subscribe(b=>{b.currentPassage!==f&&(f=b.currentPassage,Xd())});let c=C.getState().variables,h=C.getState().historyIndex;C.subscribe(b=>{b.variables!==c&&(b.historyIndex===h?xd():Cd()),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.');Ee(w(qd,{}),p);const y=ah();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"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.43.7","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>var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel=\"modulepreload\"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return x(e,s,i,a,null)}function x(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function S(){return{current:null}}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(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`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=v({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),oe(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ce(i,o,a),t.__e=t.__=null,o.__e!=n&&D(o)}}function D(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}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!k.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(k)}function k(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,E(e)}finally{a.length=k.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=te(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=oe(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&de(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?c=A(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=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]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ne(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),fe(s,s));return r}function A(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=A(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function j(e,t){return t=t||[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){j(e,t)}):t.push(e)),t}function ne(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function re(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function ie(e,t,n,r,i){var a,o;n: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||re(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||re(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(l,`$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=u,e.addEventListener(t,a?f:d,a)):e.removeEventListener(t,a?f:d,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 n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ae(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=u++;else if(t.t<n.u)return;return n(r.event?r.event(t):t)}}}function oe(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,S,T,E,D,O,k,te,A,j=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof j==`function`)try{if(S=t.props,T=j.prototype&&j.prototype.render,E=(d=j.contextType)&&i[d.__c],D=d?E?E.props.value:d.__:i,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new j(S,D):(t.__c=f=new w(S,D),f.constructor=j,f.render=pe),E&&E.sub(f),f.state||(f.state={}),f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&j.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,j.getDerivedStateFromProps(S,f.__s))),m=f.props,g=f.state,f.__v=t,p)T&&j.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&j.getDerivedStateFromProps==null&&S!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(S,D),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(S,f.__s,D)){t.__v!=n.__v&&(f.props=S,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(S,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=D,f.props=S,f.__P=e,f.__e=!1,O=r.__r,k=0,T)f.state=f.__s,f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++k<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),te=d!=null&&d.type===C&&d.key==null?le(d.props.children):d,c=ee(e,_(te)?te:[te],t,n,i,a,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(A=o.length;A--;)y(o[A]);se(t)}else t.__e=n.__e,t.__k=n.__k,e.then||se(t);r.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ue(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function se(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(se))}function ce(e,t,n){for(var i=0;i<n.length;i++)de(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function le(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(le):v({},e)}function ue(e,t,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(r.__m&&r.__m(t,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=s&&n.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||ie(e,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||ie(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,_(h)?h:[h],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l||(d=`value`,C==`progress`&&v==null?e.removeAttribute(`value`):v!=null&&(v!==e[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&ie(e,d,v,x[d],o),d=`checked`,b!=null&&b!=e[d]&&ie(e,d,b,x[d],o))}return e}function de(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function fe(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||de(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&fe(i[a],t,n||typeof e.type!=`function`);n||y(e.__e),e.__c=e.__=e.__e=void 0}function pe(e,t,n){return this.constructor(e,n)}function me(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],oe(t,e=(!a&&i||t).__k=b(C,null,[e]),o||m,m,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ce(s,e,c)}function he(e,t){me(e,t,he)}function ge(e,t,r){var i,a,o,s,c=v({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?i=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?n.call(arguments,2):r),x(e.type,c,i||e.key,a||e.ref,null)}function _e(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,O(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+ p++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=h.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,l=/(PointerCapture)$|Capture$/i,u=0,d=ae(!1),f=ae(!0),p=0;var ve,M,ye,be,xe=0,Se=[],N=r,Ce=N.__b,we=N.__r,Te=N.diffed,Ee=N.__c,De=N.unmount,Oe=N.__;function ke(e,t){N.__h&&N.__h(M,e,xe||t),xe=0;var n=M.__H||(M.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function P(e){return xe=1,Ae(He,e)}function Ae(e,t,n){var r=ke(ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):He(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=M,!M.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};M.__f=!0;var a=M.shouldComponentUpdate,o=M.componentWillUpdate;M.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},M.shouldComponentUpdate=i}return r.__N||r.__}function je(e,t){var n=ke(ve++,3);!N.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,M.__H.__h.push(n))}function Me(e,t){var n=ke(ve++,4);!N.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,M.__h.push(n))}function F(e){return xe=5,I(function(){return{current:e}},[])}function Ne(e,t,n){xe=6,Me(function(){if(typeof e==`function`){var n=e(t());return function(){e(null),n&&typeof n==`function`&&n()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function I(e,t){var n=ke(ve++,7);return Ve(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function L(e,t){return xe=8,I(function(){return e},t)}function R(e){var t=M.context[e.__c],n=ke(ve++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(M)),t.props.value):e.__}function Pe(e,t){N.useDebugValue&&N.useDebugValue(t?t(e):e)}function Fe(){var e=ke(ve++,11);if(!e.__){for(var t=M.__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 Ie(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ze),t.__h.some(Be),t.__h=[]}catch(n){t.__h=[],N.__e(n,e.__v)}}}N.__b=function(e){M=null,Ce&&Ce(e)},N.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},N.__r=function(e){we&&we(e),ve=0;var t=(M=e.__c).__H;t&&(ye===M?(t.__h=[],M.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(ze),t.__h.some(Be),t.__h=[],ve=0)),ye=M},N.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&be===N.requestAnimationFrame||((be=N.requestAnimationFrame)||Re)(Ie)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ye=M=null},N.__c=function(e,t){t.some(function(e){try{e.__h.some(ze),e.__h=e.__h.filter(function(e){return!e.__||Be(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],N.__e(n,e.__v)}}),Ee&&Ee(e,t)},N.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{ze(e)}catch(e){t=e}}),n.__H=void 0,t&&N.__e(t,n.__v))};var Le=typeof requestAnimationFrame==`function`;function Re(e){var t,n=function(){clearTimeout(r),Le&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Le&&(t=requestAnimationFrame(n))}function ze(e){var t=M,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),M=t}function Be(e){var t=M;e.__c=e.__(),M=t}function Ve(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function He(e,t){return typeof t==`function`?t(e):t}var Ue=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},We=(e=>e?Ue(e):Ue);function Ge(e,t){for(var n in t)e[n]=t[n];return e}function Ke(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 qe(e,t){var n=t(),r=P({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Me(function(){i.__=n,i.u=t,Je(i)&&a({t:i})},[e,n,t]),je(function(){return Je(i)&&a({t:i}),e(function(){Je(i)&&a({t:i})})},[e]),n}function Je(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 Ye(e){e()}function Xe(e){return e}function Ze(){return[!1,Ye]}var Qe=Me;function $e(e,t){this.props=e,this.context=t}function et(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&(typeof n==`function`?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:Ke(this.props,e)}function r(t){return this.shouldComponentUpdate=n,b(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.__f=r.prototype.isReactComponent=!0,r.type=e,r}($e.prototype=new w).isPureReactComponent=!0,$e.prototype.shouldComponentUpdate=function(e,t){return Ke(this.props,e)||Ke(this.state,t)};var tt=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),tt&&tt(e)};var nt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.forward_ref`)||3911;function rt(e){function t(t){var n=Ge({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=nt,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=`ForwardRef(`+(e.displayName||e.name)+`)`,t}var it=function(e,t){return e==null?null:j(j(e).map(t))},at={map:it,forEach:it,count:function(e){return e?j(e).length:0},only:function(e){var t=j(e);if(t.length!==1)throw`Children.only`;return t[0]},toArray:j},ot=r.__e;r.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}ot(e,t,n,r)};var st=r.unmount;function ct(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Ge({},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(e){return ct(e,t,n)})),e}function lt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return lt(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function ut(){this.__u=0,this.o=null,this.__b=null}function dt(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function ft(e){var t,n,r,i=null;function a(a){if(t||(t=e()).then(function(e){e&&(i=e.default||e),r=!0},function(e){n=e,r=!0}),n)throw n;if(!r)throw t;return i?b(i,a):null}return a.displayName=`Lazy`,a.__f=!0,a}function pt(){this.i=null,this.l=null}r.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),st&&st(e)},(ut.prototype=new w).__c=function(e,t){var n=t.__c,r=this;r.o??(r.o=[]),r.o.push(n);var i=dt(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=lt(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},ut.prototype.componentWillUnmount=function(){this.o=[]},ut.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]=ct(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(C,null,e.fallback);return i&&(i.__u&=-33),[b(C,null,t.__a?null:e.children),i]};var mt=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 ht(e){return this.getChildContext=function(){return e.context},e.children}function gt(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){me(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(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}me(b(ht,{context:t.context},e.__v),t.v)}function _t(e,t){var n=b(gt,{__v:e,h:t});return n.containerInfo=t,n}(pt.prototype=new w).__a=function(e){var t=this,n=dt(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),mt(t,e,r)):i()};n?n(a):a()}},pt.prototype.render=function(e){this.i=null,this.l=new Map;var t=j(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},pt.prototype.componentDidUpdate=pt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){mt(e,n,t)})};var vt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,yt=/^(?: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]/,bt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,xt=/[A-Z0-9]/g,St=typeof document<`u`,Ct=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function wt(e,t,n){return t.__k??(t.textContent=``),me(e,t),typeof n==`function`&&n(),e?e.__c:null}function Tt(e,t,n){return he(e,t),typeof n==`function`&&n(),e?e.__c:null}w.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(w.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Et=r.event;r.event=function(e){return Et&&(e=Et(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Dt,Ot={configurable:!0,get:function(){return this.class}},kt=r.vnode;r.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||St&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Ct(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:bt.test(a)&&(a=s):s=a=`oninput`:i&&yt.test(a)?a=a.replace(xt,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=j(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=j(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,Ot)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=vt,kt&&kt(e)};var At=r.__r;r.__r=function(e){At&&At(e),Dt=e.__c};var jt=r.diffed;r.diffed=function(e){jt&&jt(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),Dt=null};var Mt={ReactCurrentDispatcher:{current:{readContext:function(e){return Dt.__n[e.__c].props.value},useCallback:L,useContext:R,useDebugValue:Pe,useDeferredValue:Xe,useEffect:je,useId:Fe,useImperativeHandle:Ne,useInsertionEffect:Qe,useLayoutEffect:Me,useMemo:I,useReducer:Ae,useRef:F,useState:P,useSyncExternalStore:qe,useTransition:Ze}}};function Nt(e){return b.bind(null,e)}function Pt(e){return!!e&&e.$$typeof===vt}function Ft(e){return Pt(e)&&e.type===C}function It(e){return!!e&&typeof e.displayName==`string`&&e.displayName.indexOf(`Memo(`)==0}function Lt(e){return Pt(e)?ge.apply(null,arguments):e}function Rt(e){return!!e.__k&&(me(null,e),!0)}function zt(e){return e&&(e.base||e.nodeType===1&&e)||null}var Bt={useState:P,useId:Fe,useReducer:Ae,useEffect:je,useLayoutEffect:Me,useInsertionEffect:Qe,useTransition:Ze,useDeferredValue:Xe,useSyncExternalStore:qe,startTransition:Ye,useRef:F,useImperativeHandle:Ne,useMemo:I,useCallback:L,useContext:R,useDebugValue:Pe,version:`18.3.1`,Children:at,render:wt,hydrate:Tt,unmountComponentAtNode:Rt,createPortal:_t,createElement:b,createContext:_e,createFactory:Nt,cloneElement:Lt,createRef:S,Fragment:C,isValidElement:Pt,isElement:Pt,isFragment:Ft,isMemo:It,findDOMNode:zt,Component:w,PureComponent:$e,memo:et,forwardRef:rt,flushSync:function(e,t){var n=r.debounceRendering;r.debounceRendering=function(e){return e()};var i=e(t);return r.debounceRendering=n,i},unstable_batchedUpdates:function(e,t){return e(t)},StrictMode:C,Suspense:ut,SuspenseList:pt,lazy:ft,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Mt},Vt=e=>e;function Ht(e,t=Vt){let n=Bt.useSyncExternalStore(e.subscribe,Bt.useCallback(()=>t(e.getState()),[e,t]),Bt.useCallback(()=>t(e.getInitialState()),[e,t]));return Bt.useDebugValue(n),n}var Ut=e=>{let t=We(e),n=e=>Ht(t,e);return Object.assign(n,t),n},Wt=(e=>e?Ut(e):Ut),Gt=Symbol.for(`immer-nothing`),Kt=Symbol.for(`immer-draftable`),z=Symbol.for(`immer-state`);function B(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var qt=Object,Jt=qt.getPrototypeOf,Yt=`constructor`,Xt=`prototype`,Zt=`configurable`,Qt=`enumerable`,$t=`writable`,en=`value`,tn=e=>!!e&&!!e[z];function nn(e){return e?on(e)||pn(e)||!!e[Kt]||!!e[Yt]?.[Kt]||mn(e)||hn(e):!1}var rn=qt[Xt][Yt].toString(),an=new WeakMap;function on(e){if(!e||!gn(e))return!1;let t=Jt(e);if(t===null||t===qt[Xt])return!0;let n=qt.hasOwnProperty.call(t,Yt)&&t[Yt];if(n===Object)return!0;if(!_n(n))return!1;let r=an.get(n);return r===void 0&&(r=Function.toString.call(n),an.set(n,r)),r===rn}function sn(e,t,n=!0){cn(e)===0?(n?Reflect.ownKeys(e):qt.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function cn(e){let t=e[z];return t?t.type_:pn(e)?1:mn(e)?2:hn(e)?3:0}var ln=(e,t,n=cn(e))=>n===2?e.has(t):qt[Xt].hasOwnProperty.call(e,t),un=(e,t,n=cn(e))=>n===2?e.get(t):e[t],dn=(e,t,n,r=cn(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function fn(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var pn=Array.isArray,mn=e=>e instanceof Map,hn=e=>e instanceof Set,gn=e=>typeof e==`object`,_n=e=>typeof e==`function`,vn=e=>typeof e==`boolean`;function yn(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var bn=e=>gn(e)?e?.[z]:null,xn=e=>e.copy_||e.base_,Sn=e=>e.modified_?e.copy_:e.base_;function Cn(e,t){if(mn(e))return new Map(e);if(hn(e))return new Set(e);if(pn(e))return Array[Xt].slice.call(e);let n=on(e);if(t===!0||t===`class_only`&&!n){let t=qt.getOwnPropertyDescriptors(e);delete t[z];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[$t]===!1&&(a[$t]=!0,a[Zt]=!0),(a.get||a.set)&&(t[i]={[Zt]:!0,[$t]:!0,[Qt]:a[Qt],[en]:e[i]})}return qt.create(Jt(e),t)}else{let t=Jt(e);if(t!==null&&n)return{...e};let r=qt.create(t);return qt.assign(r,e)}}function wn(e,t=!1){return Dn(e)||tn(e)||!nn(e)?e:(cn(e)>1&&qt.defineProperties(e,{set:En,add:En,clear:En,delete:En}),qt.freeze(e),t&&sn(e,(e,t)=>{wn(t,!0)},!1),e)}function Tn(){B(2)}var En={[en]:Tn};function Dn(e){return e===null||!gn(e)?!0:qt.isFrozen(e)}var On=`MapSet`,kn=`Patches`,An=`ArrayMethods`,jn={};function Mn(e){let t=jn[e];return t||B(0,e),t}var Nn=e=>!!jn[e];function Pn(e,t){jn[e]||(jn[e]=t)}var Fn,In=()=>Fn,Ln=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Nn(On)?Mn(On):void 0,arrayMethodsPlugin_:Nn(An)?Mn(An):void 0});function Rn(e,t){t&&(e.patchPlugin_=Mn(kn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function zn(e){Bn(e),e.drafts_.forEach(Hn),e.drafts_=null}function Bn(e){e===Fn&&(Fn=e.parent_)}var Vn=e=>Fn=Ln(Fn,e);function Hn(e){let t=e[z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Un(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[z].modified_&&(zn(t),B(4)),nn(e)&&(e=Wn(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[z].base_,e,t)}else e=Wn(t,n);return Gn(t,e,!0),zn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===Gt?void 0:e}function Wn(e,t){if(Dn(t))return t;let n=t[z];if(!n)return $n(t,e.handledSet_,e);if(!qn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);Zn(n,e)}return n.copy_}function Gn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&wn(t,n)}function Kn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var qn=(e,t)=>e.scope_===t,Jn=[];function Yn(e,t,n,r){let i=xn(e),a=e.type_;if(r!==void 0&&un(i,r,a)===t){dn(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;sn(i,(e,n)=>{if(tn(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Jn;for(let e of o)dn(i,e,n,a)}function Xn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!qn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Sn(i);Yn(e,i.draft_??i,a,n),Zn(i,r)})}function Zn(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}Kn(e)}}function Qn(e,t,n){let{scope_:r}=e;if(tn(n)){let i=n[z];qn(i,r)&&i.callbacks_.push(function(){sr(e),Yn(e,n,Sn(i),t)})}else nn(n)&&e.callbacks_.push(function(){let i=xn(e);e.type_===3?i.has(n)&&$n(n,r.handledSet_,r):un(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&$n(un(e.copy_,t,e.type_),r.handledSet_,r)})}function $n(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||tn(e)||t.has(e)||!nn(e)||Dn(e)?e:(t.add(e),sn(e,(r,i)=>{if(tn(i)){let t=i[z];qn(t,n)&&(dn(e,r,Sn(t),e.type_),Kn(t))}else nn(i)&&$n(i,t,n)}),e)}function er(e,t){let n=pn(e),r={type_:n?1:0,scope_:t?t.scope_:In(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=tr;n&&(i=[r],a=nr);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var tr={get(e,t){if(t===z)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=xn(e);if(!ln(i,t,e.type_))return ir(e,i,t);let a=i[t];if(e.finalized_||!nn(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&yn(t))return a;if(a===rr(e.base_,t)){sr(e);let n=e.type_===1?+t:t,r=lr(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in xn(e)},ownKeys(e){return Reflect.ownKeys(xn(e))},set(e,t,n){let r=ar(xn(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=rr(xn(e),t),i=r?.[z];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(fn(n,r)&&(n!==void 0||ln(e.base_,t,e.type_)))return!0;sr(e),or(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Qn(e,t,n),!0)},deleteProperty(e,t){return sr(e),rr(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),or(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=xn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[$t]:!0,[Zt]:e.type_!==1||t!==`length`,[Qt]:r[Qt],[en]:n[t]}},defineProperty(){B(11)},getPrototypeOf(e){return Jt(e.base_)},setPrototypeOf(){B(12)}},nr={};for(let e in tr){let t=tr[e];nr[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}nr.deleteProperty=function(e,t){return nr.set.call(this,e,t,void 0)},nr.set=function(e,t,n){return tr.set.call(this,e[0],t,n,e[0])};function rr(e,t){let n=e[z];return(n?xn(n):e)[t]}function ir(e,t,n){let r=ar(t,n);return r?en in r?r[en]:r.get?.call(e.draft_):void 0}function ar(e,t){if(!(t in e))return;let n=Jt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Jt(n)}}function or(e){e.modified_||(e.modified_=!0,e.parent_&&or(e.parent_))}function sr(e){e.copy_||(e.assigned_=new Map,e.copy_=Cn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var cr=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(_n(e)&&!_n(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}_n(t)||B(6),n!==void 0&&!_n(n)&&B(7);let r;if(nn(e)){let i=Vn(this),a=lr(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?zn(i):Bn(i)}return Rn(i,n),Un(r,i)}else if(!e||!gn(e)){if(r=t(e),r===void 0&&(r=e),r===Gt&&(r=void 0),this.autoFreeze_&&wn(r,!0),n){let t=[],i=[];Mn(kn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else B(1,e)},this.produceWithPatches=(e,t)=>{if(_n(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},vn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),vn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),vn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){nn(e)||B(8),tn(e)&&(e=ur(e));let t=Vn(this),n=lr(t,e,void 0);return n[z].isManual_=!0,Bn(t),n}finishDraft(e,t){let n=e&&e[z];(!n||!n.isManual_)&&B(9);let{scope_:r}=n;return Rn(r,t),Un(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--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=Mn(kn).applyPatches_;return tn(e)?r(e,t):this.produce(e,e=>r(e,t))}};function lr(e,t,n,r){let[i,a]=mn(t)?Mn(On).proxyMap_(t,n):hn(t)?Mn(On).proxySet_(t,n):er(t,n);return(n?.scope_??In()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Xn(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function ur(e){return tn(e)||B(10,e),dr(e)}function dr(e){if(!nn(e)||Dn(e))return e;let t=e[z],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Cn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Cn(e,!0);return sn(n,(e,t)=>{dn(n,e,dr(t))},r),t&&(t.finalized_=!1),n}function fr(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=bn(un(e,n.key_)),i=un(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||ln(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=un(n,r),!gn(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[z];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;sn(e.assigned_,(e,l)=>{let u=un(o,e,c),f=un(s,e,c),p=l?ln(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===Gt?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=cn(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Yt)&&B(19),_n(o)&&n===Xt&&B(19),o=un(o,n),gn(o)||B(18,i.join(`/`))}let s=cn(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:B(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:B(17,a)}}),e}function u(e){if(!nn(e))return e;if(pn(e))return e.map(u);if(mn(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(hn(e))return new Set(Array.from(e).map(u));let t=Object.create(Jt(e));for(let n in e)t[n]=u(e[n]);return ln(e,Kt)&&(t[Kt]=e[Kt]),t}function d(e){return tn(e)?u(e):e}Pn(kn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var pr=new cr,mr=pr.produce,hr=pr.produceWithPatches.bind(pr),gr=pr.applyPatches.bind(pr),_r=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?mr(e):e,n,...r),e(r.setState,n,r)),vr=/[a-zA-Z]/,yr=new Set([`br`,`col`,`hr`,`img`,`wbr`]);function br(e){let t=e.indexOf(`|`);if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};let n=e.indexOf(`->`);if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};let r=e.indexOf(`<-`);if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};let i=e.trim();return{display:i,target:i}}function xr(e){let 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 Sr(e,t){let n=[],r=``,i=t;for(;i<e.length&&(e[i]===`.`||e[i]===`#`);){let t=e[i];i++;let a=``;for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))a+=e[i],i++;else if(e[i]===`{`&&(e[i+1]===`$`||e[i+1]===`_`||e[i+1]===`@`)){let t=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===`}`)i++,a+=e.slice(t,i);else{i=t;break}}else break;a&&(t===`.`?n.push(a):r=a)}return{className:n.join(` `),id:r,endIdx:i}}function Cr(e,t){let 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;let r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;let i=e.slice(r,t);if(!i)break;if(e[t]===`=`)if(t++,e[t]===`\"`||e[t]===`'`){let r=e[t];t++;let a=t,o=0;for(;t<e.length;){if(e[t]===`{`)o++;else if(e[t]===`}`)o--;else if(e[t]===r&&o<=0)break;t++}n[i]=e.slice(a,t),t<e.length&&t++}else{let r=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(r,t)}else n[i]=``}return{attributes:n,endIdx:t}}function wr(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 Tr(e){let t=[],n=0,r=0;function i(n){n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})}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);let a=n;n+=2;let o,s;if(e[n]===`.`||e[n]===`#`){let t=Sr(e,n);o=t.className||void 0,s=t.id||void 0,n=t.endIdx,e[n]===` `&&n++}let c=1,l=n;for(;n<e.length&&c>0;)if(e[n]===`[`&&e[n+1]===`[`)c++,n+=2;else if(e[n]===`]`&&e[n+1]===`]`){if(c--,c===0)break;n+=2}else n++;if(c!==0){n=a+2,r=a;continue}let u=e.slice(l,n);n+=2;let{display:d,target:f}=br(u),p={type:`link`,display:d,target:f,start:a,end:n};o&&(p.className=o),s&&(p.id=s),t.push(p),r=n;continue}if(e[n]===`{`){let a=n,o=e[n+1],s,c;if(o===`.`||o===`#`){i(n);let o=Sr(e,n+1);s=o.className||void 0,c=o.id||void 0;let l=o.endIdx;e[l]===` `&&l++;let u=e[l];if(u===`$`){n=l+1;let i=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let o=e.slice(i,n);if(e[n]===`}`){n++;let e={type:`variable`,name:o,scope:`variable`,start:a,end:n};s&&(e.className=s),c&&(e.id=c),t.push(e),r=n;continue}let u=wr(e,i);if(u!==-1){let i=e.slice(l,u);n=u+1;let o={type:`expression`,expression:i,start:a,end:n};s&&(o.className=s),c&&(o.id=c),t.push(o),r=n;continue}n=a+1,r=a;continue}if(u===`_`){n=l+1;let i=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let o=e.slice(i,n);if(e[n]===`}`){n++;let e={type:`variable`,name:o,scope:`temporary`,start:a,end:n};s&&(e.className=s),c&&(e.id=c),t.push(e),r=n;continue}let u=wr(e,i);if(u!==-1){let i=e.slice(l,u);n=u+1;let o={type:`expression`,expression:i,start:a,end:n};s&&(o.className=s),c&&(o.id=c),t.push(o),r=n;continue}n=a+1,r=a;continue}if(u===`@`){n=l+1;let i=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let o=e.slice(i,n);if(e[n]===`}`){n++;let e={type:`variable`,name:o,scope:`local`,start:a,end:n};s&&(e.className=s),c&&(e.id=c),t.push(e),r=n;continue}let u=wr(e,i);if(u!==-1){let i=e.slice(l,u);n=u+1;let o={type:`expression`,expression:i,start:a,end:n};s&&(o.className=s),c&&(o.id=c),t.push(o),r=n;continue}n=a+1,r=a;continue}if(u===`%`){n=l+1;let i=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let o=e.slice(i,n);if(e[n]===`}`){n++;let e={type:`variable`,name:o,scope:`transient`,start:a,end:n};s&&(e.className=s),c&&(e.id=c),t.push(e),r=n;continue}let u=wr(e,i);if(u!==-1){let i=e.slice(l,u);n=u+1;let o={type:`expression`,expression:i,start:a,end:n};s&&(o.className=s),c&&(o.id=c),t.push(o),r=n;continue}n=a+1,r=a;continue}if(u!==void 0&&/[a-zA-Z]/.test(u)){n=l;let i=1,o=n;for(;n<e.length&&i>0;)e[n]===`{`?i++:e[n]===`}`&&i--,i>0&&n++;if(i!==0){n=a+1,r=a;continue}let u=e.slice(o,n);n++;let{name:d,rawArgs:f,isClose:p}=xr(u),m={type:`macro`,name:d,rawArgs:f,isClose:p,start:a,end:n};s&&(m.className=s),c&&(m.id=c),t.push(m),r=n;continue}n=a+1,r=a;continue}if(o===`$`){i(n),n+=2;let o=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let s=e.slice(o,n);if(e[n]===`}`){n++,t.push({type:`variable`,name:s,scope:`variable`,start:a,end:n}),r=n;continue}let c=wr(e,o);if(c!==-1){let i=e.slice(a+1,c);n=c+1,t.push({type:`expression`,expression:i,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===`_`){i(n),n+=2;let o=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let s=e.slice(o,n);if(e[n]===`}`){n++,t.push({type:`variable`,name:s,scope:`temporary`,start:a,end:n}),r=n;continue}let c=wr(e,o);if(c!==-1){let i=e.slice(a+1,c);n=c+1,t.push({type:`expression`,expression:i,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===`@`){i(n),n+=2;let o=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let s=e.slice(o,n);if(e[n]===`}`){n++,t.push({type:`variable`,name:s,scope:`local`,start:a,end:n}),r=n;continue}let c=wr(e,o);if(c!==-1){let i=e.slice(a+1,c);n=c+1,t.push({type:`expression`,expression:i,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===`%`){i(n),n+=2;let o=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;let s=e.slice(o,n);if(e[n]===`}`){n++,t.push({type:`variable`,name:s,scope:`transient`,start:a,end:n}),r=n;continue}let c=wr(e,o);if(c!==-1){let i=e.slice(a+1,c);n=c+1,t.push({type:`expression`,expression:i,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 o=1,s=n;for(;n<e.length&&o>0;)e[n]===`{`?o++:e[n]===`}`&&o--,o>0&&n++;if(o!==0){n=a+1,r=a;continue}let c=e.slice(s,n);n++;let{name:l,rawArgs:u,isClose:d}=xr(c);t.push({type:`macro`,name:l,rawArgs:u,isClose:d,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===`<`){let a=n,o=n+1,s=e[o]===`/`;s&&o++;let c=o;for(;o<e.length&&/[a-zA-Z0-9-]/.test(e[o]);)o++;let l=e.slice(c,o),u=l.toLowerCase();if(l&&vr.test(l[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===`>`){o++,i(a),t.push({type:`html`,tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{let s=Cr(e,o);o=s.endIdx;let c=yr.has(u);if(e[o]===`/`&&(c=!0,o++),e[o]===`>`){o++,i(a),t.push({type:`html`,tag:l,attributes:s.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}var Er=new Set([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function Dr(e){Er.add(e.toLowerCase())}var Or={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},kr=new Set([`if`,`switch`,`timed`]);function Ar(e){let t=[],n=[];function r(){if(n.length===0)return t;let e=n[n.length-1].node;return e.type===`macro`&&e.branches&&e.branches.length>0?e.branches[e.branches.length-1].children:e.children}for(let t of e)switch(t.type){case`text`:r().push({type:`text`,value:t.value});break;case`link`:{let e={type:`macro`,name:`link`,rawArgs:`\"${t.display}\" \"${t.target}\"`,children:[]};t.className&&(e.className=t.className),t.id&&(e.id=t.id),r().push(e);break}case`variable`:{let e={type:`variable`,name:t.name,scope:t.scope};t.className&&(e.className=t.className),t.id&&(e.id=t.id),r().push(e);break}case`expression`:{let e={type:`expression`,expression:t.expression};t.className&&(e.className=t.className),t.id&&(e.id=t.id),r().push(e);break}case`html`:{if(t.isSelfClose){r().push({type:`html`,tag:t.tag,attributes:t.attributes,children:[]});break}if(t.isClose){if(n.length===0)throw Error(`Unexpected closing </${t.tag}> (at character ${t.start})`);let e=n[n.length-1];if(e.node.type!==`html`||e.node.tag.toLowerCase()!==t.tag.toLowerCase()){let n=e.node.type===`html`?`</${e.node.tag}>`:`{/${e.node.name}}`;throw Error(`Expected ${n} but found </${t.tag}> (at character ${t.start})`)}n.pop(),r().push(e.node);break}let e={type:`html`,tag:t.tag,attributes:t.attributes,children:[]};n.push({node:e,start:t.start});break}case`macro`:{let e=t.name.toLowerCase();if(t.isClose){if(n.length===0)throw Error(`Unexpected closing {/${t.name}} (at character ${t.start})`);let i=n[n.length-1];if(i.node.type!==`macro`||i.node.name!==e){let e=i.node.type===`macro`?`{/${i.node.name}}`:`</${i.node.tag}>`;throw Error(`Expected ${e} but found {/${t.name}} (at character ${t.start})`)}n.pop(),r().push(i.node);break}if(Or[e]){let r=Or[e],i=n.length>0?n[n.length-1].node:null;if(!i||i.type!==`macro`||i.name!==r)throw Error(`{${t.name}} without matching {${r}} (at character ${t.start})`);let a={rawArgs:t.rawArgs,children:[]};t.className&&(a.className=t.className),t.id&&(a.id=t.id),i.branches.push(a);break}if(Er.has(e)){let r={type:`macro`,name:e,rawArgs:t.rawArgs,children:[]};if(kr.has(e)){let e={rawArgs:t.rawArgs,children:[]};t.className&&(e.className=t.className),t.id&&(e.id=t.id),r.branches=[e]}else t.className&&(r.className=t.className),t.id&&(r.id=t.id);n.push({node:r,start:t.start});break}{let n={type:`macro`,name:e,rawArgs:t.rawArgs,children:[]};t.className&&(n.className=t.className),t.id&&(n.id=t.id),r().push(n)}break}default:throw Error(`Unknown token type: ${t.type}`)}if(n.length>0){let e=n[n.length-1],t=e.node.type===`html`?`<${e.node.tag}>`:`{${e.node.name}} macro`;throw Error(`Unclosed ${t} (opened at character ${e.start})`)}return t}function jr(){let e=Z(e=>e.variables),t=Z(e=>e.temporary),n=Z(e=>e.transient),r=R(Ws);return I(()=>[e,t,r,n],[e,t,r,n])}function Mr(e){let t=e|0;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,t|1);return e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Nr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var Pr=!1,Fr=``,Ir=0,Lr=null;function Rr(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,Fr=n,Ir=0,Lr=Mr(Nr(n)),Pr=!0}function zr(e,t){Fr=e,Ir=0,Lr=Mr(Nr(e)),Pr=!0;for(let e=0;e<t;e++)Lr();Ir=t}function Br(){Pr=!1,Fr=``,Ir=0,Lr=null}function Vr(){return Pr?{seed:Fr,pull:Ir}:null}function Hr(){return!Pr||!Lr?Math.random():(Ir++,Lr())}function Ur(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Hr()*(t-e+1))+e}function Wr(){return Pr}function Gr(){return Fr}function Kr(){return Ir}var qr=500,Jr=new Map,Yr=/\\$(\\w+)/g,Xr=/(?<![.\\w])_(\\w+)/g,Zr=/@(\\w+)/g,Qr=/(?<!\\w)%(\\w+)/g;function $r(e){return e.replace(Yr,`variables[\"$1\"]`).replace(Xr,`temporary[\"$1\"]`).replace(Zr,`locals[\"$1\"]`).replace(Qr,`transient[\"$1\"]`)}function ei(e){let t=``,n=``,r=0;function i(){n&&(t+=$r(n),n=``)}for(;r<e.length;){let a=e.charAt(r);if(a===`\"`||a===`'`){i();let n=a,o=n;for(r++;r<e.length;){let t=e.charAt(r);if(t===`\\\\`&&r+1<e.length)o+=t+e.charAt(r+1),r+=2;else if(t===n){o+=n,r++;break}else o+=t,r++}t+=o;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){let n=e.charAt(r);if(n===`\\\\`&&r+1<e.length)t+=n+e.charAt(r+1),r+=2;else if(n===`$`&&e.charAt(r+1)===`{`){t+=\"${\",r+=2;let n=1,i=``;for(;r<e.length&&n>0;){let t=e.charAt(r);if(t===`{`)n++,i+=t;else if(t===`}`){if(n--,n===0)break;i+=t}else if(t===`\\\\`&&r+1<e.length)i+=t+e.charAt(r+1),r++;else if(t===`\"`||t===`'`){for(i+=t,r++;r<e.length;){let n=e.charAt(r);if(n===`\\\\`&&r+1<e.length)i+=n+e.charAt(r+1),r+=2;else if(n===t){i+=n,r++;break}else i+=n,r++}continue}else if(t===\"`\"){for(i+=t,r++;r<e.length;){let t=e.charAt(r);if(t===`\\\\`&&r+1<e.length)i+=t+e.charAt(r+1),r+=2;else if(t===`$`&&e.charAt(r+1)===`{`){i+=\"${\",r+=2;let t=1;for(;r<e.length&&t>0;){let n=e.charAt(r);n===`{`?t++:n===`}`&&t--,t>0&&(i+=n),r++}i+=`}`}else if(t===\"`\"){i+=t,r++;break}else i+=t,r++}continue}else i+=t;r++}t+=ei(i),r<e.length&&e.charAt(r)===`}`&&(t+=`}`,r++)}else if(n===\"`\"){t+=\"`\",r++;break}else t+=n,r++}continue}n+=a,r++}return i(),t}var ti=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function ni(e,t){let n=Jr.get(e);if(n)return Jr.delete(e),Jr.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,ti+t);if(Jr.set(e,r),Jr.size>qr){let e=Jr.keys().next().value;e!==void 0&&Jr.delete(e)}return r}var ri=null,ii=null,ai=null;function oi(){let{visitCounts:e,renderCounts:t}=Z.getState();if(ri&&ii===e&&ai===t)return ri;let n=t=>e[t??Z.getState().currentPassage]??0,r=e=>n(e)>0,i=(...e)=>e.some(e=>n(e)>0),a=(...e)=>e.every(e=>n(e)>0),o=e=>t[e??Z.getState().currentPassage]??0;return ri={currentPassage:()=>{let e=Z.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage:()=>{let e=Z.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},visited:n,hasVisited:r,hasVisitedAny:i,hasVisitedAll:a,rendered:o,hasRendered:e=>o(e)>0,hasRenderedAny:(...e)=>e.some(e=>o(e)>0),hasRenderedAll:(...e)=>e.every(e=>o(e)>0),random:Hr,randomInt:Ur},ii=e,ai=t,ri}function si(e,t,n,r={},i={}){let a=`return (${ei(e)});`;return ni(a,a)(t,n,r,oi(),i)}function ci(e,t,n,r={},i={}){let a=ei(e);ni(`exec:`+a,a)(t,n,r,oi(),i)}var li=/\\{[\\$_@%]\\w/;function ui(e){return li.test(e)}function di(e,t){let n=e;for(let e=1;e<t.length;e++){if(typeof n!=`object`||!n)return;n=n[t[e]]}return n}function fi(e,t,n,r,i={}){let a=si(e,t,n,r,i);return a==null?``:String(a)}function pi(e,t,n,r,i){let a=e[0],o=e.slice(1).split(`.`),s=o[0],c;return c=a===`$`?t[s]:a===`_`?n[s]:a===`%`?i[s]:r[s],o.length>1&&(c=di(c,o)),c==null?``:String(c)}function mi(e,t,n,r,i={}){let a=``,o=0;for(;o<e.length;){if(e[o]!==`{`){let t=e.indexOf(`{`,o);if(t===-1){a+=e.slice(o);break}a+=e.slice(o,t),o=t;continue}o++;let s=e[o];if(s!==`$`&&s!==`_`&&s!==`@`&&s!==`%`){a+=`{`;continue}let c=1,l=o;for(;l<e.length&&c>0;)l++,e[l]===`{`?c++:e[l]===`}`&&c--;if(c!==0){a+=`{`;continue}let u=e.slice(o,l);o=l+1,/^[\\$_@%][\\w.]+$/.test(u)?a+=pi(u,t,n,r,i):a+=fi(u,t,n,r,i)}return a}function hi(){let[e,t,n,r]=jr();return L(i=>i===void 0||!ui(i)?i:mi(i,e,t,n,r),[e,t,n,r])}var gi=0;Array.isArray;function V(e,t,n,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gi,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}function _i({name:e,scope:t,className:n,id:r}){let i=hi();n=i(n),r=i(r);let a=R(Ws),o=e.split(`.`),s=o[0],c=Z(e=>t===`variable`?e.variables[s]:t===`temporary`?e.temporary[s]:t===`transient`?e.transient[s]:void 0),l;l=t===`local`?s in a?a[s]:void 0:c;for(let e=1;e<o.length;e++){if(typeof l!=`object`||!l){l=void 0;break}let t=o[e];l=l[t]}let u=l==null?``:String(l);return n||r?V(`span`,{id:r,class:n,children:u}):V(C,{children:u})}function vi({expression:e,className:t,id:n}){let r=hi();t=r(t),n=r(n);let i=R(Ws),a=Z(e=>e.variables),o=Z(e=>e.temporary),s=Z(e=>e.transient),c;try{let t=si(e,a,o,i,s);c=t==null?``:String(t)}catch{c=`{error: ${e}}`}return t||n?V(`span`,{id:n,class:t,children:c}):V(C,{children:c})}function yi(e){let 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 bi(e){let t=[],n=``,r=0,i=null;for(let a=0;a<e.length;a++){let 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(let e of t)if(!yi(e))return null;return t}function xi(e){let t=[],n=``,r=0,i=null,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(i){n+=s,s===i&&e[o-1]!==`\\\\`&&(i=null);continue}if(s===`\"`||s===`'`||s===\"`\"){i=s,n+=s;continue}if(s===`(`||s===`[`||s===`{`){r++,n+=s;continue}if(s===`)`||s===`]`||s===`}`){r--,n+=s;continue}if(s===`,`&&r===0){a=!0,t.push(n.trim()),n=``;continue}n+=s}let o=n.trim();if(o&&t.push(o),!a&&t.length===1){let e=bi(t[0]);if(e)return e}return t}function Si({body:e,parentValues:t,ownKeys:n}){let r=R(q),[i,a]=P({}),o=I(()=>({...t,...n,...i}),[t,n,i]),s=F(o);s.current=o;let c=L(()=>s.current,[]),l=L((e,t)=>{a(n=>({...n,[e]:t}))},[]),u=I(()=>({update:l,getValues:c}),[l,c]);return V(Gs.Provider,{value:u,children:V(Ws.Provider,{value:o,children:uc(e,{nobr:r,locals:o})})})}function Ci({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=R(Ws),a=R(q),[o,s,c,l]=jr(),u=r?.length?r:null;if(t.length===0||!n)return V(qs.Provider,{value:u,children:uc(e,{nobr:a,locals:i})});let d=xi(n),f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=si(t,o,s,c,l)}catch{n=void 0}f.push(n)}let p=I(()=>{let e={};for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=f[n];return e},f);return V(qs.Provider,{value:u,children:V(Si,{body:e,parentValues:i,ownKeys:p})})}var wi=new Map;function Ti(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);wi.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Ei(e){return wi.get(e.toLowerCase())}var Di=new Map;function Oi(e,t){Di.set(e.toLowerCase(),t)}function ki(e){return Di.get(e.toLowerCase())}var Ai=new Set;function ji(e){Ai.add(e.toLowerCase())}function Mi(e){return Ai.has(e.toLowerCase())}var Ni=new Map;function Pi(e,t){Ni.set(e.toLowerCase(),t)}function Fi(){return Array.from(Ni.values())}var Ii=document.createElement(`i`);function Li(e){let t=`&`+e+`;`;Ii.innerHTML=t;let n=Ii.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Ri(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+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 H(e,t){return e.length>0?(Ri(e,e.length,0,t),e):t}var zi={}.hasOwnProperty;function Bi(e){let t={},n=-1;for(;++n<e.length;)Vi(t,e[n]);return t}function Vi(e,t){let n;for(n in t){let r=(zi.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){zi.call(r,a)||(r[a]=[]);let e=i[a];Hi(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Hi(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Ri(e,0,0,r)}function Ui(e){let t={},n=-1;for(;++n<e.length;)Wi(t,e[n]);return t}function Wi(e,t){let n;for(n in t){let r=(zi.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function Gi(e,t){let 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)}var Ki={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function qi(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+Ki[e]+`;`}}function Ji(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Yi=ia(/[A-Za-z]/),Xi=ia(/[\\dA-Za-z]/),Zi=ia(/[#-'*+\\--9=?A-Z^-~]/);function Qi(e){return e!==null&&(e<32||e===127)}var $i=ia(/\\d/),ea=ia(/[\\dA-Fa-f]/),ta=ia(/[!-/:-@[-`{-~]/);function U(e){return e!==null&&e<-2}function W(e){return e!==null&&(e<0||e===32)}function G(e){return e===-2||e===-1||e===32}var na=ia(/\\p{P}|\\p{S}/u),ra=ia(/\\s/);function ia(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function aa(e,t){let n=qi(oa(e||``));if(!t)return n;let 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 oa(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Xi(e.charCodeAt(n+1))&&Xi(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){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),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)}var sa={}.hasOwnProperty,ca=/^(https?|ircs?|mailto|xmpp)$/i,la=/^https?$/i;function ua(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=Ui([{enter:{blockQuote:ee,codeFenced:ne,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:ae,codeText:L,content:Se,definition:_e,definitionDestinationString:M,definitionLabelString:h,definitionTitleString:h,emphasis:Ne,htmlFlow:je,htmlText:F,image:se,label:h,link:ce,listItemMarker:E,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:A,reference:h,resource:fe,resourceDestinationString:pe,resourceTitleString:h,setextHeading:Ce,strong:I},exit:{atxHeading:Te,atxHeadingSequence:N,autolinkEmail:Be,autolinkProtocol:ze,blockQuote:te,characterEscapeValue:Oe,characterReferenceMarkerHexadecimal:Le,characterReferenceMarkerNumeric:Le,characterReferenceValue:Re,codeFenced:oe,codeFencedFence:ie,codeFencedFenceInfo:re,codeFencedFenceMeta:S,codeFlowValue:P,codeIndented:oe,codeText:R,codeTextData:Oe,data:Oe,definition:xe,definitionDestinationString:ye,definitionLabelString:ve,definitionTitleString:be,emphasis:Pe,hardBreakEscape:Ae,hardBreakTrailing:Ae,htmlFlow:Me,htmlFlowData:Oe,htmlText:Me,htmlTextData:Oe,image:ge,label:ue,labelText:le,lineEnding:ke,link:ge,listOrdered:D,listUnordered:O,paragraph:j,reference:S,referenceString:de,resource:S,resourceDestinationString:me,resourceTitleString:he,setextHeading:De,setextHeadingLineSequence:Ee,setextHeadingText:we,strong:Fe,thematicBreak:Ie}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=H(o,e.slice(n,t)),n=t):(a=H(a,e.slice(n,t+1)),n=t+1));a=H(a,o),a=H(a,e.slice(n)),t=-1;let c=a;for(s.enter.null&&s.enter.null.call(l);++t<e.length;){let e=s[c[t][0]],n=c[t][1].type,r=e[n];sa.call(e,n)&&r&&r.call({sliceSerialize:c[t][2].sliceSerialize,...l},c[t][1])}return s.exit.null&&s.exit.null.call(l),i[0].join(``)}function f(e){let t=e.length,n=0,r=0,i=!1,a;for(;++n<t;){let t=e[n];if(t[1]._container)a=void 0,t[0]===`enter`?r++:r--;else switch(t[1].type){case`listItemPrefix`:t[0]===`exit`&&(a=!0);break;case`linePrefix`:break;case`lineEndingBlank`:t[0]===`enter`&&!r&&(a?a=void 0:i=!0);break;default:a=void 0}}e[0][1]._loose=i}function p(e,t){c[e]=t}function m(e){return c[e]}function h(){i.push([])}function g(){return i.pop().join(``)}function _(e){n&&(p(`lastWasTag`,!0),i[i.length-1].push(e))}function v(e){p(`lastWasTag`),i[i.length-1].push(e)}function y(){v(u||`\n`)}function b(){let e=i[i.length-1],t=e[e.length-1],n=t?t.charCodeAt(t.length-1):null;n===10||n===13||n===null||y()}function x(e){return m(`ignoreEncode`)?e:qi(e)}function S(){g()}function C(e){o.push(!e._loose),b(),_(`<ol`),p(`expectFirstItem`,!0)}function w(e){o.push(!e._loose),b(),_(`<ul`),p(`expectFirstItem`,!0)}function T(e){if(m(`expectFirstItem`)){let t=Number.parseInt(this.sliceSerialize(e),10);t!==1&&_(` start=\"`+x(String(t))+`\"`)}}function E(){m(`expectFirstItem`)?_(`>`):k(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function D(){k(),o.pop(),y(),_(`</ol>`)}function O(){k(),o.pop(),y(),_(`</ul>`)}function k(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function ee(){o.push(!1),b(),_(`<blockquote>`)}function te(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function A(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function j(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ne(){b(),_(`<pre><code`),p(`fencesCount`,0)}function re(){_(` class=\"language-`+g()+`\"`)}function ie(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function ae(){b(),_(`<pre><code>`)}function oe(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function se(){a.push({image:!0}),n=void 0}function ce(){a.push({})}function le(e){a[a.length-1].labelId=this.sliceSerialize(e)}function ue(){a[a.length-1].label=g()}function de(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function fe(){h(),a[a.length-1].destination=``}function pe(){h(),p(`ignoreEncode`,!0)}function me(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function he(){a[a.length-1].title=g()}function ge(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[Ji(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+aa(s.destination,t.allowDangerousProtocol?void 0:la)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+aa(s.destination,t.allowDangerousProtocol?void 0:ca)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function _e(){h(),a.push({})}function ve(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function M(){h(),p(`ignoreEncode`,!0)}function ye(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function be(){a[a.length-1].title=g()}function xe(){let e=a[a.length-1],t=Ji(e.labelId);g(),sa.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function Se(){p(`slurpAllLineEndings`,!0)}function N(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function Ce(){h(),p(`slurpAllLineEndings`)}function we(){p(`slurpAllLineEndings`,!0)}function Te(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function Ee(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function De(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function Oe(e){v(x(this.sliceSerialize(e)))}function ke(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function P(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function Ae(){_(`<br />`)}function je(){b(),F()}function Me(){p(`ignoreEncode`)}function F(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Ne(){_(`<em>`)}function I(){_(`<strong>`)}function L(){p(`inCodeText`,!0),_(`<code>`)}function R(){p(`inCodeText`),_(`</code>`)}function Pe(){_(`</em>`)}function Fe(){_(`</strong>`)}function Ie(){b(),_(`<hr />`)}function Le(e){p(`characterReferenceType`,e.type)}function Re(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?Gi(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):Li(t))),p(`characterReferenceType`)}function ze(e){let n=this.sliceSerialize(e);_(`<a href=\"`+aa(n,t.allowDangerousProtocol?void 0:ca)+`\">`),v(x(n)),_(`</a>`)}function Be(e){let t=this.sliceSerialize(e);_(`<a href=\"`+aa(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function K(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return G(r)?(e.enter(n),s(r)):t(r)}function s(r){return G(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var da={tokenize:fa};function fa(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),K(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return U(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var pa={tokenize:ha},ma={tokenize:ga};function ha(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Ri(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ma,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(ma,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return U(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Ri(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ga(e,t,n){return K(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function _a(e){if(e===null||W(e)||ra(e))return 1;if(na(e))return 2}function va(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var ya={name:`attention`,resolveAll:ba,tokenize:xa};function ba(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Sa(d,-c),Sa(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=H(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=H(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=H(l,va(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=H(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=H(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Ri(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function xa(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=_a(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=_a(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Sa(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ca={name:`autolink`,tokenize:wa};function wa(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Yi(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Xi(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Xi(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Qi(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Zi(t)?(e.consume(t),l):n(t)}function u(e){return Xi(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Xi(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Ta={partial:!0,tokenize:Ea};function Ea(e,t,n){return r;function r(t){return G(t)?K(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||U(e)?t(e):n(e)}}var Da={continuation:{tokenize:ka},exit:Aa,name:`blockQuote`,tokenize:Oa};function Oa(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return G(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function ka(e,t,n){let r=this;return i;function i(t){return G(t)?K(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Da,t,n)(r)}}function Aa(e){e.exit(`blockQuote`)}var ja={name:`characterEscape`,tokenize:Ma};function Ma(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return ta(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Na={name:`characterReference`,tokenize:Pa};function Pa(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Xi,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=ea,u):(e.enter(`characterReferenceValue`),a=7,o=$i,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Xi&&!Li(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Fa={partial:!0,tokenize:Ra},Ia={concrete:!0,name:`codeFenced`,tokenize:La};function La(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),G(t)?K(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||U(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Fa,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||U(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):G(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),K(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||U(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||U(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&G(t)?K(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||U(t)?e.check(Fa,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||U(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),G(t)?K(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),G(t)?K(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||U(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Ra(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var za={name:`codeIndented`,tokenize:Va},Ba={partial:!0,tokenize:Ha};function Va(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),K(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):U(t)?e.attempt(Ba,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||U(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Ha(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):U(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):K(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):U(e)?i(e):n(e)}}var Ua={name:`codeText`,previous:Ga,resolve:Wa,tokenize:Ka};function Wa(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 Ga(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Ka(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):U(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||U(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var qa=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError(\"Cannot access index `\"+e+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Ja(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Ja(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Ja(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Ja(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Ja(this.left,t.reverse())}}};function Ja(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 Ya(e){let t={},n=-1,r,i,a,o,s,c,l,u=new qa(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Xa(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.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={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Ri(e,0,1/0,u.slice(0)),!l}function Xa(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Za={resolve:$a,tokenize:eo},Qa={partial:!0,tokenize:to};function $a(e){return Ya(e),e}function eo(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):U(t)?e.check(Qa,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function to(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),K(e,a,`linePrefix`)}function a(i){if(i===null||U(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function no(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Qi(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||U(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||W(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Qi(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function ro(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):U(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||U(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!G(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function io(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):U(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),K(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||U(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function ao(e,t){let n;return r;function r(i){return U(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):G(i)?K(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var oo={name:`definition`,tokenize:co},so={partial:!0,tokenize:lo};function co(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return ro.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Ji(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return W(t)?ao(e,l)(t):l(t)}function l(t){return no(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(so,d,d)(t)}function d(t){return G(t)?K(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||U(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function lo(e,t,n){return r;function r(t){return W(t)?ao(e,i)(t):n(t)}function i(t){return io(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return G(t)?K(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||U(e)?t(e):n(e)}}var uo={name:`hardBreakEscape`,tokenize:fo};function fo(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return U(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var po={name:`headingAtx`,resolve:mo,tokenize:ho};function mo(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`},Ri(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function ho(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||W(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||U(n)?(e.exit(`atxHeading`),t(n)):G(n)?K(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||W(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var go=`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`.split(`.`),_o=[`pre`,`script`,`style`,`textarea`],vo={concrete:!0,name:`htmlFlow`,resolveTo:xo,tokenize:So},yo={partial:!0,tokenize:wo},bo={partial:!0,tokenize:Co};function xo(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 So(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ie):Yi(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Yi(a)?(e.consume(a),i=4,r.interrupt?t:ie):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ie):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return Yi(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||W(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&_o.includes(l)?(i=1,r.interrupt?t(s):O(s)):go.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Xi(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return G(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Yi(t)?(e.consume(t),b):G(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Xi(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):G(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):G(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||U(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||W(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||G(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||U(t)?O(t):G(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),A):t===60&&i===1?(e.consume(t),j):t===62&&i===4?(e.consume(t),ae):t===63&&i===3?(e.consume(t),ie):t===93&&i===5?(e.consume(t),re):U(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(yo,oe,k)(t)):t===null||U(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(bo,ee,oe)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return t===null||U(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function A(t){return t===45?(e.consume(t),ie):O(t)}function j(t){return t===47?(e.consume(t),o=``,ne):O(t)}function ne(t){if(t===62){let n=o.toLowerCase();return _o.includes(n)?(e.consume(t),ae):O(t)}return Yi(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function re(t){return t===93?(e.consume(t),ie):O(t)}function ie(t){return t===62?(e.consume(t),ae):t===45&&i===2?(e.consume(t),ie):O(t)}function ae(t){return t===null||U(t)?(e.exit(`htmlFlowData`),oe(t)):(e.consume(t),ae)}function oe(n){return e.exit(`htmlFlow`),t(n)}}function Co(e,t,n){let r=this;return i;function i(t){return U(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function wo(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Ta,t,n)}}var To={name:`htmlText`,tokenize:Eo};function Eo(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Yi(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Yi(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):U(t)?(o=d,j(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?A(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):U(t)?(o=h,j(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?A(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?A(t):U(t)?(o=v,j(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):U(t)?(o=y,j(t)):(e.consume(t),y)}function b(e){return e===62?A(e):y(e)}function x(t){return Yi(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Xi(t)?(e.consume(t),S):C(t)}function C(t){return U(t)?(o=C,j(t)):G(t)?(e.consume(t),C):A(t)}function w(t){return t===45||Xi(t)?(e.consume(t),w):t===47||t===62||W(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),A):t===58||t===95||Yi(t)?(e.consume(t),E):U(t)?(o=T,j(t)):G(t)?(e.consume(t),T):A(t)}function E(t){return t===45||t===46||t===58||t===95||Xi(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):U(t)?(o=D,j(t)):G(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):U(t)?(o=O,j(t)):G(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,te):t===null?n(t):U(t)?(o=k,j(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||W(t)?T(t):(e.consume(t),ee)}function te(e){return e===47||e===62||W(e)?T(e):n(e)}function A(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function j(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return G(t)?K(e,re,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):re(t)}function re(t){return e.enter(`htmlTextData`),o(t)}}var Do={name:`labelEnd`,resolveAll:jo,resolveTo:Mo,tokenize:No},Oo={tokenize:Po},ko={tokenize:Fo},Ao={tokenize:Io};function jo(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Ri(e,0,e.length,n),e}function Mo(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);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=H(s,e.slice(a+1,a+r+3)),s=H(s,[[`enter`,u,t]]),s=H(s,va(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=H(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=H(s,e.slice(o+1)),s=H(s,[[`exit`,c,t]]),Ri(e,a,e.length,s),e}function No(e,t,n){let r=this,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(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Ji(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Oo,u,o?u:d)(t):t===91?e.attempt(ko,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Ao,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Po(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return W(t)?ao(e,a)(t):a(t)}function a(t){return t===41?u(t):no(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return W(t)?ao(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?io(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return W(t)?ao(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Fo(e,t,n){let r=this;return i;function i(t){return ro.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Ji(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Io(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Lo={name:`labelStartImage`,resolveAll:Do.resolveAll,tokenize:Ro};function Ro(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var zo={name:`labelStartLink`,resolveAll:Do.resolveAll,tokenize:Bo};function Bo(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Vo={name:`lineEnding`,tokenize:Ho};function Ho(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),K(e,t,`linePrefix`)}}var Uo={name:`thematicBreak`,tokenize:Wo};function Wo(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||U(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),G(t)?K(e,s,`whitespace`)(t):s(t))}}var Go={continuation:{tokenize:Yo},exit:Zo,name:`list`,tokenize:Jo},Ko={partial:!0,tokenize:Qo},qo={partial:!0,tokenize:Xo};function Jo(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:$i(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Uo,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return $i(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Ta,r.interrupt?n:u,e.attempt(Ko,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return G(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Yo(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ta,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,K(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!G(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(qo,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,K(e,e.attempt(Go,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Xo(e,t,n){let r=this;return K(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Zo(e){e.exit(this.containerState.type)}function Qo(e,t,n){let r=this;return K(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!G(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var $o={name:`setextUnderline`,resolveTo:es,tokenize:ts};function es(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);let 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 ts(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),G(t)?K(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||U(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var ns={tokenize:rs};function rs(e){let t=this,n=e.attempt(Ta,r,e.attempt(this.parser.constructs.flowInitial,i,K(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Za,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var is={resolveAll:cs()},as=ss(`string`),os=ss(`text`);function ss(e){return{resolveAll:cs(e===`text`?ls:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function cs(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function ls(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||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={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var us=t({attentionMarkers:()=>vs,contentInitial:()=>fs,disable:()=>ys,document:()=>ds,flow:()=>ms,flowInitial:()=>ps,insideSpan:()=>_s,string:()=>hs,text:()=>gs}),ds={42:Go,43:Go,45:Go,48:Go,49:Go,50:Go,51:Go,52:Go,53:Go,54:Go,55:Go,56:Go,57:Go,62:Da},fs={91:oo},ps={[-2]:za,[-1]:za,32:za},ms={35:po,42:Uo,45:[$o,Uo],60:vo,61:$o,95:Uo,96:Ia,126:Ia},hs={38:Na,92:ja},gs={[-5]:Vo,[-4]:Vo,[-3]:Vo,33:Lo,38:Na,42:ya,60:[Ca,To],91:zo,92:[uo,ja],93:Do,95:ya,96:Ua},_s={null:[ya,is]},vs={null:[42,95]},ys={null:[]};function bs(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=H(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=va(a,l.events,l),l.events):[]}function f(e,t){return Ss(p(e),t)}function p(e){return xs(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){U(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Ri(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function xs(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Ss(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],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 Cs(e){let t={constructs:Bi([us,...(e||{}).extensions||[]]),content:n(da),defined:[],document:n(pa),flow:n(ns),lazy:{},string:n(as),text:n(os)};return t;function n(e){return n;function n(n){return bs(t,e,n)}}}function ws(e){for(;!Ya(e););return e}var Ts=/[\\0\\t\\n\\r]/g;function Es(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(Ts.lastIndex=u,c=Ts.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Ds(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),ua(n)(ws(Cs(n).document().write(Es()(e,t,!0))))}var Os={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function ks(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Os[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];e===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(`<td`+e+`>`))},tableHead(){this.lineEndingIfNeeded(),this.tag(`<thead>`)},tableHeader(){let e=Os[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];this.lineEndingIfNeeded(),this.tag(`<th`+e+`>`)},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,As)),this.raw(this.encode(t))},table(){this.setData(`tableAlign`),this.setData(`slurpAllLineEndings`),this.lineEndingIfNeeded(),this.tag(`</table>`)},tableBody(){this.lineEndingIfNeeded(),this.tag(`</tbody>`)},tableData(){let 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(){let e=this.getData(`tableColumn`);this.tag(`</th>`),this.setData(`tableColumn`,e+1)},tableRow(){let e=this.getData(`tableAlign`),t=this.getData(`tableColumn`);for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(`<td`+Os[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function As(e,t){return t===`|`?t:e}var js=class{constructor(){this.map=[]}add(e,t,n){Ms(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Ms(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 Ns(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 Ps(){return{flow:{null:{name:`table`,tokenize:Fs,resolveAll:Is}}}}function Fs(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):U(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):G(t)?K(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||W(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,G(t)?K(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return G(t)?K(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||U(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return G(t)?K(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||U(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||U(n)?(e.exit(`tableRow`),t(n)):G(n)?K(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||W(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Is(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new js;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Rs(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Ls(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Ls(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Ls(f,t,o,i,n,d)):(o[0]=o[1],d=Ls(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Rs(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Ns(t.events,n))}return e}function Ls(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},zs(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=zs(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=zs(t.events,n[2]),a=zs(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},zs(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Rs(e,t,n,r,i){let a=[],o=zs(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 zs(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function Bs(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function Vs(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ri(o,o.length,0,va(s,e.slice(r+1,n),t)),Ri(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ri(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=_a(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=_a(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function Hs(e,t){let n=[`codeIndented`];return t?.inline&&n.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`),Ds(e,{allowDangerousHtml:!0,extensions:[Ps(),Vs(),{disable:{null:n}}],htmlExtensions:[ks(),Bs()]})}var Us={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>({})},Ws=_e({}),Gs=_e(Us),q=_e(!1),Ks=_e(!1),qs=_e(null);function Js(e,t,n=!1){let r=document.createElement(`div`);if(r.innerHTML=e.trim(),n)for(let e of Array.from(r.querySelectorAll(`:scope > p`)))e.replaceWith(...Array.from(e.childNodes));return V(C,{children:Array.from(r.childNodes).map((e,n)=>Ys(e,n,t))})}function Ys(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=r.getAttribute(`data-tw`);if(a!=null)return n[parseInt(a,10)];let o={key:t};for(let e of Array.from(r.attributes))o[e.name]=e.value;return b(i,o,...Array.from(r.childNodes).map((e,t)=>Ys(e,t,n)))}return null}var Xs=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.dfn.em.i.kbd.label.mark.meter.output.progress.q.rp.rt.ruby.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function Zs({node:e}){let t=hi(),n=R(q),r=R(Ws),i=R(Ks),a={};for(let[n,r]of Object.entries(e.attributes))a[n]=t(r)??r;let o=e.tag.toLowerCase()===`svg`,s=Xs.has(e.tag.toLowerCase()),c=e.children.length>0?i||o?tc(e.children):uc(e.children,{nobr:n,locals:r,inline:s}):void 0,l=b(e.tag,a,c);return o?V(Ks.Provider,{value:!0,children:l}):l}function Qs(){let e=R(qs),t=R(q),n=R(Ws);return!e||e.length===0?null:V(C,{children:uc(e,{nobr:t,locals:n})})}function $s(e,t){if(Mi(e.name))return null;let n=Ei(e.name);if(n)return V(Ci,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);let r=ki(e.name);return r?V(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):V(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function ec(e,t){switch(e.type){case`text`:return e.value;case`variable`:return e.scope===`local`&&e.name===`children`?V(Qs,{},t):V(_i,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case`expression`:return V(vi,{expression:e.expression,className:e.className,id:e.id},t);case`macro`:return $s(e,t);case`html`:return V(Zs,{node:e},t);default:return e}}function tc(e){return e.length===0?null:e.map((e,t)=>ec(e,t))}function nc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2==1}function rc(e,t){let n=Z.getState(),r=e.name.split(`.`),i=r[0],a;a=e.scope===`variable`?n.variables[i]:e.scope===`temporary`?n.temporary[i]:e.scope===`transient`?n.transient[i]:t[i];for(let e=1;e<r.length;e++){if(typeof a!=`object`||!a)return``;a=a[r[e]]}return a==null?``:String(a)}var ic=/[*_`#|~\\[>\\\\\\-+=]|!\\[|\\d+\\./,ac=/\\n\\s*\\n/,oc=/(<span data-tw=\"\\d+\"><\\/span>)/,sc=/^<span data-tw=\"(\\d+)\"><\\/span>$/,cc=/<span data-tw=\"\\d+\"><\\/span>/g;function lc(e,t,n){let r=e.split(oc),i=[];for(let e of r){let n=sc.exec(e);n?i.push(t[parseInt(n[1],10)]):e&&i.push(e)}return n?V(C,{children:i}):b(`p`,null,...i)}function uc(e,t){if(e.length===0)return null;if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||/\\n\\s*\\n/.test(e.value))))return e.map((e,t)=>ec(e,t));let n=[],r=``,i=t?.locals??{};for(let t=0;t<e.length;t++){let a=e[t];if(a.type===`text`)r+=a.value;else if(a.type===`variable`&&nc(r))r+=rc(a,i);else{let e=n.length;n.push(ec(a,t)),r+=`<span data-tw=\"${e}\"></span>`}}let a=r.replace(cc,``);return!ic.test(a)&&!ac.test(a)?lc(r,n,t?.nobr):Js(Hs(r,{inline:t?.inline}),n,t?.nobr)}function dc(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.version!==1||typeof t.ifid!=`string`||typeof t.save!=`object`||t.save===null)return!1;let n=t.save;if(typeof n.meta!=`object`||n.meta===null||typeof n.payload!=`object`||n.payload===null)return!1;let 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;let 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 fc(e){if(typeof e!=`object`||!e)return!1;let 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 pc(){let e=new Map,t=new Map,n=new Map;return{type:`memory`,async putSave(t){e.set(t.meta.id,t)},async getSave(t){return e.get(t)},async deleteSave(t){e.delete(t)},async getSavesByIfid(t){return[...e.values()].filter(e=>e.meta.ifid===t)},async deleteSavesByIfid(t){for(let n of[...e.keys()]){let r=e.get(n);r&&r.meta.ifid===t&&e.delete(n)}},async deleteSavesByPlaythrough(t){let n=[];for(let r of[...e.keys()]){let i=e.get(r);i&&i.meta.playthroughId===t&&(e.delete(r),n.push(r))}return n},async putPlaythrough(e){t.set(e.id,e)},async getPlaythroughsByIfid(e){return[...t.values()].filter(t=>t.ifid===e)},async deletePlaythroughsByIfid(e){for(let n of[...t.keys()]){let r=t.get(n);r&&r.ifid===e&&t.delete(n)}},async deletePlaythroughById(e){t.delete(e)},async getMeta(e){return n.get(e)},async setMeta(e,t){n.set(e,t)},async deleteMeta(e){n.delete(e)},async deleteMetaByPrefix(e){for(let t of[...n.keys()])t.startsWith(e)&&n.delete(t)},async deleteMetaByIfid(e){for(let t of[...n.keys()])t.includes(e)&&n.delete(t)},async getAllMetaKeys(){return[...n.keys()]},async destroy(){e.clear(),t.clear(),n.clear()}}}var mc=`spindle.save.`,hc=`spindle.pt.`,gc=`spindle.meta.`,_c=`spindle.idx.saves.`,vc=`spindle.idx.pt.`,yc=`spindle.idx.saves-pt.`;function bc(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function xc(e,t){localStorage.setItem(e,JSON.stringify(t))}function Sc(e){localStorage.removeItem(e)}function Cc(e){return bc(e)??[]}function wc(e,t){let n=Cc(e);n.includes(t)||(n.push(t),xc(e,n))}function Tc(e,t){xc(e,Cc(e).filter(e=>e!==t))}function Ec(){return{type:`localstorage`,async putSave(e){let t=e.meta.id;xc(`${mc}${t}`,e),wc(`${_c}${e.meta.ifid}`,t),wc(`${yc}${e.meta.playthroughId}`,t)},async getSave(e){return bc(`${mc}${e}`)},async deleteSave(e){let t=bc(`${mc}${e}`);t&&(Tc(`${_c}${t.meta.ifid}`,e),Tc(`${yc}${t.meta.playthroughId}`,e)),Sc(`${mc}${e}`)},async getSavesByIfid(e){let t=Cc(`${_c}${e}`),n=[];for(let e of t){let t=bc(`${mc}${e}`);t&&n.push(t)}return n},async deleteSavesByIfid(e){let t=Cc(`${_c}${e}`);for(let e of t){let t=bc(`${mc}${e}`);t&&Tc(`${yc}${t.meta.playthroughId}`,e),Sc(`${mc}${e}`)}Sc(`${_c}${e}`)},async deleteSavesByPlaythrough(e){let t=Cc(`${yc}${e}`);for(let e of t){let t=bc(`${mc}${e}`);t&&Tc(`${_c}${t.meta.ifid}`,e),Sc(`${mc}${e}`)}return Sc(`${yc}${e}`),t},async putPlaythrough(e){xc(`${hc}${e.id}`,e),wc(`${vc}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){let t=Cc(`${vc}${e}`),n=[];for(let e of t){let t=bc(`${hc}${e}`);t&&n.push(t)}return n},async deletePlaythroughsByIfid(e){let t=Cc(`${vc}${e}`);for(let e of t)Sc(`${hc}${e}`);Sc(`${vc}${e}`)},async deletePlaythroughById(e){let t=bc(`${hc}${e}`);t&&Tc(`${vc}${t.ifid}`,e),Sc(`${hc}${e}`)},async getMeta(e){return bc(`${gc}${e}`)},async setMeta(e,t){xc(`${gc}${e}`,t)},async deleteMeta(e){Sc(`${gc}${e}`)},async deleteMetaByPrefix(e){let t=`${gc}${e}`;for(let e of Object.keys(localStorage))e.startsWith(t)&&localStorage.removeItem(e)},async deleteMetaByIfid(e){for(let t of Object.keys(localStorage))t.startsWith(gc)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){let e=[];for(let t of Object.keys(localStorage))t.startsWith(gc)&&e.push(t.slice(13));return e},async destroy(){for(let e of Object.keys(localStorage))e.startsWith(`spindle.`)&&localStorage.removeItem(e)}}}var Dc=`spindle`,Oc=1;function kc(){let e=null;function t(){return e||(e=new Promise((e,t)=>{let n=indexedDB.open(Dc,Oc);n.onupgradeneeded=()=>{let e=n.result;if(!e.objectStoreNames.contains(`saves`)){let t=e.createObjectStore(`saves`,{keyPath:`meta.id`});t.createIndex(`ifid`,`meta.ifid`,{unique:!1}),t.createIndex(`playthroughId`,`meta.playthroughId`,{unique:!1})}e.objectStoreNames.contains(`playthroughs`)||e.createObjectStore(`playthroughs`,{keyPath:`id`}).createIndex(`ifid`,`ifid`,{unique:!1}),e.objectStoreNames.contains(`meta`)||e.createObjectStore(`meta`,{keyPath:`key`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),e)}function n(e,n){return t().then(t=>t.transaction(e,n).objectStore(e))}function r(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function i(e,t,i){return await r((await n(e,`readonly`)).index(t).getAll(i))??[]}return{type:`indexeddb`,async putSave(e){await r((await n(`saves`,`readwrite`)).put(e))},async getSave(e){return await r((await n(`saves`,`readonly`)).get(e))??void 0},async deleteSave(e){await r((await n(`saves`,`readwrite`)).delete(e))},async getSavesByIfid(e){return i(`saves`,`ifid`,e)},async deleteSavesByIfid(e){let t=await i(`saves`,`ifid`,e),a=await n(`saves`,`readwrite`);for(let e of t)await r(a.delete(e.meta.id))},async deleteSavesByPlaythrough(e){let t=await i(`saves`,`playthroughId`,e),a=await n(`saves`,`readwrite`),o=[];for(let e of t)await r(a.delete(e.meta.id)),o.push(e.meta.id);return o},async putPlaythrough(e){await r((await n(`playthroughs`,`readwrite`)).put(e))},async getPlaythroughsByIfid(e){return i(`playthroughs`,`ifid`,e)},async deletePlaythroughsByIfid(e){let t=await i(`playthroughs`,`ifid`,e),a=await n(`playthroughs`,`readwrite`);for(let e of t)await r(a.delete(e.id))},async deletePlaythroughById(e){await r((await n(`playthroughs`,`readwrite`)).delete(e))},async getMeta(e){let t=await r((await n(`meta`,`readonly`)).get(e));return t?t.value:void 0},async setMeta(e,t){await r((await n(`meta`,`readwrite`)).put({key:e,value:t}))},async deleteMeta(e){await r((await n(`meta`,`readwrite`)).delete(e))},async deleteMetaByPrefix(e){let t=await r((await n(`meta`,`readwrite`)).getAll());for(let i of t)i.key.startsWith(e)&&await r((await n(`meta`,`readwrite`)).delete(i.key))},async deleteMetaByIfid(e){let t=await r((await n(`meta`,`readwrite`)).getAll());for(let i of t)i.key.includes(e)&&await r((await n(`meta`,`readwrite`)).delete(i.key))},async getAllMetaKeys(){return(await r((await n(`meta`,`readonly`)).getAll())).map(e=>e.key)},async destroy(){(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(Dc);n.onsuccess=()=>e(),n.onerror=()=>t(n.error)})}}}var Ac=null;async function jc(){if(typeof indexedDB<`u`)try{return await new Promise((e,t)=>{let n=indexedDB.open(`__spindle_probe__`,1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(`__spindle_probe__`),e()},n.onerror=()=>t(n.error)}),kc()}catch{}if(typeof localStorage<`u`)try{let e=`__spindle_probe__`;localStorage.setItem(e,`1`);let t=localStorage.getItem(e);if(localStorage.removeItem(e),t===`1`)return Ec()}catch{}return pc()}async function J(){return Ac||(Ac=await jc(),Ac)}function Mc(){Ac=null}function Nc(){return Ac?.type??`memory`}var Pc=new Map,Fc=new Map;function Ic(e,t){Pc.set(e,t),Fc.set(t,e)}function Lc(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Y(e){let t=new Map;function n(e){if(typeof e!=`object`||!e)return e;let r=e;if(t.has(r))return t.get(r);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){let i=[];t.set(r,i);for(let t=0;t<e.length;t++)i[t]=n(e[t]);return i}if(e instanceof Map){let i=new Map;t.set(r,i);for(let[t,r]of e)i.set(n(t),n(r));return i}if(e instanceof Set){let i=new Set;t.set(r,i);for(let t of e)i.add(n(t));return i}let i=r.constructor;if(Fc.get(i)!==void 0){let e=Object.create(Object.getPrototypeOf(r));t.set(r,e);for(let t of Object.keys(r))e[t]=n(r[t]);return e}if(Lc(e)||typeof e==`object`){let e={};t.set(r,e);for(let t of Object.keys(r))e[t]=n(r[t]);return e}return e}return n(e)}var Rc=`__spindle_class__`,zc=`__spindle_data__`;function Bc(e){let t=new Set;function n(e){if(typeof e!=`object`||!e)return e;let r=e;if(t.has(r))throw Error(`spindle: Cannot serialize circular references`);if(t.add(r),e instanceof Date)return t.delete(r),{[Rc]:`__Date__`,[zc]:{iso:e.toISOString()}};if(e instanceof RegExp)return t.delete(r),{[Rc]:`__RegExp__`,[zc]:{source:e.source,flags:e.flags}};if(Array.isArray(e)){let i=e.map(e=>n(e));return t.delete(r),i}if(e instanceof Map){let i=[...e].map(([e,t])=>[n(e),n(t)]);return t.delete(r),{[Rc]:`__Map__`,[zc]:{entries:i}}}if(e instanceof Set){let i=[...e].map(e=>n(e));return t.delete(r),{[Rc]:`__Set__`,[zc]:{entries:i}}}let i=r.constructor,a=Fc.get(i);if(a!==void 0){let e={};for(let t of Object.keys(r))e[t]=n(r[t]);return t.delete(r),{[Rc]:a,[zc]:e}}let o={};for(let e of Object.keys(r))o[e]=n(r[e]);return t.delete(r),o}return n(e)}function Vc(e){function t(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>t(e));let n=e;if(Rc in n&&zc in n){let e=n[Rc],r=n[zc];if(e===`__Date__`)return new Date(r.iso);if(e===`__RegExp__`)return new RegExp(r.source,r.flags);if(e===`__Map__`){let e=r.entries;return new Map(e.map(([e,n])=>[t(e),t(n)]))}if(e===`__Set__`){let e=r.entries;return new Set(e.map(e=>t(e)))}let i=Pc.get(e);if(!i){console.warn(`spindle: Class \"${e}\" not registered. Falling back to plain object.`);let n={};for(let e of Object.keys(r))n[e]=t(r[e]);return n}let a=Object.create(i.prototype);for(let e of Object.keys(r))a[e]=t(r[e]);return a}let r=n.constructor;if(Fc.has(r))return e;let i={};for(let e of Object.keys(n))i[e]=t(n[e]);return i}return t(e)}var Hc=null,Uc=null,Wc=!1;function Gc(e){Hc=e}function Kc(e){Uc=e}function qc(e){if(Uc)try{let t=Function(`passage`,`variables`,Uc)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(Hc)try{let t=Hc(e);if(typeof t==`string`&&t.trim())return t.trim()}catch{}let t=new Date().toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return`${e.passage} - ${t}`}async function Jc(){Wc||(Wc=!0)}async function Yc(e){let t=await J(),n=(await t.getPlaythroughsByIfid(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await t.putPlaythrough(i),await t.setMeta(`currentPlaythroughId.${e}`,r),r}async function Xc(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function Zc(e,t,n,r={}){let i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:qc(n),passage:n.passage,custom:r},o=Y(n);o.variables=Bc(o.variables),o.history=o.history.map(e=>({...e,variables:Bc(e.variables)}));let s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function Qc(e,t,n){let r=await J(),i=await r.getSave(e);if(!i)return;let a=Y(t);a.variables=Bc(a.variables),a.history=a.history.map(e=>({...e,variables:Bc(e.variables)}));let 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 $c(e){let t=await(await J()).getSave(e);if(!t)return;let n=t.payload;return n.variables=Vc(n.variables),n.history=n.history.map(e=>({...e,variables:Vc(e.variables)})),n}async function el(e){await(await J()).deleteSave(e)}async function tl(e,t){let n=await J(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,updatedAt:new Date().toISOString()}};await n.putSave(i)}async function nl(e){let t=await J(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}var rl=`autosave.`,il=`slot.`,al=`slotIndex.`;function ol(e,t){return t==null?`${rl}${e}`:`${il}${t}.${e}`}async function sl(e,t,n,r,i){let a=await J(),o=ol(e,r),s=await a.getMeta(o);if(s){let e=await Qc(s,n,i);if(e)return e}let c=await Zc(e,t,n,{isAutosave:!r,...r==null?{}:{slot:r},...i});if(await a.setMeta(o,c.meta.id),r!=null){let t=`${al}${e}`,n=await a.getMeta(t)??[];n.includes(r)||await a.setMeta(t,[...n,r])}return c}async function cl(e,t){let n=await J(),r=ol(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function ll(e,t){let n=ol(e,t),r=await(await J()).getMeta(n);if(r)return $c(r)}async function ul(e){let t={};await cl(e)&&(t[``]=!0);let n=`${al}${e}`,r=await(await J()).getMeta(n)??[];for(let n of r)await cl(e,n)&&(t[n]=!0);return t}async function dl(e,t){let n=await J(),r=ol(e,t),i=await n.getMeta(r);if(!i)return null;let 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 fl(e){let t=[],n=await dl(e);n&&t.push(n);let r=`${al}${e}`,i=await(await J()).getMeta(r)??[];for(let n of i){let r=await dl(e,n);r&&t.push(r)}return t}async function pl(e,t){let n=await J(),r=ol(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){let r=`${al}${e}`,i=(await n.getMeta(r)??[]).filter(e=>e!==t);await n.setMeta(r,i)}}var ml=`spindle.session.`;function hl(e,t){try{sessionStorage.setItem(`${ml}${e}`,JSON.stringify(t))}catch{}}function gl(e){try{let t=sessionStorage.getItem(`${ml}${e}`);if(!t)return;let n=JSON.parse(t);if(!fc(n))return;let r=n;return r.variables=Vc(r.variables),r.history=r.history.map(e=>({...e,variables:Vc(e.variables)})),r}catch{return}}function _l(e){try{sessionStorage.removeItem(`${ml}${e}`)}catch{}}async function vl(e){let t=await(await J()).getSave(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function yl(e,t){if(e.version!==1)throw Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=await J(),r=Y(e.save);if(r.meta.id=crypto.randomUUID(),r.meta.updatedAt=new Date().toISOString(),!(await n.getPlaythroughsByIfid(t)).some(e=>e.id===r.meta.playthroughId)){let e={id:r.meta.playthroughId,ifid:t,createdAt:r.meta.createdAt,label:`Imported`};await n.putPlaythrough(e)}return await n.putSave(r),r}async function bl(e){let t=await J(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=JSON.stringify(e.payload).length;e.meta.estimatedBytes=n,await t.putSave(e),i+=n}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}}async function xl(e){let t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),_l(e)}async function Sl(){if(await(await J()).destroy(),Mc(),typeof sessionStorage<`u`){let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n?.startsWith(`spindle.session.`)&&e.push(n)}for(let t of e)sessionStorage.removeItem(t)}}async function Cl(e,t){let n=await J(),r=await n.deleteSavesByPlaythrough(t);await n.deletePlaythroughById(t);let i=new Set(r),a=await n.getAllMetaKeys();for(let e of a)if(e.startsWith(`slot.`)||e.startsWith(`autosave.`)){let t=await n.getMeta(e);t&&i.has(t)&&await n.deleteMeta(e)}let o=`currentPlaythroughId.${e}`;await n.getMeta(o)===t&&await n.deleteMeta(o)}function wl(){let e=Z.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=Ar(Tr(t.content)),n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),me(b(()=>uc(e),null),n)}let n=e.storyData.passages.get(`SaveTitle`);n&&Kc(n.content)}var Tl=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`]),El=new Map;function Dl(e,t){if(!Tl.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=El.get(e);return n||(n=new Set,El.set(e,n)),n.add(t),()=>{n.delete(t)}}function X(e,...t){let n=El.get(e);if(n)for(let e of[...n])e(...t)}var Ol=0,kl=[],Al=!1,jl=[],Ml=null,Nl=null;function Pl(e){let t=Z.getState();try{return!!si(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Fl(e,t){let n=Ol++,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:Pl(e),priority:i?.priority??0};return kl.push(o),kl.sort((e,t)=>t.priority-e.priority),()=>{kl=kl.filter(e=>e.id!==n)}}function Il(e){kl=kl.filter(t=>t.name!==e)}function Ll(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){let e=Z.getState();ci(n.run,e.variables,e.temporary)}n.dialog&&(jl.push({passageName:n.dialog}),Ml?.()),n.goto&&Z.getState().navigate(n.goto)}}var Rl=10;function zl(){if(!Al){Al=!0;try{for(let e=0;e<Rl;e++){let e=!1,t=[...kl];for(let n of t){if(!kl.includes(n))continue;let t=Pl(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(kl=kl.filter(e=>e.id!==n.id)),Ll(n))}if(!e)break}}finally{Al=!1}}}function Bl(){for(let e of kl)e.lastResult=Pl(e.condition)}function Vl(){kl=[],jl=[],Ol=0,Nl?.closeAll()}function Hl(e){return Ml=e,jl.length>0&&e(),()=>{Ml===e&&(Ml=null)}}function Ul(){return jl.shift()}function Wl(){return jl.length}function Gl(e){Nl?Nl.push(e):(jl.push(e),Ml?.())}function Kl(){jl=[]}function ql(e){return Nl=e,()=>{Nl===e&&(Nl=null)}}function Jl(){Nl?.close()}function Yl(){Kl(),Nl?.closeAll()}function Xl(){return Nl?.isOpen()??!1}fr();var Zl=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),Ql={},$l=[],eu={};function tu(e){return e.map(e=>({...e,value:e.value===void 0?void 0:Y(e.value)}))}function nu(e,t){let[,n,r]=hr(e,e=>{let n=e;for(let e of Object.keys(n))e in t||delete n[e];for(let[e,r]of Object.entries(t))n[e]=r});return{forward:tu(n),inverse:tu(r)}}function ru(e){let t=Ql;for(let n=0;n<e;n++)t=gr(t,$l[n].forward);return t}var iu=[];function au(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(iu.length>i.length&&(iu.length=i.length),iu.length<i.length)if(i.length-iu.length===1){let e=i.length-1;iu[e]={passage:i[e].passage,variables:Bc(r),timestamp:i[e].timestamp,prng:i[e].prng}}else{let e=Ql;for(let t=0;t<i.length;t++)if(t>0&&(e=gr(e,$l[t-1].forward)),t>=iu.length){let n=t===i.length-1?r:e;iu[t]={passage:i[t].passage,variables:Bc(n),timestamp:i[t].timestamp,prng:i[t].prng}}}hl(t.ifid,{passage:n,variables:Bc(r),history:iu,historyIndex:a,visitCounts:o,renderCounts:s,prng:Vr()})}}function ou(e){Ql=e,$l=[],eu=e,iu=[]}var su=[],cu=!1;function lu(e){cu&&su.push(e)}function uu(){cu=!0}function du(){for(let e of su)e();su=[],cu=!1}function fu(e){e?.prng?zr(e.prng.seed,e.prng.pull):e&&Br()}var Z=Wt()(_r((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:t=>{e(e=>{e.maxHistory=Math.max(1,Math.round(t))})},init:(n,r={},i={})=>{let a=n.passagesById.get(n.startNode);if(!a)throw Error(`spindle: Start passage (pid=${n.startNode}) not found.`);let o=Y(r);ou(Y(o)),e(e=>{e.storyData=n,e.currentPassage=a.name,e.variables=o,e.variableDefaults=r,e.transient=Y(i),e.transientDefaults=i,e.temporary={},e.history=[{passage:a.name,timestamp:Date.now()}],e.historyIndex=0,e.visitCounts={[a.name]:1},e.renderCounts={[a.name]:1}}),eu=t().variables;let s=n.ifid;Jc().then(async()=>{let t=await Xc(s);if(t)e(e=>{e.playthroughId=t});else{let t=await Yc(s);e(e=>{e.playthroughId=t})}let n=await ul(s);Object.keys(n).length>0&&e(e=>{e.knownSaves=n})}).catch(e=>console.error(`spindle: failed to init save system`,e))},navigate:n=>{let{storyData:r,variables:i}=t();if(!r)return;if(Zl.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}let a=t().currentPassage;X(`beforenavigate`,n);let o=nu(eu,i);e(e=>{e.temporary={},e.currentPassage=n,e.history=e.history.slice(0,e.historyIndex+1),$l.length=e.historyIndex,$l.push(o),e.history.push({passage:n,timestamp:Date.now(),prng:Vr()});let t=e.history.length-e.maxHistory;if(t>0){for(let e=0;e<t;e++)Ql=gr(Ql,$l[e].forward);e.history=e.history.slice(t),$l=$l.slice(t),iu=iu.slice(t)}e.historyIndex=e.history.length-1,e.visitCounts[n]=(e.visitCounts[n]??0)+1,e.renderCounts[n]=(e.renderCounts[n]??0)+1}),eu=t().variables,au(t),X(`afternavigate`,n,a)},goBack:()=>{let{historyIndex:n,variables:r}=t();if(n<=0)return;let i=t().currentPassage,a=t().history[n-1].passage;X(`beforenavigate`,a);let o=Y(gr(r,$l[n-1].inverse));e(e=>{e.historyIndex--,e.currentPassage=e.history[e.historyIndex].passage,e.variables=o,e.temporary={}}),eu=t().variables,fu(t().history[t().historyIndex]),au(t),X(`afternavigate`,a,i)},goForward:()=>{let{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;let a=t().currentPassage,o=r[n+1].passage;X(`beforenavigate`,o);let s=Y(gr(i,$l[n].forward));e(e=>{e.historyIndex++,e.currentPassage=e.history[e.historyIndex].passage,e.variables=s,e.temporary={}}),eu=t().variables,fu(t().history[t().historyIndex]),au(t),X(`afternavigate`,o,a)},setVariable:(t,n)=>{e(e=>{e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{e.temporary[t]=n})},deleteVariable:t=>{e(e=>{delete e.variables[t]})},deleteTemporary:t=>{e(e=>{delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{e.transient[t]=n})},deleteTransient:t=>{e(e=>{delete e.transient[t]})},trackRender:t=>{e(e=>{e.renderCounts[t]=(e.renderCounts[t]??0)+1})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),X(`beforerestart`);let o=t().renderDeferred;du(),Br(),Vl();let s=Y(r);ou(Y(s)),e(e=>{e.currentPassage=a.name,e.variables=s,e.transient=Y(i),e.temporary={},e.history=[{passage:a.name,timestamp:Date.now()}],e.historyIndex=0,e.visitCounts={[a.name]:1},e.renderCounts={[a.name]:1},o||(e.renderDeferred=!1)}),eu=t().variables,uu(),wl(),_l(n.ifid),X(`storyinit`),Yc(n.ifid).then(t=>{e(e=>{e.playthroughId=t})}).catch(e=>console.error(`spindle: failed to start new playthrough`,e))},save:(n,r)=>{let{storyData:i,playthroughId:a}=t();if(!i)return;X(`beforesave`,n,r);let o=t().getSavePayload();e(e=>{e.saveError=null}),sl(i.ifid,a,o,n,r).then(()=>{e(e=>{e.knownSaves={...e.knownSaves,[n??``]:!0}}),X(`aftersave`,n)}).catch(t=>{console.error(`spindle: failed to save`,t),e(e=>{e.saveError=t instanceof Error?t.message:`Failed to save`})})},load:n=>{let{storyData:r}=t();r&&(e(e=>{e.loadError=null}),ll(r.ifid,n).then(e=>{e&&t().loadFromPayload(e)}).catch(t=>{console.error(`spindle: failed to load save`,t),e(e=>{e.loadError=t instanceof Error?t.message:`Failed to load`})}))},hasSave:e=>{let{storyData:n,knownSaves:r}=t();return n?(e??``)in r:!1},getSaveInfo:async e=>{let{storyData:n}=t();return n?dl(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?fl(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();r&&pl(r.ifid,n).then(()=>{e(e=>{let t=n??``,{[t]:r,...i}=e.knownSaves;e.knownSaves=i})}).catch(e=>{console.error(`spindle: failed to delete save`,e)})},clearGameData:()=>{let{storyData:n}=t();n&&xl(n.ifid).then(()=>{e(e=>{e.knownSaves={}}),t().restart()}).catch(e=>{console.error(`spindle: failed to clear game data`,e)})},clearAllData:()=>{let{storyData:n}=t();n&&Sl().then(()=>{e(e=>{e.knownSaves={}}),t().restart()}).catch(e=>{console.error(`spindle: failed to clear all data`,e)})},deletePlaythrough:n=>{let{storyData:r}=t();r&&Cl(r.ifid,n).then(async()=>{let t=await ul(r.ifid);e(e=>{e.knownSaves=t})}).catch(e=>{console.error(`spindle: failed to delete playthrough`,e)})},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[],c=Ql;for(let e=0;e<r.length;e++)e>0&&(c=gr(c,$l[e-1].forward)),s.push({passage:r[e].passage,variables:Y(c),timestamp:r[e].timestamp,prng:r[e].prng});return{passage:e,variables:Y(n),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:Vr()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}X(`beforeload`,void 0);let r=Vc(n.history[0]?.variables??{}),i=[],a=r;for(let e=1;e<n.history.length;e++){let t=Vc(n.history[e].variables);i.push(nu(a,t)),a=t}Ql=Y(r),$l=i,iu=[],e(e=>{e.currentPassage=n.passage,e.variables=Vc(n.variables),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),e.visitCounts=n.visitCounts??{},e.renderCounts=n.renderCounts??{},e.temporary={},e.transient=Y(t().transientDefaults)}),eu=t().variables,n.prng?zr(n.prng.seed,n.prng.pull):Br(),X(`afterload`,void 0)},getHistoryVariables:e=>Y(ru(e)),setTransition:t=>{e(e=>{e.transitionConfig=t})},setNextTransition:t=>{e(e=>{e.nextTransition=t})},consumeNextTransition:()=>{let n=t().nextTransition;return n!==null&&e(e=>{e.nextTransition=null}),n},deferRender:()=>{e(e=>{e.renderDeferred=!0})},clearDeferredRender:()=>{e(e=>{e.renderDeferred=!1})}}))),pu=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function mu(){let e=Z(e=>e.storyData)?.passages.get(`StoryInterface`),t=e===void 0?pu:e.content,n=e?.tags.includes(`nobr`)??!1,r=I(()=>{try{return V(C,{children:tc(Ar(Tr(t)))})}catch(e){return V(`span`,{class:`error`,children:[`Error in StoryInterface:`,` `,e instanceof Error?e.message:String(e)]})}},[t]);return n?V(q.Provider,{value:!0,children:r}):r}var hu=_e(null);function gu({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){let a=F(r);a.current=r;let o=L(()=>a.current(),[]),s=Z(e=>e.storyData),c=(e?s?.passages.get(e):void 0)?.content??t,l=I(()=>{if(!c)return V(`div`,{class:`error`,children:`Dialog: no content available`});try{return uc(Ar(Tr(c)))}catch(e){return V(`div`,{class:`error`,children:[`Error in dialog: `,e instanceof Error?e.message:String(e)]})}},[c]),u=e=>{e.target.classList.contains(`dialog-overlay`)&&o()},d=n?`dialog-panel ${n}`:`dialog-panel`;return V(hu.Provider,{value:o,children:V(`div`,{class:`dialog-overlay`,onClick:u,children:V(`div`,{class:d,children:[i&&V(`button`,{class:`dialog-close`,onClick:o,children:`✕`}),V(`div`,{class:`dialog-body`,children:l})]})})})}function _u(){let[e,t]=P([]),n=F(e);n.current=e;let r=L(e=>{t(t=>[...t,e])},[]),i=L(()=>{t(e=>e.slice(0,-1))},[]),a=L(()=>{t([])},[]);return je(()=>ql({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),je(()=>Hl(()=>{let e=[];for(;Wl()>0;){let t=Ul();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:V(C,{children:e.map((e,t)=>V(gu,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton},`${e.passageName}-${t}`))})}function vu(){let e=Z(e=>e.storyData),t=Z(e=>e.currentPassage),n=Z(e=>e.nobr);if(je(()=>{let e=e=>{e.key===`F6`?(e.preventDefault(),Z.getState().save()):e.key===`F9`&&(e.preventDefault(),Z.getState().load())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return V(`div`,{class:`loading`,children:`Loading...`});let r=V(C,{children:[V(mu,{}),V(_u,{})]});return n?V(q.Provider,{value:!0,children:r}):r}function yu(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`\"`).replace(/'/g,`'`).replace(/&/g,`&`)}function bu(){let e=document.querySelector(`tw-storydata`);if(!e)throw Error(`spindle: No <tw-storydata> element found in the document.`);let 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`)||``,o=e.querySelector(`[type=\"text/twine-css\"]`)?.textContent||``,s=e.querySelector(`[type=\"text/twine-javascript\"]`)?.textContent||``,c=new Map,l=new Map;for(let t of e.querySelectorAll(`tw-passagedata`)){let e=parseInt(t.getAttribute(`pid`)||`0`,10),n=t.getAttribute(`name`)||``,r=(t.getAttribute(`tags`)||``).split(/\\s+/).filter(e=>e.length>0),i=yu(t.innerHTML),a={},o=new Set([`pid`,`name`,`tags`]);for(let e of t.attributes)o.has(e.name)||(a[e.name]=e.value);let s={pid:e,name:n,tags:r,metadata:a,content:i};c.set(n,s),l.set(e,s)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:l,userCSS:o,userScript:s}}var xu=new Map,Q={},Su=!1;function Cu(){return`spindle.${Z.getState().storyData?.ifid||`unknown`}.settings`}function wu(){localStorage.setItem(Cu(),JSON.stringify(Q))}function Tu(){if(!Su){Su=!0;try{let e=localStorage.getItem(Cu());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(Q={...Q,...t})}}catch{}}}var Eu={addToggle(e,t){xu.set(e,{type:`toggle`,config:t}),e in Q||(Q[e]=t.default),Tu()},addList(e,t){xu.set(e,{type:`list`,config:t}),e in Q||(Q[e]=t.default),Tu()},addRange(e,t){xu.set(e,{type:`range`,config:t}),e in Q||(Q[e]=t.default),Tu()},get(e){return Q[e]},getToggle(e){let t=Q[e];return typeof t==`boolean`?t:!1},getList(e){let t=Q[e];return typeof t==`string`?t:``},getRange(e){let t=Q[e];return typeof t==`number`?t:0},set(e,t){Q[e]=t,wu()},getAll(){return{...Q}},getDefinitions(){return xu},hasAny(){return xu.size>0}};function Du(e,t,n){let r=Z.getState(),i=Y(r.variables),a=Y(r.temporary),o=Y(r.transient),s={...t};ci(e,i,a,s,o);for(let e of Object.keys(i))i[e]!==r.variables[e]&&r.setVariable(e,i[e]);for(let e of Object.keys(a))a[e]!==r.temporary[e]&&r.setTemporary(e,a[e]);for(let e of Object.keys(o))o[e]!==r.transient[e]&&r.setTransient(e,o[e]);for(let e of Object.keys(s))s[e]!==t[e]&&n(e,s[e]);for(let e of Object.keys(r.variables))e in i||r.deleteVariable(e);for(let e of Object.keys(r.temporary))e in a||r.deleteTemporary(e);for(let e of Object.keys(r.transient))e in o||r.deleteTransient(e);for(let e of Object.keys(t))e in s||n(e,void 0)}var Ou=new Map,ku=new Map;function Au(e,t,n){if(n)return n;let r=`${e}:${t}`,i=(ku.get(r)??0)+1;return ku.set(r,i),i===1?r:`${r}:${i}`}function ju(e){return Ou.set(e.id,e),Fu(),()=>{Ou.delete(e.id),Fu()}}function Mu(){return Array.from(Ou.values())}function Nu(e){return Ou.get(e)}function Pu(){ku.clear()}function Fu(){X(`actionsChanged`)}function Iu(e){let t=F(``),n=F(e.perform);n.current=e.perform,t.current||(t.current=Au(e.type,e.key,e.authorId));let r=t.current;return Me(()=>{let t={id:r,type:e.type,label:e.label,perform:(...e)=>n.current(...e)};return e.target!==void 0&&(t.target=e.target),e.variable!==void 0&&(t.variable=e.variable),e.options!==void 0&&(t.options=e.options),e.value!==void 0&&(t.value=e.value),e.disabled!==void 0&&(t.disabled=e.disabled),ju(t)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Lu(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function Ru(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function zu(){let e=Z.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?Ru(t):``}function Bu(e){let t=e.match(/^\\s*([\"']?\\$[\\w.]+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);return t?{varName:t[1].replace(/[\"']/g,``),placeholder:t[2]||``}:{varName:e.trim(),placeholder:``}}function Vu(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let e=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,`$2`);t.push(e)}return t}function Hu(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var Uu={useState:P,useRef:F,useEffect:je,useLayoutEffect:Me,useCallback:L,useMemo:I,useContext:R};function Wu(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Gu(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];(r[n]==null||typeof r[n]!=`object`)&&(r[n]={}),r=r[n]}r[t[t.length-1]]=n}function $(e,t=`builtin`){function n(t){let n=t.className,r=t.id,i;e.interpolate&&(i=hi(),n=i(n),r=i(r));let{update:a,getValues:o}=R(Gs),s=R(q),c=R(Ws),l={collectText:Lu,sourceLocation:zu,parseVarArgs:Bu,extractOptions:Vu,h:b,renderNodes:(e,t)=>uc(e,{nobr:s,locals:c,...t}),renderInlineNodes:tc,hooks:Uu,useAction:Iu,className:n,id:r,resolve:i,cls:Hu(e.name,n),mutate:e=>Du(e,o(),a),update:a,getValues:o,wrap:e=>n||r?b(`span`,{id:r,class:n},e):b(C,null,e)};if(e.merged){l.merged=jr();let e=l.merged;l.evaluate=t=>si(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=t.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,``)??``;if(n.startsWith(`%`))return b(`span`,{class:`error`},`{${e.name}}: transient variables (%${n.slice(1)}) cannot be bound to input macros`);let r=n.replace(/[\"']/g,``).replace(/^\\$/,``),i=r.split(`.`);l.varName=r,l.value=Z(e=>Wu(e.variables,i)),l.getValue=()=>Wu(Z.getState().variables,i),l.setValue=e=>{Z.setState(t=>{Gu(t.variables,i,e)})}}return e.render(t,l)}Oi(e.name,n);let r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(Pi(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(let t of e.subMacros)ji(t);r&&Dr(e.name)}var Ku=null,qu=null;function Ju(){return qu}var Yu=!1;function Xu(){if(Yu)return;Yu=!0;let e={...Z.getState().variables},t={...Z.getState().transient};Z.subscribe(n=>{let r={},i=!1,a=new Set([...Object.keys(e),...Object.keys(n.variables)]);for(let t of a)n.variables[t]!==e[t]&&(r[t]={from:e[t],to:n.variables[t]},i=!0);let o=new Set([...Object.keys(t),...Object.keys(n.transient)]);for(let e of o)n.transient[e]!==t[e]&&(r[`%${e}`]={from:t[e],to:n.transient[e]},i=!0);e={...n.variables},t={...n.transient},i&&X(`variableChanged`,r)})}function Zu(){return{get(e){return e.startsWith(`%`)?Z.getState().transient[e.slice(1)]:Z.getState().variables[e]},set(e,t){let n=Z.getState();if(typeof e==`string`)e.startsWith(`%`)?n.setTransient(e.slice(1),t):n.setVariable(e,t);else for(let[t,r]of Object.entries(e))t.startsWith(`%`)?n.setTransient(t.slice(1),r):n.setVariable(t,r)},goto(e){Z.getState().navigate(e)},back(){Z.getState().goBack()},forward(){Z.getState().goForward()},restart(){Z.getState().restart()},save(e,t){Z.getState().save(e,t)},load(e){Z.getState().load(e)},hasSave(e){return Z.getState().hasSave(e)},getSaveInfo(e){return Z.getState().getSaveInfo(e)},listSaves(){return Z.getState().listSaves()},deleteSave(e){Z.getState().deleteSave(e)},visited(e){let t=Z.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){let{visitCounts:t}=Z.getState();return e.some(e=>(t[e]??0)>0)},hasVisitedAll(...e){let{visitCounts:t}=Z.getState();return e.every(e=>(t[e]??0)>0)},rendered(e){let t=Z.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){let{renderCounts:t}=Z.getState();return e.some(e=>(t[e]??0)>0)},hasRenderedAll(...e){let{renderCounts:t}=Z.getState();return e.every(e=>(t[e]??0)>0)},currentPassage(){let e=Z.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){let e=Z.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return Z.getState().storyData?.name||``},get passage(){return Z.getState().currentPassage},settings:Eu,registerClass(e,t){Ic(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return Fi()},saves:{setTitleGenerator(e){Gc(e)}},storage:{async getInfo(){let e=Z.getState().storyData?.ifid;return e?bl(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Nc()}},async getQuota(){if(typeof navigator<`u`&&navigator.storage?.estimate)try{let 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(){let e=Z.getState().storyData?.ifid;e&&(await xl(e),Z.setState(e=>{e.knownSaves={}}),Z.getState().restart())},async clearAllData(){await Sl(),Z.setState(e=>{e.knownSaves={}}),Z.getState().restart()},async deletePlaythrough(e){let{storyData:t}=Z.getState();if(!t)return;await Cl(t.ifid,e);let n=await ul(t.ifid);Z.setState(e=>{e.knownSaves=n})},get backend(){return Nc()}},getActions(){return Mu()},performAction(e,t){let n=Nu(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){e===`variableChanged`&&Xu();let n=Dl(e,t);return lu(n),n},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Mu())})})})},watch(e,t){return Fl(e,t)},unwatch(e){Il(e)},openDialog(e,t){Gl({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Jl()},closeAllDialogs(){Yl()},isDialogOpen(){return Xl()},setNobr(e){Z.setState({nobr:e})},setCSS(e){let t=document.getElementById(`spindle-styles`);t&&(t.disabled=!e)},setTransition(e){Z.getState().setTransition(e)},setNextTransition(e){Z.getState().setNextTransition(e)},deferRender(){Z.getState().deferRender(),qu=new Promise(e=>{Ku=e})},ready(){Ku&&(Z.getState().clearDeferredRender(),Ku(),Ku=null,qu=null)},random(){return Hr()},randomInt(e,t){return Ur(e,t)},config:{get maxHistory(){return Z.getState().maxHistory},set maxHistory(e){Z.getState().setMaxHistory(e)}},prng:{init(e,t){Rr(e,t);let{historyIndex:n}=Z.getState();Z.setState(e=>{let t=e.history[n];t&&(t.prng=Vr())})},isEnabled(){return Wr()},get seed(){return Gr()},get pull(){return Kr()}}}}function Qu(){window.Story=Zu()}function $u(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var ed=/\\$(\\w+(?:\\.\\w+)*)/g,td=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,nd=new Set([`number`,`string`,`boolean`]);function rd(e){if(Array.isArray(e))return{type:`array`};if(typeof e==`object`&&e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,rd(r));return{type:`object`,fields:t}}let t=typeof e;if(!nd.has(t))throw Error(`Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function id(e,t=`$`){let n=new Map,r=$u(t),i=t===`%`?`StoryTransients`:`StoryVariables`;for(let a of e.split(`\n`)){let e=a.trim();if(!e)continue;let o=e.match(r);if(!o)throw Error(`${i}: Invalid declaration: \"${e}\". Expected: ${t}name = value`);let[,s,c]=o,l;try{l=Function(`return (`+c+`)`)()}catch(e){throw Error(`${i}: Failed to evaluate \"${t}${s} = ${c}\": ${e instanceof Error?e.message:e}`)}let u;try{u=rd(l)}catch(e){throw Error(`${i}: ${e instanceof Error?e.message:e}`)}n.set(s,{...u,name:s,default:l})}return n}function ad(e){let t=new Set,n;for(td.lastIndex=0;(n=td.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function od(e,t,n){let r=e.split(`.`),i=r[0];if(n.has(i))return null;let a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let e=1;e<r.length;e++){let t=r[e];if(o.type===`array`)return null;if(o.type!==`object`||!o.fields)return`Cannot access field \"${t}\" on $${r.slice(0,e).join(`.`)} (type: ${o.type})`;let n=o.fields.get(t);if(!n)return null;o=n}return null}function sd(e,t){let n=[];for(let[r,i]of e){if(r===`StoryVariables`||r===`StoryTransients`)continue;let e=ad(i.content),a;for(ed.lastIndex=0;(a=ed.exec(i.content))!==null;){let i=a[1],o=od(i,t,e);o&&n.push(`Passage \"${r}\": ${o}`)}}return n}function cd(e){let t={};for(let[n,r]of e)t[n]=r.default;return t}function ld(e){for(let t of e){if(t.type===`variable`&&t.scope===`local`&&t.name===`children`||t.type===`html`&&ld(t.children))return!0;if(t.type===`macro`){if(ld(t.children))return!0;if(t.branches){for(let e of t.branches)if(ld(e.children))return!0}}}return!1}function ud({macro:e,error:t}){return V(`span`,{class:`error`,title:String(t),children:`{${e} error${zu()}: ${t instanceof Error?t.message:String(t)}}`})}$({name:`set`,render({rawArgs:e},t){let n=t.hooks.useRef(!1),r=t.hooks.useRef(null);if(!n.current){n.current=!0;try{t.mutate(e)}catch(n){r.current=n,console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,n)}}return r.current?V(ud,{macro:`set`,error:r.current}):null}}),$({name:`print`,interpolate:!0,merged:!0,render({rawArgs:e},t){try{let n=t.evaluate(e),r=n==null?``:String(n);return t.wrap(r)}catch(e){return V(ud,{macro:`print`,error:e})}}});function dd(e){let t=e.trim(),n=0;for(let e=0;e<t.length;e++){let r=t[e];if(r===`(`||r===`[`||r===`{`)n++;else if(r===`)`||r===`]`||r===`}`)n--;else if(r===`=`&&n===0){if(t[e+1]===`=`){e++;continue}if(e>0&&t[e-1]===`!`)continue;let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n.match(/^[$_@]\\w+$/))throw Error(`{computed}: target must be $name, _name, or @name, got \"${n}\"`);return{target:n,expr:r}}}throw Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function fd(e,t){if(Object.is(e,t))return!0;if(typeof e==`object`&&e&&typeof t==`object`&&t)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function pd(e,t,n,r,i,a,o,s,c,l,u){let d;try{d=si(e,i,a,o,s)}catch(e){console.error(`spindle: Error in {computed ${c}}${zu()}:`,e);return}if(!fd(l.current,d))if(l.current=d,r)try{u(t,d)}catch(e){console.error(`spindle: Error in {computed ${c}}${zu()}:`,e)}else{let e=Z.getState();n?e.setTemporary(t,d):e.setVariable(t,d)}}$({name:`computed`,merged:!0,render({rawArgs:e},t){let[n,r,i,a]=t.merged,o,s;try{({target:o,expr:s}=dd(e))}catch(e){return V(ud,{macro:`computed`,error:e})}let c=o.startsWith(`@`),l=o.startsWith(`_`),u=o.slice(1),d=c?t.update:null,f=t.hooks.useRef(void 0),p=t.hooks.useRef(!1);return p.current||(p.current=!0,pd(s,u,l,c,n,r,i,a,e,f,d)),t.hooks.useLayoutEffect(()=>{pd(s,u,l,c,n,r,i,a,e,f,d)},[n,r,i,a]),null}});function md(e){let t=e.trim(),n=``,r=t,i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??``,r=r.slice(0,i.index??r.length).trim());let a=hd(r);if(a.length<2)throw Error(`meter requires two arguments: {meter currentExpr maxExpr}`);return{currentExpr:a[0],maxExpr:a.slice(1).join(` `),labelMode:n}}function hd(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let 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 gd(e,t,n){return n===`none`?null:n===`%`?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}$({name:`meter`,interpolate:!0,merged:!0,render({rawArgs:e},t){try{let{currentExpr:n,maxExpr:r,labelMode:i}=md(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),c=gd(a,o,i),l=t.cls;return V(`div`,{class:l,id:t.id,children:[V(`div`,{class:`macro-meter-fill`,style:`width: ${s}%`}),c!=null&&V(`span`,{class:`macro-meter-label`,children:c})]})}catch(e){return V(ud,{macro:`meter`,error:e})}}}),$({name:`if`,block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){function n(e){let n=t.renderNodes(e.children),r=t.resolve(e.className),i=t.resolve(e.id);return r||i?V(`span`,{id:i,class:r,children:n}):V(C,{children:n})}for(let r of e){if(r.rawArgs===``)return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(e){return V(ud,{macro:`if`,error:e})}}return null}});function _d(e){let t=e.indexOf(` of `);if(t===-1)throw Error(`{for} requires \"of\" keyword: {for ${e}}`);let n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(`,`).map(e=>e.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(`@`))throw Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(`@`))throw Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function vd({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){let[o,s]=P(()=>({})),c=I(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i]),l=I(()=>({...e,...c,...o}),[e,c,o]),u=F(l);u.current=l;let d=L(()=>u.current,[]),f=L((e,t)=>{s(n=>({...n,[e]:t}))},[]),p=I(()=>({update:f,getValues:d}),[f,d]),m=R(q);return V(Gs.Provider,{value:p,children:V(Ws.Provider,{value:l,children:uc(a,{nobr:m,locals:l})})})}$({name:`for`,block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){let r=R(Ws),i;try{i=_d(e)}catch(e){return V(ud,{macro:`for`,error:e})}let{itemVar:a,indexVar:o,listExpr:s}=i,c;try{let e=n.evaluate(s);if(!Array.isArray(e))return V(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});c=e}catch(e){return V(ud,{macro:`for`,error:e})}let l=c.map((e,n)=>V(vd,{parentValues:r,itemVar:a,itemValue:e,indexVar:o,indexValue:n,children:t},`${n}-${JSON.stringify(e)}`));return n.wrap(l)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(e){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,e)}},[]),null}}),$({name:`button`,block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,``))??e,i=R(q),a=()=>{let e=document.createElement(`div`);me(b(q.Provider,{value:i},b(Gs.Provider,{value:{update:n.update,getValues:n.getValues}},b(Ws.Provider,{value:n.getValues()},uc(t)))),e),me(null,e)};return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),V(`button`,{id:n.id,class:n.cls,onClick:a,children:r})}});function yd(e){let t=[],n=/([\"'])(.*?)\\1/g,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 bd(e,t,n,r){let i=document.createElement(`div`);me(b(q.Provider,{value:r},b(Gs.Provider,{value:{update:n,getValues:t}},b(Ws.Provider,{value:t()},uc(e)))),i),me(null,i)}$({name:`link`,block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){let{display:r,passage:i}=yd(e),a=R(q);return n.useAction({type:`link`,key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{bd(t,n.getValues,n.update,a),i&&Z.getState().navigate(i)}}),V(`a`,{id:n.id,class:n.cls,href:`#`,onClick:e=>{e.preventDefault(),bd(t,n.getValues,n.update,a),i&&Z.getState().navigate(i)},children:r})}}),$({name:`switch`,subMacros:[`case`,`default`],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return V(ud,{macro:`switch`,error:e})}let i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a.rawArgs===``){i=a;continue}try{let e=n.evaluate(a.rawArgs);if(r===e)return V(C,{children:n.renderNodes(a.children)})}catch(e){return V(ud,{macro:`case`,error:e})}}return i?V(C,{children:n.renderNodes(i.children)}):null}});function xd(e){let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2)):t.endsWith(`s`)?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}$({name:`timed`,subMacros:[`next`],interpolate:!0,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(e=>({delay:e.rawArgs?xd(e.rawArgs):0,nodes:e.children,className:e.className,id:e.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;let e=o+1,t=a[e].delay,n=setTimeout(()=>{s(e)},t);return()=>clearTimeout(n)},[o,a]),o<0)return t.wrap(null);let c=a[o],l=t.renderNodes(c.nodes),u=t.resolve(c.className),d=t.resolve(c.id),f=u||d?V(`span`,{id:d,class:u,children:l}):l;return t.wrap(f)}});var Sd=_e({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){let{useState:r,useEffect:i,useCallback:a}=n.hooks,o=xd(e),[s,c]=r(0),[l,u]=r(!1),d=a(()=>u(!0),[]);if(i(()=>{if(l)return;let e=setInterval(()=>{c(e=>e+1)},o);return()=>clearInterval(e)},[o,l]),s===0&&!l)return null;let f=V(Sd.Provider,{value:{stop:d},children:V(`span`,{children:n.renderNodes(t)},s)});return n.className||n.id?V(`span`,{id:n.id,class:n.cls,children:f}):f}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(Sd);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}}),$({name:`type`,block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){let{useState:r,useEffect:i,useRef:a}=n.hooks,o=xd(e),s=a(null),[c,l]=r(0),[u,d]=r(0),f=a(0);f.current=u,i(()=>{s.current&&l((s.current.textContent||``).length)},[]),i(()=>{if(c===0||f.current>=c)return;let e=setInterval(()=>{d(t=>t>=c?(clearInterval(e),t):t+1)},o);return()=>clearInterval(e)},[c,o]);let p=u>=c&&c>0,m=[`macro-type`,p?`macro-type-done`:``,n.className||``].filter(Boolean).join(` `);return V(`span`,{id:n.id,class:m,ref:s,style:{clipPath:void 0},children:[V(`span`,{class:`macro-type-inner`,style:{display:`inline`,visibility:c===0?`hidden`:`visible`,clipPath:c>0&&!p?`inset(0 ${(c-u)/c*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!p&&c>0&&V(`span`,{class:`macro-type-cursor`})]})}});function Cd(e){let t=e.trim().split(/\\s+/);return{name:t[0].replace(/[\"']/g,``),params:t.slice(1).filter(e=>e.startsWith(`@`))}}$({name:`widget`,block:!0,render({rawArgs:e,children:t=[]},n){let{name:r,params:i}=Cd(e),a=JSON.stringify(t),o=i.join(`,`);return n.hooks.useLayoutEffect(()=>{Ti(r,t,i)},[r,a,o]),null}}),$({name:`story-title`,render(e,t){let n=Z(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return V(`span`,{id:t.id,class:r,children:n})}});function wd(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=P(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:`menubar-button`,c=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}),V(C,{children:[V(`button`,{id:n.id,class:s,onClick:c,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&V(gu,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}wd({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Z(e=>e.goBack),disabled:!Z(e=>e.historyIndex>0)})}),wd({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Z(e=>e.goForward),disabled:!Z(e=>e.historyIndex<e.history.length-1)})}),wd({name:`quicksave`,label:`QuickSave`,actionType:`save`,title:`Quick Save (F6)`,setup:()=>({perform:Z(e=>e.save)})}),wd({name:`quickload`,label:`QuickLoad`,actionType:`load`,title:`Quick Load (F9)`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let e=Z(e=>e.load),t=Z(e=>e.hasSave);return Z(e=>e.knownSaves),{perform:()=>e(),disabled:!t()}}}),wd({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Z(e=>e.restart)})}),wd({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),wd({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!Eu.hasAny(),dialog:{passageName:`Settings`,fallbackMarkup:`{settings-controls}`,panelClass:`dialog-settings`}}),$({name:`dialog`,block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){let[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,``).trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,``))??o,c=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,``);return V(C,{children:[V(`button`,{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&V(gu,{passageName:c,onClose:()=>i(!1),showCloseButton:!a})]})}});function Td(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Ed(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Dd(){let[e,t]=P(`load`),[n,r]=P([]),[i,a]=P(!0),[o,s]=P(null),[c,l]=P(()=>new Set),[u,d]=P(null),[f,p]=P(``),m=F(null),h=F(null),g=R(hu),_=Z(e=>e.storyData),v=Z(e=>e.playthroughId),y=Z(e=>e.getSavePayload),b=Z(e=>e.loadFromPayload),x=_?.ifid??``,S=L(async()=>{x&&(r(await nl(x)),a(!1))},[x]);je(()=>{S()},[S]),je(()=>{u&&m.current&&(m.current.focus(),m.current.select())},[u]);let C=F(),w=(e,t=`success`)=>{clearTimeout(C.current),s({text:e,type:t}),C.current=window.setTimeout(()=>s(null),3e3)};je(()=>()=>clearTimeout(C.current),[]);let T=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},E=async()=>{if(!(!x||!v))try{await Zc(x,v,y()),w(`Save created`),await S()}catch{w(`Failed to create save`,`error`)}},D=async e=>{try{await Qc(e,y()),w(`Save overwritten`),await S()}catch{w(`Failed to overwrite save`,`error`)}},O=async e=>{try{b(e.payload),w(`Game loaded`),g&&setTimeout(g,500)}catch{w(`Failed to load save`,`error`)}},k=async e=>{if(confirm(`Delete this save?`))try{await el(e),w(`Save deleted`),await S()}catch{w(`Failed to delete save`,`error`)}},ee=e=>{d(e.meta.id),p(e.meta.title)},te=async()=>{if(!(!u||!f.trim()))try{await tl(u,f.trim()),d(null),w(`Save renamed`),await S()}catch{w(`Failed to rename`,`error`)}},A=e=>{e.key===`Enter`?te():e.key===`Escape`&&d(null)},j=async e=>{try{let t=await vl(e);if(!t)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`save-${t.save.meta.title.replace(/[^a-z0-9]/gi,`_`)}.json`,i.click(),URL.revokeObjectURL(r),w(`Save exported`)}catch{w(`Failed to export save`,`error`)}},ne=()=>{h.current?.click()},re=async e=>{let t=e.target,n=t.files?.[0];if(n){t.value=``;try{let e=await n.text(),t=JSON.parse(e);if(!dc(t))throw Error(`Invalid save file format`);await yl(t,x),w(`Save imported`),await S()}catch(e){w(e instanceof Error?e.message:`Failed to import save`,`error`)}}},ie=n.reduce((e,t)=>e+t.saves.length,0);return V(`div`,{class:`save-manager`,children:[V(`div`,{class:`saves-header`,children:V(`div`,{class:`saves-header-left`,children:V(`div`,{class:`saves-mode-toggle`,children:[V(`button`,{class:e===`save`?`active`:``,onClick:()=>t(`save`),children:`Save`}),V(`button`,{class:e===`load`?`active`:``,onClick:()=>t(`load`),children:`Load`})]})})}),V(`div`,{class:`saves-toolbar`,children:[V(`button`,{class:`saves-toolbar-button`,onClick:ne,children:`Import`}),V(`input`,{ref:h,type:`file`,accept:`.json`,style:`display:none`,onChange:re})]}),V(`div`,{class:`saves-body`,children:[i?V(`div`,{class:`saves-empty`,children:`Loading...`}):ie===0&&e===`load`?V(`div`,{class:`saves-empty`,children:`No saves yet`}):n.map(t=>{let n=c.has(t.playthrough.id),r=t.playthrough.id===v;return e===`save`&&!r||e===`load`&&t.saves.length===0&&!r?null:V(`div`,{class:`playthrough-group`,children:[V(`div`,{class:`playthrough-header`,onClick:()=>T(t.playthrough.id),children:[V(`span`,{class:`playthrough-chevron ${n?``:`open`}`,children:`▶`}),V(`span`,{class:`playthrough-label`,children:[t.playthrough.label,r?` (current)`:``]}),V(`span`,{class:`playthrough-date`,children:Ed(t.playthrough.createdAt)})]}),!n&&V(`div`,{class:`playthrough-saves`,children:[t.saves.map(t=>V(`div`,{class:`save-slot`,children:[V(`div`,{class:`save-slot-info`,children:[u===t.meta.id?V(`input`,{ref:m,class:`save-rename-input`,value:f,onInput:e=>p(e.target.value),onKeyDown:A,onBlur:te}):V(`div`,{class:`save-slot-title`,children:t.meta.title}),V(`div`,{class:`save-slot-meta`,children:[V(`span`,{children:t.meta.passage}),V(`span`,{children:Td(t.meta.updatedAt)})]})]}),V(`div`,{class:`save-slot-actions`,children:[e===`save`?V(`button`,{class:`save-slot-action primary`,onClick:()=>D(t.meta.id),children:`Save Here`}):V(`button`,{class:`save-slot-action primary`,onClick:()=>O(t),children:`Load`}),V(`button`,{class:`save-slot-action`,onClick:()=>ee(t),children:`Rename`}),V(`button`,{class:`save-slot-action`,onClick:()=>j(t.meta.id),children:`Export`}),V(`button`,{class:`save-slot-action danger`,onClick:()=>k(t.meta.id),children:`Delete`})]})]},t.meta.id)),e===`save`&&r&&V(`button`,{class:`save-slot-new`,onClick:E,children:`+ New Save`})]})]},t.playthrough.id)}),e===`save`&&!i&&!n.some(e=>e.playthrough.id===v)&&V(`div`,{class:`playthrough-group`,children:V(`div`,{class:`playthrough-saves`,children:V(`button`,{class:`save-slot-new`,onClick:E,children:`+ New Save`})})})]}),o&&V(`div`,{class:`saves-status ${o.type===`error`?`error`:``}`,children:o.text})]})}$({name:`save-manager`,render(){return V(Dd,{})}});function Od({name:e,def:t}){let[n,r]=P(()=>Eu.get(e)),i=t=>{r(t),Eu.set(e,t)};switch(t.type){case`toggle`:return V(`label`,{class:`settings-row`,children:[V(`span`,{children:t.config.label}),V(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return V(`label`,{class:`settings-row`,children:[V(`span`,{children:t.config.label}),V(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>V(`option`,{value:e,children:e},e))})]});case`range`:return V(`label`,{class:`settings-row`,children:[V(`span`,{children:[t.config.label,`: `,String(n)]}),V(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function kd(){let e=Eu.getDefinitions();return V(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>V(Od,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return V(kd,{})}}),$({name:`include`,interpolate:!0,merged:!0,render({rawArgs:e},t){let n=Z(e=>e.storyData);if(!n)return null;let r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,``).trim(),a;try{let e=t.evaluate(i);a=String(e)}catch{a=i.replace(/^[\"']|[\"']$/g,``)}let o=n.passages.get(a);if(o&&Z.getState().trackRender(a),!o)return V(`span`,{class:`error`,children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});let s=o.tags.includes(`nobr`),c=Ar(Tr(o.content)),l=r?t.renderInlineNodes(c):t.renderNodes(c,s?{nobr:!0}:void 0);return s?t.wrap(t.h(q.Provider,{value:!0},l)):t.wrap(l)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(q.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}}),$({name:`goto`,merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{let r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,``)}Z.getState().navigate(n)},[]),null}}),$({name:`unset`,render({rawArgs:e},t){let n=t.hooks.useRef(!1);if(!n.current){n.current=!0;let r=Z.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}}),$({name:`textbox`,storeVar:!0,render({rawArgs:e},t){let{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:e=>t.setValue(e===void 0?``:String(e))}),V(`input`,{type:`text`,id:t.id,class:t.cls,value:t.value==null?``:String(t.value),placeholder:n,onInput:e=>t.setValue(e.target.value)})}}),$({name:`numberbox`,storeVar:!0,render({rawArgs:e},t){let{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:e=>t.setValue(e===void 0?0:Number(e))}),V(`input`,{type:`number`,id:t.id,class:t.cls,value:t.value==null?``:String(t.value),placeholder:n,onInput:e=>{let n=e.target.value;t.setValue(n===``?0:Number(n))}})}}),$({name:`textarea`,storeVar:!0,render({rawArgs:e},t){let{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:e=>t.setValue(e===void 0?``:String(e))}),V(`textarea`,{id:t.id,class:t.cls,value:t.value==null?``:String(t.value),placeholder:n,onInput:e=>t.setValue(e.target.value)})}});function Ad(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??``}$({name:`checkbox`,storeVar:!0,render({rawArgs:e},t){let n=Ad(e);return t.useAction({type:`checkbox`,key:`$${t.varName}`,authorId:t.id,label:n||t.varName||``,variable:t.varName,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.value:!!e)}),V(`label`,{id:t.id,class:t.cls,children:[V(`input`,{type:`checkbox`,checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function jd(e){let t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){let t=e.trim().split(/\\s+/).slice(1);return{value:t[0]??``,label:t.slice(1).join(` `)}}return{value:t[1],label:t[2]}}$({name:`radiobutton`,storeVar:!0,render({rawArgs:e},t){let{value:n,label:r}=jd(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)}),V(`label`,{id:t.id,class:t.cls,children:[V(`input`,{type:`radio`,name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,subMacros:[`option`],storeVar:!0,render({children:e=[]},t){let 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:e=>{e!==void 0&&t.setValue(String(e))}}),V(`select`,{id:t.id,class:t.cls,value:t.value==null?``:String(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>V(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,storeVar:!0,render({children:e=[]},t){let n=t.extractOptions(e),r=()=>{if(n.length===0)return;let e=t.getValue(),r=(n.indexOf(String(e))+1)%n.length;t.setValue(n[r])};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:e=>{e===void 0?r():t.setValue(e)}}),V(`button`,{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Md(e){return uc(Ar(Tr(e.content)),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}var Nd=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function Pd({passage:e,dataTransition:t}){let n=Z(e=>e.storyData),r=Nd.has(e.name),[i,a]=P(!1),o=I(()=>{try{return Md(e)}catch(t){return V(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,Ru(e),`:`,` `,t instanceof Error?t.message:String(t)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(`PassageHeader`),c=r?void 0:n?.passages.get(`PassageFooter`),l=r?void 0:n?.passages.get(`PassageDone`),u=I(()=>{if(!s)return null;try{return Md(s)}catch(e){return console.error(`spindle: Error in PassageHeader:`,e),null}},[s?.content]),d=I(()=>{if(!c)return null;try{return Md(c)}catch(e){return console.error(`spindle: Error in PassageFooter:`,e),null}},[c?.content]);je(()=>(l&&a(!0),()=>a(!1)),[e.name]);let f=I(()=>{if(!i||!l)return null;try{return Md(l)}catch(e){return console.error(`spindle: Error in PassageDone:`,e),null}},[i,l?.content]),p=e.tags.includes(`nobr`),m=V(`div`,{class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[u&&V(`div`,{class:`passage-header`,children:u}),o,d&&V(`div`,{class:`passage-footer`,children:d}),f&&V(`div`,{hidden:!0,children:f})]});return p?V(q.Provider,{value:!0,children:m}):m}var Fd=new Set([`none`,`fade`,`fade-through`,`crossfade`]),Id={type:`fade-through`,duration:300,pause:50};function Ld(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!Fd.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;let r={type:n};for(let t of e)if(t.startsWith(`duration:`)){let e=Number(t.slice(9));Number.isNaN(e)||(r.duration=e)}else if(t.startsWith(`pause:`)){let e=Number(t.slice(6));Number.isNaN(e)||(r.pause=e)}return r}function Rd(e){return{type:e.type,duration:e.duration??Id.duration,pause:e.pause??Id.pause}}function zd(e,t,n){let r=Ld(e);return r?Rd(r):t?Rd(t):n?Rd(n):{...Id}}function Bd(e,t){let n=e.cloneNode(!0);n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);n.style.pointerEvents=`none`,n.style.userSelect=`none`;let i=n.querySelectorAll(`audio, video`);for(let e=0;e<i.length;e++){let t=i[e];t.pause?.(),t.muted=!0}return n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function Vd(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 Hd(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}$({name:`passage`,interpolate:!0,render(e,t){let n=Z(e=>e.currentPassage),r=Z(e=>e.storyData),i=Z(e=>e.renderDeferred),[a,o]=P(n),s=F(`fade`),c=F(0),l=F(null),u=F([]),d=L(()=>{for(let e of u.current)clearTimeout(e);u.current=[],Hd(l.current)},[]);je(()=>{let e=Z.getState(),{history:t,historyIndex:i,transitionConfig:f}=e,p=e.consumeNextTransition(),m=c.current;c.current=t.length;let h=!a,g=t.length===1&&i===0&&m>1,_=t.length>1&&i===t.length-1&&m>1&&Math.abs(t.length-m)>1;if(n===a)return;d();let v=r?.passages.get(n);if(!v){s.current=`none`,o(n);return}if(h||g||_){s.current=`fade`,o(n);return}let y=zd(v.tags,p,f);s.current=y.type;let b=l.current;if(y.type===`none`){o(n);return}if(y.type===`fade`){b&&Vd(b,y),o(n);return}if(y.type===`fade-through`){if(!b){o(n);return}Vd(b,y);let e=b.querySelector(`.passage`);if(!e){o(n);return}let t=Bd(e,y.type);b.appendChild(t),o(``);let r=y.duration+y.pause,i=setTimeout(()=>{o(n)},r),a=r+y.duration;u.current=[i,setTimeout(()=>{Hd(b)},a)];return}if(y.type===`crossfade`){if(!b){o(n);return}Vd(b,y);let e=b.querySelector(`.passage`);if(!e){o(n);return}let t=Bd(e,y.type);b.classList.add(`passage-container--crossfading`),b.appendChild(t),o(n),u.current=[setTimeout(()=>{Hd(b)},y.duration)];return}o(n)},[n]);let f=i?r?.passages.get(`StoryLoading`)??null:a?r?.passages.get(a):null;if(!f&&a&&!i)return V(`div`,{class:`error`,children:[`Error: Passage “`,a,`” not found.`]});let p=r?.passages.get(`PassageReady`);return V(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!i&&p&&V(`div`,{hidden:!0,children:Md(p)},`ready-${n}`),V(`div`,{class:`passage-container`,ref:l,children:f&&V(Pd,{passage:f,dataTransition:i?`none`:s.current},i?`loading`:a)})]})}}),$({name:`watch`,render(e,t){let{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;let a=i[2],o=r.slice(i[0].length),s={},c=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g,l;for(;(l=c.exec(o))!==null;){let e=l[1]??l[5],t=l[2]??l[3]??l[4];if(e)switch(e){case`goto`:s.goto=t;break;case`dialog`:s.dialog=t;break;case`run`:s.run=t;break;case`name`:s.name=t;break;case`priority`:s.priority=t?Number(t):0;break;case`once`:s.once=!0;break}}let u=n.useRef(!1);return u.current||(u.current=!0,Fl(a,s)),null}}),$({name:`unwatch`,render(e,t){let n=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,``),r=t.hooks.useRef(!1);return r.current||(r.current=!0,Il(n)),null}});var Ud=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}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;-webkit-user-select: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:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;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:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;align-items:center;gap:.5em;padding:.4em 0;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.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{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.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{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.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{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.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 #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.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:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function Wd(e,t){e.innerHTML=``;let n=document.createElement(`div`);n.style.cssText=`font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto`;let r=document.createElement(`h1`);r.style.color=`#c00`,r.textContent=`Story Validation Errors`,n.appendChild(r);let i=document.createElement(`ul`);i.style.cssText=`line-height:1.6`;for(let e of t){let t=document.createElement(`li`);t.textContent=e,i.appendChild(t)}n.appendChild(i),e.appendChild(n)}function Gd(){let e=bu(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=Ud,document.head.appendChild(t),Qu(),e.userCSS){let t=document.createElement(`style`);t.textContent=e.userCSS,document.head.appendChild(t)}if(e.userScript)try{Function(e.userScript)()}catch(e){console.error(`spindle: Error in story JavaScript:`,e)}document.dispatchEvent(new CustomEvent(`:storystartup`));let n={},r=e.passages.get(`StoryVariables`);if(!r){let e=`Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.`,t=document.getElementById(`root`);throw t&&Wd(t,[e]),Error(`spindle: ${e}`)}let i=id(r.content),a=sd(e.passages,i),o={},s=e.passages.get(`StoryTransients`);if(s){let e=id(s.content,`%`);for(let t of e.keys())i.has(t)&&a.push(`StoryTransients: Variable \"${t}\" is already declared in StoryVariables. Names must be unique across scopes.`);o=cd(e)}if(a.length>0){let e=document.getElementById(`root`);throw e&&Wd(e,a),Error(`spindle: ${a.length} validation error(s):\\n${a.join(`\n`)}`)}n=cd(i),Z.getState().init(e,n,o),uu(),wl();let c=gl(e.ifid);c&&Z.getState().loadFromPayload(c),X(`storyinit`);let l=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(let[,t]of e.passages)if(t.tags.includes(`widget`)){let e;for(;(e=l.exec(t.content))!==null;){let t=e[1],n=e[2];/\\{@children\\}/.test(n)&&Dr(t)}l.lastIndex=0}for(let[,t]of e.passages)if(t.tags.includes(`widget`)){let e=Ar(Tr(t.content));for(let t of e)if(t.type===`macro`&&t.name===`widget`&&t.rawArgs){let e=t.rawArgs.trim().split(/\\s+/),n=e[0].replace(/[\"']/g,``),r=e.slice(1).filter(e=>e.startsWith(`$`)||e.startsWith(`_`)||e.startsWith(`@`)),i=t.children,a=ld(i);Ti(n,i,r,a),a&&Dr(n)}}let u=``;Z.subscribe(e=>{e.currentPassage!==u&&(u=e.currentPassage,Pu())});let d=Z.getState().variables,f=Z.getState().historyIndex;Z.subscribe(e=>{e.variables!==d&&(e.historyIndex===f?zl():Bl()),d=e.variables,f=e.historyIndex});let p=e.passages.get(`StoryInterface`);p&&!p.content.includes(`{passage}`)&&console.warn(`spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.`);let m=document.getElementById(`root`);if(!m)throw Error(`spindle: No <div id=\"root\"> element found.`);me(V(vu,{}),m);let h=Ju();h?h.then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Gd):Gd();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rohal12/spindle",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Preact-based story format for Twine 2.",
|
|
6
6
|
"license": "Unlicense",
|
|
@@ -61,28 +61,29 @@
|
|
|
61
61
|
"micromark": "^4.0.2",
|
|
62
62
|
"micromark-extension-gfm-strikethrough": "^2.1.0",
|
|
63
63
|
"micromark-extension-gfm-table": "^2.1.1",
|
|
64
|
-
"preact": "^10.
|
|
65
|
-
"zustand": "^5.0.
|
|
64
|
+
"preact": "^10.29.0",
|
|
65
|
+
"zustand": "^5.0.12"
|
|
66
66
|
},
|
|
67
67
|
"lint-staged": {
|
|
68
68
|
"*": "prettier --write --ignore-unknown"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@preact/preset-vite": "^2.10.
|
|
72
|
-
"@rohal12/twee-ts": "^1.
|
|
71
|
+
"@preact/preset-vite": "^2.10.5",
|
|
72
|
+
"@rohal12/twee-ts": "^1.14.0",
|
|
73
73
|
"@types/js-yaml": "^4.0.9",
|
|
74
|
-
"@types/
|
|
75
|
-
"@
|
|
76
|
-
"
|
|
74
|
+
"@types/node": "^25.5.0",
|
|
75
|
+
"@types/react": "^19.2.14",
|
|
76
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
77
|
+
"happy-dom": "^20.8.9",
|
|
77
78
|
"husky": "^9.1.7",
|
|
78
79
|
"js-yaml": "^4.1.1",
|
|
79
|
-
"lint-staged": "^16.
|
|
80
|
+
"lint-staged": "^16.4.0",
|
|
80
81
|
"playwright": "^1.58.2",
|
|
81
82
|
"prettier": "^3.8.1",
|
|
82
|
-
"typescript": "^
|
|
83
|
-
"vite": "^
|
|
84
|
-
"vite-plugin-singlefile": "^2.3.
|
|
83
|
+
"typescript": "^6.0.2",
|
|
84
|
+
"vite": "^8.0.3",
|
|
85
|
+
"vite-plugin-singlefile": "^2.3.2",
|
|
85
86
|
"vitepress": "^1.6.4",
|
|
86
|
-
"vitest": "^4.
|
|
87
|
+
"vitest": "^4.1.2"
|
|
87
88
|
}
|
|
88
89
|
}
|