@rohal12/spindle 0.3.0 → 0.3.2

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.
Files changed (2) hide show
  1. package/dist/pkg/format.js +1 -1
  2. package/package.json +10 -10
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.2.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 s of a.addedNodes)s.tagName===\"LINK\"&&s.rel===\"modulepreload\"&&r(s)}).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 st,O,Mr,ze,jn,Br,Vr,Hr,wn,Zt,Jt,jr,xt={},vt=[],va=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ot=Array.isArray;function be(e,t){for(var n in t)e[n]=t[n];return e}function kn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function me(e,t,n){var r,i,a,s={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?st.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return Xe(e,s,r,i,null)}function Xe(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??++Mr,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function wa(){return{current:null}}function G(e){return e.children}function xe(e,t){this.props=e,this.context=t}function Ve(e,t){if(t==null)return e.__?Ve(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\"?Ve(e):null}function ka(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=be({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Sn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ve(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Qr(r,a,i),t.__e=t.__=null,a.__e!=n&&qr(a)}}function qr(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}),qr(e)}function Xt(e){(!e.__d&&(e.__d=!0)&&ze.push(e)&&!wt.__r++||jn!=O.debounceRendering)&&((jn=O.debounceRendering)||Br)(wt)}function wt(){for(var e,t=1;ze.length;)ze.length>t&&ze.sort(Vr),e=ze.shift(),t=ze.length,ka(e);wt.__r=0}function Ur(e,t,n,r,i,a,s,o,u,l,f){var c,p,h,_,w,I,b,v=r&&r.__k||vt,C=t.length;for(u=Sa(n,t,v,u,C),c=0;c<C;c++)(h=n.__k[c])!=null&&(p=h.__i!=-1&&v[h.__i]||xt,h.__i=c,I=Sn(e,h,p,i,a,s,o,u,l,f),_=h.__e,h.ref&&p.ref!=h.ref&&(p.ref&&Cn(p.ref,null,h),f.push(h.ref,h.__c||_,h)),w==null&&_!=null&&(w=_),(b=!!(4&h.__u))||p.__k===h.__k?u=Wr(h,u,e,b):typeof h.type==\"function\"&&I!==void 0?u=I:_&&(u=_.nextSibling),h.__u&=-7);return n.__e=w,u}function Sa(e,t,n,r,i){var a,s,o,u,l,f=n.length,c=f,p=0;for(e.__k=new Array(i),a=0;a<i;a++)(s=t[a])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[a]=Xe(null,s,null,null,null):ot(s)?s=e.__k[a]=Xe(G,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[a]=Xe(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,u=a+p,s.__=e,s.__b=e.__b+1,o=null,(l=s.__i=Ca(s,n,u,c))!=-1&&(c--,(o=n[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(i>f?p--:i<f&&p++),typeof s.type!=\"function\"&&(s.__u|=4)):l!=u&&(l==u-1?p--:l==u+1?p++:(l>u?p--:p++,s.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(o=n[a])!=null&&(2&o.__u)==0&&(o.__e==r&&(r=Ve(o)),Kr(o,o));return r}function Wr(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=Wr(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ve(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ce(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(ot(e)?e.some(function(n){Ce(n,t)}):t.push(e)),t}function Ca(e,t,n,r){var i,a,s,o=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&o==null||f&&o==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[s=i>=0?i--:a++])!=null&&(2&l.__u)==0&&o==l.key&&u==l.type)return s}return-1}function qn(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||va.test(t)?n:n+\"px\"}function ft(e,t,n,r,i){var a,s;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||qn(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||qn(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Hr,\"$1\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=wn,e.addEventListener(t,a?Jt:Zt,a)):e.removeEventListener(t,a?Jt:Zt,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 Un(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=wn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Sn(e,t,n,r,i,a,s,o,u,l){var f,c,p,h,_,w,I,b,v,C,z,E,x,P,M,L=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[o=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof L==\"function\")try{if(b=t.props,v=\"prototype\"in L&&L.prototype.render,C=(f=L.contextType)&&r[f.__c],z=f?C?C.props.value:f.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(v?t.__c=c=new L(b,z):(t.__c=c=new xe(b,z),c.constructor=L,c.render=Aa),C&&C.sub(c),c.state||(c.state={}),c.__n=r,p=c.__d=!0,c.__h=[],c._sb=[]),v&&c.__s==null&&(c.__s=c.state),v&&L.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=be({},c.__s)),be(c.__s,L.getDerivedStateFromProps(b,c.__s))),h=c.props,_=c.state,c.__v=t,p)v&&L.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),v&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(v&&L.getDerivedStateFromProps==null&&b!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,z),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,z)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),vt.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,z),v&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,_,w)})}if(c.context=z,c.props=b,c.__P=e,c.__e=!1,E=O.__r,x=0,v)c.state=c.__s,c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),vt.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++x<25);c.state=c.__s,c.getChildContext!=null&&(r=be(be({},r),c.getChildContext())),v&&!p&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,_)),P=f!=null&&f.type===G&&f.key==null?Gr(f.props.children):f,o=Ur(e,ot(P)?P:[P],t,n,r,i,a,s,o,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(M=a.length;M--;)kn(a[M]);en(t)}else t.__e=n.__e,t.__k=n.__k,y.then||en(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=Ia(n.__e,t,n,r,i,a,s,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:o}function en(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(en))}function Qr(e,t,n){for(var r=0;r<n.length;r++)Cn(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 Gr(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ot(e)?e.map(Gr):be({},e)}function Ia(e,t,n,r,i,a,s,o,u){var l,f,c,p,h,_,w,I=n.props||xt,b=t.props,v=t.type;if(v==\"svg\"?i=\"http://www.w3.org/2000/svg\":v==\"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==!!v&&(v?h.localName==v:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(b);e=document.createElementNS(i,v,b.is&&b),o&&(O.__m&&O.__m(t,a),o=!1),a=null}if(v==null)I===b||o&&e.data==b||(e.data=b);else{if(a=a&&st.call(e.childNodes),!o&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(h=e.attributes[l]).name]=h.value;for(l in I)h=I[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||ft(e,l,null,h,i);for(l in b)h=b[l],l==\"children\"?p=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?_=h:l==\"checked\"?w=h:o&&typeof h!=\"function\"||I[l]===h||ft(e,l,h,I[l],i);if(f)o||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Ur(t.type==\"template\"?e.content:e,ot(p)?p:[p],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,s,a?a[0]:n.__k&&Ve(n,0),o,u),a!=null)for(l=a.length;l--;)kn(a[l]);o||(l=\"value\",v==\"progress\"&&_==null?e.removeAttribute(\"value\"):_!=null&&(_!==e[l]||v==\"progress\"&&!_||v==\"option\"&&_!=I[l])&&ft(e,l,_,I[l],i),l=\"checked\",w!=null&&w!=e[l]&&ft(e,l,w,I[l],i))}return e}function Cn(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 Kr(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Cn(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]&&Kr(r[i],t,n||typeof e.type!=\"function\");n||kn(e.__e),e.__c=e.__=e.__e=void 0}function Aa(e,t,n){return this.constructor(e,n)}function He(e,t,n){var r,i,a,s;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],s=[],Sn(t,e=(!r&&n||t).__k=me(G,null,[e]),i||xt,xt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?st.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,s),Qr(a,e,s)}function Yr(e,t){He(e,t,Yr)}function Ea(e,t,n){var r,i,a,s,o=be({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(o.children=arguments.length>3?st.call(arguments,2):n),Xe(e.type,o,r||e.key,i||e.ref,null)}function In(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(s){s.__e=!0,Xt(s)})},this.sub=function(a){r.add(a);var s=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),s&&s.call(a)}}),n.children}return t.__c=\"__cC\"+jr++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}st=vt.slice,O={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(o){e=o}throw e}},Mr=0,xe.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=be({},this.state),typeof e==\"function\"&&(e=e(be({},n),this.props)),e&&be(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Xt(this))},xe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Xt(this))},xe.prototype.render=G,ze=[],Br=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Vr=function(e,t){return e.__v.__b-t.__v.__b},wt.__r=0,Hr=/(PointerCapture)$|Capture$/i,wn=0,Zt=Un(!1),Jt=Un(!0),jr=0;var $a=0;function g(e,t,n,r,i,a){t||(t={});var s,o,u=t;if(\"ref\"in u)for(o in u={},t)o==\"ref\"?s=t[o]:u[o]=t[o];var l={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--$a,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(s=e.defaultProps))for(o in s)u[o]===void 0&&(u[o]=s[o]);return O.vnode&&O.vnode(l),l}var Ae,U,Ht,Wn,je=0,Zr=[],Q=O,Qn=Q.__b,Gn=Q.__r,Kn=Q.diffed,Yn=Q.__c,Zn=Q.unmount,Jn=Q.__;function We(e,t){Q.__h&&Q.__h(U,e,je||t),je=0;var n=U.__H||(U.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return je=1,An(ti,e)}function An(e,t,n){var r=We(Ae++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ti(void 0,t),function(o){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,o);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=U,!U.__f)){var i=function(o,u,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(p){return p.__c});if(f.every(function(p){return!p.__N}))return!a||a.call(this,o,u,l);var c=r.__c.props!==o;return f.some(function(p){if(p.__N){var h=p.__[0];p.__=p.__N,p.__N=void 0,h!==p.__[0]&&(c=!0)}}),a&&a.call(this,o,u,l)||c};U.__f=!0;var a=U.shouldComponentUpdate,s=U.componentWillUpdate;U.componentWillUpdate=function(o,u,l){if(this.__e){var f=a;a=void 0,i(o,u,l),a=f}s&&s.call(this,o,u,l)},U.shouldComponentUpdate=i}return r.__N||r.__}function ve(e,t){var n=We(Ae++,3);!Q.__s&&En(n.__H,t)&&(n.__=e,n.u=t,U.__H.__h.push(n))}function ue(e,t){var n=We(Ae++,4);!Q.__s&&En(n.__H,t)&&(n.__=e,n.u=t,U.__h.push(n))}function qe(e){return je=5,Qe(function(){return{current:e}},[])}function Jr(e,t,n){je=6,ue(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 Qe(e,t){var n=We(Ae++,7);return En(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Tt(e,t){return je=8,Qe(function(){return e},t)}function ke(e){var t=U.context[e.__c],n=We(Ae++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(U)),t.props.value):e.__}function Xr(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ei(){var e=We(Ae++,11);if(!e.__){for(var t=U.__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 Pa(){for(var e;e=Zr.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(_t),t.__h.some(tn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){U=null,Qn&&Qn(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Jn&&Jn(e,t)},Q.__r=function(e){Gn&&Gn(e),Ae=0;var t=(U=e.__c).__H;t&&(Ht===U?(t.__h=[],U.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(_t),t.__h.some(tn),t.__h=[],Ae=0)),Ht=U},Q.diffed=function(e){Kn&&Kn(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Zr.push(t)!==1&&Wn===Q.requestAnimationFrame||((Wn=Q.requestAnimationFrame)||Ta)(Pa)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ht=U=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(_t),n.__h=n.__h.filter(function(r){return!r.__||tn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Yn&&Yn(e,t)},Q.unmount=function(e){Zn&&Zn(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{_t(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Xn=typeof requestAnimationFrame==\"function\";function Ta(e){var t,n=function(){clearTimeout(r),Xn&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Xn&&(t=requestAnimationFrame(n))}function _t(e){var t=U,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),U=t}function tn(e){var t=U;e.__c=e.__(),U=t}function En(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ti(e,t){return typeof t==\"function\"?t(e):t}const er=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const p=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(h=>h(t,p))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,o);return o},Na=(e=>e?er(e):er);function ni(e,t){for(var n in t)e[n]=t[n];return e}function nn(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 ri(e,t){var n=t(),r=Z({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ue(function(){i.__=n,i.u=t,jt(i)&&a({t:i})},[e,n,t]),ve(function(){return jt(i)&&a({t:i}),e(function(){jt(i)&&a({t:i})})},[e]),n}function jt(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 ii(e){e()}function ai(e){return e}function si(){return[!1,ii]}var oi=ue;function rn(e,t){this.props=e,this.context=t}function Da(e,t){function n(i){var a=this.props.ref,s=a==i.ref;return!s&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!s:nn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,me(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(rn.prototype=new xe).isPureReactComponent=!0,rn.prototype.shouldComponentUpdate=function(e,t){return nn(this.props,e)||nn(this.state,t)};var tr=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),tr&&tr(e)};var za=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Oa(e){function t(n){var r=ni({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=za,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var nr=function(e,t){return e==null?null:Ce(Ce(e).map(t))},Fa={map:nr,forEach:nr,count:function(e){return e?Ce(e).length:0},only:function(e){var t=Ce(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ce},Ra=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)}Ra(e,t,n,r)};var rr=O.unmount;function li(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=ni({},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 li(r,t,n)})),e}function ui(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ui(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 yt(){this.__u=0,this.o=null,this.__b=null}function ci(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function La(e){var t,n,r,i=null;function a(s){if(t||(t=e()).then(function(o){o&&(i=o.default||o),r=!0},function(o){n=o,r=!0}),n)throw n;if(!r)throw t;return i?me(i,s):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Je(){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),rr&&rr(e)},(yt.prototype=new xe).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ci(r.__v),a=!1,s=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=s;var o=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=ui(l,l.__c.__P,l.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=o,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(s,s)},yt.prototype.componentWillUnmount=function(){this.o=[]},yt.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]=li(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&me(G,null,e.fallback);return i&&(i.__u&=-33),[me(G,null,t.__a?null:e.children),i]};var ir=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 Ma(e){return this.getChildContext=function(){return e.context},e.children}function Ba(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){He(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)}}}He(me(Ma,{context:t.context},e.__v),t.v)}function Va(e,t){var n=me(Ba,{__v:e,h:t});return n.containerInfo=t,n}(Je.prototype=new xe).__a=function(e){var t=this,n=ci(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ir(t,e,r)):i()};n?n(a):a()}},Je.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ce(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},Je.prototype.componentDidUpdate=Je.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ir(e,n,t)})};var fi=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Ha=/^(?: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]/,ja=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,qa=/[A-Z0-9]/g,Ua=typeof document<\"u\",Wa=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Qa(e,t,n){return t.__k==null&&(t.textContent=\"\"),He(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ga(e,t,n){return Yr(e,t),typeof n==\"function\"&&n(),e?e.__c:null}xe.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(xe.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ar=O.event;function Ka(){}function Ya(){return this.cancelBubble}function Za(){return this.defaultPrevented}O.event=function(e){return ar&&(e=ar(e)),e.persist=Ka,e.isPropagationStopped=Ya,e.isDefaultPrevented=Za,e.nativeEvent=e};var $n,Ja={enumerable:!1,configurable:!0,get:function(){return this.class}},sr=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 s in n){var o=n[s];if(!(s===\"value\"&&\"defaultValue\"in n&&o==null||Ua&&s===\"children\"&&r===\"noscript\"||s===\"class\"||s===\"className\")){var u=s.toLowerCase();s===\"defaultValue\"&&\"value\"in n&&n.value==null?s=\"value\":s===\"download\"&&o===!0?o=\"\":u===\"translate\"&&o===\"no\"?o=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?s=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Wa(n.type)?u===\"onfocus\"?s=\"onfocusin\":u===\"onblur\"?s=\"onfocusout\":ja.test(s)&&(s=u):u=s=\"oninput\":a&&Ha.test(s)?s=s.replace(qa,\"-$&\").toLowerCase():o===null&&(o=void 0),u===\"oninput\"&&i[s=u]&&(s=\"oninputCapture\"),i[s]=o}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ce(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ce(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\",Ja)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=fi,sr&&sr(e)};var or=O.__r;O.__r=function(e){or&&or(e),$n=e.__c};var lr=O.diffed;O.diffed=function(e){lr&&lr(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),$n=null};var Xa={ReactCurrentDispatcher:{current:{readContext:function(e){return $n.__n[e.__c].props.value},useCallback:Tt,useContext:ke,useDebugValue:Xr,useDeferredValue:ai,useEffect:ve,useId:ei,useImperativeHandle:Jr,useInsertionEffect:oi,useLayoutEffect:ue,useMemo:Qe,useReducer:An,useRef:qe,useState:Z,useSyncExternalStore:ri,useTransition:si}}};function es(e){return me.bind(null,e)}function Nt(e){return!!e&&e.$$typeof===fi}function ts(e){return Nt(e)&&e.type===G}function ns(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function rs(e){return Nt(e)?Ea.apply(null,arguments):e}function is(e){return!!e.__k&&(He(null,e),!0)}function as(e){return e&&(e.base||e.nodeType===1&&e)||null}var ss=function(e,t){return e(t)},os=function(e,t){return e(t)},ls=G,us=Nt,ht={useState:Z,useId:ei,useReducer:An,useEffect:ve,useLayoutEffect:ue,useInsertionEffect:oi,useTransition:si,useDeferredValue:ai,useSyncExternalStore:ri,startTransition:ii,useRef:qe,useImperativeHandle:Jr,useMemo:Qe,useCallback:Tt,useContext:ke,useDebugValue:Xr,version:\"18.3.1\",Children:Fa,render:Qa,hydrate:Ga,unmountComponentAtNode:is,createPortal:Va,createElement:me,createContext:In,createFactory:es,cloneElement:rs,createRef:wa,Fragment:G,isValidElement:Nt,isElement:us,isFragment:ts,isMemo:ns,findDOMNode:as,Component:xe,PureComponent:rn,memo:Da,forwardRef:Oa,flushSync:os,unstable_batchedUpdates:ss,StrictMode:ls,Suspense:yt,SuspenseList:Je,lazy:La,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Xa};const cs=e=>e;function fs(e,t=cs){const n=ht.useSyncExternalStore(e.subscribe,ht.useCallback(()=>t(e.getState()),[e,t]),ht.useCallback(()=>t(e.getInitialState()),[e,t]));return ht.useDebugValue(n),n}const hs=e=>{const t=Na(e),n=r=>fs(t,r);return Object.assign(n,t),n},ps=(e=>hs);var hi=Symbol.for(\"immer-nothing\"),ur=Symbol.for(\"immer-draftable\"),le=Symbol.for(\"immer-state\");function de(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var tt=Object.getPrototypeOf;function Ue(e){return!!e&&!!e[le]}function Oe(e){return e?pi(e)||Array.isArray(e)||!!e[ur]||!!e.constructor?.[ur]||lt(e)||zt(e):!1}var ds=Object.prototype.constructor.toString(),cr=new WeakMap;function pi(e){if(!e||typeof e!=\"object\")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;if(n===Object)return!0;if(typeof n!=\"function\")return!1;let r=cr.get(n);return r===void 0&&(r=Function.toString.call(n),cr.set(n,r)),r===ds}function kt(e,t,n=!0){Dt(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Dt(e){const t=e[le];return t?t.type_:Array.isArray(e)?1:lt(e)?2:zt(e)?3:0}function an(e,t){return Dt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function di(e,t,n){const r=Dt(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function ms(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function lt(e){return e instanceof Map}function zt(e){return e instanceof Set}function De(e){return e.copy_||e.base_}function sn(e,t){if(lt(e))return new Map(e);if(zt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=pi(e);if(t===!0||t===\"class_only\"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[le];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(tt(e),r)}else{const r=tt(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function Pn(e,t=!1){return Ot(e)||Ue(e)||!Oe(e)||(Dt(e)>1&&Object.defineProperties(e,{set:pt,add:pt,clear:pt,delete:pt}),Object.freeze(e),t&&Object.values(e).forEach(n=>Pn(n,!0))),e}function gs(){de(2)}var pt={value:gs};function Ot(e){return e===null||typeof e!=\"object\"?!0:Object.isFrozen(e)}var _s={};function Fe(e){const t=_s[e];return t||de(0,e),t}var nt;function mi(){return nt}function ys(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function fr(e,t){t&&(Fe(\"Patches\"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function on(e){ln(e),e.drafts_.forEach(bs),e.drafts_=null}function ln(e){e===nt&&(nt=e.parent_)}function hr(e){return nt=ys(nt,e)}function bs(e){const t=e[le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[le].modified_&&(on(t),de(4)),Oe(e)&&(e=St(t,e),t.parent_||Ct(t,e)),t.patches_&&Fe(\"Patches\").generateReplacementPatches_(n[le].base_,e,t.patches_,t.inversePatches_)):e=St(t,n,[]),on(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hi?e:void 0}function St(e,t,n){if(Ot(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[le];if(!i)return kt(t,(a,s)=>dr(e,i,t,a,s,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return Ct(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),kt(s,(u,l)=>dr(e,i,a,u,l,n,o),r),Ct(e,a,!1),n&&e.patches_&&Fe(\"Patches\").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function dr(e,t,n,r,i,a,s){if(i==null||typeof i!=\"object\"&&!s)return;const o=Ot(i);if(!(o&&!s)){if(Ue(i)){const u=a&&t&&t.type_!==3&&!an(t.assigned_,r)?a.concat(r):void 0,l=St(e,i,u);if(di(n,r,l),Ue(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Oe(i)&&!o){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&o)return;St(e,i),(!t||!t.scope_.parent_)&&typeof r!=\"symbol\"&&(lt(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Ct(e,i)}}}function Ct(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Pn(t,n)}function xs(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:mi(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=Tn;n&&(i=[r],a=rt);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var Tn={get(e,t){if(t===le)return e;const n=De(e);if(!an(n,t))return vs(e,n,t);const r=n[t];return e.finalized_||!Oe(r)?r:r===qt(e.base_,t)?(Ut(e),e.copy_[t]=cn(r,e)):r},has(e,t){return t in De(e)},ownKeys(e){return Reflect.ownKeys(De(e))},set(e,t,n){const r=gi(De(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=qt(De(e),t),a=i?.[le];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(ms(n,i)&&(n!==void 0||an(e.base_,t)))return!0;Ut(e),un(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_[t]=!0),!0},deleteProperty(e,t){return qt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ut(e),un(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=De(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!==\"length\",enumerable:r.enumerable,value:n[t]}},defineProperty(){de(11)},getPrototypeOf(e){return tt(e.base_)},setPrototypeOf(){de(12)}},rt={};kt(Tn,(e,t)=>{rt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});rt.deleteProperty=function(e,t){return rt.set.call(this,e,t,void 0)};rt.set=function(e,t,n){return Tn.set.call(this,e[0],t,n,e[0])};function qt(e,t){const n=e[le];return(n?De(n):e)[t]}function vs(e,t,n){const r=gi(t,n);return r?\"value\"in r?r.value:r.get?.call(e.draft_):void 0}function gi(e,t){if(!(t in e))return;let n=tt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tt(n)}}function un(e){e.modified_||(e.modified_=!0,e.parent_&&un(e.parent_))}function Ut(e){e.copy_||(e.copy_=sn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ws=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t==\"function\"&&typeof n!=\"function\"){const a=n;n=t;const s=this;return function(u=a,...l){return s.produce(u,f=>n.call(this,f,...l))}}typeof n!=\"function\"&&de(6),r!==void 0&&typeof r!=\"function\"&&de(7);let i;if(Oe(t)){const a=hr(this),s=cn(t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?on(a):ln(a)}return fr(a,r),pr(i,a)}else if(!t||typeof t!=\"object\"){if(i=n(t),i===void 0&&(i=t),i===hi&&(i=void 0),this.autoFreeze_&&Pn(i,!0),r){const a=[],s=[];Fe(\"Patches\").generateReplacementPatches_(t,i,a,s),r(a,s)}return i}else de(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t==\"function\")return(s,...o)=>this.produceWithPatches(s,u=>t(u,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},typeof e?.autoFreeze==\"boolean\"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy==\"boolean\"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration==\"boolean\"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Oe(e)||de(8),Ue(e)&&(e=ks(e));const t=hr(this),n=cn(e,void 0);return n[le].isManual_=!0,ln(t),n}finishDraft(e,t){const n=e&&e[le];(!n||!n.isManual_)&&de(9);const{scope_:r}=n;return fr(r,t),pr(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=Fe(\"Patches\").applyPatches_;return Ue(e)?r(e,t):this.produce(e,i=>r(i,t))}};function cn(e,t){const n=lt(e)?Fe(\"MapSet\").proxyMap_(e,t):zt(e)?Fe(\"MapSet\").proxySet_(e,t):xs(e,t);return(t?t.scope_:mi()).drafts_.push(n),n}function ks(e){return Ue(e)||de(10,e),_i(e)}function _i(e){if(!Oe(e)||Ot(e))return e;const t=e[le];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=sn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=sn(e,!0);return kt(n,(i,a)=>{di(n,i,_i(a))},r),t&&(t.finalized_=!1),n}var Ss=new ws,Cs=Ss.produce;const Is=e=>(t,n,r)=>(r.setState=(i,a,...s)=>{const o=typeof i==\"function\"?Cs(i):i;return t(o,a,...s)},e(r.setState,n,r)),As=Is,Es=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\"]),$s=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Ps(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 mr(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 gr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;const s=i;for(;i<e.length&&/[a-zA-Z0-9_-]/.test(e[i]);)i++;if(i>s){const o=e.slice(s,i);a===\".\"?n.push(o):r=o}}return{className:n.join(\" \"),id:r,endIdx:i}}function Ts(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 s=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(s,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 ut(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]===\"[\"){i(n);const a=n;n+=2;let s,o;if(e[n]===\".\"||e[n]===\"#\"){const _=gr(e,n);s=_.className||void 0,o=_.id||void 0,n=_.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:p}=Ps(f),h={type:\"link\",display:c,target:p,start:a,end:n};s&&(h.className=s),o&&(h.id=o),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let s=e[n+1],o,u;if(s===\".\"||s===\"#\"){i(n);const l=gr(e,n+1);o=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 p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(p,n);if(e[n]===\"}\"){n++;const _={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const p=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(p,n);if(e[n]===\"}\"){n++;const _={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let p=1;const h=n;for(;n<e.length&&p>0;)e[n]===\"{\"?p++:e[n]===\"}\"&&p--,p>0&&n++;if(p!==0){n=a+1,r=a;continue}const _=e.slice(h,n);n++;const{name:w,rawArgs:I,isClose:b}=mr(_),v={type:\"macro\",name:w,rawArgs:I,isClose:b,start:a,end:n};o&&(v.className=o),u&&(v.id=u),t.push(v),r=n;continue}n=a+1,r=a;continue}if(s===\"$\"){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(s===\"_\"){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(s!==void 0&&(s===\"/\"||/[a-zA-Z]/.test(s))){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:p,rawArgs:h,isClose:_}=mr(c);t.push({type:\"macro\",name:p,rawArgs:h,isClose:_,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let s=n+1;const o=e[s]===\"/\";o&&s++;const u=s;for(;s<e.length&&/[a-zA-Z0-9]/.test(e[s]);)s++;const l=e.slice(u,s).toLowerCase();if(l&&Es.has(l))if(o){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:s}),r=s,n=s;continue}}else{const f=Ts(e,s);s=f.endIdx;let c=$s.has(l);if(e[s]===\"/\"&&(c=!0,s++),e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:s}),r=s,n=s;continue}}n++;continue}n++}return i(e.length),t}const Ns=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),_r={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Ds=new Set([\"if\",\"switch\",\"timed\"]);function ct(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);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 s=n[n.length-1];if(s.node.type!==\"html\"||s.node.tag!==i.tag){const o=s.node.type===\"html\"?`</${s.node.tag}>`:`{/${s.node.name}}`;throw new Error(`Expected ${o} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(s.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 s=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(_r[i.name]){const a=_r[i.name],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),s.branches.push(o);break}if(Ns.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(Ds.has(i.name)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),a.branches=[s]}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}}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}const yr=new Map;function yi(e){return e.replace(/\\$(\\w+)/g,'variables[\"$1\"]').replace(/\\b_(\\w+)/g,'temporary[\"$1\"]')}const zs=\"const {visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll}=__fns;\";function bi(e,t){let n=yr.get(e);return n||(n=new Function(\"variables\",\"temporary\",\"__fns\",zs+t),yr.set(e,n)),n}function xi(){const e=k.getState(),{visitCounts:t,renderCounts:n}=e,r=c=>t[c]??0,i=c=>r(c)>0,a=(...c)=>c.some(p=>r(p)>0),s=(...c)=>c.every(p=>r(p)>0),o=c=>n[c]??0;return{visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:s,rendered:o,hasRendered:c=>o(c)>0,hasRenderedAny:(...c)=>c.some(p=>o(p)>0),hasRenderedAll:(...c)=>c.every(p=>o(p)>0)}}function we(e,t,n){const i=`return (${yi(e)});`;return bi(i,i)(t,n,xi())}function Re(e,t,n){const r=yi(e);bi(\"exec:\"+r,r)(t,n,xi())}const Os=\"spindle\",Fs=1;let dt=null,Wt=null;function $e(){return Wt||(Wt={saves:new Map,playthroughs:new Map,meta:new Map}),Wt}function Rs(){return dt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(dt=new Promise((e,t)=>{const n=indexedDB.open(Os,Fs);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)}),dt))}function Pe(e,t){return Rs().then(n=>n.transaction(e,t).objectStore(e))}function Te(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function Ft(e){try{const t=await Pe(\"saves\",\"readwrite\");await Te(t.put(e))}catch{$e().saves.set(e.meta.id,e)}}async function Rt(e){try{const t=await Pe(\"saves\",\"readonly\");return await Te(t.get(e))??void 0}catch{return $e().saves.get(e)}}async function Ls(e){try{const t=await Pe(\"saves\",\"readwrite\");await Te(t.delete(e))}catch{$e().saves.delete(e)}}async function Ms(e){try{const n=(await Pe(\"saves\",\"readonly\")).index(\"ifid\");return await Te(n.getAll(e))??[]}catch{return[...$e().saves.values()].filter(t=>t.meta.ifid===e)}}async function vi(e){try{const t=await Pe(\"playthroughs\",\"readwrite\");await Te(t.put(e))}catch{$e().playthroughs.set(e.id,e)}}async function Nn(e){try{const n=(await Pe(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Te(n.getAll(e))??[]}catch{return[...$e().playthroughs.values()].filter(t=>t.ifid===e)}}async function Dn(e){try{const t=await Pe(\"meta\",\"readonly\"),n=await Te(t.get(e));return n?n.value:void 0}catch{return $e().meta.get(e)}}async function wi(e,t){try{const n=await Pe(\"meta\",\"readwrite\");await Te(n.put({key:e,value:t}))}catch{$e().meta.set(e,t)}}const ki=new Map,Lt=new Map;function Bs(e,t){ki.set(e,t),Lt.set(t,e)}function Vs(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function W(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 o=[];t.set(i,o);for(let u=0;u<r.length;u++)o[u]=n(r[u]);return o}const a=i.constructor;if(Lt.get(a)!==void 0){const o=Object.create(Object.getPrototypeOf(i));t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}if(Vs(r)||typeof r==\"object\"){const o={};t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}return r}return n(e)}const fn=\"__spindle_class__\",hn=\"__spindle_data__\";function It(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,s=Lt.get(a);if(s!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[fn]:s,[hn]:u}}const o={};for(const u of Object.keys(i))o[u]=n(i[u]);return t.delete(i),o}return n(e)}function At(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(s=>t(s));const r=n;if(fn in r&&hn in r){const s=r[fn],o=r[hn],u=ki.get(s);if(!u){console.warn(`spindle: Class \"${s}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(o))f[c]=t(o[c]);return f}const l=Object.create(u.prototype);for(const f of Object.keys(o))l[f]=t(o[f]);return l}const i=r.constructor;if(Lt.has(i))return n;const a={};for(const s of Object.keys(r))a[s]=t(r[s]);return a}return t(e)}let pn=null,dn=null,br=!1;function Hs(e){pn=e}function js(e){dn=e}function qs(e){if(dn)try{const i=new Function(\"passage\",\"variables\",dn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(pn)try{const r=pn(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 Us(){br||(br=!0)}async function xr(e){const n=(await Nn(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await vi(i),await wi(`currentPlaythroughId.${e}`,r),r}async function Ws(e){return Dn(`currentPlaythroughId.${e}`)}async function Si(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:qs(n),passage:n.passage,custom:r},s=W(n);s.variables=It(s.variables),s.history=s.history.map(u=>({...u,variables:It(u.variables)}));const o={meta:a,payload:s};return await Ft(o),o}async function Ci(e,t){const n=await Rt(e);if(!n)return;n.meta.updatedAt=new Date().toISOString(),n.meta.passage=t.passage;const r=W(t);return r.variables=It(r.variables),r.history=r.history.map(i=>({...i,variables:It(i.variables)})),n.payload=r,await Ft(n),n}async function Qs(e){const t=await Rt(e);if(!t)return;const n=t.payload;return n.variables=At(n.variables),n.history=n.history.map(r=>({...r,variables:At(r.variables)})),n}async function Gs(e){await Ls(e)}async function Ks(e,t){const n=await Rt(e);n&&(n.meta.title=t,n.meta.updatedAt=new Date().toISOString(),await Ft(n))}async function Ys(e){const[t,n]=await Promise.all([Ms(e),Nn(e)]),r=new Map;for(const o of n)r.set(o.id,o);const i=new Map;for(const o of t){const u=o.meta.playthroughId;i.has(u)||i.set(u,[]),i.get(u).push(o)}for(const o of i.values())o.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],s=[...r.values()].sort((o,u)=>new Date(u.createdAt).getTime()-new Date(o.createdAt).getTime());for(const o of s){const u=i.get(o.id)??[];a.push({playthrough:o,saves:u})}for(const[o,u]of i)r.has(o)||a.push({playthrough:{id:o,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const Ii=\"autosave.\";async function Zs(e,t,n){const r=`${Ii}${e}`,i=await Dn(r);if(i){const s=await Ci(i,n);if(s)return s}const a=await Si(e,t,n,{isAutosave:!0});return await wi(r,a.meta.id),a}async function Js(e){const t=`${Ii}${e}`,n=await Dn(t);if(n)return Qs(n)}async function Xs(e){const t=await Rt(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function eo(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=W(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Nn(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await vi(a)}return await Ft(n),n}function to(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Re(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Re(i,t,n)}}}function Ai(){const e=k.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=ut(t.content),r=ct(n),i=W(e.variables),a=W(e.temporary);to(r,i,a);for(const o of Object.keys(i))i[o]!==e.variables[o]&&e.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==e.temporary[o]&&e.setTemporary(o,a[o]);const s=e.storyData.passages.get(\"SaveTitle\");s&&js(s.content)}const k=ps()(As((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",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=W(r);e(o=>{o.storyData=n,o.currentPassage=i.name,o.variables=a,o.variableDefaults=r,o.temporary={},o.history=[{passage:i.name,variables:W(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}});const s=n.ifid;Us().then(async()=>{const o=await Ws(s);if(o)e(u=>{u.playthroughId=o});else{const u=await xr(s);e(l=>{l.playthroughId=u})}})},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:W(i.variables),timestamp:Date.now()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=W(r.variables),n.temporary={}})},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=W(r.variables),n.temporary={}})},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;const a=W(r);e(s=>{s.currentPassage=i.name,s.variables=a,s.temporary={},s.history=[{passage:i.name,variables:W(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Ai(),xr(n.ifid).then(s=>{e(o=>{o.playthroughId=s})})},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:s,historyIndex:o,visitCounts:u,renderCounts:l}=t();if(!n)return;const f={passage:i,variables:W(a),history:W(s),historyIndex:o,visitCounts:{...u},renderCounts:{...l}};Zs(n.ifid,r,f).then(()=>{e(c=>{c.saveVersion++})})},load:()=>{const{storyData:n}=t();n&&Js(n.ifid).then(r=>{r&&e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}})})},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:s,renderCounts:o}=t();return{passage:n,variables:W(r),history:W(i),historyIndex:a,visitCounts:{...s},renderCounts:{...o}}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=At(n.variables),r.history=n.history.map(i=>({...i,variables:At(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}})}}))),Et=new Map,mn=new Set,gn=new Map;function no(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(gn.get(r)??0)+1;return gn.set(r,i),i===1?r:`${r}:${i}`}function ro(e){return Et.set(e.id,e),wr(),()=>{Et.delete(e.id),wr()}}function vr(){return Array.from(Et.values())}function io(e){return Et.get(e)}function ao(){gn.clear()}function so(e){return mn.add(e),()=>{mn.delete(e)}}function wr(){for(const e of mn)e()}function ne(e){const t=qe(\"\");t.current||(t.current=no(e.type,e.key,e.authorId));const n=t.current;return ue(()=>{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),ro(r)}),n}function oo({target:e,className:t,id:n,children:r}){const i=k(o=>o.navigate),a=o=>{o.preventDefault(),i(e)};ne({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return g(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function lo({name:e,scope:t,className:n,id:r}){const i=ke(Ee),a=e.split(\".\"),s=a[0],o=k(c=>t===\"variable\"?c.variables[s]:c.temporary[s]),u=t===\"variable\"?`$${s}`:`_${s}`;let l=u in i?i[u]:o;for(let c=1;c<a.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}l=l[a[c]]}const f=l==null?\"\":String(l);return n||r?g(\"span\",{id:r,class:n,children:f}):g(G,{children:f})}function uo({rawArgs:e}){return ue(()=>{const t=k.getState(),n=W(t.variables),r=W(t.temporary);try{Re(e,n,r)}catch(i){console.error(`spindle: Error in {set ${e}}:`,i);return}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])},[]),null}function co({rawArgs:e,className:t,id:n}){const r=k(u=>u.variables),i=k(u=>u.temporary),a=ke(Ee),s={...r},o={...i};for(const[u,l]of Object.entries(a))u.startsWith(\"$\")?s[u.slice(1)]=l:u.startsWith(\"_\")&&(o[u.slice(1)]=l);try{const u=we(e,s,o),l=u==null?\"\":String(u);return t||n?g(\"span\",{id:n,class:t,children:l}):g(G,{children:l})}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{print error: ${u.message}}`})}}function fo({branches:e}){const t=k(o=>o.variables),n=k(o=>o.temporary),r=ke(Ee),i={...t},a={...n};for(const[o,u]of Object.entries(r))o.startsWith(\"$\")?i[o.slice(1)]=u:o.startsWith(\"_\")&&(a[o.slice(1)]=u);function s(o){const u=fe(o.children);return o.className||o.id?g(\"span\",{id:o.id,class:o.className,children:u}):g(G,{children:u})}for(const o of e){if(o.rawArgs===\"\")return s(o);try{if(we(o.rawArgs,i,a))return s(o)}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{if error: ${u.message}}`})}}return null}function ho(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(o=>o.trim()),a=i[0],s=i.length>1?i[1]:null;return{itemVar:a,indexVar:s,listExpr:r}}function po({rawArgs:e,children:t,className:n,id:r}){const i=k(w=>w.variables),a=k(w=>w.temporary),s=ke(Ee),o={...i},u={...a};for(const[w,I]of Object.entries(s))w.startsWith(\"$\")?o[w.slice(1)]=I:w.startsWith(\"_\")&&(u[w.slice(1)]=I);let l;try{l=ho(e)}catch(w){return g(\"span\",{class:\"error\",title:String(w),children:`{for error: ${w.message}}`})}const{itemVar:f,indexVar:c,listExpr:p}=l;let h;try{const w=we(p,o,u);if(!Array.isArray(w))return g(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});h=w}catch(w){return g(\"span\",{class:\"error\",title:String(w),children:`{for error: ${w.message}}`})}const _=h.map((w,I)=>{const b={...s,[f]:w};return c&&(b[c]=I),g(Ee.Provider,{value:b,children:fe(t)},I)});return n||r?g(\"span\",{id:r,class:n,children:_}):g(G,{children:_})}function mo(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function go({children:e}){const t=mo(e);return ue(()=>{const n=k.getState(),r=W(n.variables),i=W(n.temporary);try{Re(t,r,i)}catch(a){console.error(\"spindle: Error in {do}:\",a);return}for(const a of Object.keys(r))r[a]!==n.variables[a]&&n.setVariable(a,r[a]);for(const a of Object.keys(i))i[a]!==n.temporary[a]&&n.setTemporary(a,i[a])},[]),null}function Ei(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function _o({rawArgs:e,children:t,className:n,id:r}){const i=()=>{const s=k.getState(),o=W(s.variables),u=W(s.temporary);try{Re(e,o,u)}catch(l){console.error(`spindle: Error in {button ${e}}:`,l);return}for(const l of Object.keys(o))o[l]!==s.variables[l]&&s.setVariable(l,o[l]);for(const l of Object.keys(u))u[l]!==s.temporary[l]&&s.setTemporary(l,u[l])};ne({type:\"button\",key:e,authorId:r,label:Ei(t)||e,perform:i});const a=n?`macro-button ${n}`:\"macro-button\";return g(\"button\",{id:r,class:a,onClick:i,children:Wi(t)})}function yo({className:e,id:t}){const n=k(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return g(\"span\",{id:t,class:r,children:n})}function bo({className:e,id:t}){const n=k(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ne({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),g(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function xo({className:e,id:t}){const n=k(a=>a.goBack),r=k(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ne({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function vo({className:e,id:t}){const n=k(a=>a.goForward),r=k(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ne({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function wo({className:e,id:t}){const n=k(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ne({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),g(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function ko({className:e,id:t}){const n=k(o=>o.load),r=k(o=>o.hasSave);k(o=>o.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),s=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ne({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),g(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:s,children:\"QuickLoad\"})}const Ye=new Map;let ce={};function $i(){return`spindle.${k.getState().storyData?.ifid||\"unknown\"}.settings`}function So(){localStorage.setItem($i(),JSON.stringify(ce))}function Qt(){try{const e=localStorage.getItem($i());e&&(ce={...ce,...JSON.parse(e)})}catch{}}const it={addToggle(e,t){Ye.set(e,{type:\"toggle\",config:t}),e in ce||(ce[e]=t.default),Qt()},addList(e,t){Ye.set(e,{type:\"list\",config:t}),e in ce||(ce[e]=t.default),Qt()},addRange(e,t){Ye.set(e,{type:\"range\",config:t}),e in ce||(ce[e]=t.default),Qt()},get(e){return ce[e]},set(e,t){ce[e]=t,So()},getAll(){return{...ce}},getDefinitions(){return Ye},hasAny(){return Ye.size>0}};function Co({name:e,def:t}){const[n,r]=Z(()=>it.get(e)),i=a=>{r(a),it.set(e,a)};switch(t.type){case\"toggle\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>g(\"option\",{value:a,children:a},a))})]});case\"range\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:[t.config.label,\": \",String(n)]}),g(\"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 Io({onClose:e}){const t=it.getDefinitions();return g(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:g(\"div\",{class:\"settings-panel\",children:[g(\"div\",{class:\"settings-header\",children:[g(\"span\",{children:\"Settings\"}),g(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>g(Co,{name:r,def:i},r))})]})})}function Ao({className:e,id:t}){const[n,r]=Z(!1);if(!it.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return g(G,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&g(Io,{onClose:()=>r(!1)})]})}function Eo(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 $o(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Po({onClose:e}){const[t,n]=Z(\"load\"),[r,i]=Z([]),[a,s]=Z(!0),[o,u]=Z(null),[l,f]=Z(new Set),[c,p]=Z(null),[h,_]=Z(\"\"),w=qe(null),I=qe(null),b=k(A=>A.storyData),v=k(A=>A.playthroughId),C=k(A=>A.getSavePayload),z=k(A=>A.loadFromPayload),E=b?.ifid??\"\",x=Tt(async()=>{if(!E)return;const A=await Ys(E);i(A),s(!1)},[E]);ve(()=>{x()},[x]),ve(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]);const P=(A,q=\"success\")=>{u({text:A,type:q}),setTimeout(()=>u(null),3e3)},M=A=>{f(q=>{const d=new Set(q);return d.has(A)?d.delete(A):d.add(A),d})},L=async()=>{if(!(!E||!v))try{const A=C();await Si(E,v,A),P(\"Save created\"),await x()}catch{P(\"Failed to create save\",\"error\")}},y=async A=>{try{const q=C();await Ci(A,q),P(\"Save overwritten\"),await x()}catch{P(\"Failed to overwrite save\",\"error\")}},$=async A=>{try{z(A.payload),P(\"Game loaded\"),setTimeout(e,500)}catch{P(\"Failed to load save\",\"error\")}},T=async A=>{if(confirm(\"Delete this save?\"))try{await Gs(A),P(\"Save deleted\"),await x()}catch{P(\"Failed to delete save\",\"error\")}},H=A=>{p(A.meta.id),_(A.meta.title)},j=async()=>{if(!(!c||!h.trim()))try{await Ks(c,h.trim()),p(null),P(\"Save renamed\"),await x()}catch{P(\"Failed to rename\",\"error\")}},R=A=>{A.key===\"Enter\"?j():A.key===\"Escape\"&&p(null)},Y=async A=>{try{const q=await Xs(A);if(!q)return;const d=new Blob([JSON.stringify(q,null,2)],{type:\"application/json\"}),V=URL.createObjectURL(d),re=document.createElement(\"a\");re.href=V,re.download=`save-${q.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,re.click(),URL.revokeObjectURL(V),P(\"Save exported\")}catch{P(\"Failed to export save\",\"error\")}},K=()=>{I.current?.click()},ae=async A=>{const q=A.target,d=q.files?.[0];if(d){q.value=\"\";try{const V=await d.text(),re=JSON.parse(V);await eo(re,E),P(\"Save imported\"),await x()}catch(V){P(V instanceof Error?V.message:\"Failed to import save\",\"error\")}}},he=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},m=r.reduce((A,q)=>A+q.saves.length,0);return g(\"div\",{class:\"saves-overlay\",onClick:he,children:g(\"div\",{class:\"saves-panel\",children:[g(\"div\",{class:\"saves-header\",children:[g(\"div\",{class:\"saves-header-left\",children:g(\"div\",{class:\"saves-mode-toggle\",children:[g(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),g(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),g(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"saves-toolbar\",children:[g(\"button\",{class:\"saves-toolbar-button\",onClick:K,children:\"Import\"}),g(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ae})]}),g(\"div\",{class:\"saves-body\",children:[a?g(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&t===\"load\"?g(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const q=l.has(A.playthrough.id),d=A.playthrough.id===v;return t===\"save\"&&!d||t===\"load\"&&A.saves.length===0&&!d?null:g(\"div\",{class:\"playthrough-group\",children:[g(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[g(\"span\",{class:`playthrough-chevron ${q?\"\":\"open\"}`,children:\"▶\"}),g(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,d?\" (current)\":\"\"]}),g(\"span\",{class:\"playthrough-date\",children:$o(A.playthrough.createdAt)})]}),!q&&g(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(V=>g(\"div\",{class:\"save-slot\",children:[g(\"div\",{class:\"save-slot-info\",children:[c===V.meta.id?g(\"input\",{ref:w,class:\"save-rename-input\",value:h,onInput:re=>_(re.target.value),onKeyDown:R,onBlur:j}):g(\"div\",{class:\"save-slot-title\",children:V.meta.title}),g(\"div\",{class:\"save-slot-meta\",children:[g(\"span\",{children:V.meta.passage}),g(\"span\",{children:Eo(V.meta.updatedAt)})]})]}),g(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?g(\"button\",{class:\"save-slot-action primary\",onClick:()=>y(V.meta.id),children:\"Save Here\"}):g(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(V),children:\"Load\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>H(V),children:\"Rename\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>Y(V.meta.id),children:\"Export\"}),g(\"button\",{class:\"save-slot-action danger\",onClick:()=>T(V.meta.id),children:\"Delete\"})]})]},V.meta.id)),t===\"save\"&&d&&g(\"button\",{class:\"save-slot-new\",onClick:L,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===v)&&g(\"div\",{class:\"playthrough-group\",children:g(\"div\",{class:\"playthrough-saves\",children:g(\"button\",{class:\"save-slot-new\",onClick:L,children:\"+ New Save\"})})})]}),o&&g(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})})}function To({className:e,id:t}){const[n,r]=Z(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return g(G,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&g(Po,{onClose:()=>r(!1)})]})}function No({rawArgs:e,className:t,id:n}){const r=k(c=>c.storyData),i=k(c=>c.variables),a=k(c=>c.temporary);if(!r)return null;let s;try{const c=we(e,i,a);s=String(c)}catch{s=e.replace(/^[\"']|[\"']$/g,\"\")}const o=r.passages.get(s);if(o&&k.getState().trackRender(s),!o)return g(\"span\",{class:\"error\",children:`{include: passage \"${s}\" not found}`});const u=ut(o.content),l=ct(u),f=fe(l);return t||n?g(\"span\",{id:n,class:t,children:f}):g(G,{children:f})}function Do({rawArgs:e}){return ue(()=>{const t=k.getState();let n;try{const r=we(e,t.variables,t.temporary);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}t.navigate(n)},[]),null}function zo({rawArgs:e}){return ue(()=>{const t=k.getState(),n=e.trim();n.startsWith(\"$\")?t.deleteVariable(n.slice(1)):n.startsWith(\"_\")?t.deleteTemporary(n.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${n}\"`)},[]),null}function Oo(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 Fo({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Oo(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);ne({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return g(\"input\",{type:\"text\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function Ro(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 Lo({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Ro(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);ne({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return g(\"input\",{type:\"number\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>{const f=l.target.value;o(a,f===\"\"?0:Number(f))}})}function Mo(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 Bo({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Mo(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);ne({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return g(\"textarea\",{id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function Vo(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}}function Ho({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Vo(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);ne({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!s,perform:l=>o(a,l!==void 0?!!l:!s)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return g(\"label\",{id:n,class:u,children:[g(\"input\",{type:\"checkbox\",checked:!!s,onChange:()=>o(a,!s)}),i?` ${i}`:null]})}function jo(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]}}function qo({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=jo(e),s=r.startsWith(\"$\")?r.slice(1):r,o=k(f=>f.variables[s]),u=k(f=>f.setVariable);ne({type:\"radiobutton\",key:`$${s}:${i}`,authorId:n,label:a||i,variable:s,value:o,perform:()=>u(s,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return g(\"label\",{id:n,class:l,children:[g(\"input\",{type:\"radio\",name:`radio-${s}`,checked:o===i,onChange:()=>u(s,i)}),a?` ${a}`:null]})}function Pi(e){const t=[];for(const n of e)n.type===\"macro\"&&n.name===\"option\"&&t.push(n.rawArgs.trim());return t}function Uo({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=k(f=>f.variables[a]),o=k(f=>f.setVariable),u=Pi(t);ne({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:s,perform:f=>{f!==void 0&&o(a,String(f))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return g(\"select\",{id:r,class:l,value:s==null?\"\":String(s),onChange:f=>o(a,f.target.value),children:u.map(f=>g(\"option\",{value:f,children:f},f))})}function Wo({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=k(c=>c.variables[a]),o=k(c=>c.setVariable),u=Pi(t),l=()=>{if(u.length===0)return;const p=(u.indexOf(String(s))+1)%u.length;o(a,u[p])};ne({type:\"cycle\",key:`$${a}`,authorId:r,label:s==null?u[0]||\"\":String(s),variable:a,options:u,value:s,perform:c=>{c!==void 0?o(a,c):l()}});const f=n?`macro-cycle ${n}`:\"macro-cycle\";return g(\"button\",{id:r,class:f,onClick:l,children:s==null?u[0]||\"\":String(s)})}function Qo(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function kr(e){const t=k.getState(),n=W(t.variables),r=W(t.temporary);for(const i of e)if(i.type===\"macro\"){if(i.name===\"set\")try{Re(i.rawArgs,n,r)}catch(a){console.error(\"spindle: Error in {link} child {set}:\",a)}else if(i.name===\"do\"){const a=Ei(i.children);try{Re(a,n,r)}catch(s){console.error(\"spindle: Error in {link} child {do}:\",s)}}}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])}function Go({rawArgs:e,children:t,className:n,id:r}){const{display:i,passage:a}=Qo(e),s=u=>{u.preventDefault(),kr(t),a&&k.getState().navigate(a)};ne({type:\"link\",key:a||i,authorId:r,label:i,target:a??void 0,perform:()=>{kr(t),a&&k.getState().navigate(a)}});const o=n?`macro-link ${n}`:\"macro-link\";return g(\"a\",{id:r,class:o,href:\"#\",onClick:s,children:i})}function Ko({rawArgs:e,branches:t}){const n=k(l=>l.variables),r=k(l=>l.temporary),i=ke(Ee),a={...n},s={...r};for(const[l,f]of Object.entries(i))l.startsWith(\"$\")?a[l.slice(1)]=f:l.startsWith(\"_\")&&(s[l.slice(1)]=f);let o;try{o=we(e,a,s)}catch(l){return g(\"span\",{class:\"error\",title:String(l),children:`{switch error: ${l.message}}`})}let u=null;for(const l of t){if(l.rawArgs===\"\"){u=l;continue}try{const f=we(l.rawArgs,a,s);if(o===f)return g(G,{children:fe(l.children)})}catch(f){return g(\"span\",{class:\"error\",title:String(f),children:`{case error: ${f.message}}`})}}return u?g(G,{children:fe(u.children)}):null}function $t(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)}function Yo({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=[];a.push({delay:$t(e),nodes:t});for(const l of n){const f=l.rawArgs?$t(l.rawArgs):0;a.push({delay:f,nodes:l.children})}const[s,o]=Z(-1);if(ve(()=>{if(s>=a.length-1)return;const l=s+1,f=a[l].delay,c=setTimeout(()=>{o(l)},f);return()=>clearTimeout(c)},[s,a.length]),s<0)return null;const u=fe(a[s].nodes);return r||i?g(\"span\",{id:i,class:r,children:u}):g(G,{children:u})}const Ti=In({stop:()=>{}});function Zo({rawArgs:e,children:t,className:n,id:r}){const i=$t(e),[a,s]=Z(0),[o,u]=Z(!1),l=Tt(()=>u(!0),[]);if(ve(()=>{if(o)return;const p=setInterval(()=>{s(h=>h+1)},i);return()=>clearInterval(p)},[i,o]),a===0&&!o)return null;const f=n?`macro-repeat ${n}`:void 0,c=g(Ti.Provider,{value:{stop:l},children:fe(t)});return f||r?g(\"span\",{id:r,class:f,children:c}):c}function Jo(){const{stop:e}=ke(Ti);return ue(()=>{e()},[e]),null}function Xo({rawArgs:e,children:t,className:n,id:r}){const i=$t(e),a=qe(null),[s,o]=Z(0),[u,l]=Z(0);ve(()=>{if(a.current){const p=a.current.textContent||\"\";o(p.length)}},[]),ve(()=>{if(s===0||u>=s)return;const p=setInterval(()=>{l(h=>h>=s?(clearInterval(p),h):h+1)},i);return()=>clearInterval(p)},[s,i]);const f=u>=s&&s>0,c=[\"macro-type\",f?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return g(\"span\",{id:r,class:c,ref:a,style:{clipPath:(s>0&&!f,void 0)},children:[g(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!f?`inset(0 ${(s-u)/s*100}% 0 0)`:void 0},children:Wi(t)}),!f&&s>0&&g(\"span\",{class:\"macro-type-cursor\"})]})}const Ni=new Map;function Di(e,t){Ni.set(e.toLowerCase(),t)}function el(e){return Ni.get(e.toLowerCase())}function tl({rawArgs:e,children:t}){const n=e.trim().replace(/[\"']/g,\"\");return ue(()=>{Di(n,t)},[]),null}function nl(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(),s=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:s}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function rl(e,t){return Object.is(e,t)?!0:typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null?JSON.stringify(e)===JSON.stringify(t):!1}function il({rawArgs:e}){k(s=>s.variables),k(s=>s.temporary);const t=ke(Ee),{target:n,expr:r}=nl(e),i=n.startsWith(\"_\"),a=n.slice(1);return ue(()=>{const s=k.getState(),o={...s.variables},u={...s.temporary};for(const[c,p]of Object.entries(t))c.startsWith(\"$\")?o[c.slice(1)]=p:c.startsWith(\"_\")&&(u[c.slice(1)]=p);let l;try{l=we(r,o,u)}catch(c){console.error(`spindle: Error in {computed ${e}}:`,c);return}const f=i?s.temporary[a]:s.variables[a];rl(f,l)||(i?s.setTemporary(a,l):s.setVariable(a,l))}),null}function al(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).trim());const a=sl(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 sl(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 ol(e,t,n){return n===\"none\"?null:n===\"%\"?`${Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function ll({rawArgs:e,className:t,id:n}){const r=k(u=>u.variables),i=k(u=>u.temporary),a=ke(Ee),s={...r},o={...i};for(const[u,l]of Object.entries(a))u.startsWith(\"$\")?s[u.slice(1)]=l:u.startsWith(\"_\")&&(o[u.slice(1)]=l);try{const{currentExpr:u,maxExpr:l,labelMode:f}=al(e),c=Number(we(u,s,o)),p=Number(we(l,s,o)),h=Math.max(0,Math.min(100,c/p*100)),_=ol(c,p,f),w=[\"macro-meter\",t].filter(Boolean).join(\" \");return g(\"div\",{class:w,id:n,children:[g(\"div\",{class:\"macro-meter-fill\",style:`width: ${h}%`}),_!=null&&g(\"span\",{class:\"macro-meter-label\",children:_})]})}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{meter error: ${u.message}}`})}}const ul=new Map;function cl(e){return ul.get(e.toLowerCase())}const Sr=document.createElement(\"i\");function zi(e){const t=\"&\"+e+\";\";Sr.innerHTML=t;const n=Sr.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function oe(e,t,n,r){const i=e.length;let a=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a<r.length;)s=r.slice(a,a+1e4),s.unshift(t,0),e.splice(...s),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(oe(e,e.length,0,t),e):t}const _n={}.hasOwnProperty;function fl(e){const t={};let n=-1;for(;++n<e.length;)hl(t,e[n]);return t}function hl(e,t){let n;for(n in t){const i=(_n.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){_n.call(i,s)||(i[s]=[]);const o=a[s];pl(i[s],Array.isArray(o)?o:o?[o]:[])}}}function pl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);oe(e,0,0,r)}function dl(e){const t={};let n=-1;for(;++n<e.length;)ml(t,e[n]);return t}function ml(e,t){let n;for(n in t){const i=(_n.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a)i[s]=a[s]}}function gl(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 _l={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Oi(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+_l[n]+\";\"}}function at(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const ye=Ne(/[A-Za-z]/),se=Ne(/[\\dA-Za-z]/),yl=Ne(/[#-'*+\\--9=?A-Z^-~]/);function yn(e){return e!==null&&(e<32||e===127)}const bn=Ne(/\\d/),bl=Ne(/[\\dA-Fa-f]/),xl=Ne(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function F(e){return e===-2||e===-1||e===32}const vl=Ne(/\\p{P}|\\p{S}/u),wl=Ne(/\\s/);function Ne(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function mt(e,t){const n=Oi(kl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),s=n.indexOf(\"/\");return r<0||s>-1&&r>s||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function kl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let s=\"\";if(a===37&&se(e.charCodeAt(n+1))&&se(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(s=String.fromCharCode(a));else if(a>55295&&a<57344){const o=e.charCodeAt(n+1);a<56320&&o>56319&&o<57344?(s=String.fromCharCode(a,o),i=1):s=\"�\"}else s=String.fromCharCode(a);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const Cr={}.hasOwnProperty,Ir=/^(https?|ircs?|mailto|xmpp)$/i,Sl=/^https?$/i;function Cl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],s=[],u=dl([{enter:{blockQuote:R,codeFenced:he,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:q,codeText:pa,content:ta,definition:Ki,definitionDestinationString:Zi,definitionLabelString:I,definitionTitleString:I,emphasis:fa,htmlFlow:ca,htmlText:Ln,image:V,label:I,link:re,listItemMarker:$,listItemValue:y,listOrdered:M,listUnordered:L,paragraph:K,reference:I,resource:Le,resourceDestinationString:Me,resourceTitleString:I,setextHeading:ra,strong:ha},exit:{atxHeading:aa,atxHeadingSequence:na,autolinkEmail:xa,autolinkProtocol:ba,blockQuote:Y,characterEscapeValue:Ke,characterReferenceMarkerHexadecimal:Mn,characterReferenceMarkerNumeric:Mn,characterReferenceValue:ya,codeFenced:d,codeFencedFence:A,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:ua,codeIndented:d,codeText:da,codeTextData:Ke,data:Ke,definition:ea,definitionDestinationString:Ji,definitionLabelString:Yi,definitionTitleString:Xi,emphasis:ma,hardBreakEscape:Fn,hardBreakTrailing:Fn,htmlFlow:Rn,htmlFlowData:Ke,htmlText:Rn,htmlTextData:Ke,image:On,label:Ge,labelText:J,lineEnding:la,link:On,listOrdered:T,listUnordered:H,paragraph:ae,reference:P,referenceString:Ie,resource:P,resourceDestinationString:Vt,resourceTitleString:Gi,setextHeading:oa,setextHeadingLineSequence:sa,setextHeadingText:ia,strong:ga,thematicBreak:_a}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:s},f={buffer:I,encode:x,getData:w,lineEndingIfNeeded:E,options:t,raw:C,resume:b,setData:_,tag:v};let c=t.defaultLineEnding;return p;function p(S){let N=-1,X=0;const pe=[];let ge=[],Se=[];for(;++N<S.length;)!c&&(S[N][1].type===\"lineEnding\"||S[N][1].type===\"lineEndingBlank\")&&(c=S[N][2].sliceSerialize(S[N][1])),(S[N][1].type===\"listOrdered\"||S[N][1].type===\"listUnordered\")&&(S[N][0]===\"enter\"?pe.push(N):h(S.slice(pe.pop(),N))),S[N][1].type===\"definition\"&&(S[N][0]===\"enter\"?(Se=ee(Se,S.slice(X,N)),X=N):(ge=ee(ge,S.slice(X,N+1)),X=N+1));ge=ee(ge,Se),ge=ee(ge,S.slice(X)),N=-1;const _e=ge;for(u.enter.null&&u.enter.null.call(f);++N<S.length;){const Bn=u[_e[N][0]],Vn=_e[N][1].type,Hn=Bn[Vn];Cr.call(Bn,Vn)&&Hn&&Hn.call({sliceSerialize:_e[N][2].sliceSerialize,...f},_e[N][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(S){const N=S.length;let X=0,pe=0,ge=!1,Se;for(;++X<N;){const _e=S[X];if(_e[1]._container)Se=void 0,_e[0]===\"enter\"?pe++:pe--;else switch(_e[1].type){case\"listItemPrefix\":{_e[0]===\"exit\"&&(Se=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{_e[0]===\"enter\"&&!pe&&(Se?Se=void 0:ge=!0);break}default:Se=void 0}}S[0][1]._loose=ge}function _(S,N){l[S]=N}function w(S){return l[S]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function v(S){n&&(_(\"lastWasTag\",!0),i[i.length-1].push(S))}function C(S){_(\"lastWasTag\"),i[i.length-1].push(S)}function z(){C(c||`\n`)}function E(){const S=i[i.length-1],N=S[S.length-1],X=N?N.charCodeAt(N.length-1):null;X===10||X===13||X===null||z()}function x(S){return w(\"ignoreEncode\")?S:Oi(S)}function P(){b()}function M(S){s.push(!S._loose),E(),v(\"<ol\"),_(\"expectFirstItem\",!0)}function L(S){s.push(!S._loose),E(),v(\"<ul\"),_(\"expectFirstItem\",!0)}function y(S){if(w(\"expectFirstItem\")){const N=Number.parseInt(this.sliceSerialize(S),10);N!==1&&v(' start=\"'+x(String(N))+'\"')}}function $(){w(\"expectFirstItem\")?v(\">\"):j(),E(),v(\"<li>\"),_(\"expectFirstItem\"),_(\"lastWasTag\")}function T(){j(),s.pop(),z(),v(\"</ol>\")}function H(){j(),s.pop(),z(),v(\"</ul>\")}function j(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&E(),v(\"</li>\"),_(\"slurpAllLineEndings\")}function R(){s.push(!1),E(),v(\"<blockquote>\")}function Y(){s.pop(),E(),v(\"</blockquote>\"),_(\"slurpAllLineEndings\")}function K(){s[s.length-1]||(E(),v(\"<p>\")),_(\"slurpAllLineEndings\")}function ae(){s[s.length-1]?_(\"slurpAllLineEndings\",!0):v(\"</p>\")}function he(){E(),v(\"<pre><code\"),_(\"fencesCount\",0)}function m(){const S=b();v(' class=\"language-'+S+'\"')}function A(){const S=w(\"fencesCount\")||0;S||(v(\">\"),_(\"slurpOneLineEnding\",!0)),_(\"fencesCount\",S+1)}function q(){E(),v(\"<pre><code>\")}function d(){const S=w(\"fencesCount\");S!==void 0&&S<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&z(),w(\"flowCodeSeenData\")&&E(),v(\"</code></pre>\"),S!==void 0&&S<2&&E(),_(\"flowCodeSeenData\"),_(\"fencesCount\"),_(\"slurpOneLineEnding\")}function V(){a.push({image:!0}),n=void 0}function re(){a.push({})}function J(S){a[a.length-1].labelId=this.sliceSerialize(S)}function Ge(){a[a.length-1].label=b()}function Ie(S){a[a.length-1].referenceId=this.sliceSerialize(S)}function Le(){I(),a[a.length-1].destination=\"\"}function Me(){I(),_(\"ignoreEncode\",!0)}function Vt(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function Gi(){a[a.length-1].title=b()}function On(){let S=a.length-1;const N=a[S],X=N.referenceId||N.labelId,pe=N.destination===void 0?r[at(X)]:N;for(n=!0;S--;)if(a[S].image){n=void 0;break}N.image?(v('<img src=\"'+mt(pe.destination,t.allowDangerousProtocol?void 0:Sl)+'\" alt=\"'),C(N.label),v('\"')):v('<a href=\"'+mt(pe.destination,t.allowDangerousProtocol?void 0:Ir)+'\"'),v(pe.title?' title=\"'+pe.title+'\"':\"\"),N.image?v(\" />\"):(v(\">\"),C(N.label),v(\"</a>\")),a.pop()}function Ki(){I(),a.push({})}function Yi(S){b(),a[a.length-1].labelId=this.sliceSerialize(S)}function Zi(){I(),_(\"ignoreEncode\",!0)}function Ji(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function Xi(){a[a.length-1].title=b()}function ea(){const S=a[a.length-1],N=at(S.labelId);b(),Cr.call(r,N)||(r[N]=a[a.length-1]),a.pop()}function ta(){_(\"slurpAllLineEndings\",!0)}function na(S){w(\"headingRank\")||(_(\"headingRank\",this.sliceSerialize(S).length),E(),v(\"<h\"+w(\"headingRank\")+\">\"))}function ra(){I(),_(\"slurpAllLineEndings\")}function ia(){_(\"slurpAllLineEndings\",!0)}function aa(){v(\"</h\"+w(\"headingRank\")+\">\"),_(\"headingRank\")}function sa(S){_(\"headingRank\",this.sliceSerialize(S).charCodeAt(0)===61?1:2)}function oa(){const S=b();E(),v(\"<h\"+w(\"headingRank\")+\">\"),C(S),v(\"</h\"+w(\"headingRank\")+\">\"),_(\"slurpAllLineEndings\"),_(\"headingRank\")}function Ke(S){C(x(this.sliceSerialize(S)))}function la(S){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){_(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){C(\" \");return}C(x(this.sliceSerialize(S)))}}function ua(S){C(x(this.sliceSerialize(S))),_(\"flowCodeSeenData\",!0)}function Fn(){v(\"<br />\")}function ca(){E(),Ln()}function Rn(){_(\"ignoreEncode\")}function Ln(){t.allowDangerousHtml&&_(\"ignoreEncode\",!0)}function fa(){v(\"<em>\")}function ha(){v(\"<strong>\")}function pa(){_(\"inCodeText\",!0),v(\"<code>\")}function da(){_(\"inCodeText\"),v(\"</code>\")}function ma(){v(\"</em>\")}function ga(){v(\"</strong>\")}function _a(){E(),v(\"<hr />\")}function Mn(S){_(\"characterReferenceType\",S.type)}function ya(S){const N=this.sliceSerialize(S),X=w(\"characterReferenceType\")?gl(N,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):zi(N);C(x(X)),_(\"characterReferenceType\")}function ba(S){const N=this.sliceSerialize(S);v('<a href=\"'+mt(N,t.allowDangerousProtocol?void 0:Ir)+'\">'),C(x(N)),v(\"</a>\")}function xa(S){const N=this.sliceSerialize(S);v('<a href=\"'+mt(\"mailto:\"+N)+'\">'),C(x(N)),v(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(u){return F(u)?(e.enter(n),o(u)):t(u)}function o(u){return F(u)&&a++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Il={tokenize:Al};function Al(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(o){return e.enter(\"paragraph\"),a(o)}function a(o){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,s(o)}function s(o){if(o===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(o);return}return D(o)?(e.consume(o),e.exit(\"chunkText\"),a):(e.consume(o),s)}}const El={tokenize:$l},Ar={tokenize:Pl};function $l(e){const t=this,n=[];let r=0,i,a,s;return o;function o(C){if(r<n.length){const z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,l)(C)}return l(C)}function u(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const z=t.events.length;let E=z,x;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){x=t.events[E][1].end;break}b(r);let P=z;for(;P<t.events.length;)t.events[P][1].end={...x},P++;return oe(t.events,E+1,0,t.events.slice(z)),t.events.length=P,l(C)}return o(C)}function l(C){if(r===n.length){if(!i)return p(C);if(i.currentConstruct&&i.currentConstruct.concrete)return _(C);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ar,f,c)(C)}function f(C){return i&&v(),b(r),p(C)}function c(C){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,_(C)}function p(C){return t.containerState={},e.attempt(Ar,h,_)(C)}function h(C){return r++,n.push([t.currentConstruct,t.containerState]),p(C)}function _(C){if(C===null){i&&v(),b(0),e.consume(C);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(C)}function w(C){if(C===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(C);return}return D(C)?(e.consume(C),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,o):(e.consume(C),w)}function I(C,z){const E=t.sliceStream(C);if(z&&E.push(null),C.previous=a,a&&(a.next=C),a=C,i.defineSkip(C.start),i.write(E),t.parser.lazy[C.start.line]){let x=i.events.length;for(;x--;)if(i.events[x][1].start.offset<s&&(!i.events[x][1].end||i.events[x][1].end.offset>s))return;const P=t.events.length;let M=P,L,y;for(;M--;)if(t.events[M][0]===\"exit\"&&t.events[M][1].type===\"chunkFlow\"){if(L){y=t.events[M][1].end;break}L=!0}for(b(r),x=P;x<t.events.length;)t.events[x][1].end={...y},x++;oe(t.events,M+1,0,t.events.slice(P)),t.events.length=x}}function b(C){let z=n.length;for(;z-- >C;){const E=n[z];t.containerState=E[1],E[0].exit.call(t,e)}n.length=C}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Pl(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Pt(e){if(e===null||te(e)||wl(e))return 1;if(vl(e))return 2}function Mt(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 xn={name:\"attention\",resolveAll:Tl,tokenize:Nl};function Tl(e,t){let n=-1,r,i,a,s,o,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},p={...e[n][1].start};Er(c,-u),Er(p,u),s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:p},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...s.start},end:{...o.end}},e[r][1].end={...s.start},e[n][1].start={...o.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",s,t],[\"exit\",s,t],[\"enter\",a,t]]),l=ee(l,Mt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,oe(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 Nl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Pt(r);let a;return s;function s(u){return a=u,e.enter(\"attentionSequence\"),o(u)}function o(u){if(u===a)return e.consume(u),o;const l=e.exit(\"attentionSequence\"),f=Pt(u),c=!f||f===2&&i||n.includes(u),p=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!p)),l._close=!!(a===42?p:p&&(f||!c)),t(u)}}function Er(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Dl={name:\"autolink\",tokenize:zl};function zl(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 ye(h)?(e.consume(h),s):h===64?n(h):l(h)}function s(h){return h===43||h===45||h===46||se(h)?(r=1,o(h)):l(h)}function o(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||se(h))&&r++<32?(e.consume(h),o):(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||yn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):yl(h)?(e.consume(h),l):n(h)}function f(h){return se(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):p(h)}function p(h){if((h===45||se(h))&&r++<63){const _=h===45?p:c;return e.consume(h),_}return n(h)}}const Bt={partial:!0,tokenize:Ol};function Ol(e,t,n){return r;function r(a){return F(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||D(a)?t(a):n(a)}}const Fi={continuation:{tokenize:Rl},exit:Ll,name:\"blockQuote\",tokenize:Fl};function Fl(e,t,n){const r=this;return i;function i(s){if(s===62){const o=r.containerState;return o.open||(e.enter(\"blockQuote\",{_container:!0}),o.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(s),e.exit(\"blockQuoteMarker\"),a}return n(s)}function a(s){return F(s)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(s),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(s))}}function Rl(e,t,n){const r=this;return i;function i(s){return F(s)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s):a(s)}function a(s){return e.attempt(Fi,t,n)(s)}}function Ll(e){e.exit(\"blockQuote\")}const Ri={name:\"characterEscape\",tokenize:Ml};function Ml(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 xl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Li={name:\"characterReference\",tokenize:Bl};function Bl(e,t,n){const r=this;let i=0,a,s;return o;function o(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,s=se,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,s=bl,f):(e.enter(\"characterReferenceValue\"),a=7,s=bn,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return s===se&&!zi(r.sliceSerialize(p))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return s(c)&&i++<a?(e.consume(c),f):n(c)}}const $r={partial:!0,tokenize:Hl},Pr={concrete:!0,name:\"codeFenced\",tokenize:Vl};function Vl(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,s=0,o;return u;function u(x){return l(x)}function l(x){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,o=x,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(x)}function f(x){return x===o?(s++,e.consume(x),f):s<3?n(x):(e.exit(\"codeFencedFenceSequence\"),F(x)?B(e,c,\"whitespace\")(x):c(x))}function c(x){return x===null||D(x)?(e.exit(\"codeFencedFence\"),r.interrupt?t(x):e.check($r,w,z)(x)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(x))}function p(x){return x===null||D(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(x)):F(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,h,\"whitespace\")(x)):x===96&&x===o?n(x):(e.consume(x),p)}function h(x){return x===null||D(x)?c(x):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),_(x))}function _(x){return x===null||D(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(x)):x===96&&x===o?n(x):(e.consume(x),_)}function w(x){return e.attempt(i,z,I)(x)}function I(x){return e.enter(\"lineEnding\"),e.consume(x),e.exit(\"lineEnding\"),b}function b(x){return a>0&&F(x)?B(e,v,\"linePrefix\",a+1)(x):v(x)}function v(x){return x===null||D(x)?e.check($r,w,z)(x):(e.enter(\"codeFlowValue\"),C(x))}function C(x){return x===null||D(x)?(e.exit(\"codeFlowValue\"),v(x)):(e.consume(x),C)}function z(x){return e.exit(\"codeFenced\"),t(x)}function E(x,P,M){let L=0;return y;function y(R){return x.enter(\"lineEnding\"),x.consume(R),x.exit(\"lineEnding\"),$}function $(R){return x.enter(\"codeFencedFence\"),F(R)?B(x,T,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):T(R)}function T(R){return R===o?(x.enter(\"codeFencedFenceSequence\"),H(R)):M(R)}function H(R){return R===o?(L++,x.consume(R),H):L>=s?(x.exit(\"codeFencedFenceSequence\"),F(R)?B(x,j,\"whitespace\")(R):j(R)):M(R)}function j(R){return R===null||D(R)?(x.exit(\"codeFencedFence\"),P(R)):M(R)}}}function Hl(e,t,n){const r=this;return i;function i(s){return s===null?n(s):(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}const Gt={name:\"codeIndented\",tokenize:ql},jl={partial:!0,tokenize:Ul};function ql(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(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?s(l):n(l)}function s(l){return l===null?u(l):D(l)?e.attempt(jl,s,u)(l):(e.enter(\"codeFlowValue\"),o(l))}function o(l){return l===null||D(l)?(e.exit(\"codeFlowValue\"),s(l)):(e.consume(l),o)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Ul(e,t,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):D(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(s)}function a(s){const o=r.events[r.events.length-1];return o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):D(s)?i(s):n(s)}}const Wl={name:\"codeText\",previous:Gl,resolve:Ql,tokenize:Kl};function Ql(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 Gl(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Kl(e,t,n){let r=0,i,a;return s;function s(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),o(c)}function o(c){return c===96?(e.consume(c),r++,o):(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)):D(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||D(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 Yl{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&&Ze(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),Ze(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ze(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);Ze(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ze(this.left,n.reverse())}}}function Ze(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 Mi(e){const t={};let n=-1,r,i,a,s,o,u,l;const f=new Yl(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,Zl(f,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(s=f.get(a),s[1].type===\"lineEnding\"||s[1].type===\"lineEndingBlank\")s[0]===\"enter\"&&(i&&(f.get(i)[1].type=\"lineEndingBlank\"),s[1].type=\"lineEnding\",i=a);else if(!(s[1].type===\"linePrefix\"||s[1].type===\"listItemIndent\"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return oe(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function Zl(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const o=s.events,u=[],l={};let f,c,p=-1,h=n,_=0,w=0;const I=[w];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(f),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++p<o.length;)o[p][0]===\"exit\"&&o[p-1][0]===\"enter\"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(w=p+1,I.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):I.pop(),p=I.length;p--;){const b=o.slice(I[p],I[p+1]),v=a.pop();u.push([v,v+b.length-1]),e.splice(v,2,b)}for(u.reverse(),p=-1;++p<u.length;)l[_+u[p][0]]=_+u[p][1],_+=u[p][1]-u[p][0]-1;return l}const Jl={resolve:eu,tokenize:tu},Xl={partial:!0,tokenize:nu};function eu(e){return Mi(e),e}function tu(e,t){let n;return r;function r(o){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(o)}function i(o){return o===null?a(o):D(o)?e.check(Xl,s,a)(o):(e.consume(o),i)}function a(o){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(o)}function s(o){return e.consume(o),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function nu(e,t,n){const r=this;return i;function i(s){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(s){if(s===null||D(s))return n(s);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function Bi(e,t,n,r,i,a,s,o,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),p):b===null||b===32||b===41||yn(b)?n(b):(e.enter(r),e.enter(s),e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),w(b))}function p(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===62?(e.exit(\"chunkString\"),e.exit(o),p(b)):b===null||b===60||D(b)?n(b):(e.consume(b),b===92?_:h)}function _(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function w(b){return!f&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(o),e.exit(s),e.exit(r),t(b)):f<l&&b===40?(e.consume(b),f++,w):b===41?(e.consume(b),f--,w):b===null||b===32||b===40||yn(b)?n(b):(e.consume(b),b===92?I:w)}function I(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function Vi(e,t,n,r,i,a){const s=this;let o=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 o>999||h===null||h===91||h===93&&!u||h===94&&!o&&\"_hiddenFootnoteSupport\"in s.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):D(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||D(h)||o++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!F(h)),h===92?p:c)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,c):c(h)}}function Hi(e,t,n,r,i,a){let s;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),s=p===40?41:p,u):n(p)}function u(p){return p===s?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),l(p))}function l(p){return p===s?(e.exit(a),u(s)):p===null?n(p):D(p)?(e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(p))}function f(p){return p===s||p===null||D(p)?(e.exit(\"chunkString\"),l(p)):(e.consume(p),p===92?c:f)}function c(p){return p===s||p===92?(e.consume(p),f):f(p)}}function et(e,t){let n;return r;function r(i){return D(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):F(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ru={name:\"definition\",tokenize:au},iu={partial:!0,tokenize:su};function au(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),s(h)}function s(h){return Vi.call(r,e,o,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function o(h){return i=at(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 te(h)?et(e,l)(h):l(h)}function l(h){return Bi(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(iu,c,c)(h)}function c(h){return F(h)?B(e,p,\"whitespace\")(h):p(h)}function p(h){return h===null||D(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function su(e,t,n){return r;function r(o){return te(o)?et(e,i)(o):n(o)}function i(o){return Hi(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(o)}function a(o){return F(o)?B(e,s,\"whitespace\")(o):s(o)}function s(o){return o===null||D(o)?t(o):n(o)}}const ou={name:\"hardBreakEscape\",tokenize:lu};function lu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return D(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const uu={name:\"headingAtx\",resolve:cu,tokenize:fu};function cu(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\"},oe(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function fu(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),s(f)}function s(f){return f===35&&r++<6?(e.consume(f),s):f===null||te(f)?(e.exit(\"atxHeadingSequence\"),o(f)):n(f)}function o(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||D(f)?(e.exit(\"atxHeading\"),t(f)):F(f)?B(e,o,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),o(f))}function l(f){return f===null||f===35||te(f)?(e.exit(\"atxHeadingText\"),o(f)):(e.consume(f),l)}}const hu=[\"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\"],Tr=[\"pre\",\"script\",\"style\",\"textarea\"],pu={concrete:!0,name:\"htmlFlow\",resolveTo:gu,tokenize:_u},du={partial:!0,tokenize:bu},mu={partial:!0,tokenize:yu};function gu(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 _u(e,t,n){const r=this;let i,a,s,o,u;return l;function l(d){return f(d)}function f(d){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(d),c}function c(d){return d===33?(e.consume(d),p):d===47?(e.consume(d),a=!0,w):d===63?(e.consume(d),i=3,r.interrupt?t:m):ye(d)?(e.consume(d),s=String.fromCharCode(d),I):n(d)}function p(d){return d===45?(e.consume(d),i=2,h):d===91?(e.consume(d),i=5,o=0,_):ye(d)?(e.consume(d),i=4,r.interrupt?t:m):n(d)}function h(d){return d===45?(e.consume(d),r.interrupt?t:m):n(d)}function _(d){const V=\"CDATA[\";return d===V.charCodeAt(o++)?(e.consume(d),o===V.length?r.interrupt?t:T:_):n(d)}function w(d){return ye(d)?(e.consume(d),s=String.fromCharCode(d),I):n(d)}function I(d){if(d===null||d===47||d===62||te(d)){const V=d===47,re=s.toLowerCase();return!V&&!a&&Tr.includes(re)?(i=1,r.interrupt?t(d):T(d)):hu.includes(s.toLowerCase())?(i=6,V?(e.consume(d),b):r.interrupt?t(d):T(d)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(d):a?v(d):C(d))}return d===45||se(d)?(e.consume(d),s+=String.fromCharCode(d),I):n(d)}function b(d){return d===62?(e.consume(d),r.interrupt?t:T):n(d)}function v(d){return F(d)?(e.consume(d),v):y(d)}function C(d){return d===47?(e.consume(d),y):d===58||d===95||ye(d)?(e.consume(d),z):F(d)?(e.consume(d),C):y(d)}function z(d){return d===45||d===46||d===58||d===95||se(d)?(e.consume(d),z):E(d)}function E(d){return d===61?(e.consume(d),x):F(d)?(e.consume(d),E):C(d)}function x(d){return d===null||d===60||d===61||d===62||d===96?n(d):d===34||d===39?(e.consume(d),u=d,P):F(d)?(e.consume(d),x):M(d)}function P(d){return d===u?(e.consume(d),u=null,L):d===null||D(d)?n(d):(e.consume(d),P)}function M(d){return d===null||d===34||d===39||d===47||d===60||d===61||d===62||d===96||te(d)?E(d):(e.consume(d),M)}function L(d){return d===47||d===62||F(d)?C(d):n(d)}function y(d){return d===62?(e.consume(d),$):n(d)}function $(d){return d===null||D(d)?T(d):F(d)?(e.consume(d),$):n(d)}function T(d){return d===45&&i===2?(e.consume(d),Y):d===60&&i===1?(e.consume(d),K):d===62&&i===4?(e.consume(d),A):d===63&&i===3?(e.consume(d),m):d===93&&i===5?(e.consume(d),he):D(d)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(du,q,H)(d)):d===null||D(d)?(e.exit(\"htmlFlowData\"),H(d)):(e.consume(d),T)}function H(d){return e.check(mu,j,q)(d)}function j(d){return e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),R}function R(d){return d===null||D(d)?H(d):(e.enter(\"htmlFlowData\"),T(d))}function Y(d){return d===45?(e.consume(d),m):T(d)}function K(d){return d===47?(e.consume(d),s=\"\",ae):T(d)}function ae(d){if(d===62){const V=s.toLowerCase();return Tr.includes(V)?(e.consume(d),A):T(d)}return ye(d)&&s.length<8?(e.consume(d),s+=String.fromCharCode(d),ae):T(d)}function he(d){return d===93?(e.consume(d),m):T(d)}function m(d){return d===62?(e.consume(d),A):d===45&&i===2?(e.consume(d),m):T(d)}function A(d){return d===null||D(d)?(e.exit(\"htmlFlowData\"),q(d)):(e.consume(d),A)}function q(d){return e.exit(\"htmlFlow\"),t(d)}}function yu(e,t,n){const r=this;return i;function i(s){return D(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a):n(s)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function bu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Bt,t,n)}}const xu={name:\"htmlText\",tokenize:vu};function vu(e,t,n){const r=this;let i,a,s;return o;function o(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),C):ye(m)?(e.consume(m),M):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,_):ye(m)?(e.consume(m),v):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),p):D(m)?(s=c,K(m)):(e.consume(m),c)}function p(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?Y(m):m===45?p(m):c(m)}function _(m){const A=\"CDATA[\";return m===A.charCodeAt(a++)?(e.consume(m),a===A.length?w:_):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),I):D(m)?(s=w,K(m)):(e.consume(m),w)}function I(m){return m===93?(e.consume(m),b):w(m)}function b(m){return m===62?Y(m):m===93?(e.consume(m),b):w(m)}function v(m){return m===null||m===62?Y(m):D(m)?(s=v,K(m)):(e.consume(m),v)}function C(m){return m===null?n(m):m===63?(e.consume(m),z):D(m)?(s=C,K(m)):(e.consume(m),C)}function z(m){return m===62?Y(m):C(m)}function E(m){return ye(m)?(e.consume(m),x):n(m)}function x(m){return m===45||se(m)?(e.consume(m),x):P(m)}function P(m){return D(m)?(s=P,K(m)):F(m)?(e.consume(m),P):Y(m)}function M(m){return m===45||se(m)?(e.consume(m),M):m===47||m===62||te(m)?L(m):n(m)}function L(m){return m===47?(e.consume(m),Y):m===58||m===95||ye(m)?(e.consume(m),y):D(m)?(s=L,K(m)):F(m)?(e.consume(m),L):Y(m)}function y(m){return m===45||m===46||m===58||m===95||se(m)?(e.consume(m),y):$(m)}function $(m){return m===61?(e.consume(m),T):D(m)?(s=$,K(m)):F(m)?(e.consume(m),$):L(m)}function T(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,H):D(m)?(s=T,K(m)):F(m)?(e.consume(m),T):(e.consume(m),j)}function H(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):D(m)?(s=H,K(m)):(e.consume(m),H)}function j(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?L(m):(e.consume(m),j)}function R(m){return m===47||m===62||te(m)?L(m):n(m)}function Y(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function K(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),ae}function ae(m){return F(m)?B(e,he,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):he(m)}function he(m){return e.enter(\"htmlTextData\"),s(m)}}const zn={name:\"labelEnd\",resolveAll:Cu,resolveTo:Iu,tokenize:Au},wu={tokenize:Eu},ku={tokenize:$u},Su={tokenize:Pu};function Cu(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&&oe(e,0,e.length,n),e}function Iu(e,t){let n=e.length,r=0,i,a,s,o;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(s){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\"&&(s=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[s][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[s-2][1].start}};return o=[[\"enter\",u,t],[\"enter\",l,t]],o=ee(o,e.slice(a+1,a+r+3)),o=ee(o,[[\"enter\",f,t]]),o=ee(o,Mt(t.parser.constructs.insideSpan.null,e.slice(a+r+4,s-3),t)),o=ee(o,[[\"exit\",f,t],e[s-2],e[s-1],[\"exit\",l,t]]),o=ee(o,e.slice(s+1)),o=ee(o,[[\"exit\",u,t]]),oe(e,a,e.length,o),e}function Au(e,t,n){const r=this;let i=r.events.length,a,s;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 o;function o(p){return a?a._inactive?c(p):(s=r.parser.defined.includes(at(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(p),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(p)}function u(p){return p===40?e.attempt(wu,f,s?f:c)(p):p===91?e.attempt(ku,f,s?l:c)(p):s?f(p):c(p)}function l(p){return e.attempt(Su,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function Eu(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 te(c)?et(e,a)(c):a(c)}function a(c){return c===41?f(c):Bi(e,s,o,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function s(c){return te(c)?et(e,u)(c):f(c)}function o(c){return n(c)}function u(c){return c===34||c===39||c===40?Hi(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return te(c)?et(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 $u(e,t,n){const r=this;return i;function i(o){return Vi.call(r,e,a,s,\"reference\",\"referenceMarker\",\"referenceString\")(o)}function a(o){return r.parser.defined.includes(at(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function Pu(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 Tu={name:\"labelStartImage\",resolveAll:zn.resolveAll,tokenize:Nu};function Nu(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(o),e.exit(\"labelImageMarker\"),a}function a(o){return o===91?(e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),s):n(o)}function s(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Du={name:\"labelStartLink\",resolveAll:zn.resolveAll,tokenize:zu};function zu(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const Kt={name:\"lineEnding\",tokenize:Ou};function Ou(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const bt={name:\"thematicBreak\",tokenize:Fu};function Fu(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),s(l)}function s(l){return i=l,o(l)}function o(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||D(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),F(l)?B(e,o,\"whitespace\")(l):o(l))}}const ie={continuation:{tokenize:Bu},exit:Hu,name:\"list\",tokenize:Mu},Ru={partial:!0,tokenize:ju},Lu={partial:!0,tokenize:Vu};function Mu(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,s=0;return o;function o(h){const _=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(_===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:bn(h)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(bt,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 bn(h)&&++s<10?(e.consume(h),u):(!r.interrupt||s<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(Bt,r.interrupt?n:f,e.attempt(Ru,p,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,p(h)}function c(h){return F(h)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(h),e.exit(\"listItemPrefixWhitespace\"),p):n(h)}function p(h){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(h)}}function Bu(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bt,i,a);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(o)}function a(o){return r.containerState.furtherBlankLines||!F(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Lu,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(ie,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o)}}function Vu(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"listItemIndent\"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(a):n(a)}}function Hu(e){e.exit(this.containerState.type)}function ju(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const s=r.events[r.events.length-1];return!F(a)&&s&&s[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Nr={name:\"setextUnderline\",resolveTo:qu,tokenize:Uu};function qu(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 s={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\",s,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=s,e.push([\"exit\",s,t]),e}function Uu(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,s(l)):n(l)}function s(l){return e.enter(\"setextHeadingLineSequence\"),o(l)}function o(l){return l===i?(e.consume(l),o):(e.exit(\"setextHeadingLineSequence\"),F(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||D(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Wu={tokenize:Qu};function Qu(e){const t=this,n=e.attempt(Bt,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Jl,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 Gu={resolveAll:qi()},Ku=ji(\"string\"),Yu=ji(\"text\");function ji(e){return{resolveAll:qi(e===\"text\"?Zu:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,s,o);return s;function s(f){return l(f)?a(f):o(f)}function o(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 p=-1;if(c)for(;++p<c.length;){const h=c[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function qi(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 Zu(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,s=-1,o=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(s=l.length;l.charCodeAt(s-1)===32;)o++,s--;if(s)break;s=-1}else if(l===-2)u=!0,o++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const l={type:n===e.length||u||o<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?s:r.start._bufferIndex+s,_index:r.start._index+a,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},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 Ju={42:ie,43:ie,45:ie,48:ie,49:ie,50:ie,51:ie,52:ie,53:ie,54:ie,55:ie,56:ie,57:ie,62:Fi},Xu={91:ru},ec={[-2]:Gt,[-1]:Gt,32:Gt},tc={35:uu,42:bt,45:[Nr,bt],60:pu,61:Nr,95:bt,96:Pr,126:Pr},nc={38:Li,92:Ri},rc={[-5]:Kt,[-4]:Kt,[-3]:Kt,33:Tu,38:Li,42:xn,60:[Dl,xu],91:Du,92:[ou,Ri],93:zn,95:xn,96:Wl},ic={null:[xn,Gu]},ac={null:[42,95]},sc={null:[]},oc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ac,contentInitial:Xu,disable:sc,document:Ju,flow:tc,flowInitial:ec,insideSpan:ic,string:nc,text:rc},Symbol.toStringTag,{value:\"Module\"}));function lc(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 s=[],o=[];const u={attempt:P(E),check:P(x),consume:v,enter:C,exit:z,interrupt:P(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:_,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c($){return s=ee(s,$),I(),s[s.length-1]!==null?[]:(M(t,0),l.events=Mt(a,l.events,l),l.events)}function p($,T){return cc(h($),T)}function h($){return uc(s,$)}function _(){const{_bufferIndex:$,_index:T,line:H,column:j,offset:R}=r;return{_bufferIndex:$,_index:T,line:H,column:j,offset:R}}function w($){i[$.line]=$.column,y()}function I(){let $;for(;r._index<s.length;){const T=s[r._index];if(typeof T==\"string\")for($=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===$&&r._bufferIndex<T.length;)b(T.charCodeAt(r._bufferIndex));else b(T)}}function b($){f=f($)}function v($){D($)?(r.line++,r.column=1,r.offset+=$===-3?2:1,y()):$!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=$}function C($,T){const H=T||{};return H.type=$,H.start=_(),l.events.push([\"enter\",H,l]),o.push(H),H}function z($){const T=o.pop();return T.end=_(),l.events.push([\"exit\",T,l]),T}function E($,T){M($,T.from)}function x($,T){T.restore()}function P($,T){return H;function H(j,R,Y){let K,ae,he,m;return Array.isArray(j)?q(j):\"tokenize\"in j?q([j]):A(j);function A(J){return Ge;function Ge(Ie){const Le=Ie!==null&&J[Ie],Me=Ie!==null&&J.null,Vt=[...Array.isArray(Le)?Le:Le?[Le]:[],...Array.isArray(Me)?Me:Me?[Me]:[]];return q(Vt)(Ie)}}function q(J){return K=J,ae=0,J.length===0?Y:d(J[ae])}function d(J){return Ge;function Ge(Ie){return m=L(),he=J,J.partial||(l.currentConstruct=J),J.name&&l.parser.constructs.disable.null.includes(J.name)?re():J.tokenize.call(T?Object.assign(Object.create(l),T):l,u,V,re)(Ie)}}function V(J){return $(he,m),R}function re(J){return m.restore(),++ae<K.length?d(K[ae]):Y}}}function M($,T){$.resolveAll&&!a.includes($)&&a.push($),$.resolve&&oe(l.events,T,l.events.length-T,$.resolve(l.events.slice(T),l)),$.resolveTo&&(l.events=$.resolveTo(l.events,l))}function L(){const $=_(),T=l.previous,H=l.currentConstruct,j=l.events.length,R=Array.from(o);return{from:j,restore:Y};function Y(){r=$,l.previous=T,l.currentConstruct=H,l.events.length=j,o=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function uc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let s;if(n===i)s=[e[n].slice(r,a)];else{if(s=e.slice(n,i),r>-1){const o=s[0];typeof o==\"string\"?s[0]=o.slice(r):s.shift()}a>0&&s.push(e[i].slice(0,a))}return s}function cc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let s;if(typeof a==\"string\")s=a;else switch(a){case-5:{s=\"\\r\";break}case-4:{s=`\n`;break}case-3:{s=`\\r\n`;break}case-2:{s=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;s=\" \";break}default:s=String.fromCharCode(a)}i=a===-2,r.push(s)}return r.join(\"\")}function fc(e){const r={constructs:fl([oc,...(e||{}).extensions||[]]),content:i(Il),defined:[],document:i(El),flow:i(Wu),lazy:{},string:i(Ku),text:i(Yu)};return r;function i(a){return s;function s(o){return lc(r,a,o)}}}function hc(e){for(;!Mi(e););return e}const Dr=/[\\0\\t\\n\\r]/g;function pc(){let e=1,t=\"\",n=!0,r;return i;function i(a,s,o){const u=[];let l,f,c,p,h;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(s||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(Dr.lastIndex=c,l=Dr.exec(a),p=l&&l.index!==void 0?l.index:a.length,h=a.charCodeAt(p),!l){t=a.slice(c);break}if(h===10&&c===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<p&&(u.push(a.slice(c,p)),e+=p-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=p+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function dc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Cl(n)(hc(fc(n).document().write(pc()(e,t,!0))))}const Yt={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function mc(){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=Yt[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=Yt[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,gc)),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\"+Yt[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function gc(e,t){return t===\"|\"?t:e}class _c{constructor(){this.map=[]}add(t,n,r){yc(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[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 yc(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 bc(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 xc(){return{flow:{null:{name:\"table\",tokenize:vc,resolveAll:wc}}}}function vc(e,t,n){const r=this;let i=0,a=0,s;return o;function o(y){let $=r.events.length-1;for(;$>-1;){const j=r.events[$][1].type;if(j===\"lineEnding\"||j===\"linePrefix\")$--;else break}const T=$>-1?r.events[$][1].type:null,H=T===\"tableHead\"||T===\"tableRow\"?x:u;return H===x&&r.parser.lazy[r.now().line]?n(y):H(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(s=!0,a+=1),f(y)}function f(y){return y===null?n(y):D(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),h):n(y):F(y)?B(e,f,\"whitespace\")(y):(a+=1,s&&(s=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),s=!0,f):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),f(y)):(e.consume(y),y===92?p:c)}function p(y){return y===92||y===124?(e.consume(y),c):c(y)}function h(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),s=!1,F(y)?B(e,_,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):_(y))}function _(y){return y===45||y===58?I(y):y===124?(s=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),w):E(y)}function w(y){return F(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,s=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||D(y)?z(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),v(y)):E(y)}function v(y){return y===45?(e.consume(y),v):y===58?(s=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),C):(e.exit(\"tableDelimiterFiller\"),C(y))}function C(y){return F(y)?B(e,z,\"whitespace\")(y):z(y)}function z(y){return y===124?_(y):y===null||D(y)?!s||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function x(y){return e.enter(\"tableRow\"),P(y)}function P(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),P):y===null||D(y)?(e.exit(\"tableRow\"),t(y)):F(y)?B(e,P,\"whitespace\")(y):(e.enter(\"data\"),M(y))}function M(y){return y===null||y===124||te(y)?(e.exit(\"data\"),P(y)):(e.consume(y),y===92?L:M)}function L(y){return y===92||y===124?(e.consume(y),M):M(y)}}function wc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,u=0,l,f,c;const p=new _c;for(;++n<e.length;){const h=e[n],_=h[1];h[0]===\"enter\"?_.type===\"tableHead\"?(o=!1,u!==0&&(zr(p,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},_.start),end:Object.assign({},_.end)},p.add(n,0,[[\"enter\",l,t]])):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,f={type:\"tableBody\",start:Object.assign({},_.start),end:Object.assign({},_.end)},p.add(n,0,[[\"enter\",f,t]])),i=_.type===\"tableDelimiterRow\"?2:f?3:1):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],c=gt(p,t,a,i,void 0,c),a=[0,0,0,0]),s[2]=n)):_.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],c=gt(p,t,a,i,void 0,c)),a=s,s=[a[1],n,0,0])):_.type===\"tableHead\"?(o=!0,u=n):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(s[0]=s[1],c=gt(p,t,a,i,n,c)):s[1]!==0&&(c=gt(p,t,s,i,n,c)),i=0):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")&&(s[3]=n)}for(u!==0&&zr(p,t,u,l,f),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]===\"enter\"&&h[1].type===\"table\"&&(h[1]._align=bc(t.events,n))}return e}function gt(e,t,n,r,i,a){const s=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",o=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Be(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Be(t.events,n[1]);if(a={type:s,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=Be(t.events,n[2]),f=Be(t.events,n[3]),c={type:o,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type=\"chunkText\",p[1].contentType=\"text\",n[3]>n[2]+1){const _=n[2]+1,w=n[3]-n[2]-1;e.add(_,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Be(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function zr(e,t,n,r,i){const a=[],s=Be(t.events,n);i&&(i.end=Object.assign({},s),a.push([\"exit\",i,t])),r.end=Object.assign({},s),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function Be(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function kc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Sc(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(s,o){let u=-1;for(;++u<s.length;)if(s[u][0]===\"enter\"&&s[u][1].type===\"strikethroughSequenceTemporary\"&&s[u][1]._close){let l=u;for(;l--;)if(s[l][0]===\"exit\"&&s[l][1].type===\"strikethroughSequenceTemporary\"&&s[l][1]._open&&s[u][1].end.offset-s[u][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[u][1].type=\"strikethroughSequence\",s[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},s[l][1].start),end:Object.assign({},s[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},s[l][1].end),end:Object.assign({},s[u][1].start)},p=[[\"enter\",f,o],[\"enter\",s[l][1],o],[\"exit\",s[l][1],o],[\"enter\",c,o]],h=o.parser.constructs.insideSpan.null;h&&oe(p,p.length,0,Mt(h,s.slice(l+1,u),o)),oe(p,p.length,0,[[\"exit\",c,o],[\"enter\",s[u][1],o],[\"exit\",s[u][1],o],[\"exit\",f,o]]),oe(s,l-1,u-l+3,p),u=l+p.length-2;break}}for(u=-1;++u<s.length;)s[u][1].type===\"strikethroughSequenceTemporary\"&&(s[u][1].type=\"data\");return s}function a(s,o,u){const l=this.previous,f=this.events;let c=0;return p;function p(_){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(_):(s.enter(\"strikethroughSequenceTemporary\"),h(_))}function h(_){const w=Pt(l);if(_===126)return c>1?u(_):(s.consume(_),c++,h);if(c<2&&!n)return u(_);const I=s.exit(\"strikethroughSequenceTemporary\"),b=Pt(_);return I._open=!b||b===2&&!!w,I._close=!w||w===2&&!!b,o(_)}}}function Cc(e){return dc(e,{allowDangerousHtml:!0,extensions:[xc(),Sc()],htmlExtensions:[mc(),kc()]})}const Ee=In({});function Ic(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Ui(i,a,t));return g(G,{children:r})}function Ui(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 s={key:t};for(const u of Array.from(r.attributes))s[u.name]=u.value;const o=Array.from(r.childNodes).map((u,l)=>Ui(u,l,n));return me(i,s,...o)}return null}function Ac(e,t){switch(e.name){case\"set\":return g(uo,{rawArgs:e.rawArgs},t);case\"computed\":return g(il,{rawArgs:e.rawArgs},t);case\"print\":return g(co,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return g(ll,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"if\":return g(fo,{branches:e.branches},t);case\"for\":return g(po,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return g(go,{children:e.children},t);case\"button\":return g(_o,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return g(yo,{className:e.className,id:e.id},t);case\"back\":return g(xo,{className:e.className,id:e.id},t);case\"forward\":return g(vo,{className:e.className,id:e.id},t);case\"restart\":return g(bo,{className:e.className,id:e.id},t);case\"quicksave\":return g(wo,{className:e.className,id:e.id},t);case\"quickload\":return g(ko,{className:e.className,id:e.id},t);case\"settings\":return g(Ao,{className:e.className,id:e.id},t);case\"saves\":return g(To,{className:e.className,id:e.id},t);case\"include\":return g(No,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return g(Do,{rawArgs:e.rawArgs},t);case\"unset\":return g(zo,{rawArgs:e.rawArgs},t);case\"textbox\":return g(Fo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return g(Lo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return g(Bo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return g(Ho,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return g(qo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return g(Uo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return g(Wo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return g(Go,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return g(Ko,{rawArgs:e.rawArgs,branches:e.branches},t);case\"timed\":return g(Yo,{rawArgs:e.rawArgs,children:e.children,branches:e.branches,className:e.className,id:e.id},t);case\"repeat\":return g(Zo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return g(Jo,{},t);case\"type\":return g(Xo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return g(tl,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=el(e.name);if(n)return g(G,{children:fe(n)});const r=cl(e.name);return r?g(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:fe(e.children)},t):g(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function vn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return g(oo,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return g(lo,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Ac(e,t);case\"html\":return me(e.tag,{key:t,...e.attributes},e.children.length>0?fe(e.children):void 0)}}function Wi(e){return e.length===0?null:e.map((t,n)=>vn(t,n))}function fe(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,s)=>vn(a,s));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const s=e[a];if(s.type===\"text\")r+=s.value;else{const o=n.length;n.push(vn(s,a)),r+=`<span data-tw=\"${o}\"></span>`}}const i=Cc(r);return Ic(i,n)}function Ec({passage:e}){const t=Qe(()=>{try{const n=ut(e.content),r=ct(n);return fe(r)}catch(n){return g(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”:\",\" \",n.message]})}},[e.content,e.name]);return g(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}const $c=\"{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}\";function Pc(){const t=k(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:$c,r=Qe(()=>{try{const i=ut(n),a=ct(i);return fe(a)}catch(i){return g(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",i.message]})}},[n]);return g(G,{children:r})}function Tc(){const e=k(r=>r.currentPassage),t=k(r=>r.storyData);if(ve(()=>{const r=i=>{i.key===\"F6\"?(i.preventDefault(),k.getState().save()):i.key===\"F9\"&&(i.preventDefault(),k.getState().load())};return document.addEventListener(\"keydown\",r),()=>document.removeEventListener(\"keydown\",r)},[]),!t||!e)return g(\"div\",{class:\"loading\",children:\"Loading...\"});const n=t.passages.get(e);return n?g(G,{children:[g(\"header\",{class:\"story-menubar\",children:g(Pc,{})}),g(\"div\",{id:\"story\",class:\"story\",children:g(Ec,{passage:n},e)})]}):g(\"div\",{class:\"error\",children:[\"Error: Passage “\",e,\"” not found.\"]})}function Nc(){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\")||\"\",o=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const p of e.querySelectorAll(\"tw-passagedata\")){const h=parseInt(p.getAttribute(\"pid\")||\"0\",10),_=p.getAttribute(\"name\")||\"\",w=(p.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(v=>v.length>0),I=p.textContent||\"\",b={pid:h,name:_,tags:w,content:I};f.set(_,b),c.set(h,b)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:o,userScript:l}}function Dc(){return{get(e){return k.getState().variables[e]},set(e,t){const n=k.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){k.getState().navigate(e)},back(){k.getState().goBack()},forward(){k.getState().goForward()},restart(){k.getState().restart()},save(e){k.getState().save(e)},load(e){k.getState().load(e)},hasSave(e){return k.getState().hasSave(e)},visited(e){return k.getState().visitCounts[e]??0},hasVisited(e){return(k.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=k.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=k.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return k.getState().renderCounts[e]??0},hasRendered(e){return(k.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=k.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=k.getState();return e.every(n=>(t[n]??0)>0)},get title(){return k.getState().storyData?.name||\"\"},get passage(){return k.getState().currentPassage},settings:it,registerClass(e,t){Bs(e,t)},saves:{setTitleGenerator(e){Hs(e)}},getActions(){return vr()},performAction(e,t){const n=io(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=k.getState().currentPassage;return k.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return so(t);if(e===\"variableChanged\"){let n={...k.getState().variables};return k.subscribe(r=>{const i={};let a=!1;const s=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const o of s)r.variables[o]!==n[o]&&(i[o]={from:n[o],to:r.variables[o]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(vr())})})})}}}function zc(){window.Story=Dc()}const Oc=/^\\$(\\w+)\\s*=\\s*(.+)$/,Or=/\\$(\\w+(?:\\.\\w+)*)/g,Fr=/\\{for\\s+(\\$\\w+)(?:\\s*,\\s*(\\$\\w+))?\\s+of\\b/g;function Qi(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const t=new Map;for(const[n,r]of Object.entries(e))t.set(n,Qi(r));return{type:\"object\",fields:t}}return{type:typeof e}}function Fc(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Oc);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,s]=i;let o;try{o=new Function(\"return (\"+s+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${s}\": ${l instanceof Error?l.message:l}`)}const u=Qi(o);t.set(a,{...u,name:a,default:o})}return t}function Rc(e){const t=new Set;let n;for(Fr.lastIndex=0;(n=Fr.exec(e))!==null;)t.add(n[1].slice(1)),n[2]&&t.add(n[2].slice(1));return t}function Lc(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 s=a;for(let o=1;o<r.length;o++){if(s.type===\"array\"&&r[o]===\"length\")return null;if(s.type!==\"object\"||!s.fields)return`Cannot access field \"${r[o]}\" on $${r.slice(0,o).join(\".\")} (type: ${s.type})`;const u=s.fields.get(r[o]);if(!u)return null;s=u}return null}function Mc(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Rc(i.content);let s;for(Or.lastIndex=0;(s=Or.exec(i.content))!==null;){const o=s[1],u=Lc(o,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Bc(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function Rr(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 s=document.createElement(\"li\");s.textContent=a,i.appendChild(s)}n.appendChild(i),e.appendChild(n)}function Lr(){const e=Nc();if(zc(),e.userCSS){const o=document.createElement(\"style\");o.textContent=e.userCSS,document.head.appendChild(o)}if(e.userScript)try{new Function(e.userScript)()}catch(o){console.error(\"spindle: Error in story JavaScript:\",o)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const o=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",u=document.getElementById(\"root\");throw u&&Rr(u,[o]),new Error(`spindle: ${o}`)}const r=Fc(n.content),i=Mc(e.passages,r);if(i.length>0){const o=document.getElementById(\"root\");throw o&&Rr(o,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=Bc(r),k.getState().init(e,t),Ai();for(const[,o]of e.passages)if(o.tags.includes(\"widget\")){const u=ut(o.content),l=ct(u);for(const f of l)if(f.type===\"macro\"&&f.name===\"widget\"&&f.rawArgs){const c=f.rawArgs.trim().replace(/[\"']/g,\"\");Di(c,f.children)}}let a=\"\";k.subscribe(o=>{o.currentPassage!==a&&(a=o.currentPassage,ao())});const s=document.getElementById(\"root\");if(!s)throw new Error('spindle: No <div id=\"root\"> element found.');He(g(Tc,{}),s)}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Lr):Lr();</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{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.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}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{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}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding: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-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{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-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.2.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 s of a.addedNodes)s.tagName===\"LINK\"&&s.rel===\"modulepreload\"&&r(s)}).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 ut,F,ri,Re,ir,ii,ai,si,On,cn,fn,oi,Ct={},It=[],Ha=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ct=Array.isArray;function xe(e,t){for(var n in t)e[n]=t[n];return e}function Rn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ge(e,t,n){var r,i,a,s={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?ut.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return nt(e,s,r,i,null)}function nt(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??++ri,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(a),a}function qa(){return{current:null}}function G(e){return e.children}function ve(e,t){this.props=e,this.context=t}function Ue(e,t){if(t==null)return e.__?Ue(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\"?Ue(e):null}function Ua(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=xe({},t);a.__v=t.__v+1,F.vnode&&F.vnode(a),Ln(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ue(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,fi(r,a,i),t.__e=t.__=null,a.__e!=n&&li(a)}}function li(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}),li(e)}function hn(e){(!e.__d&&(e.__d=!0)&&Re.push(e)&&!At.__r++||ir!=F.debounceRendering)&&((ir=F.debounceRendering)||ii)(At)}function At(){for(var e,t=1;Re.length;)Re.length>t&&Re.sort(ai),e=Re.shift(),t=Re.length,Ua(e);At.__r=0}function ui(e,t,n,r,i,a,s,o,u,l,f){var c,d,h,_,w,I,b,v=r&&r.__k||It,C=t.length;for(u=ja(n,t,v,u,C),c=0;c<C;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&v[h.__i]||Ct,h.__i=c,I=Ln(e,h,d,i,a,s,o,u,l,f),_=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Mn(d.ref,null,h),f.push(h.ref,h.__c||_,h)),w==null&&_!=null&&(w=_),(b=!!(4&h.__u))||d.__k===h.__k?u=ci(h,u,e,b):typeof h.type==\"function\"&&I!==void 0?u=I:_&&(u=_.nextSibling),h.__u&=-7);return n.__e=w,u}function ja(e,t,n,r,i){var a,s,o,u,l,f=n.length,c=f,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(s=t[a])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[a]=nt(null,s,null,null,null):ct(s)?s=e.__k[a]=nt(G,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[a]=nt(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,u=a+d,s.__=e,s.__b=e.__b+1,o=null,(l=s.__i=Wa(s,n,u,c))!=-1&&(c--,(o=n[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(i>f?d--:i<f&&d++),typeof s.type!=\"function\"&&(s.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,s.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(o=n[a])!=null&&(2&o.__u)==0&&(o.__e==r&&(r=Ue(o)),di(o,o));return r}function ci(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=ci(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ue(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ae(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(ct(e)?e.some(function(n){Ae(n,t)}):t.push(e)),t}function Wa(e,t,n,r){var i,a,s,o=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&o==null||f&&o==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[s=i>=0?i--:a++])!=null&&(2&l.__u)==0&&o==l.key&&u==l.type)return s}return-1}function ar(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Ha.test(t)?n:n+\"px\"}function pt(e,t,n,r,i){var a,s;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||ar(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||ar(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(si,\"$1\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=On,e.addEventListener(t,a?fn:cn,a)):e.removeEventListener(t,a?fn:cn,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 sr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=On++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function Ln(e,t,n,r,i,a,s,o,u,l){var f,c,d,h,_,w,I,b,v,C,z,E,x,$,M,L=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[o=t.__e=n.__e]),(f=F.__b)&&f(t);e:if(typeof L==\"function\")try{if(b=t.props,v=\"prototype\"in L&&L.prototype.render,C=(f=L.contextType)&&r[f.__c],z=f?C?C.props.value:f.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(v?t.__c=c=new L(b,z):(t.__c=c=new ve(b,z),c.constructor=L,c.render=Ga),C&&C.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),v&&c.__s==null&&(c.__s=c.state),v&&L.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=xe({},c.__s)),xe(c.__s,L.getDerivedStateFromProps(b,c.__s))),h=c.props,_=c.state,c.__v=t,d)v&&L.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),v&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(v&&L.getDerivedStateFromProps==null&&b!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,z),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,z)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),It.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,z),v&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,_,w)})}if(c.context=z,c.props=b,c.__P=e,c.__e=!1,E=F.__r,x=0,v)c.state=c.__s,c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),It.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++x<25);c.state=c.__s,c.getChildContext!=null&&(r=xe(xe({},r),c.getChildContext())),v&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,_)),$=f!=null&&f.type===G&&f.key==null?hi(f.props.children):f,o=ui(e,ct($)?$:[$],t,n,r,i,a,s,o,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(M=a.length;M--;)Rn(a[M]);dn(t)}else t.__e=n.__e,t.__k=n.__k,y.then||dn(t);F.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=Qa(n.__e,t,n,r,i,a,s,u,l);return(f=F.diffed)&&f(t),128&t.__u?void 0:o}function dn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(dn))}function fi(e,t,n){for(var r=0;r<n.length;r++)Mn(n[r],n[++r],n[++r]);F.__c&&F.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){F.__e(a,i.__v)}})}function hi(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ct(e)?e.map(hi):xe({},e)}function Qa(e,t,n,r,i,a,s,o,u){var l,f,c,d,h,_,w,I=n.props||Ct,b=t.props,v=t.type;if(v==\"svg\"?i=\"http://www.w3.org/2000/svg\":v==\"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==!!v&&(v?h.localName==v:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(b);e=document.createElementNS(i,v,b.is&&b),o&&(F.__m&&F.__m(t,a),o=!1),a=null}if(v==null)I===b||o&&e.data==b||(e.data=b);else{if(a=a&&ut.call(e.childNodes),!o&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(h=e.attributes[l]).name]=h.value;for(l in I)h=I[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||pt(e,l,null,h,i);for(l in b)h=b[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?_=h:l==\"checked\"?w=h:o&&typeof h!=\"function\"||I[l]===h||pt(e,l,h,I[l],i);if(f)o||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ui(t.type==\"template\"?e.content:e,ct(d)?d:[d],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,s,a?a[0]:n.__k&&Ue(n,0),o,u),a!=null)for(l=a.length;l--;)Rn(a[l]);o||(l=\"value\",v==\"progress\"&&_==null?e.removeAttribute(\"value\"):_!=null&&(_!==e[l]||v==\"progress\"&&!_||v==\"option\"&&_!=I[l])&&pt(e,l,_,I[l],i),l=\"checked\",w!=null&&w!=e[l]&&pt(e,l,w,I[l],i))}return e}function Mn(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){F.__e(i,n)}}function di(e,t,n){var r,i;if(F.unmount&&F.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Mn(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){F.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&di(r[i],t,n||typeof e.type!=\"function\");n||Rn(e.__e),e.__c=e.__=e.__e=void 0}function Ga(e,t,n){return this.constructor(e,n)}function je(e,t,n){var r,i,a,s;t==document&&(t=document.documentElement),F.__&&F.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],s=[],Ln(t,e=(!r&&n||t).__k=ge(G,null,[e]),i||Ct,Ct,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?ut.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,s),fi(a,e,s)}function pi(e,t){je(e,t,pi)}function Ka(e,t,n){var r,i,a,s,o=xe({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(o.children=arguments.length>3?ut.call(arguments,2):n),nt(e.type,o,r||e.key,i||e.ref,null)}function Bn(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(s){s.__e=!0,hn(s)})},this.sub=function(a){r.add(a);var s=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),s&&s.call(a)}}),n.children}return t.__c=\"__cC\"+oi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}ut=It.slice,F={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(o){e=o}throw e}},ri=0,ve.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=xe({},this.state),typeof e==\"function\"&&(e=e(xe({},n),this.props)),e&&xe(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),hn(this))},ve.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),hn(this))},ve.prototype.render=G,Re=[],ii=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ai=function(e,t){return e.__v.__b-t.__v.__b},At.__r=0,si=/(PointerCapture)$|Capture$/i,On=0,cn=sr(!1),fn=sr(!0),oi=0;var Ya=0;function g(e,t,n,r,i,a){t||(t={});var s,o,u=t;if(\"ref\"in u)for(o in u={},t)o==\"ref\"?s=t[o]:u[o]=t[o];var l={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ya,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(s=e.defaultProps))for(o in s)u[o]===void 0&&(u[o]=s[o]);return F.vnode&&F.vnode(l),l}var $e,j,en,or,We=0,mi=[],Q=F,lr=Q.__b,ur=Q.__r,cr=Q.diffed,fr=Q.__c,hr=Q.unmount,dr=Q.__;function Ke(e,t){Q.__h&&Q.__h(j,e,We||t),We=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return We=1,Vn(bi,e)}function Vn(e,t,n){var r=Ke($e++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):bi(void 0,t),function(o){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,o);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(o,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,o,u,l);var c=r.__c.props!==o;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,o,u,l)||c};j.__f=!0;var a=j.shouldComponentUpdate,s=j.componentWillUpdate;j.componentWillUpdate=function(o,u,l){if(this.__e){var f=a;a=void 0,i(o,u,l),a=f}s&&s.call(this,o,u,l)},j.shouldComponentUpdate=i}return r.__N||r.__}function we(e,t){var n=Ke($e++,3);!Q.__s&&Hn(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function ce(e,t){var n=Ke($e++,4);!Q.__s&&Hn(n.__H,t)&&(n.__=e,n.u=t,j.__h.push(n))}function Qe(e){return We=5,Ye(function(){return{current:e}},[])}function gi(e,t,n){We=6,ce(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 Ye(e,t){var n=Ke($e++,7);return Hn(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Mt(e,t){return We=8,Ye(function(){return e},t)}function Se(e){var t=j.context[e.__c],n=Ke($e++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(j)),t.props.value):e.__}function _i(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function yi(){var e=Ke($e++,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 Za(){for(var e;e=mi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(xt),t.__h.some(pn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){j=null,lr&&lr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),dr&&dr(e,t)},Q.__r=function(e){ur&&ur(e),$e=0;var t=(j=e.__c).__H;t&&(en===j?(t.__h=[],j.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(xt),t.__h.some(pn),t.__h=[],$e=0)),en=j},Q.diffed=function(e){cr&&cr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(mi.push(t)!==1&&or===Q.requestAnimationFrame||((or=Q.requestAnimationFrame)||Ja)(Za)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),en=j=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(xt),n.__h=n.__h.filter(function(r){return!r.__||pn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),fr&&fr(e,t)},Q.unmount=function(e){hr&&hr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{xt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var pr=typeof requestAnimationFrame==\"function\";function Ja(e){var t,n=function(){clearTimeout(r),pr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);pr&&(t=requestAnimationFrame(n))}function xt(e){var t=j,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),j=t}function pn(e){var t=j;e.__c=e.__(),j=t}function Hn(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function bi(e,t){return typeof t==\"function\"?t(e):t}const mr=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,o={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,o);return o},Xa=(e=>e?mr(e):mr);function xi(e,t){for(var n in t)e[n]=t[n];return e}function mn(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 vi(e,t){var n=t(),r=Z({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ce(function(){i.__=n,i.u=t,tn(i)&&a({t:i})},[e,n,t]),we(function(){return tn(i)&&a({t:i}),e(function(){tn(i)&&a({t:i})})},[e]),n}function tn(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 wi(e){e()}function ki(e){return e}function Si(){return[!1,wi]}var Ci=ce;function gn(e,t){this.props=e,this.context=t}function es(e,t){function n(i){var a=this.props.ref,s=a==i.ref;return!s&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!s:mn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,ge(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(gn.prototype=new ve).isPureReactComponent=!0,gn.prototype.shouldComponentUpdate=function(e,t){return mn(this.props,e)||mn(this.state,t)};var gr=F.__b;F.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),gr&&gr(e)};var ts=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ns(e){function t(n){var r=xi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ts,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var _r=function(e,t){return e==null?null:Ae(Ae(e).map(t))},rs={map:_r,forEach:_r,count:function(e){return e?Ae(e).length:0},only:function(e){var t=Ae(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ae},is=F.__e;F.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}is(e,t,n,r)};var yr=F.unmount;function Ii(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=xi({},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 Ii(r,t,n)})),e}function Ai(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Ai(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 vt(){this.__u=0,this.o=null,this.__b=null}function Ei(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function as(e){var t,n,r,i=null;function a(s){if(t||(t=e()).then(function(o){o&&(i=o.default||o),r=!0},function(o){n=o,r=!0}),n)throw n;if(!r)throw t;return i?ge(i,s):null}return a.displayName=\"Lazy\",a.__f=!0,a}function tt(){this.i=null,this.l=null}F.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),yr&&yr(e)},(vt.prototype=new ve).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ei(r.__v),a=!1,s=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=s;var o=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Ai(l,l.__c.__P,l.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=o,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(s,s)},vt.prototype.componentWillUnmount=function(){this.o=[]},vt.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]=Ii(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&ge(G,null,e.fallback);return i&&(i.__u&=-33),[ge(G,null,t.__a?null:e.children),i]};var br=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 os(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){je(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)}}}je(ge(ss,{context:t.context},e.__v),t.v)}function ls(e,t){var n=ge(os,{__v:e,h:t});return n.containerInfo=t,n}(tt.prototype=new ve).__a=function(e){var t=this,n=Ei(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),br(t,e,r)):i()};n?n(a):a()}},tt.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ae(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},tt.prototype.componentDidUpdate=tt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){br(e,n,t)})};var Pi=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,us=/^(?: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]/,cs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,fs=/[A-Z0-9]/g,hs=typeof document<\"u\",ds=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function ps(e,t,n){return t.__k==null&&(t.textContent=\"\"),je(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ms(e,t,n){return pi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}ve.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(ve.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var xr=F.event;function gs(){}function _s(){return this.cancelBubble}function ys(){return this.defaultPrevented}F.event=function(e){return xr&&(e=xr(e)),e.persist=gs,e.isPropagationStopped=_s,e.isDefaultPrevented=ys,e.nativeEvent=e};var qn,bs={enumerable:!1,configurable:!0,get:function(){return this.class}},vr=F.vnode;F.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var s in n){var o=n[s];if(!(s===\"value\"&&\"defaultValue\"in n&&o==null||hs&&s===\"children\"&&r===\"noscript\"||s===\"class\"||s===\"className\")){var u=s.toLowerCase();s===\"defaultValue\"&&\"value\"in n&&n.value==null?s=\"value\":s===\"download\"&&o===!0?o=\"\":u===\"translate\"&&o===\"no\"?o=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?s=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ds(n.type)?u===\"onfocus\"?s=\"onfocusin\":u===\"onblur\"?s=\"onfocusout\":cs.test(s)&&(s=u):u=s=\"oninput\":a&&us.test(s)?s=s.replace(fs,\"-$&\").toLowerCase():o===null&&(o=void 0),u===\"oninput\"&&i[s=u]&&(s=\"oninputCapture\"),i[s]=o}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ae(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ae(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\",bs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Pi,vr&&vr(e)};var wr=F.__r;F.__r=function(e){wr&&wr(e),qn=e.__c};var kr=F.diffed;F.diffed=function(e){kr&&kr(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),qn=null};var xs={ReactCurrentDispatcher:{current:{readContext:function(e){return qn.__n[e.__c].props.value},useCallback:Mt,useContext:Se,useDebugValue:_i,useDeferredValue:ki,useEffect:we,useId:yi,useImperativeHandle:gi,useInsertionEffect:Ci,useLayoutEffect:ce,useMemo:Ye,useReducer:Vn,useRef:Qe,useState:Z,useSyncExternalStore:vi,useTransition:Si}}};function vs(e){return ge.bind(null,e)}function Bt(e){return!!e&&e.$$typeof===Pi}function ws(e){return Bt(e)&&e.type===G}function ks(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ss(e){return Bt(e)?Ka.apply(null,arguments):e}function Cs(e){return!!e.__k&&(je(null,e),!0)}function Is(e){return e&&(e.base||e.nodeType===1&&e)||null}var As=function(e,t){return e(t)},Es=function(e,t){return e(t)},Ps=G,$s=Bt,mt={useState:Z,useId:yi,useReducer:Vn,useEffect:we,useLayoutEffect:ce,useInsertionEffect:Ci,useTransition:Si,useDeferredValue:ki,useSyncExternalStore:vi,startTransition:wi,useRef:Qe,useImperativeHandle:gi,useMemo:Ye,useCallback:Mt,useContext:Se,useDebugValue:_i,version:\"18.3.1\",Children:rs,render:ps,hydrate:ms,unmountComponentAtNode:Cs,createPortal:ls,createElement:ge,createContext:Bn,createFactory:vs,cloneElement:Ss,createRef:qa,Fragment:G,isValidElement:Bt,isElement:$s,isFragment:ws,isMemo:ks,findDOMNode:Is,Component:ve,PureComponent:gn,memo:es,forwardRef:ns,flushSync:Es,unstable_batchedUpdates:As,StrictMode:Ps,Suspense:vt,SuspenseList:tt,lazy:as,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:xs};const Ts=e=>e;function Ns(e,t=Ts){const n=mt.useSyncExternalStore(e.subscribe,mt.useCallback(()=>t(e.getState()),[e,t]),mt.useCallback(()=>t(e.getInitialState()),[e,t]));return mt.useDebugValue(n),n}const Ds=e=>{const t=Xa(e),n=r=>Ns(t,r);return Object.assign(n,t),n},zs=(e=>Ds);var $i=Symbol.for(\"immer-nothing\"),Sr=Symbol.for(\"immer-draftable\"),ne=Symbol.for(\"immer-state\");function me(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var oe=Object,Ge=oe.getPrototypeOf,Et=\"constructor\",Vt=\"prototype\",_n=\"configurable\",Pt=\"enumerable\",wt=\"writable\",it=\"value\",Te=e=>!!e&&!!e[ne];function Ee(e){return e?Ti(e)||qt(e)||!!e[Sr]||!!e[Et]?.[Sr]||Ut(e)||jt(e):!1}var Fs=oe[Vt][Et].toString(),Cr=new WeakMap;function Ti(e){if(!e||!Un(e))return!1;const t=Ge(e);if(t===null||t===oe[Vt])return!0;const n=oe.hasOwnProperty.call(t,Et)&&t[Et];if(n===Object)return!0;if(!He(n))return!1;let r=Cr.get(n);return r===void 0&&(r=Function.toString.call(n),Cr.set(n,r)),r===Fs}function Ht(e,t,n=!0){ft(e)===0?(n?Reflect.ownKeys(e):oe.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function ft(e){const t=e[ne];return t?t.type_:qt(e)?1:Ut(e)?2:jt(e)?3:0}var Ir=(e,t,n=ft(e))=>n===2?e.has(t):oe[Vt].hasOwnProperty.call(e,t),yn=(e,t,n=ft(e))=>n===2?e.get(t):e[t],$t=(e,t,n,r=ft(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 qt=Array.isArray,Ut=e=>e instanceof Map,jt=e=>e instanceof Set,Un=e=>typeof e==\"object\",He=e=>typeof e==\"function\",nn=e=>typeof e==\"boolean\";function Rs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ie=e=>e.copy_||e.base_,jn=e=>e.modified_?e.copy_:e.base_;function bn(e,t){if(Ut(e))return new Map(e);if(jt(e))return new Set(e);if(qt(e))return Array[Vt].slice.call(e);const n=Ti(e);if(t===!0||t===\"class_only\"&&!n){const r=oe.getOwnPropertyDescriptors(e);delete r[ne];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[wt]===!1&&(o[wt]=!0,o[_n]=!0),(o.get||o.set)&&(r[s]={[_n]:!0,[wt]:!0,[Pt]:o[Pt],[it]:e[s]})}return oe.create(Ge(e),r)}else{const r=Ge(e);if(r!==null&&n)return{...e};const i=oe.create(r);return oe.assign(i,e)}}function Wn(e,t=!1){return Wt(e)||Te(e)||!Ee(e)||(ft(e)>1&&oe.defineProperties(e,{set:gt,add:gt,clear:gt,delete:gt}),oe.freeze(e),t&&Ht(e,(n,r)=>{Wn(r,!0)},!1)),e}function Ls(){me(2)}var gt={[it]:Ls};function Wt(e){return e===null||!Un(e)?!0:oe.isFrozen(e)}var Tt=\"MapSet\",xn=\"Patches\",Ar=\"ArrayMethods\",Ni={};function Le(e){const t=Ni[e];return t||me(0,e),t}var Er=e=>!!Ni[e],at,Di=()=>at,Ms=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Er(Tt)?Le(Tt):void 0,arrayMethodsPlugin_:Er(Ar)?Le(Ar):void 0});function Pr(e,t){t&&(e.patchPlugin_=Le(xn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function vn(e){wn(e),e.drafts_.forEach(Bs),e.drafts_=null}function wn(e){e===at&&(at=e.parent_)}var $r=e=>at=Ms(at,e);function Bs(e){const t=e[ne];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Tr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ne].modified_&&(vn(t),me(4)),Ee(e)&&(e=Nr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ne].base_,e,t)}else e=Nr(t,n);return Vs(t,e,!0),vn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==$i?e:void 0}function Nr(e,t){if(Wt(t))return t;const n=t[ne];if(!n)return Nt(t,e.handledSet_,e);if(!Qt(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);Oi(n,e)}return n.copy_}function Vs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Wn(t,n)}function zi(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Qt=(e,t)=>e.scope_===t,Hs=[];function Fi(e,t,n,r){const i=Ie(e),a=e.type_;if(r!==void 0&&yn(i,r,a)===t){$t(i,r,n,a);return}if(!e.draftLocations_){const o=e.draftLocations_=new Map;Ht(i,(u,l)=>{if(Te(l)){const f=o.get(l)||[];f.push(u),o.set(l,f)}})}const s=e.draftLocations_.get(t)??Hs;for(const o of s)$t(i,o,n,a)}function qs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Qt(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=jn(a);Fi(e,a.draft_??a,s,n),Oi(a,i)})}function Oi(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)}zi(e)}}function Us(e,t,n){const{scope_:r}=e;if(Te(n)){const i=n[ne];Qt(i,r)&&i.callbacks_.push(function(){kt(e);const s=jn(i);Fi(e,n,s,t)})}else Ee(n)&&e.callbacks_.push(function(){const a=Ie(e);e.type_===3?a.has(n)&&Nt(n,r.handledSet_,r):yn(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Nt(yn(e.copy_,t,e.type_),r.handledSet_,r)})}function Nt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Te(e)||t.has(e)||!Ee(e)||Wt(e)||(t.add(e),Ht(e,(r,i)=>{if(Te(i)){const a=i[ne];if(Qt(a,n)){const s=jn(a);$t(e,r,s,e.type_),zi(a)}}else Ee(i)&&Nt(i,t,n)})),e}function js(e,t){const n=qt(e),r={type_:n?1:0,scope_:t?t.scope_:Di(),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=Dt;n&&(i=[r],a=st);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var Dt={get(e,t){if(t===ne)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Ie(e);if(!Ir(i,t,e.type_))return Ws(e,i,t);const a=i[t];if(e.finalized_||!Ee(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Rs(t))return a;if(a===rn(e.base_,t)){kt(e);const s=e.type_===1?+t:t,o=Sn(e.scope_,a,e,s);return e.copy_[s]=o}return a},has(e,t){return t in Ie(e)},ownKeys(e){return Reflect.ownKeys(Ie(e))},set(e,t,n){const r=Ri(Ie(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=rn(Ie(e),t),a=i?.[ne];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Os(n,i)&&(n!==void 0||Ir(e.base_,t,e.type_)))return!0;kt(e),kn(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),Us(e,t,n)),!0},deleteProperty(e,t){return kt(e),rn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),kn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ie(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[wt]:!0,[_n]:e.type_!==1||t!==\"length\",[Pt]:r[Pt],[it]:n[t]}},defineProperty(){me(11)},getPrototypeOf(e){return Ge(e.base_)},setPrototypeOf(){me(12)}},st={};for(let e in Dt){let t=Dt[e];st[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}st.deleteProperty=function(e,t){return st.set.call(this,e,t,void 0)};st.set=function(e,t,n){return Dt.set.call(this,e[0],t,n,e[0])};function rn(e,t){const n=e[ne];return(n?Ie(n):e)[t]}function Ws(e,t,n){const r=Ri(t,n);return r?it in r?r[it]:r.get?.call(e.draft_):void 0}function Ri(e,t){if(!(t in e))return;let n=Ge(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ge(n)}}function kn(e){e.modified_||(e.modified_=!0,e.parent_&&kn(e.parent_))}function kt(e){e.copy_||(e.assigned_=new Map,e.copy_=bn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Qs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(He(t)&&!He(n)){const a=n;n=t;const s=this;return function(u=a,...l){return s.produce(u,f=>n.call(this,f,...l))}}He(n)||me(6),r!==void 0&&!He(r)&&me(7);let i;if(Ee(t)){const a=$r(this),s=Sn(a,t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?vn(a):wn(a)}return Pr(a,r),Tr(i,a)}else if(!t||!Un(t)){if(i=n(t),i===void 0&&(i=t),i===$i&&(i=void 0),this.autoFreeze_&&Wn(i,!0),r){const a=[],s=[];Le(xn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:s}),r(a,s)}return i}else me(1,t)},this.produceWithPatches=(t,n)=>{if(He(t))return(s,...o)=>this.produceWithPatches(s,u=>t(u,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},nn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),nn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),nn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ee(e)||me(8),Te(e)&&(e=Gs(e));const t=$r(this),n=Sn(t,e,void 0);return n[ne].isManual_=!0,wn(t),n}finishDraft(e,t){const n=e&&e[ne];(!n||!n.isManual_)&&me(9);const{scope_:r}=n;return Pr(r,t),Tr(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=Le(xn).applyPatches_;return Te(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Sn(e,t,n,r){const[i,a]=Ut(t)?Le(Tt).proxyMap_(t,n):jt(t)?Le(Tt).proxySet_(t,n):js(t,n);return(n?.scope_??Di()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?qs(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 Gs(e){return Te(e)||me(10,e),Li(e)}function Li(e){if(!Ee(e)||Wt(e))return e;const t=e[ne];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=bn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=bn(e,!0);return Ht(n,(i,a)=>{$t(n,i,Li(a))},r),t&&(t.finalized_=!1),n}var Ks=new Qs,Ys=Ks.produce;const Zs=e=>(t,n,r)=>(r.setState=(i,a,...s)=>{const o=typeof i==\"function\"?Ys(i):i;return t(o,a,...s)},e(r.setState,n,r)),Js=Zs,Xs=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\"]),eo=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function to(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 Dr(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 zr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;const s=i;for(;i<e.length&&/[a-zA-Z0-9_-]/.test(e[i]);)i++;if(i>s){const o=e.slice(s,i);a===\".\"?n.push(o):r=o}}return{className:n.join(\" \"),id:r,endIdx:i}}function no(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 s=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(s,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]===\"[\"){i(n);const a=n;n+=2;let s,o;if(e[n]===\".\"||e[n]===\"#\"){const _=zr(e,n);s=_.className||void 0,o=_.id||void 0,n=_.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}=to(f),h={type:\"link\",display:c,target:d,start:a,end:n};s&&(h.className=s),o&&(h.id=o),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let s=e[n+1],o,u;if(s===\".\"||s===\"#\"){i(n);const l=zr(e,n+1);o=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 _={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),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 _={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),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 _=e.slice(h,n);n++;const{name:w,rawArgs:I,isClose:b}=Dr(_),v={type:\"macro\",name:w,rawArgs:I,isClose:b,start:a,end:n};o&&(v.className=o),u&&(v.id=u),t.push(v),r=n;continue}n=a+1,r=a;continue}if(s===\"$\"){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(s===\"_\"){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(s!==void 0&&(s===\"/\"||/[a-zA-Z]/.test(s))){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:_}=Dr(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:_,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let s=n+1;const o=e[s]===\"/\";o&&s++;const u=s;for(;s<e.length&&/[a-zA-Z0-9]/.test(e[s]);)s++;const l=e.slice(u,s).toLowerCase();if(l&&Xs.has(l))if(o){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:s}),r=s,n=s;continue}}else{const f=no(e,s);s=f.endIdx;let c=eo.has(l);if(e[s]===\"/\"&&(c=!0,s++),e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:s}),r=s,n=s;continue}}n++;continue}n++}return i(e.length),t}const ro=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Fr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},io=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 a={type:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);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 s=n[n.length-1];if(s.node.type!==\"html\"||s.node.tag!==i.tag){const o=s.node.type===\"html\"?`</${s.node.tag}>`:`{/${s.node.name}}`;throw new Error(`Expected ${o} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(s.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 s=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(Fr[i.name]){const a=Fr[i.name],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),s.branches.push(o);break}if(ro.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(io.has(i.name)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),a.branches=[s]}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}}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}const Or=new Map;function Mi(e){return e.replace(/\\$(\\w+)/g,'variables[\"$1\"]').replace(/\\b_(\\w+)/g,'temporary[\"$1\"]')}const ao=\"const {visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll}=__fns;\";function Bi(e,t){let n=Or.get(e);return n||(n=new Function(\"variables\",\"temporary\",\"__fns\",ao+t),Or.set(e,n)),n}function Vi(){const e=k.getState(),{visitCounts:t,renderCounts:n}=e,r=c=>t[c]??0,i=c=>r(c)>0,a=(...c)=>c.some(d=>r(d)>0),s=(...c)=>c.every(d=>r(d)>0),o=c=>n[c]??0;return{visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:s,rendered:o,hasRendered:c=>o(c)>0,hasRenderedAny:(...c)=>c.some(d=>o(d)>0),hasRenderedAll:(...c)=>c.every(d=>o(d)>0)}}function ke(e,t,n){const i=`return (${Mi(e)});`;return Bi(i,i)(t,n,Vi())}function Me(e,t,n){const r=Mi(e);Bi(\"exec:\"+r,r)(t,n,Vi())}const so=\"spindle\",oo=1;let _t=null,an=null;function De(){return an||(an={saves:new Map,playthroughs:new Map,meta:new Map}),an}function lo(){return _t||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(_t=new Promise((e,t)=>{const n=indexedDB.open(so,oo);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)}),_t))}function ze(e,t){return lo().then(n=>n.transaction(e,t).objectStore(e))}function Fe(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function Gt(e){try{const t=await ze(\"saves\",\"readwrite\");await Fe(t.put(e))}catch{De().saves.set(e.meta.id,e)}}async function Kt(e){try{const t=await ze(\"saves\",\"readonly\");return await Fe(t.get(e))??void 0}catch{return De().saves.get(e)}}async function uo(e){try{const t=await ze(\"saves\",\"readwrite\");await Fe(t.delete(e))}catch{De().saves.delete(e)}}async function co(e){try{const n=(await ze(\"saves\",\"readonly\")).index(\"ifid\");return await Fe(n.getAll(e))??[]}catch{return[...De().saves.values()].filter(t=>t.meta.ifid===e)}}async function Hi(e){try{const t=await ze(\"playthroughs\",\"readwrite\");await Fe(t.put(e))}catch{De().playthroughs.set(e.id,e)}}async function Qn(e){try{const n=(await ze(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Fe(n.getAll(e))??[]}catch{return[...De().playthroughs.values()].filter(t=>t.ifid===e)}}async function Gn(e){try{const t=await ze(\"meta\",\"readonly\"),n=await Fe(t.get(e));return n?n.value:void 0}catch{return De().meta.get(e)}}async function qi(e,t){try{const n=await ze(\"meta\",\"readwrite\");await Fe(n.put({key:e,value:t}))}catch{De().meta.set(e,t)}}const Ui=new Map,Yt=new Map;function fo(e,t){Ui.set(e,t),Yt.set(t,e)}function ho(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function W(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 o=[];t.set(i,o);for(let u=0;u<r.length;u++)o[u]=n(r[u]);return o}const a=i.constructor;if(Yt.get(a)!==void 0){const o=Object.create(Object.getPrototypeOf(i));t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}if(ho(r)||typeof r==\"object\"){const o={};t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}return r}return n(e)}const Cn=\"__spindle_class__\",In=\"__spindle_data__\";function zt(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,s=Yt.get(a);if(s!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Cn]:s,[In]:u}}const o={};for(const u of Object.keys(i))o[u]=n(i[u]);return t.delete(i),o}return n(e)}function Ft(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(s=>t(s));const r=n;if(Cn in r&&In in r){const s=r[Cn],o=r[In],u=Ui.get(s);if(!u){console.warn(`spindle: Class \"${s}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(o))f[c]=t(o[c]);return f}const l=Object.create(u.prototype);for(const f of Object.keys(o))l[f]=t(o[f]);return l}const i=r.constructor;if(Yt.has(i))return n;const a={};for(const s of Object.keys(r))a[s]=t(r[s]);return a}return t(e)}let An=null,En=null,Rr=!1;function po(e){An=e}function mo(e){En=e}function go(e){if(En)try{const i=new Function(\"passage\",\"variables\",En)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(An)try{const r=An(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 _o(){Rr||(Rr=!0)}async function Lr(e){const n=(await Qn(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await Hi(i),await qi(`currentPlaythroughId.${e}`,r),r}async function yo(e){return Gn(`currentPlaythroughId.${e}`)}async function ji(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:go(n),passage:n.passage,custom:r},s=W(n);s.variables=zt(s.variables),s.history=s.history.map(u=>({...u,variables:zt(u.variables)}));const o={meta:a,payload:s};return await Gt(o),o}async function Wi(e,t){const n=await Kt(e);if(!n)return;n.meta.updatedAt=new Date().toISOString(),n.meta.passage=t.passage;const r=W(t);return r.variables=zt(r.variables),r.history=r.history.map(i=>({...i,variables:zt(i.variables)})),n.payload=r,await Gt(n),n}async function bo(e){const t=await Kt(e);if(!t)return;const n=t.payload;return n.variables=Ft(n.variables),n.history=n.history.map(r=>({...r,variables:Ft(r.variables)})),n}async function xo(e){await uo(e)}async function vo(e,t){const n=await Kt(e);n&&(n.meta.title=t,n.meta.updatedAt=new Date().toISOString(),await Gt(n))}async function wo(e){const[t,n]=await Promise.all([co(e),Qn(e)]),r=new Map;for(const o of n)r.set(o.id,o);const i=new Map;for(const o of t){const u=o.meta.playthroughId;i.has(u)||i.set(u,[]),i.get(u).push(o)}for(const o of i.values())o.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],s=[...r.values()].sort((o,u)=>new Date(u.createdAt).getTime()-new Date(o.createdAt).getTime());for(const o of s){const u=i.get(o.id)??[];a.push({playthrough:o,saves:u})}for(const[o,u]of i)r.has(o)||a.push({playthrough:{id:o,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const Qi=\"autosave.\";async function ko(e,t,n){const r=`${Qi}${e}`,i=await Gn(r);if(i){const s=await Wi(i,n);if(s)return s}const a=await ji(e,t,n,{isAutosave:!0});return await qi(r,a.meta.id),a}async function So(e){const t=`${Qi}${e}`,n=await Gn(t);if(n)return bo(n)}async function Co(e){const t=await Kt(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Io(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=W(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Qn(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await Hi(a)}return await Gt(n),n}function Ao(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Me(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Me(i,t,n)}}}function Gi(){const e=k.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=ht(t.content),r=dt(n),i=W(e.variables),a=W(e.temporary);Ao(r,i,a);for(const o of Object.keys(i))i[o]!==e.variables[o]&&e.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==e.temporary[o]&&e.setTemporary(o,a[o]);const s=e.storyData.passages.get(\"SaveTitle\");s&&mo(s.content)}const k=zs()(Js((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",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=W(r);e(o=>{o.storyData=n,o.currentPassage=i.name,o.variables=a,o.variableDefaults=r,o.temporary={},o.history=[{passage:i.name,variables:W(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}});const s=n.ifid;_o().then(async()=>{const o=await yo(s);if(o)e(u=>{u.playthroughId=o});else{const u=await Lr(s);e(l=>{l.playthroughId=u})}})},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:W(i.variables),timestamp:Date.now()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=W(r.variables),n.temporary={}})},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=W(r.variables),n.temporary={}})},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;const a=W(r);e(s=>{s.currentPassage=i.name,s.variables=a,s.temporary={},s.history=[{passage:i.name,variables:W(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Gi(),Lr(n.ifid).then(s=>{e(o=>{o.playthroughId=s})})},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:s,historyIndex:o,visitCounts:u,renderCounts:l}=t();if(!n)return;const f={passage:i,variables:W(a),history:W(s),historyIndex:o,visitCounts:{...u},renderCounts:{...l}};ko(n.ifid,r,f).then(()=>{e(c=>{c.saveVersion++})})},load:()=>{const{storyData:n}=t();n&&So(n.ifid).then(r=>{r&&e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}})})},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:s,renderCounts:o}=t();return{passage:n,variables:W(r),history:W(i),historyIndex:a,visitCounts:{...s},renderCounts:{...o}}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Ft(n.variables),r.history=n.history.map(i=>({...i,variables:Ft(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}})}}))),Ot=new Map,Pn=new Set,$n=new Map;function Eo(e,t,n){if(n)return n;const r=`${e}:${t}`,i=($n.get(r)??0)+1;return $n.set(r,i),i===1?r:`${r}:${i}`}function Po(e){return Ot.set(e.id,e),Br(),()=>{Ot.delete(e.id),Br()}}function Mr(){return Array.from(Ot.values())}function $o(e){return Ot.get(e)}function To(){$n.clear()}function No(e){return Pn.add(e),()=>{Pn.delete(e)}}function Br(){for(const e of Pn)e()}function re(e){const t=Qe(\"\");t.current||(t.current=Eo(e.type,e.key,e.authorId));const n=t.current;return ce(()=>{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),Po(r)}),n}function Do({target:e,className:t,id:n,children:r}){const i=k(o=>o.navigate),a=o=>{o.preventDefault(),i(e)};re({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return g(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function zo({name:e,scope:t,className:n,id:r}){const i=Se(Ne),a=e.split(\".\"),s=a[0],o=k(c=>t===\"variable\"?c.variables[s]:c.temporary[s]),u=t===\"variable\"?`$${s}`:`_${s}`;let l=u in i?i[u]:o;for(let c=1;c<a.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}l=l[a[c]]}const f=l==null?\"\":String(l);return n||r?g(\"span\",{id:r,class:n,children:f}):g(G,{children:f})}function Fo({rawArgs:e}){return ce(()=>{const t=k.getState(),n=W(t.variables),r=W(t.temporary);try{Me(e,n,r)}catch(i){console.error(`spindle: Error in {set ${e}}:`,i);return}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])},[]),null}function Oo({rawArgs:e,className:t,id:n}){const r=k(u=>u.variables),i=k(u=>u.temporary),a=Se(Ne),s={...r},o={...i};for(const[u,l]of Object.entries(a))u.startsWith(\"$\")?s[u.slice(1)]=l:u.startsWith(\"_\")&&(o[u.slice(1)]=l);try{const u=ke(e,s,o),l=u==null?\"\":String(u);return t||n?g(\"span\",{id:n,class:t,children:l}):g(G,{children:l})}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{print error: ${u.message}}`})}}function Ro({branches:e}){const t=k(o=>o.variables),n=k(o=>o.temporary),r=Se(Ne),i={...t},a={...n};for(const[o,u]of Object.entries(r))o.startsWith(\"$\")?i[o.slice(1)]=u:o.startsWith(\"_\")&&(a[o.slice(1)]=u);function s(o){const u=he(o.children);return o.className||o.id?g(\"span\",{id:o.id,class:o.className,children:u}):g(G,{children:u})}for(const o of e){if(o.rawArgs===\"\")return s(o);try{if(ke(o.rawArgs,i,a))return s(o)}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{if error: ${u.message}}`})}}return null}function Lo(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(o=>o.trim()),a=i[0],s=i.length>1?i[1]:null;return{itemVar:a,indexVar:s,listExpr:r}}function Mo({rawArgs:e,children:t,className:n,id:r}){const i=k(w=>w.variables),a=k(w=>w.temporary),s=Se(Ne),o={...i},u={...a};for(const[w,I]of Object.entries(s))w.startsWith(\"$\")?o[w.slice(1)]=I:w.startsWith(\"_\")&&(u[w.slice(1)]=I);let l;try{l=Lo(e)}catch(w){return g(\"span\",{class:\"error\",title:String(w),children:`{for error: ${w.message}}`})}const{itemVar:f,indexVar:c,listExpr:d}=l;let h;try{const w=ke(d,o,u);if(!Array.isArray(w))return g(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});h=w}catch(w){return g(\"span\",{class:\"error\",title:String(w),children:`{for error: ${w.message}}`})}const _=h.map((w,I)=>{const b={...s,[f]:w};return c&&(b[c]=I),g(Ne.Provider,{value:b,children:he(t)},I)});return n||r?g(\"span\",{id:r,class:n,children:_}):g(G,{children:_})}function Bo(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Vo({children:e}){const t=Bo(e);return ce(()=>{const n=k.getState(),r=W(n.variables),i=W(n.temporary);try{Me(t,r,i)}catch(a){console.error(\"spindle: Error in {do}:\",a);return}for(const a of Object.keys(r))r[a]!==n.variables[a]&&n.setVariable(a,r[a]);for(const a of Object.keys(i))i[a]!==n.temporary[a]&&n.setTemporary(a,i[a])},[]),null}function Ki(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Ho({rawArgs:e,children:t,className:n,id:r}){const i=()=>{const s=k.getState(),o=W(s.variables),u=W(s.temporary);try{Me(e,o,u)}catch(l){console.error(`spindle: Error in {button ${e}}:`,l);return}for(const l of Object.keys(o))o[l]!==s.variables[l]&&s.setVariable(l,o[l]);for(const l of Object.keys(u))u[l]!==s.temporary[l]&&s.setTemporary(l,u[l])};re({type:\"button\",key:e,authorId:r,label:Ki(t)||e,perform:i});const a=n?`macro-button ${n}`:\"macro-button\";return g(\"button\",{id:r,class:a,onClick:i,children:da(t)})}function qo({className:e,id:t}){const n=k(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return g(\"span\",{id:t,class:r,children:n})}function Uo({className:e,id:t}){const n=k(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return re({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),g(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function jo({className:e,id:t}){const n=k(a=>a.goBack),r=k(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return re({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function Wo({className:e,id:t}){const n=k(a=>a.goForward),r=k(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return re({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function Qo({className:e,id:t}){const n=k(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return re({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),g(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function Go({className:e,id:t}){const n=k(o=>o.load),r=k(o=>o.hasSave);k(o=>o.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),s=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return re({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),g(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:s,children:\"QuickLoad\"})}const Xe=new Map;let fe={};function Yi(){return`spindle.${k.getState().storyData?.ifid||\"unknown\"}.settings`}function Ko(){localStorage.setItem(Yi(),JSON.stringify(fe))}function sn(){try{const e=localStorage.getItem(Yi());e&&(fe={...fe,...JSON.parse(e)})}catch{}}const ot={addToggle(e,t){Xe.set(e,{type:\"toggle\",config:t}),e in fe||(fe[e]=t.default),sn()},addList(e,t){Xe.set(e,{type:\"list\",config:t}),e in fe||(fe[e]=t.default),sn()},addRange(e,t){Xe.set(e,{type:\"range\",config:t}),e in fe||(fe[e]=t.default),sn()},get(e){return fe[e]},set(e,t){fe[e]=t,Ko()},getAll(){return{...fe}},getDefinitions(){return Xe},hasAny(){return Xe.size>0}};function Yo({name:e,def:t}){const[n,r]=Z(()=>ot.get(e)),i=a=>{r(a),ot.set(e,a)};switch(t.type){case\"toggle\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>g(\"option\",{value:a,children:a},a))})]});case\"range\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:[t.config.label,\": \",String(n)]}),g(\"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 Zo({onClose:e}){const t=ot.getDefinitions();return g(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:g(\"div\",{class:\"settings-panel\",children:[g(\"div\",{class:\"settings-header\",children:[g(\"span\",{children:\"Settings\"}),g(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>g(Yo,{name:r,def:i},r))})]})})}function Jo({className:e,id:t}){const[n,r]=Z(!1);if(!ot.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return g(G,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&g(Zo,{onClose:()=>r(!1)})]})}function Xo(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 el(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function tl({onClose:e}){const[t,n]=Z(\"load\"),[r,i]=Z([]),[a,s]=Z(!0),[o,u]=Z(null),[l,f]=Z(new Set),[c,d]=Z(null),[h,_]=Z(\"\"),w=Qe(null),I=Qe(null),b=k(A=>A.storyData),v=k(A=>A.playthroughId),C=k(A=>A.getSavePayload),z=k(A=>A.loadFromPayload),E=b?.ifid??\"\",x=Mt(async()=>{if(!E)return;const A=await wo(E);i(A),s(!1)},[E]);we(()=>{x()},[x]),we(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]);const $=(A,U=\"success\")=>{u({text:A,type:U}),setTimeout(()=>u(null),3e3)},M=A=>{f(U=>{const p=new Set(U);return p.has(A)?p.delete(A):p.add(A),p})},L=async()=>{if(!(!E||!v))try{const A=C();await ji(E,v,A),$(\"Save created\"),await x()}catch{$(\"Failed to create save\",\"error\")}},y=async A=>{try{const U=C();await Wi(A,U),$(\"Save overwritten\"),await x()}catch{$(\"Failed to overwrite save\",\"error\")}},P=async A=>{try{z(A.payload),$(\"Game loaded\"),setTimeout(e,500)}catch{$(\"Failed to load save\",\"error\")}},T=async A=>{if(confirm(\"Delete this save?\"))try{await xo(A),$(\"Save deleted\"),await x()}catch{$(\"Failed to delete save\",\"error\")}},H=A=>{d(A.meta.id),_(A.meta.title)},q=async()=>{if(!(!c||!h.trim()))try{await vo(c,h.trim()),d(null),$(\"Save renamed\"),await x()}catch{$(\"Failed to rename\",\"error\")}},R=A=>{A.key===\"Enter\"?q():A.key===\"Escape\"&&d(null)},Y=async A=>{try{const U=await Co(A);if(!U)return;const p=new Blob([JSON.stringify(U,null,2)],{type:\"application/json\"}),V=URL.createObjectURL(p),ie=document.createElement(\"a\");ie.href=V,ie.download=`save-${U.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ie.click(),URL.revokeObjectURL(V),$(\"Save exported\")}catch{$(\"Failed to export save\",\"error\")}},K=()=>{I.current?.click()},se=async A=>{const U=A.target,p=U.files?.[0];if(p){U.value=\"\";try{const V=await p.text(),ie=JSON.parse(V);await Io(ie,E),$(\"Save imported\"),await x()}catch(V){$(V instanceof Error?V.message:\"Failed to import save\",\"error\")}}},de=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},m=r.reduce((A,U)=>A+U.saves.length,0);return g(\"div\",{class:\"saves-overlay\",onClick:de,children:g(\"div\",{class:\"saves-panel\",children:[g(\"div\",{class:\"saves-header\",children:[g(\"div\",{class:\"saves-header-left\",children:g(\"div\",{class:\"saves-mode-toggle\",children:[g(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),g(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),g(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"saves-toolbar\",children:[g(\"button\",{class:\"saves-toolbar-button\",onClick:K,children:\"Import\"}),g(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:se})]}),g(\"div\",{class:\"saves-body\",children:[a?g(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&t===\"load\"?g(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const U=l.has(A.playthrough.id),p=A.playthrough.id===v;return t===\"save\"&&!p||t===\"load\"&&A.saves.length===0&&!p?null:g(\"div\",{class:\"playthrough-group\",children:[g(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[g(\"span\",{class:`playthrough-chevron ${U?\"\":\"open\"}`,children:\"▶\"}),g(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,p?\" (current)\":\"\"]}),g(\"span\",{class:\"playthrough-date\",children:el(A.playthrough.createdAt)})]}),!U&&g(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(V=>g(\"div\",{class:\"save-slot\",children:[g(\"div\",{class:\"save-slot-info\",children:[c===V.meta.id?g(\"input\",{ref:w,class:\"save-rename-input\",value:h,onInput:ie=>_(ie.target.value),onKeyDown:R,onBlur:q}):g(\"div\",{class:\"save-slot-title\",children:V.meta.title}),g(\"div\",{class:\"save-slot-meta\",children:[g(\"span\",{children:V.meta.passage}),g(\"span\",{children:Xo(V.meta.updatedAt)})]})]}),g(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?g(\"button\",{class:\"save-slot-action primary\",onClick:()=>y(V.meta.id),children:\"Save Here\"}):g(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(V),children:\"Load\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>H(V),children:\"Rename\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>Y(V.meta.id),children:\"Export\"}),g(\"button\",{class:\"save-slot-action danger\",onClick:()=>T(V.meta.id),children:\"Delete\"})]})]},V.meta.id)),t===\"save\"&&p&&g(\"button\",{class:\"save-slot-new\",onClick:L,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===v)&&g(\"div\",{class:\"playthrough-group\",children:g(\"div\",{class:\"playthrough-saves\",children:g(\"button\",{class:\"save-slot-new\",onClick:L,children:\"+ New Save\"})})})]}),o&&g(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})})}function nl({className:e,id:t}){const[n,r]=Z(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return g(G,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&g(tl,{onClose:()=>r(!1)})]})}function rl({rawArgs:e,className:t,id:n}){const r=k(c=>c.storyData),i=k(c=>c.variables),a=k(c=>c.temporary);if(!r)return null;let s;try{const c=ke(e,i,a);s=String(c)}catch{s=e.replace(/^[\"']|[\"']$/g,\"\")}const o=r.passages.get(s);if(o&&k.getState().trackRender(s),!o)return g(\"span\",{class:\"error\",children:`{include: passage \"${s}\" not found}`});const u=ht(o.content),l=dt(u),f=he(l);return t||n?g(\"span\",{id:n,class:t,children:f}):g(G,{children:f})}function il({rawArgs:e}){return ce(()=>{const t=k.getState();let n;try{const r=ke(e,t.variables,t.temporary);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}t.navigate(n)},[]),null}function al({rawArgs:e}){return ce(()=>{const t=k.getState(),n=e.trim();n.startsWith(\"$\")?t.deleteVariable(n.slice(1)):n.startsWith(\"_\")?t.deleteTemporary(n.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${n}\"`)},[]),null}function sl(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 ol({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=sl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);re({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return g(\"input\",{type:\"text\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function ll(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 ul({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=ll(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);re({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return g(\"input\",{type:\"number\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>{const f=l.target.value;o(a,f===\"\"?0:Number(f))}})}function cl(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 fl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=cl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);re({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return g(\"textarea\",{id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function hl(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}}function dl({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=hl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=k(l=>l.variables[a]),o=k(l=>l.setVariable);re({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!s,perform:l=>o(a,l!==void 0?!!l:!s)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return g(\"label\",{id:n,class:u,children:[g(\"input\",{type:\"checkbox\",checked:!!s,onChange:()=>o(a,!s)}),i?` ${i}`:null]})}function pl(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]}}function ml({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=pl(e),s=r.startsWith(\"$\")?r.slice(1):r,o=k(f=>f.variables[s]),u=k(f=>f.setVariable);re({type:\"radiobutton\",key:`$${s}:${i}`,authorId:n,label:a||i,variable:s,value:o,perform:()=>u(s,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return g(\"label\",{id:n,class:l,children:[g(\"input\",{type:\"radio\",name:`radio-${s}`,checked:o===i,onChange:()=>u(s,i)}),a?` ${a}`:null]})}function Zi(e){const t=[];for(const n of e)n.type===\"macro\"&&n.name===\"option\"&&t.push(n.rawArgs.trim());return t}function gl({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=k(f=>f.variables[a]),o=k(f=>f.setVariable),u=Zi(t);re({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:s,perform:f=>{f!==void 0&&o(a,String(f))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return g(\"select\",{id:r,class:l,value:s==null?\"\":String(s),onChange:f=>o(a,f.target.value),children:u.map(f=>g(\"option\",{value:f,children:f},f))})}function _l({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=k(c=>c.variables[a]),o=k(c=>c.setVariable),u=Zi(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(s))+1)%u.length;o(a,u[d])};re({type:\"cycle\",key:`$${a}`,authorId:r,label:s==null?u[0]||\"\":String(s),variable:a,options:u,value:s,perform:c=>{c!==void 0?o(a,c):l()}});const f=n?`macro-cycle ${n}`:\"macro-cycle\";return g(\"button\",{id:r,class:f,onClick:l,children:s==null?u[0]||\"\":String(s)})}function yl(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Vr(e){const t=k.getState(),n=W(t.variables),r=W(t.temporary);for(const i of e)if(i.type===\"macro\"){if(i.name===\"set\")try{Me(i.rawArgs,n,r)}catch(a){console.error(\"spindle: Error in {link} child {set}:\",a)}else if(i.name===\"do\"){const a=Ki(i.children);try{Me(a,n,r)}catch(s){console.error(\"spindle: Error in {link} child {do}:\",s)}}}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])}function bl({rawArgs:e,children:t,className:n,id:r}){const{display:i,passage:a}=yl(e),s=u=>{u.preventDefault(),Vr(t),a&&k.getState().navigate(a)};re({type:\"link\",key:a||i,authorId:r,label:i,target:a??void 0,perform:()=>{Vr(t),a&&k.getState().navigate(a)}});const o=n?`macro-link ${n}`:\"macro-link\";return g(\"a\",{id:r,class:o,href:\"#\",onClick:s,children:i})}function xl({rawArgs:e,branches:t}){const n=k(l=>l.variables),r=k(l=>l.temporary),i=Se(Ne),a={...n},s={...r};for(const[l,f]of Object.entries(i))l.startsWith(\"$\")?a[l.slice(1)]=f:l.startsWith(\"_\")&&(s[l.slice(1)]=f);let o;try{o=ke(e,a,s)}catch(l){return g(\"span\",{class:\"error\",title:String(l),children:`{switch error: ${l.message}}`})}let u=null;for(const l of t){if(l.rawArgs===\"\"){u=l;continue}try{const f=ke(l.rawArgs,a,s);if(o===f)return g(G,{children:he(l.children)})}catch(f){return g(\"span\",{class:\"error\",title:String(f),children:`{case error: ${f.message}}`})}}return u?g(G,{children:he(u.children)}):null}function Rt(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)}function vl({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=[];a.push({delay:Rt(e),nodes:t});for(const l of n){const f=l.rawArgs?Rt(l.rawArgs):0;a.push({delay:f,nodes:l.children})}const[s,o]=Z(-1);if(we(()=>{if(s>=a.length-1)return;const l=s+1,f=a[l].delay,c=setTimeout(()=>{o(l)},f);return()=>clearTimeout(c)},[s,a.length]),s<0)return null;const u=he(a[s].nodes);return r||i?g(\"span\",{id:i,class:r,children:u}):g(G,{children:u})}const Ji=Bn({stop:()=>{}});function wl({rawArgs:e,children:t,className:n,id:r}){const i=Rt(e),[a,s]=Z(0),[o,u]=Z(!1),l=Mt(()=>u(!0),[]);if(we(()=>{if(o)return;const d=setInterval(()=>{s(h=>h+1)},i);return()=>clearInterval(d)},[i,o]),a===0&&!o)return null;const f=n?`macro-repeat ${n}`:void 0,c=g(Ji.Provider,{value:{stop:l},children:he(t)});return f||r?g(\"span\",{id:r,class:f,children:c}):c}function kl(){const{stop:e}=Se(Ji);return ce(()=>{e()},[e]),null}function Sl({rawArgs:e,children:t,className:n,id:r}){const i=Rt(e),a=Qe(null),[s,o]=Z(0),[u,l]=Z(0);we(()=>{if(a.current){const d=a.current.textContent||\"\";o(d.length)}},[]),we(()=>{if(s===0||u>=s)return;const d=setInterval(()=>{l(h=>h>=s?(clearInterval(d),h):h+1)},i);return()=>clearInterval(d)},[s,i]);const f=u>=s&&s>0,c=[\"macro-type\",f?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return g(\"span\",{id:r,class:c,ref:a,style:{clipPath:(s>0&&!f,void 0)},children:[g(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!f?`inset(0 ${(s-u)/s*100}% 0 0)`:void 0},children:da(t)}),!f&&s>0&&g(\"span\",{class:\"macro-type-cursor\"})]})}const Xi=new Map;function ea(e,t){Xi.set(e.toLowerCase(),t)}function Cl(e){return Xi.get(e.toLowerCase())}function Il({rawArgs:e,children:t}){const n=e.trim().replace(/[\"']/g,\"\");return ce(()=>{ea(n,t)},[]),null}function Al(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(),s=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:s}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function El(e,t){return Object.is(e,t)?!0:typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null?JSON.stringify(e)===JSON.stringify(t):!1}function Pl({rawArgs:e}){k(s=>s.variables),k(s=>s.temporary);const t=Se(Ne),{target:n,expr:r}=Al(e),i=n.startsWith(\"_\"),a=n.slice(1);return ce(()=>{const s=k.getState(),o={...s.variables},u={...s.temporary};for(const[c,d]of Object.entries(t))c.startsWith(\"$\")?o[c.slice(1)]=d:c.startsWith(\"_\")&&(u[c.slice(1)]=d);let l;try{l=ke(r,o,u)}catch(c){console.error(`spindle: Error in {computed ${e}}:`,c);return}const f=i?s.temporary[a]:s.variables[a];El(f,l)||(i?s.setTemporary(a,l):s.setVariable(a,l))}),null}function $l(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).trim());const a=Tl(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 Tl(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 Nl(e,t,n){return n===\"none\"?null:n===\"%\"?`${Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function Dl({rawArgs:e,className:t,id:n}){const r=k(u=>u.variables),i=k(u=>u.temporary),a=Se(Ne),s={...r},o={...i};for(const[u,l]of Object.entries(a))u.startsWith(\"$\")?s[u.slice(1)]=l:u.startsWith(\"_\")&&(o[u.slice(1)]=l);try{const{currentExpr:u,maxExpr:l,labelMode:f}=$l(e),c=Number(ke(u,s,o)),d=Number(ke(l,s,o)),h=Math.max(0,Math.min(100,c/d*100)),_=Nl(c,d,f),w=[\"macro-meter\",t].filter(Boolean).join(\" \");return g(\"div\",{class:w,id:n,children:[g(\"div\",{class:\"macro-meter-fill\",style:`width: ${h}%`}),_!=null&&g(\"span\",{class:\"macro-meter-label\",children:_})]})}catch(u){return g(\"span\",{class:\"error\",title:String(u),children:`{meter error: ${u.message}}`})}}const zl=new Map;function Fl(e){return zl.get(e.toLowerCase())}const Hr=document.createElement(\"i\");function ta(e){const t=\"&\"+e+\";\";Hr.innerHTML=t;const n=Hr.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ue(e,t,n,r){const i=e.length;let a=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a<r.length;)s=r.slice(a,a+1e4),s.unshift(t,0),e.splice(...s),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(ue(e,e.length,0,t),e):t}const Tn={}.hasOwnProperty;function Ol(e){const t={};let n=-1;for(;++n<e.length;)Rl(t,e[n]);return t}function Rl(e,t){let n;for(n in t){const i=(Tn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Tn.call(i,s)||(i[s]=[]);const o=a[s];Ll(i[s],Array.isArray(o)?o:o?[o]:[])}}}function Ll(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ue(e,0,0,r)}function Ml(e){const t={};let n=-1;for(;++n<e.length;)Bl(t,e[n]);return t}function Bl(e,t){let n;for(n in t){const i=(Tn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a)i[s]=a[s]}}function Vl(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 Hl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function na(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Hl[n]+\";\"}}function lt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const be=Oe(/[A-Za-z]/),le=Oe(/[\\dA-Za-z]/),ql=Oe(/[#-'*+\\--9=?A-Z^-~]/);function Nn(e){return e!==null&&(e<32||e===127)}const Dn=Oe(/\\d/),Ul=Oe(/[\\dA-Fa-f]/),jl=Oe(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function O(e){return e===-2||e===-1||e===32}const Wl=Oe(/\\p{P}|\\p{S}/u),Ql=Oe(/\\s/);function Oe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function yt(e,t){const n=na(Gl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),s=n.indexOf(\"/\");return r<0||s>-1&&r>s||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Gl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let s=\"\";if(a===37&&le(e.charCodeAt(n+1))&&le(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(s=String.fromCharCode(a));else if(a>55295&&a<57344){const o=e.charCodeAt(n+1);a<56320&&o>56319&&o<57344?(s=String.fromCharCode(a,o),i=1):s=\"�\"}else s=String.fromCharCode(a);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const qr={}.hasOwnProperty,Ur=/^(https?|ircs?|mailto|xmpp)$/i,Kl=/^https?$/i;function Yl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],s=[],u=Ml([{enter:{blockQuote:R,codeFenced:de,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:U,codeText:za,content:wa,definition:ga,definitionDestinationString:ya,definitionLabelString:I,definitionTitleString:I,emphasis:Na,htmlFlow:Ta,htmlText:Xn,image:V,label:I,link:ie,listItemMarker:P,listItemValue:y,listOrdered:M,listUnordered:L,paragraph:K,reference:I,resource:Be,resourceDestinationString:Ve,resourceTitleString:I,setextHeading:Sa,strong:Da},exit:{atxHeading:Ia,atxHeadingSequence:ka,autolinkEmail:Va,autolinkProtocol:Ba,blockQuote:Y,characterEscapeValue:Je,characterReferenceMarkerHexadecimal:er,characterReferenceMarkerNumeric:er,characterReferenceValue:Ma,codeFenced:p,codeFencedFence:A,codeFencedFenceInfo:m,codeFencedFenceMeta:$,codeFlowValue:$a,codeIndented:p,codeText:Fa,codeTextData:Je,data:Je,definition:va,definitionDestinationString:ba,definitionLabelString:_a,definitionTitleString:xa,emphasis:Oa,hardBreakEscape:Zn,hardBreakTrailing:Zn,htmlFlow:Jn,htmlFlowData:Je,htmlText:Jn,htmlTextData:Je,image:Yn,label:Ze,labelText:J,lineEnding:Pa,link:Yn,listOrdered:T,listUnordered:H,paragraph:se,reference:$,referenceString:Pe,resource:$,resourceDestinationString:Xt,resourceTitleString:ma,setextHeading:Ea,setextHeadingLineSequence:Aa,setextHeadingText:Ca,strong:Ra,thematicBreak:La}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:s},f={buffer:I,encode:x,getData:w,lineEndingIfNeeded:E,options:t,raw:C,resume:b,setData:_,tag:v};let c=t.defaultLineEnding;return d;function d(S){let N=-1,X=0;const pe=[];let _e=[],Ce=[];for(;++N<S.length;)!c&&(S[N][1].type===\"lineEnding\"||S[N][1].type===\"lineEndingBlank\")&&(c=S[N][2].sliceSerialize(S[N][1])),(S[N][1].type===\"listOrdered\"||S[N][1].type===\"listUnordered\")&&(S[N][0]===\"enter\"?pe.push(N):h(S.slice(pe.pop(),N))),S[N][1].type===\"definition\"&&(S[N][0]===\"enter\"?(Ce=ee(Ce,S.slice(X,N)),X=N):(_e=ee(_e,S.slice(X,N+1)),X=N+1));_e=ee(_e,Ce),_e=ee(_e,S.slice(X)),N=-1;const ye=_e;for(u.enter.null&&u.enter.null.call(f);++N<S.length;){const tr=u[ye[N][0]],nr=ye[N][1].type,rr=tr[nr];qr.call(tr,nr)&&rr&&rr.call({sliceSerialize:ye[N][2].sliceSerialize,...f},ye[N][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(S){const N=S.length;let X=0,pe=0,_e=!1,Ce;for(;++X<N;){const ye=S[X];if(ye[1]._container)Ce=void 0,ye[0]===\"enter\"?pe++:pe--;else switch(ye[1].type){case\"listItemPrefix\":{ye[0]===\"exit\"&&(Ce=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{ye[0]===\"enter\"&&!pe&&(Ce?Ce=void 0:_e=!0);break}default:Ce=void 0}}S[0][1]._loose=_e}function _(S,N){l[S]=N}function w(S){return l[S]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function v(S){n&&(_(\"lastWasTag\",!0),i[i.length-1].push(S))}function C(S){_(\"lastWasTag\"),i[i.length-1].push(S)}function z(){C(c||`\n`)}function E(){const S=i[i.length-1],N=S[S.length-1],X=N?N.charCodeAt(N.length-1):null;X===10||X===13||X===null||z()}function x(S){return w(\"ignoreEncode\")?S:na(S)}function $(){b()}function M(S){s.push(!S._loose),E(),v(\"<ol\"),_(\"expectFirstItem\",!0)}function L(S){s.push(!S._loose),E(),v(\"<ul\"),_(\"expectFirstItem\",!0)}function y(S){if(w(\"expectFirstItem\")){const N=Number.parseInt(this.sliceSerialize(S),10);N!==1&&v(' start=\"'+x(String(N))+'\"')}}function P(){w(\"expectFirstItem\")?v(\">\"):q(),E(),v(\"<li>\"),_(\"expectFirstItem\"),_(\"lastWasTag\")}function T(){q(),s.pop(),z(),v(\"</ol>\")}function H(){q(),s.pop(),z(),v(\"</ul>\")}function q(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&E(),v(\"</li>\"),_(\"slurpAllLineEndings\")}function R(){s.push(!1),E(),v(\"<blockquote>\")}function Y(){s.pop(),E(),v(\"</blockquote>\"),_(\"slurpAllLineEndings\")}function K(){s[s.length-1]||(E(),v(\"<p>\")),_(\"slurpAllLineEndings\")}function se(){s[s.length-1]?_(\"slurpAllLineEndings\",!0):v(\"</p>\")}function de(){E(),v(\"<pre><code\"),_(\"fencesCount\",0)}function m(){const S=b();v(' class=\"language-'+S+'\"')}function A(){const S=w(\"fencesCount\")||0;S||(v(\">\"),_(\"slurpOneLineEnding\",!0)),_(\"fencesCount\",S+1)}function U(){E(),v(\"<pre><code>\")}function p(){const S=w(\"fencesCount\");S!==void 0&&S<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&z(),w(\"flowCodeSeenData\")&&E(),v(\"</code></pre>\"),S!==void 0&&S<2&&E(),_(\"flowCodeSeenData\"),_(\"fencesCount\"),_(\"slurpOneLineEnding\")}function V(){a.push({image:!0}),n=void 0}function ie(){a.push({})}function J(S){a[a.length-1].labelId=this.sliceSerialize(S)}function Ze(){a[a.length-1].label=b()}function Pe(S){a[a.length-1].referenceId=this.sliceSerialize(S)}function Be(){I(),a[a.length-1].destination=\"\"}function Ve(){I(),_(\"ignoreEncode\",!0)}function Xt(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function ma(){a[a.length-1].title=b()}function Yn(){let S=a.length-1;const N=a[S],X=N.referenceId||N.labelId,pe=N.destination===void 0?r[lt(X)]:N;for(n=!0;S--;)if(a[S].image){n=void 0;break}N.image?(v('<img src=\"'+yt(pe.destination,t.allowDangerousProtocol?void 0:Kl)+'\" alt=\"'),C(N.label),v('\"')):v('<a href=\"'+yt(pe.destination,t.allowDangerousProtocol?void 0:Ur)+'\"'),v(pe.title?' title=\"'+pe.title+'\"':\"\"),N.image?v(\" />\"):(v(\">\"),C(N.label),v(\"</a>\")),a.pop()}function ga(){I(),a.push({})}function _a(S){b(),a[a.length-1].labelId=this.sliceSerialize(S)}function ya(){I(),_(\"ignoreEncode\",!0)}function ba(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function xa(){a[a.length-1].title=b()}function va(){const S=a[a.length-1],N=lt(S.labelId);b(),qr.call(r,N)||(r[N]=a[a.length-1]),a.pop()}function wa(){_(\"slurpAllLineEndings\",!0)}function ka(S){w(\"headingRank\")||(_(\"headingRank\",this.sliceSerialize(S).length),E(),v(\"<h\"+w(\"headingRank\")+\">\"))}function Sa(){I(),_(\"slurpAllLineEndings\")}function Ca(){_(\"slurpAllLineEndings\",!0)}function Ia(){v(\"</h\"+w(\"headingRank\")+\">\"),_(\"headingRank\")}function Aa(S){_(\"headingRank\",this.sliceSerialize(S).charCodeAt(0)===61?1:2)}function Ea(){const S=b();E(),v(\"<h\"+w(\"headingRank\")+\">\"),C(S),v(\"</h\"+w(\"headingRank\")+\">\"),_(\"slurpAllLineEndings\"),_(\"headingRank\")}function Je(S){C(x(this.sliceSerialize(S)))}function Pa(S){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){_(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){C(\" \");return}C(x(this.sliceSerialize(S)))}}function $a(S){C(x(this.sliceSerialize(S))),_(\"flowCodeSeenData\",!0)}function Zn(){v(\"<br />\")}function Ta(){E(),Xn()}function Jn(){_(\"ignoreEncode\")}function Xn(){t.allowDangerousHtml&&_(\"ignoreEncode\",!0)}function Na(){v(\"<em>\")}function Da(){v(\"<strong>\")}function za(){_(\"inCodeText\",!0),v(\"<code>\")}function Fa(){_(\"inCodeText\"),v(\"</code>\")}function Oa(){v(\"</em>\")}function Ra(){v(\"</strong>\")}function La(){E(),v(\"<hr />\")}function er(S){_(\"characterReferenceType\",S.type)}function Ma(S){const N=this.sliceSerialize(S),X=w(\"characterReferenceType\")?Vl(N,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):ta(N);C(x(X)),_(\"characterReferenceType\")}function Ba(S){const N=this.sliceSerialize(S);v('<a href=\"'+yt(N,t.allowDangerousProtocol?void 0:Ur)+'\">'),C(x(N)),v(\"</a>\")}function Va(S){const N=this.sliceSerialize(S);v('<a href=\"'+yt(\"mailto:\"+N)+'\">'),C(x(N)),v(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(u){return O(u)?(e.enter(n),o(u)):t(u)}function o(u){return O(u)&&a++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Zl={tokenize:Jl};function Jl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(o){return e.enter(\"paragraph\"),a(o)}function a(o){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,s(o)}function s(o){if(o===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(o);return}return D(o)?(e.consume(o),e.exit(\"chunkText\"),a):(e.consume(o),s)}}const Xl={tokenize:eu},jr={tokenize:tu};function eu(e){const t=this,n=[];let r=0,i,a,s;return o;function o(C){if(r<n.length){const z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,u,l)(C)}return l(C)}function u(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const z=t.events.length;let E=z,x;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){x=t.events[E][1].end;break}b(r);let $=z;for(;$<t.events.length;)t.events[$][1].end={...x},$++;return ue(t.events,E+1,0,t.events.slice(z)),t.events.length=$,l(C)}return o(C)}function l(C){if(r===n.length){if(!i)return d(C);if(i.currentConstruct&&i.currentConstruct.concrete)return _(C);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(jr,f,c)(C)}function f(C){return i&&v(),b(r),d(C)}function c(C){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,_(C)}function d(C){return t.containerState={},e.attempt(jr,h,_)(C)}function h(C){return r++,n.push([t.currentConstruct,t.containerState]),d(C)}function _(C){if(C===null){i&&v(),b(0),e.consume(C);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(C)}function w(C){if(C===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(C);return}return D(C)?(e.consume(C),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,o):(e.consume(C),w)}function I(C,z){const E=t.sliceStream(C);if(z&&E.push(null),C.previous=a,a&&(a.next=C),a=C,i.defineSkip(C.start),i.write(E),t.parser.lazy[C.start.line]){let x=i.events.length;for(;x--;)if(i.events[x][1].start.offset<s&&(!i.events[x][1].end||i.events[x][1].end.offset>s))return;const $=t.events.length;let M=$,L,y;for(;M--;)if(t.events[M][0]===\"exit\"&&t.events[M][1].type===\"chunkFlow\"){if(L){y=t.events[M][1].end;break}L=!0}for(b(r),x=$;x<t.events.length;)t.events[x][1].end={...y},x++;ue(t.events,M+1,0,t.events.slice($)),t.events.length=x}}function b(C){let z=n.length;for(;z-- >C;){const E=n[z];t.containerState=E[1],E[0].exit.call(t,e)}n.length=C}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Lt(e){if(e===null||te(e)||Ql(e))return 1;if(Wl(e))return 2}function Zt(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 zn={name:\"attention\",resolveAll:nu,tokenize:ru};function nu(e,t){let n=-1,r,i,a,s,o,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};Wr(c,-u),Wr(d,u),s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},o={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:{...s.start},end:{...o.end}},e[r][1].end={...s.start},e[n][1].start={...o.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",s,t],[\"exit\",s,t],[\"enter\",a,t]]),l=ee(l,Zt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,ue(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 ru(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Lt(r);let a;return s;function s(u){return a=u,e.enter(\"attentionSequence\"),o(u)}function o(u){if(u===a)return e.consume(u),o;const l=e.exit(\"attentionSequence\"),f=Lt(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 Wr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const iu={name:\"autolink\",tokenize:au};function au(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 be(h)?(e.consume(h),s):h===64?n(h):l(h)}function s(h){return h===43||h===45||h===46||le(h)?(r=1,o(h)):l(h)}function o(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||le(h))&&r++<32?(e.consume(h),o):(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||Nn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):ql(h)?(e.consume(h),l):n(h)}function f(h){return le(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||le(h))&&r++<63){const _=h===45?d:c;return e.consume(h),_}return n(h)}}const Jt={partial:!0,tokenize:su};function su(e,t,n){return r;function r(a){return O(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||D(a)?t(a):n(a)}}const ra={continuation:{tokenize:lu},exit:uu,name:\"blockQuote\",tokenize:ou};function ou(e,t,n){const r=this;return i;function i(s){if(s===62){const o=r.containerState;return o.open||(e.enter(\"blockQuote\",{_container:!0}),o.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(s),e.exit(\"blockQuoteMarker\"),a}return n(s)}function a(s){return O(s)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(s),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(s))}}function lu(e,t,n){const r=this;return i;function i(s){return O(s)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s):a(s)}function a(s){return e.attempt(ra,t,n)(s)}}function uu(e){e.exit(\"blockQuote\")}const ia={name:\"characterEscape\",tokenize:cu};function cu(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 jl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const aa={name:\"characterReference\",tokenize:fu};function fu(e,t,n){const r=this;let i=0,a,s;return o;function o(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,s=le,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,s=Ul,f):(e.enter(\"characterReferenceValue\"),a=7,s=Dn,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return s===le&&!ta(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return s(c)&&i++<a?(e.consume(c),f):n(c)}}const Qr={partial:!0,tokenize:du},Gr={concrete:!0,name:\"codeFenced\",tokenize:hu};function hu(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,s=0,o;return u;function u(x){return l(x)}function l(x){const $=r.events[r.events.length-1];return a=$&&$[1].type===\"linePrefix\"?$[2].sliceSerialize($[1],!0).length:0,o=x,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(x)}function f(x){return x===o?(s++,e.consume(x),f):s<3?n(x):(e.exit(\"codeFencedFenceSequence\"),O(x)?B(e,c,\"whitespace\")(x):c(x))}function c(x){return x===null||D(x)?(e.exit(\"codeFencedFence\"),r.interrupt?t(x):e.check(Qr,w,z)(x)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(x))}function d(x){return x===null||D(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(x)):O(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,h,\"whitespace\")(x)):x===96&&x===o?n(x):(e.consume(x),d)}function h(x){return x===null||D(x)?c(x):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),_(x))}function _(x){return x===null||D(x)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(x)):x===96&&x===o?n(x):(e.consume(x),_)}function w(x){return e.attempt(i,z,I)(x)}function I(x){return e.enter(\"lineEnding\"),e.consume(x),e.exit(\"lineEnding\"),b}function b(x){return a>0&&O(x)?B(e,v,\"linePrefix\",a+1)(x):v(x)}function v(x){return x===null||D(x)?e.check(Qr,w,z)(x):(e.enter(\"codeFlowValue\"),C(x))}function C(x){return x===null||D(x)?(e.exit(\"codeFlowValue\"),v(x)):(e.consume(x),C)}function z(x){return e.exit(\"codeFenced\"),t(x)}function E(x,$,M){let L=0;return y;function y(R){return x.enter(\"lineEnding\"),x.consume(R),x.exit(\"lineEnding\"),P}function P(R){return x.enter(\"codeFencedFence\"),O(R)?B(x,T,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):T(R)}function T(R){return R===o?(x.enter(\"codeFencedFenceSequence\"),H(R)):M(R)}function H(R){return R===o?(L++,x.consume(R),H):L>=s?(x.exit(\"codeFencedFenceSequence\"),O(R)?B(x,q,\"whitespace\")(R):q(R)):M(R)}function q(R){return R===null||D(R)?(x.exit(\"codeFencedFence\"),$(R)):M(R)}}}function du(e,t,n){const r=this;return i;function i(s){return s===null?n(s):(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}const on={name:\"codeIndented\",tokenize:mu},pu={partial:!0,tokenize:gu};function mu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(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?s(l):n(l)}function s(l){return l===null?u(l):D(l)?e.attempt(pu,s,u)(l):(e.enter(\"codeFlowValue\"),o(l))}function o(l){return l===null||D(l)?(e.exit(\"codeFlowValue\"),s(l)):(e.consume(l),o)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function gu(e,t,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):D(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(s)}function a(s){const o=r.events[r.events.length-1];return o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):D(s)?i(s):n(s)}}const _u={name:\"codeText\",previous:bu,resolve:yu,tokenize:xu};function yu(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 bu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function xu(e,t,n){let r=0,i,a;return s;function s(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),o(c)}function o(c){return c===96?(e.consume(c),r++,o):(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)):D(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||D(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 vu{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&et(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),et(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),et(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);et(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);et(this.left,n.reverse())}}}function et(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function sa(e){const t={};let n=-1,r,i,a,s,o,u,l;const f=new vu(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,wu(f,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(s=f.get(a),s[1].type===\"lineEnding\"||s[1].type===\"lineEndingBlank\")s[0]===\"enter\"&&(i&&(f.get(i)[1].type=\"lineEndingBlank\"),s[1].type=\"lineEnding\",i=a);else if(!(s[1].type===\"linePrefix\"||s[1].type===\"listItemIndent\"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return ue(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function wu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const o=s.events,u=[],l={};let f,c,d=-1,h=n,_=0,w=0;const I=[w];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(f),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++d<o.length;)o[d][0]===\"exit\"&&o[d-1][0]===\"enter\"&&o[d][1].type===o[d-1][1].type&&o[d][1].start.line!==o[d][1].end.line&&(w=d+1,I.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):I.pop(),d=I.length;d--;){const b=o.slice(I[d],I[d+1]),v=a.pop();u.push([v,v+b.length-1]),e.splice(v,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[_+u[d][0]]=_+u[d][1],_+=u[d][1]-u[d][0]-1;return l}const ku={resolve:Cu,tokenize:Iu},Su={partial:!0,tokenize:Au};function Cu(e){return sa(e),e}function Iu(e,t){let n;return r;function r(o){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(o)}function i(o){return o===null?a(o):D(o)?e.check(Su,s,a)(o):(e.consume(o),i)}function a(o){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(o)}function s(o){return e.consume(o),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Au(e,t,n){const r=this;return i;function i(s){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(s){if(s===null||D(s))return n(s);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function oa(e,t,n,r,i,a,s,o,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||Nn(b)?n(b):(e.enter(r),e.enter(s),e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),w(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===62?(e.exit(\"chunkString\"),e.exit(o),d(b)):b===null||b===60||D(b)?n(b):(e.consume(b),b===92?_:h)}function _(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function w(b){return!f&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(o),e.exit(s),e.exit(r),t(b)):f<l&&b===40?(e.consume(b),f++,w):b===41?(e.consume(b),f--,w):b===null||b===32||b===40||Nn(b)?n(b):(e.consume(b),b===92?I:w)}function I(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function la(e,t,n,r,i,a){const s=this;let o=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 o>999||h===null||h===91||h===93&&!u||h===94&&!o&&\"_hiddenFootnoteSupport\"in s.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):D(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||D(h)||o++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!O(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),o++,c):c(h)}}function ua(e,t,n,r,i,a){let s;return o;function o(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),s=d===40?41:d,u):n(d)}function u(d){return d===s?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===s?(e.exit(a),u(s)):d===null?n(d):D(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===s||d===null||D(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:f)}function c(d){return d===s||d===92?(e.consume(d),f):f(d)}}function rt(e,t){let n;return r;function r(i){return D(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):O(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Eu={name:\"definition\",tokenize:$u},Pu={partial:!0,tokenize:Tu};function $u(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),s(h)}function s(h){return la.call(r,e,o,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function o(h){return i=lt(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 te(h)?rt(e,l)(h):l(h)}function l(h){return oa(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(Pu,c,c)(h)}function c(h){return O(h)?B(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||D(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function Tu(e,t,n){return r;function r(o){return te(o)?rt(e,i)(o):n(o)}function i(o){return ua(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(o)}function a(o){return O(o)?B(e,s,\"whitespace\")(o):s(o)}function s(o){return o===null||D(o)?t(o):n(o)}}const Nu={name:\"hardBreakEscape\",tokenize:Du};function Du(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return D(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const zu={name:\"headingAtx\",resolve:Fu,tokenize:Ou};function Fu(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\"},ue(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Ou(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),s(f)}function s(f){return f===35&&r++<6?(e.consume(f),s):f===null||te(f)?(e.exit(\"atxHeadingSequence\"),o(f)):n(f)}function o(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||D(f)?(e.exit(\"atxHeading\"),t(f)):O(f)?B(e,o,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),o(f))}function l(f){return f===null||f===35||te(f)?(e.exit(\"atxHeadingText\"),o(f)):(e.consume(f),l)}}const Ru=[\"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\"],Kr=[\"pre\",\"script\",\"style\",\"textarea\"],Lu={concrete:!0,name:\"htmlFlow\",resolveTo:Vu,tokenize:Hu},Mu={partial:!0,tokenize:Uu},Bu={partial:!0,tokenize:qu};function Vu(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 Hu(e,t,n){const r=this;let i,a,s,o,u;return l;function l(p){return f(p)}function f(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),a=!0,w):p===63?(e.consume(p),i=3,r.interrupt?t:m):be(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,h):p===91?(e.consume(p),i=5,o=0,_):be(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function h(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function _(p){const V=\"CDATA[\";return p===V.charCodeAt(o++)?(e.consume(p),o===V.length?r.interrupt?t:T:_):n(p)}function w(p){return be(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const V=p===47,ie=s.toLowerCase();return!V&&!a&&Kr.includes(ie)?(i=1,r.interrupt?t(p):T(p)):Ru.includes(s.toLowerCase())?(i=6,V?(e.consume(p),b):r.interrupt?t(p):T(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?v(p):C(p))}return p===45||le(p)?(e.consume(p),s+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:T):n(p)}function v(p){return O(p)?(e.consume(p),v):y(p)}function C(p){return p===47?(e.consume(p),y):p===58||p===95||be(p)?(e.consume(p),z):O(p)?(e.consume(p),C):y(p)}function z(p){return p===45||p===46||p===58||p===95||le(p)?(e.consume(p),z):E(p)}function E(p){return p===61?(e.consume(p),x):O(p)?(e.consume(p),E):C(p)}function x(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,$):O(p)?(e.consume(p),x):M(p)}function $(p){return p===u?(e.consume(p),u=null,L):p===null||D(p)?n(p):(e.consume(p),$)}function M(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),M)}function L(p){return p===47||p===62||O(p)?C(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||D(p)?T(p):O(p)?(e.consume(p),P):n(p)}function T(p){return p===45&&i===2?(e.consume(p),Y):p===60&&i===1?(e.consume(p),K):p===62&&i===4?(e.consume(p),A):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),de):D(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Mu,U,H)(p)):p===null||D(p)?(e.exit(\"htmlFlowData\"),H(p)):(e.consume(p),T)}function H(p){return e.check(Bu,q,U)(p)}function q(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||D(p)?H(p):(e.enter(\"htmlFlowData\"),T(p))}function Y(p){return p===45?(e.consume(p),m):T(p)}function K(p){return p===47?(e.consume(p),s=\"\",se):T(p)}function se(p){if(p===62){const V=s.toLowerCase();return Kr.includes(V)?(e.consume(p),A):T(p)}return be(p)&&s.length<8?(e.consume(p),s+=String.fromCharCode(p),se):T(p)}function de(p){return p===93?(e.consume(p),m):T(p)}function m(p){return p===62?(e.consume(p),A):p===45&&i===2?(e.consume(p),m):T(p)}function A(p){return p===null||D(p)?(e.exit(\"htmlFlowData\"),U(p)):(e.consume(p),A)}function U(p){return e.exit(\"htmlFlow\"),t(p)}}function qu(e,t,n){const r=this;return i;function i(s){return D(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a):n(s)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function Uu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Jt,t,n)}}const ju={name:\"htmlText\",tokenize:Wu};function Wu(e,t,n){const r=this;let i,a,s;return o;function o(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),C):be(m)?(e.consume(m),M):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,_):be(m)?(e.consume(m),v):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):D(m)?(s=c,K(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?Y(m):m===45?d(m):c(m)}function _(m){const A=\"CDATA[\";return m===A.charCodeAt(a++)?(e.consume(m),a===A.length?w:_):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),I):D(m)?(s=w,K(m)):(e.consume(m),w)}function I(m){return m===93?(e.consume(m),b):w(m)}function b(m){return m===62?Y(m):m===93?(e.consume(m),b):w(m)}function v(m){return m===null||m===62?Y(m):D(m)?(s=v,K(m)):(e.consume(m),v)}function C(m){return m===null?n(m):m===63?(e.consume(m),z):D(m)?(s=C,K(m)):(e.consume(m),C)}function z(m){return m===62?Y(m):C(m)}function E(m){return be(m)?(e.consume(m),x):n(m)}function x(m){return m===45||le(m)?(e.consume(m),x):$(m)}function $(m){return D(m)?(s=$,K(m)):O(m)?(e.consume(m),$):Y(m)}function M(m){return m===45||le(m)?(e.consume(m),M):m===47||m===62||te(m)?L(m):n(m)}function L(m){return m===47?(e.consume(m),Y):m===58||m===95||be(m)?(e.consume(m),y):D(m)?(s=L,K(m)):O(m)?(e.consume(m),L):Y(m)}function y(m){return m===45||m===46||m===58||m===95||le(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),T):D(m)?(s=P,K(m)):O(m)?(e.consume(m),P):L(m)}function T(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,H):D(m)?(s=T,K(m)):O(m)?(e.consume(m),T):(e.consume(m),q)}function H(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):D(m)?(s=H,K(m)):(e.consume(m),H)}function q(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?L(m):(e.consume(m),q)}function R(m){return m===47||m===62||te(m)?L(m):n(m)}function Y(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function K(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),se}function se(m){return O(m)?B(e,de,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):de(m)}function de(m){return e.enter(\"htmlTextData\"),s(m)}}const Kn={name:\"labelEnd\",resolveAll:Yu,resolveTo:Zu,tokenize:Ju},Qu={tokenize:Xu},Gu={tokenize:ec},Ku={tokenize:tc};function Yu(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&&ue(e,0,e.length,n),e}function Zu(e,t){let n=e.length,r=0,i,a,s,o;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(s){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\"&&(s=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[s][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[s-2][1].start}};return o=[[\"enter\",u,t],[\"enter\",l,t]],o=ee(o,e.slice(a+1,a+r+3)),o=ee(o,[[\"enter\",f,t]]),o=ee(o,Zt(t.parser.constructs.insideSpan.null,e.slice(a+r+4,s-3),t)),o=ee(o,[[\"exit\",f,t],e[s-2],e[s-1],[\"exit\",l,t]]),o=ee(o,e.slice(s+1)),o=ee(o,[[\"exit\",u,t]]),ue(e,a,e.length,o),e}function Ju(e,t,n){const r=this;let i=r.events.length,a,s;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 o;function o(d){return a?a._inactive?c(d):(s=r.parser.defined.includes(lt(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(Qu,f,s?f:c)(d):d===91?e.attempt(Gu,f,s?l:c)(d):s?f(d):c(d)}function l(d){return e.attempt(Ku,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Xu(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 te(c)?rt(e,a)(c):a(c)}function a(c){return c===41?f(c):oa(e,s,o,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function s(c){return te(c)?rt(e,u)(c):f(c)}function o(c){return n(c)}function u(c){return c===34||c===39||c===40?ua(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return te(c)?rt(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 ec(e,t,n){const r=this;return i;function i(o){return la.call(r,e,a,s,\"reference\",\"referenceMarker\",\"referenceString\")(o)}function a(o){return r.parser.defined.includes(lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function tc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const nc={name:\"labelStartImage\",resolveAll:Kn.resolveAll,tokenize:rc};function rc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(o),e.exit(\"labelImageMarker\"),a}function a(o){return o===91?(e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),s):n(o)}function s(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const ic={name:\"labelStartLink\",resolveAll:Kn.resolveAll,tokenize:ac};function ac(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const ln={name:\"lineEnding\",tokenize:sc};function sc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const St={name:\"thematicBreak\",tokenize:oc};function oc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),s(l)}function s(l){return i=l,o(l)}function o(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||D(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),O(l)?B(e,o,\"whitespace\")(l):o(l))}}const ae={continuation:{tokenize:fc},exit:dc,name:\"list\",tokenize:cc},lc={partial:!0,tokenize:pc},uc={partial:!0,tokenize:hc};function cc(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,s=0;return o;function o(h){const _=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(_===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:Dn(h)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(St,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 Dn(h)&&++s<10?(e.consume(h),u):(!r.interrupt||s<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(Jt,r.interrupt?n:f,e.attempt(lc,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return O(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 fc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Jt,i,a);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(o)}function a(o){return r.containerState.furtherBlankLines||!O(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(uc,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(ae,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o)}}function hc(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"listItemIndent\"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(a):n(a)}}function dc(e){e.exit(this.containerState.type)}function pc(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const s=r.events[r.events.length-1];return!O(a)&&s&&s[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Yr={name:\"setextUnderline\",resolveTo:mc,tokenize:gc};function mc(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 s={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\",s,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=s,e.push([\"exit\",s,t]),e}function gc(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,s(l)):n(l)}function s(l){return e.enter(\"setextHeadingLineSequence\"),o(l)}function o(l){return l===i?(e.consume(l),o):(e.exit(\"setextHeadingLineSequence\"),O(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||D(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const _c={tokenize:yc};function yc(e){const t=this,n=e.attempt(Jt,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ku,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 bc={resolveAll:fa()},xc=ca(\"string\"),vc=ca(\"text\");function ca(e){return{resolveAll:fa(e===\"text\"?wc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,s,o);return s;function s(f){return l(f)?a(f):o(f)}function o(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 fa(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 wc(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,s=-1,o=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(s=l.length;l.charCodeAt(s-1)===32;)o++,s--;if(s)break;s=-1}else if(l===-2)u=!0,o++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const l={type:n===e.length||u||o<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?s:r.start._bufferIndex+s,_index:r.start._index+a,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},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 kc={42:ae,43:ae,45:ae,48:ae,49:ae,50:ae,51:ae,52:ae,53:ae,54:ae,55:ae,56:ae,57:ae,62:ra},Sc={91:Eu},Cc={[-2]:on,[-1]:on,32:on},Ic={35:zu,42:St,45:[Yr,St],60:Lu,61:Yr,95:St,96:Gr,126:Gr},Ac={38:aa,92:ia},Ec={[-5]:ln,[-4]:ln,[-3]:ln,33:nc,38:aa,42:zn,60:[iu,ju],91:ic,92:[Nu,ia],93:Kn,95:zn,96:_u},Pc={null:[zn,bc]},$c={null:[42,95]},Tc={null:[]},Nc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:$c,contentInitial:Sc,disable:Tc,document:kc,flow:Ic,flowInitial:Cc,insideSpan:Pc,string:Ac,text:Ec},Symbol.toStringTag,{value:\"Module\"}));function Dc(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 s=[],o=[];const u={attempt:$(E),check:$(x),consume:v,enter:C,exit:z,interrupt:$(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:_,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(P){return s=ee(s,P),I(),s[s.length-1]!==null?[]:(M(t,0),l.events=Zt(a,l.events,l),l.events)}function d(P,T){return Fc(h(P),T)}function h(P){return zc(s,P)}function _(){const{_bufferIndex:P,_index:T,line:H,column:q,offset:R}=r;return{_bufferIndex:P,_index:T,line:H,column:q,offset:R}}function w(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<s.length;){const T=s[r._index];if(typeof T==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<T.length;)b(T.charCodeAt(r._bufferIndex));else b(T)}}function b(P){f=f(P)}function v(P){D(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function C(P,T){const H=T||{};return H.type=P,H.start=_(),l.events.push([\"enter\",H,l]),o.push(H),H}function z(P){const T=o.pop();return T.end=_(),l.events.push([\"exit\",T,l]),T}function E(P,T){M(P,T.from)}function x(P,T){T.restore()}function $(P,T){return H;function H(q,R,Y){let K,se,de,m;return Array.isArray(q)?U(q):\"tokenize\"in q?U([q]):A(q);function A(J){return Ze;function Ze(Pe){const Be=Pe!==null&&J[Pe],Ve=Pe!==null&&J.null,Xt=[...Array.isArray(Be)?Be:Be?[Be]:[],...Array.isArray(Ve)?Ve:Ve?[Ve]:[]];return U(Xt)(Pe)}}function U(J){return K=J,se=0,J.length===0?Y:p(J[se])}function p(J){return Ze;function Ze(Pe){return m=L(),de=J,J.partial||(l.currentConstruct=J),J.name&&l.parser.constructs.disable.null.includes(J.name)?ie():J.tokenize.call(T?Object.assign(Object.create(l),T):l,u,V,ie)(Pe)}}function V(J){return P(de,m),R}function ie(J){return m.restore(),++se<K.length?p(K[se]):Y}}}function M(P,T){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&ue(l.events,T,l.events.length-T,P.resolve(l.events.slice(T),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function L(){const P=_(),T=l.previous,H=l.currentConstruct,q=l.events.length,R=Array.from(o);return{from:q,restore:Y};function Y(){r=P,l.previous=T,l.currentConstruct=H,l.events.length=q,o=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function zc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let s;if(n===i)s=[e[n].slice(r,a)];else{if(s=e.slice(n,i),r>-1){const o=s[0];typeof o==\"string\"?s[0]=o.slice(r):s.shift()}a>0&&s.push(e[i].slice(0,a))}return s}function Fc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let s;if(typeof a==\"string\")s=a;else switch(a){case-5:{s=\"\\r\";break}case-4:{s=`\n`;break}case-3:{s=`\\r\n`;break}case-2:{s=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;s=\" \";break}default:s=String.fromCharCode(a)}i=a===-2,r.push(s)}return r.join(\"\")}function Oc(e){const r={constructs:Ol([Nc,...(e||{}).extensions||[]]),content:i(Zl),defined:[],document:i(Xl),flow:i(_c),lazy:{},string:i(xc),text:i(vc)};return r;function i(a){return s;function s(o){return Dc(r,a,o)}}}function Rc(e){for(;!sa(e););return e}const Zr=/[\\0\\t\\n\\r]/g;function Lc(){let e=1,t=\"\",n=!0,r;return i;function i(a,s,o){const u=[];let l,f,c,d,h;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(s||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(Zr.lastIndex=c,l=Zr.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 o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Mc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Yl(n)(Rc(Oc(n).document().write(Lc()(e,t,!0))))}const un={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Bc(){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=un[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=un[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,Vc)),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\"+un[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Vc(e,t){return t===\"|\"?t:e}class Hc{constructor(){this.map=[]}add(t,n,r){qc(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[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 qc(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 Uc(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 jc(){return{flow:{null:{name:\"table\",tokenize:Wc,resolveAll:Qc}}}}function Wc(e,t,n){const r=this;let i=0,a=0,s;return o;function o(y){let P=r.events.length-1;for(;P>-1;){const q=r.events[P][1].type;if(q===\"lineEnding\"||q===\"linePrefix\")P--;else break}const T=P>-1?r.events[P][1].type:null,H=T===\"tableHead\"||T===\"tableRow\"?x:u;return H===x&&r.parser.lazy[r.now().line]?n(y):H(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(s=!0,a+=1),f(y)}function f(y){return y===null?n(y):D(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),h):n(y):O(y)?B(e,f,\"whitespace\")(y):(a+=1,s&&(s=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),s=!0,f):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),f(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function h(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),s=!1,O(y)?B(e,_,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):_(y))}function _(y){return y===45||y===58?I(y):y===124?(s=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),w):E(y)}function w(y){return O(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,s=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||D(y)?z(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),v(y)):E(y)}function v(y){return y===45?(e.consume(y),v):y===58?(s=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),C):(e.exit(\"tableDelimiterFiller\"),C(y))}function C(y){return O(y)?B(e,z,\"whitespace\")(y):z(y)}function z(y){return y===124?_(y):y===null||D(y)?!s||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function x(y){return e.enter(\"tableRow\"),$(y)}function $(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),$):y===null||D(y)?(e.exit(\"tableRow\"),t(y)):O(y)?B(e,$,\"whitespace\")(y):(e.enter(\"data\"),M(y))}function M(y){return y===null||y===124||te(y)?(e.exit(\"data\"),$(y)):(e.consume(y),y===92?L:M)}function L(y){return y===92||y===124?(e.consume(y),M):M(y)}}function Qc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,u=0,l,f,c;const d=new Hc;for(;++n<e.length;){const h=e[n],_=h[1];h[0]===\"enter\"?_.type===\"tableHead\"?(o=!1,u!==0&&(Jr(d,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},_.start),end:Object.assign({},_.end)},d.add(n,0,[[\"enter\",l,t]])):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,f={type:\"tableBody\",start:Object.assign({},_.start),end:Object.assign({},_.end)},d.add(n,0,[[\"enter\",f,t]])),i=_.type===\"tableDelimiterRow\"?2:f?3:1):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],c=bt(d,t,a,i,void 0,c),a=[0,0,0,0]),s[2]=n)):_.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],c=bt(d,t,a,i,void 0,c)),a=s,s=[a[1],n,0,0])):_.type===\"tableHead\"?(o=!0,u=n):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(s[0]=s[1],c=bt(d,t,a,i,n,c)):s[1]!==0&&(c=bt(d,t,s,i,n,c)),i=0):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")&&(s[3]=n)}for(u!==0&&Jr(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=Uc(t.events,n))}return e}function bt(e,t,n,r,i,a){const s=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",o=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},qe(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=qe(t.events,n[1]);if(a={type:s,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=qe(t.events,n[2]),f=qe(t.events,n[3]),c={type:o,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 _=n[2]+1,w=n[3]-n[2]-1;e.add(_,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},qe(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Jr(e,t,n,r,i){const a=[],s=qe(t.events,n);i&&(i.end=Object.assign({},s),a.push([\"exit\",i,t])),r.end=Object.assign({},s),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function qe(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Gc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Kc(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(s,o){let u=-1;for(;++u<s.length;)if(s[u][0]===\"enter\"&&s[u][1].type===\"strikethroughSequenceTemporary\"&&s[u][1]._close){let l=u;for(;l--;)if(s[l][0]===\"exit\"&&s[l][1].type===\"strikethroughSequenceTemporary\"&&s[l][1]._open&&s[u][1].end.offset-s[u][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[u][1].type=\"strikethroughSequence\",s[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},s[l][1].start),end:Object.assign({},s[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},s[l][1].end),end:Object.assign({},s[u][1].start)},d=[[\"enter\",f,o],[\"enter\",s[l][1],o],[\"exit\",s[l][1],o],[\"enter\",c,o]],h=o.parser.constructs.insideSpan.null;h&&ue(d,d.length,0,Zt(h,s.slice(l+1,u),o)),ue(d,d.length,0,[[\"exit\",c,o],[\"enter\",s[u][1],o],[\"exit\",s[u][1],o],[\"exit\",f,o]]),ue(s,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<s.length;)s[u][1].type===\"strikethroughSequenceTemporary\"&&(s[u][1].type=\"data\");return s}function a(s,o,u){const l=this.previous,f=this.events;let c=0;return d;function d(_){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(_):(s.enter(\"strikethroughSequenceTemporary\"),h(_))}function h(_){const w=Lt(l);if(_===126)return c>1?u(_):(s.consume(_),c++,h);if(c<2&&!n)return u(_);const I=s.exit(\"strikethroughSequenceTemporary\"),b=Lt(_);return I._open=!b||b===2&&!!w,I._close=!w||w===2&&!!b,o(_)}}}function Yc(e){return Mc(e,{allowDangerousHtml:!0,extensions:[jc(),Kc()],htmlExtensions:[Bc(),Gc()]})}const Ne=Bn({});function Zc(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>ha(i,a,t));return g(G,{children:r})}function ha(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 s={key:t};for(const u of Array.from(r.attributes))s[u.name]=u.value;const o=Array.from(r.childNodes).map((u,l)=>ha(u,l,n));return ge(i,s,...o)}return null}function Jc(e,t){switch(e.name){case\"set\":return g(Fo,{rawArgs:e.rawArgs},t);case\"computed\":return g(Pl,{rawArgs:e.rawArgs},t);case\"print\":return g(Oo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return g(Dl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"if\":return g(Ro,{branches:e.branches},t);case\"for\":return g(Mo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return g(Vo,{children:e.children},t);case\"button\":return g(Ho,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return g(qo,{className:e.className,id:e.id},t);case\"back\":return g(jo,{className:e.className,id:e.id},t);case\"forward\":return g(Wo,{className:e.className,id:e.id},t);case\"restart\":return g(Uo,{className:e.className,id:e.id},t);case\"quicksave\":return g(Qo,{className:e.className,id:e.id},t);case\"quickload\":return g(Go,{className:e.className,id:e.id},t);case\"settings\":return g(Jo,{className:e.className,id:e.id},t);case\"saves\":return g(nl,{className:e.className,id:e.id},t);case\"include\":return g(rl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return g(il,{rawArgs:e.rawArgs},t);case\"unset\":return g(al,{rawArgs:e.rawArgs},t);case\"textbox\":return g(ol,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return g(ul,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return g(fl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return g(dl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return g(ml,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return g(gl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return g(_l,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return g(bl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return g(xl,{rawArgs:e.rawArgs,branches:e.branches},t);case\"timed\":return g(vl,{rawArgs:e.rawArgs,children:e.children,branches:e.branches,className:e.className,id:e.id},t);case\"repeat\":return g(wl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return g(kl,{},t);case\"type\":return g(Sl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return g(Il,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=Cl(e.name);if(n)return g(G,{children:he(n)});const r=Fl(e.name);return r?g(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:he(e.children)},t):g(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function Fn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return g(Do,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return g(zo,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Jc(e,t);case\"html\":return ge(e.tag,{key:t,...e.attributes},e.children.length>0?he(e.children):void 0)}}function da(e){return e.length===0?null:e.map((t,n)=>Fn(t,n))}function he(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,s)=>Fn(a,s));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const s=e[a];if(s.type===\"text\")r+=s.value;else{const o=n.length;n.push(Fn(s,a)),r+=`<span data-tw=\"${o}\"></span>`}}const i=Yc(r);return Zc(i,n)}function Xc({passage:e}){const t=Ye(()=>{try{const n=ht(e.content),r=dt(n);return he(r)}catch(n){return g(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”:\",\" \",n.message]})}},[e.content,e.name]);return g(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}const ef=\"{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}\";function tf(){const t=k(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:ef,r=Ye(()=>{try{const i=ht(n),a=dt(i);return he(a)}catch(i){return g(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",i.message]})}},[n]);return g(G,{children:r})}function nf(){const e=k(r=>r.currentPassage),t=k(r=>r.storyData);if(we(()=>{const r=i=>{i.key===\"F6\"?(i.preventDefault(),k.getState().save()):i.key===\"F9\"&&(i.preventDefault(),k.getState().load())};return document.addEventListener(\"keydown\",r),()=>document.removeEventListener(\"keydown\",r)},[]),!t||!e)return g(\"div\",{class:\"loading\",children:\"Loading...\"});const n=t.passages.get(e);return n?g(G,{children:[g(\"header\",{class:\"story-menubar\",children:g(tf,{})}),g(\"div\",{id:\"story\",class:\"story\",children:g(Xc,{passage:n},e)})]}):g(\"div\",{class:\"error\",children:[\"Error: Passage “\",e,\"” not found.\"]})}function rf(){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\")||\"\",o=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),_=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(v=>v.length>0),I=d.textContent||\"\",b={pid:h,name:_,tags:w,content:I};f.set(_,b),c.set(h,b)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:o,userScript:l}}function af(){return{get(e){return k.getState().variables[e]},set(e,t){const n=k.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){k.getState().navigate(e)},back(){k.getState().goBack()},forward(){k.getState().goForward()},restart(){k.getState().restart()},save(e){k.getState().save(e)},load(e){k.getState().load(e)},hasSave(e){return k.getState().hasSave(e)},visited(e){return k.getState().visitCounts[e]??0},hasVisited(e){return(k.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=k.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=k.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return k.getState().renderCounts[e]??0},hasRendered(e){return(k.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=k.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=k.getState();return e.every(n=>(t[n]??0)>0)},get title(){return k.getState().storyData?.name||\"\"},get passage(){return k.getState().currentPassage},settings:ot,registerClass(e,t){fo(e,t)},saves:{setTitleGenerator(e){po(e)}},getActions(){return Mr()},performAction(e,t){const n=$o(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=k.getState().currentPassage;return k.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return No(t);if(e===\"variableChanged\"){let n={...k.getState().variables};return k.subscribe(r=>{const i={};let a=!1;const s=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const o of s)r.variables[o]!==n[o]&&(i[o]={from:n[o],to:r.variables[o]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Mr())})})})}}}function sf(){window.Story=af()}const of=/^\\$(\\w+)\\s*=\\s*(.+)$/,Xr=/\\$(\\w+(?:\\.\\w+)*)/g,ei=/\\{for\\s+(\\$\\w+)(?:\\s*,\\s*(\\$\\w+))?\\s+of\\b/g;function pa(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const t=new Map;for(const[n,r]of Object.entries(e))t.set(n,pa(r));return{type:\"object\",fields:t}}return{type:typeof e}}function lf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(of);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,s]=i;let o;try{o=new Function(\"return (\"+s+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${s}\": ${l instanceof Error?l.message:l}`)}const u=pa(o);t.set(a,{...u,name:a,default:o})}return t}function uf(e){const t=new Set;let n;for(ei.lastIndex=0;(n=ei.exec(e))!==null;)t.add(n[1].slice(1)),n[2]&&t.add(n[2].slice(1));return t}function cf(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 s=a;for(let o=1;o<r.length;o++){if(s.type===\"array\"&&r[o]===\"length\")return null;if(s.type!==\"object\"||!s.fields)return`Cannot access field \"${r[o]}\" on $${r.slice(0,o).join(\".\")} (type: ${s.type})`;const u=s.fields.get(r[o]);if(!u)return null;s=u}return null}function ff(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=uf(i.content);let s;for(Xr.lastIndex=0;(s=Xr.exec(i.content))!==null;){const o=s[1],u=cf(o,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function hf(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function ti(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 s=document.createElement(\"li\");s.textContent=a,i.appendChild(s)}n.appendChild(i),e.appendChild(n)}function ni(){const e=rf();if(sf(),e.userCSS){const o=document.createElement(\"style\");o.textContent=e.userCSS,document.head.appendChild(o)}if(e.userScript)try{new Function(e.userScript)()}catch(o){console.error(\"spindle: Error in story JavaScript:\",o)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const o=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",u=document.getElementById(\"root\");throw u&&ti(u,[o]),new Error(`spindle: ${o}`)}const r=lf(n.content),i=ff(e.passages,r);if(i.length>0){const o=document.getElementById(\"root\");throw o&&ti(o,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=hf(r),k.getState().init(e,t),Gi();for(const[,o]of e.passages)if(o.tags.includes(\"widget\")){const u=ht(o.content),l=dt(u);for(const f of l)if(f.type===\"macro\"&&f.name===\"widget\"&&f.rawArgs){const c=f.rawArgs.trim().replace(/[\"']/g,\"\");ea(c,f.children)}}let a=\"\";k.subscribe(o=>{o.currentPassage!==a&&(a=o.currentPassage,To())});const s=document.getElementById(\"root\");if(!s)throw new Error('spindle: No <div id=\"root\"> element found.');je(g(nf,{}),s)}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",ni):ni();</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{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.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}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{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}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding: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-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{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-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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rohal12/spindle",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "A Preact-based story format for Twine 2.",
6
6
  "license": "Unlicense",
@@ -49,25 +49,25 @@
49
49
  "prepublishOnly": "bun run test && bun run build"
50
50
  },
51
51
  "dependencies": {
52
- "immer": "^10.1.0",
52
+ "immer": "^11.1.4",
53
53
  "micromark": "^4.0.2",
54
54
  "micromark-extension-gfm-strikethrough": "^2.1.0",
55
55
  "micromark-extension-gfm-table": "^2.1.1",
56
- "preact": "^10.25.0",
57
- "zustand": "^5.0.0"
56
+ "preact": "^10.28.4",
57
+ "zustand": "^5.0.11"
58
58
  },
59
59
  "devDependencies": {
60
- "@preact/preset-vite": "^2.9.0",
61
- "@rohal12/twee-ts": "^1.0.0",
60
+ "@preact/preset-vite": "^2.10.3",
61
+ "@rohal12/twee-ts": "^1.1.2",
62
62
  "@types/js-yaml": "^4.0.9",
63
63
  "@vitest/coverage-v8": "^4.0.18",
64
- "happy-dom": "^20.7.0",
64
+ "happy-dom": "^20.8.3",
65
65
  "js-yaml": "^4.1.1",
66
66
  "playwright": "^1.58.2",
67
67
  "prettier": "^3.8.1",
68
- "typescript": "^5.7.0",
69
- "vite": "^6.0.0",
70
- "vite-plugin-singlefile": "^2.0.0",
68
+ "typescript": "^5.9.3",
69
+ "vite": "^7.3.1",
70
+ "vite-plugin-singlefile": "^2.3.0",
71
71
  "vitepress": "^1.6.4",
72
72
  "vitest": "^4.0.18"
73
73
  }