@rohal12/spindle 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.35.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Ht,O,ia,Ge,Jr,aa,oa,sa,kr,Gn,Yn,la,dn={},hn=[],Zo=/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 Xo(){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 es(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,es(e);pn.__r=0}function ca(e,t,n,r,i,a,o,s,u,l,d){var f,p,c,h,v,S,_,w=r&&r.__k||hn,x=t.length;for(u=ts(n,t,w,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(p=c.__i!=-1&&w[c.__i]||dn,c.__i=f,S=xr(e,c,p,i,a,o,s,u,l,d),h=c.__e,c.ref&&p.ref!=c.ref&&(p.ref&&Cr(p.ref,null,c),d.push(c.ref,c.__c||h,c)),v==null&&h!=null&&(v=h),(_=!!(4&c.__u))||p.__k===c.__k?u=fa(c,u,e,_):typeof c.type==\"function\"&&S!==void 0?u=S:h&&(u=h.nextSibling),c.__u&=-7);return n.__e=v,u}function ts(e,t,n,r,i){var a,o,s,u,l,d=n.length,f=d,p=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=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+p,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ns(o,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?p--:i<d&&p++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?p--:l==u+1?p++:(l>u?p--:p++,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 ns(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\"||Zo.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,p,c,h,v,S,_,w,x,A,I,y,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(_=t.props,w=\"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:(w?t.__c=f=new z(_,A):(t.__c=f=new De(_,A),f.constructor=z,f.render=is),x&&x.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),w&&f.__s==null&&(f.__s=f.state),w&&z.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Te({},f.__s)),Te(f.__s,z.getDerivedStateFromProps(_,f.__s))),c=f.props,h=f.state,f.__v=t,p)w&&z.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),w&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(w&&z.getDerivedStateFromProps==null&&_!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(_,A),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(_,f.__s,A)===!1){t.__v!=n.__v&&(f.props=_,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(_,f.__s,A),w&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,h,v)})}if(f.context=A,f.props=_,f.__P=e,f.__e=!1,I=O.__r,y=0,w)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&&++y<25);f.state=f.__s,f.getChildContext!=null&&(r=Te(Te({},r),f.getChildContext())),w&&!p&&f.getSnapshotBeforeUpdate!=null&&(v=f.getSnapshotBeforeUpdate(c,h)),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=rs(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 rs(e,t,n,r,i,a,o,s,u){var l,d,f,p,c,h,v,S=n.props||dn,_=t.props,w=t.type;if(w==\"svg\"?i=\"http://www.w3.org/2000/svg\":w==\"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==!!w&&(w?c.localName==w:c.nodeType==3)){e=c,a[l]=null;break}}if(e==null){if(w==null)return document.createTextNode(_);e=document.createElementNS(i,w,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(w==null)S===_||s&&e.data==_||(e.data=_);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 _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Zt(e,l,null,c,i);for(l in _)c=_[l],l==\"children\"?p=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?h=c:l==\"checked\"?v=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(p)?p:[p],t,n,r,w==\"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\",w==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[l]||w==\"progress\"&&!h||w==\"option\"&&h!=S[l])&&Zt(e,l,h,S[l],i),l=\"checked\",v!=null&&v!=e[l]&&Zt(e,l,v,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 is(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 as(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 os=0;function k(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:--os,__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,Rn,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(p){return p.__c});if(d.every(function(p){return!p.__N}))return!a||a.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(p){if(p.__N){var c=p.__[0];p.__=p.__N,p.__N=void 0,c!==p.__[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 ss(){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&&(Rn===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)),Rn=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)||ls)(ss)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Rn=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 ls(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 p=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,p))}},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},us=(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,Fn(i)&&a({t:i})},[e,n,t]),we(function(){return Fn(i)&&a({t:i}),e(function(){Fn(i)&&a({t:i})})},[e]),n}function Fn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function 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 cs(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 fs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ds(e){function t(n){var r=wa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=fs,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))},hs={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},ps=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)}ps(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 gs(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 ms(e){return this.getChildContext=function(){return e.context},e.children}function _s(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(ms,{context:t.context},e.__v),t.v)}function ys(e,t){var n=Q(_s,{__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,bs=/^(?: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]/,vs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ws=/[A-Z0-9]/g,ks=typeof document<\"u\",Ss=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function xs(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Cs(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 Is(){}function Es(){return this.cancelBubble}function As(){return this.defaultPrevented}O.event=function(e){return hi&&(e=hi(e)),e.persist=Is,e.isPropagationStopped=Es,e.isDefaultPrevented=As,e.nativeEvent=e};var Ar,Ps={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||ks&&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\"||Ss(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":vs.test(o)&&(o=u):u=o=\"oninput\":a&&bs.test(o)?o=o.replace(ws,\"-$&\").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\",Ps)):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 Ts={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 Ds(e){return Q.bind(null,e)}function Cn(e){return!!e&&e.$$typeof===Ta}function Ns(e){return Cn(e)&&e.type===Y}function $s(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function zs(e){return Cn(e)?as.apply(null,arguments):e}function Rs(e){return!!e.__k&&(xe(null,e),!0)}function Fs(e){return e&&(e.base||e.nodeType===1&&e)||null}var Os=function(e,t){return e(t)},Ms=function(e,t){return e(t)},Ls=Y,Vs=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:hs,render:xs,hydrate:Cs,unmountComponentAtNode:Rs,createPortal:ys,createElement:Q,createContext:ot,createFactory:Ds,cloneElement:zs,createRef:Xo,Fragment:Y,isValidElement:Cn,isElement:Vs,isFragment:Ns,isMemo:$s,findDOMNode:Fs,Component:De,PureComponent:tr,memo:cs,forwardRef:ds,flushSync:Ms,unstable_batchedUpdates:Os,StrictMode:Ls,Suspense:sn,SuspenseList:Et,lazy:gs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ts};const Bs=e=>e;function Hs(e,t=Bs){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 qs=e=>{const t=us(e),n=r=>Hs(t,r);return Object.assign(n,t),n},Us=(e=>qs);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\",Rt=\"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 js=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===js}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),Re=(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 Ws(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 Ks(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Qs=e=>mt(e)?e?.[te]:null,Fe=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],[Rt]: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 Gs(){ae(2)}var en={[Rt]:Gs};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 Ys(e,t){bn[e]||(bn[e]=t)}var Ft,Na=()=>Ft,Js=(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(Zs),e.drafts_=null}function ar(e){e===Ft&&(Ft=e.parent_)}var wi=e=>Ft=Js(Ft,e);function Zs(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 Xs(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);Ra(n,e)}return n.copy_}function Xs(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,el=[];function za(e,t,n,r){const i=Fe(e),a=e.type_;if(r!==void 0&&Re(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)??el;for(const s of o)mn(i,s,n,a)}function tl(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),Ra(a,i)})}function Ra(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 nl(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=Fe(e);e.type_===3?a.has(n)&&vn(n,r.handledSet_,r):Re(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&vn(Re(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 rl(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=Fe(e);if(!Dt(i,t,e.type_))return il(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ks(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 Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Fa(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Mn(Fe(e),t),a=i?.[te];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ws(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),nl(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=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[ln]:!0,[nr]:e.type_!==1||t!==\"length\",[gn]:r[gn],[Rt]: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?Fe(n):e)[t]}function il(e,t,n){const r=Fa(t,n);return r?Rt in r?r[Rt]:r.get?.call(e.draft_):void 0}function Fa(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 al=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=ol(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):rl(t,n);return(n?.scope_??Na()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?tl(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 ol(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 sl(){function t(h,v=[]){if(h.key_!==void 0){const S=h.parent_.copy_??h.parent_.base_,_=Qs(Re(S,h.key_)),w=Re(S,h.key_);if(w===void 0||w!==h.draft_&&w!==h.base_&&w!==h.copy_||_!=null&&_.base_!==h.base_)return null;const x=h.parent_.type_===3;let A;if(x){const I=h.parent_;A=Array.from(I.drafts_.keys()).indexOf(h.key_)}else A=h.key_;if(!(x&&S.size>A||Dt(S,A)))return null;v.push(A)}if(h.parent_)return t(h.parent_,v);v.reverse();try{n(h.copy_,v)}catch{return null}return v}function n(h,v){let S=h;for(let _=0;_<v.length-1;_++){const w=v[_];if(S=Re(S,w),!mt(S)||S===null)throw new Error(`Cannot resolve path at '${v.join(\"/\")}'`)}return S}const r=\"replace\",i=\"add\",a=\"remove\";function o(h,v,S){if(h.scope_.processedForPatches_.has(h))return;h.scope_.processedForPatches_.add(h);const{patches_:_,inversePatches_:w}=S;switch(h.type_){case 0:case 2:return u(h,v,_,w);case 1:return s(h,v,_,w);case 3:return l(h,v,_,w)}}function s(h,v,S,_){let{base_:w,assigned_:x}=h,A=h.copy_;A.length<w.length&&([w,A]=[A,w],[S,_]=[_,S]);const I=h.allIndicesReassigned_===!0;for(let y=0;y<w.length;y++){const P=A[y],T=w[y];if((I||x?.get(y.toString()))&&P!==T){const b=P?.[te];if(b&&b.modified_)continue;const D=v.concat([y]);S.push({op:r,path:D,value:c(P)}),_.push({op:r,path:D,value:c(T)})}}for(let y=w.length;y<A.length;y++){const P=v.concat([y]);S.push({op:i,path:P,value:c(A[y])})}for(let y=A.length-1;w.length<=y;--y){const P=v.concat([y]);_.push({op:a,path:P})}}function u(h,v,S,_){const{base_:w,copy_:x,type_:A}=h;jt(h.assigned_,(I,y)=>{const P=Re(w,I,A),T=Re(x,I,A),z=y?Dt(w,I)?r:i:a;if(P===T&&z===r)return;const b=v.concat(I);S.push(z===a?{op:z,path:b}:{op:z,path:b,value:c(T)}),_.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(h,v,S,_){let{base_:w,copy_:x}=h,A=0;w.forEach(I=>{if(!x.has(I)){const y=v.concat([A]);S.push({op:a,path:y,value:I}),_.unshift({op:i,path:y,value:I})}A++}),A=0,x.forEach(I=>{if(!w.has(I)){const y=v.concat([A]);S.push({op:i,path:y,value:I}),_.unshift({op:a,path:y,value:I})}A++})}function d(h,v,S){const{patches_:_,inversePatches_:w}=S;_.push({op:r,path:[],value:v===Pr?void 0:v}),w.push({op:r,path:[],value:h})}function f(h,v){return v.forEach(S=>{const{path:_,op:w}=S;let x=h;for(let P=0;P<_.length-1;P++){const T=rt(x);let z=_[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=Re(x,z),mt(x)||ae(18,_.join(\"/\"))}const A=rt(x),I=p(S.value),y=_[_.length-1];switch(w){case r:switch(A){case 2:return x.set(y,I);case 3:ae(16);default:return x[y]=I}case i:switch(A){case 1:return y===\"-\"?x.push(I):x.splice(y,0,I);case 2:return x.set(y,I);case 3:return x.add(I);default:return x[y]=I}case a:switch(A){case 1:return x.splice(y,1);case 2:return x.delete(y);case 3:return x.delete(S.value);default:return delete x[y]}default:ae(17,w)}}),h}function p(h){if(!Ne(h))return h;if(Wt(h))return h.map(p);if(Kt(h))return new Map(Array.from(h.entries()).map(([S,_])=>[S,p(_)]));if(Qt(h))return new Set(Array.from(h).map(p));const v=Object.create(nt(h));for(const S in h)v[S]=p(h[S]);return Dt(h,Tt)&&(v[Tt]=h[Tt]),v}function c(h){return Le(h)?p(h):h}Ys(yn,{applyPatches_:f,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var Mt=new al,ll=Mt.produce,ul=Mt.produceWithPatches.bind(Mt),ht=Mt.applyPatches.bind(Mt);const cl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?ll(i):i;return t(s,a,...o)},e(r.setState,n,r)),fl=cl,dl=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\"]),hl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function pl(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 gl(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 h=Ci(e,n);o=h.className||void 0,s=h.id||void 0,n=h.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:p}=pl(d),c={type:\"link\",display:f,target:p,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 p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"variable\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f===\"_\"){n=d+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"temporary\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f===\"@\"){n=d+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"local\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let p=1;const c=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const h=e.slice(c,n);n++;const{name:v,rawArgs:S,isClose:_}=xi(h),w={type:\"macro\",name:v,rawArgs:S,isClose:_,start:a,end:n};s&&(w.className=s),u&&(w.id=u),t.push(w),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:p,rawArgs:c,isClose:h}=xi(f);t.push({type:\"macro\",name:p,rawArgs:c,isClose:h,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&dl.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=gl(e,o);o=d.endIdx;let f=hl.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\"},ml=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(ml.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 _l=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,yl=/\\{[\\$_@][\\w.]+\\}/;function bl(e){return yl.test(e)}function vl(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 wl(e,t,n,r){return e.replace(_l,(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=vl(d,u)),d==null?\"\":String(d)})}function $r(){const[e,t,n]=Nr();return he(r=>r===void 0||!bl(r)?r:wl(r,e,t,n),[e,t,n])}function kl({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 p=o[f];l=l[p]}const d=l==null?\"\":String(l);return n||r?k(\"span\",{id:r,class:n,children:d}):k(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 Sl(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 xl(){return wt}function Cl(){return Gt}function Il(){return at}const El=500,Qe=new Map,Al=/\\$(\\w+)/g,Pl=/(?<![.\\w])_(\\w+)/g,Tl=/@(\\w+)/g;function Dl(e){return e.replace(Al,'variables[\"$1\"]').replace(Pl,'temporary[\"$1\"]').replace(Tl,'locals[\"$1\"]')}function Rr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Dl(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 p=e.charAt(r);p===\"{\"?f++:p===\"}\"&&f--,f>0&&(u+=p),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Rr(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 Nl=\"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\",Nl+t);if(Qe.set(e,r),Qe.size>El){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(h=>r(h)>0),o=(...c)=>c.every(h=>r(h)>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 h=c.history[c.historyIndex-1]?.passage;return h?c.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(h=>s(h)>0),hasRenderedAll:(...c)=>c.every(h=>s(h)>0),random:zr,randomInt:Ha},Ei=t,Ai=n,tn}function An(e,t,n,r={}){const a=`return (${Rr(e)});`;return qa(a,a)(t,n,r,Ua())}function ja(e,t,n,r={}){const i=Rr(e);qa(\"exec:\"+i,i)(t,n,r,Ua())}function $l(e){const t=e[0];return!!(t==='\"'||t===\"'\"||t===\"`\"||t===\"$\"||t===\"_\"||t===\"@\"||/\\d/.test(t)||(t===\"-\"||t===\"+\")&&e.length>1&&/\\d/.test(e[1])||t===\"(\"||t===\"[\"||t===\"{\"||/^(true|false|null|undefined)$/.test(e)||t===\"!\"&&e.length>1)}function zl(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const o=e[a];if(i){n+=o,o===i&&e[a-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(/\\s/.test(o)&&r===0){n&&(t.push(n),n=\"\");continue}n+=o}if(n&&t.push(n),t.length<2)return null;for(const a of t)if(!$l(a))return null;return t}function Rl(e){const t=[];let n=\"\",r=0,i=null,a=!1;for(let s=0;s<e.length;s++){const u=e[s];if(i){n+=u,u===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(u==='\"'||u===\"'\"||u===\"`\"){i=u,n+=u;continue}if(u===\"(\"||u===\"[\"||u===\"{\"){r++,n+=u;continue}if(u===\")\"||u===\"]\"||u===\"}\"){r--,n+=u;continue}if(u===\",\"&&r===0){a=!0,t.push(n.trim()),n=\"\";continue}n+=u}const o=n.trim();if(o&&t.push(o),!a&&t.length===1){const s=zl(t[0]);if(s)return s}return t}function Fl({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,p)=>{a(c=>({...c,[f]:p}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return k(Yt.Provider,{value:d,children:k(Ce.Provider,{value:o,children:Ie(e,{nobr:r,locals:o})})})}function Ol({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 k(pr.Provider,{value:l,children:Ie(e,{nobr:a,locals:i})});const d=Rl(n),f={};for(let p=0;p<t.length;p++){const c=t[p],h=d[p];let v;if(h!==void 0)try{v=An(h,o,s,u)}catch{v=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=v}return k(pr.Provider,{value:l,children:k(Fl,{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 Ml(e){return Wa.get(e.toLowerCase())}const Qa=new Map;function Ll(e,t){Qa.set(e.toLowerCase(),t)}function Vl(e){return Qa.get(e.toLowerCase())}const Ga=new Set;function Bl(e){Ga.add(e.toLowerCase())}function Hl(e){return Ga.has(e.toLowerCase())}const Ya=new Map;function ql(e,t){Ya.set(e.toLowerCase(),t)}function Ul(){return Array.from(Ya.values())}const Pi=document.createElement(\"i\");function Ja(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 jl(e){const t={};let n=-1;for(;++n<e.length;)Wl(t,e[n]);return t}function Wl(e,t){let n;for(n in t){const i=(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];Kl(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Kl(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;)Gl(t,e[n]);return t}function Gl(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 Yl(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const Jl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Za(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Jl[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]/),Zl=Ue(/[#-'*+\\--9=?A-Z^-~]/);function fr(e){return e!==null&&(e<32||e===127)}const dr=Ue(/\\d/),Xl=Ue(/[\\dA-Fa-f]/),eu=Ue(/[!-/:-@[-`{-~]/);function F(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 tu=Ue(/\\p{P}|\\p{S}/u),nu=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=Za(ru(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function ru(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&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,iu=/^https?$/i;function au(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:Uo,content:No,definition:Io,definitionDestinationString:Ao,definitionLabelString:S,definitionTitleString:S,emphasis:Ho,htmlFlow:Bo,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:zo,strong:qo},exit:{atxHeading:Fo,atxHeadingSequence:$o,autolinkEmail:Jo,autolinkProtocol:Yo,blockQuote:Z,characterEscapeValue:xt,characterReferenceMarkerHexadecimal:Kr,characterReferenceMarkerNumeric:Kr,characterReferenceValue:Go,codeFenced:g,codeFencedFence:N,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Vo,codeIndented:g,codeText:jo,codeTextData:xt,data:xt,definition:Do,definitionDestinationString:Po,definitionLabelString:Eo,definitionTitleString:To,emphasis:Wo,hardBreakEscape:Ur,hardBreakTrailing:Ur,htmlFlow:jr,htmlFlowData:xt,htmlText:jr,htmlTextData:xt,image:qr,label:St,labelText:ee,lineEnding:Lo,link:qr,listOrdered:$,listUnordered:B,paragraph:pe,reference:P,referenceString:Ve,resource:P,resourceDestinationString:zn,resourceTitleString:Co,setextHeading:Mo,setextHeadingLineSequence:Oo,setextHeadingText:Ro,strong:Ko,thematicBreak:Qo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:S,encode:y,getData:v,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:h,tag:w};let f=t.defaultLineEnding;return p;function p(E){let R=-1,ne=0;const Se=[];let Ee=[],ze=[];for(;++R<E.length;)!f&&(E[R][1].type===\"lineEnding\"||E[R][1].type===\"lineEndingBlank\")&&(f=E[R][2].sliceSerialize(E[R][1])),(E[R][1].type===\"listOrdered\"||E[R][1].type===\"listUnordered\")&&(E[R][0]===\"enter\"?Se.push(R):c(E.slice(Se.pop(),R))),E[R][1].type===\"definition\"&&(E[R][0]===\"enter\"?(ze=ie(ze,E.slice(ne,R)),ne=R):(Ee=ie(Ee,E.slice(ne,R+1)),ne=R+1));Ee=ie(Ee,ze),Ee=ie(Ee,E.slice(ne)),R=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++R<E.length;){const Qr=u[Ae[R][0]],Gr=Ae[R][1].type,Yr=Qr[Gr];Ti.call(Qr,Gr)&&Yr&&Yr.call({sliceSerialize:Ae[R][2].sliceSerialize,...d},Ae[R][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(E){const R=E.length;let ne=0,Se=0,Ee=!1,ze;for(;++ne<R;){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 h(E,R){l[E]=R}function v(E){return l[E]}function S(){i.push([])}function _(){return i.pop().join(\"\")}function w(E){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(E))}function x(E){h(\"lastWasTag\"),i[i.length-1].push(E)}function A(){x(f||`\n`)}function I(){const E=i[i.length-1],R=E[E.length-1],ne=R?R.charCodeAt(R.length-1):null;ne===10||ne===13||ne===null||A()}function y(E){return v(\"ignoreEncode\")?E:Za(E)}function P(){_()}function T(E){o.push(!E._loose),I(),w(\"<ol\"),h(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),I(),w(\"<ul\"),h(\"expectFirstItem\",!0)}function b(E){if(v(\"expectFirstItem\")){const R=Number.parseInt(this.sliceSerialize(E),10);R!==1&&w(' start=\"'+y(String(R))+'\"')}}function D(){v(\"expectFirstItem\")?w(\">\"):U(),I(),w(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function $(){U(),o.pop(),A(),w(\"</ol>\")}function B(){U(),o.pop(),A(),w(\"</ul>\")}function U(){v(\"lastWasTag\")&&!v(\"slurpAllLineEndings\")&&I(),w(\"</li>\"),h(\"slurpAllLineEndings\")}function M(){o.push(!1),I(),w(\"<blockquote>\")}function Z(){o.pop(),I(),w(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function J(){o[o.length-1]||(I(),w(\"<p>\")),h(\"slurpAllLineEndings\")}function pe(){o[o.length-1]?h(\"slurpAllLineEndings\",!0):w(\"</p>\")}function ke(){I(),w(\"<pre><code\"),h(\"fencesCount\",0)}function m(){const E=_();w(' class=\"language-'+E+'\"')}function N(){const E=v(\"fencesCount\")||0;E||(w(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",E+1)}function j(){I(),w(\"<pre><code>\")}function g(){const E=v(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!v(\"lastWasTag\")&&A(),v(\"flowCodeSeenData\")&&I(),w(\"</code></pre>\"),E!==void 0&&E<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"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=_()}function Ve(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function ct(){S(),a[a.length-1].destination=\"\"}function ft(){S(),h(\"ignoreEncode\",!0)}function zn(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Co(){a[a.length-1].title=_()}function qr(){let E=a.length-1;const R=a[E],ne=R.referenceId||R.labelId,Se=R.destination===void 0?r[Lt(ne)]:R;for(n=!0;E--;)if(a[E].image){n=void 0;break}R.image?(w('<img src=\"'+nn(Se.destination,t.allowDangerousProtocol?void 0:iu)+'\" alt=\"'),x(R.label),w('\"')):w('<a href=\"'+nn(Se.destination,t.allowDangerousProtocol?void 0:Di)+'\"'),w(Se.title?' title=\"'+Se.title+'\"':\"\"),R.image?w(\" />\"):(w(\">\"),x(R.label),w(\"</a>\")),a.pop()}function Io(){S(),a.push({})}function Eo(E){_(),a[a.length-1].labelId=this.sliceSerialize(E)}function Ao(){S(),h(\"ignoreEncode\",!0)}function Po(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function To(){a[a.length-1].title=_()}function Do(){const E=a[a.length-1],R=Lt(E.labelId);_(),Ti.call(r,R)||(r[R]=a[a.length-1]),a.pop()}function No(){h(\"slurpAllLineEndings\",!0)}function $o(E){v(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(E).length),I(),w(\"<h\"+v(\"headingRank\")+\">\"))}function zo(){S(),h(\"slurpAllLineEndings\")}function Ro(){h(\"slurpAllLineEndings\",!0)}function Fo(){w(\"</h\"+v(\"headingRank\")+\">\"),h(\"headingRank\")}function Oo(E){h(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function Mo(){const E=_();I(),w(\"<h\"+v(\"headingRank\")+\">\"),x(E),w(\"</h\"+v(\"headingRank\")+\">\"),h(\"slurpAllLineEndings\"),h(\"headingRank\")}function xt(E){x(y(this.sliceSerialize(E)))}function Lo(E){if(!v(\"slurpAllLineEndings\")){if(v(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(v(\"inCodeText\")){x(\" \");return}x(y(this.sliceSerialize(E)))}}function Vo(E){x(y(this.sliceSerialize(E))),h(\"flowCodeSeenData\",!0)}function Ur(){w(\"<br />\")}function Bo(){I(),Wr()}function jr(){h(\"ignoreEncode\")}function Wr(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function Ho(){w(\"<em>\")}function qo(){w(\"<strong>\")}function Uo(){h(\"inCodeText\",!0),w(\"<code>\")}function jo(){h(\"inCodeText\"),w(\"</code>\")}function Wo(){w(\"</em>\")}function Ko(){w(\"</strong>\")}function Qo(){I(),w(\"<hr />\")}function Kr(E){h(\"characterReferenceType\",E.type)}function Go(E){const R=this.sliceSerialize(E),ne=v(\"characterReferenceType\")?Yl(R,v(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ja(R);x(y(ne)),h(\"characterReferenceType\")}function Yo(E){const R=this.sliceSerialize(E);w('<a href=\"'+nn(R,t.allowDangerousProtocol?void 0:Di)+'\">'),x(y(R)),w(\"</a>\")}function Jo(E){const R=this.sliceSerialize(E);w('<a href=\"'+nn(\"mailto:\"+R)+'\">'),x(y(R)),w(\"</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 ou={tokenize:su};function su(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),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 F(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const lu={tokenize:uu},Ni={tokenize:cu};function uu(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&&w();const A=t.events.length;let I=A,y;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){y=t.events[I][1].end;break}_(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={...y},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 p(x);if(i.currentConstruct&&i.currentConstruct.concrete)return h(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ni,d,f)(x)}function d(x){return i&&w(),_(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(x)}function p(x){return t.containerState={},e.attempt(Ni,c,h)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function h(x){if(x===null){i&&w(),_(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),v(x)}function v(x){if(x===null){S(e.exit(\"chunkFlow\"),!0),_(0),e.consume(x);return}return F(x)?(e.consume(x),S(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),v)}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 y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const 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(_(r),y=P;y<t.events.length;)t.events[y][1].end={...b},y++;_e(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(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 w(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function cu(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)||nu(e))return 1;if(tu(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:fu,tokenize:du};function fu(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},p={...e[n][1].start};$i(f,-u),$i(p,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:p},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 du(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),p=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?f:f&&(i||!p)),l._close=!!(a===42?p:p&&(d||!f)),t(u)}}function $i(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const hu={name:\"autolink\",tokenize:pu};function pu(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):Zl(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):p(c)}function p(c){if((c===45||me(c))&&r++<63){const h=c===45?p:f;return e.consume(c),h}return n(c)}}const Tn={partial:!0,tokenize:gu};function gu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||F(a)?t(a):n(a)}}const Xa={continuation:{tokenize:_u},exit:yu,name:\"blockQuote\",tokenize:mu};function mu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function _u(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Xa,t,n)(o)}}function yu(e){e.exit(\"blockQuote\")}const eo={name:\"characterEscape\",tokenize:bu};function bu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return eu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const to={name:\"characterReference\",tokenize:vu};function vu(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=Xl,d):(e.enter(\"characterReferenceValue\"),a=7,o=dr,d(f))}function d(f){if(f===59&&i){const p=e.exit(\"characterReferenceValue\");return o===me&&!Ja(r.sliceSerialize(p))?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:ku},Ri={concrete:!0,name:\"codeFenced\",tokenize:wu};function wu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(y)}function d(y){return y===s?(o++,e.consume(y),d):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?H(e,f,\"whitespace\")(y):f(y))}function f(y){return y===null||F(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(zi,v,A)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||F(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,c,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),p)}function c(y){return y===null||F(y)?f(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(y))}function h(y){return y===null||F(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(y)):y===96&&y===s?n(y):(e.consume(y),h)}function v(y){return e.attempt(i,A,S)(y)}function S(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?H(e,w,\"linePrefix\",a+1)(y):w(y)}function w(y){return y===null||F(y)?e.check(zi,v,A)(y):(e.enter(\"codeFlowValue\"),x(y))}function x(y){return y===null||F(y)?(e.exit(\"codeFlowValue\"),w(y)):(e.consume(y),x)}function A(y){return e.exit(\"codeFenced\"),t(y)}function I(y,P,T){let z=0;return b;function b(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),D}function D(M){return y.enter(\"codeFencedFence\"),L(M)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,y.consume(M),B):z>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?H(y,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||F(M)?(y.exit(\"codeFencedFence\"),P(M)):T(M)}}}function ku(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:xu},Su={partial:!0,tokenize:Cu};function xu(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):F(l)?e.attempt(Su,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||F(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Cu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):F(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):F(o)?i(o):n(o)}}const Iu={name:\"codeText\",previous:Au,resolve:Eu,tokenize:Pu};function Eu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Au(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Pu(e,t,n){let r=0,i,a;return o;function o(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)):F(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||F(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 Tu{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 no(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new Tu(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,Du(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 Du(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,p=-1,c=n,h=0,v=0;const S=[v];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;++p<s.length;)s[p][0]===\"exit\"&&s[p-1][0]===\"enter\"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(v=p+1,S.push(v),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(),p=S.length;p--;){const _=s.slice(S[p],S[p+1]),w=a.pop();u.push([w,w+_.length-1]),e.splice(w,2,_)}for(u.reverse(),p=-1;++p<u.length;)l[h+u[p][0]]=h+u[p][1],h+=u[p][1]-u[p][0]-1;return l}const Nu={resolve:zu,tokenize:Ru},$u={partial:!0,tokenize:Fu};function zu(e){return no(e),e}function Ru(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):F(s)?e.check($u,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Fu(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||F(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 ro(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return f;function f(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),p):_===null||_===32||_===41||fr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),v(_))}function p(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),c(_))}function c(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),p(_)):_===null||_===60||F(_)?n(_):(e.consume(_),_===92?h:c)}function h(_){return _===60||_===62||_===92?(e.consume(_),c):c(_)}function v(_){return!d&&(_===null||_===41||se(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):d<l&&_===40?(e.consume(_),d++,v):_===41?(e.consume(_),d--,v):_===null||_===32||_===40||fr(_)?n(_):(e.consume(_),_===92?S:v)}function S(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function io(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):F(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||F(c)||s++>999?(e.exit(\"chunkString\"),d(c)):(e.consume(c),u||(u=!L(c)),c===92?p:f)}function p(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function ao(e,t,n,r,i,a){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,u):n(p)}function u(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),l(p))}function l(p){return p===o?(e.exit(a),u(o)):p===null?n(p):F(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(p))}function d(p){return p===o||p===null||F(p)?(e.exit(\"chunkString\"),l(p)):(e.consume(p),p===92?f:d)}function f(p){return p===o||p===92?(e.consume(p),d):d(p)}}function Nt(e,t){let n;return r;function r(i){return F(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 Ou={name:\"definition\",tokenize:Lu},Mu={partial:!0,tokenize:Vu};function Lu(e,t,n){const r=this;let i;return a;function a(c){return e.enter(\"definition\"),o(c)}function o(c){return io.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 ro(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt(Mu,f,f)(c)}function f(c){return L(c)?H(e,p,\"whitespace\")(c):p(c)}function p(c){return c===null||F(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function Vu(e,t,n){return r;function r(s){return se(s)?Nt(e,i)(s):n(s)}function i(s){return ao(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||F(s)?t(s):n(s)}}const Bu={name:\"hardBreakEscape\",tokenize:Hu};function Hu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return F(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const qu={name:\"headingAtx\",resolve:Uu,tokenize:ju};function Uu(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 ju(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||F(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 Wu=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],Fi=[\"pre\",\"script\",\"style\",\"textarea\"],Ku={concrete:!0,name:\"htmlFlow\",resolveTo:Yu,tokenize:Ju},Qu={partial:!0,tokenize:Xu},Gu={partial:!0,tokenize:Zu};function Yu(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Ju(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),p):g===47?(e.consume(g),a=!0,v):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),o=String.fromCharCode(g),S):n(g)}function p(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,h):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 h(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:h):n(g)}function v(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&&Fi.includes(le)?(i=1,r.interrupt?t(g):$(g)):Wu.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?w(g):x(g))}return g===45||me(g)?(e.consume(g),o+=String.fromCharCode(g),S):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function w(g){return L(g)?(e.consume(g),w):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),y):L(g)?(e.consume(g),I):x(g)}function y(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),y):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||F(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||F(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):F(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Qu,j,B)(g)):g===null||F(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Gu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||F(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 Fi.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||F(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),N)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Zu(e,t,n){const r=this;return i;function i(o){return F(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Xu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Tn,t,n)}}const ec={name:\"htmlText\",tokenize:tc};function tc(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,h):Pe(m)?(e.consume(m),w):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),p):F(m)?(o=f,J(m)):(e.consume(m),f)}function p(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?p(m):f(m)}function h(m){const N=\"CDATA[\";return m===N.charCodeAt(a++)?(e.consume(m),a===N.length?v:h):n(m)}function v(m){return m===null?n(m):m===93?(e.consume(m),S):F(m)?(o=v,J(m)):(e.consume(m),v)}function S(m){return m===93?(e.consume(m),_):v(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):v(m)}function w(m){return m===null||m===62?Z(m):F(m)?(o=w,J(m)):(e.consume(m),w)}function x(m){return m===null?n(m):m===63?(e.consume(m),A):F(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),y):n(m)}function y(m){return m===45||me(m)?(e.consume(m),y):P(m)}function P(m){return F(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):F(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),$):F(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):F(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):F(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 Fr={name:\"labelEnd\",resolveAll:ac,resolveTo:oc,tokenize:sc},nc={tokenize:lc},rc={tokenize:uc},ic={tokenize:cc};function ac(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function oc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},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 sc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(p){return a?a._inactive?f(p):(o=r.parser.defined.includes(Lt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(p)}function u(p){return p===40?e.attempt(nc,d,o?d:f)(p):p===91?e.attempt(rc,d,o?l:f)(p):o?d(p):f(p)}function l(p){return e.attempt(ic,d,f)(p)}function d(p){return t(p)}function f(p){return a._balanced=!0,n(p)}}function lc(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):ro(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?ao(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 uc(e,t,n){const r=this;return i;function i(s){return io.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 cc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const fc={name:\"labelStartImage\",resolveAll:Fr.resolveAll,tokenize:dc};function dc(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 hc={name:\"labelStartLink\",resolveAll:Fr.resolveAll,tokenize:pc};function pc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Vn={name:\"lineEnding\",tokenize:gc};function gc(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:mc};function mc(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||F(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:vc},exit:kc,name:\"list\",tokenize:bc},_c={partial:!0,tokenize:Sc},yc={partial:!0,tokenize:wc};function bc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(c){const h=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(h===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:dr(c)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"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(_c,p,f))}function d(c){return r.containerState.initialBlankLine=!0,a++,p(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),p):n(c)}function p(c){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function vc(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(yc,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 wc(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 kc(e){e.exit(this.containerState.type)}function Sc(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:xc,tokenize:Cc};function xc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function Cc(e,t,n){const r=this;let i;return a;function a(l){let 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||F(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Ic={tokenize:Ec};function Ec(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(Nu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Ac={resolveAll:so()},Pc=oo(\"string\"),Tc=oo(\"text\");function oo(e){return{resolveAll:so(e===\"text\"?Dc: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 p=-1;if(f)for(;++p<f.length;){const c=f[p];if(!c.previous||c.previous.call(r,r.previous))return!0}return!1}}}function so(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 Dc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const Nc={42: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:Xa},$c={91:Ou},zc={[-2]:Ln,[-1]:Ln,32:Ln},Rc={35:qu,42:cn,45:[Oi,cn],60:Ku,61:Oi,95:cn,96:Ri,126:Ri},Fc={38:to,92:eo},Oc={[-5]:Vn,[-4]:Vn,[-3]:Vn,33:fc,38:to,42:hr,60:[hu,ec],91:hc,92:[Bu,eo],93:Fr,95:hr,96:Iu},Mc={null:[hr,Ac]},Lc={null:[42,95]},Vc={null:[]},Bc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Lc,contentInitial:$c,disable:Vc,document:Nc,flow:Rc,flowInitial:zc,insideSpan:Mc,string:Fc,text:Oc},Symbol.toStringTag,{value:\"Module\"}));function Hc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(I),check:P(y),consume:w,enter:x,exit:A,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:v,events:[],now:h,parser:e,previous:null,sliceSerialize:p,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 p(D,$){return Uc(c(D),$)}function c(D){return qc(o,D)}function h(){const{_bufferIndex:D,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:D,_index:$,line:B,column:U,offset:M}}function v(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;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(D){d=d(D)}function w(D){F(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=h(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(D){const $=s.pop();return $.end=h(),l.events.push([\"exit\",$,l]),$}function I(D,$){T(D,$.from)}function y(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=h(),$=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 qc(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 Uc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function jc(e){const r={constructs:jl([Bc,...(e||{}).extensions||[]]),content:i(ou),defined:[],document:i(lu),flow:i(Ic),lazy:{},string:i(Pc),text:i(Tc)};return r;function i(a){return o;function o(s){return Hc(r,a,s)}}}function Wc(e){for(;!no(e););return e}const Mi=/[\\0\\t\\n\\r]/g;function Kc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,f,p,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),p=l&&l.index!==void 0?l.index:a.length,c=a.charCodeAt(p),!l){t=a.slice(f);break}if(c===10&&f===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<p&&(u.push(a.slice(f,p)),e+=p-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=p+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),au(n)(Wc(jc(n).document().write(Kc()(e,t,!0))))}const Bn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Gc(){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,Yc)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+Bn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Yc(e,t){return t===\"|\"?t:e}class Jc{constructor(){this.map=[]}add(t,n,r){Zc(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 Zc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Xc(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function ef(){return{flow:{null:{name:\"table\",tokenize:tf,resolveAll:nf}}}}function tf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let 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\"?y:u;return B===y&&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):F(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?p:f)}function p(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,h,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):h(b))}function h(b){return b===45||b===58?S(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),v):I(b)}function v(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\"),_):b===45?(a+=1,_(b)):b===null||F(b)?A(b):I(b)}function _(b){return b===45?(e.enter(\"tableDelimiterFiller\"),w(b)):I(b)}function w(b){return b===45?(e.consume(b),w):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?h(b):b===null||F(b)?!o||i!==a?I(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):I(b)}function I(b){return n(b)}function y(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||F(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 nf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,f;const p=new Jc;for(;++n<e.length;){const c=e[n],h=c[1];c[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,u!==0&&(Li(p,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",l,t]])):h.type===\"tableRow\"||h.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({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",d,t]])),i=h.type===\"tableDelimiterRow\"?2:d?3:1):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=rn(p,t,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):h.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=rn(p,t,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):h.type===\"tableHead\"?(s=!0,u=n):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],f=rn(p,t,a,i,n,f)):o[1]!==0&&(f=rn(p,t,o,i,n,f)),i=0):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Li(p,t,u,l,d),p.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=Xc(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 p=t.events[n[2]],c=t.events[n[3]];if(p[1].end=Object.assign({},c[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const h=n[2]+1,v=n[3]-n[2]-1;e.add(h,v,[])}}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 rf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function af(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const 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)},p=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(p,p.length,0,Pn(c,o.slice(l+1,u),s)),_e(p,p.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,p),u=l+p.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 p;function p(h){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(h):(o.enter(\"strikethroughSequenceTemporary\"),c(h))}function c(h){const v=Sn(l);if(h===126)return f>1?u(h):(o.consume(h),f++,c);if(f<2&&!n)return u(h);const S=o.exit(\"strikethroughSequenceTemporary\"),_=Sn(h);return S._open=!_||_===2&&!!v,S._close=!v||v===2&&!!_,s(h)}}}function of(e){return Qc(e,{allowDangerousHtml:!0,extensions:[ef(),af(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Gc(),rf()]})}const sf={update:()=>{},getValues:()=>({})},Ce=ot({}),Yt=ot(sf),ce=ot(!1),pr=ot(null);function lf(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)=>lo(a,o,t));return k(Y,{children:i})}function lo(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.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)=>lo(u,l,n));return Q(i,o,...s)}return null}function uf({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 cf(){const e=G(pr),t=G(ce),n=G(Ce);return!e||e.length===0?null:k(Y,{children:Ie(e,{nobr:t,locals:n})})}function ff(e,t){if(Hl(e.name))return null;const n=Ml(e.name);if(n)return k(Ol,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=Vl(e.name);return r?k(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):k(\"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\"?k(cf,{},t):k(kl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return ff(e,t);case\"html\":return k(uf,{node:e},t);default:return e}}function uo(e){return e.length===0?null:e.map((t,n)=>gr(t,n))}function df(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function hf(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\"&&df(i))i+=hf(u,a);else{const l=r.length;r.push(gr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=of(i);return lf(o,r,t?.nobr)}function pf(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 gf(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 mf=\"spindle\",_f=1;let an=null,Hn=null;function je(){return Hn||(Hn={saves:new Map,playthroughs:new Map,meta:new Map}),Hn}function yf(){return an||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(an=new Promise((e,t)=>{const n=indexedDB.open(mf,_f);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 yf().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 co(e){try{const t=await We(\"saves\",\"readwrite\");await Ke(t.delete(e))}catch{je().saves.delete(e)}}async function bf(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 fo(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 ho=new Map,Nn=new Map;function vf(e,t){ho.set(e,t),Nn.set(t,e)}function wf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function 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(wf(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,p])=>[t(f),t(p)]))}if(o===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=ho.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 kf(e){mr=e}function Sf(e){_r=e}function xf(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 Cf(){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 fo(i),await Vt(`currentPlaythroughId.${e}`,r),r}async function If(e){return $e(`currentPlaythroughId.${e}`)}async function po(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:xf(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 go(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 Ef(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 Af(e){await co(e)}async function Pf(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 Tf(e){const[t,n]=await Promise.all([bf(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 Df=\"autosave.\",Nf=\"slot.\",$n=\"slotIndex.\";function Jt(e,t){return t!=null?`${Nf}${t}.${e}`:`${Df}${e}`}async function $f(e,t,n,r,i){const a=Jt(e,r),o=await $e(a);if(o){const u=await go(o,n,i);if(u)return u}const s=await po(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 zf(e,t){const n=Jt(e,t),r=await $e(n);if(r)return Ef(r)}async function Rf(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 Ff(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 Of(e,t){const n=Jt(e,t),r=await $e(n);if(r&&(await co(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 Mf(e,t){try{sessionStorage.setItem(`${Mr}${e}`,JSON.stringify(t))}catch{}}function Lf(e){try{const t=sessionStorage.getItem(`${Mr}${e}`);if(!t)return;const n=JSON.parse(t);if(!gf(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 Vf(e){try{sessionStorage.removeItem(`${Mr}${e}`)}catch{}}async function Bf(e){const t=await kt(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Hf(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 fo(a)}return await Dn(n),n}function mo(){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&&Sf(n.content)}let _o=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 yo(e,t){const n=_o++,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 bo(e){ve=ve.filter(t=>t.name!==e)}function qf(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 Uf=10;function jf(){if(!qn){qn=!0;try{for(let e=0;e<Uf;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)),qf(r))}if(!t)break}}finally{qn=!1}}}function Wf(){for(const e of ve)e.lastResult=Lr(e.condition)}function Kf(){ve=[],lt=[],_o=0,Me?.closeAll()}function Qf(e){return $t=e,lt.length>0&&e(),()=>{$t===e&&($t=null)}}function Gf(){return lt.shift()}function Yf(){return lt.length}function Jf(e){Me?Me.push(e):(lt.push(e),$t?.())}function Zf(){lt=[]}function Xf(e){return Me=e,()=>{Me===e&&(Me=null)}}function ed(){Me?.close()}function td(){Zf(),Me?.closeAll()}function nd(){return Me?.isOpen()??!1}sl();const rd=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]=ul(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 id(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}}}Mf(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=Us()(fl((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;Cf().then(async()=>{const s=await If(o);if(s)e(l=>{l.playthroughId=s});else{const l=await Bi(o);e(d=>{d.playthroughId=l})}const u=await Rf(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(rd.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(),Kf();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,mo(),Vf(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}),$f(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}),zf(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?Ff(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&Of(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(id(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}}))),ad=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function od(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:ad,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const a=bt(n),o=vt(a);return k(Y,{children:uo(o)})}catch(a){return k(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?k(ce.Provider,{value:!0,children:i}):i}const vo=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 k(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=bt(l),h=vt(c);return Ie(h)}catch(c){return k(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&o()},p=n?`dialog-panel ${n}`:\"dialog-panel\";return k(vo.Provider,{value:o,children:k(\"div\",{class:\"dialog-overlay\",onClick:f,children:k(\"div\",{class:p,children:[i&&k(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),k(\"div\",{class:\"dialog-body\",children:d})]})})})}function sd(){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(()=>Xf({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),we(()=>Qf(()=>{const o=[];for(;Yf()>0;){const s=Gf();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:k(Y,{children:e.map((o,s)=>k(Vr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function ld(){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 k(\"div\",{class:\"loading\",children:\"Loading...\"});const r=k(Y,{children:[k(od,{}),k(sd,{})]});return n?k(ce.Provider,{value:!0,children:r}):r}function ud(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function cd(){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 p of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(p.getAttribute(\"pid\")||\"0\",10),h=p.getAttribute(\"name\")||\"\",v=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),S=ud(p.innerHTML),_={},w=new Set([\"pid\",\"name\",\"tags\"]);for(const A of p.attributes)w.has(A.name)||(_[A.name]=A.value);const x={pid:c,name:h,tags:v,metadata:_,content:S};d.set(h,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 wo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function fd(){localStorage.setItem(wo(),JSON.stringify(ue))}function jn(){if(!Ki){Ki=!0;try{const e=localStorage.getItem(wo());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,fd()},getAll(){return{...ue}},getDefinitions(){return It},hasAny(){return It.size>0}};function dd(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 hd(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 pd(e){return xn.set(e.id,e),Gi(),()=>{xn.delete(e.id),Gi()}}function Qi(){return Array.from(xn.values())}function gd(e){return xn.get(e)}function md(){vr.clear()}function _d(e){return br.add(e),()=>{br.delete(e)}}function Gi(){for(const e of br)e()}function yd(e){const t=oe(\"\"),n=oe(e.perform);n.current=e.perform,t.current||(t.current=hd(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),pd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function bd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function ko(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?ko(t):\"\"}function vd(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 wd(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 kd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Sd={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 xd(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,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=$r(),a=s(a),o=s(o));const{update:u,getValues:l}=G(Yt),d=G(ce),f=G(Ce),c={collectText:bd,sourceLocation:Br,parseVarArgs:vd,extractOptions:wd,h:Q,renderNodes:(h,v)=>Ie(h,{nobr:d,locals:f,...v}),renderInlineNodes:uo,hooks:Sd,useAction:yd,className:a,id:o,resolve:s,cls:kd(e.name,a),mutate:h=>dd(h,l(),u),update:u,getValues:l,wrap:h=>a||o?Q(\"span\",{id:o,class:a},h):Q(Y,null,h)};if(e.merged){c.merged=Nr();const h=c.merged;c.evaluate=v=>An(v,h[0],h[1],h[2])}if(e.storeVar){const v=(i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),S=v.split(\".\");c.varName=v,c.value=C(_=>Yi(_.variables,S)),c.getValue=()=>Yi(C.getState().variables,S),c.setValue=_=>{C.setState(w=>{xd(w.variables,S,_)})}}return e.render(i,c)}Ll(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(ql(e.name,{name:e.name,block:r,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters,source:t}),e.subMacros)for(const i of e.subMacros)Bl(i);r&&lr(e.name)}function Cd(){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){vf(e,t)},defineMacro(e){V(e,\"user\")},getMacroRegistry(){return Ul()},saves:{setTitleGenerator(e){kf(e)}},getActions(){return Qi()},performAction(e,t){const n=gd(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 _d(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 yo(e,t)},unwatch(e){bo(e)},openDialog(e,t){Jf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){ed()},closeAllDialogs(){td()},isDialogOpen(){return nd()},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){Sl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=kn())})},isEnabled(){return xl()},get seed(){return Cl()},get pull(){return Il()}}}}function Id(){window.Story=Cd()}const Ed=/^\\$(\\w+)\\s*=\\s*(.+)$/,Ji=/\\$(\\w+(?:\\.\\w+)*)/g,Zi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Ad=new Set([\"number\",\"string\",\"boolean\"]);function So(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,So(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Ad.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Pd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Ed);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=So(s);t.set(a,{...u,name:a,default:s})}return t}function Td(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 Dd(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 Nd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Td(i.content);let o;for(Ji.lastIndex=0;(o=Ji.exec(i.content))!==null;){const s=o[1],u=Dd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function $d(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 k(\"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 k(qe,{macro:\"print\",error:n})}}});function zd(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 Rd(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(!Rd(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}=zd(e))}catch(d){return k(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 Fd(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=Od(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 Od(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 Md(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}=Fd(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=Md(a,o,i),l=t.cls;return k(\"div\",{class:l,id:t.id,children:[k(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&k(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return k(qe,{macro:\"meter\",error:n})}}});V({name:\"if\",block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?k(\"span\",{id:o,class:a,children:i}):k(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 k(qe,{macro:\"if\",error:i})}}return null}});function Ld(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 Vd({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((p,c)=>{a(h=>({...h,[p]:c}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),f=G(ce);return k(Yt.Provider,{value:d,children:k(Ce.Provider,{value:o,children:Ie(r,{nobr:f,locals:o})})})}V({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=G(Ce);let i;try{i=Ld(e)}catch(d){return k(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 k(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return k(qe,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const p={[a]:d,...o?{[o]:f}:void 0};return k(Vd,{parentValues:r,ownKeys:p,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",block:!0,render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",block:!0,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}),k(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function Bd(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\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Bd(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)}}),k(\"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 k(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 k(Y,{children:n.renderNodes(o.children)})}catch(s){return k(qe,{macro:\"case\",error:s})}}return i?k(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,h=a[c].delay,v=setTimeout(()=>{s(c)},h);return()=>clearTimeout(v)},[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),p=d||f?k(\"span\",{id:f,class:d,children:l}):l;return t.wrap(p)}});const xo=ot({stop:()=>{}});V({name:\"repeat\",block:!0,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(h=>h+1)},o);return()=>clearInterval(c)},[o,l]),s===0&&!l)return null;const p=k(xo.Provider,{value:{stop:f},children:k(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?k(\"span\",{id:n.id,class:n.cls,children:p}):p}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(xo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",block:!0,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),p=a(0);p.current=d,i(()=>{if(s.current){const v=s.current.textContent||\"\";l(v.length)}},[]),i(()=>{if(u===0||p.current>=u)return;const v=setInterval(()=>{f(S=>S>=u?(clearInterval(v),S):S+1)},o);return()=>clearInterval(v)},[u,o]);const c=d>=u&&u>0,h=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return k(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[k(\"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&&k(\"span\",{class:\"macro-type-cursor\"})]})}});function Hd(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\",block:!0,render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Hd(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 k(\"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}),k(Y,{children:[k(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&k(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 k(Y,{children:[k(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&k(Vr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function qd(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 Ud(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function jd(){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),[p,c]=X(\"\"),h=oe(null),v=oe(null),S=G(vo),_=C(N=>N.storyData),w=C(N=>N.playthroughId),x=C(N=>N.getSavePayload),A=C(N=>N.loadFromPayload),I=_?.ifid??\"\",y=he(async()=>{if(!I)return;const N=await Tf(I);r(N),a(!1)},[I]);we(()=>{y()},[y]),we(()=>{d&&h.current&&(h.current.focus(),h.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||!w))try{const N=x();await po(I,w,N),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},D=async N=>{try{const j=x();await go(N,j),T(\"Save overwritten\"),await y()}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 Af(N),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=N=>{f(N.meta.id),c(N.meta.title)},M=async()=>{if(!(!d||!p.trim()))try{await Pf(d,p.trim()),f(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},Z=N=>{N.key===\"Enter\"?M():N.key===\"Escape\"&&f(null)},J=async N=>{try{const j=await Bf(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=()=>{v.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(!pf(le))throw new Error(\"Invalid save file format\");await Hf(le,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((N,j)=>N+j.saves.length,0);return k(\"div\",{class:\"save-manager\",children:[k(\"div\",{class:\"saves-header\",children:k(\"div\",{class:\"saves-header-left\",children:k(\"div\",{class:\"saves-mode-toggle\",children:[k(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),k(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),k(\"div\",{class:\"saves-toolbar\",children:[k(\"button\",{class:\"saves-toolbar-button\",onClick:pe,children:\"Import\"}),k(\"input\",{ref:v,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),k(\"div\",{class:\"saves-body\",children:[i?k(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?k(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(N=>{const j=u.has(N.playthrough.id),g=N.playthrough.id===w;return e===\"save\"&&!g||e===\"load\"&&N.saves.length===0&&!g?null:k(\"div\",{class:\"playthrough-group\",children:[k(\"div\",{class:\"playthrough-header\",onClick:()=>z(N.playthrough.id),children:[k(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),k(\"span\",{class:\"playthrough-label\",children:[N.playthrough.label,g?\" (current)\":\"\"]}),k(\"span\",{class:\"playthrough-date\",children:Ud(N.playthrough.createdAt)})]}),!j&&k(\"div\",{class:\"playthrough-saves\",children:[N.saves.map(q=>k(\"div\",{class:\"save-slot\",children:[k(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?k(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:le=>c(le.target.value),onKeyDown:Z,onBlur:M}):k(\"div\",{class:\"save-slot-title\",children:q.meta.title}),k(\"div\",{class:\"save-slot-meta\",children:[k(\"span\",{children:q.meta.passage}),k(\"span\",{children:qd(q.meta.updatedAt)})]})]}),k(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?k(\"button\",{class:\"save-slot-action primary\",onClick:()=>D(q.meta.id),children:\"Save Here\"}):k(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),k(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),k(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),k(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&k(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},N.playthrough.id)}),e===\"save\"&&!i&&!n.some(N=>N.playthrough.id===w)&&k(\"div\",{class:\"playthrough-group\",children:k(\"div\",{class:\"playthrough-saves\",children:k(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&k(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return k(jd,{})}});function Wd({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 k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:t.config.label}),k(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:t.config.label}),k(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>k(\"option\",{value:a,children:a},a))})]});case\"range\":return k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:[t.config.label,\": \",String(n)]}),k(\"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 Kd(){const e=Bt.getDefinitions();return k(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>k(Wd,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return k(Kd,{})}});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 k(\"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\",block:!0,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):\"\")}),k(\"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)}),k(\"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):\"\")}),k(\"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)}),k(\"label\",{id:t.id,class:t.cls,children:[k(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function Gd(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}=Gd(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)}),k(\"label\",{id:t.id,class:t.cls,children:[k(\"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))}}),k(\"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=>k(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),k(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",block:!0,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 Yd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Jd({passage:e,dataTransition:t}){const n=C(v=>v.storyData),r=Yd.has(e.name),[i,a]=X(!1),o=de(()=>{try{return At(e)}catch(v){return k(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",ko(e),\":\",\" \",v instanceof Error?v.message:String(v)]})}},[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(v){return console.error(\"spindle: Error in PassageHeader:\",v),null}},[s?.content]),f=de(()=>{if(!u)return null;try{return At(u)}catch(v){return console.error(\"spindle: Error in PassageFooter:\",v),null}},[u?.content]);we(()=>(l&&a(!0),()=>a(!1)),[e.name]);const p=de(()=>{if(!i||!l)return null;try{return At(l)}catch(v){return console.error(\"spindle: Error in PassageDone:\",v),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),h=k(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&k(\"div\",{class:\"passage-header\",children:d}),o,f&&k(\"div\",{class:\"passage-footer\",children:f}),p&&k(\"div\",{hidden:!0,children:p})]});return c?k(ce.Provider,{value:!0,children:h}):h}const Zd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),wr={type:\"fade-through\",duration:300,pause:50};function Xd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Zd.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 eh(e,t,n){const r=Xd(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:h,historyIndex:v,transitionConfig:S}=c,_=c.consumeNextTransition(),w=s.current;s.current=h.length;const x=!i,A=h.length===1&&v===0&&w>1,I=h.length>1&&v===h.length-1&&w>1&&Math.abs(h.length-w)>1;if(n===i)return;d();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(x||A||I){o.current=\"fade\",a(n);return}const P=eh(y.tags,_,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 k(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const p=r?.passages.get(\"PassageReady\");return k(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[p&&k(\"div\",{hidden:!0,children:At(p)},`ready-${n}`),k(\"div\",{class:\"passage-container\",ref:u,children:f&&k(Jd,{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],p=l[2]??l[3]??l[4];if(f)switch(f){case\"goto\":s.goto=p;break;case\"dialog\":s.dialog=p;break;case\"run\":s.run=p;break;case\"name\":s.name=p;break;case\"priority\":s.priority=p?Number(p):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,yo(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,bo(r)),null}});const th='*,*: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=cd(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=th,document.head.appendChild(t),Id(),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.\",h=document.getElementById(\"root\");throw h&&na(h,[c]),new Error(`spindle: ${c}`)}const i=Pd(r.content),a=Nd(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=$d(i),C.getState().init(e,n),mo();const o=Lf(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 h;for(;(h=s.exec(c.content))!==null;){const v=h[1],S=h[2];/\\{@children\\}/.test(S)&&lr(v)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const h=bt(c.content),v=vt(h);for(const S of v)if(S.type===\"macro\"&&S.name===\"widget\"&&S.rawArgs){const _=S.rawArgs.trim().split(/\\s+/),w=_[0].replace(/[\"']/g,\"\"),x=_.slice(1).filter(y=>y.startsWith(\"$\")||y.startsWith(\"_\")||y.startsWith(\"@\")),A=S.children,I=fn(A);Ka(w,A,x,I),I&&lr(w)}}let u=\"\";C.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,md())});let l=C.getState().variables,d=C.getState().historyIndex;C.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?jf():Wf()),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 p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');xe(k(ld,{}),p),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"})
1
+ window.storyFormat({"name":"spindle","version":"0.36.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Gt,F,fa,Ye,ni,da,ha,pa,Er,er,tr,ga,_n={},bn=[],ss=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Yt=Array.isArray;function De(e,t){for(var n in t)e[n]=t[n];return e}function Ar(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?Gt.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 Rt(e,o,r,i,null)}function Rt(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??++fa,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function ls(){return{current:null}}function Y(e){return e.children}function Te(e,t){this.props=e,this.context=t}function _t(e,t){if(t==null)return e.__?_t(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?_t(e):null}function us(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=De({},t);a.__v=t.__v+1,F.vnode&&F.vnode(a),$r(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??_t(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ba(r,a,i),t.__e=t.__=null,a.__e!=n&&ma(a)}}function ma(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}),ma(e)}function nr(e){(!e.__d&&(e.__d=!0)&&Ye.push(e)&&!vn.__r++||ni!=F.debounceRendering)&&((ni=F.debounceRendering)||da)(vn)}function vn(){for(var e,t=1;Ye.length;)Ye.length>t&&Ye.sort(ha),e=Ye.shift(),t=Ye.length,us(e);vn.__r=0}function ya(e,t,n,r,i,a,o,s,u,l,d){var f,p,c,h,v,k,y,w=r&&r.__k||bn,x=t.length;for(u=cs(n,t,w,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(p=c.__i!=-1&&w[c.__i]||_n,c.__i=f,k=$r(e,c,p,i,a,o,s,u,l,d),h=c.__e,c.ref&&p.ref!=c.ref&&(p.ref&&Dr(p.ref,null,c),d.push(c.ref,c.__c||h,c)),v==null&&h!=null&&(v=h),(y=!!(4&c.__u))||p.__k===c.__k?u=_a(c,u,e,y):typeof c.type==\"function\"&&k!==void 0?u=k:h&&(u=h.nextSibling),c.__u&=-7);return n.__e=v,u}function cs(e,t,n,r,i){var a,o,s,u,l,d=n.length,f=d,p=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=Rt(null,o,null,null,null):Yt(o)?o=e.__k[a]=Rt(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Rt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+p,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=fs(o,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?p--:i<d&&p++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?p--:l==u+1?p++:(l>u?p--:p++,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=_t(s)),wa(s,s));return r}function _a(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=_a(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=_t(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Be(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Yt(e)?e.some(function(n){Be(n,t)}):t.push(e)),t}function fs(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 ri(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ss.test(t)?n:n+\"px\"}function on(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||ri(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||ri(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(pa,\"$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=Er,e.addEventListener(t,a?tr:er,a)):e.removeEventListener(t,a?tr:er,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 ii(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Er++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function $r(e,t,n,r,i,a,o,s,u,l){var d,f,p,c,h,v,k,y,w,x,E,I,_,A,$,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=F.__b)&&d(t);e:if(typeof M==\"function\")try{if(y=t.props,w=\"prototype\"in M&&M.prototype.render,x=(d=M.contextType)&&r[d.__c],E=d?x?x.props.value:d.__:r,n.__c?k=(f=t.__c=n.__c).__=f.__E:(w?t.__c=f=new M(y,E):(t.__c=f=new Te(y,E),f.constructor=M,f.render=hs),x&&x.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),w&&f.__s==null&&(f.__s=f.state),w&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=De({},f.__s)),De(f.__s,M.getDerivedStateFromProps(y,f.__s))),c=f.props,h=f.state,f.__v=t,p)w&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),w&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(w&&M.getDerivedStateFromProps==null&&y!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,E)===!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)}),bn.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,E),w&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,h,v)})}if(f.context=E,f.props=y,f.__P=e,f.__e=!1,I=F.__r,_=0,w)f.state=f.__s,f.__d=!1,I&&I(t),d=f.render(f.props,f.state,f.context),bn.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=De(De({},r),f.getChildContext())),w&&!p&&f.getSnapshotBeforeUpdate!=null&&(v=f.getSnapshotBeforeUpdate(c,h)),A=d!=null&&d.type===Y&&d.key==null?va(d.props.children):d,s=ya(e,Yt(A)?A:[A],t,n,r,i,a,o,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),k&&(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($=a.length;$--;)Ar(a[$]);rr(t)}else t.__e=n.__e,t.__k=n.__k,b.then||rr(t);F.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ds(n.__e,t,n,r,i,a,o,u,l);return(d=F.diffed)&&d(t),128&t.__u?void 0:s}function rr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(rr))}function ba(e,t,n){for(var r=0;r<n.length;r++)Dr(n[r],n[++r],n[++r]);F.__c&&F.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){F.__e(a,i.__v)}})}function va(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Yt(e)?e.map(va):De({},e)}function ds(e,t,n,r,i,a,o,s,u){var l,d,f,p,c,h,v,k=n.props||_n,y=t.props,w=t.type;if(w==\"svg\"?i=\"http://www.w3.org/2000/svg\":w==\"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==!!w&&(w?c.localName==w:c.nodeType==3)){e=c,a[l]=null;break}}if(e==null){if(w==null)return document.createTextNode(y);e=document.createElementNS(i,w,y.is&&y),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(w==null)k===y||s&&e.data==y||(e.data=y);else{if(a=a&&Gt.call(e.childNodes),!s&&a!=null)for(k={},l=0;l<e.attributes.length;l++)k[(c=e.attributes[l]).name]=c.value;for(l in k)c=k[l],l==\"dangerouslySetInnerHTML\"?f=c:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||on(e,l,null,c,i);for(l in y)c=y[l],l==\"children\"?p=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?h=c:l==\"checked\"?v=c:s&&typeof c!=\"function\"||k[l]===c||on(e,l,c,k[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=\"\"),ya(t.type==\"template\"?e.content:e,Yt(p)?p:[p],t,n,r,w==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&_t(n,0),s,u),a!=null)for(l=a.length;l--;)Ar(a[l]);s||(l=\"value\",w==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[l]||w==\"progress\"&&!h||w==\"option\"&&h!=k[l])&&on(e,l,h,k[l],i),l=\"checked\",v!=null&&v!=e[l]&&on(e,l,v,k[l],i))}return e}function Dr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){F.__e(i,n)}}function wa(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Dr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){F.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&wa(r[i],t,n||typeof e.type!=\"function\");n||Ar(e.__e),e.__c=e.__=e.__e=void 0}function hs(e,t,n){return this.constructor(e,n)}function Ce(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),F.__&&F.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],$r(t,e=(!r&&n||t).__k=Q(Y,null,[e]),i||_n,_n,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Gt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ba(a,e,o)}function Sa(e,t){Ce(e,t,Sa)}function ps(e,t,n){var r,i,a,o,s=De({},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?Gt.call(arguments,2):n),Rt(e.type,s,r||e.key,i||e.ref,null)}function lt(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,nr(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\"+ga++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Gt=bn.slice,F={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},fa=0,Te.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=De({},this.state),typeof e==\"function\"&&(e=e(De({},n),this.props)),e&&De(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),nr(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),nr(this))},Te.prototype.render=Y,Ye=[],da=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ha=function(e,t){return e.__v.__b-t.__v.__b},vn.__r=0,pa=/(PointerCapture)$|Capture$/i,Er=0,er=ii(!1),tr=ii(!0),ga=0;var gs=0;function S(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gs,__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 F.vnode&&F.vnode(l),l}var je,W,Bn,ai,bt=0,ka=[],K=F,oi=K.__b,si=K.__r,li=K.diffed,ui=K.__c,ci=K.unmount,fi=K.__;function St(e,t){K.__h&&K.__h(W,e,bt||t),bt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ee(e){return bt=1,Tr(Pa,e)}function Tr(e,t,n){var r=St(je++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Pa(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(p){return p.__c});if(d.every(function(p){return!p.__N}))return!a||a.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(p){if(p.__N){var c=p.__[0];p.__=p.__N,p.__N=void 0,c!==p.__[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 Se(e,t){var n=St(je++,3);!K.__s&&Nr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ut(e,t){var n=St(je++,4);!K.__s&&Nr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return bt=5,he(function(){return{current:e}},[])}function xa(e,t,n){bt=6,ut(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 he(e,t){var n=St(je++,7);return Nr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function pe(e,t){return bt=8,he(function(){return e},t)}function G(e){var t=W.context[e.__c],n=St(je++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ca(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Ia(){var e=St(je++,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 ms(){for(var e;e=ka.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(dn),t.__h.some(ir),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,oi&&oi(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),fi&&fi(e,t)},K.__r=function(e){si&&si(e),je=0;var t=(W=e.__c).__H;t&&(Bn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(dn),t.__h.some(ir),t.__h=[],je=0)),Bn=W},K.diffed=function(e){li&&li(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ka.push(t)!==1&&ai===K.requestAnimationFrame||((ai=K.requestAnimationFrame)||ys)(ms)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Bn=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(dn),n.__h=n.__h.filter(function(r){return!r.__||ir(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),ui&&ui(e,t)},K.unmount=function(e){ci&&ci(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{dn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var di=typeof requestAnimationFrame==\"function\";function ys(e){var t,n=function(){clearTimeout(r),di&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);di&&(t=requestAnimationFrame(n))}function dn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function ir(e){var t=W;e.__c=e.__(),W=t}function Nr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Pa(e,t){return typeof t==\"function\"?t(e):t}const hi=e=>{let t;const n=new Set,r=(l,d)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const p=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,p))}},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},_s=(e=>e?hi(e):hi);function Ea(e,t){for(var n in t)e[n]=t[n];return e}function ar(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 Aa(e,t){var n=t(),r=ee({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ut(function(){i.__=n,i.u=t,Vn(i)&&a({t:i})},[e,n,t]),Se(function(){return Vn(i)&&a({t:i}),e(function(){Vn(i)&&a({t:i})})},[e]),n}function Vn(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 $a(e){e()}function Da(e){return e}function Ta(){return[!1,$a]}var Na=ut;function or(e,t){this.props=e,this.context=t}function bs(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:ar(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}(or.prototype=new Te).isPureReactComponent=!0,or.prototype.shouldComponentUpdate=function(e,t){return ar(this.props,e)||ar(this.state,t)};var pi=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),pi&&pi(e)};var vs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ws(e){function t(n){var r=Ea({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=vs,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var gi=function(e,t){return e==null?null:Be(Be(e).map(t))},Ss={map:gi,forEach:gi,count:function(e){return e?Be(e).length:0},only:function(e){var t=Be(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Be},ks=F.__e;F.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}ks(e,t,n,r)};var mi=F.unmount;function Ma(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=Ea({},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 Ma(r,t,n)})),e}function za(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return za(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 hn(){this.__u=0,this.o=null,this.__b=null}function Ra(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function xs(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 Mt(){this.i=null,this.l=null}F.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),mi&&mi(e)},(hn.prototype=new Te).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ra(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]=za(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)},hn.prototype.componentWillUnmount=function(){this.o=[]},hn.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]=Ma(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 yi=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 Cs(e){return this.getChildContext=function(){return e.context},e.children}function Is(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ce(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)}}}Ce(Q(Cs,{context:t.context},e.__v),t.v)}function Ps(e,t){var n=Q(Is,{__v:e,h:t});return n.containerInfo=t,n}(Mt.prototype=new Te).__a=function(e){var t=this,n=Ra(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),yi(t,e,r)):i()};n?n(a):a()}},Mt.prototype.render=function(e){this.i=null,this.l=new Map;var t=Be(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},Mt.prototype.componentDidUpdate=Mt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){yi(e,n,t)})};var Fa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Es=/^(?: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]/,As=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,$s=/[A-Z0-9]/g,Ds=typeof document<\"u\",Ts=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ns(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ce(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ms(e,t,n){return Sa(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Te.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Te.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var _i=F.event;function zs(){}function Rs(){return this.cancelBubble}function Fs(){return this.defaultPrevented}F.event=function(e){return _i&&(e=_i(e)),e.persist=zs,e.isPropagationStopped=Rs,e.isDefaultPrevented=Fs,e.nativeEvent=e};var Mr,Os={enumerable:!1,configurable:!0,get:function(){return this.class}},bi=F.vnode;F.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||Ds&&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\"||Ts(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":As.test(o)&&(o=u):u=o=\"oninput\":a&&Es.test(o)?o=o.replace($s,\"-$&\").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=Be(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Be(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\",Os)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Fa,bi&&bi(e)};var vi=F.__r;F.__r=function(e){vi&&vi(e),Mr=e.__c};var wi=F.diffed;F.diffed=function(e){wi&&wi(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),Mr=null};var Ls={ReactCurrentDispatcher:{current:{readContext:function(e){return Mr.__n[e.__c].props.value},useCallback:pe,useContext:G,useDebugValue:Ca,useDeferredValue:Da,useEffect:Se,useId:Ia,useImperativeHandle:xa,useInsertionEffect:Na,useLayoutEffect:ut,useMemo:he,useReducer:Tr,useRef:se,useState:ee,useSyncExternalStore:Aa,useTransition:Ta}}};function Bs(e){return Q.bind(null,e)}function Dn(e){return!!e&&e.$$typeof===Fa}function Vs(e){return Dn(e)&&e.type===Y}function Hs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function qs(e){return Dn(e)?ps.apply(null,arguments):e}function Us(e){return!!e.__k&&(Ce(null,e),!0)}function js(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ws=function(e,t){return e(t)},Ks=function(e,t){return e(t)},Qs=Y,Gs=Dn,sn={useState:ee,useId:Ia,useReducer:Tr,useEffect:Se,useLayoutEffect:ut,useInsertionEffect:Na,useTransition:Ta,useDeferredValue:Da,useSyncExternalStore:Aa,startTransition:$a,useRef:se,useImperativeHandle:xa,useMemo:he,useCallback:pe,useContext:G,useDebugValue:Ca,version:\"18.3.1\",Children:Ss,render:Ns,hydrate:Ms,unmountComponentAtNode:Us,createPortal:Ps,createElement:Q,createContext:lt,createFactory:Bs,cloneElement:qs,createRef:ls,Fragment:Y,isValidElement:Dn,isElement:Gs,isFragment:Vs,isMemo:Hs,findDOMNode:js,Component:Te,PureComponent:or,memo:bs,forwardRef:ws,flushSync:Ks,unstable_batchedUpdates:Ws,StrictMode:Qs,Suspense:hn,SuspenseList:Mt,lazy:xs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ls};const Ys=e=>e;function Js(e,t=Ys){const n=sn.useSyncExternalStore(e.subscribe,sn.useCallback(()=>t(e.getState()),[e,t]),sn.useCallback(()=>t(e.getInitialState()),[e,t]));return sn.useDebugValue(n),n}const Xs=e=>{const t=_s(e),n=r=>Js(t,r);return Object.assign(n,t),n},Zs=(e=>Xs);var zr=Symbol.for(\"immer-nothing\"),Ft=Symbol.for(\"immer-draftable\"),ne=Symbol.for(\"immer-state\");function oe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var me=Object,it=me.getPrototypeOf,Ht=\"constructor\",Jt=\"prototype\",sr=\"configurable\",wn=\"enumerable\",pn=\"writable\",qt=\"value\",He=e=>!!e&&!!e[ne];function Ne(e){return e?Oa(e)||Zt(e)||!!e[Ft]||!!e[Ht]?.[Ft]||en(e)||tn(e):!1}var el=me[Jt][Ht].toString(),Si=new WeakMap;function Oa(e){if(!e||!vt(e))return!1;const t=it(e);if(t===null||t===me[Jt])return!0;const n=me.hasOwnProperty.call(t,Ht)&&t[Ht];if(n===Object)return!0;if(!Je(n))return!1;let r=Si.get(n);return r===void 0&&(r=Function.toString.call(n),Si.set(n,r)),r===el}function Xt(e,t,n=!0){at(e)===0?(n?Reflect.ownKeys(e):me.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function at(e){const t=e[ne];return t?t.type_:Zt(e)?1:en(e)?2:tn(e)?3:0}var Ot=(e,t,n=at(e))=>n===2?e.has(t):me[Jt].hasOwnProperty.call(e,t),Oe=(e,t,n=at(e))=>n===2?e.get(t):e[t],Sn=(e,t,n,r=at(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function tl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Zt=Array.isArray,en=e=>e instanceof Map,tn=e=>e instanceof Set,vt=e=>typeof e==\"object\",Je=e=>typeof e==\"function\",Hn=e=>typeof e==\"boolean\";function nl(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var rl=e=>vt(e)?e?.[ne]:null,Le=e=>e.copy_||e.base_,Rr=e=>e.modified_?e.copy_:e.base_;function lr(e,t){if(en(e))return new Map(e);if(tn(e))return new Set(e);if(Zt(e))return Array[Jt].slice.call(e);const n=Oa(e);if(t===!0||t===\"class_only\"&&!n){const r=me.getOwnPropertyDescriptors(e);delete r[ne];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[pn]===!1&&(s[pn]=!0,s[sr]=!0),(s.get||s.set)&&(r[o]={[sr]:!0,[pn]:!0,[wn]:s[wn],[qt]:e[o]})}return me.create(it(e),r)}else{const r=it(e);if(r!==null&&n)return{...e};const i=me.create(r);return me.assign(i,e)}}function Fr(e,t=!1){return Tn(e)||He(e)||!Ne(e)||(at(e)>1&&me.defineProperties(e,{set:ln,add:ln,clear:ln,delete:ln}),me.freeze(e),t&&Xt(e,(n,r)=>{Fr(r,!0)},!1)),e}function il(){oe(2)}var ln={[qt]:il};function Tn(e){return e===null||!vt(e)?!0:me.isFrozen(e)}var kn=\"MapSet\",xn=\"Patches\",ki=\"ArrayMethods\",Cn={};function ot(e){const t=Cn[e];return t||oe(0,e),t}var xi=e=>!!Cn[e];function al(e,t){Cn[e]||(Cn[e]=t)}var Ut,La=()=>Ut,ol=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:xi(kn)?ot(kn):void 0,arrayMethodsPlugin_:xi(ki)?ot(ki):void 0});function Ci(e,t){t&&(e.patchPlugin_=ot(xn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ur(e){cr(e),e.drafts_.forEach(sl),e.drafts_=null}function cr(e){e===Ut&&(Ut=e.parent_)}var Ii=e=>Ut=ol(Ut,e);function sl(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Pi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(ur(t),oe(4)),Ne(e)&&(e=Ei(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Ei(t,n);return ll(t,e,!0),ur(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==zr?e:void 0}function Ei(e,t){if(Tn(t))return t;const n=t[ne];if(!n)return In(t,e.handledSet_,e);if(!Nn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);Ha(n,e)}return n.copy_}function ll(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Fr(t,n)}function Ba(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Nn=(e,t)=>e.scope_===t,ul=[];function Va(e,t,n,r){const i=Le(e),a=e.type_;if(r!==void 0&&Oe(i,r,a)===t){Sn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Xt(i,(u,l)=>{if(He(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??ul;for(const s of o)Sn(i,s,n,a)}function cl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Nn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Rr(a);Va(e,a.draft_??a,o,n),Ha(a,i)})}function Ha(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)}Ba(e)}}function fl(e,t,n){const{scope_:r}=e;if(He(n)){const i=n[ne];Nn(i,r)&&i.callbacks_.push(function(){gn(e);const o=Rr(i);Va(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Le(e);e.type_===3?a.has(n)&&In(n,r.handledSet_,r):Oe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&In(Oe(e.copy_,t,e.type_),r.handledSet_,r)})}function In(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||He(e)||t.has(e)||!Ne(e)||Tn(e)||(t.add(e),Xt(e,(r,i)=>{if(He(i)){const a=i[ne];if(Nn(a,n)){const o=Rr(a);Sn(e,r,o,e.type_),Ba(a)}}else Ne(i)&&In(i,t,n)})),e}function dl(e,t){const n=Zt(e),r={type_:n?1:0,scope_:t?t.scope_:La(),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=Pn;n&&(i=[r],a=jt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Pn={get(e,t){if(t===ne)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Le(e);if(!Ot(i,t,e.type_))return hl(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&nl(t))return a;if(a===qn(e.base_,t)){gn(e);const o=e.type_===1?+t:t,s=dr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Le(e)},ownKeys(e){return Reflect.ownKeys(Le(e))},set(e,t,n){const r=qa(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=qn(Le(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(tl(n,i)&&(n!==void 0||Ot(e.base_,t,e.type_)))return!0;gn(e),fr(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),fl(e,t,n)),!0},deleteProperty(e,t){return gn(e),qn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),fr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Le(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[pn]:!0,[sr]:e.type_!==1||t!==\"length\",[wn]:r[wn],[qt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return it(e.base_)},setPrototypeOf(){oe(12)}},jt={};for(let e in Pn){let t=Pn[e];jt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}jt.deleteProperty=function(e,t){return jt.set.call(this,e,t,void 0)};jt.set=function(e,t,n){return Pn.set.call(this,e[0],t,n,e[0])};function qn(e,t){const n=e[ne];return(n?Le(n):e)[t]}function hl(e,t,n){const r=qa(t,n);return r?qt in r?r[qt]:r.get?.call(e.draft_):void 0}function qa(e,t){if(!(t in e))return;let n=it(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=it(n)}}function fr(e){e.modified_||(e.modified_=!0,e.parent_&&fr(e.parent_))}function gn(e){e.copy_||(e.assigned_=new Map,e.copy_=lr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var pl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Je(t)&&!Je(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Je(n)||oe(6),r!==void 0&&!Je(r)&&oe(7);let i;if(Ne(t)){const a=Ii(this),o=dr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?ur(a):cr(a)}return Ci(a,r),Pi(i,a)}else if(!t||!vt(t)){if(i=n(t),i===void 0&&(i=t),i===zr&&(i=void 0),this.autoFreeze_&&Fr(i,!0),r){const a=[],o=[];ot(xn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Je(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},Hn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Hn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Hn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||oe(8),He(e)&&(e=gl(e));const t=Ii(this),n=dr(t,e,void 0);return n[ne].isManual_=!0,cr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return Ci(r,t),Pi(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=ot(xn).applyPatches_;return He(e)?r(e,t):this.produce(e,i=>r(i,t))}};function dr(e,t,n,r){const[i,a]=en(t)?ot(kn).proxyMap_(t,n):tn(t)?ot(kn).proxySet_(t,n):dl(t,n);return(n?.scope_??La()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?cl(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 gl(e){return He(e)||oe(10,e),Ua(e)}function Ua(e){if(!Ne(e)||Tn(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=lr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=lr(e,!0);return Xt(n,(i,a)=>{Sn(n,i,Ua(a))},r),t&&(t.finalized_=!1),n}function ml(){function t(h,v=[]){if(h.key_!==void 0){const k=h.parent_.copy_??h.parent_.base_,y=rl(Oe(k,h.key_)),w=Oe(k,h.key_);if(w===void 0||w!==h.draft_&&w!==h.base_&&w!==h.copy_||y!=null&&y.base_!==h.base_)return null;const x=h.parent_.type_===3;let E;if(x){const I=h.parent_;E=Array.from(I.drafts_.keys()).indexOf(h.key_)}else E=h.key_;if(!(x&&k.size>E||Ot(k,E)))return null;v.push(E)}if(h.parent_)return t(h.parent_,v);v.reverse();try{n(h.copy_,v)}catch{return null}return v}function n(h,v){let k=h;for(let y=0;y<v.length-1;y++){const w=v[y];if(k=Oe(k,w),!vt(k)||k===null)throw new Error(`Cannot resolve path at '${v.join(\"/\")}'`)}return k}const r=\"replace\",i=\"add\",a=\"remove\";function o(h,v,k){if(h.scope_.processedForPatches_.has(h))return;h.scope_.processedForPatches_.add(h);const{patches_:y,inversePatches_:w}=k;switch(h.type_){case 0:case 2:return u(h,v,y,w);case 1:return s(h,v,y,w);case 3:return l(h,v,y,w)}}function s(h,v,k,y){let{base_:w,assigned_:x}=h,E=h.copy_;E.length<w.length&&([w,E]=[E,w],[k,y]=[y,k]);const I=h.allIndicesReassigned_===!0;for(let _=0;_<w.length;_++){const A=E[_],$=w[_];if((I||x?.get(_.toString()))&&A!==$){const b=A?.[ne];if(b&&b.modified_)continue;const D=v.concat([_]);k.push({op:r,path:D,value:c(A)}),y.push({op:r,path:D,value:c($)})}}for(let _=w.length;_<E.length;_++){const A=v.concat([_]);k.push({op:i,path:A,value:c(E[_])})}for(let _=E.length-1;w.length<=_;--_){const A=v.concat([_]);y.push({op:a,path:A})}}function u(h,v,k,y){const{base_:w,copy_:x,type_:E}=h;Xt(h.assigned_,(I,_)=>{const A=Oe(w,I,E),$=Oe(x,I,E),M=_?Ot(w,I)?r:i:a;if(A===$&&M===r)return;const b=v.concat(I);k.push(M===a?{op:M,path:b}:{op:M,path:b,value:c($)}),y.push(M===i?{op:a,path:b}:M===a?{op:i,path:b,value:c(A)}:{op:r,path:b,value:c(A)})})}function l(h,v,k,y){let{base_:w,copy_:x}=h,E=0;w.forEach(I=>{if(!x.has(I)){const _=v.concat([E]);k.push({op:a,path:_,value:I}),y.unshift({op:i,path:_,value:I})}E++}),E=0,x.forEach(I=>{if(!w.has(I)){const _=v.concat([E]);k.push({op:i,path:_,value:I}),y.unshift({op:a,path:_,value:I})}E++})}function d(h,v,k){const{patches_:y,inversePatches_:w}=k;y.push({op:r,path:[],value:v===zr?void 0:v}),w.push({op:r,path:[],value:h})}function f(h,v){return v.forEach(k=>{const{path:y,op:w}=k;let x=h;for(let A=0;A<y.length-1;A++){const $=at(x);let M=y[A];typeof M!=\"string\"&&typeof M!=\"number\"&&(M=\"\"+M),($===0||$===1)&&(M===\"__proto__\"||M===Ht)&&oe(19),Je(x)&&M===Jt&&oe(19),x=Oe(x,M),vt(x)||oe(18,y.join(\"/\"))}const E=at(x),I=p(k.value),_=y[y.length-1];switch(w){case r:switch(E){case 2:return x.set(_,I);case 3:oe(16);default:return x[_]=I}case i:switch(E){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(E){case 1:return x.splice(_,1);case 2:return x.delete(_);case 3:return x.delete(k.value);default:return delete x[_]}default:oe(17,w)}}),h}function p(h){if(!Ne(h))return h;if(Zt(h))return h.map(p);if(en(h))return new Map(Array.from(h.entries()).map(([k,y])=>[k,p(y)]));if(tn(h))return new Set(Array.from(h).map(p));const v=Object.create(it(h));for(const k in h)v[k]=p(h[k]);return Ot(h,Ft)&&(v[Ft]=h[Ft]),v}function c(h){return He(h)?p(h):h}al(xn,{applyPatches_:f,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var Wt=new pl,yl=Wt.produce,_l=Wt.produceWithPatches.bind(Wt),mt=Wt.applyPatches.bind(Wt);const bl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?yl(i):i;return t(s,a,...o)},e(r.setState,n,r)),vl=bl,wl=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\"]),Sl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function kl(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 Ai(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 $i(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 xl(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 kt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const h=$i(e,n);o=h.className||void 0,s=h.id||void 0,n=h.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:p}=kl(d),c={type:\"link\",display:f,target:p,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=$i(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 p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"variable\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f===\"_\"){n=d+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"temporary\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f===\"@\"){n=d+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:c,scope:\"local\",start:a,end:n};s&&(h.className=s),u&&(h.id=u),t.push(h),r=n;continue}n=a+1,r=a;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let p=1;const c=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const h=e.slice(c,n);n++;const{name:v,rawArgs:k,isClose:y}=Ai(h),w={type:\"macro\",name:v,rawArgs:k,isClose:y,start:a,end:n};s&&(w.className=s),u&&(w.id=u),t.push(w),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:p,rawArgs:c,isClose:h}=Ai(f);t.push({type:\"macro\",name:p,rawArgs:c,isClose:h,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&wl.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=xl(e,o);o=d.endIdx;let f=Sl.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 ja=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function hr(e){ja.add(e.toLowerCase())}const Di={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Cl=new Set([\"if\",\"switch\",\"timed\"]);function xt(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(Di[a]){const o=Di[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(ja.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(Cl.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 Or(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=G(Ie);return he(()=>[e,t,n],[e,t,n])}const Il=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,Pl=/\\{[\\$_@][\\w.]+\\}/;function El(e){return Pl.test(e)}function Al(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 $l(e,t,n,r){return e.replace(Il,(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=Al(d,u)),d==null?\"\":String(d)})}function Lr(){const[e,t,n]=Or();return pe(r=>r===void 0||!El(r)?r:$l(r,e,t,n),[e,t,n])}function Dl({name:e,scope:t,className:n,id:r}){const i=Lr();n=i(n),r=i(r);const a=G(Ie),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 p=o[f];l=l[p]}const d=l==null?\"\":String(l);return n||r?S(\"span\",{id:r,class:n,children:d}):S(Y,{children:d})}function Wa(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 Ka(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let Ct=!1,nn=\"\",st=0,wt=null;function Tl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,nn=n,st=0,wt=Wa(Ka(n)),Ct=!0}function Qa(e,t){nn=e,st=0,wt=Wa(Ka(e)),Ct=!0;for(let n=0;n<t;n++)wt();st=t}function pr(){Ct=!1,nn=\"\",st=0,wt=null}function En(){return Ct?{seed:nn,pull:st}:null}function Br(){return!Ct||!wt?Math.random():(st++,wt())}function Ga(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Br()*(t-e+1))+e}function Nl(){return Ct}function Ml(){return nn}function zl(){return st}const Rl=500,Qe=new Map,Fl=/\\$(\\w+)/g,Ol=/(?<![.\\w])_(\\w+)/g,Ll=/@(\\w+)/g;function Bl(e){return e.replace(Fl,'variables[\"$1\"]').replace(Ol,'temporary[\"$1\"]').replace(Ll,'locals[\"$1\"]')}function Vr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Bl(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 p=e.charAt(r);p===\"{\"?f++:p===\"}\"&&f--,f>0&&(u+=p),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Vr(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 Vl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ya(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\",Vl+t);if(Qe.set(e,r),Qe.size>Rl){const i=Qe.keys().next().value;i!==void 0&&Qe.delete(i)}return r}let un=null,Ti=null,Ni=null;function Ja(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(un&&Ti===t&&Ni===n)return un;const r=c=>t[c??C.getState().currentPassage]??0,i=c=>r(c)>0,a=(...c)=>c.some(h=>r(h)>0),o=(...c)=>c.every(h=>r(h)>0),s=c=>n[c??C.getState().currentPassage]??0;return un={currentPassage:()=>{const c=C.getState();return c.storyData?.passages.get(c.currentPassage)},previousPassage:()=>{const c=C.getState();if(c.historyIndex<=0)return;const h=c.history[c.historyIndex-1]?.passage;return h?c.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(h=>s(h)>0),hasRenderedAll:(...c)=>c.every(h=>s(h)>0),random:Br,randomInt:Ga},Ti=t,Ni=n,un}function Mn(e,t,n,r={}){const a=`return (${Vr(e)});`;return Ya(a,a)(t,n,r,Ja())}function Xa(e,t,n,r={}){const i=Vr(e);Ya(\"exec:\"+i,i)(t,n,r,Ja())}function Hl(e){const t=e[0];return!!(t==='\"'||t===\"'\"||t===\"`\"||t===\"$\"||t===\"_\"||t===\"@\"||/\\d/.test(t)||(t===\"-\"||t===\"+\")&&e.length>1&&/\\d/.test(e[1])||t===\"(\"||t===\"[\"||t===\"{\"||/^(true|false|null|undefined)$/.test(e)||t===\"!\"&&e.length>1)}function ql(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const o=e[a];if(i){n+=o,o===i&&e[a-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(/\\s/.test(o)&&r===0){n&&(t.push(n),n=\"\");continue}n+=o}if(n&&t.push(n),t.length<2)return null;for(const a of t)if(!Hl(a))return null;return t}function Ul(e){const t=[];let n=\"\",r=0,i=null,a=!1;for(let s=0;s<e.length;s++){const u=e[s];if(i){n+=u,u===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(u==='\"'||u===\"'\"||u===\"`\"){i=u,n+=u;continue}if(u===\"(\"||u===\"[\"||u===\"{\"){r++,n+=u;continue}if(u===\")\"||u===\"]\"||u===\"}\"){r--,n+=u;continue}if(u===\",\"&&r===0){a=!0,t.push(n.trim()),n=\"\";continue}n+=u}const o=n.trim();if(o&&t.push(o),!a&&t.length===1){const s=ql(t[0]);if(s)return s}return t}function jl({body:e,parentValues:t,ownKeys:n}){const r=G(fe),[i,a]=ee({}),o={...t,...n,...i},s=se(o);s.current=o;const u=pe(()=>s.current,[]),l=pe((f,p)=>{a(c=>({...c,[f]:p}))},[]),d=he(()=>({update:l,getValues:u}),[l,u]);return S(rn.Provider,{value:d,children:S(Ie.Provider,{value:o,children:Pe(e,{nobr:r,locals:o})})})}function Wl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=G(Ie),a=G(fe),[o,s,u]=Or(),l=r?.length?r:null;if(t.length===0||!n)return S(br.Provider,{value:l,children:Pe(e,{nobr:a,locals:i})});const d=Ul(n),f={};for(let p=0;p<t.length;p++){const c=t[p],h=d[p];let v;if(h!==void 0)try{v=Mn(h,o,s,u)}catch{v=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=v}return S(br.Provider,{value:l,children:S(jl,{body:e,parentValues:i,ownKeys:f})})}const Za=new Map;function eo(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");Za.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Kl(e){return Za.get(e.toLowerCase())}const to=new Map;function Ql(e,t){to.set(e.toLowerCase(),t)}function Gl(e){return to.get(e.toLowerCase())}const no=new Set;function Yl(e){no.add(e.toLowerCase())}function Jl(e){return no.has(e.toLowerCase())}const ro=new Map;function Xl(e,t){ro.set(e.toLowerCase(),t)}function Zl(){return Array.from(ro.values())}const Mi=document.createElement(\"i\");function io(e){const t=\"&\"+e+\";\";Mi.innerHTML=t;const n=Mi.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 ae(e,t){return e.length>0?(_e(e,e.length,0,t),e):t}const gr={}.hasOwnProperty;function eu(e){const t={};let n=-1;for(;++n<e.length;)tu(t,e[n]);return t}function tu(e,t){let n;for(n in t){const i=(gr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){gr.call(i,o)||(i[o]=[]);const s=a[o];nu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function nu(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 ru(e){const t={};let n=-1;for(;++n<e.length;)iu(t,e[n]);return t}function iu(e,t){let n;for(n in t){const i=(gr.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 au(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 ou={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function ao(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+ou[n]+\";\"}}function Kt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const $e=Ke(/[A-Za-z]/),ye=Ke(/[\\dA-Za-z]/),su=Ke(/[#-'*+\\--9=?A-Z^-~]/);function mr(e){return e!==null&&(e<32||e===127)}const yr=Ke(/\\d/),lu=Ke(/[\\dA-Fa-f]/),uu=Ke(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const cu=Ke(/\\p{P}|\\p{S}/u),fu=Ke(/\\s/);function Ke(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function cn(e,t){const n=ao(du(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 du(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&ye(e.charCodeAt(n+1))&&ye(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 zi={}.hasOwnProperty,Ri=/^(https?|ircs?|mailto|xmpp)$/i,hu=/^https?$/i;function pu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=ru([{enter:{blockQuote:O,codeFenced:ke,codeFencedFenceInfo:k,codeFencedFenceMeta:k,codeIndented:j,codeText:Zo,content:Vo,definition:zo,definitionDestinationString:Fo,definitionLabelString:k,definitionTitleString:k,emphasis:Jo,htmlFlow:Yo,htmlText:Jr,image:q,label:k,link:ue,listItemMarker:D,listItemValue:b,listOrdered:$,listUnordered:M,paragraph:X,reference:k,resource:dt,resourceDestinationString:ht,resourceTitleString:k,setextHeading:qo,strong:Xo},exit:{atxHeading:jo,atxHeadingSequence:Ho,autolinkEmail:os,autolinkProtocol:as,blockQuote:Z,characterEscapeValue:Pt,characterReferenceMarkerHexadecimal:Xr,characterReferenceMarkerNumeric:Xr,characterReferenceValue:is,codeFenced:g,codeFencedFence:T,codeFencedFenceInfo:m,codeFencedFenceMeta:A,codeFlowValue:Go,codeIndented:g,codeText:es,codeTextData:Pt,data:Pt,definition:Bo,definitionDestinationString:Oo,definitionLabelString:Ro,definitionTitleString:Lo,emphasis:ts,hardBreakEscape:Gr,hardBreakTrailing:Gr,htmlFlow:Yr,htmlFlowData:Pt,htmlText:Yr,htmlTextData:Pt,image:Qr,label:It,labelText:te,lineEnding:Qo,link:Qr,listOrdered:N,listUnordered:V,paragraph:ge,reference:A,referenceString:qe,resource:A,resourceDestinationString:Ln,resourceTitleString:Mo,setextHeading:Ko,setextHeadingLineSequence:Wo,setextHeadingText:Uo,strong:ns,thematicBreak:rs}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:k,encode:_,getData:v,lineEndingIfNeeded:I,options:t,raw:x,resume:y,setData:h,tag:w};let f=t.defaultLineEnding;return p;function p(P){let z=-1,re=0;const xe=[];let Ee=[],Me=[];for(;++z<P.length;)!f&&(P[z][1].type===\"lineEnding\"||P[z][1].type===\"lineEndingBlank\")&&(f=P[z][2].sliceSerialize(P[z][1])),(P[z][1].type===\"listOrdered\"||P[z][1].type===\"listUnordered\")&&(P[z][0]===\"enter\"?xe.push(z):c(P.slice(xe.pop(),z))),P[z][1].type===\"definition\"&&(P[z][0]===\"enter\"?(Me=ae(Me,P.slice(re,z)),re=z):(Ee=ae(Ee,P.slice(re,z+1)),re=z+1));Ee=ae(Ee,Me),Ee=ae(Ee,P.slice(re)),z=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++z<P.length;){const Zr=u[Ae[z][0]],ei=Ae[z][1].type,ti=Zr[ei];zi.call(Zr,ei)&&ti&&ti.call({sliceSerialize:Ae[z][2].sliceSerialize,...d},Ae[z][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(P){const z=P.length;let re=0,xe=0,Ee=!1,Me;for(;++re<z;){const Ae=P[re];if(Ae[1]._container)Me=void 0,Ae[0]===\"enter\"?xe++:xe--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(Me=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!xe&&(Me?Me=void 0:Ee=!0);break}default:Me=void 0}}P[0][1]._loose=Ee}function h(P,z){l[P]=z}function v(P){return l[P]}function k(){i.push([])}function y(){return i.pop().join(\"\")}function w(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(f||`\n`)}function I(){const P=i[i.length-1],z=P[P.length-1],re=z?z.charCodeAt(z.length-1):null;re===10||re===13||re===null||E()}function _(P){return v(\"ignoreEncode\")?P:ao(P)}function A(){y()}function $(P){o.push(!P._loose),I(),w(\"<ol\"),h(\"expectFirstItem\",!0)}function M(P){o.push(!P._loose),I(),w(\"<ul\"),h(\"expectFirstItem\",!0)}function b(P){if(v(\"expectFirstItem\")){const z=Number.parseInt(this.sliceSerialize(P),10);z!==1&&w(' start=\"'+_(String(z))+'\"')}}function D(){v(\"expectFirstItem\")?w(\">\"):U(),I(),w(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),w(\"</ol>\")}function V(){U(),o.pop(),E(),w(\"</ul>\")}function U(){v(\"lastWasTag\")&&!v(\"slurpAllLineEndings\")&&I(),w(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),w(\"<blockquote>\")}function Z(){o.pop(),I(),w(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),w(\"<p>\")),h(\"slurpAllLineEndings\")}function ge(){o[o.length-1]?h(\"slurpAllLineEndings\",!0):w(\"</p>\")}function ke(){I(),w(\"<pre><code\"),h(\"fencesCount\",0)}function m(){const P=y();w(' class=\"language-'+P+'\"')}function T(){const P=v(\"fencesCount\")||0;P||(w(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),w(\"<pre><code>\")}function g(){const P=v(\"fencesCount\");P!==void 0&&P<2&&l.tightStack.length>0&&!v(\"lastWasTag\")&&E(),v(\"flowCodeSeenData\")&&I(),w(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function It(){a[a.length-1].label=y()}function qe(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function dt(){k(),a[a.length-1].destination=\"\"}function ht(){k(),h(\"ignoreEncode\",!0)}function Ln(){a[a.length-1].destination=y(),h(\"ignoreEncode\")}function Mo(){a[a.length-1].title=y()}function Qr(){let P=a.length-1;const z=a[P],re=z.referenceId||z.labelId,xe=z.destination===void 0?r[Kt(re)]:z;for(n=!0;P--;)if(a[P].image){n=void 0;break}z.image?(w('<img src=\"'+cn(xe.destination,t.allowDangerousProtocol?void 0:hu)+'\" alt=\"'),x(z.label),w('\"')):w('<a href=\"'+cn(xe.destination,t.allowDangerousProtocol?void 0:Ri)+'\"'),w(xe.title?' title=\"'+xe.title+'\"':\"\"),z.image?w(\" />\"):(w(\">\"),x(z.label),w(\"</a>\")),a.pop()}function zo(){k(),a.push({})}function Ro(P){y(),a[a.length-1].labelId=this.sliceSerialize(P)}function Fo(){k(),h(\"ignoreEncode\",!0)}function Oo(){a[a.length-1].destination=y(),h(\"ignoreEncode\")}function Lo(){a[a.length-1].title=y()}function Bo(){const P=a[a.length-1],z=Kt(P.labelId);y(),zi.call(r,z)||(r[z]=a[a.length-1]),a.pop()}function Vo(){h(\"slurpAllLineEndings\",!0)}function Ho(P){v(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),w(\"<h\"+v(\"headingRank\")+\">\"))}function qo(){k(),h(\"slurpAllLineEndings\")}function Uo(){h(\"slurpAllLineEndings\",!0)}function jo(){w(\"</h\"+v(\"headingRank\")+\">\"),h(\"headingRank\")}function Wo(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function Ko(){const P=y();I(),w(\"<h\"+v(\"headingRank\")+\">\"),x(P),w(\"</h\"+v(\"headingRank\")+\">\"),h(\"slurpAllLineEndings\"),h(\"headingRank\")}function Pt(P){x(_(this.sliceSerialize(P)))}function Qo(P){if(!v(\"slurpAllLineEndings\")){if(v(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(v(\"inCodeText\")){x(\" \");return}x(_(this.sliceSerialize(P)))}}function Go(P){x(_(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function Gr(){w(\"<br />\")}function Yo(){I(),Jr()}function Yr(){h(\"ignoreEncode\")}function Jr(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function Jo(){w(\"<em>\")}function Xo(){w(\"<strong>\")}function Zo(){h(\"inCodeText\",!0),w(\"<code>\")}function es(){h(\"inCodeText\"),w(\"</code>\")}function ts(){w(\"</em>\")}function ns(){w(\"</strong>\")}function rs(){I(),w(\"<hr />\")}function Xr(P){h(\"characterReferenceType\",P.type)}function is(P){const z=this.sliceSerialize(P),re=v(\"characterReferenceType\")?au(z,v(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):io(z);x(_(re)),h(\"characterReferenceType\")}function as(P){const z=this.sliceSerialize(P);w('<a href=\"'+cn(z,t.allowDangerousProtocol?void 0:Ri)+'\">'),x(_(z)),w(\"</a>\")}function os(P){const z=this.sliceSerialize(P);w('<a href=\"'+cn(\"mailto:\"+z)+'\">'),x(_(z)),w(\"</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 gu={tokenize:mu};function mu(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 yu={tokenize:_u},Fi={tokenize:bu};function _u(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&w();const E=t.events.length;let I=E,_;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){_=t.events[I][1].end;break}y(r);let A=E;for(;A<t.events.length;)t.events[A][1].end={..._},A++;return _e(t.events,I+1,0,t.events.slice(E)),t.events.length=A,l(x)}return s(x)}function l(x){if(r===n.length){if(!i)return p(x);if(i.currentConstruct&&i.currentConstruct.concrete)return h(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Fi,d,f)(x)}function d(x){return i&&w(),y(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(x)}function p(x){return t.containerState={},e.attempt(Fi,c,h)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function h(x){if(x===null){i&&w(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),v(x)}function v(x){if(x===null){k(e.exit(\"chunkFlow\"),!0),y(0),e.consume(x);return}return R(x)?(e.consume(x),k(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),v)}function k(x,E){const I=t.sliceStream(x);if(E&&I.push(null),x.previous=a,a&&(a.next=x),a=x,i.defineSkip(x.start),i.write(I),t.parser.lazy[x.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const A=t.events.length;let $=A,M,b;for(;$--;)if(t.events[$][0]===\"exit\"&&t.events[$][1].type===\"chunkFlow\"){if(M){b=t.events[$][1].end;break}M=!0}for(y(r),_=A;_<t.events.length;)t.events[_][1].end={...b},_++;_e(t.events,$+1,0,t.events.slice(A)),t.events.length=_}}function y(x){let E=n.length;for(;E-- >x;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=x}function w(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function bu(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 An(e){if(e===null||le(e)||fu(e))return 1;if(cu(e))return 2}function zn(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 _r={name:\"attention\",resolveAll:vu,tokenize:wu};function vu(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},p={...e[n][1].start};Oi(f,-u),Oi(p,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:p},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=ae(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ae(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ae(l,zn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ae(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=ae(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 wu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=An(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=An(u),f=!d||d===2&&i||n.includes(u),p=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?f:f&&(i||!p)),l._close=!!(a===42?p:p&&(d||!f)),t(u)}}function Oi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Su={name:\"autolink\",tokenize:ku};function ku(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 $e(c)?(e.consume(c),o):c===64?n(c):l(c)}function o(c){return c===43||c===45||c===46||ye(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||ye(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||mr(c)?n(c):(e.consume(c),u)}function l(c){return c===64?(e.consume(c),d):su(c)?(e.consume(c),l):n(c)}function d(c){return ye(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):p(c)}function p(c){if((c===45||ye(c))&&r++<63){const h=c===45?p:f;return e.consume(c),h}return n(c)}}const Rn={partial:!0,tokenize:xu};function xu(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 oo={continuation:{tokenize:Iu},exit:Pu,name:\"blockQuote\",tokenize:Cu};function Cu(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 Iu(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(oo,t,n)(o)}}function Pu(e){e.exit(\"blockQuote\")}const so={name:\"characterEscape\",tokenize:Eu};function Eu(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 uu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const lo={name:\"characterReference\",tokenize:Au};function Au(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=ye,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=lu,d):(e.enter(\"characterReferenceValue\"),a=7,o=yr,d(f))}function d(f){if(f===59&&i){const p=e.exit(\"characterReferenceValue\");return o===ye&&!io(r.sliceSerialize(p))?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 Li={partial:!0,tokenize:Du},Bi={concrete:!0,name:\"codeFenced\",tokenize:$u};function $u(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 A=r.events[r.events.length-1];return a=A&&A[1].type===\"linePrefix\"?A[2].sliceSerialize(A[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(Li,v,E)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){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(_),p)}function c(_){return _===null||R(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),h)}function v(_){return e.attempt(i,E,k)(_)}function k(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return a>0&&L(_)?H(e,w,\"linePrefix\",a+1)(_):w(_)}function w(_){return _===null||R(_)?e.check(Li,v,E)(_):(e.enter(\"codeFlowValue\"),x(_))}function x(_){return _===null||R(_)?(e.exit(\"codeFlowValue\"),w(_)):(e.consume(_),x)}function E(_){return e.exit(\"codeFenced\"),t(_)}function I(_,A,$){let M=0;return b;function b(O){return _.enter(\"lineEnding\"),_.consume(O),_.exit(\"lineEnding\"),D}function D(O){return _.enter(\"codeFencedFence\"),L(O)?H(_,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(O):N(O)}function N(O){return O===s?(_.enter(\"codeFencedFenceSequence\"),V(O)):$(O)}function V(O){return O===s?(M++,_.consume(O),V):M>=o?(_.exit(\"codeFencedFenceSequence\"),L(O)?H(_,U,\"whitespace\")(O):U(O)):$(O)}function U(O){return O===null||R(O)?(_.exit(\"codeFencedFence\"),A(O)):$(O)}}}function Du(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 Un={name:\"codeIndented\",tokenize:Nu},Tu={partial:!0,tokenize:Mu};function Nu(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(Tu,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 Mu(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 zu={name:\"codeText\",previous:Fu,resolve:Ru,tokenize:Ou};function Ru(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Fu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Ou(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 Lu{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&&Et(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),Et(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Et(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);Et(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Et(this.left,n.reverse())}}}function Et(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 uo(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new Lu(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,Bu(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 Bu(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,p=-1,c=n,h=0,v=0;const k=[v];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;++p<s.length;)s[p][0]===\"exit\"&&s[p-1][0]===\"enter\"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(v=p+1,k.push(v),c._tokenizer=void 0,c.previous=void 0,c=c.next);for(o.events=[],c?(c._tokenizer=void 0,c.previous=void 0):k.pop(),p=k.length;p--;){const y=s.slice(k[p],k[p+1]),w=a.pop();u.push([w,w+y.length-1]),e.splice(w,2,y)}for(u.reverse(),p=-1;++p<u.length;)l[h+u[p][0]]=h+u[p][1],h+=u[p][1]-u[p][0]-1;return l}const Vu={resolve:qu,tokenize:Uu},Hu={partial:!0,tokenize:ju};function qu(e){return uo(e),e}function Uu(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(Hu,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function ju(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 co(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),p):y===null||y===32||y===41||mr(y)?n(y):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),v(y))}function p(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),p(y)):y===null||y===60||R(y)?n(y):(e.consume(y),y===92?h:c)}function h(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function v(y){return!d&&(y===null||y===41||le(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(y)):d<l&&y===40?(e.consume(y),d++,v):y===41?(e.consume(y),d--,v):y===null||y===32||y===40||mr(y)?n(y):(e.consume(y),y===92?k:v)}function k(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function fo(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?p:f)}function p(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function ho(e,t,n,r,i,a){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,u):n(p)}function u(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),l(p))}function l(p){return p===o?(e.exit(a),u(o)):p===null?n(p):R(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(p))}function d(p){return p===o||p===null||R(p)?(e.exit(\"chunkString\"),l(p)):(e.consume(p),p===92?f:d)}function f(p){return p===o||p===92?(e.consume(p),d):d(p)}}function Lt(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 Wu={name:\"definition\",tokenize:Qu},Ku={partial:!0,tokenize:Gu};function Qu(e,t,n){const r=this;let i;return a;function a(c){return e.enter(\"definition\"),o(c)}function o(c){return fo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(c)}function s(c){return i=Kt(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 le(c)?Lt(e,l)(c):l(c)}function l(c){return co(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt(Ku,f,f)(c)}function f(c){return L(c)?H(e,p,\"whitespace\")(c):p(c)}function p(c){return c===null||R(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function Gu(e,t,n){return r;function r(s){return le(s)?Lt(e,i)(s):n(s)}function i(s){return ho(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 Yu={name:\"hardBreakEscape\",tokenize:Ju};function Ju(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 Xu={name:\"headingAtx\",resolve:Zu,tokenize:ec};function Zu(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 ec(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||le(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||le(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const tc=[\"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\"],Vi=[\"pre\",\"script\",\"style\",\"textarea\"],nc={concrete:!0,name:\"htmlFlow\",resolveTo:ac,tokenize:oc},rc={partial:!0,tokenize:lc},ic={partial:!0,tokenize:sc};function ac(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 oc(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),p):g===47?(e.consume(g),a=!0,v):g===63?(e.consume(g),i=3,r.interrupt?t:m):$e(g)?(e.consume(g),o=String.fromCharCode(g),k):n(g)}function p(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,h):$e(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 h(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:N:h):n(g)}function v(g){return $e(g)?(e.consume(g),o=String.fromCharCode(g),k):n(g)}function k(g){if(g===null||g===47||g===62||le(g)){const q=g===47,ue=o.toLowerCase();return!q&&!a&&Vi.includes(ue)?(i=1,r.interrupt?t(g):N(g)):tc.includes(o.toLowerCase())?(i=6,q?(e.consume(g),y):r.interrupt?t(g):N(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?w(g):x(g))}return g===45||ye(g)?(e.consume(g),o+=String.fromCharCode(g),k):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:N):n(g)}function w(g){return L(g)?(e.consume(g),w):b(g)}function x(g){return g===47?(e.consume(g),b):g===58||g===95||$e(g)?(e.consume(g),E):L(g)?(e.consume(g),x):b(g)}function E(g){return g===45||g===46||g===58||g===95||ye(g)?(e.consume(g),E):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,A):L(g)?(e.consume(g),_):$(g)}function A(g){return g===u?(e.consume(g),u=null,M):g===null||R(g)?n(g):(e.consume(g),A)}function $(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||le(g)?I(g):(e.consume(g),$)}function M(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)?N(g):L(g)?(e.consume(g),D):n(g)}function N(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),T):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(rc,j,V)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(ic,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),O}function O(g){return g===null||R(g)?V(g):(e.enter(\"htmlFlowData\"),N(g))}function Z(g){return g===45?(e.consume(g),m):N(g)}function X(g){return g===47?(e.consume(g),o=\"\",ge):N(g)}function ge(g){if(g===62){const q=o.toLowerCase();return Vi.includes(q)?(e.consume(g),T):N(g)}return $e(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),ge):N(g)}function ke(g){return g===93?(e.consume(g),m):N(g)}function m(g){return g===62?(e.consume(g),T):g===45&&i===2?(e.consume(g),m):N(g)}function T(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),T)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function sc(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 lc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Rn,t,n)}}const uc={name:\"htmlText\",tokenize:cc};function cc(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):$e(m)?(e.consume(m),$):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,h):$e(m)?(e.consume(m),w):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),p):R(m)?(o=f,X(m)):(e.consume(m),f)}function p(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?p(m):f(m)}function h(m){const T=\"CDATA[\";return m===T.charCodeAt(a++)?(e.consume(m),a===T.length?v:h):n(m)}function v(m){return m===null?n(m):m===93?(e.consume(m),k):R(m)?(o=v,X(m)):(e.consume(m),v)}function k(m){return m===93?(e.consume(m),y):v(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):v(m)}function w(m){return m===null||m===62?Z(m):R(m)?(o=w,X(m)):(e.consume(m),w)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):R(m)?(o=x,X(m)):(e.consume(m),x)}function E(m){return m===62?Z(m):x(m)}function I(m){return $e(m)?(e.consume(m),_):n(m)}function _(m){return m===45||ye(m)?(e.consume(m),_):A(m)}function A(m){return R(m)?(o=A,X(m)):L(m)?(e.consume(m),A):Z(m)}function $(m){return m===45||ye(m)?(e.consume(m),$):m===47||m===62||le(m)?M(m):n(m)}function M(m){return m===47?(e.consume(m),Z):m===58||m===95||$e(m)?(e.consume(m),b):R(m)?(o=M,X(m)):L(m)?(e.consume(m),M):Z(m)}function b(m){return m===45||m===46||m===58||m===95||ye(m)?(e.consume(m),b):D(m)}function D(m){return m===61?(e.consume(m),N):R(m)?(o=D,X(m)):L(m)?(e.consume(m),D):M(m)}function N(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):R(m)?(o=N,X(m)):L(m)?(e.consume(m),N):(e.consume(m),U)}function V(m){return m===i?(e.consume(m),i=void 0,O):m===null?n(m):R(m)?(o=V,X(m)):(e.consume(m),V)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||le(m)?M(m):(e.consume(m),U)}function O(m){return m===47||m===62||le(m)?M(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function X(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),ge}function ge(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 Hr={name:\"labelEnd\",resolveAll:pc,resolveTo:gc,tokenize:mc},fc={tokenize:yc},dc={tokenize:_c},hc={tokenize:bc};function pc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function gc(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=ae(s,e.slice(a+1,a+r+3)),s=ae(s,[[\"enter\",d,t]]),s=ae(s,zn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ae(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ae(s,e.slice(o+1)),s=ae(s,[[\"exit\",u,t]]),_e(e,a,e.length,s),e}function mc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(p){return a?a._inactive?f(p):(o=r.parser.defined.includes(Kt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(p)}function u(p){return p===40?e.attempt(fc,d,o?d:f)(p):p===91?e.attempt(dc,d,o?l:f)(p):o?d(p):f(p)}function l(p){return e.attempt(hc,d,f)(p)}function d(p){return t(p)}function f(p){return a._balanced=!0,n(p)}}function yc(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 le(f)?Lt(e,a)(f):a(f)}function a(f){return f===41?d(f):co(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function o(f){return le(f)?Lt(e,u)(f):d(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?ho(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):d(f)}function l(f){return le(f)?Lt(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 _c(e,t,n){const r=this;return i;function i(s){return fo.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Kt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function bc(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 vc={name:\"labelStartImage\",resolveAll:Hr.resolveAll,tokenize:wc};function wc(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 Sc={name:\"labelStartLink\",resolveAll:Hr.resolveAll,tokenize:kc};function kc(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 jn={name:\"lineEnding\",tokenize:xc};function xc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const mn={name:\"thematicBreak\",tokenize:Cc};function Cc(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 de={continuation:{tokenize:Ac},exit:Dc,name:\"list\",tokenize:Ec},Ic={partial:!0,tokenize:Tc},Pc={partial:!0,tokenize:$c};function Ec(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 h=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(h===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:yr(c)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"listUnordered\")return e.enter(\"listItemPrefix\"),c===42||c===45?e.check(mn,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 yr(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(Rn,r.interrupt?n:d,e.attempt(Ic,p,f))}function d(c){return r.containerState.initialBlankLine=!0,a++,p(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),p):n(c)}function p(c){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function Ac(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Rn,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(Pc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(de,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function $c(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 Dc(e){e.exit(this.containerState.type)}function Tc(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 Hi={name:\"setextUnderline\",resolveTo:Nc,tokenize:Mc};function Nc(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 Mc(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 zc={tokenize:Rc};function Rc(e){const t=this,n=e.attempt(Rn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Vu,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 Fc={resolveAll:go()},Oc=po(\"string\"),Lc=po(\"text\");function po(e){return{resolveAll:go(e===\"text\"?Bc: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 p=-1;if(f)for(;++p<f.length;){const c=f[p];if(!c.previous||c.previous.call(r,r.previous))return!0}return!1}}}function go(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 Bc(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 Vc={42:de,43:de,45:de,48:de,49:de,50:de,51:de,52:de,53:de,54:de,55:de,56:de,57:de,62:oo},Hc={91:Wu},qc={[-2]:Un,[-1]:Un,32:Un},Uc={35:Xu,42:mn,45:[Hi,mn],60:nc,61:Hi,95:mn,96:Bi,126:Bi},jc={38:lo,92:so},Wc={[-5]:jn,[-4]:jn,[-3]:jn,33:vc,38:lo,42:_r,60:[Su,uc],91:Sc,92:[Yu,so],93:Hr,95:_r,96:zu},Kc={null:[_r,Fc]},Qc={null:[42,95]},Gc={null:[]},Yc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Qc,contentInitial:Hc,disable:Gc,document:Vc,flow:Uc,flowInitial:qc,insideSpan:Kc,string:jc,text:Wc},Symbol.toStringTag,{value:\"Module\"}));function Jc(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:A(I),check:A(_),consume:w,enter:x,exit:E,interrupt:A(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:v,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:c,write:f};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function f(D){return o=ae(o,D),k(),o[o.length-1]!==null?[]:($(t,0),l.events=zn(a,l.events,l),l.events)}function p(D,N){return Zc(c(D),N)}function c(D){return Xc(o,D)}function h(){const{_bufferIndex:D,_index:N,line:V,column:U,offset:O}=r;return{_bufferIndex:D,_index:N,line:V,column:U,offset:O}}function v(D){i[D.line]=D.column,b()}function k(){let D;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<N.length;)y(N.charCodeAt(r._bufferIndex));else y(N)}}function y(D){d=d(D)}function w(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,N){const V=N||{};return V.type=D,V.start=h(),l.events.push([\"enter\",V,l]),s.push(V),V}function E(D){const N=s.pop();return N.end=h(),l.events.push([\"exit\",N,l]),N}function I(D,N){$(D,N.from)}function _(D,N){N.restore()}function A(D,N){return V;function V(U,O,Z){let X,ge,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):T(U);function T(te){return It;function It(qe){const dt=qe!==null&&te[qe],ht=qe!==null&&te.null,Ln=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(ht)?ht:ht?[ht]:[]];return j(Ln)(qe)}}function j(te){return X=te,ge=0,te.length===0?Z:g(te[ge])}function g(te){return It;function It(qe){return m=M(),ke=te,te.partial||(l.currentConstruct=te),te.name&&l.parser.constructs.disable.null.includes(te.name)?ue():te.tokenize.call(N?Object.assign(Object.create(l),N):l,u,q,ue)(qe)}}function q(te){return D(ke,m),O}function ue(te){return m.restore(),++ge<X.length?g(X[ge]):Z}}}function $(D,N){D.resolveAll&&!a.includes(D)&&a.push(D),D.resolve&&_e(l.events,N,l.events.length-N,D.resolve(l.events.slice(N),l)),D.resolveTo&&(l.events=D.resolveTo(l.events,l))}function M(){const D=h(),N=l.previous,V=l.currentConstruct,U=l.events.length,O=Array.from(s);return{from:U,restore:Z};function Z(){r=D,l.previous=N,l.currentConstruct=V,l.events.length=U,s=O,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Xc(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 Zc(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 ef(e){const r={constructs:eu([Yc,...(e||{}).extensions||[]]),content:i(gu),defined:[],document:i(yu),flow:i(zc),lazy:{},string:i(Oc),text:i(Lc)};return r;function i(a){return o;function o(s){return Jc(r,a,s)}}}function tf(e){for(;!uo(e););return e}const qi=/[\\0\\t\\n\\r]/g;function nf(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,f,p,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(qi.lastIndex=f,l=qi.exec(a),p=l&&l.index!==void 0?l.index:a.length,c=a.charCodeAt(p),!l){t=a.slice(f);break}if(c===10&&f===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<p&&(u.push(a.slice(f,p)),e+=p-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=p+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function rf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),pu(n)(tf(ef(n).document().write(nf()(e,t,!0))))}const Wn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function af(){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=Wn[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=Wn[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,of)),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\"+Wn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function of(e,t){return t===\"|\"?t:e}class sf{constructor(){this.map=[]}add(t,n,r){lf(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 lf(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 uf(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 cf(){return{flow:{null:{name:\"table\",tokenize:ff,resolveAll:df}}}}function ff(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 N=D>-1?r.events[D][1].type:null,V=N===\"tableHead\"||N===\"tableRow\"?_:u;return V===_&&r.parser.lazy[r.now().line]?n(b):V(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||le(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?p:f)}function p(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,h,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):h(b))}function h(b){return b===45||b===58?k(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),v):I(b)}function v(b){return L(b)?H(e,k,\"whitespace\")(b):k(b)}function k(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)?E(b):I(b)}function y(b){return b===45?(e.enter(\"tableDelimiterFiller\"),w(b)):I(b)}function w(b){return b===45?(e.consume(b),w):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,E,\"whitespace\")(b):E(b)}function E(b){return b===124?h(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\"),A(b)}function A(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),A):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,A,\"whitespace\")(b):(e.enter(\"data\"),$(b))}function $(b){return b===null||b===124||le(b)?(e.exit(\"data\"),A(b)):(e.consume(b),b===92?M:$)}function M(b){return b===92||b===124?(e.consume(b),$):$(b)}}function df(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 p=new sf;for(;++n<e.length;){const c=e[n],h=c[1];c[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,u!==0&&(Ui(p,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",l,t]])):h.type===\"tableRow\"||h.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({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",d,t]])),i=h.type===\"tableDelimiterRow\"?2:d?3:1):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=fn(p,t,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):h.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=fn(p,t,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):h.type===\"tableHead\"?(s=!0,u=n):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],f=fn(p,t,a,i,n,f)):o[1]!==0&&(f=fn(p,t,o,i,n,f)),i=0):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ui(p,t,u,l,d),p.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=uf(t.events,n))}return e}function fn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},gt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=gt(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=gt(t.events,n[2]),d=gt(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 p=t.events[n[2]],c=t.events[n[3]];if(p[1].end=Object.assign({},c[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const h=n[2]+1,v=n[3]-n[2]-1;e.add(h,v,[])}}e.add(n[3]+1,0,[[\"exit\",f,t]])}return i!==void 0&&(a.end=Object.assign({},gt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ui(e,t,n,r,i){const a=[],o=gt(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 gt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function hf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function pf(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let 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)},p=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(p,p.length,0,zn(c,o.slice(l+1,u),s)),_e(p,p.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,p),u=l+p.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 p;function p(h){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(h):(o.enter(\"strikethroughSequenceTemporary\"),c(h))}function c(h){const v=An(l);if(h===126)return f>1?u(h):(o.consume(h),f++,c);if(f<2&&!n)return u(h);const k=o.exit(\"strikethroughSequenceTemporary\"),y=An(h);return k._open=!y||y===2&&!!v,k._close=!v||v===2&&!!y,s(h)}}}function gf(e){return rf(e,{allowDangerousHtml:!0,extensions:[cf(),pf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[af(),hf()]})}const mf={update:()=>{},getValues:()=>({})},Ie=lt({}),rn=lt(mf),fe=lt(!1),br=lt(null);function yf(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)=>mo(a,o,t));return S(Y,{children:i})}function mo(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)=>mo(u,l,n));return Q(i,o,...s)}return null}function _f({node:e}){const t=Lr(),n=G(fe),r=G(Ie),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return Q(e.tag,i,e.children.length>0?Pe(e.children,{nobr:n,locals:r}):void 0)}function bf(){const e=G(br),t=G(fe),n=G(Ie);return!e||e.length===0?null:S(Y,{children:Pe(e,{nobr:t,locals:n})})}function vf(e,t){if(Jl(e.name))return null;const n=Kl(e.name);if(n)return S(Wl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=Gl(e.name);return r?S(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):S(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function vr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?S(bf,{},t):S(Dl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return vf(e,t);case\"html\":return S(_f,{node:e},t);default:return e}}function yo(e){return e.length===0?null:e.map((t,n)=>vr(t,n))}function wf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Sf(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 Pe(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>vr(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\"&&wf(i))i+=Sf(u,a);else{const l=r.length;r.push(vr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=gf(i);return yf(o,r,t?.nobr)}function kf(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 xf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}function Cf(){const e=new Map,t=new Map,n=new Map;return{type:\"memory\",async putSave(r){e.set(r.meta.id,r)},async getSave(r){return e.get(r)},async deleteSave(r){e.delete(r)},async getSavesByIfid(r){return[...e.values()].filter(i=>i.meta.ifid===r)},async deleteSavesByIfid(r){for(const i of[...e.keys()]){const a=e.get(i);a&&a.meta.ifid===r&&e.delete(i)}},async deleteSavesByPlaythrough(r){const i=[];for(const a of[...e.keys()]){const o=e.get(a);o&&o.meta.playthroughId===r&&(e.delete(a),i.push(a))}return i},async putPlaythrough(r){t.set(r.id,r)},async getPlaythroughsByIfid(r){return[...t.values()].filter(i=>i.ifid===r)},async deletePlaythroughsByIfid(r){for(const i of[...t.keys()]){const a=t.get(i);a&&a.ifid===r&&t.delete(i)}},async deletePlaythroughById(r){t.delete(r)},async getMeta(r){return n.get(r)},async setMeta(r,i){n.set(r,i)},async deleteMeta(r){n.delete(r)},async deleteMetaByPrefix(r){for(const i of[...n.keys()])i.startsWith(r)&&n.delete(i)},async deleteMetaByIfid(r){for(const i of[...n.keys()])i.includes(r)&&n.delete(i)},async getAllMetaKeys(){return[...n.keys()]},async destroy(){e.clear(),t.clear(),n.clear()}}}const ze=\"spindle.save.\",At=\"spindle.pt.\",Ge=\"spindle.meta.\",pt=\"spindle.idx.saves.\",$t=\"spindle.idx.pt.\",Dt=\"spindle.idx.saves-pt.\";function Fe(e){const t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function Bt(e,t){localStorage.setItem(e,JSON.stringify(t))}function Re(e){localStorage.removeItem(e)}function Xe(e){return Fe(e)??[]}function Kn(e,t){const n=Xe(e);n.includes(t)||(n.push(t),Bt(e,n))}function Tt(e,t){const n=Xe(e).filter(r=>r!==t);Bt(e,n)}function If(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;Bt(`${ze}${t}`,e),Kn(`${pt}${e.meta.ifid}`,t),Kn(`${Dt}${e.meta.playthroughId}`,t)},async getSave(e){return Fe(`${ze}${e}`)},async deleteSave(e){const t=Fe(`${ze}${e}`);t&&(Tt(`${pt}${t.meta.ifid}`,e),Tt(`${Dt}${t.meta.playthroughId}`,e)),Re(`${ze}${e}`)},async getSavesByIfid(e){const t=Xe(`${pt}${e}`),n=[];for(const r of t){const i=Fe(`${ze}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=Xe(`${pt}${e}`);for(const n of t){const r=Fe(`${ze}${n}`);r&&Tt(`${Dt}${r.meta.playthroughId}`,n),Re(`${ze}${n}`)}Re(`${pt}${e}`)},async deleteSavesByPlaythrough(e){const t=Xe(`${Dt}${e}`);for(const n of t){const r=Fe(`${ze}${n}`);r&&Tt(`${pt}${r.meta.ifid}`,n),Re(`${ze}${n}`)}return Re(`${Dt}${e}`),t},async putPlaythrough(e){Bt(`${At}${e.id}`,e),Kn(`${$t}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){const t=Xe(`${$t}${e}`),n=[];for(const r of t){const i=Fe(`${At}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=Xe(`${$t}${e}`);for(const n of t)Re(`${At}${n}`);Re(`${$t}${e}`)},async deletePlaythroughById(e){const t=Fe(`${At}${e}`);t&&Tt(`${$t}${t.ifid}`,e),Re(`${At}${e}`)},async getMeta(e){return Fe(`${Ge}${e}`)},async setMeta(e,t){Bt(`${Ge}${e}`,t)},async deleteMeta(e){Re(`${Ge}${e}`)},async deleteMetaByPrefix(e){const t=`${Ge}${e}`;for(const n of Object.keys(localStorage))n.startsWith(t)&&localStorage.removeItem(n)},async deleteMetaByIfid(e){for(const t of Object.keys(localStorage))t.startsWith(Ge)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){const e=[];for(const t of Object.keys(localStorage))t.startsWith(Ge)&&e.push(t.slice(Ge.length));return e},async destroy(){for(const e of Object.keys(localStorage))e.startsWith(\"spindle.\")&&localStorage.removeItem(e)}}}const ji=\"spindle\",Pf=1;function Ef(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(ji,Pf);s.onupgradeneeded=()=>{const u=s.result;if(!u.objectStoreNames.contains(\"saves\")){const l=u.createObjectStore(\"saves\",{keyPath:\"meta.id\"});l.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),l.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}u.objectStoreNames.contains(\"playthroughs\")||u.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),u.objectStoreNames.contains(\"meta\")||u.createObjectStore(\"meta\",{keyPath:\"key\"})},s.onsuccess=()=>a(s.result),s.onerror=()=>o(s.error)}),e)}function n(a,o){return t().then(s=>s.transaction(a,o).objectStore(a))}function r(a){return new Promise((o,s)=>{a.onsuccess=()=>o(a.result),a.onerror=()=>s(a.error)})}async function i(a,o,s){const l=(await n(a,\"readonly\")).index(o);return await r(l.getAll(s))??[]}return{type:\"indexeddb\",async putSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.put(a))},async getSave(a){const o=await n(\"saves\",\"readonly\");return await r(o.get(a))??void 0},async deleteSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.delete(a))},async getSavesByIfid(a){return i(\"saves\",\"ifid\",a)},async deleteSavesByIfid(a){const o=await i(\"saves\",\"ifid\",a),s=await n(\"saves\",\"readwrite\");for(const u of o)await r(s.delete(u.meta.id))},async deleteSavesByPlaythrough(a){const o=await i(\"saves\",\"playthroughId\",a),s=await n(\"saves\",\"readwrite\"),u=[];for(const l of o)await r(s.delete(l.meta.id)),u.push(l.meta.id);return u},async putPlaythrough(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.put(a))},async getPlaythroughsByIfid(a){return i(\"playthroughs\",\"ifid\",a)},async deletePlaythroughsByIfid(a){const o=await i(\"playthroughs\",\"ifid\",a),s=await n(\"playthroughs\",\"readwrite\");for(const u of o)await r(s.delete(u.id))},async deletePlaythroughById(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.delete(a))},async getMeta(a){const o=await n(\"meta\",\"readonly\"),s=await r(o.get(a));return s?s.value:void 0},async setMeta(a,o){const s=await n(\"meta\",\"readwrite\");await r(s.put({key:a,value:o}))},async deleteMeta(a){const o=await n(\"meta\",\"readwrite\");await r(o.delete(a))},async deleteMetaByPrefix(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const u of s)if(u.key.startsWith(a)){const l=await n(\"meta\",\"readwrite\");await r(l.delete(u.key))}},async deleteMetaByIfid(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const u of s)if(u.key.includes(a)){const l=await n(\"meta\",\"readwrite\");await r(l.delete(u.key))}},async getAllMetaKeys(){const a=await n(\"meta\",\"readonly\");return(await r(a.getAll())).map(s=>s.key)},async destroy(){(await t()).close(),e=null,await new Promise((o,s)=>{const u=indexedDB.deleteDatabase(ji);u.onsuccess=()=>o(),u.onerror=()=>s(u.error)})}}}let yt=null;async function Af(){if(typeof indexedDB<\"u\")try{return await new Promise((e,t)=>{const n=indexedDB.open(\"__spindle_probe__\",1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(\"__spindle_probe__\"),e()},n.onerror=()=>t(n.error)}),Ef()}catch{}if(typeof localStorage<\"u\")try{const e=\"__spindle_probe__\";localStorage.setItem(e,\"1\");const t=localStorage.getItem(e);if(localStorage.removeItem(e),t===\"1\")return If()}catch{}return Cf()}async function J(){return yt||(yt=await Af(),yt)}function $f(){yt=null}function Wi(){return yt?.type??\"memory\"}const _o=new Map,Fn=new Map;function Df(e,t){_o.set(e,t),Fn.set(t,e)}function Tf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ie(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let 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(Fn.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(Tf(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 Ze=\"__spindle_class__\",et=\"__spindle_data__\";function nt(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),{[Ze]:\"__Date__\",[et]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Ze]:\"__RegExp__\",[et]:{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),{[Ze]:\"__Map__\",[et]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[Ze]:\"__Set__\",[et]:{entries:u}}}const a=i.constructor,o=Fn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Ze]:o,[et]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function rt(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(Ze in r&&et in r){const o=r[Ze],s=r[et];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,p])=>[t(f),t(p)]))}if(o===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=_o.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(Fn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let wr=null,Sr=null,Ki=!1;function Nf(e){wr=e}function Mf(e){Sr=e}function zf(e){if(Sr)try{const i=new Function(\"passage\",\"variables\",Sr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(wr)try{const r=wr(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 Rf(){Ki||(Ki=!0)}async function Qi(e){const t=await J(),r=(await t.getPlaythroughsByIfid(e)).length+1,i=crypto.randomUUID(),a={id:i,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await t.putPlaythrough(a),await t.setMeta(`currentPlaythroughId.${e}`,i),i}async function Ff(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function bo(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:zf(n),passage:n.passage,custom:r},o=ie(n);o.variables=nt(o.variables),o.history=o.history.map(u=>({...u,variables:nt(u.variables)}));const s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function vo(e,t,n){const r=await J(),i=await r.getSave(e);if(!i)return;const a=ie(t);a.variables=nt(a.variables),a.history=a.history.map(s=>({...s,variables:nt(s.variables)}));const o={meta:{...i.meta,updatedAt:new Date().toISOString(),passage:t.passage,...n!=null?{custom:{...i.meta.custom,...n}}:{}},payload:a};return o.meta.estimatedBytes=JSON.stringify(a).length,await r.putSave(o),o}async function Of(e){const t=await(await J()).getSave(e);if(!t)return;const n=t.payload;return n.variables=rt(n.variables),n.history=n.history.map(r=>({...r,variables:rt(r.variables)})),n}async function Lf(e){await(await J()).deleteSave(e)}async function Bf(e,t){const n=await J(),r=await n.getSave(e);if(!r)return;const i={...r,meta:{...r.meta,title:t,updatedAt:new Date().toISOString()}};await n.putSave(i)}async function Vf(e){const t=await J(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(const u of r)i.set(u.id,u);const a=new Map;for(const u of n){const l=u.meta.playthroughId,d=a.get(l);d?d.push(u):a.set(l,[u])}for(const u of a.values())u.sort((l,d)=>new Date(d.meta.updatedAt).getTime()-new Date(l.meta.updatedAt).getTime());const o=[],s=[...i.values()].sort((u,l)=>new Date(l.createdAt).getTime()-new Date(u.createdAt).getTime());for(const u of s){const l=a.get(u.id)??[];o.push({playthrough:u,saves:l})}for(const[u,l]of a)i.has(u)||o.push({playthrough:{id:u,ifid:e,createdAt:l[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:l});return o}const Hf=\"autosave.\",qf=\"slot.\",On=\"slotIndex.\";function an(e,t){return t!=null?`${qf}${t}.${e}`:`${Hf}${e}`}async function Uf(e,t,n,r,i){const a=await J(),o=an(e,r),s=await a.getMeta(o);if(s){const l=await vo(s,n,i);if(l)return l}const u=await bo(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,u.meta.id),r!=null){const l=`${On}${e}`,d=await a.getMeta(l)??[];d.includes(r)||await a.setMeta(l,[...d,r])}return u}async function Gi(e,t){const n=await J(),r=an(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function jf(e,t){const n=an(e,t),r=await(await J()).getMeta(n);if(r)return Of(r)}async function kr(e){const t={};await Gi(e)&&(t[\"\"]=!0);const n=`${On}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await Gi(e,i)&&(t[i]=!0);return t}async function xr(e,t){const n=await J(),r=an(e,t),i=await n.getMeta(r);if(!i)return null;const a=await n.getSave(i);return a?{slot:t??\"\",title:a.meta.title,passage:a.meta.passage,createdAt:a.meta.createdAt,updatedAt:a.meta.updatedAt,custom:a.meta.custom??{}}:null}async function Wf(e){const t=[],n=await xr(e);n&&t.push(n);const r=`${On}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await xr(e,a);o&&t.push(o)}return t}async function Kf(e,t){const n=await J(),r=an(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${On}${e}`,s=(await n.getMeta(a)??[]).filter(u=>u!==t);await n.setMeta(a,s)}}const qr=\"spindle.session.\";function Qf(e,t){try{sessionStorage.setItem(`${qr}${e}`,JSON.stringify(t))}catch{}}function Gf(e){try{const t=sessionStorage.getItem(`${qr}${e}`);if(!t)return;const n=JSON.parse(t);if(!xf(n))return;const r=n;return r.variables=rt(r.variables),r.history=r.history.map(i=>({...i,variables:rt(i.variables)})),r}catch{return}}function wo(e){try{sessionStorage.removeItem(`${qr}${e}`)}catch{}}async function Yf(e){const t=await(await J()).getSave(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Jf(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=await J(),r=ie(e.save);if(r.meta.id=crypto.randomUUID(),r.meta.updatedAt=new Date().toISOString(),!(await n.getPlaythroughsByIfid(t)).some(o=>o.id===r.meta.playthroughId)){const o={id:r.meta.playthroughId,ifid:t,createdAt:r.meta.createdAt,label:\"Imported\"};await n.putPlaythrough(o)}return await n.putSave(r),r}async function Xf(e){const t=await J(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e);let i=0;for(const a of n)if(a.meta.estimatedBytes!=null)i+=a.meta.estimatedBytes;else{const o=JSON.stringify(a.payload).length;a.meta.estimatedBytes=o,await t.putSave(a),i+=o}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}}async function So(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),wo(e)}async function ko(){if(await(await J()).destroy(),$f(),typeof sessionStorage<\"u\"){const t=[];for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);r?.startsWith(\"spindle.session.\")&&t.push(r)}for(const n of t)sessionStorage.removeItem(n)}}async function xo(e,t){const n=await J(),r=await n.deleteSavesByPlaythrough(t);await n.deletePlaythroughById(t);const i=new Set(r),a=await n.getAllMetaKeys();for(const u of a)if(u.startsWith(\"slot.\")||u.startsWith(\"autosave.\")){const l=await n.getMeta(u);l&&i.has(l)&&await n.deleteMeta(u)}const o=`currentPlaythroughId.${e}`;await n.getMeta(o)===t&&await n.deleteMeta(o)}function Co(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=kt(t.content),i=xt(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),Ce(Q(()=>Pe(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&Mf(n.content)}let Io=0,we=[],Qn=!1,ct=[],Vt=null,Ve=null;function Ur(e){const t=C.getState();try{return!!Mn(e,t.variables,t.temporary)}catch{return!1}}function Po(e,t){const n=Io++,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:Ur(e),priority:i?.priority??0};return we.push(o),we.sort((s,u)=>u.priority-s.priority),()=>{we=we.filter(s=>s.id!==n)}}function Eo(e){we=we.filter(t=>t.name!==e)}function Zf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Xa(n.run,r.variables,r.temporary)}n.dialog&&(ct.push({passageName:n.dialog}),Vt?.()),n.goto&&C.getState().navigate(n.goto)}}const ed=10;function td(){if(!Qn){Qn=!0;try{for(let e=0;e<ed;e++){let t=!1;const n=[...we];for(const r of n){if(!we.includes(r))continue;const i=Ur(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(we=we.filter(o=>o.id!==r.id)),Zf(r))}if(!t)break}}finally{Qn=!1}}}function nd(){for(const e of we)e.lastResult=Ur(e.condition)}function rd(){we=[],ct=[],Io=0,Ve?.closeAll()}function id(e){return Vt=e,ct.length>0&&e(),()=>{Vt===e&&(Vt=null)}}function ad(){return ct.shift()}function od(){return ct.length}function sd(e){Ve?Ve.push(e):(ct.push(e),Vt?.())}function ld(){ct=[]}function ud(e){return Ve=e,()=>{Ve===e&&(Ve=null)}}function cd(){Ve?.close()}function fd(){ld(),Ve?.closeAll()}function dd(){return Ve?.isOpen()??!1}ml();const hd=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let tt={},be=[],Ue={};function Yi(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function Ji(e,t){const[,n,r]=_l(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:Yi(n),inverse:Yi(r)}}function pd(e){let t=tt;for(let n=0;n<e;n++)t=mt(t,be[n].forward);return t}let ve=[];function Gn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(ve.length>i.length&&(ve.length=i.length),ve.length<i.length)if(i.length-ve.length===1){const l=i.length-1;ve[l]={passage:i[l].passage,variables:nt(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=tt;for(let d=0;d<i.length;d++)if(d>0&&(l=mt(l,be[d-1].forward)),d>=ve.length){const f=d===i.length-1?r:l;ve[d]={passage:i[d].passage,variables:nt(f),timestamp:i[d].timestamp,prng:i[d].prng}}}Qf(t.ifid,{passage:n,variables:nt(r),history:ve,historyIndex:a,visitCounts:o,renderCounts:s,prng:En()})}}function Xi(e){tt=e,be=[],Ue=e,ve=[]}function Zi(e){e?.prng?Qa(e.prng.seed,e.prng.pull):e&&pr()}const C=Zs()(vl((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=ie(r);Xi(ie(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Ue=t().variables;const o=n.ifid;Rf().then(async()=>{const s=await Ff(o);if(s)e(l=>{l.playthroughId=s});else{const l=await Qi(o);e(d=>{d.playthroughId=l})}const u=await kr(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(hd.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=Ji(Ue,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),be.length=o.historyIndex,be.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:En()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)tt=mt(tt,be[u].forward);o.history=o.history.slice(s),be=be.slice(s),ve=ve.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Ue=t().variables,Gn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ie(mt(r,be[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Ue=t().variables,Zi(t().history[t().historyIndex]),Gn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ie(mt(i,be[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Ue=t().variables,Zi(t().history[t().historyIndex]),Gn(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;pr(),rd();const a=ie(r);Xi(ie(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}}),Ue=t().variables,Co(),wo(n.ifid),Qi(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}),Uf(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}),jf(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?xr(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?Wf(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&Kf(r.ifid,n).then(()=>{e(i=>{const a=n??\"\",{[a]:o,...s}=i.knownSaves;i.knownSaves=s})}).catch(i=>{console.error(\"spindle: failed to delete save\",i)})},clearGameData:()=>{const{storyData:n}=t();n&&So(n.ifid).then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear game data\",r)})},clearAllData:()=>{const{storyData:n}=t();n&&ko().then(()=>{e(r=>{r.knownSaves={}}),t().restart()}).catch(r=>{console.error(\"spindle: failed to clear all data\",r)})},deletePlaythrough:n=>{const{storyData:r}=t();r&&xo(r.ifid,n).then(async()=>{const i=await kr(r.ifid);e(a=>{a.knownSaves=i})}).catch(i=>{console.error(\"spindle: failed to delete playthrough\",i)})},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=tt;for(let d=0;d<i.length;d++)d>0&&(l=mt(l,be[d-1].forward)),u.push({passage:i[d].passage,variables:ie(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:ie(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:En()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=rt(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=rt(n.history[o].variables);i.push(Ji(a,s)),a=s}tt=ie(r),be=i,ve=[],e(o=>{o.currentPassage=n.passage,o.variables=rt(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={}}),Ue=t().variables,n.prng?Qa(n.prng.seed,n.prng.pull):pr()},getHistoryVariables:n=>ie(pd(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n}}))),gd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function md(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:gd,r=t?.tags.includes(\"nobr\")??!1,i=he(()=>{try{const a=kt(n),o=xt(a);return S(Y,{children:yo(o)})}catch(a){return S(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?S(fe.Provider,{value:!0,children:i}):i}const Ao=lt(null);function jr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=se(r);a.current=r;const o=pe(()=>a.current(),[]),s=C(c=>c.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,d=he(()=>{if(!l)return S(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=kt(l),h=xt(c);return Pe(h)}catch(c){return S(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&o()},p=n?`dialog-panel ${n}`:\"dialog-panel\";return S(Ao.Provider,{value:o,children:S(\"div\",{class:\"dialog-overlay\",onClick:f,children:S(\"div\",{class:p,children:[i&&S(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),S(\"div\",{class:\"dialog-body\",children:d})]})})})}function yd(){const[e,t]=ee([]),n=se(e);n.current=e;const r=pe(o=>{t(s=>[...s,o])},[]),i=pe(()=>{t(o=>o.slice(0,-1))},[]),a=pe(()=>{t([])},[]);return Se(()=>ud({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Se(()=>id(()=>{const o=[];for(;od()>0;){const s=ad();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:S(Y,{children:e.map((o,s)=>S(jr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function _d(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Se(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return S(\"div\",{class:\"loading\",children:\"Loading...\"});const r=S(Y,{children:[S(md,{}),S(yd,{})]});return n?S(fe.Provider,{value:!0,children:r}):r}function bd(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function vd(){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 p of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(p.getAttribute(\"pid\")||\"0\",10),h=p.getAttribute(\"name\")||\"\",v=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),k=bd(p.innerHTML),y={},w=new Set([\"pid\",\"name\",\"tags\"]);for(const E of p.attributes)w.has(E.name)||(y[E.name]=E.value);const x={pid:c,name:h,tags:v,metadata:y,content:k};d.set(h,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 Nt=new Map;let ce={},ea=!1;function $o(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function wd(){localStorage.setItem($o(),JSON.stringify(ce))}function Yn(){if(!ea){ea=!0;try{const e=localStorage.getItem($o());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ce={...ce,...t})}}catch{}}}const Qt={addToggle(e,t){Nt.set(e,{type:\"toggle\",config:t}),e in ce||(ce[e]=t.default),Yn()},addList(e,t){Nt.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),Yn()},addRange(e,t){Nt.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),Yn()},get(e){return ce[e]},getToggle(e){const t=ce[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ce[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ce[e];return typeof t==\"number\"?t:0},set(e,t){ce[e]=t,wd()},getAll(){return{...ce}},getDefinitions(){return Nt},hasAny(){return Nt.size>0}};function Sd(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};Xa(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 $n=new Map,Cr=new Set,Ir=new Map;function kd(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Ir.get(r)??0)+1;return Ir.set(r,i),i===1?r:`${r}:${i}`}function xd(e){return $n.set(e.id,e),na(),()=>{$n.delete(e.id),na()}}function ta(){return Array.from($n.values())}function Cd(e){return $n.get(e)}function Id(){Ir.clear()}function Pd(e){return Cr.add(e),()=>{Cr.delete(e)}}function na(){for(const e of Cr)e()}function Ed(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=kd(e.type,e.key,e.authorId));const r=t.current;return ut(()=>{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),xd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Ad(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Do(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Wr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Do(t):\"\"}function $d(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 Dd(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 Td(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Nd={useState:ee,useRef:se,useEffect:Se,useLayoutEffect:ut,useCallback:pe,useMemo:he,useContext:G};function ra(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 B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=Lr(),a=s(a),o=s(o));const{update:u,getValues:l}=G(rn),d=G(fe),f=G(Ie),c={collectText:Ad,sourceLocation:Wr,parseVarArgs:$d,extractOptions:Dd,h:Q,renderNodes:(h,v)=>Pe(h,{nobr:d,locals:f,...v}),renderInlineNodes:yo,hooks:Nd,useAction:Ed,className:a,id:o,resolve:s,cls:Td(e.name,a),mutate:h=>Sd(h,l(),u),update:u,getValues:l,wrap:h=>a||o?Q(\"span\",{id:o,class:a},h):Q(Y,null,h)};if(e.merged){c.merged=Or();const h=c.merged;c.evaluate=v=>Mn(v,h[0],h[1],h[2])}if(e.storeVar){const v=(i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),k=v.split(\".\");c.varName=v,c.value=C(y=>ra(y.variables,k)),c.getValue=()=>ra(C.getState().variables,k),c.setValue=y=>{C.setState(w=>{Md(w.variables,k,y)})}}return e.render(i,c)}Ql(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(Xl(e.name,{name:e.name,block:r,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters,source:t}),e.subMacros)for(const i of e.subMacros)Yl(i);r&&hr(e.name)}function zd(){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:Qt,registerClass(e,t){Df(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return Zl()},saves:{setTitleGenerator(e){Nf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?Xf(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Wi()}},async getQuota(){if(typeof navigator<\"u\"&&navigator.storage?.estimate)try{const e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},async clearGameData(){const e=C.getState().storyData?.ifid;e&&(await So(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await ko(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await xo(t.ifid,e);const n=await kr(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return Wi()}},getActions(){return ta()},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 Pd(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(ta())})})})},watch(e,t){return Po(e,t)},unwatch(e){Eo(e)},openDialog(e,t){sd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){cd()},closeAllDialogs(){fd()},isDialogOpen(){return dd()},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 Br()},randomInt(e,t){return Ga(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){Tl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=En())})},isEnabled(){return Nl()},get seed(){return Ml()},get pull(){return zl()}}}}function Rd(){window.Story=zd()}const Fd=/^\\$(\\w+)\\s*=\\s*(.+)$/,ia=/\\$(\\w+(?:\\.\\w+)*)/g,aa=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Od=new Set([\"number\",\"string\",\"boolean\"]);function To(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,To(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Od.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Ld(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Fd);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=To(s);t.set(a,{...u,name:a,default:s})}return t}function Bd(e){const t=new Set;let n;for(aa.lastIndex=0;(n=aa.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Vd(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 Hd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Bd(i.content);let o;for(ia.lastIndex=0;(o=ia.exec(i.content))!==null;){const s=o[1],u=Vd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function qd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function yn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&yn(t.children))return!0;if(t.type===\"macro\"){if(yn(t.children))return!0;if(t.branches){for(const n of t.branches)if(yn(n.children))return!0}}}return!1}B({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 We({macro:e,error:t}){return S(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Wr()}: ${t instanceof Error?t.message:String(t)}}`})}B({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return S(We,{macro:\"print\",error:n})}}});function Ud(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 jd(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 oa(e,t,n,r,i,a,o){let s;try{s=Mn(e,r,i,a)}catch(l){console.error(`spindle: Error in {computed ${o}}${Wr()}:`,l);return}const u=n?i[t]:r[t];if(!jd(u,s)){const l=C.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}B({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=Ud(e))}catch(d){return S(We,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,oa(o,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{oa(o,u,s,n,r,i,e)},[n,r,i]),null}});function Wd(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=Kd(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 Kd(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 Qd(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}B({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=Wd(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=Qd(a,o,i),l=t.cls;return S(\"div\",{class:l,id:t.id,children:[S(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&S(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return S(We,{macro:\"meter\",error:n})}}});B({name:\"if\",block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?S(\"span\",{id:o,class:a,children:i}):S(Y,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return S(We,{macro:\"if\",error:i})}}return null}});function Gd(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 Yd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=ee(()=>({...n})),o={...e,...t,...i},s=se(o);s.current=o;const u=pe(()=>s.current,[]),l=pe((p,c)=>{a(h=>({...h,[p]:c}))},[]),d=he(()=>({update:l,getValues:u}),[l,u]),f=G(fe);return S(rn.Provider,{value:d,children:S(Ie.Provider,{value:o,children:Pe(r,{nobr:f,locals:o})})})}B({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=G(Ie);let i;try{i=Gd(e)}catch(d){return S(We,{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 S(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return S(We,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const p={[a]:d,...o?{[o]:f}:void 0};return S(Yd,{parentValues:r,ownKeys:p,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});B({name:\"do\",block:!0,render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});B({name:\"button\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=G(fe),a=()=>{const o=document.createElement(\"div\"),s=Q(fe.Provider,{value:i},Q(rn.Provider,{value:{update:n.update,getValues:n.getValues}},Q(Ie.Provider,{value:n.getValues()},Pe(t))));Ce(s,o),Ce(null,o)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:a}),S(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function Jd(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 sa(e,t,n,r){const i=document.createElement(\"div\"),a=Q(fe.Provider,{value:r},Q(rn.Provider,{value:{update:n,getValues:t}},Q(Ie.Provider,{value:t()},Pe(e))));Ce(a,i),Ce(null,i)}B({name:\"link\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Jd(e),a=G(fe),o=s=>{s.preventDefault(),sa(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:()=>{sa(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),S(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});B({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return S(We,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return S(Y,{children:n.renderNodes(o.children)})}catch(s){return S(We,{macro:\"case\",error:s})}}return i?S(Y,{children:n.renderNodes(i.children)}):null}});function Kr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}B({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(c=>({delay:c.rawArgs?Kr(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,h=a[c].delay,v=setTimeout(()=>{s(c)},h);return()=>clearTimeout(v)},[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),p=d||f?S(\"span\",{id:f,class:d,children:l}):l;return t.wrap(p)}});const No=lt({stop:()=>{}});B({name:\"repeat\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Kr(e),[s,u]=r(0),[l,d]=r(!1),f=a(()=>d(!0),[]);if(i(()=>{if(l)return;const c=setInterval(()=>{u(h=>h+1)},o);return()=>clearInterval(c)},[o,l]),s===0&&!l)return null;const p=S(No.Provider,{value:{stop:f},children:S(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?S(\"span\",{id:n.id,class:n.cls,children:p}):p}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(No);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});B({name:\"type\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Kr(e),s=a(null),[u,l]=r(0),[d,f]=r(0),p=a(0);p.current=d,i(()=>{if(s.current){const v=s.current.textContent||\"\";l(v.length)}},[]),i(()=>{if(u===0||p.current>=u)return;const v=setInterval(()=>{f(k=>k>=u?(clearInterval(v),k):k+1)},o);return()=>clearInterval(v)},[u,o]);const c=d>=u&&u>0,h=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return S(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[S(\"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&&S(\"span\",{class:\"macro-type-cursor\"})]})}});function Xd(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}B({name:\"widget\",block:!0,render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Xd(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{eo(r,t,i)},[r,a,o]),null}});B({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return S(\"span\",{id:t.id,class:r,children:n})}});function ft(e){B({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=ee(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),S(Y,{children:[S(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&S(jr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}ft({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});ft({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});ft({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});ft({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()}}});ft({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});ft({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});ft({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Qt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});B({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return S(Y,{children:[S(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&S(jr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function Zd(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 eh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function th(){const[e,t]=ee(\"load\"),[n,r]=ee([]),[i,a]=ee(!0),[o,s]=ee(null),[u,l]=ee(()=>new Set),[d,f]=ee(null),[p,c]=ee(\"\"),h=se(null),v=se(null),k=G(Ao),y=C(T=>T.storyData),w=C(T=>T.playthroughId),x=C(T=>T.getSavePayload),E=C(T=>T.loadFromPayload),I=y?.ifid??\"\",_=pe(async()=>{if(!I)return;const T=await Vf(I);r(T),a(!1)},[I]);Se(()=>{_()},[_]),Se(()=>{d&&h.current&&(h.current.focus(),h.current.select())},[d]);const A=se(),$=(T,j=\"success\")=>{clearTimeout(A.current),s({text:T,type:j}),A.current=window.setTimeout(()=>s(null),3e3)};Se(()=>()=>clearTimeout(A.current),[]);const M=T=>{l(j=>{const g=new Set(j);return g.has(T)?g.delete(T):g.add(T),g})},b=async()=>{if(!(!I||!w))try{const T=x();await bo(I,w,T),$(\"Save created\"),await _()}catch{$(\"Failed to create save\",\"error\")}},D=async T=>{try{const j=x();await vo(T,j),$(\"Save overwritten\"),await _()}catch{$(\"Failed to overwrite save\",\"error\")}},N=async T=>{try{E(T.payload),$(\"Game loaded\"),k&&setTimeout(k,500)}catch{$(\"Failed to load save\",\"error\")}},V=async T=>{if(confirm(\"Delete this save?\"))try{await Lf(T),$(\"Save deleted\"),await _()}catch{$(\"Failed to delete save\",\"error\")}},U=T=>{f(T.meta.id),c(T.meta.title)},O=async()=>{if(!(!d||!p.trim()))try{await Bf(d,p.trim()),f(null),$(\"Save renamed\"),await _()}catch{$(\"Failed to rename\",\"error\")}},Z=T=>{T.key===\"Enter\"?O():T.key===\"Escape\"&&f(null)},X=async T=>{try{const j=await Yf(T);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),ue=document.createElement(\"a\");ue.href=q,ue.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ue.click(),URL.revokeObjectURL(q),$(\"Save exported\")}catch{$(\"Failed to export save\",\"error\")}},ge=()=>{v.current?.click()},ke=async T=>{const j=T.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),ue=JSON.parse(q);if(!kf(ue))throw new Error(\"Invalid save file format\");await Jf(ue,I),$(\"Save imported\"),await _()}catch(q){$(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((T,j)=>T+j.saves.length,0);return S(\"div\",{class:\"save-manager\",children:[S(\"div\",{class:\"saves-header\",children:S(\"div\",{class:\"saves-header-left\",children:S(\"div\",{class:\"saves-mode-toggle\",children:[S(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),S(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),S(\"div\",{class:\"saves-toolbar\",children:[S(\"button\",{class:\"saves-toolbar-button\",onClick:ge,children:\"Import\"}),S(\"input\",{ref:v,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),S(\"div\",{class:\"saves-body\",children:[i?S(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?S(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(T=>{const j=u.has(T.playthrough.id),g=T.playthrough.id===w;return e===\"save\"&&!g||e===\"load\"&&T.saves.length===0&&!g?null:S(\"div\",{class:\"playthrough-group\",children:[S(\"div\",{class:\"playthrough-header\",onClick:()=>M(T.playthrough.id),children:[S(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),S(\"span\",{class:\"playthrough-label\",children:[T.playthrough.label,g?\" (current)\":\"\"]}),S(\"span\",{class:\"playthrough-date\",children:eh(T.playthrough.createdAt)})]}),!j&&S(\"div\",{class:\"playthrough-saves\",children:[T.saves.map(q=>S(\"div\",{class:\"save-slot\",children:[S(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?S(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>c(ue.target.value),onKeyDown:Z,onBlur:O}):S(\"div\",{class:\"save-slot-title\",children:q.meta.title}),S(\"div\",{class:\"save-slot-meta\",children:[S(\"span\",{children:q.meta.passage}),S(\"span\",{children:Zd(q.meta.updatedAt)})]})]}),S(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?S(\"button\",{class:\"save-slot-action primary\",onClick:()=>D(q.meta.id),children:\"Save Here\"}):S(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q),children:\"Load\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>X(q.meta.id),children:\"Export\"}),S(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&S(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},T.playthrough.id)}),e===\"save\"&&!i&&!n.some(T=>T.playthrough.id===w)&&S(\"div\",{class:\"playthrough-group\",children:S(\"div\",{class:\"playthrough-saves\",children:S(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&S(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return S(th,{})}});function nh({name:e,def:t}){const[n,r]=ee(()=>Qt.get(e)),i=a=>{r(a),Qt.set(e,a)};switch(t.type){case\"toggle\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>S(\"option\",{value:a,children:a},a))})]});case\"range\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:[t.config.label,\": \",String(n)]}),S(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function rh(){const e=Qt.getDefinitions();return S(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>S(nh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return S(rh,{})}});B({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 S(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=kt(o.content),l=xt(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(fe.Provider,{value:!0},d)):t.wrap(d)}});B({name:\"nobr\",block:!0,render({children:e=[]},t){return t.wrap(t.h(fe.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});B({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});B({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _name, or @name), got \"${i}\"`)}return null}});B({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});B({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),S(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});B({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function ih(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=ih(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function ah(e){const t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}B({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=ah(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),S(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>S(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),S(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function zt(e){const t=kt(e.content),n=xt(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const oh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function sh({passage:e,dataTransition:t}){const n=C(v=>v.storyData),r=oh.has(e.name),[i,a]=ee(!1),o=he(()=>{try{return zt(e)}catch(v){return S(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Do(e),\":\",\" \",v instanceof Error?v.message:String(v)]})}},[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=he(()=>{if(!s)return null;try{return zt(s)}catch(v){return console.error(\"spindle: Error in PassageHeader:\",v),null}},[s?.content]),f=he(()=>{if(!u)return null;try{return zt(u)}catch(v){return console.error(\"spindle: Error in PassageFooter:\",v),null}},[u?.content]);Se(()=>(l&&a(!0),()=>a(!1)),[e.name]);const p=he(()=>{if(!i||!l)return null;try{return zt(l)}catch(v){return console.error(\"spindle: Error in PassageDone:\",v),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),h=S(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&S(\"div\",{class:\"passage-header\",children:d}),o,f&&S(\"div\",{class:\"passage-footer\",children:f}),p&&S(\"div\",{hidden:!0,children:p})]});return c?S(fe.Provider,{value:!0,children:h}):h}const lh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Pr={type:\"fade-through\",duration:300,pause:50};function uh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!lh.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 Jn(e){return{type:e.type,duration:e.duration??Pr.duration,pause:e.pause??Pr.pause}}function ch(e,t,n){const r=uh(e);return r?Jn(r):t?Jn(t):n?Jn(n):{...Pr}}function la(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 Xn(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 Zn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(c=>c.currentPassage),r=C(c=>c.storyData),[i,a]=ee(n),o=se(\"fade\"),s=se(0),u=se(null),l=se([]),d=pe(()=>{for(const c of l.current)clearTimeout(c);l.current=[],Zn(u.current)},[]);Se(()=>{const c=C.getState(),{history:h,historyIndex:v,transitionConfig:k}=c,y=c.consumeNextTransition(),w=s.current;s.current=h.length;const x=!i,E=h.length===1&&v===0&&w>1,I=h.length>1&&v===h.length-1&&w>1&&Math.abs(h.length-w)>1;if(n===i)return;d();const _=r?.passages.get(n);if(!_){o.current=\"none\",a(n);return}if(x||E||I){o.current=\"fade\",a(n);return}const A=ch(_.tags,y,k);o.current=A.type;const $=u.current;if(A.type===\"none\"){a(n);return}if(A.type===\"fade\"){$&&Xn($,A),a(n);return}if(A.type===\"fade-through\"){if(!$){a(n);return}Xn($,A);const M=$.querySelector(\".passage\");if(!M){a(n);return}const b=la(M,A.type);$.appendChild(b),a(\"\");const D=A.duration+A.pause,N=setTimeout(()=>{a(n)},D),V=D+A.duration,U=setTimeout(()=>{Zn($)},V);l.current=[N,U];return}if(A.type===\"crossfade\"){if(!$){a(n);return}Xn($,A);const M=$.querySelector(\".passage\");if(!M){a(n);return}const b=la(M,A.type);$.classList.add(\"passage-container--crossfading\"),$.appendChild(b),a(n);const D=setTimeout(()=>{Zn($)},A.duration);l.current=[D];return}a(n)},[n]);const f=i?r?.passages.get(i):null;if(!f&&i)return S(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const p=r?.passages.get(\"PassageReady\");return S(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[p&&S(\"div\",{hidden:!0,children:zt(p)},`ready-${n}`),S(\"div\",{class:\"passage-container\",ref:u,children:f&&S(sh,{passage:f,dataTransition:o.current},i)})]})}});B({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const f=l[1]??l[5],p=l[2]??l[3]??l[4];if(f)switch(f){case\"goto\":s.goto=p;break;case\"dialog\":s.dialog=p;break;case\"run\":s.run=p;break;case\"name\":s.name=p;break;case\"priority\":s.priority=p?Number(p):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,Po(a,s)),null}});B({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,Eo(r)),null}});const fh='*,*: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 ua(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 ca(){const e=vd(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=fh,document.head.appendChild(t),Rd(),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.\",h=document.getElementById(\"root\");throw h&&ua(h,[c]),new Error(`spindle: ${c}`)}const i=Ld(r.content),a=Hd(e.passages,i);if(a.length>0){const c=document.getElementById(\"root\");throw c&&ua(c,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=qd(i),C.getState().init(e,n),Co();const o=Gf(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 h;for(;(h=s.exec(c.content))!==null;){const v=h[1],k=h[2];/\\{@children\\}/.test(k)&&hr(v)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const h=kt(c.content),v=xt(h);for(const k of v)if(k.type===\"macro\"&&k.name===\"widget\"&&k.rawArgs){const y=k.rawArgs.trim().split(/\\s+/),w=y[0].replace(/[\"']/g,\"\"),x=y.slice(1).filter(_=>_.startsWith(\"$\")||_.startsWith(\"_\")||_.startsWith(\"@\")),E=k.children,I=yn(E);eo(w,E,x,I),I&&hr(w)}}let u=\"\";C.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,Id())});let l=C.getState().variables,d=C.getState().historyIndex;C.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?td():nd()),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 p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');Ce(S(_d,{}),p),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ca):ca();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})