@rohal12/spindle 0.31.3 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.31.3","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 Vt,O,na,Ke,Gr,ra,ia,aa,br,Wn,Qn,oa,cn={},fn=[],Go=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Bt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function vr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function K(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?Vt.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 At(e,o,r,i,null)}function At(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??++na,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Yo(){return{current:null}}function Y(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function ht(e,t){if(t==null)return e.__?ht(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\"?ht(e):null}function Jo(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),wr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ht(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ca(r,a,i),t.__e=t.__=null,a.__e!=n&&sa(a)}}function sa(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}),sa(e)}function Kn(e){(!e.__d&&(e.__d=!0)&&Ke.push(e)&&!dn.__r++||Gr!=O.debounceRendering)&&((Gr=O.debounceRendering)||ra)(dn)}function dn(){for(var e,t=1;Ke.length;)Ke.length>t&&Ke.sort(ia),e=Ke.shift(),t=Ke.length,Jo(e);dn.__r=0}function la(e,t,n,r,i,a,o,s,u,l,d){var f,h,c,p,w,S,y,k=r&&r.__k||fn,x=t.length;for(u=Zo(n,t,k,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(h=c.__i!=-1&&k[c.__i]||cn,c.__i=f,S=wr(e,c,h,i,a,o,s,u,l,d),p=c.__e,c.ref&&h.ref!=c.ref&&(h.ref&&kr(h.ref,null,c),d.push(c.ref,c.__c||p,c)),w==null&&p!=null&&(w=p),(y=!!(4&c.__u))||h.__k===c.__k?u=ua(c,u,e,y):typeof c.type==\"function\"&&S!==void 0?u=S:p&&(u=p.nextSibling),c.__u&=-7);return n.__e=w,u}function Zo(e,t,n,r,i){var a,o,s,u,l,d=n.length,f=d,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]=At(null,o,null,null,null):Bt(o)?o=e.__k[a]=At(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=At(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Xo(o,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(f)for(a=0;a<d;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ht(s)),da(s,s));return r}function ua(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=ua(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ht(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Bt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Xo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function Yr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Go.test(t)?n:n+\"px\"}function Yt(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||Yr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Yr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(aa,\"$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=br,e.addEventListener(t,a?Qn:Wn,a)):e.removeEventListener(t,a?Qn:Wn,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 Jr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=br++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function wr(e,t,n,r,i,a,o,s,u,l){var d,f,h,c,p,w,S,y,k,x,A,C,_,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(y=t.props,k=\"prototype\"in z&&z.prototype.render,x=(d=z.contextType)&&r[d.__c],A=d?x?x.props.value:d.__:r,n.__c?S=(f=t.__c=n.__c).__=f.__E:(k?t.__c=f=new z(y,A):(t.__c=f=new Ne(y,A),f.constructor=z,f.render=ts),x&&x.sub(f),f.state||(f.state={}),f.__n=r,h=f.__d=!0,f.__h=[],f._sb=[]),k&&f.__s==null&&(f.__s=f.state),k&&z.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Te({},f.__s)),Te(f.__s,z.getDerivedStateFromProps(y,f.__s))),c=f.props,p=f.state,f.__v=t,h)k&&z.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),k&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&y!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,A),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,A)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),fn.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,A),k&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,p,w)})}if(f.context=A,f.props=y,f.__P=e,f.__e=!1,C=O.__r,_=0,k)f.state=f.__s,f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),fn.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++_<25);f.state=f.__s,f.getChildContext!=null&&(r=Te(Te({},r),f.getChildContext())),k&&!h&&f.getSnapshotBeforeUpdate!=null&&(w=f.getSnapshotBeforeUpdate(c,p)),P=d!=null&&d.type===Y&&d.key==null?fa(d.props.children):d,s=la(e,Bt(P)?P:[P],t,n,r,i,a,o,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),S&&(f.__E=f.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)vr(a[T]);Gn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Gn(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=es(n.__e,t,n,r,i,a,o,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Gn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Gn))}function ca(e,t,n){for(var r=0;r<n.length;r++)kr(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 fa(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Bt(e)?e.map(fa):Te({},e)}function es(e,t,n,r,i,a,o,s,u){var l,d,f,h,c,p,w,S=n.props||cn,y=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((c=a[l])&&\"setAttribute\"in c==!!k&&(k?c.localName==k:c.nodeType==3)){e=c,a[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(y);e=document.createElementNS(i,k,y.is&&y),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)S===y||s&&e.data==y||(e.data=y);else{if(a=a&&Vt.call(e.childNodes),!s&&a!=null)for(S={},l=0;l<e.attributes.length;l++)S[(c=e.attributes[l]).name]=c.value;for(l in S)c=S[l],l==\"dangerouslySetInnerHTML\"?f=c:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||Yt(e,l,null,c,i);for(l in y)c=y[l],l==\"children\"?h=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?p=c:l==\"checked\"?w=c:s&&typeof c!=\"function\"||S[l]===c||Yt(e,l,c,S[l],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),la(t.type==\"template\"?e.content:e,Bt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&ht(n,0),s,u),a!=null)for(l=a.length;l--;)vr(a[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=S[l])&&Yt(e,l,p,S[l],i),l=\"checked\",w!=null&&w!=e[l]&&Yt(e,l,w,S[l],i))}return e}function kr(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 da(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||kr(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]&&da(r[i],t,n||typeof e.type!=\"function\");n||vr(e.__e),e.__c=e.__=e.__e=void 0}function ts(e,t,n){return this.constructor(e,n)}function xe(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=[],wr(t,e=(!r&&n||t).__k=K(Y,null,[e]),i||cn,cn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Vt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ca(a,e,o)}function ha(e,t){xe(e,t,ha)}function ns(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?Vt.call(arguments,2):n),At(e.type,s,r||e.key,i||e.ref,null)}function at(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,Kn(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+oa++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Vt=fn.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}},na=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),Kn(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Kn(this))},Ne.prototype.render=Y,Ke=[],ra=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ia=function(e,t){return e.__v.__b-t.__v.__b},dn.__r=0,aa=/(PointerCapture)$|Capture$/i,br=0,Wn=Jr(!1),Qn=Jr(!0),oa=0;var rs=0;function v(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rs,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var Be,W,Dn,Zr,pt=0,pa=[],Q=O,Xr=Q.__b,ei=Q.__r,ti=Q.diffed,ni=Q.__c,ri=Q.unmount,ii=Q.__;function yt(e,t){Q.__h&&Q.__h(W,e,pt||t),pt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return pt=1,Sr(ya,e)}function Sr(e,t,n){var r=yt(Be++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ya(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(h){if(h.__N){var c=h.__[0];h.__=h.__N,h.__N=void 0,c!==h.__[0]&&(f=!0)}}),a&&a.call(this,s,u,l)||f};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=a;a=void 0,i(s,u,l),a=d}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function we(e,t){var n=yt(Be++,3);!Q.__s&&xr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ot(e,t){var n=yt(Be++,4);!Q.__s&&xr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function oe(e){return pt=5,de(function(){return{current:e}},[])}function ga(e,t,n){pt=6,ot(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 de(e,t){var n=yt(Be++,7);return xr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function he(e,t){return pt=8,de(function(){return e},t)}function G(e){var t=W.context[e.__c],n=yt(Be++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ma(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function _a(){var e=yt(Be++,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 is(){for(var e;e=pa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rn),t.__h.some(Yn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Xr&&Xr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ii&&ii(e,t)},Q.__r=function(e){ei&&ei(e),Be=0;var t=(W=e.__c).__H;t&&(Dn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(rn),t.__h.some(Yn),t.__h=[],Be=0)),Dn=W},Q.diffed=function(e){ti&&ti(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(pa.push(t)!==1&&Zr===Q.requestAnimationFrame||((Zr=Q.requestAnimationFrame)||as)(is)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Dn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(rn),n.__h=n.__h.filter(function(r){return!r.__||Yn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),ni&&ni(e,t)},Q.unmount=function(e){ri&&ri(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{rn(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ai=typeof requestAnimationFrame==\"function\";function as(e){var t,n=function(){clearTimeout(r),ai&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ai&&(t=requestAnimationFrame(n))}function rn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Yn(e){var t=W;e.__c=e.__(),W=t}function xr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ya(e,t){return typeof t==\"function\"?t(e):t}const oi=e=>{let t;const n=new Set,r=(l,d)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const h=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},os=(e=>e?oi(e):oi);function ba(e,t){for(var n in t)e[n]=t[n];return e}function Jn(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 va(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ot(function(){i.__=n,i.u=t,$n(i)&&a({t:i})},[e,n,t]),we(function(){return $n(i)&&a({t:i}),e(function(){$n(i)&&a({t:i})})},[e]),n}function $n(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function wa(e){e()}function ka(e){return e}function Sa(){return[!1,wa]}var xa=ot;function Zn(e,t){this.props=e,this.context=t}function ss(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:Jn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,K(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Zn.prototype=new Ne).isPureReactComponent=!0,Zn.prototype.shouldComponentUpdate=function(e,t){return Jn(this.props,e)||Jn(this.state,t)};var si=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),si&&si(e)};var ls=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function us(e){function t(n){var r=ba({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ls,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var li=function(e,t){return e==null?null:Re(Re(e).map(t))},cs={map:li,forEach:li,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},fs=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)}fs(e,t,n,r)};var ui=O.unmount;function Ca(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=ba({},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 Ca(r,t,n)})),e}function Ia(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ia(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 an(){this.__u=0,this.o=null,this.__b=null}function Ea(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ds(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?K(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function It(){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),ui&&ui(e)},(an.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ea(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Ia(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},an.prototype.componentWillUnmount=function(){this.o=[]},an.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]=Ca(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&K(Y,null,e.fallback);return i&&(i.__u&=-33),[K(Y,null,t.__a?null:e.children),i]};var ci=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 hs(e){return this.getChildContext=function(){return e.context},e.children}function ps(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){xe(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)}}}xe(K(hs,{context:t.context},e.__v),t.v)}function gs(e,t){var n=K(ps,{__v:e,h:t});return n.containerInfo=t,n}(It.prototype=new Ne).__a=function(e){var t=this,n=Ea(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ci(t,e,r)):i()};n?n(a):a()}},It.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(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},It.prototype.componentDidUpdate=It.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ci(e,n,t)})};var Aa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ms=/^(?: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]/,_s=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ys=/[A-Z0-9]/g,bs=typeof document<\"u\",vs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function ws(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ks(e,t,n){return ha(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 fi=O.event;function Ss(){}function xs(){return this.cancelBubble}function Cs(){return this.defaultPrevented}O.event=function(e){return fi&&(e=fi(e)),e.persist=Ss,e.isPropagationStopped=xs,e.isDefaultPrevented=Cs,e.nativeEvent=e};var Cr,Is={enumerable:!1,configurable:!0,get:function(){return this.class}},di=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||bs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||vs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":_s.test(o)&&(o=u):u=o=\"oninput\":a&&ms.test(o)?o=o.replace(ys,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Is)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Aa,di&&di(e)};var hi=O.__r;O.__r=function(e){hi&&hi(e),Cr=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),Cr=null};var Es={ReactCurrentDispatcher:{current:{readContext:function(e){return Cr.__n[e.__c].props.value},useCallback:he,useContext:G,useDebugValue:ma,useDeferredValue:ka,useEffect:we,useId:_a,useImperativeHandle:ga,useInsertionEffect:xa,useLayoutEffect:ot,useMemo:de,useReducer:Sr,useRef:oe,useState:X,useSyncExternalStore:va,useTransition:Sa}}};function As(e){return K.bind(null,e)}function Sn(e){return!!e&&e.$$typeof===Aa}function Ps(e){return Sn(e)&&e.type===Y}function Ts(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ns(e){return Sn(e)?ns.apply(null,arguments):e}function Ds(e){return!!e.__k&&(xe(null,e),!0)}function $s(e){return e&&(e.base||e.nodeType===1&&e)||null}var zs=function(e,t){return e(t)},Fs=function(e,t){return e(t)},Rs=Y,Os=Sn,Jt={useState:X,useId:_a,useReducer:Sr,useEffect:we,useLayoutEffect:ot,useInsertionEffect:xa,useTransition:Sa,useDeferredValue:ka,useSyncExternalStore:va,startTransition:wa,useRef:oe,useImperativeHandle:ga,useMemo:de,useCallback:he,useContext:G,useDebugValue:ma,version:\"18.3.1\",Children:cs,render:ws,hydrate:ks,unmountComponentAtNode:Ds,createPortal:gs,createElement:K,createContext:at,createFactory:As,cloneElement:Ns,createRef:Yo,Fragment:Y,isValidElement:Sn,isElement:Os,isFragment:Ps,isMemo:Ts,findDOMNode:$s,Component:Ne,PureComponent:Zn,memo:ss,forwardRef:us,flushSync:Fs,unstable_batchedUpdates:zs,StrictMode:Rs,Suspense:an,SuspenseList:It,lazy:ds,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Es};const Ms=e=>e;function Ls(e,t=Ms){const n=Jt.useSyncExternalStore(e.subscribe,Jt.useCallback(()=>t(e.getState()),[e,t]),Jt.useCallback(()=>t(e.getInitialState()),[e,t]));return Jt.useDebugValue(n),n}const Vs=e=>{const t=os(e),n=r=>Ls(t,r);return Object.assign(n,t),n},Bs=(e=>Vs);var Ir=Symbol.for(\"immer-nothing\"),Pt=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function ae(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ge=Object,tt=ge.getPrototypeOf,$t=\"constructor\",Ht=\"prototype\",Xn=\"configurable\",hn=\"enumerable\",on=\"writable\",zt=\"value\",Me=e=>!!e&&!!e[te];function De(e){return e?Pa(e)||Ut(e)||!!e[Pt]||!!e[$t]?.[Pt]||jt(e)||Wt(e):!1}var Hs=ge[Ht][$t].toString(),gi=new WeakMap;function Pa(e){if(!e||!gt(e))return!1;const t=tt(e);if(t===null||t===ge[Ht])return!0;const n=ge.hasOwnProperty.call(t,$t)&&t[$t];if(n===Object)return!0;if(!Ge(n))return!1;let r=gi.get(n);return r===void 0&&(r=Function.toString.call(n),gi.set(n,r)),r===Hs}function qt(e,t,n=!0){nt(e)===0?(n?Reflect.ownKeys(e):ge.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function nt(e){const t=e[te];return t?t.type_:Ut(e)?1:jt(e)?2:Wt(e)?3:0}var Tt=(e,t,n=nt(e))=>n===2?e.has(t):ge[Ht].hasOwnProperty.call(e,t),ze=(e,t,n=nt(e))=>n===2?e.get(t):e[t],pn=(e,t,n,r=nt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function qs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ut=Array.isArray,jt=e=>e instanceof Map,Wt=e=>e instanceof Set,gt=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",zn=e=>typeof e==\"boolean\";function Us(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var js=e=>gt(e)?e?.[te]:null,Fe=e=>e.copy_||e.base_,Er=e=>e.modified_?e.copy_:e.base_;function er(e,t){if(jt(e))return new Map(e);if(Wt(e))return new Set(e);if(Ut(e))return Array[Ht].slice.call(e);const n=Pa(e);if(t===!0||t===\"class_only\"&&!n){const r=ge.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[on]===!1&&(s[on]=!0,s[Xn]=!0),(s.get||s.set)&&(r[o]={[Xn]:!0,[on]:!0,[hn]:s[hn],[zt]:e[o]})}return ge.create(tt(e),r)}else{const r=tt(e);if(r!==null&&n)return{...e};const i=ge.create(r);return ge.assign(i,e)}}function Ar(e,t=!1){return xn(e)||Me(e)||!De(e)||(nt(e)>1&&ge.defineProperties(e,{set:Zt,add:Zt,clear:Zt,delete:Zt}),ge.freeze(e),t&&qt(e,(n,r)=>{Ar(r,!0)},!1)),e}function Ws(){ae(2)}var Zt={[zt]:Ws};function xn(e){return e===null||!gt(e)?!0:ge.isFrozen(e)}var gn=\"MapSet\",mn=\"Patches\",mi=\"ArrayMethods\",_n={};function rt(e){const t=_n[e];return t||ae(0,e),t}var _i=e=>!!_n[e];function Qs(e,t){_n[e]||(_n[e]=t)}var Ft,Ta=()=>Ft,Ks=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:_i(gn)?rt(gn):void 0,arrayMethodsPlugin_:_i(mi)?rt(mi):void 0});function yi(e,t){t&&(e.patchPlugin_=rt(mn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function tr(e){nr(e),e.drafts_.forEach(Gs),e.drafts_=null}function nr(e){e===Ft&&(Ft=e.parent_)}var bi=e=>Ft=Ks(Ft,e);function Gs(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function vi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(tr(t),ae(4)),De(e)&&(e=wi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=wi(t,n);return Ys(t,e,!0),tr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ir?e:void 0}function wi(e,t){if(xn(t))return t;const n=t[te];if(!n)return yn(t,e.handledSet_,e);if(!Cn(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);$a(n,e)}return n.copy_}function Ys(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ar(t,n)}function Na(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Cn=(e,t)=>e.scope_===t,Js=[];function Da(e,t,n,r){const i=Fe(e),a=e.type_;if(r!==void 0&&ze(i,r,a)===t){pn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;qt(i,(u,l)=>{if(Me(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??Js;for(const s of o)pn(i,s,n,a)}function Zs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Cn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Er(a);Da(e,a.draft_??a,o,n),$a(a,i)})}function $a(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}Na(e)}}function Xs(e,t,n){const{scope_:r}=e;if(Me(n)){const i=n[te];Cn(i,r)&&i.callbacks_.push(function(){sn(e);const o=Er(i);Da(e,n,o,t)})}else De(n)&&e.callbacks_.push(function(){const a=Fe(e);e.type_===3?a.has(n)&&yn(n,r.handledSet_,r):ze(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&yn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function yn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Me(e)||t.has(e)||!De(e)||xn(e)||(t.add(e),qt(e,(r,i)=>{if(Me(i)){const a=i[te];if(Cn(a,n)){const o=Er(a);pn(e,r,o,e.type_),Na(a)}}else De(i)&&yn(i,t,n)})),e}function el(e,t){const n=Ut(e),r={type_:n?1:0,scope_:t?t.scope_:Ta(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=bn;n&&(i=[r],a=Rt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var bn={get(e,t){if(t===te)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=Fe(e);if(!Tt(i,t,e.type_))return tl(e,i,t);const a=i[t];if(e.finalized_||!De(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Us(t))return a;if(a===Fn(e.base_,t)){sn(e);const o=e.type_===1?+t:t,s=ir(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=za(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Fn(Fe(e),t),a=i?.[te];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(qs(n,i)&&(n!==void 0||Tt(e.base_,t,e.type_)))return!0;sn(e),rr(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),Xs(e,t,n)),!0},deleteProperty(e,t){return sn(e),Fn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),rr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[on]:!0,[Xn]:e.type_!==1||t!==\"length\",[hn]:r[hn],[zt]:n[t]}},defineProperty(){ae(11)},getPrototypeOf(e){return tt(e.base_)},setPrototypeOf(){ae(12)}},Rt={};for(let e in bn){let t=bn[e];Rt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Rt.deleteProperty=function(e,t){return Rt.set.call(this,e,t,void 0)};Rt.set=function(e,t,n){return bn.set.call(this,e[0],t,n,e[0])};function Fn(e,t){const n=e[te];return(n?Fe(n):e)[t]}function tl(e,t,n){const r=za(t,n);return r?zt in r?r[zt]:r.get?.call(e.draft_):void 0}function za(e,t){if(!(t in e))return;let n=tt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tt(n)}}function rr(e){e.modified_||(e.modified_=!0,e.parent_&&rr(e.parent_))}function sn(e){e.copy_||(e.assigned_=new Map,e.copy_=er(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var nl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ge(t)&&!Ge(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Ge(n)||ae(6),r!==void 0&&!Ge(r)&&ae(7);let i;if(De(t)){const a=bi(this),o=ir(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?tr(a):nr(a)}return yi(a,r),vi(i,a)}else if(!t||!gt(t)){if(i=n(t),i===void 0&&(i=t),i===Ir&&(i=void 0),this.autoFreeze_&&Ar(i,!0),r){const a=[],o=[];rt(mn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ae(1,t)},this.produceWithPatches=(t,n)=>{if(Ge(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},zn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),zn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),zn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){De(e)||ae(8),Me(e)&&(e=rl(e));const t=bi(this),n=ir(t,e,void 0);return n[te].isManual_=!0,nr(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return yi(r,t),vi(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=rt(mn).applyPatches_;return Me(e)?r(e,t):this.produce(e,i=>r(i,t))}};function ir(e,t,n,r){const[i,a]=jt(t)?rt(gn).proxyMap_(t,n):Wt(t)?rt(gn).proxySet_(t,n):el(t,n);return(n?.scope_??Ta()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Zs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function rl(e){return Me(e)||ae(10,e),Fa(e)}function Fa(e){if(!De(e)||xn(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=er(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=er(e,!0);return qt(n,(i,a)=>{pn(n,i,Fa(a))},r),t&&(t.finalized_=!1),n}function il(){function t(p,w=[]){if(p.key_!==void 0){const S=p.parent_.copy_??p.parent_.base_,y=js(ze(S,p.key_)),k=ze(S,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||y!=null&&y.base_!==p.base_)return null;const x=p.parent_.type_===3;let A;if(x){const C=p.parent_;A=Array.from(C.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(x&&S.size>A||Tt(S,A)))return null;w.push(A)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let S=p;for(let y=0;y<w.length-1;y++){const k=w[y];if(S=ze(S,k),!gt(S)||S===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return S}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,S){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:y,inversePatches_:k}=S;switch(p.type_){case 0:case 2:return u(p,w,y,k);case 1:return s(p,w,y,k);case 3:return l(p,w,y,k)}}function s(p,w,S,y){let{base_:k,assigned_:x}=p,A=p.copy_;A.length<k.length&&([k,A]=[A,k],[S,y]=[y,S]);const C=p.allIndicesReassigned_===!0;for(let _=0;_<k.length;_++){const P=A[_],T=k[_];if((C||x?.get(_.toString()))&&P!==T){const b=P?.[te];if(b&&b.modified_)continue;const N=w.concat([_]);S.push({op:r,path:N,value:c(P)}),y.push({op:r,path:N,value:c(T)})}}for(let _=k.length;_<A.length;_++){const P=w.concat([_]);S.push({op:i,path:P,value:c(A[_])})}for(let _=A.length-1;k.length<=_;--_){const P=w.concat([_]);y.push({op:a,path:P})}}function u(p,w,S,y){const{base_:k,copy_:x,type_:A}=p;qt(p.assigned_,(C,_)=>{const P=ze(k,C,A),T=ze(x,C,A),z=_?Tt(k,C)?r:i:a;if(P===T&&z===r)return;const b=w.concat(C);S.push(z===a?{op:z,path:b}:{op:z,path:b,value:c(T)}),y.push(z===i?{op:a,path:b}:z===a?{op:i,path:b,value:c(P)}:{op:r,path:b,value:c(P)})})}function l(p,w,S,y){let{base_:k,copy_:x}=p,A=0;k.forEach(C=>{if(!x.has(C)){const _=w.concat([A]);S.push({op:a,path:_,value:C}),y.unshift({op:i,path:_,value:C})}A++}),A=0,x.forEach(C=>{if(!k.has(C)){const _=w.concat([A]);S.push({op:i,path:_,value:C}),y.unshift({op:a,path:_,value:C})}A++})}function d(p,w,S){const{patches_:y,inversePatches_:k}=S;y.push({op:r,path:[],value:w===Ir?void 0:w}),k.push({op:r,path:[],value:p})}function f(p,w){return w.forEach(S=>{const{path:y,op:k}=S;let x=p;for(let P=0;P<y.length-1;P++){const T=nt(x);let z=y[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===$t)&&ae(19),Ge(x)&&z===Ht&&ae(19),x=ze(x,z),gt(x)||ae(18,y.join(\"/\"))}const A=nt(x),C=h(S.value),_=y[y.length-1];switch(k){case r:switch(A){case 2:return x.set(_,C);case 3:ae(16);default:return x[_]=C}case i:switch(A){case 1:return _===\"-\"?x.push(C):x.splice(_,0,C);case 2:return x.set(_,C);case 3:return x.add(C);default:return x[_]=C}case a:switch(A){case 1:return x.splice(_,1);case 2:return x.delete(_);case 3:return x.delete(S.value);default:return delete x[_]}default:ae(17,k)}}),p}function h(p){if(!De(p))return p;if(Ut(p))return p.map(h);if(jt(p))return new Map(Array.from(p.entries()).map(([S,y])=>[S,h(y)]));if(Wt(p))return new Set(Array.from(p).map(h));const w=Object.create(tt(p));for(const S in p)w[S]=h(p[S]);return Tt(p,Pt)&&(w[Pt]=p[Pt]),w}function c(p){return Me(p)?h(p):p}Qs(mn,{applyPatches_:f,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var Ot=new nl,al=Ot.produce,ol=Ot.produceWithPatches.bind(Ot),dt=Ot.applyPatches.bind(Ot);const sl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?al(i):i;return t(s,a,...o)},e(r.setState,n,r)),ll=sl,ul=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),cl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function fl(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 ki(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 Si(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 dl(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 bt(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=Si(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const d=e.slice(l,n);n+=2;const{display:f,target:h}=fl(d),c={type:\"link\",display:f,target:h,start:a,end:n};o&&(c.className=o),s&&(c.id=s),t.push(c),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=Si(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const f=e[d];if(f===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let h=1;const c=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(c,n);n++;const{name:w,rawArgs:S,isClose:y}=ki(p),k={type:\"macro\",name:w,rawArgs:S,isClose:y,start:a,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const f=e.slice(d,n);n++;const{name:h,rawArgs:c,isClose:p}=ki(f);t.push({type:\"macro\",name:h,rawArgs:c,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&ul.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const d=dl(e,o);o=d.endIdx;let f=cl.has(l);if(e[o]===\"/\"&&(f=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:f,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ra=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ar(e){Ra.add(e.toLowerCase())}const xi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},hl=new Set([\"if\",\"switch\",\"timed\"]);function vt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{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(xi[a]){const o=xi[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 u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if(Ra.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(hl.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 Pr(){const e=I(r=>r.variables),t=I(r=>r.temporary),n=G(Ce);return de(()=>[e,t,n],[e,t,n])}const pl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,gl=/\\{[\\$_@][\\w.]+\\}/;function ml(e){return gl.test(e)}function _l(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 yl(e,t,n,r){return e.replace(pl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let d;return o===\"$\"?d=t[l]:o===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=_l(d,u)),d==null?\"\":String(d)})}function Tr(){const[e,t,n]=Pr();return he(r=>r===void 0||!ml(r)?r:yl(r,e,t,n),[e,t,n])}function bl({name:e,scope:t,className:n,id:r}){const i=Tr();n=i(n),r=i(r);const a=G(Ce),o=e.split(\".\"),s=o[0],u=I(f=>t===\"variable\"?f.variables[s]:t===\"temporary\"?f.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let f=1;f<o.length;f++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[f];l=l[h]}const d=l==null?\"\":String(l);return n||r?v(\"span\",{id:r,class:n,children:d}):v(Y,{children:d})}function Oa(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 Ma(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let wt=!1,Qt=\"\",it=0,mt=null;function vl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Qt=n,it=0,mt=Oa(Ma(n)),wt=!0}function La(e,t){Qt=e,it=0,mt=Oa(Ma(e)),wt=!0;for(let n=0;n<t;n++)mt();it=t}function or(){wt=!1,Qt=\"\",it=0,mt=null}function vn(){return wt?{seed:Qt,pull:it}:null}function Nr(){return!wt||!mt?Math.random():(it++,mt())}function Va(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Nr()*(t-e+1))+e}function wl(){return wt}function kl(){return Qt}function Sl(){return it}const xl=500,Qe=new Map,Cl=/\\$(\\w+)/g,Il=/(?<![.\\w])_(\\w+)/g,El=/@(\\w+)/g;function Al(e){return e.replace(Cl,'variables[\"$1\"]').replace(Il,'temporary[\"$1\"]').replace(El,'locals[\"$1\"]')}function Dr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Al(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else if(l===\"\\\\\"&&r+1<e.length)u+=l+e.charAt(r+1),r++;else if(l==='\"'||l===\"'\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===l){u+=d,r++;break}else u+=d,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===\"$\"&&e.charAt(r+1)===\"{\"){u+=\"${\",r+=2;let f=1;for(;r<e.length&&f>0;){const h=e.charAt(r);h===\"{\"?f++:h===\"}\"&&f--,f>0&&(u+=h),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Dr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Pl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ba(e,t){const n=Qe.get(e);if(n)return Qe.delete(e),Qe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Pl+t);if(Qe.set(e,r),Qe.size>xl){const i=Qe.keys().next().value;i!==void 0&&Qe.delete(i)}return r}let Xt=null,Ci=null,Ii=null;function Ha(){const e=I.getState(),{visitCounts:t,renderCounts:n}=e;if(Xt&&Ci===t&&Ii===n)return Xt;const r=c=>t[c??I.getState().currentPassage]??0,i=c=>r(c)>0,a=(...c)=>c.some(p=>r(p)>0),o=(...c)=>c.every(p=>r(p)>0),s=c=>n[c??I.getState().currentPassage]??0;return Xt={currentPassage:()=>{const c=I.getState();return c.storyData?.passages.get(c.currentPassage)},previousPassage:()=>{const c=I.getState();if(c.historyIndex<=0)return;const p=c.history[c.historyIndex-1]?.passage;return p?c.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(p=>s(p)>0),hasRenderedAll:(...c)=>c.every(p=>s(p)>0),random:Nr,randomInt:Va},Ci=t,Ii=n,Xt}function In(e,t,n,r={}){const a=`return (${Dr(e)});`;return Ba(a,a)(t,n,r,Ha())}function qa(e,t,n,r={}){const i=Dr(e);Ba(\"exec:\"+i,i)(t,n,r,Ha())}function Tl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function Nl({body:e,parentValues:t,ownKeys:n}){const r=G(ce),[i,a]=X({}),o={...t,...n,...i},s=oe(o);s.current=o;const u=he(()=>s.current,[]),l=he((f,h)=>{a(c=>({...c,[f]:h}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return v(Kt.Provider,{value:d,children:v(Ce.Provider,{value:o,children:Ie(e,{nobr:r,locals:o})})})}function Dl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=G(Ce),a=G(ce),[o,s,u]=Pr(),l=r?.length?r:null;if(t.length===0||!n)return v(fr.Provider,{value:l,children:Ie(e,{nobr:a,locals:i})});const d=Tl(n),f={};for(let h=0;h<t.length;h++){const c=t[h],p=d[h];let w;if(p!==void 0)try{w=In(p,o,s,u)}catch{w=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=w}return v(fr.Provider,{value:l,children:v(Nl,{body:e,parentValues:i,ownKeys:f})})}const Ua=new Map;function ja(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");Ua.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function $l(e){return Ua.get(e.toLowerCase())}const Wa=new Map;function zl(e,t){Wa.set(e.toLowerCase(),t)}function Fl(e){return Wa.get(e.toLowerCase())}const Qa=new Set;function Rl(e){Qa.add(e.toLowerCase())}function Ol(e){return Qa.has(e.toLowerCase())}const Ei=document.createElement(\"i\");function Ka(e){const t=\"&\"+e+\";\";Ei.innerHTML=t;const n=Ei.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function _e(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 ie(e,t){return e.length>0?(_e(e,e.length,0,t),e):t}const sr={}.hasOwnProperty;function Ml(e){const t={};let n=-1;for(;++n<e.length;)Ll(t,e[n]);return t}function Ll(e,t){let n;for(n in t){const i=(sr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){sr.call(i,o)||(i[o]=[]);const s=a[o];Vl(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Vl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);_e(e,0,0,r)}function Bl(e){const t={};let n=-1;for(;++n<e.length;)Hl(t,e[n]);return t}function Hl(e,t){let n;for(n in t){const i=(sr.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 ql(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 Ul={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ga(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Ul[n]+\";\"}}function Mt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Pe=qe(/[A-Za-z]/),me=qe(/[\\dA-Za-z]/),jl=qe(/[#-'*+\\--9=?A-Z^-~]/);function lr(e){return e!==null&&(e<32||e===127)}const ur=qe(/\\d/),Wl=qe(/[\\dA-Fa-f]/),Ql=qe(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Kl=qe(/\\p{P}|\\p{S}/u),Gl=qe(/\\s/);function qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function en(e,t){const n=Ga(Yl(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 Yl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&me(e.charCodeAt(n+1))&&me(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 Ai={}.hasOwnProperty,Pi=/^(https?|ircs?|mailto|xmpp)$/i,Jl=/^https?$/i;function Zl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Bl([{enter:{blockQuote:M,codeFenced:ke,codeFencedFenceInfo:S,codeFencedFenceMeta:S,codeIndented:j,codeText:Bo,content:Po,definition:So,definitionDestinationString:Co,definitionLabelString:S,definitionTitleString:S,emphasis:Lo,htmlFlow:Mo,htmlText:Ur,image:q,label:S,link:le,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:J,reference:S,resource:ut,resourceDestinationString:ct,resourceTitleString:S,setextHeading:No,strong:Vo},exit:{atxHeading:$o,atxHeadingSequence:To,autolinkEmail:Ko,autolinkProtocol:Qo,blockQuote:Z,characterEscapeValue:St,characterReferenceMarkerHexadecimal:jr,characterReferenceMarkerNumeric:jr,characterReferenceValue:Wo,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Oo,codeIndented:g,codeText:Ho,codeTextData:St,data:St,definition:Ao,definitionDestinationString:Io,definitionLabelString:xo,definitionTitleString:Eo,emphasis:qo,hardBreakEscape:Hr,hardBreakTrailing:Hr,htmlFlow:qr,htmlFlowData:St,htmlText:qr,htmlTextData:St,image:Br,label:kt,labelText:ee,lineEnding:Ro,link:Br,listOrdered:$,listUnordered:B,paragraph:pe,reference:P,referenceString:Le,resource:P,resourceDestinationString:Nn,resourceTitleString:ko,setextHeading:Fo,setextHeadingLineSequence:zo,setextHeadingText:Do,strong:Uo,thematicBreak:jo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:S,encode:_,getData:w,lineEndingIfNeeded:C,options:t,raw:x,resume:y,setData:p,tag:k};let f=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const Se=[];let Ee=[],$e=[];for(;++F<E.length;)!f&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(f=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?Se.push(F):c(E.slice(Se.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=ie($e,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,$e),Ee=ie(Ee,E.slice(ne)),F=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const Wr=u[Ae[F][0]],Qr=Ae[F][1].type,Kr=Wr[Qr];Ai.call(Wr,Qr)&&Kr&&Kr.call({sliceSerialize:Ae[F][2].sliceSerialize,...d},Ae[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(E){const F=E.length;let ne=0,Se=0,Ee=!1,$e;for(;++ne<F;){const Ae=E[ne];if(Ae[1]._container)$e=void 0,Ae[0]===\"enter\"?Se++:Se--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Se&&($e?$e=void 0:Ee=!0);break}default:$e=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function w(E){return l[E]}function S(){i.push([])}function y(){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 A(){x(f||`\n`)}function C(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||A()}function _(E){return w(\"ignoreEncode\")?E:Ga(E)}function P(){y()}function T(E){o.push(!E._loose),C(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),C(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(w(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+_(String(F))+'\"')}}function N(){w(\"expectFirstItem\")?k(\">\"):U(),C(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),A(),k(\"</ol>\")}function B(){U(),o.pop(),A(),k(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&C(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),C(),k(\"<blockquote>\")}function Z(){o.pop(),C(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function J(){o[o.length-1]||(C(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function pe(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function ke(){C(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=y();k(' class=\"language-'+E+'\"')}function D(){const E=w(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){C(),k(\"<pre><code>\")}function g(){const E=w(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&A(),w(\"flowCodeSeenData\")&&C(),k(\"</code></pre>\"),E!==void 0&&E<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function le(){a.push({})}function ee(E){a[a.length-1].labelId=this.sliceSerialize(E)}function kt(){a[a.length-1].label=y()}function Le(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function ut(){S(),a[a.length-1].destination=\"\"}function ct(){S(),p(\"ignoreEncode\",!0)}function Nn(){a[a.length-1].destination=y(),p(\"ignoreEncode\")}function ko(){a[a.length-1].title=y()}function Br(){let E=a.length-1;const F=a[E],ne=F.referenceId||F.labelId,Se=F.destination===void 0?r[Mt(ne)]:F;for(n=!0;E--;)if(a[E].image){n=void 0;break}F.image?(k('<img src=\"'+en(Se.destination,t.allowDangerousProtocol?void 0:Jl)+'\" alt=\"'),x(F.label),k('\"')):k('<a href=\"'+en(Se.destination,t.allowDangerousProtocol?void 0:Pi)+'\"'),k(Se.title?' title=\"'+Se.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),x(F.label),k(\"</a>\")),a.pop()}function So(){S(),a.push({})}function xo(E){y(),a[a.length-1].labelId=this.sliceSerialize(E)}function Co(){S(),p(\"ignoreEncode\",!0)}function Io(){a[a.length-1].destination=y(),p(\"ignoreEncode\")}function Eo(){a[a.length-1].title=y()}function Ao(){const E=a[a.length-1],F=Mt(E.labelId);y(),Ai.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Po(){p(\"slurpAllLineEndings\",!0)}function To(E){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),C(),k(\"<h\"+w(\"headingRank\")+\">\"))}function No(){S(),p(\"slurpAllLineEndings\")}function Do(){p(\"slurpAllLineEndings\",!0)}function $o(){k(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function zo(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function Fo(){const E=y();C(),k(\"<h\"+w(\"headingRank\")+\">\"),x(E),k(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function St(E){x(_(this.sliceSerialize(E)))}function Ro(E){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){x(\" \");return}x(_(this.sliceSerialize(E)))}}function Oo(E){x(_(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Hr(){k(\"<br />\")}function Mo(){C(),Ur()}function qr(){p(\"ignoreEncode\")}function Ur(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Lo(){k(\"<em>\")}function Vo(){k(\"<strong>\")}function Bo(){p(\"inCodeText\",!0),k(\"<code>\")}function Ho(){p(\"inCodeText\"),k(\"</code>\")}function qo(){k(\"</em>\")}function Uo(){k(\"</strong>\")}function jo(){C(),k(\"<hr />\")}function jr(E){p(\"characterReferenceType\",E.type)}function Wo(E){const F=this.sliceSerialize(E),ne=w(\"characterReferenceType\")?ql(F,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ka(F);x(_(ne)),p(\"characterReferenceType\")}function Qo(E){const F=this.sliceSerialize(E);k('<a href=\"'+en(F,t.allowDangerousProtocol?void 0:Pi)+'\">'),x(_(F)),k(\"</a>\")}function Ko(E){const F=this.sliceSerialize(E);k('<a href=\"'+en(\"mailto:\"+F)+'\">'),x(_(F)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Xl={tokenize:eu};function eu(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 u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const tu={tokenize:nu},Ti={tokenize:ru};function nu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let C=A,_;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){_=t.events[C][1].end;break}y(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={..._},P++;return _e(t.events,C+1,0,t.events.slice(A)),t.events.length=P,l(x)}return s(x)}function l(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(Ti,d,f)(x)}function d(x){return i&&k(),y(r),h(x)}function f(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(Ti,c,p)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function p(x){if(x===null){i&&k(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(x)}function w(x){if(x===null){S(e.exit(\"chunkFlow\"),!0),y(0),e.consume(x);return}return R(x)?(e.consume(x),S(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),w)}function S(x,A){const C=t.sliceStream(x);if(A&&C.push(null),x.previous=a,a&&(a.next=x),a=x,i.defineSkip(x.start),i.write(C),t.parser.lazy[x.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(y(r),_=P;_<t.events.length;)t.events[_][1].end={...b},_++;_e(t.events,T+1,0,t.events.slice(P)),t.events.length=_}}function y(x){let A=n.length;for(;A-- >x;){const C=n[A];t.containerState=C[1],C[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 ru(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 wn(e){if(e===null||se(e)||Gl(e))return 1;if(Kl(e))return 2}function En(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 cr={name:\"attention\",resolveAll:iu,tokenize:au};function iu(e,t){let n=-1,r,i,a,o,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Ni(f,-u),Ni(h,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:f,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ie(l,En(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,_e(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function au(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=wn(u),f=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?f:f&&(i||!h)),l._close=!!(a===42?h:h&&(d||!f)),t(u)}}function Ni(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ou={name:\"autolink\",tokenize:su};function su(e,t,n){let r=0;return i;function i(c){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(c){return Pe(c)?(e.consume(c),o):c===64?n(c):l(c)}function o(c){return c===43||c===45||c===46||me(c)?(r=1,s(c)):l(c)}function s(c){return c===58?(e.consume(c),r=0,u):(c===43||c===45||c===46||me(c))&&r++<32?(e.consume(c),s):(r=0,l(c))}function u(c){return c===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):c===null||c===32||c===60||lr(c)?n(c):(e.consume(c),u)}function l(c){return c===64?(e.consume(c),d):jl(c)?(e.consume(c),l):n(c)}function d(c){return me(c)?f(c):n(c)}function f(c){return c===46?(e.consume(c),r=0,d):c===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(c)}function h(c){if((c===45||me(c))&&r++<63){const p=c===45?h:f;return e.consume(c),p}return n(c)}}const An={partial:!0,tokenize:lu};function lu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const Ya={continuation:{tokenize:cu},exit:fu,name:\"blockQuote\",tokenize:uu};function uu(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 cu(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(Ya,t,n)(o)}}function fu(e){e.exit(\"blockQuote\")}const Ja={name:\"characterEscape\",tokenize:du};function du(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 Ql(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Za={name:\"characterReference\",tokenize:hu};function hu(e,t,n){const r=this;let i=0,a,o;return s;function s(f){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),u}function u(f){return f===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(f),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=me,d(f))}function l(f){return f===88||f===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(f),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Wl,d):(e.enter(\"characterReferenceValue\"),a=7,o=ur,d(f))}function d(f){if(f===59&&i){const h=e.exit(\"characterReferenceValue\");return o===me&&!Ka(r.sliceSerialize(h))?n(f):(e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(f)&&i++<a?(e.consume(f),d):n(f)}}const Di={partial:!0,tokenize:gu},$i={concrete:!0,name:\"codeFenced\",tokenize:pu};function pu(e,t,n){const r=this,i={partial:!0,tokenize:C};let a=0,o=0,s;return u;function u(_){return l(_)}function l(_){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=_,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(_)}function d(_){return _===s?(o++,e.consume(_),d):o<3?n(_):(e.exit(\"codeFencedFenceSequence\"),L(_)?H(e,f,\"whitespace\")(_):f(_))}function f(_){return _===null||R(_)?(e.exit(\"codeFencedFence\"),r.interrupt?t(_):e.check(Di,w,A)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(_)):L(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,c,\"whitespace\")(_)):_===96&&_===s?n(_):(e.consume(_),h)}function c(_){return _===null||R(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),p)}function w(_){return e.attempt(i,A,S)(_)}function S(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return a>0&&L(_)?H(e,k,\"linePrefix\",a+1)(_):k(_)}function k(_){return _===null||R(_)?e.check(Di,w,A)(_):(e.enter(\"codeFlowValue\"),x(_))}function x(_){return _===null||R(_)?(e.exit(\"codeFlowValue\"),k(_)):(e.consume(_),x)}function A(_){return e.exit(\"codeFenced\"),t(_)}function C(_,P,T){let z=0;return b;function b(M){return _.enter(\"lineEnding\"),_.consume(M),_.exit(\"lineEnding\"),N}function N(M){return _.enter(\"codeFencedFence\"),L(M)?H(_,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(_.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,_.consume(M),B):z>=o?(_.exit(\"codeFencedFenceSequence\"),L(M)?H(_,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(_.exit(\"codeFencedFence\"),P(M)):T(M)}}}function gu(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 Rn={name:\"codeIndented\",tokenize:_u},mu={partial:!0,tokenize:yu};function _u(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(mu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function yu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(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):R(o)?i(o):n(o)}}const bu={name:\"codeText\",previous:wu,resolve:vu,tokenize:ku};function vu(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 wu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function ku(e,t,n){let r=0,i,a;return o;function o(f){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(f)}function s(f){return f===96?(e.consume(f),r++,s):(e.exit(\"codeTextSequence\"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter(\"space\"),e.consume(f),e.exit(\"space\"),u):f===96?(a=e.enter(\"codeTextSequence\"),i=0,d(f)):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(f))}function l(f){return f===null||f===32||f===96||R(f)?(e.exit(\"codeTextData\"),u(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(f)):(a.type=\"codeTextData\",l(f))}}class Su{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&&xt(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),xt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),xt(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);xt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);xt(this.left,n.reverse())}}}function xt(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 Xa(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new Su(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,xu(d,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(d.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={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function xu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let d,f,h=-1,c=n,p=0,w=0;const S=[w];for(;c;){for(;e.get(++i)[1]!==c;);a.push(i),c._tokenizer||(d=r.sliceStream(c),c.next||d.push(null),f&&o.defineSkip(c.start),c._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),c._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=c,c=c.next}for(c=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&&(w=h+1,S.push(w),c._tokenizer=void 0,c.previous=void 0,c=c.next);for(o.events=[],c?(c._tokenizer=void 0,c.previous=void 0):S.pop(),h=S.length;h--;){const y=s.slice(S[h],S[h+1]),k=a.pop();u.push([k,k+y.length-1]),e.splice(k,2,y)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const Cu={resolve:Eu,tokenize:Au},Iu={partial:!0,tokenize:Pu};function Eu(e){return Xa(e),e}function Au(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):R(s)?e.check(Iu,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 Pu(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||R(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 eo(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(y),e.exit(a),h):y===null||y===32||y===41||lr(y)?n(y):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(y))}function h(y){return y===62?(e.enter(a),e.consume(y),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),c(y))}function c(y){return y===62?(e.exit(\"chunkString\"),e.exit(s),h(y)):y===null||y===60||R(y)?n(y):(e.consume(y),y===92?p:c)}function p(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function w(y){return!d&&(y===null||y===41||se(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(y)):d<l&&y===40?(e.consume(y),d++,w):y===41?(e.consume(y),d--,w):y===null||y===32||y===40||lr(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function to(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(c){return e.enter(r),e.enter(i),e.consume(c),e.exit(i),e.enter(a),d}function d(c){return s>999||c===null||c===91||c===93&&!u||c===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(c):c===93?(e.exit(a),e.enter(i),e.consume(c),e.exit(i),e.exit(r),t):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),f(c))}function f(c){return c===null||c===91||c===93||R(c)||s++>999?(e.exit(\"chunkString\"),d(c)):(e.consume(c),u||(u=!L(c)),c===92?h:f)}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function no(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,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(e.consume(h),d):d(h)}}function Nt(e,t){let n;return r;function r(i){return R(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 Tu={name:\"definition\",tokenize:Du},Nu={partial:!0,tokenize:$u};function Du(e,t,n){const r=this;let i;return a;function a(c){return e.enter(\"definition\"),o(c)}function o(c){return to.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(c)}function s(c){return i=Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),c===58?(e.enter(\"definitionMarker\"),e.consume(c),e.exit(\"definitionMarker\"),u):n(c)}function u(c){return se(c)?Nt(e,l)(c):l(c)}function l(c){return eo(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt(Nu,f,f)(c)}function f(c){return L(c)?H(e,h,\"whitespace\")(c):h(c)}function h(c){return c===null||R(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function $u(e,t,n){return r;function r(s){return se(s)?Nt(e,i)(s):n(s)}function i(s){return no(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||R(s)?t(s):n(s)}}const zu={name:\"hardBreakEscape\",tokenize:Fu};function Fu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Ru={name:\"headingAtx\",resolve:Ou,tokenize:Mu};function Ou(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\"},_e(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Mu(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),a(d)}function a(d){return e.enter(\"atxHeadingSequence\"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||se(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||se(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Lu=[\"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\"],zi=[\"pre\",\"script\",\"style\",\"textarea\"],Vu={concrete:!0,name:\"htmlFlow\",resolveTo:qu,tokenize:Uu},Bu={partial:!0,tokenize:Wu},Hu={partial:!0,tokenize:ju};function qu(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 Uu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),f}function f(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),o=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,p):Pe(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function c(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:$:p):n(g)}function w(g){return Pe(g)?(e.consume(g),o=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||se(g)){const q=g===47,le=o.toLowerCase();return!q&&!a&&zi.includes(le)?(i=1,r.interrupt?t(g):$(g)):Lu.includes(o.toLowerCase())?(i=6,q?(e.consume(g),y):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?k(g):x(g))}return g===45||me(g)?(e.consume(g),o+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):b(g)}function x(g){return g===47?(e.consume(g),b):g===58||g===95||Pe(g)?(e.consume(g),A):L(g)?(e.consume(g),x):b(g)}function A(g){return g===45||g===46||g===58||g===95||me(g)?(e.consume(g),A):C(g)}function C(g){return g===61?(e.consume(g),_):L(g)?(e.consume(g),C):x(g)}function _(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),_):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||se(g)?C(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?x(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),J):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Bu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Hu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function J(g){return g===47?(e.consume(g),o=\"\",pe):$(g)}function pe(g){if(g===62){const q=o.toLowerCase();return zi.includes(q)?(e.consume(g),D):$(g)}return Pe(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),pe):$(g)}function ke(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function ju(e,t,n){const r=this;return i;function i(o){return R(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 Wu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(An,t,n)}}const Qu={name:\"htmlText\",tokenize:Ku};function Ku(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),C):m===63?(e.consume(m),x):Pe(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,p):Pe(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),c):n(m)}function f(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=f,J(m)):(e.consume(m),f)}function h(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?h(m):f(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(a++)?(e.consume(m),a===D.length?w:p):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):R(m)?(o=w,J(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):w(m)}function k(m){return m===null||m===62?Z(m):R(m)?(o=k,J(m)):(e.consume(m),k)}function x(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(o=x,J(m)):(e.consume(m),x)}function A(m){return m===62?Z(m):x(m)}function C(m){return Pe(m)?(e.consume(m),_):n(m)}function _(m){return m===45||me(m)?(e.consume(m),_):P(m)}function P(m){return R(m)?(o=P,J(m)):L(m)?(e.consume(m),P):Z(m)}function T(m){return m===45||me(m)?(e.consume(m),T):m===47||m===62||se(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Pe(m)?(e.consume(m),b):R(m)?(o=z,J(m)):L(m)?(e.consume(m),z):Z(m)}function b(m){return m===45||m===46||m===58||m===95||me(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(o=N,J(m)):L(m)?(e.consume(m),N):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(o=$,J(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,J(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||se(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||se(m)?z(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function J(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),pe}function pe(m){return L(m)?H(e,ke,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ke(m)}function ke(m){return e.enter(\"htmlTextData\"),o(m)}}const $r={name:\"labelEnd\",resolveAll:Zu,resolveTo:Xu,tokenize:ec},Gu={tokenize:tc},Yu={tokenize:nc},Ju={tokenize:rc};function Zu(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&&_e(e,0,e.length,n),e}function Xu(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},d={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(a+1,a+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,En(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ie(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ie(s,e.slice(o+1)),s=ie(s,[[\"exit\",u,t]]),_e(e,a,e.length,s),e}function ec(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?f(h):(o=r.parser.defined.includes(Mt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Gu,d,o?d:f)(h):h===91?e.attempt(Yu,d,o?l:f)(h):o?d(h):f(h)}function l(h){return e.attempt(Ju,d,f)(h)}function d(h){return t(h)}function f(h){return a._balanced=!0,n(h)}}function tc(e,t,n){return r;function r(f){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),i}function i(f){return se(f)?Nt(e,a)(f):a(f)}function a(f){return f===41?d(f):eo(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function o(f){return se(f)?Nt(e,u)(f):d(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?no(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):d(f)}function l(f){return se(f)?Nt(e,d)(f):d(f)}function d(f){return f===41?(e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(f)}}function nc(e,t,n){const r=this;return i;function i(s){return to.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function rc(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 ic={name:\"labelStartImage\",resolveAll:$r.resolveAll,tokenize:ac};function ac(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 oc={name:\"labelStartLink\",resolveAll:$r.resolveAll,tokenize:sc};function sc(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 On={name:\"lineEnding\",tokenize:lc};function lc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const ln={name:\"thematicBreak\",tokenize:uc};function uc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const fe={continuation:{tokenize:hc},exit:gc,name:\"list\",tokenize:dc},cc={partial:!0,tokenize:mc},fc={partial:!0,tokenize:pc};function dc(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(c){const p=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:ur(c)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),c===42||c===45?e.check(ln,n,l)(c):l(c);if(!r.interrupt||c===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(c)}return n(c)}function u(c){return ur(c)&&++o<10?(e.consume(c),u):(!r.interrupt||o<2)&&(r.containerState.marker?c===r.containerState.marker:c===41||c===46)?(e.exit(\"listItemValue\"),l(c)):n(c)}function l(c){return e.enter(\"listItemMarker\"),e.consume(c),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||c,e.check(An,r.interrupt?n:d,e.attempt(cc,h,f))}function d(c){return r.containerState.initialBlankLine=!0,a++,h(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),h):n(c)}function h(c){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function hc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(An,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(fc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(fe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function pc(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 gc(e){e.exit(this.containerState.type)}function mc(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 Fi={name:\"setextUnderline\",resolveTo:_c,tokenize:yc};function _c(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 yc(e,t,n){const r=this;let i;return a;function a(l){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){f=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const bc={tokenize:vc};function vc(e){const t=this,n=e.attempt(An,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Cu,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 wc={resolveAll:io()},kc=ro(\"string\"),Sc=ro(\"text\");function ro(e){return{resolveAll:io(e===\"text\"?xc: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(d){return l(d)?a(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),a(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const c=f[h];if(!c.previous||c.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 xc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const Cc={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:Ya},Ic={91:Tu},Ec={[-2]:Rn,[-1]:Rn,32:Rn},Ac={35:Ru,42:ln,45:[Fi,ln],60:Vu,61:Fi,95:ln,96:$i,126:$i},Pc={38:Za,92:Ja},Tc={[-5]:On,[-4]:On,[-3]:On,33:ic,38:Za,42:cr,60:[ou,Qu],91:oc,92:[zu,Ja],93:$r,95:cr,96:bu},Nc={null:[cr,wc]},Dc={null:[42,95]},$c={null:[]},zc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Dc,contentInitial:Ic,disable:$c,document:Cc,flow:Ac,flowInitial:Ec,insideSpan:Nc,string:Pc,text:Tc},Symbol.toStringTag,{value:\"Module\"}));function Fc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(C),check:P(_),consume:k,enter:x,exit:A,interrupt:P(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:c,write:f};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function f(N){return o=ie(o,N),S(),o[o.length-1]!==null?[]:(T(t,0),l.events=En(a,l.events,l),l.events)}function h(N,$){return Oc(c(N),$)}function c(N){return Rc(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:M}}function w(N){i[N.line]=N.column,b()}function S(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)y($.charCodeAt(r._bufferIndex));else y($)}}function y(N){d=d(N)}function k(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-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=N}function x(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function C(N,$){T(N,$.from)}function _(N,$){$.restore()}function P(N,$){return B;function B(U,M,Z){let J,pe,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(ee){return kt;function kt(Le){const ut=Le!==null&&ee[Le],ct=Le!==null&&ee.null,Nn=[...Array.isArray(ut)?ut:ut?[ut]:[],...Array.isArray(ct)?ct:ct?[ct]:[]];return j(Nn)(Le)}}function j(ee){return J=ee,pe=0,ee.length===0?Z:g(ee[pe])}function g(ee){return kt;function kt(Le){return m=z(),ke=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?le():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,le)(Le)}}function q(ee){return N(ke,m),M}function le(ee){return m.restore(),++pe<J.length?g(J[pe]):Z}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&_e(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Rc(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 Oc(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 Mc(e){const r={constructs:Ml([zc,...(e||{}).extensions||[]]),content:i(Xl),defined:[],document:i(tu),flow:i(bc),lazy:{},string:i(kc),text:i(Sc)};return r;function i(a){return o;function o(s){return Fc(r,a,s)}}}function Lc(e){for(;!Xa(e););return e}const Ri=/[\\0\\t\\n\\r]/g;function Vc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,f,h,c;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),f=0,t=\"\",n&&(a.charCodeAt(0)===65279&&f++,n=void 0);f<a.length;){if(Ri.lastIndex=f,l=Ri.exec(a),h=l&&l.index!==void 0?l.index:a.length,c=a.charCodeAt(h),!l){t=a.slice(f);break}if(c===10&&f===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<h&&(u.push(a.slice(f,h)),e+=h-f),c){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Bc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Zl(n)(Lc(Mc(n).document().write(Vc()(e,t,!0))))}const Mn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Hc(){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=Mn[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=Mn[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,qc)),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\"+Mn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function qc(e,t){return t===\"|\"?t:e}class Uc{constructor(){this.map=[]}add(t,n,r){jc(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function jc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Wc(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 Qc(){return{flow:{null:{name:\"table\",tokenize:Kc,resolveAll:Gc}}}}function Kc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?_:u;return B===_&&r.parser.lazy[r.now().line]?n(b):B(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),d(b)}function d(b){return b===null?n(b):R(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),c):n(b):L(b)?H(e,d,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,d):(e.enter(\"data\"),f(b)))}function f(b){return b===null||b===124||se(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:f)}function h(b){return b===92||b===124?(e.consume(b),f):f(b)}function c(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?S(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):C(b)}function w(b){return L(b)?H(e,S,\"whitespace\")(b):S(b)}function S(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),y):b===45?(a+=1,y(b)):b===null||R(b)?A(b):C(b)}function y(b){return b===45?(e.enter(\"tableDelimiterFiller\"),k(b)):C(b)}function k(b){return b===45?(e.consume(b),k):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(b))}function x(b){return L(b)?H(e,A,\"whitespace\")(b):A(b)}function A(b){return b===124?p(b):b===null||R(b)?!o||i!==a?C(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):C(b)}function C(b){return n(b)}function _(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||se(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Gc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,f;const h=new Uc;for(;++n<e.length;){const c=e[n],p=c[1];c[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Oi(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,f=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=tn(h,t,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=tn(h,t,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],f=tn(h,t,a,i,n,f)):o[1]!==0&&(f=tn(h,t,o,i,n,f)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Oi(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=Wc(t.events,n))}return e}function tn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},ft(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=ft(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=ft(t.events,n[2]),d=ft(t.events,n[3]),f={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",f,t]]),r!==2){const h=t.events[n[2]],c=t.events[n[3]];if(h[1].end=Object.assign({},c[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",f,t]])}return i!==void 0&&(a.end=Object.assign({},ft(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Oi(e,t,n,r,i){const a=[],o=ft(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 ft(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Yc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Jc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},f={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},h=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(h,h.length,0,En(c,o.slice(l+1,u),s)),_e(h,h.length,0,[[\"exit\",f,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",d,s]]),_e(o,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,d=this.events;let f=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),c(p))}function c(p){const w=wn(l);if(p===126)return f>1?u(p):(o.consume(p),f++,c);if(f<2&&!n)return u(p);const S=o.exit(\"strikethroughSequenceTemporary\"),y=wn(p);return S._open=!y||y===2&&!!w,S._close=!w||w===2&&!!y,s(p)}}}function Zc(e){return Bc(e,{allowDangerousHtml:!0,extensions:[Qc(),Jc(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Hc(),Yc()]})}const Xc={update:()=>{},getValues:()=>({})},Ce=at({}),Kt=at(Xc),ce=at(!1),fr=at(null);function ef(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>ao(a,o,t));return v(Y,{children:i})}function ao(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 u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>ao(u,l,n));return K(i,o,...s)}return null}function tf({node:e}){const t=Tr(),n=G(ce),r=G(Ce),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return K(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function nf(){const e=G(fr),t=G(ce),n=G(Ce);return!e||e.length===0?null:v(Y,{children:Ie(e,{nobr:t,locals:n})})}function rf(e,t){if(Ol(e.name))return null;const n=$l(e.name);if(n)return v(Dl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=Fl(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 dr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?v(nf,{},t):v(bl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return rf(e,t);case\"html\":return v(tf,{node:e},t);default:return e}}function oo(e){return e.length===0?null:e.map((t,n)=>dr(t,n))}function af(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=I.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>dr(s,u));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&af(i))i+=of(u,a);else{const l=r.length;r.push(dr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=Zc(i);return ef(o,r,t?.nobr)}function sf(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 lf(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\")}const uf=\"spindle\",cf=1;let nn=null,Ln=null;function Ue(){return Ln||(Ln={saves:new Map,playthroughs:new Map,meta:new Map}),Ln}function ff(){return nn||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(nn=new Promise((e,t)=>{const n=indexedDB.open(uf,cf);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),nn))}function je(e,t){return ff().then(n=>n.transaction(e,t).objectStore(e))}function We(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function Pn(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.put(e))}catch{Ue().saves.set(e.meta.id,e)}}async function Gt(e){try{const t=await je(\"saves\",\"readonly\");return await We(t.get(e))??void 0}catch{return Ue().saves.get(e)}}async function df(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.delete(e))}catch{Ue().saves.delete(e)}}async function hf(e){try{const n=(await je(\"saves\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().saves.values()].filter(t=>t.meta.ifid===e)}}async function so(e){try{const t=await je(\"playthroughs\",\"readwrite\");await We(t.put(e))}catch{Ue().playthroughs.set(e.id,e)}}async function zr(e){try{const n=(await je(\"playthroughs\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().playthroughs.values()].filter(t=>t.ifid===e)}}async function _t(e){try{const t=await je(\"meta\",\"readonly\"),n=await We(t.get(e));return n?n.value:void 0}catch{return Ue().meta.get(e)}}async function hr(e,t){try{const n=await je(\"meta\",\"readwrite\");await We(n.put({key:e,value:t}))}catch{Ue().meta.set(e,t)}}const lo=new Map,Tn=new Map;function pf(e,t){lo.set(e,t),Tn.set(t,e)}function gf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[u,l]of r)s.set(n(u),n(l));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const u of r)s.add(n(u));return s}const a=i.constructor;if(Tn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(gf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Ye=\"__spindle_class__\",Je=\"__spindle_data__\";function Xe(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),{[Ye]:\"__Date__\",[Je]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Ye]:\"__RegExp__\",[Je]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}if(r instanceof Map){const u=[...r].map(([l,d])=>[n(l),n(d)]);return t.delete(i),{[Ye]:\"__Map__\",[Je]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[Ye]:\"__Set__\",[Je]:{entries:u}}}const a=i.constructor,o=Tn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Ye]:o,[Je]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function et(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(Ye in r&&Je in r){const o=r[Ye],s=r[Je];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const d=s.entries;return new Map(d.map(([f,h])=>[t(f),t(h)]))}if(o===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=lo.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const d={};for(const f of Object.keys(s))d[f]=t(s[f]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(Tn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let pr=null,gr=null,Mi=!1;function mf(e){pr=e}function _f(e){gr=e}function yf(e){if(gr)try{const i=new Function(\"passage\",\"variables\",gr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(pr)try{const r=pr(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 bf(){Mi||(Mi=!0)}async function Li(e){const n=(await zr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await so(i),await hr(`currentPlaythroughId.${e}`,r),r}async function vf(e){return _t(`currentPlaythroughId.${e}`)}async function uo(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:yf(n),passage:n.passage,custom:r},o=re(n);o.variables=Xe(o.variables),o.history=o.history.map(u=>({...u,variables:Xe(u.variables)}));const s={meta:a,payload:o};return await Pn(s),s}async function co(e,t){const n=await Gt(e);if(!n)return;const r=re(t);r.variables=Xe(r.variables),r.history=r.history.map(a=>({...a,variables:Xe(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await Pn(i),i}async function wf(e){const t=await Gt(e);if(!t)return;const n=t.payload;return n.variables=et(n.variables),n.history=n.history.map(r=>({...r,variables:et(r.variables)})),n}async function kf(e){await df(e)}async function Sf(e,t){const n=await Gt(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await Pn(r)}async function xf(e){const[t,n]=await Promise.all([hf(e),zr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const Cf=\"autosave.\",If=\"slot.\",fo=\"slotIndex.\";function Fr(e,t){return t!=null?`${If}${t}.${e}`:`${Cf}${e}`}async function Ef(e,t,n,r){const i=Fr(e,r),a=await _t(i);if(a){const s=await co(a,n);if(s)return s}const o=await uo(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{}});if(await hr(i,o.meta.id),r!=null){const s=`${fo}${e}`,u=await _t(s)??[];u.includes(r)||await hr(s,[...u,r])}return o}async function Vi(e,t){const n=Fr(e,t),r=await _t(n);return r?await Gt(r)!==void 0:!1}async function Af(e,t){const n=Fr(e,t),r=await _t(n);if(r)return wf(r)}async function Pf(e){const t={};await Vi(e)&&(t[\"\"]=!0);const n=`${fo}${e}`,r=await _t(n)??[];for(const i of r)await Vi(e,i)&&(t[i]=!0);return t}const Rr=\"spindle.session.\";function Tf(e,t){try{sessionStorage.setItem(`${Rr}${e}`,JSON.stringify(t))}catch{}}function Nf(e){try{const t=sessionStorage.getItem(`${Rr}${e}`);if(!t)return;const n=JSON.parse(t);if(!lf(n))return;const r=n;return r.variables=et(r.variables),r.history=r.history.map(i=>({...i,variables:et(i.variables)})),r}catch{return}}function Df(e){try{sessionStorage.removeItem(`${Rr}${e}`)}catch{}}async function $f(e){const t=await Gt(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function zf(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=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await zr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await so(a)}return await Pn(n),n}function ho(){const e=I.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=bt(t.content),i=vt(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),xe(K(()=>Ie(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&_f(n.content)}let po=0,ve=[],Vn=!1,st=[],Dt=null,Oe=null;function Or(e){const t=I.getState();try{return!!In(e,t.variables,t.temporary)}catch{return!1}}function go(e,t){const n=po++,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:Or(e),priority:i?.priority??0};return ve.push(o),ve.sort((s,u)=>u.priority-s.priority),()=>{ve=ve.filter(s=>s.id!==n)}}function mo(e){ve=ve.filter(t=>t.name!==e)}function Ff(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=I.getState();qa(n.run,r.variables,r.temporary)}n.dialog&&(st.push({passageName:n.dialog}),Dt?.()),n.goto&&I.getState().navigate(n.goto)}}const Rf=10;function Of(){if(!Vn){Vn=!0;try{for(let e=0;e<Rf;e++){let t=!1;const n=[...ve];for(const r of n){if(!ve.includes(r))continue;const i=Or(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ve=ve.filter(o=>o.id!==r.id)),Ff(r))}if(!t)break}}finally{Vn=!1}}}function Mf(){for(const e of ve)e.lastResult=Or(e.condition)}function Lf(){ve=[],st=[],po=0,Oe?.closeAll()}function Vf(e){return Dt=e,st.length>0&&e(),()=>{Dt===e&&(Dt=null)}}function Bf(){return st.shift()}function Hf(){return st.length}function qf(e){Oe?Oe.push(e):(st.push(e),Dt?.())}function Uf(){st=[]}function jf(e){return Oe=e,()=>{Oe===e&&(Oe=null)}}function Wf(){Oe?.close()}function Qf(){Uf(),Oe?.closeAll()}function Kf(){return Oe?.isOpen()??!1}il();const Gf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ze={},ye=[],Ve={};function Bi(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Hi(e,t){const[,n,r]=ol(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:Bi(n),inverse:Bi(r)}}function Yf(e){let t=Ze;for(let n=0;n<e;n++)t=dt(t,ye[n].forward);return t}let be=[];function Bn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(be.length>i.length&&(be.length=i.length),be.length<i.length)if(i.length-be.length===1){const l=i.length-1;be[l]={passage:i[l].passage,variables:Xe(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ze;for(let d=0;d<i.length;d++)if(d>0&&(l=dt(l,ye[d-1].forward)),d>=be.length){const f=d===i.length-1?r:l;be[d]={passage:i[d].passage,variables:Xe(f),timestamp:i[d].timestamp,prng:i[d].prng}}}Tf(t.ifid,{passage:n,variables:Xe(r),history:be,historyIndex:a,visitCounts:o,renderCounts:s,prng:vn()})}}function qi(e){Ze=e,ye=[],Ve=e,be=[]}function Ui(e){e?.prng?La(e.prng.seed,e.prng.pull):e&&or()}const I=Bs()(ll((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=re(r);qi(re(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Ve=t().variables;const o=n.ifid;bf().then(async()=>{const s=await vf(o);if(s)e(l=>{l.playthroughId=s});else{const l=await Li(o);e(d=>{d.playthroughId=l})}const u=await Pf(o);Object.keys(u).length>0&&e(l=>{l.knownSaves=u})}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Gf.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=Hi(Ve,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),ye.length=o.historyIndex,ye.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:vn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ze=dt(Ze,ye[u].forward);o.history=o.history.slice(s),ye=ye.slice(s),be=be.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Ve=t().variables,Bn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(dt(r,ye[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Ve=t().variables,Ui(t().history[t().historyIndex]),Bn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=re(dt(i,ye[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Ve=t().variables,Ui(t().history[t().historyIndex]),Bn(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;or(),Lf();const a=re(r);qi(re(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Ve=t().variables,ho(),Df(n.ifid),Li(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:n=>{const{storyData:r,playthroughId:i}=t();if(!r)return;const a=t().getSavePayload();e(o=>{o.saveError=null}),Ef(r.ifid,i,a,n).then(()=>{e(o=>{o.knownSaves={...o.knownSaves,[n??\"\"]:!0}})}).catch(o=>{console.error(\"spindle: failed to save\",o),e(s=>{s.saveError=o instanceof Error?o.message:\"Failed to save\"})})},load:n=>{const{storyData:r}=t();r&&(e(i=>{i.loadError=null}),Af(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},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Ze;for(let d=0;d<i.length;d++)d>0&&(l=dt(l,ye[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:vn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=et(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=et(n.history[o].variables);i.push(Hi(a,s)),a=s}Ze=re(r),ye=i,be=[],e(o=>{o.currentPassage=n.passage,o.variables=et(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={}}),Ve=t().variables,n.prng?La(n.prng.seed,n.prng.pull):or()},getHistoryVariables:n=>re(Yf(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}}))),Jf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Zf(){const t=I(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Jf,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const a=bt(n),o=vt(a);return v(Y,{children:oo(o)})}catch(a){return v(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?v(ce.Provider,{value:!0,children:i}):i}const _o=at(null);function Mr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=oe(r);a.current=r;const o=he(()=>a.current(),[]),s=I(c=>c.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,d=de(()=>{if(!l)return v(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=bt(l),p=vt(c);return Ie(p)}catch(c){return v(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&o()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return v(_o.Provider,{value:o,children:v(\"div\",{class:\"dialog-overlay\",onClick:f,children:v(\"div\",{class:h,children:[i&&v(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),v(\"div\",{class:\"dialog-body\",children:d})]})})})}function Xf(){const[e,t]=X([]),n=oe(e);n.current=e;const r=he(o=>{t(s=>[...s,o])},[]),i=he(()=>{t(o=>o.slice(0,-1))},[]),a=he(()=>{t([])},[]);return we(()=>jf({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),we(()=>Vf(()=>{const o=[];for(;Hf()>0;){const s=Bf();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:v(Y,{children:e.map((o,s)=>v(Mr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function ed(){const e=I(i=>i.storyData),t=I(i=>i.currentPassage),n=I(i=>i.nobr);if(we(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),I.getState().save()):a.key===\"F9\"&&(a.preventDefault(),I.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return v(\"div\",{class:\"loading\",children:\"Loading...\"});const r=v(Y,{children:[v(Zf,{}),v(Xf,{})]});return n?v(ce.Provider,{value:!0,children:r}):r}function td(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function nd(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,f=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",w=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),S=td(h.innerHTML),y={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)k.has(A.name)||(y[A.name]=A.value);const x={pid:c,name:p,tags:w,metadata:y,content:S};d.set(p,x),f.set(c,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:d,passagesById:f,userCSS:s,userScript:l}}const Ct=new Map;let ue={},ji=!1;function yo(){return`spindle.${I.getState().storyData?.ifid||\"unknown\"}.settings`}function rd(){localStorage.setItem(yo(),JSON.stringify(ue))}function Hn(){if(!ji){ji=!0;try{const e=localStorage.getItem(yo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ue={...ue,...t})}}catch{}}}const Lt={addToggle(e,t){Ct.set(e,{type:\"toggle\",config:t}),e in ue||(ue[e]=t.default),Hn()},addList(e,t){Ct.set(e,{type:\"list\",config:t}),e in ue||(ue[e]=t.default),Hn()},addRange(e,t){Ct.set(e,{type:\"range\",config:t}),e in ue||(ue[e]=t.default),Hn()},get(e){return ue[e]},getToggle(e){const t=ue[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ue[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ue[e];return typeof t==\"number\"?t:0},set(e,t){ue[e]=t,rd()},getAll(){return{...ue}},getDefinitions(){return Ct},hasAny(){return Ct.size>0}};function id(e,t,n){const r=I.getState(),i=re(r.variables),a=re(r.temporary),o={...t};qa(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(s,o[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const kn=new Map,mr=new Set,_r=new Map;function ad(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(_r.get(r)??0)+1;return _r.set(r,i),i===1?r:`${r}:${i}`}function od(e){return kn.set(e.id,e),Qi(),()=>{kn.delete(e.id),Qi()}}function Wi(){return Array.from(kn.values())}function sd(e){return kn.get(e)}function ld(){_r.clear()}function ud(e){return mr.add(e),()=>{mr.delete(e)}}function Qi(){for(const e of mr)e()}function cd(e){const t=oe(\"\"),n=oe(e.perform);n.current=e.perform,t.current||(t.current=ad(e.type,e.key,e.authorId));const r=t.current;return ot(()=>{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),od(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function fd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function bo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Lr(){const e=I.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?bo(t):\"\"}function dd(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 hd(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 pd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const gd={useState:X,useRef:oe,useEffect:we,useLayoutEffect:ot,useCallback:he,useMemo:de,useContext:G};function Ki(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function md(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 V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=Tr(),r=a(r),i=a(i));const{update:o,getValues:s}=G(Kt),u=G(ce),l=G(Ce),f={collectText:fd,sourceLocation:Lr,parseVarArgs:dd,extractOptions:hd,h:K,renderNodes:(h,c)=>Ie(h,{nobr:u,locals:l,...c}),renderInlineNodes:oo,hooks:gd,useAction:cd,className:r,id:i,resolve:a,cls:pd(e.name,r),mutate:h=>id(h,s(),o),update:o,getValues:s,wrap:h=>r||i?K(\"span\",{id:i,class:r},h):K(Y,null,h)};if(e.merged){f.merged=Pr();const h=f.merged;f.evaluate=c=>In(c,h[0],h[1],h[2])}if(e.storeVar){const c=(n.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),p=c.split(\".\");f.varName=c,f.value=I(w=>Ki(w.variables,p)),f.getValue=()=>Ki(I.getState().variables,p),f.setValue=w=>{I.setState(S=>{md(S.variables,p,w)})}}return e.render(n,f)}if(zl(e.name,t),e.subMacros)for(const n of e.subMacros)Rl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ar(e.name)}function _d(){return{get(e){return I.getState().variables[e]},set(e,t){const n=I.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){I.getState().navigate(e)},back(){I.getState().goBack()},forward(){I.getState().goForward()},restart(){I.getState().restart()},save(e){I.getState().save(e)},load(e){I.getState().load(e)},hasSave(e){return I.getState().hasSave(e)},visited(e){const t=I.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=I.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=I.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=I.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 I.getState().storyData?.name||\"\"},get passage(){return I.getState().currentPassage},settings:Lt,registerClass(e,t){pf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){mf(e)}},getActions(){return Wi()},performAction(e,t){const n=sd(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=I.getState().currentPassage;return I.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return ud(t);if(e===\"variableChanged\"){let n={...I.getState().variables};return I.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Wi())})})})},watch(e,t){return go(e,t)},unwatch(e){mo(e)},openDialog(e,t){qf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Wf()},closeAllDialogs(){Qf()},isDialogOpen(){return Kf()},setNobr(e){I.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){I.getState().setTransition(e)},setNextTransition(e){I.getState().setNextTransition(e)},random(){return Nr()},randomInt(e,t){return Va(e,t)},config:{get maxHistory(){return I.getState().maxHistory},set maxHistory(e){I.getState().setMaxHistory(e)}},prng:{init(e,t){vl(e,t);const{historyIndex:n}=I.getState();I.setState(r=>{const i=r.history[n];i&&(i.prng=vn())})},isEnabled(){return wl()},get seed(){return kl()},get pull(){return Sl()}}}}function yd(){window.Story=_d()}const bd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Gi=/\\$(\\w+(?:\\.\\w+)*)/g,Yi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,vd=new Set([\"number\",\"string\",\"boolean\"]);function vo(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,vo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!vd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function wd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(bd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=vo(s);t.set(a,{...u,name:a,default:s})}return t}function kd(e){const t=new Set;let n;for(Yi.lastIndex=0;(n=Yi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Sd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function xd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=kd(i.content);let o;for(Gi.lastIndex=0;(o=Gi.exec(i.content))!==null;){const s=o[1],u=Sd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Cd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function un(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&un(t.children))return!0;if(t.type===\"macro\"){if(un(t.children))return!0;if(t.branches){for(const n of t.branches)if(un(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function He({macro:e,error:t}){return v(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Lr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return v(He,{macro:\"print\",error:n})}}});function Id(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function Ed(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 Ji(e,t,n,r,i,a,o){let s;try{s=In(e,r,i,a)}catch(l){console.error(`spindle: Error in {computed ${o}}${Lr()}:`,l);return}const u=n?i[t]:r[t];if(!Ed(u,s)){const l=I.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=Id(e))}catch(d){return v(He,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,Ji(o,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{Ji(o,u,s,n,r,i,e)},[n,r,i]),null}});function Ad(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=Pd(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 Pd(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 Td(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=Ad(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=Td(a,o,i),l=t.cls;return v(\"div\",{class:l,id:t.id,children:[v(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&v(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return v(He,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?v(\"span\",{id:o,class:a,children:i}):v(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 v(He,{macro:\"if\",error:i})}}return null}});function Nd(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 Dd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=X(()=>({...n})),o={...e,...t,...i},s=oe(o);s.current=o;const u=he(()=>s.current,[]),l=he((h,c)=>{a(p=>({...p,[h]:c}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),f=G(ce);return v(Kt.Provider,{value:d,children:v(Ce.Provider,{value:o,children:Ie(r,{nobr:f,locals:o})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=G(Ce);let i;try{i=Nd(e)}catch(d){return v(He,{macro:\"for\",error:d})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return v(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return v(He,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const h={[a]:d,...o?{[o]:f}:void 0};return v(Dd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=G(ce),a=()=>{const o=document.createElement(\"div\"),s=K(ce.Provider,{value:i},K(Kt.Provider,{value:{update:n.update,getValues:n.getValues}},K(Ce.Provider,{value:n.getValues()},Ie(t))));xe(s,o),xe(null,o)};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 $d(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Zi(e,t,n,r){const i=document.createElement(\"div\"),a=K(ce.Provider,{value:r},K(Kt.Provider,{value:{update:n,getValues:t}},K(Ce.Provider,{value:t()},Ie(e))));xe(a,i),xe(null,i)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=$d(e),a=G(ce),o=s=>{s.preventDefault(),Zi(t,n.getValues,n.update,a),i&&I.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Zi(t,n.getValues,n.update,a),i&&I.getState().navigate(i)}}),v(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return v(He,{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 v(Y,{children:n.renderNodes(o.children)})}catch(s){return v(He,{macro:\"case\",error:s})}}return i?v(Y,{children:n.renderNodes(i.children)}):null}});function Vr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(c=>({delay:c.rawArgs?Vr(c.rawArgs):0,nodes:c.children,className:c.className,id:c.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const c=o+1,p=a[c].delay,w=setTimeout(()=>{s(c)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),d=t.resolve(u.className),f=t.resolve(u.id),h=d||f?v(\"span\",{id:f,class:d,children:l}):l;return t.wrap(h)}});const wo=at({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Vr(e),[s,u]=r(0),[l,d]=r(!1),f=a(()=>d(!0),[]);if(i(()=>{if(l)return;const c=setInterval(()=>{u(p=>p+1)},o);return()=>clearInterval(c)},[o,l]),s===0&&!l)return null;const h=v(wo.Provider,{value:{stop:f},children:v(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?v(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(wo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Vr(e),s=a(null),[u,l]=r(0),[d,f]=r(0),h=a(0);h.current=d,i(()=>{if(s.current){const w=s.current.textContent||\"\";l(w.length)}},[]),i(()=>{if(u===0||h.current>=u)return;const w=setInterval(()=>{f(S=>S>=u?(clearInterval(w),S):S+1)},o);return()=>clearInterval(w)},[u,o]);const c=d>=u&&u>0,p=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return v(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[v(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!c?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!c&&u>0&&v(\"span\",{class:\"macro-type-cursor\"})]})}});function zd(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=zd(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{ja(r,t,i)},[r,a,o]),null}});V({name:\"story-title\",render(e,t){const n=I(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return v(\"span\",{id:t.id,class:r,children:n})}});function lt(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),v(Y,{children:[v(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&v(Mr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}lt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:I(e=>e.goBack),disabled:!I(e=>e.historyIndex>0)})});lt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:I(e=>e.goForward),disabled:!I(e=>e.historyIndex<e.history.length-1)})});lt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:I(e=>e.save)})});lt({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=I(n=>n.load),t=I(n=>n.hasSave);return I(n=>n.knownSaves),{perform:()=>e(),disabled:!t()}}});lt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:I(e=>e.restart)})});lt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});lt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Lt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({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,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return v(Y,{children:[v(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&v(Mr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function Fd(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 Rd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Od(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,a]=X(!0),[o,s]=X(null),[u,l]=X(()=>new Set),[d,f]=X(null),[h,c]=X(\"\"),p=oe(null),w=oe(null),S=G(_o),y=I(D=>D.storyData),k=I(D=>D.playthroughId),x=I(D=>D.getSavePayload),A=I(D=>D.loadFromPayload),C=y?.ifid??\"\",_=he(async()=>{if(!C)return;const D=await xf(C);r(D),a(!1)},[C]);we(()=>{_()},[_]),we(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=oe(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)};we(()=>()=>clearTimeout(P.current),[]);const z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!C||!k))try{const D=x();await uo(C,k,D),T(\"Save created\"),await _()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=x();await co(D,j),T(\"Save overwritten\"),await _()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{A(D.payload),T(\"Game loaded\"),S&&setTimeout(S,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await kf(D),T(\"Save deleted\"),await _()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{f(D.meta.id),c(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await Sf(d,h.trim()),f(null),T(\"Save renamed\"),await _()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&f(null)},J=async D=>{try{const j=await $f(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),le=document.createElement(\"a\");le.href=q,le.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,le.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},pe=()=>{w.current?.click()},ke=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),le=JSON.parse(q);if(!sf(le))throw new Error(\"Invalid save file format\");await zf(le,C),T(\"Save imported\"),await _()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.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:pe,children:\"Import\"}),v(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),v(\"div\",{class:\"saves-body\",children:[i?v(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?v(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:v(\"div\",{class:\"playthrough-group\",children:[v(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[v(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),v(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),v(\"span\",{class:\"playthrough-date\",children:Rd(D.playthrough.createdAt)})]}),!j&&v(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>v(\"div\",{class:\"save-slot\",children:[v(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?v(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:le=>c(le.target.value),onKeyDown:Z,onBlur:M}):v(\"div\",{class:\"save-slot-title\",children:q.meta.title}),v(\"div\",{class:\"save-slot-meta\",children:[v(\"span\",{children:q.meta.passage}),v(\"span\",{children:Fd(q.meta.updatedAt)})]})]}),v(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?v(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):v(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),v(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===k)&&v(\"div\",{class:\"playthrough-group\",children:v(\"div\",{class:\"playthrough-saves\",children:v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&v(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return v(Od,{})}});function Md({name:e,def:t}){const[n,r]=X(()=>Lt.get(e)),i=a=>{r(a),Lt.set(e,a)};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:a=>i(a.target.checked)})]});case\"list\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>v(\"option\",{value:a,children:a},a))})]});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:a=>i(parseFloat(a.target.value))})]})}}function Ld(){const e=Lt.getDefinitions();return v(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>v(Md,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return v(Ld,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=I(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const f=t.evaluate(i);a=String(f)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&I.getState().trackRender(a),!o)return v(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=bt(o.content),l=vt(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(ce.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(ce.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}I.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=I.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _name, or @name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),v(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),v(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),v(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Vd(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Vd(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)}),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 Bd(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]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Bd(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]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),v(\"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=>v(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const 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()}}),v(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Et(e){const t=bt(e.content),n=vt(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const Hd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function qd({passage:e,dataTransition:t}){const n=I(w=>w.storyData),r=Hd.has(e.name),[i,a]=X(!1),o=de(()=>{try{return Et(e)}catch(w){return v(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",bo(e),\":\",\" \",w instanceof Error?w.message:String(w)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=de(()=>{if(!s)return null;try{return Et(s)}catch(w){return console.error(\"spindle: Error in PassageHeader:\",w),null}},[s?.content]),f=de(()=>{if(!u)return null;try{return Et(u)}catch(w){return console.error(\"spindle: Error in PassageFooter:\",w),null}},[u?.content]);we(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return Et(l)}catch(w){return console.error(\"spindle: Error in PassageDone:\",w),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),p=v(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&v(\"div\",{class:\"passage-header\",children:d}),o,f&&v(\"div\",{class:\"passage-footer\",children:f}),h&&v(\"div\",{hidden:!0,children:h})]});return c?v(ce.Provider,{value:!0,children:p}):p}const Ud=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),yr={type:\"fade-through\",duration:300,pause:50};function jd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Ud.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 qn(e){return{type:e.type,duration:e.duration??yr.duration,pause:e.pause??yr.pause}}function Wd(e,t,n){const r=jd(e);return r?qn(r):t?qn(t):n?qn(n):{...yr}}function Xi(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 Un(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 jn(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()}V({name:\"passage\",interpolate:!0,render(e,t){const n=I(c=>c.currentPassage),r=I(c=>c.storyData),[i,a]=X(n),o=oe(\"fade\"),s=oe(0),u=oe(null),l=oe([]),d=he(()=>{for(const c of l.current)clearTimeout(c);l.current=[],jn(u.current)},[]);we(()=>{const c=I.getState(),{history:p,historyIndex:w,transitionConfig:S}=c,y=c.consumeNextTransition(),k=s.current;s.current=p.length;const x=!i,A=p.length===1&&w===0&&k>1,C=p.length>1&&w===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const _=r?.passages.get(n);if(!_){o.current=\"none\",a(n);return}if(x||A||C){o.current=\"fade\",a(n);return}const P=Wd(_.tags,y,S);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Un(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Un(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Xi(z,P.type);T.appendChild(b),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{jn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Un(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Xi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{jn(T)},P.duration);l.current=[N];return}a(n)},[n]);const f=i?r?.passages.get(i):null;if(!f&&i)return v(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return v(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&v(\"div\",{hidden:!0,children:Et(h)},`ready-${n}`),v(\"div\",{class:\"passage-container\",ref:u,children:f&&v(qd,{passage:f,dataTransition:o.current},i)})]})}});V({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={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const f=l[1]??l[5],h=l[2]??l[3]??l[4];if(f)switch(f){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 d=n.useRef(!1);return d.current||(d.current=!0,go(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,mo(r)),null}});const Qd='*,*: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 ea(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 ta(){const e=nd(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Qd,document.head.appendChild(t),yd(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",p=document.getElementById(\"root\");throw p&&ea(p,[c]),new Error(`spindle: ${c}`)}const i=wd(r.content),a=xd(e.passages,i);if(a.length>0){const c=document.getElementById(\"root\");throw c&&ea(c,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=Cd(i),I.getState().init(e,n),ho();const o=Nf(e.ifid);o&&I.getState().loadFromPayload(o);const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){let p;for(;(p=s.exec(c.content))!==null;){const w=p[1],S=p[2];/\\{@children\\}/.test(S)&&ar(w)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const p=bt(c.content),w=vt(p);for(const S of w)if(S.type===\"macro\"&&S.name===\"widget\"&&S.rawArgs){const y=S.rawArgs.trim().split(/\\s+/),k=y[0].replace(/[\"']/g,\"\"),x=y.slice(1).filter(_=>_.startsWith(\"$\")||_.startsWith(\"_\")||_.startsWith(\"@\")),A=S.children,C=un(A);ja(k,A,x,C),C&&ar(k)}}let u=\"\";I.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,ld())});let l=I.getState().variables,d=I.getState().historyIndex;I.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?Of():Mf()),l=c.variables,d=c.historyIndex});const f=e.passages.get(\"StoryInterface\");f&&!f.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const h=document.getElementById(\"root\");if(!h)throw new Error('spindle: No <div id=\"root\"> element found.');xe(v(ed,{}),h),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ta):ta();</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.32.1","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Ht,O,ia,Ge,Jr,aa,oa,sa,kr,Gn,Yn,la,dn={},hn=[],Jo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,qt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function Sr(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?Ht.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 Pt(e,o,r,i,null)}function Pt(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??++ia,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Zo(){return{current:null}}function Y(e){return e.children}function De(e,t){this.props=e,this.context=t}function pt(e,t){if(t==null)return e.__?pt(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\"?pt(e):null}function Xo(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),xr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??pt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,da(r,a,i),t.__e=t.__=null,a.__e!=n&&ua(a)}}function ua(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}),ua(e)}function Jn(e){(!e.__d&&(e.__d=!0)&&Ge.push(e)&&!pn.__r++||Jr!=O.debounceRendering)&&((Jr=O.debounceRendering)||aa)(pn)}function pn(){for(var e,t=1;Ge.length;)Ge.length>t&&Ge.sort(oa),e=Ge.shift(),t=Ge.length,Xo(e);pn.__r=0}function ca(e,t,n,r,i,a,o,s,u,l,d){var f,h,c,p,w,S,y,k=r&&r.__k||hn,x=t.length;for(u=es(n,t,k,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(h=c.__i!=-1&&k[c.__i]||dn,c.__i=f,S=xr(e,c,h,i,a,o,s,u,l,d),p=c.__e,c.ref&&h.ref!=c.ref&&(h.ref&&Cr(h.ref,null,c),d.push(c.ref,c.__c||p,c)),w==null&&p!=null&&(w=p),(y=!!(4&c.__u))||h.__k===c.__k?u=fa(c,u,e,y):typeof c.type==\"function\"&&S!==void 0?u=S:p&&(u=p.nextSibling),c.__u&=-7);return n.__e=w,u}function es(e,t,n,r,i){var a,o,s,u,l,d=n.length,f=d,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]=Pt(null,o,null,null,null):qt(o)?o=e.__k[a]=Pt(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Pt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ts(o,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(f)for(a=0;a<d;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=pt(s)),pa(s,s));return r}function fa(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=fa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=pt(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Oe(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(qt(e)?e.some(function(n){Oe(n,t)}):t.push(e)),t}function ts(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function Zr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Jo.test(t)?n:n+\"px\"}function Zt(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||Zr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Zr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(sa,\"$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=kr,e.addEventListener(t,a?Yn:Gn,a)):e.removeEventListener(t,a?Yn:Gn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Xr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=kr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function xr(e,t,n,r,i,a,o,s,u,l){var d,f,h,c,p,w,S,y,k,x,A,I,_,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(y=t.props,k=\"prototype\"in z&&z.prototype.render,x=(d=z.contextType)&&r[d.__c],A=d?x?x.props.value:d.__:r,n.__c?S=(f=t.__c=n.__c).__=f.__E:(k?t.__c=f=new z(y,A):(t.__c=f=new De(y,A),f.constructor=z,f.render=rs),x&&x.sub(f),f.state||(f.state={}),f.__n=r,h=f.__d=!0,f.__h=[],f._sb=[]),k&&f.__s==null&&(f.__s=f.state),k&&z.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Te({},f.__s)),Te(f.__s,z.getDerivedStateFromProps(y,f.__s))),c=f.props,p=f.state,f.__v=t,h)k&&z.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),k&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&y!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,A),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,A)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),hn.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,A),k&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,p,w)})}if(f.context=A,f.props=y,f.__P=e,f.__e=!1,I=O.__r,_=0,k)f.state=f.__s,f.__d=!1,I&&I(t),d=f.render(f.props,f.state,f.context),hn.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,I&&I(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++_<25);f.state=f.__s,f.getChildContext!=null&&(r=Te(Te({},r),f.getChildContext())),k&&!h&&f.getSnapshotBeforeUpdate!=null&&(w=f.getSnapshotBeforeUpdate(c,p)),P=d!=null&&d.type===Y&&d.key==null?ha(d.props.children):d,s=ca(e,qt(P)?P:[P],t,n,r,i,a,o,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),S&&(f.__E=f.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)Sr(a[T]);Zn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Zn(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ns(n.__e,t,n,r,i,a,o,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Zn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Zn))}function da(e,t,n){for(var r=0;r<n.length;r++)Cr(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 ha(e){return typeof e!=\"object\"||e==null||e.__b>0?e:qt(e)?e.map(ha):Te({},e)}function ns(e,t,n,r,i,a,o,s,u){var l,d,f,h,c,p,w,S=n.props||dn,y=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((c=a[l])&&\"setAttribute\"in c==!!k&&(k?c.localName==k:c.nodeType==3)){e=c,a[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(y);e=document.createElementNS(i,k,y.is&&y),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)S===y||s&&e.data==y||(e.data=y);else{if(a=a&&Ht.call(e.childNodes),!s&&a!=null)for(S={},l=0;l<e.attributes.length;l++)S[(c=e.attributes[l]).name]=c.value;for(l in S)c=S[l],l==\"dangerouslySetInnerHTML\"?f=c:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||Zt(e,l,null,c,i);for(l in y)c=y[l],l==\"children\"?h=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?p=c:l==\"checked\"?w=c:s&&typeof c!=\"function\"||S[l]===c||Zt(e,l,c,S[l],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),ca(t.type==\"template\"?e.content:e,qt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&pt(n,0),s,u),a!=null)for(l=a.length;l--;)Sr(a[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=S[l])&&Zt(e,l,p,S[l],i),l=\"checked\",w!=null&&w!=e[l]&&Zt(e,l,w,S[l],i))}return e}function Cr(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 pa(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Cr(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]&&pa(r[i],t,n||typeof e.type!=\"function\");n||Sr(e.__e),e.__c=e.__=e.__e=void 0}function rs(e,t,n){return this.constructor(e,n)}function xe(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=[],xr(t,e=(!r&&n||t).__k=Q(Y,null,[e]),i||dn,dn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ht.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),da(a,e,o)}function ga(e,t){xe(e,t,ga)}function is(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?Ht.call(arguments,2):n),Pt(e.type,s,r||e.key,i||e.ref,null)}function ot(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,Jn(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\"+la++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Ht=hn.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}},ia=0,De.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),Jn(this))},De.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Jn(this))},De.prototype.render=Y,Ge=[],aa=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,oa=function(e,t){return e.__v.__b-t.__v.__b},pn.__r=0,sa=/(PointerCapture)$|Capture$/i,kr=0,Gn=Xr(!1),Yn=Xr(!0),la=0;var as=0;function v(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--as,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var He,W,Fn,ei,gt=0,ma=[],K=O,ti=K.__b,ni=K.__r,ri=K.diffed,ii=K.__c,ai=K.unmount,oi=K.__;function yt(e,t){K.__h&&K.__h(W,e,gt||t),gt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return gt=1,Ir(va,e)}function Ir(e,t,n){var r=yt(He++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):va(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(h){if(h.__N){var c=h.__[0];h.__=h.__N,h.__N=void 0,c!==h.__[0]&&(f=!0)}}),a&&a.call(this,s,u,l)||f};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=a;a=void 0,i(s,u,l),a=d}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function we(e,t){var n=yt(He++,3);!K.__s&&Er(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function st(e,t){var n=yt(He++,4);!K.__s&&Er(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function oe(e){return gt=5,de(function(){return{current:e}},[])}function _a(e,t,n){gt=6,st(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 de(e,t){var n=yt(He++,7);return Er(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function he(e,t){return gt=8,de(function(){return e},t)}function G(e){var t=W.context[e.__c],n=yt(He++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ya(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function ba(){var e=yt(He++,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 os(){for(var e;e=ma.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(on),t.__h.some(Xn),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,ti&&ti(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),oi&&oi(e,t)},K.__r=function(e){ni&&ni(e),He=0;var t=(W=e.__c).__H;t&&(Fn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(on),t.__h.some(Xn),t.__h=[],He=0)),Fn=W},K.diffed=function(e){ri&&ri(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ma.push(t)!==1&&ei===K.requestAnimationFrame||((ei=K.requestAnimationFrame)||ss)(os)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Fn=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(on),n.__h=n.__h.filter(function(r){return!r.__||Xn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),ii&&ii(e,t)},K.unmount=function(e){ai&&ai(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{on(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var si=typeof requestAnimationFrame==\"function\";function ss(e){var t,n=function(){clearTimeout(r),si&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);si&&(t=requestAnimationFrame(n))}function on(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Xn(e){var t=W;e.__c=e.__(),W=t}function Er(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function va(e,t){return typeof t==\"function\"?t(e):t}const li=e=>{let t;const n=new Set,r=(l,d)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const h=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},ls=(e=>e?li(e):li);function wa(e,t){for(var n in t)e[n]=t[n];return e}function er(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 ka(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,a=r[1];return st(function(){i.__=n,i.u=t,Rn(i)&&a({t:i})},[e,n,t]),we(function(){return Rn(i)&&a({t:i}),e(function(){Rn(i)&&a({t:i})})},[e]),n}function Rn(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 Sa(e){e()}function xa(e){return e}function Ca(){return[!1,Sa]}var Ia=st;function tr(e,t){this.props=e,this.context=t}function us(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:er(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}(tr.prototype=new De).isPureReactComponent=!0,tr.prototype.shouldComponentUpdate=function(e,t){return er(this.props,e)||er(this.state,t)};var ui=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ui&&ui(e)};var cs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function fs(e){function t(n){var r=wa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=cs,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ci=function(e,t){return e==null?null:Oe(Oe(e).map(t))},ds={map:ci,forEach:ci,count:function(e){return e?Oe(e).length:0},only:function(e){var t=Oe(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Oe},hs=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)}hs(e,t,n,r)};var fi=O.unmount;function Ea(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=wa({},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 Ea(r,t,n)})),e}function Aa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Aa(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 sn(){this.__u=0,this.o=null,this.__b=null}function Pa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ps(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 Et(){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),fi&&fi(e)},(sn.prototype=new De).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Pa(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Aa(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},sn.prototype.componentWillUnmount=function(){this.o=[]},sn.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]=Ea(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 di=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 gs(e){return this.getChildContext=function(){return e.context},e.children}function ms(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){xe(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)}}}xe(Q(gs,{context:t.context},e.__v),t.v)}function _s(e,t){var n=Q(ms,{__v:e,h:t});return n.containerInfo=t,n}(Et.prototype=new De).__a=function(e){var t=this,n=Pa(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),di(t,e,r)):i()};n?n(a):a()}},Et.prototype.render=function(e){this.i=null,this.l=new Map;var t=Oe(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},Et.prototype.componentDidUpdate=Et.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){di(e,n,t)})};var Ta=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ys=/^(?: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,ws=typeof document<\"u\",ks=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ss(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function xs(e,t,n){return ga(e,t),typeof n==\"function\"&&n(),e?e.__c:null}De.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(De.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var hi=O.event;function Cs(){}function Is(){return this.cancelBubble}function Es(){return this.defaultPrevented}O.event=function(e){return hi&&(e=hi(e)),e.persist=Cs,e.isPropagationStopped=Is,e.isDefaultPrevented=Es,e.nativeEvent=e};var Ar,As={enumerable:!1,configurable:!0,get:function(){return this.class}},pi=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||ws&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ks(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":bs.test(o)&&(o=u):u=o=\"oninput\":a&&ys.test(o)?o=o.replace(vs,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Oe(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Oe(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",As)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ta,pi&&pi(e)};var gi=O.__r;O.__r=function(e){gi&&gi(e),Ar=e.__c};var mi=O.diffed;O.diffed=function(e){mi&&mi(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),Ar=null};var Ps={ReactCurrentDispatcher:{current:{readContext:function(e){return Ar.__n[e.__c].props.value},useCallback:he,useContext:G,useDebugValue:ya,useDeferredValue:xa,useEffect:we,useId:ba,useImperativeHandle:_a,useInsertionEffect:Ia,useLayoutEffect:st,useMemo:de,useReducer:Ir,useRef:oe,useState:X,useSyncExternalStore:ka,useTransition:Ca}}};function Ts(e){return Q.bind(null,e)}function Cn(e){return!!e&&e.$$typeof===Ta}function Ds(e){return Cn(e)&&e.type===Y}function Ns(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function $s(e){return Cn(e)?is.apply(null,arguments):e}function zs(e){return!!e.__k&&(xe(null,e),!0)}function Fs(e){return e&&(e.base||e.nodeType===1&&e)||null}var Rs=function(e,t){return e(t)},Os=function(e,t){return e(t)},Ms=Y,Ls=Cn,Xt={useState:X,useId:ba,useReducer:Ir,useEffect:we,useLayoutEffect:st,useInsertionEffect:Ia,useTransition:Ca,useDeferredValue:xa,useSyncExternalStore:ka,startTransition:Sa,useRef:oe,useImperativeHandle:_a,useMemo:de,useCallback:he,useContext:G,useDebugValue:ya,version:\"18.3.1\",Children:ds,render:Ss,hydrate:xs,unmountComponentAtNode:zs,createPortal:_s,createElement:Q,createContext:ot,createFactory:Ts,cloneElement:$s,createRef:Zo,Fragment:Y,isValidElement:Cn,isElement:Ls,isFragment:Ds,isMemo:Ns,findDOMNode:Fs,Component:De,PureComponent:tr,memo:us,forwardRef:fs,flushSync:Os,unstable_batchedUpdates:Rs,StrictMode:Ms,Suspense:sn,SuspenseList:Et,lazy:ps,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ps};const Vs=e=>e;function Bs(e,t=Vs){const n=Xt.useSyncExternalStore(e.subscribe,Xt.useCallback(()=>t(e.getState()),[e,t]),Xt.useCallback(()=>t(e.getInitialState()),[e,t]));return Xt.useDebugValue(n),n}const Hs=e=>{const t=ls(e),n=r=>Bs(t,r);return Object.assign(n,t),n},qs=(e=>Hs);var Pr=Symbol.for(\"immer-nothing\"),Tt=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function ae(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ge=Object,nt=ge.getPrototypeOf,zt=\"constructor\",Ut=\"prototype\",nr=\"configurable\",gn=\"enumerable\",ln=\"writable\",Ft=\"value\",Le=e=>!!e&&!!e[te];function Ne(e){return e?Da(e)||Wt(e)||!!e[Tt]||!!e[zt]?.[Tt]||Kt(e)||Qt(e):!1}var Us=ge[Ut][zt].toString(),_i=new WeakMap;function Da(e){if(!e||!mt(e))return!1;const t=nt(e);if(t===null||t===ge[Ut])return!0;const n=ge.hasOwnProperty.call(t,zt)&&t[zt];if(n===Object)return!0;if(!Ye(n))return!1;let r=_i.get(n);return r===void 0&&(r=Function.toString.call(n),_i.set(n,r)),r===Us}function jt(e,t,n=!0){rt(e)===0?(n?Reflect.ownKeys(e):ge.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function rt(e){const t=e[te];return t?t.type_:Wt(e)?1:Kt(e)?2:Qt(e)?3:0}var Dt=(e,t,n=rt(e))=>n===2?e.has(t):ge[Ut].hasOwnProperty.call(e,t),Fe=(e,t,n=rt(e))=>n===2?e.get(t):e[t],mn=(e,t,n,r=rt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function js(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Wt=Array.isArray,Kt=e=>e instanceof Map,Qt=e=>e instanceof Set,mt=e=>typeof e==\"object\",Ye=e=>typeof e==\"function\",On=e=>typeof e==\"boolean\";function Ws(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ks=e=>mt(e)?e?.[te]:null,Re=e=>e.copy_||e.base_,Tr=e=>e.modified_?e.copy_:e.base_;function rr(e,t){if(Kt(e))return new Map(e);if(Qt(e))return new Set(e);if(Wt(e))return Array[Ut].slice.call(e);const n=Da(e);if(t===!0||t===\"class_only\"&&!n){const r=ge.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[ln]===!1&&(s[ln]=!0,s[nr]=!0),(s.get||s.set)&&(r[o]={[nr]:!0,[ln]:!0,[gn]:s[gn],[Ft]:e[o]})}return ge.create(nt(e),r)}else{const r=nt(e);if(r!==null&&n)return{...e};const i=ge.create(r);return ge.assign(i,e)}}function Dr(e,t=!1){return In(e)||Le(e)||!Ne(e)||(rt(e)>1&&ge.defineProperties(e,{set:en,add:en,clear:en,delete:en}),ge.freeze(e),t&&jt(e,(n,r)=>{Dr(r,!0)},!1)),e}function Qs(){ae(2)}var en={[Ft]:Qs};function In(e){return e===null||!mt(e)?!0:ge.isFrozen(e)}var _n=\"MapSet\",yn=\"Patches\",yi=\"ArrayMethods\",bn={};function it(e){const t=bn[e];return t||ae(0,e),t}var bi=e=>!!bn[e];function Gs(e,t){bn[e]||(bn[e]=t)}var Rt,Na=()=>Rt,Ys=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:bi(_n)?it(_n):void 0,arrayMethodsPlugin_:bi(yi)?it(yi):void 0});function vi(e,t){t&&(e.patchPlugin_=it(yn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ir(e){ar(e),e.drafts_.forEach(Js),e.drafts_=null}function ar(e){e===Rt&&(Rt=e.parent_)}var wi=e=>Rt=Ys(Rt,e);function Js(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ki(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(ir(t),ae(4)),Ne(e)&&(e=Si(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=Si(t,n);return Zs(t,e,!0),ir(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Pr?e:void 0}function Si(e,t){if(In(t))return t;const n=t[te];if(!n)return vn(t,e.handledSet_,e);if(!En(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);Fa(n,e)}return n.copy_}function Zs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Dr(t,n)}function $a(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var En=(e,t)=>e.scope_===t,Xs=[];function za(e,t,n,r){const i=Re(e),a=e.type_;if(r!==void 0&&Fe(i,r,a)===t){mn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;jt(i,(u,l)=>{if(Le(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??Xs;for(const s of o)mn(i,s,n,a)}function el(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!En(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Tr(a);za(e,a.draft_??a,o,n),Fa(a,i)})}function Fa(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)}$a(e)}}function tl(e,t,n){const{scope_:r}=e;if(Le(n)){const i=n[te];En(i,r)&&i.callbacks_.push(function(){un(e);const o=Tr(i);za(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Re(e);e.type_===3?a.has(n)&&vn(n,r.handledSet_,r):Fe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&vn(Fe(e.copy_,t,e.type_),r.handledSet_,r)})}function vn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Le(e)||t.has(e)||!Ne(e)||In(e)||(t.add(e),jt(e,(r,i)=>{if(Le(i)){const a=i[te];if(En(a,n)){const o=Tr(a);mn(e,r,o,e.type_),$a(a)}}else Ne(i)&&vn(i,t,n)})),e}function nl(e,t){const n=Wt(e),r={type_:n?1:0,scope_:t?t.scope_:Na(),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=wn;n&&(i=[r],a=Ot);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var wn={get(e,t){if(t===te)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=Re(e);if(!Dt(i,t,e.type_))return rl(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ws(t))return a;if(a===Mn(e.base_,t)){un(e);const o=e.type_===1?+t:t,s=sr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Re(e)},ownKeys(e){return Reflect.ownKeys(Re(e))},set(e,t,n){const r=Ra(Re(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Mn(Re(e),t),a=i?.[te];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(js(n,i)&&(n!==void 0||Dt(e.base_,t,e.type_)))return!0;un(e),or(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),tl(e,t,n)),!0},deleteProperty(e,t){return un(e),Mn(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){const n=Re(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[ln]:!0,[nr]:e.type_!==1||t!==\"length\",[gn]:r[gn],[Ft]:n[t]}},defineProperty(){ae(11)},getPrototypeOf(e){return nt(e.base_)},setPrototypeOf(){ae(12)}},Ot={};for(let e in wn){let t=wn[e];Ot[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ot.deleteProperty=function(e,t){return Ot.set.call(this,e,t,void 0)};Ot.set=function(e,t,n){return wn.set.call(this,e[0],t,n,e[0])};function Mn(e,t){const n=e[te];return(n?Re(n):e)[t]}function rl(e,t,n){const r=Ra(t,n);return r?Ft in r?r[Ft]:r.get?.call(e.draft_):void 0}function Ra(e,t){if(!(t in e))return;let n=nt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=nt(n)}}function or(e){e.modified_||(e.modified_=!0,e.parent_&&or(e.parent_))}function un(e){e.copy_||(e.assigned_=new Map,e.copy_=rr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var il=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ye(t)&&!Ye(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Ye(n)||ae(6),r!==void 0&&!Ye(r)&&ae(7);let i;if(Ne(t)){const a=wi(this),o=sr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?ir(a):ar(a)}return vi(a,r),ki(i,a)}else if(!t||!mt(t)){if(i=n(t),i===void 0&&(i=t),i===Pr&&(i=void 0),this.autoFreeze_&&Dr(i,!0),r){const a=[],o=[];it(yn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ae(1,t)},this.produceWithPatches=(t,n)=>{if(Ye(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},On(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),On(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),On(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||ae(8),Le(e)&&(e=al(e));const t=wi(this),n=sr(t,e,void 0);return n[te].isManual_=!0,ar(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return vi(r,t),ki(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=it(yn).applyPatches_;return Le(e)?r(e,t):this.produce(e,i=>r(i,t))}};function sr(e,t,n,r){const[i,a]=Kt(t)?it(_n).proxyMap_(t,n):Qt(t)?it(_n).proxySet_(t,n):nl(t,n);return(n?.scope_??Na()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?el(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function al(e){return Le(e)||ae(10,e),Oa(e)}function Oa(e){if(!Ne(e)||In(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=rr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=rr(e,!0);return jt(n,(i,a)=>{mn(n,i,Oa(a))},r),t&&(t.finalized_=!1),n}function ol(){function t(p,w=[]){if(p.key_!==void 0){const S=p.parent_.copy_??p.parent_.base_,y=Ks(Fe(S,p.key_)),k=Fe(S,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||y!=null&&y.base_!==p.base_)return null;const x=p.parent_.type_===3;let A;if(x){const I=p.parent_;A=Array.from(I.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(x&&S.size>A||Dt(S,A)))return null;w.push(A)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let S=p;for(let y=0;y<w.length-1;y++){const k=w[y];if(S=Fe(S,k),!mt(S)||S===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return S}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,S){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:y,inversePatches_:k}=S;switch(p.type_){case 0:case 2:return u(p,w,y,k);case 1:return s(p,w,y,k);case 3:return l(p,w,y,k)}}function s(p,w,S,y){let{base_:k,assigned_:x}=p,A=p.copy_;A.length<k.length&&([k,A]=[A,k],[S,y]=[y,S]);const I=p.allIndicesReassigned_===!0;for(let _=0;_<k.length;_++){const P=A[_],T=k[_];if((I||x?.get(_.toString()))&&P!==T){const b=P?.[te];if(b&&b.modified_)continue;const D=w.concat([_]);S.push({op:r,path:D,value:c(P)}),y.push({op:r,path:D,value:c(T)})}}for(let _=k.length;_<A.length;_++){const P=w.concat([_]);S.push({op:i,path:P,value:c(A[_])})}for(let _=A.length-1;k.length<=_;--_){const P=w.concat([_]);y.push({op:a,path:P})}}function u(p,w,S,y){const{base_:k,copy_:x,type_:A}=p;jt(p.assigned_,(I,_)=>{const P=Fe(k,I,A),T=Fe(x,I,A),z=_?Dt(k,I)?r:i:a;if(P===T&&z===r)return;const b=w.concat(I);S.push(z===a?{op:z,path:b}:{op:z,path:b,value:c(T)}),y.push(z===i?{op:a,path:b}:z===a?{op:i,path:b,value:c(P)}:{op:r,path:b,value:c(P)})})}function l(p,w,S,y){let{base_:k,copy_:x}=p,A=0;k.forEach(I=>{if(!x.has(I)){const _=w.concat([A]);S.push({op:a,path:_,value:I}),y.unshift({op:i,path:_,value:I})}A++}),A=0,x.forEach(I=>{if(!k.has(I)){const _=w.concat([A]);S.push({op:i,path:_,value:I}),y.unshift({op:a,path:_,value:I})}A++})}function d(p,w,S){const{patches_:y,inversePatches_:k}=S;y.push({op:r,path:[],value:w===Pr?void 0:w}),k.push({op:r,path:[],value:p})}function f(p,w){return w.forEach(S=>{const{path:y,op:k}=S;let x=p;for(let P=0;P<y.length-1;P++){const T=rt(x);let z=y[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===zt)&&ae(19),Ye(x)&&z===Ut&&ae(19),x=Fe(x,z),mt(x)||ae(18,y.join(\"/\"))}const A=rt(x),I=h(S.value),_=y[y.length-1];switch(k){case r:switch(A){case 2:return x.set(_,I);case 3:ae(16);default:return x[_]=I}case i:switch(A){case 1:return _===\"-\"?x.push(I):x.splice(_,0,I);case 2:return x.set(_,I);case 3:return x.add(I);default:return x[_]=I}case a:switch(A){case 1:return x.splice(_,1);case 2:return x.delete(_);case 3:return x.delete(S.value);default:return delete x[_]}default:ae(17,k)}}),p}function h(p){if(!Ne(p))return p;if(Wt(p))return p.map(h);if(Kt(p))return new Map(Array.from(p.entries()).map(([S,y])=>[S,h(y)]));if(Qt(p))return new Set(Array.from(p).map(h));const w=Object.create(nt(p));for(const S in p)w[S]=h(p[S]);return Dt(p,Tt)&&(w[Tt]=p[Tt]),w}function c(p){return Le(p)?h(p):p}Gs(yn,{applyPatches_:f,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var Mt=new il,sl=Mt.produce,ll=Mt.produceWithPatches.bind(Mt),ht=Mt.applyPatches.bind(Mt);const ul=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?sl(i):i;return t(s,a,...o)},e(r.setState,n,r)),cl=ul,fl=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),dl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function hl(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 xi(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 Ci(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 pl(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 bt(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=Ci(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const d=e.slice(l,n);n+=2;const{display:f,target:h}=hl(d),c={type:\"link\",display:f,target:h,start:a,end:n};o&&(c.className=o),s&&(c.id=s),t.push(c),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=Ci(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const f=e[d];if(f===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let h=1;const c=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(c,n);n++;const{name:w,rawArgs:S,isClose:y}=xi(p),k={type:\"macro\",name:w,rawArgs:S,isClose:y,start:a,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const f=e.slice(d,n);n++;const{name:h,rawArgs:c,isClose:p}=xi(f);t.push({type:\"macro\",name:h,rawArgs:c,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&fl.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const d=pl(e,o);o=d.endIdx;let f=dl.has(l);if(e[o]===\"/\"&&(f=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:f,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ma=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function lr(e){Ma.add(e.toLowerCase())}const Ii={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},gl=new Set([\"if\",\"switch\",\"timed\"]);function vt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{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(Ii[a]){const o=Ii[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 u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if(Ma.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(gl.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 Nr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=G(Ce);return de(()=>[e,t,n],[e,t,n])}const ml=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,_l=/\\{[\\$_@][\\w.]+\\}/;function yl(e){return _l.test(e)}function bl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function vl(e,t,n,r){return e.replace(ml,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let d;return o===\"$\"?d=t[l]:o===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=bl(d,u)),d==null?\"\":String(d)})}function $r(){const[e,t,n]=Nr();return he(r=>r===void 0||!yl(r)?r:vl(r,e,t,n),[e,t,n])}function wl({name:e,scope:t,className:n,id:r}){const i=$r();n=i(n),r=i(r);const a=G(Ce),o=e.split(\".\"),s=o[0],u=C(f=>t===\"variable\"?f.variables[s]:t===\"temporary\"?f.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let f=1;f<o.length;f++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[f];l=l[h]}const d=l==null?\"\":String(l);return n||r?v(\"span\",{id:r,class:n,children:d}):v(Y,{children:d})}function La(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 Va(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let wt=!1,Gt=\"\",at=0,_t=null;function kl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Gt=n,at=0,_t=La(Va(n)),wt=!0}function Ba(e,t){Gt=e,at=0,_t=La(Va(e)),wt=!0;for(let n=0;n<t;n++)_t();at=t}function ur(){wt=!1,Gt=\"\",at=0,_t=null}function kn(){return wt?{seed:Gt,pull:at}:null}function zr(){return!wt||!_t?Math.random():(at++,_t())}function Ha(e,t){return e>t&&([e,t]=[t,e]),Math.floor(zr()*(t-e+1))+e}function Sl(){return wt}function xl(){return Gt}function Cl(){return at}const Il=500,Qe=new Map,El=/\\$(\\w+)/g,Al=/(?<![.\\w])_(\\w+)/g,Pl=/@(\\w+)/g;function Tl(e){return e.replace(El,'variables[\"$1\"]').replace(Al,'temporary[\"$1\"]').replace(Pl,'locals[\"$1\"]')}function Fr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Tl(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else if(l===\"\\\\\"&&r+1<e.length)u+=l+e.charAt(r+1),r++;else if(l==='\"'||l===\"'\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===l){u+=d,r++;break}else u+=d,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===\"$\"&&e.charAt(r+1)===\"{\"){u+=\"${\",r+=2;let f=1;for(;r<e.length&&f>0;){const h=e.charAt(r);h===\"{\"?f++:h===\"}\"&&f--,f>0&&(u+=h),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Fr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Dl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function qa(e,t){const n=Qe.get(e);if(n)return Qe.delete(e),Qe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Dl+t);if(Qe.set(e,r),Qe.size>Il){const i=Qe.keys().next().value;i!==void 0&&Qe.delete(i)}return r}let tn=null,Ei=null,Ai=null;function Ua(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(tn&&Ei===t&&Ai===n)return tn;const r=c=>t[c??C.getState().currentPassage]??0,i=c=>r(c)>0,a=(...c)=>c.some(p=>r(p)>0),o=(...c)=>c.every(p=>r(p)>0),s=c=>n[c??C.getState().currentPassage]??0;return tn={currentPassage:()=>{const c=C.getState();return c.storyData?.passages.get(c.currentPassage)},previousPassage:()=>{const c=C.getState();if(c.historyIndex<=0)return;const p=c.history[c.historyIndex-1]?.passage;return p?c.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(p=>s(p)>0),hasRenderedAll:(...c)=>c.every(p=>s(p)>0),random:zr,randomInt:Ha},Ei=t,Ai=n,tn}function An(e,t,n,r={}){const a=`return (${Fr(e)});`;return qa(a,a)(t,n,r,Ua())}function ja(e,t,n,r={}){const i=Fr(e);qa(\"exec:\"+i,i)(t,n,r,Ua())}function Nl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function $l({body:e,parentValues:t,ownKeys:n}){const r=G(ce),[i,a]=X({}),o={...t,...n,...i},s=oe(o);s.current=o;const u=he(()=>s.current,[]),l=he((f,h)=>{a(c=>({...c,[f]:h}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return v(Yt.Provider,{value:d,children:v(Ce.Provider,{value:o,children:Ie(e,{nobr:r,locals:o})})})}function zl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=G(Ce),a=G(ce),[o,s,u]=Nr(),l=r?.length?r:null;if(t.length===0||!n)return v(pr.Provider,{value:l,children:Ie(e,{nobr:a,locals:i})});const d=Nl(n),f={};for(let h=0;h<t.length;h++){const c=t[h],p=d[h];let w;if(p!==void 0)try{w=An(p,o,s,u)}catch{w=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=w}return v(pr.Provider,{value:l,children:v($l,{body:e,parentValues:i,ownKeys:f})})}const Wa=new Map;function Ka(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");Wa.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Fl(e){return Wa.get(e.toLowerCase())}const Qa=new Map;function Rl(e,t){Qa.set(e.toLowerCase(),t)}function Ol(e){return Qa.get(e.toLowerCase())}const Ga=new Set;function Ml(e){Ga.add(e.toLowerCase())}function Ll(e){return Ga.has(e.toLowerCase())}const Pi=document.createElement(\"i\");function Ya(e){const t=\"&\"+e+\";\";Pi.innerHTML=t;const n=Pi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function _e(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 ie(e,t){return e.length>0?(_e(e,e.length,0,t),e):t}const cr={}.hasOwnProperty;function Vl(e){const t={};let n=-1;for(;++n<e.length;)Bl(t,e[n]);return t}function Bl(e,t){let n;for(n in t){const i=(cr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){cr.call(i,o)||(i[o]=[]);const s=a[o];Hl(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Hl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);_e(e,0,0,r)}function ql(e){const t={};let n=-1;for(;++n<e.length;)Ul(t,e[n]);return t}function Ul(e,t){let n;for(n in t){const i=(cr.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 jl(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 Wl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ja(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Wl[n]+\";\"}}function Lt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Pe=Ue(/[A-Za-z]/),me=Ue(/[\\dA-Za-z]/),Kl=Ue(/[#-'*+\\--9=?A-Z^-~]/);function fr(e){return e!==null&&(e<32||e===127)}const dr=Ue(/\\d/),Ql=Ue(/[\\dA-Fa-f]/),Gl=Ue(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Yl=Ue(/\\p{P}|\\p{S}/u),Jl=Ue(/\\s/);function Ue(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function nn(e,t){const n=Ja(Zl(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 Zl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&me(e.charCodeAt(n+1))&&me(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 Ti={}.hasOwnProperty,Di=/^(https?|ircs?|mailto|xmpp)$/i,Xl=/^https?$/i;function eu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=ql([{enter:{blockQuote:M,codeFenced:ke,codeFencedFenceInfo:S,codeFencedFenceMeta:S,codeIndented:j,codeText:qo,content:Do,definition:Co,definitionDestinationString:Eo,definitionLabelString:S,definitionTitleString:S,emphasis:Bo,htmlFlow:Vo,htmlText:Wr,image:q,label:S,link:le,listItemMarker:D,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:J,reference:S,resource:ct,resourceDestinationString:ft,resourceTitleString:S,setextHeading:$o,strong:Ho},exit:{atxHeading:Fo,atxHeadingSequence:No,autolinkEmail:Yo,autolinkProtocol:Go,blockQuote:Z,characterEscapeValue:xt,characterReferenceMarkerHexadecimal:Kr,characterReferenceMarkerNumeric:Kr,characterReferenceValue:Qo,codeFenced:g,codeFencedFence:N,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Lo,codeIndented:g,codeText:Uo,codeTextData:xt,data:xt,definition:To,definitionDestinationString:Ao,definitionLabelString:Io,definitionTitleString:Po,emphasis:jo,hardBreakEscape:Ur,hardBreakTrailing:Ur,htmlFlow:jr,htmlFlowData:xt,htmlText:jr,htmlTextData:xt,image:qr,label:St,labelText:ee,lineEnding:Mo,link:qr,listOrdered:$,listUnordered:B,paragraph:pe,reference:P,referenceString:Ve,resource:P,resourceDestinationString:zn,resourceTitleString:xo,setextHeading:Oo,setextHeadingLineSequence:Ro,setextHeadingText:zo,strong:Wo,thematicBreak:Ko}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:S,encode:_,getData:w,lineEndingIfNeeded:I,options:t,raw:x,resume:y,setData:p,tag:k};let f=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const Se=[];let Ee=[],ze=[];for(;++F<E.length;)!f&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(f=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?Se.push(F):c(E.slice(Se.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?(ze=ie(ze,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,ze),Ee=ie(Ee,E.slice(ne)),F=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const Qr=u[Ae[F][0]],Gr=Ae[F][1].type,Yr=Qr[Gr];Ti.call(Qr,Gr)&&Yr&&Yr.call({sliceSerialize:Ae[F][2].sliceSerialize,...d},Ae[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(E){const F=E.length;let ne=0,Se=0,Ee=!1,ze;for(;++ne<F;){const Ae=E[ne];if(Ae[1]._container)ze=void 0,Ae[0]===\"enter\"?Se++:Se--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(ze=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Se&&(ze?ze=void 0:Ee=!0);break}default:ze=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function w(E){return l[E]}function S(){i.push([])}function y(){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 A(){x(f||`\n`)}function I(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||A()}function _(E){return w(\"ignoreEncode\")?E:Ja(E)}function P(){y()}function T(E){o.push(!E._loose),I(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),I(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(w(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+_(String(F))+'\"')}}function D(){w(\"expectFirstItem\")?k(\">\"):U(),I(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),A(),k(\"</ol>\")}function B(){U(),o.pop(),A(),k(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&I(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),I(),k(\"<blockquote>\")}function Z(){o.pop(),I(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function J(){o[o.length-1]||(I(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function pe(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function ke(){I(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=y();k(' class=\"language-'+E+'\"')}function N(){const E=w(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){I(),k(\"<pre><code>\")}function g(){const E=w(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&A(),w(\"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 le(){a.push({})}function ee(E){a[a.length-1].labelId=this.sliceSerialize(E)}function St(){a[a.length-1].label=y()}function Ve(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function ct(){S(),a[a.length-1].destination=\"\"}function ft(){S(),p(\"ignoreEncode\",!0)}function zn(){a[a.length-1].destination=y(),p(\"ignoreEncode\")}function xo(){a[a.length-1].title=y()}function qr(){let E=a.length-1;const F=a[E],ne=F.referenceId||F.labelId,Se=F.destination===void 0?r[Lt(ne)]:F;for(n=!0;E--;)if(a[E].image){n=void 0;break}F.image?(k('<img src=\"'+nn(Se.destination,t.allowDangerousProtocol?void 0:Xl)+'\" alt=\"'),x(F.label),k('\"')):k('<a href=\"'+nn(Se.destination,t.allowDangerousProtocol?void 0:Di)+'\"'),k(Se.title?' title=\"'+Se.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),x(F.label),k(\"</a>\")),a.pop()}function Co(){S(),a.push({})}function Io(E){y(),a[a.length-1].labelId=this.sliceSerialize(E)}function Eo(){S(),p(\"ignoreEncode\",!0)}function Ao(){a[a.length-1].destination=y(),p(\"ignoreEncode\")}function Po(){a[a.length-1].title=y()}function To(){const E=a[a.length-1],F=Lt(E.labelId);y(),Ti.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Do(){p(\"slurpAllLineEndings\",!0)}function No(E){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),I(),k(\"<h\"+w(\"headingRank\")+\">\"))}function $o(){S(),p(\"slurpAllLineEndings\")}function zo(){p(\"slurpAllLineEndings\",!0)}function Fo(){k(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function Ro(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function Oo(){const E=y();I(),k(\"<h\"+w(\"headingRank\")+\">\"),x(E),k(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function xt(E){x(_(this.sliceSerialize(E)))}function Mo(E){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){x(\" \");return}x(_(this.sliceSerialize(E)))}}function Lo(E){x(_(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Ur(){k(\"<br />\")}function Vo(){I(),Wr()}function jr(){p(\"ignoreEncode\")}function Wr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Bo(){k(\"<em>\")}function Ho(){k(\"<strong>\")}function qo(){p(\"inCodeText\",!0),k(\"<code>\")}function Uo(){p(\"inCodeText\"),k(\"</code>\")}function jo(){k(\"</em>\")}function Wo(){k(\"</strong>\")}function Ko(){I(),k(\"<hr />\")}function Kr(E){p(\"characterReferenceType\",E.type)}function Qo(E){const F=this.sliceSerialize(E),ne=w(\"characterReferenceType\")?jl(F,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ya(F);x(_(ne)),p(\"characterReferenceType\")}function Go(E){const F=this.sliceSerialize(E);k('<a href=\"'+nn(F,t.allowDangerousProtocol?void 0:Di)+'\">'),x(_(F)),k(\"</a>\")}function Yo(E){const F=this.sliceSerialize(E);k('<a href=\"'+nn(\"mailto:\"+F)+'\">'),x(_(F)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const tu={tokenize:nu};function nu(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 u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const ru={tokenize:iu},Ni={tokenize:au};function iu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let I=A,_;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){_=t.events[I][1].end;break}y(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={..._},P++;return _e(t.events,I+1,0,t.events.slice(A)),t.events.length=P,l(x)}return s(x)}function l(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(Ni,d,f)(x)}function d(x){return i&&k(),y(r),h(x)}function f(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(Ni,c,p)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function p(x){if(x===null){i&&k(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(x)}function w(x){if(x===null){S(e.exit(\"chunkFlow\"),!0),y(0),e.consume(x);return}return R(x)?(e.consume(x),S(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),w)}function S(x,A){const I=t.sliceStream(x);if(A&&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 _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(y(r),_=P;_<t.events.length;)t.events[_][1].end={...b},_++;_e(t.events,T+1,0,t.events.slice(P)),t.events.length=_}}function y(x){let A=n.length;for(;A-- >x;){const I=n[A];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 au(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 Sn(e){if(e===null||se(e)||Jl(e))return 1;if(Yl(e))return 2}function Pn(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 hr={name:\"attention\",resolveAll:ou,tokenize:su};function ou(e,t){let n=-1,r,i,a,o,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};$i(f,-u),$i(h,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:f,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ie(l,Pn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,_e(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function su(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Sn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=Sn(u),f=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?f:f&&(i||!h)),l._close=!!(a===42?h:h&&(d||!f)),t(u)}}function $i(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const lu={name:\"autolink\",tokenize:uu};function uu(e,t,n){let r=0;return i;function i(c){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(c){return Pe(c)?(e.consume(c),o):c===64?n(c):l(c)}function o(c){return c===43||c===45||c===46||me(c)?(r=1,s(c)):l(c)}function s(c){return c===58?(e.consume(c),r=0,u):(c===43||c===45||c===46||me(c))&&r++<32?(e.consume(c),s):(r=0,l(c))}function u(c){return c===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):c===null||c===32||c===60||fr(c)?n(c):(e.consume(c),u)}function l(c){return c===64?(e.consume(c),d):Kl(c)?(e.consume(c),l):n(c)}function d(c){return me(c)?f(c):n(c)}function f(c){return c===46?(e.consume(c),r=0,d):c===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(c)}function h(c){if((c===45||me(c))&&r++<63){const p=c===45?h:f;return e.consume(c),p}return n(c)}}const Tn={partial:!0,tokenize:cu};function cu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const Za={continuation:{tokenize:du},exit:hu,name:\"blockQuote\",tokenize:fu};function fu(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 du(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(Za,t,n)(o)}}function hu(e){e.exit(\"blockQuote\")}const Xa={name:\"characterEscape\",tokenize:pu};function pu(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 Gl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const eo={name:\"characterReference\",tokenize:gu};function gu(e,t,n){const r=this;let i=0,a,o;return s;function s(f){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),u}function u(f){return f===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(f),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=me,d(f))}function l(f){return f===88||f===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(f),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Ql,d):(e.enter(\"characterReferenceValue\"),a=7,o=dr,d(f))}function d(f){if(f===59&&i){const h=e.exit(\"characterReferenceValue\");return o===me&&!Ya(r.sliceSerialize(h))?n(f):(e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(f)&&i++<a?(e.consume(f),d):n(f)}}const zi={partial:!0,tokenize:_u},Fi={concrete:!0,name:\"codeFenced\",tokenize:mu};function mu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(_){return l(_)}function l(_){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=_,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(_)}function d(_){return _===s?(o++,e.consume(_),d):o<3?n(_):(e.exit(\"codeFencedFenceSequence\"),L(_)?H(e,f,\"whitespace\")(_):f(_))}function f(_){return _===null||R(_)?(e.exit(\"codeFencedFence\"),r.interrupt?t(_):e.check(zi,w,A)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(_)):L(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,c,\"whitespace\")(_)):_===96&&_===s?n(_):(e.consume(_),h)}function c(_){return _===null||R(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),p)}function w(_){return e.attempt(i,A,S)(_)}function S(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return a>0&&L(_)?H(e,k,\"linePrefix\",a+1)(_):k(_)}function k(_){return _===null||R(_)?e.check(zi,w,A)(_):(e.enter(\"codeFlowValue\"),x(_))}function x(_){return _===null||R(_)?(e.exit(\"codeFlowValue\"),k(_)):(e.consume(_),x)}function A(_){return e.exit(\"codeFenced\"),t(_)}function I(_,P,T){let z=0;return b;function b(M){return _.enter(\"lineEnding\"),_.consume(M),_.exit(\"lineEnding\"),D}function D(M){return _.enter(\"codeFencedFence\"),L(M)?H(_,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(_.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,_.consume(M),B):z>=o?(_.exit(\"codeFencedFenceSequence\"),L(M)?H(_,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(_.exit(\"codeFencedFence\"),P(M)):T(M)}}}function _u(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 Ln={name:\"codeIndented\",tokenize:bu},yu={partial:!0,tokenize:vu};function bu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(yu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function vu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(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):R(o)?i(o):n(o)}}const wu={name:\"codeText\",previous:Su,resolve:ku,tokenize:xu};function ku(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Su(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function xu(e,t,n){let r=0,i,a;return o;function o(f){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(f)}function s(f){return f===96?(e.consume(f),r++,s):(e.exit(\"codeTextSequence\"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter(\"space\"),e.consume(f),e.exit(\"space\"),u):f===96?(a=e.enter(\"codeTextSequence\"),i=0,d(f)):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(f))}function l(f){return f===null||f===32||f===96||R(f)?(e.exit(\"codeTextData\"),u(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(f)):(a.type=\"codeTextData\",l(f))}}class Cu{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&&Ct(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),Ct(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ct(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);Ct(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ct(this.left,n.reverse())}}}function Ct(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 to(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new Cu(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Iu(d,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(d.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={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function Iu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let d,f,h=-1,c=n,p=0,w=0;const S=[w];for(;c;){for(;e.get(++i)[1]!==c;);a.push(i),c._tokenizer||(d=r.sliceStream(c),c.next||d.push(null),f&&o.defineSkip(c.start),c._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),c._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=c,c=c.next}for(c=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&&(w=h+1,S.push(w),c._tokenizer=void 0,c.previous=void 0,c=c.next);for(o.events=[],c?(c._tokenizer=void 0,c.previous=void 0):S.pop(),h=S.length;h--;){const y=s.slice(S[h],S[h+1]),k=a.pop();u.push([k,k+y.length-1]),e.splice(k,2,y)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const Eu={resolve:Pu,tokenize:Tu},Au={partial:!0,tokenize:Du};function Pu(e){return to(e),e}function Tu(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):R(s)?e.check(Au,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 Du(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||R(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 no(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(y),e.exit(a),h):y===null||y===32||y===41||fr(y)?n(y):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(y))}function h(y){return y===62?(e.enter(a),e.consume(y),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),c(y))}function c(y){return y===62?(e.exit(\"chunkString\"),e.exit(s),h(y)):y===null||y===60||R(y)?n(y):(e.consume(y),y===92?p:c)}function p(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function w(y){return!d&&(y===null||y===41||se(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(y)):d<l&&y===40?(e.consume(y),d++,w):y===41?(e.consume(y),d--,w):y===null||y===32||y===40||fr(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function ro(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(c){return e.enter(r),e.enter(i),e.consume(c),e.exit(i),e.enter(a),d}function d(c){return s>999||c===null||c===91||c===93&&!u||c===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(c):c===93?(e.exit(a),e.enter(i),e.consume(c),e.exit(i),e.exit(r),t):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),f(c))}function f(c){return c===null||c===91||c===93||R(c)||s++>999?(e.exit(\"chunkString\"),d(c)):(e.consume(c),u||(u=!L(c)),c===92?h:f)}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function io(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,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(e.consume(h),d):d(h)}}function Nt(e,t){let n;return r;function r(i){return R(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 Nu={name:\"definition\",tokenize:zu},$u={partial:!0,tokenize:Fu};function zu(e,t,n){const r=this;let i;return a;function a(c){return e.enter(\"definition\"),o(c)}function o(c){return ro.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(c)}function s(c){return i=Lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),c===58?(e.enter(\"definitionMarker\"),e.consume(c),e.exit(\"definitionMarker\"),u):n(c)}function u(c){return se(c)?Nt(e,l)(c):l(c)}function l(c){return no(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt($u,f,f)(c)}function f(c){return L(c)?H(e,h,\"whitespace\")(c):h(c)}function h(c){return c===null||R(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function Fu(e,t,n){return r;function r(s){return se(s)?Nt(e,i)(s):n(s)}function i(s){return io(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||R(s)?t(s):n(s)}}const Ru={name:\"hardBreakEscape\",tokenize:Ou};function Ou(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Mu={name:\"headingAtx\",resolve:Lu,tokenize:Vu};function Lu(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\"},_e(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Vu(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),a(d)}function a(d){return e.enter(\"atxHeadingSequence\"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||se(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||se(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Bu=[\"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\"],Ri=[\"pre\",\"script\",\"style\",\"textarea\"],Hu={concrete:!0,name:\"htmlFlow\",resolveTo:ju,tokenize:Wu},qu={partial:!0,tokenize:Qu},Uu={partial:!0,tokenize:Ku};function ju(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 Wu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),f}function f(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),o=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,p):Pe(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function c(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:$:p):n(g)}function w(g){return Pe(g)?(e.consume(g),o=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||se(g)){const q=g===47,le=o.toLowerCase();return!q&&!a&&Ri.includes(le)?(i=1,r.interrupt?t(g):$(g)):Bu.includes(o.toLowerCase())?(i=6,q?(e.consume(g),y):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?k(g):x(g))}return g===45||me(g)?(e.consume(g),o+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):b(g)}function x(g){return g===47?(e.consume(g),b):g===58||g===95||Pe(g)?(e.consume(g),A):L(g)?(e.consume(g),x):b(g)}function A(g){return g===45||g===46||g===58||g===95||me(g)?(e.consume(g),A):I(g)}function I(g){return g===61?(e.consume(g),_):L(g)?(e.consume(g),I):x(g)}function _(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),_):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||se(g)?I(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?x(g):n(g)}function b(g){return g===62?(e.consume(g),D):n(g)}function D(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),D):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),J):g===62&&i===4?(e.consume(g),N):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(qu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Uu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function J(g){return g===47?(e.consume(g),o=\"\",pe):$(g)}function pe(g){if(g===62){const q=o.toLowerCase();return Ri.includes(q)?(e.consume(g),N):$(g)}return Pe(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),pe):$(g)}function ke(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),N):g===45&&i===2?(e.consume(g),m):$(g)}function N(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),N)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Ku(e,t,n){const r=this;return i;function i(o){return R(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 Qu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Tn,t,n)}}const Gu={name:\"htmlText\",tokenize:Yu};function Yu(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),I):m===63?(e.consume(m),x):Pe(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,p):Pe(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),c):n(m)}function f(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=f,J(m)):(e.consume(m),f)}function h(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?h(m):f(m)}function p(m){const N=\"CDATA[\";return m===N.charCodeAt(a++)?(e.consume(m),a===N.length?w:p):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):R(m)?(o=w,J(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):w(m)}function k(m){return m===null||m===62?Z(m):R(m)?(o=k,J(m)):(e.consume(m),k)}function x(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(o=x,J(m)):(e.consume(m),x)}function A(m){return m===62?Z(m):x(m)}function I(m){return Pe(m)?(e.consume(m),_):n(m)}function _(m){return m===45||me(m)?(e.consume(m),_):P(m)}function P(m){return R(m)?(o=P,J(m)):L(m)?(e.consume(m),P):Z(m)}function T(m){return m===45||me(m)?(e.consume(m),T):m===47||m===62||se(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Pe(m)?(e.consume(m),b):R(m)?(o=z,J(m)):L(m)?(e.consume(m),z):Z(m)}function b(m){return m===45||m===46||m===58||m===95||me(m)?(e.consume(m),b):D(m)}function D(m){return m===61?(e.consume(m),$):R(m)?(o=D,J(m)):L(m)?(e.consume(m),D):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(o=$,J(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,J(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||se(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||se(m)?z(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function J(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),pe}function pe(m){return L(m)?H(e,ke,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ke(m)}function ke(m){return e.enter(\"htmlTextData\"),o(m)}}const Rr={name:\"labelEnd\",resolveAll:ec,resolveTo:tc,tokenize:nc},Ju={tokenize:rc},Zu={tokenize:ic},Xu={tokenize:ac};function ec(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function tc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},d={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(a+1,a+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,Pn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ie(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ie(s,e.slice(o+1)),s=ie(s,[[\"exit\",u,t]]),_e(e,a,e.length,s),e}function nc(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?f(h):(o=r.parser.defined.includes(Lt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Ju,d,o?d:f)(h):h===91?e.attempt(Zu,d,o?l:f)(h):o?d(h):f(h)}function l(h){return e.attempt(Xu,d,f)(h)}function d(h){return t(h)}function f(h){return a._balanced=!0,n(h)}}function rc(e,t,n){return r;function r(f){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),i}function i(f){return se(f)?Nt(e,a)(f):a(f)}function a(f){return f===41?d(f):no(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function o(f){return se(f)?Nt(e,u)(f):d(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?io(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):d(f)}function l(f){return se(f)?Nt(e,d)(f):d(f)}function d(f){return f===41?(e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(f)}}function ic(e,t,n){const r=this;return i;function i(s){return ro.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function ac(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 oc={name:\"labelStartImage\",resolveAll:Rr.resolveAll,tokenize:sc};function sc(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 lc={name:\"labelStartLink\",resolveAll:Rr.resolveAll,tokenize:uc};function uc(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 Vn={name:\"lineEnding\",tokenize:cc};function cc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const cn={name:\"thematicBreak\",tokenize:fc};function fc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const fe={continuation:{tokenize:gc},exit:_c,name:\"list\",tokenize:pc},dc={partial:!0,tokenize:yc},hc={partial:!0,tokenize:mc};function pc(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(c){const p=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:dr(c)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),c===42||c===45?e.check(cn,n,l)(c):l(c);if(!r.interrupt||c===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(c)}return n(c)}function u(c){return dr(c)&&++o<10?(e.consume(c),u):(!r.interrupt||o<2)&&(r.containerState.marker?c===r.containerState.marker:c===41||c===46)?(e.exit(\"listItemValue\"),l(c)):n(c)}function l(c){return e.enter(\"listItemMarker\"),e.consume(c),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||c,e.check(Tn,r.interrupt?n:d,e.attempt(dc,h,f))}function d(c){return r.containerState.initialBlankLine=!0,a++,h(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),h):n(c)}function h(c){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function gc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Tn,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(hc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(fe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function mc(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 _c(e){e.exit(this.containerState.type)}function yc(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 Oi={name:\"setextUnderline\",resolveTo:bc,tokenize:vc};function bc(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 vc(e,t,n){const r=this;let i;return a;function a(l){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){f=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const wc={tokenize:kc};function kc(e){const t=this,n=e.attempt(Tn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Eu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Sc={resolveAll:oo()},xc=ao(\"string\"),Cc=ao(\"text\");function ao(e){return{resolveAll:oo(e===\"text\"?Ic: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(d){return l(d)?a(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),a(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const c=f[h];if(!c.previous||c.previous.call(r,r.previous))return!0}return!1}}}function oo(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 Ic(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const Ec={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:Za},Ac={91:Nu},Pc={[-2]:Ln,[-1]:Ln,32:Ln},Tc={35:Mu,42:cn,45:[Oi,cn],60:Hu,61:Oi,95:cn,96:Fi,126:Fi},Dc={38:eo,92:Xa},Nc={[-5]:Vn,[-4]:Vn,[-3]:Vn,33:oc,38:eo,42:hr,60:[lu,Gu],91:lc,92:[Ru,Xa],93:Rr,95:hr,96:wu},$c={null:[hr,Sc]},zc={null:[42,95]},Fc={null:[]},Rc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:zc,contentInitial:Ac,disable:Fc,document:Ec,flow:Tc,flowInitial:Pc,insideSpan:$c,string:Dc,text:Nc},Symbol.toStringTag,{value:\"Module\"}));function Oc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(I),check:P(_),consume:k,enter:x,exit:A,interrupt:P(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:c,write:f};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function f(D){return o=ie(o,D),S(),o[o.length-1]!==null?[]:(T(t,0),l.events=Pn(a,l.events,l),l.events)}function h(D,$){return Lc(c(D),$)}function c(D){return Mc(o,D)}function p(){const{_bufferIndex:D,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:D,_index:$,line:B,column:U,offset:M}}function w(D){i[D.line]=D.column,b()}function S(){let D;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<$.length;)y($.charCodeAt(r._bufferIndex));else y($)}}function y(D){d=d(D)}function k(D){R(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,b()):D!==-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=D}function x(D,$){const B=$||{};return B.type=D,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(D){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function I(D,$){T(D,$.from)}function _(D,$){$.restore()}function P(D,$){return B;function B(U,M,Z){let J,pe,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):N(U);function N(ee){return St;function St(Ve){const ct=Ve!==null&&ee[Ve],ft=Ve!==null&&ee.null,zn=[...Array.isArray(ct)?ct:ct?[ct]:[],...Array.isArray(ft)?ft:ft?[ft]:[]];return j(zn)(Ve)}}function j(ee){return J=ee,pe=0,ee.length===0?Z:g(ee[pe])}function g(ee){return St;function St(Ve){return m=z(),ke=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?le():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,le)(Ve)}}function q(ee){return D(ke,m),M}function le(ee){return m.restore(),++pe<J.length?g(J[pe]):Z}}}function T(D,$){D.resolveAll&&!a.includes(D)&&a.push(D),D.resolve&&_e(l.events,$,l.events.length-$,D.resolve(l.events.slice($),l)),D.resolveTo&&(l.events=D.resolveTo(l.events,l))}function z(){const D=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=D,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Mc(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 Lc(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 Vc(e){const r={constructs:Vl([Rc,...(e||{}).extensions||[]]),content:i(tu),defined:[],document:i(ru),flow:i(wc),lazy:{},string:i(xc),text:i(Cc)};return r;function i(a){return o;function o(s){return Oc(r,a,s)}}}function Bc(e){for(;!to(e););return e}const Mi=/[\\0\\t\\n\\r]/g;function Hc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,f,h,c;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),f=0,t=\"\",n&&(a.charCodeAt(0)===65279&&f++,n=void 0);f<a.length;){if(Mi.lastIndex=f,l=Mi.exec(a),h=l&&l.index!==void 0?l.index:a.length,c=a.charCodeAt(h),!l){t=a.slice(f);break}if(c===10&&f===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<h&&(u.push(a.slice(f,h)),e+=h-f),c){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function qc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),eu(n)(Bc(Vc(n).document().write(Hc()(e,t,!0))))}const Bn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Uc(){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=Bn[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=Bn[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,jc)),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\"+Bn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function jc(e,t){return t===\"|\"?t:e}class Wc{constructor(){this.map=[]}add(t,n,r){Kc(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 Kc(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 Qc(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 Gc(){return{flow:{null:{name:\"table\",tokenize:Yc,resolveAll:Jc}}}}function Yc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let D=r.events.length-1;for(;D>-1;){const U=r.events[D][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")D--;else break}const $=D>-1?r.events[D][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?_:u;return B===_&&r.parser.lazy[r.now().line]?n(b):B(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),d(b)}function d(b){return b===null?n(b):R(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),c):n(b):L(b)?H(e,d,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,d):(e.enter(\"data\"),f(b)))}function f(b){return b===null||b===124||se(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:f)}function h(b){return b===92||b===124?(e.consume(b),f):f(b)}function c(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?S(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):I(b)}function w(b){return L(b)?H(e,S,\"whitespace\")(b):S(b)}function S(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),y):b===45?(a+=1,y(b)):b===null||R(b)?A(b):I(b)}function y(b){return b===45?(e.enter(\"tableDelimiterFiller\"),k(b)):I(b)}function k(b){return b===45?(e.consume(b),k):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(b))}function x(b){return L(b)?H(e,A,\"whitespace\")(b):A(b)}function A(b){return b===124?p(b):b===null||R(b)?!o||i!==a?I(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):I(b)}function I(b){return n(b)}function _(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||se(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Jc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,f;const h=new Wc;for(;++n<e.length;){const c=e[n],p=c[1];c[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Li(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,f=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=rn(h,t,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=rn(h,t,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],f=rn(h,t,a,i,n,f)):o[1]!==0&&(f=rn(h,t,o,i,n,f)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Li(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=Qc(t.events,n))}return e}function rn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},dt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=dt(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=dt(t.events,n[2]),d=dt(t.events,n[3]),f={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",f,t]]),r!==2){const h=t.events[n[2]],c=t.events[n[3]];if(h[1].end=Object.assign({},c[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",f,t]])}return i!==void 0&&(a.end=Object.assign({},dt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Li(e,t,n,r,i){const a=[],o=dt(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 dt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Zc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Xc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},f={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},h=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(h,h.length,0,Pn(c,o.slice(l+1,u),s)),_e(h,h.length,0,[[\"exit\",f,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",d,s]]),_e(o,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,d=this.events;let f=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),c(p))}function c(p){const w=Sn(l);if(p===126)return f>1?u(p):(o.consume(p),f++,c);if(f<2&&!n)return u(p);const S=o.exit(\"strikethroughSequenceTemporary\"),y=Sn(p);return S._open=!y||y===2&&!!w,S._close=!w||w===2&&!!y,s(p)}}}function ef(e){return qc(e,{allowDangerousHtml:!0,extensions:[Gc(),Xc(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Uc(),Zc()]})}const tf={update:()=>{},getValues:()=>({})},Ce=ot({}),Yt=ot(tf),ce=ot(!1),pr=ot(null);function nf(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)=>so(a,o,t));return v(Y,{children:i})}function so(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 u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>so(u,l,n));return Q(i,o,...s)}return null}function rf({node:e}){const t=$r(),n=G(ce),r=G(Ce),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return Q(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function af(){const e=G(pr),t=G(ce),n=G(Ce);return!e||e.length===0?null:v(Y,{children:Ie(e,{nobr:t,locals:n})})}function of(e,t){if(Ll(e.name))return null;const n=Fl(e.name);if(n)return v(zl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=Ol(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 gr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?v(af,{},t):v(wl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return of(e,t);case\"html\":return v(rf,{node:e},t);default:return e}}function lo(e){return e.length===0?null:e.map((t,n)=>gr(t,n))}function sf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function lf(e,t){const n=C.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>gr(s,u));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&sf(i))i+=lf(u,a);else{const l=r.length;r.push(gr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=ef(i);return nf(o,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 cf(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\")}const ff=\"spindle\",df=1;let an=null,Hn=null;function je(){return Hn||(Hn={saves:new Map,playthroughs:new Map,meta:new Map}),Hn}function hf(){return an||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(an=new Promise((e,t)=>{const n=indexedDB.open(ff,df);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),an))}function We(e,t){return hf().then(n=>n.transaction(e,t).objectStore(e))}function Ke(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function Dn(e){try{const t=await We(\"saves\",\"readwrite\");await Ke(t.put(e))}catch{je().saves.set(e.meta.id,e)}}async function kt(e){try{const t=await We(\"saves\",\"readonly\");return await Ke(t.get(e))??void 0}catch{return je().saves.get(e)}}async function uo(e){try{const t=await We(\"saves\",\"readwrite\");await Ke(t.delete(e))}catch{je().saves.delete(e)}}async function pf(e){try{const n=(await We(\"saves\",\"readonly\")).index(\"ifid\");return await Ke(n.getAll(e))??[]}catch{return[...je().saves.values()].filter(t=>t.meta.ifid===e)}}async function co(e){try{const t=await We(\"playthroughs\",\"readwrite\");await Ke(t.put(e))}catch{je().playthroughs.set(e.id,e)}}async function Or(e){try{const n=(await We(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Ke(n.getAll(e))??[]}catch{return[...je().playthroughs.values()].filter(t=>t.ifid===e)}}async function $e(e){try{const t=await We(\"meta\",\"readonly\"),n=await Ke(t.get(e));return n?n.value:void 0}catch{return je().meta.get(e)}}async function Vt(e,t){try{const n=await We(\"meta\",\"readwrite\");await Ke(n.put({key:e,value:t}))}catch{je().meta.set(e,t)}}const fo=new Map,Nn=new Map;function gf(e,t){fo.set(e,t),Nn.set(t,e)}function mf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[u,l]of r)s.set(n(u),n(l));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const u of r)s.add(n(u));return s}const a=i.constructor;if(Nn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(mf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Je=\"__spindle_class__\",Ze=\"__spindle_data__\";function et(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),{[Je]:\"__Date__\",[Ze]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Je]:\"__RegExp__\",[Ze]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}if(r instanceof Map){const u=[...r].map(([l,d])=>[n(l),n(d)]);return t.delete(i),{[Je]:\"__Map__\",[Ze]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[Je]:\"__Set__\",[Ze]:{entries:u}}}const a=i.constructor,o=Nn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Je]:o,[Ze]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function tt(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(Je in r&&Ze in r){const o=r[Je],s=r[Ze];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const d=s.entries;return new Map(d.map(([f,h])=>[t(f),t(h)]))}if(o===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=fo.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const d={};for(const f of Object.keys(s))d[f]=t(s[f]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(Nn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let mr=null,_r=null,Vi=!1;function _f(e){mr=e}function yf(e){_r=e}function bf(e){if(_r)try{const i=new Function(\"passage\",\"variables\",_r)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(mr)try{const r=mr(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 vf(){Vi||(Vi=!0)}async function Bi(e){const n=(await Or(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await co(i),await Vt(`currentPlaythroughId.${e}`,r),r}async function wf(e){return $e(`currentPlaythroughId.${e}`)}async function ho(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:bf(n),passage:n.passage,custom:r},o=re(n);o.variables=et(o.variables),o.history=o.history.map(u=>({...u,variables:et(u.variables)}));const s={meta:a,payload:o};return await Dn(s),s}async function po(e,t,n){const r=await kt(e);if(!r)return;const i=re(t);i.variables=et(i.variables),i.history=i.history.map(o=>({...o,variables:et(o.variables)}));const a={meta:{...r.meta,updatedAt:new Date().toISOString(),passage:t.passage,...n!=null?{custom:{...r.meta.custom,...n}}:{}},payload:i};return await Dn(a),a}async function kf(e){const t=await kt(e);if(!t)return;const n=t.payload;return n.variables=tt(n.variables),n.history=n.history.map(r=>({...r,variables:tt(r.variables)})),n}async function Sf(e){await uo(e)}async function xf(e,t){const n=await kt(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await Dn(r)}async function Cf(e){const[t,n]=await Promise.all([pf(e),Or(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const If=\"autosave.\",Ef=\"slot.\",$n=\"slotIndex.\";function Jt(e,t){return t!=null?`${Ef}${t}.${e}`:`${If}${e}`}async function Af(e,t,n,r,i){const a=Jt(e,r),o=await $e(a);if(o){const u=await po(o,n,i);if(u)return u}const s=await ho(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await Vt(a,s.meta.id),r!=null){const u=`${$n}${e}`,l=await $e(u)??[];l.includes(r)||await Vt(u,[...l,r])}return s}async function Hi(e,t){const n=Jt(e,t),r=await $e(n);return r?await kt(r)!==void 0:!1}async function Pf(e,t){const n=Jt(e,t),r=await $e(n);if(r)return kf(r)}async function Tf(e){const t={};await Hi(e)&&(t[\"\"]=!0);const n=`${$n}${e}`,r=await $e(n)??[];for(const i of r)await Hi(e,i)&&(t[i]=!0);return t}async function yr(e,t){const n=Jt(e,t),r=await $e(n);if(!r)return null;const i=await kt(r);return i?{slot:t??\"\",title:i.meta.title,passage:i.meta.passage,createdAt:i.meta.createdAt,updatedAt:i.meta.updatedAt,custom:i.meta.custom??{}}:null}async function Df(e){const t=[],n=await yr(e);n&&t.push(n);const r=`${$n}${e}`,i=await $e(r)??[];for(const a of i){const o=await yr(e,a);o&&t.push(o)}return t}async function Nf(e,t){const n=Jt(e,t),r=await $e(n);if(r&&(await uo(r),await Vt(n,void 0),t!=null)){const i=`${$n}${e}`,o=(await $e(i)??[]).filter(s=>s!==t);await Vt(i,o)}}const Mr=\"spindle.session.\";function $f(e,t){try{sessionStorage.setItem(`${Mr}${e}`,JSON.stringify(t))}catch{}}function zf(e){try{const t=sessionStorage.getItem(`${Mr}${e}`);if(!t)return;const n=JSON.parse(t);if(!cf(n))return;const r=n;return r.variables=tt(r.variables),r.history=r.history.map(i=>({...i,variables:tt(i.variables)})),r}catch{return}}function Ff(e){try{sessionStorage.removeItem(`${Mr}${e}`)}catch{}}async function Rf(e){const t=await kt(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Of(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=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Or(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await co(a)}return await Dn(n),n}function go(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=bt(t.content),i=vt(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),xe(Q(()=>Ie(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&yf(n.content)}let mo=0,ve=[],qn=!1,lt=[],$t=null,Me=null;function Lr(e){const t=C.getState();try{return!!An(e,t.variables,t.temporary)}catch{return!1}}function _o(e,t){const n=mo++,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:Lr(e),priority:i?.priority??0};return ve.push(o),ve.sort((s,u)=>u.priority-s.priority),()=>{ve=ve.filter(s=>s.id!==n)}}function yo(e){ve=ve.filter(t=>t.name!==e)}function Mf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();ja(n.run,r.variables,r.temporary)}n.dialog&&(lt.push({passageName:n.dialog}),$t?.()),n.goto&&C.getState().navigate(n.goto)}}const Lf=10;function Vf(){if(!qn){qn=!0;try{for(let e=0;e<Lf;e++){let t=!1;const n=[...ve];for(const r of n){if(!ve.includes(r))continue;const i=Lr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ve=ve.filter(o=>o.id!==r.id)),Mf(r))}if(!t)break}}finally{qn=!1}}}function Bf(){for(const e of ve)e.lastResult=Lr(e.condition)}function Hf(){ve=[],lt=[],mo=0,Me?.closeAll()}function qf(e){return $t=e,lt.length>0&&e(),()=>{$t===e&&($t=null)}}function Uf(){return lt.shift()}function jf(){return lt.length}function Wf(e){Me?Me.push(e):(lt.push(e),$t?.())}function Kf(){lt=[]}function Qf(e){return Me=e,()=>{Me===e&&(Me=null)}}function Gf(){Me?.close()}function Yf(){Kf(),Me?.closeAll()}function Jf(){return Me?.isOpen()??!1}ol();const Zf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Xe={},ye=[],Be={};function qi(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Ui(e,t){const[,n,r]=ll(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:qi(n),inverse:qi(r)}}function Xf(e){let t=Xe;for(let n=0;n<e;n++)t=ht(t,ye[n].forward);return t}let be=[];function Un(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(be.length>i.length&&(be.length=i.length),be.length<i.length)if(i.length-be.length===1){const l=i.length-1;be[l]={passage:i[l].passage,variables:et(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Xe;for(let d=0;d<i.length;d++)if(d>0&&(l=ht(l,ye[d-1].forward)),d>=be.length){const f=d===i.length-1?r:l;be[d]={passage:i[d].passage,variables:et(f),timestamp:i[d].timestamp,prng:i[d].prng}}}$f(t.ifid,{passage:n,variables:et(r),history:be,historyIndex:a,visitCounts:o,renderCounts:s,prng:kn()})}}function ji(e){Xe=e,ye=[],Be=e,be=[]}function Wi(e){e?.prng?Ba(e.prng.seed,e.prng.pull):e&&ur()}const C=qs()(cl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=re(r);ji(re(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Be=t().variables;const o=n.ifid;vf().then(async()=>{const s=await wf(o);if(s)e(l=>{l.playthroughId=s});else{const l=await Bi(o);e(d=>{d.playthroughId=l})}const u=await Tf(o);Object.keys(u).length>0&&e(l=>{l.knownSaves=u})}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Zf.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=Ui(Be,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),ye.length=o.historyIndex,ye.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:kn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Xe=ht(Xe,ye[u].forward);o.history=o.history.slice(s),ye=ye.slice(s),be=be.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Be=t().variables,Un(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(ht(r,ye[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Be=t().variables,Wi(t().history[t().historyIndex]),Un(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=re(ht(i,ye[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Be=t().variables,Wi(t().history[t().historyIndex]),Un(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;ur(),Hf();const a=re(r);ji(re(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Be=t().variables,go(),Ff(n.ifid),Bi(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:(n,r)=>{const{storyData:i,playthroughId:a}=t();if(!i)return;const o=t().getSavePayload();e(s=>{s.saveError=null}),Af(i.ifid,a,o,n,r).then(()=>{e(s=>{s.knownSaves={...s.knownSaves,[n??\"\"]:!0}})}).catch(s=>{console.error(\"spindle: failed to save\",s),e(u=>{u.saveError=s instanceof Error?s.message:\"Failed to save\"})})},load:n=>{const{storyData:r}=t();r&&(e(i=>{i.loadError=null}),Pf(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?yr(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?Df(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&Nf(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)})},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Xe;for(let d=0;d<i.length;d++)d>0&&(l=ht(l,ye[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:kn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=tt(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=tt(n.history[o].variables);i.push(Ui(a,s)),a=s}Xe=re(r),ye=i,be=[],e(o=>{o.currentPassage=n.passage,o.variables=tt(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={}}),Be=t().variables,n.prng?Ba(n.prng.seed,n.prng.pull):ur()},getHistoryVariables:n=>re(Xf(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}}))),ed=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function td(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:ed,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const a=bt(n),o=vt(a);return v(Y,{children:lo(o)})}catch(a){return v(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?v(ce.Provider,{value:!0,children:i}):i}const bo=ot(null);function Vr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=oe(r);a.current=r;const o=he(()=>a.current(),[]),s=C(c=>c.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,d=de(()=>{if(!l)return v(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=bt(l),p=vt(c);return Ie(p)}catch(c){return v(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&o()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return v(bo.Provider,{value:o,children:v(\"div\",{class:\"dialog-overlay\",onClick:f,children:v(\"div\",{class:h,children:[i&&v(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),v(\"div\",{class:\"dialog-body\",children:d})]})})})}function nd(){const[e,t]=X([]),n=oe(e);n.current=e;const r=he(o=>{t(s=>[...s,o])},[]),i=he(()=>{t(o=>o.slice(0,-1))},[]),a=he(()=>{t([])},[]);return we(()=>Qf({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),we(()=>qf(()=>{const o=[];for(;jf()>0;){const s=Uf();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:v(Y,{children:e.map((o,s)=>v(Vr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function rd(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(we(()=>{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 v(\"div\",{class:\"loading\",children:\"Loading...\"});const r=v(Y,{children:[v(td,{}),v(nd,{})]});return n?v(ce.Provider,{value:!0,children:r}):r}function id(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function ad(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,f=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",w=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),S=id(h.innerHTML),y={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)k.has(A.name)||(y[A.name]=A.value);const x={pid:c,name:p,tags:w,metadata:y,content:S};d.set(p,x),f.set(c,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:d,passagesById:f,userCSS:s,userScript:l}}const It=new Map;let ue={},Ki=!1;function vo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function od(){localStorage.setItem(vo(),JSON.stringify(ue))}function jn(){if(!Ki){Ki=!0;try{const e=localStorage.getItem(vo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ue={...ue,...t})}}catch{}}}const Bt={addToggle(e,t){It.set(e,{type:\"toggle\",config:t}),e in ue||(ue[e]=t.default),jn()},addList(e,t){It.set(e,{type:\"list\",config:t}),e in ue||(ue[e]=t.default),jn()},addRange(e,t){It.set(e,{type:\"range\",config:t}),e in ue||(ue[e]=t.default),jn()},get(e){return ue[e]},getToggle(e){const t=ue[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ue[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ue[e];return typeof t==\"number\"?t:0},set(e,t){ue[e]=t,od()},getAll(){return{...ue}},getDefinitions(){return It},hasAny(){return It.size>0}};function sd(e,t,n){const r=C.getState(),i=re(r.variables),a=re(r.temporary),o={...t};ja(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(s,o[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const xn=new Map,br=new Set,vr=new Map;function ld(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(vr.get(r)??0)+1;return vr.set(r,i),i===1?r:`${r}:${i}`}function ud(e){return xn.set(e.id,e),Gi(),()=>{xn.delete(e.id),Gi()}}function Qi(){return Array.from(xn.values())}function cd(e){return xn.get(e)}function fd(){vr.clear()}function dd(e){return br.add(e),()=>{br.delete(e)}}function Gi(){for(const e of br)e()}function hd(e){const t=oe(\"\"),n=oe(e.perform);n.current=e.perform,t.current||(t.current=ld(e.type,e.key,e.authorId));const r=t.current;return st(()=>{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),ud(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function pd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function wo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Br(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?wo(t):\"\"}function gd(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 md(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 _d(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const yd={useState:X,useRef:oe,useEffect:we,useLayoutEffect:st,useCallback:he,useMemo:de,useContext:G};function Yi(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function bd(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 V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=$r(),r=a(r),i=a(i));const{update:o,getValues:s}=G(Yt),u=G(ce),l=G(Ce),f={collectText:pd,sourceLocation:Br,parseVarArgs:gd,extractOptions:md,h:Q,renderNodes:(h,c)=>Ie(h,{nobr:u,locals:l,...c}),renderInlineNodes:lo,hooks:yd,useAction:hd,className:r,id:i,resolve:a,cls:_d(e.name,r),mutate:h=>sd(h,s(),o),update:o,getValues:s,wrap:h=>r||i?Q(\"span\",{id:i,class:r},h):Q(Y,null,h)};if(e.merged){f.merged=Nr();const h=f.merged;f.evaluate=c=>An(c,h[0],h[1],h[2])}if(e.storeVar){const c=(n.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),p=c.split(\".\");f.varName=c,f.value=C(w=>Yi(w.variables,p)),f.getValue=()=>Yi(C.getState().variables,p),f.setValue=w=>{C.setState(S=>{bd(S.variables,p,w)})}}return e.render(n,f)}if(Rl(e.name,t),e.subMacros)for(const n of e.subMacros)Ml(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&lr(e.name)}function vd(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e,t){C.getState().save(e,t)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},getSaveInfo(e){return C.getState().getSaveInfo(e)},listSaves(){return C.getState().listSaves()},deleteSave(e){C.getState().deleteSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:Bt,registerClass(e,t){gf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){_f(e)}},getActions(){return Qi()},performAction(e,t){const n=cd(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return dd(t);if(e===\"variableChanged\"){let n={...C.getState().variables};return C.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Qi())})})})},watch(e,t){return _o(e,t)},unwatch(e){yo(e)},openDialog(e,t){Wf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Gf()},closeAllDialogs(){Yf()},isDialogOpen(){return Jf()},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)},random(){return zr()},randomInt(e,t){return Ha(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){kl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=kn())})},isEnabled(){return Sl()},get seed(){return xl()},get pull(){return Cl()}}}}function wd(){window.Story=vd()}const kd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Ji=/\\$(\\w+(?:\\.\\w+)*)/g,Zi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Sd=new Set([\"number\",\"string\",\"boolean\"]);function ko(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,ko(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Sd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function xd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(kd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=ko(s);t.set(a,{...u,name:a,default:s})}return t}function Cd(e){const t=new Set;let n;for(Zi.lastIndex=0;(n=Zi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Id(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function Ed(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Cd(i.content);let o;for(Ji.lastIndex=0;(o=Ji.exec(i.content))!==null;){const s=o[1],u=Id(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Ad(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function fn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&fn(t.children))return!0;if(t.type===\"macro\"){if(fn(t.children))return!0;if(t.branches){for(const n of t.branches)if(fn(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function qe({macro:e,error:t}){return v(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Br()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return v(qe,{macro:\"print\",error:n})}}});function Pd(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function Td(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 Xi(e,t,n,r,i,a,o){let s;try{s=An(e,r,i,a)}catch(l){console.error(`spindle: Error in {computed ${o}}${Br()}:`,l);return}const u=n?i[t]:r[t];if(!Td(u,s)){const l=C.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=Pd(e))}catch(d){return v(qe,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,Xi(o,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{Xi(o,u,s,n,r,i,e)},[n,r,i]),null}});function Dd(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=Nd(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 Nd(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 $d(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=Dd(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=$d(a,o,i),l=t.cls;return v(\"div\",{class:l,id:t.id,children:[v(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&v(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return v(qe,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?v(\"span\",{id:o,class:a,children:i}):v(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 v(qe,{macro:\"if\",error:i})}}return null}});function zd(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 Fd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=X(()=>({...n})),o={...e,...t,...i},s=oe(o);s.current=o;const u=he(()=>s.current,[]),l=he((h,c)=>{a(p=>({...p,[h]:c}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),f=G(ce);return v(Yt.Provider,{value:d,children:v(Ce.Provider,{value:o,children:Ie(r,{nobr:f,locals:o})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=G(Ce);let i;try{i=zd(e)}catch(d){return v(qe,{macro:\"for\",error:d})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return v(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return v(qe,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const h={[a]:d,...o?{[o]:f}:void 0};return v(Fd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=G(ce),a=()=>{const o=document.createElement(\"div\"),s=Q(ce.Provider,{value:i},Q(Yt.Provider,{value:{update:n.update,getValues:n.getValues}},Q(Ce.Provider,{value:n.getValues()},Ie(t))));xe(s,o),xe(null,o)};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 Rd(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 ea(e,t,n,r){const i=document.createElement(\"div\"),a=Q(ce.Provider,{value:r},Q(Yt.Provider,{value:{update:n,getValues:t}},Q(Ce.Provider,{value:t()},Ie(e))));xe(a,i),xe(null,i)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Rd(e),a=G(ce),o=s=>{s.preventDefault(),ea(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:()=>{ea(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),v(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return v(qe,{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 v(Y,{children:n.renderNodes(o.children)})}catch(s){return v(qe,{macro:\"case\",error:s})}}return i?v(Y,{children:n.renderNodes(i.children)}):null}});function Hr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(c=>({delay:c.rawArgs?Hr(c.rawArgs):0,nodes:c.children,className:c.className,id:c.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const c=o+1,p=a[c].delay,w=setTimeout(()=>{s(c)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),d=t.resolve(u.className),f=t.resolve(u.id),h=d||f?v(\"span\",{id:f,class:d,children:l}):l;return t.wrap(h)}});const So=ot({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Hr(e),[s,u]=r(0),[l,d]=r(!1),f=a(()=>d(!0),[]);if(i(()=>{if(l)return;const c=setInterval(()=>{u(p=>p+1)},o);return()=>clearInterval(c)},[o,l]),s===0&&!l)return null;const h=v(So.Provider,{value:{stop:f},children:v(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?v(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(So);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Hr(e),s=a(null),[u,l]=r(0),[d,f]=r(0),h=a(0);h.current=d,i(()=>{if(s.current){const w=s.current.textContent||\"\";l(w.length)}},[]),i(()=>{if(u===0||h.current>=u)return;const w=setInterval(()=>{f(S=>S>=u?(clearInterval(w),S):S+1)},o);return()=>clearInterval(w)},[u,o]);const c=d>=u&&u>0,p=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return v(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[v(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!c?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!c&&u>0&&v(\"span\",{class:\"macro-type-cursor\"})]})}});function Od(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Od(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{Ka(r,t,i)},[r,a,o]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return v(\"span\",{id:t.id,class:r,children:n})}});function ut(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),v(Y,{children:[v(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&v(Vr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}ut({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});ut({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});ut({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});ut({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()}}});ut({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});ut({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});ut({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Bt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({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,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return v(Y,{children:[v(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&v(Vr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function Md(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 Ld(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Vd(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,a]=X(!0),[o,s]=X(null),[u,l]=X(()=>new Set),[d,f]=X(null),[h,c]=X(\"\"),p=oe(null),w=oe(null),S=G(bo),y=C(N=>N.storyData),k=C(N=>N.playthroughId),x=C(N=>N.getSavePayload),A=C(N=>N.loadFromPayload),I=y?.ifid??\"\",_=he(async()=>{if(!I)return;const N=await Cf(I);r(N),a(!1)},[I]);we(()=>{_()},[_]),we(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=oe(),T=(N,j=\"success\")=>{clearTimeout(P.current),s({text:N,type:j}),P.current=window.setTimeout(()=>s(null),3e3)};we(()=>()=>clearTimeout(P.current),[]);const z=N=>{l(j=>{const g=new Set(j);return g.has(N)?g.delete(N):g.add(N),g})},b=async()=>{if(!(!I||!k))try{const N=x();await ho(I,k,N),T(\"Save created\"),await _()}catch{T(\"Failed to create save\",\"error\")}},D=async N=>{try{const j=x();await po(N,j),T(\"Save overwritten\"),await _()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async N=>{try{A(N.payload),T(\"Game loaded\"),S&&setTimeout(S,500)}catch{T(\"Failed to load save\",\"error\")}},B=async N=>{if(confirm(\"Delete this save?\"))try{await Sf(N),T(\"Save deleted\"),await _()}catch{T(\"Failed to delete save\",\"error\")}},U=N=>{f(N.meta.id),c(N.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await xf(d,h.trim()),f(null),T(\"Save renamed\"),await _()}catch{T(\"Failed to rename\",\"error\")}},Z=N=>{N.key===\"Enter\"?M():N.key===\"Escape\"&&f(null)},J=async N=>{try{const j=await Rf(N);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),le=document.createElement(\"a\");le.href=q,le.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,le.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},pe=()=>{w.current?.click()},ke=async N=>{const j=N.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),le=JSON.parse(q);if(!uf(le))throw new Error(\"Invalid save file format\");await Of(le,I),T(\"Save imported\"),await _()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((N,j)=>N+j.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:pe,children:\"Import\"}),v(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),v(\"div\",{class:\"saves-body\",children:[i?v(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?v(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(N=>{const j=u.has(N.playthrough.id),g=N.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&N.saves.length===0&&!g?null:v(\"div\",{class:\"playthrough-group\",children:[v(\"div\",{class:\"playthrough-header\",onClick:()=>z(N.playthrough.id),children:[v(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),v(\"span\",{class:\"playthrough-label\",children:[N.playthrough.label,g?\" (current)\":\"\"]}),v(\"span\",{class:\"playthrough-date\",children:Ld(N.playthrough.createdAt)})]}),!j&&v(\"div\",{class:\"playthrough-saves\",children:[N.saves.map(q=>v(\"div\",{class:\"save-slot\",children:[v(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?v(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:le=>c(le.target.value),onKeyDown:Z,onBlur:M}):v(\"div\",{class:\"save-slot-title\",children:q.meta.title}),v(\"div\",{class:\"save-slot-meta\",children:[v(\"span\",{children:q.meta.passage}),v(\"span\",{children:Md(q.meta.updatedAt)})]})]}),v(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?v(\"button\",{class:\"save-slot-action primary\",onClick:()=>D(q.meta.id),children:\"Save Here\"}):v(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),v(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},N.playthrough.id)}),e===\"save\"&&!i&&!n.some(N=>N.playthrough.id===k)&&v(\"div\",{class:\"playthrough-group\",children:v(\"div\",{class:\"playthrough-saves\",children:v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&v(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return v(Vd,{})}});function Bd({name:e,def:t}){const[n,r]=X(()=>Bt.get(e)),i=a=>{r(a),Bt.set(e,a)};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:a=>i(a.target.checked)})]});case\"list\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>v(\"option\",{value:a,children:a},a))})]});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:a=>i(parseFloat(a.target.value))})]})}}function Hd(){const e=Bt.getDefinitions();return v(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>v(Bd,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return v(Hd,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const f=t.evaluate(i);a=String(f)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return v(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=bt(o.content),l=vt(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(ce.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(ce.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _name, or @name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),v(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),v(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),v(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function qd(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=qd(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)}),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 Ud(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]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Ud(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]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),v(\"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=>v(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const 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()}}),v(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function At(e){const t=bt(e.content),n=vt(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const jd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Wd({passage:e,dataTransition:t}){const n=C(w=>w.storyData),r=jd.has(e.name),[i,a]=X(!1),o=de(()=>{try{return At(e)}catch(w){return v(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",wo(e),\":\",\" \",w instanceof Error?w.message:String(w)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=de(()=>{if(!s)return null;try{return At(s)}catch(w){return console.error(\"spindle: Error in PassageHeader:\",w),null}},[s?.content]),f=de(()=>{if(!u)return null;try{return At(u)}catch(w){return console.error(\"spindle: Error in PassageFooter:\",w),null}},[u?.content]);we(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return At(l)}catch(w){return console.error(\"spindle: Error in PassageDone:\",w),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),p=v(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&v(\"div\",{class:\"passage-header\",children:d}),o,f&&v(\"div\",{class:\"passage-footer\",children:f}),h&&v(\"div\",{hidden:!0,children:h})]});return c?v(ce.Provider,{value:!0,children:p}):p}const Kd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),wr={type:\"fade-through\",duration:300,pause:50};function Qd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Kd.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 Wn(e){return{type:e.type,duration:e.duration??wr.duration,pause:e.pause??wr.pause}}function Gd(e,t,n){const r=Qd(e);return r?Wn(r):t?Wn(t):n?Wn(n):{...wr}}function ta(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 Kn(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 Qn(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()}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(c=>c.currentPassage),r=C(c=>c.storyData),[i,a]=X(n),o=oe(\"fade\"),s=oe(0),u=oe(null),l=oe([]),d=he(()=>{for(const c of l.current)clearTimeout(c);l.current=[],Qn(u.current)},[]);we(()=>{const c=C.getState(),{history:p,historyIndex:w,transitionConfig:S}=c,y=c.consumeNextTransition(),k=s.current;s.current=p.length;const x=!i,A=p.length===1&&w===0&&k>1,I=p.length>1&&w===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const _=r?.passages.get(n);if(!_){o.current=\"none\",a(n);return}if(x||A||I){o.current=\"fade\",a(n);return}const P=Gd(_.tags,y,S);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Kn(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Kn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=ta(z,P.type);T.appendChild(b),a(\"\");const D=P.duration+P.pause,$=setTimeout(()=>{a(n)},D),B=D+P.duration,U=setTimeout(()=>{Qn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Kn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=ta(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const D=setTimeout(()=>{Qn(T)},P.duration);l.current=[D];return}a(n)},[n]);const f=i?r?.passages.get(i):null;if(!f&&i)return v(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return v(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&v(\"div\",{hidden:!0,children:At(h)},`ready-${n}`),v(\"div\",{class:\"passage-container\",ref:u,children:f&&v(Wd,{passage:f,dataTransition:o.current},i)})]})}});V({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={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const f=l[1]??l[5],h=l[2]??l[3]??l[4];if(f)switch(f){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 d=n.useRef(!1);return d.current||(d.current=!0,_o(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,yo(r)),null}});const Yd='*,*: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 na(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 ra(){const e=ad(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Yd,document.head.appendChild(t),wd(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",p=document.getElementById(\"root\");throw p&&na(p,[c]),new Error(`spindle: ${c}`)}const i=xd(r.content),a=Ed(e.passages,i);if(a.length>0){const c=document.getElementById(\"root\");throw c&&na(c,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=Ad(i),C.getState().init(e,n),go();const o=zf(e.ifid);o&&C.getState().loadFromPayload(o);const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){let p;for(;(p=s.exec(c.content))!==null;){const w=p[1],S=p[2];/\\{@children\\}/.test(S)&&lr(w)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const p=bt(c.content),w=vt(p);for(const S of w)if(S.type===\"macro\"&&S.name===\"widget\"&&S.rawArgs){const y=S.rawArgs.trim().split(/\\s+/),k=y[0].replace(/[\"']/g,\"\"),x=y.slice(1).filter(_=>_.startsWith(\"$\")||_.startsWith(\"_\")||_.startsWith(\"@\")),A=S.children,I=fn(A);Ka(k,A,x,I),I&&lr(k)}}let u=\"\";C.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,fd())});let l=C.getState().variables,d=C.getState().historyIndex;C.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?Vf():Bf()),l=c.variables,d=c.historyIndex});const f=e.passages.get(\"StoryInterface\");f&&!f.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const h=document.getElementById(\"root\");if(!h)throw new Error('spindle: No <div id=\"root\"> element found.');xe(v(rd,{}),h),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ra):ra();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})