@rohal12/spindle 0.21.0 → 0.22.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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.21.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 Dt,O,Gi,je,Hr,Ki,Yi,Zi,hr,Vn,Bn,Ji,nn={},rn=[],qo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$t=Array.isArray;function Ce(e,t){for(var n in t)e[n]=t[n];return e}function dr(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?Dt.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 St(e,o,r,i,null)}function St(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??++Gi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Uo(){return{current:null}}function G(e){return e.children}function Ie(e,t){this.props=e,this.context=t}function st(e,t){if(t==null)return e.__?st(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\"?st(e):null}function Wo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ce({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),pr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??st(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,na(r,a,i),t.__e=t.__=null,a.__e!=n&&Xi(a)}}function Xi(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}),Xi(e)}function Hn(e){(!e.__d&&(e.__d=!0)&&je.push(e)&&!an.__r++||Hr!=O.debounceRendering)&&((Hr=O.debounceRendering)||Ki)(an)}function an(){for(var e,t=1;je.length;)je.length>t&&je.sort(Yi),e=je.shift(),t=je.length,Wo(e);an.__r=0}function ea(e,t,n,r,i,a,o,s,u,l,f){var c,d,h,p,w,x,_,b=r&&r.__k||rn,k=t.length;for(u=jo(n,t,b,u,k),c=0;c<k;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&b[h.__i]||nn,h.__i=c,x=pr(e,h,d,i,a,o,s,u,l,f),p=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&mr(d.ref,null,h),f.push(h.ref,h.__c||p,h)),w==null&&p!=null&&(w=p),(_=!!(4&h.__u))||d.__k===h.__k?u=ta(h,u,e,_):typeof h.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),h.__u&=-7);return n.__e=w,u}function jo(e,t,n,r,i){var a,o,s,u,l,f=n.length,c=f,d=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]=St(null,o,null,null,null):$t(o)?o=e.__k[a]=St(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=St(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+d,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Qo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>f?d--:i<f&&d++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,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=st(s)),ia(s,s));return r}function ta(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=ta(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=st(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function $e(e,t){return t=t||[],e==null||typeof e==\"boolean\"||($t(e)?e.some(function(n){$e(n,t)}):t.push(e)),t}function Qo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&u==l.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function qr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||qo.test(t)?n:n+\"px\"}function qt(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||qr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||qr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Zi,\"$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=hr,e.addEventListener(t,a?Bn:Vn,a)):e.removeEventListener(t,a?Bn:Vn,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 Ur(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=hr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function pr(e,t,n,r,i,a,o,s,u,l){var f,c,d,h,p,w,x,_,b,k,E,I,y,P,T,F=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof F==\"function\")try{if(_=t.props,b=\"prototype\"in F&&F.prototype.render,k=(f=F.contextType)&&r[f.__c],E=f?k?k.props.value:f.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(b?t.__c=c=new F(_,E):(t.__c=c=new Ie(_,E),c.constructor=F,c.render=Ko),k&&k.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),b&&c.__s==null&&(c.__s=c.state),b&&F.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ce({},c.__s)),Ce(c.__s,F.getDerivedStateFromProps(_,c.__s))),h=c.props,p=c.state,c.__v=t,d)b&&F.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),b&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(b&&F.getDerivedStateFromProps==null&&_!==h&&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)}),rn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),b&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,p,w)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=O.__r,y=0,b)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),rn.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&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Ce(Ce({},r),c.getChildContext())),b&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,p)),P=f!=null&&f.type===G&&f.key==null?ra(f.props.children):f,s=ea(e,$t(P)?P:[P],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(v){if(t.__v=null,u||a!=null)if(v.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)dr(a[T]);qn(t)}else t.__e=n.__e,t.__k=n.__k,v.then||qn(t);O.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Go(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function qn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(qn))}function na(e,t,n){for(var r=0;r<n.length;r++)mr(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function ra(e){return typeof e!=\"object\"||e==null||e.__b>0?e:$t(e)?e.map(ra):Ce({},e)}function Go(e,t,n,r,i,a,o,s,u){var l,f,c,d,h,p,w,x=n.props||nn,_=t.props,b=t.type;if(b==\"svg\"?i=\"http://www.w3.org/2000/svg\":b==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&\"setAttribute\"in h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(_);e=document.createElementNS(i,b,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(b==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Dt.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(h=e.attributes[l]).name]=h.value;for(l in x)h=x[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||qt(e,l,null,h,i);for(l in _)h=_[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?p=h:l==\"checked\"?w=h:s&&typeof h!=\"function\"||x[l]===h||qt(e,l,h,x[l],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ea(t.type==\"template\"?e.content:e,$t(d)?d:[d],t,n,r,b==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&st(n,0),s,u),a!=null)for(l=a.length;l--;)dr(a[l]);s||(l=\"value\",b==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||b==\"progress\"&&!p||b==\"option\"&&p!=x[l])&&qt(e,l,p,x[l],i),l=\"checked\",w!=null&&w!=e[l]&&qt(e,l,w,x[l],i))}return e}function mr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function ia(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||mr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ia(r[i],t,n||typeof e.type!=\"function\");n||dr(e.__e),e.__c=e.__=e.__e=void 0}function Ko(e,t,n){return this.constructor(e,n)}function ye(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],pr(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||nn,nn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Dt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),na(a,e,o)}function aa(e,t){ye(e,t,aa)}function Yo(e,t,n){var r,i,a,o,s=Ce({},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?Dt.call(arguments,2):n),St(e.type,s,r||e.key,i||e.ref,null)}function Ft(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,Hn(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\"+Ji++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Dt=rn.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Gi=0,Ie.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ce({},this.state),typeof e==\"function\"&&(e=e(Ce({},n),this.props)),e&&Ce(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Hn(this))},Ie.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Hn(this))},Ie.prototype.render=G,je=[],Ki=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yi=function(e,t){return e.__v.__b-t.__v.__b},an.__r=0,Zi=/(PointerCapture)$|Capture$/i,hr=0,Vn=Ur(!1),Bn=Ur(!0),Ji=0;var Zo=0;function S(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zo,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var Le,j,In,Wr,lt=0,oa=[],Q=O,jr=Q.__b,Qr=Q.__r,Gr=Q.diffed,Kr=Q.__c,Yr=Q.unmount,Zr=Q.__;function ft(e,t){Q.__h&&Q.__h(j,e,lt||t),lt=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function J(e){return lt=1,gr(ca,e)}function gr(e,t,n){var r=ft(Le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ca(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(d){return d.__c});if(f.every(function(d){return!d.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return f.some(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};j.__f=!0;var a=j.shouldComponentUpdate,o=j.componentWillUpdate;j.componentWillUpdate=function(s,u,l){if(this.__e){var f=a;a=void 0,i(s,u,l),a=f}o&&o.call(this,s,u,l)},j.shouldComponentUpdate=i}return r.__N||r.__}function Ee(e,t){var n=ft(Le++,3);!Q.__s&&_r(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function tt(e,t){var n=ft(Le++,4);!Q.__s&&_r(n.__H,t)&&(n.__=e,n.u=t,j.__h.push(n))}function ce(e){return lt=5,fe(function(){return{current:e}},[])}function sa(e,t,n){lt=6,tt(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 fe(e,t){var n=ft(Le++,7);return _r(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function be(e,t){return lt=8,fe(function(){return e},t)}function ze(e){var t=j.context[e.__c],n=ft(Le++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(j)),t.props.value):e.__}function la(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ua(){var e=ft(Le++,11);if(!e.__){for(var t=j.__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 Jo(){for(var e;e=oa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Yt),t.__h.some(Un),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){j=null,jr&&jr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Zr&&Zr(e,t)},Q.__r=function(e){Qr&&Qr(e),Le=0;var t=(j=e.__c).__H;t&&(In===j?(t.__h=[],j.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Yt),t.__h.some(Un),t.__h=[],Le=0)),In=j},Q.diffed=function(e){Gr&&Gr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(oa.push(t)!==1&&Wr===Q.requestAnimationFrame||((Wr=Q.requestAnimationFrame)||Xo)(Jo)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),In=j=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Yt),n.__h=n.__h.filter(function(r){return!r.__||Un(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Kr&&Kr(e,t)},Q.unmount=function(e){Yr&&Yr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Yt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Jr=typeof requestAnimationFrame==\"function\";function Xo(e){var t,n=function(){clearTimeout(r),Jr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Jr&&(t=requestAnimationFrame(n))}function Yt(e){var t=j,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),j=t}function Un(e){var t=j;e.__c=e.__(),j=t}function _r(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ca(e,t){return typeof t==\"function\"?t(e):t}const Xr=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(h=>h(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},es=(e=>e?Xr(e):Xr);function fa(e,t){for(var n in t)e[n]=t[n];return e}function Wn(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 ha(e,t){var n=t(),r=J({t:{__:n,u:t}}),i=r[0].t,a=r[1];return tt(function(){i.__=n,i.u=t,En(i)&&a({t:i})},[e,n,t]),Ee(function(){return En(i)&&a({t:i}),e(function(){En(i)&&a({t:i})})},[e]),n}function En(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 da(e){e()}function pa(e){return e}function ma(){return[!1,da]}var ga=tt;function jn(e,t){this.props=e,this.context=t}function ts(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:Wn(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}(jn.prototype=new Ie).isPureReactComponent=!0,jn.prototype.shouldComponentUpdate=function(e,t){return Wn(this.props,e)||Wn(this.state,t)};var ei=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ei&&ei(e)};var ns=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function rs(e){function t(n){var r=fa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ns,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ti=function(e,t){return e==null?null:$e($e(e).map(t))},is={map:ti,forEach:ti,count:function(e){return e?$e(e).length:0},only:function(e){var t=$e(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:$e},as=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}as(e,t,n,r)};var ni=O.unmount;function _a(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=fa({},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 _a(r,t,n)})),e}function ya(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ya(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 Zt(){this.__u=0,this.o=null,this.__b=null}function ba(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function os(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 bt(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ni&&ni(e)},(Zt.prototype=new Ie).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ba(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=ya(l,l.__c.__P,l.__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)},Zt.prototype.componentWillUnmount=function(){this.o=[]},Zt.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]=_a(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 ri=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 ss(e){return this.getChildContext=function(){return e.context},e.children}function ls(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){ye(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)}}}ye(Y(ss,{context:t.context},e.__v),t.v)}function us(e,t){var n=Y(ls,{__v:e,h:t});return n.containerInfo=t,n}(bt.prototype=new Ie).__a=function(e){var t=this,n=ba(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ri(t,e,r)):i()};n?n(a):a()}},bt.prototype.render=function(e){this.i=null,this.l=new Map;var t=$e(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},bt.prototype.componentDidUpdate=bt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ri(e,n,t)})};var va=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,cs=/^(?: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]/,fs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,hs=/[A-Z0-9]/g,ds=typeof document<\"u\",ps=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function ms(e,t,n){return t.__k==null&&(t.textContent=\"\"),ye(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function gs(e,t,n){return aa(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ie.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ie.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ii=O.event;function _s(){}function ys(){return this.cancelBubble}function bs(){return this.defaultPrevented}O.event=function(e){return ii&&(e=ii(e)),e.persist=_s,e.isPropagationStopped=ys,e.isDefaultPrevented=bs,e.nativeEvent=e};var yr,vs={enumerable:!1,configurable:!0,get:function(){return this.class}},ai=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||ds&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ps(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":fs.test(o)&&(o=u):u=o=\"oninput\":a&&cs.test(o)?o=o.replace(hs,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=$e(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=$e(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",vs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=va,ai&&ai(e)};var oi=O.__r;O.__r=function(e){oi&&oi(e),yr=e.__c};var si=O.diffed;O.diffed=function(e){si&&si(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),yr=null};var Ss={ReactCurrentDispatcher:{current:{readContext:function(e){return yr.__n[e.__c].props.value},useCallback:be,useContext:ze,useDebugValue:la,useDeferredValue:pa,useEffect:Ee,useId:ua,useImperativeHandle:sa,useInsertionEffect:ga,useLayoutEffect:tt,useMemo:fe,useReducer:gr,useRef:ce,useState:J,useSyncExternalStore:ha,useTransition:ma}}};function ws(e){return Y.bind(null,e)}function gn(e){return!!e&&e.$$typeof===va}function ks(e){return gn(e)&&e.type===G}function xs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Cs(e){return gn(e)?Yo.apply(null,arguments):e}function Is(e){return!!e.__k&&(ye(null,e),!0)}function Es(e){return e&&(e.base||e.nodeType===1&&e)||null}var As=function(e,t){return e(t)},Ps=function(e,t){return e(t)},Ts=G,Ns=gn,Ut={useState:J,useId:ua,useReducer:gr,useEffect:Ee,useLayoutEffect:tt,useInsertionEffect:ga,useTransition:ma,useDeferredValue:pa,useSyncExternalStore:ha,startTransition:da,useRef:ce,useImperativeHandle:sa,useMemo:fe,useCallback:be,useContext:ze,useDebugValue:la,version:\"18.3.1\",Children:is,render:ms,hydrate:gs,unmountComponentAtNode:Is,createPortal:us,createElement:Y,createContext:Ft,createFactory:ws,cloneElement:Cs,createRef:Uo,Fragment:G,isValidElement:gn,isElement:Ns,isFragment:ks,isMemo:xs,findDOMNode:Es,Component:Ie,PureComponent:jn,memo:ts,forwardRef:rs,flushSync:Ps,unstable_batchedUpdates:As,StrictMode:Ts,Suspense:Zt,SuspenseList:bt,lazy:os,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ss};const Ds=e=>e;function $s(e,t=Ds){const n=Ut.useSyncExternalStore(e.subscribe,Ut.useCallback(()=>t(e.getState()),[e,t]),Ut.useCallback(()=>t(e.getInitialState()),[e,t]));return Ut.useDebugValue(n),n}const Fs=e=>{const t=es(e),n=r=>$s(t,r);return Object.assign(n,t),n},zs=(e=>Fs);var br=Symbol.for(\"immer-nothing\"),wt=Symbol.for(\"immer-draftable\"),ee=Symbol.for(\"immer-state\");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var he=Object,Ze=he.getPrototypeOf,Ct=\"constructor\",zt=\"prototype\",Qn=\"configurable\",on=\"enumerable\",Jt=\"writable\",It=\"value\",Fe=e=>!!e&&!!e[ee];function Ae(e){return e?Sa(e)||Ot(e)||!!e[wt]||!!e[Ct]?.[wt]||Lt(e)||Mt(e):!1}var Rs=he[zt][Ct].toString(),li=new WeakMap;function Sa(e){if(!e||!ut(e))return!1;const t=Ze(e);if(t===null||t===he[zt])return!0;const n=he.hasOwnProperty.call(t,Ct)&&t[Ct];if(n===Object)return!0;if(!Qe(n))return!1;let r=li.get(n);return r===void 0&&(r=Function.toString.call(n),li.set(n,r)),r===Rs}function Rt(e,t,n=!0){Je(e)===0?(n?Reflect.ownKeys(e):he.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Je(e){const t=e[ee];return t?t.type_:Ot(e)?1:Lt(e)?2:Mt(e)?3:0}var kt=(e,t,n=Je(e))=>n===2?e.has(t):he[zt].hasOwnProperty.call(e,t),Ne=(e,t,n=Je(e))=>n===2?e.get(t):e[t],sn=(e,t,n,r=Je(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Os(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ot=Array.isArray,Lt=e=>e instanceof Map,Mt=e=>e instanceof Set,ut=e=>typeof e==\"object\",Qe=e=>typeof e==\"function\",An=e=>typeof e==\"boolean\";function Ls(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ms=e=>ut(e)?e?.[ee]:null,De=e=>e.copy_||e.base_,vr=e=>e.modified_?e.copy_:e.base_;function Gn(e,t){if(Lt(e))return new Map(e);if(Mt(e))return new Set(e);if(Ot(e))return Array[zt].slice.call(e);const n=Sa(e);if(t===!0||t===\"class_only\"&&!n){const r=he.getOwnPropertyDescriptors(e);delete r[ee];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Jt]===!1&&(s[Jt]=!0,s[Qn]=!0),(s.get||s.set)&&(r[o]={[Qn]:!0,[Jt]:!0,[on]:s[on],[It]:e[o]})}return he.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=he.create(r);return he.assign(i,e)}}function Sr(e,t=!1){return _n(e)||Fe(e)||!Ae(e)||(Je(e)>1&&he.defineProperties(e,{set:Wt,add:Wt,clear:Wt,delete:Wt}),he.freeze(e),t&&Rt(e,(n,r)=>{Sr(r,!0)},!1)),e}function Vs(){ie(2)}var Wt={[It]:Vs};function _n(e){return e===null||!ut(e)?!0:he.isFrozen(e)}var ln=\"MapSet\",un=\"Patches\",ui=\"ArrayMethods\",cn={};function Xe(e){const t=cn[e];return t||ie(0,e),t}var ci=e=>!!cn[e];function Bs(e,t){cn[e]||(cn[e]=t)}var Et,wa=()=>Et,Hs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ci(ln)?Xe(ln):void 0,arrayMethodsPlugin_:ci(ui)?Xe(ui):void 0});function fi(e,t){t&&(e.patchPlugin_=Xe(un),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kn(e){Yn(e),e.drafts_.forEach(qs),e.drafts_=null}function Yn(e){e===Et&&(Et=e.parent_)}var hi=e=>Et=Hs(Et,e);function qs(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function di(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Kn(t),ie(4)),Ae(e)&&(e=pi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ee].base_,e,t)}else e=pi(t,n);return Us(t,e,!0),Kn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==br?e:void 0}function pi(e,t){if(_n(t))return t;const n=t[ee];if(!n)return fn(t,e.handledSet_,e);if(!yn(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);Ca(n,e)}return n.copy_}function Us(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sr(t,n)}function ka(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var yn=(e,t)=>e.scope_===t,Ws=[];function xa(e,t,n,r){const i=De(e),a=e.type_;if(r!==void 0&&Ne(i,r,a)===t){sn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Rt(i,(u,l)=>{if(Fe(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??Ws;for(const s of o)sn(i,s,n,a)}function js(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!yn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=vr(a);xa(e,a.draft_??a,o,n),Ca(a,i)})}function Ca(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 Qs(e,t,n){const{scope_:r}=e;if(Fe(n)){const i=n[ee];yn(i,r)&&i.callbacks_.push(function(){Xt(e);const o=vr(i);xa(e,n,o,t)})}else Ae(n)&&e.callbacks_.push(function(){const a=De(e);e.type_===3?a.has(n)&&fn(n,r.handledSet_,r):Ne(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&fn(Ne(e.copy_,t,e.type_),r.handledSet_,r)})}function fn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fe(e)||t.has(e)||!Ae(e)||_n(e)||(t.add(e),Rt(e,(r,i)=>{if(Fe(i)){const a=i[ee];if(yn(a,n)){const o=vr(a);sn(e,r,o,e.type_),ka(a)}}else Ae(i)&&fn(i,t,n)})),e}function Gs(e,t){const n=Ot(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=hn;n&&(i=[r],a=At);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hn={get(e,t){if(t===ee)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=De(e);if(!kt(i,t,e.type_))return Ks(e,i,t);const a=i[t];if(e.finalized_||!Ae(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ls(t))return a;if(a===Pn(e.base_,t)){Xt(e);const o=e.type_===1?+t:t,s=Jn(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in De(e)},ownKeys(e){return Reflect.ownKeys(De(e))},set(e,t,n){const r=Ia(De(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Pn(De(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Os(n,i)&&(n!==void 0||kt(e.base_,t,e.type_)))return!0;Xt(e),Zn(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),Qs(e,t,n)),!0},deleteProperty(e,t){return Xt(e),Pn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Zn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=De(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Jt]:!0,[Qn]:e.type_!==1||t!==\"length\",[on]:r[on],[It]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},At={};for(let e in hn){let t=hn[e];At[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}At.deleteProperty=function(e,t){return At.set.call(this,e,t,void 0)};At.set=function(e,t,n){return hn.set.call(this,e[0],t,n,e[0])};function Pn(e,t){const n=e[ee];return(n?De(n):e)[t]}function Ks(e,t,n){const r=Ia(t,n);return r?It in r?r[It]:r.get?.call(e.draft_):void 0}function Ia(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function Xt(e){e.copy_||(e.assigned_=new Map,e.copy_=Gn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ys=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Qe(t)&&!Qe(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,f=>n.call(this,f,...l))}}Qe(n)||ie(6),r!==void 0&&!Qe(r)&&ie(7);let i;if(Ae(t)){const a=hi(this),o=Jn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Kn(a):Yn(a)}return fi(a,r),di(i,a)}else if(!t||!ut(t)){if(i=n(t),i===void 0&&(i=t),i===br&&(i=void 0),this.autoFreeze_&&Sr(i,!0),r){const a=[],o=[];Xe(un).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ie(1,t)},this.produceWithPatches=(t,n)=>{if(Qe(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},An(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),An(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),An(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ae(e)||ie(8),Fe(e)&&(e=Zs(e));const t=hi(this),n=Jn(t,e,void 0);return n[ee].isManual_=!0,Yn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return fi(r,t),di(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Xe(un).applyPatches_;return Fe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Jn(e,t,n,r){const[i,a]=Lt(t)?Xe(ln).proxyMap_(t,n):Mt(t)?Xe(ln).proxySet_(t,n):Gs(t,n);return(n?.scope_??wa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?js(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Zs(e){return Fe(e)||ie(10,e),Ea(e)}function Ea(e){if(!Ae(e)||_n(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Gn(e,!0);return Rt(n,(i,a)=>{sn(n,i,Ea(a))},r),t&&(t.finalized_=!1),n}function Js(){function t(p,w=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Ms(Ne(x,p.key_)),b=Ne(x,p.key_);if(b===void 0||b!==p.draft_&&b!==p.base_&&b!==p.copy_||_!=null&&_.base_!==p.base_)return null;const k=p.parent_.type_===3;let E;if(k){const I=p.parent_;E=Array.from(I.drafts_.keys()).indexOf(p.key_)}else E=p.key_;if(!(k&&x.size>E||kt(x,E)))return null;w.push(E)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let x=p;for(let _=0;_<w.length-1;_++){const b=w[_];if(x=Ne(x,b),!ut(x)||x===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:b}=x;switch(p.type_){case 0:case 2:return u(p,w,_,b);case 1:return s(p,w,_,b);case 3:return l(p,w,_,b)}}function s(p,w,x,_){let{base_:b,assigned_:k}=p,E=p.copy_;E.length<b.length&&([b,E]=[E,b],[x,_]=[_,x]);const I=p.allIndicesReassigned_===!0;for(let y=0;y<b.length;y++){const P=E[y],T=b[y];if((I||k?.get(y.toString()))&&P!==T){const v=P?.[ee];if(v&&v.modified_)continue;const N=w.concat([y]);x.push({op:r,path:N,value:h(P)}),_.push({op:r,path:N,value:h(T)})}}for(let y=b.length;y<E.length;y++){const P=w.concat([y]);x.push({op:i,path:P,value:h(E[y])})}for(let y=E.length-1;b.length<=y;--y){const P=w.concat([y]);_.push({op:a,path:P})}}function u(p,w,x,_){const{base_:b,copy_:k,type_:E}=p;Rt(p.assigned_,(I,y)=>{const P=Ne(b,I,E),T=Ne(k,I,E),F=y?kt(b,I)?r:i:a;if(P===T&&F===r)return;const v=w.concat(I);x.push(F===a?{op:F,path:v}:{op:F,path:v,value:h(T)}),_.push(F===i?{op:a,path:v}:F===a?{op:i,path:v,value:h(P)}:{op:r,path:v,value:h(P)})})}function l(p,w,x,_){let{base_:b,copy_:k}=p,E=0;b.forEach(I=>{if(!k.has(I)){const y=w.concat([E]);x.push({op:a,path:y,value:I}),_.unshift({op:i,path:y,value:I})}E++}),E=0,k.forEach(I=>{if(!b.has(I)){const y=w.concat([E]);x.push({op:i,path:y,value:I}),_.unshift({op:a,path:y,value:I})}E++})}function f(p,w,x){const{patches_:_,inversePatches_:b}=x;_.push({op:r,path:[],value:w===br?void 0:w}),b.push({op:r,path:[],value:p})}function c(p,w){return w.forEach(x=>{const{path:_,op:b}=x;let k=p;for(let P=0;P<_.length-1;P++){const T=Je(k);let F=_[P];typeof F!=\"string\"&&typeof F!=\"number\"&&(F=\"\"+F),(T===0||T===1)&&(F===\"__proto__\"||F===Ct)&&ie(19),Qe(k)&&F===zt&&ie(19),k=Ne(k,F),ut(k)||ie(18,_.join(\"/\"))}const E=Je(k),I=d(x.value),y=_[_.length-1];switch(b){case r:switch(E){case 2:return k.set(y,I);case 3:ie(16);default:return k[y]=I}case i:switch(E){case 1:return y===\"-\"?k.push(I):k.splice(y,0,I);case 2:return k.set(y,I);case 3:return k.add(I);default:return k[y]=I}case a:switch(E){case 1:return k.splice(y,1);case 2:return k.delete(y);case 3:return k.delete(x.value);default:return delete k[y]}default:ie(17,b)}}),p}function d(p){if(!Ae(p))return p;if(Ot(p))return p.map(d);if(Lt(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,d(_)]));if(Mt(p))return new Set(Array.from(p).map(d));const w=Object.create(Ze(p));for(const x in p)w[x]=d(p[x]);return kt(p,wt)&&(w[wt]=p[wt]),w}function h(p){return Fe(p)?d(p):p}Bs(un,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Pt=new Ys,Xs=Pt.produce,el=Pt.produceWithPatches.bind(Pt),ot=Pt.applyPatches.bind(Pt);const tl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Xs(i):i;return t(s,a,...o)},e(r.setState,n,r)),nl=tl,rl=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),il=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function al(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function mi(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function gi(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 ol(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;for(;t<e.length&&e[t]!==a;)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 ht(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=gi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const f=e.slice(l,n);n+=2;const{display:c,target:d}=al(f),h={type:\"link\",display:c,target:d,start:a,end:n};o&&(h.className=o),s&&(h.id=s),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=gi(e,n+1);s=l.className||void 0,u=l.id||void 0;let f=l.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let d=1;const h=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const p=e.slice(h,n);n++;const{name:w,rawArgs:x,isClose:_}=mi(p),b={type:\"macro\",name:w,rawArgs:x,isClose:_,start:a,end:n};s&&(b.className=s),u&&(b.id=u),t.push(b),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const f=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:d,rawArgs:h,isClose:p}=mi(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&rl.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const f=ol(e,o);o=f.endIdx;let c=il.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const sl=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\"]),_i={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},ll=new Set([\"if\",\"switch\",\"timed\"]);function dt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const o=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${o} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(_i[i.name]){const a=_i[i.name],o=n.length>0?n[n.length-1].node:null;if(!o||o.type!==\"macro\"||o.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches.push(s);break}if(sl.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(ll.has(i.name)){const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),a.branches=[o]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}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=ze(Be);return fe(()=>[e,t,n],[e,t,n])}const ul=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,cl=/\\{[\\$_@][\\w.]+\\}/;function Aa(e){return cl.test(e)}function fl(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 Pa(e,t,n,r){return e.replace(ul,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let f;return o===\"$\"?f=t[l]:o===\"_\"?f=n[l]:f=r[l],u.length>1&&(f=fl(f,u)),f==null?\"\":String(f)})}function kr(){const[e,t,n]=wr();return be(r=>r===void 0||!Aa(r)?r:Pa(r,e,t,n),[e,t,n])}function hl({name:e,scope:t,className:n,id:r}){const i=kr();n=i(n),r=i(r);const a=ze(Be),o=e.split(\".\"),s=o[0],u=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=o[c];l=l[d]}const f=l==null?\"\":String(l);return n||r?S(\"span\",{id:r,class:n,children:f}):S(G,{children:f})}function Ta(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 Na(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let pt=!1,Vt=\"\",et=0,ct=null;function dl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Vt=n,et=0,ct=Ta(Na(n)),pt=!0}function Da(e,t){Vt=e,et=0,ct=Ta(Na(e)),pt=!0;for(let n=0;n<t;n++)ct();et=t}function Xn(){pt=!1,Vt=\"\",et=0,ct=null}function dn(){return pt?{seed:Vt,pull:et}:null}function xr(){return!pt||!ct?Math.random():(et++,ct())}function $a(e,t){return e>t&&([e,t]=[t,e]),Math.floor(xr()*(t-e+1))+e}function pl(){return pt}function ml(){return Vt}function gl(){return et}const _l=500,We=new Map,yl=/\\$(\\w+)/g,bl=/\\b_(\\w+)/g,vl=/@(\\w+)/g;function Sl(e){return e.replace(yl,'variables[\"$1\"]').replace(bl,'temporary[\"$1\"]').replace(vl,'locals[\"$1\"]')}function Cr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Sl(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=Cr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const wl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Fa(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",wl+t);if(We.set(e,r),We.size>_l){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let jt=null,yi=null,bi=null;function za(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(jt&&yi===t&&bi===n)return jt;const r=h=>t[h??C.getState().currentPassage]??0,i=h=>r(h)>0,a=(...h)=>h.some(p=>r(p)>0),o=(...h)=>h.every(p=>r(p)>0),s=h=>n[h??C.getState().currentPassage]??0;return jt={currentPassage:()=>{const h=C.getState();return h.storyData?.passages.get(h.currentPassage)},previousPassage:()=>{const h=C.getState();if(h.historyIndex<=0)return;const p=h.history[h.historyIndex-1]?.passage;return p?h.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:h=>s(h)>0,hasRenderedAny:(...h)=>h.some(p=>s(p)>0),hasRenderedAll:(...h)=>h.every(p=>s(p)>0),random:xr,randomInt:$a},yi=t,bi=n,jt}function bn(e,t,n,r={}){const a=`return (${Cr(e)});`;return Fa(a,a)(t,n,r,za())}function Ra(e,t,n,r={}){const i=Cr(e);Fa(\"exec:\"+i,i)(t,n,r,za())}function kl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function xl({body:e,parentValues:t,ownKeys:n}){const[r,i]=J(()=>({...t,...n})),a=ce(r);a.current=r;const o=be(()=>a.current,[]),s=be((l,f)=>{i(c=>({...c,[l]:f}))},[]),u=fe(()=>({update:s,getValues:o}),[s,o]);return S(Bt.Provider,{value:u,children:S(Be.Provider,{value:r,children:Pe(e)})})}function Cl({body:e,params:t,rawArgs:n}){const r=ze(Be),[i,a,o]=wr();if(t.length===0||!n)return S(G,{children:Pe(e)});const s=kl(n),u={};for(let l=0;l<t.length;l++){const f=t[l],c=s[l];let d;if(c!==void 0)try{d=bn(c,i,a,o)}catch{d=void 0}u[f.startsWith(\"@\")?f.slice(1):f]=d}return S(xl,{body:e,parentValues:r,ownKeys:u})}const Oa=new Map;function La(e,t,n){Oa.set(e.toLowerCase(),{body:t,params:n})}function Il(e){return Oa.get(e.toLowerCase())}const Ma=new Map;function El(e,t){Ma.set(e.toLowerCase(),t)}function Al(e){return Ma.get(e.toLowerCase())}const Va=new Set;function Pl(e){Va.add(e.toLowerCase())}function Tl(e){return Va.has(e.toLowerCase())}const vi=document.createElement(\"i\");function Ba(e){const t=\"&\"+e+\";\";vi.innerHTML=t;const n=vi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function pe(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 re(e,t){return e.length>0?(pe(e,e.length,0,t),e):t}const er={}.hasOwnProperty;function Nl(e){const t={};let n=-1;for(;++n<e.length;)Dl(t,e[n]);return t}function Dl(e,t){let n;for(n in t){const i=(er.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){er.call(i,o)||(i[o]=[]);const s=a[o];$l(i[o],Array.isArray(s)?s:s?[s]:[])}}}function $l(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);pe(e,0,0,r)}function Fl(e){const t={};let n=-1;for(;++n<e.length;)zl(t,e[n]);return t}function zl(e,t){let n;for(n in t){const i=(er.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 Rl(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 Ol={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ha(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Ol[n]+\";\"}}function Tt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const xe=Ve(/[A-Za-z]/),de=Ve(/[\\dA-Za-z]/),Ll=Ve(/[#-'*+\\--9=?A-Z^-~]/);function tr(e){return e!==null&&(e<32||e===127)}const nr=Ve(/\\d/),Ml=Ve(/[\\dA-Fa-f]/),Vl=Ve(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function ae(e){return e!==null&&(e<0||e===32)}function M(e){return e===-2||e===-1||e===32}const Bl=Ve(/\\p{P}|\\p{S}/u),Hl=Ve(/\\s/);function Ve(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Qt(e,t){const n=Ha(ql(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 ql(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&de(e.charCodeAt(n+1))&&de(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 Si={}.hasOwnProperty,wi=/^(https?|ircs?|mailto|xmpp)$/i,Ul=/^https?$/i;function Wl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Fl([{enter:{blockQuote:L,codeFenced:ve,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:W,codeText:zo,content:ko,definition:_o,definitionDestinationString:bo,definitionLabelString:x,definitionTitleString:x,emphasis:$o,htmlFlow:Do,htmlText:Or,image:q,label:x,link:oe,listItemMarker:N,listItemValue:v,listOrdered:T,listUnordered:F,paragraph:K,reference:x,resource:rt,resourceDestinationString:it,resourceTitleString:x,setextHeading:Co,strong:Fo},exit:{atxHeading:Eo,atxHeadingSequence:xo,autolinkEmail:Ho,autolinkProtocol:Bo,blockQuote:Z,characterEscapeValue:gt,characterReferenceMarkerHexadecimal:Lr,characterReferenceMarkerNumeric:Lr,characterReferenceValue:Vo,codeFenced:m,codeFencedFence:D,codeFencedFenceInfo:g,codeFencedFenceMeta:P,codeFlowValue:No,codeIndented:m,codeText:Ro,codeTextData:gt,data:gt,definition:wo,definitionDestinationString:vo,definitionLabelString:yo,definitionTitleString:So,emphasis:Oo,hardBreakEscape:zr,hardBreakTrailing:zr,htmlFlow:Rr,htmlFlowData:gt,htmlText:Rr,htmlTextData:gt,image:Fr,label:mt,labelText:X,lineEnding:To,link:Fr,listOrdered:$,listUnordered:B,paragraph:ue,reference:P,referenceString:Re,resource:P,resourceDestinationString:Cn,resourceTitleString:go,setextHeading:Po,setextHeadingLineSequence:Ao,setextHeadingText:Io,strong:Lo,thematicBreak:Mo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},f={buffer:x,encode:y,getData:w,lineEndingIfNeeded:I,options:t,raw:k,resume:_,setData:p,tag:b};let c=t.defaultLineEnding;return d;function d(A){let z=-1,te=0;const Se=[];let we=[],Te=[];for(;++z<A.length;)!c&&(A[z][1].type===\"lineEnding\"||A[z][1].type===\"lineEndingBlank\")&&(c=A[z][2].sliceSerialize(A[z][1])),(A[z][1].type===\"listOrdered\"||A[z][1].type===\"listUnordered\")&&(A[z][0]===\"enter\"?Se.push(z):h(A.slice(Se.pop(),z))),A[z][1].type===\"definition\"&&(A[z][0]===\"enter\"?(Te=re(Te,A.slice(te,z)),te=z):(we=re(we,A.slice(te,z+1)),te=z+1));we=re(we,Te),we=re(we,A.slice(te)),z=-1;const ke=we;for(u.enter.null&&u.enter.null.call(f);++z<A.length;){const Mr=u[ke[z][0]],Vr=ke[z][1].type,Br=Mr[Vr];Si.call(Mr,Vr)&&Br&&Br.call({sliceSerialize:ke[z][2].sliceSerialize,...f},ke[z][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(A){const z=A.length;let te=0,Se=0,we=!1,Te;for(;++te<z;){const ke=A[te];if(ke[1]._container)Te=void 0,ke[0]===\"enter\"?Se++:Se--;else switch(ke[1].type){case\"listItemPrefix\":{ke[0]===\"exit\"&&(Te=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{ke[0]===\"enter\"&&!Se&&(Te?Te=void 0:we=!0);break}default:Te=void 0}}A[0][1]._loose=we}function p(A,z){l[A]=z}function w(A){return l[A]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function b(A){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(A))}function k(A){p(\"lastWasTag\"),i[i.length-1].push(A)}function E(){k(c||`\n`)}function I(){const A=i[i.length-1],z=A[A.length-1],te=z?z.charCodeAt(z.length-1):null;te===10||te===13||te===null||E()}function y(A){return w(\"ignoreEncode\")?A:Ha(A)}function P(){_()}function T(A){o.push(!A._loose),I(),b(\"<ol\"),p(\"expectFirstItem\",!0)}function F(A){o.push(!A._loose),I(),b(\"<ul\"),p(\"expectFirstItem\",!0)}function v(A){if(w(\"expectFirstItem\")){const z=Number.parseInt(this.sliceSerialize(A),10);z!==1&&b(' start=\"'+y(String(z))+'\"')}}function N(){w(\"expectFirstItem\")?b(\">\"):U(),I(),b(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),E(),b(\"</ol>\")}function B(){U(),o.pop(),E(),b(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&I(),b(\"</li>\"),p(\"slurpAllLineEndings\")}function L(){o.push(!1),I(),b(\"<blockquote>\")}function Z(){o.pop(),I(),b(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function K(){o[o.length-1]||(I(),b(\"<p>\")),p(\"slurpAllLineEndings\")}function ue(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):b(\"</p>\")}function ve(){I(),b(\"<pre><code\"),p(\"fencesCount\",0)}function g(){const A=_();b(' class=\"language-'+A+'\"')}function D(){const A=w(\"fencesCount\")||0;A||(b(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",A+1)}function W(){I(),b(\"<pre><code>\")}function m(){const A=w(\"fencesCount\");A!==void 0&&A<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&E(),w(\"flowCodeSeenData\")&&I(),b(\"</code></pre>\"),A!==void 0&&A<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function oe(){a.push({})}function X(A){a[a.length-1].labelId=this.sliceSerialize(A)}function mt(){a[a.length-1].label=_()}function Re(A){a[a.length-1].referenceId=this.sliceSerialize(A)}function rt(){x(),a[a.length-1].destination=\"\"}function it(){x(),p(\"ignoreEncode\",!0)}function Cn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function go(){a[a.length-1].title=_()}function Fr(){let A=a.length-1;const z=a[A],te=z.referenceId||z.labelId,Se=z.destination===void 0?r[Tt(te)]:z;for(n=!0;A--;)if(a[A].image){n=void 0;break}z.image?(b('<img src=\"'+Qt(Se.destination,t.allowDangerousProtocol?void 0:Ul)+'\" alt=\"'),k(z.label),b('\"')):b('<a href=\"'+Qt(Se.destination,t.allowDangerousProtocol?void 0:wi)+'\"'),b(Se.title?' title=\"'+Se.title+'\"':\"\"),z.image?b(\" />\"):(b(\">\"),k(z.label),b(\"</a>\")),a.pop()}function _o(){x(),a.push({})}function yo(A){_(),a[a.length-1].labelId=this.sliceSerialize(A)}function bo(){x(),p(\"ignoreEncode\",!0)}function vo(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function So(){a[a.length-1].title=_()}function wo(){const A=a[a.length-1],z=Tt(A.labelId);_(),Si.call(r,z)||(r[z]=a[a.length-1]),a.pop()}function ko(){p(\"slurpAllLineEndings\",!0)}function xo(A){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(A).length),I(),b(\"<h\"+w(\"headingRank\")+\">\"))}function Co(){x(),p(\"slurpAllLineEndings\")}function Io(){p(\"slurpAllLineEndings\",!0)}function Eo(){b(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function Ao(A){p(\"headingRank\",this.sliceSerialize(A).charCodeAt(0)===61?1:2)}function Po(){const A=_();I(),b(\"<h\"+w(\"headingRank\")+\">\"),k(A),b(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function gt(A){k(y(this.sliceSerialize(A)))}function To(A){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){k(\" \");return}k(y(this.sliceSerialize(A)))}}function No(A){k(y(this.sliceSerialize(A))),p(\"flowCodeSeenData\",!0)}function zr(){b(\"<br />\")}function Do(){I(),Or()}function Rr(){p(\"ignoreEncode\")}function Or(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function $o(){b(\"<em>\")}function Fo(){b(\"<strong>\")}function zo(){p(\"inCodeText\",!0),b(\"<code>\")}function Ro(){p(\"inCodeText\"),b(\"</code>\")}function Oo(){b(\"</em>\")}function Lo(){b(\"</strong>\")}function Mo(){I(),b(\"<hr />\")}function Lr(A){p(\"characterReferenceType\",A.type)}function Vo(A){const z=this.sliceSerialize(A),te=w(\"characterReferenceType\")?Rl(z,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ba(z);k(y(te)),p(\"characterReferenceType\")}function Bo(A){const z=this.sliceSerialize(A);b('<a href=\"'+Qt(z,t.allowDangerousProtocol?void 0:wi)+'\">'),k(y(z)),b(\"</a>\")}function Ho(A){const z=this.sliceSerialize(A);b('<a href=\"'+Qt(\"mailto:\"+z)+'\">'),k(y(z)),b(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return M(u)?(e.enter(n),s(u)):t(u)}function s(u){return M(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const jl={tokenize:Ql};function Ql(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Gl={tokenize:Kl},ki={tokenize:Yl};function Kl(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&b();const E=t.events.length;let I=E,y;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){y=t.events[I][1].end;break}_(r);let P=E;for(;P<t.events.length;)t.events[P][1].end={...y},P++;return pe(t.events,I+1,0,t.events.slice(E)),t.events.length=P,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return d(k);if(i.currentConstruct&&i.currentConstruct.concrete)return p(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ki,f,c)(k)}function f(k){return i&&b(),_(r),d(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(k)}function d(k){return t.containerState={},e.attempt(ki,h,p)(k)}function h(k){return r++,n.push([t.currentConstruct,t.containerState]),d(k)}function p(k){if(k===null){i&&b(),_(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(k)}function w(k){if(k===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(k);return}return R(k)?(e.consume(k),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),w)}function x(k,E){const I=t.sliceStream(k);if(E&&I.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(I),t.parser.lazy[k.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const P=t.events.length;let T=P,F,v;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(F){v=t.events[T][1].end;break}F=!0}for(_(r),y=P;y<t.events.length;)t.events[y][1].end={...v},y++;pe(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(k){let E=n.length;for(;E-- >k;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=k}function b(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Yl(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 pn(e){if(e===null||ae(e)||Hl(e))return 1;if(Bl(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 rr={name:\"attention\",resolveAll:Zl,tokenize:Jl};function Zl(e,t){let n=-1,r,i,a,o,s,u,l,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;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};xi(c,-u),xi(d,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=re(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=re(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=re(l,vn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=re(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=re(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,pe(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Jl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=pn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),f=pn(u),c=!f||f===2&&i||n.includes(u),d=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(f||!c)),t(u)}}function xi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Xl={name:\"autolink\",tokenize:eu};function eu(e,t,n){let r=0;return i;function i(h){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(h){return xe(h)?(e.consume(h),o):h===64?n(h):l(h)}function o(h){return h===43||h===45||h===46||de(h)?(r=1,s(h)):l(h)}function s(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||de(h))&&r++<32?(e.consume(h),s):(r=0,l(h))}function u(h){return h===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h===null||h===32||h===60||tr(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):Ll(h)?(e.consume(h),l):n(h)}function f(h){return de(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(h)}function d(h){if((h===45||de(h))&&r++<63){const p=h===45?d:c;return e.consume(h),p}return n(h)}}const Sn={partial:!0,tokenize:tu};function tu(e,t,n){return r;function r(a){return M(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const qa={continuation:{tokenize:ru},exit:iu,name:\"blockQuote\",tokenize:nu};function nu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return M(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function ru(e,t,n){const r=this;return i;function i(o){return M(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(qa,t,n)(o)}}function iu(e){e.exit(\"blockQuote\")}const Ua={name:\"characterEscape\",tokenize:au};function au(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 Vl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Wa={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\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=de,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Ml,f):(e.enter(\"characterReferenceValue\"),a=7,o=nr,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===de&&!Ba(r.sliceSerialize(d))?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 Ci={partial:!0,tokenize:lu},Ii={concrete:!0,name:\"codeFenced\",tokenize:su};function su(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(y)}function f(y){return y===s?(o++,e.consume(y),f):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),M(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Ci,w,E)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(y))}function d(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):M(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,h,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),d)}function h(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function w(y){return e.attempt(i,E,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&M(y)?H(e,b,\"linePrefix\",a+1)(y):b(y)}function b(y){return y===null||R(y)?e.check(Ci,w,E)(y):(e.enter(\"codeFlowValue\"),k(y))}function k(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),b(y)):(e.consume(y),k)}function E(y){return e.exit(\"codeFenced\"),t(y)}function I(y,P,T){let F=0;return v;function v(L){return y.enter(\"lineEnding\"),y.consume(L),y.exit(\"lineEnding\"),N}function N(L){return y.enter(\"codeFencedFence\"),M(L)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(L):$(L)}function $(L){return L===s?(y.enter(\"codeFencedFenceSequence\"),B(L)):T(L)}function B(L){return L===s?(F++,y.consume(L),B):F>=o?(y.exit(\"codeFencedFenceSequence\"),M(L)?H(y,U,\"whitespace\")(L):U(L)):T(L)}function U(L){return L===null||R(L)?(y.exit(\"codeFencedFence\"),P(L)):T(L)}}}function lu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Tn={name:\"codeIndented\",tokenize:cu},uu={partial:!0,tokenize:fu};function cu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(uu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function fu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):R(o)?i(o):n(o)}}const hu={name:\"codeText\",previous:pu,resolve:du,tokenize:mu};function du(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 pu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function mu(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\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class gu{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 ja(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new gu(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\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,_u(f,n)),n=t[n],l=!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 pe(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function _u(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let f,c,d=-1,h=n,p=0,w=0;const x=[w];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,x.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),d=x.length;d--;){const _=s.slice(x[d],x[d+1]),b=a.pop();u.push([b,b+_.length-1]),e.splice(b,2,_)}for(u.reverse(),d=-1;++d<u.length;)l[p+u[d][0]]=p+u[d][1],p+=u[d][1]-u[d][0]-1;return l}const yu={resolve:vu,tokenize:Su},bu={partial:!0,tokenize:wu};function vu(e){return ja(e),e}function Su(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):R(s)?e.check(bu,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 wu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Qa(e,t,n,r,i,a,o,s,u){const l=u||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),d):_===null||_===32||_===41||tr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(_))}function d(_){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\"}),h(_))}function h(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),d(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:h)}function p(_){return _===60||_===62||_===92?(e.consume(_),h):h(_)}function w(_){return!f&&(_===null||_===41||ae(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<l&&_===40?(e.consume(_),f++,w):_===41?(e.consume(_),f--,w):_===null||_===32||_===40||tr(_)?n(_):(e.consume(_),_===92?x:w)}function x(_){return _===40||_===41||_===92?(e.consume(_),w):w(_)}}function Ga(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(a),f}function f(h){return s>999||h===null||h===91||h===93&&!u||h===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(h))}function c(h){return h===null||h===91||h===93||R(h)||s++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!M(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function Ka(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):n(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===o?(e.exit(a),u(o)):d===null?n(d):R(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===o||d===null||R(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:f)}function c(d){return d===o||d===92?(e.consume(d),f):f(d)}}function xt(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):M(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ku={name:\"definition\",tokenize:Cu},xu={partial:!0,tokenize:Iu};function Cu(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),o(h)}function o(h){return Ga.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function s(h){return i=Tt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter(\"definitionMarker\"),e.consume(h),e.exit(\"definitionMarker\"),u):n(h)}function u(h){return ae(h)?xt(e,l)(h):l(h)}function l(h){return Qa(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(xu,c,c)(h)}function c(h){return M(h)?H(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||R(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function Iu(e,t,n){return r;function r(s){return ae(s)?xt(e,i)(s):n(s)}function i(s){return Ka(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return M(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const Eu={name:\"hardBreakEscape\",tokenize:Au};function Au(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Pu={name:\"headingAtx\",resolve:Tu,tokenize:Nu};function Tu(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\"},pe(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Nu(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||ae(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||R(f)?(e.exit(\"atxHeading\"),t(f)):M(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),s(f))}function l(f){return f===null||f===35||ae(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),l)}}const Du=[\"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\"],Ei=[\"pre\",\"script\",\"style\",\"textarea\"],$u={concrete:!0,name:\"htmlFlow\",resolveTo:Ru,tokenize:Ou},Fu={partial:!0,tokenize:Mu},zu={partial:!0,tokenize:Lu};function Ru(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 Ou(e,t,n){const r=this;let i,a,o,s,u;return l;function l(m){return f(m)}function f(m){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(m),c}function c(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),a=!0,w):m===63?(e.consume(m),i=3,r.interrupt?t:g):xe(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function d(m){return m===45?(e.consume(m),i=2,h):m===91?(e.consume(m),i=5,s=0,p):xe(m)?(e.consume(m),i=4,r.interrupt?t:g):n(m)}function h(m){return m===45?(e.consume(m),r.interrupt?t:g):n(m)}function p(m){const q=\"CDATA[\";return m===q.charCodeAt(s++)?(e.consume(m),s===q.length?r.interrupt?t:$:p):n(m)}function w(m){return xe(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function x(m){if(m===null||m===47||m===62||ae(m)){const q=m===47,oe=o.toLowerCase();return!q&&!a&&Ei.includes(oe)?(i=1,r.interrupt?t(m):$(m)):Du.includes(o.toLowerCase())?(i=6,q?(e.consume(m),_):r.interrupt?t(m):$(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(m):a?b(m):k(m))}return m===45||de(m)?(e.consume(m),o+=String.fromCharCode(m),x):n(m)}function _(m){return m===62?(e.consume(m),r.interrupt?t:$):n(m)}function b(m){return M(m)?(e.consume(m),b):v(m)}function k(m){return m===47?(e.consume(m),v):m===58||m===95||xe(m)?(e.consume(m),E):M(m)?(e.consume(m),k):v(m)}function E(m){return m===45||m===46||m===58||m===95||de(m)?(e.consume(m),E):I(m)}function I(m){return m===61?(e.consume(m),y):M(m)?(e.consume(m),I):k(m)}function y(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),u=m,P):M(m)?(e.consume(m),y):T(m)}function P(m){return m===u?(e.consume(m),u=null,F):m===null||R(m)?n(m):(e.consume(m),P)}function T(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||ae(m)?I(m):(e.consume(m),T)}function F(m){return m===47||m===62||M(m)?k(m):n(m)}function v(m){return m===62?(e.consume(m),N):n(m)}function N(m){return m===null||R(m)?$(m):M(m)?(e.consume(m),N):n(m)}function $(m){return m===45&&i===2?(e.consume(m),Z):m===60&&i===1?(e.consume(m),K):m===62&&i===4?(e.consume(m),D):m===63&&i===3?(e.consume(m),g):m===93&&i===5?(e.consume(m),ve):R(m)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Fu,W,B)(m)):m===null||R(m)?(e.exit(\"htmlFlowData\"),B(m)):(e.consume(m),$)}function B(m){return e.check(zu,U,W)(m)}function U(m){return e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),L}function L(m){return m===null||R(m)?B(m):(e.enter(\"htmlFlowData\"),$(m))}function Z(m){return m===45?(e.consume(m),g):$(m)}function K(m){return m===47?(e.consume(m),o=\"\",ue):$(m)}function ue(m){if(m===62){const q=o.toLowerCase();return Ei.includes(q)?(e.consume(m),D):$(m)}return xe(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),ue):$(m)}function ve(m){return m===93?(e.consume(m),g):$(m)}function g(m){return m===62?(e.consume(m),D):m===45&&i===2?(e.consume(m),g):$(m)}function D(m){return m===null||R(m)?(e.exit(\"htmlFlowData\"),W(m)):(e.consume(m),D)}function W(m){return e.exit(\"htmlFlow\"),t(m)}}function Lu(e,t,n){const r=this;return i;function i(o){return R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Mu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Sn,t,n)}}const Vu={name:\"htmlText\",tokenize:Bu};function Bu(e,t,n){const r=this;let i,a,o;return s;function s(g){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(g),u}function u(g){return g===33?(e.consume(g),l):g===47?(e.consume(g),I):g===63?(e.consume(g),k):xe(g)?(e.consume(g),T):n(g)}function l(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),a=0,p):xe(g)?(e.consume(g),b):n(g)}function f(g){return g===45?(e.consume(g),h):n(g)}function c(g){return g===null?n(g):g===45?(e.consume(g),d):R(g)?(o=c,K(g)):(e.consume(g),c)}function d(g){return g===45?(e.consume(g),h):c(g)}function h(g){return g===62?Z(g):g===45?d(g):c(g)}function p(g){const D=\"CDATA[\";return g===D.charCodeAt(a++)?(e.consume(g),a===D.length?w:p):n(g)}function w(g){return g===null?n(g):g===93?(e.consume(g),x):R(g)?(o=w,K(g)):(e.consume(g),w)}function x(g){return g===93?(e.consume(g),_):w(g)}function _(g){return g===62?Z(g):g===93?(e.consume(g),_):w(g)}function b(g){return g===null||g===62?Z(g):R(g)?(o=b,K(g)):(e.consume(g),b)}function k(g){return g===null?n(g):g===63?(e.consume(g),E):R(g)?(o=k,K(g)):(e.consume(g),k)}function E(g){return g===62?Z(g):k(g)}function I(g){return xe(g)?(e.consume(g),y):n(g)}function y(g){return g===45||de(g)?(e.consume(g),y):P(g)}function P(g){return R(g)?(o=P,K(g)):M(g)?(e.consume(g),P):Z(g)}function T(g){return g===45||de(g)?(e.consume(g),T):g===47||g===62||ae(g)?F(g):n(g)}function F(g){return g===47?(e.consume(g),Z):g===58||g===95||xe(g)?(e.consume(g),v):R(g)?(o=F,K(g)):M(g)?(e.consume(g),F):Z(g)}function v(g){return g===45||g===46||g===58||g===95||de(g)?(e.consume(g),v):N(g)}function N(g){return g===61?(e.consume(g),$):R(g)?(o=N,K(g)):M(g)?(e.consume(g),N):F(g)}function $(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),i=g,B):R(g)?(o=$,K(g)):M(g)?(e.consume(g),$):(e.consume(g),U)}function B(g){return g===i?(e.consume(g),i=void 0,L):g===null?n(g):R(g)?(o=B,K(g)):(e.consume(g),B)}function U(g){return g===null||g===34||g===39||g===60||g===61||g===96?n(g):g===47||g===62||ae(g)?F(g):(e.consume(g),U)}function L(g){return g===47||g===62||ae(g)?F(g):n(g)}function Z(g){return g===62?(e.consume(g),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(g)}function K(g){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),ue}function ue(g){return M(g)?H(e,ve,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(g):ve(g)}function ve(g){return e.enter(\"htmlTextData\"),o(g)}}const Ir={name:\"labelEnd\",resolveAll:Wu,resolveTo:ju,tokenize:Qu},Hu={tokenize:Gu},qu={tokenize:Ku},Uu={tokenize:Yu};function Wu(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&&pe(e,0,e.length,n),e}function ju(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=re(s,e.slice(a+1,a+r+3)),s=re(s,[[\"enter\",f,t]]),s=re(s,vn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=re(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=re(s,e.slice(o+1)),s=re(s,[[\"exit\",u,t]]),pe(e,a,e.length,s),e}function Qu(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(d){return a?a._inactive?c(d):(o=r.parser.defined.includes(Tt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Hu,f,o?f:c)(d):d===91?e.attempt(qu,f,o?l:c)(d):o?f(d):c(d)}function l(d){return e.attempt(Uu,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Gu(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 ae(c)?xt(e,a)(c):a(c)}function a(c){return c===41?f(c):Qa(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ae(c)?xt(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Ka(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ae(c)?xt(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 Ku(e,t,n){const r=this;return i;function i(s){return Ga.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Tt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Yu(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 Zu={name:\"labelStartImage\",resolveAll:Ir.resolveAll,tokenize:Ju};function Ju(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 Xu={name:\"labelStartLink\",resolveAll:Ir.resolveAll,tokenize:ec};function ec(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Nn={name:\"lineEnding\",tokenize:tc};function tc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const en={name:\"thematicBreak\",tokenize:nc};function nc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),M(l)?H(e,s,\"whitespace\")(l):s(l))}}const le={continuation:{tokenize:oc},exit:lc,name:\"list\",tokenize:ac},rc={partial:!0,tokenize:uc},ic={partial:!0,tokenize:sc};function ac(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(h){const p=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:nr(h)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(en,n,l)(h):l(h);if(!r.interrupt||h===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(h)}return n(h)}function u(h){return nr(h)&&++o<10?(e.consume(h),u):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit(\"listItemValue\"),l(h)):n(h)}function l(h){return e.enter(\"listItemMarker\"),e.consume(h),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||h,e.check(Sn,r.interrupt?n:f,e.attempt(rc,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return M(h)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(h),e.exit(\"listItemPrefixWhitespace\"),d):n(h)}function d(h){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(h)}}function oc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sn,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||!M(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(ic,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(le,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function sc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function lc(e){e.exit(this.containerState.type)}function uc(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!M(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Ai={name:\"setextUnderline\",resolveTo:cc,tokenize:fc};function cc(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 fc(e,t,n){const r=this;let i;return a;function a(l){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=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),M(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const hc={tokenize:dc};function dc(e){const t=this,n=e.attempt(Sn,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 pc={resolveAll:Za()},mc=Ya(\"string\"),gc=Ya(\"text\");function Ya(e){return{resolveAll:Za(e===\"text\"?_c: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 l(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),u}function u(f){return l(f)?(n.exit(\"data\"),a(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const c=i[f];let d=-1;if(c)for(;++d<c.length;){const h=c[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Za(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 _c(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const yc={42:le,43:le,45:le,48:le,49:le,50:le,51:le,52:le,53:le,54:le,55:le,56:le,57:le,62:qa},bc={91:ku},vc={[-2]:Tn,[-1]:Tn,32:Tn},Sc={35:Pu,42:en,45:[Ai,en],60:$u,61:Ai,95:en,96:Ii,126:Ii},wc={38:Wa,92:Ua},kc={[-5]:Nn,[-4]:Nn,[-3]:Nn,33:Zu,38:Wa,42:rr,60:[Xl,Vu],91:Xu,92:[Eu,Ua],93:Ir,95:rr,96:hu},xc={null:[rr,pc]},Cc={null:[42,95]},Ic={null:[]},Ec=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Cc,contentInitial:bc,disable:Ic,document:yc,flow:Sc,flowInitial:vc,insideSpan:xc,string:wc,text:kc},Symbol.toStringTag,{value:\"Module\"}));function Ac(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(I),check:P(y),consume:b,enter:k,exit:E,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=re(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=vn(a,l.events,l),l.events)}function d(N,$){return Tc(h(N),$)}function h(N){return Pc(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:L}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:L}}function w(N){i[N.line]=N.column,v()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){f=f(N)}function b(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,v()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function k(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function E(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function I(N,$){T(N,$.from)}function y(N,$){$.restore()}function P(N,$){return B;function B(U,L,Z){let K,ue,ve,g;return Array.isArray(U)?W(U):\"tokenize\"in U?W([U]):D(U);function D(X){return mt;function mt(Re){const rt=Re!==null&&X[Re],it=Re!==null&&X.null,Cn=[...Array.isArray(rt)?rt:rt?[rt]:[],...Array.isArray(it)?it:it?[it]:[]];return W(Cn)(Re)}}function W(X){return K=X,ue=0,X.length===0?Z:m(X[ue])}function m(X){return mt;function mt(Re){return g=F(),ve=X,X.partial||(l.currentConstruct=X),X.name&&l.parser.constructs.disable.null.includes(X.name)?oe():X.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,oe)(Re)}}function q(X){return N(ve,g),L}function oe(X){return g.restore(),++ue<K.length?m(K[ue]):Z}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&pe(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function F(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,L=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=L,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Pc(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 Tc(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 Nc(e){const r={constructs:Nl([Ec,...(e||{}).extensions||[]]),content:i(jl),defined:[],document:i(Gl),flow:i(hc),lazy:{},string:i(mc),text:i(gc)};return r;function i(a){return o;function o(s){return Ac(r,a,s)}}}function Dc(e){for(;!ja(e););return e}const Pi=/[\\0\\t\\n\\r]/g;function $c(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,f,c,d,h;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(Pi.lastIndex=c,l=Pi.exec(a),d=l&&l.index!==void 0?l.index:a.length,h=a.charCodeAt(d),!l){t=a.slice(c);break}if(h===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Fc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Wl(n)(Dc(Nc(n).document().write($c()(e,t,!0))))}const Dn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function zc(){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=Dn[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=Dn[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,Rc)),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\"+Dn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Rc(e,t){return t===\"|\"?t:e}class Oc{constructor(){this.map=[]}add(t,n,r){Lc(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 Lc(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 Mc(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 Vc(){return{flow:{null:{name:\"table\",tokenize:Bc,resolveAll:Hc}}}}function Bc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(v):B(v)}function u(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(v)}function l(v){return v===124||(o=!0,a+=1),f(v)}function f(v){return v===null?n(v):R(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),h):n(v):M(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||ae(v)?(e.exit(\"data\"),f(v)):(e.consume(v),v===92?d:c)}function d(v){return v===92||v===124?(e.consume(v),c):c(v)}function h(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,M(v)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):p(v))}function p(v){return v===45||v===58?x(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),w):I(v)}function w(v){return M(v)?H(e,x,\"whitespace\")(v):x(v)}function x(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),_):v===45?(a+=1,_(v)):v===null||R(v)?E(v):I(v)}function _(v){return v===45?(e.enter(\"tableDelimiterFiller\"),b(v)):I(v)}function b(v){return v===45?(e.consume(v),b):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(v))}function k(v){return M(v)?H(e,E,\"whitespace\")(v):E(v)}function E(v){return v===124?p(v):v===null||R(v)?!o||i!==a?I(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):I(v)}function I(v){return n(v)}function y(v){return e.enter(\"tableRow\"),P(v)}function P(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),P):v===null||R(v)?(e.exit(\"tableRow\"),t(v)):M(v)?H(e,P,\"whitespace\")(v):(e.enter(\"data\"),T(v))}function T(v){return v===null||v===124||ae(v)?(e.exit(\"data\"),P(v)):(e.consume(v),v===92?F:T)}function F(v){return v===92||v===124?(e.consume(v),T):T(v)}}function Hc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,f,c;const d=new Oc;for(;++n<e.length;){const h=e[n],p=h[1];h[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Ti(d,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",f,t]])),i=p.type===\"tableDelimiterRow\"?2:f?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Gt(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Gt(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Gt(d,t,a,i,n,c)):o[1]!==0&&(c=Gt(d,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ti(d,t,u,l,f),d.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]===\"enter\"&&h[1].type===\"table\"&&(h[1]._align=Mc(t.events,n))}return e}function Gt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},at(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=at(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=at(t.events,n[2]),f=at(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},at(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ti(e,t,n,r,i){const a=[],o=at(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 at(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function qc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Uc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},d=[[\"enter\",f,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],h=s.parser.constructs.insideSpan.null;h&&pe(d,d.length,0,vn(h,o.slice(l+1,u),s)),pe(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),pe(o,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,f=this.events;let c=0;return d;function d(p){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),h(p))}function h(p){const w=pn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,h);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=pn(p);return x._open=!_||_===2&&!!w,x._close=!w||w===2&&!!_,s(p)}}}function Wc(e){return Fc(e,{allowDangerousHtml:!0,extensions:[Vc(),Uc()],htmlExtensions:[zc(),qc()]})}const jc={update:()=>{},getValues:()=>({})},Be=Ft({}),Bt=Ft(jc);function Qc(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Ja(i,a,t));return S(G,{children:r})}function Ja(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>Ja(u,l,n));return Y(i,o,...s)}return null}function Gc({node:e}){const t=kr(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return Y(e.tag,n,e.children.length>0?Pe(e.children):void 0)}function Kc(e,t){if(Tl(e.name))return null;const n=Il(e.name);if(n)return S(Cl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Al(e.name);return r?S(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):S(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function ir(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return S(hl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Kc(e,t);case\"html\":return S(Gc,{node:e},t);default:return e}}function Xa(e){return e.length===0?null:e.map((t,n)=>ir(t,n))}function Yc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Zc(e){const t=C.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let a=1;a<n.length;a++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[a]]}return i==null?\"\":String(i)}function Pe(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,o)=>ir(a,o));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const o=e[a];if(o.type===\"text\")r+=o.value.replace(/^[ \\t]{4,}/gm,\" \");else if(o.type===\"variable\"&&Yc(r))r+=Zc(o);else{const s=n.length;n.push(ir(o,a)),r+=`<span data-tw=\"${s}\"></span>`}}const i=Wc(r);return Qc(i,n)}const Jc=\"spindle\",Xc=1;let Kt=null,$n=null;function He(){return $n||($n={saves:new Map,playthroughs:new Map,meta:new Map}),$n}function ef(){return Kt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Kt=new Promise((e,t)=>{const n=indexedDB.open(Jc,Xc);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),Kt))}function qe(e,t){return ef().then(n=>n.transaction(e,t).objectStore(e))}function Ue(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function wn(e){try{const t=await qe(\"saves\",\"readwrite\");await Ue(t.put(e))}catch{He().saves.set(e.meta.id,e)}}async function kn(e){try{const t=await qe(\"saves\",\"readonly\");return await Ue(t.get(e))??void 0}catch{return He().saves.get(e)}}async function tf(e){try{const t=await qe(\"saves\",\"readwrite\");await Ue(t.delete(e))}catch{He().saves.delete(e)}}async function nf(e){try{const n=(await qe(\"saves\",\"readonly\")).index(\"ifid\");return await Ue(n.getAll(e))??[]}catch{return[...He().saves.values()].filter(t=>t.meta.ifid===e)}}async function eo(e){try{const t=await qe(\"playthroughs\",\"readwrite\");await Ue(t.put(e))}catch{He().playthroughs.set(e.id,e)}}async function Er(e){try{const n=(await qe(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Ue(n.getAll(e))??[]}catch{return[...He().playthroughs.values()].filter(t=>t.ifid===e)}}async function Ar(e){try{const t=await qe(\"meta\",\"readonly\"),n=await Ue(t.get(e));return n?n.value:void 0}catch{return He().meta.get(e)}}async function to(e,t){try{const n=await qe(\"meta\",\"readwrite\");await Ue(n.put({key:e,value:t}))}catch{He().meta.set(e,t)}}const no=new Map,xn=new Map;function rf(e,t){no.set(e,t),xn.set(t,e)}function af(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ne(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(xn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(af(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const ar=\"__spindle_class__\",or=\"__spindle_data__\";function Ke(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),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=xn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[ar]:o,[or]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Ye(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(ar in r&&or in r){const o=r[ar],s=r[or],u=no.get(o);if(!u){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 l=Object.create(u.prototype);for(const f of Object.keys(s))l[f]=t(s[f]);return l}const i=r.constructor;if(xn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let sr=null,lr=null,Ni=!1;function of(e){sr=e}function sf(e){lr=e}function lf(e){if(lr)try{const i=new Function(\"passage\",\"variables\",lr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(sr)try{const r=sr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function uf(){Ni||(Ni=!0)}async function Di(e){const n=(await Er(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await eo(i),await to(`currentPlaythroughId.${e}`,r),r}async function cf(e){return Ar(`currentPlaythroughId.${e}`)}async function ro(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:lf(n),passage:n.passage,custom:r},o=ne(n);o.variables=Ke(o.variables),o.history=o.history.map(u=>({...u,variables:Ke(u.variables)}));const s={meta:a,payload:o};return await wn(s),s}async function io(e,t){const n=await kn(e);if(!n)return;const r=ne(t);r.variables=Ke(r.variables),r.history=r.history.map(a=>({...a,variables:Ke(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await wn(i),i}async function ff(e){const t=await kn(e);if(!t)return;const n=t.payload;return n.variables=Ye(n.variables),n.history=n.history.map(r=>({...r,variables:Ye(r.variables)})),n}async function hf(e){await tf(e)}async function df(e,t){const n=await kn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await wn(r)}async function pf(e){const[t,n]=await Promise.all([nf(e),Er(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const ao=\"autosave.\";async function mf(e,t,n){const r=`${ao}${e}`,i=await Ar(r);if(i){const o=await io(i,n);if(o)return o}const a=await ro(e,t,n,{isAutosave:!0});return await to(r,a.meta.id),a}async function gf(e){const t=`${ao}${e}`,n=await Ar(t);if(n)return ff(n)}const Pr=\"spindle.session.\";function _f(e,t){try{sessionStorage.setItem(`${Pr}${e}`,JSON.stringify(t))}catch{}}function yf(e){try{const t=sessionStorage.getItem(`${Pr}${e}`);if(!t)return;const n=JSON.parse(t);return n.variables=Ye(n.variables),n.history=n.history.map(r=>({...r,variables:Ye(r.variables)})),n}catch{return}}function bf(e){try{sessionStorage.removeItem(`${Pr}${e}`)}catch{}}async function vf(e){const t=await kn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Sf(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=ne(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Er(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await eo(a)}return await wn(n),n}function oo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=ht(t.content),i=dt(r),a=document.createElement(\"div\");ye(Y(()=>Pe(i),null),a),ye(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&sf(n.content)}let so=0,_e=[],Fn=!1,Ht=[],tn=null;function Tr(e){const t=C.getState();try{return!!bn(e,t.variables,t.temporary)}catch{return!1}}function lo(e,t){const n=so++,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:Tr(e),priority:i?.priority??0};return _e.push(o),_e.sort((s,u)=>u.priority-s.priority),()=>{_e=_e.filter(s=>s.id!==n)}}function uo(e){_e=_e.filter(t=>t.name!==e)}function wf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Ra(n.run,r.variables,r.temporary)}n.dialog&&(Ht.push(n.dialog),tn?.()),n.goto&&C.getState().navigate(n.goto)}}const kf=10;function xf(){if(!Fn){Fn=!0;try{for(let e=0;e<kf;e++){let t=!1;const n=[..._e];for(const r of n){if(!_e.includes(r))continue;const i=Tr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(_e=_e.filter(o=>o.id!==r.id)),wf(r))}if(!t)break}}finally{Fn=!1}}}function Cf(){for(const e of _e)e.lastResult=Tr(e.condition)}function If(){_e=[],Ht=[],so=0}function Ef(e){return tn=e,Ht.length>0&&e(),()=>{tn===e&&(tn=null)}}function $i(){return Ht.shift()}function Af(){return Ht.length}Js();const Pf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ge={},me=[],Oe={};function Fi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function zi(e,t){const[,n,r]=el(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:Fi(n),inverse:Fi(r)}}function Tf(e){let t=Ge;for(let n=0;n<e;n++)t=ot(t,me[n].forward);return t}let ge=[];function zn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(ge.length>i.length&&(ge.length=i.length),ge.length<i.length)if(i.length-ge.length===1){const l=i.length-1;ge[l]={passage:i[l].passage,variables:Ke(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ge;for(let f=0;f<i.length;f++)if(f>0&&(l=ot(l,me[f-1].forward)),f>=ge.length){const c=f===i.length-1?r:l;ge[f]={passage:i[f].passage,variables:Ke(c),timestamp:i[f].timestamp,prng:i[f].prng}}}_f(t.ifid,{passage:n,variables:Ke(r),history:ge,historyIndex:a,visitCounts:o,renderCounts:s,prng:dn()})}}function Ri(e){Ge=e,me=[],Oe=e,ge=[]}function Oi(e){e?.prng?Da(e.prng.seed,e.prng.pull):e&&Xn()}const C=zs()(nl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,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=ne(r);Ri(ne(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}}),Oe=t().variables;const o=n.ifid;uf().then(async()=>{const s=await cf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await Di(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Pf.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=zi(Oe,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),me.length=o.historyIndex,me.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:dn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ge=ot(Ge,me[u].forward);o.history=o.history.slice(s),me=me.slice(s),ge=ge.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Oe=t().variables,zn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(ot(r,me[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Oe=t().variables,Oi(t().history[t().historyIndex]),zn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(ot(i,me[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Oe=t().variables,Oi(t().history[t().historyIndex]),zn(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Xn(),If();const a=ne(r);Ri(ne(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Oe=t().variables,oo(),bf(n.ifid),Di(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),mf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),gf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Ge;for(let f=0;f<i.length;f++)f>0&&(l=ot(l,me[f-1].forward)),u.push({passage:i[f].passage,variables:ne(l),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:ne(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:dn()}},loadFromPayload:n=>{const r=Ye(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Ye(n.history[o].variables);i.push(zi(a,s)),a=s}Ge=ne(r),me=i,ge=[],e(o=>{o.currentPassage=n.passage,o.variables=Ye(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=n.historyIndex,o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Oe=t().variables,n.prng?Da(n.prng.seed,n.prng.pull):Xn()},getHistoryVariables:n=>ne(Tf(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}}))),Nf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Df(){const t=C(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Nf;try{const r=ht(n),i=dt(r);return S(G,{children:Xa(i)})}catch(r){return S(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}const co=Ft(null);function Nr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=C(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=fe(()=>{if(!o)return S(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=ht(o),c=dt(f);return Pe(c)}catch(f){return S(\"div\",{class:\"error\",children:[\"Error in dialog: \",f.message]})}},[o]),u=f=>{f.target.classList.contains(\"dialog-overlay\")&&r()},l=n?`dialog-panel ${n}`:\"dialog-panel\";return S(co.Provider,{value:r,children:S(\"div\",{class:\"dialog-overlay\",onClick:u,children:S(\"div\",{class:l,children:[S(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),S(\"div\",{class:\"dialog-body\",children:s})]})})})}function $f(){const[e,t]=J(null),n=be(()=>{const i=$i();t(i??null)},[]);Ee(()=>Ef(()=>{t(i=>i!==null?i:$i()??null)}),[]);const r=be(()=>{t(null),Af()>0&&requestAnimationFrame(n)},[n]);return e?S(Nr,{passageName:e,onClose:r}):null}function Ff(){const e=C(n=>n.storyData),t=C(n=>n.currentPassage);return Ee(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),C.getState().save()):r.key===\"F9\"&&(r.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?S(\"div\",{class:\"loading\",children:\"Loading...\"}):S(G,{children:[S(Df,{}),S($f,{})]})}function zf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const h=parseInt(d.getAttribute(\"pid\")||\"0\",10),p=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),x=d.textContent||\"\",_={},b=new Set([\"pid\",\"name\",\"tags\"]);for(const E of d.attributes)b.has(E.name)||(_[E.name]=E.value);const k={pid:h,name:p,tags:w,metadata:_,content:x};f.set(p,k),c.set(h,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:l}}const yt=new Map;let se={},Li=!1;function fo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Rf(){localStorage.setItem(fo(),JSON.stringify(se))}function Rn(){if(!Li){Li=!0;try{const e=localStorage.getItem(fo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(se={...se,...t})}}catch{}}}const Nt={addToggle(e,t){yt.set(e,{type:\"toggle\",config:t}),e in se||(se[e]=t.default),Rn()},addList(e,t){yt.set(e,{type:\"list\",config:t}),e in se||(se[e]=t.default),Rn()},addRange(e,t){yt.set(e,{type:\"range\",config:t}),e in se||(se[e]=t.default),Rn()},get(e){return se[e]},getToggle(e){const t=se[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=se[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=se[e];return typeof t==\"number\"?t:0},set(e,t){se[e]=t,Rf()},getAll(){return{...se}},getDefinitions(){return yt},hasAny(){return yt.size>0}};function Of(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Ra(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])}const mn=new Map,ur=new Set,cr=new Map;function Lf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(cr.get(r)??0)+1;return cr.set(r,i),i===1?r:`${r}:${i}`}function Mf(e){return mn.set(e.id,e),Vi(),()=>{mn.delete(e.id),Vi()}}function Mi(){return Array.from(mn.values())}function Vf(e){return mn.get(e)}function Bf(){cr.clear()}function Hf(e){return ur.add(e),()=>{ur.delete(e)}}function Vi(){for(const e of ur)e()}function qf(e){const t=ce(\"\");t.current||(t.current=Lf(e.type,e.key,e.authorId));const n=t.current;return tt(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),Mf(r)}),n}function Uf(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 Dr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?ho(t):\"\"}function Wf(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 jf(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 Qf(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Gf={useState:J,useRef:ce,useEffect:Ee,useLayoutEffect:tt,useCallback:be,useMemo:fe,useContext:ze};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=kr(),r=a(r),i=a(i));const{update:o,getValues:s}=ze(Bt),u={collectText:Uf,sourceLocation:Dr,parseVarArgs:Wf,extractOptions:jf,h:Y,renderNodes:Pe,renderInlineNodes:Xa,hooks:Gf,useAction:qf,className:r,id:i,resolve:a,cls:Qf(e.name,r),mutate:l=>Of(l,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){u.merged=wr();const l=u.merged;u.evaluate=f=>bn(f,l[0],l[1],l[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");u.varName=f,u.value=C(d=>d.variables[f]);const c=C(d=>d.setVariable);u.setValue=d=>c(f,d)}return u.wrap=l=>u.className||u.id?Y(\"span\",{id:u.id,class:u.className},l):Y(G,null,l),e.render(n,u)}if(El(e.name,t),e.subMacros)for(const n of e.subMacros)Pl(n)}function Kf(){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){C.getState().save(e)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(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:Nt,registerClass(e,t){rf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){of(e)}},getActions(){return Mi()},performAction(e,t){const n=Vf(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return Hf(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(Mi())})})})},watch(e,t){return lo(e,t)},unwatch(e){uo(e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},random(){return xr()},randomInt(e,t){return $a(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){dl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=dn())})},isEnabled(){return pl()},get seed(){return ml()},get pull(){return gl()}}}}function Yf(){window.Story=Kf()}const Zf=/^\\$(\\w+)\\s*=\\s*(.+)$/,Bi=/\\$(\\w+(?:\\.\\w+)*)/g,Hi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Jf=new Set([\"number\",\"string\",\"boolean\"]);function po(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,po(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Jf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Xf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Zf);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=po(s);t.set(a,{...u,name:a,default:s})}return t}function eh(e){const t=new Set;let n;for(Hi.lastIndex=0;(n=Hi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function th(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function nh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=eh(i.content);let o;for(Bi.lastIndex=0;(o=Bi.exec(i.content))!==null;){const s=o[1],u=th(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function rh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Me({macro:e,error:t}){return S(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Dr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return S(Me,{macro:\"print\",error:n})}}});function ih(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 ah(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 qi(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=bn(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${Dr()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];ah(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=ih(e))}catch(f){return S(Me,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const f=C.getState();qi(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{qi(o,u,s,n,r,i,e)},[n,r,i]),null}});function oh(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=sh(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 sh(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 lh(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=oh(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=lh(a,o,i),l=t.cls;return S(\"div\",{class:l,id:t.id,children:[S(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&S(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return S(Me,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?S(\"span\",{id:o,class:a,children:i}):S(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 S(Me,{macro:\"if\",error:i})}}return null}});function uh(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 ch({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=J(()=>({...e,...t,...n})),o=ce(i);o.current=i;const s=be(()=>o.current,[]),u=be((f,c)=>{a(d=>({...d,[f]:c}))},[]),l=fe(()=>({update:u,getValues:s}),[u,s]);return S(Bt.Provider,{value:l,children:S(Be.Provider,{value:i,children:Pe(r)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ze(Be);let i;try{i=uh(e)}catch(f){return S(Me,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const f=n.evaluate(s);if(!Array.isArray(f))return S(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=f}catch(f){return S(Me,{macro:\"for\",error:f})}const l=u.map((f,c)=>{const d={[a]:f,...o?{[o]:c}:void 0};return S(ch,{parentValues:r,ownKeys:d,initialValues:{},children:t},c)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=()=>{const a=document.createElement(\"div\"),o=Y(Bt.Provider,{value:{update:n.update,getValues:n.getValues}},Y(Be.Provider,{value:n.getValues()},Pe(t)));ye(o,a),ye(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:i}),S(\"button\",{id:n.id,class:n.cls,onClick:i,children:r})}});function fh(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 Ui(e,t,n){const r=document.createElement(\"div\"),i=Y(Bt.Provider,{value:{update:n,getValues:t}},Y(Be.Provider,{value:t()},Pe(e)));ye(i,r),ye(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=fh(e),a=o=>{o.preventDefault(),Ui(t,n.getValues,n.update),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Ui(t,n.getValues,n.update),i&&C.getState().navigate(i)}}),S(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return S(Me,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return S(G,{children:n.renderNodes(o.children)})}catch(s){return S(Me,{macro:\"case\",error:s})}}return i?S(G,{children:n.renderNodes(i.children)}):null}});function $r(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(h=>({delay:h.rawArgs?$r(h.rawArgs):0,nodes:h.children,className:h.className,id:h.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const h=o+1,p=a[h].delay,w=setTimeout(()=>{s(h)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),f=t.resolve(u.className),c=t.resolve(u.id),d=f||c?S(\"span\",{id:c,class:f,children:l}):l;return t.wrap(d)}});const mo=Ft({stop:()=>{}});V({name:\"repeat\",render({rawArgs:e,children:t=[],className:n,id:r},i){const{useState:a,useEffect:o,useCallback:s,useMemo:u}=i.hooks,[l,f]=u(()=>{const k=E=>{if(!E||!Aa(E))return E;const I=C.getState();return Pa(E,I.variables,I.temporary,{})};return[k(n),k(r)]},[n,r]),c=$r(e),[d,h]=a(0),[p,w]=a(!1),x=s(()=>w(!0),[]);if(o(()=>{if(p)return;const k=setInterval(()=>{h(E=>E+1)},c);return()=>clearInterval(k)},[c,p]),d===0&&!p)return null;const _=l?`macro-repeat ${l}`:void 0,b=S(mo.Provider,{value:{stop:x},children:S(\"span\",{children:i.renderNodes(t)},d)});return _||f?S(\"span\",{id:f,class:_,children:b}):b}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(mo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=$r(e),s=a(null),[u,l]=r(0),[f,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||f>=u)return;const p=setInterval(()=>{c(w=>w>=u?(clearInterval(p),w):w+1)},o);return()=>clearInterval(p)},[u,o]);const d=f>=u&&u>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return S(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!d,void 0)},children:[S(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!d?`inset(0 ${(u-f)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&u>0&&S(\"span\",{class:\"macro-type-cursor\"})]})}});function hh(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=hh(e);return n.hooks.useLayoutEffect(()=>{La(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return S(\"span\",{id:t.id,class:r,children:n})}});function nt(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=e.dialog?J(!1):[!1,void 0],a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),S(G,{children:[S(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&S(Nr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}nt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});nt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});nt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});nt({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.saveVersion),{perform:()=>e(),disabled:!t()}}});nt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});nt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});nt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Nt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,o=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return S(G,{children:[S(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:a}),r&&S(Nr,{passageName:o,onClose:()=>i(!1)})]})}});function dh(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)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function ph(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 mh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function gh(){const[e,t]=J(\"load\"),[n,r]=J([]),[i,a]=J(!0),[o,s]=J(null),[u,l]=J(()=>new Set),[f,c]=J(null),[d,h]=J(\"\"),p=ce(null),w=ce(null),x=ze(co),_=C(D=>D.storyData),b=C(D=>D.playthroughId),k=C(D=>D.getSavePayload),E=C(D=>D.loadFromPayload),I=_?.ifid??\"\",y=be(async()=>{if(!I)return;const D=await pf(I);r(D),a(!1)},[I]);Ee(()=>{y()},[y]),Ee(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const P=ce(),T=(D,W=\"success\")=>{clearTimeout(P.current),s({text:D,type:W}),P.current=window.setTimeout(()=>s(null),3e3)},F=D=>{l(W=>{const m=new Set(W);return m.has(D)?m.delete(D):m.add(D),m})},v=async()=>{if(!(!I||!b))try{const D=k();await ro(I,b,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const W=k();await io(D,W),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{E(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await hf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),h(D.meta.title)},L=async()=>{if(!(!f||!d.trim()))try{await df(f,d.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?L():D.key===\"Escape\"&&c(null)},K=async D=>{try{const W=await vf(D);if(!W)return;const m=new Blob([JSON.stringify(W,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(m),oe=document.createElement(\"a\");oe.href=q,oe.download=`save-${W.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,oe.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},ue=()=>{w.current?.click()},ve=async D=>{const W=D.target,m=W.files?.[0];if(m){W.value=\"\";try{const q=await m.text(),oe=JSON.parse(q);if(!dh(oe))throw new Error(\"Invalid save file format\");await Sf(oe,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},g=n.reduce((D,W)=>D+W.saves.length,0);return S(\"div\",{class:\"save-manager\",children:[S(\"div\",{class:\"saves-header\",children:S(\"div\",{class:\"saves-header-left\",children:S(\"div\",{class:\"saves-mode-toggle\",children:[S(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),S(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),S(\"div\",{class:\"saves-toolbar\",children:[S(\"button\",{class:\"saves-toolbar-button\",onClick:ue,children:\"Import\"}),S(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ve})]}),S(\"div\",{class:\"saves-body\",children:[i?S(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):g===0&&e===\"load\"?S(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const W=u.has(D.playthrough.id),m=D.playthrough.id===b;return e===\"save\"&&!m||e===\"load\"&&D.saves.length===0&&!m?null:S(\"div\",{class:\"playthrough-group\",children:[S(\"div\",{class:\"playthrough-header\",onClick:()=>F(D.playthrough.id),children:[S(\"span\",{class:`playthrough-chevron ${W?\"\":\"open\"}`,children:\"▶\"}),S(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,m?\" (current)\":\"\"]}),S(\"span\",{class:\"playthrough-date\",children:mh(D.playthrough.createdAt)})]}),!W&&S(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>S(\"div\",{class:\"save-slot\",children:[S(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?S(\"input\",{ref:p,class:\"save-rename-input\",value:d,onInput:oe=>h(oe.target.value),onKeyDown:Z,onBlur:L}):S(\"div\",{class:\"save-slot-title\",children:q.meta.title}),S(\"div\",{class:\"save-slot-meta\",children:[S(\"span\",{children:q.meta.passage}),S(\"span\",{children:ph(q.meta.updatedAt)})]})]}),S(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?S(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):S(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>K(q.meta.id),children:\"Export\"}),S(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&m&&S(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===b)&&S(\"div\",{class:\"playthrough-group\",children:S(\"div\",{class:\"playthrough-saves\",children:S(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&S(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return S(gh,{})}});function _h({name:e,def:t}){const[n,r]=J(()=>Nt.get(e)),i=a=>{r(a),Nt.set(e,a)};switch(t.type){case\"toggle\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>S(\"option\",{value:a,children:a},a))})]});case\"range\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:[t.config.label,\": \",String(n)]}),S(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function yh(){const e=Nt.getDefinitions();return S(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>S(_h,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return S(yh,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const f=t.evaluate(i);a=String(f)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return S(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=ht(o.content),u=dt(s),l=r?t.renderInlineNodes(u):t.renderNodes(u);return t.wrap(l)}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),S(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function bh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}V({name:\"checkbox\",render({rawArgs:e},t){const{varName:n,label:r}=bh(e),i=n.startsWith(\"$\")?n.slice(1):n,a=C(s=>s.variables[i]),o=C(s=>s.setVariable);return t.useAction({type:\"checkbox\",key:`$${i}`,authorId:t.id,label:r||i,variable:i,value:!!a,perform:s=>o(i,s!==void 0?!!s:!a)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>o(i,!a)}),r?` ${r}`:null]})}});function vh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}V({name:\"radiobutton\",render({rawArgs:e},t){const{varName:n,value:r,label:i}=vh(e),a=n.startsWith(\"$\")?n.slice(1):n,o=C(u=>u.variables[a]),s=C(u=>u.setVariable);return t.useAction({type:\"radiobutton\",key:`$${a}:${r}`,authorId:t.id,label:i||r,variable:a,value:o,perform:()=>s(a,r)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"radio\",name:`radio-${a}`,checked:o===r,onChange:()=>s(a,r)}),i?` ${i}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),S(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>S(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const a=(n.indexOf(String(t.value))+1)%n.length;t.setValue(n[a])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),S(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function vt(e){const t=ht(e.content),n=dt(t);return Pe(n)}const Sh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function wh({passage:e,dataTransition:t}){const n=C(h=>h.storyData),r=Sh.has(e.name),[i,a]=J(!1),o=fe(()=>{try{return vt(e)}catch(h){return S(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",ho(e),\": \",h.message]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),f=fe(()=>{if(!s)return null;try{return vt(s)}catch(h){return console.error(\"spindle: Error in PassageHeader:\",h),null}},[s?.content]),c=fe(()=>{if(!u)return null;try{return vt(u)}catch(h){return console.error(\"spindle: Error in PassageFooter:\",h),null}},[u?.content]);Ee(()=>(l&&a(!0),()=>a(!1)),[e.name]);const d=fe(()=>{if(!i||!l)return null;try{return vt(l)}catch(h){return console.error(\"spindle: Error in PassageDone:\",h),null}},[i,l?.content]);return S(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&S(\"div\",{class:\"passage-header\",children:f}),o,c&&S(\"div\",{class:\"passage-footer\",children:c}),d&&S(\"div\",{hidden:!0,children:d})]})}const kh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),fr={type:\"fade-through\",duration:300,pause:50};function xh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!kh.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 On(e){return{type:e.type,duration:e.duration??fr.duration,pause:e.pause??fr.pause}}function Ch(e,t,n){const r=xh(e);return r?On(r):t?On(t):n?On(n):{...fr}}function Wi(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 Ln(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 Mn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(h=>h.currentPassage),r=C(h=>h.storyData),[i,a]=J(n),o=ce(\"fade\"),s=ce(0),u=ce(null),l=ce([]),f=be(()=>{for(const h of l.current)clearTimeout(h);l.current=[],Mn(u.current)},[]);Ee(()=>{const h=C.getState(),{history:p,historyIndex:w,transitionConfig:x}=h,_=h.consumeNextTransition(),b=s.current;s.current=p.length;const k=!i,E=p.length===1&&w===0&&b>1,I=p.length>1&&w===p.length-1&&b>1&&Math.abs(p.length-b)>1;if(n===i)return;f();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(k||E||I){o.current=\"fade\",a(n);return}const P=Ch(y.tags,_,x);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Ln(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Ln(T,P);const F=T.querySelector(\".passage\");if(!F){a(n);return}const v=Wi(F,P.type);T.appendChild(v),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{Mn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Ln(T,P);const F=T.querySelector(\".passage\");if(!F){a(n);return}const v=Wi(F,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(v),a(n);const N=setTimeout(()=>{Mn(T)},P.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return S(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return S(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[d&&S(\"div\",{hidden:!0,children:vt(d)},`ready-${n}`),S(\"div\",{class:\"passage-container\",ref:u,children:c&&S(wh,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],d=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=d;break;case\"dialog\":s.dialog=d;break;case\"run\":s.run=d;break;case\"name\":s.name=d;break;case\"priority\":s.priority=d?Number(d):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,lo(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,uo(r)),null}});function ji(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 Qi(){const e=zf();if(Yf(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",d=document.getElementById(\"root\");throw d&&ji(d,[c]),new Error(`spindle: ${c}`)}const r=Xf(n.content),i=nh(e.passages,r);if(i.length>0){const c=document.getElementById(\"root\");throw c&&ji(c,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=rh(r),C.getState().init(e,t),oo();const a=yf(e.ifid);a&&C.getState().loadFromPayload(a);for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const d=ht(c.content),h=dt(d);for(const p of h)if(p.type===\"macro\"&&p.name===\"widget\"&&p.rawArgs){const w=p.rawArgs.trim().split(/\\s+/),x=w[0].replace(/[\"']/g,\"\"),_=w.slice(1).filter(b=>b.startsWith(\"$\")||b.startsWith(\"_\")||b.startsWith(\"@\"));La(x,p.children,_)}}let o=\"\";C.subscribe(c=>{c.currentPassage!==o&&(o=c.currentPassage,Bf())});let s=C.getState().variables,u=C.getState().historyIndex;C.subscribe(c=>{c.variables!==s&&(c.historyIndex===u?xf():Cf()),s=c.variables,u=c.historyIndex});const l=e.passages.get(\"StoryInterface\");l&&!l.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const f=document.getElementById(\"root\");if(!f)throw new Error('spindle: No <div id=\"root\"> element found.');ye(S(Ff,{}),f),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Qi):Qi();</script>\n <style rel=\"stylesheet\" crossorigin>*,*: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}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.22.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 Dt,O,Gi,je,Hr,Ki,Yi,Zi,hr,Vn,Bn,Ji,nn={},rn=[],qo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$t=Array.isArray;function Ce(e,t){for(var n in t)e[n]=t[n];return e}function dr(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?Dt.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 St(e,o,r,i,null)}function St(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??++Gi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Uo(){return{current:null}}function G(e){return e.children}function Ie(e,t){this.props=e,this.context=t}function st(e,t){if(t==null)return e.__?st(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\"?st(e):null}function Wo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ce({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),pr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??st(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,na(r,a,i),t.__e=t.__=null,a.__e!=n&&Xi(a)}}function Xi(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}),Xi(e)}function Hn(e){(!e.__d&&(e.__d=!0)&&je.push(e)&&!an.__r++||Hr!=O.debounceRendering)&&((Hr=O.debounceRendering)||Ki)(an)}function an(){for(var e,t=1;je.length;)je.length>t&&je.sort(Yi),e=je.shift(),t=je.length,Wo(e);an.__r=0}function ea(e,t,n,r,i,a,o,s,u,l,f){var c,d,h,p,w,x,_,b=r&&r.__k||rn,k=t.length;for(u=jo(n,t,b,u,k),c=0;c<k;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&b[h.__i]||nn,h.__i=c,x=pr(e,h,d,i,a,o,s,u,l,f),p=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&mr(d.ref,null,h),f.push(h.ref,h.__c||p,h)),w==null&&p!=null&&(w=p),(_=!!(4&h.__u))||d.__k===h.__k?u=ta(h,u,e,_):typeof h.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),h.__u&=-7);return n.__e=w,u}function jo(e,t,n,r,i){var a,o,s,u,l,f=n.length,c=f,d=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]=St(null,o,null,null,null):$t(o)?o=e.__k[a]=St(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=St(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+d,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Qo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>f?d--:i<f&&d++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,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=st(s)),ia(s,s));return r}function ta(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=ta(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=st(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function $e(e,t){return t=t||[],e==null||typeof e==\"boolean\"||($t(e)?e.some(function(n){$e(n,t)}):t.push(e)),t}function Qo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&u==l.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function qr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||qo.test(t)?n:n+\"px\"}function qt(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||qr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||qr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Zi,\"$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=hr,e.addEventListener(t,a?Bn:Vn,a)):e.removeEventListener(t,a?Bn:Vn,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 Ur(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=hr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function pr(e,t,n,r,i,a,o,s,u,l){var f,c,d,h,p,w,x,_,b,k,E,I,y,P,T,F=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof F==\"function\")try{if(_=t.props,b=\"prototype\"in F&&F.prototype.render,k=(f=F.contextType)&&r[f.__c],E=f?k?k.props.value:f.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(b?t.__c=c=new F(_,E):(t.__c=c=new Ie(_,E),c.constructor=F,c.render=Ko),k&&k.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),b&&c.__s==null&&(c.__s=c.state),b&&F.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ce({},c.__s)),Ce(c.__s,F.getDerivedStateFromProps(_,c.__s))),h=c.props,p=c.state,c.__v=t,d)b&&F.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),b&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(b&&F.getDerivedStateFromProps==null&&_!==h&&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)}),rn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),b&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,p,w)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=O.__r,y=0,b)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),rn.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&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Ce(Ce({},r),c.getChildContext())),b&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,p)),P=f!=null&&f.type===G&&f.key==null?ra(f.props.children):f,s=ea(e,$t(P)?P:[P],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(v){if(t.__v=null,u||a!=null)if(v.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)dr(a[T]);qn(t)}else t.__e=n.__e,t.__k=n.__k,v.then||qn(t);O.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Go(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function qn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(qn))}function na(e,t,n){for(var r=0;r<n.length;r++)mr(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function ra(e){return typeof e!=\"object\"||e==null||e.__b>0?e:$t(e)?e.map(ra):Ce({},e)}function Go(e,t,n,r,i,a,o,s,u){var l,f,c,d,h,p,w,x=n.props||nn,_=t.props,b=t.type;if(b==\"svg\"?i=\"http://www.w3.org/2000/svg\":b==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&\"setAttribute\"in h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(_);e=document.createElementNS(i,b,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(b==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Dt.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(h=e.attributes[l]).name]=h.value;for(l in x)h=x[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||qt(e,l,null,h,i);for(l in _)h=_[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?p=h:l==\"checked\"?w=h:s&&typeof h!=\"function\"||x[l]===h||qt(e,l,h,x[l],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ea(t.type==\"template\"?e.content:e,$t(d)?d:[d],t,n,r,b==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&st(n,0),s,u),a!=null)for(l=a.length;l--;)dr(a[l]);s||(l=\"value\",b==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||b==\"progress\"&&!p||b==\"option\"&&p!=x[l])&&qt(e,l,p,x[l],i),l=\"checked\",w!=null&&w!=e[l]&&qt(e,l,w,x[l],i))}return e}function mr(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function ia(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||mr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ia(r[i],t,n||typeof e.type!=\"function\");n||dr(e.__e),e.__c=e.__=e.__e=void 0}function Ko(e,t,n){return this.constructor(e,n)}function ye(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],pr(t,e=(!r&&n||t).__k=Y(G,null,[e]),i||nn,nn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Dt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),na(a,e,o)}function aa(e,t){ye(e,t,aa)}function Yo(e,t,n){var r,i,a,o,s=Ce({},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?Dt.call(arguments,2):n),St(e.type,s,r||e.key,i||e.ref,null)}function Ft(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,Hn(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\"+Ji++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Dt=rn.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Gi=0,Ie.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ce({},this.state),typeof e==\"function\"&&(e=e(Ce({},n),this.props)),e&&Ce(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Hn(this))},Ie.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Hn(this))},Ie.prototype.render=G,je=[],Ki=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yi=function(e,t){return e.__v.__b-t.__v.__b},an.__r=0,Zi=/(PointerCapture)$|Capture$/i,hr=0,Vn=Ur(!1),Bn=Ur(!0),Ji=0;var Zo=0;function S(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zo,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var Le,j,In,Wr,lt=0,oa=[],Q=O,jr=Q.__b,Qr=Q.__r,Gr=Q.diffed,Kr=Q.__c,Yr=Q.unmount,Zr=Q.__;function ft(e,t){Q.__h&&Q.__h(j,e,lt||t),lt=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function J(e){return lt=1,gr(ca,e)}function gr(e,t,n){var r=ft(Le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ca(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(d){return d.__c});if(f.every(function(d){return!d.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return f.some(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};j.__f=!0;var a=j.shouldComponentUpdate,o=j.componentWillUpdate;j.componentWillUpdate=function(s,u,l){if(this.__e){var f=a;a=void 0,i(s,u,l),a=f}o&&o.call(this,s,u,l)},j.shouldComponentUpdate=i}return r.__N||r.__}function Ee(e,t){var n=ft(Le++,3);!Q.__s&&_r(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function tt(e,t){var n=ft(Le++,4);!Q.__s&&_r(n.__H,t)&&(n.__=e,n.u=t,j.__h.push(n))}function ce(e){return lt=5,fe(function(){return{current:e}},[])}function sa(e,t,n){lt=6,tt(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 fe(e,t){var n=ft(Le++,7);return _r(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function be(e,t){return lt=8,fe(function(){return e},t)}function ze(e){var t=j.context[e.__c],n=ft(Le++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(j)),t.props.value):e.__}function la(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ua(){var e=ft(Le++,11);if(!e.__){for(var t=j.__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 Jo(){for(var e;e=oa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Yt),t.__h.some(Un),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){j=null,jr&&jr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Zr&&Zr(e,t)},Q.__r=function(e){Qr&&Qr(e),Le=0;var t=(j=e.__c).__H;t&&(In===j?(t.__h=[],j.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Yt),t.__h.some(Un),t.__h=[],Le=0)),In=j},Q.diffed=function(e){Gr&&Gr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(oa.push(t)!==1&&Wr===Q.requestAnimationFrame||((Wr=Q.requestAnimationFrame)||Xo)(Jo)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),In=j=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Yt),n.__h=n.__h.filter(function(r){return!r.__||Un(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Kr&&Kr(e,t)},Q.unmount=function(e){Yr&&Yr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Yt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Jr=typeof requestAnimationFrame==\"function\";function Xo(e){var t,n=function(){clearTimeout(r),Jr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Jr&&(t=requestAnimationFrame(n))}function Yt(e){var t=j,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),j=t}function Un(e){var t=j;e.__c=e.__(),j=t}function _r(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ca(e,t){return typeof t==\"function\"?t(e):t}const Xr=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(h=>h(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},es=(e=>e?Xr(e):Xr);function fa(e,t){for(var n in t)e[n]=t[n];return e}function Wn(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 ha(e,t){var n=t(),r=J({t:{__:n,u:t}}),i=r[0].t,a=r[1];return tt(function(){i.__=n,i.u=t,En(i)&&a({t:i})},[e,n,t]),Ee(function(){return En(i)&&a({t:i}),e(function(){En(i)&&a({t:i})})},[e]),n}function En(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 da(e){e()}function pa(e){return e}function ma(){return[!1,da]}var ga=tt;function jn(e,t){this.props=e,this.context=t}function ts(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:Wn(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}(jn.prototype=new Ie).isPureReactComponent=!0,jn.prototype.shouldComponentUpdate=function(e,t){return Wn(this.props,e)||Wn(this.state,t)};var ei=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ei&&ei(e)};var ns=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function rs(e){function t(n){var r=fa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ns,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ti=function(e,t){return e==null?null:$e($e(e).map(t))},is={map:ti,forEach:ti,count:function(e){return e?$e(e).length:0},only:function(e){var t=$e(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:$e},as=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}as(e,t,n,r)};var ni=O.unmount;function _a(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=fa({},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 _a(r,t,n)})),e}function ya(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ya(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 Zt(){this.__u=0,this.o=null,this.__b=null}function ba(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function os(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 bt(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ni&&ni(e)},(Zt.prototype=new Ie).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ba(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=ya(l,l.__c.__P,l.__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)},Zt.prototype.componentWillUnmount=function(){this.o=[]},Zt.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]=_a(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 ri=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 ss(e){return this.getChildContext=function(){return e.context},e.children}function ls(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){ye(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)}}}ye(Y(ss,{context:t.context},e.__v),t.v)}function us(e,t){var n=Y(ls,{__v:e,h:t});return n.containerInfo=t,n}(bt.prototype=new Ie).__a=function(e){var t=this,n=ba(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ri(t,e,r)):i()};n?n(a):a()}},bt.prototype.render=function(e){this.i=null,this.l=new Map;var t=$e(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},bt.prototype.componentDidUpdate=bt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ri(e,n,t)})};var va=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,cs=/^(?: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]/,fs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,hs=/[A-Z0-9]/g,ds=typeof document<\"u\",ps=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function ms(e,t,n){return t.__k==null&&(t.textContent=\"\"),ye(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function gs(e,t,n){return aa(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ie.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ie.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ii=O.event;function _s(){}function ys(){return this.cancelBubble}function bs(){return this.defaultPrevented}O.event=function(e){return ii&&(e=ii(e)),e.persist=_s,e.isPropagationStopped=ys,e.isDefaultPrevented=bs,e.nativeEvent=e};var yr,vs={enumerable:!1,configurable:!0,get:function(){return this.class}},ai=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||ds&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ps(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":fs.test(o)&&(o=u):u=o=\"oninput\":a&&cs.test(o)?o=o.replace(hs,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=$e(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=$e(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",vs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=va,ai&&ai(e)};var oi=O.__r;O.__r=function(e){oi&&oi(e),yr=e.__c};var si=O.diffed;O.diffed=function(e){si&&si(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),yr=null};var Ss={ReactCurrentDispatcher:{current:{readContext:function(e){return yr.__n[e.__c].props.value},useCallback:be,useContext:ze,useDebugValue:la,useDeferredValue:pa,useEffect:Ee,useId:ua,useImperativeHandle:sa,useInsertionEffect:ga,useLayoutEffect:tt,useMemo:fe,useReducer:gr,useRef:ce,useState:J,useSyncExternalStore:ha,useTransition:ma}}};function ws(e){return Y.bind(null,e)}function gn(e){return!!e&&e.$$typeof===va}function ks(e){return gn(e)&&e.type===G}function xs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Cs(e){return gn(e)?Yo.apply(null,arguments):e}function Is(e){return!!e.__k&&(ye(null,e),!0)}function Es(e){return e&&(e.base||e.nodeType===1&&e)||null}var As=function(e,t){return e(t)},Ps=function(e,t){return e(t)},Ts=G,Ns=gn,Ut={useState:J,useId:ua,useReducer:gr,useEffect:Ee,useLayoutEffect:tt,useInsertionEffect:ga,useTransition:ma,useDeferredValue:pa,useSyncExternalStore:ha,startTransition:da,useRef:ce,useImperativeHandle:sa,useMemo:fe,useCallback:be,useContext:ze,useDebugValue:la,version:\"18.3.1\",Children:is,render:ms,hydrate:gs,unmountComponentAtNode:Is,createPortal:us,createElement:Y,createContext:Ft,createFactory:ws,cloneElement:Cs,createRef:Uo,Fragment:G,isValidElement:gn,isElement:Ns,isFragment:ks,isMemo:xs,findDOMNode:Es,Component:Ie,PureComponent:jn,memo:ts,forwardRef:rs,flushSync:Ps,unstable_batchedUpdates:As,StrictMode:Ts,Suspense:Zt,SuspenseList:bt,lazy:os,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ss};const Ds=e=>e;function $s(e,t=Ds){const n=Ut.useSyncExternalStore(e.subscribe,Ut.useCallback(()=>t(e.getState()),[e,t]),Ut.useCallback(()=>t(e.getInitialState()),[e,t]));return Ut.useDebugValue(n),n}const Fs=e=>{const t=es(e),n=r=>$s(t,r);return Object.assign(n,t),n},zs=(e=>Fs);var br=Symbol.for(\"immer-nothing\"),wt=Symbol.for(\"immer-draftable\"),ee=Symbol.for(\"immer-state\");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var he=Object,Ze=he.getPrototypeOf,Ct=\"constructor\",zt=\"prototype\",Qn=\"configurable\",on=\"enumerable\",Jt=\"writable\",It=\"value\",Fe=e=>!!e&&!!e[ee];function Ae(e){return e?Sa(e)||Ot(e)||!!e[wt]||!!e[Ct]?.[wt]||Lt(e)||Mt(e):!1}var Rs=he[zt][Ct].toString(),li=new WeakMap;function Sa(e){if(!e||!ut(e))return!1;const t=Ze(e);if(t===null||t===he[zt])return!0;const n=he.hasOwnProperty.call(t,Ct)&&t[Ct];if(n===Object)return!0;if(!Qe(n))return!1;let r=li.get(n);return r===void 0&&(r=Function.toString.call(n),li.set(n,r)),r===Rs}function Rt(e,t,n=!0){Je(e)===0?(n?Reflect.ownKeys(e):he.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Je(e){const t=e[ee];return t?t.type_:Ot(e)?1:Lt(e)?2:Mt(e)?3:0}var kt=(e,t,n=Je(e))=>n===2?e.has(t):he[zt].hasOwnProperty.call(e,t),Ne=(e,t,n=Je(e))=>n===2?e.get(t):e[t],sn=(e,t,n,r=Je(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Os(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ot=Array.isArray,Lt=e=>e instanceof Map,Mt=e=>e instanceof Set,ut=e=>typeof e==\"object\",Qe=e=>typeof e==\"function\",An=e=>typeof e==\"boolean\";function Ls(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ms=e=>ut(e)?e?.[ee]:null,De=e=>e.copy_||e.base_,vr=e=>e.modified_?e.copy_:e.base_;function Gn(e,t){if(Lt(e))return new Map(e);if(Mt(e))return new Set(e);if(Ot(e))return Array[zt].slice.call(e);const n=Sa(e);if(t===!0||t===\"class_only\"&&!n){const r=he.getOwnPropertyDescriptors(e);delete r[ee];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Jt]===!1&&(s[Jt]=!0,s[Qn]=!0),(s.get||s.set)&&(r[o]={[Qn]:!0,[Jt]:!0,[on]:s[on],[It]:e[o]})}return he.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=he.create(r);return he.assign(i,e)}}function Sr(e,t=!1){return _n(e)||Fe(e)||!Ae(e)||(Je(e)>1&&he.defineProperties(e,{set:Wt,add:Wt,clear:Wt,delete:Wt}),he.freeze(e),t&&Rt(e,(n,r)=>{Sr(r,!0)},!1)),e}function Vs(){ie(2)}var Wt={[It]:Vs};function _n(e){return e===null||!ut(e)?!0:he.isFrozen(e)}var ln=\"MapSet\",un=\"Patches\",ui=\"ArrayMethods\",cn={};function Xe(e){const t=cn[e];return t||ie(0,e),t}var ci=e=>!!cn[e];function Bs(e,t){cn[e]||(cn[e]=t)}var Et,wa=()=>Et,Hs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ci(ln)?Xe(ln):void 0,arrayMethodsPlugin_:ci(ui)?Xe(ui):void 0});function fi(e,t){t&&(e.patchPlugin_=Xe(un),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kn(e){Yn(e),e.drafts_.forEach(qs),e.drafts_=null}function Yn(e){e===Et&&(Et=e.parent_)}var hi=e=>Et=Hs(Et,e);function qs(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function di(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Kn(t),ie(4)),Ae(e)&&(e=pi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ee].base_,e,t)}else e=pi(t,n);return Us(t,e,!0),Kn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==br?e:void 0}function pi(e,t){if(_n(t))return t;const n=t[ee];if(!n)return fn(t,e.handledSet_,e);if(!yn(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);Ca(n,e)}return n.copy_}function Us(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sr(t,n)}function ka(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var yn=(e,t)=>e.scope_===t,Ws=[];function xa(e,t,n,r){const i=De(e),a=e.type_;if(r!==void 0&&Ne(i,r,a)===t){sn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Rt(i,(u,l)=>{if(Fe(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??Ws;for(const s of o)sn(i,s,n,a)}function js(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!yn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=vr(a);xa(e,a.draft_??a,o,n),Ca(a,i)})}function Ca(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 Qs(e,t,n){const{scope_:r}=e;if(Fe(n)){const i=n[ee];yn(i,r)&&i.callbacks_.push(function(){Xt(e);const o=vr(i);xa(e,n,o,t)})}else Ae(n)&&e.callbacks_.push(function(){const a=De(e);e.type_===3?a.has(n)&&fn(n,r.handledSet_,r):Ne(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&fn(Ne(e.copy_,t,e.type_),r.handledSet_,r)})}function fn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fe(e)||t.has(e)||!Ae(e)||_n(e)||(t.add(e),Rt(e,(r,i)=>{if(Fe(i)){const a=i[ee];if(yn(a,n)){const o=vr(a);sn(e,r,o,e.type_),ka(a)}}else Ae(i)&&fn(i,t,n)})),e}function Gs(e,t){const n=Ot(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=hn;n&&(i=[r],a=At);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hn={get(e,t){if(t===ee)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=De(e);if(!kt(i,t,e.type_))return Ks(e,i,t);const a=i[t];if(e.finalized_||!Ae(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ls(t))return a;if(a===Pn(e.base_,t)){Xt(e);const o=e.type_===1?+t:t,s=Jn(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in De(e)},ownKeys(e){return Reflect.ownKeys(De(e))},set(e,t,n){const r=Ia(De(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Pn(De(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Os(n,i)&&(n!==void 0||kt(e.base_,t,e.type_)))return!0;Xt(e),Zn(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),Qs(e,t,n)),!0},deleteProperty(e,t){return Xt(e),Pn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Zn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=De(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Jt]:!0,[Qn]:e.type_!==1||t!==\"length\",[on]:r[on],[It]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},At={};for(let e in hn){let t=hn[e];At[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}At.deleteProperty=function(e,t){return At.set.call(this,e,t,void 0)};At.set=function(e,t,n){return hn.set.call(this,e[0],t,n,e[0])};function Pn(e,t){const n=e[ee];return(n?De(n):e)[t]}function Ks(e,t,n){const r=Ia(t,n);return r?It in r?r[It]:r.get?.call(e.draft_):void 0}function Ia(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function Xt(e){e.copy_||(e.assigned_=new Map,e.copy_=Gn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ys=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Qe(t)&&!Qe(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,f=>n.call(this,f,...l))}}Qe(n)||ie(6),r!==void 0&&!Qe(r)&&ie(7);let i;if(Ae(t)){const a=hi(this),o=Jn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Kn(a):Yn(a)}return fi(a,r),di(i,a)}else if(!t||!ut(t)){if(i=n(t),i===void 0&&(i=t),i===br&&(i=void 0),this.autoFreeze_&&Sr(i,!0),r){const a=[],o=[];Xe(un).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ie(1,t)},this.produceWithPatches=(t,n)=>{if(Qe(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},An(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),An(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),An(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ae(e)||ie(8),Fe(e)&&(e=Zs(e));const t=hi(this),n=Jn(t,e,void 0);return n[ee].isManual_=!0,Yn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return fi(r,t),di(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Xe(un).applyPatches_;return Fe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Jn(e,t,n,r){const[i,a]=Lt(t)?Xe(ln).proxyMap_(t,n):Mt(t)?Xe(ln).proxySet_(t,n):Gs(t,n);return(n?.scope_??wa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?js(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Zs(e){return Fe(e)||ie(10,e),Ea(e)}function Ea(e){if(!Ae(e)||_n(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Gn(e,!0);return Rt(n,(i,a)=>{sn(n,i,Ea(a))},r),t&&(t.finalized_=!1),n}function Js(){function t(p,w=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Ms(Ne(x,p.key_)),b=Ne(x,p.key_);if(b===void 0||b!==p.draft_&&b!==p.base_&&b!==p.copy_||_!=null&&_.base_!==p.base_)return null;const k=p.parent_.type_===3;let E;if(k){const I=p.parent_;E=Array.from(I.drafts_.keys()).indexOf(p.key_)}else E=p.key_;if(!(k&&x.size>E||kt(x,E)))return null;w.push(E)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let x=p;for(let _=0;_<w.length-1;_++){const b=w[_];if(x=Ne(x,b),!ut(x)||x===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:b}=x;switch(p.type_){case 0:case 2:return u(p,w,_,b);case 1:return s(p,w,_,b);case 3:return l(p,w,_,b)}}function s(p,w,x,_){let{base_:b,assigned_:k}=p,E=p.copy_;E.length<b.length&&([b,E]=[E,b],[x,_]=[_,x]);const I=p.allIndicesReassigned_===!0;for(let y=0;y<b.length;y++){const P=E[y],T=b[y];if((I||k?.get(y.toString()))&&P!==T){const v=P?.[ee];if(v&&v.modified_)continue;const N=w.concat([y]);x.push({op:r,path:N,value:h(P)}),_.push({op:r,path:N,value:h(T)})}}for(let y=b.length;y<E.length;y++){const P=w.concat([y]);x.push({op:i,path:P,value:h(E[y])})}for(let y=E.length-1;b.length<=y;--y){const P=w.concat([y]);_.push({op:a,path:P})}}function u(p,w,x,_){const{base_:b,copy_:k,type_:E}=p;Rt(p.assigned_,(I,y)=>{const P=Ne(b,I,E),T=Ne(k,I,E),F=y?kt(b,I)?r:i:a;if(P===T&&F===r)return;const v=w.concat(I);x.push(F===a?{op:F,path:v}:{op:F,path:v,value:h(T)}),_.push(F===i?{op:a,path:v}:F===a?{op:i,path:v,value:h(P)}:{op:r,path:v,value:h(P)})})}function l(p,w,x,_){let{base_:b,copy_:k}=p,E=0;b.forEach(I=>{if(!k.has(I)){const y=w.concat([E]);x.push({op:a,path:y,value:I}),_.unshift({op:i,path:y,value:I})}E++}),E=0,k.forEach(I=>{if(!b.has(I)){const y=w.concat([E]);x.push({op:i,path:y,value:I}),_.unshift({op:a,path:y,value:I})}E++})}function f(p,w,x){const{patches_:_,inversePatches_:b}=x;_.push({op:r,path:[],value:w===br?void 0:w}),b.push({op:r,path:[],value:p})}function c(p,w){return w.forEach(x=>{const{path:_,op:b}=x;let k=p;for(let P=0;P<_.length-1;P++){const T=Je(k);let F=_[P];typeof F!=\"string\"&&typeof F!=\"number\"&&(F=\"\"+F),(T===0||T===1)&&(F===\"__proto__\"||F===Ct)&&ie(19),Qe(k)&&F===zt&&ie(19),k=Ne(k,F),ut(k)||ie(18,_.join(\"/\"))}const E=Je(k),I=d(x.value),y=_[_.length-1];switch(b){case r:switch(E){case 2:return k.set(y,I);case 3:ie(16);default:return k[y]=I}case i:switch(E){case 1:return y===\"-\"?k.push(I):k.splice(y,0,I);case 2:return k.set(y,I);case 3:return k.add(I);default:return k[y]=I}case a:switch(E){case 1:return k.splice(y,1);case 2:return k.delete(y);case 3:return k.delete(x.value);default:return delete k[y]}default:ie(17,b)}}),p}function d(p){if(!Ae(p))return p;if(Ot(p))return p.map(d);if(Lt(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,d(_)]));if(Mt(p))return new Set(Array.from(p).map(d));const w=Object.create(Ze(p));for(const x in p)w[x]=d(p[x]);return kt(p,wt)&&(w[wt]=p[wt]),w}function h(p){return Fe(p)?d(p):p}Bs(un,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Pt=new Ys,Xs=Pt.produce,el=Pt.produceWithPatches.bind(Pt),ot=Pt.applyPatches.bind(Pt);const tl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Xs(i):i;return t(s,a,...o)},e(r.setState,n,r)),nl=tl,rl=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),il=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function al(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function mi(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function gi(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 ol(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;for(;t<e.length&&e[t]!==a;)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 ht(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=gi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const f=e.slice(l,n);n+=2;const{display:c,target:d}=al(f),h={type:\"link\",display:c,target:d,start:a,end:n};o&&(h.className=o),s&&(h.id=s),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=gi(e,n+1);s=l.className||void 0,u=l.id||void 0;let f=l.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:h,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let d=1;const h=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const p=e.slice(h,n);n++;const{name:w,rawArgs:x,isClose:_}=mi(p),b={type:\"macro\",name:w,rawArgs:x,isClose:_,start:a,end:n};s&&(b.className=s),u&&(b.id=u),t.push(b),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const f=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:d,rawArgs:h,isClose:p}=mi(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&rl.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const f=ol(e,o);o=f.endIdx;let c=il.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const sl=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]),_i={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},ll=new Set([\"if\",\"switch\",\"timed\"]);function dt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const o=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${o} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(_i[i.name]){const a=_i[i.name],o=n.length>0?n[n.length-1].node:null;if(!o||o.type!==\"macro\"||o.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches.push(s);break}if(sl.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(ll.has(i.name)){const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),a.branches=[o]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}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=ze(Be);return fe(()=>[e,t,n],[e,t,n])}const ul=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,cl=/\\{[\\$_@][\\w.]+\\}/;function Aa(e){return cl.test(e)}function fl(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 Pa(e,t,n,r){return e.replace(ul,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let f;return o===\"$\"?f=t[l]:o===\"_\"?f=n[l]:f=r[l],u.length>1&&(f=fl(f,u)),f==null?\"\":String(f)})}function kr(){const[e,t,n]=wr();return be(r=>r===void 0||!Aa(r)?r:Pa(r,e,t,n),[e,t,n])}function hl({name:e,scope:t,className:n,id:r}){const i=kr();n=i(n),r=i(r);const a=ze(Be),o=e.split(\".\"),s=o[0],u=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=o[c];l=l[d]}const f=l==null?\"\":String(l);return n||r?S(\"span\",{id:r,class:n,children:f}):S(G,{children:f})}function Ta(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 Na(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let pt=!1,Vt=\"\",et=0,ct=null;function dl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Vt=n,et=0,ct=Ta(Na(n)),pt=!0}function Da(e,t){Vt=e,et=0,ct=Ta(Na(e)),pt=!0;for(let n=0;n<t;n++)ct();et=t}function Xn(){pt=!1,Vt=\"\",et=0,ct=null}function dn(){return pt?{seed:Vt,pull:et}:null}function xr(){return!pt||!ct?Math.random():(et++,ct())}function $a(e,t){return e>t&&([e,t]=[t,e]),Math.floor(xr()*(t-e+1))+e}function pl(){return pt}function ml(){return Vt}function gl(){return et}const _l=500,We=new Map,yl=/\\$(\\w+)/g,bl=/\\b_(\\w+)/g,vl=/@(\\w+)/g;function Sl(e){return e.replace(yl,'variables[\"$1\"]').replace(bl,'temporary[\"$1\"]').replace(vl,'locals[\"$1\"]')}function Cr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Sl(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=Cr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const wl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Fa(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",wl+t);if(We.set(e,r),We.size>_l){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let jt=null,yi=null,bi=null;function za(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(jt&&yi===t&&bi===n)return jt;const r=h=>t[h??C.getState().currentPassage]??0,i=h=>r(h)>0,a=(...h)=>h.some(p=>r(p)>0),o=(...h)=>h.every(p=>r(p)>0),s=h=>n[h??C.getState().currentPassage]??0;return jt={currentPassage:()=>{const h=C.getState();return h.storyData?.passages.get(h.currentPassage)},previousPassage:()=>{const h=C.getState();if(h.historyIndex<=0)return;const p=h.history[h.historyIndex-1]?.passage;return p?h.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:h=>s(h)>0,hasRenderedAny:(...h)=>h.some(p=>s(p)>0),hasRenderedAll:(...h)=>h.every(p=>s(p)>0),random:xr,randomInt:$a},yi=t,bi=n,jt}function bn(e,t,n,r={}){const a=`return (${Cr(e)});`;return Fa(a,a)(t,n,r,za())}function Ra(e,t,n,r={}){const i=Cr(e);Fa(\"exec:\"+i,i)(t,n,r,za())}function kl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function xl({body:e,parentValues:t,ownKeys:n}){const[r,i]=J(()=>({...t,...n})),a=ce(r);a.current=r;const o=be(()=>a.current,[]),s=be((l,f)=>{i(c=>({...c,[l]:f}))},[]),u=fe(()=>({update:s,getValues:o}),[s,o]);return S(Bt.Provider,{value:u,children:S(Be.Provider,{value:r,children:Pe(e)})})}function Cl({body:e,params:t,rawArgs:n}){const r=ze(Be),[i,a,o]=wr();if(t.length===0||!n)return S(G,{children:Pe(e)});const s=kl(n),u={};for(let l=0;l<t.length;l++){const f=t[l],c=s[l];let d;if(c!==void 0)try{d=bn(c,i,a,o)}catch{d=void 0}u[f.startsWith(\"@\")?f.slice(1):f]=d}return S(xl,{body:e,parentValues:r,ownKeys:u})}const Oa=new Map;function La(e,t,n){Oa.set(e.toLowerCase(),{body:t,params:n})}function Il(e){return Oa.get(e.toLowerCase())}const Ma=new Map;function El(e,t){Ma.set(e.toLowerCase(),t)}function Al(e){return Ma.get(e.toLowerCase())}const Va=new Set;function Pl(e){Va.add(e.toLowerCase())}function Tl(e){return Va.has(e.toLowerCase())}const vi=document.createElement(\"i\");function Ba(e){const t=\"&\"+e+\";\";vi.innerHTML=t;const n=vi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function pe(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 re(e,t){return e.length>0?(pe(e,e.length,0,t),e):t}const er={}.hasOwnProperty;function Nl(e){const t={};let n=-1;for(;++n<e.length;)Dl(t,e[n]);return t}function Dl(e,t){let n;for(n in t){const i=(er.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){er.call(i,o)||(i[o]=[]);const s=a[o];$l(i[o],Array.isArray(s)?s:s?[s]:[])}}}function $l(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);pe(e,0,0,r)}function Fl(e){const t={};let n=-1;for(;++n<e.length;)zl(t,e[n]);return t}function zl(e,t){let n;for(n in t){const i=(er.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 Rl(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 Ol={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ha(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Ol[n]+\";\"}}function Tt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const xe=Ve(/[A-Za-z]/),de=Ve(/[\\dA-Za-z]/),Ll=Ve(/[#-'*+\\--9=?A-Z^-~]/);function tr(e){return e!==null&&(e<32||e===127)}const nr=Ve(/\\d/),Ml=Ve(/[\\dA-Fa-f]/),Vl=Ve(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function ae(e){return e!==null&&(e<0||e===32)}function M(e){return e===-2||e===-1||e===32}const Bl=Ve(/\\p{P}|\\p{S}/u),Hl=Ve(/\\s/);function Ve(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Qt(e,t){const n=Ha(ql(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 ql(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&de(e.charCodeAt(n+1))&&de(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 Si={}.hasOwnProperty,wi=/^(https?|ircs?|mailto|xmpp)$/i,Ul=/^https?$/i;function Wl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Fl([{enter:{blockQuote:L,codeFenced:ve,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:W,codeText:zo,content:ko,definition:_o,definitionDestinationString:bo,definitionLabelString:x,definitionTitleString:x,emphasis:$o,htmlFlow:Do,htmlText:Or,image:q,label:x,link:oe,listItemMarker:N,listItemValue:v,listOrdered:T,listUnordered:F,paragraph:K,reference:x,resource:rt,resourceDestinationString:it,resourceTitleString:x,setextHeading:Co,strong:Fo},exit:{atxHeading:Eo,atxHeadingSequence:xo,autolinkEmail:Ho,autolinkProtocol:Bo,blockQuote:Z,characterEscapeValue:gt,characterReferenceMarkerHexadecimal:Lr,characterReferenceMarkerNumeric:Lr,characterReferenceValue:Vo,codeFenced:m,codeFencedFence:D,codeFencedFenceInfo:g,codeFencedFenceMeta:P,codeFlowValue:No,codeIndented:m,codeText:Ro,codeTextData:gt,data:gt,definition:wo,definitionDestinationString:vo,definitionLabelString:yo,definitionTitleString:So,emphasis:Oo,hardBreakEscape:zr,hardBreakTrailing:zr,htmlFlow:Rr,htmlFlowData:gt,htmlText:Rr,htmlTextData:gt,image:Fr,label:mt,labelText:X,lineEnding:To,link:Fr,listOrdered:$,listUnordered:B,paragraph:ue,reference:P,referenceString:Re,resource:P,resourceDestinationString:Cn,resourceTitleString:go,setextHeading:Po,setextHeadingLineSequence:Ao,setextHeadingText:Io,strong:Lo,thematicBreak:Mo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},f={buffer:x,encode:y,getData:w,lineEndingIfNeeded:I,options:t,raw:k,resume:_,setData:p,tag:b};let c=t.defaultLineEnding;return d;function d(A){let z=-1,te=0;const Se=[];let we=[],Te=[];for(;++z<A.length;)!c&&(A[z][1].type===\"lineEnding\"||A[z][1].type===\"lineEndingBlank\")&&(c=A[z][2].sliceSerialize(A[z][1])),(A[z][1].type===\"listOrdered\"||A[z][1].type===\"listUnordered\")&&(A[z][0]===\"enter\"?Se.push(z):h(A.slice(Se.pop(),z))),A[z][1].type===\"definition\"&&(A[z][0]===\"enter\"?(Te=re(Te,A.slice(te,z)),te=z):(we=re(we,A.slice(te,z+1)),te=z+1));we=re(we,Te),we=re(we,A.slice(te)),z=-1;const ke=we;for(u.enter.null&&u.enter.null.call(f);++z<A.length;){const Mr=u[ke[z][0]],Vr=ke[z][1].type,Br=Mr[Vr];Si.call(Mr,Vr)&&Br&&Br.call({sliceSerialize:ke[z][2].sliceSerialize,...f},ke[z][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(A){const z=A.length;let te=0,Se=0,we=!1,Te;for(;++te<z;){const ke=A[te];if(ke[1]._container)Te=void 0,ke[0]===\"enter\"?Se++:Se--;else switch(ke[1].type){case\"listItemPrefix\":{ke[0]===\"exit\"&&(Te=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{ke[0]===\"enter\"&&!Se&&(Te?Te=void 0:we=!0);break}default:Te=void 0}}A[0][1]._loose=we}function p(A,z){l[A]=z}function w(A){return l[A]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function b(A){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(A))}function k(A){p(\"lastWasTag\"),i[i.length-1].push(A)}function E(){k(c||`\n`)}function I(){const A=i[i.length-1],z=A[A.length-1],te=z?z.charCodeAt(z.length-1):null;te===10||te===13||te===null||E()}function y(A){return w(\"ignoreEncode\")?A:Ha(A)}function P(){_()}function T(A){o.push(!A._loose),I(),b(\"<ol\"),p(\"expectFirstItem\",!0)}function F(A){o.push(!A._loose),I(),b(\"<ul\"),p(\"expectFirstItem\",!0)}function v(A){if(w(\"expectFirstItem\")){const z=Number.parseInt(this.sliceSerialize(A),10);z!==1&&b(' start=\"'+y(String(z))+'\"')}}function N(){w(\"expectFirstItem\")?b(\">\"):U(),I(),b(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),E(),b(\"</ol>\")}function B(){U(),o.pop(),E(),b(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&I(),b(\"</li>\"),p(\"slurpAllLineEndings\")}function L(){o.push(!1),I(),b(\"<blockquote>\")}function Z(){o.pop(),I(),b(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function K(){o[o.length-1]||(I(),b(\"<p>\")),p(\"slurpAllLineEndings\")}function ue(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):b(\"</p>\")}function ve(){I(),b(\"<pre><code\"),p(\"fencesCount\",0)}function g(){const A=_();b(' class=\"language-'+A+'\"')}function D(){const A=w(\"fencesCount\")||0;A||(b(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",A+1)}function W(){I(),b(\"<pre><code>\")}function m(){const A=w(\"fencesCount\");A!==void 0&&A<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&E(),w(\"flowCodeSeenData\")&&I(),b(\"</code></pre>\"),A!==void 0&&A<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function oe(){a.push({})}function X(A){a[a.length-1].labelId=this.sliceSerialize(A)}function mt(){a[a.length-1].label=_()}function Re(A){a[a.length-1].referenceId=this.sliceSerialize(A)}function rt(){x(),a[a.length-1].destination=\"\"}function it(){x(),p(\"ignoreEncode\",!0)}function Cn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function go(){a[a.length-1].title=_()}function Fr(){let A=a.length-1;const z=a[A],te=z.referenceId||z.labelId,Se=z.destination===void 0?r[Tt(te)]:z;for(n=!0;A--;)if(a[A].image){n=void 0;break}z.image?(b('<img src=\"'+Qt(Se.destination,t.allowDangerousProtocol?void 0:Ul)+'\" alt=\"'),k(z.label),b('\"')):b('<a href=\"'+Qt(Se.destination,t.allowDangerousProtocol?void 0:wi)+'\"'),b(Se.title?' title=\"'+Se.title+'\"':\"\"),z.image?b(\" />\"):(b(\">\"),k(z.label),b(\"</a>\")),a.pop()}function _o(){x(),a.push({})}function yo(A){_(),a[a.length-1].labelId=this.sliceSerialize(A)}function bo(){x(),p(\"ignoreEncode\",!0)}function vo(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function So(){a[a.length-1].title=_()}function wo(){const A=a[a.length-1],z=Tt(A.labelId);_(),Si.call(r,z)||(r[z]=a[a.length-1]),a.pop()}function ko(){p(\"slurpAllLineEndings\",!0)}function xo(A){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(A).length),I(),b(\"<h\"+w(\"headingRank\")+\">\"))}function Co(){x(),p(\"slurpAllLineEndings\")}function Io(){p(\"slurpAllLineEndings\",!0)}function Eo(){b(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function Ao(A){p(\"headingRank\",this.sliceSerialize(A).charCodeAt(0)===61?1:2)}function Po(){const A=_();I(),b(\"<h\"+w(\"headingRank\")+\">\"),k(A),b(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function gt(A){k(y(this.sliceSerialize(A)))}function To(A){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){k(\" \");return}k(y(this.sliceSerialize(A)))}}function No(A){k(y(this.sliceSerialize(A))),p(\"flowCodeSeenData\",!0)}function zr(){b(\"<br />\")}function Do(){I(),Or()}function Rr(){p(\"ignoreEncode\")}function Or(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function $o(){b(\"<em>\")}function Fo(){b(\"<strong>\")}function zo(){p(\"inCodeText\",!0),b(\"<code>\")}function Ro(){p(\"inCodeText\"),b(\"</code>\")}function Oo(){b(\"</em>\")}function Lo(){b(\"</strong>\")}function Mo(){I(),b(\"<hr />\")}function Lr(A){p(\"characterReferenceType\",A.type)}function Vo(A){const z=this.sliceSerialize(A),te=w(\"characterReferenceType\")?Rl(z,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ba(z);k(y(te)),p(\"characterReferenceType\")}function Bo(A){const z=this.sliceSerialize(A);b('<a href=\"'+Qt(z,t.allowDangerousProtocol?void 0:wi)+'\">'),k(y(z)),b(\"</a>\")}function Ho(A){const z=this.sliceSerialize(A);b('<a href=\"'+Qt(\"mailto:\"+z)+'\">'),k(y(z)),b(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return M(u)?(e.enter(n),s(u)):t(u)}function s(u){return M(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const jl={tokenize:Ql};function Ql(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Gl={tokenize:Kl},ki={tokenize:Yl};function Kl(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&b();const E=t.events.length;let I=E,y;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){y=t.events[I][1].end;break}_(r);let P=E;for(;P<t.events.length;)t.events[P][1].end={...y},P++;return pe(t.events,I+1,0,t.events.slice(E)),t.events.length=P,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return d(k);if(i.currentConstruct&&i.currentConstruct.concrete)return p(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ki,f,c)(k)}function f(k){return i&&b(),_(r),d(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(k)}function d(k){return t.containerState={},e.attempt(ki,h,p)(k)}function h(k){return r++,n.push([t.currentConstruct,t.containerState]),d(k)}function p(k){if(k===null){i&&b(),_(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(k)}function w(k){if(k===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(k);return}return R(k)?(e.consume(k),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),w)}function x(k,E){const I=t.sliceStream(k);if(E&&I.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(I),t.parser.lazy[k.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const P=t.events.length;let T=P,F,v;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(F){v=t.events[T][1].end;break}F=!0}for(_(r),y=P;y<t.events.length;)t.events[y][1].end={...v},y++;pe(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(k){let E=n.length;for(;E-- >k;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=k}function b(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Yl(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 pn(e){if(e===null||ae(e)||Hl(e))return 1;if(Bl(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 rr={name:\"attention\",resolveAll:Zl,tokenize:Jl};function Zl(e,t){let n=-1,r,i,a,o,s,u,l,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;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};xi(c,-u),xi(d,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=re(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=re(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=re(l,vn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=re(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=re(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,pe(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Jl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=pn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),f=pn(u),c=!f||f===2&&i||n.includes(u),d=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(f||!c)),t(u)}}function xi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Xl={name:\"autolink\",tokenize:eu};function eu(e,t,n){let r=0;return i;function i(h){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(h){return xe(h)?(e.consume(h),o):h===64?n(h):l(h)}function o(h){return h===43||h===45||h===46||de(h)?(r=1,s(h)):l(h)}function s(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||de(h))&&r++<32?(e.consume(h),s):(r=0,l(h))}function u(h){return h===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h===null||h===32||h===60||tr(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):Ll(h)?(e.consume(h),l):n(h)}function f(h){return de(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(h)}function d(h){if((h===45||de(h))&&r++<63){const p=h===45?d:c;return e.consume(h),p}return n(h)}}const Sn={partial:!0,tokenize:tu};function tu(e,t,n){return r;function r(a){return M(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const qa={continuation:{tokenize:ru},exit:iu,name:\"blockQuote\",tokenize:nu};function nu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return M(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function ru(e,t,n){const r=this;return i;function i(o){return M(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(qa,t,n)(o)}}function iu(e){e.exit(\"blockQuote\")}const Ua={name:\"characterEscape\",tokenize:au};function au(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 Vl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Wa={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\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=de,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Ml,f):(e.enter(\"characterReferenceValue\"),a=7,o=nr,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===de&&!Ba(r.sliceSerialize(d))?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 Ci={partial:!0,tokenize:lu},Ii={concrete:!0,name:\"codeFenced\",tokenize:su};function su(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(y)}function f(y){return y===s?(o++,e.consume(y),f):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),M(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Ci,w,E)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(y))}function d(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):M(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,h,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),d)}function h(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function w(y){return e.attempt(i,E,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&M(y)?H(e,b,\"linePrefix\",a+1)(y):b(y)}function b(y){return y===null||R(y)?e.check(Ci,w,E)(y):(e.enter(\"codeFlowValue\"),k(y))}function k(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),b(y)):(e.consume(y),k)}function E(y){return e.exit(\"codeFenced\"),t(y)}function I(y,P,T){let F=0;return v;function v(L){return y.enter(\"lineEnding\"),y.consume(L),y.exit(\"lineEnding\"),N}function N(L){return y.enter(\"codeFencedFence\"),M(L)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(L):$(L)}function $(L){return L===s?(y.enter(\"codeFencedFenceSequence\"),B(L)):T(L)}function B(L){return L===s?(F++,y.consume(L),B):F>=o?(y.exit(\"codeFencedFenceSequence\"),M(L)?H(y,U,\"whitespace\")(L):U(L)):T(L)}function U(L){return L===null||R(L)?(y.exit(\"codeFencedFence\"),P(L)):T(L)}}}function lu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Tn={name:\"codeIndented\",tokenize:cu},uu={partial:!0,tokenize:fu};function cu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(uu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function fu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):R(o)?i(o):n(o)}}const hu={name:\"codeText\",previous:pu,resolve:du,tokenize:mu};function du(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 pu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function mu(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\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class gu{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 ja(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new gu(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\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,_u(f,n)),n=t[n],l=!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 pe(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function _u(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let f,c,d=-1,h=n,p=0,w=0;const x=[w];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,x.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),d=x.length;d--;){const _=s.slice(x[d],x[d+1]),b=a.pop();u.push([b,b+_.length-1]),e.splice(b,2,_)}for(u.reverse(),d=-1;++d<u.length;)l[p+u[d][0]]=p+u[d][1],p+=u[d][1]-u[d][0]-1;return l}const yu={resolve:vu,tokenize:Su},bu={partial:!0,tokenize:wu};function vu(e){return ja(e),e}function Su(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):R(s)?e.check(bu,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 wu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Qa(e,t,n,r,i,a,o,s,u){const l=u||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),d):_===null||_===32||_===41||tr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(_))}function d(_){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\"}),h(_))}function h(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),d(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:h)}function p(_){return _===60||_===62||_===92?(e.consume(_),h):h(_)}function w(_){return!f&&(_===null||_===41||ae(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<l&&_===40?(e.consume(_),f++,w):_===41?(e.consume(_),f--,w):_===null||_===32||_===40||tr(_)?n(_):(e.consume(_),_===92?x:w)}function x(_){return _===40||_===41||_===92?(e.consume(_),w):w(_)}}function Ga(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(a),f}function f(h){return s>999||h===null||h===91||h===93&&!u||h===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(h))}function c(h){return h===null||h===91||h===93||R(h)||s++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!M(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function Ka(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):n(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===o?(e.exit(a),u(o)):d===null?n(d):R(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===o||d===null||R(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:f)}function c(d){return d===o||d===92?(e.consume(d),f):f(d)}}function xt(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):M(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ku={name:\"definition\",tokenize:Cu},xu={partial:!0,tokenize:Iu};function Cu(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),o(h)}function o(h){return Ga.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function s(h){return i=Tt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter(\"definitionMarker\"),e.consume(h),e.exit(\"definitionMarker\"),u):n(h)}function u(h){return ae(h)?xt(e,l)(h):l(h)}function l(h){return Qa(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(xu,c,c)(h)}function c(h){return M(h)?H(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||R(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function Iu(e,t,n){return r;function r(s){return ae(s)?xt(e,i)(s):n(s)}function i(s){return Ka(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return M(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const Eu={name:\"hardBreakEscape\",tokenize:Au};function Au(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Pu={name:\"headingAtx\",resolve:Tu,tokenize:Nu};function Tu(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\"},pe(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Nu(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||ae(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||R(f)?(e.exit(\"atxHeading\"),t(f)):M(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),s(f))}function l(f){return f===null||f===35||ae(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),l)}}const Du=[\"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\"],Ei=[\"pre\",\"script\",\"style\",\"textarea\"],$u={concrete:!0,name:\"htmlFlow\",resolveTo:Ru,tokenize:Ou},Fu={partial:!0,tokenize:Mu},zu={partial:!0,tokenize:Lu};function Ru(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 Ou(e,t,n){const r=this;let i,a,o,s,u;return l;function l(m){return f(m)}function f(m){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(m),c}function c(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),a=!0,w):m===63?(e.consume(m),i=3,r.interrupt?t:g):xe(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function d(m){return m===45?(e.consume(m),i=2,h):m===91?(e.consume(m),i=5,s=0,p):xe(m)?(e.consume(m),i=4,r.interrupt?t:g):n(m)}function h(m){return m===45?(e.consume(m),r.interrupt?t:g):n(m)}function p(m){const q=\"CDATA[\";return m===q.charCodeAt(s++)?(e.consume(m),s===q.length?r.interrupt?t:$:p):n(m)}function w(m){return xe(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function x(m){if(m===null||m===47||m===62||ae(m)){const q=m===47,oe=o.toLowerCase();return!q&&!a&&Ei.includes(oe)?(i=1,r.interrupt?t(m):$(m)):Du.includes(o.toLowerCase())?(i=6,q?(e.consume(m),_):r.interrupt?t(m):$(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(m):a?b(m):k(m))}return m===45||de(m)?(e.consume(m),o+=String.fromCharCode(m),x):n(m)}function _(m){return m===62?(e.consume(m),r.interrupt?t:$):n(m)}function b(m){return M(m)?(e.consume(m),b):v(m)}function k(m){return m===47?(e.consume(m),v):m===58||m===95||xe(m)?(e.consume(m),E):M(m)?(e.consume(m),k):v(m)}function E(m){return m===45||m===46||m===58||m===95||de(m)?(e.consume(m),E):I(m)}function I(m){return m===61?(e.consume(m),y):M(m)?(e.consume(m),I):k(m)}function y(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),u=m,P):M(m)?(e.consume(m),y):T(m)}function P(m){return m===u?(e.consume(m),u=null,F):m===null||R(m)?n(m):(e.consume(m),P)}function T(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||ae(m)?I(m):(e.consume(m),T)}function F(m){return m===47||m===62||M(m)?k(m):n(m)}function v(m){return m===62?(e.consume(m),N):n(m)}function N(m){return m===null||R(m)?$(m):M(m)?(e.consume(m),N):n(m)}function $(m){return m===45&&i===2?(e.consume(m),Z):m===60&&i===1?(e.consume(m),K):m===62&&i===4?(e.consume(m),D):m===63&&i===3?(e.consume(m),g):m===93&&i===5?(e.consume(m),ve):R(m)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Fu,W,B)(m)):m===null||R(m)?(e.exit(\"htmlFlowData\"),B(m)):(e.consume(m),$)}function B(m){return e.check(zu,U,W)(m)}function U(m){return e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),L}function L(m){return m===null||R(m)?B(m):(e.enter(\"htmlFlowData\"),$(m))}function Z(m){return m===45?(e.consume(m),g):$(m)}function K(m){return m===47?(e.consume(m),o=\"\",ue):$(m)}function ue(m){if(m===62){const q=o.toLowerCase();return Ei.includes(q)?(e.consume(m),D):$(m)}return xe(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),ue):$(m)}function ve(m){return m===93?(e.consume(m),g):$(m)}function g(m){return m===62?(e.consume(m),D):m===45&&i===2?(e.consume(m),g):$(m)}function D(m){return m===null||R(m)?(e.exit(\"htmlFlowData\"),W(m)):(e.consume(m),D)}function W(m){return e.exit(\"htmlFlow\"),t(m)}}function Lu(e,t,n){const r=this;return i;function i(o){return R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Mu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Sn,t,n)}}const Vu={name:\"htmlText\",tokenize:Bu};function Bu(e,t,n){const r=this;let i,a,o;return s;function s(g){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(g),u}function u(g){return g===33?(e.consume(g),l):g===47?(e.consume(g),I):g===63?(e.consume(g),k):xe(g)?(e.consume(g),T):n(g)}function l(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),a=0,p):xe(g)?(e.consume(g),b):n(g)}function f(g){return g===45?(e.consume(g),h):n(g)}function c(g){return g===null?n(g):g===45?(e.consume(g),d):R(g)?(o=c,K(g)):(e.consume(g),c)}function d(g){return g===45?(e.consume(g),h):c(g)}function h(g){return g===62?Z(g):g===45?d(g):c(g)}function p(g){const D=\"CDATA[\";return g===D.charCodeAt(a++)?(e.consume(g),a===D.length?w:p):n(g)}function w(g){return g===null?n(g):g===93?(e.consume(g),x):R(g)?(o=w,K(g)):(e.consume(g),w)}function x(g){return g===93?(e.consume(g),_):w(g)}function _(g){return g===62?Z(g):g===93?(e.consume(g),_):w(g)}function b(g){return g===null||g===62?Z(g):R(g)?(o=b,K(g)):(e.consume(g),b)}function k(g){return g===null?n(g):g===63?(e.consume(g),E):R(g)?(o=k,K(g)):(e.consume(g),k)}function E(g){return g===62?Z(g):k(g)}function I(g){return xe(g)?(e.consume(g),y):n(g)}function y(g){return g===45||de(g)?(e.consume(g),y):P(g)}function P(g){return R(g)?(o=P,K(g)):M(g)?(e.consume(g),P):Z(g)}function T(g){return g===45||de(g)?(e.consume(g),T):g===47||g===62||ae(g)?F(g):n(g)}function F(g){return g===47?(e.consume(g),Z):g===58||g===95||xe(g)?(e.consume(g),v):R(g)?(o=F,K(g)):M(g)?(e.consume(g),F):Z(g)}function v(g){return g===45||g===46||g===58||g===95||de(g)?(e.consume(g),v):N(g)}function N(g){return g===61?(e.consume(g),$):R(g)?(o=N,K(g)):M(g)?(e.consume(g),N):F(g)}function $(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),i=g,B):R(g)?(o=$,K(g)):M(g)?(e.consume(g),$):(e.consume(g),U)}function B(g){return g===i?(e.consume(g),i=void 0,L):g===null?n(g):R(g)?(o=B,K(g)):(e.consume(g),B)}function U(g){return g===null||g===34||g===39||g===60||g===61||g===96?n(g):g===47||g===62||ae(g)?F(g):(e.consume(g),U)}function L(g){return g===47||g===62||ae(g)?F(g):n(g)}function Z(g){return g===62?(e.consume(g),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(g)}function K(g){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),ue}function ue(g){return M(g)?H(e,ve,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(g):ve(g)}function ve(g){return e.enter(\"htmlTextData\"),o(g)}}const Ir={name:\"labelEnd\",resolveAll:Wu,resolveTo:ju,tokenize:Qu},Hu={tokenize:Gu},qu={tokenize:Ku},Uu={tokenize:Yu};function Wu(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&&pe(e,0,e.length,n),e}function ju(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=re(s,e.slice(a+1,a+r+3)),s=re(s,[[\"enter\",f,t]]),s=re(s,vn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=re(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=re(s,e.slice(o+1)),s=re(s,[[\"exit\",u,t]]),pe(e,a,e.length,s),e}function Qu(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(d){return a?a._inactive?c(d):(o=r.parser.defined.includes(Tt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Hu,f,o?f:c)(d):d===91?e.attempt(qu,f,o?l:c)(d):o?f(d):c(d)}function l(d){return e.attempt(Uu,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Gu(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 ae(c)?xt(e,a)(c):a(c)}function a(c){return c===41?f(c):Qa(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ae(c)?xt(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Ka(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ae(c)?xt(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 Ku(e,t,n){const r=this;return i;function i(s){return Ga.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Tt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Yu(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 Zu={name:\"labelStartImage\",resolveAll:Ir.resolveAll,tokenize:Ju};function Ju(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 Xu={name:\"labelStartLink\",resolveAll:Ir.resolveAll,tokenize:ec};function ec(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Nn={name:\"lineEnding\",tokenize:tc};function tc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const en={name:\"thematicBreak\",tokenize:nc};function nc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),M(l)?H(e,s,\"whitespace\")(l):s(l))}}const le={continuation:{tokenize:oc},exit:lc,name:\"list\",tokenize:ac},rc={partial:!0,tokenize:uc},ic={partial:!0,tokenize:sc};function ac(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(h){const p=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:nr(h)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(en,n,l)(h):l(h);if(!r.interrupt||h===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(h)}return n(h)}function u(h){return nr(h)&&++o<10?(e.consume(h),u):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit(\"listItemValue\"),l(h)):n(h)}function l(h){return e.enter(\"listItemMarker\"),e.consume(h),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||h,e.check(Sn,r.interrupt?n:f,e.attempt(rc,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return M(h)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(h),e.exit(\"listItemPrefixWhitespace\"),d):n(h)}function d(h){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(h)}}function oc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sn,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||!M(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(ic,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(le,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function sc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function lc(e){e.exit(this.containerState.type)}function uc(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!M(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Ai={name:\"setextUnderline\",resolveTo:cc,tokenize:fc};function cc(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 fc(e,t,n){const r=this;let i;return a;function a(l){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=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),M(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const hc={tokenize:dc};function dc(e){const t=this,n=e.attempt(Sn,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 pc={resolveAll:Za()},mc=Ya(\"string\"),gc=Ya(\"text\");function Ya(e){return{resolveAll:Za(e===\"text\"?_c: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 l(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),u}function u(f){return l(f)?(n.exit(\"data\"),a(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const c=i[f];let d=-1;if(c)for(;++d<c.length;){const h=c[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Za(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 _c(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const yc={42:le,43:le,45:le,48:le,49:le,50:le,51:le,52:le,53:le,54:le,55:le,56:le,57:le,62:qa},bc={91:ku},vc={[-2]:Tn,[-1]:Tn,32:Tn},Sc={35:Pu,42:en,45:[Ai,en],60:$u,61:Ai,95:en,96:Ii,126:Ii},wc={38:Wa,92:Ua},kc={[-5]:Nn,[-4]:Nn,[-3]:Nn,33:Zu,38:Wa,42:rr,60:[Xl,Vu],91:Xu,92:[Eu,Ua],93:Ir,95:rr,96:hu},xc={null:[rr,pc]},Cc={null:[42,95]},Ic={null:[]},Ec=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Cc,contentInitial:bc,disable:Ic,document:yc,flow:Sc,flowInitial:vc,insideSpan:xc,string:wc,text:kc},Symbol.toStringTag,{value:\"Module\"}));function Ac(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(I),check:P(y),consume:b,enter:k,exit:E,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=re(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=vn(a,l.events,l),l.events)}function d(N,$){return Tc(h(N),$)}function h(N){return Pc(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:L}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:L}}function w(N){i[N.line]=N.column,v()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){f=f(N)}function b(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,v()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function k(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function E(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function I(N,$){T(N,$.from)}function y(N,$){$.restore()}function P(N,$){return B;function B(U,L,Z){let K,ue,ve,g;return Array.isArray(U)?W(U):\"tokenize\"in U?W([U]):D(U);function D(X){return mt;function mt(Re){const rt=Re!==null&&X[Re],it=Re!==null&&X.null,Cn=[...Array.isArray(rt)?rt:rt?[rt]:[],...Array.isArray(it)?it:it?[it]:[]];return W(Cn)(Re)}}function W(X){return K=X,ue=0,X.length===0?Z:m(X[ue])}function m(X){return mt;function mt(Re){return g=F(),ve=X,X.partial||(l.currentConstruct=X),X.name&&l.parser.constructs.disable.null.includes(X.name)?oe():X.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,oe)(Re)}}function q(X){return N(ve,g),L}function oe(X){return g.restore(),++ue<K.length?m(K[ue]):Z}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&pe(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function F(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,L=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=L,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Pc(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 Tc(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 Nc(e){const r={constructs:Nl([Ec,...(e||{}).extensions||[]]),content:i(jl),defined:[],document:i(Gl),flow:i(hc),lazy:{},string:i(mc),text:i(gc)};return r;function i(a){return o;function o(s){return Ac(r,a,s)}}}function Dc(e){for(;!ja(e););return e}const Pi=/[\\0\\t\\n\\r]/g;function $c(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,f,c,d,h;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(Pi.lastIndex=c,l=Pi.exec(a),d=l&&l.index!==void 0?l.index:a.length,h=a.charCodeAt(d),!l){t=a.slice(c);break}if(h===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Fc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Wl(n)(Dc(Nc(n).document().write($c()(e,t,!0))))}const Dn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function zc(){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=Dn[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=Dn[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,Rc)),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\"+Dn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Rc(e,t){return t===\"|\"?t:e}class Oc{constructor(){this.map=[]}add(t,n,r){Lc(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 Lc(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 Mc(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 Vc(){return{flow:{null:{name:\"table\",tokenize:Bc,resolveAll:Hc}}}}function Bc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(v):B(v)}function u(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(v)}function l(v){return v===124||(o=!0,a+=1),f(v)}function f(v){return v===null?n(v):R(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),h):n(v):M(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||ae(v)?(e.exit(\"data\"),f(v)):(e.consume(v),v===92?d:c)}function d(v){return v===92||v===124?(e.consume(v),c):c(v)}function h(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,M(v)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):p(v))}function p(v){return v===45||v===58?x(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),w):I(v)}function w(v){return M(v)?H(e,x,\"whitespace\")(v):x(v)}function x(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),_):v===45?(a+=1,_(v)):v===null||R(v)?E(v):I(v)}function _(v){return v===45?(e.enter(\"tableDelimiterFiller\"),b(v)):I(v)}function b(v){return v===45?(e.consume(v),b):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(v))}function k(v){return M(v)?H(e,E,\"whitespace\")(v):E(v)}function E(v){return v===124?p(v):v===null||R(v)?!o||i!==a?I(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):I(v)}function I(v){return n(v)}function y(v){return e.enter(\"tableRow\"),P(v)}function P(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),P):v===null||R(v)?(e.exit(\"tableRow\"),t(v)):M(v)?H(e,P,\"whitespace\")(v):(e.enter(\"data\"),T(v))}function T(v){return v===null||v===124||ae(v)?(e.exit(\"data\"),P(v)):(e.consume(v),v===92?F:T)}function F(v){return v===92||v===124?(e.consume(v),T):T(v)}}function Hc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,f,c;const d=new Oc;for(;++n<e.length;){const h=e[n],p=h[1];h[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Ti(d,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[[\"enter\",f,t]])),i=p.type===\"tableDelimiterRow\"?2:f?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Gt(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Gt(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Gt(d,t,a,i,n,c)):o[1]!==0&&(c=Gt(d,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ti(d,t,u,l,f),d.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]===\"enter\"&&h[1].type===\"table\"&&(h[1]._align=Mc(t.events,n))}return e}function Gt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},at(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=at(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=at(t.events,n[2]),f=at(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},at(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ti(e,t,n,r,i){const a=[],o=at(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 at(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function qc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Uc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},d=[[\"enter\",f,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],h=s.parser.constructs.insideSpan.null;h&&pe(d,d.length,0,vn(h,o.slice(l+1,u),s)),pe(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),pe(o,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,f=this.events;let c=0;return d;function d(p){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),h(p))}function h(p){const w=pn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,h);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=pn(p);return x._open=!_||_===2&&!!w,x._close=!w||w===2&&!!_,s(p)}}}function Wc(e){return Fc(e,{allowDangerousHtml:!0,extensions:[Vc(),Uc()],htmlExtensions:[zc(),qc()]})}const jc={update:()=>{},getValues:()=>({})},Be=Ft({}),Bt=Ft(jc);function Qc(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)=>Ja(a,o,t));return S(G,{children:i})}function Ja(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>Ja(u,l,n));return Y(i,o,...s)}return null}function Gc({node:e}){const t=kr(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return Y(e.tag,n,e.children.length>0?Pe(e.children):void 0)}function Kc(e,t){if(Tl(e.name))return null;const n=Il(e.name);if(n)return S(Cl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Al(e.name);return r?S(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):S(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function ir(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return S(hl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Kc(e,t);case\"html\":return S(Gc,{node:e},t);default:return e}}function Xa(e){return e.length===0?null:e.map((t,n)=>ir(t,n))}function Yc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Zc(e){const t=C.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let a=1;a<n.length;a++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[a]]}return i==null?\"\":String(i)}function Pe(e,t){if(e.length===0)return null;if(!e.some(o=>o.type===\"text\"))return e.map((o,s)=>ir(o,s));const r=[];let i=\"\";for(let o=0;o<e.length;o++){const s=e[o];if(s.type===\"text\")i+=s.value.replace(/^[ \\t]{4,}/gm,\" \");else if(s.type===\"variable\"&&Yc(i))i+=Zc(s);else{const u=r.length;r.push(ir(s,o)),i+=`<span data-tw=\"${u}\"></span>`}}const a=Wc(i);return Qc(a,r,t?.nobr)}const Jc=\"spindle\",Xc=1;let Kt=null,$n=null;function He(){return $n||($n={saves:new Map,playthroughs:new Map,meta:new Map}),$n}function ef(){return Kt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Kt=new Promise((e,t)=>{const n=indexedDB.open(Jc,Xc);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),Kt))}function qe(e,t){return ef().then(n=>n.transaction(e,t).objectStore(e))}function Ue(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function wn(e){try{const t=await qe(\"saves\",\"readwrite\");await Ue(t.put(e))}catch{He().saves.set(e.meta.id,e)}}async function kn(e){try{const t=await qe(\"saves\",\"readonly\");return await Ue(t.get(e))??void 0}catch{return He().saves.get(e)}}async function tf(e){try{const t=await qe(\"saves\",\"readwrite\");await Ue(t.delete(e))}catch{He().saves.delete(e)}}async function nf(e){try{const n=(await qe(\"saves\",\"readonly\")).index(\"ifid\");return await Ue(n.getAll(e))??[]}catch{return[...He().saves.values()].filter(t=>t.meta.ifid===e)}}async function eo(e){try{const t=await qe(\"playthroughs\",\"readwrite\");await Ue(t.put(e))}catch{He().playthroughs.set(e.id,e)}}async function Er(e){try{const n=(await qe(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Ue(n.getAll(e))??[]}catch{return[...He().playthroughs.values()].filter(t=>t.ifid===e)}}async function Ar(e){try{const t=await qe(\"meta\",\"readonly\"),n=await Ue(t.get(e));return n?n.value:void 0}catch{return He().meta.get(e)}}async function to(e,t){try{const n=await qe(\"meta\",\"readwrite\");await Ue(n.put({key:e,value:t}))}catch{He().meta.set(e,t)}}const no=new Map,xn=new Map;function rf(e,t){no.set(e,t),xn.set(t,e)}function af(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ne(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(xn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(af(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const ar=\"__spindle_class__\",or=\"__spindle_data__\";function Ke(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),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=xn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[ar]:o,[or]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Ye(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(ar in r&&or in r){const o=r[ar],s=r[or],u=no.get(o);if(!u){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 l=Object.create(u.prototype);for(const f of Object.keys(s))l[f]=t(s[f]);return l}const i=r.constructor;if(xn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let sr=null,lr=null,Ni=!1;function of(e){sr=e}function sf(e){lr=e}function lf(e){if(lr)try{const i=new Function(\"passage\",\"variables\",lr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(sr)try{const r=sr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function uf(){Ni||(Ni=!0)}async function Di(e){const n=(await Er(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await eo(i),await to(`currentPlaythroughId.${e}`,r),r}async function cf(e){return Ar(`currentPlaythroughId.${e}`)}async function ro(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:lf(n),passage:n.passage,custom:r},o=ne(n);o.variables=Ke(o.variables),o.history=o.history.map(u=>({...u,variables:Ke(u.variables)}));const s={meta:a,payload:o};return await wn(s),s}async function io(e,t){const n=await kn(e);if(!n)return;const r=ne(t);r.variables=Ke(r.variables),r.history=r.history.map(a=>({...a,variables:Ke(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await wn(i),i}async function ff(e){const t=await kn(e);if(!t)return;const n=t.payload;return n.variables=Ye(n.variables),n.history=n.history.map(r=>({...r,variables:Ye(r.variables)})),n}async function hf(e){await tf(e)}async function df(e,t){const n=await kn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await wn(r)}async function pf(e){const[t,n]=await Promise.all([nf(e),Er(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const ao=\"autosave.\";async function mf(e,t,n){const r=`${ao}${e}`,i=await Ar(r);if(i){const o=await io(i,n);if(o)return o}const a=await ro(e,t,n,{isAutosave:!0});return await to(r,a.meta.id),a}async function gf(e){const t=`${ao}${e}`,n=await Ar(t);if(n)return ff(n)}const Pr=\"spindle.session.\";function _f(e,t){try{sessionStorage.setItem(`${Pr}${e}`,JSON.stringify(t))}catch{}}function yf(e){try{const t=sessionStorage.getItem(`${Pr}${e}`);if(!t)return;const n=JSON.parse(t);return n.variables=Ye(n.variables),n.history=n.history.map(r=>({...r,variables:Ye(r.variables)})),n}catch{return}}function bf(e){try{sessionStorage.removeItem(`${Pr}${e}`)}catch{}}async function vf(e){const t=await kn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Sf(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=ne(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Er(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await eo(a)}return await wn(n),n}function oo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=ht(t.content),i=dt(r),a=document.createElement(\"div\");ye(Y(()=>Pe(i),null),a),ye(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&sf(n.content)}let so=0,_e=[],Fn=!1,Ht=[],tn=null;function Tr(e){const t=C.getState();try{return!!bn(e,t.variables,t.temporary)}catch{return!1}}function lo(e,t){const n=so++,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:Tr(e),priority:i?.priority??0};return _e.push(o),_e.sort((s,u)=>u.priority-s.priority),()=>{_e=_e.filter(s=>s.id!==n)}}function uo(e){_e=_e.filter(t=>t.name!==e)}function wf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Ra(n.run,r.variables,r.temporary)}n.dialog&&(Ht.push(n.dialog),tn?.()),n.goto&&C.getState().navigate(n.goto)}}const kf=10;function xf(){if(!Fn){Fn=!0;try{for(let e=0;e<kf;e++){let t=!1;const n=[..._e];for(const r of n){if(!_e.includes(r))continue;const i=Tr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(_e=_e.filter(o=>o.id!==r.id)),wf(r))}if(!t)break}}finally{Fn=!1}}}function Cf(){for(const e of _e)e.lastResult=Tr(e.condition)}function If(){_e=[],Ht=[],so=0}function Ef(e){return tn=e,Ht.length>0&&e(),()=>{tn===e&&(tn=null)}}function $i(){return Ht.shift()}function Af(){return Ht.length}Js();const Pf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ge={},me=[],Oe={};function Fi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function zi(e,t){const[,n,r]=el(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:Fi(n),inverse:Fi(r)}}function Tf(e){let t=Ge;for(let n=0;n<e;n++)t=ot(t,me[n].forward);return t}let ge=[];function zn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(ge.length>i.length&&(ge.length=i.length),ge.length<i.length)if(i.length-ge.length===1){const l=i.length-1;ge[l]={passage:i[l].passage,variables:Ke(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ge;for(let f=0;f<i.length;f++)if(f>0&&(l=ot(l,me[f-1].forward)),f>=ge.length){const c=f===i.length-1?r:l;ge[f]={passage:i[f].passage,variables:Ke(c),timestamp:i[f].timestamp,prng:i[f].prng}}}_f(t.ifid,{passage:n,variables:Ke(r),history:ge,historyIndex:a,visitCounts:o,renderCounts:s,prng:dn()})}}function Ri(e){Ge=e,me=[],Oe=e,ge=[]}function Oi(e){e?.prng?Da(e.prng.seed,e.prng.pull):e&&Xn()}const C=zs()(nl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,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=ne(r);Ri(ne(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}}),Oe=t().variables;const o=n.ifid;uf().then(async()=>{const s=await cf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await Di(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Pf.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=zi(Oe,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),me.length=o.historyIndex,me.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:dn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ge=ot(Ge,me[u].forward);o.history=o.history.slice(s),me=me.slice(s),ge=ge.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Oe=t().variables,zn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(ot(r,me[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Oe=t().variables,Oi(t().history[t().historyIndex]),zn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(ot(i,me[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Oe=t().variables,Oi(t().history[t().historyIndex]),zn(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Xn(),If();const a=ne(r);Ri(ne(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Oe=t().variables,oo(),bf(n.ifid),Di(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),mf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),gf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Ge;for(let f=0;f<i.length;f++)f>0&&(l=ot(l,me[f-1].forward)),u.push({passage:i[f].passage,variables:ne(l),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:ne(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:dn()}},loadFromPayload:n=>{const r=Ye(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Ye(n.history[o].variables);i.push(zi(a,s)),a=s}Ge=ne(r),me=i,ge=[],e(o=>{o.currentPassage=n.passage,o.variables=Ye(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=n.historyIndex,o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Oe=t().variables,n.prng?Da(n.prng.seed,n.prng.pull):Xn()},getHistoryVariables:n=>ne(Tf(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}}))),Nf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Df(){const t=C(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Nf;try{const r=ht(n),i=dt(r);return S(G,{children:Xa(i)})}catch(r){return S(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}const co=Ft(null);function Nr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=C(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=fe(()=>{if(!o)return S(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=ht(o),c=dt(f);return Pe(c)}catch(f){return S(\"div\",{class:\"error\",children:[\"Error in dialog: \",f.message]})}},[o]),u=f=>{f.target.classList.contains(\"dialog-overlay\")&&r()},l=n?`dialog-panel ${n}`:\"dialog-panel\";return S(co.Provider,{value:r,children:S(\"div\",{class:\"dialog-overlay\",onClick:u,children:S(\"div\",{class:l,children:[S(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),S(\"div\",{class:\"dialog-body\",children:s})]})})})}function $f(){const[e,t]=J(null),n=be(()=>{const i=$i();t(i??null)},[]);Ee(()=>Ef(()=>{t(i=>i!==null?i:$i()??null)}),[]);const r=be(()=>{t(null),Af()>0&&requestAnimationFrame(n)},[n]);return e?S(Nr,{passageName:e,onClose:r}):null}function Ff(){const e=C(n=>n.storyData),t=C(n=>n.currentPassage);return Ee(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),C.getState().save()):r.key===\"F9\"&&(r.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?S(\"div\",{class:\"loading\",children:\"Loading...\"}):S(G,{children:[S(Df,{}),S($f,{})]})}function zf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const h=parseInt(d.getAttribute(\"pid\")||\"0\",10),p=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),x=d.textContent||\"\",_={},b=new Set([\"pid\",\"name\",\"tags\"]);for(const E of d.attributes)b.has(E.name)||(_[E.name]=E.value);const k={pid:h,name:p,tags:w,metadata:_,content:x};f.set(p,k),c.set(h,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:l}}const yt=new Map;let se={},Li=!1;function fo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Rf(){localStorage.setItem(fo(),JSON.stringify(se))}function Rn(){if(!Li){Li=!0;try{const e=localStorage.getItem(fo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(se={...se,...t})}}catch{}}}const Nt={addToggle(e,t){yt.set(e,{type:\"toggle\",config:t}),e in se||(se[e]=t.default),Rn()},addList(e,t){yt.set(e,{type:\"list\",config:t}),e in se||(se[e]=t.default),Rn()},addRange(e,t){yt.set(e,{type:\"range\",config:t}),e in se||(se[e]=t.default),Rn()},get(e){return se[e]},getToggle(e){const t=se[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=se[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=se[e];return typeof t==\"number\"?t:0},set(e,t){se[e]=t,Rf()},getAll(){return{...se}},getDefinitions(){return yt},hasAny(){return yt.size>0}};function Of(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Ra(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])}const mn=new Map,ur=new Set,cr=new Map;function Lf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(cr.get(r)??0)+1;return cr.set(r,i),i===1?r:`${r}:${i}`}function Mf(e){return mn.set(e.id,e),Vi(),()=>{mn.delete(e.id),Vi()}}function Mi(){return Array.from(mn.values())}function Vf(e){return mn.get(e)}function Bf(){cr.clear()}function Hf(e){return ur.add(e),()=>{ur.delete(e)}}function Vi(){for(const e of ur)e()}function qf(e){const t=ce(\"\");t.current||(t.current=Lf(e.type,e.key,e.authorId));const n=t.current;return tt(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),Mf(r)}),n}function Uf(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 Dr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?ho(t):\"\"}function Wf(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 jf(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 Qf(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Gf={useState:J,useRef:ce,useEffect:Ee,useLayoutEffect:tt,useCallback:be,useMemo:fe,useContext:ze};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=kr(),r=a(r),i=a(i));const{update:o,getValues:s}=ze(Bt),u={collectText:Uf,sourceLocation:Dr,parseVarArgs:Wf,extractOptions:jf,h:Y,renderNodes:Pe,renderInlineNodes:Xa,hooks:Gf,useAction:qf,className:r,id:i,resolve:a,cls:Qf(e.name,r),mutate:l=>Of(l,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){u.merged=wr();const l=u.merged;u.evaluate=f=>bn(f,l[0],l[1],l[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");u.varName=f,u.value=C(d=>d.variables[f]);const c=C(d=>d.setVariable);u.setValue=d=>c(f,d)}return u.wrap=l=>u.className||u.id?Y(\"span\",{id:u.id,class:u.className},l):Y(G,null,l),e.render(n,u)}if(El(e.name,t),e.subMacros)for(const n of e.subMacros)Pl(n)}function Kf(){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){C.getState().save(e)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(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:Nt,registerClass(e,t){rf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){of(e)}},getActions(){return Mi()},performAction(e,t){const n=Vf(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return Hf(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(Mi())})})})},watch(e,t){return lo(e,t)},unwatch(e){uo(e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},random(){return xr()},randomInt(e,t){return $a(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){dl(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=dn())})},isEnabled(){return pl()},get seed(){return ml()},get pull(){return gl()}}}}function Yf(){window.Story=Kf()}const Zf=/^\\$(\\w+)\\s*=\\s*(.+)$/,Bi=/\\$(\\w+(?:\\.\\w+)*)/g,Hi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Jf=new Set([\"number\",\"string\",\"boolean\"]);function po(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,po(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Jf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Xf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Zf);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=po(s);t.set(a,{...u,name:a,default:s})}return t}function eh(e){const t=new Set;let n;for(Hi.lastIndex=0;(n=Hi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function th(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function nh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=eh(i.content);let o;for(Bi.lastIndex=0;(o=Bi.exec(i.content))!==null;){const s=o[1],u=th(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function rh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Me({macro:e,error:t}){return S(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Dr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return S(Me,{macro:\"print\",error:n})}}});function ih(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 ah(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 qi(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=bn(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${Dr()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];ah(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=ih(e))}catch(f){return S(Me,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const f=C.getState();qi(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{qi(o,u,s,n,r,i,e)},[n,r,i]),null}});function oh(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=sh(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 sh(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 lh(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=oh(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=lh(a,o,i),l=t.cls;return S(\"div\",{class:l,id:t.id,children:[S(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&S(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return S(Me,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?S(\"span\",{id:o,class:a,children:i}):S(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 S(Me,{macro:\"if\",error:i})}}return null}});function uh(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 ch({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=J(()=>({...e,...t,...n})),o=ce(i);o.current=i;const s=be(()=>o.current,[]),u=be((f,c)=>{a(d=>({...d,[f]:c}))},[]),l=fe(()=>({update:u,getValues:s}),[u,s]);return S(Bt.Provider,{value:l,children:S(Be.Provider,{value:i,children:Pe(r)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ze(Be);let i;try{i=uh(e)}catch(f){return S(Me,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const f=n.evaluate(s);if(!Array.isArray(f))return S(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=f}catch(f){return S(Me,{macro:\"for\",error:f})}const l=u.map((f,c)=>{const d={[a]:f,...o?{[o]:c}:void 0};return S(ch,{parentValues:r,ownKeys:d,initialValues:{},children:t},c)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=()=>{const a=document.createElement(\"div\"),o=Y(Bt.Provider,{value:{update:n.update,getValues:n.getValues}},Y(Be.Provider,{value:n.getValues()},Pe(t)));ye(o,a),ye(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:i}),S(\"button\",{id:n.id,class:n.cls,onClick:i,children:r})}});function fh(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 Ui(e,t,n){const r=document.createElement(\"div\"),i=Y(Bt.Provider,{value:{update:n,getValues:t}},Y(Be.Provider,{value:t()},Pe(e)));ye(i,r),ye(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=fh(e),a=o=>{o.preventDefault(),Ui(t,n.getValues,n.update),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Ui(t,n.getValues,n.update),i&&C.getState().navigate(i)}}),S(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return S(Me,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return S(G,{children:n.renderNodes(o.children)})}catch(s){return S(Me,{macro:\"case\",error:s})}}return i?S(G,{children:n.renderNodes(i.children)}):null}});function $r(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(h=>({delay:h.rawArgs?$r(h.rawArgs):0,nodes:h.children,className:h.className,id:h.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const h=o+1,p=a[h].delay,w=setTimeout(()=>{s(h)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),f=t.resolve(u.className),c=t.resolve(u.id),d=f||c?S(\"span\",{id:c,class:f,children:l}):l;return t.wrap(d)}});const mo=Ft({stop:()=>{}});V({name:\"repeat\",render({rawArgs:e,children:t=[],className:n,id:r},i){const{useState:a,useEffect:o,useCallback:s,useMemo:u}=i.hooks,[l,f]=u(()=>{const k=E=>{if(!E||!Aa(E))return E;const I=C.getState();return Pa(E,I.variables,I.temporary,{})};return[k(n),k(r)]},[n,r]),c=$r(e),[d,h]=a(0),[p,w]=a(!1),x=s(()=>w(!0),[]);if(o(()=>{if(p)return;const k=setInterval(()=>{h(E=>E+1)},c);return()=>clearInterval(k)},[c,p]),d===0&&!p)return null;const _=l?`macro-repeat ${l}`:void 0,b=S(mo.Provider,{value:{stop:x},children:S(\"span\",{children:i.renderNodes(t)},d)});return _||f?S(\"span\",{id:f,class:_,children:b}):b}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(mo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=$r(e),s=a(null),[u,l]=r(0),[f,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||f>=u)return;const p=setInterval(()=>{c(w=>w>=u?(clearInterval(p),w):w+1)},o);return()=>clearInterval(p)},[u,o]);const d=f>=u&&u>0,h=[\"macro-type\",d?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return S(\"span\",{id:n.id,class:h,ref:s,style:{clipPath:(u>0&&!d,void 0)},children:[S(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!d?`inset(0 ${(u-f)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!d&&u>0&&S(\"span\",{class:\"macro-type-cursor\"})]})}});function hh(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=hh(e);return n.hooks.useLayoutEffect(()=>{La(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return S(\"span\",{id:t.id,class:r,children:n})}});function nt(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=e.dialog?J(!1):[!1,void 0],a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),S(G,{children:[S(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&S(Nr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}nt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});nt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});nt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});nt({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.saveVersion),{perform:()=>e(),disabled:!t()}}});nt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});nt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});nt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Nt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,o=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return S(G,{children:[S(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:a}),r&&S(Nr,{passageName:o,onClose:()=>i(!1)})]})}});function dh(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)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function ph(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 mh(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function gh(){const[e,t]=J(\"load\"),[n,r]=J([]),[i,a]=J(!0),[o,s]=J(null),[u,l]=J(()=>new Set),[f,c]=J(null),[d,h]=J(\"\"),p=ce(null),w=ce(null),x=ze(co),_=C(D=>D.storyData),b=C(D=>D.playthroughId),k=C(D=>D.getSavePayload),E=C(D=>D.loadFromPayload),I=_?.ifid??\"\",y=be(async()=>{if(!I)return;const D=await pf(I);r(D),a(!1)},[I]);Ee(()=>{y()},[y]),Ee(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const P=ce(),T=(D,W=\"success\")=>{clearTimeout(P.current),s({text:D,type:W}),P.current=window.setTimeout(()=>s(null),3e3)},F=D=>{l(W=>{const m=new Set(W);return m.has(D)?m.delete(D):m.add(D),m})},v=async()=>{if(!(!I||!b))try{const D=k();await ro(I,b,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const W=k();await io(D,W),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{E(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await hf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),h(D.meta.title)},L=async()=>{if(!(!f||!d.trim()))try{await df(f,d.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?L():D.key===\"Escape\"&&c(null)},K=async D=>{try{const W=await vf(D);if(!W)return;const m=new Blob([JSON.stringify(W,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(m),oe=document.createElement(\"a\");oe.href=q,oe.download=`save-${W.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,oe.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},ue=()=>{w.current?.click()},ve=async D=>{const W=D.target,m=W.files?.[0];if(m){W.value=\"\";try{const q=await m.text(),oe=JSON.parse(q);if(!dh(oe))throw new Error(\"Invalid save file format\");await Sf(oe,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},g=n.reduce((D,W)=>D+W.saves.length,0);return S(\"div\",{class:\"save-manager\",children:[S(\"div\",{class:\"saves-header\",children:S(\"div\",{class:\"saves-header-left\",children:S(\"div\",{class:\"saves-mode-toggle\",children:[S(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),S(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),S(\"div\",{class:\"saves-toolbar\",children:[S(\"button\",{class:\"saves-toolbar-button\",onClick:ue,children:\"Import\"}),S(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ve})]}),S(\"div\",{class:\"saves-body\",children:[i?S(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):g===0&&e===\"load\"?S(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const W=u.has(D.playthrough.id),m=D.playthrough.id===b;return e===\"save\"&&!m||e===\"load\"&&D.saves.length===0&&!m?null:S(\"div\",{class:\"playthrough-group\",children:[S(\"div\",{class:\"playthrough-header\",onClick:()=>F(D.playthrough.id),children:[S(\"span\",{class:`playthrough-chevron ${W?\"\":\"open\"}`,children:\"▶\"}),S(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,m?\" (current)\":\"\"]}),S(\"span\",{class:\"playthrough-date\",children:mh(D.playthrough.createdAt)})]}),!W&&S(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>S(\"div\",{class:\"save-slot\",children:[S(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?S(\"input\",{ref:p,class:\"save-rename-input\",value:d,onInput:oe=>h(oe.target.value),onKeyDown:Z,onBlur:L}):S(\"div\",{class:\"save-slot-title\",children:q.meta.title}),S(\"div\",{class:\"save-slot-meta\",children:[S(\"span\",{children:q.meta.passage}),S(\"span\",{children:ph(q.meta.updatedAt)})]})]}),S(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?S(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):S(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),S(\"button\",{class:\"save-slot-action\",onClick:()=>K(q.meta.id),children:\"Export\"}),S(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&m&&S(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===b)&&S(\"div\",{class:\"playthrough-group\",children:S(\"div\",{class:\"playthrough-saves\",children:S(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&S(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return S(gh,{})}});function _h({name:e,def:t}){const[n,r]=J(()=>Nt.get(e)),i=a=>{r(a),Nt.set(e,a)};switch(t.type){case\"toggle\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:t.config.label}),S(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>S(\"option\",{value:a,children:a},a))})]});case\"range\":return S(\"label\",{class:\"settings-row\",children:[S(\"span\",{children:[t.config.label,\": \",String(n)]}),S(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function yh(){const e=Nt.getDefinitions();return S(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>S(_h,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return S(yh,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const f=t.evaluate(i);a=String(f)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return S(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=ht(o.content),u=dt(s),l=r?t.renderInlineNodes(u):t.renderNodes(u);return t.wrap(l)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.renderNodes(e,{nobr:!0}))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),S(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),S(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function bh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}V({name:\"checkbox\",render({rawArgs:e},t){const{varName:n,label:r}=bh(e),i=n.startsWith(\"$\")?n.slice(1):n,a=C(s=>s.variables[i]),o=C(s=>s.setVariable);return t.useAction({type:\"checkbox\",key:`$${i}`,authorId:t.id,label:r||i,variable:i,value:!!a,perform:s=>o(i,s!==void 0?!!s:!a)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>o(i,!a)}),r?` ${r}`:null]})}});function vh(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}V({name:\"radiobutton\",render({rawArgs:e},t){const{varName:n,value:r,label:i}=vh(e),a=n.startsWith(\"$\")?n.slice(1):n,o=C(u=>u.variables[a]),s=C(u=>u.setVariable);return t.useAction({type:\"radiobutton\",key:`$${a}:${r}`,authorId:t.id,label:i||r,variable:a,value:o,perform:()=>s(a,r)}),S(\"label\",{id:t.id,class:t.cls,children:[S(\"input\",{type:\"radio\",name:`radio-${a}`,checked:o===r,onChange:()=>s(a,r)}),i?` ${i}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),S(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>S(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const a=(n.indexOf(String(t.value))+1)%n.length;t.setValue(n[a])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),S(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function vt(e){const t=ht(e.content),n=dt(t),r=e.tags.includes(\"nobr\");return Pe(n,r?{nobr:!0}:void 0)}const Sh=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function wh({passage:e,dataTransition:t}){const n=C(h=>h.storyData),r=Sh.has(e.name),[i,a]=J(!1),o=fe(()=>{try{return vt(e)}catch(h){return S(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",ho(e),\": \",h.message]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),f=fe(()=>{if(!s)return null;try{return vt(s)}catch(h){return console.error(\"spindle: Error in PassageHeader:\",h),null}},[s?.content]),c=fe(()=>{if(!u)return null;try{return vt(u)}catch(h){return console.error(\"spindle: Error in PassageFooter:\",h),null}},[u?.content]);Ee(()=>(l&&a(!0),()=>a(!1)),[e.name]);const d=fe(()=>{if(!i||!l)return null;try{return vt(l)}catch(h){return console.error(\"spindle: Error in PassageDone:\",h),null}},[i,l?.content]);return S(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&S(\"div\",{class:\"passage-header\",children:f}),o,c&&S(\"div\",{class:\"passage-footer\",children:c}),d&&S(\"div\",{hidden:!0,children:d})]})}const kh=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),fr={type:\"fade-through\",duration:300,pause:50};function xh(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!kh.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 On(e){return{type:e.type,duration:e.duration??fr.duration,pause:e.pause??fr.pause}}function Ch(e,t,n){const r=xh(e);return r?On(r):t?On(t):n?On(n):{...fr}}function Wi(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 Ln(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 Mn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(h=>h.currentPassage),r=C(h=>h.storyData),[i,a]=J(n),o=ce(\"fade\"),s=ce(0),u=ce(null),l=ce([]),f=be(()=>{for(const h of l.current)clearTimeout(h);l.current=[],Mn(u.current)},[]);Ee(()=>{const h=C.getState(),{history:p,historyIndex:w,transitionConfig:x}=h,_=h.consumeNextTransition(),b=s.current;s.current=p.length;const k=!i,E=p.length===1&&w===0&&b>1,I=p.length>1&&w===p.length-1&&b>1&&Math.abs(p.length-b)>1;if(n===i)return;f();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(k||E||I){o.current=\"fade\",a(n);return}const P=Ch(y.tags,_,x);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Ln(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Ln(T,P);const F=T.querySelector(\".passage\");if(!F){a(n);return}const v=Wi(F,P.type);T.appendChild(v),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{Mn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Ln(T,P);const F=T.querySelector(\".passage\");if(!F){a(n);return}const v=Wi(F,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(v),a(n);const N=setTimeout(()=>{Mn(T)},P.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return S(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const d=r?.passages.get(\"PassageReady\");return S(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[d&&S(\"div\",{hidden:!0,children:vt(d)},`ready-${n}`),S(\"div\",{class:\"passage-container\",ref:u,children:c&&S(wh,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],d=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=d;break;case\"dialog\":s.dialog=d;break;case\"run\":s.run=d;break;case\"name\":s.name=d;break;case\"priority\":s.priority=d?Number(d):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,lo(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,uo(r)),null}});function ji(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 Qi(){const e=zf();if(Yf(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",d=document.getElementById(\"root\");throw d&&ji(d,[c]),new Error(`spindle: ${c}`)}const r=Xf(n.content),i=nh(e.passages,r);if(i.length>0){const c=document.getElementById(\"root\");throw c&&ji(c,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=rh(r),C.getState().init(e,t),oo();const a=yf(e.ifid);a&&C.getState().loadFromPayload(a);for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const d=ht(c.content),h=dt(d);for(const p of h)if(p.type===\"macro\"&&p.name===\"widget\"&&p.rawArgs){const w=p.rawArgs.trim().split(/\\s+/),x=w[0].replace(/[\"']/g,\"\"),_=w.slice(1).filter(b=>b.startsWith(\"$\")||b.startsWith(\"_\")||b.startsWith(\"@\"));La(x,p.children,_)}}let o=\"\";C.subscribe(c=>{c.currentPassage!==o&&(o=c.currentPassage,Bf())});let s=C.getState().variables,u=C.getState().historyIndex;C.subscribe(c=>{c.variables!==s&&(c.historyIndex===u?xf():Cf()),s=c.variables,u=c.historyIndex});const l=e.passages.get(\"StoryInterface\");l&&!l.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const f=document.getElementById(\"root\");if(!f)throw new Error('spindle: No <div id=\"root\"> element found.');ye(S(Ff,{}),f),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Qi):Qi();</script>\n <style rel=\"stylesheet\" crossorigin>*,*: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}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
package/package.json
CHANGED
|
@@ -9,7 +9,8 @@ import { sourceLocationOf } from '../utils/source-location';
|
|
|
9
9
|
export function renderPassageContent(passage: PassageData) {
|
|
10
10
|
const tokens = tokenize(passage.content);
|
|
11
11
|
const ast = buildAST(tokens);
|
|
12
|
-
|
|
12
|
+
const nobr = passage.tags.includes('nobr');
|
|
13
|
+
return renderNodes(ast, nobr ? { nobr: true } : undefined);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
interface PassageProps {
|
|
@@ -20,6 +20,7 @@ import '../components/macros/Dialog';
|
|
|
20
20
|
import '../components/macros/SaveManager';
|
|
21
21
|
import '../components/macros/SettingsControls';
|
|
22
22
|
import '../components/macros/Include';
|
|
23
|
+
import '../components/macros/Nobr';
|
|
23
24
|
import '../components/macros/Goto';
|
|
24
25
|
import '../components/macros/Unset';
|
|
25
26
|
import '../components/macros/Textbox';
|
package/src/markup/ast.ts
CHANGED
package/src/markup/render.tsx
CHANGED
|
@@ -29,9 +29,15 @@ export const LocalsUpdateContext = createContext<LocalsUpdater>(defaultUpdater);
|
|
|
29
29
|
function htmlToPreact(
|
|
30
30
|
html: string,
|
|
31
31
|
components: preact.ComponentChildren[],
|
|
32
|
+
nobr = false,
|
|
32
33
|
): preact.ComponentChildren {
|
|
33
34
|
const temp = document.createElement('div');
|
|
34
35
|
temp.innerHTML = html.trim();
|
|
36
|
+
if (nobr) {
|
|
37
|
+
for (const p of Array.from(temp.querySelectorAll(':scope > p'))) {
|
|
38
|
+
p.replaceWith(...Array.from(p.childNodes));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
35
41
|
const children = Array.from(temp.childNodes).map((child, i) =>
|
|
36
42
|
convertDomNode(child, i, components),
|
|
37
43
|
);
|
|
@@ -210,7 +216,10 @@ function getVariableTextValue(node: VariableNode): string {
|
|
|
210
216
|
* After micromark processes the combined string, the HTML is parsed back into
|
|
211
217
|
* Preact VNodes with placeholders replaced by the real rendered components.
|
|
212
218
|
*/
|
|
213
|
-
export function renderNodes(
|
|
219
|
+
export function renderNodes(
|
|
220
|
+
nodes: ASTNode[],
|
|
221
|
+
options?: { nobr?: boolean },
|
|
222
|
+
): preact.ComponentChildren {
|
|
214
223
|
if (nodes.length === 0) return null;
|
|
215
224
|
|
|
216
225
|
// If there's no text at all, render nodes directly without markdown
|
|
@@ -241,5 +250,5 @@ export function renderNodes(nodes: ASTNode[]): preact.ComponentChildren {
|
|
|
241
250
|
const html = markdownToHtml(combined);
|
|
242
251
|
|
|
243
252
|
// Convert HTML to Preact VNodes, replacing placeholders with components
|
|
244
|
-
return htmlToPreact(html, components);
|
|
253
|
+
return htmlToPreact(html, components, options?.nobr);
|
|
245
254
|
}
|