@rohal12/spindle 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.3.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 at,O,Nr,De,Mn,Dr,zr,Or,yn,Kt,Yt,Fr,bt={},xt=[],pa=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,st=Array.isArray;function ye(e,t){for(var n in t)e[n]=t[n];return e}function bn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function de(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?at.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 Ze(e,s,r,i,null)}function Ze(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??++Nr,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function da(){return{current:null}}function G(e){return e.children}function be(e,t){this.props=e,this.context=t}function Be(e,t){if(t==null)return e.__?Be(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\"?Be(e):null}function ma(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=ye({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),xn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Be(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Br(r,a,i),t.__e=t.__=null,a.__e!=n&&Rr(a)}}function Rr(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}),Rr(e)}function Zt(e){(!e.__d&&(e.__d=!0)&&De.push(e)&&!vt.__r++||Mn!=O.debounceRendering)&&((Mn=O.debounceRendering)||Dr)(vt)}function vt(){for(var e,t=1;De.length;)De.length>t&&De.sort(zr),e=De.shift(),t=De.length,ma(e);vt.__r=0}function Lr(e,t,n,r,i,a,s,o,u,l,f){var c,p,h,_,w,I,b,v=r&&r.__k||xt,C=t.length;for(u=ga(n,t,v,u,C),c=0;c<C;c++)(h=n.__k[c])!=null&&(p=h.__i!=-1&&v[h.__i]||bt,h.__i=c,I=xn(e,h,p,i,a,s,o,u,l,f),_=h.__e,h.ref&&p.ref!=h.ref&&(p.ref&&vn(p.ref,null,h),f.push(h.ref,h.__c||_,h)),w==null&&_!=null&&(w=_),(b=!!(4&h.__u))||p.__k===h.__k?u=Mr(h,u,e,b):typeof h.type==\"function\"&&I!==void 0?u=I:_&&(u=_.nextSibling),h.__u&=-7);return n.__e=w,u}function ga(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]=Ze(null,s,null,null,null):st(s)?s=e.__k[a]=Ze(G,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[a]=Ze(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=_a(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=Be(o)),Hr(o,o));return r}function Mr(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=Mr(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Be(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Se(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(st(e)?e.some(function(n){Se(n,t)}):t.push(e)),t}function _a(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 Bn(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||pa.test(t)?n:n+\"px\"}function ct(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||Bn(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Bn(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Or,\"$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=yn,e.addEventListener(t,a?Yt:Kt,a)):e.removeEventListener(t,a?Yt:Kt,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 Vn(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=yn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function xn(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 be(b,z),c.constructor=L,c.render=ba),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=ye({},c.__s)),ye(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)}),xt.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),xt.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=ye(ye({},r),c.getChildContext())),v&&!p&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(h,_)),P=f!=null&&f.type===G&&f.key==null?Vr(f.props.children):f,o=Lr(e,st(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--;)bn(a[M]);Jt(t)}else t.__e=n.__e,t.__k=n.__k,y.then||Jt(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=ya(n.__e,t,n,r,i,a,s,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:o}function Jt(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Jt))}function Br(e,t,n){for(var r=0;r<n.length;r++)vn(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 Vr(e){return typeof e!=\"object\"||e==null||e.__b>0?e:st(e)?e.map(Vr):ye({},e)}function ya(e,t,n,r,i,a,s,o,u){var l,f,c,p,h,_,w,I=n.props||bt,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&&at.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||ct(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||ct(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=\"\"),Lr(t.type==\"template\"?e.content:e,st(p)?p:[p],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,s,a?a[0]:n.__k&&Be(n,0),o,u),a!=null)for(l=a.length;l--;)bn(a[l]);o||(l=\"value\",v==\"progress\"&&_==null?e.removeAttribute(\"value\"):_!=null&&(_!==e[l]||v==\"progress\"&&!_||v==\"option\"&&_!=I[l])&&ct(e,l,_,I[l],i),l=\"checked\",w!=null&&w!=e[l]&&ct(e,l,w,I[l],i))}return e}function vn(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 Hr(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||vn(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]&&Hr(r[i],t,n||typeof e.type!=\"function\");n||bn(e.__e),e.__c=e.__=e.__e=void 0}function ba(e,t,n){return this.constructor(e,n)}function Ve(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=[],xn(t,e=(!r&&n||t).__k=de(G,null,[e]),i||bt,bt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?at.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,s),Br(a,e,s)}function jr(e,t){Ve(e,t,jr)}function xa(e,t,n){var r,i,a,s,o=ye({},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?at.call(arguments,2):n),Ze(e.type,o,r||e.key,i||e.ref,null)}function wn(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,Zt(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\"+Fr++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}at=xt.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}},Nr=0,be.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ye({},this.state),typeof e==\"function\"&&(e=e(ye({},n),this.props)),e&&ye(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Zt(this))},be.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Zt(this))},be.prototype.render=G,De=[],Dr=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,zr=function(e,t){return e.__v.__b-t.__v.__b},vt.__r=0,Or=/(PointerCapture)$|Capture$/i,yn=0,Kt=Vn(!1),Yt=Vn(!0),Fr=0;var va=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:--va,__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 Ie,U,Bt,Hn,He=0,qr=[],Q=O,jn=Q.__b,qn=Q.__r,Un=Q.diffed,Wn=Q.__c,Qn=Q.unmount,Gn=Q.__;function qe(e,t){Q.__h&&Q.__h(U,e,He||t),He=0;var n=U.__H||(U.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return He=1,kn(Gr,e)}function kn(e,t,n){var r=qe(Ie++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Gr(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 xe(e,t){var n=qe(Ie++,3);!Q.__s&&Sn(n.__H,t)&&(n.__=e,n.u=t,U.__H.__h.push(n))}function ce(e,t){var n=qe(Ie++,4);!Q.__s&&Sn(n.__H,t)&&(n.__=e,n.u=t,U.__h.push(n))}function Xe(e){return He=5,Ue(function(){return{current:e}},[])}function Ur(e,t,n){He=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 Ue(e,t){var n=qe(Ie++,7);return Sn(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Tt(e,t){return He=8,Ue(function(){return e},t)}function we(e){var t=U.context[e.__c],n=qe(Ie++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(U)),t.props.value):e.__}function Wr(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function Qr(){var e=qe(Ie++,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 wa(){for(var e;e=qr.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(gt),t.__h.some(Xt),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){U=null,jn&&jn(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Gn&&Gn(e,t)},Q.__r=function(e){qn&&qn(e),Ie=0;var t=(U=e.__c).__H;t&&(Bt===U?(t.__h=[],U.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(gt),t.__h.some(Xt),t.__h=[],Ie=0)),Bt=U},Q.diffed=function(e){Un&&Un(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(qr.push(t)!==1&&Hn===Q.requestAnimationFrame||((Hn=Q.requestAnimationFrame)||ka)(wa)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Bt=U=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(gt),n.__h=n.__h.filter(function(r){return!r.__||Xt(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Wn&&Wn(e,t)},Q.unmount=function(e){Qn&&Qn(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{gt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Kn=typeof requestAnimationFrame==\"function\";function ka(e){var t,n=function(){clearTimeout(r),Kn&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Kn&&(t=requestAnimationFrame(n))}function gt(e){var t=U,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),U=t}function Xt(e){var t=U;e.__c=e.__(),U=t}function Sn(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Gr(e,t){return typeof t==\"function\"?t(e):t}const Yn=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},Sa=(e=>e?Yn(e):Yn);function Kr(e,t){for(var n in t)e[n]=t[n];return e}function en(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 Yr(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,Vt(i)&&a({t:i})},[e,n,t]),xe(function(){return Vt(i)&&a({t:i}),e(function(){Vt(i)&&a({t:i})})},[e]),n}function Vt(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 Zr(e){e()}function Jr(e){return e}function Xr(){return[!1,Zr]}var ei=ce;function tn(e,t){this.props=e,this.context=t}function Ca(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:en(this.props,i)}function r(i){return this.shouldComponentUpdate=n,de(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(tn.prototype=new be).isPureReactComponent=!0,tn.prototype.shouldComponentUpdate=function(e,t){return en(this.props,e)||en(this.state,t)};var Zn=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Zn&&Zn(e)};var Ia=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Aa(e){function t(n){var r=Kr({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ia,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Jn=function(e,t){return e==null?null:Se(Se(e).map(t))},Ea={map:Jn,forEach:Jn,count:function(e){return e?Se(e).length:0},only:function(e){var t=Se(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Se},Ta=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)}Ta(e,t,n,r)};var Xn=O.unmount;function ti(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=Kr({},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 ti(r,t,n)})),e}function ni(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ni(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 _t(){this.__u=0,this.o=null,this.__b=null}function ri(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Pa(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?de(i,s):null}return a.displayName=\"Lazy\",a.__f=!0,a}function Ye(){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),Xn&&Xn(e)},(_t.prototype=new be).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ri(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]=ni(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)},_t.prototype.componentWillUnmount=function(){this.o=[]},_t.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]=ti(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&de(G,null,e.fallback);return i&&(i.__u&=-33),[de(G,null,t.__a?null:e.children),i]};var er=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 $a(e){return this.getChildContext=function(){return e.context},e.children}function Na(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ve(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)}}}Ve(de($a,{context:t.context},e.__v),t.v)}function Da(e,t){var n=de(Na,{__v:e,h:t});return n.containerInfo=t,n}(Ye.prototype=new be).__a=function(e){var t=this,n=ri(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),er(t,e,r)):i()};n?n(a):a()}},Ye.prototype.render=function(e){this.i=null,this.l=new Map;var t=Se(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},Ye.prototype.componentDidUpdate=Ye.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){er(e,n,t)})};var ii=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,za=/^(?: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]/,Oa=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Fa=/[A-Z0-9]/g,Ra=typeof document<\"u\",La=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ma(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ve(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ba(e,t,n){return jr(e,t),typeof n==\"function\"&&n(),e?e.__c:null}be.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(be.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var tr=O.event;function Va(){}function Ha(){return this.cancelBubble}function ja(){return this.defaultPrevented}O.event=function(e){return tr&&(e=tr(e)),e.persist=Va,e.isPropagationStopped=Ha,e.isDefaultPrevented=ja,e.nativeEvent=e};var Cn,qa={enumerable:!1,configurable:!0,get:function(){return this.class}},nr=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||Ra&&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\"||La(n.type)?u===\"onfocus\"?s=\"onfocusin\":u===\"onblur\"?s=\"onfocusout\":Oa.test(s)&&(s=u):u=s=\"oninput\":a&&za.test(s)?s=s.replace(Fa,\"-$&\").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=Se(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Se(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\",qa)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=ii,nr&&nr(e)};var rr=O.__r;O.__r=function(e){rr&&rr(e),Cn=e.__c};var ir=O.diffed;O.diffed=function(e){ir&&ir(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),Cn=null};var Ua={ReactCurrentDispatcher:{current:{readContext:function(e){return Cn.__n[e.__c].props.value},useCallback:Tt,useContext:we,useDebugValue:Wr,useDeferredValue:Jr,useEffect:xe,useId:Qr,useImperativeHandle:Ur,useInsertionEffect:ei,useLayoutEffect:ce,useMemo:Ue,useReducer:kn,useRef:Xe,useState:Z,useSyncExternalStore:Yr,useTransition:Xr}}};function Wa(e){return de.bind(null,e)}function Pt(e){return!!e&&e.$$typeof===ii}function Qa(e){return Pt(e)&&e.type===G}function Ga(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ka(e){return Pt(e)?xa.apply(null,arguments):e}function Ya(e){return!!e.__k&&(Ve(null,e),!0)}function Za(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ja=function(e,t){return e(t)},Xa=function(e,t){return e(t)},es=G,ts=Pt,ft={useState:Z,useId:Qr,useReducer:kn,useEffect:xe,useLayoutEffect:ce,useInsertionEffect:ei,useTransition:Xr,useDeferredValue:Jr,useSyncExternalStore:Yr,startTransition:Zr,useRef:Xe,useImperativeHandle:Ur,useMemo:Ue,useCallback:Tt,useContext:we,useDebugValue:Wr,version:\"18.3.1\",Children:Ea,render:Ma,hydrate:Ba,unmountComponentAtNode:Ya,createPortal:Da,createElement:de,createContext:wn,createFactory:Wa,cloneElement:Ka,createRef:da,Fragment:G,isValidElement:Pt,isElement:ts,isFragment:Qa,isMemo:Ga,findDOMNode:Za,Component:be,PureComponent:tn,memo:Ca,forwardRef:Aa,flushSync:Xa,unstable_batchedUpdates:Ja,StrictMode:es,Suspense:_t,SuspenseList:Ye,lazy:Pa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ua};const ns=e=>e;function rs(e,t=ns){const n=ft.useSyncExternalStore(e.subscribe,ft.useCallback(()=>t(e.getState()),[e,t]),ft.useCallback(()=>t(e.getInitialState()),[e,t]));return ft.useDebugValue(n),n}const is=e=>{const t=Sa(e),n=r=>rs(t,r);return Object.assign(n,t),n},as=(e=>is);var ai=Symbol.for(\"immer-nothing\"),ar=Symbol.for(\"immer-draftable\"),oe=Symbol.for(\"immer-state\");function pe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var et=Object.getPrototypeOf;function je(e){return!!e&&!!e[oe]}function ze(e){return e?si(e)||Array.isArray(e)||!!e[ar]||!!e.constructor?.[ar]||ot(e)||Nt(e):!1}var ss=Object.prototype.constructor.toString(),sr=new WeakMap;function si(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=sr.get(n);return r===void 0&&(r=Function.toString.call(n),sr.set(n,r)),r===ss}function wt(e,t,n=!0){$t(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 $t(e){const t=e[oe];return t?t.type_:Array.isArray(e)?1:ot(e)?2:Nt(e)?3:0}function nn(e,t){return $t(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function oi(e,t,n){const r=$t(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}function ot(e){return e instanceof Map}function Nt(e){return e instanceof Set}function Ne(e){return e.copy_||e.base_}function rn(e,t){if(ot(e))return new Map(e);if(Nt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=si(e);if(t===!0||t===\"class_only\"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[oe];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(et(e),r)}else{const r=et(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function In(e,t=!1){return Dt(e)||je(e)||!ze(e)||($t(e)>1&&Object.defineProperties(e,{set:ht,add:ht,clear:ht,delete:ht}),Object.freeze(e),t&&Object.values(e).forEach(n=>In(n,!0))),e}function ls(){pe(2)}var ht={value:ls};function Dt(e){return e===null||typeof e!=\"object\"?!0:Object.isFrozen(e)}var us={};function Oe(e){const t=us[e];return t||pe(0,e),t}var tt;function li(){return tt}function cs(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function or(e,t){t&&(Oe(\"Patches\"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function an(e){sn(e),e.drafts_.forEach(fs),e.drafts_=null}function sn(e){e===tt&&(tt=e.parent_)}function lr(e){return tt=cs(tt,e)}function fs(e){const t=e[oe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ur(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[oe].modified_&&(an(t),pe(4)),ze(e)&&(e=kt(t,e),t.parent_||St(t,e)),t.patches_&&Oe(\"Patches\").generateReplacementPatches_(n[oe].base_,e,t.patches_,t.inversePatches_)):e=kt(t,n,[]),an(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ai?e:void 0}function kt(e,t,n){if(Dt(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[oe];if(!i)return wt(t,(a,s)=>cr(e,i,t,a,s,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return St(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),wt(s,(u,l)=>cr(e,i,a,u,l,n,o),r),St(e,a,!1),n&&e.patches_&&Oe(\"Patches\").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function cr(e,t,n,r,i,a,s){if(i==null||typeof i!=\"object\"&&!s)return;const o=Dt(i);if(!(o&&!s)){if(je(i)){const u=a&&t&&t.type_!==3&&!nn(t.assigned_,r)?a.concat(r):void 0,l=kt(e,i,u);if(oi(n,r,l),je(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(ze(i)&&!o){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&o)return;kt(e,i),(!t||!t.scope_.parent_)&&typeof r!=\"symbol\"&&(ot(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&St(e,i)}}}function St(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&In(t,n)}function hs(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:li(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=An;n&&(i=[r],a=nt);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var An={get(e,t){if(t===oe)return e;const n=Ne(e);if(!nn(n,t))return ps(e,n,t);const r=n[t];return e.finalized_||!ze(r)?r:r===Ht(e.base_,t)?(jt(e),e.copy_[t]=ln(r,e)):r},has(e,t){return t in Ne(e)},ownKeys(e){return Reflect.ownKeys(Ne(e))},set(e,t,n){const r=ui(Ne(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Ht(Ne(e),t),a=i?.[oe];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(os(n,i)&&(n!==void 0||nn(e.base_,t)))return!0;jt(e),on(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 Ht(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,jt(e),on(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ne(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!==\"length\",enumerable:r.enumerable,value:n[t]}},defineProperty(){pe(11)},getPrototypeOf(e){return et(e.base_)},setPrototypeOf(){pe(12)}},nt={};wt(An,(e,t)=>{nt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});nt.deleteProperty=function(e,t){return nt.set.call(this,e,t,void 0)};nt.set=function(e,t,n){return An.set.call(this,e[0],t,n,e[0])};function Ht(e,t){const n=e[oe];return(n?Ne(n):e)[t]}function ps(e,t,n){const r=ui(t,n);return r?\"value\"in r?r.value:r.get?.call(e.draft_):void 0}function ui(e,t){if(!(t in e))return;let n=et(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=et(n)}}function on(e){e.modified_||(e.modified_=!0,e.parent_&&on(e.parent_))}function jt(e){e.copy_||(e.copy_=rn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ds=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\"&&pe(6),r!==void 0&&typeof r!=\"function\"&&pe(7);let i;if(ze(t)){const a=lr(this),s=ln(t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?an(a):sn(a)}return or(a,r),ur(i,a)}else if(!t||typeof t!=\"object\"){if(i=n(t),i===void 0&&(i=t),i===ai&&(i=void 0),this.autoFreeze_&&In(i,!0),r){const a=[],s=[];Oe(\"Patches\").generateReplacementPatches_(t,i,a,s),r(a,s)}return i}else pe(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){ze(e)||pe(8),je(e)&&(e=ms(e));const t=lr(this),n=ln(e,void 0);return n[oe].isManual_=!0,sn(t),n}finishDraft(e,t){const n=e&&e[oe];(!n||!n.isManual_)&&pe(9);const{scope_:r}=n;return or(r,t),ur(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=Oe(\"Patches\").applyPatches_;return je(e)?r(e,t):this.produce(e,i=>r(i,t))}};function ln(e,t){const n=ot(e)?Oe(\"MapSet\").proxyMap_(e,t):Nt(e)?Oe(\"MapSet\").proxySet_(e,t):hs(e,t);return(t?t.scope_:li()).drafts_.push(n),n}function ms(e){return je(e)||pe(10,e),ci(e)}function ci(e){if(!ze(e)||Dt(e))return e;const t=e[oe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=rn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=rn(e,!0);return wt(n,(i,a)=>{oi(n,i,ci(a))},r),t&&(t.finalized_=!1),n}var gs=new ds,_s=gs.produce;const ys=e=>(t,n,r)=>(r.setState=(i,a,...s)=>{const o=typeof i==\"function\"?_s(i):i;return t(o,a,...s)},e(r.setState,n,r)),bs=ys,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\"]),vs=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function ws(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 fr(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 hr(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 ks(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 lt(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 _=hr(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}=ws(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=hr(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}=fr(_),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:_}=fr(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&&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=ks(e,s);s=f.endIdx;let c=vs.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 Ss=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),pr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Cs=new Set([\"if\",\"switch\",\"timed\"]);function ut(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(pr[i.name]){const a=pr[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(Ss.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(Cs.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 dr=new Map;function fi(e){return e.replace(/\\$(\\w+)/g,'variables[\"$1\"]').replace(/\\b_(\\w+)/g,'temporary[\"$1\"]')}const Is=\"const {visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll}=__fns;\";function hi(e,t){let n=dr.get(e);return n||(n=new Function(\"variables\",\"temporary\",\"__fns\",Is+t),dr.set(e,n)),n}function pi(){const e=S.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 ve(e,t,n){const i=`return (${fi(e)});`;return hi(i,i)(t,n,pi())}function Fe(e,t,n){const r=fi(e);hi(\"exec:\"+r,r)(t,n,pi())}const As=\"spindle\",Es=1;let pt=null,qt=null;function Ee(){return qt||(qt={saves:new Map,playthroughs:new Map,meta:new Map}),qt}function Ts(){return pt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(pt=new Promise((e,t)=>{const n=indexedDB.open(As,Es);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)}),pt))}function Te(e,t){return Ts().then(n=>n.transaction(e,t).objectStore(e))}function Pe(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function zt(e){try{const t=await Te(\"saves\",\"readwrite\");await Pe(t.put(e))}catch{Ee().saves.set(e.meta.id,e)}}async function Ot(e){try{const t=await Te(\"saves\",\"readonly\");return await Pe(t.get(e))??void 0}catch{return Ee().saves.get(e)}}async function Ps(e){try{const t=await Te(\"saves\",\"readwrite\");await Pe(t.delete(e))}catch{Ee().saves.delete(e)}}async function $s(e){try{const n=(await Te(\"saves\",\"readonly\")).index(\"ifid\");return await Pe(n.getAll(e))??[]}catch{return[...Ee().saves.values()].filter(t=>t.meta.ifid===e)}}async function di(e){try{const t=await Te(\"playthroughs\",\"readwrite\");await Pe(t.put(e))}catch{Ee().playthroughs.set(e.id,e)}}async function En(e){try{const n=(await Te(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Pe(n.getAll(e))??[]}catch{return[...Ee().playthroughs.values()].filter(t=>t.ifid===e)}}async function Tn(e){try{const t=await Te(\"meta\",\"readonly\"),n=await Pe(t.get(e));return n?n.value:void 0}catch{return Ee().meta.get(e)}}async function mi(e,t){try{const n=await Te(\"meta\",\"readwrite\");await Pe(n.put({key:e,value:t}))}catch{Ee().meta.set(e,t)}}const gi=new Map,Ft=new Map;function Ns(e,t){gi.set(e,t),Ft.set(t,e)}function Ds(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(Ft.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(Ds(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 un=\"__spindle_class__\",cn=\"__spindle_data__\";function Ct(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=Ft.get(a);if(s!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[un]:s,[cn]:u}}const o={};for(const u of Object.keys(i))o[u]=n(i[u]);return t.delete(i),o}return n(e)}function It(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(un in r&&cn in r){const s=r[un],o=r[cn],u=gi.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(Ft.has(i))return n;const a={};for(const s of Object.keys(r))a[s]=t(r[s]);return a}return t(e)}let fn=null,hn=null,mr=!1;function zs(e){fn=e}function Os(e){hn=e}function Fs(e){if(hn)try{const i=new Function(\"passage\",\"variables\",hn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(fn)try{const r=fn(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 Rs(){mr||(mr=!0)}async function gr(e){const n=(await En(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await di(i),await mi(`currentPlaythroughId.${e}`,r),r}async function Ls(e){return Tn(`currentPlaythroughId.${e}`)}async function _i(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Fs(n),passage:n.passage,custom:r},s=W(n);s.variables=Ct(s.variables),s.history=s.history.map(u=>({...u,variables:Ct(u.variables)}));const o={meta:a,payload:s};return await zt(o),o}async function yi(e,t){const n=await Ot(e);if(!n)return;n.meta.updatedAt=new Date().toISOString(),n.meta.passage=t.passage;const r=W(t);return r.variables=Ct(r.variables),r.history=r.history.map(i=>({...i,variables:Ct(i.variables)})),n.payload=r,await zt(n),n}async function Ms(e){const t=await Ot(e);if(!t)return;const n=t.payload;return n.variables=It(n.variables),n.history=n.history.map(r=>({...r,variables:It(r.variables)})),n}async function Bs(e){await Ps(e)}async function Vs(e,t){const n=await Ot(e);n&&(n.meta.title=t,n.meta.updatedAt=new Date().toISOString(),await zt(n))}async function Hs(e){const[t,n]=await Promise.all([$s(e),En(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 bi=\"autosave.\";async function js(e,t,n){const r=`${bi}${e}`,i=await Tn(r);if(i){const s=await yi(i,n);if(s)return s}const a=await _i(e,t,n,{isAutosave:!0});return await mi(r,a.meta.id),a}async function qs(e){const t=`${bi}${e}`,n=await Tn(t);if(n)return Ms(n)}async function Us(e){const t=await Ot(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Ws(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 En(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await di(a)}return await zt(n),n}function Qs(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Fe(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Fe(i,t,n)}}}function xi(){const e=S.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=lt(t.content),r=ut(n),i=W(e.variables),a=W(e.temporary);Qs(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&&Os(s.content)}const S=as()(bs((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;Rs().then(async()=>{const o=await Ls(s);if(o)e(u=>{u.playthroughId=o});else{const u=await gr(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}}),xi(),gr(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}};js(n.ifid,r,f).then(()=>{e(c=>{c.saveVersion++})})},load:()=>{const{storyData:n}=t();n&&qs(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=It(n.variables),r.history=n.history.map(i=>({...i,variables:It(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}})}})));function Gs({target:e,className:t,id:n,children:r}){const i=S(o=>o.navigate),a=o=>{o.preventDefault(),i(e)},s=t?`passage-link ${t}`:\"passage-link\";return g(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function Ks({name:e,scope:t,className:n,id:r}){const i=we(Ae),a=e.split(\".\"),s=a[0],o=S(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 Ys({rawArgs:e}){return ce(()=>{const t=S.getState(),n=W(t.variables),r=W(t.temporary);try{Fe(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 Zs({rawArgs:e,className:t,id:n}){const r=S(u=>u.variables),i=S(u=>u.temporary),a=we(Ae),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=ve(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 Js({branches:e}){const t=S(o=>o.variables),n=S(o=>o.temporary),r=we(Ae),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=ue(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(ve(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 Xs(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 eo({rawArgs:e,children:t,className:n,id:r}){const i=S(w=>w.variables),a=S(w=>w.temporary),s=we(Ae),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=Xs(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=ve(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(Ae.Provider,{value:b,children:ue(t)},I)});return n||r?g(\"span\",{id:r,class:n,children:_}):g(G,{children:_})}function to(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function no({children:e}){const t=to(e);return ce(()=>{const n=S.getState(),r=W(n.variables),i=W(n.temporary);try{Fe(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 ro({rawArgs:e,children:t,className:n,id:r}){const i=()=>{const s=S.getState(),o=W(s.variables),u=W(s.temporary);try{Fe(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])},a=n?`macro-button ${n}`:\"macro-button\";return g(\"button\",{id:r,class:a,onClick:i,children:Li(t)})}function io({className:e,id:t}){const n=S(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return g(\"span\",{id:t,class:r,children:n})}function ao({className:e,id:t}){const n=S(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\";return g(\"button\",{id:t,class:r,onClick:()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()},children:\"↺ Restart\"})}function so({className:e,id:t}){const n=S(a=>a.goBack),r=S(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function oo({className:e,id:t}){const n=S(a=>a.goForward),r=S(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function lo({className:e,id:t}){const n=S(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return g(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function uo({className:e,id:t}){const n=S(o=>o.load),r=S(o=>o.hasSave);S(o=>o.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r();return g(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()},children:\"QuickLoad\"})}const Ge=new Map;let le={};function vi(){return`spindle.${S.getState().storyData?.ifid||\"unknown\"}.settings`}function co(){localStorage.setItem(vi(),JSON.stringify(le))}function Ut(){try{const e=localStorage.getItem(vi());e&&(le={...le,...JSON.parse(e)})}catch{}}const rt={addToggle(e,t){Ge.set(e,{type:\"toggle\",config:t}),e in le||(le[e]=t.default),Ut()},addList(e,t){Ge.set(e,{type:\"list\",config:t}),e in le||(le[e]=t.default),Ut()},addRange(e,t){Ge.set(e,{type:\"range\",config:t}),e in le||(le[e]=t.default),Ut()},get(e){return le[e]},set(e,t){le[e]=t,co()},getAll(){return{...le}},getDefinitions(){return Ge},hasAny(){return Ge.size>0}};function fo({name:e,def:t}){const[n,r]=Z(()=>rt.get(e)),i=a=>{r(a),rt.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 ho({onClose:e}){const t=rt.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(fo,{name:r,def:i},r))})]})})}function po({className:e,id:t}){const[n,r]=Z(!1);if(!rt.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(ho,{onClose:()=>r(!1)})]})}function mo(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 go(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function _o({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=Xe(null),I=Xe(null),b=S(A=>A.storyData),v=S(A=>A.playthroughId),C=S(A=>A.getSavePayload),z=S(A=>A.loadFromPayload),E=b?.ifid??\"\",x=Tt(async()=>{if(!E)return;const A=await Hs(E);i(A),s(!1)},[E]);xe(()=>{x()},[x]),xe(()=>{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 _i(E,v,A),P(\"Save created\"),await x()}catch{P(\"Failed to create save\",\"error\")}},y=async A=>{try{const q=C();await yi(A,q),P(\"Save overwritten\"),await x()}catch{P(\"Failed to overwrite save\",\"error\")}},T=async A=>{try{z(A.payload),P(\"Game loaded\"),setTimeout(e,500)}catch{P(\"Failed to load save\",\"error\")}},$=async A=>{if(confirm(\"Delete this save?\"))try{await Bs(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 Vs(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 Us(A);if(!q)return;const d=new Blob([JSON.stringify(q,null,2)],{type:\"application/json\"}),V=URL.createObjectURL(d),ne=document.createElement(\"a\");ne.href=V,ne.download=`save-${q.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,ne.click(),URL.revokeObjectURL(V),P(\"Save exported\")}catch{P(\"Failed to export save\",\"error\")}},K=()=>{I.current?.click()},ie=async A=>{const q=A.target,d=q.files?.[0];if(d){q.value=\"\";try{const V=await d.text(),ne=JSON.parse(V);await Ws(ne,E),P(\"Save imported\"),await x()}catch(V){P(V instanceof Error?V.message:\"Failed to import save\",\"error\")}}},fe=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:fe,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:ie})]}),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:go(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:ne=>_(ne.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:mo(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:()=>T(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:()=>$(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 yo({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(_o,{onClose:()=>r(!1)})]})}function bo({rawArgs:e,className:t,id:n}){const r=S(c=>c.storyData),i=S(c=>c.variables),a=S(c=>c.temporary);if(!r)return null;let s;try{const c=ve(e,i,a);s=String(c)}catch{s=e.replace(/^[\"']|[\"']$/g,\"\")}const o=r.passages.get(s);if(o&&S.getState().trackRender(s),!o)return g(\"span\",{class:\"error\",children:`{include: passage \"${s}\" not found}`});const u=lt(o.content),l=ut(u),f=ue(l);return t||n?g(\"span\",{id:n,class:t,children:f}):g(G,{children:f})}function xo({rawArgs:e}){return ce(()=>{const t=S.getState();let n;try{const r=ve(e,t.variables,t.temporary);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}t.navigate(n)},[]),null}function vo({rawArgs:e}){return ce(()=>{const t=S.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 wo(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 ko({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=wo(e),a=r.startsWith(\"$\")?r.slice(1):r,s=S(l=>l.variables[a]),o=S(l=>l.setVariable),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 So(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 Co({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=So(e),a=r.startsWith(\"$\")?r.slice(1):r,s=S(l=>l.variables[a]),o=S(l=>l.setVariable),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 Io(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 Ao({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Io(e),a=r.startsWith(\"$\")?r.slice(1):r,s=S(l=>l.variables[a]),o=S(l=>l.setVariable),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 Eo(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 To({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Eo(e),a=r.startsWith(\"$\")?r.slice(1):r,s=S(l=>l.variables[a]),o=S(l=>l.setVariable),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 Po(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 $o({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=Po(e),s=r.startsWith(\"$\")?r.slice(1):r,o=S(f=>f.variables[s]),u=S(f=>f.setVariable),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 wi(e){const t=[];for(const n of e)n.type===\"macro\"&&n.name===\"option\"&&t.push(n.rawArgs.trim());return t}function No({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=S(f=>f.variables[a]),o=S(f=>f.setVariable),u=wi(t),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 Do({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=S(c=>c.variables[a]),o=S(c=>c.setVariable),u=wi(t),l=()=>{if(u.length===0)return;const p=(u.indexOf(String(s))+1)%u.length;o(a,u[p])},f=n?`macro-cycle ${n}`:\"macro-cycle\";return g(\"button\",{id:r,class:f,onClick:l,children:s==null?u[0]||\"\":String(s)})}function zo(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 Oo(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Fo(e){const t=S.getState(),n=W(t.variables),r=W(t.temporary);for(const i of e)if(i.type===\"macro\"){if(i.name===\"set\")try{Fe(i.rawArgs,n,r)}catch(a){console.error(\"spindle: Error in {link} child {set}:\",a)}else if(i.name===\"do\"){const a=Oo(i.children);try{Fe(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 Ro({rawArgs:e,children:t,className:n,id:r}){const{display:i,passage:a}=zo(e),s=u=>{u.preventDefault(),Fo(t),a&&S.getState().navigate(a)},o=n?`macro-link ${n}`:\"macro-link\";return g(\"a\",{id:r,class:o,href:\"#\",onClick:s,children:i})}function Lo({rawArgs:e,branches:t}){const n=S(l=>l.variables),r=S(l=>l.temporary),i=we(Ae),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=ve(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=ve(l.rawArgs,a,s);if(o===f)return g(G,{children:ue(l.children)})}catch(f){return g(\"span\",{class:\"error\",title:String(f),children:`{case error: ${f.message}}`})}}return u?g(G,{children:ue(u.children)}):null}function At(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 Mo({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=[];a.push({delay:At(e),nodes:t});for(const l of n){const f=l.rawArgs?At(l.rawArgs):0;a.push({delay:f,nodes:l.children})}const[s,o]=Z(-1);if(xe(()=>{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=ue(a[s].nodes);return r||i?g(\"span\",{id:i,class:r,children:u}):g(G,{children:u})}const ki=wn({stop:()=>{}});function Bo({rawArgs:e,children:t,className:n,id:r}){const i=At(e),[a,s]=Z(0),[o,u]=Z(!1),l=Tt(()=>u(!0),[]);if(xe(()=>{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(ki.Provider,{value:{stop:l},children:ue(t)});return f||r?g(\"span\",{id:r,class:f,children:c}):c}function Vo(){const{stop:e}=we(ki);return ce(()=>{e()},[e]),null}function Ho({rawArgs:e,children:t,className:n,id:r}){const i=At(e),a=Xe(null),[s,o]=Z(0),[u,l]=Z(0);xe(()=>{if(a.current){const p=a.current.textContent||\"\";o(p.length)}},[]),xe(()=>{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:Li(t)}),!f&&s>0&&g(\"span\",{class:\"macro-type-cursor\"})]})}const Si=new Map;function Ci(e,t){Si.set(e.toLowerCase(),t)}function jo(e){return Si.get(e.toLowerCase())}function qo({rawArgs:e,children:t}){const n=e.trim().replace(/[\"']/g,\"\");return ce(()=>{Ci(n,t)},[]),null}function Uo(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 Wo(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 Qo({rawArgs:e}){S(s=>s.variables),S(s=>s.temporary);const t=we(Ae),{target:n,expr:r}=Uo(e),i=n.startsWith(\"_\"),a=n.slice(1);return ce(()=>{const s=S.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=ve(r,o,u)}catch(c){console.error(`spindle: Error in {computed ${e}}:`,c);return}const f=i?s.temporary[a]:s.variables[a];Wo(f,l)||(i?s.setTemporary(a,l):s.setVariable(a,l))}),null}function Go(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=Ko(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 Ko(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 Yo(e,t,n){return n===\"none\"?null:n===\"%\"?`${Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function Zo({rawArgs:e,className:t,id:n}){const r=S(u=>u.variables),i=S(u=>u.temporary),a=we(Ae),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}=Go(e),c=Number(ve(u,s,o)),p=Number(ve(l,s,o)),h=Math.max(0,Math.min(100,c/p*100)),_=Yo(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 Jo=new Map;function Xo(e){return Jo.get(e.toLowerCase())}const _r=document.createElement(\"i\");function Ii(e){const t=\"&\"+e+\";\";_r.innerHTML=t;const n=_r.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function se(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?(se(e,e.length,0,t),e):t}const pn={}.hasOwnProperty;function el(e){const t={};let n=-1;for(;++n<e.length;)tl(t,e[n]);return t}function tl(e,t){let n;for(n in t){const i=(pn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){pn.call(i,s)||(i[s]=[]);const o=a[s];nl(i[s],Array.isArray(o)?o:o?[o]:[])}}}function nl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);se(e,0,0,r)}function rl(e){const t={};let n=-1;for(;++n<e.length;)il(t,e[n]);return t}function il(e,t){let n;for(n in t){const i=(pn.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 al(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 sl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ai(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+sl[n]+\";\"}}function it(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const _e=$e(/[A-Za-z]/),ae=$e(/[\\dA-Za-z]/),ol=$e(/[#-'*+\\--9=?A-Z^-~]/);function dn(e){return e!==null&&(e<32||e===127)}const mn=$e(/\\d/),ll=$e(/[\\dA-Fa-f]/),ul=$e(/[!-/:-@[-`{-~]/);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 cl=$e(/\\p{P}|\\p{S}/u),fl=$e(/\\s/);function $e(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function dt(e,t){const n=Ai(hl(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 hl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let s=\"\";if(a===37&&ae(e.charCodeAt(n+1))&&ae(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 yr={}.hasOwnProperty,br=/^(https?|ircs?|mailto|xmpp)$/i,pl=/^https?$/i;function dl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],s=[],u=rl([{enter:{blockQuote:R,codeFenced:fe,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:q,codeText:aa,content:Qi,definition:Vi,definitionDestinationString:ji,definitionLabelString:I,definitionTitleString:I,emphasis:ra,htmlFlow:na,htmlText:zn,image:V,label:I,link:ne,listItemMarker:T,listItemValue:y,listOrdered:M,listUnordered:L,paragraph:K,reference:I,resource:Re,resourceDestinationString:Le,resourceTitleString:I,setextHeading:Ki,strong:ia},exit:{atxHeading:Zi,atxHeadingSequence:Gi,autolinkEmail:ha,autolinkProtocol:fa,blockQuote:Y,characterEscapeValue:Qe,characterReferenceMarkerHexadecimal:On,characterReferenceMarkerNumeric:On,characterReferenceValue:ca,codeFenced:d,codeFencedFence:A,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:ta,codeIndented:d,codeText:sa,codeTextData:Qe,data:Qe,definition:Wi,definitionDestinationString:qi,definitionLabelString:Hi,definitionTitleString:Ui,emphasis:oa,hardBreakEscape:Nn,hardBreakTrailing:Nn,htmlFlow:Dn,htmlFlowData:Qe,htmlText:Dn,htmlTextData:Qe,image:$n,label:We,labelText:J,lineEnding:ea,link:$n,listOrdered:$,listUnordered:H,paragraph:ie,reference:P,referenceString:Ce,resource:P,resourceDestinationString:Mt,resourceTitleString:Bi,setextHeading:Xi,setextHeadingLineSequence:Ji,setextHeadingText:Yi,strong:la,thematicBreak:ua}},...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(k){let N=-1,X=0;const he=[];let me=[],ke=[];for(;++N<k.length;)!c&&(k[N][1].type===\"lineEnding\"||k[N][1].type===\"lineEndingBlank\")&&(c=k[N][2].sliceSerialize(k[N][1])),(k[N][1].type===\"listOrdered\"||k[N][1].type===\"listUnordered\")&&(k[N][0]===\"enter\"?he.push(N):h(k.slice(he.pop(),N))),k[N][1].type===\"definition\"&&(k[N][0]===\"enter\"?(ke=ee(ke,k.slice(X,N)),X=N):(me=ee(me,k.slice(X,N+1)),X=N+1));me=ee(me,ke),me=ee(me,k.slice(X)),N=-1;const ge=me;for(u.enter.null&&u.enter.null.call(f);++N<k.length;){const Fn=u[ge[N][0]],Rn=ge[N][1].type,Ln=Fn[Rn];yr.call(Fn,Rn)&&Ln&&Ln.call({sliceSerialize:ge[N][2].sliceSerialize,...f},ge[N][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(k){const N=k.length;let X=0,he=0,me=!1,ke;for(;++X<N;){const ge=k[X];if(ge[1]._container)ke=void 0,ge[0]===\"enter\"?he++:he--;else switch(ge[1].type){case\"listItemPrefix\":{ge[0]===\"exit\"&&(ke=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{ge[0]===\"enter\"&&!he&&(ke?ke=void 0:me=!0);break}default:ke=void 0}}k[0][1]._loose=me}function _(k,N){l[k]=N}function w(k){return l[k]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function v(k){n&&(_(\"lastWasTag\",!0),i[i.length-1].push(k))}function C(k){_(\"lastWasTag\"),i[i.length-1].push(k)}function z(){C(c||`\n`)}function E(){const k=i[i.length-1],N=k[k.length-1],X=N?N.charCodeAt(N.length-1):null;X===10||X===13||X===null||z()}function x(k){return w(\"ignoreEncode\")?k:Ai(k)}function P(){b()}function M(k){s.push(!k._loose),E(),v(\"<ol\"),_(\"expectFirstItem\",!0)}function L(k){s.push(!k._loose),E(),v(\"<ul\"),_(\"expectFirstItem\",!0)}function y(k){if(w(\"expectFirstItem\")){const N=Number.parseInt(this.sliceSerialize(k),10);N!==1&&v(' start=\"'+x(String(N))+'\"')}}function T(){w(\"expectFirstItem\")?v(\">\"):j(),E(),v(\"<li>\"),_(\"expectFirstItem\"),_(\"lastWasTag\")}function $(){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 ie(){s[s.length-1]?_(\"slurpAllLineEndings\",!0):v(\"</p>\")}function fe(){E(),v(\"<pre><code\"),_(\"fencesCount\",0)}function m(){const k=b();v(' class=\"language-'+k+'\"')}function A(){const k=w(\"fencesCount\")||0;k||(v(\">\"),_(\"slurpOneLineEnding\",!0)),_(\"fencesCount\",k+1)}function q(){E(),v(\"<pre><code>\")}function d(){const k=w(\"fencesCount\");k!==void 0&&k<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&z(),w(\"flowCodeSeenData\")&&E(),v(\"</code></pre>\"),k!==void 0&&k<2&&E(),_(\"flowCodeSeenData\"),_(\"fencesCount\"),_(\"slurpOneLineEnding\")}function V(){a.push({image:!0}),n=void 0}function ne(){a.push({})}function J(k){a[a.length-1].labelId=this.sliceSerialize(k)}function We(){a[a.length-1].label=b()}function Ce(k){a[a.length-1].referenceId=this.sliceSerialize(k)}function Re(){I(),a[a.length-1].destination=\"\"}function Le(){I(),_(\"ignoreEncode\",!0)}function Mt(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function Bi(){a[a.length-1].title=b()}function $n(){let k=a.length-1;const N=a[k],X=N.referenceId||N.labelId,he=N.destination===void 0?r[it(X)]:N;for(n=!0;k--;)if(a[k].image){n=void 0;break}N.image?(v('<img src=\"'+dt(he.destination,t.allowDangerousProtocol?void 0:pl)+'\" alt=\"'),C(N.label),v('\"')):v('<a href=\"'+dt(he.destination,t.allowDangerousProtocol?void 0:br)+'\"'),v(he.title?' title=\"'+he.title+'\"':\"\"),N.image?v(\" />\"):(v(\">\"),C(N.label),v(\"</a>\")),a.pop()}function Vi(){I(),a.push({})}function Hi(k){b(),a[a.length-1].labelId=this.sliceSerialize(k)}function ji(){I(),_(\"ignoreEncode\",!0)}function qi(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function Ui(){a[a.length-1].title=b()}function Wi(){const k=a[a.length-1],N=it(k.labelId);b(),yr.call(r,N)||(r[N]=a[a.length-1]),a.pop()}function Qi(){_(\"slurpAllLineEndings\",!0)}function Gi(k){w(\"headingRank\")||(_(\"headingRank\",this.sliceSerialize(k).length),E(),v(\"<h\"+w(\"headingRank\")+\">\"))}function Ki(){I(),_(\"slurpAllLineEndings\")}function Yi(){_(\"slurpAllLineEndings\",!0)}function Zi(){v(\"</h\"+w(\"headingRank\")+\">\"),_(\"headingRank\")}function Ji(k){_(\"headingRank\",this.sliceSerialize(k).charCodeAt(0)===61?1:2)}function Xi(){const k=b();E(),v(\"<h\"+w(\"headingRank\")+\">\"),C(k),v(\"</h\"+w(\"headingRank\")+\">\"),_(\"slurpAllLineEndings\"),_(\"headingRank\")}function Qe(k){C(x(this.sliceSerialize(k)))}function ea(k){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){_(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){C(\" \");return}C(x(this.sliceSerialize(k)))}}function ta(k){C(x(this.sliceSerialize(k))),_(\"flowCodeSeenData\",!0)}function Nn(){v(\"<br />\")}function na(){E(),zn()}function Dn(){_(\"ignoreEncode\")}function zn(){t.allowDangerousHtml&&_(\"ignoreEncode\",!0)}function ra(){v(\"<em>\")}function ia(){v(\"<strong>\")}function aa(){_(\"inCodeText\",!0),v(\"<code>\")}function sa(){_(\"inCodeText\"),v(\"</code>\")}function oa(){v(\"</em>\")}function la(){v(\"</strong>\")}function ua(){E(),v(\"<hr />\")}function On(k){_(\"characterReferenceType\",k.type)}function ca(k){const N=this.sliceSerialize(k),X=w(\"characterReferenceType\")?al(N,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ii(N);C(x(X)),_(\"characterReferenceType\")}function fa(k){const N=this.sliceSerialize(k);v('<a href=\"'+dt(N,t.allowDangerousProtocol?void 0:br)+'\">'),C(x(N)),v(\"</a>\")}function ha(k){const N=this.sliceSerialize(k);v('<a href=\"'+dt(\"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 ml={tokenize:gl};function gl(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 _l={tokenize:yl},xr={tokenize:bl};function yl(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 se(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(xr,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(xr,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++;se(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 bl(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 Et(e){if(e===null||te(e)||fl(e))return 1;if(cl(e))return 2}function Rt(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 gn={name:\"attention\",resolveAll:xl,tokenize:vl};function xl(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};vr(c,-u),vr(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,Rt(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,se(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 vl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Et(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=Et(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 vr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const wl={name:\"autolink\",tokenize:kl};function kl(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 _e(h)?(e.consume(h),s):h===64?n(h):l(h)}function s(h){return h===43||h===45||h===46||ae(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||ae(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||dn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):ol(h)?(e.consume(h),l):n(h)}function f(h){return ae(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||ae(h))&&r++<63){const _=h===45?p:c;return e.consume(h),_}return n(h)}}const Lt={partial:!0,tokenize:Sl};function Sl(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 Ei={continuation:{tokenize:Il},exit:Al,name:\"blockQuote\",tokenize:Cl};function Cl(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 Il(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(Ei,t,n)(s)}}function Al(e){e.exit(\"blockQuote\")}const Ti={name:\"characterEscape\",tokenize:El};function El(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 ul(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Pi={name:\"characterReference\",tokenize:Tl};function Tl(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=ae,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=ll,f):(e.enter(\"characterReferenceValue\"),a=7,s=mn,f(c))}function f(c){if(c===59&&i){const p=e.exit(\"characterReferenceValue\");return s===ae&&!Ii(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 wr={partial:!0,tokenize:$l},kr={concrete:!0,name:\"codeFenced\",tokenize:Pl};function Pl(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(wr,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(wr,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\"),T}function T(R){return x.enter(\"codeFencedFence\"),F(R)?B(x,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):$(R)}function $(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 $l(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 Wt={name:\"codeIndented\",tokenize:Dl},Nl={partial:!0,tokenize:zl};function Dl(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(Nl,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 zl(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 Ol={name:\"codeText\",previous:Rl,resolve:Fl,tokenize:Ll};function Fl(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 Rl(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Ll(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 Ml{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&&Ke(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),Ke(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ke(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);Ke(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ke(this.left,n.reverse())}}}function Ke(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 $i(e){const t={};let n=-1,r,i,a,s,o,u,l;const f=new Ml(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,Bl(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 se(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function Bl(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 Vl={resolve:jl,tokenize:ql},Hl={partial:!0,tokenize:Ul};function jl(e){return $i(e),e}function ql(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(Hl,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 Ul(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 Ni(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||dn(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||dn(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 Di(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 zi(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 Je(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 Wl={name:\"definition\",tokenize:Gl},Ql={partial:!0,tokenize:Kl};function Gl(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),s(h)}function s(h){return Di.call(r,e,o,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function o(h){return i=it(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)?Je(e,l)(h):l(h)}function l(h){return Ni(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(Ql,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 Kl(e,t,n){return r;function r(o){return te(o)?Je(e,i)(o):n(o)}function i(o){return zi(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 Yl={name:\"hardBreakEscape\",tokenize:Zl};function Zl(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 Jl={name:\"headingAtx\",resolve:Xl,tokenize:eu};function Xl(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\"},se(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function eu(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 tu=[\"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\"],Sr=[\"pre\",\"script\",\"style\",\"textarea\"],nu={concrete:!0,name:\"htmlFlow\",resolveTo:au,tokenize:su},ru={partial:!0,tokenize:lu},iu={partial:!0,tokenize:ou};function au(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 su(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):_e(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,_):_e(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:$:_):n(d)}function w(d){return _e(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,ne=s.toLowerCase();return!V&&!a&&Sr.includes(ne)?(i=1,r.interrupt?t(d):$(d)):tu.includes(s.toLowerCase())?(i=6,V?(e.consume(d),b):r.interrupt?t(d):$(d)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(d):a?v(d):C(d))}return d===45||ae(d)?(e.consume(d),s+=String.fromCharCode(d),I):n(d)}function b(d){return d===62?(e.consume(d),r.interrupt?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||_e(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||ae(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),T):n(d)}function T(d){return d===null||D(d)?$(d):F(d)?(e.consume(d),T):n(d)}function $(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),fe):D(d)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(ru,q,H)(d)):d===null||D(d)?(e.exit(\"htmlFlowData\"),H(d)):(e.consume(d),$)}function H(d){return e.check(iu,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\"),$(d))}function Y(d){return d===45?(e.consume(d),m):$(d)}function K(d){return d===47?(e.consume(d),s=\"\",ie):$(d)}function ie(d){if(d===62){const V=s.toLowerCase();return Sr.includes(V)?(e.consume(d),A):$(d)}return _e(d)&&s.length<8?(e.consume(d),s+=String.fromCharCode(d),ie):$(d)}function fe(d){return d===93?(e.consume(d),m):$(d)}function m(d){return d===62?(e.consume(d),A):d===45&&i===2?(e.consume(d),m):$(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 ou(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 lu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Lt,t,n)}}const uu={name:\"htmlText\",tokenize:cu};function cu(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):_e(m)?(e.consume(m),M):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,_):_e(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 _e(m)?(e.consume(m),x):n(m)}function x(m){return m===45||ae(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||ae(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||_e(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||ae(m)?(e.consume(m),y):T(m)}function T(m){return m===61?(e.consume(m),$):D(m)?(s=T,K(m)):F(m)?(e.consume(m),T):L(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,H):D(m)?(s=$,K(m)):F(m)?(e.consume(m),$):(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\"),ie}function ie(m){return F(m)?B(e,fe,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):fe(m)}function fe(m){return e.enter(\"htmlTextData\"),s(m)}}const Pn={name:\"labelEnd\",resolveAll:du,resolveTo:mu,tokenize:gu},fu={tokenize:_u},hu={tokenize:yu},pu={tokenize:bu};function du(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&&se(e,0,e.length,n),e}function mu(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,Rt(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]]),se(e,a,e.length,o),e}function gu(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(it(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(fu,f,s?f:c)(p):p===91?e.attempt(hu,f,s?l:c)(p):s?f(p):c(p)}function l(p){return e.attempt(pu,f,c)(p)}function f(p){return t(p)}function c(p){return a._balanced=!0,n(p)}}function _u(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)?Je(e,a)(c):a(c)}function a(c){return c===41?f(c):Ni(e,s,o,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function s(c){return te(c)?Je(e,u)(c):f(c)}function o(c){return n(c)}function u(c){return c===34||c===39||c===40?zi(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return te(c)?Je(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 yu(e,t,n){const r=this;return i;function i(o){return Di.call(r,e,a,s,\"reference\",\"referenceMarker\",\"referenceString\")(o)}function a(o){return r.parser.defined.includes(it(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function bu(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 xu={name:\"labelStartImage\",resolveAll:Pn.resolveAll,tokenize:vu};function vu(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 wu={name:\"labelStartLink\",resolveAll:Pn.resolveAll,tokenize:ku};function ku(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 Qt={name:\"lineEnding\",tokenize:Su};function Su(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const yt={name:\"thematicBreak\",tokenize:Cu};function Cu(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 re={continuation:{tokenize:Tu},exit:$u,name:\"list\",tokenize:Eu},Iu={partial:!0,tokenize:Nu},Au={partial:!0,tokenize:Pu};function Eu(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:mn(h)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(yt,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 mn(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(Lt,r.interrupt?n:f,e.attempt(Iu,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 Tu(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Lt,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(Au,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(re,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o)}}function Pu(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 $u(e){e.exit(this.containerState.type)}function Nu(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 Cr={name:\"setextUnderline\",resolveTo:Du,tokenize:zu};function Du(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 zu(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 Ou={tokenize:Fu};function Fu(e){const t=this,n=e.attempt(Lt,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Vl,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 Ru={resolveAll:Fi()},Lu=Oi(\"string\"),Mu=Oi(\"text\");function Oi(e){return{resolveAll:Fi(e===\"text\"?Bu: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 Fi(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 Bu(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 Vu={42:re,43:re,45:re,48:re,49:re,50:re,51:re,52:re,53:re,54:re,55:re,56:re,57:re,62:Ei},Hu={91:Wl},ju={[-2]:Wt,[-1]:Wt,32:Wt},qu={35:Jl,42:yt,45:[Cr,yt],60:nu,61:Cr,95:yt,96:kr,126:kr},Uu={38:Pi,92:Ti},Wu={[-5]:Qt,[-4]:Qt,[-3]:Qt,33:xu,38:Pi,42:gn,60:[wl,uu],91:wu,92:[Yl,Ti],93:Pn,95:gn,96:Ol},Qu={null:[gn,Ru]},Gu={null:[42,95]},Ku={null:[]},Yu=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Gu,contentInitial:Hu,disable:Ku,document:Vu,flow:qu,flowInitial:ju,insideSpan:Qu,string:Uu,text:Wu},Symbol.toStringTag,{value:\"Module\"}));function Zu(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(T){return s=ee(s,T),I(),s[s.length-1]!==null?[]:(M(t,0),l.events=Rt(a,l.events,l),l.events)}function p(T,$){return Xu(h(T),$)}function h(T){return Ju(s,T)}function _(){const{_bufferIndex:T,_index:$,line:H,column:j,offset:R}=r;return{_bufferIndex:T,_index:$,line:H,column:j,offset:R}}function w(T){i[T.line]=T.column,y()}function I(){let T;for(;r._index<s.length;){const $=s[r._index];if(typeof $==\"string\")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(T){f=f(T)}function v(T){D(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,y()):T!==-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=T}function C(T,$){const H=$||{};return H.type=T,H.start=_(),l.events.push([\"enter\",H,l]),o.push(H),H}function z(T){const $=o.pop();return $.end=_(),l.events.push([\"exit\",$,l]),$}function E(T,$){M(T,$.from)}function x(T,$){$.restore()}function P(T,$){return H;function H(j,R,Y){let K,ie,fe,m;return Array.isArray(j)?q(j):\"tokenize\"in j?q([j]):A(j);function A(J){return We;function We(Ce){const Re=Ce!==null&&J[Ce],Le=Ce!==null&&J.null,Mt=[...Array.isArray(Re)?Re:Re?[Re]:[],...Array.isArray(Le)?Le:Le?[Le]:[]];return q(Mt)(Ce)}}function q(J){return K=J,ie=0,J.length===0?Y:d(J[ie])}function d(J){return We;function We(Ce){return m=L(),fe=J,J.partial||(l.currentConstruct=J),J.name&&l.parser.constructs.disable.null.includes(J.name)?ne():J.tokenize.call($?Object.assign(Object.create(l),$):l,u,V,ne)(Ce)}}function V(J){return T(fe,m),R}function ne(J){return m.restore(),++ie<K.length?d(K[ie]):Y}}}function M(T,$){T.resolveAll&&!a.includes(T)&&a.push(T),T.resolve&&se(l.events,$,l.events.length-$,T.resolve(l.events.slice($),l)),T.resolveTo&&(l.events=T.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=T,l.previous=$,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 Ju(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 Xu(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 ec(e){const r={constructs:el([Yu,...(e||{}).extensions||[]]),content:i(ml),defined:[],document:i(_l),flow:i(Ou),lazy:{},string:i(Lu),text:i(Mu)};return r;function i(a){return s;function s(o){return Zu(r,a,o)}}}function tc(e){for(;!$i(e););return e}const Ir=/[\\0\\t\\n\\r]/g;function nc(){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(Ir.lastIndex=c,l=Ir.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 rc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),dl(n)(tc(ec(n).document().write(nc()(e,t,!0))))}const Gt={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function ic(){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=Gt[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=Gt[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,ac)),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\"+Gt[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function ac(e,t){return t===\"|\"?t:e}class sc{constructor(){this.map=[]}add(t,n,r){oc(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 oc(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 lc(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 uc(){return{flow:{null:{name:\"table\",tokenize:cc,resolveAll:fc}}}}function cc(e,t,n){const r=this;let i=0,a=0,s;return o;function o(y){let T=r.events.length-1;for(;T>-1;){const j=r.events[T][1].type;if(j===\"lineEnding\"||j===\"linePrefix\")T--;else break}const $=T>-1?r.events[T][1].type:null,H=$===\"tableHead\"||$===\"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 fc(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 sc;for(;++n<e.length;){const h=e[n],_=h[1];h[0]===\"enter\"?_.type===\"tableHead\"?(o=!1,u!==0&&(Ar(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=mt(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=mt(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=mt(p,t,a,i,n,c)):s[1]!==0&&(c=mt(p,t,s,i,n,c)),i=0):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")&&(s[3]=n)}for(u!==0&&Ar(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=lc(t.events,n))}return e}function mt(e,t,n,r,i,a){const s=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",o=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Me(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Me(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=Me(t.events,n[2]),f=Me(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({},Me(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ar(e,t,n,r,i){const a=[],s=Me(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 Me(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function hc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function pc(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&&se(p,p.length,0,Rt(h,s.slice(l+1,u),o)),se(p,p.length,0,[[\"exit\",c,o],[\"enter\",s[u][1],o],[\"exit\",s[u][1],o],[\"exit\",f,o]]),se(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=Et(l);if(_===126)return c>1?u(_):(s.consume(_),c++,h);if(c<2&&!n)return u(_);const I=s.exit(\"strikethroughSequenceTemporary\"),b=Et(_);return I._open=!b||b===2&&!!w,I._close=!w||w===2&&!!b,o(_)}}}function dc(e){return rc(e,{allowDangerousHtml:!0,extensions:[uc(),pc()],htmlExtensions:[ic(),hc()]})}const Ae=wn({});function mc(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Ri(i,a,t));return g(G,{children:r})}function Ri(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)=>Ri(u,l,n));return de(i,s,...o)}return null}function gc(e,t){switch(e.name){case\"set\":return g(Ys,{rawArgs:e.rawArgs},t);case\"computed\":return g(Qo,{rawArgs:e.rawArgs},t);case\"print\":return g(Zs,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return g(Zo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"if\":return g(Js,{branches:e.branches},t);case\"for\":return g(eo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return g(no,{children:e.children},t);case\"button\":return g(ro,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return g(io,{className:e.className,id:e.id},t);case\"back\":return g(so,{className:e.className,id:e.id},t);case\"forward\":return g(oo,{className:e.className,id:e.id},t);case\"restart\":return g(ao,{className:e.className,id:e.id},t);case\"quicksave\":return g(lo,{className:e.className,id:e.id},t);case\"quickload\":return g(uo,{className:e.className,id:e.id},t);case\"settings\":return g(po,{className:e.className,id:e.id},t);case\"saves\":return g(yo,{className:e.className,id:e.id},t);case\"include\":return g(bo,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return g(xo,{rawArgs:e.rawArgs},t);case\"unset\":return g(vo,{rawArgs:e.rawArgs},t);case\"textbox\":return g(ko,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return g(Co,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return g(Ao,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return g(To,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return g($o,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return g(No,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return g(Do,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return g(Ro,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return g(Lo,{rawArgs:e.rawArgs,branches:e.branches},t);case\"timed\":return g(Mo,{rawArgs:e.rawArgs,children:e.children,branches:e.branches,className:e.className,id:e.id},t);case\"repeat\":return g(Bo,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return g(Vo,{},t);case\"type\":return g(Ho,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return g(qo,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=jo(e.name);if(n)return g(G,{children:ue(n)});const r=Xo(e.name);return r?g(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:ue(e.children)},t):g(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function _n(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return g(Gs,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return g(Ks,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return gc(e,t);case\"html\":return de(e.tag,{key:t,...e.attributes},e.children.length>0?ue(e.children):void 0)}}function Li(e){return e.length===0?null:e.map((t,n)=>_n(t,n))}function ue(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,s)=>_n(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(_n(s,a)),r+=`<span data-tw=\"${o}\"></span>`}}const i=dc(r);return mc(i,n)}function _c({passage:e}){const t=Ue(()=>{try{const n=lt(e.content),r=ut(n);return ue(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 yc=\"{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}\";function bc(){const t=S(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:yc,r=Ue(()=>{try{const i=lt(n),a=ut(i);return ue(a)}catch(i){return g(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",i.message]})}},[n]);return g(G,{children:r})}function xc(){const e=S(r=>r.currentPassage),t=S(r=>r.storyData);if(xe(()=>{const r=i=>{i.key===\"F6\"?(i.preventDefault(),S.getState().save()):i.key===\"F9\"&&(i.preventDefault(),S.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(bc,{})}),g(\"div\",{id:\"story\",class:\"story\",children:g(_c,{passage:n},e)})]}):g(\"div\",{class:\"error\",children:[\"Error: Passage “\",e,\"” not found.\"]})}function vc(){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 wc(){return{get(e){return S.getState().variables[e]},set(e,t){const n=S.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){S.getState().navigate(e)},back(){S.getState().goBack()},forward(){S.getState().goForward()},restart(){S.getState().restart()},save(e){S.getState().save(e)},load(e){S.getState().load(e)},hasSave(e){return S.getState().hasSave(e)},visited(e){return S.getState().visitCounts[e]??0},hasVisited(e){return(S.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return S.getState().renderCounts[e]??0},hasRendered(e){return(S.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},get title(){return S.getState().storyData?.name||\"\"},settings:rt,registerClass(e,t){Ns(e,t)},saves:{setTitleGenerator(e){zs(e)}}}}function kc(){window.Story=wc()}const Sc=/^\\$(\\w+)\\s*=\\s*(.+)$/,Er=/\\$(\\w+(?:\\.\\w+)*)/g,Tr=/\\{for\\s+(\\$\\w+)(?:\\s*,\\s*(\\$\\w+))?\\s+of\\b/g;function Mi(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,Mi(r));return{type:\"object\",fields:t}}return{type:typeof e}}function Cc(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Sc);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=Mi(o);t.set(a,{...u,name:a,default:o})}return t}function Ic(e){const t=new Set;let n;for(Tr.lastIndex=0;(n=Tr.exec(e))!==null;)t.add(n[1].slice(1)),n[2]&&t.add(n[2].slice(1));return t}function Ac(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`Undeclared field: $${r.slice(0,o+1).join(\".\")}`;s=u}return null}function Ec(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Ic(i.content);let s;for(Er.lastIndex=0;(s=Er.exec(i.content))!==null;){const o=s[1],u=Ac(o,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Tc(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function Pr(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 $r(){const e=vc();if(kc(),e.userCSS){const s=document.createElement(\"style\");s.textContent=e.userCSS,document.head.appendChild(s)}if(e.userScript)try{new Function(e.userScript)()}catch(s){console.error(\"spindle: Error in story JavaScript:\",s)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const s=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",o=document.getElementById(\"root\");throw o&&Pr(o,[s]),new Error(`spindle: ${s}`)}const r=Cc(n.content),i=Ec(e.passages,r);if(i.length>0){const s=document.getElementById(\"root\");throw s&&Pr(s,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=Tc(r),S.getState().init(e,t),xi();for(const[,s]of e.passages)if(s.tags.includes(\"widget\")){const o=lt(s.content),u=ut(o);for(const l of u)if(l.type===\"macro\"&&l.name===\"widget\"&&l.rawArgs){const f=l.rawArgs.trim().replace(/[\"']/g,\"\");Ci(f,l.children)}}const a=document.getElementById(\"root\");if(!a)throw new Error('spindle: No <div id=\"root\"> element found.');Ve(g(xc,{}),a)}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",$r):$r();</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 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"})