@rohal12/spindle 0.39.1 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +1 -1
- package/src/index.tsx +4 -1
- package/src/store.ts +42 -0
- package/src/story-api.ts +21 -6
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.39.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,_a,Je,li,ba,va,wa,Rr,ar,or,Sa,kn={},xn=[],ps=/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??++_a,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function gs(){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 ms(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),zr(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,Ia(r,a,i),t.__e=t.__=null,a.__e!=n&&ka(a)}}function ka(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}),ka(e)}function sr(e){(!e.__d&&(e.__d=!0)&&Je.push(e)&&!Cn.__r++||li!=F.debounceRendering)&&((li=F.debounceRendering)||ba)(Cn)}function Cn(){for(var e,t=1;Je.length;)Je.length>t&&Je.sort(va),e=Je.shift(),t=Je.length,ms(e);Cn.__r=0}function xa(e,t,n,r,i,a,o,s,l,u,f){var c,p,d,h,y,k,_,S=r&&r.__k||xn,x=t.length;for(l=ys(n,t,S,l,x),c=0;c<x;c++)(d=n.__k[c])!=null&&(p=d.__i!=-1&&S[d.__i]||kn,d.__i=c,k=zr(e,d,p,i,a,o,s,l,u,f),h=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&Fr(p.ref,null,d),f.push(d.ref,d.__c||h,d)),y==null&&h!=null&&(y=h),(_=!!(4&d.__u))||p.__k===d.__k?l=Ca(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 ys(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=_s(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)),Ea(s,s));return r}function Ca(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=Ca(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 _s(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 ui(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ps.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||ui(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||ui(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(wa,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=Rr,e.addEventListener(t,a?or:ar,a)):e.removeEventListener(t,a?or:ar,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function ci(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Rr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function zr(e,t,n,r,i,a,o,s,l,u){var f,c,p,d,h,y,k,_,S,x,E,I,b,$,A,D=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=F.__b)&&f(t);e:if(typeof D==\"function\")try{if(_=t.props,S=\"prototype\"in D&&D.prototype.render,x=(f=D.contextType)&&r[f.__c],E=f?x?x.props.value:f.__:r,n.__c?k=(c=t.__c=n.__c).__=c.__E:(S?t.__c=c=new D(_,E):(t.__c=c=new Te(_,E),c.constructor=D,c.render=vs),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)}),xn.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),xn.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?Pa(f.props.children):f,s=xa(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]);lr(t)}else t.__e=n.__e,t.__k=n.__k,v.then||lr(t);F.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=bs(n.__e,t,n,r,i,a,o,l,u);return(f=F.diffed)&&f(t),128&t.__u?void 0:s}function lr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(lr))}function Ia(e,t,n){for(var r=0;r<n.length;r++)Fr(n[r],n[++r],n[++r]);F.__c&&F.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){F.__e(a,i.__v)}})}function Pa(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Xt(e)?e.map(Pa):De({},e)}function bs(e,t,n,r,i,a,o,s,l){var u,f,c,p,d,h,y,k=n.props||kn,_=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=\"\"),xa(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 Fr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){F.__e(i,n)}}function Ea(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Fr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){F.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ea(r[i],t,n||typeof e.type!=\"function\");n||Mr(e.__e),e.__c=e.__=e.__e=void 0}function vs(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=[],zr(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||kn,kn,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),Ia(a,e,o)}function Aa(e,t){Ie(e,t,Aa)}function ws(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,sr(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+Sa++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Jt=xn.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}},_a=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),sr(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),sr(this))},Te.prototype.render=G,Je=[],ba=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,va=function(e,t){return e.__v.__b-t.__v.__b},Cn.__r=0,wa=/(PointerCapture)$|Capture$/i,Rr=0,ar=ci(!1),or=ci(!0),Sa=0;var Ss=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:--Ss,__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,jn,fi,vt=0,$a=[],K=F,di=K.__b,hi=K.__r,pi=K.diffed,gi=K.__c,mi=K.unmount,yi=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,Or(Ra,e)}function Or(e,t,n){var r=kt(je++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ra(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&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ut(e,t){var n=kt(je++,4);!K.__s&&Lr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return vt=5,he(function(){return{current:e}},[])}function Da(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 Lr(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 Ta(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function Na(){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 ks(){for(var e;e=$a.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(gn),t.__h.some(ur),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,di&&di(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),yi&&yi(e,t)},K.__r=function(e){hi&&hi(e),je=0;var t=(W=e.__c).__H;t&&(jn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(gn),t.__h.some(ur),t.__h=[],je=0)),jn=W},K.diffed=function(e){pi&&pi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&($a.push(t)!==1&&fi===K.requestAnimationFrame||((fi=K.requestAnimationFrame)||xs)(ks)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),jn=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(gn),n.__h=n.__h.filter(function(r){return!r.__||ur(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),gi&&gi(e,t)},K.unmount=function(e){mi&&mi(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 _i=typeof requestAnimationFrame==\"function\";function xs(e){var t,n=function(){clearTimeout(r),_i&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);_i&&(t=requestAnimationFrame(n))}function gn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function ur(e){var t=W;e.__c=e.__(),W=t}function Lr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Ra(e,t){return typeof t==\"function\"?t(e):t}const bi=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},Cs=(e=>e?bi(e):bi);function Ma(e,t){for(var n in t)e[n]=t[n];return e}function cr(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function za(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,Wn(i)&&a({t:i})},[e,n,t]),Se(function(){return Wn(i)&&a({t:i}),e(function(){Wn(i)&&a({t:i})})},[e]),n}function Wn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function Fa(e){e()}function Oa(e){return e}function La(){return[!1,Fa]}var Ba=ut;function fr(e,t){this.props=e,this.context=t}function Is(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:cr(this.props,i)}function r(i){return this.shouldComponentUpdate=n,Y(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(fr.prototype=new Te).isPureReactComponent=!0,fr.prototype.shouldComponentUpdate=function(e,t){return cr(this.props,e)||cr(this.state,t)};var vi=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),vi&&vi(e)};var Ps=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Es(e){function t(n){var r=Ma({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ps,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var wi=function(e,t){return e==null?null:Be(Be(e).map(t))},As={map:wi,forEach:wi,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},$s=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)}$s(e,t,n,r)};var Si=F.unmount;function Va(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 Va(r,t,n)})),e}function Ha(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ha(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 qa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ds(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?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),Si&&Si(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=qa(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]=Ha(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]=Va(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 ki=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 Ts(e){return this.getChildContext=function(){return e.context},e.children}function Ns(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(Ts,{context:t.context},e.__v),t.v)}function Rs(e,t){var n=Y(Ns,{__v:e,h:t});return n.containerInfo=t,n}(zt.prototype=new Te).__a=function(e){var t=this,n=qa(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ki(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){ki(e,n,t)})};var Ua=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]/,zs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Fs=/[A-Z0-9]/g,Os=typeof document<\"u\",Ls=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Bs(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ie(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Vs(e,t,n){return Aa(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 xi=F.event;function Hs(){}function qs(){return this.cancelBubble}function Us(){return this.defaultPrevented}F.event=function(e){return xi&&(e=xi(e)),e.persist=Hs,e.isPropagationStopped=qs,e.isDefaultPrevented=Us,e.nativeEvent=e};var Br,js={enumerable:!1,configurable:!0,get:function(){return this.class}},Ci=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||Os&&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\"||Ls(n.type)?l===\"onfocus\"?o=\"onfocusin\":l===\"onblur\"?o=\"onfocusout\":zs.test(o)&&(o=l):l=o=\"oninput\":a&&Ms.test(o)?o=o.replace(Fs,\"-$&\").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\",js)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ua,Ci&&Ci(e)};var Ii=F.__r;F.__r=function(e){Ii&&Ii(e),Br=e.__c};var Pi=F.diffed;F.diffed=function(e){Pi&&Pi(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),Br=null};var Ws={ReactCurrentDispatcher:{current:{readContext:function(e){return Br.__n[e.__c].props.value},useCallback:pe,useContext:Q,useDebugValue:Ta,useDeferredValue:Oa,useEffect:Se,useId:Na,useImperativeHandle:Da,useInsertionEffect:Ba,useLayoutEffect:ut,useMemo:he,useReducer:Or,useRef:se,useState:ee,useSyncExternalStore:za,useTransition:La}}};function Ks(e){return Y.bind(null,e)}function zn(e){return!!e&&e.$$typeof===Ua}function Qs(e){return zn(e)&&e.type===G}function Gs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ys(e){return zn(e)?ws.apply(null,arguments):e}function Js(e){return!!e.__k&&(Ie(null,e),!0)}function Xs(e){return e&&(e.base||e.nodeType===1&&e)||null}var Zs=function(e,t){return e(t)},el=function(e,t){return e(t)},tl=G,nl=zn,un={useState:ee,useId:Na,useReducer:Or,useEffect:Se,useLayoutEffect:ut,useInsertionEffect:Ba,useTransition:La,useDeferredValue:Oa,useSyncExternalStore:za,startTransition:Fa,useRef:se,useImperativeHandle:Da,useMemo:he,useCallback:pe,useContext:Q,useDebugValue:Ta,version:\"18.3.1\",Children:As,render:Bs,hydrate:Vs,unmountComponentAtNode:Js,createPortal:Rs,createElement:Y,createContext:Ke,createFactory:Ks,cloneElement:Ys,createRef:gs,Fragment:G,isValidElement:zn,isElement:nl,isFragment:Qs,isMemo:Gs,findDOMNode:Xs,Component:Te,PureComponent:fr,memo:Is,forwardRef:Es,flushSync:el,unstable_batchedUpdates:Zs,StrictMode:tl,Suspense:mn,SuspenseList:zt,lazy:Ds,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ws};const rl=e=>e;function il(e,t=rl){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 al=e=>{const t=Cs(e),n=r=>il(t,r);return Object.assign(n,t),n},ol=(e=>al);var Vr=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\",dr=\"configurable\",In=\"enumerable\",yn=\"writable\",jt=\"value\",He=e=>!!e&&!!e[ne];function Ne(e){return e?ja(e)||tn(e)||!!e[Lt]||!!e[Ut]?.[Lt]||nn(e)||rn(e):!1}var sl=me[Zt][Ut].toString(),Ei=new WeakMap;function ja(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=Ei.get(n);return r===void 0&&(r=Function.toString.call(n),Ei.set(n,r)),r===sl}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],Pn=(e,t,n,r=ot(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function ll(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\",Kn=e=>typeof e==\"boolean\";function ul(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var cl=e=>wt(e)?e?.[ne]:null,Le=e=>e.copy_||e.base_,Hr=e=>e.modified_?e.copy_:e.base_;function hr(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=ja(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[dr]=!0),(s.get||s.set)&&(r[o]={[dr]:!0,[yn]:!0,[In]:s[In],[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 qr(e,t=!1){return Fn(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)=>{qr(r,!0)},!1)),e}function fl(){oe(2)}var cn={[jt]:fl};function Fn(e){return e===null||!wt(e)?!0:me.isFrozen(e)}var En=\"MapSet\",An=\"Patches\",Ai=\"ArrayMethods\",$n={};function st(e){const t=$n[e];return t||oe(0,e),t}var $i=e=>!!$n[e];function dl(e,t){$n[e]||($n[e]=t)}var Wt,Wa=()=>Wt,hl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:$i(En)?st(En):void 0,arrayMethodsPlugin_:$i(Ai)?st(Ai):void 0});function Di(e,t){t&&(e.patchPlugin_=st(An),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function pr(e){gr(e),e.drafts_.forEach(pl),e.drafts_=null}function gr(e){e===Wt&&(Wt=e.parent_)}var Ti=e=>Wt=hl(Wt,e);function pl(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ni(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(pr(t),oe(4)),Ne(e)&&(e=Ri(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Ri(t,n);return gl(t,e,!0),pr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Vr?e:void 0}function Ri(e,t){if(Fn(t))return t;const n=t[ne];if(!n)return Dn(t,e.handledSet_,e);if(!On(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);Ga(n,e)}return n.copy_}function gl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qr(t,n)}function Ka(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var On=(e,t)=>e.scope_===t,ml=[];function Qa(e,t,n,r){const i=Le(e),a=e.type_;if(r!==void 0&&Oe(i,r,a)===t){Pn(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)??ml;for(const s of o)Pn(i,s,n,a)}function yl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!On(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Hr(a);Qa(e,a.draft_??a,o,n),Ga(a,i)})}function Ga(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)}Ka(e)}}function _l(e,t,n){const{scope_:r}=e;if(He(n)){const i=n[ne];On(i,r)&&i.callbacks_.push(function(){_n(e);const o=Hr(i);Qa(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Le(e);e.type_===3?a.has(n)&&Dn(n,r.handledSet_,r):Oe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Dn(Oe(e.copy_,t,e.type_),r.handledSet_,r)})}function Dn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||He(e)||t.has(e)||!Ne(e)||Fn(e)||(t.add(e),en(e,(r,i)=>{if(He(i)){const a=i[ne];if(On(a,n)){const o=Hr(a);Pn(e,r,o,e.type_),Ka(a)}}else Ne(i)&&Dn(i,t,n)})),e}function bl(e,t){const n=tn(e),r={type_:n?1:0,scope_:t?t.scope_:Wa(),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=Tn;n&&(i=[r],a=Kt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Tn={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 vl(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&ul(t))return a;if(a===Qn(e.base_,t)){_n(e);const o=e.type_===1?+t:t,s=yr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Le(e)},ownKeys(e){return Reflect.ownKeys(Le(e))},set(e,t,n){const r=Ya(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Qn(Le(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(ll(n,i)&&(n!==void 0||Bt(e.base_,t,e.type_)))return!0;_n(e),mr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),_l(e,t,n)),!0},deleteProperty(e,t){return _n(e),Qn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),mr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Le(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[yn]:!0,[dr]:e.type_!==1||t!==\"length\",[In]:r[In],[jt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return at(e.base_)},setPrototypeOf(){oe(12)}},Kt={};for(let e in Tn){let t=Tn[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 Tn.set.call(this,e[0],t,n,e[0])};function Qn(e,t){const n=e[ne];return(n?Le(n):e)[t]}function vl(e,t,n){const r=Ya(t,n);return r?jt in r?r[jt]:r.get?.call(e.draft_):void 0}function Ya(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 mr(e){e.modified_||(e.modified_=!0,e.parent_&&mr(e.parent_))}function _n(e){e.copy_||(e.assigned_=new Map,e.copy_=hr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var wl=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=Ti(this),o=yr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?pr(a):gr(a)}return Di(a,r),Ni(i,a)}else if(!t||!wt(t)){if(i=n(t),i===void 0&&(i=t),i===Vr&&(i=void 0),this.autoFreeze_&&qr(i,!0),r){const a=[],o=[];st(An).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]},Kn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Kn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Kn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||oe(8),He(e)&&(e=Sl(e));const t=Ti(this),n=yr(t,e,void 0);return n[ne].isManual_=!0,gr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return Di(r,t),Ni(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(An).applyPatches_;return He(e)?r(e,t):this.produce(e,i=>r(i,t))}};function yr(e,t,n,r){const[i,a]=nn(t)?st(En).proxyMap_(t,n):rn(t)?st(En).proxySet_(t,n):bl(t,n);return(n?.scope_??Wa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?yl(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 Sl(e){return He(e)||oe(10,e),Ja(e)}function Ja(e){if(!Ne(e)||Fn(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=hr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=hr(e,!0);return en(n,(i,a)=>{Pn(n,i,Ja(a))},r),t&&(t.finalized_=!1),n}function kl(){function t(h,y=[]){if(h.key_!==void 0){const k=h.parent_.copy_??h.parent_.base_,_=cl(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===Vr?void 0:y}),S.push({op:r,path:[],value:h})}function c(h,y){return y.forEach(k=>{const{path:_,op:S}=k;let x=h;for(let $=0;$<_.length-1;$++){const A=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}dl(An,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Qt=new wl,xl=Qt.produce,Cl=Qt.produceWithPatches.bind(Qt),yt=Qt.applyPatches.bind(Qt);const Il=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?xl(i):i;return t(s,a,...o)},e(r.setState,n,r)),Pl=Il,El=/[a-zA-Z]/,Al=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function $l(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 zi(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function Dl(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;t++}n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function 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=zi(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}=$l(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=zi(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&&El.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=Dl(e,o);o=c.endIdx;let p=Al.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 Xa=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function _r(e){Xa.add(e.toLowerCase())}const Fi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Tl=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(Fi[a]){const o=Fi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const l={rawArgs:i.rawArgs,children:[]};i.className&&(l.className=i.className),i.id&&(l.id=i.id),s.branches.push(l);break}if(Xa.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(Tl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function Ur(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Q(ke);return he(()=>[e,t,n],[e,t,n])}function Za(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 eo(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 Nl(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=Za(eo(n)),It=!0}function to(e,t){an=e,lt=0,St=Za(eo(e)),It=!0;for(let n=0;n<t;n++)St();lt=t}function br(){It=!1,an=\"\",lt=0,St=null}function Nn(){return It?{seed:an,pull:lt}:null}function jr(){return!It||!St?Math.random():(lt++,St())}function no(e,t){return e>t&&([e,t]=[t,e]),Math.floor(jr()*(t-e+1))+e}function Rl(){return It}function Ml(){return an}function zl(){return lt}const Fl=500,Ge=new Map,Ol=/\\$(\\w+)/g,Ll=/(?<![.\\w])_(\\w+)/g,Bl=/@(\\w+)/g;function Vl(e){return e.replace(Ol,'variables[\"$1\"]').replace(Ll,'temporary[\"$1\"]').replace(Bl,'locals[\"$1\"]')}function Wr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Vl(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const l=e.charAt(r);if(l===\"\\\\\"&&r+1<e.length)s+=l+e.charAt(r+1),r+=2;else if(l===o){s+=o,r++;break}else s+=l,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,l=\"\";for(;r<e.length&&s>0;){const u=e.charAt(r);if(u===\"{\")s++,l+=u;else if(u===\"}\"){if(s--,s===0)break;l+=u}else if(u===\"\\\\\"&&r+1<e.length)l+=u+e.charAt(r+1),r++;else if(u==='\"'||u===\"'\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===u){l+=f,r++;break}else l+=f,r++}continue}else if(u===\"`\"){for(l+=u,r++;r<e.length;){const f=e.charAt(r);if(f===\"\\\\\"&&r+1<e.length)l+=f+e.charAt(r+1),r+=2;else if(f===\"$\"&&e.charAt(r+1)===\"{\"){l+=\"${\",r+=2;let c=1;for(;r<e.length&&c>0;){const p=e.charAt(r);p===\"{\"?c++:p===\"}\"&&c--,c>0&&(l+=p),r++}l+=\"}\"}else if(f===\"`\"){l+=f,r++;break}else l+=f,r++}continue}else l+=u;r++}t+=Wr(l),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Hl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ro(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\",Hl+t);if(Ge.set(e,r),Ge.size>Fl){const i=Ge.keys().next().value;i!==void 0&&Ge.delete(i)}return r}let fn=null,Oi=null,Li=null;function io(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(fn&&Oi===t&&Li===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:jr,randomInt:no},Oi=t,Li=n,fn}function Pt(e,t,n,r={}){const a=`return (${Wr(e)});`;return ro(a,a)(t,n,r,io())}function ao(e,t,n,r={}){const i=Wr(e);ro(\"exec:\"+i,i)(t,n,r,io())}const ql=/\\{[\\$_@]\\w/;function Ul(e){return ql.test(e)}function jl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function Wl(e,t,n,r){const i=Pt(e,t,n,r);return i==null?\"\":String(i)}function Kl(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=jl(l,o)),l==null?\"\":String(l)}function Ql(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+=Kl(u,t,n,r):i+=Wl(u,t,n,r)}return i}function Ln(){const[e,t,n]=Ur();return pe(r=>r===void 0||!Ul(r)?r:Ql(r,e,t,n),[e,t,n])}function Gl({name:e,scope:t,className:n,id:r}){const i=Ln();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 Yl({expression:e,className:t,id:n}){const r=Ln();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 Jl(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 Xl(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(!Jl(a))return null;return t}function Zl(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=Xl(t[0]);if(s)return s}return t}function eu({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 tu({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(ke),a=Q(fe),[o,s,l]=Ur(),u=r?.length?r:null;if(t.length===0||!n)return w(xr.Provider,{value:u,children:Pe(e,{nobr:a,locals:i})});const f=Zl(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(xr.Provider,{value:u,children:w(eu,{body:e,parentValues:i,ownKeys:c})})}const oo=new Map;function so(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");oo.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function nu(e){return oo.get(e.toLowerCase())}const lo=new Map;function ru(e,t){lo.set(e.toLowerCase(),t)}function iu(e){return lo.get(e.toLowerCase())}const uo=new Set;function au(e){uo.add(e.toLowerCase())}function ou(e){return uo.has(e.toLowerCase())}const co=new Map;function su(e,t){co.set(e.toLowerCase(),t)}function lu(){return Array.from(co.values())}const Bi=document.createElement(\"i\");function fo(e){const t=\"&\"+e+\";\";Bi.innerHTML=t;const n=Bi.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 vr={}.hasOwnProperty;function uu(e){const t={};let n=-1;for(;++n<e.length;)cu(t,e[n]);return t}function cu(e,t){let n;for(n in t){const i=(vr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){vr.call(i,o)||(i[o]=[]);const s=a[o];fu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function fu(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 du(e){const t={};let n=-1;for(;++n<e.length;)hu(t,e[n]);return t}function hu(e,t){let n;for(n in t){const i=(vr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function pu(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 gu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function ho(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+gu[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]/),mu=Qe(/[#-'*+\\--9=?A-Z^-~]/);function wr(e){return e!==null&&(e<32||e===127)}const Sr=Qe(/\\d/),yu=Qe(/[\\dA-Fa-f]/),_u=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 bu=Qe(/\\p{P}|\\p{S}/u),vu=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=ho(wu(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 wu(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 Vi={}.hasOwnProperty,Hi=/^(https?|ircs?|mailto|xmpp)$/i,Su=/^https?$/i;function ku(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=du([{enter:{blockQuote:O,codeFenced:xe,codeFencedFenceInfo:k,codeFencedFenceMeta:k,codeIndented:j,codeText:os,content:Qo,definition:Ho,definitionDestinationString:Uo,definitionLabelString:k,definitionTitleString:k,emphasis:is,htmlFlow:rs,htmlText:ri,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:Yo,strong:as},exit:{atxHeading:Xo,atxHeadingSequence:Go,autolinkEmail:hs,autolinkProtocol:ds,blockQuote:Z,characterEscapeValue:At,characterReferenceMarkerHexadecimal:ii,characterReferenceMarkerNumeric:ii,characterReferenceValue:fs,codeFenced:g,codeFencedFence:R,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:ns,codeIndented:g,codeText:ss,codeTextData:At,data:At,definition:Ko,definitionDestinationString:jo,definitionLabelString:qo,definitionTitleString:Wo,emphasis:ls,hardBreakEscape:ti,hardBreakTrailing:ti,htmlFlow:ni,htmlFlowData:At,htmlText:ni,htmlTextData:At,image:ei,label:Et,labelText:te,lineEnding:ts,link:ei,listOrdered:N,listUnordered:V,paragraph:ge,reference:$,referenceString:qe,resource:$,resourceDestinationString:Un,resourceTitleString:Vo,setextHeading:es,setextHeadingLineSequence:Zo,setextHeadingText:Jo,strong:us,thematicBreak:cs}},...t.htmlExtensions||[]]),u={definitions:r,tightStack:o},f={buffer:k,encode:b,getData:y,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:h,tag:S};let c=t.defaultLineEnding;return p;function p(P){let M=-1,re=0;const Ce=[];let Ee=[],Re=[];for(;++M<P.length;)!c&&(P[M][1].type===\"lineEnding\"||P[M][1].type===\"lineEndingBlank\")&&(c=P[M][2].sliceSerialize(P[M][1])),(P[M][1].type===\"listOrdered\"||P[M][1].type===\"listUnordered\")&&(P[M][0]===\"enter\"?Ce.push(M):d(P.slice(Ce.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(l.enter.null&&l.enter.null.call(f);++M<P.length;){const ai=l[Ae[M][0]],oi=Ae[M][1].type,si=ai[oi];Vi.call(ai,oi)&&si&&si.call({sliceSerialize:Ae[M][2].sliceSerialize,...f},Ae[M][1])}return l.exit.null&&l.exit.null.call(f),i[0].join(\"\")}function d(P){const M=P.length;let re=0,Ce=0,Ee=!1,Re;for(;++re<M;){const Ae=P[re];if(Ae[1]._container)Re=void 0,Ae[0]===\"enter\"?Ce++:Ce--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(Re=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Ce&&(Re?Re=void 0:Ee=!0);break}default:Re=void 0}}P[0][1]._loose=Ee}function h(P,M){u[P]=M}function y(P){return u[P]}function k(){i.push([])}function _(){return i.pop().join(\"\")}function S(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(c||`\n`)}function I(){const P=i[i.length-1],M=P[P.length-1],re=M?M.charCodeAt(M.length-1):null;re===10||re===13||re===null||E()}function b(P){return y(\"ignoreEncode\")?P:ho(P)}function $(){_()}function A(P){o.push(!P._loose),I(),S(\"<ol\"),h(\"expectFirstItem\",!0)}function D(P){o.push(!P._loose),I(),S(\"<ul\"),h(\"expectFirstItem\",!0)}function v(P){if(y(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(P),10);M!==1&&S(' start=\"'+b(String(M))+'\"')}}function T(){y(\"expectFirstItem\")?S(\">\"):U(),I(),S(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),S(\"</ol>\")}function V(){U(),o.pop(),E(),S(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),S(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),S(\"<blockquote>\")}function Z(){o.pop(),I(),S(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),S(\"<p>\")),h(\"slurpAllLineEndings\")}function 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 R(){const P=y(\"fencesCount\")||0;P||(S(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),S(\"<pre><code>\")}function g(){const P=y(\"fencesCount\");P!==void 0&&P<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&E(),y(\"flowCodeSeenData\")&&I(),S(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function 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 Un(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Vo(){a[a.length-1].title=_()}function ei(){let P=a.length-1;const M=a[P],re=M.referenceId||M.labelId,Ce=M.destination===void 0?r[Gt(re)]:M;for(n=!0;P--;)if(a[P].image){n=void 0;break}M.image?(S('<img src=\"'+dn(Ce.destination,t.allowDangerousProtocol?void 0:Su)+'\" alt=\"'),x(M.label),S('\"')):S('<a href=\"'+dn(Ce.destination,t.allowDangerousProtocol?void 0:Hi)+'\"'),S(Ce.title?' title=\"'+Ce.title+'\"':\"\"),M.image?S(\" />\"):(S(\">\"),x(M.label),S(\"</a>\")),a.pop()}function Ho(){k(),a.push({})}function qo(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function Uo(){k(),h(\"ignoreEncode\",!0)}function jo(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Wo(){a[a.length-1].title=_()}function Ko(){const P=a[a.length-1],M=Gt(P.labelId);_(),Vi.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Qo(){h(\"slurpAllLineEndings\",!0)}function Go(P){y(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),S(\"<h\"+y(\"headingRank\")+\">\"))}function Yo(){k(),h(\"slurpAllLineEndings\")}function Jo(){h(\"slurpAllLineEndings\",!0)}function Xo(){S(\"</h\"+y(\"headingRank\")+\">\"),h(\"headingRank\")}function Zo(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function es(){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 ts(P){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(b(this.sliceSerialize(P)))}}function ns(P){x(b(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function ti(){S(\"<br />\")}function rs(){I(),ri()}function ni(){h(\"ignoreEncode\")}function ri(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function is(){S(\"<em>\")}function as(){S(\"<strong>\")}function os(){h(\"inCodeText\",!0),S(\"<code>\")}function ss(){h(\"inCodeText\"),S(\"</code>\")}function ls(){S(\"</em>\")}function us(){S(\"</strong>\")}function cs(){I(),S(\"<hr />\")}function ii(P){h(\"characterReferenceType\",P.type)}function fs(P){const M=this.sliceSerialize(P),re=y(\"characterReferenceType\")?pu(M,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):fo(M);x(b(re)),h(\"characterReferenceType\")}function ds(P){const M=this.sliceSerialize(P);S('<a href=\"'+dn(M,t.allowDangerousProtocol?void 0:Hi)+'\">'),x(b(M)),S(\"</a>\")}function hs(P){const M=this.sliceSerialize(P);S('<a href=\"'+dn(\"mailto:\"+M)+'\">'),x(b(M)),S(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return L(l)?(e.enter(n),s(l)):t(l)}function s(l){return L(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const xu={tokenize:Cu};function Cu(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 Iu={tokenize:Pu},qi={tokenize:Eu};function Pu(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(qi,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(qi,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 Eu(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 Rn(e){if(e===null||le(e)||vu(e))return 1;if(bu(e))return 2}function Bn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const kr={name:\"attention\",resolveAll:Au,tokenize:$u};function Au(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};Ui(c,-l),Ui(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,Bn(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 $u(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Rn(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=Rn(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 Ui(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Du={name:\"autolink\",tokenize:Tu};function Tu(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||wr(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),f):mu(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 Vn={partial:!0,tokenize:Nu};function Nu(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 po={continuation:{tokenize:Mu},exit:zu,name:\"blockQuote\",tokenize:Ru};function Ru(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(po,t,n)(o)}}function zu(e){e.exit(\"blockQuote\")}const go={name:\"characterEscape\",tokenize:Fu};function Fu(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 _u(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const mo={name:\"characterReference\",tokenize:Ou};function Ou(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=yu,f):(e.enter(\"characterReferenceValue\"),a=7,o=Sr,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return o===ye&&!fo(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 ji={partial:!0,tokenize:Bu},Wi={concrete:!0,name:\"codeFenced\",tokenize:Lu};function Lu(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(ji,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(ji,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 Bu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Gn={name:\"codeIndented\",tokenize:Hu},Vu={partial:!0,tokenize:qu};function Hu(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(Vu,o,l)(u):(e.enter(\"codeFlowValue\"),s(u))}function s(u){return u===null||z(u)?(e.exit(\"codeFlowValue\"),o(u)):(e.consume(u),s)}function l(u){return e.exit(\"codeIndented\"),t(u)}}function qu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?i(o):n(o)}}const Uu={name:\"codeText\",previous:Wu,resolve:ju,tokenize:Ku};function ju(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Wu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Ku(e,t,n){let r=0,i,a;return o;function o(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 Qu{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 yo(e){const t={};let n=-1,r,i,a,o,s,l,u;const f=new Qu(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,Gu(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 Gu(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 Yu={resolve:Xu,tokenize:Zu},Ju={partial:!0,tokenize:ec};function Xu(e){return yo(e),e}function Zu(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(Ju,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 ec(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 _o(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||wr(_)?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||wr(_)?n(_):(e.consume(_),_===92?k:y)}function k(_){return _===40||_===41||_===92?(e.consume(_),y):y(_)}}function bo(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 vo(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 tc={name:\"definition\",tokenize:rc},nc={partial:!0,tokenize:ic};function rc(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return bo.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 _o(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(nc,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 ic(e,t,n){return r;function r(s){return le(s)?Vt(e,i)(s):n(s)}function i(s){return vo(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 ac={name:\"hardBreakEscape\",tokenize:oc};function oc(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 sc={name:\"headingAtx\",resolve:lc,tokenize:uc};function lc(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 uc(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 cc=[\"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\"],Ki=[\"pre\",\"script\",\"style\",\"textarea\"],fc={concrete:!0,name:\"htmlFlow\",resolveTo:pc,tokenize:gc},dc={partial:!0,tokenize:yc},hc={partial:!0,tokenize:mc};function pc(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 gc(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&&Ki.includes(ue)?(i=1,r.interrupt?t(g):N(g)):cc.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),R):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(dc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(hc,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 Ki.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 xe(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 mc(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 yc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Vn,t,n)}}const _c={name:\"htmlText\",tokenize:bc};function bc(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 R=\"CDATA[\";return m===R.charCodeAt(a++)?(e.consume(m),a===R.length?y:h):n(m)}function y(m){return m===null?n(m):m===93?(e.consume(m),k):z(m)?(o=y,X(m)):(e.consume(m),y)}function k(m){return m===93?(e.consume(m),_):y(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):y(m)}function S(m){return m===null||m===62?Z(m):z(m)?(o=S,X(m)):(e.consume(m),S)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=x,X(m)):(e.consume(m),x)}function E(m){return m===62?Z(m):x(m)}function I(m){return $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 Kr={name:\"labelEnd\",resolveAll:kc,resolveTo:xc,tokenize:Cc},vc={tokenize:Ic},wc={tokenize:Pc},Sc={tokenize:Ec};function kc(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 xc(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,Bn(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 Cc(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(vc,f,o?f:c)(p):p===91?e.attempt(wc,f,o?u:c)(p):o?f(p):c(p)}function u(p){return e.attempt(Sc,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function Ic(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):_o(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?vo(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 Pc(e,t,n){const r=this;return i;function i(s){return bo.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 Ec(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 Ac={name:\"labelStartImage\",resolveAll:Kr.resolveAll,tokenize:$c};function $c(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 Dc={name:\"labelStartLink\",resolveAll:Kr.resolveAll,tokenize:Tc};function Tc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Yn={name:\"lineEnding\",tokenize:Nc};function Nc(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:Rc};function Rc(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:Oc},exit:Bc,name:\"list\",tokenize:Fc},Mc={partial:!0,tokenize:Vc},zc={partial:!0,tokenize:Lc};function Fc(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:Sr(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 Sr(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),u(d)):n(d)}function u(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(Vn,r.interrupt?n:f,e.attempt(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 Oc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Vn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(zc,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 Lc(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 Bc(e){e.exit(this.containerState.type)}function Vc(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 Qi={name:\"setextUnderline\",resolveTo:Hc,tokenize:qc};function Hc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function qc(e,t,n){const r=this;let i;return a;function a(u){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!==\"lineEnding\"&&r.events[f][1].type!==\"linePrefix\"&&r.events[f][1].type!==\"content\"){c=r.events[f][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=u,o(u)):n(u)}function o(u){return e.enter(\"setextHeadingLineSequence\"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit(\"setextHeadingLineSequence\"),L(u)?H(e,l,\"lineSuffix\")(u):l(u))}function l(u){return u===null||z(u)?(e.exit(\"setextHeadingLine\"),t(u)):n(u)}}const Uc={tokenize:jc};function jc(e){const t=this,n=e.attempt(Vn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Yu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Wc={resolveAll:So()},Kc=wo(\"string\"),Qc=wo(\"text\");function wo(e){return{resolveAll:So(e===\"text\"?Gc: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 So(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function Gc(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 Yc={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:po},Jc={91:tc},Xc={[-2]:Gn,[-1]:Gn,32:Gn},Zc={35:sc,42:bn,45:[Qi,bn],60:fc,61:Qi,95:bn,96:Wi,126:Wi},ef={38:mo,92:go},tf={[-5]:Yn,[-4]:Yn,[-3]:Yn,33:Ac,38:mo,42:kr,60:[Du,_c],91:Dc,92:[ac,go],93:Kr,95:kr,96:Uu},nf={null:[kr,Wc]},rf={null:[42,95]},af={null:[]},of=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rf,contentInitial:Jc,disable:af,document:Yc,flow:Zc,flowInitial:Xc,insideSpan:nf,string:ef,text:tf},Symbol.toStringTag,{value:\"Module\"}));function sf(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=Bn(a,u.events,u),u.events)}function p(T,N){return uf(d(T),N)}function d(T){return lf(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]):R(U);function R(te){return Et;function Et(qe){const dt=qe!==null&&te[qe],ht=qe!==null&&te.null,Un=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(ht)?ht:ht?[ht]:[]];return j(Un)(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 lf(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 uf(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 cf(e){const r={constructs:uu([of,...(e||{}).extensions||[]]),content:i(xu),defined:[],document:i(Iu),flow:i(Uc),lazy:{},string:i(Kc),text:i(Qc)};return r;function i(a){return o;function o(s){return sf(r,a,s)}}}function ff(e){for(;!yo(e););return e}const Gi=/[\\0\\t\\n\\r]/g;function df(){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(Gi.lastIndex=c,u=Gi.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 hf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),ku(n)(ff(cf(n).document().write(df()(e,t,!0))))}const Jn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function pf(){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=Jn[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=Jn[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,gf)),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\"+Jn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function gf(e,t){return t===\"|\"?t:e}class mf{constructor(){this.map=[]}add(t,n,r){yf(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 yf(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 _f(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 bf(){return{flow:{null:{name:\"table\",tokenize:vf,resolveAll:wf}}}}function vf(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 wf(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 mf;for(;++n<e.length;){const d=e[n],h=d[1];d[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,l!==0&&(Yi(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&&Yi(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=_f(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 Yi(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 Sf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function kf(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,Bn(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=Rn(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\"),_=Rn(h);return k._open=!_||_===2&&!!y,k._close=!y||y===2&&!!_,s(h)}}}function xf(e){return hf(e,{allowDangerousHtml:!0,extensions:[bf(),kf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[pf(),Sf()]})}const Cf={update:()=>{},getValues:()=>({})},ke=Ke({}),on=Ke(Cf),fe=Ke(!1),Ji=Ke(!1),xr=Ke(null);function If(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)=>ko(a,o,t));return w(G,{children:i})}function ko(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)=>ko(l,u,n));return Y(i,o,...s)}return null}function Pf({node:e}){const t=Ln(),n=Q(fe),r=Q(ke),i=Q(Ji),a={};for(const[u,f]of Object.entries(e.attributes))a[u]=t(f)??f;const o=e.tag.toLowerCase()===\"svg\",s=e.children.length>0?i||o?Qr(e.children):Pe(e.children,{nobr:n,locals:r}):void 0,l=Y(e.tag,a,s);return o?w(Ji.Provider,{value:!0,children:l}):l}function Ef(){const e=Q(xr),t=Q(fe),n=Q(ke);return!e||e.length===0?null:w(G,{children:Pe(e,{nobr:t,locals:n})})}function Af(e,t){if(ou(e.name))return null;const n=nu(e.name);if(n)return w(tu,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=iu(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function Cr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(Ef,{},t):w(Gl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return w(Yl,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Af(e,t);case\"html\":return w(Pf,{node:e},t);default:return e}}function Qr(e){return e.length===0?null:e.map((t,n)=>Cr(t,n))}function $f(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Df(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)=>Cr(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\"&&$f(i))i+=Df(l,a);else{const u=r.length;r.push(Cr(l,s)),i+=`<span data-tw=\"${u}\"></span>`}}const o=xf(i);return If(o,r,t?.nobr)}function Tf(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 Nf(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 Rf(){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.\",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 Xn(e,t){const n=Ze(e);n.includes(t)||(n.push(t),Ht(e,n))}function Rt(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(`${Me}${t}`,e),Xn(`${gt}${e.meta.ifid}`,t),Xn(`${Nt}${e.meta.playthroughId}`,t)},async getSave(e){return Fe(`${Me}${e}`)},async deleteSave(e){const t=Fe(`${Me}${e}`);t&&(Rt(`${gt}${t.meta.ifid}`,e),Rt(`${Nt}${t.meta.playthroughId}`,e)),ze(`${Me}${e}`)},async getSavesByIfid(e){const t=Ze(`${gt}${e}`),n=[];for(const r of t){const i=Fe(`${Me}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=Ze(`${gt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Rt(`${Nt}${r.meta.playthroughId}`,n),ze(`${Me}${n}`)}ze(`${gt}${e}`)},async deleteSavesByPlaythrough(e){const t=Ze(`${Nt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Rt(`${gt}${r.meta.ifid}`,n),ze(`${Me}${n}`)}return ze(`${Nt}${e}`),t},async putPlaythrough(e){Ht(`${Dt}${e.id}`,e),Xn(`${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&&Rt(`${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 Xi=\"spindle\",zf=1;function Ff(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(Xi,zf);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(Xi);l.onsuccess=()=>o(),l.onerror=()=>s(l.error)})}}}let _t=null;async function Of(){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)}),Ff()}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 Rf()}async function J(){return _t||(_t=await Of(),_t)}function Lf(){_t=null}function Zi(){return _t?.type??\"memory\"}const xo=new Map,Hn=new Map;function Bf(e,t){xo.set(e,t),Hn.set(t,e)}function Vf(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(Hn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const l of Object.keys(i))s[l]=n(i[l]);return s}if(Vf(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=Hn.get(a);if(o!==void 0){const l={};for(const u of Object.keys(i))l[u]=n(i[u]);return t.delete(i),{[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=xo.get(o);if(!l){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(s))f[c]=t(s[c]);return f}const u=Object.create(l.prototype);for(const f of Object.keys(s))u[f]=t(s[f]);return u}const i=r.constructor;if(Hn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Ir=null,Pr=null,ea=!1;function Hf(e){Ir=e}function qf(e){Pr=e}function Uf(e){if(Pr)try{const i=new Function(\"passage\",\"variables\",Pr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Ir)try{const r=Ir(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function jf(){ea||(ea=!0)}async function ta(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 Wf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function Co(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Uf(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 Io(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 Kf(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 Qf(e){await(await J()).deleteSave(e)}async function Gf(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 Yf(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 Jf=\"autosave.\",Xf=\"slot.\",qn=\"slotIndex.\";function sn(e,t){return t!=null?`${Xf}${t}.${e}`:`${Jf}${e}`}async function Zf(e,t,n,r,i){const a=await J(),o=sn(e,r),s=await a.getMeta(o);if(s){const u=await Io(s,n,i);if(u)return u}const l=await Co(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,l.meta.id),r!=null){const u=`${qn}${e}`,f=await a.getMeta(u)??[];f.includes(r)||await a.setMeta(u,[...f,r])}return l}async function na(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 ed(e,t){const n=sn(e,t),r=await(await J()).getMeta(n);if(r)return Kf(r)}async function Er(e){const t={};await na(e)&&(t[\"\"]=!0);const n=`${qn}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await na(e,i)&&(t[i]=!0);return t}async function Ar(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 td(e){const t=[],n=await Ar(e);n&&t.push(n);const r=`${qn}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await Ar(e,a);o&&t.push(o)}return t}async function nd(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=`${qn}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Gr=\"spindle.session.\";function rd(e,t){try{sessionStorage.setItem(`${Gr}${e}`,JSON.stringify(t))}catch{}}function id(e){try{const t=sessionStorage.getItem(`${Gr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Nf(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 Po(e){try{sessionStorage.removeItem(`${Gr}${e}`)}catch{}}async function ad(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 od(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 sd(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 Eo(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Po(e)}async function Ao(){if(await(await J()).destroy(),Lf(),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 $o(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 Do(){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&&qf(n.content)}let To=0,we=[],Zn=!1,ct=[],qt=null,Ve=null;function Yr(e){const t=C.getState();try{return!!Pt(e,t.variables,t.temporary)}catch{return!1}}function No(e,t){const n=To++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Yr(e),priority:i?.priority??0};return we.push(o),we.sort((s,l)=>l.priority-s.priority),()=>{we=we.filter(s=>s.id!==n)}}function Ro(e){we=we.filter(t=>t.name!==e)}function ld(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();ao(n.run,r.variables,r.temporary)}n.dialog&&(ct.push({passageName:n.dialog}),qt?.()),n.goto&&C.getState().navigate(n.goto)}}const ud=10;function cd(){if(!Zn){Zn=!0;try{for(let e=0;e<ud;e++){let t=!1;const n=[...we];for(const r of n){if(!we.includes(r))continue;const i=Yr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(we=we.filter(o=>o.id!==r.id)),ld(r))}if(!t)break}}finally{Zn=!1}}}function fd(){for(const e of we)e.lastResult=Yr(e.condition)}function dd(){we=[],ct=[],To=0,Ve?.closeAll()}function hd(e){return qt=e,ct.length>0&&e(),()=>{qt===e&&(qt=null)}}function pd(){return ct.shift()}function gd(){return ct.length}function md(e){Ve?Ve.push(e):(ct.push(e),qt?.())}function yd(){ct=[]}function _d(e){return Ve=e,()=>{Ve===e&&(Ve=null)}}function bd(){Ve?.close()}function vd(){yd(),Ve?.closeAll()}function wd(){return Ve?.isOpen()??!1}kl();const Sd=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let nt={},be=[],Ue={};function ra(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function ia(e,t){const[,n,r]=Cl(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:ra(n),inverse:ra(r)}}function kd(e){let t=nt;for(let n=0;n<e;n++)t=yt(t,be[n].forward);return t}let ve=[];function er(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}}}rd(t.ifid,{passage:n,variables:rt(r),history:ve,historyIndex:a,visitCounts:o,renderCounts:s,prng:Nn()})}}function aa(e){nt=e,be=[],Ue=e,ve=[]}let vn=[];function xd(e){return vn.push(e),()=>{vn=vn.filter(t=>t!==e)}}function Mo(){for(const e of vn)e()}let wn=[];function Cd(e){return wn.push(e),()=>{wn=wn.filter(t=>t!==e)}}function Id(){for(const e of wn)e()}function oa(e){e?.prng?to(e.prng.seed,e.prng.pull):e&&br()}const C=ol()(Pl((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);aa(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;jf().then(async()=>{const s=await Wf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ta(o);e(f=>{f.playthroughId=u})}const l=await Er(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(Sd.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=ia(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:Nn()});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,er(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,oa(t().history[t().historyIndex]),er(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,oa(t().history[t().historyIndex]),er(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;e(s=>{s.renderDeferred=!1}),Id();const a=t().renderDeferred;br(),dd();const o=ie(r);aa(ie(o)),e(s=>{s.currentPassage=i.name,s.variables=o,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1},a||(s.renderDeferred=!1)}),Ue=t().variables,Do(),Po(n.ifid),Mo(),ta(n.ifid).then(s=>{e(l=>{l.playthroughId=s})}).catch(s=>console.error(\"spindle: failed to start new playthrough\",s))},save:(n,r)=>{const{storyData:i,playthroughId:a}=t();if(!i)return;const o=t().getSavePayload();e(s=>{s.saveError=null}),Zf(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}),ed(r.ifid,n).then(i=>{i&&t().loadFromPayload(i)}).catch(i=>{console.error(\"spindle: failed to load save\",i),e(a=>{a.loadError=i instanceof Error?i.message:\"Failed to load\"})}))},hasSave:n=>{const{storyData:r,knownSaves:i}=t();return r?(n??\"\")in i:!1},getSaveInfo:async n=>{const{storyData:r}=t();return r?Ar(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?td(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&nd(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&&Eo(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&&Ao().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&&$o(r.ifid,n).then(async()=>{const i=await Er(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:Nn()}},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(ia(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?to(n.prng.seed,n.prng.pull):br()},getHistoryVariables:n=>ie(kd(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})}}))),Pd=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Ed(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Pd,r=t?.tags.includes(\"nobr\")??!1,i=he(()=>{try{const a=xt(n),o=Ct(a);return w(G,{children:Qr(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(fe.Provider,{value:!0,children:i}):i}const zo=Ke(null);function Jr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=se(r);a.current=r;const o=pe(()=>a.current(),[]),s=C(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(zo.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 Ad(){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(()=>_d({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Se(()=>hd(()=>{const o=[];for(;gd()>0;){const s=pd();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(G,{children:e.map((o,s)=>w(Jr,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function $d(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Se(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(G,{children:[w(Ed,{}),w(Ad,{})]});return n?w(fe.Provider,{value:!0,children:r}):r}function Dd(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Td(){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=Dd(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 Mt=new Map;let ce={},sa=!1;function Fo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Nd(){localStorage.setItem(Fo(),JSON.stringify(ce))}function tr(){if(!sa){sa=!0;try{const e=localStorage.getItem(Fo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ce={...ce,...t})}}catch{}}}const Yt={addToggle(e,t){Mt.set(e,{type:\"toggle\",config:t}),e in ce||(ce[e]=t.default),tr()},addList(e,t){Mt.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),tr()},addRange(e,t){Mt.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),tr()},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,Nd()},getAll(){return{...ce}},getDefinitions(){return Mt},hasAny(){return Mt.size>0}};function Rd(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};ao(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,$r=new Set,Dr=new Map;function Md(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Dr.get(r)??0)+1;return Dr.set(r,i),i===1?r:`${r}:${i}`}function zd(e){return Mn.set(e.id,e),ua(),()=>{Mn.delete(e.id),ua()}}function la(){return Array.from(Mn.values())}function Fd(e){return Mn.get(e)}function Od(){Dr.clear()}function Ld(e){return $r.add(e),()=>{$r.delete(e)}}function ua(){for(const e of $r)e()}function Bd(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=Md(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),zd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Vd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Oo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Xr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Oo(t):\"\"}function Hd(e){const t=e.match(/^\\s*([\"']?\\$[\\w.]+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function qd(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function Ud(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const jd={useState:ee,useRef:se,useEffect:Se,useLayoutEffect:ut,useCallback:pe,useMemo:he,useContext:Q};function ca(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function Wd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=Ln(),a=s(a),o=s(o));const{update:l,getValues:u}=Q(on),f=Q(fe),c=Q(ke),d={collectText:Vd,sourceLocation:Xr,parseVarArgs:Hd,extractOptions:qd,h:Y,renderNodes:(h,y)=>Pe(h,{nobr:f,locals:c,...y}),renderInlineNodes:Qr,hooks:jd,useAction:Bd,className:a,id:o,resolve:s,cls:Ud(e.name,a),mutate:h=>Rd(h,u(),l),update:l,getValues:u,wrap:h=>a||o?Y(\"span\",{id:o,class:a},h):Y(G,null,h)};if(e.merged){d.merged=Ur();const h=d.merged;d.evaluate=y=>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(_=>ca(_.variables,k)),d.getValue=()=>ca(C.getState().variables,k),d.setValue=_=>{C.setState(S=>{Wd(S.variables,k,_)})}}return e.render(i,d)}ru(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(su(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)au(i);r&&_r(e.name)}let pn=null,Tr=null;function Kd(){return Tr}function Qd(){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){Bf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return lu()},saves:{setTitleGenerator(e){Hf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?sd(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Zi()}},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 Eo(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await Ao(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await $o(t.ifid,e);const n=await Er(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return Zi()}},getActions(){return la()},performAction(e,t){const n=Fd(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===\"beforerestart\")return Cd(t);if(e===\"storyinit\")return xd(t);if(e===\"actionsChanged\")return Ld(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(la())})})})},watch(e,t){return No(e,t)},unwatch(e){Ro(e)},openDialog(e,t){md({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){bd()},closeAllDialogs(){vd()},isDialogOpen(){return wd()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Tr=new Promise(e=>{pn=e})},ready(){pn&&(C.getState().clearDeferredRender(),pn(),pn=null,Tr=null)},random(){return jr()},randomInt(e,t){return no(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){Nl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=Nn())})},isEnabled(){return Rl()},get seed(){return Ml()},get pull(){return zl()}}}}function Gd(){window.Story=Qd()}const Yd=/^\\$(\\w+)\\s*=\\s*(.+)$/,fa=/\\$(\\w+(?:\\.\\w+)*)/g,da=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Jd=new Set([\"number\",\"string\",\"boolean\"]);function Lo(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,Lo(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 Xd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Yd);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=Lo(s);t.set(a,{...l,name:a,default:s})}return t}function Zd(e){const t=new Set;let n;for(da.lastIndex=0;(n=da.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function eh(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 th(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Zd(i.content);let o;for(fa.lastIndex=0;(o=fa.exec(i.content))!==null;){const s=o[1],l=eh(s,t,a);l&&n.push(`Passage \"${r}\": ${l}`)}}return n}function nh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function Sn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&Sn(t.children))return!0;if(t.type===\"macro\"){if(Sn(t.children))return!0;if(t.branches){for(const n of t.branches)if(Sn(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${Xr()}: ${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 rh(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 ih(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 ha(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}}${Xr()}:`,u);return}const l=n?i[t]:r[t];if(!ih(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}=rh(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,ha(o,l,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{ha(o,l,s,n,r,i,e)},[n,r,i]),null}});function ah(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=oh(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 oh(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 sh(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}=ah(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=sh(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 lh(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 uh({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=lh(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(uh,{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 ch(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 pa(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}=ch(e),a=Q(fe),o=s=>{s.preventDefault(),pa(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:()=>{pa(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 Zr(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?Zr(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 Bo=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=Zr(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(Bo.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(Bo);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=Zr(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 fh(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}=fh(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{so(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(Jr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}ft({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});ft({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});ft({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});ft({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=C(n=>n.load),t=C(n=>n.hasSave);return C(n=>n.knownSaves),{perform:()=>e(),disabled:!t()}}});ft({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});ft({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});ft({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!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(Jr,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function dh(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 hh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function ph(){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(zo),_=C(R=>R.storyData),S=C(R=>R.playthroughId),x=C(R=>R.getSavePayload),E=C(R=>R.loadFromPayload),I=_?.ifid??\"\",b=pe(async()=>{if(!I)return;const R=await Yf(I);r(R),a(!1)},[I]);Se(()=>{b()},[b]),Se(()=>{f&&h.current&&(h.current.focus(),h.current.select())},[f]);const $=se(),A=(R,j=\"success\")=>{clearTimeout($.current),s({text:R,type:j}),$.current=window.setTimeout(()=>s(null),3e3)};Se(()=>()=>clearTimeout($.current),[]);const D=R=>{u(j=>{const g=new Set(j);return g.has(R)?g.delete(R):g.add(R),g})},v=async()=>{if(!(!I||!S))try{const R=x();await Co(I,S,R),A(\"Save created\"),await b()}catch{A(\"Failed to create save\",\"error\")}},T=async R=>{try{const j=x();await Io(R,j),A(\"Save overwritten\"),await b()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async R=>{try{E(R.payload),A(\"Game loaded\"),k&&setTimeout(k,500)}catch{A(\"Failed to load save\",\"error\")}},V=async R=>{if(confirm(\"Delete this save?\"))try{await Qf(R),A(\"Save deleted\"),await b()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{c(R.meta.id),d(R.meta.title)},O=async()=>{if(!(!f||!p.trim()))try{await Gf(f,p.trim()),c(null),A(\"Save renamed\"),await b()}catch{A(\"Failed to rename\",\"error\")}},Z=R=>{R.key===\"Enter\"?O():R.key===\"Escape\"&&c(null)},X=async R=>{try{const j=await ad(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=()=>{y.current?.click()},xe=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(!Tf(ue))throw new Error(\"Invalid save file format\");await od(ue,I),A(\"Save imported\"),await b()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((R,j)=>R+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick: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(R=>{const j=l.has(R.playthrough.id),g=R.playthrough.id===S;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>D(R.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[R.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:hh(R.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[R.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?w(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>d(ue.target.value),onKeyDown:Z,onBlur:O}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:dh(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(ph,{})}});function gh({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 mh(){const e=Yt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(gh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(mh,{})}});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 yh(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=yh(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 _h(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}=_h(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 bh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function vh({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=bh.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,\"”\",Oo(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 wh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Nr={type:\"fade-through\",duration:300,pause:50};function Sh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!wh.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function nr(e){return{type:e.type,duration:e.duration??Nr.duration,pause:e.pause??Nr.pause}}function kh(e,t,n){const r=Sh(e);return r?nr(r):t?nr(t):n?nr(n):{...Nr}}function ga(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function rr(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function ir(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}B({name:\"passage\",interpolate:!0,render(e,t){const n=C(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=[],ir(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=kh($.tags,S,_);s.current=A.type;const D=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){D&&rr(D,A),o(n);return}if(A.type===\"fade-through\"){if(!D){o(n);return}rr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ga(v,A.type);D.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{ir(D)},U);f.current=[V,O];return}if(A.type===\"crossfade\"){if(!D){o(n);return}rr(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=ga(v,A.type);D.classList.add(\"passage-container--crossfading\"),D.appendChild(T),o(n);const N=setTimeout(()=>{ir(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(vh,{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,No(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,Ro(r)),null}});const xh='*,*: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 ma(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 ya(){const e=Td(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=xh,document.head.appendChild(t),Gd(),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&&ma(y,[h]),new Error(`spindle: ${h}`)}const i=Xd(r.content),a=th(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&ma(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=nh(i),C.getState().init(e,n),Do();const o=id(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(_)&&_r(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=Sn(I);so(x,I,E,b),b&&_r(x)}}let l=\"\";C.subscribe(h=>{h.currentPassage!==l&&(l=h.currentPassage,Od())});let u=C.getState().variables,f=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===f?cd():fd()),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($d,{}),p);const d=Kd();d?d.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ya):ya();</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.40.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xt,F,wa,Je,fi,Sa,ka,xa,zr,or,sr,Ca,xn={},Cn=[],_s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zt=Array.isArray;function De(e,t){for(var n in t)e[n]=t[n];return e}function Fr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Y(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Xt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Lt(e,o,r,i,null)}function Lt(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++wa,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function bs(){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 vs(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),Or(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,Aa(r,a,i),t.__e=t.__=null,a.__e!=n&&Ia(a)}}function Ia(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}),Ia(e)}function lr(e){(!e.__d&&(e.__d=!0)&&Je.push(e)&&!In.__r++||fi!=F.debounceRendering)&&((fi=F.debounceRendering)||Sa)(In)}function In(){for(var e,t=1;Je.length;)Je.length>t&&Je.sort(ka),e=Je.shift(),t=Je.length,vs(e);In.__r=0}function Pa(e,t,n,r,i,a,o,s,l,u,f){var c,p,d,h,y,k,_,S=r&&r.__k||Cn,x=t.length;for(l=ws(n,t,S,l,x),c=0;c<x;c++)(d=n.__k[c])!=null&&(p=d.__i!=-1&&S[d.__i]||xn,d.__i=c,k=Or(e,d,p,i,a,o,s,l,u,f),h=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&Lr(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=Ea(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 ws(e,t,n,r,i){var a,o,s,l,u,f=n.length,c=f,p=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=Lt(null,o,null,null,null):Zt(o)?o=e.__k[a]=Lt(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Lt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+p,o.__=e,o.__b=e.__b+1,s=null,(u=o.__i=Ss(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)),Da(s,s));return r}function Ea(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=Ea(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\"||(Zt(e)?e.some(function(n){Be(n,t)}):t.push(e)),t}function Ss(e,t,n,r){var i,a,o,s=e.key,l=e.type,u=t[n],f=u!=null&&(2&u.__u)==0;if(u===null&&s==null||f&&s==u.key&&l==u.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((u=t[o=i>=0?i--:a++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return o}return-1}function di(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||_s.test(t)?n:n+\"px\"}function un(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||di(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||di(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(xa,\"$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=zr,e.addEventListener(t,a?sr:or,a)):e.removeEventListener(t,a?sr:or,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 hi(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=zr++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function Or(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=xs),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)}),Cn.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),Cn.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?$a(f.props.children):f,s=Pa(e,Zt($)?$:[$],t,n,r,i,a,o,s,l,u),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),k&&(c.__E=c.__=null)}catch(v){if(t.__v=null,l||a!=null)if(v.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(A=a.length;A--;)Fr(a[A]);ur(t)}else t.__e=n.__e,t.__k=n.__k,v.then||ur(t);F.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ks(n.__e,t,n,r,i,a,o,l,u);return(f=F.diffed)&&f(t),128&t.__u?void 0:s}function ur(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ur))}function Aa(e,t,n){for(var r=0;r<n.length;r++)Lr(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 $a(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Zt(e)?e.map($a):De({},e)}function ks(e,t,n,r,i,a,o,s,l){var u,f,c,p,d,h,y,k=n.props||xn,_=t.props,S=t.type;if(S==\"svg\"?i=\"http://www.w3.org/2000/svg\":S==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(u=0;u<a.length;u++)if((d=a[u])&&\"setAttribute\"in d==!!S&&(S?d.localName==S:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(S==null)return document.createTextNode(_);e=document.createElementNS(i,S,_.is&&_),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(S==null)k===_||s&&e.data==_||(e.data=_);else{if(a=a&&Xt.call(e.childNodes),!s&&a!=null)for(k={},u=0;u<e.attributes.length;u++)k[(d=e.attributes[u]).name]=d.value;for(u in k)d=k[u],u==\"dangerouslySetInnerHTML\"?c=d:u==\"children\"||u in _||u==\"value\"&&\"defaultValue\"in _||u==\"checked\"&&\"defaultChecked\"in _||un(e,u,null,d,i);for(u in _)d=_[u],u==\"children\"?p=d:u==\"dangerouslySetInnerHTML\"?f=d:u==\"value\"?h=d:u==\"checked\"?y=d:s&&typeof d!=\"function\"||k[u]===d||un(e,u,d,k[u],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Pa(t.type==\"template\"?e.content:e,Zt(p)?p:[p],t,n,r,S==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&bt(n,0),s,l),a!=null)for(u=a.length;u--;)Fr(a[u]);s||(u=\"value\",S==\"progress\"&&h==null?e.removeAttribute(\"value\"):h!=null&&(h!==e[u]||S==\"progress\"&&!h||S==\"option\"&&h!=k[u])&&un(e,u,h,k[u],i),u=\"checked\",y!=null&&y!=e[u]&&un(e,u,y,k[u],i))}return e}function Lr(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 Da(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Lr(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]&&Da(r[i],t,n||typeof e.type!=\"function\");n||Fr(e.__e),e.__c=e.__=e.__e=void 0}function xs(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=[],Or(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||xn,xn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Xt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Aa(a,e,o)}function Ta(e,t){Ie(e,t,Ta)}function Cs(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?Xt.call(arguments,2):n),Lt(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,lr(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\"+Ca++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Xt=Cn.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}},wa=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),lr(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),lr(this))},Te.prototype.render=G,Je=[],Sa=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ka=function(e,t){return e.__v.__b-t.__v.__b},In.__r=0,xa=/(PointerCapture)$|Capture$/i,zr=0,or=hi(!1),sr=hi(!0),Ca=0;var Is=0;function w(e,t,n,r,i,a){t||(t={});var o,s,l=t;if(\"ref\"in l)for(s in l={},t)s==\"ref\"?o=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Is,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return F.vnode&&F.vnode(u),u}var je,W,Wn,pi,vt=0,Na=[],K=F,gi=K.__b,mi=K.__r,yi=K.diffed,_i=K.__c,bi=K.unmount,vi=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,Br(Fa,e)}function Br(e,t,n){var r=kt(je++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Fa(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(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&&Vr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ut(e,t){var n=kt(je++,4);!K.__s&&Vr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function se(e){return vt=5,he(function(){return{current:e}},[])}function Ra(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 Vr(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 Ma(e,t){K.useDebugValue&&K.useDebugValue(t?t(e):e)}function za(){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 Ps(){for(var e;e=Na.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(mn),t.__h.some(cr),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){W=null,gi&&gi(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),vi&&vi(e,t)},K.__r=function(e){mi&&mi(e),je=0;var t=(W=e.__c).__H;t&&(Wn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(mn),t.__h.some(cr),t.__h=[],je=0)),Wn=W},K.diffed=function(e){yi&&yi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Na.push(t)!==1&&pi===K.requestAnimationFrame||((pi=K.requestAnimationFrame)||Es)(Ps)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Wn=W=null},K.__c=function(e,t){t.some(function(n){try{n.__h.some(mn),n.__h=n.__h.filter(function(r){return!r.__||cr(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],K.__e(r,n.__v)}}),_i&&_i(e,t)},K.unmount=function(e){bi&&bi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{mn(r)}catch(i){t=i}}),n.__H=void 0,t&&K.__e(t,n.__v))};var wi=typeof requestAnimationFrame==\"function\";function Es(e){var t,n=function(){clearTimeout(r),wi&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);wi&&(t=requestAnimationFrame(n))}function mn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function cr(e){var t=W;e.__c=e.__(),W=t}function Vr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Fa(e,t){return typeof t==\"function\"?t(e):t}const Si=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},As=(e=>e?Si(e):Si);function Oa(e,t){for(var n in t)e[n]=t[n];return e}function fr(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 La(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,Kn(i)&&a({t:i})},[e,n,t]),Se(function(){return Kn(i)&&a({t:i}),e(function(){Kn(i)&&a({t:i})})},[e]),n}function Kn(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 Ba(e){e()}function Va(e){return e}function Ha(){return[!1,Ba]}var qa=ut;function dr(e,t){this.props=e,this.context=t}function $s(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:fr(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}(dr.prototype=new Te).isPureReactComponent=!0,dr.prototype.shouldComponentUpdate=function(e,t){return fr(this.props,e)||fr(this.state,t)};var ki=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ki&&ki(e)};var Ds=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Ts(e){function t(n){var r=Oa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ds,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var xi=function(e,t){return e==null?null:Be(Be(e).map(t))},Ns={map:xi,forEach:xi,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},Rs=F.__e;F.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Rs(e,t,n,r)};var Ci=F.unmount;function Ua(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=Oa({},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 Ua(r,t,n)})),e}function ja(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ja(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function yn(){this.__u=0,this.o=null,this.__b=null}function Wa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ms(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?Y(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Ft(){this.i=null,this.l=null}F.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ci&&Ci(e)},(yn.prototype=new Te).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Wa(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]=ja(u,u.__c.__P,u.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=s,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},yn.prototype.componentWillUnmount=function(){this.o=[]},yn.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=Ua(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 Ii=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function zs(e){return this.getChildContext=function(){return e.context},e.children}function Fs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){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(zs,{context:t.context},e.__v),t.v)}function Os(e,t){var n=Y(Fs,{__v:e,h:t});return n.containerInfo=t,n}(Ft.prototype=new Te).__a=function(e){var t=this,n=Wa(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ii(t,e,r)):i()};n?n(a):a()}},Ft.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},Ft.prototype.componentDidUpdate=Ft.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ii(e,n,t)})};var Ka=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ls=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Bs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Vs=/[A-Z0-9]/g,Hs=typeof document<\"u\",qs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Us(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ie(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function js(e,t,n){return Ta(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 Pi=F.event;function Ws(){}function Ks(){return this.cancelBubble}function Qs(){return this.defaultPrevented}F.event=function(e){return Pi&&(e=Pi(e)),e.persist=Ws,e.isPropagationStopped=Ks,e.isDefaultPrevented=Qs,e.nativeEvent=e};var Hr,Gs={enumerable:!1,configurable:!0,get:function(){return this.class}},Ei=F.vnode;F.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||Hs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var l=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":l===\"translate\"&&s===\"no\"?s=!1:l[0]===\"o\"&&l[1]===\"n\"?l===\"ondoubleclick\"?o=\"ondblclick\":l!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||qs(n.type)?l===\"onfocus\"?o=\"onfocusin\":l===\"onblur\"?o=\"onfocusout\":Bs.test(o)&&(o=l):l=o=\"oninput\":a&&Ls.test(o)?o=o.replace(Vs,\"-$&\").toLowerCase():s===null&&(s=void 0),l===\"oninput\"&&i[o=l]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=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\",Gs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ka,Ei&&Ei(e)};var Ai=F.__r;F.__r=function(e){Ai&&Ai(e),Hr=e.__c};var $i=F.diffed;F.diffed=function(e){$i&&$i(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),Hr=null};var Ys={ReactCurrentDispatcher:{current:{readContext:function(e){return Hr.__n[e.__c].props.value},useCallback:pe,useContext:Q,useDebugValue:Ma,useDeferredValue:Va,useEffect:Se,useId:za,useImperativeHandle:Ra,useInsertionEffect:qa,useLayoutEffect:ut,useMemo:he,useReducer:Br,useRef:se,useState:ee,useSyncExternalStore:La,useTransition:Ha}}};function Js(e){return Y.bind(null,e)}function Fn(e){return!!e&&e.$$typeof===Ka}function Xs(e){return Fn(e)&&e.type===G}function Zs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function el(e){return Fn(e)?Cs.apply(null,arguments):e}function tl(e){return!!e.__k&&(Ie(null,e),!0)}function nl(e){return e&&(e.base||e.nodeType===1&&e)||null}var rl=function(e,t){return e(t)},il=function(e,t){return e(t)},al=G,ol=Fn,cn={useState:ee,useId:za,useReducer:Br,useEffect:Se,useLayoutEffect:ut,useInsertionEffect:qa,useTransition:Ha,useDeferredValue:Va,useSyncExternalStore:La,startTransition:Ba,useRef:se,useImperativeHandle:Ra,useMemo:he,useCallback:pe,useContext:Q,useDebugValue:Ma,version:\"18.3.1\",Children:Ns,render:Us,hydrate:js,unmountComponentAtNode:tl,createPortal:Os,createElement:Y,createContext:Ke,createFactory:Js,cloneElement:el,createRef:bs,Fragment:G,isValidElement:Fn,isElement:ol,isFragment:Xs,isMemo:Zs,findDOMNode:nl,Component:Te,PureComponent:dr,memo:$s,forwardRef:Ts,flushSync:il,unstable_batchedUpdates:rl,StrictMode:al,Suspense:yn,SuspenseList:Ft,lazy:Ms,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ys};const sl=e=>e;function ll(e,t=sl){const n=cn.useSyncExternalStore(e.subscribe,cn.useCallback(()=>t(e.getState()),[e,t]),cn.useCallback(()=>t(e.getInitialState()),[e,t]));return cn.useDebugValue(n),n}const ul=e=>{const t=As(e),n=r=>ll(t,r);return Object.assign(n,t),n},cl=(e=>ul);var qr=Symbol.for(\"immer-nothing\"),Bt=Symbol.for(\"immer-draftable\"),ne=Symbol.for(\"immer-state\");function oe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var me=Object,at=me.getPrototypeOf,jt=\"constructor\",en=\"prototype\",hr=\"configurable\",Pn=\"enumerable\",_n=\"writable\",Wt=\"value\",He=e=>!!e&&!!e[ne];function Ne(e){return e?Qa(e)||nn(e)||!!e[Bt]||!!e[jt]?.[Bt]||rn(e)||an(e):!1}var fl=me[en][jt].toString(),Di=new WeakMap;function Qa(e){if(!e||!wt(e))return!1;const t=at(e);if(t===null||t===me[en])return!0;const n=me.hasOwnProperty.call(t,jt)&&t[jt];if(n===Object)return!0;if(!Xe(n))return!1;let r=Di.get(n);return r===void 0&&(r=Function.toString.call(n),Di.set(n,r)),r===fl}function tn(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_:nn(e)?1:rn(e)?2:an(e)?3:0}var Vt=(e,t,n=ot(e))=>n===2?e.has(t):me[en].hasOwnProperty.call(e,t),Oe=(e,t,n=ot(e))=>n===2?e.get(t):e[t],En=(e,t,n,r=ot(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function dl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var nn=Array.isArray,rn=e=>e instanceof Map,an=e=>e instanceof Set,wt=e=>typeof e==\"object\",Xe=e=>typeof e==\"function\",Qn=e=>typeof e==\"boolean\";function hl(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var pl=e=>wt(e)?e?.[ne]:null,Le=e=>e.copy_||e.base_,Ur=e=>e.modified_?e.copy_:e.base_;function pr(e,t){if(rn(e))return new Map(e);if(an(e))return new Set(e);if(nn(e))return Array[en].slice.call(e);const n=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[_n]===!1&&(s[_n]=!0,s[hr]=!0),(s.get||s.set)&&(r[o]={[hr]:!0,[_n]:!0,[Pn]:s[Pn],[Wt]: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 jr(e,t=!1){return On(e)||He(e)||!Ne(e)||(ot(e)>1&&me.defineProperties(e,{set:fn,add:fn,clear:fn,delete:fn}),me.freeze(e),t&&tn(e,(n,r)=>{jr(r,!0)},!1)),e}function gl(){oe(2)}var fn={[Wt]:gl};function On(e){return e===null||!wt(e)?!0:me.isFrozen(e)}var An=\"MapSet\",$n=\"Patches\",Ti=\"ArrayMethods\",Dn={};function st(e){const t=Dn[e];return t||oe(0,e),t}var Ni=e=>!!Dn[e];function ml(e,t){Dn[e]||(Dn[e]=t)}var Kt,Ga=()=>Kt,yl=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ni(An)?st(An):void 0,arrayMethodsPlugin_:Ni(Ti)?st(Ti):void 0});function Ri(e,t){t&&(e.patchPlugin_=st($n),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function gr(e){mr(e),e.drafts_.forEach(_l),e.drafts_=null}function mr(e){e===Kt&&(Kt=e.parent_)}var Mi=e=>Kt=yl(Kt,e);function _l(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function zi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(gr(t),oe(4)),Ne(e)&&(e=Fi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Fi(t,n);return bl(t,e,!0),gr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==qr?e:void 0}function Fi(e,t){if(On(t))return t;const n=t[ne];if(!n)return Tn(t,e.handledSet_,e);if(!Ln(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);Xa(n,e)}return n.copy_}function bl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&jr(t,n)}function Ya(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Ln=(e,t)=>e.scope_===t,vl=[];function Ja(e,t,n,r){const i=Le(e),a=e.type_;if(r!==void 0&&Oe(i,r,a)===t){En(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;tn(i,(l,u)=>{if(He(u)){const f=s.get(u)||[];f.push(l),s.set(u,f)}})}const o=e.draftLocations_.get(t)??vl;for(const s of o)En(i,s,n,a)}function wl(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Ln(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=Ur(a);Ja(e,a.draft_??a,o,n),Xa(a,i)})}function Xa(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)}Ya(e)}}function Sl(e,t,n){const{scope_:r}=e;if(He(n)){const i=n[ne];Ln(i,r)&&i.callbacks_.push(function(){bn(e);const o=Ur(i);Ja(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Le(e);e.type_===3?a.has(n)&&Tn(n,r.handledSet_,r):Oe(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Tn(Oe(e.copy_,t,e.type_),r.handledSet_,r)})}function Tn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||He(e)||t.has(e)||!Ne(e)||On(e)||(t.add(e),tn(e,(r,i)=>{if(He(i)){const a=i[ne];if(Ln(a,n)){const o=Ur(a);En(e,r,o,e.type_),Ya(a)}}else Ne(i)&&Tn(i,t,n)})),e}function kl(e,t){const n=nn(e),r={type_:n?1:0,scope_:t?t.scope_:Ga(),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=Nn;n&&(i=[r],a=Qt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Nn={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(!Vt(i,t,e.type_))return xl(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&hl(t))return a;if(a===Gn(e.base_,t)){bn(e);const o=e.type_===1?+t:t,s=_r(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=Za(Le(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Gn(Le(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(dl(n,i)&&(n!==void 0||Vt(e.base_,t,e.type_)))return!0;bn(e),yr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Sl(e,t,n)),!0},deleteProperty(e,t){return bn(e),Gn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),yr(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&&{[_n]:!0,[hr]:e.type_!==1||t!==\"length\",[Pn]:r[Pn],[Wt]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return at(e.base_)},setPrototypeOf(){oe(12)}},Qt={};for(let e in Nn){let t=Nn[e];Qt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Qt.deleteProperty=function(e,t){return Qt.set.call(this,e,t,void 0)};Qt.set=function(e,t,n){return Nn.set.call(this,e[0],t,n,e[0])};function Gn(e,t){const n=e[ne];return(n?Le(n):e)[t]}function xl(e,t,n){const r=Za(t,n);return r?Wt in r?r[Wt]:r.get?.call(e.draft_):void 0}function Za(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 yr(e){e.modified_||(e.modified_=!0,e.parent_&&yr(e.parent_))}function bn(e){e.copy_||(e.assigned_=new Map,e.copy_=pr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Cl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(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=Mi(this),o=_r(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?gr(a):mr(a)}return Ri(a,r),zi(i,a)}else if(!t||!wt(t)){if(i=n(t),i===void 0&&(i=t),i===qr&&(i=void 0),this.autoFreeze_&&jr(i,!0),r){const a=[],o=[];st($n).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]},Qn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Qn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Qn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||oe(8),He(e)&&(e=Il(e));const t=Mi(this),n=_r(t,e,void 0);return n[ne].isManual_=!0,mr(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return Ri(r,t),zi(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($n).applyPatches_;return He(e)?r(e,t):this.produce(e,i=>r(i,t))}};function _r(e,t,n,r){const[i,a]=rn(t)?st(An).proxyMap_(t,n):an(t)?st(An).proxySet_(t,n):kl(t,n);return(n?.scope_??Ga()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?wl(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=l;a.modified_&&u&&u.generatePatches_(a,[],l)}),i}function Il(e){return He(e)||oe(10,e),eo(e)}function eo(e){if(!Ne(e)||On(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=pr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=pr(e,!0);return tn(n,(i,a)=>{En(n,i,eo(a))},r),t&&(t.finalized_=!1),n}function Pl(){function t(h,y=[]){if(h.key_!==void 0){const k=h.parent_.copy_??h.parent_.base_,_=pl(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||Vt(k,E)))return null;y.push(E)}if(h.parent_)return t(h.parent_,y);y.reverse();try{n(h.copy_,y)}catch{return null}return y}function n(h,y){let k=h;for(let _=0;_<y.length-1;_++){const S=y[_];if(k=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;tn(h.assigned_,(I,b)=>{const $=Oe(S,I,E),A=Oe(x,I,E),D=b?Vt(S,I)?r:i:a;if($===A&&D===r)return;const v=y.concat(I);k.push(D===a?{op:D,path:v}:{op:D,path:v,value:d(A)}),_.push(D===i?{op:a,path:v}:D===a?{op:i,path:v,value:d($)}:{op:r,path:v,value:d($)})})}function u(h,y,k,_){let{base_:S,copy_:x}=h,E=0;S.forEach(I=>{if(!x.has(I)){const b=y.concat([E]);k.push({op:a,path:b,value:I}),_.unshift({op:i,path:b,value:I})}E++}),E=0,x.forEach(I=>{if(!S.has(I)){const b=y.concat([E]);k.push({op:i,path:b,value:I}),_.unshift({op:a,path:b,value:I})}E++})}function f(h,y,k){const{patches_:_,inversePatches_:S}=k;_.push({op:r,path:[],value:y===qr?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===jt)&&oe(19),Xe(x)&&D===en&&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(nn(h))return h.map(p);if(rn(h))return new Map(Array.from(h.entries()).map(([k,_])=>[k,p(_)]));if(an(h))return new Set(Array.from(h).map(p));const y=Object.create(at(h));for(const k in h)y[k]=p(h[k]);return Vt(h,Bt)&&(y[Bt]=h[Bt]),y}function d(h){return He(h)?p(h):h}ml($n,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Gt=new Cl,El=Gt.produce,Al=Gt.produceWithPatches.bind(Gt),yt=Gt.applyPatches.bind(Gt);const $l=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?El(i):i;return t(s,a,...o)},e(r.setState,n,r)),Dl=$l,Tl=/[a-zA-Z]/,Nl=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Rl(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function Oi(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 Li(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function Ml(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;t++}n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function 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=Li(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}=Rl(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=Li(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:_}=Oi(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}=Oi(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&&Tl.test(u[0]))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:u,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const c=Ml(e,o);o=c.endIdx;let p=Nl.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 to=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function br(e){to.add(e.toLowerCase())}const Bi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},zl=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(Bi[a]){const o=Bi[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(to.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(zl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function Wr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=Q(ke);return he(()=>[e,t,n],[e,t,n])}function no(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 ro(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,on=\"\",lt=0,St=null;function Fl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,on=n,lt=0,St=no(ro(n)),It=!0}function io(e,t){on=e,lt=0,St=no(ro(e)),It=!0;for(let n=0;n<t;n++)St();lt=t}function vr(){It=!1,on=\"\",lt=0,St=null}function Rn(){return It?{seed:on,pull:lt}:null}function Kr(){return!It||!St?Math.random():(lt++,St())}function ao(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Kr()*(t-e+1))+e}function Ol(){return It}function Ll(){return on}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 Qr(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 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+=Qr(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 Wl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function oo(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 dn=null,Vi=null,Hi=null;function so(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(dn&&Vi===t&&Hi===n)return dn;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(h=>r(h)>0),o=(...d)=>d.every(h=>r(h)>0),s=d=>n[d??C.getState().currentPassage]??0;return dn={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const h=d.history[d.historyIndex-1]?.passage;return h?d.storyData?.passages.get(h):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(h=>s(h)>0),hasRenderedAll:(...d)=>d.every(h=>s(h)>0),random:Kr,randomInt:ao},Vi=t,Hi=n,dn}function Pt(e,t,n,r={}){const a=`return (${Qr(e)});`;return oo(a,a)(t,n,r,so())}function lo(e,t,n,r={}){const i=Qr(e);oo(\"exec:\"+i,i)(t,n,r,so())}const Kl=/\\{[\\$_@]\\w/;function Ql(e){return Kl.test(e)}function Gl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function Yl(e,t,n,r){const i=Pt(e,t,n,r);return i==null?\"\":String(i)}function Jl(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=Gl(l,o)),l==null?\"\":String(l)}function Xl(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+=Jl(u,t,n,r):i+=Yl(u,t,n,r)}return i}function Bn(){const[e,t,n]=Wr();return pe(r=>r===void 0||!Ql(r)?r:Xl(r,e,t,n),[e,t,n])}function Zl({name:e,scope:t,className:n,id:r}){const i=Bn();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 eu({expression:e,className:t,id:n}){const r=Bn();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 tu(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 nu(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(!tu(a))return null;return t}function ru(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=nu(t[0]);if(s)return s}return t}function iu({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(sn.Provider,{value:f,children:w(ke.Provider,{value:o,children:Pe(e,{nobr:r,locals:o})})})}function au({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=Q(ke),a=Q(fe),[o,s,l]=Wr(),u=r?.length?r:null;if(t.length===0||!n)return w(Cr.Provider,{value:u,children:Pe(e,{nobr:a,locals:i})});const f=ru(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(Cr.Provider,{value:u,children:w(iu,{body:e,parentValues:i,ownKeys:c})})}const uo=new Map;function co(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");uo.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function ou(e){return uo.get(e.toLowerCase())}const fo=new Map;function su(e,t){fo.set(e.toLowerCase(),t)}function lu(e){return fo.get(e.toLowerCase())}const ho=new Set;function uu(e){ho.add(e.toLowerCase())}function cu(e){return ho.has(e.toLowerCase())}const po=new Map;function fu(e,t){po.set(e.toLowerCase(),t)}function du(){return Array.from(po.values())}const qi=document.createElement(\"i\");function go(e){const t=\"&\"+e+\";\";qi.innerHTML=t;const n=qi.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 wr={}.hasOwnProperty;function hu(e){const t={};let n=-1;for(;++n<e.length;)pu(t,e[n]);return t}function pu(e,t){let n;for(n in t){const i=(wr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){wr.call(i,o)||(i[o]=[]);const s=a[o];gu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function gu(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 mu(e){const t={};let n=-1;for(;++n<e.length;)yu(t,e[n]);return t}function yu(e,t){let n;for(n in t){const i=(wr.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 _u(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 bu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function mo(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+bu[n]+\";\"}}function Yt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const $e=Qe(/[A-Za-z]/),ye=Qe(/[\\dA-Za-z]/),vu=Qe(/[#-'*+\\--9=?A-Z^-~]/);function Sr(e){return e!==null&&(e<32||e===127)}const kr=Qe(/\\d/),wu=Qe(/[\\dA-Fa-f]/),Su=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 ku=Qe(/\\p{P}|\\p{S}/u),xu=Qe(/\\s/);function Qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function hn(e,t){const n=mo(Cu(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 Cu(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 Ui={}.hasOwnProperty,ji=/^(https?|ircs?|mailto|xmpp)$/i,Iu=/^https?$/i;function Pu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],l=mu([{enter:{blockQuote:O,codeFenced:xe,codeFencedFenceInfo:k,codeFencedFenceMeta:k,codeIndented:j,codeText:cs,content:Xo,definition:Wo,definitionDestinationString:Qo,definitionLabelString:k,definitionTitleString:k,emphasis:ls,htmlFlow:ss,htmlText:oi,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:es,strong:us},exit:{atxHeading:ns,atxHeadingSequence:Zo,autolinkEmail:ys,autolinkProtocol:ms,blockQuote:Z,characterEscapeValue:At,characterReferenceMarkerHexadecimal:si,characterReferenceMarkerNumeric:si,characterReferenceValue:gs,codeFenced:g,codeFencedFence:R,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:os,codeIndented:g,codeText:fs,codeTextData:At,data:At,definition:Jo,definitionDestinationString:Go,definitionLabelString:Ko,definitionTitleString:Yo,emphasis:ds,hardBreakEscape:ii,hardBreakTrailing:ii,htmlFlow:ai,htmlFlowData:At,htmlText:ai,htmlTextData:At,image:ri,label:Et,labelText:te,lineEnding:as,link:ri,listOrdered:N,listUnordered:V,paragraph:ge,reference:$,referenceString:qe,resource:$,resourceDestinationString:jn,resourceTitleString:jo,setextHeading:is,setextHeadingLineSequence:rs,setextHeadingText:ts,strong:hs,thematicBreak:ps}},...t.htmlExtensions||[]]),u={definitions:r,tightStack:o},f={buffer:k,encode:b,getData:y,lineEndingIfNeeded:I,options:t,raw:x,resume:_,setData:h,tag:S};let c=t.defaultLineEnding;return p;function p(P){let M=-1,re=0;const Ce=[];let Ee=[],Re=[];for(;++M<P.length;)!c&&(P[M][1].type===\"lineEnding\"||P[M][1].type===\"lineEndingBlank\")&&(c=P[M][2].sliceSerialize(P[M][1])),(P[M][1].type===\"listOrdered\"||P[M][1].type===\"listUnordered\")&&(P[M][0]===\"enter\"?Ce.push(M):d(P.slice(Ce.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(l.enter.null&&l.enter.null.call(f);++M<P.length;){const li=l[Ae[M][0]],ui=Ae[M][1].type,ci=li[ui];Ui.call(li,ui)&&ci&&ci.call({sliceSerialize:Ae[M][2].sliceSerialize,...f},Ae[M][1])}return l.exit.null&&l.exit.null.call(f),i[0].join(\"\")}function d(P){const M=P.length;let re=0,Ce=0,Ee=!1,Re;for(;++re<M;){const Ae=P[re];if(Ae[1]._container)Re=void 0,Ae[0]===\"enter\"?Ce++:Ce--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&(Re=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Ce&&(Re?Re=void 0:Ee=!0);break}default:Re=void 0}}P[0][1]._loose=Ee}function h(P,M){u[P]=M}function y(P){return u[P]}function k(){i.push([])}function _(){return i.pop().join(\"\")}function S(P){n&&(h(\"lastWasTag\",!0),i[i.length-1].push(P))}function x(P){h(\"lastWasTag\"),i[i.length-1].push(P)}function E(){x(c||`\n`)}function I(){const P=i[i.length-1],M=P[P.length-1],re=M?M.charCodeAt(M.length-1):null;re===10||re===13||re===null||E()}function b(P){return y(\"ignoreEncode\")?P:mo(P)}function $(){_()}function A(P){o.push(!P._loose),I(),S(\"<ol\"),h(\"expectFirstItem\",!0)}function D(P){o.push(!P._loose),I(),S(\"<ul\"),h(\"expectFirstItem\",!0)}function v(P){if(y(\"expectFirstItem\")){const M=Number.parseInt(this.sliceSerialize(P),10);M!==1&&S(' start=\"'+b(String(M))+'\"')}}function T(){y(\"expectFirstItem\")?S(\">\"):U(),I(),S(\"<li>\"),h(\"expectFirstItem\"),h(\"lastWasTag\")}function N(){U(),o.pop(),E(),S(\"</ol>\")}function V(){U(),o.pop(),E(),S(\"</ul>\")}function U(){y(\"lastWasTag\")&&!y(\"slurpAllLineEndings\")&&I(),S(\"</li>\"),h(\"slurpAllLineEndings\")}function O(){o.push(!1),I(),S(\"<blockquote>\")}function Z(){o.pop(),I(),S(\"</blockquote>\"),h(\"slurpAllLineEndings\")}function X(){o[o.length-1]||(I(),S(\"<p>\")),h(\"slurpAllLineEndings\")}function 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 R(){const P=y(\"fencesCount\")||0;P||(S(\">\"),h(\"slurpOneLineEnding\",!0)),h(\"fencesCount\",P+1)}function j(){I(),S(\"<pre><code>\")}function g(){const P=y(\"fencesCount\");P!==void 0&&P<2&&u.tightStack.length>0&&!y(\"lastWasTag\")&&E(),y(\"flowCodeSeenData\")&&I(),S(\"</code></pre>\"),P!==void 0&&P<2&&I(),h(\"flowCodeSeenData\"),h(\"fencesCount\"),h(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function te(P){a[a.length-1].labelId=this.sliceSerialize(P)}function 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 jn(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function jo(){a[a.length-1].title=_()}function ri(){let P=a.length-1;const M=a[P],re=M.referenceId||M.labelId,Ce=M.destination===void 0?r[Yt(re)]:M;for(n=!0;P--;)if(a[P].image){n=void 0;break}M.image?(S('<img src=\"'+hn(Ce.destination,t.allowDangerousProtocol?void 0:Iu)+'\" alt=\"'),x(M.label),S('\"')):S('<a href=\"'+hn(Ce.destination,t.allowDangerousProtocol?void 0:ji)+'\"'),S(Ce.title?' title=\"'+Ce.title+'\"':\"\"),M.image?S(\" />\"):(S(\">\"),x(M.label),S(\"</a>\")),a.pop()}function Wo(){k(),a.push({})}function Ko(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function Qo(){k(),h(\"ignoreEncode\",!0)}function Go(){a[a.length-1].destination=_(),h(\"ignoreEncode\")}function Yo(){a[a.length-1].title=_()}function Jo(){const P=a[a.length-1],M=Yt(P.labelId);_(),Ui.call(r,M)||(r[M]=a[a.length-1]),a.pop()}function Xo(){h(\"slurpAllLineEndings\",!0)}function Zo(P){y(\"headingRank\")||(h(\"headingRank\",this.sliceSerialize(P).length),I(),S(\"<h\"+y(\"headingRank\")+\">\"))}function es(){k(),h(\"slurpAllLineEndings\")}function ts(){h(\"slurpAllLineEndings\",!0)}function ns(){S(\"</h\"+y(\"headingRank\")+\">\"),h(\"headingRank\")}function rs(P){h(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function is(){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 as(P){if(!y(\"slurpAllLineEndings\")){if(y(\"slurpOneLineEnding\")){h(\"slurpOneLineEnding\");return}if(y(\"inCodeText\")){x(\" \");return}x(b(this.sliceSerialize(P)))}}function os(P){x(b(this.sliceSerialize(P))),h(\"flowCodeSeenData\",!0)}function ii(){S(\"<br />\")}function ss(){I(),oi()}function ai(){h(\"ignoreEncode\")}function oi(){t.allowDangerousHtml&&h(\"ignoreEncode\",!0)}function ls(){S(\"<em>\")}function us(){S(\"<strong>\")}function cs(){h(\"inCodeText\",!0),S(\"<code>\")}function fs(){h(\"inCodeText\"),S(\"</code>\")}function ds(){S(\"</em>\")}function hs(){S(\"</strong>\")}function ps(){I(),S(\"<hr />\")}function si(P){h(\"characterReferenceType\",P.type)}function gs(P){const M=this.sliceSerialize(P),re=y(\"characterReferenceType\")?_u(M,y(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):go(M);x(b(re)),h(\"characterReferenceType\")}function ms(P){const M=this.sliceSerialize(P);S('<a href=\"'+hn(M,t.allowDangerousProtocol?void 0:ji)+'\">'),x(b(M)),S(\"</a>\")}function ys(P){const M=this.sliceSerialize(P);S('<a href=\"'+hn(\"mailto:\"+M)+'\">'),x(b(M)),S(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return L(l)?(e.enter(n),s(l)):t(l)}function s(l){return L(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const Eu={tokenize:Au};function Au(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 $u={tokenize:Du},Wi={tokenize:Tu};function Du(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(Wi,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(Wi,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 Tu(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 Mn(e){if(e===null||le(e)||xu(e))return 1;if(ku(e))return 2}function Vn(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 xr={name:\"attention\",resolveAll:Nu,tokenize:Ru};function Nu(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};Ki(c,-l),Ki(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,Vn(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 Ru(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Mn(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=Mn(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 Ki(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Mu={name:\"autolink\",tokenize:zu};function zu(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||Sr(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),f):vu(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 Hn={partial:!0,tokenize:Fu};function Fu(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||z(a)?t(a):n(a)}}const yo={continuation:{tokenize:Lu},exit:Bu,name:\"blockQuote\",tokenize:Ou};function Ou(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 Lu(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(yo,t,n)(o)}}function Bu(e){e.exit(\"blockQuote\")}const _o={name:\"characterEscape\",tokenize:Vu};function Vu(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 Su(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const bo={name:\"characterReference\",tokenize:Hu};function Hu(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=wu,f):(e.enter(\"characterReferenceValue\"),a=7,o=kr,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return o===ye&&!go(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 Qi={partial:!0,tokenize:Uu},Gi={concrete:!0,name:\"codeFenced\",tokenize:qu};function qu(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(Qi,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(Qi,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 Uu(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 Yn={name:\"codeIndented\",tokenize:Wu},ju={partial:!0,tokenize:Ku};function Wu(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(ju,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 Ku(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:Yu,resolve:Gu,tokenize:Ju};function Gu(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 Yu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Ju(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),l):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):z(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),l):(e.enter(\"codeTextData\"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit(\"codeTextData\"),l(c)):(e.consume(c),u)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",u(c))}}class Xu{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 vo(e){const t={};let n=-1,r,i,a,o,s,l,u;const f=new Xu(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,Zu(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 Zu(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 ec={resolve:nc,tokenize:rc},tc={partial:!0,tokenize:ic};function nc(e){return vo(e),e}function rc(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(tc,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 ic(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 wo(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||Sr(_)?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||Sr(_)?n(_):(e.consume(_),_===92?k:y)}function k(_){return _===40||_===41||_===92?(e.consume(_),y):y(_)}}function So(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 ko(e,t,n,r,i,a){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),u(p))}function u(p){return p===o?(e.exit(a),l(o)):p===null?n(p):z(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),H(e,u,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(p))}function f(p){return p===o||p===null||z(p)?(e.exit(\"chunkString\"),u(p)):(e.consume(p),p===92?c:f)}function c(p){return p===o||p===92?(e.consume(p),f):f(p)}}function Ht(e,t){let n;return r;function r(i){return z(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ac={name:\"definition\",tokenize:sc},oc={partial:!0,tokenize:lc};function sc(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return So.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),l):n(d)}function l(d){return le(d)?Ht(e,u)(d):u(d)}function u(d){return wo(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(oc,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 lc(e,t,n){return r;function r(s){return le(s)?Ht(e,i)(s):n(s)}function i(s){return ko(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 uc={name:\"hardBreakEscape\",tokenize:cc};function cc(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 fc={name:\"headingAtx\",resolve:dc,tokenize:hc};function dc(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 hc(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 pc=[\"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\"],Yi=[\"pre\",\"script\",\"style\",\"textarea\"],gc={concrete:!0,name:\"htmlFlow\",resolveTo:_c,tokenize:bc},mc={partial:!0,tokenize:wc},yc={partial:!0,tokenize:vc};function _c(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 bc(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&&Yi.includes(ue)?(i=1,r.interrupt?t(g):N(g)):pc.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),R):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(mc,j,V)(g)):g===null||z(g)?(e.exit(\"htmlFlowData\"),V(g)):(e.consume(g),N)}function V(g){return e.check(yc,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 Yi.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 xe(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 vc(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 wc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Hn,t,n)}}const Sc={name:\"htmlText\",tokenize:kc};function kc(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 R=\"CDATA[\";return m===R.charCodeAt(a++)?(e.consume(m),a===R.length?y:h):n(m)}function y(m){return m===null?n(m):m===93?(e.consume(m),k):z(m)?(o=y,X(m)):(e.consume(m),y)}function k(m){return m===93?(e.consume(m),_):y(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):y(m)}function S(m){return m===null||m===62?Z(m):z(m)?(o=S,X(m)):(e.consume(m),S)}function x(m){return m===null?n(m):m===63?(e.consume(m),E):z(m)?(o=x,X(m)):(e.consume(m),x)}function E(m){return m===62?Z(m):x(m)}function I(m){return $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 Gr={name:\"labelEnd\",resolveAll:Pc,resolveTo:Ec,tokenize:Ac},xc={tokenize:$c},Cc={tokenize:Dc},Ic={tokenize:Tc};function Pc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function Ec(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,Vn(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 Ac(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(p){return a?a._inactive?c(p):(o=r.parser.defined.includes(Yt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),l):n(p)}function l(p){return p===40?e.attempt(xc,f,o?f:c)(p):p===91?e.attempt(Cc,f,o?u:c)(p):o?f(p):c(p)}function u(p){return e.attempt(Ic,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function $c(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return le(c)?Ht(e,a)(c):a(c)}function a(c){return c===41?f(c):wo(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return le(c)?Ht(e,l)(c):f(c)}function s(c){return n(c)}function l(c){return c===34||c===39||c===40?ko(e,u,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function u(c){return le(c)?Ht(e,f)(c):f(c)}function f(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Dc(e,t,n){const r=this;return i;function i(s){return So.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Yt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Tc(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 Nc={name:\"labelStartImage\",resolveAll:Gr.resolveAll,tokenize:Rc};function Rc(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 Mc={name:\"labelStartLink\",resolveAll:Gr.resolveAll,tokenize:zc};function zc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Jn={name:\"lineEnding\",tokenize:Fc};function Fc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const vn={name:\"thematicBreak\",tokenize:Oc};function Oc(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:Hc},exit:Uc,name:\"list\",tokenize:Vc},Lc={partial:!0,tokenize:jc},Bc={partial:!0,tokenize:qc};function Vc(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:kr(d)){if(r.containerState.type||(r.containerState.type=h,e.enter(h,{_container:!0})),h===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(vn,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),l(d)}return n(d)}function l(d){return kr(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(Hn,r.interrupt?n:f,e.attempt(Lc,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 Hc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Hn,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(Bc,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 qc(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 Uc(e){e.exit(this.containerState.type)}function jc(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 Ji={name:\"setextUnderline\",resolveTo:Wc,tokenize:Kc};function Wc(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 Kc(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:Gc};function Gc(e){const t=this,n=e.attempt(Hn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ec,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 Yc={resolveAll:Co()},Jc=xo(\"string\"),Xc=xo(\"text\");function xo(e){return{resolveAll:Co(e===\"text\"?Zc: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 Co(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 Zc(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 ef={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:yo},tf={91:ac},nf={[-2]:Yn,[-1]:Yn,32:Yn},rf={35:fc,42:vn,45:[Ji,vn],60:gc,61:Ji,95:vn,96:Gi,126:Gi},af={38:bo,92:_o},of={[-5]:Jn,[-4]:Jn,[-3]:Jn,33:Nc,38:bo,42:xr,60:[Mu,Sc],91:Mc,92:[uc,_o],93:Gr,95:xr,96:Qu},sf={null:[xr,Yc]},lf={null:[42,95]},uf={null:[]},cf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lf,contentInitial:tf,disable:uf,document:ef,flow:rf,flowInitial:nf,insideSpan:sf,string:af,text:of},Symbol.toStringTag,{value:\"Module\"}));function ff(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=Vn(a,u.events,u),u.events)}function p(T,N){return hf(d(T),N)}function d(T){return df(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]):R(U);function R(te){return Et;function Et(qe){const dt=qe!==null&&te[qe],ht=qe!==null&&te.null,jn=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(ht)?ht:ht?[ht]:[]];return j(jn)(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 df(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 hf(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 pf(e){const r={constructs:hu([cf,...(e||{}).extensions||[]]),content:i(Eu),defined:[],document:i($u),flow:i(Qc),lazy:{},string:i(Jc),text:i(Xc)};return r;function i(a){return o;function o(s){return ff(r,a,s)}}}function gf(e){for(;!vo(e););return e}const Xi=/[\\0\\t\\n\\r]/g;function mf(){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(Xi.lastIndex=c,u=Xi.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 yf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Pu(n)(gf(pf(n).document().write(mf()(e,t,!0))))}const Xn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function _f(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Xn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=Xn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,bf)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+Xn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function bf(e,t){return t===\"|\"?t:e}class vf{constructor(){this.map=[]}add(t,n,r){wf(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 wf(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 Sf(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 kf(){return{flow:{null:{name:\"table\",tokenize:xf,resolveAll:Cf}}}}function xf(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 Cf(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 vf;for(;++n<e.length;){const d=e[n],h=d[1];d[0]===\"enter\"?h.type===\"tableHead\"?(s=!1,l!==0&&(Zi(p,t,l,u,f),f=void 0,l=0),u={type:\"table\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",u,t]])):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[[\"enter\",f,t]])),i=h.type===\"tableDelimiterRow\"?2:f?3:1):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=pn(p,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):h.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=pn(p,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):h.type===\"tableHead\"?(s=!0,l=n):h.type===\"tableRow\"||h.type===\"tableDelimiterRow\"?(l=n,a[1]!==0?(o[0]=o[1],c=pn(p,t,a,i,n,c)):o[1]!==0&&(c=pn(p,t,o,i,n,c)),i=0):i&&(h.type===\"data\"||h.type===\"tableDelimiterMarker\"||h.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(l!==0&&Zi(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=Sf(t.events,n))}return e}function pn(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},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 Zi(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 If(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Pf(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]===\"enter\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]===\"exit\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type=\"strikethroughSequence\",o[u][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},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,Vn(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=Mn(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\"),_=Mn(h);return k._open=!_||_===2&&!!y,k._close=!y||y===2&&!!_,s(h)}}}function Ef(e){return yf(e,{allowDangerousHtml:!0,extensions:[kf(),Pf(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[_f(),If()]})}const Af={update:()=>{},getValues:()=>({})},ke=Ke({}),sn=Ke(Af),fe=Ke(!1),ea=Ke(!1),Cr=Ke(null);function $f(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)=>Io(a,o,t));return w(G,{children:i})}function Io(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)=>Io(l,u,n));return Y(i,o,...s)}return null}function Df({node:e}){const t=Bn(),n=Q(fe),r=Q(ke),i=Q(ea),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?Yr(e.children):Pe(e.children,{nobr:n,locals:r}):void 0,l=Y(e.tag,a,s);return o?w(ea.Provider,{value:!0,children:l}):l}function Tf(){const e=Q(Cr),t=Q(fe),n=Q(ke);return!e||e.length===0?null:w(G,{children:Pe(e,{nobr:t,locals:n})})}function Nf(e,t){if(cu(e.name))return null;const n=ou(e.name);if(n)return w(au,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=lu(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 Ir(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(Tf,{},t):w(Zl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"expression\":return w(eu,{expression:e.expression,className:e.className,id:e.id},t);case\"macro\":return Nf(e,t);case\"html\":return w(Df,{node:e},t);default:return e}}function Yr(e){return e.length===0?null:e.map((t,n)=>Ir(t,n))}function Rf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Mf(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)=>Ir(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\"&&Rf(i))i+=Mf(l,a);else{const u=r.length;r.push(Ir(l,s)),i+=`<span data-tw=\"${u}\"></span>`}}const o=Ef(i);return $f(o,r,t?.nobr)}function zf(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 Ff(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 Of(){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.\",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 qt(e,t){localStorage.setItem(e,JSON.stringify(t))}function ze(e){localStorage.removeItem(e)}function Ze(e){return Fe(e)??[]}function Zn(e,t){const n=Ze(e);n.includes(t)||(n.push(t),qt(e,n))}function Rt(e,t){const n=Ze(e).filter(r=>r!==t);qt(e,n)}function Lf(){return{type:\"localstorage\",async putSave(e){const t=e.meta.id;qt(`${Me}${t}`,e),Zn(`${gt}${e.meta.ifid}`,t),Zn(`${Nt}${e.meta.playthroughId}`,t)},async getSave(e){return Fe(`${Me}${e}`)},async deleteSave(e){const t=Fe(`${Me}${e}`);t&&(Rt(`${gt}${t.meta.ifid}`,e),Rt(`${Nt}${t.meta.playthroughId}`,e)),ze(`${Me}${e}`)},async getSavesByIfid(e){const t=Ze(`${gt}${e}`),n=[];for(const r of t){const i=Fe(`${Me}${r}`);i&&n.push(i)}return n},async deleteSavesByIfid(e){const t=Ze(`${gt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Rt(`${Nt}${r.meta.playthroughId}`,n),ze(`${Me}${n}`)}ze(`${gt}${e}`)},async deleteSavesByPlaythrough(e){const t=Ze(`${Nt}${e}`);for(const n of t){const r=Fe(`${Me}${n}`);r&&Rt(`${gt}${r.meta.ifid}`,n),ze(`${Me}${n}`)}return ze(`${Nt}${e}`),t},async putPlaythrough(e){qt(`${Dt}${e.id}`,e),Zn(`${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&&Rt(`${Tt}${t.ifid}`,e),ze(`${Dt}${e}`)},async getMeta(e){return Fe(`${Ye}${e}`)},async setMeta(e,t){qt(`${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 ta=\"spindle\",Bf=1;function Vf(){let e=null;function t(){return e||(e=new Promise((a,o)=>{const s=indexedDB.open(ta,Bf);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(ta);l.onsuccess=()=>o(),l.onerror=()=>s(l.error)})}}}let _t=null;async function Hf(){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)}),Vf()}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 Lf()}catch{}return Of()}async function J(){return _t||(_t=await Hf(),_t)}function qf(){_t=null}function na(){return _t?.type??\"memory\"}const Po=new Map,qn=new Map;function Uf(e,t){Po.set(e,t),qn.set(t,e)}function jf(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(qn.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(jf(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=qn.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=Po.get(o);if(!l){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(s))f[c]=t(s[c]);return f}const u=Object.create(l.prototype);for(const f of Object.keys(s))u[f]=t(s[f]);return u}const i=r.constructor;if(qn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Pr=null,Er=null,ra=!1;function Wf(e){Pr=e}function Kf(e){Er=e}function Qf(e){if(Er)try{const i=new Function(\"passage\",\"variables\",Er)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Pr)try{const r=Pr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function Gf(){ra||(ra=!0)}async function ia(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 Yf(e){return(await J()).getMeta(`currentPlaythroughId.${e}`)}async function Eo(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 Ao(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 Jf(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 Xf(e){await(await J()).deleteSave(e)}async function Zf(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 ed(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 td=\"autosave.\",nd=\"slot.\",Un=\"slotIndex.\";function ln(e,t){return t!=null?`${nd}${t}.${e}`:`${td}${e}`}async function rd(e,t,n,r,i){const a=await J(),o=ln(e,r),s=await a.getMeta(o);if(s){const u=await Ao(s,n,i);if(u)return u}const l=await Eo(e,t,n,{isAutosave:!r,...r!=null?{slot:r}:{},...i});if(await a.setMeta(o,l.meta.id),r!=null){const u=`${Un}${e}`,f=await a.getMeta(u)??[];f.includes(r)||await a.setMeta(u,[...f,r])}return l}async function aa(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);return i?await n.getSave(i)!==void 0:!1}async function id(e,t){const n=ln(e,t),r=await(await J()).getMeta(n);if(r)return Jf(r)}async function Ar(e){const t={};await aa(e)&&(t[\"\"]=!0);const n=`${Un}${e}`,r=await(await J()).getMeta(n)??[];for(const i of r)await aa(e,i)&&(t[i]=!0);return t}async function $r(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(!i)return null;const a=await n.getSave(i);return a?{slot:t??\"\",title:a.meta.title,passage:a.meta.passage,createdAt:a.meta.createdAt,updatedAt:a.meta.updatedAt,custom:a.meta.custom??{}}:null}async function ad(e){const t=[],n=await $r(e);n&&t.push(n);const r=`${Un}${e}`,i=await(await J()).getMeta(r)??[];for(const a of i){const o=await $r(e,a);o&&t.push(o)}return t}async function od(e,t){const n=await J(),r=ln(e,t),i=await n.getMeta(r);if(i&&(await n.deleteSave(i),await n.deleteMeta(r),t!=null)){const a=`${Un}${e}`,s=(await n.getMeta(a)??[]).filter(l=>l!==t);await n.setMeta(a,s)}}const Jr=\"spindle.session.\";function sd(e,t){try{sessionStorage.setItem(`${Jr}${e}`,JSON.stringify(t))}catch{}}function ld(e){try{const t=sessionStorage.getItem(`${Jr}${e}`);if(!t)return;const n=JSON.parse(t);if(!Ff(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 $o(e){try{sessionStorage.removeItem(`${Jr}${e}`)}catch{}}async function ud(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 cd(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 fd(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 Do(e){const t=await J();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),$o(e)}async function To(){if(await(await J()).destroy(),qf(),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 No(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 Ro(){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&&Kf(n.content)}let Mo=0,we=[],er=!1,ct=[],Ut=null,Ve=null;function Xr(e){const t=C.getState();try{return!!Pt(e,t.variables,t.temporary)}catch{return!1}}function zo(e,t){const n=Mo++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Xr(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 Fo(e){we=we.filter(t=>t.name!==e)}function dd(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();lo(n.run,r.variables,r.temporary)}n.dialog&&(ct.push({passageName:n.dialog}),Ut?.()),n.goto&&C.getState().navigate(n.goto)}}const hd=10;function pd(){if(!er){er=!0;try{for(let e=0;e<hd;e++){let t=!1;const n=[...we];for(const r of n){if(!we.includes(r))continue;const i=Xr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(we=we.filter(o=>o.id!==r.id)),dd(r))}if(!t)break}}finally{er=!1}}}function gd(){for(const e of we)e.lastResult=Xr(e.condition)}function md(){we=[],ct=[],Mo=0,Ve?.closeAll()}function yd(e){return Ut=e,ct.length>0&&e(),()=>{Ut===e&&(Ut=null)}}function _d(){return ct.shift()}function bd(){return ct.length}function vd(e){Ve?Ve.push(e):(ct.push(e),Ut?.())}function wd(){ct=[]}function Sd(e){return Ve=e,()=>{Ve===e&&(Ve=null)}}function kd(){Ve?.close()}function xd(){wd(),Ve?.closeAll()}function Cd(){return Ve?.isOpen()??!1}Pl();const Id=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"StoryLoading\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let nt={},be=[],Ue={};function oa(e){return e.map(t=>({...t,value:t.value!==void 0?ie(t.value):void 0}))}function sa(e,t){const[,n,r]=Al(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:oa(n),inverse:oa(r)}}function Pd(e){let t=nt;for(let n=0;n<e;n++)t=yt(t,be[n].forward);return t}let ve=[];function tr(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}}}sd(t.ifid,{passage:n,variables:rt(r),history:ve,historyIndex:a,visitCounts:o,renderCounts:s,prng:Rn()})}}function la(e){nt=e,be=[],Ue=e,ve=[]}let Dr=[],Zr=!1;function Mt(e){Zr&&Dr.push(e)}function Oo(){Zr=!0}function Ed(){for(const e of Dr)e();Dr=[],Zr=!1}let wn=[];function Ad(e){return wn.push(e),()=>{wn=wn.filter(t=>t!==e)}}function Lo(){for(const e of wn)e()}let Sn=[];function $d(e){return Sn.push(e),()=>{Sn=Sn.filter(t=>t!==e)}}function Dd(){for(const e of Sn)e()}function ua(e){e?.prng?io(e.prng.seed,e.prng.pull):e&&vr()}const C=cl()(Dl((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);la(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;Gf().then(async()=>{const s=await Yf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ia(o);e(f=>{f.playthroughId=u})}const l=await Ar(o);Object.keys(l).length>0&&e(u=>{u.knownSaves=l})}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Id.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=sa(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:Rn()});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,tr(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,ua(t().history[t().historyIndex]),tr(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,ua(t().history[t().historyIndex]),tr(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;e(s=>{s.renderDeferred=!1}),Dd();const a=t().renderDeferred;Ed(),vr(),md();const o=ie(r);la(ie(o)),e(s=>{s.currentPassage=i.name,s.variables=o,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1},a||(s.renderDeferred=!1)}),Ue=t().variables,Oo(),Ro(),$o(n.ifid),Lo(),ia(n.ifid).then(s=>{e(l=>{l.playthroughId=s})}).catch(s=>console.error(\"spindle: failed to start new playthrough\",s))},save:(n,r)=>{const{storyData:i,playthroughId:a}=t();if(!i)return;const o=t().getSavePayload();e(s=>{s.saveError=null}),rd(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}),id(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?$r(r.ifid,n):null},listSaves:async()=>{const{storyData:n}=t();return n?ad(n.ifid):[]},deleteSave:n=>{const{storyData:r}=t();r&&od(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&&Do(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&&To().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&&No(r.ifid,n).then(async()=>{const i=await Ar(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:Rn()}},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(sa(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?io(n.prng.seed,n.prng.pull):vr()},getHistoryVariables:n=>ie(Pd(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n},deferRender:()=>{e(n=>{n.renderDeferred=!0})},clearDeferredRender:()=>{e(n=>{n.renderDeferred=!1})}}))),Td=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Nd(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Td,r=t?.tags.includes(\"nobr\")??!1,i=he(()=>{try{const a=xt(n),o=Ct(a);return w(G,{children:Yr(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 Bo=Ke(null);function ei({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(Bo.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 Rd(){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(()=>Sd({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Se(()=>yd(()=>{const o=[];for(;bd()>0;){const s=_d();s&&o.push(s)}o.length>0&&t(s=>[...s,...o])}),[]),e.length===0?null:w(G,{children:e.map((o,s)=>w(ei,{passageName:o.passageName,panelClass:o.panelClass,onClose:i,showCloseButton:o.showCloseButton},`${o.passageName}-${s}`))})}function Md(){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(Nd,{}),w(Rd,{})]});return n?w(fe.Provider,{value:!0,children:r}):r}function zd(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Fd(){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=zd(p.innerHTML),_={},S=new Set([\"pid\",\"name\",\"tags\"]);for(const E of p.attributes)S.has(E.name)||(_[E.name]=E.value);const x={pid:d,name:h,tags:y,metadata:_,content:k};f.set(h,x),c.set(d,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:u}}const zt=new Map;let ce={},ca=!1;function Vo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Od(){localStorage.setItem(Vo(),JSON.stringify(ce))}function nr(){if(!ca){ca=!0;try{const e=localStorage.getItem(Vo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ce={...ce,...t})}}catch{}}}const Jt={addToggle(e,t){zt.set(e,{type:\"toggle\",config:t}),e in ce||(ce[e]=t.default),nr()},addList(e,t){zt.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),nr()},addRange(e,t){zt.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),nr()},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,Od()},getAll(){return{...ce}},getDefinitions(){return zt},hasAny(){return zt.size>0}};function Ld(e,t,n){const r=C.getState(),i=ie(r.variables),a=ie(r.temporary),o={...t};lo(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 zn=new Map,Tr=new Set,Nr=new Map;function Bd(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Nr.get(r)??0)+1;return Nr.set(r,i),i===1?r:`${r}:${i}`}function Vd(e){return zn.set(e.id,e),da(),()=>{zn.delete(e.id),da()}}function fa(){return Array.from(zn.values())}function Hd(e){return zn.get(e)}function qd(){Nr.clear()}function Ud(e){return Tr.add(e),()=>{Tr.delete(e)}}function da(){for(const e of Tr)e()}function jd(e){const t=se(\"\"),n=se(e.perform);n.current=e.perform,t.current||(t.current=Bd(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),Vd(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Wd(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Ho(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function ti(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?Ho(t):\"\"}function Kd(e){const t=e.match(/^\\s*([\"']?\\$[\\w.]+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Qd(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function Gd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Yd={useState:ee,useRef:se,useEffect:Se,useLayoutEffect:ut,useCallback:pe,useMemo:he,useContext:Q};function ha(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function Jd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const a=t[i];(r[a]==null||typeof r[a]!=\"object\")&&(r[a]={}),r=r[a]}r[t[t.length-1]]=n}function B(e,t=\"builtin\"){function n(i){let a=i.className,o=i.id,s;e.interpolate&&(s=Bn(),a=s(a),o=s(o));const{update:l,getValues:u}=Q(sn),f=Q(fe),c=Q(ke),d={collectText:Wd,sourceLocation:ti,parseVarArgs:Kd,extractOptions:Qd,h:Y,renderNodes:(h,y)=>Pe(h,{nobr:f,locals:c,...y}),renderInlineNodes:Yr,hooks:Yd,useAction:jd,className:a,id:o,resolve:s,cls:Gd(e.name,a),mutate:h=>Ld(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=Wr();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(_=>ha(_.variables,k)),d.getValue=()=>ha(C.getState().variables,k),d.setValue=_=>{C.setState(S=>{Jd(S.variables,k,_)})}}return e.render(i,d)}su(e.name,n);const r=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(fu(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)uu(i);r&&br(e.name)}let gn=null,Rr=null;function Xd(){return Rr}function Zd(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e,t){C.getState().save(e,t)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},getSaveInfo(e){return C.getState().getSaveInfo(e)},listSaves(){return C.getState().listSaves()},deleteSave(e){C.getState().deleteSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:Jt,registerClass(e,t){Uf(e,t)},defineMacro(e){B(e,\"user\")},getMacroRegistry(){return du()},saves:{setTitleGenerator(e){Wf(e)}},storage:{async getInfo(){const e=C.getState().storyData?.ifid;return e?fd(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:na()}},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 Do(e),C.setState(t=>{t.knownSaves={}}),C.getState().restart())},async clearAllData(){await To(),C.setState(e=>{e.knownSaves={}}),C.getState().restart()},async deletePlaythrough(e){const{storyData:t}=C.getState();if(!t)return;await No(t.ifid,e);const n=await Ar(t.ifid);C.setState(r=>{r.knownSaves=n})},get backend(){return na()}},getActions(){return fa()},performAction(e,t){const n=Hd(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;const r=C.subscribe(i=>{if(i.currentPassage!==n){const a=n;n=i.currentPassage,t(i.currentPassage,a)}});return Mt(r),r}if(e===\"beforerestart\"){const n=$d(t);return Mt(n),n}if(e===\"storyinit\"){const n=Ad(t);return Mt(n),n}if(e===\"actionsChanged\"){const n=Ud(t);return Mt(n),n}if(e===\"variableChanged\"){let n={...C.getState().variables};const r=C.subscribe(i=>{const a={};let o=!1;const s=new Set([...Object.keys(n),...Object.keys(i.variables)]);for(const l of s)i.variables[l]!==n[l]&&(a[l]={from:n[l],to:i.variables[l]},o=!0);n={...i.variables},o&&t(a)});return Mt(r),r}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(fa())})})})},watch(e,t){return zo(e,t)},unwatch(e){Fo(e)},openDialog(e,t){vd({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){kd()},closeAllDialogs(){xd()},isDialogOpen(){return Cd()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},deferRender(){C.getState().deferRender(),Rr=new Promise(e=>{gn=e})},ready(){gn&&(C.getState().clearDeferredRender(),gn(),gn=null,Rr=null)},random(){return Kr()},randomInt(e,t){return ao(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=Rn())})},isEnabled(){return Ol()},get seed(){return Ll()},get pull(){return Bl()}}}}function eh(){window.Story=Zd()}const th=/^\\$(\\w+)\\s*=\\s*(.+)$/,pa=/\\$(\\w+(?:\\.\\w+)*)/g,ga=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,nh=new Set([\"number\",\"string\",\"boolean\"]);function qo(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,qo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!nh.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function rh(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(th);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=qo(s);t.set(a,{...l,name:a,default:s})}return t}function ih(e){const t=new Set;let n;for(ga.lastIndex=0;(n=ga.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function ah(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const l=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${l}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const u=o.fields.get(l);if(!u)return null;o=u}return null}function oh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=ih(i.content);let o;for(pa.lastIndex=0;(o=pa.exec(i.content))!==null;){const s=o[1],l=ah(s,t,a);l&&n.push(`Passage \"${r}\": ${l}`)}}return n}function sh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function kn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&kn(t.children))return!0;if(t.type===\"macro\"){if(kn(t.children))return!0;if(t.branches){for(const n of t.branches)if(kn(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${ti()}: ${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 lh(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 uh(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 ma(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}}${ti()}:`,u);return}const l=n?i[t]:r[t];if(!uh(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}=lh(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,ma(o,l,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{ma(o,l,s,n,r,i,e)},[n,r,i]),null}});function ch(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=fh(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 fh(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 dh(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}=ch(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=dh(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 hh(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 ph({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(sn.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=hh(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(ph,{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(sn.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 gh(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 ya(e,t,n,r){const i=document.createElement(\"div\"),a=Y(fe.Provider,{value:r},Y(sn.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}=gh(e),a=Q(fe),o=s=>{s.preventDefault(),ya(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:()=>{ya(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 ni(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?ni(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 Uo=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=ni(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(Uo.Provider,{value:{stop:c},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:p}):p}});B({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(Uo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});B({name:\"type\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=ni(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 mh(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}=mh(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{co(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(ei,{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:()=>!Jt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});B({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,l=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(ei,{passageName:l,onClose:()=>i(!1),showCloseButton:!a})]})}});function yh(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 _h(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function bh(){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(Bo),_=C(R=>R.storyData),S=C(R=>R.playthroughId),x=C(R=>R.getSavePayload),E=C(R=>R.loadFromPayload),I=_?.ifid??\"\",b=pe(async()=>{if(!I)return;const R=await ed(I);r(R),a(!1)},[I]);Se(()=>{b()},[b]),Se(()=>{f&&h.current&&(h.current.focus(),h.current.select())},[f]);const $=se(),A=(R,j=\"success\")=>{clearTimeout($.current),s({text:R,type:j}),$.current=window.setTimeout(()=>s(null),3e3)};Se(()=>()=>clearTimeout($.current),[]);const D=R=>{u(j=>{const g=new Set(j);return g.has(R)?g.delete(R):g.add(R),g})},v=async()=>{if(!(!I||!S))try{const R=x();await Eo(I,S,R),A(\"Save created\"),await b()}catch{A(\"Failed to create save\",\"error\")}},T=async R=>{try{const j=x();await Ao(R,j),A(\"Save overwritten\"),await b()}catch{A(\"Failed to overwrite save\",\"error\")}},N=async R=>{try{E(R.payload),A(\"Game loaded\"),k&&setTimeout(k,500)}catch{A(\"Failed to load save\",\"error\")}},V=async R=>{if(confirm(\"Delete this save?\"))try{await Xf(R),A(\"Save deleted\"),await b()}catch{A(\"Failed to delete save\",\"error\")}},U=R=>{c(R.meta.id),d(R.meta.title)},O=async()=>{if(!(!f||!p.trim()))try{await Zf(f,p.trim()),c(null),A(\"Save renamed\"),await b()}catch{A(\"Failed to rename\",\"error\")}},Z=R=>{R.key===\"Enter\"?O():R.key===\"Escape\"&&c(null)},X=async R=>{try{const j=await ud(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=()=>{y.current?.click()},xe=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(!zf(ue))throw new Error(\"Invalid save file format\");await cd(ue,I),A(\"Save imported\"),await b()}catch(q){A(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((R,j)=>R+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick: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(R=>{const j=l.has(R.playthrough.id),g=R.playthrough.id===S;return e===\"save\"&&!g||e===\"load\"&&R.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>D(R.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[R.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:_h(R.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[R.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?w(\"input\",{ref:h,class:\"save-rename-input\",value:p,onInput:ue=>d(ue.target.value),onKeyDown:Z,onBlur:O}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:yh(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(bh,{})}});function vh({name:e,def:t}){const[n,r]=ee(()=>Jt.get(e)),i=a=>{r(a),Jt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function wh(){const e=Jt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(vh,{name:t,def:n},t))})}B({name:\"settings-controls\",render(){return w(wh,{})}});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 Sh(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}B({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Sh(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 kh(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}=kh(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});B({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});B({name:\"cycle\",block:!0,storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});B({name:\"span\",block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function Ot(e){const t=xt(e.content),n=Ct(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const xh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Ch({passage:e,dataTransition:t}){const n=C(y=>y.storyData),r=xh.has(e.name),[i,a]=ee(!1),o=he(()=>{try{return Ot(e)}catch(y){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",Ho(e),\":\",\" \",y instanceof Error?y.message:String(y)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),l=r?void 0:n?.passages.get(\"PassageFooter\"),u=r?void 0:n?.passages.get(\"PassageDone\"),f=he(()=>{if(!s)return null;try{return Ot(s)}catch(y){return console.error(\"spindle: Error in PassageHeader:\",y),null}},[s?.content]),c=he(()=>{if(!l)return null;try{return Ot(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 Ot(u)}catch(y){return console.error(\"spindle: Error in PassageDone:\",y),null}},[i,u?.content]),d=e.tags.includes(\"nobr\"),h=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&w(\"div\",{class:\"passage-header\",children:f}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),p&&w(\"div\",{hidden:!0,children:p})]});return d?w(fe.Provider,{value:!0,children:h}):h}const Ih=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),Mr={type:\"fade-through\",duration:300,pause:50};function Ph(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Ih.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 rr(e){return{type:e.type,duration:e.duration??Mr.duration,pause:e.pause??Mr.pause}}function Eh(e,t,n){const r=Ph(e);return r?rr(r):t?rr(t):n?rr(n):{...Mr}}function _a(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 ir(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 ar(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=[],ar(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=Eh($.tags,S,_);s.current=A.type;const D=u.current;if(A.type===\"none\"){o(n);return}if(A.type===\"fade\"){D&&ir(D,A),o(n);return}if(A.type===\"fade-through\"){if(!D){o(n);return}ir(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=_a(v,A.type);D.appendChild(T),o(\"\");const N=A.duration+A.pause,V=setTimeout(()=>{o(n)},N),U=N+A.duration,O=setTimeout(()=>{ar(D)},U);f.current=[V,O];return}if(A.type===\"crossfade\"){if(!D){o(n);return}ir(D,A);const v=D.querySelector(\".passage\");if(!v){o(n);return}const T=_a(v,A.type);D.classList.add(\"passage-container--crossfading\"),D.appendChild(T),o(n);const N=setTimeout(()=>{ar(D)},A.duration);f.current=[N];return}o(n)},[n]);const p=i?r?.passages.get(\"StoryLoading\")??null:a?r?.passages.get(a):null;if(!p&&a&&!i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",a,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[!i&&d&&w(\"div\",{hidden:!0,children:Ot(d)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:p&&w(Ch,{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,zo(a,s)),null}});B({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,Fo(r)),null}});const Ah='*,*: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 ba(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 va(){const e=Fd(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Ah,document.head.appendChild(t),eh(),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&&ba(y,[h]),new Error(`spindle: ${h}`)}const i=rh(r.content),a=oh(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&ba(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=sh(i),C.getState().init(e,n),Oo(),Ro();const o=ld(e.ifid);o&&C.getState().loadFromPayload(o),Lo();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(_)&&br(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=kn(I);co(x,I,E,b),b&&br(x)}}let l=\"\";C.subscribe(h=>{h.currentPassage!==l&&(l=h.currentPassage,qd())});let u=C.getState().variables,f=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===f?pd():gd()),u=h.variables,f=h.historyIndex});const c=e.passages.get(\"StoryInterface\");c&&!c.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const p=document.getElementById(\"root\");if(!p)throw new Error('spindle: No <div id=\"root\"> element found.');Ie(w(Md,{}),p);const d=Xd();d?d.then(()=>{document.dispatchEvent(new CustomEvent(\":storyready\"))}):document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",va):va();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|