@rohal12/spindle 0.38.0 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +1 -1
- package/src/components/macros/ExprDisplay.tsx +39 -0
- package/src/interpolation.ts +97 -19
- package/src/markup/ast.ts +24 -1
- package/src/markup/render.tsx +11 -0
- package/src/markup/tokenizer.ts +129 -12
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.38.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,ma,Je,oi,ya,_a,ba,Dr,nr,rr,va,vn={},wn=[],ds=/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 Tr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?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 zt(e,o,r,i,null)}function zt(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??++ma,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function hs(){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 ps(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),Nr(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,xa(r,a,i),t.__e=t.__=null,a.__e!=n&&wa(a)}}function wa(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}),wa(e)}function ir(e){(!e.__d&&(e.__d=!0)&&Je.push(e)&&!Sn.__r++||oi!=F.debounceRendering)&&((oi=F.debounceRendering)||ya)(Sn)}function Sn(){for(var e,t=1;Je.length;)Je.length>t&&Je.sort(_a),e=Je.shift(),t=Je.length,ps(e);Sn.__r=0}function Sa(e,t,n,r,i,a,o,s,u,l,c){var f,p,d,h,b,x,y,S=r&&r.__k||wn,k=t.length;for(u=gs(n,t,S,u,k),f=0;f<k;f++)(d=n.__k[f])!=null&&(p=d.__i!=-1&&S[d.__i]||vn,d.__i=f,x=Nr(e,d,p,i,a,o,s,u,l,c),h=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&Rr(p.ref,null,d),c.push(d.ref,d.__c||h,d)),b==null&&h!=null&&(b=h),(y=!!(4&d.__u))||p.__k===d.__k?u=ka(d,u,e,y):typeof d.type==\"function\"&&x!==void 0?u=x:h&&(u=h.nextSibling),d.__u&=-7);return n.__e=b,u}function gs(e,t,n,r,i){var a,o,s,u,l,c=n.length,f=c,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]=zt(null,o,null,null,null):Yt(o)?o=e.__k[a]=zt(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=zt(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=ms(o,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>c?p--:i<c&&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<c;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=_t(s)),Ia(s,s));return r}function ka(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=ka(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 ms(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],c=l!=null&&(2&l.__u)==0;if(l===null&&s==null||c&&s==l.key&&u==l.type)return n;if(r>(c?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 si(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ds.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||si(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||si(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(ba,\"$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=Dr,e.addEventListener(t,a?rr:nr,a)):e.removeEventListener(t,a?rr:nr,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 li(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Dr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function Nr(e,t,n,r,i,a,o,s,u,l){var c,f,p,d,h,b,x,y,S,k,E,I,_,$,A,D=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(c=F.__b)&&c(t);e:if(typeof D==\"function\")try{if(y=t.props,S=\"prototype\"in D&&D.prototype.render,k=(c=D.contextType)&&r[c.__c],E=c?k?k.props.value:c.__:r,n.__c?x=(f=t.__c=n.__c).__=f.__E:(S?t.__c=f=new D(y,E):(t.__c=f=new Te(y,E),f.constructor=D,f.render=_s),k&&k.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),S&&f.__s==null&&(f.__s=f.state),S&&D.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=De({},f.__s)),De(f.__s,D.getDerivedStateFromProps(y,f.__s))),d=f.props,h=f.state,f.__v=t,p)S&&D.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),S&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(S&&D.getDerivedStateFromProps==null&&y!==d&&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(v){v&&(v.__=t)}),wn.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),S&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(d,h,b)})}if(f.context=E,f.props=y,f.__P=e,f.__e=!1,I=F.__r,_=0,S)f.state=f.__s,f.__d=!1,I&&I(t),c=f.render(f.props,f.state,f.context),wn.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,I&&I(t),c=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())),S&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(d,h)),$=c!=null&&c.type===Y&&c.key==null?Ca(c.props.children):c,s=Sa(e,Yt($)?$:[$],t,n,r,i,a,o,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),x&&(f.__E=f.__=null)}catch(v){if(t.__v=null,u||a!=null)if(v.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=a.length;A--;)Tr(a[A]);ar(t)}else t.__e=n.__e,t.__k=n.__k,v.then||ar(t);F.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ys(n.__e,t,n,r,i,a,o,u,l);return(c=F.diffed)&&c(t),128&t.__u?void 0:s}function ar(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ar))}function xa(e,t,n){for(var r=0;r<n.length;r++)Rr(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 Ca(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Yt(e)?e.map(Ca):De({},e)}function ys(e,t,n,r,i,a,o,s,u){var l,c,f,p,d,h,b,x=n.props||vn,y=t.props,S=t.type;if(S==\"svg\"?i=\"http://www.w3.org/2000/svg\":S==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((d=a[l])&&\"setAttribute\"in d==!!S&&(S?d.localName==S:d.nodeType==3)){e=d,a[l]=null;break}}if(e==null){if(S==null)return document.createTextNode(y);e=document.createElementNS(i,S,y.is&&y),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(S==null)x===y||s&&e.data==y||(e.data=y);else{if(a=a&&Gt.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(d=e.attributes[l]).name]=d.value;for(l in x)d=x[l],l==\"dangerouslySetInnerHTML\"?f=d:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||on(e,l,null,d,i);for(l in y)d=y[l],l==\"children\"?p=d:l==\"dangerouslySetInnerHTML\"?c=d:l==\"value\"?h=d:l==\"checked\"?b=d:s&&typeof d!=\"function\"||x[l]===d||on(e,l,d,x[l],i);if(c)s||f&&(c.__html==f.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),Sa(t.type==\"template\"?e.content:e,Yt(p)?p:[p],t,n,r,S==\"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--;)Tr(a[l]);s||(l=\"value\",S==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[l]||S==\"progress\"&&!h||S==\"option\"&&h!=x[l])&&on(e,l,h,x[l],i),l=\"checked\",b!=null&&b!=e[l]&&on(e,l,b,x[l],i))}return e}function Rr(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 Ia(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Rr(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]&&Ia(r[i],t,n||typeof e.type!=\"function\");n||Tr(e.__e),e.__c=e.__=e.__e=void 0}function _s(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=[],Nr(t,e=(!r&&n||t).__k=G(Y,null,[e]),i||vn,vn,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),xa(a,e,o)}function Pa(e,t){Ce(e,t,Pa)}function bs(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),zt(e.type,s,r||e.key,i||e.ref,null)}function Ke(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,ir(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\"+va++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Gt=wn.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}},ma=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),ir(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ir(this))},Te.prototype.render=Y,Je=[],ya=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_a=function(e,t){return e.__v.__b-t.__v.__b},Sn.__r=0,ba=/(PointerCapture)$|Capture$/i,Dr=0,nr=li(!1),rr=li(!0),va=0;var vs=0;function w(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:--vs,__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,Hn,ui,bt=0,Ea=[],K=F,ci=K.__b,fi=K.__r,di=K.diffed,hi=K.__c,pi=K.unmount,gi=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,Mr(Ta,e)}function Mr(e,t,n){var r=St(je++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ta(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 c=r.__c.__H.__.filter(function(p){return p.__c});if(c.every(function(p){return!p.__N}))return!a||a.call(this,s,u,l);var f=r.__c.props!==s;return c.some(function(p){if(p.__N){var d=p.__[0];p.__=p.__N,p.__N=void 0,d!==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 c=a;a=void 0,i(s,u,l),a=c}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&&zr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ut(e,t){var n=St(je++,4);!K.__s&&zr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return bt=5,he(function(){return{current:e}},[])}function Aa(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 zr(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 Q(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 $a(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Da(){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 ws(){for(var e;e=Ea.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(hn),t.__h.some(or),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,ci&&ci(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),gi&&gi(e,t)},K.__r=function(e){fi&&fi(e),je=0;var t=(W=e.__c).__H;t&&(Hn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(hn),t.__h.some(or),t.__h=[],je=0)),Hn=W},K.diffed=function(e){di&&di(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ea.push(t)!==1&&ui===K.requestAnimationFrame||((ui=K.requestAnimationFrame)||Ss)(ws)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Hn=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(hn),n.__h=n.__h.filter(function(r){return!r.__||or(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),hi&&hi(e,t)},K.unmount=function(e){pi&&pi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{hn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var mi=typeof requestAnimationFrame==\"function\";function Ss(e){var t,n=function(){clearTimeout(r),mi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);mi&&(t=requestAnimationFrame(n))}function hn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function or(e){var t=W;e.__c=e.__(),W=t}function zr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Ta(e,t){return typeof t==\"function\"?t(e):t}const yi=e=>{let t;const n=new Set,r=(l,c)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const p=t;t=c??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(d=>d(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},ks=(e=>e?yi(e):yi);function Na(e,t){for(var n in t)e[n]=t[n];return e}function sr(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 Ra(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,qn(i)&&a({t:i})},[e,n,t]),Se(function(){return qn(i)&&a({t:i}),e(function(){qn(i)&&a({t:i})})},[e]),n}function qn(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 Ma(e){e()}function za(e){return e}function Fa(){return[!1,Ma]}var Oa=ut;function lr(e,t){this.props=e,this.context=t}function xs(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:sr(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(lr.prototype=new Te).isPureReactComponent=!0,lr.prototype.shouldComponentUpdate=function(e,t){return sr(this.props,e)||sr(this.state,t)};var _i=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),_i&&_i(e)};var Cs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Is(e){function t(n){var r=Na({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Cs,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var bi=function(e,t){return e==null?null:Be(Be(e).map(t))},Ps={map:bi,forEach:bi,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},Es=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)}Es(e,t,n,r)};var vi=F.unmount;function La(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=Na({},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 La(r,t,n)})),e}function Ba(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ba(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 pn(){this.__u=0,this.o=null,this.__b=null}function Va(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function As(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?G(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Rt(){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),vi&&vi(e)},(pn.prototype=new Te).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Va(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]=Ba(l,l.__c.__P,l.__c.__O)}var c;for(r.setState({__a:r.__b=null});c=r.o.pop();)c.__P=s,c.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},pn.prototype.componentWillUnmount=function(){this.o=[]},pn.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]=La(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&G(Y,null,e.fallback);return i&&(i.__u&=-33),[G(Y,null,t.__a?null:e.children),i]};var wi=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 $s(e){return this.getChildContext=function(){return e.context},e.children}function Ds(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(G($s,{context:t.context},e.__v),t.v)}function Ts(e,t){var n=G(Ds,{__v:e,h:t});return n.containerInfo=t,n}(Rt.prototype=new Te).__a=function(e){var t=this,n=Va(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),wi(t,e,r)):i()};n?n(a):a()}},Rt.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},Rt.prototype.componentDidUpdate=Rt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){wi(e,n,t)})};var Ha=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ns=/^(?: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]/,Rs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ms=/[A-Z0-9]/g,zs=typeof document<\"u\",Fs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Os(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ce(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ls(e,t,n){return Pa(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 Si=F.event;function Bs(){}function Vs(){return this.cancelBubble}function Hs(){return this.defaultPrevented}F.event=function(e){return Si&&(e=Si(e)),e.persist=Bs,e.isPropagationStopped=Vs,e.isDefaultPrevented=Hs,e.nativeEvent=e};var Fr,qs={enumerable:!1,configurable:!0,get:function(){return this.class}},ki=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||zs&&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\"||Fs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":Rs.test(o)&&(o=u):u=o=\"oninput\":a&&Ns.test(o)?o=o.replace(Ms,\"-$&\").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\",qs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ha,ki&&ki(e)};var xi=F.__r;F.__r=function(e){xi&&xi(e),Fr=e.__c};var Ci=F.diffed;F.diffed=function(e){Ci&&Ci(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),Fr=null};var Us={ReactCurrentDispatcher:{current:{readContext:function(e){return Fr.__n[e.__c].props.value},useCallback:pe,useContext:Q,useDebugValue:$a,useDeferredValue:za,useEffect:Se,useId:Da,useImperativeHandle:Aa,useInsertionEffect:Oa,useLayoutEffect:ut,useMemo:he,useReducer:Mr,useRef:se,useState:ee,useSyncExternalStore:Ra,useTransition:Fa}}};function js(e){return G.bind(null,e)}function Nn(e){return!!e&&e.$$typeof===Ha}function Ws(e){return Nn(e)&&e.type===Y}function Ks(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Qs(e){return Nn(e)?bs.apply(null,arguments):e}function Gs(e){return!!e.__k&&(Ce(null,e),!0)}function Ys(e){return e&&(e.base||e.nodeType===1&&e)||null}var Js=function(e,t){return e(t)},Xs=function(e,t){return e(t)},Zs=Y,el=Nn,sn={useState:ee,useId:Da,useReducer:Mr,useEffect:Se,useLayoutEffect:ut,useInsertionEffect:Oa,useTransition:Fa,useDeferredValue:za,useSyncExternalStore:Ra,startTransition:Ma,useRef:se,useImperativeHandle:Aa,useMemo:he,useCallback:pe,useContext:Q,useDebugValue:$a,version:\"18.3.1\",Children:Ps,render:Os,hydrate:Ls,unmountComponentAtNode:Gs,createPortal:Ts,createElement:G,createContext:Ke,createFactory:js,cloneElement:Qs,createRef:hs,Fragment:Y,isValidElement:Nn,isElement:el,isFragment:Ws,isMemo:Ks,findDOMNode:Ys,Component:Te,PureComponent:lr,memo:xs,forwardRef:Is,flushSync:Xs,unstable_batchedUpdates:Js,StrictMode:Zs,Suspense:pn,SuspenseList:Rt,lazy:As,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Us};const tl=e=>e;function nl(e,t=tl){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 rl=e=>{const t=ks(e),n=r=>nl(t,r);return Object.assign(n,t),n},il=(e=>rl);var Or=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,at=me.getPrototypeOf,Ht=\"constructor\",Jt=\"prototype\",ur=\"configurable\",kn=\"enumerable\",gn=\"writable\",qt=\"value\",He=e=>!!e&&!!e[ne];function Ne(e){return e?qa(e)||Zt(e)||!!e[Ft]||!!e[Ht]?.[Ft]||en(e)||tn(e):!1}var al=me[Jt][Ht].toString(),Ii=new WeakMap;function qa(e){if(!e||!vt(e))return!1;const t=at(e);if(t===null||t===me[Jt])return!0;const n=me.hasOwnProperty.call(t,Ht)&&t[Ht];if(n===Object)return!0;if(!Xe(n))return!1;let r=Ii.get(n);return r===void 0&&(r=Function.toString.call(n),Ii.set(n,r)),r===al}function Xt(e,t,n=!0){ot(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 ot(e){const t=e[ne];return t?t.type_:Zt(e)?1:en(e)?2:tn(e)?3:0}var Ot=(e,t,n=ot(e))=>n===2?e.has(t):me[Jt].hasOwnProperty.call(e,t),Oe=(e,t,n=ot(e))=>n===2?e.get(t):e[t],xn=(e,t,n,r=ot(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function ol(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\",Xe=e=>typeof e==\"function\",Un=e=>typeof e==\"boolean\";function sl(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ll=e=>vt(e)?e?.[ne]:null,Le=e=>e.copy_||e.base_,Lr=e=>e.modified_?e.copy_:e.base_;function cr(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=qa(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[gn]===!1&&(s[gn]=!0,s[ur]=!0),(s.get||s.set)&&(r[o]={[ur]:!0,[gn]:!0,[kn]:s[kn],[qt]:e[o]})}return me.create(at(e),r)}else{const r=at(e);if(r!==null&&n)return{...e};const i=me.create(r);return me.assign(i,e)}}function Br(e,t=!1){return Rn(e)||He(e)||!Ne(e)||(ot(e)>1&&me.defineProperties(e,{set:ln,add:ln,clear:ln,delete:ln}),me.freeze(e),t&&Xt(e,(n,r)=>{Br(r,!0)},!1)),e}function ul(){oe(2)}var ln={[qt]:ul};function Rn(e){return e===null||!vt(e)?!0:me.isFrozen(e)}var Cn=\"MapSet\",In=\"Patches\",Pi=\"ArrayMethods\",Pn={};function st(e){const t=Pn[e];return t||oe(0,e),t}var Ei=e=>!!Pn[e];function cl(e,t){Pn[e]||(Pn[e]=t)}var Ut,Ua=()=>Ut,fl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ei(Cn)?st(Cn):void 0,arrayMethodsPlugin_:Ei(Pi)?st(Pi):void 0});function Ai(e,t){t&&(e.patchPlugin_=st(In),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fr(e){dr(e),e.drafts_.forEach(dl),e.drafts_=null}function dr(e){e===Ut&&(Ut=e.parent_)}var $i=e=>Ut=fl(Ut,e);function dl(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Di(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(fr(t),oe(4)),Ne(e)&&(e=Ti(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Ti(t,n);return hl(t,e,!0),fr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Or?e:void 0}function Ti(e,t){if(Rn(t))return t;const n=t[ne];if(!n)return En(t,e.handledSet_,e);if(!Mn(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);Ka(n,e)}return n.copy_}function hl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Br(t,n)}function ja(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Mn=(e,t)=>e.scope_===t,pl=[];function Wa(e,t,n,r){const i=Le(e),a=e.type_;if(r!==void 0&&Oe(i,r,a)===t){xn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Xt(i,(u,l)=>{if(He(l)){const c=s.get(l)||[];c.push(u),s.set(l,c)}})}const o=e.draftLocations_.get(t)??pl;for(const s of o)xn(i,s,n,a)}function gl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Mn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Lr(a);Wa(e,a.draft_??a,o,n),Ka(a,i)})}function Ka(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}ja(e)}}function ml(e,t,n){const{scope_:r}=e;if(He(n)){const i=n[ne];Mn(i,r)&&i.callbacks_.push(function(){mn(e);const o=Lr(i);Wa(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Le(e);e.type_===3?a.has(n)&&En(n,r.handledSet_,r):Oe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&En(Oe(e.copy_,t,e.type_),r.handledSet_,r)})}function En(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||He(e)||t.has(e)||!Ne(e)||Rn(e)||(t.add(e),Xt(e,(r,i)=>{if(He(i)){const a=i[ne];if(Mn(a,n)){const o=Lr(a);xn(e,r,o,e.type_),ja(a)}}else Ne(i)&&En(i,t,n)})),e}function yl(e,t){const n=Zt(e),r={type_:n?1:0,scope_:t?t.scope_:Ua(),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=An;n&&(i=[r],a=jt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var An={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 _l(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&sl(t))return a;if(a===jn(e.base_,t)){mn(e);const o=e.type_===1?+t:t,s=pr(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=jn(Le(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(ol(n,i)&&(n!==void 0||Ot(e.base_,t,e.type_)))return!0;mn(e),hr(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),ml(e,t,n)),!0},deleteProperty(e,t){return mn(e),jn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),hr(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&&{[gn]:!0,[ur]:e.type_!==1||t!==\"length\",[kn]:r[kn],[qt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return at(e.base_)},setPrototypeOf(){oe(12)}},jt={};for(let e in An){let t=An[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 An.set.call(this,e[0],t,n,e[0])};function jn(e,t){const n=e[ne];return(n?Le(n):e)[t]}function _l(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=at(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=at(n)}}function hr(e){e.modified_||(e.modified_=!0,e.parent_&&hr(e.parent_))}function mn(e){e.copy_||(e.assigned_=new Map,e.copy_=cr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var bl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Xe(t)&&!Xe(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,c=>n.call(this,c,...l))}}Xe(n)||oe(6),r!==void 0&&!Xe(r)&&oe(7);let i;if(Ne(t)){const a=$i(this),o=pr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?fr(a):dr(a)}return Ai(a,r),Di(i,a)}else if(!t||!vt(t)){if(i=n(t),i===void 0&&(i=t),i===Or&&(i=void 0),this.autoFreeze_&&Br(i,!0),r){const a=[],o=[];st(In).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Xe(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]},Un(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Un(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Un(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||oe(8),He(e)&&(e=vl(e));const t=$i(this),n=pr(t,e,void 0);return n[ne].isManual_=!0,dr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return Ai(r,t),Di(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=st(In).applyPatches_;return He(e)?r(e,t):this.produce(e,i=>r(i,t))}};function pr(e,t,n,r){const[i,a]=en(t)?st(Cn).proxyMap_(t,n):tn(t)?st(Cn).proxySet_(t,n):yl(t,n);return(n?.scope_??Ua()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?gl(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 vl(e){return He(e)||oe(10,e),Ga(e)}function Ga(e){if(!Ne(e)||Rn(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=cr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=cr(e,!0);return Xt(n,(i,a)=>{xn(n,i,Ga(a))},r),t&&(t.finalized_=!1),n}function wl(){function t(h,b=[]){if(h.key_!==void 0){const x=h.parent_.copy_??h.parent_.base_,y=ll(Oe(x,h.key_)),S=Oe(x,h.key_);if(S===void 0||S!==h.draft_&&S!==h.base_&&S!==h.copy_||y!=null&&y.base_!==h.base_)return null;const k=h.parent_.type_===3;let E;if(k){const I=h.parent_;E=Array.from(I.drafts_.keys()).indexOf(h.key_)}else E=h.key_;if(!(k&&x.size>E||Ot(x,E)))return null;b.push(E)}if(h.parent_)return t(h.parent_,b);b.reverse();try{n(h.copy_,b)}catch{return null}return b}function n(h,b){let x=h;for(let y=0;y<b.length-1;y++){const S=b[y];if(x=Oe(x,S),!vt(x)||x===null)throw new Error(`Cannot resolve path at '${b.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(h,b,x){if(h.scope_.processedForPatches_.has(h))return;h.scope_.processedForPatches_.add(h);const{patches_:y,inversePatches_:S}=x;switch(h.type_){case 0:case 2:return u(h,b,y,S);case 1:return s(h,b,y,S);case 3:return l(h,b,y,S)}}function s(h,b,x,y){let{base_:S,assigned_:k}=h,E=h.copy_;E.length<S.length&&([S,E]=[E,S],[x,y]=[y,x]);const I=h.allIndicesReassigned_===!0;for(let _=0;_<S.length;_++){const $=E[_],A=S[_];if((I||k?.get(_.toString()))&&$!==A){const v=$?.[ne];if(v&&v.modified_)continue;const T=b.concat([_]);x.push({op:r,path:T,value:d($)}),y.push({op:r,path:T,value:d(A)})}}for(let _=S.length;_<E.length;_++){const $=b.concat([_]);x.push({op:i,path:$,value:d(E[_])})}for(let _=E.length-1;S.length<=_;--_){const $=b.concat([_]);y.push({op:a,path:$})}}function u(h,b,x,y){const{base_:S,copy_:k,type_:E}=h;Xt(h.assigned_,(I,_)=>{const $=Oe(S,I,E),A=Oe(k,I,E),D=_?Ot(S,I)?r:i:a;if($===A&&D===r)return;const v=b.concat(I);x.push(D===a?{op:D,path:v}:{op:D,path:v,value:d(A)}),y.push(D===i?{op:a,path:v}:D===a?{op:i,path:v,value:d($)}:{op:r,path:v,value:d($)})})}function l(h,b,x,y){let{base_:S,copy_:k}=h,E=0;S.forEach(I=>{if(!k.has(I)){const _=b.concat([E]);x.push({op:a,path:_,value:I}),y.unshift({op:i,path:_,value:I})}E++}),E=0,k.forEach(I=>{if(!S.has(I)){const _=b.concat([E]);x.push({op:i,path:_,value:I}),y.unshift({op:a,path:_,value:I})}E++})}function c(h,b,x){const{patches_:y,inversePatches_:S}=x;y.push({op:r,path:[],value:b===Or?void 0:b}),S.push({op:r,path:[],value:h})}function f(h,b){return b.forEach(x=>{const{path:y,op:S}=x;let k=h;for(let $=0;$<y.length-1;$++){const A=ot(k);let D=y[$];typeof D!=\"string\"&&typeof D!=\"number\"&&(D=\"\"+D),(A===0||A===1)&&(D===\"__proto__\"||D===Ht)&&oe(19),Xe(k)&&D===Jt&&oe(19),k=Oe(k,D),vt(k)||oe(18,y.join(\"/\"))}const E=ot(k),I=p(x.value),_=y[y.length-1];switch(S){case r:switch(E){case 2:return k.set(_,I);case 3:oe(16);default:return k[_]=I}case i:switch(E){case 1:return _===\"-\"?k.push(I):k.splice(_,0,I);case 2:return k.set(_,I);case 3:return k.add(I);default:return k[_]=I}case a:switch(E){case 1:return k.splice(_,1);case 2:return k.delete(_);case 3:return k.delete(x.value);default:return delete k[_]}default:oe(17,S)}}),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(([x,y])=>[x,p(y)]));if(tn(h))return new Set(Array.from(h).map(p));const b=Object.create(at(h));for(const x in h)b[x]=p(h[x]);return Ot(h,Ft)&&(b[Ft]=h[Ft]),b}function d(h){return He(h)?p(h):h}cl(In,{applyPatches_:f,generatePatches_:o,generateReplacementPatches_:c,getPath:t})}var Wt=new bl,Sl=Wt.produce,kl=Wt.produceWithPatches.bind(Wt),mt=Wt.applyPatches.bind(Wt);const xl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Sl(i):i;return t(s,a,...o)},e(r.setState,n,r)),Cl=xl,Il=/[a-zA-Z]/,Pl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function El(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 Ni(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 Ri(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 Al(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=Ri(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 c=e.slice(l,n);n+=2;const{display:f,target:p}=El(c),d={type:\"link\",display:f,target:p,start:a,end:n};o&&(d.className=o),s&&(d.id=s),t.push(d),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=Ri(e,n+1);s=l.className||void 0,u=l.id||void 0;let c=l.endIdx;e[c]===\" \"&&c++;const f=e[c];if(f===\"$\"){n=c+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:d,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=c+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:d,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=c+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const h={type:\"variable\",name:d,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=c;let p=1;const d=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const h=e.slice(d,n);n++;const{name:b,rawArgs:x,isClose:y}=Ni(h),S={type:\"macro\",name:b,rawArgs:x,isClose:y,start:a,end:n};s&&(S.className=s),u&&(S.id=u),t.push(S),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 c=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:c,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 c=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:c,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 c=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:c,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 c=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(c,n);n++;const{name:p,rawArgs:d,isClose:h}=Ni(f);t.push({type:\"macro\",name:p,rawArgs:d,isClose:h,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9-]/.test(e[o]);)o++;const l=e.slice(u,o),c=l.toLowerCase();if(l&&Il.test(l[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const f=Al(e,o);o=f.endIdx;let p=Pl.has(c);if(e[o]===\"/\"&&(p=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:p,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ya=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function gr(e){Ya.add(e.toLowerCase())}const Mi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},$l=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.toLowerCase()!==i.tag.toLowerCase()){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(Mi[a]){const o=Mi[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(Ya.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if($l.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 Vr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Q(Ie);return he(()=>[e,t,n],[e,t,n])}const Dl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,Tl=/\\{[\\$_@][\\w.]+\\}/;function Nl(e){return Tl.test(e)}function Rl(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 Ml(e,t,n,r){return e.replace(Dl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let c;return o===\"$\"?c=t[l]:o===\"_\"?c=n[l]:c=r[l],u.length>1&&(c=Rl(c,u)),c==null?\"\":String(c)})}function Hr(){const[e,t,n]=Vr();return pe(r=>r===void 0||!Nl(r)?r:Ml(r,e,t,n),[e,t,n])}function zl({name:e,scope:t,className:n,id:r}){const i=Hr();n=i(n),r=i(r);const a=Q(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 c=l==null?\"\":String(l);return n||r?w(\"span\",{id:r,class:n,children:c}):w(Y,{children:c})}function Ja(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 Xa(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=\"\",lt=0,wt=null;function Fl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,nn=n,lt=0,wt=Ja(Xa(n)),Ct=!0}function Za(e,t){nn=e,lt=0,wt=Ja(Xa(e)),Ct=!0;for(let n=0;n<t;n++)wt();lt=t}function mr(){Ct=!1,nn=\"\",lt=0,wt=null}function $n(){return Ct?{seed:nn,pull:lt}:null}function qr(){return!Ct||!wt?Math.random():(lt++,wt())}function eo(e,t){return e>t&&([e,t]=[t,e]),Math.floor(qr()*(t-e+1))+e}function Ol(){return Ct}function Ll(){return nn}function Bl(){return lt}const Vl=500,Ge=new Map,Hl=/\\$(\\w+)/g,ql=/(?<![.\\w])_(\\w+)/g,Ul=/@(\\w+)/g;function jl(e){return e.replace(Hl,'variables[\"$1\"]').replace(ql,'temporary[\"$1\"]').replace(Ul,'locals[\"$1\"]')}function Ur(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=jl(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 c=e.charAt(r);if(c===\"\\\\\"&&r+1<e.length)u+=c+e.charAt(r+1),r+=2;else if(c===l){u+=c,r++;break}else u+=c,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const c=e.charAt(r);if(c===\"\\\\\"&&r+1<e.length)u+=c+e.charAt(r+1),r+=2;else if(c===\"$\"&&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(c===\"`\"){u+=c,r++;break}else u+=c,r++}continue}else u+=l;r++}t+=Ur(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 Wl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function to(e,t){const n=Ge.get(e);if(n)return Ge.delete(e),Ge.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Wl+t);if(Ge.set(e,r),Ge.size>Vl){const i=Ge.keys().next().value;i!==void 0&&Ge.delete(i)}return r}let un=null,zi=null,Fi=null;function no(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(un&&zi===t&&Fi===n)return un;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(h=>r(h)>0),o=(...d)=>d.every(h=>r(h)>0),s=d=>n[d??C.getState().currentPassage]??0;return un={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const h=d.history[d.historyIndex-1]?.passage;return h?d.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(h=>s(h)>0),hasRenderedAll:(...d)=>d.every(h=>s(h)>0),random:qr,randomInt:eo},zi=t,Fi=n,un}function zn(e,t,n,r={}){const a=`return (${Ur(e)});`;return to(a,a)(t,n,r,no())}function ro(e,t,n,r={}){const i=Ur(e);to(\"exec:\"+i,i)(t,n,r,no())}function Kl(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(!Kl(a))return null;return t}function Gl(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 Yl({body:e,parentValues:t,ownKeys:n}){const r=Q(fe),[i,a]=ee({}),o={...t,...n,...i},s=se(o);s.current=o;const u=pe(()=>s.current,[]),l=pe((f,p)=>{a(d=>({...d,[f]:p}))},[]),c=he(()=>({update:l,getValues:u}),[l,u]);return w(rn.Provider,{value:c,children:w(Ie.Provider,{value:o,children:Pe(e,{nobr:r,locals:o})})})}function Jl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(Ie),a=Q(fe),[o,s,u]=Vr(),l=r?.length?r:null;if(t.length===0||!n)return w(wr.Provider,{value:l,children:Pe(e,{nobr:a,locals:i})});const c=Gl(n),f={};for(let p=0;p<t.length;p++){const d=t[p],h=c[p];let b;if(h!==void 0)try{b=zn(h,o,s,u)}catch{b=void 0}f[d.startsWith(\"@\")?d.slice(1):d]=b}return w(wr.Provider,{value:l,children:w(Yl,{body:e,parentValues:i,ownKeys:f})})}const io=new Map;function ao(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");io.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Xl(e){return io.get(e.toLowerCase())}const oo=new Map;function Zl(e,t){oo.set(e.toLowerCase(),t)}function eu(e){return oo.get(e.toLowerCase())}const so=new Set;function tu(e){so.add(e.toLowerCase())}function nu(e){return so.has(e.toLowerCase())}const lo=new Map;function ru(e,t){lo.set(e.toLowerCase(),t)}function iu(){return Array.from(lo.values())}const Oi=document.createElement(\"i\");function uo(e){const t=\"&\"+e+\";\";Oi.innerHTML=t;const n=Oi.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 yr={}.hasOwnProperty;function au(e){const t={};let n=-1;for(;++n<e.length;)ou(t,e[n]);return t}function ou(e,t){let n;for(n in t){const i=(yr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){yr.call(i,o)||(i[o]=[]);const s=a[o];su(i[o],Array.isArray(s)?s:s?[s]:[])}}}function su(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 lu(e){const t={};let n=-1;for(;++n<e.length;)uu(t,e[n]);return t}function uu(e,t){let n;for(n in t){const i=(yr.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 cu(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 fu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function co(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+fu[n]+\";\"}}function Kt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const $e=Qe(/[A-Za-z]/),ye=Qe(/[\\dA-Za-z]/),du=Qe(/[#-'*+\\--9=?A-Z^-~]/);function _r(e){return e!==null&&(e<32||e===127)}const br=Qe(/\\d/),hu=Qe(/[\\dA-Fa-f]/),pu=Qe(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const gu=Qe(/\\p{P}|\\p{S}/u),mu=Qe(/\\s/);function Qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function cn(e,t){const n=co(yu(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 yu(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 Li={}.hasOwnProperty,Bi=/^(https?|ircs?|mailto|xmpp)$/i,_u=/^https?$/i;function bu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=lu([{enter:{blockQuote:O,codeFenced:ke,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:is,content:Wo,definition:Bo,definitionDestinationString:Ho,definitionLabelString:x,definitionTitleString:x,emphasis:ns,htmlFlow:ts,htmlText:ti,image:q,label:x,link:ue,listItemMarker:T,listItemValue:v,listOrdered:A,listUnordered:D,paragraph:X,reference:x,resource:dt,resourceDestinationString:ht,resourceTitleString:x,setextHeading:Qo,strong:rs},exit:{atxHeading:Yo,atxHeadingSequence:Ko,autolinkEmail:fs,autolinkProtocol:cs,blockQuote:Z,characterEscapeValue:Pt,characterReferenceMarkerHexadecimal:ni,characterReferenceMarkerNumeric:ni,characterReferenceValue:us,codeFenced:g,codeFencedFence:R,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:es,codeIndented:g,codeText:as,codeTextData:Pt,data:Pt,definition:jo,definitionDestinationString:qo,definitionLabelString:Vo,definitionTitleString:Uo,emphasis:os,hardBreakEscape:Zr,hardBreakTrailing:Zr,htmlFlow:ei,htmlFlowData:Pt,htmlText:ei,htmlTextData:Pt,image:Xr,label:It,labelText:te,lineEnding:Zo,link:Xr,listOrdered:N,listUnordered:V,paragraph:ge,reference:$,referenceString:qe,resource:$,resourceDestinationString:Vn,resourceTitleString:Lo,setextHeading:Xo,setextHeadingLineSequence:Jo,setextHeadingText:Go,strong:ss,thematicBreak:ls}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},c={buffer:x,encode:_,getData:b,lineEndingIfNeeded:I,options:t,raw:k,resume:y,setData:h,tag:S};let f=t.defaultLineEnding;return p;function p(P){let M=-1,re=0;const xe=[];let Ee=[],Re=[];for(;++M<P.length;)!f&&(P[M][1].type===\"lineEnding\"||P[M][1].type===\"lineEndingBlank\")&&(f=P[M][2].sliceSerialize(P[M][1])),(P[M][1].type===\"listOrdered\"||P[M][1].type===\"listUnordered\")&&(P[M][0]===\"enter\"?xe.push(M):d(P.slice(xe.pop(),M))),P[M][1].type===\"definition\"&&(P[M][0]===\"enter\"?(Re=ae(Re,P.slice(re,M)),re=M):(Ee=ae(Ee,P.slice(re,M+1)),re=M+1));Ee=ae(Ee,Re),Ee=ae(Ee,P.slice(re)),M=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(c);++M<P.length;){const ri=u[Ae[M][0]],ii=Ae[M][1].type,ai=ri[ii];Li.call(ri,ii)&&ai&&ai.call({sliceSerialize:Ae[M][2].sliceSerialize,...c},Ae[M][1])}return u.exit.null&&u.exit.null.call(c),i[0].join(\"\")}function d(P){const M=P.length;let re=0,xe=0,Ee=!1,Re;for(;++re<M;){const Ae=P[re];if(Ae[1]._container)Re=void 0,Ae[0]===\"enter\"?xe++:xe--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(Re=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!xe&&(Re?Re=void 0:Ee=!0);break}default:Re=void 0}}P[0][1]._loose=Ee}function h(P,M){l[P]=M}function b(P){return l[P]}function x(){i.push([])}function y(){return i.pop().join(\"\")}function S(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function k(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){k(f||`\n`)}function I(){const P=i[i.length-1],M=P[P.length-1],re=M?M.charCodeAt(M.length-1):null;re===10||re===13||re===null||E()}function _(P){return b(\"ignoreEncode\")?P:co(P)}function $(){y()}function A(P){o.push(!P._loose),I(),S(\"<ol\"),h(\"expectFirstItem\",!0)}function D(P){o.push(!P._loose),I(),S(\"<ul\"),h(\"expectFirstItem\",!0)}function v(P){if(b(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(P),10);M!==1&&S(' start=\"'+_(String(M))+'\"')}}function T(){b(\"expectFirstItem\")?S(\">\"):U(),I(),S(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),S(\"</ol>\")}function V(){U(),o.pop(),E(),S(\"</ul>\")}function U(){b(\"lastWasTag\")&&!b(\"slurpAllLineEndings\")&&I(),S(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),S(\"<blockquote>\")}function Z(){o.pop(),I(),S(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),S(\"<p>\")),h(\"slurpAllLineEndings\")}function ge(){o[o.length-1]?h(\"slurpAllLineEndings\",!0):S(\"</p>\")}function ke(){I(),S(\"<pre><code\"),h(\"fencesCount\",0)}function m(){const P=y();S(' class=\"language-'+P+'\"')}function R(){const P=b(\"fencesCount\")||0;P||(S(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),S(\"<pre><code>\")}function g(){const P=b(\"fencesCount\");P!==void 0&&P<2&&l.tightStack.length>0&&!b(\"lastWasTag\")&&E(),b(\"flowCodeSeenData\")&&I(),S(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function It(){a[a.length-1].label=y()}function qe(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function dt(){x(),a[a.length-1].destination=\"\"}function ht(){x(),h(\"ignoreEncode\",!0)}function Vn(){a[a.length-1].destination=y(),h(\"ignoreEncode\")}function Lo(){a[a.length-1].title=y()}function Xr(){let P=a.length-1;const M=a[P],re=M.referenceId||M.labelId,xe=M.destination===void 0?r[Kt(re)]:M;for(n=!0;P--;)if(a[P].image){n=void 0;break}M.image?(S('<img src=\"'+cn(xe.destination,t.allowDangerousProtocol?void 0:_u)+'\" alt=\"'),k(M.label),S('\"')):S('<a href=\"'+cn(xe.destination,t.allowDangerousProtocol?void 0:Bi)+'\"'),S(xe.title?' title=\"'+xe.title+'\"':\"\"),M.image?S(\" />\"):(S(\">\"),k(M.label),S(\"</a>\")),a.pop()}function Bo(){x(),a.push({})}function Vo(P){y(),a[a.length-1].labelId=this.sliceSerialize(P)}function Ho(){x(),h(\"ignoreEncode\",!0)}function qo(){a[a.length-1].destination=y(),h(\"ignoreEncode\")}function Uo(){a[a.length-1].title=y()}function jo(){const P=a[a.length-1],M=Kt(P.labelId);y(),Li.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Wo(){h(\"slurpAllLineEndings\",!0)}function Ko(P){b(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),S(\"<h\"+b(\"headingRank\")+\">\"))}function Qo(){x(),h(\"slurpAllLineEndings\")}function Go(){h(\"slurpAllLineEndings\",!0)}function Yo(){S(\"</h\"+b(\"headingRank\")+\">\"),h(\"headingRank\")}function Jo(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function Xo(){const P=y();I(),S(\"<h\"+b(\"headingRank\")+\">\"),k(P),S(\"</h\"+b(\"headingRank\")+\">\"),h(\"slurpAllLineEndings\"),h(\"headingRank\")}function Pt(P){k(_(this.sliceSerialize(P)))}function Zo(P){if(!b(\"slurpAllLineEndings\")){if(b(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(b(\"inCodeText\")){k(\" \");return}k(_(this.sliceSerialize(P)))}}function es(P){k(_(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function Zr(){S(\"<br />\")}function ts(){I(),ti()}function ei(){h(\"ignoreEncode\")}function ti(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function ns(){S(\"<em>\")}function rs(){S(\"<strong>\")}function is(){h(\"inCodeText\",!0),S(\"<code>\")}function as(){h(\"inCodeText\"),S(\"</code>\")}function os(){S(\"</em>\")}function ss(){S(\"</strong>\")}function ls(){I(),S(\"<hr />\")}function ni(P){h(\"characterReferenceType\",P.type)}function us(P){const M=this.sliceSerialize(P),re=b(\"characterReferenceType\")?cu(M,b(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):uo(M);k(_(re)),h(\"characterReferenceType\")}function cs(P){const M=this.sliceSerialize(P);S('<a href=\"'+cn(M,t.allowDangerousProtocol?void 0:Bi)+'\">'),k(_(M)),S(\"</a>\")}function fs(P){const M=this.sliceSerialize(P);S('<a href=\"'+cn(\"mailto:\"+M)+'\">'),k(_(M)),S(\"</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 vu={tokenize:wu};function wu(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 z(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Su={tokenize:ku},Vi={tokenize:xu};function ku(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&S();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 $=E;for(;$<t.events.length;)t.events[$][1].end={..._},$++;return _e(t.events,I+1,0,t.events.slice(E)),t.events.length=$,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return p(k);if(i.currentConstruct&&i.currentConstruct.concrete)return h(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Vi,c,f)(k)}function c(k){return i&&S(),y(r),p(k)}function f(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(k)}function p(k){return t.containerState={},e.attempt(Vi,d,h)(k)}function d(k){return r++,n.push([t.currentConstruct,t.containerState]),p(k)}function h(k){if(k===null){i&&S(),y(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),b(k)}function b(k){if(k===null){x(e.exit(\"chunkFlow\"),!0),y(0),e.consume(k);return}return z(k)?(e.consume(k),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),b)}function x(k,E){const I=t.sliceStream(k);if(E&&I.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(I),t.parser.lazy[k.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 $=t.events.length;let A=$,D,v;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){if(D){v=t.events[A][1].end;break}D=!0}for(y(r),_=$;_<t.events.length;)t.events[_][1].end={...v},_++;_e(t.events,A+1,0,t.events.slice($)),t.events.length=_}}function y(k){let E=n.length;for(;E-- >k;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=k}function S(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function xu(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 Dn(e){if(e===null||le(e)||mu(e))return 1;if(gu(e))return 2}function Fn(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 vr={name:\"attention\",resolveAll:Cu,tokenize:Iu};function Cu(e,t){let n=-1,r,i,a,o,s,u,l,c;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};Hi(f,-u),Hi(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,Fn(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?(c=2,l=ae(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):c=0,_e(e,r-1,n-r+3,l),n=r+l.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Iu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Dn(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\"),c=Dn(u),f=!c||c===2&&i||n.includes(u),p=!i||i===2&&c||n.includes(r);return l._open=!!(a===42?f:f&&(i||!p)),l._close=!!(a===42?p:p&&(c||!f)),t(u)}}function Hi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Pu={name:\"autolink\",tokenize:Eu};function Eu(e,t,n){let r=0;return i;function i(d){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(d){return $e(d)?(e.consume(d),o):d===64?n(d):l(d)}function o(d){return d===43||d===45||d===46||ye(d)?(r=1,s(d)):l(d)}function s(d){return d===58?(e.consume(d),r=0,u):(d===43||d===45||d===46||ye(d))&&r++<32?(e.consume(d),s):(r=0,l(d))}function u(d){return d===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d===null||d===32||d===60||_r(d)?n(d):(e.consume(d),u)}function l(d){return d===64?(e.consume(d),c):du(d)?(e.consume(d),l):n(d)}function c(d){return ye(d)?f(d):n(d)}function f(d){return d===46?(e.consume(d),r=0,c):d===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):p(d)}function p(d){if((d===45||ye(d))&&r++<63){const h=d===45?p:f;return e.consume(d),h}return n(d)}}const On={partial:!0,tokenize:Au};function Au(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const fo={continuation:{tokenize:Du},exit:Tu,name:\"blockQuote\",tokenize:$u};function $u(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function Du(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(fo,t,n)(o)}}function Tu(e){e.exit(\"blockQuote\")}const ho={name:\"characterEscape\",tokenize:Nu};function Nu(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 pu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const po={name:\"characterReference\",tokenize:Ru};function Ru(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,c(f))}function l(f){return f===88||f===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(f),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=hu,c):(e.enter(\"characterReferenceValue\"),a=7,o=br,c(f))}function c(f){if(f===59&&i){const p=e.exit(\"characterReferenceValue\");return o===ye&&!uo(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),c):n(f)}}const qi={partial:!0,tokenize:zu},Ui={concrete:!0,name:\"codeFenced\",tokenize:Mu};function Mu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(_){return l(_)}function l(_){const $=r.events[r.events.length-1];return a=$&&$[1].type===\"linePrefix\"?$[2].sliceSerialize($[1],!0).length:0,s=_,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),c(_)}function c(_){return _===s?(o++,e.consume(_),c):o<3?n(_):(e.exit(\"codeFencedFenceSequence\"),L(_)?H(e,f,\"whitespace\")(_):f(_))}function f(_){return _===null||z(_)?(e.exit(\"codeFencedFence\"),r.interrupt?t(_):e.check(qi,b,E)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){return _===null||z(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(_)):L(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,d,\"whitespace\")(_)):_===96&&_===s?n(_):(e.consume(_),p)}function d(_){return _===null||z(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||z(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),h)}function b(_){return e.attempt(i,E,x)(_)}function x(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return a>0&&L(_)?H(e,S,\"linePrefix\",a+1)(_):S(_)}function S(_){return _===null||z(_)?e.check(qi,b,E)(_):(e.enter(\"codeFlowValue\"),k(_))}function k(_){return _===null||z(_)?(e.exit(\"codeFlowValue\"),S(_)):(e.consume(_),k)}function E(_){return e.exit(\"codeFenced\"),t(_)}function I(_,$,A){let D=0;return v;function v(O){return _.enter(\"lineEnding\"),_.consume(O),_.exit(\"lineEnding\"),T}function T(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)):A(O)}function V(O){return O===s?(D++,_.consume(O),V):D>=o?(_.exit(\"codeFencedFenceSequence\"),L(O)?H(_,U,\"whitespace\")(O):U(O)):A(O)}function U(O){return O===null||z(O)?(_.exit(\"codeFencedFence\"),$(O)):A(O)}}}function zu(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 Wn={name:\"codeIndented\",tokenize:Ou},Fu={partial:!0,tokenize:Lu};function Ou(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 c=r.events[r.events.length-1];return c&&c[1].type===\"linePrefix\"&&c[2].sliceSerialize(c[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):z(l)?e.attempt(Fu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||z(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Lu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const Bu={name:\"codeText\",previous:Hu,resolve:Vu,tokenize:qu};function Vu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Hu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function qu(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,c(f)):z(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||z(f)?(e.exit(\"codeTextData\"),u(f)):(e.consume(f),l)}function c(f){return f===96?(e.consume(f),i++,c):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(f)):(a.type=\"codeTextData\",l(f))}}class Uu{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&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 go(e){const t={};let n=-1,r,i,a,o,s,u,l;const c=new Uu(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type===\"chunkFlow\"&&c.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,ju(c,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=c.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(c.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={...c.get(i)[1].start},s=c.slice(i,n),s.unshift(r),c.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!l}function ju(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let c,f,p=-1,d=n,h=0,b=0;const x=[b];for(;d;){for(;e.get(++i)[1]!==d;);a.push(i),d._tokenizer||(c=r.sliceStream(d),d.next||c.push(null),f&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=d,d=d.next}for(d=n;++p<s.length;)s[p][0]===\"exit\"&&s[p-1][0]===\"enter\"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(b=p+1,x.push(b),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):x.pop(),p=x.length;p--;){const y=s.slice(x[p],x[p+1]),S=a.pop();u.push([S,S+y.length-1]),e.splice(S,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 Wu={resolve:Qu,tokenize:Gu},Ku={partial:!0,tokenize:Yu};function Qu(e){return go(e),e}function Gu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):z(s)?e.check(Ku,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 Yu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function mo(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let c=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||_r(y)?n(y):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),b(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\"}),d(y))}function d(y){return y===62?(e.exit(\"chunkString\"),e.exit(s),p(y)):y===null||y===60||z(y)?n(y):(e.consume(y),y===92?h:d)}function h(y){return y===60||y===62||y===92?(e.consume(y),d):d(y)}function b(y){return!c&&(y===null||y===41||le(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(y)):c<l&&y===40?(e.consume(y),c++,b):y===41?(e.consume(y),c--,b):y===null||y===32||y===40||_r(y)?n(y):(e.consume(y),y===92?x:b)}function x(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function yo(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(a),c}function c(d){return s>999||d===null||d===91||d===93&&!u||d===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(d):d===93?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):z(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),c):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===null||d===91||d===93||z(d)||s++>999?(e.exit(\"chunkString\"),c(d)):(e.consume(d),u||(u=!L(d)),d===92?p:f)}function p(d){return d===91||d===92||d===93?(e.consume(d),s++,f):f(d)}}function _o(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):z(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),c(p))}function c(p){return p===o||p===null||z(p)?(e.exit(\"chunkString\"),l(p)):(e.consume(p),p===92?f:c)}function f(p){return p===o||p===92?(e.consume(p),c):c(p)}}function Lt(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Ju={name:\"definition\",tokenize:Zu},Xu={partial:!0,tokenize:ec};function Zu(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return yo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Kt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),u):n(d)}function u(d){return le(d)?Lt(e,l)(d):l(d)}function l(d){return mo(e,c,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function c(d){return e.attempt(Xu,f,f)(d)}function f(d){return L(d)?H(e,p,\"whitespace\")(d):p(d)}function p(d){return d===null||z(d)?(e.exit(\"definition\"),r.parser.defined.push(i),t(d)):n(d)}}function ec(e,t,n){return r;function r(s){return le(s)?Lt(e,i)(s):n(s)}function i(s){return _o(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const tc={name:\"hardBreakEscape\",tokenize:nc};function nc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return z(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const rc={name:\"headingAtx\",resolve:ic,tokenize:ac};function ic(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 ac(e,t,n){let r=0;return i;function i(c){return e.enter(\"atxHeading\"),a(c)}function a(c){return e.enter(\"atxHeadingSequence\"),o(c)}function o(c){return c===35&&r++<6?(e.consume(c),o):c===null||le(c)?(e.exit(\"atxHeadingSequence\"),s(c)):n(c)}function s(c){return c===35?(e.enter(\"atxHeadingSequence\"),u(c)):c===null||z(c)?(e.exit(\"atxHeading\"),t(c)):L(c)?H(e,s,\"whitespace\")(c):(e.enter(\"atxHeadingText\"),l(c))}function u(c){return c===35?(e.consume(c),u):(e.exit(\"atxHeadingSequence\"),s(c))}function l(c){return c===null||c===35||le(c)?(e.exit(\"atxHeadingText\"),s(c)):(e.consume(c),l)}}const oc=[\"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\"],ji=[\"pre\",\"script\",\"style\",\"textarea\"],sc={concrete:!0,name:\"htmlFlow\",resolveTo:cc,tokenize:fc},lc={partial:!0,tokenize:hc},uc={partial:!0,tokenize:dc};function cc(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 fc(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return c(g)}function c(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,b):g===63?(e.consume(g),i=3,r.interrupt?t:m):$e(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function p(g){return g===45?(e.consume(g),i=2,d):g===91?(e.consume(g),i=5,s=0,h):$e(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function d(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function h(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:N:h):n(g)}function b(g){return $e(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function x(g){if(g===null||g===47||g===62||le(g)){const q=g===47,ue=o.toLowerCase();return!q&&!a&&ji.includes(ue)?(i=1,r.interrupt?t(g):N(g)):oc.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?S(g):k(g))}return g===45||ye(g)?(e.consume(g),o+=String.fromCharCode(g),x):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:N):n(g)}function S(g){return L(g)?(e.consume(g),S):v(g)}function k(g){return g===47?(e.consume(g),v):g===58||g===95||$e(g)?(e.consume(g),E):L(g)?(e.consume(g),k):v(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):k(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,$):L(g)?(e.consume(g),_):A(g)}function $(g){return g===u?(e.consume(g),u=null,D):g===null||z(g)?n(g):(e.consume(g),$)}function A(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||le(g)?I(g):(e.consume(g),A)}function D(g){return g===47||g===62||L(g)?k(g):n(g)}function v(g){return g===62?(e.consume(g),T):n(g)}function T(g){return g===null||z(g)?N(g):L(g)?(e.consume(g),T):n(g)}function N(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),R):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):z(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(lc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(uc,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),O}function O(g){return g===null||z(g)?V(g):(e.enter(\"htmlFlowData\"),N(g))}function Z(g){return g===45?(e.consume(g),m):N(g)}function X(g){return g===47?(e.consume(g),o=\"\",ge):N(g)}function ge(g){if(g===62){const q=o.toLowerCase();return ji.includes(q)?(e.consume(g),R):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),R):g===45&&i===2?(e.consume(g),m):N(g)}function R(g){return g===null||z(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),R)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function dc(e,t,n){const r=this;return i;function i(o){return z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function hc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(On,t,n)}}const pc={name:\"htmlText\",tokenize:gc};function gc(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),k):$e(m)?(e.consume(m),A):n(m)}function l(m){return m===45?(e.consume(m),c):m===91?(e.consume(m),a=0,h):$e(m)?(e.consume(m),S):n(m)}function c(m){return m===45?(e.consume(m),d):n(m)}function f(m){return m===null?n(m):m===45?(e.consume(m),p):z(m)?(o=f,X(m)):(e.consume(m),f)}function p(m){return m===45?(e.consume(m),d):f(m)}function d(m){return m===62?Z(m):m===45?p(m):f(m)}function h(m){const R=\"CDATA[\";return m===R.charCodeAt(a++)?(e.consume(m),a===R.length?b:h):n(m)}function b(m){return m===null?n(m):m===93?(e.consume(m),x):z(m)?(o=b,X(m)):(e.consume(m),b)}function x(m){return m===93?(e.consume(m),y):b(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):b(m)}function S(m){return m===null||m===62?Z(m):z(m)?(o=S,X(m)):(e.consume(m),S)}function k(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=k,X(m)):(e.consume(m),k)}function E(m){return m===62?Z(m):k(m)}function I(m){return $e(m)?(e.consume(m),_):n(m)}function _(m){return m===45||ye(m)?(e.consume(m),_):$(m)}function $(m){return z(m)?(o=$,X(m)):L(m)?(e.consume(m),$):Z(m)}function A(m){return m===45||ye(m)?(e.consume(m),A):m===47||m===62||le(m)?D(m):n(m)}function D(m){return m===47?(e.consume(m),Z):m===58||m===95||$e(m)?(e.consume(m),v):z(m)?(o=D,X(m)):L(m)?(e.consume(m),D):Z(m)}function v(m){return m===45||m===46||m===58||m===95||ye(m)?(e.consume(m),v):T(m)}function T(m){return m===61?(e.consume(m),N):z(m)?(o=T,X(m)):L(m)?(e.consume(m),T):D(m)}function N(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):z(m)?(o=N,X(m)):L(m)?(e.consume(m),N):(e.consume(m),U)}function V(m){return m===i?(e.consume(m),i=void 0,O):m===null?n(m):z(m)?(o=V,X(m)):(e.consume(m),V)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||le(m)?D(m):(e.consume(m),U)}function O(m){return m===47||m===62||le(m)?D(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function X(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),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 jr={name:\"labelEnd\",resolveAll:bc,resolveTo:vc,tokenize:wc},mc={tokenize:Sc},yc={tokenize:kc},_c={tokenize:xc};function bc(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 vc(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}},c={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\",c,t]]),s=ae(s,Fn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ae(s,[[\"exit\",c,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 wc(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(mc,c,o?c:f)(p):p===91?e.attempt(yc,c,o?l:f)(p):o?c(p):f(p)}function l(p){return e.attempt(_c,c,f)(p)}function c(p){return t(p)}function f(p){return a._balanced=!0,n(p)}}function Sc(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?c(f):mo(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function o(f){return le(f)?Lt(e,u)(f):c(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?_o(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):c(f)}function l(f){return le(f)?Lt(e,c)(f):c(f)}function c(f){return f===41?(e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(f)}}function kc(e,t,n){const r=this;return i;function i(s){return yo.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 xc(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 Cc={name:\"labelStartImage\",resolveAll:jr.resolveAll,tokenize:Ic};function Ic(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 Pc={name:\"labelStartLink\",resolveAll:jr.resolveAll,tokenize:Ec};function Ec(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 Kn={name:\"lineEnding\",tokenize:Ac};function Ac(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const yn={name:\"thematicBreak\",tokenize:$c};function $c(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||z(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:Rc},exit:zc,name:\"list\",tokenize:Nc},Dc={partial:!0,tokenize:Fc},Tc={partial:!0,tokenize:Mc};function Nc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(d){const h=r.containerState.type||(d===42||d===43||d===45?\"listUnordered\":\"listOrdered\");if(h===\"listUnordered\"?!r.containerState.marker||d===r.containerState.marker:br(d)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(yn,n,l)(d):l(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(d)}return n(d)}function u(d){return br(d)&&++o<10?(e.consume(d),u):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),l(d)):n(d)}function l(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(On,r.interrupt?n:c,e.attempt(Dc,p,f))}function c(d){return r.containerState.initialBlankLine=!0,a++,p(d)}function f(d){return L(d)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(d),e.exit(\"listItemPrefixWhitespace\"),p):n(d)}function p(d){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(d)}}function Rc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(On,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(Tc,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 Mc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function zc(e){e.exit(this.containerState.type)}function Fc(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 Wi={name:\"setextUnderline\",resolveTo:Oc,tokenize:Lc};function Oc(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 Lc(e,t,n){const r=this;let i;return a;function a(l){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!==\"lineEnding\"&&r.events[c][1].type!==\"linePrefix\"&&r.events[c][1].type!==\"content\"){f=r.events[c][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||z(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Bc={tokenize:Vc};function Vc(e){const t=this,n=e.attempt(On,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Wu,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 Hc={resolveAll:vo()},qc=bo(\"string\"),Uc=bo(\"text\");function bo(e){return{resolveAll:vo(e===\"text\"?jc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(c){return l(c)?a(c):s(c)}function s(c){if(c===null){n.consume(c);return}return n.enter(\"data\"),n.consume(c),u}function u(c){return l(c)?(n.exit(\"data\"),a(c)):(n.consume(c),u)}function l(c){if(c===null)return!0;const f=i[c];let p=-1;if(f)for(;++p<f.length;){const d=f[p];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function vo(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function jc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,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 Wc={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:fo},Kc={91:Ju},Qc={[-2]:Wn,[-1]:Wn,32:Wn},Gc={35:rc,42:yn,45:[Wi,yn],60:sc,61:Wi,95:yn,96:Ui,126:Ui},Yc={38:po,92:ho},Jc={[-5]:Kn,[-4]:Kn,[-3]:Kn,33:Cc,38:po,42:vr,60:[Pu,pc],91:Pc,92:[tc,ho],93:jr,95:vr,96:Bu},Xc={null:[vr,Hc]},Zc={null:[42,95]},ef={null:[]},tf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Zc,contentInitial:Kc,disable:ef,document:Wc,flow:Gc,flowInitial:Qc,insideSpan:Xc,string:Yc,text:Jc},Symbol.toStringTag,{value:\"Module\"}));function nf(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:$(I),check:$(_),consume:S,enter:k,exit:E,interrupt:$(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:b,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:d,write:f};let c=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function f(T){return o=ae(o,T),x(),o[o.length-1]!==null?[]:(A(t,0),l.events=Fn(a,l.events,l),l.events)}function p(T,N){return af(d(T),N)}function d(T){return rf(o,T)}function h(){const{_bufferIndex:T,_index:N,line:V,column:U,offset:O}=r;return{_bufferIndex:T,_index:N,line:V,column:U,offset:O}}function b(T){i[T.line]=T.column,v()}function x(){let T;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<N.length;)y(N.charCodeAt(r._bufferIndex));else y(N)}}function y(T){c=c(T)}function S(T){z(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,v()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=T}function k(T,N){const V=N||{};return V.type=T,V.start=h(),l.events.push([\"enter\",V,l]),s.push(V),V}function E(T){const N=s.pop();return N.end=h(),l.events.push([\"exit\",N,l]),N}function I(T,N){A(T,N.from)}function _(T,N){N.restore()}function $(T,N){return V;function V(U,O,Z){let X,ge,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):R(U);function R(te){return It;function It(qe){const dt=qe!==null&&te[qe],ht=qe!==null&&te.null,Vn=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(ht)?ht:ht?[ht]:[]];return j(Vn)(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=D(),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 T(ke,m),O}function ue(te){return m.restore(),++ge<X.length?g(X[ge]):Z}}}function A(T,N){T.resolveAll&&!a.includes(T)&&a.push(T),T.resolve&&_e(l.events,N,l.events.length-N,T.resolve(l.events.slice(N),l)),T.resolveTo&&(l.events=T.resolveTo(l.events,l))}function D(){const T=h(),N=l.previous,V=l.currentConstruct,U=l.events.length,O=Array.from(s);return{from:U,restore:Z};function Z(){r=T,l.previous=N,l.currentConstruct=V,l.events.length=U,s=O,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function rf(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 af(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 of(e){const r={constructs:au([tf,...(e||{}).extensions||[]]),content:i(vu),defined:[],document:i(Su),flow:i(Bc),lazy:{},string:i(qc),text:i(Uc)};return r;function i(a){return o;function o(s){return nf(r,a,s)}}}function sf(e){for(;!go(e););return e}const Ki=/[\\0\\t\\n\\r]/g;function lf(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,c,f,p,d;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(Ki.lastIndex=f,l=Ki.exec(a),p=l&&l.index!==void 0?l.index:a.length,d=a.charCodeAt(p),!l){t=a.slice(f);break}if(d===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),d){case 0:{u.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,u.push(-2);e++<c;)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 uf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),bu(n)(sf(of(n).document().write(lf()(e,t,!0))))}const Qn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function cf(){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=Qn[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=Qn[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,ff)),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\"+Qn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function ff(e,t){return t===\"|\"?t:e}class df{constructor(){this.map=[]}add(t,n,r){hf(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 hf(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 pf(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 gf(){return{flow:{null:{name:\"table\",tokenize:mf,resolveAll:yf}}}}function mf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let T=r.events.length-1;for(;T>-1;){const U=r.events[T][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")T--;else break}const N=T>-1?r.events[T][1].type:null,V=N===\"tableHead\"||N===\"tableRow\"?_:u;return V===_&&r.parser.lazy[r.now().line]?n(v):V(v)}function u(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(v)}function l(v){return v===124||(o=!0,a+=1),c(v)}function c(v){return v===null?n(v):z(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),d):n(v):L(v)?H(e,c,\"whitespace\")(v):(a+=1,o&&(o=!1,i+=1),v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),o=!0,c):(e.enter(\"data\"),f(v)))}function f(v){return v===null||v===124||le(v)?(e.exit(\"data\"),c(v)):(e.consume(v),v===92?p:f)}function p(v){return v===92||v===124?(e.consume(v),f):f(v)}function d(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,L(v)?H(e,h,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):h(v))}function h(v){return v===45||v===58?x(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),b):I(v)}function b(v){return L(v)?H(e,x,\"whitespace\")(v):x(v)}function x(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),y):v===45?(a+=1,y(v)):v===null||z(v)?E(v):I(v)}function y(v){return v===45?(e.enter(\"tableDelimiterFiller\"),S(v)):I(v)}function S(v){return v===45?(e.consume(v),S):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(v))}function k(v){return L(v)?H(e,E,\"whitespace\")(v):E(v)}function E(v){return v===124?h(v):v===null||z(v)?!o||i!==a?I(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):I(v)}function I(v){return n(v)}function _(v){return e.enter(\"tableRow\"),$(v)}function $(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),$):v===null||z(v)?(e.exit(\"tableRow\"),t(v)):L(v)?H(e,$,\"whitespace\")(v):(e.enter(\"data\"),A(v))}function A(v){return v===null||v===124||le(v)?(e.exit(\"data\"),$(v)):(e.consume(v),v===92?D:A)}function D(v){return v===92||v===124?(e.consume(v),A):A(v)}}function yf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,c,f;const p=new df;for(;++n<e.length;){const d=e[n],h=d[1];d[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,u!==0&&(Qi(p,t,u,l,c),c=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,c={type:\"tableBody\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",c,t]])),i=h.type===\"tableDelimiterRow\"?2:c?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&&Qi(p,t,u,l,c),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]===\"enter\"&&d[1].type===\"table\"&&(d[1]._align=pf(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]),c=gt(t.events,n[3]),f={type:s,start:Object.assign({},l),end:Object.assign({},c)};if(e.add(n[2],0,[[\"enter\",f,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const h=n[2]+1,b=n[3]-n[2]-1;e.add(h,b,[])}}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 Qi(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 _f(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function bf(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 c={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\",c,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",f,s]],d=s.parser.constructs.insideSpan.null;d&&_e(p,p.length,0,Fn(d,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\",c,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,c=this.events;let f=0;return p;function p(h){return l===126&&c[c.length-1][1].type!==\"characterEscape\"?u(h):(o.enter(\"strikethroughSequenceTemporary\"),d(h))}function d(h){const b=Dn(l);if(h===126)return f>1?u(h):(o.consume(h),f++,d);if(f<2&&!n)return u(h);const x=o.exit(\"strikethroughSequenceTemporary\"),y=Dn(h);return x._open=!y||y===2&&!!b,x._close=!b||b===2&&!!y,s(h)}}}function vf(e){return uf(e,{allowDangerousHtml:!0,extensions:[gf(),bf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[cf(),_f()]})}const wf={update:()=>{},getValues:()=>({})},Ie=Ke({}),rn=Ke(wf),fe=Ke(!1),Gi=Ke(!1),wr=Ke(null);function Sf(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)=>wo(a,o,t));return w(Y,{children:i})}function wo(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)=>wo(u,l,n));return G(i,o,...s)}return null}function kf({node:e}){const t=Hr(),n=Q(fe),r=Q(Ie),i=Q(Gi),a={};for(const[l,c]of Object.entries(e.attributes))a[l]=t(c)??c;const o=e.tag.toLowerCase()===\"svg\",s=e.children.length>0?i||o?Wr(e.children):Pe(e.children,{nobr:n,locals:r}):void 0,u=G(e.tag,a,s);return o?w(Gi.Provider,{value:!0,children:u}):u}function xf(){const e=Q(wr),t=Q(fe),n=Q(Ie);return!e||e.length===0?null:w(Y,{children:Pe(e,{nobr:t,locals:n})})}function Cf(e,t){if(nu(e.name))return null;const n=Xl(e.name);if(n)return w(Jl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=eu(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function Sr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(xf,{},t):w(zl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Cf(e,t);case\"html\":return w(kf,{node:e},t);default:return e}}function Wr(e){return e.length===0?null:e.map((t,n)=>Sr(t,n))}function If(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Pf(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)=>Sr(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\"&&If(i))i+=Pf(u,a);else{const l=r.length;r.push(Sr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=vf(i);return Sf(o,r,t?.nobr)}function Ef(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 Af(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 $f(){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 Me=\"spindle.save.\",At=\"spindle.pt.\",Ye=\"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 ze(e){localStorage.removeItem(e)}function Ze(e){return Fe(e)??[]}function Gn(e,t){const n=Ze(e);n.includes(t)||(n.push(t),Bt(e,n))}function Tt(e,t){const n=Ze(e).filter(r=>r!==t);Bt(e,n)}function Df(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;Bt(`${Me}${t}`,e),Gn(`${pt}${e.meta.ifid}`,t),Gn(`${Dt}${e.meta.playthroughId}`,t)},async getSave(e){return Fe(`${Me}${e}`)},async deleteSave(e){const t=Fe(`${Me}${e}`);t&&(Tt(`${pt}${t.meta.ifid}`,e),Tt(`${Dt}${t.meta.playthroughId}`,e)),ze(`${Me}${e}`)},async getSavesByIfid(e){const t=Ze(`${pt}${e}`),n=[];for(const r of t){const i=Fe(`${Me}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=Ze(`${pt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Tt(`${Dt}${r.meta.playthroughId}`,n),ze(`${Me}${n}`)}ze(`${pt}${e}`)},async deleteSavesByPlaythrough(e){const t=Ze(`${Dt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Tt(`${pt}${r.meta.ifid}`,n),ze(`${Me}${n}`)}return ze(`${Dt}${e}`),t},async putPlaythrough(e){Bt(`${At}${e.id}`,e),Gn(`${$t}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){const t=Ze(`${$t}${e}`),n=[];for(const r of t){const i=Fe(`${At}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=Ze(`${$t}${e}`);for(const n of t)ze(`${At}${n}`);ze(`${$t}${e}`)},async deletePlaythroughById(e){const t=Fe(`${At}${e}`);t&&Tt(`${$t}${t.ifid}`,e),ze(`${At}${e}`)},async getMeta(e){return Fe(`${Ye}${e}`)},async setMeta(e,t){Bt(`${Ye}${e}`,t)},async deleteMeta(e){ze(`${Ye}${e}`)},async deleteMetaByPrefix(e){const t=`${Ye}${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(Ye)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){const e=[];for(const t of Object.keys(localStorage))t.startsWith(Ye)&&e.push(t.slice(Ye.length));return e},async destroy(){for(const e of Object.keys(localStorage))e.startsWith(\"spindle.\")&&localStorage.removeItem(e)}}}const Yi=\"spindle\",Tf=1;function Nf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Yi,Tf);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(Yi);u.onsuccess=()=>o(),u.onerror=()=>s(u.error)})}}}let yt=null;async function Rf(){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)}),Nf()}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 Df()}catch{}return $f()}async function J(){return yt||(yt=await Rf(),yt)}function Mf(){yt=null}function Ji(){return yt?.type??\"memory\"}const So=new Map,Ln=new Map;function zf(e,t){So.set(e,t),Ln.set(t,e)}function Ff(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(Ln.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(Ff(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 et=\"__spindle_class__\",tt=\"__spindle_data__\";function rt(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),{[et]:\"__Date__\",[tt]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[et]:\"__RegExp__\",[tt]:{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,c])=>[n(l),n(c)]);return t.delete(i),{[et]:\"__Map__\",[tt]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[et]:\"__Set__\",[tt]:{entries:u}}}const a=i.constructor,o=Ln.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[et]:o,[tt]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function it(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(et in r&&tt in r){const o=r[et],s=r[tt];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const c=s.entries;return new Map(c.map(([f,p])=>[t(f),t(p)]))}if(o===\"__Set__\"){const c=s.entries;return new Set(c.map(f=>t(f)))}const u=So.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const c={};for(const f of Object.keys(s))c[f]=t(s[f]);return c}const l=Object.create(u.prototype);for(const c of Object.keys(s))l[c]=t(s[c]);return l}const i=r.constructor;if(Ln.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let kr=null,xr=null,Xi=!1;function Of(e){kr=e}function Lf(e){xr=e}function Bf(e){if(xr)try{const i=new Function(\"passage\",\"variables\",xr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(kr)try{const r=kr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function Vf(){Xi||(Xi=!0)}async function Zi(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 Hf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function ko(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Bf(n),passage:n.passage,custom:r},o=ie(n);o.variables=rt(o.variables),o.history=o.history.map(u=>({...u,variables:rt(u.variables)}));const s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function xo(e,t,n){const r=await J(),i=await r.getSave(e);if(!i)return;const a=ie(t);a.variables=rt(a.variables),a.history=a.history.map(s=>({...s,variables:rt(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 qf(e){const t=await(await J()).getSave(e);if(!t)return;const n=t.payload;return n.variables=it(n.variables),n.history=n.history.map(r=>({...r,variables:it(r.variables)})),n}async function Uf(e){await(await J()).deleteSave(e)}async function jf(e,t){const n=await J(),r=await n.getSave(e);if(!r)return;const i={...r,meta:{...r.meta,title:t,updatedAt:new Date().toISOString()}};await n.putSave(i)}async function Wf(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,c=a.get(l);c?c.push(u):a.set(l,[u])}for(const u of a.values())u.sort((l,c)=>new Date(c.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 Kf=\"autosave.\",Qf=\"slot.\",Bn=\"slotIndex.\";function an(e,t){return t!=null?`${Qf}${t}.${e}`:`${Kf}${e}`}async function Gf(e,t,n,r,i){const a=await J(),o=an(e,r),s=await a.getMeta(o);if(s){const l=await xo(s,n,i);if(l)return l}const u=await ko(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,u.meta.id),r!=null){const l=`${Bn}${e}`,c=await a.getMeta(l)??[];c.includes(r)||await a.setMeta(l,[...c,r])}return u}async function ea(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 Yf(e,t){const n=an(e,t),r=await(await J()).getMeta(n);if(r)return qf(r)}async function Cr(e){const t={};await ea(e)&&(t[\"\"]=!0);const n=`${Bn}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await ea(e,i)&&(t[i]=!0);return t}async function Ir(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 Jf(e){const t=[],n=await Ir(e);n&&t.push(n);const r=`${Bn}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await Ir(e,a);o&&t.push(o)}return t}async function Xf(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=`${Bn}${e}`,s=(await n.getMeta(a)??[]).filter(u=>u!==t);await n.setMeta(a,s)}}const Kr=\"spindle.session.\";function Zf(e,t){try{sessionStorage.setItem(`${Kr}${e}`,JSON.stringify(t))}catch{}}function ed(e){try{const t=sessionStorage.getItem(`${Kr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Af(n))return;const r=n;return r.variables=it(r.variables),r.history=r.history.map(i=>({...i,variables:it(i.variables)})),r}catch{return}}function Co(e){try{sessionStorage.removeItem(`${Kr}${e}`)}catch{}}async function td(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 nd(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 rd(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 Io(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Co(e)}async function Po(){if(await(await J()).destroy(),Mf(),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 Eo(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 Ao(){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(G(()=>Pe(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&Lf(n.content)}let $o=0,we=[],Yn=!1,ct=[],Vt=null,Ve=null;function Qr(e){const t=C.getState();try{return!!zn(e,t.variables,t.temporary)}catch{return!1}}function Do(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:Qr(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 To(e){we=we.filter(t=>t.name!==e)}function id(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();ro(n.run,r.variables,r.temporary)}n.dialog&&(ct.push({passageName:n.dialog}),Vt?.()),n.goto&&C.getState().navigate(n.goto)}}const ad=10;function od(){if(!Yn){Yn=!0;try{for(let e=0;e<ad;e++){let t=!1;const n=[...we];for(const r of n){if(!we.includes(r))continue;const i=Qr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(we=we.filter(o=>o.id!==r.id)),id(r))}if(!t)break}}finally{Yn=!1}}}function sd(){for(const e of we)e.lastResult=Qr(e.condition)}function ld(){we=[],ct=[],$o=0,Ve?.closeAll()}function ud(e){return Vt=e,ct.length>0&&e(),()=>{Vt===e&&(Vt=null)}}function cd(){return ct.shift()}function fd(){return ct.length}function dd(e){Ve?Ve.push(e):(ct.push(e),Vt?.())}function hd(){ct=[]}function pd(e){return Ve=e,()=>{Ve===e&&(Ve=null)}}function gd(){Ve?.close()}function md(){hd(),Ve?.closeAll()}function yd(){return Ve?.isOpen()??!1}wl();const _d=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let nt={},be=[],Ue={};function ta(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function na(e,t){const[,n,r]=kl(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:ta(n),inverse:ta(r)}}function bd(e){let t=nt;for(let n=0;n<e;n++)t=mt(t,be[n].forward);return t}let ve=[];function Jn(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:rt(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=nt;for(let c=0;c<i.length;c++)if(c>0&&(l=mt(l,be[c-1].forward)),c>=ve.length){const f=c===i.length-1?r:l;ve[c]={passage:i[c].passage,variables:rt(f),timestamp:i[c].timestamp,prng:i[c].prng}}}Zf(t.ifid,{passage:n,variables:rt(r),history:ve,historyIndex:a,visitCounts:o,renderCounts:s,prng:$n()})}}function ra(e){nt=e,be=[],Ue=e,ve=[]}let _n=[];function vd(e){return _n.push(e),()=>{_n=_n.filter(t=>t!==e)}}function No(){for(const e of _n)e()}function ia(e){e?.prng?Za(e.prng.seed,e.prng.pull):e&&mr()}const C=il()(Cl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=ie(r);ra(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;Vf().then(async()=>{const s=await Hf(o);if(s)e(l=>{l.playthroughId=s});else{const l=await Zi(o);e(c=>{c.playthroughId=l})}const u=await Cr(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(_d.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=na(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:$n()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)nt=mt(nt,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,Jn(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,ia(t().history[t().historyIndex]),Jn(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,ia(t().history[t().historyIndex]),Jn(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;mr(),ld();const a=ie(r);ra(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},o.renderDeferred=!1}),Ue=t().variables,Ao(),Co(n.ifid),No(),Zi(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}),Gf(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}),Yf(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?Ir(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?Jf(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&Xf(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&&Io(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&&Po().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&&Eo(r.ifid,n).then(async()=>{const i=await Cr(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=nt;for(let c=0;c<i.length;c++)c>0&&(l=mt(l,be[c-1].forward)),u.push({passage:i[c].passage,variables:ie(l),timestamp:i[c].timestamp,prng:i[c].prng});return{passage:n,variables:ie(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:$n()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=it(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=it(n.history[o].variables);i.push(na(a,s)),a=s}nt=ie(r),be=i,ve=[],e(o=>{o.currentPassage=n.passage,o.variables=it(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?Za(n.prng.seed,n.prng.pull):mr()},getHistoryVariables:n=>ie(bd(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n},deferRender:()=>{e(n=>{n.renderDeferred=!0})},clearDeferredRender:()=>{e(n=>{n.renderDeferred=!1})}}))),wd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Sd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:wd,r=t?.tags.includes(\"nobr\")??!1,i=he(()=>{try{const a=kt(n),o=xt(a);return w(Y,{children:Wr(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(fe.Provider,{value:!0,children:i}):i}const Ro=Ke(null);function Gr({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(d=>d.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,c=he(()=>{if(!l)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const d=kt(l),h=xt(d);return Pe(h)}catch(d){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",d instanceof Error?d.message:String(d)]})}},[l]),f=d=>{d.target.classList.contains(\"dialog-overlay\")&&o()},p=n?`dialog-panel ${n}`:\"dialog-panel\";return w(Ro.Provider,{value:o,children:w(\"div\",{class:\"dialog-overlay\",onClick:f,children:w(\"div\",{class:p,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:c})]})})})}function kd(){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(()=>pd({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Se(()=>ud(()=>{const o=[];for(;fd()>0;){const s=cd();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(Y,{children:e.map((o,s)=>w(Gr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function xd(){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 w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(Y,{children:[w(Sd,{}),w(kd,{})]});return n?w(fe.Provider,{value:!0,children:r}):r}function Cd(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Id(){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||\"\",c=new Map,f=new Map;for(const p of e.querySelectorAll(\"tw-passagedata\")){const d=parseInt(p.getAttribute(\"pid\")||\"0\",10),h=p.getAttribute(\"name\")||\"\",b=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),x=Cd(p.innerHTML),y={},S=new Set([\"pid\",\"name\",\"tags\"]);for(const E of p.attributes)S.has(E.name)||(y[E.name]=E.value);const k={pid:d,name:h,tags:b,metadata:y,content:x};c.set(h,k),f.set(d,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:f,userCSS:s,userScript:l}}const Nt=new Map;let ce={},aa=!1;function Mo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Pd(){localStorage.setItem(Mo(),JSON.stringify(ce))}function Xn(){if(!aa){aa=!0;try{const e=localStorage.getItem(Mo());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),Xn()},addList(e,t){Nt.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),Xn()},addRange(e,t){Nt.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),Xn()},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,Pd()},getAll(){return{...ce}},getDefinitions(){return Nt},hasAny(){return Nt.size>0}};function Ed(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};ro(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 Tn=new Map,Pr=new Set,Er=new Map;function Ad(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Er.get(r)??0)+1;return Er.set(r,i),i===1?r:`${r}:${i}`}function $d(e){return Tn.set(e.id,e),sa(),()=>{Tn.delete(e.id),sa()}}function oa(){return Array.from(Tn.values())}function Dd(e){return Tn.get(e)}function Td(){Er.clear()}function Nd(e){return Pr.add(e),()=>{Pr.delete(e)}}function sa(){for(const e of Pr)e()}function Rd(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=Ad(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),$d(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Md(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function zo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Yr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?zo(t):\"\"}function zd(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 Fd(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 Od(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Ld={useState:ee,useRef:se,useEffect:Se,useLayoutEffect:ut,useCallback:pe,useMemo:he,useContext:Q};function la(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function Bd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=Hr(),a=s(a),o=s(o));const{update:u,getValues:l}=Q(rn),c=Q(fe),f=Q(Ie),d={collectText:Md,sourceLocation:Yr,parseVarArgs:zd,extractOptions:Fd,h:G,renderNodes:(h,b)=>Pe(h,{nobr:c,locals:f,...b}),renderInlineNodes:Wr,hooks:Ld,useAction:Rd,className:a,id:o,resolve:s,cls:Od(e.name,a),mutate:h=>Ed(h,l(),u),update:u,getValues:l,wrap:h=>a||o?G(\"span\",{id:o,class:a},h):G(Y,null,h)};if(e.merged){d.merged=Vr();const h=d.merged;d.evaluate=b=>zn(b,h[0],h[1],h[2])}if(e.storeVar){const b=(i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),x=b.split(\".\");d.varName=b,d.value=C(y=>la(y.variables,x)),d.getValue=()=>la(C.getState().variables,x),d.setValue=y=>{C.setState(S=>{Bd(S.variables,x,y)})}}return e.render(i,d)}Zl(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(ru(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)tu(i);r&&gr(e.name)}let dn=null,Ar=null;function Vd(){return Ar}function Hd(){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){zf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return iu()},saves:{setTitleGenerator(e){Of(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?rd(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Ji()}},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 Io(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await Po(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await Eo(t.ifid,e);const n=await Cr(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return Ji()}},getActions(){return oa()},performAction(e,t){const n=Dd(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===\"storyinit\")return vd(t);if(e===\"actionsChanged\")return Nd(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(oa())})})})},watch(e,t){return Do(e,t)},unwatch(e){To(e)},openDialog(e,t){dd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){gd()},closeAllDialogs(){md()},isDialogOpen(){return yd()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Ar=new Promise(e=>{dn=e})},ready(){dn&&(C.getState().clearDeferredRender(),dn(),dn=null,Ar=null)},random(){return qr()},randomInt(e,t){return eo(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){Fl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=$n())})},isEnabled(){return Ol()},get seed(){return Ll()},get pull(){return Bl()}}}}function qd(){window.Story=Hd()}const Ud=/^\\$(\\w+)\\s*=\\s*(.+)$/,ua=/\\$(\\w+(?:\\.\\w+)*)/g,ca=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,jd=new Set([\"number\",\"string\",\"boolean\"]);function Fo(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,Fo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!jd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Wd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Ud);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=Fo(s);t.set(a,{...u,name:a,default:s})}return t}function Kd(e){const t=new Set;let n;for(ca.lastIndex=0;(n=ca.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Qd(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 Gd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Kd(i.content);let o;for(ua.lastIndex=0;(o=ua.exec(i.content))!==null;){const s=o[1],u=Qd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Yd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function bn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&bn(t.children))return!0;if(t.type===\"macro\"){if(bn(t.children))return!0;if(t.branches){for(const n of t.branches)if(bn(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 w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Yr()}: ${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 w(We,{macro:\"print\",error:n})}}});function Jd(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 Xd(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 fa(e,t,n,r,i,a,o){let s;try{s=zn(e,r,i,a)}catch(l){console.error(`spindle: Error in {computed ${o}}${Yr()}:`,l);return}const u=n?i[t]:r[t];if(!Xd(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}=Jd(e))}catch(c){return w(We,{macro:\"computed\",error:c})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,fa(o,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{fa(o,u,s,n,r,i,e)},[n,r,i]),null}});function Zd(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=eh(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 eh(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 th(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}=Zd(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=th(a,o,i),l=t.cls;return w(\"div\",{class:l,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&w(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return w(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?w(\"span\",{id:o,class:a,children:i}):w(Y,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return w(We,{macro:\"if\",error:i})}}return null}});function nh(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 rh({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,d)=>{a(h=>({...h,[p]:d}))},[]),c=he(()=>({update:l,getValues:u}),[l,u]),f=Q(fe);return w(rn.Provider,{value:c,children:w(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=Q(Ie);let i;try{i=nh(e)}catch(c){return w(We,{macro:\"for\",error:c})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const c=n.evaluate(s);if(!Array.isArray(c))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=c}catch(c){return w(We,{macro:\"for\",error:c})}const l=u.map((c,f)=>{const p={[a]:c,...o?{[o]:f}:void 0};return w(rh,{parentValues:r,ownKeys:p,initialValues:{},children:t},`${f}-${JSON.stringify(c)}`)});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=Q(fe),a=()=>{const o=document.createElement(\"div\"),s=G(fe.Provider,{value:i},G(rn.Provider,{value:{update:n.update,getValues:n.getValues}},G(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}),w(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function ih(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 da(e,t,n,r){const i=document.createElement(\"div\"),a=G(fe.Provider,{value:r},G(rn.Provider,{value:{update:n,getValues:t}},G(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}=ih(e),a=Q(fe),o=s=>{s.preventDefault(),da(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:()=>{da(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});B({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(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 w(Y,{children:n.renderNodes(o.children)})}catch(s){return w(We,{macro:\"case\",error:s})}}return i?w(Y,{children:n.renderNodes(i.children)}):null}});function Jr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}B({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(d=>({delay:d.rawArgs?Jr(d.rawArgs):0,nodes:d.children,className:d.className,id:d.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const d=o+1,h=a[d].delay,b=setTimeout(()=>{s(d)},h);return()=>clearTimeout(b)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),c=t.resolve(u.className),f=t.resolve(u.id),p=c||f?w(\"span\",{id:f,class:c,children:l}):l;return t.wrap(p)}});const Oo=Ke({stop:()=>{}});B({name:\"repeat\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Jr(e),[s,u]=r(0),[l,c]=r(!1),f=a(()=>c(!0),[]);if(i(()=>{if(l)return;const d=setInterval(()=>{u(h=>h+1)},o);return()=>clearInterval(d)},[o,l]),s===0&&!l)return null;const p=w(Oo.Provider,{value:{stop:f},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:p}):p}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Oo);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=Jr(e),s=a(null),[u,l]=r(0),[c,f]=r(0),p=a(0);p.current=c,i(()=>{if(s.current){const b=s.current.textContent||\"\";l(b.length)}},[]),i(()=>{if(u===0||p.current>=u)return;const b=setInterval(()=>{f(x=>x>=u?(clearInterval(b),x):x+1)},o);return()=>clearInterval(b)},[u,o]);const d=c>=u&&u>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!d,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!d?`inset(0 ${(u-c)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&u>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function ah(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}=ah(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{ao(r,t,i)},[r,a,o]),null}});B({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function 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}),w(Y,{children:[w(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Gr,{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 w(Y,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Gr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function oh(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 sh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function lh(){const[e,t]=ee(\"load\"),[n,r]=ee([]),[i,a]=ee(!0),[o,s]=ee(null),[u,l]=ee(()=>new Set),[c,f]=ee(null),[p,d]=ee(\"\"),h=se(null),b=se(null),x=Q(Ro),y=C(R=>R.storyData),S=C(R=>R.playthroughId),k=C(R=>R.getSavePayload),E=C(R=>R.loadFromPayload),I=y?.ifid??\"\",_=pe(async()=>{if(!I)return;const R=await Wf(I);r(R),a(!1)},[I]);Se(()=>{_()},[_]),Se(()=>{c&&h.current&&(h.current.focus(),h.current.select())},[c]);const $=se(),A=(R,j=\"success\")=>{clearTimeout($.current),s({text:R,type:j}),$.current=window.setTimeout(()=>s(null),3e3)};Se(()=>()=>clearTimeout($.current),[]);const D=R=>{l(j=>{const g=new Set(j);return g.has(R)?g.delete(R):g.add(R),g})},v=async()=>{if(!(!I||!S))try{const R=k();await ko(I,S,R),A(\"Save created\"),await _()}catch{A(\"Failed to create save\",\"error\")}},T=async R=>{try{const j=k();await xo(R,j),A(\"Save overwritten\"),await _()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async R=>{try{E(R.payload),A(\"Game loaded\"),x&&setTimeout(x,500)}catch{A(\"Failed to load save\",\"error\")}},V=async R=>{if(confirm(\"Delete this save?\"))try{await Uf(R),A(\"Save deleted\"),await _()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{f(R.meta.id),d(R.meta.title)},O=async()=>{if(!(!c||!p.trim()))try{await jf(c,p.trim()),f(null),A(\"Save renamed\"),await _()}catch{A(\"Failed to rename\",\"error\")}},Z=R=>{R.key===\"Enter\"?O():R.key===\"Escape\"&&f(null)},X=async R=>{try{const j=await td(R);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),ue=document.createElement(\"a\");ue.href=q,ue.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ue.click(),URL.revokeObjectURL(q),A(\"Save exported\")}catch{A(\"Failed to export save\",\"error\")}},ge=()=>{b.current?.click()},ke=async R=>{const j=R.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),ue=JSON.parse(q);if(!Ef(ue))throw new Error(\"Invalid save file format\");await nd(ue,I),A(\"Save imported\"),await _()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((R,j)=>R+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:ge,children:\"Import\"}),w(\"input\",{ref:b,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(R=>{const j=u.has(R.playthrough.id),g=R.playthrough.id===S;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>D(R.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[R.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:sh(R.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[R.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[c===q.meta.id?w(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>d(ue.target.value),onKeyDown:Z,onBlur:O}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:oh(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>T(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>X(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},R.playthrough.id)}),e===\"save\"&&!i&&!n.some(R=>R.playthrough.id===S)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return w(lh,{})}});function uh({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 w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function ch(){const e=Qt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(uh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(ch,{})}});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 w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=kt(o.content),l=xt(u),c=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(fe.Provider,{value:!0},c)):t.wrap(c)}});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):\"\")}),w(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});B({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),w(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});B({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function fh(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=fh(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function dh(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}=dh(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Mt(e){const t=kt(e.content),n=xt(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const hh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function ph({passage:e,dataTransition:t}){const n=C(b=>b.storyData),r=hh.has(e.name),[i,a]=ee(!1),o=he(()=>{try{return Mt(e)}catch(b){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",zo(e),\":\",\" \",b instanceof Error?b.message:String(b)]})}},[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\"),c=he(()=>{if(!s)return null;try{return Mt(s)}catch(b){return console.error(\"spindle: Error in PassageHeader:\",b),null}},[s?.content]),f=he(()=>{if(!u)return null;try{return Mt(u)}catch(b){return console.error(\"spindle: Error in PassageFooter:\",b),null}},[u?.content]);Se(()=>(l&&a(!0),()=>a(!1)),[e.name]);const p=he(()=>{if(!i||!l)return null;try{return Mt(l)}catch(b){return console.error(\"spindle: Error in PassageDone:\",b),null}},[i,l?.content]),d=e.tags.includes(\"nobr\"),h=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[c&&w(\"div\",{class:\"passage-header\",children:c}),o,f&&w(\"div\",{class:\"passage-footer\",children:f}),p&&w(\"div\",{hidden:!0,children:p})]});return d?w(fe.Provider,{value:!0,children:h}):h}const gh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),$r={type:\"fade-through\",duration:300,pause:50};function mh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!gh.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 Zn(e){return{type:e.type,duration:e.duration??$r.duration,pause:e.pause??$r.pause}}function yh(e,t,n){const r=mh(e);return r?Zn(r):t?Zn(t):n?Zn(n):{...$r}}function ha(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 er(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 tr(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(h=>h.currentPassage),r=C(h=>h.storyData),i=C(h=>h.renderDeferred),[a,o]=ee(n),s=se(\"fade\"),u=se(0),l=se(null),c=se([]),f=pe(()=>{for(const h of c.current)clearTimeout(h);c.current=[],tr(l.current)},[]);Se(()=>{const h=C.getState(),{history:b,historyIndex:x,transitionConfig:y}=h,S=h.consumeNextTransition(),k=u.current;u.current=b.length;const E=!a,I=b.length===1&&x===0&&k>1,_=b.length>1&&x===b.length-1&&k>1&&Math.abs(b.length-k)>1;if(n===a)return;f();const $=r?.passages.get(n);if(!$){s.current=\"none\",o(n);return}if(E||I||_){s.current=\"fade\",o(n);return}const A=yh($.tags,S,y);s.current=A.type;const D=l.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){D&&er(D,A),o(n);return}if(A.type===\"fade-through\"){if(!D){o(n);return}er(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ha(v,A.type);D.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{tr(D)},U);c.current=[V,O];return}if(A.type===\"crossfade\"){if(!D){o(n);return}er(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ha(v,A.type);D.classList.add(\"passage-container--crossfading\"),D.appendChild(T),o(n);const N=setTimeout(()=>{tr(D)},A.duration);c.current=[N];return}o(n)},[n]);const p=i?r?.passages.get(\"StoryLoading\")??null:a?r?.passages.get(a):null;if(!p&&a&&!i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",a,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[!i&&d&&w(\"div\",{hidden:!0,children:Mt(d)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:l,children:p&&w(ph,{passage:p,dataTransition:i?\"none\":s.current},i?\"loading\":a)})]})}});B({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},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 c=n.useRef(!1);return c.current||(c.current=!0,Do(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,To(r)),null}});const _h='*,*: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 pa(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 ga(){const e=Id(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=_h,document.head.appendChild(t),qd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",b=document.getElementById(\"root\");throw b&&pa(b,[h]),new Error(`spindle: ${h}`)}const i=Wd(r.content),a=Gd(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&pa(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=Yd(i),C.getState().init(e,n),Ao();const o=ed(e.ifid);o&&C.getState().loadFromPayload(o),No();const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){let b;for(;(b=s.exec(h.content))!==null;){const x=b[1],y=b[2];/\\{@children\\}/.test(y)&&gr(x)}s.lastIndex=0}for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const b=kt(h.content),x=xt(b);for(const y of x)if(y.type===\"macro\"&&y.name===\"widget\"&&y.rawArgs){const S=y.rawArgs.trim().split(/\\s+/),k=S[0].replace(/[\"']/g,\"\"),E=S.slice(1).filter($=>$.startsWith(\"$\")||$.startsWith(\"_\")||$.startsWith(\"@\")),I=y.children,_=bn(I);ao(k,I,E,_),_&&gr(k)}}let u=\"\";C.subscribe(h=>{h.currentPassage!==u&&(u=h.currentPassage,Td())});let l=C.getState().variables,c=C.getState().historyIndex;C.subscribe(h=>{h.variables!==l&&(h.historyIndex===c?od():sd()),l=h.variables,c=h.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(w(xd,{}),p);const d=Vd();d?d.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ga):ga();</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.38.1","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Jt,F,ya,Je,si,_a,ba,va,Nr,ir,ar,wa,Sn={},kn=[],hs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Xt=Array.isArray;function De(e,t){for(var n in t)e[n]=t[n];return e}function Mr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Y(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Jt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ot(e,o,r,i,null)}function Ot(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??++ya,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function ps(){return{current:null}}function G(e){return e.children}function Te(e,t){this.props=e,this.context=t}function bt(e,t){if(t==null)return e.__?bt(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\"?bt(e):null}function gs(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),Rr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??bt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Ca(r,a,i),t.__e=t.__=null,a.__e!=n&&Sa(a)}}function Sa(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Sa(e)}function or(e){(!e.__d&&(e.__d=!0)&&Je.push(e)&&!xn.__r++||si!=F.debounceRendering)&&((si=F.debounceRendering)||_a)(xn)}function xn(){for(var e,t=1;Je.length;)Je.length>t&&Je.sort(ba),e=Je.shift(),t=Je.length,gs(e);xn.__r=0}function ka(e,t,n,r,i,a,o,s,l,u,f){var c,p,d,h,y,k,_,S=r&&r.__k||kn,x=t.length;for(l=ms(n,t,S,l,x),c=0;c<x;c++)(d=n.__k[c])!=null&&(p=d.__i!=-1&&S[d.__i]||Sn,d.__i=c,k=Rr(e,d,p,i,a,o,s,l,u,f),h=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&zr(p.ref,null,d),f.push(d.ref,d.__c||h,d)),y==null&&h!=null&&(y=h),(_=!!(4&d.__u))||p.__k===d.__k?l=xa(d,l,e,_):typeof d.type==\"function\"&&k!==void 0?l=k:h&&(l=h.nextSibling),d.__u&=-7);return n.__e=y,l}function ms(e,t,n,r,i){var a,o,s,l,u,f=n.length,c=f,p=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=Ot(null,o,null,null,null):Xt(o)?o=e.__k[a]=Ot(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ot(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+p,o.__=e,o.__b=e.__b+1,s=null,(u=o.__i=ys(o,n,l,c))!=-1&&(c--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>f?p--:i<f&&p++),typeof o.type!=\"function\"&&(o.__u|=4)):u!=l&&(u==l-1?p--:u==l+1?p++:(u>l?p--:p++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=bt(s)),Pa(s,s));return r}function xa(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=xa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=bt(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\"||(Xt(e)?e.some(function(n){Be(n,t)}):t.push(e)),t}function ys(e,t,n,r){var i,a,o,s=e.key,l=e.type,u=t[n],f=u!=null&&(2&u.__u)==0;if(u===null&&s==null||f&&s==u.key&&l==u.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((u=t[o=i>=0?i--:a++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return o}return-1}function li(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||hs.test(t)?n:n+\"px\"}function ln(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||li(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||li(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(va,\"$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=Nr,e.addEventListener(t,a?ar:ir,a)):e.removeEventListener(t,a?ar:ir,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function ui(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Nr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function Rr(e,t,n,r,i,a,o,s,l,u){var f,c,p,d,h,y,k,_,S,x,E,I,b,$,A,D=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=F.__b)&&f(t);e:if(typeof D==\"function\")try{if(_=t.props,S=\"prototype\"in D&&D.prototype.render,x=(f=D.contextType)&&r[f.__c],E=f?x?x.props.value:f.__:r,n.__c?k=(c=t.__c=n.__c).__=c.__E:(S?t.__c=c=new D(_,E):(t.__c=c=new Te(_,E),c.constructor=D,c.render=bs),x&&x.sub(c),c.state||(c.state={}),c.__n=r,p=c.__d=!0,c.__h=[],c._sb=[]),S&&c.__s==null&&(c.__s=c.state),S&&D.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=De({},c.__s)),De(c.__s,D.getDerivedStateFromProps(_,c.__s))),d=c.props,h=c.state,c.__v=t,p)S&&D.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),S&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(S&&D.getDerivedStateFromProps==null&&_!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,E),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,E)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(v){v&&(v.__=t)}),kn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),S&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,h,y)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=F.__r,b=0,S)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),kn.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++b<25);c.state=c.__s,c.getChildContext!=null&&(r=De(De({},r),c.getChildContext())),S&&!p&&c.getSnapshotBeforeUpdate!=null&&(y=c.getSnapshotBeforeUpdate(d,h)),$=f!=null&&f.type===G&&f.key==null?Ia(f.props.children):f,s=ka(e,Xt($)?$:[$],t,n,r,i,a,o,s,l,u),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),k&&(c.__E=c.__=null)}catch(v){if(t.__v=null,l||a!=null)if(v.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(A=a.length;A--;)Mr(a[A]);sr(t)}else t.__e=n.__e,t.__k=n.__k,v.then||sr(t);F.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=_s(n.__e,t,n,r,i,a,o,l,u);return(f=F.diffed)&&f(t),128&t.__u?void 0:s}function sr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(sr))}function Ca(e,t,n){for(var r=0;r<n.length;r++)zr(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 Ia(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Xt(e)?e.map(Ia):De({},e)}function _s(e,t,n,r,i,a,o,s,l){var u,f,c,p,d,h,y,k=n.props||Sn,_=t.props,S=t.type;if(S==\"svg\"?i=\"http://www.w3.org/2000/svg\":S==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(u=0;u<a.length;u++)if((d=a[u])&&\"setAttribute\"in d==!!S&&(S?d.localName==S:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(S==null)return document.createTextNode(_);e=document.createElementNS(i,S,_.is&&_),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(S==null)k===_||s&&e.data==_||(e.data=_);else{if(a=a&&Jt.call(e.childNodes),!s&&a!=null)for(k={},u=0;u<e.attributes.length;u++)k[(d=e.attributes[u]).name]=d.value;for(u in k)d=k[u],u==\"dangerouslySetInnerHTML\"?c=d:u==\"children\"||u in _||u==\"value\"&&\"defaultValue\"in _||u==\"checked\"&&\"defaultChecked\"in _||ln(e,u,null,d,i);for(u in _)d=_[u],u==\"children\"?p=d:u==\"dangerouslySetInnerHTML\"?f=d:u==\"value\"?h=d:u==\"checked\"?y=d:s&&typeof d!=\"function\"||k[u]===d||ln(e,u,d,k[u],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ka(t.type==\"template\"?e.content:e,Xt(p)?p:[p],t,n,r,S==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&bt(n,0),s,l),a!=null)for(u=a.length;u--;)Mr(a[u]);s||(u=\"value\",S==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[u]||S==\"progress\"&&!h||S==\"option\"&&h!=k[u])&&ln(e,u,h,k[u],i),u=\"checked\",y!=null&&y!=e[u]&&ln(e,u,y,k[u],i))}return e}function zr(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 Pa(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||zr(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]&&Pa(r[i],t,n||typeof e.type!=\"function\");n||Mr(e.__e),e.__c=e.__=e.__e=void 0}function bs(e,t,n){return this.constructor(e,n)}function Ie(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=[],Rr(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||Sn,Sn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Jt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Ca(a,e,o)}function Ea(e,t){Ie(e,t,Ea)}function vs(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?Jt.call(arguments,2):n),Ot(e.type,s,r||e.key,i||e.ref,null)}function Ke(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,or(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+wa++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Jt=kn.slice,F={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},ya=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),or(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),or(this))},Te.prototype.render=G,Je=[],_a=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ba=function(e,t){return e.__v.__b-t.__v.__b},xn.__r=0,va=/(PointerCapture)$|Capture$/i,Nr=0,ir=ui(!1),ar=ui(!0),wa=0;var ws=0;function w(e,t,n,r,i,a){t||(t={});var o,s,l=t;if(\"ref\"in l)for(s in l={},t)s==\"ref\"?o=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ws,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return F.vnode&&F.vnode(u),u}var je,W,Un,ci,vt=0,Aa=[],K=F,fi=K.__b,di=K.__r,hi=K.diffed,pi=K.__c,gi=K.unmount,mi=K.__;function kt(e,t){K.__h&&K.__h(W,e,vt||t),vt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ee(e){return vt=1,Fr(Na,e)}function Fr(e,t,n){var r=kt(je++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Na(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(p){return p.__c});if(f.every(function(p){return!p.__N}))return!a||a.call(this,s,l,u);var c=r.__c.props!==s;return f.some(function(p){if(p.__N){var d=p.__[0];p.__=p.__N,p.__N=void 0,d!==p.__[0]&&(c=!0)}}),a&&a.call(this,s,l,u)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,l,u){if(this.__e){var f=a;a=void 0,i(s,l,u),a=f}o&&o.call(this,s,l,u)},W.shouldComponentUpdate=i}return r.__N||r.__}function Se(e,t){var n=kt(je++,3);!K.__s&&Or(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ut(e,t){var n=kt(je++,4);!K.__s&&Or(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return vt=5,he(function(){return{current:e}},[])}function $a(e,t,n){vt=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=kt(je++,7);return Or(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function pe(e,t){return vt=8,he(function(){return e},t)}function Q(e){var t=W.context[e.__c],n=kt(je++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Da(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Ta(){var e=kt(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 Ss(){for(var e;e=Aa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(gn),t.__h.some(lr),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,fi&&fi(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),mi&&mi(e,t)},K.__r=function(e){di&&di(e),je=0;var t=(W=e.__c).__H;t&&(Un===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(gn),t.__h.some(lr),t.__h=[],je=0)),Un=W},K.diffed=function(e){hi&&hi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Aa.push(t)!==1&&ci===K.requestAnimationFrame||((ci=K.requestAnimationFrame)||ks)(Ss)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Un=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(gn),n.__h=n.__h.filter(function(r){return!r.__||lr(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),pi&&pi(e,t)},K.unmount=function(e){gi&&gi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{gn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var yi=typeof requestAnimationFrame==\"function\";function ks(e){var t,n=function(){clearTimeout(r),yi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);yi&&(t=requestAnimationFrame(n))}function gn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function lr(e){var t=W;e.__c=e.__(),W=t}function Or(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Na(e,t){return typeof t==\"function\"?t(e):t}const _i=e=>{let t;const n=new Set,r=(u,f)=>{const c=typeof u==\"function\"?u(t):u;if(!Object.is(c,t)){const p=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(d=>d(t,p))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,i,s);return s},xs=(e=>e?_i(e):_i);function Ma(e,t){for(var n in t)e[n]=t[n];return e}function ur(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function Ra(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,jn(i)&&a({t:i})},[e,n,t]),Se(function(){return jn(i)&&a({t:i}),e(function(){jn(i)&&a({t:i})})},[e]),n}function jn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function za(e){e()}function Fa(e){return e}function Oa(){return[!1,za]}var La=ut;function cr(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:ur(this.props,i)}function r(i){return this.shouldComponentUpdate=n,Y(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(cr.prototype=new Te).isPureReactComponent=!0,cr.prototype.shouldComponentUpdate=function(e,t){return ur(this.props,e)||ur(this.state,t)};var bi=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),bi&&bi(e)};var Is=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Ps(e){function t(n){var r=Ma({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Is,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var vi=function(e,t){return e==null?null:Be(Be(e).map(t))},Es={map:vi,forEach:vi,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},As=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)}As(e,t,n,r)};var wi=F.unmount;function Ba(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=Ma({},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 Ba(r,t,n)})),e}function Va(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Va(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 mn(){this.__u=0,this.o=null,this.__b=null}function Ha(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function $s(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?Y(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function zt(){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),wi&&wi(e)},(mn.prototype=new Te).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ha(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(l):l())};n.__R=o;var s=n.__P;n.__P=null;var l=function(){if(!--r.__u){if(r.state.__a){var u=r.state.__a;r.__v.__k[0]=Va(u,u.__c.__P,u.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=s,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},mn.prototype.componentWillUnmount=function(){this.o=[]},mn.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]=Ba(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Y(G,null,e.fallback);return i&&(i.__u&=-33),[Y(G,null,t.__a?null:e.children),i]};var Si=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 Ds(e){return this.getChildContext=function(){return e.context},e.children}function Ts(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ie(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)}}}Ie(Y(Ds,{context:t.context},e.__v),t.v)}function Ns(e,t){var n=Y(Ts,{__v:e,h:t});return n.containerInfo=t,n}(zt.prototype=new Te).__a=function(e){var t=this,n=Ha(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Si(t,e,r)):i()};n?n(a):a()}},zt.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},zt.prototype.componentDidUpdate=zt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Si(e,n,t)})};var qa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ms=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Rs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,zs=/[A-Z0-9]/g,Fs=typeof document<\"u\",Os=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ls(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ie(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Bs(e,t,n){return Ea(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 ki=F.event;function Vs(){}function Hs(){return this.cancelBubble}function qs(){return this.defaultPrevented}F.event=function(e){return ki&&(e=ki(e)),e.persist=Vs,e.isPropagationStopped=Hs,e.isDefaultPrevented=qs,e.nativeEvent=e};var Lr,Us={enumerable:!1,configurable:!0,get:function(){return this.class}},xi=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||Fs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var l=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":l===\"translate\"&&s===\"no\"?s=!1:l[0]===\"o\"&&l[1]===\"n\"?l===\"ondoubleclick\"?o=\"ondblclick\":l!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Os(n.type)?l===\"onfocus\"?o=\"onfocusin\":l===\"onblur\"?o=\"onfocusout\":Rs.test(o)&&(o=l):l=o=\"oninput\":a&&Ms.test(o)?o=o.replace(zs,\"-$&\").toLowerCase():s===null&&(s=void 0),l===\"oninput\"&&i[o=l]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Be(n.children).forEach(function(u){u.props.selected=i.value.indexOf(u.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Be(n.children).forEach(function(u){u.props.selected=i.multiple?i.defaultValue.indexOf(u.props.value)!=-1:i.defaultValue==u.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Us)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=qa,xi&&xi(e)};var Ci=F.__r;F.__r=function(e){Ci&&Ci(e),Lr=e.__c};var Ii=F.diffed;F.diffed=function(e){Ii&&Ii(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),Lr=null};var js={ReactCurrentDispatcher:{current:{readContext:function(e){return Lr.__n[e.__c].props.value},useCallback:pe,useContext:Q,useDebugValue:Da,useDeferredValue:Fa,useEffect:Se,useId:Ta,useImperativeHandle:$a,useInsertionEffect:La,useLayoutEffect:ut,useMemo:he,useReducer:Fr,useRef:se,useState:ee,useSyncExternalStore:Ra,useTransition:Oa}}};function Ws(e){return Y.bind(null,e)}function Rn(e){return!!e&&e.$$typeof===qa}function Ks(e){return Rn(e)&&e.type===G}function Qs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Gs(e){return Rn(e)?vs.apply(null,arguments):e}function Ys(e){return!!e.__k&&(Ie(null,e),!0)}function Js(e){return e&&(e.base||e.nodeType===1&&e)||null}var Xs=function(e,t){return e(t)},Zs=function(e,t){return e(t)},el=G,tl=Rn,un={useState:ee,useId:Ta,useReducer:Fr,useEffect:Se,useLayoutEffect:ut,useInsertionEffect:La,useTransition:Oa,useDeferredValue:Fa,useSyncExternalStore:Ra,startTransition:za,useRef:se,useImperativeHandle:$a,useMemo:he,useCallback:pe,useContext:Q,useDebugValue:Da,version:\"18.3.1\",Children:Es,render:Ls,hydrate:Bs,unmountComponentAtNode:Ys,createPortal:Ns,createElement:Y,createContext:Ke,createFactory:Ws,cloneElement:Gs,createRef:ps,Fragment:G,isValidElement:Rn,isElement:tl,isFragment:Ks,isMemo:Qs,findDOMNode:Js,Component:Te,PureComponent:cr,memo:Cs,forwardRef:Ps,flushSync:Zs,unstable_batchedUpdates:Xs,StrictMode:el,Suspense:mn,SuspenseList:zt,lazy:$s,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:js};const nl=e=>e;function rl(e,t=nl){const n=un.useSyncExternalStore(e.subscribe,un.useCallback(()=>t(e.getState()),[e,t]),un.useCallback(()=>t(e.getInitialState()),[e,t]));return un.useDebugValue(n),n}const il=e=>{const t=xs(e),n=r=>rl(t,r);return Object.assign(n,t),n},al=(e=>il);var Br=Symbol.for(\"immer-nothing\"),Lt=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,at=me.getPrototypeOf,Ut=\"constructor\",Zt=\"prototype\",fr=\"configurable\",Cn=\"enumerable\",yn=\"writable\",jt=\"value\",He=e=>!!e&&!!e[ne];function Ne(e){return e?Ua(e)||tn(e)||!!e[Lt]||!!e[Ut]?.[Lt]||nn(e)||rn(e):!1}var ol=me[Zt][Ut].toString(),Pi=new WeakMap;function Ua(e){if(!e||!wt(e))return!1;const t=at(e);if(t===null||t===me[Zt])return!0;const n=me.hasOwnProperty.call(t,Ut)&&t[Ut];if(n===Object)return!0;if(!Xe(n))return!1;let r=Pi.get(n);return r===void 0&&(r=Function.toString.call(n),Pi.set(n,r)),r===ol}function en(e,t,n=!0){ot(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 ot(e){const t=e[ne];return t?t.type_:tn(e)?1:nn(e)?2:rn(e)?3:0}var Bt=(e,t,n=ot(e))=>n===2?e.has(t):me[Zt].hasOwnProperty.call(e,t),Oe=(e,t,n=ot(e))=>n===2?e.get(t):e[t],In=(e,t,n,r=ot(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function sl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var tn=Array.isArray,nn=e=>e instanceof Map,rn=e=>e instanceof Set,wt=e=>typeof e==\"object\",Xe=e=>typeof e==\"function\",Wn=e=>typeof e==\"boolean\";function ll(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var ul=e=>wt(e)?e?.[ne]:null,Le=e=>e.copy_||e.base_,Vr=e=>e.modified_?e.copy_:e.base_;function dr(e,t){if(nn(e))return new Map(e);if(rn(e))return new Set(e);if(tn(e))return Array[Zt].slice.call(e);const n=Ua(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[yn]===!1&&(s[yn]=!0,s[fr]=!0),(s.get||s.set)&&(r[o]={[fr]:!0,[yn]:!0,[Cn]:s[Cn],[jt]:e[o]})}return me.create(at(e),r)}else{const r=at(e);if(r!==null&&n)return{...e};const i=me.create(r);return me.assign(i,e)}}function Hr(e,t=!1){return zn(e)||He(e)||!Ne(e)||(ot(e)>1&&me.defineProperties(e,{set:cn,add:cn,clear:cn,delete:cn}),me.freeze(e),t&&en(e,(n,r)=>{Hr(r,!0)},!1)),e}function cl(){oe(2)}var cn={[jt]:cl};function zn(e){return e===null||!wt(e)?!0:me.isFrozen(e)}var Pn=\"MapSet\",En=\"Patches\",Ei=\"ArrayMethods\",An={};function st(e){const t=An[e];return t||oe(0,e),t}var Ai=e=>!!An[e];function fl(e,t){An[e]||(An[e]=t)}var Wt,ja=()=>Wt,dl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ai(Pn)?st(Pn):void 0,arrayMethodsPlugin_:Ai(Ei)?st(Ei):void 0});function $i(e,t){t&&(e.patchPlugin_=st(En),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hr(e){pr(e),e.drafts_.forEach(hl),e.drafts_=null}function pr(e){e===Wt&&(Wt=e.parent_)}var Di=e=>Wt=dl(Wt,e);function hl(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ti(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(hr(t),oe(4)),Ne(e)&&(e=Ni(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Ni(t,n);return pl(t,e,!0),hr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Br?e:void 0}function Ni(e,t){if(zn(t))return t;const n=t[ne];if(!n)return $n(t,e.handledSet_,e);if(!Fn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);Qa(n,e)}return n.copy_}function pl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Hr(t,n)}function Wa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Fn=(e,t)=>e.scope_===t,gl=[];function Ka(e,t,n,r){const i=Le(e),a=e.type_;if(r!==void 0&&Oe(i,r,a)===t){In(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;en(i,(l,u)=>{if(He(u)){const f=s.get(u)||[];f.push(l),s.set(u,f)}})}const o=e.draftLocations_.get(t)??gl;for(const s of o)In(i,s,n,a)}function ml(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Fn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Vr(a);Ka(e,a.draft_??a,o,n),Qa(a,i)})}function Qa(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)}Wa(e)}}function yl(e,t,n){const{scope_:r}=e;if(He(n)){const i=n[ne];Fn(i,r)&&i.callbacks_.push(function(){_n(e);const o=Vr(i);Ka(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Le(e);e.type_===3?a.has(n)&&$n(n,r.handledSet_,r):Oe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&$n(Oe(e.copy_,t,e.type_),r.handledSet_,r)})}function $n(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||He(e)||t.has(e)||!Ne(e)||zn(e)||(t.add(e),en(e,(r,i)=>{if(He(i)){const a=i[ne];if(Fn(a,n)){const o=Vr(a);In(e,r,o,e.type_),Wa(a)}}else Ne(i)&&$n(i,t,n)})),e}function _l(e,t){const n=tn(e),r={type_:n?1:0,scope_:t?t.scope_:ja(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=Dn;n&&(i=[r],a=Kt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Dn={get(e,t){if(t===ne)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Le(e);if(!Bt(i,t,e.type_))return bl(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&ll(t))return a;if(a===Kn(e.base_,t)){_n(e);const o=e.type_===1?+t:t,s=mr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Le(e)},ownKeys(e){return Reflect.ownKeys(Le(e))},set(e,t,n){const r=Ga(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Kn(Le(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(sl(n,i)&&(n!==void 0||Bt(e.base_,t,e.type_)))return!0;_n(e),gr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),yl(e,t,n)),!0},deleteProperty(e,t){return _n(e),Kn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),gr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Le(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[yn]:!0,[fr]:e.type_!==1||t!==\"length\",[Cn]:r[Cn],[jt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return at(e.base_)},setPrototypeOf(){oe(12)}},Kt={};for(let e in Dn){let t=Dn[e];Kt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Kt.deleteProperty=function(e,t){return Kt.set.call(this,e,t,void 0)};Kt.set=function(e,t,n){return Dn.set.call(this,e[0],t,n,e[0])};function Kn(e,t){const n=e[ne];return(n?Le(n):e)[t]}function bl(e,t,n){const r=Ga(t,n);return r?jt in r?r[jt]:r.get?.call(e.draft_):void 0}function Ga(e,t){if(!(t in e))return;let n=at(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=at(n)}}function gr(e){e.modified_||(e.modified_=!0,e.parent_&&gr(e.parent_))}function _n(e){e.copy_||(e.assigned_=new Map,e.copy_=dr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var vl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Xe(t)&&!Xe(n)){const a=n;n=t;const o=this;return function(l=a,...u){return o.produce(l,f=>n.call(this,f,...u))}}Xe(n)||oe(6),r!==void 0&&!Xe(r)&&oe(7);let i;if(Ne(t)){const a=Di(this),o=mr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?hr(a):pr(a)}return $i(a,r),Ti(i,a)}else if(!t||!wt(t)){if(i=n(t),i===void 0&&(i=t),i===Br&&(i=void 0),this.autoFreeze_&&Hr(i,!0),r){const a=[],o=[];st(En).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Xe(t))return(o,...s)=>this.produceWithPatches(o,l=>t(l,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},Wn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Wn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Wn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||oe(8),He(e)&&(e=wl(e));const t=Di(this),n=mr(t,e,void 0);return n[ne].isManual_=!0,pr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return $i(r,t),Ti(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=st(En).applyPatches_;return He(e)?r(e,t):this.produce(e,i=>r(i,t))}};function mr(e,t,n,r){const[i,a]=nn(t)?st(Pn).proxyMap_(t,n):rn(t)?st(Pn).proxySet_(t,n):_l(t,n);return(n?.scope_??ja()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?ml(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=l;a.modified_&&u&&u.generatePatches_(a,[],l)}),i}function wl(e){return He(e)||oe(10,e),Ya(e)}function Ya(e){if(!Ne(e)||zn(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=dr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=dr(e,!0);return en(n,(i,a)=>{In(n,i,Ya(a))},r),t&&(t.finalized_=!1),n}function Sl(){function t(h,y=[]){if(h.key_!==void 0){const k=h.parent_.copy_??h.parent_.base_,_=ul(Oe(k,h.key_)),S=Oe(k,h.key_);if(S===void 0||S!==h.draft_&&S!==h.base_&&S!==h.copy_||_!=null&&_.base_!==h.base_)return null;const x=h.parent_.type_===3;let E;if(x){const I=h.parent_;E=Array.from(I.drafts_.keys()).indexOf(h.key_)}else E=h.key_;if(!(x&&k.size>E||Bt(k,E)))return null;y.push(E)}if(h.parent_)return t(h.parent_,y);y.reverse();try{n(h.copy_,y)}catch{return null}return y}function n(h,y){let k=h;for(let _=0;_<y.length-1;_++){const S=y[_];if(k=Oe(k,S),!wt(k)||k===null)throw new Error(`Cannot resolve path at '${y.join(\"/\")}'`)}return k}const r=\"replace\",i=\"add\",a=\"remove\";function o(h,y,k){if(h.scope_.processedForPatches_.has(h))return;h.scope_.processedForPatches_.add(h);const{patches_:_,inversePatches_:S}=k;switch(h.type_){case 0:case 2:return l(h,y,_,S);case 1:return s(h,y,_,S);case 3:return u(h,y,_,S)}}function s(h,y,k,_){let{base_:S,assigned_:x}=h,E=h.copy_;E.length<S.length&&([S,E]=[E,S],[k,_]=[_,k]);const I=h.allIndicesReassigned_===!0;for(let b=0;b<S.length;b++){const $=E[b],A=S[b];if((I||x?.get(b.toString()))&&$!==A){const v=$?.[ne];if(v&&v.modified_)continue;const T=y.concat([b]);k.push({op:r,path:T,value:d($)}),_.push({op:r,path:T,value:d(A)})}}for(let b=S.length;b<E.length;b++){const $=y.concat([b]);k.push({op:i,path:$,value:d(E[b])})}for(let b=E.length-1;S.length<=b;--b){const $=y.concat([b]);_.push({op:a,path:$})}}function l(h,y,k,_){const{base_:S,copy_:x,type_:E}=h;en(h.assigned_,(I,b)=>{const $=Oe(S,I,E),A=Oe(x,I,E),D=b?Bt(S,I)?r:i:a;if($===A&&D===r)return;const v=y.concat(I);k.push(D===a?{op:D,path:v}:{op:D,path:v,value:d(A)}),_.push(D===i?{op:a,path:v}:D===a?{op:i,path:v,value:d($)}:{op:r,path:v,value:d($)})})}function u(h,y,k,_){let{base_:S,copy_:x}=h,E=0;S.forEach(I=>{if(!x.has(I)){const b=y.concat([E]);k.push({op:a,path:b,value:I}),_.unshift({op:i,path:b,value:I})}E++}),E=0,x.forEach(I=>{if(!S.has(I)){const b=y.concat([E]);k.push({op:i,path:b,value:I}),_.unshift({op:a,path:b,value:I})}E++})}function f(h,y,k){const{patches_:_,inversePatches_:S}=k;_.push({op:r,path:[],value:y===Br?void 0:y}),S.push({op:r,path:[],value:h})}function c(h,y){return y.forEach(k=>{const{path:_,op:S}=k;let x=h;for(let $=0;$<_.length-1;$++){const A=ot(x);let D=_[$];typeof D!=\"string\"&&typeof D!=\"number\"&&(D=\"\"+D),(A===0||A===1)&&(D===\"__proto__\"||D===Ut)&&oe(19),Xe(x)&&D===Zt&&oe(19),x=Oe(x,D),wt(x)||oe(18,_.join(\"/\"))}const E=ot(x),I=p(k.value),b=_[_.length-1];switch(S){case r:switch(E){case 2:return x.set(b,I);case 3:oe(16);default:return x[b]=I}case i:switch(E){case 1:return b===\"-\"?x.push(I):x.splice(b,0,I);case 2:return x.set(b,I);case 3:return x.add(I);default:return x[b]=I}case a:switch(E){case 1:return x.splice(b,1);case 2:return x.delete(b);case 3:return x.delete(k.value);default:return delete x[b]}default:oe(17,S)}}),h}function p(h){if(!Ne(h))return h;if(tn(h))return h.map(p);if(nn(h))return new Map(Array.from(h.entries()).map(([k,_])=>[k,p(_)]));if(rn(h))return new Set(Array.from(h).map(p));const y=Object.create(at(h));for(const k in h)y[k]=p(h[k]);return Bt(h,Lt)&&(y[Lt]=h[Lt]),y}function d(h){return He(h)?p(h):h}fl(En,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Qt=new vl,kl=Qt.produce,xl=Qt.produceWithPatches.bind(Qt),yt=Qt.applyPatches.bind(Qt);const Cl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?kl(i):i;return t(s,a,...o)},e(r.setState,n,r)),Il=Cl,Pl=/[a-zA-Z]/,El=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Al(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 Mi(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 Ri(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 $l(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 pt(e,t){let n=1;for(;t<e.length&&n>0;)e[t]===\"{\"?n++:e[t]===\"}\"&&n--,n>0&&t++;return n===0?t:-1}function xt(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=Ri(e,n);o=h.className||void 0,s=h.id||void 0,n=h.endIdx,e[n]===\" \"&&n++}let l=1;const u=n;for(;n<e.length&&l>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")l++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(l--,l===0)break;n+=2}else n++;if(l!==0){n=a+2,r=a;continue}const f=e.slice(u,n);n+=2;const{display:c,target:p}=Al(f),d={type:\"link\",display:c,target:p,start:a,end:n};o&&(d.className=o),s&&(d.id=s),t.push(d),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,l;if(o===\".\"||o===\"#\"){i(n);const u=Ri(e,n+1);s=u.className||void 0,l=u.id||void 0;let f=u.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"variable\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=pt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"temporary\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=pt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(p,n);if(e[n]===\"}\"){n++;const y={type:\"variable\",name:d,scope:\"local\",start:a,end:n};s&&(y.className=s),l&&(y.id=l),t.push(y),r=n;continue}const h=pt(e,p);if(h!==-1){const y=e.slice(f,h);n=h+1;const k={type:\"expression\",expression:y,start:a,end:n};s&&(k.className=s),l&&(k.id=l),t.push(k),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let p=1;const d=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const h=e.slice(d,n);n++;const{name:y,rawArgs:k,isClose:_}=Mi(h),S={type:\"macro\",name:y,rawArgs:k,isClose:_,start:a,end:n};s&&(S.className=s),l&&(S.id=l),t.push(S),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}const c=pt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}const c=pt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const u=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(u,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}const c=pt(e,u);if(c!==-1){const p=e.slice(a+1,c);n=c+1,t.push({type:\"expression\",expression:p,start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let u=1;const f=n;for(;n<e.length&&u>0;)e[n]===\"{\"?u++:e[n]===\"}\"&&u--,u>0&&n++;if(u!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:p,rawArgs:d,isClose:h}=Mi(c);t.push({type:\"macro\",name:p,rawArgs:d,isClose:h,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const l=o;for(;o<e.length&&/[a-zA-Z0-9-]/.test(e[o]);)o++;const u=e.slice(l,o),f=u.toLowerCase();if(u&&Pl.test(u[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const c=$l(e,o);o=c.endIdx;let p=El.has(f);if(e[o]===\"/\"&&(p=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:c.attributes,isClose:!1,isSelfClose:p,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ja=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function yr(e){Ja.add(e.toLowerCase())}const zi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Dl=new Set([\"if\",\"switch\",\"timed\"]);function Ct(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"expression\":{const a={type:\"expression\",expression:i.expression};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag.toLowerCase()!==i.tag.toLowerCase()){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(zi[a]){const o=zi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const l={rawArgs:i.rawArgs,children:[]};i.className&&(l.className=i.className),i.id&&(l.id=i.id),s.branches.push(l);break}if(Ja.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(Dl.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 qr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Q(ke);return he(()=>[e,t,n],[e,t,n])}function Xa(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 Za(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let It=!1,an=\"\",lt=0,St=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,an=n,lt=0,St=Xa(Za(n)),It=!0}function eo(e,t){an=e,lt=0,St=Xa(Za(e)),It=!0;for(let n=0;n<t;n++)St();lt=t}function _r(){It=!1,an=\"\",lt=0,St=null}function Tn(){return It?{seed:an,pull:lt}:null}function Ur(){return!It||!St?Math.random():(lt++,St())}function to(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Ur()*(t-e+1))+e}function Nl(){return It}function Ml(){return an}function Rl(){return lt}const zl=500,Ge=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 jr(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 l=e.charAt(r);if(l===\"\\\\\"&&r+1<e.length)s+=l+e.charAt(r+1),r+=2;else if(l===o){s+=o,r++;break}else s+=l,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,l=\"\";for(;r<e.length&&s>0;){const u=e.charAt(r);if(u===\"{\")s++,l+=u;else if(u===\"}\"){if(s--,s===0)break;l+=u}else if(u===\"\\\\\"&&r+1<e.length)l+=u+e.charAt(r+1),r++;else if(u==='\"'||u===\"'\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===u){l+=f,r++;break}else l+=f,r++}continue}else if(u===\"`\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===\"$\"&&e.charAt(r+1)===\"{\"){l+=\"${\",r+=2;let c=1;for(;r<e.length&&c>0;){const p=e.charAt(r);p===\"{\"?c++:p===\"}\"&&c--,c>0&&(l+=p),r++}l+=\"}\"}else if(f===\"`\"){l+=f,r++;break}else l+=f,r++}continue}else l+=u;r++}t+=jr(l),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Vl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function no(e,t){const n=Ge.get(e);if(n)return Ge.delete(e),Ge.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Vl+t);if(Ge.set(e,r),Ge.size>zl){const i=Ge.keys().next().value;i!==void 0&&Ge.delete(i)}return r}let fn=null,Fi=null,Oi=null;function ro(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(fn&&Fi===t&&Oi===n)return fn;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(h=>r(h)>0),o=(...d)=>d.every(h=>r(h)>0),s=d=>n[d??C.getState().currentPassage]??0;return fn={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const h=d.history[d.historyIndex-1]?.passage;return h?d.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(h=>s(h)>0),hasRenderedAll:(...d)=>d.every(h=>s(h)>0),random:Ur,randomInt:to},Fi=t,Oi=n,fn}function Pt(e,t,n,r={}){const a=`return (${jr(e)});`;return no(a,a)(t,n,r,ro())}function io(e,t,n,r={}){const i=jr(e);no(\"exec:\"+i,i)(t,n,r,ro())}const Hl=/\\{[\\$_@]\\w/;function ql(e){return Hl.test(e)}function Ul(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function jl(e,t,n,r){const i=Pt(e,t,n,r);return i==null?\"\":String(i)}function Wl(e,t,n,r){const i=e[0],o=e.slice(1).split(\".\"),s=o[0];let l;return i===\"$\"?l=t[s]:i===\"_\"?l=n[s]:l=r[s],o.length>1&&(l=Ul(l,o)),l==null?\"\":String(l)}function Kl(e,t,n,r){let i=\"\",a=0;for(;a<e.length;){if(e[a]!==\"{\"){const f=e.indexOf(\"{\",a);if(f===-1){i+=e.slice(a);break}i+=e.slice(a,f),a=f;continue}a++;const o=e[a];if(o!==\"$\"&&o!==\"_\"&&o!==\"@\"){i+=\"{\";continue}let s=1,l=a;for(;l<e.length&&s>0;)l++,e[l]===\"{\"?s++:e[l]===\"}\"&&s--;if(s!==0){i+=\"{\";continue}const u=e.slice(a,l);a=l+1,/^[\\$_@][\\w.]+$/.test(u)?i+=Wl(u,t,n,r):i+=jl(u,t,n,r)}return i}function On(){const[e,t,n]=qr();return pe(r=>r===void 0||!ql(r)?r:Kl(r,e,t,n),[e,t,n])}function Ql({name:e,scope:t,className:n,id:r}){const i=On();n=i(n),r=i(r);const a=Q(ke),o=e.split(\".\"),s=o[0],l=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let u;t===\"local\"?u=s in a?a[s]:void 0:u=l;for(let c=1;c<o.length;c++){if(u==null||typeof u!=\"object\"){u=void 0;break}const p=o[c];u=u[p]}const f=u==null?\"\":String(u);return n||r?w(\"span\",{id:r,class:n,children:f}):w(G,{children:f})}function Gl({expression:e,className:t,id:n}){const r=On();t=r(t),n=r(n);const i=Q(ke),a=C(l=>l.variables),o=C(l=>l.temporary);let s;try{const l=Pt(e,a,o,i);s=l==null?\"\":String(l)}catch{s=`{error: ${e}}`}return t||n?w(\"span\",{id:n,class:t,children:s}):w(G,{children:s})}function Yl(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 Jl(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(!Yl(a))return null;return t}function Xl(e){const t=[];let n=\"\",r=0,i=null,a=!1;for(let s=0;s<e.length;s++){const l=e[s];if(i){n+=l,l===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(l==='\"'||l===\"'\"||l===\"`\"){i=l,n+=l;continue}if(l===\"(\"||l===\"[\"||l===\"{\"){r++,n+=l;continue}if(l===\")\"||l===\"]\"||l===\"}\"){r--,n+=l;continue}if(l===\",\"&&r===0){a=!0,t.push(n.trim()),n=\"\";continue}n+=l}const o=n.trim();if(o&&t.push(o),!a&&t.length===1){const s=Jl(t[0]);if(s)return s}return t}function Zl({body:e,parentValues:t,ownKeys:n}){const r=Q(fe),[i,a]=ee({}),o={...t,...n,...i},s=se(o);s.current=o;const l=pe(()=>s.current,[]),u=pe((c,p)=>{a(d=>({...d,[c]:p}))},[]),f=he(()=>({update:u,getValues:l}),[u,l]);return w(on.Provider,{value:f,children:w(ke.Provider,{value:o,children:Pe(e,{nobr:r,locals:o})})})}function eu({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(ke),a=Q(fe),[o,s,l]=qr(),u=r?.length?r:null;if(t.length===0||!n)return w(kr.Provider,{value:u,children:Pe(e,{nobr:a,locals:i})});const f=Xl(n),c={};for(let p=0;p<t.length;p++){const d=t[p],h=f[p];let y;if(h!==void 0)try{y=Pt(h,o,s,l)}catch{y=void 0}c[d.startsWith(\"@\")?d.slice(1):d]=y}return w(kr.Provider,{value:u,children:w(Zl,{body:e,parentValues:i,ownKeys:c})})}const ao=new Map;function oo(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");ao.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function tu(e){return ao.get(e.toLowerCase())}const so=new Map;function nu(e,t){so.set(e.toLowerCase(),t)}function ru(e){return so.get(e.toLowerCase())}const lo=new Set;function iu(e){lo.add(e.toLowerCase())}function au(e){return lo.has(e.toLowerCase())}const uo=new Map;function ou(e,t){uo.set(e.toLowerCase(),t)}function su(){return Array.from(uo.values())}const Li=document.createElement(\"i\");function co(e){const t=\"&\"+e+\";\";Li.innerHTML=t;const n=Li.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function _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 br={}.hasOwnProperty;function lu(e){const t={};let n=-1;for(;++n<e.length;)uu(t,e[n]);return t}function uu(e,t){let n;for(n in t){const i=(br.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){br.call(i,o)||(i[o]=[]);const s=a[o];cu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function cu(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 fu(e){const t={};let n=-1;for(;++n<e.length;)du(t,e[n]);return t}function du(e,t){let n;for(n in t){const i=(br.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function hu(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 pu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function fo(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+pu[n]+\";\"}}function Gt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const $e=Qe(/[A-Za-z]/),ye=Qe(/[\\dA-Za-z]/),gu=Qe(/[#-'*+\\--9=?A-Z^-~]/);function vr(e){return e!==null&&(e<32||e===127)}const wr=Qe(/\\d/),mu=Qe(/[\\dA-Fa-f]/),yu=Qe(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function le(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const _u=Qe(/\\p{P}|\\p{S}/u),bu=Qe(/\\s/);function Qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function dn(e,t){const n=fo(vu(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 vu(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 Bi={}.hasOwnProperty,Vi=/^(https?|ircs?|mailto|xmpp)$/i,wu=/^https?$/i;function Su(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=fu([{enter:{blockQuote:O,codeFenced:xe,codeFencedFenceInfo:k,codeFencedFenceMeta:k,codeIndented:j,codeText:as,content:Ko,definition:Vo,definitionDestinationString:qo,definitionLabelString:k,definitionTitleString:k,emphasis:rs,htmlFlow:ns,htmlText:ni,image:q,label:k,link:ue,listItemMarker:T,listItemValue:v,listOrdered:A,listUnordered:D,paragraph:X,reference:k,resource:dt,resourceDestinationString:ht,resourceTitleString:k,setextHeading:Go,strong:is},exit:{atxHeading:Jo,atxHeadingSequence:Qo,autolinkEmail:ds,autolinkProtocol:fs,blockQuote:Z,characterEscapeValue:At,characterReferenceMarkerHexadecimal:ri,characterReferenceMarkerNumeric:ri,characterReferenceValue:cs,codeFenced:g,codeFencedFence:M,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:ts,codeIndented:g,codeText:os,codeTextData:At,data:At,definition:Wo,definitionDestinationString:Uo,definitionLabelString:Ho,definitionTitleString:jo,emphasis:ss,hardBreakEscape:ei,hardBreakTrailing:ei,htmlFlow:ti,htmlFlowData:At,htmlText:ti,htmlTextData:At,image:Zr,label:Et,labelText:te,lineEnding:es,link:Zr,listOrdered:N,listUnordered:V,paragraph:ge,reference:$,referenceString:qe,resource:$,resourceDestinationString:qn,resourceTitleString:Bo,setextHeading:Zo,setextHeadingLineSequence:Xo,setextHeadingText:Yo,strong:ls,thematicBreak:us}},...t.htmlExtensions||[]]),u={definitions:r,tightStack:o},f={buffer:k,encode:b,getData:y,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:h,tag:S};let c=t.defaultLineEnding;return p;function p(P){let R=-1,re=0;const Ce=[];let Ee=[],Me=[];for(;++R<P.length;)!c&&(P[R][1].type===\"lineEnding\"||P[R][1].type===\"lineEndingBlank\")&&(c=P[R][2].sliceSerialize(P[R][1])),(P[R][1].type===\"listOrdered\"||P[R][1].type===\"listUnordered\")&&(P[R][0]===\"enter\"?Ce.push(R):d(P.slice(Ce.pop(),R))),P[R][1].type===\"definition\"&&(P[R][0]===\"enter\"?(Me=ae(Me,P.slice(re,R)),re=R):(Ee=ae(Ee,P.slice(re,R+1)),re=R+1));Ee=ae(Ee,Me),Ee=ae(Ee,P.slice(re)),R=-1;const Ae=Ee;for(l.enter.null&&l.enter.null.call(f);++R<P.length;){const ii=l[Ae[R][0]],ai=Ae[R][1].type,oi=ii[ai];Bi.call(ii,ai)&&oi&&oi.call({sliceSerialize:Ae[R][2].sliceSerialize,...f},Ae[R][1])}return l.exit.null&&l.exit.null.call(f),i[0].join(\"\")}function d(P){const R=P.length;let re=0,Ce=0,Ee=!1,Me;for(;++re<R;){const Ae=P[re];if(Ae[1]._container)Me=void 0,Ae[0]===\"enter\"?Ce++:Ce--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(Me=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Ce&&(Me?Me=void 0:Ee=!0);break}default:Me=void 0}}P[0][1]._loose=Ee}function h(P,R){u[P]=R}function y(P){return u[P]}function k(){i.push([])}function _(){return i.pop().join(\"\")}function S(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(c||`\n`)}function I(){const P=i[i.length-1],R=P[P.length-1],re=R?R.charCodeAt(R.length-1):null;re===10||re===13||re===null||E()}function b(P){return y(\"ignoreEncode\")?P:fo(P)}function $(){_()}function A(P){o.push(!P._loose),I(),S(\"<ol\"),h(\"expectFirstItem\",!0)}function D(P){o.push(!P._loose),I(),S(\"<ul\"),h(\"expectFirstItem\",!0)}function v(P){if(y(\"expectFirstItem\")){const R=Number.parseInt(this.sliceSerialize(P),10);R!==1&&S(' start=\"'+b(String(R))+'\"')}}function T(){y(\"expectFirstItem\")?S(\">\"):U(),I(),S(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),S(\"</ol>\")}function V(){U(),o.pop(),E(),S(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),S(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),S(\"<blockquote>\")}function Z(){o.pop(),I(),S(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),S(\"<p>\")),h(\"slurpAllLineEndings\")}function ge(){o[o.length-1]?h(\"slurpAllLineEndings\",!0):S(\"</p>\")}function xe(){I(),S(\"<pre><code\"),h(\"fencesCount\",0)}function m(){const P=_();S(' class=\"language-'+P+'\"')}function M(){const P=y(\"fencesCount\")||0;P||(S(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),S(\"<pre><code>\")}function g(){const P=y(\"fencesCount\");P!==void 0&&P<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&E(),y(\"flowCodeSeenData\")&&I(),S(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function Et(){a[a.length-1].label=_()}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 qn(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Bo(){a[a.length-1].title=_()}function Zr(){let P=a.length-1;const R=a[P],re=R.referenceId||R.labelId,Ce=R.destination===void 0?r[Gt(re)]:R;for(n=!0;P--;)if(a[P].image){n=void 0;break}R.image?(S('<img src=\"'+dn(Ce.destination,t.allowDangerousProtocol?void 0:wu)+'\" alt=\"'),x(R.label),S('\"')):S('<a href=\"'+dn(Ce.destination,t.allowDangerousProtocol?void 0:Vi)+'\"'),S(Ce.title?' title=\"'+Ce.title+'\"':\"\"),R.image?S(\" />\"):(S(\">\"),x(R.label),S(\"</a>\")),a.pop()}function Vo(){k(),a.push({})}function Ho(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function qo(){k(),h(\"ignoreEncode\",!0)}function Uo(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function jo(){a[a.length-1].title=_()}function Wo(){const P=a[a.length-1],R=Gt(P.labelId);_(),Bi.call(r,R)||(r[R]=a[a.length-1]),a.pop()}function Ko(){h(\"slurpAllLineEndings\",!0)}function Qo(P){y(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),S(\"<h\"+y(\"headingRank\")+\">\"))}function Go(){k(),h(\"slurpAllLineEndings\")}function Yo(){h(\"slurpAllLineEndings\",!0)}function Jo(){S(\"</h\"+y(\"headingRank\")+\">\"),h(\"headingRank\")}function Xo(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function Zo(){const P=_();I(),S(\"<h\"+y(\"headingRank\")+\">\"),x(P),S(\"</h\"+y(\"headingRank\")+\">\"),h(\"slurpAllLineEndings\"),h(\"headingRank\")}function At(P){x(b(this.sliceSerialize(P)))}function es(P){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(b(this.sliceSerialize(P)))}}function ts(P){x(b(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function ei(){S(\"<br />\")}function ns(){I(),ni()}function ti(){h(\"ignoreEncode\")}function ni(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function rs(){S(\"<em>\")}function is(){S(\"<strong>\")}function as(){h(\"inCodeText\",!0),S(\"<code>\")}function os(){h(\"inCodeText\"),S(\"</code>\")}function ss(){S(\"</em>\")}function ls(){S(\"</strong>\")}function us(){I(),S(\"<hr />\")}function ri(P){h(\"characterReferenceType\",P.type)}function cs(P){const R=this.sliceSerialize(P),re=y(\"characterReferenceType\")?hu(R,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):co(R);x(b(re)),h(\"characterReferenceType\")}function fs(P){const R=this.sliceSerialize(P);S('<a href=\"'+dn(R,t.allowDangerousProtocol?void 0:Vi)+'\">'),x(b(R)),S(\"</a>\")}function ds(P){const R=this.sliceSerialize(P);S('<a href=\"'+dn(\"mailto:\"+R)+'\">'),x(b(R)),S(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return L(l)?(e.enter(n),s(l)):t(l)}function s(l){return L(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const ku={tokenize:xu};function xu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const l=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return z(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Cu={tokenize:Iu},Hi={tokenize:Pu};function Iu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(x){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(x)}return u(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&S();const E=t.events.length;let I=E,b;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){b=t.events[I][1].end;break}_(r);let $=E;for(;$<t.events.length;)t.events[$][1].end={...b},$++;return _e(t.events,I+1,0,t.events.slice(E)),t.events.length=$,u(x)}return s(x)}function u(x){if(r===n.length){if(!i)return p(x);if(i.currentConstruct&&i.currentConstruct.concrete)return h(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Hi,f,c)(x)}function f(x){return i&&S(),_(r),p(x)}function c(x){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(x)}function p(x){return t.containerState={},e.attempt(Hi,d,h)(x)}function d(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function h(x){if(x===null){i&&S(),_(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),y(x)}function y(x){if(x===null){k(e.exit(\"chunkFlow\"),!0),_(0),e.consume(x);return}return z(x)?(e.consume(x),k(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),y)}function k(x,E){const I=t.sliceStream(x);if(E&&I.push(null),x.previous=a,a&&(a.next=x),a=x,i.defineSkip(x.start),i.write(I),t.parser.lazy[x.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<o&&(!i.events[b][1].end||i.events[b][1].end.offset>o))return;const $=t.events.length;let A=$,D,v;for(;A--;)if(t.events[A][0]===\"exit\"&&t.events[A][1].type===\"chunkFlow\"){if(D){v=t.events[A][1].end;break}D=!0}for(_(r),b=$;b<t.events.length;)t.events[b][1].end={...v},b++;_e(t.events,A+1,0,t.events.slice($)),t.events.length=b}}function _(x){let E=n.length;for(;E-- >x;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=x}function S(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Pu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Nn(e){if(e===null||le(e)||bu(e))return 1;if(_u(e))return 2}function Ln(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Sr={name:\"attention\",resolveAll:Eu,tokenize:Au};function Eu(e,t){let n=-1,r,i,a,o,s,l,u,f;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};qi(c,-l),qi(p,l),o={type:l>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:l>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:p},a={type:l>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=ae(u,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),u=ae(u,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),u=ae(u,Ln(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=ae(u,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=ae(u,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,_e(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Au(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Nn(r);let a;return o;function o(l){return a=l,e.enter(\"attentionSequence\"),s(l)}function s(l){if(l===a)return e.consume(l),s;const u=e.exit(\"attentionSequence\"),f=Nn(l),c=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return u._open=!!(a===42?c:c&&(i||!p)),u._close=!!(a===42?p:p&&(f||!c)),t(l)}}function qi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const $u={name:\"autolink\",tokenize:Du};function Du(e,t,n){let r=0;return i;function i(d){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(d){return $e(d)?(e.consume(d),o):d===64?n(d):u(d)}function o(d){return d===43||d===45||d===46||ye(d)?(r=1,s(d)):u(d)}function s(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||ye(d))&&r++<32?(e.consume(d),s):(r=0,u(d))}function l(d){return d===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d===null||d===32||d===60||vr(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),f):gu(d)?(e.consume(d),u):n(d)}function f(d){return ye(d)?c(d):n(d)}function c(d){return d===46?(e.consume(d),r=0,f):d===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):p(d)}function p(d){if((d===45||ye(d))&&r++<63){const h=d===45?p:c;return e.consume(d),h}return n(d)}}const Bn={partial:!0,tokenize:Tu};function Tu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const ho={continuation:{tokenize:Mu},exit:Ru,name:\"blockQuote\",tokenize:Nu};function Nu(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 Mu(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(ho,t,n)(o)}}function Ru(e){e.exit(\"blockQuote\")}const po={name:\"characterEscape\",tokenize:zu};function zu(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 yu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const go={name:\"characterReference\",tokenize:Fu};function Fu(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),l}function l(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),u):(e.enter(\"characterReferenceValue\"),a=31,o=ye,f(c))}function u(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=mu,f):(e.enter(\"characterReferenceValue\"),a=7,o=wr,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return o===ye&&!co(r.sliceSerialize(p))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),f):n(c)}}const Ui={partial:!0,tokenize:Lu},ji={concrete:!0,name:\"codeFenced\",tokenize:Ou};function Ou(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return l;function l(b){return u(b)}function u(b){const $=r.events[r.events.length-1];return a=$&&$[1].type===\"linePrefix\"?$[2].sliceSerialize($[1],!0).length:0,s=b,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(b)}function f(b){return b===s?(o++,e.consume(b),f):o<3?n(b):(e.exit(\"codeFencedFenceSequence\"),L(b)?H(e,c,\"whitespace\")(b):c(b))}function c(b){return b===null||z(b)?(e.exit(\"codeFencedFence\"),r.interrupt?t(b):e.check(Ui,y,E)(b)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(b))}function p(b){return b===null||z(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(b)):L(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,d,\"whitespace\")(b)):b===96&&b===s?n(b):(e.consume(b),p)}function d(b){return b===null||z(b)?c(b):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===null||z(b)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(b)):b===96&&b===s?n(b):(e.consume(b),h)}function y(b){return e.attempt(i,E,k)(b)}function k(b){return e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),_}function _(b){return a>0&&L(b)?H(e,S,\"linePrefix\",a+1)(b):S(b)}function S(b){return b===null||z(b)?e.check(Ui,y,E)(b):(e.enter(\"codeFlowValue\"),x(b))}function x(b){return b===null||z(b)?(e.exit(\"codeFlowValue\"),S(b)):(e.consume(b),x)}function E(b){return e.exit(\"codeFenced\"),t(b)}function I(b,$,A){let D=0;return v;function v(O){return b.enter(\"lineEnding\"),b.consume(O),b.exit(\"lineEnding\"),T}function T(O){return b.enter(\"codeFencedFence\"),L(O)?H(b,N,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(O):N(O)}function N(O){return O===s?(b.enter(\"codeFencedFenceSequence\"),V(O)):A(O)}function V(O){return O===s?(D++,b.consume(O),V):D>=o?(b.exit(\"codeFencedFenceSequence\"),L(O)?H(b,U,\"whitespace\")(O):U(O)):A(O)}function U(O){return O===null||z(O)?(b.exit(\"codeFencedFence\"),$(O)):A(O)}}}function Lu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Qn={name:\"codeIndented\",tokenize:Vu},Bu={partial:!0,tokenize:Hu};function Vu(e,t,n){const r=this;return i;function i(u){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(u)}function a(u){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):z(u)?e.attempt(Bu,o,l)(u):(e.enter(\"codeFlowValue\"),s(u))}function s(u){return u===null||z(u)?(e.exit(\"codeFlowValue\"),o(u)):(e.consume(u),s)}function l(u){return e.exit(\"codeIndented\"),t(u)}}function Hu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const qu={name:\"codeText\",previous:ju,resolve:Uu,tokenize:Wu};function Uu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ju(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Wu(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),l):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):z(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),l):(e.enter(\"codeTextData\"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit(\"codeTextData\"),l(c)):(e.consume(c),u)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",u(c))}}class Ku{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&&$t(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),$t(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),$t(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);$t(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);$t(this.left,n.reverse())}}}function $t(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 mo(e){const t={};let n=-1,r,i,a,o,s,l,u;const f=new Ku(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type===\"chunkFlow\"&&f.get(n-1)[1].type===\"listItemPrefix\"&&(l=r[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type===\"lineEndingBlank\"&&(a+=2),a<l.length&&l[a][1].type===\"content\"))for(;++a<l.length&&l[a][1].type!==\"content\";)l[a][1].type===\"chunkText\"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Qu(f,n)),n=t[n],u=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=f.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(f.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...f.get(i)[1].start},s=f.slice(i,n),s.unshift(r),f.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function Qu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],u={};let f,c,p=-1,d=n,h=0,y=0;const k=[y];for(;d;){for(;e.get(++i)[1]!==d;);a.push(i),d._tokenizer||(f=r.sliceStream(d),d.next||f.push(null),c&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=d,d=d.next}for(d=n;++p<s.length;)s[p][0]===\"exit\"&&s[p-1][0]===\"enter\"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(y=p+1,k.push(y),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),p=k.length;p--;){const _=s.slice(k[p],k[p+1]),S=a.pop();l.push([S,S+_.length-1]),e.splice(S,2,_)}for(l.reverse(),p=-1;++p<l.length;)u[h+l[p][0]]=h+l[p][1],h+=l[p][1]-l[p][0]-1;return u}const Gu={resolve:Ju,tokenize:Xu},Yu={partial:!0,tokenize:Zu};function Ju(e){return mo(e),e}function Xu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):z(s)?e.check(Yu,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 Zu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function yo(e,t,n,r,i,a,o,s,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),p):_===null||_===32||_===41||vr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),y(_))}function p(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),d(_))}function d(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),p(_)):_===null||_===60||z(_)?n(_):(e.consume(_),_===92?h:d)}function h(_){return _===60||_===62||_===92?(e.consume(_),d):d(_)}function y(_){return!f&&(_===null||_===41||le(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<u&&_===40?(e.consume(_),f++,y):_===41?(e.consume(_),f--,y):_===null||_===32||_===40||vr(_)?n(_):(e.consume(_),_===92?k:y)}function k(_){return _===40||_===41||_===92?(e.consume(_),y):y(_)}}function _o(e,t,n,r,i,a){const o=this;let s=0,l;return u;function u(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(a),f}function f(d){return s>999||d===null||d===91||d===93&&!l||d===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(d):d===93?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):z(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(d))}function c(d){return d===null||d===91||d===93||z(d)||s++>999?(e.exit(\"chunkString\"),f(d)):(e.consume(d),l||(l=!L(d)),d===92?p:c)}function p(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function bo(e,t,n,r,i,a){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),u(p))}function u(p){return p===o?(e.exit(a),l(o)):p===null?n(p):z(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,u,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(p))}function f(p){return p===o||p===null||z(p)?(e.exit(\"chunkString\"),u(p)):(e.consume(p),p===92?c:f)}function c(p){return p===o||p===92?(e.consume(p),f):f(p)}}function Vt(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ec={name:\"definition\",tokenize:nc},tc={partial:!0,tokenize:rc};function nc(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return _o.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),l):n(d)}function l(d){return le(d)?Vt(e,u)(d):u(d)}function u(d){return yo(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(tc,c,c)(d)}function c(d){return L(d)?H(e,p,\"whitespace\")(d):p(d)}function p(d){return d===null||z(d)?(e.exit(\"definition\"),r.parser.defined.push(i),t(d)):n(d)}}function rc(e,t,n){return r;function r(s){return le(s)?Vt(e,i)(s):n(s)}function i(s){return bo(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const ic={name:\"hardBreakEscape\",tokenize:ac};function ac(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return z(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const oc={name:\"headingAtx\",resolve:sc,tokenize:lc};function sc(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 lc(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||le(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),l(f)):f===null||z(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit(\"atxHeadingSequence\"),s(f))}function u(f){return f===null||f===35||le(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),u)}}const uc=[\"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\"],Wi=[\"pre\",\"script\",\"style\",\"textarea\"],cc={concrete:!0,name:\"htmlFlow\",resolveTo:hc,tokenize:pc},fc={partial:!0,tokenize:mc},dc={partial:!0,tokenize:gc};function hc(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 pc(e,t,n){const r=this;let i,a,o,s,l;return u;function u(g){return f(g)}function f(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),p):g===47?(e.consume(g),a=!0,y):g===63?(e.consume(g),i=3,r.interrupt?t:m):$e(g)?(e.consume(g),o=String.fromCharCode(g),k):n(g)}function p(g){return g===45?(e.consume(g),i=2,d):g===91?(e.consume(g),i=5,s=0,h):$e(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function d(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function h(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:N:h):n(g)}function y(g){return $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&&Wi.includes(ue)?(i=1,r.interrupt?t(g):N(g)):uc.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):N(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?S(g):x(g))}return g===45||ye(g)?(e.consume(g),o+=String.fromCharCode(g),k):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:N):n(g)}function S(g){return L(g)?(e.consume(g),S):v(g)}function x(g){return g===47?(e.consume(g),v):g===58||g===95||$e(g)?(e.consume(g),E):L(g)?(e.consume(g),x):v(g)}function E(g){return g===45||g===46||g===58||g===95||ye(g)?(e.consume(g),E):I(g)}function I(g){return g===61?(e.consume(g),b):L(g)?(e.consume(g),I):x(g)}function b(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),l=g,$):L(g)?(e.consume(g),b):A(g)}function $(g){return g===l?(e.consume(g),l=null,D):g===null||z(g)?n(g):(e.consume(g),$)}function A(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||le(g)?I(g):(e.consume(g),A)}function D(g){return g===47||g===62||L(g)?x(g):n(g)}function v(g){return g===62?(e.consume(g),T):n(g)}function T(g){return g===null||z(g)?N(g):L(g)?(e.consume(g),T):n(g)}function N(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),M):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),xe):z(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(fc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(dc,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),O}function O(g){return g===null||z(g)?V(g):(e.enter(\"htmlFlowData\"),N(g))}function Z(g){return g===45?(e.consume(g),m):N(g)}function X(g){return g===47?(e.consume(g),o=\"\",ge):N(g)}function ge(g){if(g===62){const q=o.toLowerCase();return Wi.includes(q)?(e.consume(g),M):N(g)}return $e(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),ge):N(g)}function xe(g){return g===93?(e.consume(g),m):N(g)}function m(g){return g===62?(e.consume(g),M):g===45&&i===2?(e.consume(g),m):N(g)}function M(g){return g===null||z(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),M)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function gc(e,t,n){const r=this;return i;function i(o){return z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function mc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Bn,t,n)}}const yc={name:\"htmlText\",tokenize:_c};function _c(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),l}function l(m){return m===33?(e.consume(m),u):m===47?(e.consume(m),I):m===63?(e.consume(m),x):$e(m)?(e.consume(m),A):n(m)}function u(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,h):$e(m)?(e.consume(m),S):n(m)}function f(m){return m===45?(e.consume(m),d):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),p):z(m)?(o=c,X(m)):(e.consume(m),c)}function p(m){return m===45?(e.consume(m),d):c(m)}function d(m){return m===62?Z(m):m===45?p(m):c(m)}function h(m){const M=\"CDATA[\";return m===M.charCodeAt(a++)?(e.consume(m),a===M.length?y:h):n(m)}function y(m){return m===null?n(m):m===93?(e.consume(m),k):z(m)?(o=y,X(m)):(e.consume(m),y)}function k(m){return m===93?(e.consume(m),_):y(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):y(m)}function S(m){return m===null||m===62?Z(m):z(m)?(o=S,X(m)):(e.consume(m),S)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=x,X(m)):(e.consume(m),x)}function E(m){return m===62?Z(m):x(m)}function I(m){return $e(m)?(e.consume(m),b):n(m)}function b(m){return m===45||ye(m)?(e.consume(m),b):$(m)}function $(m){return z(m)?(o=$,X(m)):L(m)?(e.consume(m),$):Z(m)}function A(m){return m===45||ye(m)?(e.consume(m),A):m===47||m===62||le(m)?D(m):n(m)}function D(m){return m===47?(e.consume(m),Z):m===58||m===95||$e(m)?(e.consume(m),v):z(m)?(o=D,X(m)):L(m)?(e.consume(m),D):Z(m)}function v(m){return m===45||m===46||m===58||m===95||ye(m)?(e.consume(m),v):T(m)}function T(m){return m===61?(e.consume(m),N):z(m)?(o=T,X(m)):L(m)?(e.consume(m),T):D(m)}function N(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):z(m)?(o=N,X(m)):L(m)?(e.consume(m),N):(e.consume(m),U)}function V(m){return m===i?(e.consume(m),i=void 0,O):m===null?n(m):z(m)?(o=V,X(m)):(e.consume(m),V)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||le(m)?D(m):(e.consume(m),U)}function O(m){return m===47||m===62||le(m)?D(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function X(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),ge}function ge(m){return L(m)?H(e,xe,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):xe(m)}function xe(m){return e.enter(\"htmlTextData\"),o(m)}}const Wr={name:\"labelEnd\",resolveAll:Sc,resolveTo:kc,tokenize:xc},bc={tokenize:Cc},vc={tokenize:Ic},wc={tokenize:Pc};function Sc(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 kc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const l={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},u={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",l,t],[\"enter\",u,t]],s=ae(s,e.slice(a+1,a+r+3)),s=ae(s,[[\"enter\",f,t]]),s=ae(s,Ln(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ae(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",u,t]]),s=ae(s,e.slice(o+1)),s=ae(s,[[\"exit\",l,t]]),_e(e,a,e.length,s),e}function xc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(p){return a?a._inactive?c(p):(o=r.parser.defined.includes(Gt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),l):n(p)}function l(p){return p===40?e.attempt(bc,f,o?f:c)(p):p===91?e.attempt(vc,f,o?u:c)(p):o?f(p):c(p)}function u(p){return e.attempt(wc,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function Cc(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return le(c)?Vt(e,a)(c):a(c)}function a(c){return c===41?f(c):yo(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return le(c)?Vt(e,l)(c):f(c)}function s(c){return n(c)}function l(c){return c===34||c===39||c===40?bo(e,u,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function u(c){return le(c)?Vt(e,f)(c):f(c)}function f(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Ic(e,t,n){const r=this;return i;function i(s){return _o.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Pc(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 Ec={name:\"labelStartImage\",resolveAll:Wr.resolveAll,tokenize:Ac};function Ac(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const $c={name:\"labelStartLink\",resolveAll:Wr.resolveAll,tokenize:Dc};function Dc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Gn={name:\"lineEnding\",tokenize:Tc};function Tc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const bn={name:\"thematicBreak\",tokenize:Nc};function Nc(e,t,n){let r=0,i;return a;function a(u){return e.enter(\"thematicBreak\"),o(u)}function o(u){return i=u,s(u)}function s(u){return u===i?(e.enter(\"thematicBreakSequence\"),l(u)):r>=3&&(u===null||z(u))?(e.exit(\"thematicBreak\"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit(\"thematicBreakSequence\"),L(u)?H(e,s,\"whitespace\")(u):s(u))}}const de={continuation:{tokenize:Fc},exit:Lc,name:\"list\",tokenize:zc},Mc={partial:!0,tokenize:Bc},Rc={partial:!0,tokenize:Oc};function zc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(d){const h=r.containerState.type||(d===42||d===43||d===45?\"listUnordered\":\"listOrdered\");if(h===\"listUnordered\"?!r.containerState.marker||d===r.containerState.marker:wr(d)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(bn,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),l(d)}return n(d)}function l(d){return wr(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),u(d)):n(d)}function u(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(Bn,r.interrupt?n:f,e.attempt(Mc,p,c))}function f(d){return r.containerState.initialBlankLine=!0,a++,p(d)}function c(d){return L(d)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(d),e.exit(\"listItemPrefixWhitespace\"),p):n(d)}function p(d){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(d)}}function Fc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Rc,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 Oc(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 Lc(e){e.exit(this.containerState.type)}function Bc(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 Ki={name:\"setextUnderline\",resolveTo:Vc,tokenize:Hc};function Vc(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 Hc(e,t,n){const r=this;let i;return a;function a(u){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!==\"lineEnding\"&&r.events[f][1].type!==\"linePrefix\"&&r.events[f][1].type!==\"content\"){c=r.events[f][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=u,o(u)):n(u)}function o(u){return e.enter(\"setextHeadingLineSequence\"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit(\"setextHeadingLineSequence\"),L(u)?H(e,l,\"lineSuffix\")(u):l(u))}function l(u){return u===null||z(u)?(e.exit(\"setextHeadingLine\"),t(u)):n(u)}}const qc={tokenize:Uc};function Uc(e){const t=this,n=e.attempt(Bn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Gu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const jc={resolveAll:wo()},Wc=vo(\"string\"),Kc=vo(\"text\");function vo(e){return{resolveAll:wo(e===\"text\"?Qc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(f){return u(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),l}function l(f){return u(f)?(n.exit(\"data\"),a(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const c=i[f];let p=-1;if(c)for(;++p<c.length;){const d=c[p];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function wo(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 Qc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,l;for(;a--;){const u=i[a];if(typeof u==\"string\"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,[\"enter\",u,t],[\"exit\",u,t]),n+=2)}n++}return e}const Gc={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:ho},Yc={91:ec},Jc={[-2]:Qn,[-1]:Qn,32:Qn},Xc={35:oc,42:bn,45:[Ki,bn],60:cc,61:Ki,95:bn,96:ji,126:ji},Zc={38:go,92:po},ef={[-5]:Gn,[-4]:Gn,[-3]:Gn,33:Ec,38:go,42:Sr,60:[$u,yc],91:$c,92:[ic,po],93:Wr,95:Sr,96:qu},tf={null:[Sr,jc]},nf={null:[42,95]},rf={null:[]},af=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:nf,contentInitial:Yc,disable:rf,document:Gc,flow:Xc,flowInitial:Jc,insideSpan:tf,string:Zc,text:ef},Symbol.toStringTag,{value:\"Module\"}));function of(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const l={attempt:$(I),check:$(b),consume:S,enter:x,exit:E,interrupt:$(b,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:d,write:c};let f=t.tokenize.call(u,l);return t.resolveAll&&a.push(t),u;function c(T){return o=ae(o,T),k(),o[o.length-1]!==null?[]:(A(t,0),u.events=Ln(a,u.events,u),u.events)}function p(T,N){return lf(d(T),N)}function d(T){return sf(o,T)}function h(){const{_bufferIndex:T,_index:N,line:V,column:U,offset:O}=r;return{_bufferIndex:T,_index:N,line:V,column:U,offset:O}}function y(T){i[T.line]=T.column,v()}function k(){let T;for(;r._index<o.length;){const N=o[r._index];if(typeof N==\"string\")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<N.length;)_(N.charCodeAt(r._bufferIndex));else _(N)}}function _(T){f=f(T)}function S(T){z(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,v()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=T}function x(T,N){const V=N||{};return V.type=T,V.start=h(),u.events.push([\"enter\",V,u]),s.push(V),V}function E(T){const N=s.pop();return N.end=h(),u.events.push([\"exit\",N,u]),N}function I(T,N){A(T,N.from)}function b(T,N){N.restore()}function $(T,N){return V;function V(U,O,Z){let X,ge,xe,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):M(U);function M(te){return Et;function Et(qe){const dt=qe!==null&&te[qe],ht=qe!==null&&te.null,qn=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(ht)?ht:ht?[ht]:[]];return j(qn)(qe)}}function j(te){return X=te,ge=0,te.length===0?Z:g(te[ge])}function g(te){return Et;function Et(qe){return m=D(),xe=te,te.partial||(u.currentConstruct=te),te.name&&u.parser.constructs.disable.null.includes(te.name)?ue():te.tokenize.call(N?Object.assign(Object.create(u),N):u,l,q,ue)(qe)}}function q(te){return T(xe,m),O}function ue(te){return m.restore(),++ge<X.length?g(X[ge]):Z}}}function A(T,N){T.resolveAll&&!a.includes(T)&&a.push(T),T.resolve&&_e(u.events,N,u.events.length-N,T.resolve(u.events.slice(N),u)),T.resolveTo&&(u.events=T.resolveTo(u.events,u))}function D(){const T=h(),N=u.previous,V=u.currentConstruct,U=u.events.length,O=Array.from(s);return{from:U,restore:Z};function Z(){r=T,u.previous=N,u.currentConstruct=V,u.events.length=U,s=O,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sf(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 lf(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 uf(e){const r={constructs:lu([af,...(e||{}).extensions||[]]),content:i(ku),defined:[],document:i(Cu),flow:i(qc),lazy:{},string:i(Wc),text:i(Kc)};return r;function i(a){return o;function o(s){return of(r,a,s)}}}function cf(e){for(;!mo(e););return e}const Qi=/[\\0\\t\\n\\r]/g;function ff(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const l=[];let u,f,c,p,d;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(Qi.lastIndex=c,u=Qi.exec(a),p=u&&u.index!==void 0?u.index:a.length,d=a.charCodeAt(p),!u){t=a.slice(c);break}if(d===10&&c===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<p&&(l.push(a.slice(c,p)),e+=p-c),d){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}function df(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Su(n)(cf(uf(n).document().write(ff()(e,t,!0))))}const Yn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function hf(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Yn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Yn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,pf)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+Yn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function pf(e,t){return t===\"|\"?t:e}class gf{constructor(){this.map=[]}add(t,n,r){mf(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 mf(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 yf(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 _f(){return{flow:{null:{name:\"table\",tokenize:bf,resolveAll:vf}}}}function bf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let T=r.events.length-1;for(;T>-1;){const U=r.events[T][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")T--;else break}const N=T>-1?r.events[T][1].type:null,V=N===\"tableHead\"||N===\"tableRow\"?b:l;return V===b&&r.parser.lazy[r.now().line]?n(v):V(v)}function l(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),u(v)}function u(v){return v===124||(o=!0,a+=1),f(v)}function f(v){return v===null?n(v):z(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),d):n(v):L(v)?H(e,f,\"whitespace\")(v):(a+=1,o&&(o=!1,i+=1),v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(v)))}function c(v){return v===null||v===124||le(v)?(e.exit(\"data\"),f(v)):(e.consume(v),v===92?p:c)}function p(v){return v===92||v===124?(e.consume(v),c):c(v)}function d(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,L(v)?H(e,h,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):h(v))}function h(v){return v===45||v===58?k(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),y):I(v)}function y(v){return L(v)?H(e,k,\"whitespace\")(v):k(v)}function k(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),_):v===45?(a+=1,_(v)):v===null||z(v)?E(v):I(v)}function _(v){return v===45?(e.enter(\"tableDelimiterFiller\"),S(v)):I(v)}function S(v){return v===45?(e.consume(v),S):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(v))}function x(v){return L(v)?H(e,E,\"whitespace\")(v):E(v)}function E(v){return v===124?h(v):v===null||z(v)?!o||i!==a?I(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):I(v)}function I(v){return n(v)}function b(v){return e.enter(\"tableRow\"),$(v)}function $(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),$):v===null||z(v)?(e.exit(\"tableRow\"),t(v)):L(v)?H(e,$,\"whitespace\")(v):(e.enter(\"data\"),A(v))}function A(v){return v===null||v===124||le(v)?(e.exit(\"data\"),$(v)):(e.consume(v),v===92?D:A)}function D(v){return v===92||v===124?(e.consume(v),A):A(v)}}function vf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,u,f,c;const p=new gf;for(;++n<e.length;){const d=e[n],h=d[1];d[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,l!==0&&(Gi(p,t,l,u,f),f=void 0,l=0),u={type:\"table\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",u,t]])):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",f,t]])),i=h.type===\"tableDelimiterRow\"?2:f?3:1):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=hn(p,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):h.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=hn(p,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):h.type===\"tableHead\"?(s=!0,l=n):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(l=n,a[1]!==0?(o[0]=o[1],c=hn(p,t,a,i,n,c)):o[1]!==0&&(c=hn(p,t,o,i,n,c)),i=0):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(l!==0&&Gi(p,t,l,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]===\"enter\"&&d[1].type===\"table\"&&(d[1]._align=yf(t.events,n))}return e}function hn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},mt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const l=mt(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const u=mt(t.events,n[2]),f=mt(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const h=n[2]+1,y=n[3]-n[2]-1;e.add(h,y,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},mt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Gi(e,t,n,r,i){const a=[],o=mt(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 mt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function wf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Sf(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]===\"enter\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]===\"exit\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type=\"strikethroughSequence\",o[u][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[[\"enter\",f,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"enter\",c,s]],d=s.parser.constructs.insideSpan.null;d&&_e(p,p.length,0,Ln(d,o.slice(u+1,l),s)),_e(p,p.length,0,[[\"exit\",c,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"exit\",f,s]]),_e(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type===\"strikethroughSequenceTemporary\"&&(o[l][1].type=\"data\");return o}function a(o,s,l){const u=this.previous,f=this.events;let c=0;return p;function p(h){return u===126&&f[f.length-1][1].type!==\"characterEscape\"?l(h):(o.enter(\"strikethroughSequenceTemporary\"),d(h))}function d(h){const y=Nn(u);if(h===126)return c>1?l(h):(o.consume(h),c++,d);if(c<2&&!n)return l(h);const k=o.exit(\"strikethroughSequenceTemporary\"),_=Nn(h);return k._open=!_||_===2&&!!y,k._close=!y||y===2&&!!_,s(h)}}}function kf(e){return df(e,{allowDangerousHtml:!0,extensions:[_f(),Sf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[hf(),wf()]})}const xf={update:()=>{},getValues:()=>({})},ke=Ke({}),on=Ke(xf),fe=Ke(!1),Yi=Ke(!1),kr=Ke(null);function Cf(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>So(a,o,t));return w(G,{children:i})}function So(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const l of Array.from(r.attributes))o[l.name]=l.value;const s=Array.from(r.childNodes).map((l,u)=>So(l,u,n));return Y(i,o,...s)}return null}function If({node:e}){const t=On(),n=Q(fe),r=Q(ke),i=Q(Yi),a={};for(const[u,f]of Object.entries(e.attributes))a[u]=t(f)??f;const o=e.tag.toLowerCase()===\"svg\",s=e.children.length>0?i||o?Kr(e.children):Pe(e.children,{nobr:n,locals:r}):void 0,l=Y(e.tag,a,s);return o?w(Yi.Provider,{value:!0,children:l}):l}function Pf(){const e=Q(kr),t=Q(fe),n=Q(ke);return!e||e.length===0?null:w(G,{children:Pe(e,{nobr:t,locals:n})})}function Ef(e,t){if(au(e.name))return null;const n=tu(e.name);if(n)return w(eu,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=ru(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function xr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(Pf,{},t):w(Ql,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return w(Gl,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Ef(e,t);case\"html\":return w(If,{node:e},t);default:return e}}function Kr(e){return e.length===0?null:e.map((t,n)=>xr(t,n))}function Af(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function $f(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,l)=>xr(s,l));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const l=e[s];if(l.type===\"text\")i+=l.value;else if(l.type===\"variable\"&&Af(i))i+=$f(l,a);else{const u=r.length;r.push(xr(l,s)),i+=`<span data-tw=\"${u}\"></span>`}}const o=kf(i);return Cf(o,r,t?.nobr)}function Df(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 Tf(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 Nf(){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 Re=\"spindle.save.\",Dt=\"spindle.pt.\",Ye=\"spindle.meta.\",gt=\"spindle.idx.saves.\",Tt=\"spindle.idx.pt.\",Nt=\"spindle.idx.saves-pt.\";function Fe(e){const t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function Ht(e,t){localStorage.setItem(e,JSON.stringify(t))}function ze(e){localStorage.removeItem(e)}function Ze(e){return Fe(e)??[]}function Jn(e,t){const n=Ze(e);n.includes(t)||(n.push(t),Ht(e,n))}function Mt(e,t){const n=Ze(e).filter(r=>r!==t);Ht(e,n)}function Mf(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;Ht(`${Re}${t}`,e),Jn(`${gt}${e.meta.ifid}`,t),Jn(`${Nt}${e.meta.playthroughId}`,t)},async getSave(e){return Fe(`${Re}${e}`)},async deleteSave(e){const t=Fe(`${Re}${e}`);t&&(Mt(`${gt}${t.meta.ifid}`,e),Mt(`${Nt}${t.meta.playthroughId}`,e)),ze(`${Re}${e}`)},async getSavesByIfid(e){const t=Ze(`${gt}${e}`),n=[];for(const r of t){const i=Fe(`${Re}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=Ze(`${gt}${e}`);for(const n of t){const r=Fe(`${Re}${n}`);r&&Mt(`${Nt}${r.meta.playthroughId}`,n),ze(`${Re}${n}`)}ze(`${gt}${e}`)},async deleteSavesByPlaythrough(e){const t=Ze(`${Nt}${e}`);for(const n of t){const r=Fe(`${Re}${n}`);r&&Mt(`${gt}${r.meta.ifid}`,n),ze(`${Re}${n}`)}return ze(`${Nt}${e}`),t},async putPlaythrough(e){Ht(`${Dt}${e.id}`,e),Jn(`${Tt}${e.ifid}`,e.id)},async getPlaythroughsByIfid(e){const t=Ze(`${Tt}${e}`),n=[];for(const r of t){const i=Fe(`${Dt}${r}`);i&&n.push(i)}return n},async deletePlaythroughsByIfid(e){const t=Ze(`${Tt}${e}`);for(const n of t)ze(`${Dt}${n}`);ze(`${Tt}${e}`)},async deletePlaythroughById(e){const t=Fe(`${Dt}${e}`);t&&Mt(`${Tt}${t.ifid}`,e),ze(`${Dt}${e}`)},async getMeta(e){return Fe(`${Ye}${e}`)},async setMeta(e,t){Ht(`${Ye}${e}`,t)},async deleteMeta(e){ze(`${Ye}${e}`)},async deleteMetaByPrefix(e){const t=`${Ye}${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(Ye)&&t.includes(e)&&localStorage.removeItem(t)},async getAllMetaKeys(){const e=[];for(const t of Object.keys(localStorage))t.startsWith(Ye)&&e.push(t.slice(Ye.length));return e},async destroy(){for(const e of Object.keys(localStorage))e.startsWith(\"spindle.\")&&localStorage.removeItem(e)}}}const Ji=\"spindle\",Rf=1;function zf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Ji,Rf);s.onupgradeneeded=()=>{const l=s.result;if(!l.objectStoreNames.contains(\"saves\")){const u=l.createObjectStore(\"saves\",{keyPath:\"meta.id\"});u.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),u.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}l.objectStoreNames.contains(\"playthroughs\")||l.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),l.objectStoreNames.contains(\"meta\")||l.createObjectStore(\"meta\",{keyPath:\"key\"})},s.onsuccess=()=>a(s.result),s.onerror=()=>o(s.error)}),e)}function n(a,o){return t().then(s=>s.transaction(a,o).objectStore(a))}function r(a){return new Promise((o,s)=>{a.onsuccess=()=>o(a.result),a.onerror=()=>s(a.error)})}async function i(a,o,s){const u=(await n(a,\"readonly\")).index(o);return await r(u.getAll(s))??[]}return{type:\"indexeddb\",async putSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.put(a))},async getSave(a){const o=await n(\"saves\",\"readonly\");return await r(o.get(a))??void 0},async deleteSave(a){const o=await n(\"saves\",\"readwrite\");await r(o.delete(a))},async getSavesByIfid(a){return i(\"saves\",\"ifid\",a)},async deleteSavesByIfid(a){const o=await i(\"saves\",\"ifid\",a),s=await n(\"saves\",\"readwrite\");for(const l of o)await r(s.delete(l.meta.id))},async deleteSavesByPlaythrough(a){const o=await i(\"saves\",\"playthroughId\",a),s=await n(\"saves\",\"readwrite\"),l=[];for(const u of o)await r(s.delete(u.meta.id)),l.push(u.meta.id);return l},async putPlaythrough(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.put(a))},async getPlaythroughsByIfid(a){return i(\"playthroughs\",\"ifid\",a)},async deletePlaythroughsByIfid(a){const o=await i(\"playthroughs\",\"ifid\",a),s=await n(\"playthroughs\",\"readwrite\");for(const l of o)await r(s.delete(l.id))},async deletePlaythroughById(a){const o=await n(\"playthroughs\",\"readwrite\");await r(o.delete(a))},async getMeta(a){const o=await n(\"meta\",\"readonly\"),s=await r(o.get(a));return s?s.value:void 0},async setMeta(a,o){const s=await n(\"meta\",\"readwrite\");await r(s.put({key:a,value:o}))},async deleteMeta(a){const o=await n(\"meta\",\"readwrite\");await r(o.delete(a))},async deleteMetaByPrefix(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.startsWith(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async deleteMetaByIfid(a){const o=await n(\"meta\",\"readwrite\"),s=await r(o.getAll());for(const l of s)if(l.key.includes(a)){const u=await n(\"meta\",\"readwrite\");await r(u.delete(l.key))}},async getAllMetaKeys(){const a=await n(\"meta\",\"readonly\");return(await r(a.getAll())).map(s=>s.key)},async destroy(){(await t()).close(),e=null,await new Promise((o,s)=>{const l=indexedDB.deleteDatabase(Ji);l.onsuccess=()=>o(),l.onerror=()=>s(l.error)})}}}let _t=null;async function Ff(){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)}),zf()}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 Mf()}catch{}return Nf()}async function J(){return _t||(_t=await Ff(),_t)}function Of(){_t=null}function Xi(){return _t?.type??\"memory\"}const ko=new Map,Vn=new Map;function Lf(e,t){ko.set(e,t),Vn.set(t,e)}function Bf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ie(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let l=0;l<r.length;l++)s[l]=n(r[l]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[l,u]of r)s.set(n(l),n(u));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const l of r)s.add(n(l));return s}const a=i.constructor;if(Vn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}if(Bf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}return r}return n(e)}const et=\"__spindle_class__\",tt=\"__spindle_data__\";function rt(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),{[et]:\"__Date__\",[tt]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[et]:\"__RegExp__\",[tt]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const l=r.map(u=>n(u));return t.delete(i),l}if(r instanceof Map){const l=[...r].map(([u,f])=>[n(u),n(f)]);return t.delete(i),{[et]:\"__Map__\",[tt]:{entries:l}}}if(r instanceof Set){const l=[...r].map(u=>n(u));return t.delete(i),{[et]:\"__Set__\",[tt]:{entries:l}}}const a=i.constructor,o=Vn.get(a);if(o!==void 0){const l={};for(const u of Object.keys(i))l[u]=n(i[u]);return t.delete(i),{[et]:o,[tt]:l}}const s={};for(const l of Object.keys(i))s[l]=n(i[l]);return t.delete(i),s}return n(e)}function it(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(et in r&&tt in r){const o=r[et],s=r[tt];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);if(o===\"__Map__\"){const f=s.entries;return new Map(f.map(([c,p])=>[t(c),t(p)]))}if(o===\"__Set__\"){const f=s.entries;return new Set(f.map(c=>t(c)))}const l=ko.get(o);if(!l){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(s))f[c]=t(s[c]);return f}const u=Object.create(l.prototype);for(const f of Object.keys(s))u[f]=t(s[f]);return u}const i=r.constructor;if(Vn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Cr=null,Ir=null,Zi=!1;function Vf(e){Cr=e}function Hf(e){Ir=e}function qf(e){if(Ir)try{const i=new Function(\"passage\",\"variables\",Ir)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Cr)try{const r=Cr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function Uf(){Zi||(Zi=!0)}async function ea(e){const t=await J(),r=(await t.getPlaythroughsByIfid(e)).length+1,i=crypto.randomUUID(),a={id:i,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await t.putPlaythrough(a),await t.setMeta(`currentPlaythroughId.${e}`,i),i}async function jf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function xo(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:qf(n),passage:n.passage,custom:r},o=ie(n);o.variables=rt(o.variables),o.history=o.history.map(l=>({...l,variables:rt(l.variables)}));const s={meta:a,payload:o};return s.meta.estimatedBytes=JSON.stringify(o).length,await(await J()).putSave(s),s}async function Co(e,t,n){const r=await J(),i=await r.getSave(e);if(!i)return;const a=ie(t);a.variables=rt(a.variables),a.history=a.history.map(s=>({...s,variables:rt(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 Wf(e){const t=await(await J()).getSave(e);if(!t)return;const n=t.payload;return n.variables=it(n.variables),n.history=n.history.map(r=>({...r,variables:it(r.variables)})),n}async function Kf(e){await(await J()).deleteSave(e)}async function Qf(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 Gf(e){const t=await J(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(const l of r)i.set(l.id,l);const a=new Map;for(const l of n){const u=l.meta.playthroughId,f=a.get(u);f?f.push(l):a.set(u,[l])}for(const l of a.values())l.sort((u,f)=>new Date(f.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const o=[],s=[...i.values()].sort((l,u)=>new Date(u.createdAt).getTime()-new Date(l.createdAt).getTime());for(const l of s){const u=a.get(l.id)??[];o.push({playthrough:l,saves:u})}for(const[l,u]of a)i.has(l)||o.push({playthrough:{id:l,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const Yf=\"autosave.\",Jf=\"slot.\",Hn=\"slotIndex.\";function sn(e,t){return t!=null?`${Jf}${t}.${e}`:`${Yf}${e}`}async function Xf(e,t,n,r,i){const a=await J(),o=sn(e,r),s=await a.getMeta(o);if(s){const u=await Co(s,n,i);if(u)return u}const l=await xo(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,l.meta.id),r!=null){const u=`${Hn}${e}`,f=await a.getMeta(u)??[];f.includes(r)||await a.setMeta(u,[...f,r])}return l}async function ta(e,t){const n=await J(),r=sn(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function Zf(e,t){const n=sn(e,t),r=await(await J()).getMeta(n);if(r)return Wf(r)}async function Pr(e){const t={};await ta(e)&&(t[\"\"]=!0);const n=`${Hn}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await ta(e,i)&&(t[i]=!0);return t}async function Er(e,t){const n=await J(),r=sn(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 ed(e){const t=[],n=await Er(e);n&&t.push(n);const r=`${Hn}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await Er(e,a);o&&t.push(o)}return t}async function td(e,t){const n=await J(),r=sn(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${Hn}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Qr=\"spindle.session.\";function nd(e,t){try{sessionStorage.setItem(`${Qr}${e}`,JSON.stringify(t))}catch{}}function rd(e){try{const t=sessionStorage.getItem(`${Qr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Tf(n))return;const r=n;return r.variables=it(r.variables),r.history=r.history.map(i=>({...i,variables:it(i.variables)})),r}catch{return}}function Io(e){try{sessionStorage.removeItem(`${Qr}${e}`)}catch{}}async function id(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 ad(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 od(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 Po(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Io(e)}async function Eo(){if(await(await J()).destroy(),Of(),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 Ao(e,t){const n=await J(),r=await n.deleteSavesByPlaythrough(t);await n.deletePlaythroughById(t);const i=new Set(r),a=await n.getAllMetaKeys();for(const l of a)if(l.startsWith(\"slot.\")||l.startsWith(\"autosave.\")){const u=await n.getMeta(l);u&&i.has(u)&&await n.deleteMeta(l)}const o=`currentPlaythroughId.${e}`;await n.getMeta(o)===t&&await n.deleteMeta(o)}function $o(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=xt(t.content),i=Ct(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),Ie(Y(()=>Pe(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&Hf(n.content)}let Do=0,we=[],Xn=!1,ct=[],qt=null,Ve=null;function Gr(e){const t=C.getState();try{return!!Pt(e,t.variables,t.temporary)}catch{return!1}}function To(e,t){const n=Do++,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:Gr(e),priority:i?.priority??0};return we.push(o),we.sort((s,l)=>l.priority-s.priority),()=>{we=we.filter(s=>s.id!==n)}}function No(e){we=we.filter(t=>t.name!==e)}function sd(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();io(n.run,r.variables,r.temporary)}n.dialog&&(ct.push({passageName:n.dialog}),qt?.()),n.goto&&C.getState().navigate(n.goto)}}const ld=10;function ud(){if(!Xn){Xn=!0;try{for(let e=0;e<ld;e++){let t=!1;const n=[...we];for(const r of n){if(!we.includes(r))continue;const i=Gr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(we=we.filter(o=>o.id!==r.id)),sd(r))}if(!t)break}}finally{Xn=!1}}}function cd(){for(const e of we)e.lastResult=Gr(e.condition)}function fd(){we=[],ct=[],Do=0,Ve?.closeAll()}function dd(e){return qt=e,ct.length>0&&e(),()=>{qt===e&&(qt=null)}}function hd(){return ct.shift()}function pd(){return ct.length}function gd(e){Ve?Ve.push(e):(ct.push(e),qt?.())}function md(){ct=[]}function yd(e){return Ve=e,()=>{Ve===e&&(Ve=null)}}function _d(){Ve?.close()}function bd(){md(),Ve?.closeAll()}function vd(){return Ve?.isOpen()??!1}Sl();const wd=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let nt={},be=[],Ue={};function na(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function ra(e,t){const[,n,r]=xl(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:na(n),inverse:na(r)}}function Sd(e){let t=nt;for(let n=0;n<e;n++)t=yt(t,be[n].forward);return t}let ve=[];function Zn(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 u=i.length-1;ve[u]={passage:i[u].passage,variables:rt(r),timestamp:i[u].timestamp,prng:i[u].prng}}else{let u=nt;for(let f=0;f<i.length;f++)if(f>0&&(u=yt(u,be[f-1].forward)),f>=ve.length){const c=f===i.length-1?r:u;ve[f]={passage:i[f].passage,variables:rt(c),timestamp:i[f].timestamp,prng:i[f].prng}}}nd(t.ifid,{passage:n,variables:rt(r),history:ve,historyIndex:a,visitCounts:o,renderCounts:s,prng:Tn()})}}function ia(e){nt=e,be=[],Ue=e,ve=[]}let vn=[];function kd(e){return vn.push(e),()=>{vn=vn.filter(t=>t!==e)}}function Mo(){for(const e of vn)e()}function aa(e){e?.prng?eo(e.prng.seed,e.prng.pull):e&&_r()}const C=al()(Il((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},knownSaves:{},playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=ie(r);ia(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;Uf().then(async()=>{const s=await jf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ea(o);e(f=>{f.playthroughId=u})}const l=await Pr(o);Object.keys(l).length>0&&e(u=>{u.knownSaves=l})}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(wd.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=ra(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:Tn()});const s=o.history.length-o.maxHistory;if(s>0){for(let l=0;l<s;l++)nt=yt(nt,be[l].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,Zn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ie(yt(r,be[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Ue=t().variables,aa(t().history[t().historyIndex]),Zn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ie(yt(i,be[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Ue=t().variables,aa(t().history[t().historyIndex]),Zn(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;_r(),fd();const a=ie(r);ia(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},o.renderDeferred=!1}),Ue=t().variables,$o(),Io(n.ifid),Mo(),ea(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}),Xf(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(l=>{l.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?Er(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?ed(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&td(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&&Po(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&&Eo().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&&Ao(r.ifid,n).then(async()=>{const i=await Pr(r.ifid);e(a=>{a.knownSaves=i})}).catch(i=>{console.error(\"spindle: failed to delete playthrough\",i)})},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),l=[];let u=nt;for(let f=0;f<i.length;f++)f>0&&(u=yt(u,be[f-1].forward)),l.push({passage:i[f].passage,variables:ie(u),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:ie(r),history:l,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:Tn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=it(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=it(n.history[o].variables);i.push(ra(a,s)),a=s}nt=ie(r),be=i,ve=[],e(o=>{o.currentPassage=n.passage,o.variables=it(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?eo(n.prng.seed,n.prng.pull):_r()},getHistoryVariables:n=>ie(Sd(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n},deferRender:()=>{e(n=>{n.renderDeferred=!0})},clearDeferredRender:()=>{e(n=>{n.renderDeferred=!1})}}))),xd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Cd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:xd,r=t?.tags.includes(\"nobr\")??!1,i=he(()=>{try{const a=xt(n),o=Ct(a);return w(G,{children:Kr(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(fe.Provider,{value:!0,children:i}):i}const Ro=Ke(null);function Yr({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(d=>d.storyData),u=(e?s?.passages.get(e):void 0)?.content??t,f=he(()=>{if(!u)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const d=xt(u),h=Ct(d);return Pe(h)}catch(d){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",d instanceof Error?d.message:String(d)]})}},[u]),c=d=>{d.target.classList.contains(\"dialog-overlay\")&&o()},p=n?`dialog-panel ${n}`:\"dialog-panel\";return w(Ro.Provider,{value:o,children:w(\"div\",{class:\"dialog-overlay\",onClick:c,children:w(\"div\",{class:p,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:o,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:f})]})})})}function Id(){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(()=>yd({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Se(()=>dd(()=>{const o=[];for(;pd()>0;){const s=hd();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(G,{children:e.map((o,s)=>w(Yr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function Pd(){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 w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(G,{children:[w(Cd,{}),w(Id,{})]});return n?w(fe.Provider,{value:!0,children:r}):r}function Ed(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Ad(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",u=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const p of e.querySelectorAll(\"tw-passagedata\")){const d=parseInt(p.getAttribute(\"pid\")||\"0\",10),h=p.getAttribute(\"name\")||\"\",y=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),k=Ed(p.innerHTML),_={},S=new Set([\"pid\",\"name\",\"tags\"]);for(const E of p.attributes)S.has(E.name)||(_[E.name]=E.value);const x={pid:d,name:h,tags:y,metadata:_,content:k};f.set(h,x),c.set(d,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:u}}const Rt=new Map;let ce={},oa=!1;function zo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function $d(){localStorage.setItem(zo(),JSON.stringify(ce))}function er(){if(!oa){oa=!0;try{const e=localStorage.getItem(zo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ce={...ce,...t})}}catch{}}}const Yt={addToggle(e,t){Rt.set(e,{type:\"toggle\",config:t}),e in ce||(ce[e]=t.default),er()},addList(e,t){Rt.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),er()},addRange(e,t){Rt.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),er()},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,$d()},getAll(){return{...ce}},getDefinitions(){return Rt},hasAny(){return Rt.size>0}};function Dd(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};io(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 Mn=new Map,Ar=new Set,$r=new Map;function Td(e,t,n){if(n)return n;const r=`${e}:${t}`,i=($r.get(r)??0)+1;return $r.set(r,i),i===1?r:`${r}:${i}`}function Nd(e){return Mn.set(e.id,e),la(),()=>{Mn.delete(e.id),la()}}function sa(){return Array.from(Mn.values())}function Md(e){return Mn.get(e)}function Rd(){$r.clear()}function zd(e){return Ar.add(e),()=>{Ar.delete(e)}}function la(){for(const e of Ar)e()}function Fd(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=Td(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),Nd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Od(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Fo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Jr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Fo(t):\"\"}function Ld(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 Bd(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 Vd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Hd={useState:ee,useRef:se,useEffect:Se,useLayoutEffect:ut,useCallback:pe,useMemo:he,useContext:Q};function ua(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function qd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=On(),a=s(a),o=s(o));const{update:l,getValues:u}=Q(on),f=Q(fe),c=Q(ke),d={collectText:Od,sourceLocation:Jr,parseVarArgs:Ld,extractOptions:Bd,h:Y,renderNodes:(h,y)=>Pe(h,{nobr:f,locals:c,...y}),renderInlineNodes:Kr,hooks:Hd,useAction:Fd,className:a,id:o,resolve:s,cls:Vd(e.name,a),mutate:h=>Dd(h,u(),l),update:l,getValues:u,wrap:h=>a||o?Y(\"span\",{id:o,class:a},h):Y(G,null,h)};if(e.merged){d.merged=qr();const h=d.merged;d.evaluate=y=>Pt(y,h[0],h[1],h[2])}if(e.storeVar){const y=(i.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),k=y.split(\".\");d.varName=y,d.value=C(_=>ua(_.variables,k)),d.getValue=()=>ua(C.getState().variables,k),d.setValue=_=>{C.setState(S=>{qd(S.variables,k,_)})}}return e.render(i,d)}nu(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(ou(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)iu(i);r&&yr(e.name)}let pn=null,Dr=null;function Ud(){return Dr}function jd(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e,t){C.getState().save(e,t)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},getSaveInfo(e){return C.getState().getSaveInfo(e)},listSaves(){return C.getState().listSaves()},deleteSave(e){C.getState().deleteSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:Yt,registerClass(e,t){Lf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return su()},saves:{setTitleGenerator(e){Vf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?od(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Xi()}},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 Po(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await Eo(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await Ao(t.ifid,e);const n=await Pr(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return Xi()}},getActions(){return sa()},performAction(e,t){const n=Md(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===\"storyinit\")return kd(t);if(e===\"actionsChanged\")return zd(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(sa())})})})},watch(e,t){return To(e,t)},unwatch(e){No(e)},openDialog(e,t){gd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){_d()},closeAllDialogs(){bd()},isDialogOpen(){return vd()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Dr=new Promise(e=>{pn=e})},ready(){pn&&(C.getState().clearDeferredRender(),pn(),pn=null,Dr=null)},random(){return Ur()},randomInt(e,t){return to(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=Tn())})},isEnabled(){return Nl()},get seed(){return Ml()},get pull(){return Rl()}}}}function Wd(){window.Story=jd()}const Kd=/^\\$(\\w+)\\s*=\\s*(.+)$/,ca=/\\$(\\w+(?:\\.\\w+)*)/g,fa=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Qd=new Set([\"number\",\"string\",\"boolean\"]);function Oo(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,Oo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Qd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Gd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Kd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(u){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${u instanceof Error?u.message:u}`)}const l=Oo(s);t.set(a,{...l,name:a,default:s})}return t}function Yd(e){const t=new Set;let n;for(fa.lastIndex=0;(n=fa.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Jd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const l=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${l}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const u=o.fields.get(l);if(!u)return null;o=u}return null}function Xd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Yd(i.content);let o;for(ca.lastIndex=0;(o=ca.exec(i.content))!==null;){const s=o[1],l=Jd(s,t,a);l&&n.push(`Passage \"${r}\": ${l}`)}}return n}function Zd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function wn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&wn(t.children))return!0;if(t.type===\"macro\"){if(wn(t.children))return!0;if(t.branches){for(const n of t.branches)if(wn(n.children))return!0}}}return!1}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 w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Jr()}: ${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 w(We,{macro:\"print\",error:n})}}});function eh(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 th(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 da(e,t,n,r,i,a,o){let s;try{s=Pt(e,r,i,a)}catch(u){console.error(`spindle: Error in {computed ${o}}${Jr()}:`,u);return}const l=n?i[t]:r[t];if(!th(l,s)){const u=C.getState();n?u.setTemporary(t,s):u.setVariable(t,s)}}B({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=eh(e))}catch(f){return w(We,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),l=a.slice(1),u=t.hooks.useRef(!1);return u.current||(u.current=!0,da(o,l,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{da(o,l,s,n,r,i,e)},[n,r,i]),null}});function nh(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=rh(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 rh(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 ih(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}=nh(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),l=ih(a,o,i),u=t.cls;return w(\"div\",{class:u,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),l!=null&&w(\"span\",{class:\"macro-meter-label\",children:l})]})}catch(n){return w(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?w(\"span\",{id:o,class:a,children:i}):w(G,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return w(We,{macro:\"if\",error:i})}}return null}});function ah(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 oh({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=ee(()=>({...n})),o={...e,...t,...i},s=se(o);s.current=o;const l=pe(()=>s.current,[]),u=pe((p,d)=>{a(h=>({...h,[p]:d}))},[]),f=he(()=>({update:u,getValues:l}),[u,l]),c=Q(fe);return w(on.Provider,{value:f,children:w(ke.Provider,{value:o,children:Pe(r,{nobr:c,locals:o})})})}B({name:\"for\",block:!0,interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=Q(ke);let i;try{i=ah(e)}catch(f){return w(We,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let l;try{const f=n.evaluate(s);if(!Array.isArray(f))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});l=f}catch(f){return w(We,{macro:\"for\",error:f})}const u=l.map((f,c)=>{const p={[a]:f,...o?{[o]:c}:void 0};return w(oh,{parentValues:r,ownKeys:p,initialValues:{},children:t},`${c}-${JSON.stringify(f)}`)});return n.wrap(u)}});B({name:\"do\",block:!0,render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});B({name:\"button\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=Q(fe),a=()=>{const o=document.createElement(\"div\"),s=Y(fe.Provider,{value:i},Y(on.Provider,{value:{update:n.update,getValues:n.getValues}},Y(ke.Provider,{value:n.getValues()},Pe(t))));Ie(s,o),Ie(null,o)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:a}),w(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function sh(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 ha(e,t,n,r){const i=document.createElement(\"div\"),a=Y(fe.Provider,{value:r},Y(on.Provider,{value:{update:n,getValues:t}},Y(ke.Provider,{value:t()},Pe(e))));Ie(a,i),Ie(null,i)}B({name:\"link\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=sh(e),a=Q(fe),o=s=>{s.preventDefault(),ha(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:()=>{ha(t,n.getValues,n.update,a),i&&C.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});B({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(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 w(G,{children:n.renderNodes(o.children)})}catch(s){return w(We,{macro:\"case\",error:s})}}return i?w(G,{children:n.renderNodes(i.children)}):null}});function Xr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}B({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(d=>({delay:d.rawArgs?Xr(d.rawArgs):0,nodes:d.children,className:d.className,id:d.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const d=o+1,h=a[d].delay,y=setTimeout(()=>{s(d)},h);return()=>clearTimeout(y)},[o,a]),o<0)return t.wrap(null);const l=a[o],u=t.renderNodes(l.nodes),f=t.resolve(l.className),c=t.resolve(l.id),p=f||c?w(\"span\",{id:c,class:f,children:u}):u;return t.wrap(p)}});const Lo=Ke({stop:()=>{}});B({name:\"repeat\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Xr(e),[s,l]=r(0),[u,f]=r(!1),c=a(()=>f(!0),[]);if(i(()=>{if(u)return;const d=setInterval(()=>{l(h=>h+1)},o);return()=>clearInterval(d)},[o,u]),s===0&&!u)return null;const p=w(Lo.Provider,{value:{stop:c},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:p}):p}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Lo);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=Xr(e),s=a(null),[l,u]=r(0),[f,c]=r(0),p=a(0);p.current=f,i(()=>{if(s.current){const y=s.current.textContent||\"\";u(y.length)}},[]),i(()=>{if(l===0||p.current>=l)return;const y=setInterval(()=>{c(k=>k>=l?(clearInterval(y),k):k+1)},o);return()=>clearInterval(y)},[l,o]);const d=f>=l&&l>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(l>0&&!d,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:l===0?\"hidden\":\"visible\",clipPath:l>0&&!d?`inset(0 ${(l-f)/l*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&l>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function lh(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}=lh(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{oo(r,t,i)},[r,a,o]),null}});B({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function 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\",l=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),w(G,{children:[w(\"button\",{id:n.id,class:s,onClick:l,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Yr,{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:()=>!Yt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});B({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,l=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Yr,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function uh(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 ch(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function fh(){const[e,t]=ee(\"load\"),[n,r]=ee([]),[i,a]=ee(!0),[o,s]=ee(null),[l,u]=ee(()=>new Set),[f,c]=ee(null),[p,d]=ee(\"\"),h=se(null),y=se(null),k=Q(Ro),_=C(M=>M.storyData),S=C(M=>M.playthroughId),x=C(M=>M.getSavePayload),E=C(M=>M.loadFromPayload),I=_?.ifid??\"\",b=pe(async()=>{if(!I)return;const M=await Gf(I);r(M),a(!1)},[I]);Se(()=>{b()},[b]),Se(()=>{f&&h.current&&(h.current.focus(),h.current.select())},[f]);const $=se(),A=(M,j=\"success\")=>{clearTimeout($.current),s({text:M,type:j}),$.current=window.setTimeout(()=>s(null),3e3)};Se(()=>()=>clearTimeout($.current),[]);const D=M=>{u(j=>{const g=new Set(j);return g.has(M)?g.delete(M):g.add(M),g})},v=async()=>{if(!(!I||!S))try{const M=x();await xo(I,S,M),A(\"Save created\"),await b()}catch{A(\"Failed to create save\",\"error\")}},T=async M=>{try{const j=x();await Co(M,j),A(\"Save overwritten\"),await b()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async M=>{try{E(M.payload),A(\"Game loaded\"),k&&setTimeout(k,500)}catch{A(\"Failed to load save\",\"error\")}},V=async M=>{if(confirm(\"Delete this save?\"))try{await Kf(M),A(\"Save deleted\"),await b()}catch{A(\"Failed to delete save\",\"error\")}},U=M=>{c(M.meta.id),d(M.meta.title)},O=async()=>{if(!(!f||!p.trim()))try{await Qf(f,p.trim()),c(null),A(\"Save renamed\"),await b()}catch{A(\"Failed to rename\",\"error\")}},Z=M=>{M.key===\"Enter\"?O():M.key===\"Escape\"&&c(null)},X=async M=>{try{const j=await id(M);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),ue=document.createElement(\"a\");ue.href=q,ue.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ue.click(),URL.revokeObjectURL(q),A(\"Save exported\")}catch{A(\"Failed to export save\",\"error\")}},ge=()=>{y.current?.click()},xe=async M=>{const j=M.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),ue=JSON.parse(q);if(!Df(ue))throw new Error(\"Invalid save file format\");await ad(ue,I),A(\"Save imported\"),await b()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((M,j)=>M+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:ge,children:\"Import\"}),w(\"input\",{ref:y,type:\"file\",accept:\".json\",style:\"display:none\",onChange:xe})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(M=>{const j=l.has(M.playthrough.id),g=M.playthrough.id===S;return e===\"save\"&&!g||e===\"load\"&&M.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>D(M.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[M.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:ch(M.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[M.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?w(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>d(ue.target.value),onKeyDown:Z,onBlur:O}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:uh(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>T(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>X(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},M.playthrough.id)}),e===\"save\"&&!i&&!n.some(M=>M.playthrough.id===S)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}B({name:\"save-manager\",render(){return w(fh,{})}});function dh({name:e,def:t}){const[n,r]=ee(()=>Yt.get(e)),i=a=>{r(a),Yt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function hh(){const e=Yt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(dh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(hh,{})}});B({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),l=xt(o.content),u=Ct(l),f=r?t.renderInlineNodes(u):t.renderNodes(u,s?{nobr:!0}:void 0);return s?t.wrap(t.h(fe.Provider,{value:!0},f)):t.wrap(f)}});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):\"\")}),w(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});B({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),w(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});B({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function ph(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=ph(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function gh(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}=gh(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Ft(e){const t=xt(e.content),n=Ct(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const mh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function yh({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=mh.has(e.name),[i,a]=ee(!1),o=he(()=>{try{return Ft(e)}catch(y){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Fo(e),\":\",\" \",y instanceof Error?y.message:String(y)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),l=r?void 0:n?.passages.get(\"PassageFooter\"),u=r?void 0:n?.passages.get(\"PassageDone\"),f=he(()=>{if(!s)return null;try{return Ft(s)}catch(y){return console.error(\"spindle: Error in PassageHeader:\",y),null}},[s?.content]),c=he(()=>{if(!l)return null;try{return Ft(l)}catch(y){return console.error(\"spindle: Error in PassageFooter:\",y),null}},[l?.content]);Se(()=>(u&&a(!0),()=>a(!1)),[e.name]);const p=he(()=>{if(!i||!u)return null;try{return Ft(u)}catch(y){return console.error(\"spindle: Error in PassageDone:\",y),null}},[i,u?.content]),d=e.tags.includes(\"nobr\"),h=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&w(\"div\",{class:\"passage-header\",children:f}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),p&&w(\"div\",{hidden:!0,children:p})]});return d?w(fe.Provider,{value:!0,children:h}):h}const _h=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Tr={type:\"fade-through\",duration:300,pause:50};function bh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!_h.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function tr(e){return{type:e.type,duration:e.duration??Tr.duration,pause:e.pause??Tr.pause}}function vh(e,t,n){const r=bh(e);return r?tr(r):t?tr(t):n?tr(n):{...Tr}}function pa(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function nr(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function rr(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(h=>h.currentPassage),r=C(h=>h.storyData),i=C(h=>h.renderDeferred),[a,o]=ee(n),s=se(\"fade\"),l=se(0),u=se(null),f=se([]),c=pe(()=>{for(const h of f.current)clearTimeout(h);f.current=[],rr(u.current)},[]);Se(()=>{const h=C.getState(),{history:y,historyIndex:k,transitionConfig:_}=h,S=h.consumeNextTransition(),x=l.current;l.current=y.length;const E=!a,I=y.length===1&&k===0&&x>1,b=y.length>1&&k===y.length-1&&x>1&&Math.abs(y.length-x)>1;if(n===a)return;c();const $=r?.passages.get(n);if(!$){s.current=\"none\",o(n);return}if(E||I||b){s.current=\"fade\",o(n);return}const A=vh($.tags,S,_);s.current=A.type;const D=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){D&&nr(D,A),o(n);return}if(A.type===\"fade-through\"){if(!D){o(n);return}nr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=pa(v,A.type);D.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{rr(D)},U);f.current=[V,O];return}if(A.type===\"crossfade\"){if(!D){o(n);return}nr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=pa(v,A.type);D.classList.add(\"passage-container--crossfading\"),D.appendChild(T),o(n);const N=setTimeout(()=>{rr(D)},A.duration);f.current=[N];return}o(n)},[n]);const p=i?r?.passages.get(\"StoryLoading\")??null:a?r?.passages.get(a):null;if(!p&&a&&!i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",a,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[!i&&d&&w(\"div\",{hidden:!0,children:Ft(d)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:p&&w(yh,{passage:p,dataTransition:i?\"none\":s.current},i?\"loading\":a)})]})}});B({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},l=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let u;for(;(u=l.exec(o))!==null;){const c=u[1]??u[5],p=u[2]??u[3]??u[4];if(c)switch(c){case\"goto\":s.goto=p;break;case\"dialog\":s.dialog=p;break;case\"run\":s.run=p;break;case\"name\":s.name=p;break;case\"priority\":s.priority=p?Number(p):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,To(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,No(r)),null}});const wh='*,*: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 ga(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 ma(){const e=Ad(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=wh,document.head.appendChild(t),Wd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",y=document.getElementById(\"root\");throw y&&ga(y,[h]),new Error(`spindle: ${h}`)}const i=Gd(r.content),a=Xd(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&ga(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=Zd(i),C.getState().init(e,n),$o();const o=rd(e.ifid);o&&C.getState().loadFromPayload(o),Mo();const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){let y;for(;(y=s.exec(h.content))!==null;){const k=y[1],_=y[2];/\\{@children\\}/.test(_)&&yr(k)}s.lastIndex=0}for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const y=xt(h.content),k=Ct(y);for(const _ of k)if(_.type===\"macro\"&&_.name===\"widget\"&&_.rawArgs){const S=_.rawArgs.trim().split(/\\s+/),x=S[0].replace(/[\"']/g,\"\"),E=S.slice(1).filter($=>$.startsWith(\"$\")||$.startsWith(\"_\")||$.startsWith(\"@\")),I=_.children,b=wn(I);oo(x,I,E,b),b&&yr(x)}}let l=\"\";C.subscribe(h=>{h.currentPassage!==l&&(l=h.currentPassage,Rd())});let u=C.getState().variables,f=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===f?ud():cd()),u=h.variables,f=h.historyIndex});const c=e.passages.get(\"StoryInterface\");c&&!c.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');Ie(w(Pd,{}),p);const d=Ud();d?d.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ma):ma();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|